Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "cv.h"
- #include "highgui.h"
- IplImage* img, *img2;
- void on_mouse( int event, int x, int y, int flags, void* param )
- {
- printf("event = %08X x=%4d y=%4d flags =%08X\n",
- event, x, y, flags);
- if (flags!=0)
- cvCircle(
- img,//CvArr* img,
- cvPoint(x, y), // CvPoint center,
- rand()%30, //int radius,
- cvScalar(rand()%255, rand()%255, rand()%255, 0), //CvScalar color,
- 1, 8 , 0 // int thickness=1, int line_type=8, int shift=0 );
- );
- cvShowImage("Fig", img);
- }
- int main(int argc, char *argv[])
- {
- img2 = cvCreateImage(
- cvSize(1280, 1024), //CvSize size,
- IPL_DEPTH_8U , //int depth,
- 3 //int channels
- );
- img = cvLoadImage("Peppers.BMP", -1);
- if (img==0)
- {
- printf("Error in opening file\n");
- system("PAUSE");
- return -1;
- }
- printf("Channels %d depth %d \n", img->nChannels, img->depth);
- printf("The image Width by Height is %dX%d \n", img->width,img->height);
- printf("The image WidthStep %d \n", img->widthStep);
- cvNamedWindow("Fig", CV_WINDOW_AUTOSIZE );
- cvSetMouseCallback("Fig", on_mouse, 0 );
- cvShowImage("Fig", img );
- cvWaitKey(0);
- cvDestroyWindow( "Fig" );
- cvDestroyWindow( "Fig2" );
- cvReleaseImage( &img );
- cvReleaseImage( &img2 );
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment