PiGear API

PiGear is similar to CamGear but exclusively made to support various Raspberry Pi Camera Modules (such as OmniVision OV5647 Camera Module and Sony IMX219 Camera Module). To interface with these modules correctly, PiGear provides a flexible multi-threaded wrapper around complete picamera python library and provides us the ability to exploit its various important parameters like brightness, saturation, sensor_mode, iso, exposure, etc. effortlessly and also supports multiple camera modules such as in case of Raspberry Pi 3/3+ compute modules.

Important: :warning:

 

Importing:

You can import PiGear as follows:

from vidgear.gears import PiGear

 

Usage: :hammer:

PiGear API supports all tweak parameters and attributes available within Picamera API which can be applied to the given camera stream through **options dictionary when it's being initiated. The complete example is as follows:

# import libraries
from vidgear.gears import PiGear
import cv2

options = {"hflip": True, "exposure_mode": "auto", "iso": 800, "exposure_compensation": 15, "awb_mode": "horizon", "sensor_mode": 0} # define tweak parameters

stream = PiGear(resolution=(320, 240), framerate=60, time_delay=1,  logging = True, **options).start() # define various attributes and start the stream

# infinite loop
while True:
	
	frame = stream.read()
	# read frames

	# check if frame is None
	if frame is None:
		#if True break the infinite loop
		break
	
	# do something with frame here
	
	cv2.imshow("Output Frame", frame)
	# Show output window

	key = cv2.waitKey(1) & 0xFF
	# check for 'q' key-press
	if key == ord("q"):
		#if 'q' key-pressed break out
		break

cv2.destroyAllWindows()
# close output window

stream.stop()
# safely close video stream.

 

Attributes and Parameters: :wrench:

  1. camera_num(integer): selects the camera module index that will be used by API. Its default value is 0 and :warning: shouldn't be altered until unless if you using Raspberry Pi 3/3+ compute module in your project along with multiple camera modules. Furthermore, Its value can only be greater than zero, otherwise, it will throw ValueError for any negative value.

  2. resolution(tuple): sets the resolution (width,height). Its default value is (640,480). More information here.

  3. framerate(integer): sets the framerate. Its default value is 25. More information here.

  4. colorspace(string): set the colorspace of the video stream. Its default value is None. Check out its detailed Usage here

  5. logging(boolean): set this flag to enable/disable error logging essential for debugging. Its default value is False.

  6. time_delay(int): set the time delay(in seconds) before start reading the frames. This delay is essentially required for the Raspi camera to warm-up. Its default value is 0.

  7. **options(dict): can be used to tweak any parameter supported by PiCamera API to the input raspicam video stream. These attributes provide the flexibility to manipulate raspicam video stream various properties like brightness, saturation, senor_mode, resolution, etc. easily. These parameters can be passed using this **option dict as follows:

    options = {"hflip": True, "exposure_mode": "auto", "iso": 800, "exposure_compensation": 15, "awb_mode": "horizon", "sensor_mode": 0} 
    • All supported dict attribute parameters are listed in PiCamera Docs.

    • User-specific additional attributes: A new threaded internal Timer function is introduced in PiGear API to handle any hardware failures/frozen threads robustly. This function will keep active track of the frozen threads and will exit safely if any failure occurs at a particular timeout value. This timeout can be controlled manually using following dict attribute:

      • HWFAILURE_TIMEOUT(integer/float): Used to control the maximum time(in seconds) wait before Internal Timer exiting with a SystemError. Its value can only be between 1.0(min) and 10.0(max) and its default value is 2.0. It usage is as follows:
      options = {"HWFAILURE_TIMEOUT": 2.5} #to sets timeout to 2.5seconds
::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com



自怼圈/年番新

DU21.7
关于 ~ DebugUself with DAMA ;-)


关注公众号, 持续获得相关各种嗯哼:
zoomquiet


粤ICP备18025058号-1
公安备案号: 44049002000656 ...::