This commit is contained in:
NikolajDanger
2022-09-19 14:06:35 +02:00
parent cea460354e
commit 3cf229f0f5
3 changed files with 17 additions and 15 deletions

View File

@ -1,7 +1,7 @@
# This script shows how to open a camera in OpenCV and grab frames and show these.
# Kim S. Pedersen, 2022
import cv2 # Import the OpenCV library
from cv2 import cv2 # Import the OpenCV library
def gstreamer_pipeline(capture_width=1024, capture_height=720, framerate=30):
@ -30,20 +30,22 @@ if not cam.isOpened(): # Error
exit(-1)
# Open a window
WIN_RF = "Example 1"
cv2.namedWindow(WIN_RF)
cv2.moveWindow(WIN_RF, 100, 100)
# WIN_RF = "Example 1"
# cv2.namedWindow(WIN_RF)
# cv2.moveWindow(WIN_RF, 100, 100)
_, frame = cam.read()
cv2.imsave('test.png', frame)
while cv2.waitKey(4) == -1: # Wait for a key pressed event
retval, frameReference = cam.read() # Read frame
if not retval: # Error
print(" < < < Game over! > > > ")
exit(-1)
# Show frames
cv2.imshow(WIN_RF, frameReference)
# while cv2.waitKey(4) == -1: # Wait for a key pressed event
# retval, frameReference = cam.read() # Read frame
# if not retval: # Error
# print(" < < < Game over! > > > ")
# exit(-1)
# # Show frames
# cv2.imshow(WIN_RF, frameReference)
# Finished successfully

View File

@ -4,7 +4,7 @@ from picamera.array import PiRGBArray
from picamera import PiCamera
from fractions import *
import time
import cv2
from cv2 import cv2
print("OpenCV version = " + cv2.__version__)

View File

@ -4,7 +4,7 @@ from picamera.array import PiRGBArray
from picamera import PiCamera
from fractions import *
import time
import cv2
from cv2 import cv2
print("OpenCV version = " + cv2.__version__)