Ask Your Question
0

Extract and detect line

asked 2019-04-20 13:27:38 -0600

colx gravatar image

I need to extract a red laser line on an object from an image with python. I want to use the shape of the line to determine if the object is flat or tapered, and if it's tapered, on which side. In what way can I do it, can you post some example code?

laser line image

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-04-24 14:03:06 -0600

OpenCV has great tools to solve this. Extract the red channel from the color image (2nd image below). Threshold this image with a threshold value of about 220 (3rd image below). Do a couple rounds of dilation to fill in holes left by threshold (4th image below) After this, get the contours and pick out the top one (smallest center y value). Divide this top contour in half to get 2 contours - a left side and a right side. Then look at the aspect ratios of these 2 contours. A flat line will have a larger wd/ht ratio.

image description

edit flag offensive delete link more

Comments

Thank you very much, I'm going to do code tests in python, I post it when I have an advance

colx gravatar imagecolx ( 2019-04-24 14:37:10 -0600 )edit

Do you have python code for this

Raghunath gravatar imageRaghunath ( 2019-05-28 05:25:11 -0600 )edit

No, these results came from another, larger c++ program

Chris gravatar imageChris ( 2019-05-31 07:36:59 -0600 )edit

Chris Here is my python code Could you share c++ program so that i will convert to python if anything missing. I know c++ opencv too

Raghunath gravatar imageRaghunath ( 2019-05-31 12:40:22 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-04-20 13:27:38 -0600

Seen: 2,406 times

Last updated: Apr 24 '19