Introduction
This article mainly introduces the assembly line packaging box detection and counting application based on OpenCV, and gives the source code.
Download
Complete code and video download address:
https://github.com/freedomwebtech/rpi4-conveyor-belt-boxces-counter
The core code is as follows (cboxtest.py):
import cv2
import numpy as np
from tracker import*
cap=cv2.VideoCapture('box.mp4')
lower_range=np.array([0,46,64])
upper_range=np.array([43,115,160])
def RGB(event, x, y, flags, param):
if event == cv2.EVENT_MOUSEMOVE :
point = [x, y]
print(point)
tracker=Tracker()
cv2.namedWindow('box-counter')
cv2.setMous