Image Processing #12 - Detecting the center of text or curved line

이미지
 There are times when you need information about the center line of text or curved parts of an image. I'm making a drawing robot these days. After the robot drew the picture, I needed this method to sign it. If the center line pixel location information of the signature image is grasped, the robot can naturally sign by drawing a pen while passing through these pixels. Even when developing an autonomous driving robot, in order not to deviate from the road designated by the robot, it may be possible to identify the center line of the road and move it around this line. Implementing this function in OpenCV is quite simple. opencv-contrib-python not opencv-python There is one thing to note. It is recommended to install opencv-contrib-python instead of opencv-python, which is normally installed to use OpenCV in Python. In this example, a function called cv2.ximgproc.thinning is used, but ximgproc is not supported by opencv-python. opencv-contrib-python is installed with additional module

Image Processing #11 - Speed up image processing with numba

이미지
I have written several blogs related to watermarking.  Image Processing #4 - WaterMark without alpha channel Image Processing #5 - WaterMark using alpha channel The example Python code provided in these articles performs RGB operations on all or some pixels of an image. If it is a 2048 x 1152 size image, at least Width x Height x Channel = 7,077,888 calculations are required. And if the video is 30 frames per second, 212,336,640 operations per second are required. The Python language is easy to learn, and modules with numerous functions are provided, so high code productivity can be expected. However, if the number of repetitions of loop statements such as for and while increases, the performance decreases a lot. The reason is that because the Python language is interpreted, it reinterprets every sentence in every loop. Let's compare the performance by making the following simple example in C and Python. This simple example adds 1 to 10000000. #include <stdio.h> // for pri

Image Processing #10 - Zoom in animation

이미지
 I like to make various effects using OpenCV. If I knew how to use image processing programs such as video editing programs and Photoshop, I would probably have used these programs. But I am a programmer and I can hardly use these programs. So I enjoy using OpenCV to implement the effects I want. Zoom in Suppose you want to zoom in to a specific area in the original high-resolution image as shown below.   The final image area is marked with a box. And the display will use images of this box size. If you zoom in while maintaining the original resolution of image, the resolution will be much lower because you will need to zoom in on the gradually smaller image. This method is also possible, but I don't want the image resolution to be lowered. So at first, we will start zooming in by reducing the original image to the size of the box image. During zoom-in, the size of the image will gradually become similar to the size of the box, and the final image will be the box image. Therefore,

Install OpenCV 4.4 on Raspberry Pi

이미지
 I often work with OpenCV in Raspberry Pi or the Jetson series. In the NVidia Jetson series, OpenCV is optimized and comes with the Jetpack installation. As a result, you do not need to install OpenCV separately. However, because Raspberry Pi OS is not installed with OpenCV, users must install it themselves. Unlike the Jetson series, Raspberry Pi has no GPU to use Cuda. The Mali GPU, used by Raspberry Pi, is used only for graphics and is difficult to use in OpenCV to speed up the OpenCV processing speed. Therefore, OpenCV used by Raspberry Pi does not require special optimization. Therefore, it is less necessary to build and use the source code. The case of building the source code is probably when you need the latest version of OpenCV. If you want to use an already verified version rather than the latest version, you can easily install it by following the steps below. Install Raspberry Pi OS on the Rpi4B I will use Raspberry Pi 4 B+ 2GB memory model and the OS will use Raspberry Pi OS