Ask Your Question

Detect only a part in a video input [closed]

asked 2018-09-18 01:36:38 -0500

uraqtlee gravatar image

Hi, I'm currently making a text detection program similar to this : video As you can see the detection only works in that yellow portion. How do I make it so that my program only checks that part of the box? I'm doing it in C++ by the way.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by uraqtlee
close date 2018-09-19 10:05:00.766362


please rather attach an image, than a useless link to a external video.

also: what have you tried, so far ? do you have any code ? show us !

berak gravatar imageberak ( 2018-09-18 02:05:42 -0500 )edit

its just a simple text recognition program where it reads words through a video, but since it is detecting the entire screen capture it won't be as accurate, so what I'm trying to do is make the program just read a specific part of the video similarly to the video I linked.

uraqtlee gravatar imageuraqtlee ( 2018-09-18 03:15:33 -0500 )edit

again, your video is useless here. and we can only help, if you show us something apart from that.

berak gravatar imageberak ( 2018-09-18 03:28:20 -0500 )edit

ill try to reply asap im trying something currently

uraqtlee gravatar imageuraqtlee ( 2018-09-18 23:03:12 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-09-18 03:41:22 -0500

ak1 gravatar image

@uraqtlee You can do like this,

#include "opencv2/imgproc/imgproc.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main()

VideoCapture cam(0); //change index accordingly
    cout<<"error camera failed to open ! "<< endl;
    return -1;

    Mat img, img_roi, mask;
    bool success =;

        cout<<"error cannot read image ! "<<endl;
        return -1;


    int width = img.cols;
    int height = img.rows;

    Rect roi(width/2 - 100, height/2 - 100, 200, 200); // set roi for rectangle according to your choice

    rectangle(img, roi, Scalar(255,0,0), 2, 8, 0); // draw rectangle using above roi
    img_roi = mask(roi); 

    imshow("img", img); // showing orignal image with rectangle
    imshow("img_roi", img_roi); // showing image in the rectangle

    //now process img_roi image for further text detection processing.

    if (waitKey(3) == 27)

edit flag offensive delete link more


Whatever I have understood from your question and video. I have written my answer accordingly.

ak1 gravatar imageak1 ( 2018-09-18 03:44:44 -0500 )edit

i think this should work with my project, thanks.

uraqtlee gravatar imageuraqtlee ( 2018-09-19 10:04:45 -0500 )edit

Okay. Welcome!!

ak1 gravatar imageak1 ( 2018-09-19 23:47:16 -0500 )edit

Question Tools

1 follower


Asked: 2018-09-18 01:36:18 -0500

Seen: 123 times

Last updated: Sep 18 '18