How do you read the value of image in real time?

I want to write an APP that uses a camera to take pictures and read the RGB values of a selected point or area in real time.

The further step is to draw this value as a curve over time and even send it to a computer or other device via Bluetooth or other means.

I am new to Appinventor and wonder if it is possible to write such an APP.

Thank you!

Use:

  • the camera component for taking pictures,

  • the canvas component to show the image,

  • when the canvas is touched, also use the canvas to get the pixel color of the point, from the x and y coordinates,

  • split the color, and you have a list, with the first item as the R value, second item as the G value, third as the B value and maybe, the fourth being the alpha value. The fourth item may not exist.

1 Like

Very thanks!

Here are some things that you need to know. The Do It Result is the value that it will return, or show.

App Inventor colors.

Color blocks in App Inventor have their own drawer, separated from Math, but color blocks are really just numbers. App Inventor uses numbers to represent colors. For example, the color Red is just -65536.

image

However, you can also split a color to make it an RGB list. In the list, the first item is the R value, the second item is the G value, and that the third value is the B value. There might be a fourth value, which is the Alpha value, which decides how bright a color should be.

image

From this list of 255, 0, 0, 255, the RGB value is (255, 0, 255). If you want to get a specific value, such as B, you can use:

image

because the B value is the third item in the list.

With that knowledge, here is a demo.

Thank you. It's very helpful.

1 Like

What should I do if I want to take pictures continuously, just like a video?

My purpose is to obtain the change of pixel value in a certain area of the image over time, that is to say, the image is always changing.

Thanks.

There is a Camcorder component in the Media drawer that takes videos. Is that what you want?

However, the camera can only carry out the next operation after recording.
What I want is real-time, just like when face recognition, there is always a box on the face.

I think you need a paid extension for that. This extension by Taifun takes pictures without user interaction, and you can take pictures with this extension anytime.

Thank you.

I looked at this extension and it said that it takes a few seconds to take a picture, which is too long. What I need is real-time like face recognition.

this is what you are looking for

1 Like

That is the best solution that I know. App Inventor currently does not have real-time surface view.

Thank you for your advice.

I looked at it and it didn't seem to meet my requirements.

My goal is to write an app to monitor the brightness or pixel change of an area of the image through the camera.

Above @ [gordon_lu]( Profile - Gordon_Lu - MIT App Inventor Community )It gives good suggestions, but the speed of obtain photos is too slow. It's not what I want. What I want is the speed of obtaining images like the camera.

Thanks again.

Thank you very much. I'll try to find another solution.