Ask Your Question

Tetragramm's profile - activity

2017-08-17 17:34:05 -0500 commented question Why am I Getting distorted images after sending them from C# to OpenCV in C++?

We don't support C#, but have you checked the pitch? IE: the first image is 1414 pixels wide. Perhaps there is a gap in the memory, and each row is 1424 apart or something.

2017-08-16 20:16:02 -0500 answered a question What's the best method for tracking identical objects?

This is an excellent use of the Kalman Filter. It can estimate the position and velocity of the balls, predict where they will be in the future, and give you a confidence interval of how certain the estimates are.

As for which detection is which track, that is called track association. You should be able to get away with something simple like the Hungarian Algorithm and the distance from the Kalman Filter's prediction. The methods can become amazingly complicated though, as you add more constraints.

2017-08-16 17:23:01 -0500 commented question OpenCV in use cases requiring millisecond-level precision

I probably wouldn't use one of the built in trackers at all. Just use color thresholding to separate out the three colors, and then do your own processing of the results. Since it's so simple and regular, you don't need anything that learns like KCF.

2017-08-15 07:32:13 -0500 answered a question Human skeleton extraction from depth data by using machine learning or neural network.

Here is a link to the MPII Human Pose Database, which has a results page. The second best one has a link to a pre-trained model. I don't know if you can load it into the new DNN module, but it does work if you use their demo-code.

This doesn't use the depth data though. I'm not sure of a dataset that includes that as well.

2017-08-14 20:33:36 -0500 commented question Time to contact

That looks to be a good plan based on what I've just read.

It's up to you to turn the optical flow into the size of an object. Which shouldn't be too hard. Do optical flow, then any pair of points you can calculate the expansion. Dense optical flow will let you average over the points in a window or a sampling around it, helping filter out outliers or things moving sideways.

Expansion = (distance between points after flow - distance before flow) / (distance before flow).

2017-08-14 17:57:59 -0500 answered a question How can a single channel represent a color image?

Fun fact, CV_8UC3 == 16. The function cv::imread takes an optional second parameter which is a flag from the enum cv::imreadmodes. In that enum, 16 == IMREAD_REDUCED_GRAYSCALE_2, which has the comment

If set, always convert image to the single channel grayscale image and the image size reduced 1/2.

Try removing that second parameter and see if it works better.

2017-08-11 07:31:43 -0500 answered a question cv::Mat_ vs std::vector

cv::Mat_<> is a two dimensional structure. std::vector<> is a one dimensional structure.

If you have a 2D shape, then go ahead and use Mat_. If you have a 1D shape, you can use either, unless you want it to change size (push_back, pop_back), in which case, use vector.

2017-08-10 18:58:02 -0500 commented question [Paid job] Multi-view solvePnP routine

gau ssg un+ew @ gma il. com

Remove the spaces of course, and let me know when you see it so I can remove it before the spammers find it.

2017-08-08 22:46:36 -0500 commented question Obtain Camera Pose and camera real world position using SolvePnP C++

It's a fisheye camera, did you calibrate using the cv::fisheye::calibrate?

2017-07-29 13:15:29 -0500 answered a question Problem with exact measurement of tracking balls

It's likely that your measurements are noisy, but if you've got more than 3, you can use something called a Kalman Filter.

You can use this to get accurate estimates of noisy measurements. Set up the filter correctly, input the position of the ball every time you measure it, and read the sate for estimates of position, speed, and acceleration.

It's beyond the scope of this forum to explain how to use it, but there are many tutorials on the internet, and the OpenCV syntax is explained in the documentation (linked above) and the kalman.cpp example.

2017-07-28 17:03:27 -0500 commented question Triangulating points into world-space, and using in solvePnp.

I don't think you need the Tran.inv(), and the function cv::transform will do it to all the points in the list at once.

2017-07-27 23:03:56 -0500 answered a question How to capture Video from Firewire Basler scout Camera?

This forum supports OpenCV only. As this is not an OpenCV problem, you're probably better off contacting whoever provided the PYLON App for support.

Good Luck!

2017-07-27 17:49:21 -0500 commented question How to pass an already stored data in GPU by GpuMat to a kernel

As the documentation says

In contrast with Mat, in most cases GpuMat::isContinuous() == false . This means that rows are aligned to a size depending on the hardware. Single-row GpuMat is always a continuous matrix.
2017-07-27 00:41:21 -0500 answered a question Not understanding how calcOpticalFlowPyrLK outputs found points

You are correct.

As for what is in fb if status is not 1, it is undefined. It's likely the last value that failed the validity check, but it could also be the starting value, or anything else, including NaN. Do not use these values.

2017-07-26 18:00:14 -0500 commented question Triangulating points into world-space, and using in solvePnp.

Ok, your updatePMatrix is wrong (I think). Instead of changing the P matrix, keep what you calibrated. Instead you should just transform the points at the end of triangulateCv. Just use the rvec and tvec from solvePnP directly.

Sorry, life happened. I might have some time this weekend to do a little demo thing to test this in.

2017-07-20 21:56:35 -0500 commented answer Match 2d keypoints to 3d Triangulated points using three sets of descriptors?

Yeah, and include a sample of your image points, rvecs and tvecs so others can play with them.

2017-07-20 18:05:36 -0500 commented answer Match 2d keypoints to 3d Triangulated points using three sets of descriptors?

You shouldn't need to invert your tvec and rvec, I don't think. I don't think you need that at any point.

2017-07-16 19:52:12 -0500 commented answer Match 2d keypoints to 3d Triangulated points using three sets of descriptors?

The last function you should just transform the points by the current rvec, tvec. Turn it into a projection matrix (The 4x3 thing, the 3x3 rotation mat, then the last column is the tvec) Then use the transform function to apply it to all the points in the list. I think that's all.

2017-07-14 18:45:39 -0500 commented answer Match 2d keypoints to 3d Triangulated points using three sets of descriptors?

Ok, I need to get long, so I'm going to edit the answer.

2017-07-14 17:12:41 -0500 commented question calculate matrix rotation translation with two cameras

And what do the matrices H and R represent? I'm not familiar with any H matrix in the context of two cameras.

2017-07-11 18:38:37 -0500 commented question Reading PNG images not giving alpha values

Are you on windows? Right click on the file->Properties->Details->Bit Depth and tell us what it is.

On Ubuntu there's something called pnginfo, but I admit to never having used it.

2017-07-11 17:54:01 -0500 commented answer Match 2d keypoints to 3d Triangulated points using three sets of descriptors?

So you do realize, that each iteration of the loop sees a new copy of the tempDescriptor Mat? You need to declare that outside the loop.

2017-07-09 17:41:18 -0500 commented answer Match 2d keypoints to 3d Triangulated points using three sets of descriptors?

No, not that loop. In the frame1 loop, where you do the push_backs. You need to also save the desc that matches the keypoint.

2017-07-08 17:20:01 -0500 commented answer Match 2d keypoints to 3d Triangulated points using three sets of descriptors?

You also need to filter the descriptors the same way you do the key points. So you're removing key points, but not keeping track of which keypoint matches which descriptor. If you also remove the descriptors at the same time, and then match the smaller list against new frames, that should work.

2017-07-08 17:14:12 -0500 commented answer OpenCV filter that allows filter taking two images as Base

Regrettably, no. As best I can tell, none of them have a Java API, though it might be possible for you to add them. I have no idea what is required to make a function work in the OpenCV Java API.

2017-07-07 16:13:44 -0500 answered a question OpenCV filter that allows filter taking two images as Base

What you are looking for is in ximgproc::filters. Unfortunately, no Java version.

Personally, I prefer THIS filter. It is about as fast as the guided filter, but more accurate. It's the same algorithm used in the DisparityWLS, but you can simplify it and speed it up for normal images.

2017-07-06 17:56:00 -0500 answered a question Match 2d keypoints to 3d Triangulated points using three sets of descriptors?

Well, objectPointsTri has a 1<->1 mapping with descCurrent. And, matchPoints is (query, train), if you didn't reverse the parameters. So that means the trainIdx property of the match has the index in both descCurrent and objectPointsTri.

for(cv::DMatch& m : match)
    cv::Point3f pos = objectPointsTri[m.trainIdx];
    //Do stuff with it


Ok, to understand what you're doing, you need to break this apart into functions. You have one long block and that's probably part of why you're having trouble.

