相关疑难解决方法(0)

使用鼠标从视频上的矩形设置ROI

我有视频,当程序运行时,视频的第一帧被视为一个图像,并允许用户在图像上绘制一个矩形,绘制矩形后,用户必须右键单击图像以确认矩形.当鼠标右键单击时,图像消失,视频开始播放,其上绘制的矩形.

我能够完美地绘制矩形,但我无法将该矩形设置为ROI.

我想要做的是将该矩形设置为感兴趣区域(ROI),以对该ROI进行一些图像处理.我无法将我绘制的矩形设置为ROI.

我在Visual Studio 2010中使用OpenCV.稍后我将尝试将此程序集成到QT创建者中.

任何帮助,将不胜感激.

提前致谢.

我的完整代码如下:

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include<opencv2\opencv.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv/highgui.h>
#include <opencv/cxcore.h>
#include <opencv\cvaux.h>

using namespace cv;
using namespace std;
void my_mouse_callback( int event, int x, int y, int flags, void* param );
bool destroy=false;
CvRect box;
IplImage* image;
IplImage* frame2;
bool drawing_box = false;

void draw_box( IplImage* img, CvRect rect)
{
cvRectangle( img, cvPoint(box.x, box.y), cvPoint(box.x+box.width,box.y+box.height),
            cvScalar(0,0,255) ,2);

CvRect rect2=cvRect(box.x,box.y,box.width,box.height);
//cvSetImageROI(image, rect2);   //here I wanted to set …
Run Code Online (Sandbox Code Playgroud)

c c++ opencv image-processing computer-vision

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

c ×1

c++ ×1

computer-vision ×1

image-processing ×1

opencv ×1