stereopi-tutorial
stereopi-tutorial copied to clipboard
how to set cameras parameters ?
hi! i have made a little make up for 1_test.py:
import picamera;from picamera import PiCamera;import time;import cv2;import numpy as np
import os;from datetime import datetime
print("You can press 'Q' to quit this script.")
filename = './scenes/photo.png'# File for captured image
# Camera settimgs
cam_width,cam_height, scale_ratio = 1280, 480, 0.5
cam_width, cam_height = int((cam_width+31)/32)*32, int((cam_height+15)/16)*16
print (f"Camera resolution: {str(cam_width)}x{str(cam_height)}")
# Buffer for captured image settings
img_width,img_height = int (cam_width * scale_ratio), int (cam_height * scale_ratio)
capture = np.zeros((img_height, img_width, 4), dtype=np.uint8)
print (f"Scaled image resolution: {str(img_width)}x{str(img_height)}")
# Initialize the camera
camera = PiCamera(stereo_mode='side-by-side',stereo_decimate=False)
camera.resolution=(cam_width, cam_height)
camera.framerate = 20
# camera.exposure_mode = 'off'
# camera.shutter_speed = 1000000
# camera.contrast = 0 # Контрастность
# camera.brightness = 60 # Яркость
# camera.saturation = 0 # Насыщенность
# camera.ISO = 800 # Чувствительность
# camera.awb_mode = "auto" # "fluorescent"
# #camera.rotation = 90
# #camera.hflip = True
camera.start_preview()
time.sleep(2)
#camera_set()
t0 = datetime.now()
counter = 0
avgtime = 0
for frame in camera.capture_continuous(capture, format="bgra", use_video_port=True, \
resize=(img_width,img_height)):
counter+=1
cv2.imshow("pair", frame)
key = cv2.waitKey(1) & 0xFF
# if the `q` key was pressed, break from the loop and save last image
if key == ord("q") :
t1 = datetime.now()
timediff = t1-t0
print (f"Average time between frames: {str(avgtime)}")
print (f"Frames: {str(counter)} Time: {str(timediff.total_seconds())} Average FPS: {str(counter/timediff.total_seconds())}")
if (os.path.isdir("./scenes")==False):
os.makedirs("./scenes")
cv2.imwrite(filename, frame)
exit(0)
break
but how to set up parameters for both cameras ? Settings like camera.exposure_mode = 'off' only matter for one camera at once.