2
0
mirror of https://github.com/team2059/Dent synced 2025-01-07 22:14:14 -05:00

Added edge detection and added to the display output

This commit is contained in:
Adam Long 2015-02-06 17:17:08 +00:00
parent 28789ebc51
commit 4303b189b1

View File

@ -1,5 +1,8 @@
#include "cv.h"
#include "highgui.h"
using namespace std;
using namespace cv;
IplImage* GetThresholdedImage(IplImage* img){
// Convert the image into an HSV image
IplImage* imgHSV = cvCreateImage(cvGetSize(img), 8, 3);
@ -11,6 +14,24 @@ IplImage* GetThresholdedImage(IplImage* img){
cvReleaseImage(&imgHSV);
return imgThreshed;
}
IplImage* GetImageEdges(IplImage *img){
const int lowerEdgeThresh = 10;
const int editRatio = 3;
Mat org, dst;
//Convert the IplImage to a mat
org = img;
//Blur the image "org" and output it to dst
GaussianBlur(org,dst,Size(5,5),0,0);
//Copy dst to org to keep naming correct
org = dst;
//Use canny to find edges
Canny(org,dst,lowerEdgeThresh,lowerEdgeThresh*3,3);
//Convert the Mat back to an image
img->imageData = (char *) dst.data;
return img;
}
int main()
{
// Initialize capturing live feed from the camera
@ -23,7 +44,6 @@ int main()
printf("Could not initialize capturing...");
return -1;
}
cvNamedWindow("video");
cvNamedWindow("thresh");
while(true){
// Will hold a frame captured from the camera
@ -35,10 +55,8 @@ int main()
// If this is the first frame, we need to initialize it
// Holds the yellow thresholded image (yellow = white, rest = black)
IplImage* imgYellowThresh = GetThresholdedImage(frame);
cvShowImage("thresh", imgYellowThresh);
cvShowImage("video", frame);
//Display the image after getting the edges of the yellowThresholded image
cvShowImage("thresh", GetImageEdges(imgYellowThresh));
// Quit on keypress
int c = cvWaitKey(10);
if(c!=-1){