I'm trying to automatically draw a mesh or grid over a face, similar to the image below, to use the result in a blog post that I'm writing. However, my knowledge of computer vision is not enough to recognize which model or algorithm is behind these types of cool visualizations.
Could someone help pointing me some link to reador or a starting point?
Using Python, OpenCV and dlib the closest thing I found is something called delauny triangulation but I'm not sure if that's exactly what I'm looking for seeing the results.
Putting it in a few words what I have so far is:
Detect all faces on image and calculate their landmarks using dlib.get_frontal_face_detector() and dlib.shape_predictor() methods from dlib.
Use the method cv2.Subdiv2D() from OpenCV to compute a 2D subdivision based on my landmarks. In particulary I'm getting the delauny subdivision using the getTriangleList() method from the resulting subdivision.
The complete code is available here.
However, the result is not so attractive perhaps because the division is using triangles instead of polygons and I want to check if I can improve it!
Related
I have read this post in https://mathoverflow.net/questions/268106/generating-random-curves-with-fixed-length-and-endpoint-distance
The main task is drawing a continuous curve between two fixed points that has also a fixed length.
I wondered how can I implement it in python?
I was looking for creating it in pytorch, but opencv and scikit image also works for me.
I was unable to find even a relatively close implementation anywhere.
Do you have any suggestion what function from what package can make it work?
I was wondering if there was a simple python toolkit for region-based image segmentation. I have a grayscale image, and my goal is to efficiently find a complete segmentation such that the pixel values in each region are similar (presumably the definition of "similar" will be determined by some tolerance parameter). I am looking for an instance segmentation where every pixel belongs exactly one region.
I have looked at the scikit-image segmentation module (https://scikit-image.org/docs/dev/api/skimage.segmentation.html), but the tools there didn't seem to do what I was looking for. For instance, skimage.segmentation.watershed looked attractive, but gave poor results using markers=None.
The flood fill algorithm from scikit-image seems close to what you want, has a tolerance parameter as well.
For more fine-tuned control you can check out OpenCV
I have a fixed camera and I need to check if its position or orientation has been changed. I am trying to use OpenCV (calculating diiferencies between a reference image and a new one) for this, but I am pretty new to OpenCV (and image processing in general) but I am not really sure what specific algorithm would be the best to use for this, or how to interpret the results to find if the camera has been moved/rotated. Any ideas?
Please help,
One way to do it would be to register the two frames to each other using affine image registration from openCV. From this you can extract the rotation and displacement difference between the two frames. Unfortunately this will only work well for in-plane rotations but I still think it is your best bet.
If you post some sample code and data I would be happy to take a look.
You can use Canny or HoughLinesP to find lines,From this you can get two lines,compare it.Maybe this will be effective in some simple background.if some object in your picture,try sift or other feature extractor,you can take features to find the relationship from two frames.
I am using OpenCV and Python.
Let say I have this sequence video of the car. And I have tracked some 'interesting points' of the car with the cv2.goodFeaturesToTrack and cv2.calcOpticalFlowPyrLK. Now, given the traced points, I want to estimate a very rough shape (maybe a 3D box) of the car and its distance from the camera. It doesn't need to be that accurate.
On top of that, I want it to be keep updating in real time. The closest youtube video I can find that can give a view of what I am trying to achieve is this. I have found a new Structure from Motion module in OpenCV, but it is more on building a 3D model from a collection of points.
The question is, what is the best way of achieving this and what kind of library I can use (especially in order to construct the 3D space)?
And it is also OK if somehow I need to use C++ for this (although I am still not good in it yet).
Thanks.
There are several packages and methods for segmentation in Python. However, if I know apriori that certain pixels (and no others) correspond to a particular object, how can I use that to segment other objects?
Which methods implemented in python would lend themselves to this approach?
Thanks.
You'll want to take a look at semi-automated image segmentation. Image segmentation in a semi-automated perspective means that you know before hand what class certain pixels belong to - either foreground or background. Given this a priori information, the goal is to minimize an energy function that best segments the rest of the pixels into foreground and background.
The best two methods that I know of are Graph Cuts and Random Walks. If you want to study the fundamentals of both of them, you should read the canonical papers by Boykov (Graph Cuts) and Grady (Random Walks) respectively:
Graph Cuts - Boykov: http://www.csd.uwo.ca/~yuri/Papers/ijcv06.pdf
Random Walks - Grady: http://webdocs.cs.ualberta.ca/~nray1/CMPUT615/MRF/grady2006random.pdf
For Graph Cuts, OpenCV uses the GrabCut algorithm, which is an extension of the original Graph Cuts algorithm: http://en.wikipedia.org/wiki/GrabCut. Essentially, you surround a box around the object you want segmented, and Gaussian Mixture Models are used to model the foreground and background and the object will be segmented from the background inside this box. Additionally, you can add foreground and background markers inside the box to further constrain the solution to ensure you get a good result.
Take a look at this official OpenCV tutorial for more details: http://docs.opencv.org/trunk/doc/py_tutorials/py_imgproc/py_grabcut/py_grabcut.html
For Random Walks, this is implemented in the scikit-image library and here's a great tutorial on how to get the segmentation up and running off of their official website: http://scikit-image.org/docs/dev/auto_examples/plot_random_walker_segmentation.html
Good luck!