Shift VideoCapture stuff to Input class instead of readWebcam method; Add freeWebcam method
This commit is contained in:
parent
d1341a7c8a
commit
63745d0446
@ -1,11 +1,17 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
Input::Input(/* args */)
|
Input::Input(/* args */) : cap(0)
|
||||||
{
|
{
|
||||||
|
const int VID_HEIGHT = 240;
|
||||||
|
const int VID_WIDTH = 320;
|
||||||
|
|
||||||
|
this->cap.set(CAP_PROP_FRAME_HEIGHT, VID_HEIGHT);
|
||||||
|
this->cap.set(CAP_PROP_FRAME_WIDTH, VID_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
Input::~Input()
|
Input::~Input()
|
||||||
{
|
{
|
||||||
|
this->freeWebcam();
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat Input::readFile(String filePath)
|
Mat Input::readFile(String filePath)
|
||||||
@ -33,13 +39,7 @@ Mat Input::readFile(String filePath)
|
|||||||
|
|
||||||
Mat Input::readWebcam()
|
Mat Input::readWebcam()
|
||||||
{
|
{
|
||||||
const int VID_HEIGHT = 240;
|
|
||||||
const int VID_WIDTH = 320;
|
|
||||||
Mat image;
|
Mat image;
|
||||||
VideoCapture cap(0);
|
|
||||||
|
|
||||||
cap.set(CAP_PROP_FRAME_HEIGHT, VID_HEIGHT);
|
|
||||||
cap.set(CAP_PROP_FRAME_WIDTH, VID_WIDTH);
|
|
||||||
|
|
||||||
if(!cap.isOpened()) {
|
if(!cap.isOpened()) {
|
||||||
cout << "Fehler";
|
cout << "Fehler";
|
||||||
@ -49,4 +49,9 @@ Mat Input::readWebcam()
|
|||||||
cap.read(image);
|
cap.read(image);
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::freeWebcam()
|
||||||
|
{
|
||||||
|
this->cap.release();
|
||||||
}
|
}
|
@ -2,7 +2,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <opencv2/opencv.hpp>
|
#include <opencv2/opencv.hpp>
|
||||||
|
#include <opencv2/core/utils/logger.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
@ -10,10 +12,12 @@ using namespace cv;
|
|||||||
class Input
|
class Input
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
VideoCapture cap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Input(/* args */);
|
Input(/* args */);
|
||||||
~Input();
|
~Input();
|
||||||
Mat readFile(String filePath);
|
Mat readFile(String filePath);
|
||||||
Mat readWebcam();
|
Mat readWebcam();
|
||||||
|
void freeWebcam();
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user