最終更新:
mikk_ni3_92 2010年02月13日(土) 17:02:11履歴
現在地 >> メニュー >> OpenCV >> highgui編02 >> highgui編02::まとめ
#include <iostream> #include <ctime> #include <cv.h> #include <highgui.h> #pragma comment(lib,"cv200.lib") #pragma comment(lib,"cxcore200.lib") #pragma comment(lib,"highgui200.lib") const char *filename = "testimg.png"; int main() { IplImage *imgA = cvLoadImage(filename); if(imgA ==NULL ) { std::cerr << "Can't load image\n"; return -1; } cvNamedWindow("key and idle"); cvShowImage("key and idle",imgA);//1度表示 int key; CvRNG rng = cvRNG(static_cast<int64>(time(NULL)));//乱数のseed設定 CvPoint pt; unsigned char color[3]; for(;;) { key = cvWaitKey(500); if (key == '\033' || key == 'q')//[esc]or[q]で終了 { break; } pt = cvPoint(cvRandInt(&rng)%imgA->width, cvRandInt(&rng)%imgA->height); color[0] = cvRandInt(&rng)%256; color[1] = cvRandInt(&rng)%256; color[2] = cvRandInt(&rng)%256; cvCircle(imgA,pt,50,CV_RGB(color[0],color[1],color[2]),2); cvShowImage("key and idle",imgA);//描画 } cvReleaseImage(&imgA); cvDestroyAllWindows(); return 0; }