## FreeCAD – 1 dimension + photo = 3d drawing

Vailala
Posts: 11
Joined: Wed Aug 31, 2016 9:07 pm
Location: New Zealand

### FreeCAD – 1 dimension + photo = 3d drawing

I like to draw and sometimes make models of antique steam locos. When I first started using FreeCAD I thought that I needed to have 5 dimensions in each of the x,y and z planes in order to make an accurate drawing. But more often than not you have to work with a smaller dimension set. To compensate for this shortage of information I have made a lot of use of photo comparisons. More recently I experimented with a cloud-based software where a photo image is manipulated to produce an stl file. I decided not to continue to use this software for two reasons. It has some inherent limitations and I thought it possible that I could attain my ends more quickly and more simply by exploiting the resources to be found within FreeCAD.

I began by loading a photo image and attempting to manipulate the drawing primitives off-plane, in rotational space, and in the perspective view – a headache inducing experience. Both time-consuming and heading in the wrong direction. You end up making a perspective drawing. But there’s a sense in which your photo-image is already a perspective drawing so why not just find ways to extrapolate your needed dimensions from the photo to make your standard side and end view 3d solid drawing.

Doing this turned out to be easier than I anticipated. My inspiration was to reverse engineer the method developed by Chapman in the 18th century (Architectura Navalis Mercatoria, 1768) of using “radial diagonals” (a single radial diagonal can be decomposed into the two x, y measurements). So how can you find the “radial diagonals” in your photo and derive from them the x,y dimensions you want?

