Ask Your Question
0

Software synthesizer interface detection (lines inside of circles)

asked 2019-09-13 06:14:11 -0600

Hello world!

This is my first experience with Open CV. What an amazing library. I was able to do a lot already in only a couple of hours!

I am working a small python open cv program to detect the state of a software synthesizer. So far I have been able to detect the state of ON-OFF switches, using matchTemplate. Also I can detect circles around the potentiometers. But what I still need is to detect the orientation of the potentiometers. I was thinking about using HoughLines within the boundaries of the circles, but so far no luck.

I also have access to the bitmaps of the interface as .png (see images for both extremities), unfortunately I was not able to use matchTemplate as the image doesn't have the background ? Or because its not square ? If I could detect the "partial" image and its rotation it would be also great.

Any tips or examples ? Thanks so much in advance!

Nicolas.

image description image description image description

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2019-10-08 09:21:08 -0600

nicolasabril gravatar image

You could use matchTemplate or a similar method after masking both images to only the actual knobs.

You can decide which type of knob it is by comparing histograms. Then separate the ROI around the knob, mask it to only the circle, scale the templates to the correct size (not necessary if you're using a scale-invariant matching) while also masking only the actual knobs and try to match them.

Another thing that would probably work pretty well is using a cascade classifier, trained to the template images masked to only the knobs.

edit flag offensive delete link more
0

answered 2019-09-17 15:18:57 -0600

OpenCV has a couple techniques you can try and there is another that I don't think is in OpenCV.

warp polar

I cropped a single dial and used extract channel and threshold to get the circle you detected. See the 2nd and 3rd images below. Use this circle in Opencv's warp polar function to "unwrap" the circular dial image into a rectangle. Then search the rectangle for the dial line as the brightest horizontal region in the 4th image below. I have used this in the past to find dials on clocks and meters.

image description

mask + threshold + line detect

Create a mask (3rd image below) of the circle detected with Opencv's circle drawing function or floodFill function. Use this mask to extract the interior of the dial. You can use copy function with a mask for this. Find the brightest pixels in the masked image (4th below) and use Opencv's fitLine function to get the dial line.

image description

Circle stepping

Use the Bresenham or Midpoint circle algorithm to step around concentric circles whose radii are less than what you have detected. When you find the dial line as the largest intensity, store this point in a list. Use the list to find a best fit line. I don't think Opencv has a circle iterator that implements either of these stepping algorithms. You could try to use OpenCV's ellipse2Poly function but it gives you a sequence of points that define polyline that approximates an arc or circle. This may be good enough.

edit flag offensive delete link more

Comments

Thank you so much Chris, I haven't thought about that, I will asap!

Awesome that you tried it yourself!

nicolas_soundforce gravatar imagenicolas_soundforce ( 2019-09-19 08:38:24 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-09-13 06:13:11 -0600

Seen: 338 times

Last updated: Oct 08 '19