📜 ⬆️ ⬇️

Let's make a fashion model in a quick way!

I don’t know what you thought there from the title, but know that I didn’t mean it! :)
So, we will continue to become “Columbians and discover what millions of people knew before us”, who will remember where this almost quote comes from (hint: about the Internet) to 4 points for geek karma. So…

So, in my free time, when I don’t create crazy projects, I don’t teach people how to make money on startups , at this time I study all kinds of geek technologies, including one of them has become an obsession with me. Namely - to take your town in the suburbs of a big city and turn it into a 3d-level for some game (in FarCry / Crysis I advanced most of all in this), with photogrammetric accuracy (errors of one meter or less from the actual location of houses ).

In order to do this we need:
  1. 3d models;
  2. 3d engine;
  3. science with the terrible name of photogrammetry;
  4. even mathematics — and when you read about Spherical harmonics — you rejoice that there was a primate for a while; sad that anyway you do not understand what is there ...
  5. a ton of patience (however, I would not be a world bummer if it were true);

Let's start with 3D models


')
In the years the dust has long been erased, when the Internet was still worn by horses in teams and angry Caesar decided to be your site on Google or not, in ancient times, MetaCreations existed, which created one of the most extraordinarily convenient and logical software products that I saw , but it was destined to go the way of the eternal light bulb and be chained in Adobe's dark, raw patent dungeons and never see the light again.

Besides, who wants to get to it now, it is necessary to ride at a speed of 5kb per second for three days, and the traveler can find her in the regions where his famous Pirates of the Intensive Streams of the Swedish Bay await him. [disclaimer: there is no subtext here]

In general, there are, my friends, such a science, photogrammetry. She is engaged in the fact that a flat, in general, photograph (and preferably 2 or fifty) turns into a three-dimensional model. This science is old, and the program about which I will tell is not younger (well, younger).

In general, we meet Canoma , created 9 [!] Years ago and has not yet been surpassed! (There is an ImageModeler , PhotoModeler , but besides that they cost a lot - none of them stood side by side for simplicity and visuality.

So, let's take a couple of photos of the area from different angles.


Zatrem cursors caught in the field of view of the camera.


In general, block nafig all deprived. :) This step is optional if you are not going to publish your original photos on the Internet. I took 3 photos, but save space - there will be many screenshots here.

/ If you have a bad imagination and the paragraph about the Swedes didn’t make you think, then the search for Canoma Demo on the Internet might tell you something. /

Open Canoma. Here it is before us. I remind you that the interface was made in 1999! Winda B learned how to do interfaces. By the way, much can be moved and rearranged (interface elements) by simple dragging.


Carefully looking at the picture will allow you to find the yellow arrow, click on the "+" and add one picture. And while you are looking for it, I will destroy one of the actors, no, not Netsuke , but the one who promises that I will feel the effect from him on the eighth day. Although, of course, it's better not to keep it open for eight days, otherwise the effect will be ... explosive ...

For those who want to know what the hell on the screen is, this is a bot of the Rare NewsNews going around on the Internet with Amazon EC2 - four bots more precisely - fastbot, regularbot, categorizerbot and studybot, even against the background of uploadbot, but it’s the most boring :) I told about this project in a post about earnings on startups. Well, for those who consider it most of all, this is “Ubuntu”, the book “Web-mastering for professionals”, which serves as a stand for two cards, a torn cover from the diary and a pipka from a tripod, which I don’t know what is called. :)

We return from thoughts about the lost Activia to the model. For Kanoma, all the usual rules of photogrammetry do not work, you need to start with one shot! It is necessary to apply as much as possible on one before moving on to the second. In the same ImageModeler much better results are obtained if you work with 2 photos at once. Here it is not necessary!

Now, you see the whole market of rounded icons from below - click on the leftmost one and see the red box (well, in general, this red mesh thing). Now let's imagine that this is a deck of cards in the photo, a front view and in this mesh we will grab the corners (with the mouse) and drag them onto the cards.



