• ### Sub-Pixel Laser Line Detection

This post will describe the method I use to detect the center of the laser line for each row in the image. We can divide the process into two steps:

1. Capturing an image of the laser line
2. Calculating the center of the laser line.

## Capturing an image of the laser line

The basic idea for capturing an image of the laser line is to take two images of the object, one image will have the laser turned off and the other one will have the laser turned on. If these images are taken in a short time span the the difference between them should only be the laser line. For this to work a background with no movement is required, otherwise the movement will show up in the final image. The images are also captured in greyscale for easier computing.

## Calculating the center of the laser line

The center of the laser line can be approximated with sub-pixel accuracy by using the method for calculating the weighted mean, this works since the intensity of the laser line will be highest at the middle and lower at the edges as illustrated here:

By giving each pixel a number based on the number of pixel distance from the left side of the image. The first pixel will be 0, the second 1, third 2 and so on. Each pixel will also have an intensity value from 0 to 255 that will be used as the weights. The following equation can then be used to approximate distance from the left side to the center of the laser line:

We then calculate this for each row of the image and store it in a vector so that we can use it to triangulate the position i 3D space.

There are some downsides to this method and that is that the timing between the camera and the lasers needs to be quite good to not miss the laser line. My solution for this is to wait a couple of frames before capturing the images.

-- FilleK

• ### First Post!

So about a year ago I decided to build a 3D scanner and I spent a couple of month building a prototype (shown in the picture below), but the project was put on the shelf after that due to my final project at university. Now that I have some more free time I have started to build on my scanner again. I have built a proper version of the scanner that is more refined and less of a quick prototype. The only thing missing is the motherboard and a rewritten software. I will try to give a quick description of the hardware and software in the following sections.

## Hardware

I have built the scanner using mainly plywood for the simpler parts and then used a 3D printer for the more complicated parts. The scanner has got a removable lid to make it easier to transport and store without the risk of damaging the more sensitive parts.

The scanner is using a Logitech C920 web-cam to capture the images of the object. I would probably choose a different camera if i were to redesign the scanner, this mainly due to the auto focus function of the camera which i have not found a good way to control from the OpenCV library. The camera also buffers the images which makes it a bit tricky to get the timings right.

There are two line lasers mounted on either side of the camera at an angle of 30 degrees, this makes it possible to triangulate the position of the generated line. The lasers are a couple of cheap line lasers I found on eBay, the main criteria i had when choosing the laser was that it should be bright enough for the camera to be able to see it but not so bright that it would burn the object or my eyes.

The lasers and camera are then pointed at a rotary table where the sample is placed. The table is rotated with a stepper motor that is controlled by the easy-driver from Sparkfun. I might change it for a spare driver from my 3D printer since it runs a bit cooler (and has a smaller footprint).

All the hardware (except the web-cam) are controlled with a teensy 3.1 board that communicates with the computer over usb.

## Software

The software is currently being written in C++ with the OpenCV library for image processing and the HidAPI for communicating with the teensy board. I am currently looking into the point cloud library for processing the scanned cloud.

If you have any questions don't hesitate to write a comment below.

-- FilleK