diff --git a/lib/local/Utilities/src/SequenceCapture.cpp b/lib/local/Utilities/src/SequenceCapture.cpp index 3b606c3e..3d8da139 100644 --- a/lib/local/Utilities/src/SequenceCapture.cpp +++ b/lib/local/Utilities/src/SequenceCapture.cpp @@ -269,7 +269,7 @@ bool SequenceCapture::OpenWebcam(int device, int image_width, int image_height, start_time = cv::getTickCount(); capturing = true; - capture_threads.run([&] {CaptureThread(); }); + //capture_threads.run([&] {CaptureThread(); }); return true; @@ -447,7 +447,7 @@ void SequenceCapture::CaptureThread() cv::Mat tmp_frame; cv::Mat_ tmp_gray_frame; - if (is_webcam || !is_image_seq) + if (!is_image_seq) { bool success = capture.read(tmp_frame); @@ -459,15 +459,7 @@ void SequenceCapture::CaptureThread() } // Recording the timestamp - if (!is_webcam) - { - timestamp_curr = frame_num_int * (1.0 / fps); - } - else - { - timestamp_curr = (cv::getTickCount() - start_time) / cv::getTickFrequency(); - } - + timestamp_curr = frame_num_int * (1.0 / fps); } else if (is_image_seq) { @@ -494,12 +486,30 @@ void SequenceCapture::CaptureThread() cv::Mat SequenceCapture::GetNextFrame() { - std::tuple > data; - capture_queue.pop(data); - time_stamp = std::get<0>(data); - latest_frame = std::get<1>(data); - latest_gray_frame = std::get<2>(data); + if(!is_webcam) + { + std::tuple > data; + capture_queue.pop(data); + time_stamp = std::get<0>(data); + latest_frame = std::get<1>(data); + latest_gray_frame = std::get<2>(data); + } + else + { + // Webcam does not use the threaded interface + bool success = capture.read(latest_frame); + time_stamp = (cv::getTickCount() - start_time) / cv::getTickFrequency(); + + if (!success) + { + // Indicate lack of success by returning an empty image + latest_frame = cv::Mat(); + } + + ConvertToGrayscale_8bit(latest_frame, latest_gray_frame); + + } frame_num++; return latest_frame; diff --git a/samples/licenses.txt b/samples/licenses.txt index 19f82ae2..07c2cc85 100644 --- a/samples/licenses.txt +++ b/samples/licenses.txt @@ -4,4 +4,5 @@ https://www.flickr.com/photos/svintus2010/4548488065/in/photolist-7VWc32-dGPKW-k https://www.flickr.com/photos/58842866@N08/5388143519/in/photolist-9d8Dmc-gw5bm6-7Warab-6Jn5zL-cVyqn-9d8AZx-ykVZn-745C1V-fsnZ-9d8C9r-745C4P-czkJEw-cVyqM-dFpoGg-cVyGg-5cxqSd-haQUE-QGCbMa-5NN7zB-dGPKw-cVyBo-745C8R-cVysh-cVyB7-cVyoR-cVys6-9d8GnB-cVyDA-haQHJ-cVypm-abUokh-6JhVvz-6ZdA8C-ucatk-cVyot-9d8B8c-9d8DUP-cVyH6-mueBcx-6Jnb2j-dGPJh-9dbL4C-61TYrz-haRdB-eRwkeK-wUU8Z-h9puXH-9PYeL-5hFAFb-2HrU6a https://www.flickr.com/photos/phild41/8374763064/in/photolist-dL3RhC-66N7as-7dotLe-7cWKR5-614Znb-qtmFFa-9d8ApH-3rDKJ1-7dAJqB-9dbHLo-7cSSSv-7bYXwd-7cChJ3-76qadC-nJV7d4-8icrgY-TZXhp3-r6CqQo-7ZxYAM-c8d8ow-NzZybL-4Yc23a-9yKTpR-rLggYN-JP6Vt-9GE7Yr-4Yc3iK-q2BAZF-9dbLs9-aM48vi-7R8pUS-aEKRnZ-spZQv3-7d7tBM-nGtg3X-mueqda-6JnkB7-muehBN-aEPGau-jrTTpy-pBcvLR-62my1e-du9wzk-mudYkt-Kuizzp-c8d8eC-wEbB9G-give5v-x3tNus-7dAKev https://www.flickr.com/photos/leinadsimpson/18571168/ -https://www.flickr.com/photos/58842866@N08/5388135593/in/photolist-9d8AZx-ykVZn-745C1V-fsnZ-9d8C9r-745C4P-czkJEw-cVyqM-dFpoGg-cVyGg-5cxqSd-haQUE-QGCbMa-5NN7zB-dGPKw-cVyBo-745C8R-cVysh-cVyB7-cVyoR-cVys6-9d8GnB-cVyDA-haQHJ-cVypm-abUokh-6JhVvz-6ZdA8C-ucatk-cVyot-9d8B8c-9d8DUP-cVyH6-mueBcx-6Jnb2j-dGPJh-9dbL4C-61TYrz-haRdB-eRwkeK-wUU8Z-h9puXH-9PYeL-5hFAFb-2HrU6a-2HJCk-9dbGmh-s1RVE-9d8D9r-72eKHx \ No newline at end of file +https://www.flickr.com/photos/58842866@N08/5388135593/in/photolist-9d8AZx-ykVZn-745C1V-fsnZ-9d8C9r-745C4P-czkJEw-cVyqM-dFpoGg-cVyGg-5cxqSd-haQUE-QGCbMa-5NN7zB-dGPKw-cVyBo-745C8R-cVysh-cVyB7-cVyoR-cVys6-9d8GnB-cVyDA-haQHJ-cVypm-abUokh-6JhVvz-6ZdA8C-ucatk-cVyot-9d8B8c-9d8DUP-cVyH6-mueBcx-6Jnb2j-dGPJh-9dbL4C-61TYrz-haRdB-eRwkeK-wUU8Z-h9puXH-9PYeL-5hFAFb-2HrU6a-2HJCk-9dbGmh-s1RVE-9d8D9r-72eKHx +https://www.flickr.com/photos/montclairfilmfest/26915909057/ \ No newline at end of file diff --git a/samples/sample2.jpg b/samples/sample2.jpg index 75a50fc9..5efc6b12 100644 Binary files a/samples/sample2.jpg and b/samples/sample2.jpg differ