By the way, the usual rules of photogrammetry suggest that before using a photo - it needs to correct the curvature of the lenses (I put the first links from the Google SOAP API into links). This is done by the PTLens prog - it will make 10 photos for free, then pay (there are 10, it seems, dollars, but it’s not a pity for this program - it does everything itself and in batches, by the way if you make panoramas - it can also be very useful).




If you drag the top (where the lines are connected) - then try to put it exactly - use the "+" and "-" on the numeric keypad to move in and out; and the space and left button - drag the image ("hand tool").

You can also fix and face - then instead of an inverted triangle will be a circle. But, unfortunately, fixing faces is an order of magnitude less accurate than fixing vertices, so do all the vertices at once.

By the way, it is very important not to set vertices where you don’t see them - this is the so-called “guesstimation” (“guessing”), the more precisely everything will be arranged - the more accurate the result will be. Although, it is precisely Kanoma that is tolerated quite a bit. As you will see later, I am very lazily dotted, but I got quite an acceptable result.




On the left, you see such a thing (hereinafter, I will call it a “ball” or “sphere”). She can twist the model, by the way, in my opinion it is more convenient than in many 3D programs. Crosses - move the model. To return to the previous mode - click "Edit" above them. These wheels make it possible to understand - as Kanoma now thinks are located objects - sometimes it allows you to see the error.

What is important - by default, Kanoma assumes that all objects are located on the same plane - table, floor, etc. This is disabled via the button (i) in a circle - there is “Unfix Y” and other useful parameters - also Kanoma initially believes that objects are all exactly upright - you can also disable “Unfix all”, but these restrictions help her not to make creepy guesses about huge items. But, on the other hand, it is easy to forget about it (which I will do later :) and think about it only when writing this topic).

Try to put all the visible vertices of at least one “box” (in my case this is a deck of cards) before moving on.



Then I continued to apply vertices and edges. I fixed the table by sight. The plane (horizontal) is done with the second from the left “Horizontal Rectangle” icon - see the tips on the right. But I did not find the cylinder in Kanoma, so I had to imitate the mug through the “Curtain”. Next, another “box” is a book. And the sheet lying on the table. It is not very necessary, because the texture of the table will include it, but the usual rules of photogrammetry suggest that the more we put clear points that we see exactly (and the sheet contrasts well with the background), the better.



I made an action that fell in battles with this article through a truncated pyramid tool. And now we will twist, we will look that turned out. Not bad for a single photo.


Twist the scene, and to return to normal mode - «edit» (which is above the ball).

Next, with the help of one more box (“box”) we will make the necessary part of the laptop, and with the help of a vertical rectangle - the monitor. Now here are a couple of tricks.

The display of the laptop does not stand on the basis of the table, but on the box that simulates the lower part (with the keyboard). To “hang it up” in the air - you need to click on the button (i), it is next to the inscription “Solo off” and there press the “Unfix Y”.

The second trick is to “glue” its lower part to the top of the box. Simply put - to tell Kanoma that these two vertices are the same (at the junction) - so press CTRL and drag the lower left corner of the display to the upper left rear corner of the box imitating that part with the keyboard. Now they are stuck together.

By the way, if that - right-clicking on vertices, edges, adhesives, etc. - they can be deleted or modified.

The third trick - you can just put the lid on the laptop, but for this you had to press the Stack button on the bottom left before creating it. You can also indicate that two objects in the scene are concentrically on each other or have the same orientation (hussars, be silent!)


Twist the ball scene, let's see what happened. Activation as if a nuclear explosion smacked into a laptop. Well, nothing surprising in our time of the Large Colliders so surprise no one. Of course, this is due to the fact that from a single photograph of Kanome it is not visible that there is behind this dairy plant for the production of live bacteria. Add another photo, at the same time and more precisely arrange the objects.

