
Creating a 3D scanner from a webcam, laser, and a bunch of radio components
Last year my friend and I were at a summer school. It was necessary to make a project on it. After reading two articles about the creation of 3d scanners ( one , two ), we decided to try our hand at assembling it and, if possible, improve its design. We did not even imagine what would come of it, and even more so did not imagine that we would win with him at several scientific and engineering exhibitions. But in order. Who cares to know the result, welcome under the cut (many photos).

First, we decided to assemble a laser rangefinder. It was made based on an article on the amateur forum. Just a laser pointer and a camera. For image processing, a Java program was written. For one measurement, two photographs were taken: with a laser and without a laser. After comparing them, we could definitely find the laser point. After it worked, the rangefinder was installed on a platform that could rotate in two planes. Before I show you what happened, I need to warn you - there are not so many materials at the summer school, and therefore we assembled a prototype from what we had:

The camera can be seen immediately, and the laser is that brass cylinder above it. To rotate the platform, we used two stepper motors, which in turn were connected to the control board on the Atmega32 microcontroller. A laser was connected to it. The board itself was connected to the computer via a USB-> UART adapter. The program on the computer took pictures, processed them, put the coordinates of the received points in a file and sent commands to the control board.
The result was interesting. Yes, we found the distance. Yes, we could “aim” at any point in the hemisphere above the scanner. And our joy knew no bounds. But when we estimated the scanning time of this hemisphere, it turned out to be 48 hours. And it's not the camera. And not even in Java. And the fact that the installation was so flimsy that it fluctuated after each turn for five seconds. I had to take a measurement, turn around and wait five seconds until it stops swinging. In addition, the library for the camera before each shot turned it on and then turned it off. It took 1-2 seconds. But the summer school was ending, and there was no time to redo it: it was already the night before the delivery of the project. Rather morning. The next day, we presented our project at a competition before the scientific jury and unexpectedly won. Probably,
In fact, the summer is over, and the school year has begun. The desire to work was gone. They planned to finish the installation for the next contest, which was a month before. Month. And then suddenly three days. But in a month, we decided to change the installation. To assemble it strong, install a lens on the laser pointer, which will create a laser line. This would allow scanning immediately 720 points (there was an HD camera in the scanner). Here are just three days have made their corrections:

The second scanner is assembled from plastic sighting rulers, glue, masking tape and keeps only thanks to the blue electrical tape. Instead of a lens is a test tube. A green laser shines on this test tube. The reflected beam creates a more or less uniform laser strip on the screen. The range finder is mounted on only one motor, which rotates it in a horizontal plane. The management board was replaced with STM32VLDiscovery. It's just that I know STM32 better, and even Atmega burned out, and the programmer was long lost. It doesn’t look very good, but it works! The oscillations decreased, and the speed increased accordingly. But not much. Here a very interesting catch was discovered - the Chinese laser pointer did not turn on immediately, but gradually increased its power within a second. Thus, a second for oscillations, a second for warming up the laser, a second for a shot, and there are two of them. So we get 4 seconds. But in one measurement, we find a distance of up to 720 points! The scanning process looked something like this:

And the result is this: The

picture does not look very interesting, but the circle was voluminous in the program. You could watch it from different angles.
And what exactly is the competition? But nothing! We finished scanning everything at 4 a.m., and at 9 a.m. we found at the stand that the laser was burned out. As it turned out, while we were carrying it from the hotel to the stand, it got rain, and when it was turned on, it burned down. But it looks inoperative so that it is difficult to believe in the words “it worked 5 hours ago”. We are upset. The desire to continue vanished with a haze from the laser. But still it was collected ...
And she was collected again for the competition. Moreover, we prepared for it for a long time and thoroughly. More than a week. And here is the result:

