- 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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user