def run(): # We assume that Raiden is already started previous_receiver_info = (0, 0) camera = Camera('/dev/video0', 1024, 576) camera.set_control_value(ControlIDs.CONTRAST, 10) camera.set_control_value(ControlIDs.SATURATION, 10) while True: address_id, nonce = start_scanning(camera) if (address_id, nonce) == previous_receiver_info: continue address = RECEIVER_LIST[address_id] send_payment(address, nonce) previous_receiver_info = (address_id, nonce)
import numpy as np from PIL import Image from PyV4L2Camera.camera import Camera from PyV4L2Camera.controls import ControlIDs camera = Camera('/dev/video0', 1920, 1080) controls = camera.get_controls() for control in controls: print(control.name) camera.set_control_value(ControlIDs.BRIGHTNESS, 48) for _ in range(2): frame = camera.get_frame() # Decode the image im = Image.frombytes('RGB', (camera.width, camera.height), frame, 'raw', 'RGB') # Convert the image to a numpy array and back to the pillow image arr = np.asarray(im) im = Image.fromarray(np.uint8(arr)) print(np.mean(arr[:, :, 0])) print(np.mean(arr[:, :, 1])) print(np.mean(arr[:, :, 2])) # Display the image to show that everything works fine im.show()
# # rpi, ESC, STEER = setup_gpio() # camera = Camera('/dev/video1', 360, 200) os.system('v4l2-ctl -d /dev/video1 -c exposure_auto=1') time.sleep(0.5) camera = Camera('/dev/video1', 1280, 720) # controls = camera.get_controls() # speed = 1500 # angle = 90 # DEFAULT_CMD = '00/1500/90' # STOP_CMD = '11/1500/90' # for control in controls: # print(control.name + ":" + str(control.id)) camera.set_control_value(ControlIDs.BRIGHTNESS, 0) camera.set_control_value(ControlIDs.CONTRAST, 15) # camera.set_control_value(ControlIDs.BACKLIGHT_COMPENSATION, 50) # camera.set_control_value(ControlIDs.SATURATION, 0) # camera.set_control_value(ControlIDs.SATURATION, 0) # 360x200 img_size = [200, 360, 3] src = np.float32([[0, 200], [360, 200], [295, 120], [65, 120]]) dst = np.float32([[0, img_size[0]], [img_size[1], img_size[0]], [img_size[1], 0], [0, 0]]) robot = Robot()