3D laser scanner on Android phone


I present to you a DIY scanner based on an Android smartphone.

When designing and creating a scanner, first of all, I was interested in scanning large objects. Minimum - a man in full growth with accuracy - at least 1-2 mm.

These criteria have been successfully met. Objects are successfully scanned with natural light (without direct sunlight). The scan field is determined by the capture angle of the smartphone's camera and the distance at which the laser beam maintains sufficient brightness for detection (during the day in the room). This is a man in full growth (1.8 meters) with a capture width of 1.2 meters.

The scanner was made out of considerations "and not whether to do anything more or less useful and interesting, when there is nothing to do." All illustrations are based on the example of a “test” object (it is not correct to post scans of people).

As experience has shown, for a scanner of this type of software it is a second time and the least time was spent on it (on the final version. Apart from experiments and dead ends). Therefore, I will not discuss the features of the software in the article (Link to source codes at the end of the article.)

The purpose of the article is to talk about dead-end branches and problems gathered on the way to creating the final working version.

For the scanner in the final version is used:

  1. Samsung S5 Phone
  2. Red and green lasers with a lens for the line (90 degrees line) at 30 mW with glass optics (not the cheapest).
  3. Stepper motors 35BYGHM302-06LA 0.3A, 0.9 °
  4. A4988 Stepper Motor Drivers
  5. Bluetooth module HC-05
  6. STM32F103C8t board

Drivers A4988, exhibited at half step, which with a gearbox 15-> 120 gives 400 * 2 * 8 steps to PI.

The choice of scanning technology.


The following different options were considered.

LED Projector.


The option was considered and calculated. Even expensive projectors do not have the necessary resolution to achieve the required accuracy. And about cheap it even makes no sense to talk

Mechanical scanning of a laser beam in combination with a diffraction grating.


The idea has been tested and found valid. But not for DIY execution, for reasons:

  1. We need a sufficiently powerful laser, so that after diffraction, the labels are bright enough (the distance to the smartphone lens is 1..2 meters). And my eyes are pitiful. Laser dot already with 30mW is not useful.
  2. The requirements for the accuracy of mechanical scanning in 2 planes are too high for DIY execution.

Standard mechanical laser-line scan to a fixed scan object.


In the end, a variant with two lasers of different colors was chosen.


  1. Different colors of lasers allow you to independently detect them on the same frame.
  2. The arrangement of lasers on different sides of the camera allows you to get two scans in one pass.
  3. Two scans at a time allows you to objectively assess the quality of the scanner alignment (scans should converge and overlap each other).

As it turned out, the last criterion is the most important. The scan quality is entirely determined by the accuracy of measuring the geometric dimensions and angles of the scanner. And the presence of two scans from two lasers allows you to immediately assess the quality of the scan:
Clouds of points converged. Those. planes captured by two lasers converged on the entire surface.

Unsuccessful version of the mechanical part of the 28BYJ-48.



Although from the very beginning I assumed that this was a dead-end option that did not provide the necessary accuracy, I still checked it with various tricks:

  1. The axis of the motor is fixed bearing.
  2. Added friction element and a stopper for sampling gear play.
  3. An attempt to determine the "exact position" of the phototransistor, by laser illumination

The repeatability of the return to the same place of the laser line was low - 2-3 mm at a distance of 1.5 meters. During the operation of the gearbox, despite the apparent smoothness, jerks of 1-3 mm are visible at a distance of 1.5 meters.

Those. 28BYJ-48 is not completely suitable for a more or less accurate scanner of large objects.

Scanning requirements from my experience


Mandatory element sweep must be a gearbox.

Do not be mistaken about the mode 1 / x steps. Experiments have shown that in the 1/16 mode on the A4988 micro steps are not uniform. And at 1/8 this unevenness is noticeable by eye.

The most optimal solution for the gearbox was the use of a belt gear. Although it turned out quite cumbersome, but easy to create and accurate.
The positioning accuracy (more precisely, the repeatability of the positioning of the initial position of the lasers for scanning) of the lasers turned out to be about 0.5 mm for a 5 mm laser line width per 4 meters distance. Those. at a scanning distance (1.2-1.8 meters) it is generally difficult to measure.

Positioning - optocouplers (Chinese noname) on the slot in the disk under the lasers.

Problems with the transmission of control signals from the phone to the laser and stepper motors control module


The bottleneck in terms of scanning speed was the control channel. Since this was a DIY leisurely development at its own pleasure, all methods of communication with the smartphone were tried.

Sending control signals via Audio jack (phone Audio jack => oscilloscope)


