First time here? Check out the FAQ!

Ask Your Question
-1

Detect only a part in a video input [closed]

asked Sep 18 '18

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.

Preview: (hide)

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

Comments

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 (Sep 18 '18)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 (Sep 18 '18)edit

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

berak gravatar imageberak (Sep 18 '18)edit

ill try to reply asap im trying something currently

uraqtlee gravatar imageuraqtlee (Sep 19 '18)edit

1 answer

Sort by » oldest newest most voted
1

answered Sep 18 '18

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
if(!cam.isOpened())
{
    cout<<"error camera failed to open ! "<< endl;
    return -1;
}   

while(1)
{
    Mat img, img_roi, mask;
    bool success = cam.read(img);

    if(!success)
    {
        cout<<"error cannot read image ! "<<endl;
        return -1;
    }

    img.copyTo(mask);

    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)
        break;

}
}
Preview: (hide)

Comments

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

ak1 gravatar imageak1 (Sep 18 '18)edit

i think this should work with my project, thanks.

uraqtlee gravatar imageuraqtlee (Sep 19 '18)edit

Okay. Welcome!!

ak1 gravatar imageak1 (Sep 20 '18)edit

Question Tools

1 follower

Stats

Asked: Sep 18 '18

Seen: 229 times

Last updated: Sep 18 '18