The first thing that catches your eye is that now we are scanning not the area around the scanner, but an object that rotates on the platform. And also we got the right lens, put everything together fine, rewrote the program, and also replaced the debug board with a home-made one. And now we take only one shot per measurement. The laser is powerful enough, and the lens is good enough to unambiguously find the laser in the photo. Due to this, we do not wait for the laser to warm up - it is always on. And now we turn on the camera only once. That is, time is spent mostly on the rotation of the platform and image processing. The program added a menu for selecting accuracy. Scanning time - from two to ten minutes. Depending on the selected accuracy. With maximum accuracy, it turns out that the platform rotates 0.5 degrees in a step, and the distance is determined with an accuracy of 0.33 mm. The platform is driven by a stepper motor through a gearbox. The platform itself is a large disk, and the rubber roller on the motor shaft is small. The motor and laser were controlled by the STM32F050F4 microcontroller through field-effect transistors. At the very beginning of the article, just a toy scan obtained using this scanner. Since the scanner produces a point cloud in the .obj format, after triangulation we can print the scanned object on a 3D printer, which can be seen in the same photo. On the screen we can see the model after triangulation. No manual work on the model was carried out. The motor and laser were controlled by the STM32F050F4 microcontroller through field-effect transistors. At the very beginning of the article, just a toy scan obtained using this scanner. Since the scanner produces a point cloud in the .obj format, after triangulation we can print the scanned object on a 3D printer, which can be seen in the same photo. On the screen we can see the model after triangulation. No manual work on the model was carried out. The motor and laser were controlled by the STM32F050F4 microcontroller through field-effect transistors. At the very beginning of the article, just a toy scan obtained using this scanner. Since the scanner produces a point cloud in the .obj format, after triangulation we can print the scanned object on a 3D printer, which can be seen in the same photo. On the screen we can see the model after triangulation. No manual work on the model was carried out.
We won the competition. And he gave a pass to the international Intel ISEF competition. And so we started working on the next scanner.

At the moment, this is the latest version of the scanner that we have collected. For comparison, the platform is the second version. We tried to approach the development of the fourth scanner as thoroughly as we could. The installation was drawn in CAD, the details are laser-cut, everything is painted, nothing extra sticks out from the outside. Changes: now the platform is really a gear. It is cut out of plexiglass and has 652 cloves around the edges. This solves the problem, which greatly damaged the scans in the previous scanner: the rubber roller slipped a little, which is why the platform often did not rotate 360 degrees. The scans were either with a “cut out piece” or with overlapping. Here we always knew exactly how the platform was turned. The laser power was made adjustable programmatically. Thanks to this, it was possible to change the laser power on the fly, Avoiding illumination of unnecessary parts in low light conditions. To control all the electronics, they decided not to breed a new board, but simply use the debug F401RE-Nucleo. It has ST-LinkV2.1 installed, which works as a debugger and USB-> UART adapter.
The accuracy was amazing: Angular resolution 0.14 degrees. By distance 0.125 mm. The scanning area is a cylinder with a height of 20 cm and a diameter of 30 cm. The price of all parts and laser cutting at the time of its creation (May 2014) was less than 4000 rubles.
In the process of use, we set the maximum accuracy only once. The scan lasted 15-20 minutes. Got almost 2 million points. The laptop refused to calculate the model from a point cloud. The experiment was no longer repeated.
In the near future we plan to resume work on the project, and therefore we will finalize both the program and the installation. I hope that in the near future we will write about the step-by-step assembly, we will lay out drawings, programs and everything else. This article will no longer fit.
Thanks to everyone who read to the end!
UPD:
A colleague found a video about the scanner, which we shot on ISEF:
Yes, most of the video is not interesting, but at the end of the model on the laptop.
And here are examples of scanned objects. But they all belong to the third version of the scanner.
Dropbox
In the model.obj file, you can clearly see what happens when this rubber roller slips on the motor - the dog has three eyes. Scanning was stopped, resulting in a cutout. All files are point clouds. You can open using MeshLab. Models were not handled. Completely raw data. Above you can see the "white spots" - areas without dots. The camera does not see them. White spots can also be seen in other places. They appear either in too dark areas, or when overlapping surfaces. For example, in the stn_10.obj file, the goat’s horns overlap, which is why the inner surface of the horns did not scan.

