c++ - Draw rects specific color OpenCV -


i using following code find of blobs in image:

quad.convertto(quad, cv_8uc1); findcontours( quad, contours, hierarchy, cv_retr_tree, cv_chain_approx_simple, cv::point(0, 0) );  vector<vector<cv::point> > contours_poly( contours.size() ); vector<cv::rect> boundrect( contours.size() );  for( int = 0; < contours.size(); i++ ) { approxpolydp( mat(contours[i]), contours_poly[i], 3, true );     boundrect[i] = boundingrect( mat(contours_poly[i]) ); }  mat drawing = mat::zeros( quad.size(), cv_8uc3 ); for( int = 0; i< contours.size(); i++ ) {     scalar color = scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );     drawcontours( drawing, contours_poly, i, color, 1, 8, vector<vec4i>(), 0, cv::point() );     rectangle( drawing, boundrect[i].tl(), boundrect[i].br(), color, 2, 8, 0 ); } 

i getting result , seems working great, how can draw of bounding boxes in bright green? white , yellow , 1 green. way can make of them green? blobs of eroded text.

enter image description here

rng.uniform may uniform random law on [0,255]. have random colors...

try change

 scalar color = scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) ); 

for

scalar color = scalar(0,255, 0 ); 

colors coded using bgr system. b=0 g=255 r=0 going green !

bye,


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -