atomoclast / cSfM

A Structure From Motion implementation using OpenCV and GT SAM.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

All run but the output file is empty

aviadpinis opened this issue · comments

Hello,
Your project is very interesting,
I have compiled and ran, everything seems fine, but the output file 'options.txt.ply' is not empty but has no values with a point cloud.

this is a 'options.txt.ply' file:
ply
format ascii 1.0
element vertex 0
property float x
property float y
property float z
property float nx
property float ny
property float nz
property uchar diffuse_red
property uchar diffuse_green
property uchar diffuse_blue
end_header


I try to load this file to meshLab but this does not work.

this is the output in my terminal:

Opening Images...
Opened Images...
Finding Matches...
Finding Keypoints.
Found Keypoints. Matching them now....
Number of keypoints/poses: 4
find Fund Mat
Pushing Keypoints into vectors. Size of mask: 300
find Fund Mat
Pushing Keypoints into vectors. Size of mask: 98
find Fund Mat
Pushing Keypoints into vectors. Size of mask: 71
find Fund Mat
Pushing Keypoints into vectors. Size of mask: 182
find Fund Mat
Pushing Keypoints into vectors. Size of mask: 107
find Fund Mat
Pushing Keypoints into vectors. Size of mask: 289
Found Matches...

Initial Camera Matrix K:
[2911.5848, 0, 415;
0, 2911.5848, 360;
0, 0, 1]

Image width and height: 925, 706
Size of keypoint matches: 182
Iterating through images now...
iterating through keypoints.
Finding essential Matrix.
Size of destination: 155, Size of source: 155
Recovering Pose.
iterating through keypoints.
Finding essential Matrix.
Size of destination: 76, Size of source: 76
Recovering Pose.
image 2 ==> 1 scale=1.03861 count=136
iterating through keypoints.
Finding essential Matrix.
Size of destination: 162, Size of source: 162
Recovering Pose.
image 3 ==> 2 scale=1.16829 count=171
Running Bundle Adjustment now.

%%%%%%%%%%%%%%%%%%%%%
Initial Graph Error = 2.18264e+06
Final Graph Error = 2.60423
Resultant Camera Matrix K:
2921.55 1.68795e-07 406.039
0 2900.38 363.988
0 0 1
Copying image.
Copying image.
Copying image.
Copying image.
Copying image.
Copying image.
Copying image.
Copying image.

Now running PMVS to generate pointcloud.

--- Summary of specified options ---

of timages: 4 (range specification)

of oimages: 0 (enumeration)

level: 1 csize: 2
threshold: 0.7 wsize: 7
minImageNum: 3 CPU: 4
useVisData: 0 sequence: -1

Reading images: ****
0 1 Harris running ...Harris running ...2 Harris running ...3 Harris running ...430 harris done
DoG running...468 harris done
DoG running...482 harris done
DoG running...512 harris done
DoG running...619 dog done
653 dog done
684 dog done
712 dog done
done
adding seeds
(3,0)(2,0)(1,1)(0,1)done
---- Initial: 0 secs ----
Total pass fail0 fail1 refinepatch: 5627 2 5606 19 21
Total pass fail0 fail1 refinepatch: 100 0.0355429 99.6268 0.337658 0.373201
Expanding patches...
---- EXPANSION: 0 secs ----
Total pass fail0 fail1 refinepatch: 18 5 12 1 6
Total pass fail0 fail1 refinepatch: 100 27.7778 66.6667 5.55556 33.3333
FilterOutside
mainbody:
Gain (ave/var): 0.53037 0.212283
7 -> 7 (100%) 0 secs
Filter Exact: ****
7 -> 6 (85.7143%) 0 secs
FilterNeighbor: 6 -> 0 (0%) 0 secs
FilterGroups: STATUS: 0 0 27 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0
Expanding patches...
---- EXPANSION: 0 secs ----
Total pass fail0 fail1 refinepatch: 0 0 0 0 0
Total pass fail0 fail1 refinepatch: -nan -nan -nan -nan -nan
FilterOutside
mainbody:
Gain (ave/var): 0 0
0 -> 0 (-nan%) 0 secs
Filter Exact: ****
0 -> 0 (-nan%) 0 secs
FilterNeighbor: FilterGroups: STATUS: 0 0 27 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0
Expanding patches...
---- EXPANSION: 0 secs ----
Total pass fail0 fail1 refinepatch: 0 0 0 0 0
Total pass fail0 fail1 refinepatch: -nan -nan -nan -nan -nan
FilterOutside
mainbody:
Gain (ave/var): 0 0
0 -> 0 (-nan%) 0 secs
Filter Exact: ****
0 -> 0 (-nan%) 0 secs
FilterNeighbor: FilterGroups: STATUS: 0 0 27 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0
---- Total: 0 secs ----

