summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-11-23 15:12:20 +0100
committerStanislaw Halik <sthalik@misaki.pl>2014-11-23 15:12:20 +0100
commitaa0549fd18134f5d8fc4046ab32b46352ad379a3 (patch)
tree1a7847b8f2626bcad9867918c7b1358b9f999dd0 /ftnoir_tracker_pt
parent0c6c39986c14761c08ce24677c3196a09a4b05ca (diff)
pt: avoid crash on startup/close with opencv/highgui/libv4l
Diffstat (limited to 'ftnoir_tracker_pt')
-rw-r--r--ftnoir_tracker_pt/camera.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/ftnoir_tracker_pt/camera.cpp b/ftnoir_tracker_pt/camera.cpp
index b0cb32c9..432e0158 100644
--- a/ftnoir_tracker_pt/camera.cpp
+++ b/ftnoir_tracker_pt/camera.cpp
@@ -144,16 +144,18 @@ bool Camera::get_frame(float dt, cv::Mat* frame)
void CVCamera::start()
{
+ if (cap)
+ delete cap;
cap = new VideoCapture(desired_index);
- // extract camera info
+ _set_res();
+ _set_fps();
+ // extract camera info
if (cap->isOpened())
- {
- _set_fps();
- _set_res();
- active = true;
- active_index = desired_index;
- cam_info.res_x = cap->get(CV_CAP_PROP_FRAME_WIDTH);
- cam_info.res_y = cap->get(CV_CAP_PROP_FRAME_HEIGHT);
+ {
+ active = true;
+ active_index = desired_index;
+ cam_info.res_x = 0;
+ cam_info.res_y = 0;
} else {
delete cap;
cap = nullptr;
@@ -166,8 +168,9 @@ void CVCamera::stop()
{
cap->release();
delete cap;
+ cap = nullptr;
}
- active = false;
+ active = false;
}
bool CVCamera::_get_frame(Mat* frame)