MENU
7 DIGITAL IMAGE PROCESSING
The main aim is created an scanner 3D where we will captured several images with differentes angles of the object. We can create a point cloud from these images. Actually, we know about app with this function that is called Structure from Motion (SFM). We see how the algorithm work in the next video https://www.youtube.com/watch?v=i7ierVkXYa8 . Then we propose to use a computer vision library with SFM to transform multiples images in a point cloud. In Computer Vision field exists several libraries which implements SFM in differents languages as C++, Python, Matlab. So we choose the library OpenSFM https://github.com/mapillary/OpenSfM which is developed in Python . These framework requires some dependencies as: OpenCV OpenGV Numpy Ceres Solver Boost Python Network, Numpy, Scipy
We will detail the installation of Opencv for Ubuntu 14.04 in the next commands in the terminal: cd ~ git clone git clone https://github.com/opencv/opencv.git cd opencv git clone https://github.com/opencv/opencv_contrib.git cd ~/opencv mkdir build && cd build cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv/opencv_contrib/modules \ -D BUILD_EXAMPLES=OFF .. 8. make -j4 9. sudo make install 10. sudo ldconfig 11. $ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib 12. $ export LD_LIBRARY_PATH
To test the correct installation of OpenCV we run this python file which process the laplacian of image to detect object https://www.tutorialspoint.com/dip/laplacian_operator.htm. The content of source file is: #this function display the image gray converted from cam import cv2 def main(): cam = cv2.VideoCapture(0) cam.set(3,640) cam.set(4,480) while True: #read image form camera val, img = cam.read() if( val == False): continue #convert to gray image gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) laplacian = cv2.Laplacian(gray,cv2.CV_64F) #display the image cv2.imshow("my_cam", img) cv2.imshow("laplacian", laplacian) c = cv2.waitKey(10) if c == 27: #check the keyboard each 10 ms break # escape to quit elif c == ord('s'): cv2.imwrite('my_cam1.jpg',img) elif c == ord('t'): cv2.imwrite('my_cam2.jpg',img) cam.release()# release the cam cv2.destroyAllWindows() #destroy the windows if __name__ == '__main__': main()
The other packages OpenGV and OpenSFM are installed according OpenSFM tutorial https://github.com/mapillary/OpenSfM . The example of testing OpenSFM is detailed in the following steps: Change to OpenSFM directory: cd OpenSFM Run in terminal: bin/run_all data/berlin run Start an http server in OpenSFM directory with python -m SimpleHTTPServer Browse http://localhost:8000/viewer/reconstruction.html#file=/data/berlin/reconstruction.meshed.json. the results are shown in two least images, the point cloud is produced by application of SFM with three images: the image are sample of OpenSFM.