First prototype
First, we decided to assemble a laser rangefinder. It was made based on an article on the amateur forum. Just a laser pointer and a camera. For image processing, a Java program was written. For one measurement, two photographs were taken: with a laser and without a laser. After comparing them, we could definitely find the laser point. After it worked, the rangefinder was installed on a platform that could rotate in two planes. Before I show you what happened, I need to warn you - there are not so many materials at the summer school, and therefore we assembled a prototype from what we had:

The camera can be seen immediately, and the laser is that brass cylinder above it. To rotate the platform, we used two stepper motors, which in turn were connected to the control board on the Atmega32 microcontroller. A laser was connected to it. The board itself was connected to the computer via a USB-> UART adapter. The program on the computer took pictures, processed them, put the coordinates of the received points in a file and sent commands to the control board.
The result was interesting. Yes, we found the distance. Yes, we could “aim” at any point in the hemisphere above the scanner. And our joy knew no bounds. But when we estimated the scanning time of this hemisphere, it turned out to be 48 hours. And it's not the camera. And not even in Java. And the fact that the installation was so flimsy that it fluctuated after each turn for five seconds. I had to take a measurement, turn around and wait five seconds until it stops swinging. In addition, the library for the camera before each shot turned it on and then turned it off. It took 1-2 seconds. But the summer school was ending, and there was no time to redo it: it was already the night before the delivery of the project. Rather morning. The next day, we presented our project at a competition before the scientific jury and unexpectedly won. Probably,
Version two
In fact, the summer is over, and the school year has begun. The desire to work was gone. They planned to finish the installation for the next contest, which was a month before. Month. And then suddenly three days. But in a month, we decided to change the installation. To assemble it strong, install a lens on the laser pointer, which will create a laser line. This would allow scanning immediately 720 points (there was an HD camera in the scanner). Here are just three days have made their corrections:

The second scanner is assembled from plastic sighting rulers, glue, masking tape and keeps only thanks to the blue electrical tape. Instead of a lens is a test tube. A green laser shines on this test tube. The reflected beam creates a more or less uniform laser strip on the screen. The range finder is mounted on only one motor, which rotates it in a horizontal plane. The management board was replaced with STM32VLDiscovery. It's just that I know STM32 better, and even Atmega burned out, and the programmer was long lost. It doesn’t look very good, but it works! The oscillations decreased, and the speed increased accordingly. But not much. Here a very interesting catch was discovered - the Chinese laser pointer did not turn on immediately, but gradually increased its power within a second. Thus, a second for oscillations, a second for warming up the laser, a second for a shot, and there are two of them. So we get 4 seconds. But in one measurement, we find a distance of up to 720 points! The scanning process looked something like this:

And the result is this: The

picture does not look very interesting, but the circle was voluminous in the program. You could watch it from different angles.
And what exactly is the competition? But nothing! We finished scanning everything at 4 a.m., and at 9 a.m. we found at the stand that the laser was burned out. As it turned out, while we were carrying it from the hotel to the stand, it got rain, and when it was turned on, it burned down. But it looks inoperative so that it is difficult to believe in the words “it worked 5 hours ago”. We are upset. The desire to continue vanished with a haze from the laser. But still it was collected ...
Third version
And she was collected again for the competition. Moreover, we prepared for it for a long time and thoroughly. More than a week. And here is the result:

