Use camera (photo) to measure distances ( and area)

Hi
I have an idea and I don't know how to do it with App inventor

I want to measure distances by taking pictures with camera, in example, I will take photos like in this uploaded image, the distance of the blue ligne is known, and I ask the app for detecting and measuring the red ones.
Can I do it?

1 Like

This is a similar discussion regarding measuring from a Camera image; it might give you some ideas

A way to measure distance within a Canvas (thanks to Pythagoras ) Perhaps it can be adapted to your needs?

I have put together a quick demo of what you might do.

Assumptions

  1. petri dish is 100mm in diameter
  2. Image is cropped square to the edges of the petri dish

DESIGNER SCREENSHOT

BLOCKS

AIA
petriDistances.aia (477.3 KB)

VIDEO (go full screen for better output)

I used a stylus on my smartphone to be able to see the smaller circles to move them around. This could be scaled up for a tablet.

3 Likes

Another potential technique to measure distance. This uses the center point of Canvas Balls.


petriDishCalculation3.aia (132.8 KB)

Make measurements from an image where the dimensions of an object are known.

This works when the objects are ALL in the same plane (parallax is an issue when objects are behind your reference measurement.)

Use the black and red balls working together for measurement and use the fine control to increase 'resolution'. The center of the ball is the measurement point. The balls are translucent so it is possible to move a ball to nearly the exact point you need.

Balls can be dragged to initial measurement location point. The Red and Black locations can be fine tuned, LongPress on central "joystick" block selects changes between movement of the red or black ball.
Use the green and violet balls working together for measurement too but fine movement control of the balls is not available in the example.

Example petri dish image is 467 x 464 pixels. The radius of a ball set at 10 pixels. When you measure the diameter of the petri dish you get a result of 446 pixels; however, since the ball cannot move out of the canvas, add 10 pixels twice so the result is really 466 pixel across the diameter of the petri dish. This is fairly good precision. Check the calibration by measuring the red 100 pixel scale bar. Use the 'red and black' balls together.

Regards,
Steve

2 Likes

Hi SteveJG. I want to ask you about this subject. Can we use in transparent png or jpg, with a grid to overlap the image, so you can measure easily with quadrants? if you know the size of the object and the size of the grid, you can make a calculus of what area is occupied or not.
I think we can add the grid as optional with a switch.
I ask this because in geology we use a grid in the microscopy for COUNTING minerals.

Sure.

I would provide the grid in a large sprite that is transparent/translucent ( because the image is the background already).

Here is how to use a grid to estimate area Dot planimeter - Wikipedia
Percentage abundance Untitled

1 Like

That's the idea SteveJG!. Perfect. I was thinking in this kind of grid, also, we COULD use (my old idea of StereoNET) like a Wulff Net, equi angular or... MAYBE is more suitable for this kind of project --> the schmidt net (equi AREAL)!, because is EQUI AREAL, you can measure AREAS.
Anyway. I was thinking for this project an overlapping transparent png in the camera section and take only what is in the circular shape. So the area inside the circle could be easily measure.

This is possible using a transparent grid image in a Sprite as in this example using your idea.

The area of a circle can be calculated Area = π × r2 or by counting the grid dots overlaying the object in the image. :astonished: The existing example can determine r in pixels easily. You then need to provide code to scale pixels to to cm or cm2.

Sorry, I don't understand how you expect to determine areas with a stereo net etc. Might be possible but I think there are easier ways.

You have some interesting ideas. If you have difficulty implementing your Projects, open a new thread and the community will provide suggestions.

think you a lot, I will try it

Another way to calculate the area is by using a set of coordinates for its perimeter.

Area.aia (159.6 KB)

https://www.mathopenref.com/coordpolygonarea.html

The calculation can be done using blocks, to simplify it I have used an extension:

1 Like

Take a look at the program ImageJ, maybe it help you.

Hi Steve. I couldn't reply in time because personal health problems.
Well. About the Stereonets with schmidt net, you can measure Great Circles. all this circles have an Equal (same) area, so you can be sure the size of a part in a circle adding parts of this areas. Is like a grid (but ONLY MORE COMPLEX TO IMPLEMENT).
I was thinking we can overlap like a skin the grid or the great circles and take a snapshot of the screen (adding a button to do it), and then you can make the adding of the areas. (you have the screen to backup if you want with this).
But the grid is a fine idea. If we can overlap a grid, is a great solution.
Well. I do not take more time.
I am in debt with you. (i remember i will share Dulce de Leche from Argentina), but the project didn't evolve (you help me a little but i coudn't continue because many factors -example of this the math of a stereonets)... even i debt the dulce to you :smiley:
I want to share some of other projects related to compass and geological apps.
How can i contact with you? i do not want to disturb others, in others post i mean.
I have a earthquake alert app in motion, and a religious one too.
BUT i am stuck.
So...
Write me if you can.

I hope you are feeling better German.

Yes, we can overlap a grid on a Canvas. See post #8 :astonished: and this example:
Distance_and_AreaOnACanvaas.aia (153.4 KB) . I got the grid working but did not implement the code to transcribe pixel area and distance to meters or English units; you can do that.

I think that is too complicated. You can overlap a transparent Stereo net and Schmid net if you like using similar coding. If you really need to do some complex Math, you might try App Inventor Extensions: Math Parser | Pura Vida Apps in your app.

OK. You can start a new topic in the community under General Discussion or MIT App Inventor Help.
newTopic2
The community will be glad to help. :slight_smile: Post your questions or just ask for help developing them. I and others will help.

Start a discussion regarding earthquake detection using App Inventor( or any other topic) . Do that and I will post some code and links to an earthquake app.

Oh my. I certainly appreciate. Several weeks ago my wife and I visited an Argentine restaurant in Dallas. They had dulce de leche but not quite as I had while visiting your beautiful country years ago.

--Steve

2 Likes