samedi 30 décembre 2017

Red and Video

As known, support of video by Red is under progress. However, USB webcam can easily accessed with Red due to the presence of the camera object. Thanks a lot to Qingtian for developing this object. Camera type is used to display a video camera feed. Camara/data facet lists the connected cameras as a block of strings and camera/selected facet selects the camera to display. Lastly, camera/image facet can be used to save the content of a camera. This last facet is still unstable and the best way to capture  the content of a camera is to use to-image fonction.
For experimental purposes, I had to simultaneously record images from four cameras and as explained in the code below, this is trivial with Red. 

Code sample for accessing 4 webcams

Red [
    Title:   "Test camera Red VID "
    Author:  "Francois Jouen"
    File:    %cam4.red
    Needs:   'View
]

iSize: 320x240
margins: 10x10
cam1: none ; for camera1
cam2: none ; for camera2
cam3: none ; for camera3
cam4: none ; for camera4

render: func [acam alist][
    either acam/selected [acam/selected: none][acam/selected: alist/selected]
]

view win: layout [
    title "Red Cam"
    origin margins space margins
    btnQuit: button "Quit" [quit]
    return
    cam1: camera iSize
    cam2: camera iSize
    return 
    camList1: drop-list 220 on-create [face/data: cam1/data]
    onoff1: button "Start/Stop" on-click [render cam1 camList1]
    camList2: drop-list 220 on-create [face/data: cam2/data]
    onoff2: button "Start/Stop" on-click [render cam2 camList2]
    return
    cam3: camera iSize
    cam4: camera iSize
    return
    camList3: drop-list 220 on-create [face/data: cam3/data]
    onoff3: button "Start/Stop"  on-click [render cam3 camList3]
    camList4: drop-list 220 on-create [face/data: cam4/data]
    onoff4: button "Start/Stop" on-click [render cam4 camList4]
    do [camList1/selected: 1 camList2/selected: 2 camList3/selected: 3 camList4/selected: 4]
]

Result 









Aucun commentaire:

Enregistrer un commentaire