I would like to calculate the volume of a cup placed in front or below a camera, for example how much liquid can go in the cup in terms of ml, any idea where I can start? can OpenCV do such a calculation,
any help would be appreciated.
I would like to calculate the volume of a cup placed in front or below a camera, for example how much liquid can go in the cup in terms of ml, any idea where I can start? can OpenCV do such a calculation,
any help would be appreciated.
Determining the size of objects from images is an underdetermined problem, since the image formation process discards depth information.
So, in general, the answer to your question is no, you cannot compute the size (or volume) of a cup in general.
But you might be able to do this if you add more information about the setup:
You can use a depth camera or a stereo camera to get depth information. With this, you can estimate the size of the cup. And if you assume that the cup is cylindrical (or some regular shape), you can compute its volume with some 3D geometry.
If you have the camera fixed and you place the cup at a known distance, you can do the same as above.
If different cups have some distinctive marks (e.g. handle colors), you can look for that.
Simply detecting the cup is doable. Getting size information is the difficult part.
Are there any constants in that scenario? If possible Iād have some object of reference in the shot. (e.g. a ruler) then you could measure how many pixels equal a centimeter and estimate the volume by measuring height and diameter to calculate the volume of your approximation (e.g. cylindrical).