Hi,
I am working on a project to compare an image from my webcam to a shape I draw.
In order to compare any image from my webcam with ofVideoGrabber, I am using contour finder;
and I use the catmule method (drawing 11 draggableVertex) to create the shape.
I am struggling with comparing the pixels between the image from my webcam to the shape as the shape is filled with ofFill(), is it possible for me to do an if statement like:
if (finder.size() > ofFill()*0.7){
do something;
}
below is my code:
void ofApp::draw(){
ofFill();
ofEnableAlphaBlending();
ofSetColor(255,255,255,128);
cam.draw(0,0);
thresholded.draw(0,0,1080,810);
ofNoFill();
int numContours = finder.size();
if (numContours > 0){
vector<cv::Point> points = finder.getContour(0);
cout << "points " << points.size() << endl;
//everytime when it sees a contour, it draws shape
ofBeginShape();
for(int i = 0; i < points.size(); i++){
ofVertex(points[i].x, points[i].y);
}
ofEndShape();
finder.draw();
}
ofBeginShape();
for (int i = 0; i < nCurveVertices; i++){
if (i == 0){
ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // we need to duplicate 0 for the curve to start at point 0
ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // we need to duplicate 0 for the curve to start at point 0
} else if (i == nCurveVertices-1){
ofCurveVertex(curveVertices[i].x, curveVertices[i].y);
ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // to draw a curve from pt 6 to pt 0
ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // we duplicate the first point twice
} else {
ofCurveVertex(curveVertices[i].x, curveVertices[i].y);
}
}
ofEndShape();
}
Any comments would be very helpful :))) Cheers :)))
Karen xxx