But first! See the photo you want to add. Now twist the sphere (the ball to the left in the interface) with the 3d model so that it turns out approximately in the same perspective as in the photo. This is optional, but will help Kanoma to understand the location of the camera.



I missed this step intentionally to show that Kanoma is smart enough to find the correct camera position even from the past. I dragged all the corners that I saw in the photo to their rightful place, and fixed several edges, by the way it looks like this:


As you can see - the picture is superimposed very well.
Here it is important to tell that some lines will not coincide with what you see and this is a normal side effect of photogrammetry - there is no 100% accuracy there. But if you start to see the “Kanoma pulse” - this already means that you have hooked something in the wrong place. “Kanoma Pulse” is when the yellow lines of the outlines of objects (or the red one of the chosen) begin to beat like a heart.

[Zaum] Kanoma is constantly trying to polish the solution and is constantly on the move, solving huge matrices, and if you give incorrect input data, then due to the methods for solving these matrices (equations), an oscillating motion will be obtained (in the usual case, the solution error decreases, and the case of incorrect inputs - begins to oscillate around the solution, for details on the least squares method and the Levenberg- Markard algorithm and Sparse Bundle Ajustment . [/ zaum]


Well - it looks like it, at least for the purposes of a 5-minute 3d translation - not bad.


Click on Tortilla and enjoy the results of the laziest way to make 3d photos.




By the way, in Kanoma, you can do and animation - the tab on the bottom left. In general, there help PDF is very useful and not hammered by all sorts of reasons why this button is needed. Well done MetaCreations - a medal to them for a positive product and manual.

We export to .obj and sit down to think further about how to make the game real. I remind you that I had no idea what photogrammetry is and how it is eaten, and I didn’t have the aim to try to study it (although I had to), I just want to take a real city and make a 3d-level for the game. Did it happen with Kanoma (or even at all) - not yet, but for these purposes Kanoma came closer than everyone else (ImageModeler, PhotoModeler, Leica, etc.). I hope that someday VideoTrace will finish it all the same.

Why did not work? I have 10 thousand photos of the city. So on the fiftieth photograph of Kanoma she began to bravely mad, although only fifty buildings were applied. Well, in 1999 there was no GPU-support for a class of consumer video cards now, and if it were now rewritten for a GPU, I’m sure it would be thousands and a half, or even it would stand up.

Actually, the game and the virtual city on this have not even begun, there is something to tell, but for now you can read what I have already written .

As an example of what Canoma: Battersea Powerstation can do . And do not forget that it was made 9 years ago and has not been updated since. :)

By the way, it runs under Linux under Wine, as verified by Comrade. SovGVD .

PS There is also a way to very quickly and roughly model something like Netske - when the forms are very complex (Kanoma doesn’t do this) - the program is called 3DSOM ( examples here ), but I don’t even know how much I need to do it, it’s too simple :)

PPS Why this topic at all? I have a feeling that in the near future the Internet and the desktop will go tightly into the sphere of 3D, where we will travel around 3D worlds, put files into 3d boxes, etc. Taking into account where the technologies are moving - almost everyone will be able to create their own 3d world, often people (naturally) will want to recreate the place where they live or where they went on vacation. This technology is only a small part of what will happen in the future. It does not compete with serious 3D packages (although I cannot geo-geo in them either. One city can reproduce one building - yes, two buildings are relative to each other - something like - three - from photographs - almost unreal, three hundred? Don't be kidding ... the problem is not to model, namely to be geographically accurate).

In general, we will (possibly) live and work in virtual 3d-worlds (these technologies are getting cheaper and why not use them) - I would for example like to spread my files around the virtual shelves in the virtual room - it’s easier to remember where (in space we have been learning to navigate since childhood, and on a plane with nesting - only behind a computer).


Yoi Haji
view from Habra

Source: https://habr.com/ru/post/39932/


All Articles