diff --git a/__pycache__/detect.cpython-38.pyc b/__pycache__/detect.cpython-38.pyc index ab5ad0b..6424b2e 100644 Binary files a/__pycache__/detect.cpython-38.pyc and b/__pycache__/detect.cpython-38.pyc differ diff --git a/build/temp.linux-x86_64-3.8/detect.o b/build/temp.linux-x86_64-3.8/detect.o index 7c03903..2e8b0a2 100644 Binary files a/build/temp.linux-x86_64-3.8/detect.o and b/build/temp.linux-x86_64-3.8/detect.o differ diff --git a/detect.c b/detect.c index 8253942..fd330e5 100644 --- a/detect.c +++ b/detect.c @@ -5741,7 +5741,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P * pixelsPerMetric = smaller(dA, dB) / calibration_width * continue # <<<<<<<<<<<<<< * - * pixelsPerMetric = 25 + * #pixelsPerMetric = 25 */ goto __pyx_L16_continue; @@ -5765,19 +5765,9 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "detect.py":181 - * continue - * - * pixelsPerMetric = 25 # <<<<<<<<<<<<<< - * orig = image.copy() - * objtype = "Unknown" - */ - __Pyx_INCREF(__pyx_int_25); - __Pyx_DECREF_SET(__pyx_v_pixelsPerMetric, __pyx_int_25); - /* "detect.py":182 * - * pixelsPerMetric = 25 + * #pixelsPerMetric = 25 * orig = image.copy() # <<<<<<<<<<<<<< * objtype = "Unknown" * objname = "" @@ -5803,7 +5793,7 @@ static PyObject *__pyx_pf_6detect_14detect(CYTHON_UNUSED PyObject *__pyx_self, P __pyx_t_5 = 0; /* "detect.py":183 - * pixelsPerMetric = 25 + * #pixelsPerMetric = 25 * orig = image.copy() * objtype = "Unknown" # <<<<<<<<<<<<<< * objname = "" diff --git a/detect.cpython-38-x86_64-linux-gnu.so b/detect.cpython-38-x86_64-linux-gnu.so deleted file mode 100755 index c1389ba..0000000 Binary files a/detect.cpython-38-x86_64-linux-gnu.so and /dev/null differ diff --git a/detect.py b/detect.py index 9324b25..353a6e0 100644 --- a/detect.py +++ b/detect.py @@ -178,7 +178,7 @@ def detect(calibration_width, img_file, show, quick): pixelsPerMetric = smaller(dA, dB) / calibration_width continue - pixelsPerMetric = 25 + #pixelsPerMetric = 25 orig = image.copy() objtype = "Unknown" objname = "" @@ -187,7 +187,7 @@ def detect(calibration_width, img_file, show, quick): #orig = image.copy() num += 1 # if the contour is not sufficiently large, ignore it - if cv2.contourArea(c) < 100: # or pixelsPerMetric is None: + if cv2.contourArea(c) < 100 or pixelsPerMetric is None: continue # compute the rotated bounding box of the contour diff --git a/run_detect.py b/run_detect.py index 82c86e8..378e5ce 100644 --- a/run_detect.py +++ b/run_detect.py @@ -1,6 +1,7 @@ import detect import timeit import cv2 +from imutils.video import FPS calibration_width = 0.75 image = "img7.jpg" images = ("img.jpg", "img2.jpg", "img3.jpg", "img4.jpg", "img5.jpg", "img6.jpg", "img7.jpg", "img8.jpg") @@ -14,19 +15,22 @@ if not video: elapsed_time = timeit.timeit(go, number=3)/3 print(elapsed_time) else : - capture = cv2.VideoCapture('tcpclientsrc host=192.168.86.108 port=5001 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! appsink', cv2.CAP_GSTREAMER) - # server command for pi camera /opt/vc/bin/raspivid -t 0 -w 1920 -h 1080 -hf -fps 5 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=192.168.86.108 port=5001 - ret,frame = capture.read() - detect.detect(calibration_width, "img7.jpg", True, False) - detect.detect(calibration_width, frame, True, True) + capture = cv2.VideoCapture('udpclientsrc host=192.168.43.152 port=5001 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! videorate ! video/x-raw,framerate=5/1 ! appsink', cv2.CAP_GSTREAMER) + # server command for imx135 camera ./video2stdout | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=192.168.43.152 port=5001 + #ret,frame = capture.read() + #detect.detect(calibration_width, "img7.jpg", True, False) + #detect.detect(calibration_width, frame, True, True) + x = 0 while True: - ret,frame = capture.read() - + ret = capture.grab() + x+=1 if not ret: print('empty frame') break #print('frame') - - cv2.imshow('Item Sorter', detect.detect(calibration_width, frame, True, True)) + if x > 0: + ret,frame = capture.retrieve() + cv2.imshow('Item Sorter', detect.detect(calibration_width, frame, True, True)) + x = 0 if cv2.waitKey(1)&0xFF == ord('q'): break