How du calculate the volume of sand filled in a box with a camera - computer-vision

I have a box with a known volume. This box is filled with sand. Is it possible to calculate the volume of the sand?
I'm thinking about cameras around this box making a picture and generating a point cloud to calculate the content.
Has anyone done something like that before or has anyone an idea how I can do that?

Related

Map real world height to point cloud height

I have a point cloud that consists of a cube on a table. I'm currently trying to filter out everything except for the cube in the point cloud. Given the table height in reality and the camera pose and intrinsics, is there a way to know the coordinate of the table's bounding box so that I could filter out everything else? Thank you in advance!

how to detect a bin / box in pcl?

Hello I am new to PCL (point cloud library) and my task is to detect 3d objects in a box / bin using surflet pairs using kinect. I am able to segment and cluster some of the objects but my algorithm also detects the box as a segment. I want to know how can I detect and remove only the box in the scene ?
should I use PCA or SIFT ?
Thank you,
Saransh Vora
You could run a planar ransac and subtract all points that belong to planes of sufficiently large sizes. An additional specification would be to only subtract out planes that have a normal vector at nearly 90 degrees from unit-z. This would allow you to search for smaller planes without fearing cutting your objects in your box too badly as it would make your filter highly specific to vertical planes.
Another note, if your box doesn't move... you could just save your (empty) point cloud ie the cloud when there are no objects in the box and then when you get a new cloud use that saved cloud as a proximity filter to cut out all points which are sufficiently close to what was labeled as background.

Detecting an open door in a RGB-Image using a kinect and OpenCV

I need to be able to identify an opened door in an image taken from a kinect camra mounted on a robot.
The problem is that most of the time the image won't capture the entire door but only the lower half.
So I can't just train a HOG detector for doors because it would need to be trained on the entire door frame.
I am also able to get the whole range of kinect depth images. Would it be possible to look for something like a "hole in the wall" an assume that is a door?
I recently found this algorithm on the net.
http://docs.opencv.org/master/d1/dee/tutorial_moprh_lines_detection.html#gsc.tab=0
Now that I am able to reliably identify verticl edges in the picture, i can check them against my depth senosr data, to see if they are edges of an open door.
E.g.: if the depth to the right of the edge is far greater than on the left, its probably the left edge of the door.
With this i can identify the area "door" pretty acuratly.
I hope this can help someone else as well.

OpenCV: selection of contours in a processed image

I'm a newbie in OpenCV, and I want to know if you could select a contour in a processed image, for example, you are detecting 1 circle 2 squares and 1 triangle, and you want to know the distance between the triangle and 1 square right now, so i wish to know if you can select the figures in the processed image with a mouse instance or something like that, also, change the selection, like if i want to know the distance between the circle and square or circle and triangle, something like it. I don't know if I've explained myself, but I would appreciate your help. Thanks
Yes, it is possible (when you get there) but I'll recommend you split it into baby steps. This project is hard work, it will not happen in one day. I'll recommend scaling it down initially, aiming low and only after completion, to increase the task's complexity:
Have a circle, triangle, and square
Identify their contours
Identify the shape of each object
Compute and print out the distance between the centroids of the square and triangle.

Steps to detect and track droplets in a video using OpenCV C++

I am currently doing a project where I need to locate ink drops in a video, perform measurements such as volume estimation, velocity, and distance travelled before it becomes spherical.
Firstly, I would like to know whether I am along the right tracks in tackling this project. At the moment I have:
1.) Converted the original image to grayscale
2.) Applied Gaussian Blur then Canny edge detection (Click here for image)
3.) Located the white pixels using findNonZero() then calculated the sum of blocks of rows and the block with the highest concentration of white pixels and all the rows above it are cropped out). This removes the print heads in the image so the ROI is only the droplets below it.
4.) Used the findContours to find the contours. (Click here for image)
The above 4 steps are what I have done so far. Are the following steps below what I should do next?
Dilate the binary image first after cropping and before finding contours to ensure the contours will be closed and not open?
Maybe ignore the ones that are very open? (Any tips on how to actually do this?)
floodFill() every closed circles
Find the each contours' area using contourArea() (Can I then estimate the volume of the drop after this step with a few assumptions like its shape, pixel to volume ratio, etc?)
Find the centre of each contour and save it to an array so I can compare it to the centre of the same drop in the next frame. Once I know distance travelled of the centre of the droplet and the frame rate of the video I should be able to estimate velocity.
I am also unsure of how I can give a drop an ID so I can be sure I am tracking it properly and know when a new drop has entered the ROI.
Any help would be greatly appreciated, Thank You.
I think that your idea is good and can be quite easily extended to something that will satisfy you.
For clarification i will call red ROI from your image "redROI".
Find all droplets in redROI. Remember positions and IDs.
For each droplet position from previous step create a ROI similar to yellow rectangle:
For each rectangle check whether there is a droplet inside it.
If yes - probably it's the droplet from the previous frame, so the one you are looking for.
If no - you may try to search again in a little bit bigger rectangle or assume that the darkset point of this ROI is you droplet. If ROI is near bottom of redROI probably the droplet is gone - forget about it.
Note few things:
-size of the rectangle depends on how fast droplets move and whether they can move only vertical or diagonal (wind can change direction of move) too.
-before searching for droplets, check whether all rectangles are disjoint (the don't have any common area -> (Rect1 & Rect2).area() == 0 for each pair of rectangles).
-before searching for droplets in ROI make sure this ROI is inside redROI. So just use this code: roi = roi & redROI;
After finding new positions of every old droplet, search for droplets in whole redROI, so you won't miss any new droplet.
Let me know if you don't understand some part of this idea - i will try to explain it better.
Maybe ignore the ones that are very open? (Any tips on how to actually
do this?)
I'm not sure about it, so check it. Try to use CV_RETR_LIST as the third parameter of findContours and check the distance between first and the last point from returned (by findContours) contour - if the distance is big than the contour is open, if no - it is closed.
floodFill() every closed circles
You can just use drawContours and set thickness parameter to -1 - simpler and faster solution.
edit:
You can try to use optical flow as well - it's already implemented in openCV, here you can read nice tutorial about that: http://robotics.stanford.edu/~dstavens/cs223b/ (start from .pdf files)