Merge pull request #1063 from mshabunin:reduce-dependencies
commit
880deec68f
65 changed files with 366 additions and 341 deletions
@ -1,2 +1,2 @@ |
||||
set(the_description "Background Segmentation Algorithms") |
||||
ocv_define_module(bgsegm opencv_core opencv_imgproc opencv_video opencv_highgui WRAP python) |
||||
ocv_define_module(bgsegm opencv_core opencv_imgproc opencv_video WRAP python) |
||||
|
@ -1,2 +1,2 @@ |
||||
set(the_description "Custom Calibration Pattern") |
||||
ocv_define_module(ccalib opencv_core opencv_imgproc opencv_calib3d opencv_features2d WRAP python) |
||||
ocv_define_module(ccalib opencv_core opencv_imgproc opencv_calib3d opencv_features2d opencv_highgui WRAP python) |
||||
|
@ -1,4 +1,4 @@ |
||||
set(the_description "datasets framework") |
||||
ocv_define_module(datasets opencv_core opencv_ml opencv_flann opencv_text WRAP python) |
||||
ocv_define_module(datasets opencv_core opencv_imgcodecs opencv_ml opencv_flann opencv_text WRAP python) |
||||
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4267) # flann, Win64 |
||||
|
@ -1,2 +1,2 @@ |
||||
set(the_description "Line descriptor") |
||||
ocv_define_module(line_descriptor opencv_features2d opencv_imgproc opencv_highgui WRAP python) |
||||
ocv_define_module(line_descriptor opencv_imgproc OPTIONAL opencv_features2d WRAP python) |
||||
|
@ -1,2 +1,2 @@ |
||||
set(the_description "Optical Flow Algorithms") |
||||
ocv_define_module(optflow opencv_core opencv_imgproc opencv_video opencv_highgui opencv_ximgproc WRAP python) |
||||
ocv_define_module(optflow opencv_core opencv_imgproc opencv_video opencv_ximgproc opencv_imgcodecs WRAP python) |
||||
|
@ -1,2 +1,2 @@ |
||||
set(the_description "Phase Unwrapping API") |
||||
ocv_define_module(phase_unwrapping opencv_core opencv_calib3d opencv_imgproc opencv_highgui opencv_features2d opencv_rgbd WRAP python java) |
||||
ocv_define_module(phase_unwrapping opencv_core opencv_imgproc WRAP python java) |
||||
|
@ -1,2 +1,2 @@ |
||||
set(the_description "Plot function for Mat data.") |
||||
ocv_define_module(plot opencv_core opencv_highgui WRAP python) |
||||
ocv_define_module(plot opencv_core opencv_imgproc WRAP python) |
||||
|
@ -1,3 +1,2 @@ |
||||
set(the_description "RGBD algorithms") |
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) |
||||
ocv_define_module(rgbd opencv_core opencv_calib3d opencv_highgui opencv_imgproc WRAP python) |
||||
ocv_define_module(rgbd opencv_core opencv_calib3d opencv_imgproc WRAP python) |
||||
|
@ -1,2 +1,2 @@ |
||||
set(the_description "Stereo Correspondence") |
||||
ocv_define_module(stereo opencv_imgproc opencv_features2d opencv_core opencv_highgui opencv_calib3d) |
||||
ocv_define_module(stereo opencv_imgproc opencv_features2d opencv_core opencv_calib3d) |
||||
|
@ -1,2 +1,2 @@ |
||||
set(the_description "Structured Light API") |
||||
ocv_define_module(structured_light opencv_core opencv_calib3d opencv_imgproc opencv_highgui opencv_features2d opencv_rgbd opencv_phase_unwrapping OPTIONAL opencv_viz WRAP python java) |
||||
ocv_define_module(structured_light opencv_core opencv_imgproc opencv_calib3d opencv_phase_unwrapping OPTIONAL opencv_viz WRAP python java) |
||||
|
@ -1,2 +1,2 @@ |
||||
set(the_description "Tracking API") |
||||
ocv_define_module(tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_plot OPTIONAL opencv_dnn opencv_datasets WRAP java python) |
||||
ocv_define_module(tracking opencv_imgproc opencv_core opencv_video opencv_plot OPTIONAL opencv_dnn opencv_datasets WRAP java python) |
||||
|
@ -0,0 +1,197 @@ |
||||
#ifndef _ROISELECTOR_HPP_ |
||||
#define _ROISELECTOR_HPP_ |
||||
|
||||
#include "opencv2/core.hpp" |
||||
#include "opencv2/highgui.hpp" |
||||
#include "opencv2/imgproc.hpp" |
||||
|
||||
cv::Rect2d selectROI(cv::Mat img, bool fromCenter = true); |
||||
cv::Rect2d selectROI(const cv::String& windowName, cv::Mat img, bool showCrossair = true, bool fromCenter = true); |
||||
void selectROI(const cv::String& windowName, cv::Mat img, std::vector<cv::Rect2d> & boundingBox, bool fromCenter = true); |
||||
|
||||
//==================================================================================================
|
||||
|
||||
class ROISelector |
||||
{ |
||||
public: |
||||
cv::Rect2d select(cv::Mat img, bool fromCenter = true) |
||||
{ |
||||
return select("ROI selector", img, fromCenter); |
||||
} |
||||
|
||||
cv::Rect2d select(const cv::String &windowName, cv::Mat img, bool showCrossair = true, bool fromCenter = true) |
||||
{ |
||||
|
||||
key = 0; |
||||
|
||||
// set the drawing mode
|
||||
selectorParams.drawFromCenter = fromCenter; |
||||
|
||||
// show the image and give feedback to user
|
||||
cv::imshow(windowName, img); |
||||
|
||||
// copy the data, rectangle should be drawn in the fresh image
|
||||
selectorParams.image = img.clone(); |
||||
|
||||
// select the object
|
||||
cv::setMouseCallback(windowName, mouseHandler, (void *)&selectorParams); |
||||
|
||||
// end selection process on SPACE (32) ESC (27) or ENTER (13)
|
||||
while (!(key == 32 || key == 27 || key == 13)) |
||||
{ |
||||
// draw the selected object
|
||||
cv::rectangle(selectorParams.image, selectorParams.box, cv::Scalar(255, 0, 0), 2, 1); |
||||
|
||||
// draw cross air in the middle of bounding box
|
||||
if (showCrossair) |
||||
{ |
||||
// horizontal line
|
||||
cv::line(selectorParams.image, |
||||
cv::Point((int)selectorParams.box.x, |
||||
(int)(selectorParams.box.y + selectorParams.box.height / 2)), |
||||
cv::Point((int)(selectorParams.box.x + selectorParams.box.width), |
||||
(int)(selectorParams.box.y + selectorParams.box.height / 2)), |
||||
cv::Scalar(255, 0, 0), 2, 1); |
||||
|
||||
// vertical line
|
||||
cv::line(selectorParams.image, |
||||
cv::Point((int)(selectorParams.box.x + selectorParams.box.width / 2), |
||||
(int)selectorParams.box.y), |
||||
cv::Point((int)(selectorParams.box.x + selectorParams.box.width / 2), |
||||
(int)(selectorParams.box.y + selectorParams.box.height)), |
||||
cv::Scalar(255, 0, 0), 2, 1); |
||||
} |
||||
|
||||
// show the image bouding box
|
||||
cv::imshow(windowName, selectorParams.image); |
||||
|
||||
// reset the image
|
||||
selectorParams.image = img.clone(); |
||||
|
||||
// get keyboard event, extract lower 8 bits for scancode comparison
|
||||
key = cv::waitKey(1) & 0xFF; |
||||
} |
||||
|
||||
return selectorParams.box; |
||||
} |
||||
|
||||
void select(const cv::String &windowName, cv::Mat img, std::vector<cv::Rect2d> &boundingBox, bool fromCenter = true) |
||||
{ |
||||
std::vector<cv::Rect2d> box; |
||||
cv::Rect2d temp; |
||||
key = 0; |
||||
|
||||
// show notice to user
|
||||
printf("Select an object to track and then press SPACE or ENTER button!\n"); |
||||
printf("Finish the selection process by pressing ESC button!\n"); |
||||
|
||||
// while key is not ESC (27)
|
||||
for (;;) |
||||
{ |
||||
temp = select(windowName, img, true, fromCenter); |
||||
if (key == 27) |
||||
break; |
||||
if (temp.width > 0 && temp.height > 0) |
||||
box.push_back(temp); |
||||
} |
||||
boundingBox = box; |
||||
} |
||||
|
||||
struct handlerT |
||||
{ |
||||
// basic parameters
|
||||
bool isDrawing; |
||||
cv::Rect2d box; |
||||
cv::Mat image; |
||||
|
||||
// parameters for drawing from the center
|
||||
bool drawFromCenter; |
||||
cv::Point2f center; |
||||
|
||||
// initializer list
|
||||
handlerT() : isDrawing(false), drawFromCenter(true){}; |
||||
} selectorParams; |
||||
|
||||
// to store the tracked objects
|
||||
std::vector<handlerT> objects; |
||||
|
||||
private: |
||||
static void mouseHandler(int event, int x, int y, int flags, void *param) |
||||
{ |
||||
ROISelector *self = static_cast<ROISelector *>(param); |
||||
self->opencv_mouse_callback(event, x, y, flags, param); |
||||
} |
||||
|
||||
void opencv_mouse_callback(int event, int x, int y, int, void *param) |
||||
{ |
||||
handlerT *data = (handlerT *)param; |
||||
switch (event) |
||||
{ |
||||
// update the selected bounding box
|
||||
case cv::EVENT_MOUSEMOVE: |
||||
if (data->isDrawing) |
||||
{ |
||||
if (data->drawFromCenter) |
||||
{ |
||||
data->box.width = 2 * (x - data->center.x) /*data->box.x*/; |
||||
data->box.height = 2 * (y - data->center.y) /*data->box.y*/; |
||||
data->box.x = data->center.x - data->box.width / 2.0; |
||||
data->box.y = data->center.y - data->box.height / 2.0; |
||||
} |
||||
else |
||||
{ |
||||
data->box.width = x - data->box.x; |
||||
data->box.height = y - data->box.y; |
||||
} |
||||
} |
||||
break; |
||||
|
||||
// start to select the bounding box
|
||||
case cv::EVENT_LBUTTONDOWN: |
||||
data->isDrawing = true; |
||||
data->box = cv::Rect2d(x, y, 0, 0); |
||||
data->center = cv::Point2f((float)x, (float)y); |
||||
break; |
||||
|
||||
// cleaning up the selected bounding box
|
||||
case cv::EVENT_LBUTTONUP: |
||||
data->isDrawing = false; |
||||
if (data->box.width < 0) |
||||
{ |
||||
data->box.x += data->box.width; |
||||
data->box.width *= -1; |
||||
} |
||||
if (data->box.height < 0) |
||||
{ |
||||
data->box.y += data->box.height; |
||||
data->box.height *= -1; |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
|
||||
// save the keypressed characted
|
||||
int key; |
||||
}; |
||||
|
||||
//==================================================================================================
|
||||
|
||||
static ROISelector _selector; |
||||
|
||||
cv::Rect2d selectROI(cv::Mat img, bool fromCenter) |
||||
{ |
||||
return _selector.select("ROI selector", img, true, fromCenter); |
||||
}; |
||||
|
||||
cv::Rect2d selectROI(const cv::String &windowName, cv::Mat img, bool showCrossair, bool fromCenter) |
||||
{ |
||||
printf("Select an object to track and then press SPACE or ENTER button!\n"); |
||||
return _selector.select(windowName, img, showCrossair, fromCenter); |
||||
}; |
||||
|
||||
void selectROI(const cv::String &windowName, cv::Mat img, std::vector<cv::Rect2d> &boundingBox, bool fromCenter) |
||||
{ |
||||
return _selector.select(windowName, img, boundingBox, fromCenter); |
||||
} |
||||
|
||||
#endif // _ROISELECTOR_HPP_
|
@ -1,185 +0,0 @@ |
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp" |
||||
|
||||
namespace cv { |
||||
void ROISelector::mouseHandler(int event, int x, int y, int flags, void *param){ |
||||
ROISelector *self =static_cast<ROISelector*>(param); |
||||
self->opencv_mouse_callback(event,x,y,flags,param); |
||||
} |
||||
|
||||
void ROISelector::opencv_mouse_callback( int event, int x, int y, int , void *param ){ |
||||
handlerT * data = (handlerT*)param; |
||||
switch( event ){ |
||||
// update the selected bounding box
|
||||
case EVENT_MOUSEMOVE: |
||||
if( data->isDrawing ){ |
||||
if(data->drawFromCenter){ |
||||
data->box.width = 2*(x-data->center.x)/*data->box.x*/; |
||||
data->box.height = 2*(y-data->center.y)/*data->box.y*/; |
||||
data->box.x = data->center.x-data->box.width/2.0; |
||||
data->box.y = data->center.y-data->box.height/2.0; |
||||
}else{ |
||||
data->box.width = x-data->box.x; |
||||
data->box.height = y-data->box.y; |
||||
} |
||||
} |
||||
break; |
||||
|
||||
// start to select the bounding box
|
||||
case EVENT_LBUTTONDOWN: |
||||
data->isDrawing = true; |
||||
data->box = cvRect( x, y, 0, 0 ); |
||||
data->center = Point2f((float)x,(float)y); |
||||
break; |
||||
|
||||
// cleaning up the selected bounding box
|
||||
case EVENT_LBUTTONUP: |
||||
data->isDrawing = false; |
||||
if( data->box.width < 0 ){ |
||||
data->box.x += data->box.width; |
||||
data->box.width *= -1; |
||||
} |
||||
if( data->box.height < 0 ){ |
||||
data->box.y += data->box.height; |
||||
data->box.height *= -1; |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
|
||||
Rect2d ROISelector::select(Mat img, bool fromCenter){ |
||||
return select("ROI selector", img, fromCenter); |
||||
} |
||||
|
||||
Rect2d ROISelector::select(const cv::String& windowName, Mat img, bool showCrossair, bool fromCenter){ |
||||
|
||||
key=0; |
||||
|
||||
// set the drawing mode
|
||||
selectorParams.drawFromCenter = fromCenter; |
||||
|
||||
// show the image and give feedback to user
|
||||
imshow(windowName,img); |
||||
|
||||
// copy the data, rectangle should be drawn in the fresh image
|
||||
selectorParams.image=img.clone(); |
||||
|
||||
// select the object
|
||||
setMouseCallback( windowName, mouseHandler, (void *)&selectorParams ); |
||||
|
||||
// end selection process on SPACE (32) ESC (27) or ENTER (13)
|
||||
while(!(key==32 || key==27 || key==13)){ |
||||
// draw the selected object
|
||||
rectangle( |
||||
selectorParams.image, |
||||
selectorParams.box, |
||||
Scalar(255,0,0),2,1 |
||||
); |
||||
|
||||
// draw cross air in the middle of bounding box
|
||||
if(showCrossair){ |
||||
// horizontal line
|
||||
line( |
||||
selectorParams.image, |
||||
Point((int)selectorParams.box.x,(int)(selectorParams.box.y+selectorParams.box.height/2)), |
||||
Point((int)(selectorParams.box.x+selectorParams.box.width),(int)(selectorParams.box.y+selectorParams.box.height/2)), |
||||
Scalar(255,0,0),2,1 |
||||
); |
||||
|
||||
// vertical line
|
||||
line( |
||||
selectorParams.image, |
||||
Point((int)(selectorParams.box.x+selectorParams.box.width/2),(int)selectorParams.box.y), |
||||
Point((int)(selectorParams.box.x+selectorParams.box.width/2),(int)(selectorParams.box.y+selectorParams.box.height)), |
||||
Scalar(255,0,0),2,1 |
||||
); |
||||
} |
||||
|
||||
// show the image bouding box
|
||||
imshow(windowName,selectorParams.image); |
||||
|
||||
// reset the image
|
||||
selectorParams.image=img.clone(); |
||||
|
||||
//get keyboard event, extract lower 8 bits for scancode comparison
|
||||
key=waitKey(1) & 0xFF; |
||||
} |
||||
|
||||
|
||||
return selectorParams.box; |
||||
} |
||||
|
||||
void ROISelector::select(const cv::String& windowName, Mat img, std::vector<Rect2d> & boundingBox, bool fromCenter){ |
||||
std::vector<Rect2d> box; |
||||
Rect2d temp; |
||||
key=0; |
||||
|
||||
// show notice to user
|
||||
printf("Select an object to track and then press SPACE or ENTER button!\n" ); |
||||
printf("Finish the selection process by pressing ESC button!\n" ); |
||||
|
||||
// while key is not ESC (27)
|
||||
for(;;) { |
||||
temp=select(windowName, img, true, fromCenter); |
||||
if(key==27) break; |
||||
if(temp.width>0 && temp.height>0) |
||||
box.push_back(temp); |
||||
} |
||||
boundingBox=box; |
||||
} |
||||
|
||||
ROISelector _selector; |
||||
Rect2d selectROI(Mat img, bool fromCenter){ |
||||
return _selector.select("ROI selector", img, true, fromCenter); |
||||
}; |
||||
|
||||
Rect2d selectROI(const cv::String& windowName, Mat img, bool showCrossair, bool fromCenter){ |
||||
printf("Select an object to track and then press SPACE or ENTER button!\n" ); |
||||
return _selector.select(windowName,img, showCrossair, fromCenter); |
||||
}; |
||||
|
||||
void selectROI(const cv::String& windowName, Mat img, std::vector<Rect2d> & boundingBox, bool fromCenter){ |
||||
return _selector.select(windowName, img, boundingBox, fromCenter); |
||||
} |
||||
|
||||
} /* namespace cv */ |
@ -1,5 +1,4 @@ |
||||
set(the_description "Contributed/Experimental Algorithms for Salient 2D Features Detection") |
||||
ocv_define_module(xfeatures2d opencv_core opencv_imgproc opencv_features2d opencv_calib3d opencv_shape opencv_highgui opencv_videoio opencv_ml |
||||
OPTIONAL opencv_cudaarithm WRAP python java) |
||||
ocv_define_module(xfeatures2d opencv_core opencv_imgproc opencv_features2d opencv_calib3d OPTIONAL opencv_shape opencv_cudaarithm WRAP python java) |
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/download_vgg.cmake) |
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/download_boostdesc.cmake) |
||||
|
@ -1,2 +1,2 @@ |
||||
set(the_description "Extended image processing module. It includes edge-aware filters and etc.") |
||||
ocv_define_module(ximgproc opencv_imgproc opencv_core opencv_highgui opencv_calib3d WRAP python) |
||||
ocv_define_module(ximgproc opencv_core opencv_imgproc opencv_calib3d opencv_imgcodecs WRAP python) |
||||
|
@ -1,5 +1,5 @@ |
||||
set(the_description "Object detection algorithms") |
||||
ocv_define_module(xobjdetect opencv_core opencv_imgproc opencv_highgui opencv_objdetect WRAP python) |
||||
ocv_define_module(xobjdetect opencv_core opencv_imgproc opencv_objdetect opencv_imgcodecs WRAP python) |
||||
if (BUILD_opencv_apps AND NOT APPLE_FRAMEWORK) |
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools ${CMAKE_CURRENT_BINARY_DIR}/tools) |
||||
endif() |
||||
|
@ -1,2 +1,2 @@ |
||||
set(the_description "Addon to basic photo module") |
||||
ocv_define_module(xphoto opencv_core opencv_imgproc OPTIONAL opencv_photo opencv_highgui opencv_photo WRAP python) |
||||
ocv_define_module(xphoto opencv_core opencv_imgproc WRAP python) |
||||
|
Loading…
Reference in new issue