I know this is a well documented problem but I didn't manage to find a satisfactory solution online. Here goes.
I am using cvCalcOpticalFlowPyrLK to track motion of feature points. I find the feature points with cvGoodFeaturesToTrack and refine it with cvFindCornerSubPix. I find the feature points in my first frame (reference frame) and use LK to track the movement of these points with respect to the reference frame. I update the points with current frame feature points coordinate with they are found. Heres what I observed:
1) The no. of good feature points found by cvGoodFeaturesToTrack is very little. I tried to find 100 points but I always get less than 10 points.
2) The no. of feature points after 5-6 frames decreased by 50 percent and then another 50 by 5 frames later, and this is when the subject is not in motion. The tracking is patchy in the sense some of the points are correctly tracked but some are way off.
I have seen demo application on youtube or iphone app. The drop off of the no. of feature points from frame to frame is not what I see in my application. So I am suspecting parameters I set might be wrong.
This is how I call the functions:
cvGoodFeaturesToTrack(
image,
eigen_image,
temp_image,
corners_point,
&corner_count,
0.01(quality level),
3(min distance),
0,
10(block size),
0(use harris),
0.04(k));
cvFindCornerSubPix(
image,
cornersPoint,
corner_count,
cvSize(WINDOW_SIZE, WINDOW_SIZE),
cvSize(-1, -1),
cvTermCriteria(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 20, 0.3));
cvCalcOpticalFlowPyrLK(image,
currentFrame,
rpV->pyramid_images0,
rpV->pyramid_images1,
cornersPoint,
cornersCurrent,
corner_count,
cvSize(WINDOW_SIZE, WINDOW_SIZE),
10(level),
features_found,
feature_errors,
cvTermCriteria(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 20, 0.3),
0);
Another thing is that I am using a greyscale camera (infra red camera). I dont it matters by too much though. I am wondering if I am missing anything important here.
Any form of help is much appreciated.
Thanks,
Kelvin
There are a few issues:
Calling cvFindCornerSubpix does not help if the features you are tracking don't look like corners of a checkerboard.
Use of a pyramid is appropriate only if the apparent motion is larger than the window size from frame to frame, for a reasonable window size.
Hard to tell why you are not getting enough good features to track without seeing your imagery. Perhaps it's rather blurry?
Related
I am trying to rotate a group of objects in the scene by applying Rotation to each node. The rotation part of the code is as simple as:
for node in sceneView.scene.rootNode.childNodes {
node.localRotate(by: SCNVector4(0,1,0, Double.pi/180))
}
The expected result is the resulting node will rotate by 1 degree every time it is triggered. However, I have noticed sometimes the resulting image have reversed y values (for example, the rotation vector was -1 in the previous frame but the next frame it suddenly becomes +1), resulting in something looks like an illusion. The frequency looks like it happens every other frame or so. I tried with different axis but the same thing also occurs. I have tried both localRotate and Rotate, the problem still exists. Is this suppose to happen?
This is a video link for demonstrating the problem:
https://res.cloudinary.com/df7kpyhrg/video/upload/v1616634641/RPReplay_Final1616634008_ohvg1k.mp4
I am still not 100% sure, but I think the problem was I need to use the simd version of the ar modification. I need to use simdRotate instead of rotate. I believe the current flip in the video is the change in the angel which will look like reflection. To give a clearer example, suppose the current angel is 0 and it increments in the scale of 0.1 radian, the values will be 0, -0.1, 0.1, -0.2, 0.2 and so on. Therefore the flip results are the intermediate results to be executed. This stack overflow posts explains the difference between simd and non-simd methods nicely
What does SIMD mean?
I am animating some frames of a monster jumping and swinging a sword, and the frames are such that the width gets bigger or smaller as he swings the sword (the monster standing is 500 width, but his sword, fully extended to the left, adds another 200 width, thus he varies from 500 to 700 or more in width)
I originally took each frame, which is on a transparent background, and used the Photoshop magic wand tool to select just the monster. I then saved these frames like that, and when I used them to animate, the monster warped and changed sizes (it looked bad).
The original frames had a large 1000 x 1000 transparent background surrounding him, and as a result it always kept him "bound" so that it never warped.
My question is what is a good way to create frames of animation where the sprite inside might change size or width as he's moving so that there is no warping?
If I have to use a large border of transparent pixels, is that the recommended approach? I'm noticing that for my animation, each monster takes up about 3 - 5MB. I plan on potentially having a lot of these people ultimately, so i'm wondering if this is the best approach (using large 900 x 900 images all the time, plus I'll be using more for 2x and 1x). So all of this seems like it could spiral out of control to 4 or 5GB.
What are other people doing when making animations that require different poses and positions? Just fixing the frames with borders that are as small as possible?
Thanks!
You should probably change the approach to animation and use inverse kinematics instead. Take a look at this and Ray's tutorial.
I am working on a small education demo which should measure height and width of the object using iOS camera.
EDIT:
I have a new theory to measure the width of an object.
In above image, if i can get Angle α and Angle ß, i can get width of the unknown side by using trigonometry formulas. I have the values of b1 and b2 already.
OLD:
Right now, i am focusing on measuring length only.
As per my knowledge it should be 3 step process.
User snaps one end of the object.
User snaps other end of the object.
User snaps center of the object. (Suggest me a better way for these please)
I get the approximate measurements using above process, but for the 3rd step, in which user snaps the center of the object. I want to show pointer location on screen (as camera overlay) to help user determine the center of the object.
This is how i am doing it right now.
How can i draw pointer location for 3rd step?
Note: Please suggest alternative/best way to make it possible. I would love another suggestions. Thanks.!!
First of all I must appreciate your work you have done till now. Another good thing is the way of explaining, salute!!!!!
After reading of your question, I feel that you dont need code, you can do it. I think you need direction only.
As per your explanation, you want to record angle of rotation of the device.
If you want to measure angle of rotation, you have to use compas readings. But compas readings will change if user tild the device. So you have to use accelerometer to measure tilding of device.
In short you have to make some combination and equation of both compas and accelerometer readings. Use compas to measure angle and use accelerometer to measure tilding of device.
If you want further information to implement it, you can ask me.
Hope this will help you....
My graphics is such that in order for my view content to properly align with graphics, it needs to rotate in depth ie along z-axis. Maybe 5-10 degrees along z, and negative 5-10 degrees along y.
Currently I use this: (argView is my imageview)
[argView.layer setTransform:CATransform3DMakeRotation(0.5, 1, -1, 0)];
However this gives me very skewed image - definitely not what I want, but I don't know what I should be supplying there.
I began by reading apple docs but there are just so many functions I am getting confused.
If someone has any good guide that will make it very easy for me, great.
If someone can point to where this exact thing has been done, greater.
I'm using the Emgu shape detection example application to detect rectangles on a given image. The dimensions of the resized image appear to impact the number of shapes detected even though the aspect ratio remains the same. Here's what I mean:
Using (400,400), actual img size == 342,400
Using (520,520), actual img size == 445,520
Why is this so? And how can the optimal value be determined?
Thanks
I replied to your post on EMGU but figured you haven't checked back but this is it. The shape detection works on the principle of thresh-holding unlikely matches, this prevents lots of false classifications. This is true for many image processing algorithms. Basically there are no perfect setting and a designer must select the most appropriate settings to produce the most desirable results. I.E. match the most objects without saying there's more than there actually is.
You will need to adjust each variable individually to see what kind of results you get. Start of with the edge detection.
Image<Gray, Byte> cannyEdges = gray.Canny(cannyThreshold, cannyThresholdLinking);
Have a look at your smaller image see what the difference is between the rectangles detected and the one that isn't. You could be missing and edge or a corner which is why it's not classified. If you are adjust cannyThreshold and observe the results, if good then keep it :) if bad :( go back to the original value. Once satisfied adjust cannyThresholdLinking and observe.
You will keep repeating this until you get a preferred image the advantage here is that you have 3 items to compare you will continue until the item that's not being recognised matches the other two.
If they are the similar, likely as it is a black and white image you'll need to go onto the Hough lines detection.
LineSegment2D[] lines = cannyEdges.HoughLinesBinary(
1, //Distance resolution in pixel-related units
Math.PI / 45.0, //Angle resolution measured in radians.
20, //threshold
30, //min Line width
10 //gap between lines
)[0]; //Get the lines from the first channel
Use the same method of adjusting one value at a time and observing the output you will hopefully find the settings you need. Never jump in with both feet and change all the values as you will never know if your improving the accuracy or not. Finally if all else fails look at the section that inspects the Hough results for a rectangle
if (angle < 80 || angle > 100)
{
isRectangle = false;
break;
}
Less variables to change as hough should do all the work for you. but still it could all work out here.
I'm sorry that there is no straight forward answer, but I hope you keep at it and solve the problem. Else you could always resize the image each time.
Cheers
Chris