Camera Calibration using Perspective Views of Rectangles

I have played around a bit. I think the reconstruction works, but the buildings in the scene are not parallel to each other. Even the pool seems to have odd angles. We don’t know at what rotation the other building is nor how far away it is. See the modified file for what I mean.

Attachments

Camera Calibration_Jul2017_v5_marcor.blend (1.37 MB)

I think the image is stretched or something has been applied which cant be match. I dont think they put the items in angles, doesnt look good if everything is straight and has angles.

The poles of that fitness build are in line of the other building, yet the roof just wont match up. As if its tilted, but if we look at the text, we see the wall is straight and the roof is flat on it. But i got the feeling something has been retouched there. This is a render as well, done by SO ON. Beautiful image.

Ill check your file, thanks!

Hi everyone

I have released version v0.4 with the help of rombout. There is almost no change in functionality, but note that the location is now

3D View > Tool shelf > Tools

by default. This can be changed in the add-on preferences dialog (File > User Preferences > Add-ons).

Enjoy!

Hi guys!
Sorry for delay with replying
Marcor, Rombout, thank you for your respond and for your efforts.
First of all i want to say that my goal was to define is it possible to match this photo without photoshop, distortion and rotation tweaks. So i used BLAM to make rough match (but its problem that it not fixes camera shifting) Than other tweaks i made just intuitively. And finally after 20 minutes of adjustments focal length and camera shifting i get the result which is almost perfectly fit.
Here it is.


Also to double check perspective i repeat photo match of this image in sketchup. So almost everything has a right angles including the table.

So my point is that if it possible to match manually there is sould be some algorithm which potentially can solve this automatically

Thank you Rombout for your tries but as you see no rotation needed

Marcor, according to one point perspective you are correct, sorry for my incompetence
-According To rectangles which i use.
unfortunately solve focal X+ Y isnt work fine for this scene so i adjusted image in crita to achieve parallel lines to solve it for +Y algorithm. and used this rectangular


So i get the result which is ok but far from perfect (only left side solved pretty good)


-According to hidden points of rectangular. You are correct but it can be predictable if to follow perspective lines

  • Resolution of image is really low but it’s enough for example to solve it in sketchup

In general i want to say that perhaps there is not exhaustive number algorithms here?
Maybe it is possible to use something similar to sketchup logic that allows to get better matches?
or took something from this project (CADtools)


Thank you for your attention. Best wishes

Hi Legofon

Thanks for your detailed reply. I think it’s nice that you managed to calibrate the camera somehow. Of course it would be better to have it done automatically.

I think the problem is that the input data to the add-on were not adequate to give a perfect result. You saw, it was nearly ok. Have you noticed, that in the back of the kitchen, where your rectangle is, there is a horizontal white counter dividing the black cupboards above and below. If you look to the very right of that counter, you will notice that the cupboard above is sligtly behind the front of the counter. The same must be true to the left side, but you can not see it clearly. I think that the cupboard below the counter is not receded in the same manner (I think one can see that, again to the right). Therefore, your rectangle is not perfectly vertical. You see, a subtle error is enough to give a result that is sligtly less than perfect. I may be mistaken about the geometry, but still, some slight error will have occured.

What to do about it? Well, the question is: what do you want to do with the result? Insert an object into the scene? A slight error will not be noticeable (most of the time). Reconstruct the kitchen? When the original image is not visible, nobody will know the difference. What do artists do, when they confront an unsolvable problem? They cheat!

Please do not get discouraged. Next time it will work perfectly, I’m sure. Otherwise: Remember this: https://github.com/mrossini-ethz/camera-calibration-pvr#things-you-should-know
marcor

Wups, I think I just managed it with this add-on. I used the rectangle that is selected in the image plus two dangling vertices at the ceiling (also selected). It’s near perfect.


marcor

Thank you for your thoughts, Marcor
Absolutely agree with you, in most cases 100% match is not needed, sometimes perfectionism is really annoying thing)) :D. But in case texture projection for example, accuracy is important.
Anyway addon is supercool and i’ll use it in future with great pleasure)):slight_smile:

By the way, just another workflow, not so cool but it works. (Cool is to stay in Blender:D)
Using Sketchup Make which is free, we can make quick camera match and then export this scene into dae (Collada), Than just import it into blender. This file includes camera which is already match to this perspective. So you need just drag and drop image into viewport, set to Camera and press “fit”. That’s it. And then we can continue with modeling.



Thank you one more time! Waiting for the new features !
Best wishes!!

WOW!! Awesome result !! Is this result with +X +Y algorithm?
I tried almost the same approach (The same plane and the same ceiling lines) but i failed for some reason and final result looks really far from original.
Anyway you proved that your addon works great!! I take my hat off!!
I see that I need learn it more deeply! Thank you!!

Marcor,
Just checked and repeated your steps…
YOU ARE GENIUS!!!
Really almost ideal match!! You just made me happy!!!
Love this addon!!! Many Thanks!!

So the Solve X+Y was done with this case, handy to know when and how to use that

Hi Legofon

With “texture projection”, do you mean projecting the image into the (reconstructed) scene? That means using UV coordinates that are “projected from view”? In that case, you can still cheat a little (if the camera calibration was not perfect) by tweaking the UV coordinates of your mesh. Do you agree?

marcor

Hi marcor

Yes exactly

Yes I am agree with you, also if to take into account that now perspective match is almost ideal, thats not a problem at all !

If anyone has any advice on this, it’d be really helpful.

I still haven’t managed to solve it, I just receive the same error, I know its something I’m probably doing wrong, I just can’t work out quite what it is.

Hi LionheartUK

Sorry, I didn’t see your post at all!

Have you had a look at the animated GIFs which I posted just recently that demonstrate the use of the add-on?

Is your mesh flat on the x-y-plane? Furthermore, the rectangle you made doesn’t seem to to represent any rectangle in your image.

I have no possibility to try the image at the moment, maybe someone else has.

marcor

I just tried it. To get Solve X+Y, you need to adjust every corner manually first and them make the 2 dangling verts. No line can be aligning else it give the error.

Here’s the file, if you go to top ORTHO view you see what i did.

Its bit difficult scene cause i think the perspective isnt correct. When i tried to do the stairs i noticed the verticals arent correct no more

Attachments


Sketched scene.blend (214 KB)

rombout beat me to it!

Here is my solution: Simply use “Solve Focal” (NO x- or y-shift) with a rectangle on the floor (selected in the screenshot). I had to eyeball the direction of the long edges by using the tiles on the near side.


The result is pretty much perfect.

marcor

Wow indeed, much better then mine! I went for one of the columns, but that results in problems as you can see.

Man this thing good :wink:

I had a idea, perhaps we can expand the tool by adding camera details if they are know. This way we could apply FOV, sensor height and width. I think thise could make the calibration more precise would it?

Not sure however how to implement such a thing :slight_smile:

Hi rombout

I know, this has been asked before. The problem is that your focal length (or FOV) are not precisely known. Even if you read the number off the camera’s lens, it will not be totally accurate (lens manufacturers lie and lenses have tolerances) and it may even depend on the focus distance. Sensor size does not really matter for calibration.

However, I think it would help in some situations, for example if you ‘Solve Focal’ and two sides of the rectangle are parallel (which will result in an error). You can avoid this normally by using ‘Solve Focal+Y’, but then it will solve for shift in y-direction as well (which may not be desireable).

Why don’t you open an issue (feature request) on GitHub and we’ll discuss it there! Everybody will be invited to join that discussion!

Have more knoledge will help get the image get better i think. Now its just wild guessing by angles.