The attached image (Gauging Drawing) shows how to get what you want from the photo-image. The drawn lines are “cubes” from which we can directly read heights above rail level, e.g. wheel diameter and boiler height for both front and rear wheel. The ratio of the front wheel height and boiler height is 3.1171. The ratio for the rear wheel height and boiler height is 3.1 (3.1 /3.1171 = 0.9945) – as measured from the photo. Checking the respective horizontal width of the front and rear wheels gives a “shrinkage” rate of 0.9875 as we traverse the longitudinal dimension from left to right. At this point we can feed in the one known dimension of wheel diameter and start calculating a large set of dimensions (frame height, boiler diameter, boiler pitch height, wheelbase, etc, etc.

I checked this method on a photo of a loco for which I already had many dimensions and some drawings. I found that the photo-based approach was usually no more than 1/2 of a scale inch out (less than 1%). Or was it “out”? I can’t get much better than this using scaled drawings since line-thickness is always an issue. Dimensions may help but these too sometimes contain drawing office errors and not everything comes from the machine shop having exactly the same dimensions as specified on the drawing.

Limitations? I am greatly helped by the fact that the 19th C steam locos I draw are basically composed of cubes and cylinders. Also, some photos are much easier to work with than others. Especially when they are taken with a standard or long focal length lens and the camera is held at eye level and not tilted up or down. Bearing in mind these qualifications my conclusion is that it is possible to make an accurate 3d solid drawing based on a photo and one dimension.

The image Sketch0001 is an incomplete 3d drawing of a loco from a photo. But from this point on most of the work is just filling in the details.

I hope this ramble is of some interest to somebody.

Cheers,

Vailala
Attachments
Sketch0001.jpeg (76.83 KiB) Viewed 5044 times
GaugingDrawing01.jpeg (79.19 KiB) Viewed 5044 times
microelly2
Posts: 4244
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

### Re: FreeCAD – 1 dimension + photo = 3d drawing

It's realy a hard job to get the 3D model back from a perspective photo.
I started work on a reconstruction wb some month ago
viewtopic.php?f=8&t=14595
it's possible to get a lot of information out of an image, but human interaction is necessary.
having multiple images from different viewpoints with the same camera is a good way to reconstruct the 3rd dimension.

In your case there are 2 circles of the wheels. This information and the focla lenght of the camera can be used to create a parallel projection image from the perspective one in a first step.
It's interesting how to get 3D models back.
Vailala
Posts: 11
Joined: Wed Aug 31, 2016 9:07 pm
Location: New Zealand

### Re: FreeCAD – 1 dimension + photo = 3d drawing

Thank you Microelly for your comment. While searching for help on the topic of drawing from photos I read your thread. I thought your approach had merit but it seemed to me to be too complicated for my purposes and what it promised also seemed to me to lie far off in the future.

Instead I decided to reject all the traditional approaches to drawing from photos as rooted in ancient drawing board practices. It would be quite possible to use the photo and draw lines to vanishing points, etc, enter camera lens data, etc. But I thought doing so was unnecessarily complicated and somewhat neglectful of the maths concepts inherent in the OCC kernel.

The first thing I began looking for in the photo was a tensor metric, a single number that encapsulates all the x,y dimensions. From this point of view I am looking at the loco as a 2d and 3d simplectic manifold, or Hamiltonian matrix, i.e. as a topological entity.

But to me the important step is to realise that you don’t want to draw the loco. Rather you want to draw the mold into which the loco has to fit. That’s the purpose of the gauge bars. If you imagine a model boat hull pressed into soft sand then your task is to draw the mold. But you don’t need to “skin” the mold, simply establishing a set of gauge points is enough and these can be put on the screen in a skeletal way.

The method I have outlined will work for many (most? all?) objects. Cultural clues are not really relevant (e.g. wheels are oval in a photo, but we know they are round) although their use does give us mental comfort. There is no problem in drawing a house from a photo using this method, except that houses, unlike locos are not usually built on a mirror plane so you will need two photos.

From another point of view we are simply looking for a way to derive an x,y,z view from an object in “rotational space” (which looks to me to be the Hamiltonian 4th dimension) and our object can be viewed as a topological entity defined by boolean values arranged in a lattice. Is this how the scaling function works? It seems to me that conceptualising the issues mentioned in your thread in this way might advance things.

Cheers

Vailala
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm

### Re: FreeCAD – 1 dimension + photo = 3d drawing

Hello Vailala,

I did find your explanations very interesting! The question of building models from photos has been mentioned in the past in the Help forum. When it gets asked again, I'll be sure to link to your topic.

Thanks for sharing!

Norm
chrisb
Posts: 15271
Joined: Tue Mar 17, 2015 9:14 am

### Re: FreeCAD – 1 dimension + photo = 3d drawing

I once tried to redraw a car from a photo - what a nightmare. It would have been easier and the result would probably have been better if I had known what you presented here.
mario52
Posts: 2535
Joined: Wed May 16, 2012 2:13 pm

### Re: FreeCAD – 1 dimension + photo = 3d drawing

hi
here other macro for use bmp image Macro_Texture

one example use with points How to handle pdf import properly and feasibly?

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets. My macros on Gist.github
Vailala
Posts: 11
Joined: Wed Aug 31, 2016 9:07 pm
Location: New Zealand

### Re: FreeCAD – 1 dimension + photo = 3d drawing

I had read Mario’s threads some little time ago when I was considering how best to do the lettering on the O&K coach (described below on this forum) and I decided then not to use the procedure of plotting points, join lines, lofting, etc. In those cases where the photo image is more or less “square on” to the camera it is quicker and much simpler to simply draw over the letters with 3d primitives – cubes and cylinders. The minor variations on the photo plane can be simply ignored and accuracy checking can be done by looking for 3-point coincidences. The final result can be cloned/scaled. This works for all fonts I have tried so far. Others, such as italic fonts, may need to be shear mapped. Minor variations between your primitive on the screen and the background image will also be found when drawing/tracing over a digitised plan copied from a paper original. The paper may not have been held flat, copier lens distortion may be present, the paper may have been subject to differential stretch, etc.

As far as deriving an x,y,z view from a perspective view (photo or drawing) is concerned it’s worth noting that Chapman’s radial diagonals (utilising Simpson’s 1750 “Method of Fluxions”) seemed true but remained a conjecture until Kolmogorov’s 1930 proof (complexity function, hypercubes) – and his other 1930 paper on intuitionist logic which gives us the Brep fail report. Brep “true” reports are non-computable since the machine cannot know the purpose of our drawing.

I have looked over a number of different approaches to the problem of deriving x,y, z views from perspective drawings. It’s a fact that FreeCAD and other programs have no difficulty in giving us a perspective view of an x,y, z drawing. This is simply done to the whole screen by method of quaternions (Hamiltonians, 4d space), and calculating quaternion values. For manipulating individual objects in rotational space, if you want to avoid the “Transform” function, you need to find the geometric centre of the object. This can be found by using the “Slicer” function on each of the x, y and z axes to locate the geometric centre. The slicer axes can then be manipulated to correspond with the “perspective image” and the cylinder positioned over this image. The attached sketch shows a cylinder that started as diam 20 height 30 and then altered to diam 8 height 40. The positioning axes are aligned to the photo image centrelines. The lesson from this is that it’s far easier to manipulate the x, y, z slicer planes (which automatically throws the object into a perspective view) than it is to directly manipulate the object in rotational space. Scaling can also be used effectively in this context. The x, y, z scaling function is located at the geometric centre of the object and uses quaternion values for calculation purposes.

Doing things in this way is not entirely useless but it also illustrates that it is probably simpler and quicker to gauge and make a straight drawing in another window, as I chose to do. Whichever way you choose to go quite a bit of semantic input is required.

Putting the issue another way, while a 3d perspective drawing in a “Hamiltonian space” can be easily converted to a 3d drawing in Euclidean space the same cannot be said of a 2d photo image. To do so requires additional axial dimensional metrics, the creation of a 3d “cloud” of points and the use of functions such as Kolmogorov complexity in a hypercube context.

For drawing more complex curvilinear objects (organic shapes) the scaling function becomes invaluable. I have found it to be useful when making some drawings of indigenous Papua New Guinea architecture, shapes similar to the original Sydney Opera house sketches. Please be assured, NormandC, that I otherwise always follow your excellent advice.

Perhaps the functionality of FreeCAD may be enhanced by increasing the scaling axes from 3 to 6 and even 9.

Again I would like to express my gratitude to FreeCAD and its commentators and maintainers for providing a wonderfully interesting desktop of ideas.

Cheers,

Vailala
Attachments
Boiler image.jpeg (40.59 KiB) Viewed 4584 times