Thresholds

Discussion related to "under the hood" OpenMV topics.
HarryWeston
Posts: 5
Joined: Wed Aug 23, 2017 9:56 am

Thresholds

Postby HarryWeston » Wed Aug 23, 2017 10:31 am

I am new to openmv and confused by seeing the use of thresholds everywhere but I can't find any documentation on the subject. Can someone please point me to where I can find thresholds explained? I would like to know: what they are used for; why they are used; how to define and use them; and what the parameters are. Apologies if I have missed something obvious.
User avatar
kwagyeman
Posts: 1175
Joined: Sun May 24, 2015 2:10 pm

Re: Thresholds

Postby kwagyeman » Wed Aug 23, 2017 12:36 pm

Hi, yeah, sorry about the lack of documentation... That's not going to be fixed for a little while.

Um, please see the Tools -Machine Vision -Threshold editor in OpenMV IDE. This will let you pick LAB or grayscale thresholds using OpenMV IDE. That is, if you are doing something involving color tracking.

As for other thresholds on functions, so please understand that when working with computer vision methods you have to tune parameters to get the best results. When you see things like the threshold for find lines it's used to filter out how many detections you want.

Um, I can answer better if you can ask a more specific question. Please let me know where exactly you need help.
Nyamekye,
HarryWeston
Posts: 5
Joined: Wed Aug 23, 2017 9:56 am

Re: Thresholds

Postby HarryWeston » Wed Aug 23, 2017 2:34 pm

Thank you for that prompt reply. And thank you and all those involved for producing this system and making it freely available, we amateur experimenters are very fortunate to have such clever facilities to use and save us a lot of work if we didn't have them. Very much appreciated. My project is a die rolling machine to test the fairness of deliberately loaded dice for statistical experiments. I'm giving a talk on some aspects of statistical analysis in November. So I want to use my Openmv Cam M7, just received, to to be able to count the black spots on a white die on a black background. Of course the exact shades of back and white will vary according to the lighting, and the orientation of the die and its location on the image will vary randomly from roll to roll. I will be grateful for any help.
HarryWeston
Posts: 5
Joined: Wed Aug 23, 2017 9:56 am

Re: Thresholds

Postby HarryWeston » Wed Aug 23, 2017 3:03 pm

Further to my post just now, I am trying out the "single_color_grayscale_blob_tracking_2.py" from the examples which puts a white rectangle round the white die. I need to adapt it to pick out the pips on the die itself. Again I would be grateful for any help in achieving this.
User avatar
kwagyeman
Posts: 1175
Joined: Sun May 24, 2015 2:10 pm

Re: Thresholds

Postby kwagyeman » Wed Aug 23, 2017 4:50 pm

Okay, cool. Yeah, so, please use the histeq() method on the image to stabilize the contrast after turning white balance and autogain off. Then you should see a very contrasty image. After which, open the threshold editor from OpenMV IDE. It's under tools/machine vision.

Once you so that you'll be able to drag some sliders for grayscale mode to select the grayscale thresholds to detect the die.

Not that doing what you want is easy and needs to be done in two steps. First you want to find all of the die ROIs. This means the first threshold looks for all the dies in the image against the background. Then once you have those ROIs you then call find blobs again with a new threshold for the pips on the die targeting just the die ROIs. Finally, you only want to count pips which aren't connected to the edge of the die because that might be the background.

I can write a simple piece of example code for you but it will take a while because I don't have time right now.
Nyamekye,
HarryWeston
Posts: 5
Joined: Wed Aug 23, 2017 9:56 am

Re: Thresholds

Postby HarryWeston » Wed Aug 23, 2017 6:02 pm

Thanks for that advice, looks good. It's late here in UK now, I'll try it out tomorrow. And thanks for our time and trouble in responding to my request, much appreciated.
HarryWeston
Posts: 5
Joined: Wed Aug 23, 2017 9:56 am

Re: Thresholds

Postby HarryWeston » Thu Aug 24, 2017 5:35 pm

After a day on this, and following your advice, I am well on the way to solving the problem, again thank you very much for you help.
User avatar
kwagyeman
Posts: 1175
Joined: Sun May 24, 2015 2:10 pm

Re: Thresholds

Postby kwagyeman » Fri Aug 25, 2017 12:05 am

Let me know if you need anything else. :)
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest