Skip to content

Commit 06a7fba

Browse files
added freeze to point hist
1 parent a0b4990 commit 06a7fba

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

src/utils/hist_color_params_collector_point.cpp

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ int channels[] = { 0, 1 };
3030
float h_range[] = { 0, 179 };
3131
float s_range[] = { 0, 255 };
3232
const float* ranges[] = { h_range, s_range };
33+
bool freeze = false;
3334

3435
static void on_trackbar_size( int, void*){
3536
sd->minSizePc = double(size) * 0.0001;
@@ -49,6 +50,7 @@ void pickPoint( int event, int x, int y, int, void *){
4950
floodFill( last_image, mask2, seed, newVal, 0, Scalar( lo, lo, lo ), Scalar( up, up, up), flags );
5051
mask = mask2( Range( 1, mask2.rows - 1 ), Range( 1, mask2.cols - 1 ) );
5152
saved_image = last_image.clone();
53+
freeze = true;
5254
}
5355
else if( event == EVENT_RBUTTONDOWN && !saved_image.empty() ){
5456
int h_bins = 30; int s_bins = 32;
@@ -59,7 +61,8 @@ void pickPoint( int event, int x, int y, int, void *){
5961
/// Get the Histogram and normalize it
6062
calcHist( &hsv, 1, channels, mask, hist, 2, histSize, ranges, true, false );
6163
normalize( hist, hist, 0, 255, NORM_MINMAX, -1, Mat() );
62-
64+
65+
freeze = false;
6366
hca->setHist(hist);
6467
mask.release();
6568
}
@@ -69,19 +72,24 @@ void imageCallback(const sensor_msgs::ImageConstPtr& msg)
6972
{
7073
try
7174
{
72-
last_image = cv_bridge::toCvShare(msg, "bgr8")->image;
73-
74-
coloredObject.Identify(last_image, cv::Mat(), seq);
75-
seq++;
76-
77-
Mat image2draw = last_image.clone();
78-
coloredObject.draw(image2draw,Scalar(0,255,0));
75+
Mat image2draw;
76+
if( !freeze){
77+
last_image = cv_bridge::toCvShare(msg, "bgr8")->image;
7978

80-
if( !mask.empty() ){
81-
vector<vector<Point> > contours;
82-
vector<Vec4i> hierarchy;
83-
findContours( mask, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE );
84-
drawContours( image2draw, contours, -1, Scalar(0,0,255), 2, 8);
79+
coloredObject.Identify(last_image, cv::Mat(), seq);
80+
seq++;
81+
82+
image2draw = last_image.clone();
83+
coloredObject.draw(image2draw,Scalar(0,255,0));
84+
}
85+
else{
86+
if( !mask.empty() ){
87+
image2draw = saved_image;
88+
vector<vector<Point> > contours;
89+
vector<Vec4i> hierarchy;
90+
findContours( mask, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE );
91+
drawContours( image2draw, contours, -1, Scalar(0,0,255), 2, 8);
92+
}
8593
}
8694

8795
cv::imshow(OUTPUT_WINDOW, image2draw);

0 commit comments

Comments
 (0)