Operation complete. Navigate to output/options/ and open 'options.txt.ply' to view your model.


do you have any idea what should i do?

Seems to be an issue with PMVS I believe...

I ran this successfully at the time on Ubuntu 16.04. Maybe it's a versioning issue?

Also, did you check out the proper tag for GTSAM?

Thank you for fast response,
I think that is the problem, I debugging the project and everything seems good.
I work with Ubuntu 18.04, you have an idea of how to check PMVS?

My tag in GTSAM is 4.0.0-alpha2, it's good?

Again, Thank you very much

No problem!

For PMVS, check out their direct website. I basically took the executable from their tar on this page, and placed it in the run directory for cSFM.

Maybe try and download the tar and go through the steps in "Things to try first" and make sure it works like that. Then copy over the appropriate binaries/files to the cSFM folder.

As for GTSAM, that's what I used as well. So that should work.

Nice, I ran "Things to try first" and this is working very good, so I build again your project and this is work, not working exactly like your, but a beautiful model.

image

Just because I try to understand, the Bundle adjustment correct the pose of the camera and the
PMVS after that creates a point cloud.
Is it possible to create a point cloud from Bundle adjustment without PMVS?
That is the edges in the BA are the points between all two images(or more) so why not take them points for point cloud? why use in PMVS?

Thank you

with SfM, we have multiple images that are taken from different perspectives, we use BA to try and find the features that overlap and basically do a least squares approximation to calculate these depths of points.

PMVS basically takes in these images and the camera points and uses it to do the epipolar geometry to recover the structure.

Consider a Stereo camera, where we have two cameras that have a fixed baseline between the cameras. We have a known distance from one to the other.

In the case of SfM, we have one camera in different spots, so we must use BA to figure out these transformations.

Does that make sense?

Yes, it makes sense, but if I understand true, the Epipolar Geometry says that between two images have a baseline that the same point lies in two images if the point really shows in two images.
and you use in Epipolar Geometry in Feature Matching.

So I thinking that because we calculated Feature extraction and Feature Matching in start pipeline, so you know how points show in two images, also you know how points matching between images.

When you create the GTSAM graph you give the pose of a camera into Vertex and the point that matches between images also into Vertex, the edges between images are these points.
The BA do a least-squares approximation that camera pose and the depths points?
if it is true why not get the depths points from the GTSAM (i. e. BA) and use them to create the point cloud?

You theoretically could, but PMVS is used because it already takes some BA output to create the pointcloud models. That's it. 😄

Nice, so this is possible but easier use in PMVS, Thank you.

If it's okay, I have another question.
I try to run this code in other data, and the results are very bad.

The recoverPose function return "status" parameter that all values are 0,
and if I understand right the value for this parameter has 1 for the value that uses them and 0 if not use them, and it is not possible to get recoverPose that is rotation matrix and transition vector, without use in no one of points.
I searched a solution for this issue, but I did not find, you have an idea?

Thank you very much for all.

No problem!

It depends on the input images. I noticed that because it's an unsorted SfM algorithm, it really needs to have a lot of overlap in the images for there to be good matches. Look at the example you built above. Many of the images are very similar with only small changes in perspective.

I will admit, this is a short-coming of this implementation that could be improved.

Thank you,
you helped me a lot.