Ask Your Question
0

Detect objects in real time video with least latency

asked 2019-09-17 06:24:00 -0500

saurabh162 gravatar image

updated 2019-09-17 09:01:32 -0500

Witek gravatar image

Dear Developers,

I am require to meet requirement of one of my project using OpenCV. I am beginner in this field and gained basic knowledge in this field by reading and watching online tutorials .

Before i start with implementation of my project I want to have guidance from you about efficient methods/ ways in Opencv, I can use to meet requirement of my project.

Below I have written a brief overview of project and steps I think I will take to meet requirement of project. Kindly inform me if you have some better ideas to solve the requirements I have in my project.

Project: In my project I will be dealing with human machine interaction. In which work area will be painted similar to chess board:

image description

and 2D camera will be mounted on top of work area to give real time video about activity happening in this work area.

Additionally, in this system a robotic hand can enter work area only from a1 to h1 edge or from a8 to h8 edge of board with some tool as given in figure:

image description

So in above given system I need to detect whenever anything (example robotic hand) enter in given work area (from edge a1 to h1 or/and from edge a8 to h8 ) and inform main system about it, with the cells covered by appeared object (example c1 to e1 in above case) in terms of alphabets and numbers.

Moreover, in this system it is not important to recognize what has been detected on work area but it is important to inform main system about presence of new object between a1 and h1 orand a8 and h8 boxes with cells covered by it with minimum possible latency (maximum latency allowed is 10 ms as frame rate of our camera is 90 fps).

In order to solve above problem, I can guess following steps.

  1. Segment given work area (chess board ) on the basis of black and white boxes and name them in terms of alphabets and numbers and save it in system memory.

  2. Store photo of work place (without any object) as a reference

  3. Compare (may be using logical and operator) cells a1 to h1 and a8 to h8 in each incoming frame from camera with reference photo of work place taken in step 2 and inform system whenever there is any change in these cells above some threshold value (e.g 0.5)

Question related to above task

  1. Whether above steps decided by me is correct to accomplish this task or whether I can achieve this task by taking some other steps more efficiently?

  2. How to segment work place on the bases of black and white boxes and thereafter name them in terms of alphabets and numbers and then save it in memory?

  3. What is the efficient way to mask complete work place and observe only cells between a1 to h1 and between 8a to 8h?

  4. Whether “logical and operator” will be correct choice to compare frames we are getting from ...

(more)
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2019-09-17 18:18:54 -0500

Witek gravatar image

updated 2019-09-17 18:29:45 -0500

Generally you are correct. Here is a few hints:

If the chessboard is stationary you do not have to detect it automatically - you can do it once manually and crop the area of interest, like so: croppedImage=wholeImage(Rect(x, y, width, height));

Instead of logical AND use subtraction and thresholding - this will let you ignore minor changes in pixels' brightness or color. Count non zero pixels - if their number exceeds some threshold, you probably have some object in the field of view. Find contours and bounding rectangle. Or iterate through all white pixels and find the leftmost and the rightmost ones - I think it might be faster than finding contours and bounding box, but contours still should run in less than 10 ms (provided you don't get hundreds of separate pixels). Either way you know the left and right boundary of your object, so you know where it is in terms of squares (as you know where the squares are).

Look at these two sites to learn about OpenCV:

https://www.learnopencv.com/

https://www.pyimagesearch.com/

edit flag offensive delete link more

Comments

Thank you very much Witek for your help :)

saurabh162 gravatar imagesaurabh162 ( 2019-09-18 03:39:51 -0500 )edit

@Witek can you please suggest me some effective and efficient way using which I can find and save location/coordinates of each square in my chess board and save it in some datastructure at the start of my program.

As presently I am able to detect object on my chessboard and draw bounding rectangle around them as you mentioned and now my next task is to compare object coordinates with coordinates of squares on my chessboard and find location of object in terms of square boxes on chess board. Please inform me if you need any other information from me. Thanks :)

saurabh162 gravatar imagesaurabh162 ( 2019-09-26 02:47:15 -0500 )edit

findChessboardCorders will detect the chessboard and store the square coordinates for you

Witek gravatar imageWitek ( 2019-09-30 19:09:08 -0500 )edit

@Witek many thanks for your help...I will use "findChessboardCorners" function to find square coordinates..

saurabh162 gravatar imagesaurabh162 ( 2019-10-01 04:06:11 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-09-17 06:24:00 -0500

Seen: 60 times

Last updated: Sep 17