diff options
Diffstat (limited to 'tracker-pt/module')
-rw-r--r-- | tracker-pt/module/CMakeLists.txt | 6 | ||||
-rw-r--r-- | tracker-pt/module/frame.hpp | 2 | ||||
-rw-r--r-- | tracker-pt/module/point_extractor.cpp | 25 | ||||
-rw-r--r-- | tracker-pt/module/point_extractor.h | 2 |
4 files changed, 19 insertions, 16 deletions
diff --git a/tracker-pt/module/CMakeLists.txt b/tracker-pt/module/CMakeLists.txt index 43580a1f..f0f90f8a 100644 --- a/tracker-pt/module/CMakeLists.txt +++ b/tracker-pt/module/CMakeLists.txt @@ -1,6 +1,8 @@ find_package(OpenCV QUIET) if(OpenCV_FOUND) + otr_module(tracker-pt-static STATIC) + target_link_libraries(${self} opentrack-tracker-pt-base) + target_include_directories(${self} PUBLIC "${CMAKE_SOURCE_DIR}/tracker-pt") otr_module(tracker-pt) - target_link_libraries(opentrack-tracker-pt opentrack-tracker-pt-base) - target_include_directories(opentrack-tracker-pt PRIVATE "${CMAKE_SOURCE_DIR}/tracker-pt") + target_link_libraries(${self} opentrack-tracker-pt-static) endif() diff --git a/tracker-pt/module/frame.hpp b/tracker-pt/module/frame.hpp index 9e4f809a..49dde49e 100644 --- a/tracker-pt/module/frame.hpp +++ b/tracker-pt/module/frame.hpp @@ -30,7 +30,7 @@ private: static void ensure_size(cv::Mat& frame, int w, int h, int type); bool fresh = true; - cv::Mat frame_copy, frame_color, frame_out; + cv::Mat frame_copy, frame_color, frame_out, frame_out2; }; } // ns pt_module diff --git a/tracker-pt/module/point_extractor.cpp b/tracker-pt/module/point_extractor.cpp index 427925ab..1208da4e 100644 --- a/tracker-pt/module/point_extractor.cpp +++ b/tracker-pt/module/point_extractor.cpp @@ -102,7 +102,7 @@ void PointExtractor::ensure_buffers(const cv::Mat& frame) { frame_gray = cv::Mat1b(H, W); frame_bin = cv::Mat1b(H, W); - frame_blobs = cv::Mat1b(H, W); + frame_gray_unmasked = cv::Mat1b(H, W); } } @@ -180,7 +180,7 @@ void PointExtractor::threshold_image(const cv::Mat& frame_gray, cv::Mat1b& outpu const f radius = (f) threshold_radius_value(frame_gray.cols, frame_gray.rows, threshold_slider_value); - float const* const __restrict ptr = (float*) hist.ptr(0); + float const* const __restrict ptr = hist.ptr<float>(0); const unsigned area = uround(3 * M_PI * radius*radius); const unsigned sz = unsigned(hist.cols * hist.rows); unsigned thres = 32; @@ -202,33 +202,34 @@ void PointExtractor::extract_points(const pt_frame& frame_, pt_preview& preview_ cv::Mat& preview_frame = *preview_frame_.as<Preview>(); ensure_buffers(frame); - color_to_grayscale(frame, frame_gray); + color_to_grayscale(frame, frame_gray_unmasked); #if defined PREVIEW cv::imshow("capture", frame_gray); cv::waitKey(1); #endif - threshold_image(frame_gray, frame_bin); - - blobs.clear(); - frame_bin.copyTo(frame_blobs); + threshold_image(frame_gray_unmasked, frame_bin); + frame_gray_unmasked.copyTo(frame_gray, frame_bin); const f region_size_min = s.min_point_size; const f region_size_max = s.max_point_size; unsigned idx = 0; - for (int y=0; y < frame_blobs.rows; y++) + + blobs.clear(); + + for (int y=0; y < frame_bin.rows; y++) { - const unsigned char* ptr_bin = frame_blobs.ptr(y); - for (int x=0; x < frame_blobs.cols; x++) + const unsigned char* ptr_bin = frame_bin.ptr(y); + for (int x=0; x < frame_bin.cols; x++) { if (ptr_bin[x] != 255) continue; idx = blobs.size() + 1; cv::Rect rect; - cv::floodFill(frame_blobs, + cv::floodFill(frame_bin, cv::Point(x,y), cv::Scalar(idx), &rect, @@ -244,7 +245,7 @@ void PointExtractor::extract_points(const pt_frame& frame_, pt_preview& preview_ for (int i=rect.y; i < ymax; i++) { - unsigned char const* const __restrict ptr_blobs = frame_blobs.ptr(i); + unsigned char const* const __restrict ptr_blobs = frame_bin.ptr(i); unsigned char const* const __restrict ptr_gray = frame_gray.ptr(i); for (int j=rect.x; j < xmax; j++) { diff --git a/tracker-pt/module/point_extractor.h b/tracker-pt/module/point_extractor.h index eac2268c..2288f1a1 100644 --- a/tracker-pt/module/point_extractor.h +++ b/tracker-pt/module/point_extractor.h @@ -40,7 +40,7 @@ private: pt_settings s; - cv::Mat1b frame_gray, frame_bin, frame_blobs; + cv::Mat1b frame_gray_unmasked, frame_bin, frame_gray; cv::Mat1f hist; std::vector<blob> blobs; cv::Mat1b ch[3]; |