本文整理汇总了C++中cvSetMouseCallback函数的典型用法代码示例。如果您正苦于以下问题:C++ cvSetMouseCallback函数的具体用法?C++ cvSetMouseCallback怎么用?C++ cvSetMouseCallback使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cvSetMouseCallback函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: camera
FkFingerKeyboard::FkFingerKeyboard(int camIndexTop, int camIndexBottom, int keyboardType) : camera(camIndexTop, camIndexBottom),
mouseListener(camera.getResolution()), preProcessor(keyboardType, camera.getResolution()), postProcessor(camera.getResolution()) {
dstImageTop = cvCreateImage(camera.getResolution(), IPL_DEPTH_8U, 3);
dstImageBottom = cvCreateImage(camera.getResolution(), IPL_DEPTH_8U, 3);
cvNamedWindow(WINDOW_NAME_TOP, CV_WINDOW_AUTOSIZE);
cvNamedWindow(WINDOW_NAME_BOTTOM, CV_WINDOW_AUTOSIZE);
#ifdef _WINDOWS
cvCreateTrackbar("Bright", WINDOW_NAME_BOTTOM, camera.getBright(), 255, camera.setBrightness);
cvCreateTrackbar("Contra", WINDOW_NAME_BOTTOM, camera.getContra(), 255, camera.setContrast);
cvCreateTrackbar("Satura", WINDOW_NAME_BOTTOM, camera.getSatura(), 255, camera.setSaturation);
cvCreateTrackbar("Exposu", WINDOW_NAME_BOTTOM, camera.getExposu(), 10, camera.setExposure);
cvCreateTrackbar("Gain", WINDOW_NAME_BOTTOM, camera.getGain(), 10, camera.setGain);
cvCreateTrackbar("White", WINDOW_NAME_BOTTOM, camera.getWhite(), 10000, camera.setWhiteBalance);
//cvCreateTrackbar("Bright", WINDOW_NAME_TOP, camera.getBright(), 255, camera.setBrightnessTop);
//cvCreateTrackbar("Contra", WINDOW_NAME_TOP, camera.getContra(), 255, camera.setContrastTop);
//cvCreateTrackbar("Satura", WINDOW_NAME_TOP, camera.getSatura(), 255, camera.setSaturationTop);
cvSetMouseCallback(WINDOW_NAME_TOP, mouseListener.mouseClickEvent, WINDOW_NAME_TOP);
cvSetMouseCallback(WINDOW_NAME_BOTTOM, mouseListener.mouseClickEvent, WINDOW_NAME_BOTTOM);
#endif
#ifndef _WINDOWS
cvSetMouseCallback(WINDOW_NAME_TOP, mouseListener.mouseClickEvent, (void*)WINDOW_NAME_TOP);
cvSetMouseCallback(WINDOW_NAME_BOTTOM, mouseListener.mouseClickEvent, (void*)WINDOW_NAME_BOTTOM);
#endif
#ifdef _WINDOWS
message = new FkWindowsMessage();
#endif
#ifndef _WINDOWS
message = new FkConsoleMessage();
#endif
this->mouseListener.setMessenger(message);
}
示例2: getBBFromUser
// TODO: member of Gui
// --> problem: callback function mouseHandler as member!
int getBBFromUser(IplImage *img, CvRect &rect, Gui *gui, const string &message)
{
window_name = gui->windowName();
cvDestroyWindow(window_name.c_str());
cvNamedWindow(window_name.c_str(), CV_WINDOW_AUTOSIZE);
cvMoveWindow(window_name.c_str(), 100, 100);
img0 = (IplImage *)cvClone(img);
rect = cvRect(-1, -1, -1, -1);
bb = ▭
bool correctBB = false;
cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 0.5, 0.5, 0, 1, 8);
cvSetMouseCallback(window_name.c_str(), mouseHandler, NULL);
cvPutText(img0, message.c_str(), cvPoint(500, 60),
&font, cvScalar(255, 255, 0));
cvShowImage(window_name.c_str(), img0);
while (!correctBB)
{
char key = cvWaitKey(0);
if (tolower(key) == 'q')
{
return PROGRAM_EXIT;
}
if (((key == '\n') || (key == '\r') || (key == '\r\n')) && (bb->x != -1) && (bb->y != -1))
{
correctBB = true;
}
}
if (rect.width < 0)
{
rect.x += rect.width;
rect.width = abs(rect.width);
}
if (rect.height < 0)
{
rect.y += rect.height;
rect.height = abs(rect.height);
}
cvSetMouseCallback(window_name.c_str(), NULL, NULL);
cvReleaseImage(&img0);
cvReleaseImage(&img1);
return SUCCESS;
}
示例3: main
int main()
{
img = cvLoadImage( "lena.bmp", 1 );
rect = cvRect( -1, -1, 0, 0);
// 副本
temp = cvCloneImage( img );
original = cvCloneImage(img);
cvNamedWindow("draw rect");
cvSetMouseCallback("draw rect", my_mouse_callback, (void*)img);
while(1)
{
cvCopyImage(img, temp);
if(draw)
{
draw_rect( temp , rect );
}
cvShowImage( "draw rect", temp);
if(cvWaitKey(15) == 27)
break;
}
cvReleaseImage(&img);
cvReleaseImage(&temp);
cvReleaseImage(&original);
cvDestroyAllWindows();
return 0;
}
示例4: cvLoadImage
void PerspetiveRectificationWithQt::startOne()
{
std::string pathSource = "picture10.jpg";
IplImage* image = cvLoadImage(pathSource.c_str());
if(image!=NULL) {
quadrangle = new InputQuadrangle();
cvNamedWindow("image",1);
cvShowImage("image",image);
cvSetMouseCallback( "image", mouseHandler, NULL );
while(globalMouseCounter<4) {
cvWaitKey();
}
QTime time;
time.start();
Rectification *rectification = new Rectification();
rectification->calculateDimension(quadrangle);
IplImage* output = cvCreateImage(cvSize(rectification->mWidth, rectification->mHeight),IPL_DEPTH_8U,3);
output = rectification->rectify(image,output,rectification->mWidth,rectification->mHeight,rectification->mOldFirstApexX,rectification->mOldFirstApexY
,rectification->newPictureXApex,rectification->newPictureYApex,rectification->mPictureApexXPosition,rectification->mPictureApexYPosition);
int milis = time.elapsed();
ui.label_2->setNum(milis);
cvNamedWindow("image2");
cvShowImage("image2",output);
cvWaitKey();
cvReleaseImage(&output);
cvReleaseImage(&image);
cvDestroyWindow("image");
cvDestroyWindow("image2");
delete quadrangle;
delete rectification;
}
}
开发者ID:Damian-Lopata,项目名称:ImagePerspectiveRectification,代码行数:33,代码来源:perspetiverectificationwithqt.cpp
示例5: cvNamedWindow
TSDisplay::TSDisplay (char* name){
TSDISPLAYTOCALLBACK = this;
cvNamedWindow(name);
cvSetMouseCallback(name, fon_mouse, 0);
}
示例6: cvSetMouseCallback
void ImgEditWindow::setupCallbacks() {
cvSetMouseCallback(cvGetWindowName(m_window),
&ImgEditWindow::wrapperToOnMouseCallback,
this);
}
示例7: Init
void Init(int argc, char *argv[])
{
capture = cvCaptureFromCAM(CV_CAP_ANY);
if(!capture){
std::cout << "error starting video capture" << std::endl;
exit(0);
}
//propose a resolution
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);
//get the actual (supported) resolution
ivWidth = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
ivHeight = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);
std::cout << "camera/video resolution: " << ivWidth << "x" << ivHeight << std::endl;
#ifdef FORCE_RESIZING
ivWidth = RESOLUTION_X;
ivHeight = RESOLUTION_Y;
#endif
cvNamedWindow("MOCTLD", 0); //CV_WINDOW_AUTOSIZE );
CvSize wsize = {ivWidth, ivHeight};
curImage = cvCreateImage(wsize, IPL_DEPTH_8U, 3);
cvResizeWindow("MOCTLD", ivWidth, ivHeight);
cvSetMouseCallback("MOCTLD", MouseHandler);
}
示例8: main
int main()
{
IplImage* orginal_image=cvLoadImage("3.7.jpg");
assert(orginal_image!=NULL);
IplImage *temp_image=cvCreateImage(cvGetSize(orginal_image),orginal_image->depth,orginal_image->nChannels);
assert(temp_image!=NULL);
cvNamedWindow("Show");
cvSetMouseCallback("Show",my_callback,(void*)temp_image);
while(1)
{
IplImage *temp_image=cvCloneImage(orginal_image);
if(true==g_isdown)
{
high_light(temp_image,g_rect);
Draw_hist(temp_image,g_rect);
}
else
{
high_light(temp_image,g_rect);
Draw_hist(temp_image,g_rect);
}
cvShowImage("Show",temp_image);
if('q'==cvWaitKey(30))
{
break;
}
}
cvDestroyAllWindows();
return 0;
}
示例9: main
int main(int argc, char** argv)
{
/* load an image */
img0 = cvLoadImage(argv[1], -1);
img2 = cvCreateImage(cvGetSize(img0), img0->depth, 3);
int width = img0->width;
int height = img0->height;
huearr = (int*)malloc(width*height*sizeof(int));
toHue(img0, huearr);
cvCvtColor(img0, img2, CV_BGR2HSV);
/* create new window and register mouse handler */
cvNamedWindow("image", CV_WINDOW_AUTOSIZE);
cvSetMouseCallback( "image", mouseHandler, NULL );
/* display the image */
cvShowImage("image", img0);
cvWaitKey(0);
cvDestroyWindow("image");
cvReleaseImage(&img0);
cvReleaseImage(&img1);
cvReleaseImage(&img2);
cvReleaseImage(&img3);
return 0;
}
示例10: setPoints
void setPoints() {
perspectivecount = 0;
cvSetMouseCallback("monitor", perspective_mouse);
while (perspectivecount <= 3) {
int temp = perspectivecount;
cvWaitKey(30);
if (temp < perspectivecount) {
originalPoints[perspectivecount-1] = cvPoint2D32f(perspectiveX, perspectiveY);
}
}
CvPoint2D32f temp;
for (int i = 0 ; i < 3 ; ++i) {
for (int j = 0 ; j < 3-i; ++j) {
if (originalPoints[j].y > originalPoints[j+1].y) {
temp = originalPoints[j];
originalPoints[j]=originalPoints[j+1];
originalPoints[j+1]=temp;
}
}
}
if (originalPoints[0].x > originalPoints[1].x) {
temp = originalPoints[0];
originalPoints[0]=originalPoints[1];
originalPoints[1]=temp;
}
if (originalPoints[2].x > originalPoints[3].x) {
temp = originalPoints[2];
originalPoints[2]=originalPoints[3];
originalPoints[3]=temp;
}
}
示例11: main
int main() {
// Image & hsvImage
//IplImage *hsv;
// Video Capture
CvCapture *capture;
// Key for keyboard event
char key;
// Number of tracked pixels
int nbPixels;
// Next position of the object we overlay
CvPoint objectNextPos;
// Initialize the video Capture (200 => CV_CAP_V4L2)
capture = cvCreateCameraCapture(200);
// Check if the capture is ok
if (!capture) {
printf("Can't initialize the video capture.\n");
return -1;
}
// Create the windows
cvNamedWindow("Test Color Tracking", CV_WINDOW_AUTOSIZE);
cvNamedWindow("Test Mask", CV_WINDOW_AUTOSIZE);
cvMoveWindow("Test Color Tracking", 0, 100);
cvMoveWindow("Test Mask", 650, 100);
// Mouse event to select the tracked color on the original image
cvSetMouseCallback("Test Color Tracking", getObjectColor);
// While we don't want to quit
while(key != 'Q' && key != 'q') {
// We get the current image
image = cvQueryFrame(capture);
// If there is no image, we exit the loop
if(!image)
continue;
objectNextPos = binarisation(image, &nbPixels);
addObjectToVideo(image, objectNextPos, nbPixels);
// We wait 10 ms
key = cvWaitKey(10);
}
// Destroy the windows we have created
cvDestroyWindow("Test Color Tracking");
cvDestroyWindow("Test Mask");
// Destroy the capture
cvReleaseCapture(&capture);
return 0;
}
示例12: main
int main(int argc, char *argv[])
{
if (argc != 2)
{
printf("usage: ./analyzer <cropped_image>\n");
exit(0);
}
IplImage* region = cvLoadImage(argv[1],CV_LOAD_IMAGE_COLOR);
height = region->height;
width = region->width;
step = region->widthStep;
channels = region->nChannels;
img_hsv = convertRGBtoHSV(region);
hsv_data = (uchar *)img_hsv->imageData;
cvNamedWindow("window",CV_GUI_EXPANDED);
cvSetMouseCallback("window", my_mouse_callback, region);
cvShowImage("window",region);
while (key != 'q')
{
key = cvWaitKey(0);
}
printf("%d %d %d | %d %d %d\n", h_min,s_min,v_min, h_max, s_max, v_max);
cvDestroyAllWindows();
cvReleaseImage(®ion);
cvReleaseImage(&img_hsv);
return 0;
}
示例13: getBBFromUser
// TODO: member of Gui
// --> problem: callback function mouseHandler as member!
int getBBFromUser(Mat* mat, CvRect &rect, Gui *gui)
{
window_name = gui->windowName();
img0 = mat;
rect = cvRect(-1, -1, -1, -1);
bb = ▭
bool correctBB = false;
cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 0.5, 0.5, 0, 1, 8);
cvSetMouseCallback(window_name.c_str(), mouseHandler, NULL);
//putText(img0, "Draw a bounding box and press Enter", cvPoint(0, 60), &font, cvScalar(255, 255, 0));
imshow(window_name.c_str(), *img0);
while(!correctBB)
{
char key = cvWaitKey(0);
if(tolower(key) == 'q')
{
return PROGRAM_EXIT;
}
if(((key == '\n') || (key == '\r') || (key == '\r\n')) && (bb->x != -1) && (bb->y != -1))
{
correctBB = true;
}
}
if(rect.width < 0)
{
rect.x += rect.width;
rect.width = abs(rect.width);
}
if(rect.height < 0)
{
rect.y += rect.height;
rect.height = abs(rect.height);
}
cvSetMouseCallback(window_name.c_str(), NULL, NULL);
//cvReleaseImage(&img0);
//cvReleaseImage(&img1);
return SUCCESS;
}
示例14: cvNamedWindow
bool SCSM::annotate() {
cvNamedWindow("image", 1);
cvShowImage("image", &IplImage(img));
cvSetMouseCallback("image", on_mouse, 0);
cvWaitKey(0);
cvDestroyWindow("image");
return 0;
}
示例15: Open_GUI
void Open_GUI()
{
int i;
//Make the eye image (in monochrome):
eye_image=cvCreateImageHeader(cvSize(RESOLUTION_WIDTH,RESOLUTION_HEIGHT), 8, 1 );
eye_image->imageData=(char *)malloc(RESOLUTION_WIDTH*RESOLUTION_HEIGHT);
//Make the eye image (in monochrome):
threshold_image = cvCloneImage(eye_image);
//Make the ellipse image (in RGB) :
ellipse_image=cvCreateImageHeader(cvSize(RESOLUTION_WIDTH,RESOLUTION_HEIGHT), 8, 3 );
ellipse_image->imageData=(char *)malloc(RESOLUTION_WIDTH*RESOLUTION_HEIGHT*3);
//Make the scene image:
scene_image=cvCreateImageHeader(cvSize(RESOLUTION_WIDTH,RESOLUTION_HEIGHT), 8, 3 );
scene_image->imageData=(char *)malloc(RESOLUTION_WIDTH*RESOLUTION_HEIGHT*3);
//Make the grayscale scene image:
scene_image_grayscale=cvCreateImageHeader(cvSize(RESOLUTION_WIDTH,RESOLUTION_HEIGHT), 8, 1 );
scene_image_grayscale->imageData=(char *)malloc(RESOLUTION_WIDTH*RESOLUTION_HEIGHT);
//Create the windows
cvNamedWindow(control_window, 1);
cvNamedWindow(ellipse_window, 0);
cvNamedWindow(scene_window, 0);
cvNamedWindow(eye_window, 0);
cvNamedWindow(original_eye_window, 0);
//setup the mouse call back funtion here for calibration
cvSetMouseCallback(scene_window, on_mouse_scene, NULL);
cvSetMouseCallback(eye_window, on_mouse_eye, NULL);
cvCreateTrackbar("Edge Threshold", control_window, &pupil_edge_thres, 255, NULL );
cvCreateTrackbar("Rays Number", control_window, &rays, 180, NULL );
cvCreateTrackbar("Min Feature Candidates", control_window, &min_feature_candidates, 30, NULL );
cvCreateTrackbar("Corneal Window Size",control_window, &cr_window_size, FRAMEH, NULL );
//Init colors
White = CV_RGB(255,255,255);
Red = CV_RGB(255,0,0);
Green = CV_RGB(0,255,0);
Blue = CV_RGB(0,0,255);
Yellow = CV_RGB(255,255,0);
}