How to use Similarity

I have an application where I’m trying to automate taking a melting point. I have a small capillary tube that contains a small amount of a chemical I want to take the melting point. The microprecessor controls heating the tube and I get the temperature from an LM-35 connected to the ADC. I want to use the camera to compare a snapshot of the tube (with chemical) before melting - basically a small tube with some powder inside - usually white. So the 1st image is the un-melted sample - call it image1. The tube is heated and another snapshot is taken - image2. I want to compare the two using image2.get_similarity(image1) and use the value as a trigger to decide if the sample has melted. Image2 will be the same as Image1 (a value for similarity close to 1) until the sample begins to melt. When it melts the sample will turn into a liquid and the similarity value should change to something much less than 1.

The program runs fine but the similarity values are always 1 even when I hold up something completely different in front of the camera (like a pencil).
So I must not be using “get_similarity” correctly.

Any suggestions?

Don’t use that method. It is really just good at telling how bad jpeg compression is.

Do this, use frame differencing, then to suppress noise in the frame differenced image use the mid_point filter with the bias set to 0 to zero most of the pixels in the image. Then use get_stats()/get_histogram() to get the color stats, then look at the change in this. The frame differencing examples show off how to do this all expect the mid_point filter steps. I suggest adding it since it heavily removes noise.

Thank you for the suggestion. I’m working with in now and I think it will work as you suggest.

The first time I ran the program it worked and I made a few modifications. When I try to run it now I get an error on line


The error is “images not equal”

I tried extra_fb.deallocate() but still get the same error. How can I fix this?


I figured out what I did wrong. I changed the sensor in 1 place to GRAYSCALE but didn’t change it in the allocate statement.
It’s working.