mirror of
https://github.com/lostjared/Acid.Cam.v2.Qt.git
synced 2025-12-18 21:00:13 +01:00
added test to for when initialization fails
This commit is contained in:
@@ -386,7 +386,8 @@ bool AC_MainWindow::startCamera(int res, int dev, const QString &outdir, bool re
|
|||||||
file_new_capture->setEnabled(false);
|
file_new_capture->setEnabled(false);
|
||||||
file_new_video->setEnabled(false);
|
file_new_video->setEnabled(false);
|
||||||
controls_stop->setEnabled(true);
|
controls_stop->setEnabled(true);
|
||||||
playback->setVideoCamera(dev, res, writer, recording);
|
bool rt_val = playback->setVideoCamera(dev, res, writer, recording);
|
||||||
|
if(rt_val == false) return false;
|
||||||
playback->Play();
|
playback->Play();
|
||||||
disp->show();
|
disp->show();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -29,13 +29,17 @@ void Playback::setVideo(cv::VideoCapture cap, cv::VideoWriter wr, bool record) {
|
|||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playback::setVideoCamera(int device, int res, cv::VideoWriter wr, bool record) {
|
bool Playback::setVideoCamera(int device, int res, cv::VideoWriter wr, bool record) {
|
||||||
mode = MODE_CAMERA;
|
mode = MODE_CAMERA;
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
if(capture.isOpened()) {
|
if(capture.isOpened()) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
capture.open(device);
|
capture.open(device);
|
||||||
|
if(!capture.isOpened()) {
|
||||||
|
mutex.unlock();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
recording = record;
|
recording = record;
|
||||||
writer = wr;
|
writer = wr;
|
||||||
@@ -63,6 +67,7 @@ void Playback::setVideoCamera(int device, int res, cv::VideoWriter wr, bool reco
|
|||||||
capture.set(CV_CAP_PROP_FRAME_HEIGHT, res_h);
|
capture.set(CV_CAP_PROP_FRAME_HEIGHT, res_h);
|
||||||
}
|
}
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playback::setVector(std::vector<std::pair<int, int>> v) {
|
void Playback::setVector(std::vector<std::pair<int, int>> v) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public:
|
|||||||
void Stop();
|
void Stop();
|
||||||
void Release();
|
void Release();
|
||||||
void setVideo(cv::VideoCapture cap, cv::VideoWriter writer, bool record);
|
void setVideo(cv::VideoCapture cap, cv::VideoWriter writer, bool record);
|
||||||
void setVideoCamera(int device, int res, cv::VideoWriter writer, bool record);
|
bool setVideoCamera(int device, int res, cv::VideoWriter writer, bool record);
|
||||||
bool isStopped() const;
|
bool isStopped() const;
|
||||||
void run();
|
void run();
|
||||||
void msleep(int ms);
|
void msleep(int ms);
|
||||||
|
|||||||
Reference in New Issue
Block a user