2월, 2020의 게시물 표시

Image transfer over the ethernet

이미지
You can download the source codes here( https://github.com/raspberry-pi-maker/OpenCV ) In this post, I'll show you how to display an image you've created or read from a file using OpenCV, on another computer. As a protocol for transmitting image data to another computer via Ethernet, UDP or TCP can be selected. We will use UDP here. The reason for this is as follows. In the same subnet, even if UDP communication is used, packet loss or duplication does not occur.  It's faster and lighter than TCP, so it's even better if you need to transfer multiple images per second, such as video. prerequisite There are several protocols for transferring images, but in this post, I will send uncompressed image data directly in the form of numpy arrays. Numpy over network The most important part of numpy data transfer and recovery is byte sorting of numpy data. The sender sorts bytes using the numpy tobytes () function. The receiver then creates a one-dimensional

OpenCV Installation - Rasbian Buster, Jessie, DietPi Buster

이미지
In this post, we will install OpenCV on Raspberry Pi . Raspberry Pie doesn't have a GPU, so you don't need to set up acceleration with CUDA. Therefore, it is easiest to install a package that has already been created. But old version of Rasbian(Jessie) doesn't have python package. So you have to build the source code to install the OpenCV. And I'm going to install OpenCV 4.1.1 to DietPi. DietPi is a lightweight version of Debian. Prepare Rasbian Buster headless sd card image Prepare the image using Etcher. I used 2019-09-26-raspbian-buster-lite.zip image. Do not boot the Raspberry Pi immediately after creating the image, but create a size 0 ssh file on the / boot partition. The reason for this file is to make it a headless image. This allows remote ssh operations without having to connect a monitor to the Raspberry Pi. However, to get an IP address using dhcp, the network cable must be connected. <Create ssh file in the boot partition> Then run the

Animation #3 - Make snowing gif animation using OpenCV, PIL

이미지
The method of making gif animation is omitted because it was explained earlier. In this post, we use the random module to create a random number of snow particles and then shake them to the ground over time. Unlike the previous post, there is no image to prepare in advance. Create snowing animation import cv2 import numpy as np from PIL import Image from PIL import ImageDraw import time , os import argparse from random import * parser = argparse . ArgumentParser(description = "OpenCV Example" ) parser . add_argument( "--maxcnt" , default = 5 , type = int, help = "X axis snow max count" ) parser . add_argument( "--mincnt" , default = 1 , type = int, help = "X axis snow min count" ) parser . add_argument( "--size" , default = 5 , type = int, help = "snowball size(diameter)" ) args = parser . parse_args() count = 0 FPS = 5 SLEEP = 2.0 / FPS height =

Animation #2 - Make gif animation using OpenCV, PIL

이미지
In a previous post, you learned how to create simple animations using OpenCV and numpy. In this post, I'll show you how to create animations that move your eyes and save them as gif files. Prepare the following images in advance. These files can be downloaded from the following repo: https://github.com/raspberry-pi-maker/OpenCV The animation loops indefinitely, but in the first loop we made a gif file. The thing to watch for is moving the pupil image to the count1.bmp image. Masking function process_masking is a function often used in the previous example. However, this function has changed slightly from the previous one.The reason for this is that when the pupil moves out of the eye region, it should not be drawn. The previous masking function does not have this feature.  <Result of using original masking function> Therefore, in order to avoid drawing pupils outside the eye area, the image background color and masking process must be done once again. The bold