From c70edd41663a4cbdb30c289d75ab67ebcdc3cff8 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 26 Jan 2021 20:36:40 +0100 Subject: [PATCH] fixed vision documentation --- docs/source/lib/Vision.rst | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/docs/source/lib/Vision.rst b/docs/source/lib/Vision.rst index 736cc60..5c030d9 100644 --- a/docs/source/lib/Vision.rst +++ b/docs/source/lib/Vision.rst @@ -32,13 +32,14 @@ Using the Vision Module import cv2 from compLib import Vision - # get newest opencv frame from camera - frame = Vision.Streaming.get_frame() + while True: + # get newest opencv frame from camera + frame = Vision.Streaming.get_frame() - # do some processing with the frame..... + # do some processing with the frame..... - # publish frame to streaming server - Vision.Streaming.publish_frame(frame) + # publish frame to streaming server + Vision.Streaming.publish_frame(frame) Connect the raspberry pi to your internet and view the stream at: "http://your_raspi_ip:9898/". This should display your raspberry pi camera. Note: the stream will lag a little bit BUT the processing of the image will be done in @@ -68,22 +69,23 @@ For testing you can point it at this image: import cv2 from compLib import Vision - # get newest opencv frame from camera - frame = Vision.Streaming.get_frame() + while True: + # get newest opencv frame from camera + frame = Vision.Streaming.get_frame() - criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001) + criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001) - # convert image to grayscale image - gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) + # convert image to grayscale image + gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) - # find the chessboard corners - ret, corners = cv2.findChessboardCorners(gray, (6, 9), None) + # find the chessboard corners + ret, corners = cv2.findChessboardCorners(gray, (6, 9), None) - # draw detected chessboard position onto the image - cv2.drawChessboardCorners(frame, (6, 9), corners, ret) + # draw detected chessboard position onto the image + cv2.drawChessboardCorners(frame, (6, 9), corners, ret) - # publish frame to streaming server - Vision.Streaming.publish_frame(frame) + # publish frame to streaming server + Vision.Streaming.publish_frame(frame) Connect the raspberry pi to your internet and view the stream at: "http://your_raspi_ip:9898/".