The first thing that catches your eye is that now we are scanning not the area around the scanner, but an object that rotates on the platform. And also we got the right lens, put everything together fine, rewrote the program, and also replaced the debug board with a home-made one. And now we take only one shot per measurement. The laser is powerful enough, and the lens is good enough to unambiguously find the laser in the photo. Due to this, we do not wait for the laser to warm up - it is always on. And now we turn on the camera only once. That is, time is spent mostly on the rotation of the platform and image processing. The program added a menu for selecting accuracy. Scanning time - from two to ten minutes. Depending on the selected accuracy. With maximum accuracy, it turns out that the platform rotates 0.5 degrees in a step, and the distance is determined with an accuracy of 0.33 mm. The platform is driven by a stepper motor through a gearbox. The platform itself is a large disk, and the rubber roller on the motor shaft is small. The motor and laser were controlled by the STM32F050F4 microcontroller through field-effect transistors. At the very beginning of the article, just a toy scan obtained using this scanner. Since the scanner produces a point cloud in the .obj format, after triangulation we can print the scanned object on a 3D printer, which can be seen in the same photo. On the screen we can see the model after triangulation. No manual work on the model was carried out. The motor and laser were controlled by the STM32F050F4 microcontroller through field-effect transistors. At the very beginning of the article, just a toy scan obtained using this scanner. Since the scanner produces a point cloud in the .obj format, after triangulation we can print the scanned object on a 3D printer, which can be seen in the same photo. On the screen we can see the model after triangulation. No manual work on the model was carried out. The motor and laser were controlled by the STM32F050F4 microcontroller through field-effect transistors. At the very beginning of the article, just a toy scan obtained using this scanner. Since the scanner produces a point cloud in the .obj format, after triangulation we can print the scanned object on a 3D printer, which can be seen in the same photo. On the screen we can see the model after triangulation. No manual work on the model was carried out.
We won the competition. And he gave a pass to the international Intel ISEF competition. And so we started working on the next scanner.
Fourth version

At the moment, this is the latest version of the scanner that we have collected. For comparison, the platform is the second version. We tried to approach the development of the fourth scanner as thoroughly as we could. The installation was drawn in CAD, the details are laser-cut, everything is painted, nothing extra sticks out from the outside. Changes: now the platform is really a gear. It is cut out of plexiglass and has 652 cloves around the edges. This solves the problem, which greatly damaged the scans in the previous scanner: the rubber roller slipped a little, which is why the platform often did not rotate 360 degrees. The scans were either with a “cut out piece” or with overlapping. Here we always knew exactly how the platform was turned. The laser power was made adjustable programmatically. Thanks to this, it was possible to change the laser power on the fly, Avoiding illumination of unnecessary parts in low light conditions. To control all the electronics, they decided not to breed a new board, but simply use the debug F401RE-Nucleo. It has ST-LinkV2.1 installed, which works as a debugger and USB-> UART adapter.
The accuracy was amazing: Angular resolution 0.14 degrees. By distance 0.125 mm. The scanning area is a cylinder with a height of 20 cm and a diameter of 30 cm. The price of all parts and laser cutting at the time of its creation (May 2014) was less than 4000 rubles.
In the process of use, we set the maximum accuracy only once. The scan lasted 15-20 minutes. Got almost 2 million points. The laptop refused to calculate the model from a point cloud. The experiment was no longer repeated.
Conclusion
In the near future we plan to resume work on the project, and therefore we will finalize both the program and the installation. I hope that in the near future we will write about the step-by-step assembly, we will lay out drawings, programs and everything else. This article will no longer fit.
Thanks to everyone who read to the end!
UPD:
A colleague found a video about the scanner, which we shot on ISEF:
Yes, most of the video is not interesting, but at the end of the model on the laptop.
And here are examples of scanned objects. But they all belong to the third version of the scanner.
Dropbox
In the model.obj file, you can clearly see what happens when this rubber roller slips on the motor - the dog has three eyes. Scanning was stopped, resulting in a cutout. All files are point clouds. You can open using MeshLab. Models were not handled. Completely raw data. Above you can see the "white spots" - areas without dots. The camera does not see them. White spots can also be seen in other places. They appear either in too dark areas, or when overlapping surfaces. For example, in the stn_10.obj file, the goat’s horns overlap, which is why the inner surface of the horns did not scan.