def __init__(self, scaling_factor=0.5):
# Initialize the video capture object
self.cap = cv2.VideoCapture(0)
# Capture the frame from the webcam
_, self.frame = self.cap.read()
# Scaling factor for the captured frame
self.scaling_factor = scaling_factor
# Resize the frame
self.frame = cv2.resize(self.frame, None,
fx=self.scaling_factor, fy=self.scaling_factor,
interpolation=cv2.INTER_AREA)
# Create a window to display the frame
cv2.namedWindow('Object Tracker')
# Set the mouse callback function to track the mouse
cv2.setMouseCallback('Object Tracker', self.mouse_event)
# Initialize variable related to rectangular region selection
self.selection = None
# Initialize variable related to starting position
self.drag_start = None
# Initialize variable related to the state of tracking
self.tracking_state = 0
# Define a method to track the mouse events
camshift.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录