- improved lasertrack

- VideoSource supports image resizing if file resolution doesn't match requested resolution


git-svn-id: http://moon:8086/svn/software/trunk/projects/opencv@333 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2016-10-22 12:57:48 +00:00
parent a59fa57d9a
commit 176b58d9cc
3 changed files with 66 additions and 47 deletions
+1
View File
@@ -63,6 +63,7 @@ class RgbProcess(Fifo):
def __init__(self, name='RgbProcess', resolution=(320, 240, 3), numEntries=2, next=None):
super(RgbProcess, self).__init__((numEntries, ) + resolution)
self.name = name
self.res = resolution
self.next = next
self.thread = Thread(target=self.run)
self.cancel = False
+11 -1
View File
@@ -1,5 +1,6 @@
import time
import cv2
import imutils
from threading import Thread
from picamera import PiCamera
from piCameraPipeline.PiCameraPipeline import RgbProcessorAdapter
@@ -41,10 +42,19 @@ class VideoSource(RgbProcessorAdapter):
def fileReadThread(self):
cap = cv2.VideoCapture(self.fileName)
cap_w = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
cap_h = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
needResize = False
if self.resolution[0] != cap_w or self.resolution[1] != cap_h:
needResize = True
while not self.cancel:
ret, frame = cap.read()
if ret:
self.write(frame)
if needResize:
self.write(imutils.resize(frame, width=self.resolution[0], height=self.resolution[1]))
else:
self.write(frame)
else:
break
time.sleep(1.0/self.framerate)