Ask Your Question

Sina_shiry's profile - activity

2016-06-30 00:43:52 -0600 received badge  Editor (source)
2016-06-30 00:42:10 -0600 asked a question "addImage" and "render" functions

visual studio don't know these commands, and what's the "miw" in this code:

Reference: OpenCV by example

Page: 137

vector< vector<float> > ExtractFeatures(Mat img, vector<int>* 
left=NULL, vector<int>* top=NULL)
{
 vector< vector<float> > output;
 vector<vector<Point> > contours;
 Mat input= img.clone();

 vector<Vec4i> hierarchy;
 findContours(input, contours, hierarchy, RETR_CCOMP, CHAIN_APPROX_
SIMPLE);
 // Check the number of objects detected
 if(contours.size() == 0 ){
 return output;
 }
 RNG rng( 0xFFFFFFFF );
 for(int i=0; i<contours.size(); i++){

 Mat mask= Mat::zeros(img.rows, img.cols, CV_8UC1);
 drawContours(mask, contours, i, Scalar(1), FILLED, LINE_8, 
 hierarchy, 1);
 Scalar area_s= sum(mask);
 float area= area_s[0];
 if(area>500){ //if the area is greather than min.

 RotatedRect r= minAreaRect(contours[i]);
 float width= r.size.width;
 float height= r.size.height;
 float ar=(width<height)?height/width:width/height;
 vector<float> row;
 row.push_back(area);
 row.push_back(ar);
 output.push_back(row);
 if(left!=NULL){
 left->push_back((int)r.center.x);
 }
 if(top!=NULL){
 top->push_back((int)r.center.y);
 }

 miw->addImage("Extract Features", mask*255);
 miw->render();
 waitKey(10);
 }
 }
 return output;
}