Find a free direction in a pointcloud - python

in my setup I have a depth camera looking down on the box. There is one object which should be moved (red rectangle) and obstacles (black things). I need to find a free direction to move the object there on the certain distance (1 m lets say). I have the point cloud of the scene and the transformation between the camera and the ground plane. My idea was to reduce the pointcloud to 2 dimensions, build some sort of occupancy map and try to build a free line pixel by pixel from the objects center with lets say 5 degrees step clockwise. However, I feel that its a too complicated aproach for such task. Is there any simplier solution? Otherwise, how could I take in account objects size? Just add half of the biggest object`s dimesion to each obstacle? But in this case it will consume a lot of safe space as well, because the object is not symmetrical. I use python so any library suggestion would also be very helpful. Thanks!
Setup:
https://i.stack.imgur.com/WjxFL.png

Related

How to get the depth coordinate in the world system from the depth camera

depth camera: intel realsense D415
language: python
I am trying to get the z coordinate of a depth point in the world coordinate system. I am wondering if there's an embedded method or if there is a way to obtain that?
Thank you in advance!
It sounds like you want to use a separate and fixed object in the scene as a reference, e.g. a table supporting your objects of interest.
Finding the 3D plane of the table is usually easy: you use some robust fitting algorithm along with reasonable priors (e.g. the largest plane, or the largest plane approximately oriented in a known way with respect to the camera).
Finding a plane, however, only gives you a "z" direction orthogonal to it, plus a translation vector to a point on the plane which may not be a desirable one. So you need a way to identify some desirable "origin" point in the point cloud. This is usually done using an object (a.k.a. "calibration jig" or "rig") of known shape that can easily be identified and precisely fit to a model. For example, a billiard ball (fit a sphere, find the center, offset by the radius to the contact point with the plane), or a cone (find the center of the base), etc. Note that using a conical jig allows to find both plane and point in one shot.

Can I compute camera pose from image with known scale?

I have a photo taken from a camera (whose focal length, principle point, and distortion coefficients I know). The photo has a 8cm x 8cm post-in on a table and the center of the post-it is the origin (0, 0) again in cm. I've also indicated the positive-y axis on the post-it.
From this information is it possible to compute the location of the camera and the vector in which the camera is looking in Python using OpenCV? If someone has a snippet of code that does that (assuming you know the coordinates of the post-it corners already) that would be amazing!
Use OpenCV's solvePnP specifying SOLVEPNP_IPPE_SQUARE in the flags. With only 4 points (and a postit) the solution will be quite sensitive to how accurately you mark their images, so ask yourself whether you really need the camera pose and location for your application, and how accurately. E.g., if you just want to make a flat CG "sticker" stay fixed on the table while the camera moves, all you need is estimating a homography, a much simpler task.
It does look like you have all the information required. The marker you use can be easily segmented. Shape analysis will provide corners. I did something similar to get basic eyesight tracking:
Here is a complete example.
Segmentation result for the example:
Please notice, accuracy really matters, so it might be useful to rely on several sets of points.

Calculating distance between camera and object real time

I am so new to this area. I want to improve myself and I need your advices. I want to detect objects and find the distances between the objects and my camera by using a phone camera. What should I learn in order to achive this? Any advices would be appreciated.
If you want the following: "a single picture, taken with any camera, at any distance, and calculate the distance given an image", then I fear that might be impossible, because there is no depth with a single view. It would be pretty impossible for a nn to just guess how far an object is away by how big an image is. Retrieved from wikipedia:
Depth perception arises from a variety of depth cues. These are
typically classified into binocular cues that are based on the receipt
of sensory information in three dimensions from both eyes and
monocular cues that can be represented in just two dimensions and
observed with just one eye
Now this is out of the way, you did say YOUR camera, using a specific camera changes things, if you know the focal length and angle of view, that would help a lot. Here are some links to illustrate that:
focal length
angle of view
Maybe you can calculate your way out of this, but you will need some constraints or callibration, one way or another. Hope I helped a bit

Best OpenCV algorithm for detecting fast moving ball?

I am new to OpenCV. I am working on a project that involves tracking and detecting a spinning roulette ball. Here is the video I want to use: https://www.youtube.com/watch?v=IzZNaVQ3FnA&list=LL_a67IPXKsmu48W4swCQpMQ&index=7&t=0s
I want to get the ball time for 1 revolution. But the ball is quite fast and hard to detect. I am not sure how to overcome this.
What would be the best algorithm for doing this?
By subtracting successive images, you will isolate the ball as a (slightly curved) line segment. Both its length and its angular position are cues for the speed.
Anyway, these parameters are a little tricky to extract for a side view, as the ellipse has to be "unprojected" to a top view, to see the original circle. You need to know the relative position of the wheel and the viewer, which you most probably don't know.
An approximate solution is obtained by stretching the ellipse in the direction of the small axis.

How to create steerable Edge Detection filters using Python or discard edges that don't conform to desired angle

I know how to do basic Canny edge detection using OpenCV. However I need to discard all edges that do not fall within 15 degrees of a predetermined angle.
Any help would be greatly appreciated.
Its an old question but here is the process you should use.
1]Start by filter your source image (back-ground subtract/color/etc)
2]Apply a generic Edge detector or a steerable filter or (if you want to get some really good result & are doing it for research purposes look for Phase Strectch Transform Algorithm
3]Save those line in a vector/whatever
4]Create a circle drawing algorithm (here is the main idea)
Your circle drawing algorithm (CDA further) will take every point returned by your edge filter.
For each point it will build circles of a variable diameter [Dmin;Dmax] based on the max/min distance you can accept for two points be considered on the same line.
If no next-pixel are present in the circle octant corresponding to your angle, simply dismiss it.
Once you have your lines that match your angle you can sort them by length to dismiss line probably due to noise.
You should also note that there is other methods, this method as some good aspect:
1- Its robust against noise & low quality images/video
2- Its CUDA compliant (i.e. easy to push in parallel processing).
3-Its fast and roughly more accurate than most basic line detectors.

Categories

Resources