C# OpenCV在摄影机流窗口中设置ROI

C# OpenCV在摄影机流窗口中设置ROI,c#,opencv,C#,Opencv,我想用相机拍摄的图像在窗口中设置感兴趣的区域。。怎么做? 我正在将C与OpenCVSharp和Visual C一起使用 诸如此类: using (CvCapture cap = CvCapture.FromCamera(0)) // device type + camera index using (CvWindow v = new CvWindow("Live Stream")) while (CvWindow.WaitKey(10) < 0) {

我想用相机拍摄的图像在窗口中设置感兴趣的区域。。怎么做? 我正在将C与OpenCVSharp和Visual C一起使用

诸如此类:

using (CvCapture cap = CvCapture.FromCamera(0)) // device type + camera index
using (CvWindow v = new CvWindow("Live Stream"))
while (CvWindow.WaitKey(10) < 0)
            {
                using (IplImage src = cap.QueryFrame())
                v.Image = src;
              // Then set ROI and send it to picturebox
                pictureBox.Image = BitmapConverter.ToBitmap(ROI);
            }
使用(CvCapture cap=CvCapture.FromCamera(0))//设备类型+摄像机索引
使用(CvWindow v=新CvWindow(“实时流”))
while(CvWindow.WaitKey(10)<0)
{
使用(IplImage src=cap.QueryFrame())
v、 Image=src;
//然后设置ROI并将其发送到picturebox
pictureBox.Image=BitmapConverter.ToBitmap(ROI);
}

我会在图像顶部创建一个矩形,下面的内容可能会有所帮助

使用创建的矩形裁剪选定区域:

    Rectangle cropArea new Rectangle(0, 0, 10, 10);  
    Bitmap bmpImage = new Bitmap(img);
    Bitmap bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);

我会在图像的顶部创建一个矩形,下面可能会有所帮助

使用创建的矩形裁剪选定区域:

    Rectangle cropArea new Rectangle(0, 0, 10, 10);  
    Bitmap bmpImage = new Bitmap(img);
    Bitmap bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);
我不知道C语言,但我将如何在C++中使用OpenCV 2。希望翻译很容易。语句
matroirect=frame(Rect(200100100))
创建一个标头,该标头与
共享数据,但仅在感兴趣的区域中

using namespace cv;

int main(int argc, const char * argv[]) {

    VideoCapture cap; 
    if(argc > 1) 
        cap.open(string(argv[1])); 
    else 
        cap.open(0); 
    Mat frame; 
    namedWindow("video", 1); 
    for(;;) {
        cap >> frame; 
        if(!frame.data) 
            break; 

        //Create the region of interest
        Mat roiRect = frame(Rect(200,200,100,100));
        //Do something with the region of interest
        roiRect *= 0.4;

        imshow("video", frame); 
        if(waitKey(30) >= 0) 
            break;
    }

    return 0;
}
我不知道C语言,但我将如何在C++中使用OpenCV 2。希望翻译很容易。语句
matroirect=frame(Rect(200100100))
创建一个标头,该标头与
共享数据,但仅在感兴趣的区域中

using namespace cv;

int main(int argc, const char * argv[]) {

    VideoCapture cap; 
    if(argc > 1) 
        cap.open(string(argv[1])); 
    else 
        cap.open(0); 
    Mat frame; 
    namedWindow("video", 1); 
    for(;;) {
        cap >> frame; 
        if(!frame.data) 
            break; 

        //Create the region of interest
        Mat roiRect = frame(Rect(200,200,100,100));
        //Do something with the region of interest
        roiRect *= 0.4;

        imshow("video", frame); 
        if(waitKey(30) >= 0) 
            break;
    }

    return 0;
}