The most braking way to transfer data in real time. Yes, with floating time. Up to 500 ms (!) From program activation of audio data transmission to the actual appearance of a signal in the Audio jack.

This exotics was verified because, by work, we had to deal with mobile readers of chip cards.

Photodiodes on the screen of the smartphone (a piece of the screen of the phone => phototransistors + STM32F103)


For the sake of interest, even such an exotic method as phototransistors with a 2x2 matrix in the form of clothespins on the screen was tested.

Although this method of issuing information from the phone turned out to be the fastest, but not so fundamentally faster (10 ms vs 50ms) than Bluetooth, which would put up with its shortcomings (a clothespin on the screen).

IR channel (phone => TSOP1736-> STM32F103)


The method of transmission through the IR channel has also been practically tested. Even some implementation of the data transfer protocol had to be done.

But IR also turned out to be not very convenient (the photo sensor is inconvenient to mount on the phone), and not too faster than Bluetooth.

WiFi module (phone => ESP8266-RS232-> STM32F103)


The results of testing this module turned out to be completely discouraging. The request-response (echo) execution time turned out to be unpredictably floating in the range of 20-300 ms (on average 150 ms). Why and what - did not understand. I came across only an article about the unsuccessful attempt to use ESP8266 for real-time data exchange with stringent requirements for request / response time.

Those. ESP8266 with “standard” TCP firmware -> RS232 is not suitable for such purposes.

Selected version of the control module and signaling


Finally, after all the experiments, the Bluetooth (HC-05 module) channel was selected. Gives stable (and this is the most important) data transfer request-response in 40ms.

The time is quite large and greatly affects the scan time (half of the total time).
But the best option was not achieved.

As a control module is a widespread board with SM32F103C8T.


Methods for detecting lines on the frame.


The easiest way to select laser lines in a frame is to use frame subtraction with the laser turned off and the laser frame.

In principle, the search for the frame without subtraction also works. But it works much worse in daylight. Although this mode was left in the software for comparative tests (photo mode below. All other photos with frame subtraction mode).


The practical value of the option without subtraction of frames was low.

It is possible and possible to extract the laser signal from this noisy information. However, he did not bother.

The frame subtraction option works well.

Any experiments with attempts to approximate the line and processing the entire frame showed that the more complex the algorithm, the more often it “makes a mistake” and also slows down the processing “on the fly”. The fastest (and simplest) laser search algorithm (laser point) on the horizontal line turned out to be:


Time for processing one frame by searching for “green” and “red line” - 3ms.

Clouds of points for the red and green laser are considered separately. With proper mechanical adjustment, they are reduced to an accuracy of <1 mm.

Accuracy and adjustment


Accuracy was within 1 mm at a distance of 1.2 meters. For the most part due to the resolution of the camera phone (1920x1080) and the width of the laser beam.

It is very important to get the static and dynamic settings for getting the correct scans. The accuracy / non-accuracy of the settings is clearly visible when loading both point clouds in MeshLab. Ideally, the clouds point should converge, complementing each other.

Static parameters are set as accurately as possible once:

  1. The tangent of the angle of view of the camera.
  2. Length "shoulders" of lasers (from the center of the lens to the axis of rotation).

And of course, the maximum focusing of laser lenses at a given scanning distance and “verticality” of laser lines.

The dynamic parameter of the actual angle of the position of the lasers relative to the virtual plane of the frame has to be adjusted every time when the phone is mixed in the mount. To do this, set up mode in the software. By placing the lasers in the center of the screen and adjusting the angle, it is necessary to set the calculated distance as close as possible to the true (measured) distance for both lasers.

Before adjustment:


After adjustment:


findings


This design, perhaps, can be repeated by anyone. I cut all the parts from fiberglass on the CNC.

Of course, without a CNC router, it is difficult to make a pulley for a laser. But given the fact that you need a rotation angle of a maximum of 90 degrees, then with proper patience you can also cut out the pulley with a needle file.

But it is better to do everything on the CNC. The requirements for axial play of the swivel unit are high. Scan quality is 100% determined by manufacturing accuracy and alignment.

The scanner did in the background. At times with breaks for a couple of months. Therefore, I cannot estimate the total complexity of its creation.

The total cost of the design is not too high. As shown by my experiments, although it is far from industrial scanners of large objects, you can get quite decent scans.
The quality of scans in the first place affects the accuracy of the mechanical part. In this sense, in DIY it is difficult to deal with the mechanics created for industrial scanners.

Source

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


All Articles