Skip to content

mfkiwl/Aligner

 
 

Repository files navigation

Aligner

Vision Aligning Software with CUDA, C++ and Python on Nvidia Jetson Nano

An aligner is a device that uses two cameras to correct a rotated and shifted object.

Each camera detects rotation and shifting of the region of interest.

This software locates the changed region of interest.

OpenCV's template matching is vulnerable to rotation and cannot be used.

So I implemented an algorithm using GPU.

CUDA, C++ (Calculation) <----- share memory -----> Python(Web viewer, Django)


(CMakeLists.txt -> Edit cuda version)

mkdir build

cd build

cmake ..

make

./Aligner


Idea of finding a rotated object

  1. In a circular region, an object rotated about the midpoint of the region has the same mean, variance, skewness, and kurtosis as compared to the original(the mean, variance, skewness, and kurtosis are called moments vectors).

  2. The circular integral of an object is maintained as it rotates around the center of the circle

At 2, circular integration is slow because it is difficult to utilize the GPU's shared memory and caching.

At 1, Specify a rectangular area instead of a circular area, Can utilize the GPU's shared memory and caching, which is fast.

However, it is inaccurate because it is not a circular region.

Therefore, the moment vector is found in the rectangular area to quickly determine the candidate group. After that, the correct coordinates are returned by using 2.


Algorithm progress (CUDA, C++, image process)

  1. Grab Scene

  2. Set object(pattern)

  3. Compute object's info (1st~4th moments vector, circular integral vector with a radius dimension, ...)

  4. Specify the ROI(search area, near the object) in the scene

  5. Grab rotated and shifted Scene

  6. Search object in ROI(using CUDA)

6.1. moments vector comparison

6.1.1. Compute the moments vector for each pixel in the ROI

6.1.2. Compare the moments vector of the object with the moments vector of the pixels in the ROI.

6.1.3. A candidate group is extracted by applying an adaptive threshold.

6.2. circular integral vector comparison

6.2.1. Calculate a circular integral vector with a radius dimension for the candidates.

6.2.2. Compare the circular integral vector of the object with the circular integral vector of the pixels in the ROI. get correlation coefficient

6.2.3. Extract the coordinates with the highest correlation coefficient


structure(CUDA, C++) :

AlignerLauncher

----Aligner

--------PatternMatching

------------CudaSupporter

--------Grabber

--------MemorySharing

--------//Webcam

--------kbhit

AlignerConsts

<----- shared memory -----> Python(Web viewer, Django)


AlignerLauncher : Launch C++ and Python

Aligner : Set and free shared memory, set and free camera, image process, communicate with python

PatternMatching : Manage GPU memory, launch CUDA kernel, image process using OpenCV

CudaSupporter : Image process, use CUDA to find the moment vector and circular integral vector for each pixel.

Grabber : Pylon camera class, set and dispose camera and grab

MemorySharing : Memory share with python. Sharing memory in bytes. Images are shared as a one-dimensional byte array. Numbers greater than 255 are shared by the number's quotient and remainder.

Webcam : If you have no pylon camera, activate this and modify CMakeLists

AlignerConsts : Consts

kbhit : Key press check function


Result Existing PC for aligner takes 200ms or more per image, and the price is more than 600$(2021.08.).

On the other hand, this software does not require Windows and input/output devices, and takes less than 50ms per image.


슬라이드1 슬라이드2 슬라이드3 슬라이드4 슬라이드5 슬라이드6 슬라이드7 슬라이드8 슬라이드9 슬라이드10 슬라이드11 슬라이드12 슬라이드13 슬라이드14 슬라이드15 슬라이드16 슬라이드17 슬라이드18 슬라이드19 슬라이드20 슬라이드21 슬라이드22 슬라이드23 슬라이드24 슬라이드25 슬라이드26 슬라이드27 슬라이드28 슬라이드29

About

circuit alignment software with CUDA

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 39.7%
  • Cuda 32.1%
  • Python 16.9%
  • HTML 6.5%
  • C 3.5%
  • CMake 1.3%