✨
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
# This script shows how to open a camera in OpenCV and grab frames and show these.
|
# This script shows how to open a camera in OpenCV and grab frames and show these.
|
||||||
# Kim S. Pedersen, 2022
|
# 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):
|
def gstreamer_pipeline(capture_width=1024, capture_height=720, framerate=30):
|
||||||
@ -30,20 +30,22 @@ if not cam.isOpened(): # Error
|
|||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
# Open a window
|
# Open a window
|
||||||
WIN_RF = "Example 1"
|
# WIN_RF = "Example 1"
|
||||||
cv2.namedWindow(WIN_RF)
|
# cv2.namedWindow(WIN_RF)
|
||||||
cv2.moveWindow(WIN_RF, 100, 100)
|
# 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
|
# while cv2.waitKey(4) == -1: # Wait for a key pressed event
|
||||||
retval, frameReference = cam.read() # Read frame
|
# retval, frameReference = cam.read() # Read frame
|
||||||
|
|
||||||
if not retval: # Error
|
# if not retval: # Error
|
||||||
print(" < < < Game over! > > > ")
|
# print(" < < < Game over! > > > ")
|
||||||
exit(-1)
|
# exit(-1)
|
||||||
|
|
||||||
# Show frames
|
# # Show frames
|
||||||
cv2.imshow(WIN_RF, frameReference)
|
# cv2.imshow(WIN_RF, frameReference)
|
||||||
|
|
||||||
|
|
||||||
# Finished successfully
|
# Finished successfully
|
||||||
|
@ -4,7 +4,7 @@ from picamera.array import PiRGBArray
|
|||||||
from picamera import PiCamera
|
from picamera import PiCamera
|
||||||
from fractions import *
|
from fractions import *
|
||||||
import time
|
import time
|
||||||
import cv2
|
from cv2 import cv2
|
||||||
|
|
||||||
|
|
||||||
print("OpenCV version = " + cv2.__version__)
|
print("OpenCV version = " + cv2.__version__)
|
||||||
|
@ -4,7 +4,7 @@ from picamera.array import PiRGBArray
|
|||||||
from picamera import PiCamera
|
from picamera import PiCamera
|
||||||
from fractions import *
|
from fractions import *
|
||||||
import time
|
import time
|
||||||
import cv2
|
from cv2 import cv2
|
||||||
|
|
||||||
|
|
||||||
print("OpenCV version = " + cv2.__version__)
|
print("OpenCV version = " + cv2.__version__)
|
||||||
|
Reference in New Issue
Block a user