Scinner
Posts: 4
Joined: Mon Feb 13, 2017 10:33 am

Pixel Search, how to?

Mon Feb 13, 2017 10:49 am

Hi there!

Im trying to build a cheap PH-controler for my water resevoir and thought Id do this with the raspberry pi + webcam and a cheap PH-meter :)

Id like to mount a webcam to the PH-meter and have the RPi do a pixel search of the live feed(or saved image) of the webcam to determine what the PH is and based on the info either pump Ph down/up solution in to the tank.

Is there a way to search pixels on the RPi?

I would greatly appreciate all the help I can get!

texy
Forum Moderator
Forum Moderator
Posts: 5161
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Pixel Search, how to?

Mon Feb 13, 2017 10:52 am

Hi and welcome to the forum.
Rather than viewing a display with a camera, why not have the pi read the ph level with a ph probe?
Google will give you a few hits on the hardware required, using a readily available ph probe from eBay, for example.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

Scinner
Posts: 4
Joined: Mon Feb 13, 2017 10:33 am

Re: Pixel Search, how to?

Mon Feb 13, 2017 11:00 am

texy wrote:Hi and welcome to the forum.
Rather than viewing a display with a camera, why not have the pi read the ph level with a ph probe?
Google will give you a few hits on the hardware required, using a readily available ph probe from eBay, for example.
Texy

Thank you, sir!

There also are complete solutions for PH-controlling.
The thing is that I want to do it as cheap as possible and I have a RPi, webcam and PH-meter so by doing it this way it would be free for me!

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Pixel Search, how to?

Tue Feb 14, 2017 3:05 pm

What kind of output does the Ph-meter give ? a number on a LCD-screen ?

If that is the case you are basically trying to do OCR. And that is a pretty large subject.
There is a open source OCR library called Tesseract that might be usable for you.

Example tutorial for License Plates.
https://www.youtube.com/watch?v=lNzSWLwaixw

Scinner
Posts: 4
Joined: Mon Feb 13, 2017 10:33 am

Re: Pixel Search, how to?

Tue Feb 14, 2017 3:44 pm

topguy wrote:What kind of output does the Ph-meter give ? a number on a LCD-screen ?

If that is the case you are basically trying to do OCR. And that is a pretty large subject.
There is a open source OCR library called Tesseract that might be usable for you.

Example tutorial for License Plates.
https://www.youtube.com/watch?v=lNzSWLwaixw
Yes a 3 digit number.
I was thinking that I could just do somekind of "pixel get color" on one pixel in each digit segment. Each digit got 7 segments and if the segment is lit it's black and if not lit its green. Then through som logic statments get the reading I want. A working OCR would be a bit overkill to use.

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Pixel Search, how to?

Tue Feb 14, 2017 4:38 pm

If you have at all time 100% control of the relative position of the camera and PH-meter and the lighting in the room then your method might also work.

Any picture grabbed to memory from camera or read from a file (and decoded if its a jpeg/png) is then just a big array of values. You search through them on the Pi the same as on any other machine if you plan to make your own software.
You need to know how the RGB pixels are organised in that array to find the color value or a certain position.

example:
I have an 8bit RGB picture of size 320x200 pixels, each pixel is then 3 bytes.
The size of the memorybuffer (array) is then 320*200*3 = 192.000 bytes.
I know that the first 3 bytes is the pixel in the top left corner of the image and the next is the next pixel on the right.

To find the color of a pixel on position 15 (from left edge) and 33 (from the top) I have to do simple math, I read 3 bytes at position ( 33*320 + 15 )*3 = 31725.
How to do something useful with those 3 bytes is another discussion, if you simply want to differentiate between light and dark its often enough to use the Green value.

Scinner
Posts: 4
Joined: Mon Feb 13, 2017 10:33 am

Re: Pixel Search, how to?

Tue Feb 14, 2017 5:32 pm

I'm going to build somekind of camera housing fastened over the LCD with a led illuminate the LCD.

The calculating way also seems interesting! I have to read up about that. Thanks!

Return to “General programming discussion”