The functions you need that I'm not going to write for you are (and you already have some of these)

  1. DetectKeypoints (Takes image, returns keypoints and descriptors)
  2. MatchKeypoints (Takes descriptors, returns matches) Below I've used 1st arg as query, 2nd as train.
  3. FilterMatches (Takes matches, takes either keypoints or descriptors, takes indication if query or train, returns filtered list)
  4. Adjust3dPoints (Takes 3d points, rvec, tvec, returns the points in absolute coordinate frame

        kpsL, descL = DetectKeypoints(left)
        kpsR, descR = DetectKeypoints(right)
        matches = MatchKeypoints(descL, descR)
        goodL = FilterMatches(kpsL, matches, query)
        goodD = FilterMatches(descL, matches, query)
        goodR = FilterMatches(kpsR, matches, train)
        3dPts = Triangulate(goodL, goodR)
        kpsL, descL = DetectKeypoints(left)
        kpsR, descR = DetectKeypoints(right)
        matches = MatchKeypoints(goodD, descL)
        3dPts = FilterMatches(3dPts, query)
        goodNew = FilterMatches(kpsL, train)
        rvec, tvec = solvePnP(3dPts, goodNew)
        matches = MatchKeypoints(descL, descR)
        goodL = FilterMatches(kpsL, matches, query)
        goodD = FilterMatches(descL, matches, query)
        goodR = FilterMatches(kpsR, matches, train)
        3dPts = Triangulate(goodL, goodR)
        3dPts = Adjust3dPoints(3dPts, rvec, tvec)

So each set of frames produces a list of keypoints for L an R, one for each match, in order, A matching set of Descriptors for L, and 3dPts, one for each match, in the same order.

Everything after the first matches the new L to the old L, and filters by those matches. Then those get used for solvePnp.

After the first frame you have to adjust the 3dPoints, because triangulate assumes the camera is the coordinate reference, but we know it isn't, so you have to adjust for that.

2017-07-06 17:41:27 -0500 answered a question Rolling Guidance Filter

HERE is the paper that describes the rolling guidance filter and particularly how it differs from the Gaussian and a few other edge aware filters.

2017-07-04 15:07:18 -0500 answered a question Tracking existing Keypoints across a video?

calcOpticalFlowPyrLK will track a point or set of points from frame to frame. This is particularly good for small motions per frame, where the appearance doesn't change much between frames.

You can of course augment this by using a descriptor such as ORB, SURF, SIFT or similar to create descriptors for each point and match those as well to make sure the correct point is found.

2017-07-04 11:45:18 -0500 commented answer Rodrigues rotation

Like I said, I'm not sure what it is representing, but it is not the same thing and cannot be substituted. K (capital) is very much not the same as k (not capital). It may look similar, but if you use it without understanding, you'll use it wrong.

Specifically, K^2 v = k cross (k cross v), but the top equation has k (k dot v) in the third term.

2017-07-02 21:19:41 -0500 commented question Why vGPU (Tesla K80) on Google cloud slower than GTX940M on T460P

I'm not actually sure there is a GPU portion for that classifier...

The nvidia-smi report, I'm not very familiar with it, but isn't that just the default process? It's not using it for computation?

2017-07-02 19:05:28 -0500 commented answer Rodrigues rotation

Looking at HERE, still a cos involved. Not sure what the Matrix Notation there represents, but that's definitely not the formula you use.

2017-07-02 17:07:14 -0500 answered a question Rodrigues rotation

I think the relevant bit is up the page a bit. In the Statement section. There you see exactly the equation you ask about.

2017-06-30 17:06:26 -0500 commented answer Retrieve yaw, pitch, roll from rvec

To be clear, there is no such thing as a "rotation matrix for a x-y'-z" Tait-Bryan sequence". There is only a rotation matrix. By definition, all euler angles describing an orientation produce a particular rotation matrix.

If someone gives you three numbers and says "Here's the euler angles for a rotation", you must ask which order they are, and you'll get a response from that table (or one like it). If someone gives you a rotation matrix, you're done. You already know everything about the rotation.

2017-06-30 16:59:23 -0500 commented answer Retrieve yaw, pitch, roll from rvec

You are mis-understanding what that shows. All of those are valid decompositions and produce valid euler angles, and all start from the same rotation matrix. They merely produce different sets of euler angles. One of those is equivalent to yaw pitch roll, the others are something else. But they all are the same rotation matrix, and the same orientation in space.

2017-06-29 20:13:08 -0500 answered a question Fast Matching Pyramids Rotationinvariance

You can't really "downsample" rotation. At least, not if you're just trying to find the object.

If you need to find the specific rotation that is best, and template matching can find the object while the rotation is incorrect by a significant amount, then you rotate the image with big steps, doing template matching on each one. The around the best angle, do finer steps and repeat until it's precise enough.

2017-06-29 20:03:36 -0500 answered a question Place data of Mat at a specific memoryarea pointed to by a pointer

If you map the pointer into a Mat, and the Mat is the exact size and type of what you are copying, you can simply use the copyTo function.

Mat src_mat(img.rows, img.cols, img.type(), src_ptr, *pitch if necessary*);

copyTo is the only reliable way to do this. Some functions will store their result into it, but not all, and some depend on the other input parameters for where they store it.

2017-06-29 19:59:13 -0500 commented question Overlaying masked image over another?

There are plenty of perfectly good reasons to do this berak. No reason to be rude.

2017-06-29 19:56:11 -0500 answered a question Overlaying masked image over another?

The copyTo function takes a mask as a parameter.

transparent.copyTo(background, mask);
2017-06-29 19:52:38 -0500 answered a question Retrieve yaw, pitch, roll from rvec

The rotation matrix is the rotation matrix is the rotation matrix. There is only one. The decomposition into three euler angles is where the rotation order changes. You can go from the rotation matrix to any of those angle orders, you just need to decide which order is what you need.

Remember, the camera is looking up the z axis. So yaw rotates the image, pitch turns the image to the left and right, and roll is up and down in the image. (assuming all the other angles are 0, combining them is less simple)

2017-06-29 17:49:22 -0500 commented answer Using solvePnp on a video stream with changing points.

Ah, I see the problem. You need to use triangulate points using the projection matrices from the previous frame.

Secondly, don't do a separate solvePnP for both cameras, or they'll start drifting. Do it just for the one that calibrates as the origin, then apply the transformation you get for the second camera to the results from solvePnP to get it's location.

Thirdly, each frame, use the results from solvePnP to create new projection mats to use with triangulate points.

2017-06-28 17:38:17 -0500 commented answer Using solvePnp on a video stream with changing points.

Do you have an external reference that you use as 0,0,0? If not, then there's no true difference between camera and object space.

Your code is too fragmented for me to follow the data flow, but it should go like this:

  1. Camera is a (0,0,0) or some initial value based on a reference point
  2. Capture image and use camera pose to find 3d locations of points
  3. Capture image and find keypoint matches between previous frame and this
  4. With the previous 3d points, and new 2d points, use solvePnP, which gives current pose (in same coordinate frame you started with)
  5. Go to 3 and repeat.
2017-06-27 17:31:19 -0500 commented question Retrieve yaw, pitch, roll from rvec

Ah, no. By definition, pitch is y and roll is x. Always has been. Check the link in your answer.

2017-06-27 07:32:59 -0500 commented answer Using solvePnp on a video stream with changing points.

Ok, let's debug this from the beginning.

Is the first set of points correct? IE, the first frame, you are at (0,0,0), and you see all these points out in the world. Are they approximately correct? All positive z, and they show up in the right place on the image when you use projectPoints?

2017-06-26 17:39:45 -0500 answered a question Using solvePnp on a video stream with changing points.

To get the additive value, you want to use THIS function.

HERE is a good presentation on what you're doing that should help with finding references and the terms you need to search for.

2017-06-25 16:30:08 -0500 commented question Retrieve yaw, pitch, roll from rvec

Nope, I just worked it out.

The yaw 90 puts the camera x = -y, camera y = x, camera z = z

Then Roll -90 then rotates around the camera x so you get camera x = -y, camera y = -z, camera z = x, which is what you want. If you did pitch -90, you would be rotating around the y, and would get camera x = -z.

Any yaw and a pitch of -90 gives you your camera x = down, which would mean your camera is turned so the right side of the image is down.

2017-06-24 19:41:43 -0500 answered a question Calculate x distance to line from edge at middle of y?

Well, this is more geometry than computer vision, but here you go.

Turn your line into the form y = m*x+b. If you don't know how, use the example to get two points on the line, and solve. Then x = (y-b)/m, where y = rows/2

2017-06-23 16:08:52 -0500 commented question Retrieve yaw, pitch, roll from rvec

Hmm, nope. A camera looking east would have a yaw component of magnitude 90. Positive or negative, I'm not sure without coloring my fingers, but I can tell it's needed.

2017-06-22 22:35:31 -0500 commented question Retrieve yaw, pitch, roll from rvec

The rotation matrix is independent of operation and stores the complete rotational information. When decomposing it to euler angles you choose the order of those rotations.

The camera coordinates are x is right, y is down, z is out into the world. The world coordinates are defined by the points you use solvePnP with.