Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

As @berak said, you'll need time. You can find some code in several Github repo to achieve something similar, but at least you have to spend some time on it, to edit an obtain what are you looking for . There are also several book that can help you understand better some things. Let's try to do some reverse engineering, you'll find out that you need: an image, you need to distinguish the rice from the rest of the meal (as @Kafan told, it cannot be xray, all the things must be visible), and then count the rice grain. Let's say that if you expect a unit precision in counting the rice grain may you need further experiment aka more time invested especially if the grain are very close each others. An object detector can do the job for sure, but you'll need some pre-processing first. I suggest you to take a look at this presentation where they try to count rice and you can see how that it is achieved. There is also a Github repo for general food detection based on YOLO, you can see it here. It doesn't count every single grain, but maybe is can be a start. But again, don't expect that result come out of the box: OpenCV provide to you the technology and the algorithm to work with, but the solution must be addressed from you ;)

As @berak said, you'll need time. You can find some code in several Github repo to achieve something similar, but at least you have to spend some time on it, to edit an obtain what are you looking for . There are also several book that can help you understand better some things. Let's try to do some reverse engineering, you'll find out that you need: an image, you need to distinguish the rice from the rest of the meal (as @Kafan told, it cannot be xray, all the things must be visible), and then count the rice grain. Let's say that if you expect a unit precision in counting the rice grain may you need further experiment aka more time invested especially if the grain are very close each others. An object detector can do the job for sure, but you'll need some pre-processing first. I suggest you to take a look at this presentation where they try to count rice and you can see how that it is achieved. There is also a Github repo for general food detection based on YOLO, you can see it here. It doesn't count every single grain, but maybe is can be a start. But again, don't expect that result come out of the box: OpenCV provide to you the technology and the algorithm to work with, but the solution must be addressed from you ;)

P.S. from an image you can obtain for sure the x and y coordinate, regarding the z coordinates it depends: you can retrieve it only if you know the camera parameters.