void thresholdCalculator::drawPupilImageWithScanLine(int x, int y, int w, int h, ofxCvGrayscaleImage & img) { ofEnableAlphaBlending(); ofPushMatrix(); ofTranslate(x, y, 0); ofSetColor(255, 255, 255); img.draw(0, 0, w, h); ofSetColor(255, 255, 255,80); ofLine(0, scanY, w, scanY); ofLine(scanX, 0, scanX, h); ofSetColor(255, 0, 0, 50); ofFill(); ofCircle(whiteLocMin.x * (img.width / roi.width), whiteLocMin.y * (img.height / roi.height), 10); ofDisableAlphaBlending(); ofSetColor(255, 255, 255); ofDrawBitmapString("imgBeforeThreshold", 1, h + 12); ofPopMatrix(); }
void draw(){ // sampleImg.draw(0, 0, 450, 450); cannyImg.draw(0, 0, 450, 450); cannyInvertImg.draw(450, 0, 450, 450); }
void draw() { ofSetColor(255); // A few helper variables for layout. int hw = width / 2; // Half width int hh = height / 2; // Half height. int qw = width / 4; // Quarter width. int qh = height / 4; // Quarter height. int lx = 14; // Label offset x. int ly = 20; // Label offset y. grayscaleImage.draw(0, 0, qw, qh); ofDrawBitmapStringHighlight("0. Grayscale", lx, ly); grayscaleBackgroundImage.draw(qw, 0, qw, qh); ofDrawBitmapStringHighlight("1. Background\n (spacebar)", lx + qw, ly); grayscaleAbsoluteDifference.draw(0, qh, qw, qh); ofDrawBitmapStringHighlight("2. Grayscale - Background", lx, ly + qh); grayscaleBinary.draw(qw, qh, qw, qh); ofDrawBitmapStringHighlight("3. Threshold " + ofToString(threshold) + "\n (-/+: change threshold)\n ( i: invert)", lx + qw, ly + qh); // Here we use ofPushMatrix(), ... to scale all of the contours and bounding boxes. ofPushStyle(); ofPushMatrix(); ofTranslate(hw, 0); ofScale(0.5, 0.5, 1); grayscaleBinary.draw(0, 0); contourFinder.draw(); // Draw all of the contours and their bounding boxes. // Draw our line. ofSetColor(ofColor::yellow); holePositions.draw(); ofPopMatrix(); ofDrawBitmapStringHighlight("4. Contours and Bounding Boxes\n Draw a yellow line to follow\n the center of the largest blob.", lx + hw, ly); ofPopStyle(); colorImage.draw(0, 0);//, hw, hh); // ofDrawBitmapStringHighlight("5. Original", lx, ly + hh); for (int i = 0; i < contourFinder.nBlobs; ++i) { ofPolyline contour(contourFinder.blobs[i].pts); // Resample to reduce the resolution. contour = contour.getResampledBySpacing(5); float interpolatedIndex = offset * contour.size(); ofPoint position = contour.getPointAtIndexInterpolated(interpolatedIndex); ofPoint normal = contour.getNormalAtIndexInterpolated(interpolatedIndex); // Make a line pointing normal to the contour. ofPoint lineEnd = position - normal * 30; ofSetColor(ofColor::yellow); contour.draw(); ofLine(position, lineEnd); ofCircle(lineEnd, 2); } }