If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

An accidental image processing collection.

I have a couple of projects in mind that require the ability to convert a set of photographs into a 3D model.
As a result I have been searching around for a suitable program to do this process, since it involves maths that I have long ago forgotten (if I ever knew it).

I eventually came across Regard3D which seems to get quite good reviews.
Of course the Linux support comments were not encouraging:

Linux
Unfortunately, there are no binaries available for Linux, so you'll need to compile the program, and its executable and library dependencies, from source. The developer's build instructions leave most of the process as an exercise for the reader, so a degree of familiarity with C++ and Cmake will come in handy.To do Figure out complete build/install procedure

The phrase "exercise for the reader" should have rung alarm bells, but, no, I dive into the process of building this program - I mean, how hard could it be ?

On the Regard3D site the first thing you notice is that there is both the source zip file for Regard3D, and one for openMVG which has apparently been modified a bit for use with the program.

Hence the first task was to build this library.
It unpacks to 64MB of source, so it takes while to build.
Its final step is to link 22MB of static libraries, where it announces there are undefined references
So I wade through the unfamiliar cmake files to adjust them so that it finds the needed libraries.
I notice that there are some warnings so I have a look at them. Mostly they were unimportant warnings, but a couple were real bugs, but easy enough to fix.
At this point I finally read the build instructions through to the end and discovered that I was installing it incorrectly, so I adjusted the configure command to set the installation prefix.
Item 1 done.

Step two: Build the program.
This starts with an iterative process of running the cmake program.
Finding out what package it couldn't find and installing it.
It is amazing that build instructions will tell you about libpng, and other minor packages, but overlook wxWidgets, Qt5, and Boost.
I guess these have been installed in the developer's systems for so long they are just considered part of the system.
Eventually it wrote out the make files and could have a go at actually compiling the program.
A few compile errors needed fixing, some of which make me wonder if the source I am compiling is the same source as is being used to build the Windows and Mac binaries.
[I will run a diff between the original source and its "fixed" form and report the actual changes in a later post.]
Eventually the program is created.

Step three: Run the program.
The very first thing that comes up is a dialog box:

Third party executables not found.
Please put them where the executable is located.

This is a bit concerning since I had not seen any reference to additional programs being needed, and what programs ??
This was followed by other warning dialogs about the data files containing details of cameras which were easily resolved.
The program then started with a work flow tree on the left, an OpenGL viewer in the middle with some controls for it on the right.
The first step is to load in some pictures which it did, but failed to find the camera details and complained that it could not proceed.

Step four: Debugging.
The program comes with (as in its a separate download) a CSV file of camera details - the model that is saved with the jpg image and the width of the image sensor. After about a day of hand tracing through multi-threaded code that uses wxWidgets (new to me) I finally get down to the code that parses the CSV file and discover that it has been trying to use ';' as the separator - truly weird.
It was then able to load the pictures and start searching for "matches" - bits of image that can be found on more than one photo.
This crashed the program.
So, I enabled core files, crashed it again, and fired up gdb.
The program was crashing when adding what looked like a vector of floats to a storage vector.
I have never seen this code fail, so I started to look for other problems, such as race conditions in the multi-threading.
That came up empty, so the next candidate was memory corruption - a nasty type of bug to find.
Valgrind is the answer to finding these memory issues. It found about 23000 problems, but none of them looked like the culprit.
[Not sure why there is so much access of uninitialised data in wxWidgets.]
So, time to dig a bit deeper and follow down the call sequence in the gdb back trace.
Turns out, what I thought was std::vector<float, 144> was actually a single column matrix from the eigen3 library.
Tracking down into that I find that it uses the new C++ move operator, but then tries to access the data that was just moved
Once that was fixed it was all fairly straight forward to use up to the point where it produces a "point cloud".

It displays the point cloud in its OpenGL view window - very small.
Now, the left mouse button does rotations, but the other buttons for pan and zoom don't work.
I then loaded the point cloud into Blender and zoomed in to see quite a nice 3D representation of the object in the photos.

There are two more steps necessary to get the model in a usable form - made up of triangles rather than points.
For these the program requires those missing third party programs

Looking at the tutorial for Regard3D there are links to the home pages for these programs.
So I now have 7 projects to build.
Once done I will have a rather comprehensive graphics processing collection.

Re: An accidental image processing collection.

Originally Posted by lsatenstein

When you go fishing, and when you catch a fish, you can't stop fishing until you reel it in.
Ditto for a project. Are you getting any sleep?

I have several projects which I am currently working on.
I spend a week or so on each one, and then move on to the next one.
I find a week is long enough to really get "into" the project and get something done.
The week might drag out a bit if what I am doing is keeping my interest, but in this case discovering I had another 7 things to build was the trigger to put it aside for a while.