From 569a81ae390026e52944e4394e8102f00c43ecb5 Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Sun, 29 Oct 2017 10:43:25 +0000 Subject: [PATCH] Bounding box visualization fix for opening image sequences in the GUI. --- lib/local/CppInerop/CameraInterop.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/local/CppInerop/CameraInterop.h b/lib/local/CppInerop/CameraInterop.h index 9dee04e..be25bba 100644 --- a/lib/local/CppInerop/CameraInterop.h +++ b/lib/local/CppInerop/CameraInterop.h @@ -160,6 +160,18 @@ namespace CameraInterop { this->image_files->push_back(msclr::interop::marshal_as(image_files[i])); } vid_length = image_files->Count; + + // Read the first frame to determine the capture width and height + cv::Mat tmp = cv::imread(this->image_files->at(0)); + + if (tmp.empty()) + { + throw gcnew CaptureFailedException("Failed to open image sequence"); + } + + this->width = tmp.size().width; + this->height = tmp.size().height; + } static void split(const std::string &s, char delim, std::vector &elems) {