2/13/2022 0 Comments Install navit on raspberry piJust power on the pi, open up a terminal and launch the bluetooth controller. I've been using the Raspberry Pi 3 B+, which has bluetooth built in, so I don't need any other adapters. With the bluetooth adapter in place, we can now connect our Pi to it. It detected a lot of unnecessary objects, and I did notice that sometimes it would detect shadows as objects. Output = cv2.bitwise_and(image, image, mask=mask)ĭilation = cv2.dilate(mask, kernel, iterations = 3)Ĭlosing = cv2.morphologyEx(dilation, cv2.MORPH_GRADIENT, kernel)Ĭlosing = cv2.morphologyEx(dilation, cv2.MORPH_CLOSE, kernel)Ĭontours, hierarchy = cv2.findContours(closing, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) #use the color range to create a mask for the image and apply it to the image YAlert = (heightAlert/2) + 100 #determine y coordinates for areaĬv2.line(image, (0,yAlert), (widthAlert,yAlert),(0,0,255),2) #draw a line to show area HeightAlert = np.size(image, 0) #get height of image WidthAlert = np.size(image, 1) #get width of image RawCapture = PiRGBArray(camera, size=(320, 240))įor still in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True): I just named my file car_detector.py import timeĬamera.resolution = (320, 240) #a smaller resolution means faster processing For the fully documented code, you can visit my github repository. Once OpenCV is installed, we can create a new Python file and start on the code. Luckily the Pi can do this through the Python "pip" command pip3 install opencv-python It worked like a charm, and there was practically no lag!īefore starting on the code, we have to install OpenCV on the Pi first. Saving it and testing it out by running "python image_overlay.py", I tested it out on a small scale using a toy car to see how it worked. Img_overlay = camera.add_overlay(img.tobytes(), size=img.size) I just named the file image_overlay.py import picamera Next we'll create a python script that utilizes the PIL python image editor and the PiCamera (if you are not using a Pi Camera, then adjust the code for your video input). This was done intentionally, but feel free to change the image dimensions if you are streaming at a different resolution. The image above is exactly 640x480, which just so happens to be the same resolution my camera will be streaming at.
0 Comments
Leave a Reply. |
AuthorLindsey ArchivesCategories |