\include\opencv""> \include\opencv"">
Download presentation
Presentation is loading. Please wait.
Published byVictor Franklin Modified over 9 years ago
1
Detect Candle
3
Open VC++ Directories configuration: Tools > Options > Projects and Solutions > VC++ Directories Choose "Show directories for: Include files" Add "Folder OpenCV>\include\opencv"
4
Choose "Show directories for: Library files" Add " \lib" Choose "Show directories for: Source files" Add " \src\cv " Add " \src\cvaux " Add " \src\cxcore " Add " \src\highgui"
5
Open Linker Input properties: Configuration Properties > Linker > Input edit "Additional Dependencies" Add "cv210.lib" Add "cxcore210.lib" Add "highgui210.lib"
6
IplImage cvQueryFrame(CvCapture* capture) cvCreateImage(CvSize size, int depth, int channels) cvLoadImage(const char* filename, int iscolor=CV_LOAD_IMAGE_COLOR) cvReleaseImage(IplImage** image)
7
HighGui cvNamedWindow(const char* name, int flags) cvShowImage(const char* name, const CvArr* image) cvWaitKey(int delay=0) cvDestroyWindow(const char* name) cvDestroyAllWindows()
8
#include int main( int argc, char** argv ) { IplImage* img = cvLoadImage( “photo.jpg”); // โหลดภาพ photo.jpg cvNamedWindow( “Example1”, CV_WINDOW_AUTOSIZE ); // สร้างหน้าต่างสำหรับแสดงผล cvShowImage( “Example1”, img ); // กำหนดให้ภาพมาแสดงผลที่หน้าต่าง cvWaitKey(0); // Wait for any key cvReleaseImage( &img ); // Clear Memory cvDestroyWindow( “Example1” ); // หยุดการทำงานของหน้าต่างแสดงผล }
10
Write String cvInitFont(CvFont* font, int fontFace, double hscale, double vscale, double shear=0, int thickness=1, int lineType=8) cvPutText(CvArr* img, const char* text, CvPoint org, const CvFont* font, CvScalar color) Draw Circle cvCircle(CvArr* img, CvPoint center, int radius, CvScalar color, int thickness=1, int lineType=8, int shift=0) Draw Rectangle cvRectangle(CvArr* img, CvPoint pt1, CvPoint pt2, CvScalar color, int thickness=1, int lineType=8, int shift=0) Draw Line cvLine(CvArr* img, CvPoint pt1, CvPoint pt2, CvScalar color, int thickness=1, int lineType=8, int shift=0)
11
//Print string CvFont font; cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0, 0, 1, CV_AA); cvPutText(img,"Hello", cvPoint(20,20), &font, cvScalar(255, 255, 255, 0)); //Draw x-mark cvLine(img, cvPoint(0,0), cvPoint(10,10), cvScalar(0,0,255,0)) cvLine(img, cvPoint(10,0), cvPoint(0,10), cvScalar(0,0,255,0))
13
Access image data RGB image ImgHeight = x, ImgWidth = y Image[x][y] = (img->imageData + x * img->widthStep) + (3*y) Red Channel = Image[x][y] + 2 Green Channel = Image[x][y] + 1 Blue Channel = Image[x][y]
14
//Convert image to red channel void cutoff_gb ( IplImage* img ) { for( int x=0; x height; x++ ) { uchar* ptr = (uchar*) (img->imageData + x * img->widthStep); for( int y=0; y width; y++ ) { ptr[3*y] = 0; ptr[3*y+1] = 0; }
16
Convert color space cvCvtColor(CvArr* src, CvArr* dst, int code) code = X2Y (such asRGB2GRAY, RGB2HSV) Blur image cvSmooth(CvArr* src, CvArr* dst, int smoothtype=CV_GAUSSIAN, int param1=3, int param2=0) Cut threshold cvThreshold(CvArr* src, CvArr* dst, double threshold, double maxValue, int thresholdType)
20
Get Capture from camera CvCapture* capture = cvCreateCameraCapture( int index ); Get Image from capture IplImage *img = cvQueryFrame( capture );
21
//Capture from camera CvCapture* capture = cvCreateCameraCapture( 0 ); IplImage* img = cvQueryFrame( capture ); cvNamedWindow( "Input", CV_WINDOW_AUTOSIZE ); while(cvWaitKey(5) != 27) // wait 5 ms for press ESC { cvShowImage( "Input", img ); img = cvQueryFrame( capture ); } cvDestroyAllWindows();
22
IplImage* temp = cvCreateImage(cvGetSize(img),IPL_DEPTH_8U,1); cvCvtColor(img,temp,CV_RGB2GRAY); cvSmooth(temp,temp,CV_GAUSSIAN,7,7); CvMemStorage* MemStorage = cvCreateMemStorage(0); CvSeq* Circles = cvHoughCircles(temp,MemStorage,CV_HOUGH_GRADIENT,DP,MIN_DIST,200,100); for (int i = 0; i total; i++) { float* c = (float*)cvGetSeqElem( Circles, i ); if( cvRound(c[2]) MAX_RADIUS) continue; //Draw cvCircle( result, cvPoint(cvRound(c[0]),cvRound(c[1])),3, CV_RGB(0,255,0), -1, 8, 0 ); cvCircle( result, cvPoint(cvRound(c[0]),cvRound(c[1])),cvRound(c[2]), CV_RGB(255,0,0), 3, 8, 0 ); //แสดงรัศมี char radius_word[100]; sprintf(radius_word,"%d",cvRound(c[2])); cvPutText(result,radius_word, cvPoint(cvRound(c[0]),cvRound(c[1])), &font, cvScalar(255, 0, 0, 0)); }
24
CvRect cvRect( int x, int y, int width, int height ) ROI (Region Of Interest) cvSetImageROI(IplImage* image, CvRect rect) cvResetImageROI(IplImage* image) cvCopy(CvArr* src, CvArr* dst, CvArr* mask=NULL)
26
Get Position Count black&white Cut ROI cvHoughCircles cvSmooth cvCvtColor Capture from camera
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.