I have a problem, when i take a photo with my tablet, i use opencv for detecting a face and recognition a face. So i would try to rotate the face in order to have for example the eyes and mounth in the same position for example all with the same horizontal angle.
Can you suggest me some OpenCv functions or some useful links for do this?
Thanks in advance.
Marco
I think the opencv remapping tutorial might help
http://opencv.itseez.com/doc/tutorials/imgproc/imgtrans/remap/remap.html#remap
Full answer:
Use this to locate the eyes cascade_classifier
now when you have a point for each eye - build the line equation and use simple trigonometry to find the angle. when you have the angle - use the remap to rotate or even better use this warp_affine
Related
I had a similar situation like described in this question. Within the question, the user who asked wrote the following equation:
It seems to work *, but does somebody know, how to get this equation? I was not able to find anything like this anywhere else...
Thanks in advance!
*) I also guess I kinda understand the equation:
the left part is the ray coming from the camera and going through the image point, therefore on the right side the real-world coordinates have to be translated and rotated as if the camera would be placed in (0,0,0)... sort of?
I just can't find a paper or anything to confirm the equation
It is a simple pinhole camera model equation. I guess what you are looking for, at least partially described PDF: here. You can also google more math yourself using keywords: camera calibration, pinhole model.
When camera is moving forward/backward, I think stereo rectification would not work. I guess I have to search along the epipolar line directly. Currently, my only clue is to use LineIterator to iterate through epipolar line, and use its neighbors as descriptor. This is very unintelligent method. So I want to know if there is other ways, or helpful opencv functions.
Old problem - Mark Pollefeys had a nice solution for it about 18 years ago. The idea is to rectify in polar coordinates.
See his short paper and lecture notes, and look around for tech reports from there.
You could try with Scale Invariant Feature Transform (SIFT) maybe with this descriptor you could get the key-points and stabilize the image with some transformation function per frame.
SIFT in Matlab
did somebody tried to find a pizzamarker like this one with "only" OpenCV so far?
I was trying to detect this one but couldn't get good results so far. I do not know where this marker is in picture (no ROI is possible), the marker will be somewhere in the room (different ligthning effects) and not faceing orthoonal towards us. What I want - the corners and later the orientation of this marker extracted with the corners but first of all only the 5Corners. (up, down, left, right, center)
I was trying so far: threshold, noiseclearing, find contours but nothing realy helped for a good result. Chessboards or square markers are normaly found because of their (parallel) lines- i guess this can't help me here...
What is an easy way to find those markers?
How would you start?
Use other colorformat like HSV?
A step-by-step idea or tutorial would be realy helpfull. Cause i couldn't find tuts at the net. Maybe this marker isn't called pizzamarker -> does somebody knows the real name?
thx for help
First - thank you for all of your help.
It seems that several methods are usefull. Some more or less time expansive.
For me it was the easiest with a template matching but not with the same marker.
I used only a small part of it...
this can be found 5 times(4 times negative and one positive) in this new marker:
now I use only the 4 most negatives Points and the most positive and got my 5 points that I finaly wanted. To make this more sure, I check if they are close to each other and will do a cornerSubPix().
If you need something which can operate in real-time I'd go down the edge detection route and look for intersecting lines like these guys did. Seems fast and robust to lighting changes.
Read up on the Hough Line Transform in openCV to get started.
Addendum:
Black to White is the strongest edge you can have. If you create a gradient image and use the strongest edges found in the scene (via histogram or other) you will be able to limit the detection to only the black/white edges. Look for intersections. This should give you a small number of center points to apply Hough ellipse detection (or alternate) to. You could rotate in a template as a further check if you wish.
BTW.. OpenCV has Edge Detection, Hough transform and FitEllipse if you do go down this route.
actually this 'pizza' pattern is one of the building blocks of the haar featured used in the
Viola–Jones object detection framework.
So what I would do is compute the summed area table, or integral image using cv::integral(img) and then run exhaustive search for this pattern, on various scales (size dependant).
In each window you are using only 9 points (top-left, top-center, ..., bottom left).
You can train and use cvHaarDetectObjects to detect the marker using VJ.
Probably not the fastest method but it should work.
You can find more info on object detection methods using OpenCV here: http://opencv.willowgarage.com/documentation/object_detection.html
I have an image on the wall. I'd like to create its 3D perspective views by myself. Suppose the points on the images, camera location, orientation of the camera are given, how can I do to obtain the 3d perspective matrix to play with the original image?
I understand I can use the orientation of the camera to calculate the 3d rotation matrix, but I've no idea how to calculate the subsequent projection matrix...
I've come across this link (see Section Perspective Projection), but I don't understand what's going on after projection.. And what is the difference between the camera position and the viewer's position?
Thanks a lot.
use openGl and its open example to solve your problem.
in bellow link there are good samples to undestand 3d reconstruction:
http://www.songho.ca/opengl/gl_transform.html
wish helpful
I am using OpenCV Haar Algorithm to track the Head and overlay an image over the Head.
What I am doing is saving frames generated by camera and overlaying image over each frames.
And time is not a constraint as I am not doing it Real-Time.
My code is working fine for say 45 degree of left and right rotation of Head.
But I need something which will track up to 90 degree of rotation.
Even I got many reference of OpenCV functions and link to estimate Head Pose
Please provide me some reference. Code Examples will be cool.
Thanks in advance
You can use an algorithm like SURF (you have samples in OpenCV package) and use it over a picture of the face, the over the image, and then use SURF descriptors to match the points and estimate the 3d position of the face in the image.
You can use the same code on the sample "find_obj" but replace the image by the face picture you want to track.
Hope this helps.
There is a functionc in openCV called POSIT that permit to estimate the pose of 3d object in a single image. It implements POSIT algorithm. Try to have a look there.
You could check the EHCI project at http://code.google.com/p/ehci/ as it gives a nice overview about POSIT and Lukas Kanade.