コード例 #1
0
ファイル: test.py プロジェクト: buglabs/FactoryTests
import bugv4l as bg


# open the bug camera as a 640x480 image
bg.open(dev_code=bg.V4L2_DEVNODE_RAW,
        raw_fmt=bg.format(640, 480,bg.V4L2_PIX_FMT_SGRBG8))

# put in walking 1's test pattern mode
bg.set_ctrl(bg.V4L2_CID_TEST_PATTERN, 1) 

# start the image stream
bg.start()

# capture an image
img = bg.grab()

# copy data into a python string so we can use it after closing down the stream
data = img.get_data()

# stop the stream and close the bug camera
bg.stop()
bg.close()

# now compare the captured data to ideal test pattern
base_pattern = '\x00\x00\x01\x01\x02\x02\x04\x04\x08\x08\x10\x10  @@\x80\x80\xff\xff'
N = len(base_pattern)
ideal = base_pattern * (len(data)/N)

print "Captured Test Pattern is correct: ", (ideal == data)

コード例 #2
0
ファイル: camtest.py プロジェクト: buglabs/FactoryTests
import bugv4l as bg
import os


os.system("cp /usr/images/testingflash.fb /dev/fb0")

# open the bug camera as a 640x480 image
bg.open(dev_code=bg.V4L2_DEVNODE_RESIZER,
        raw_fmt=bg.format(2048,1536, bg.V4L2_PIX_FMT_YUYV),
        resizer_fmt=bg.format(640, 480))

bg.set_red_led(False)

bg.set_ctrl(bg.V4L2_CID_FLASH_STROBE, 1) # turn on flash LED strobe
os.system("sleep 3")

bg.set_ctrl(bg.V4L2_CID_FLASH_STROBE, 0) # turn off flash LED strobe

os.system("cp /usr/images/testingleds.fb /dev/fb0")

bg.set_red_led(True)
os.system("sleep 2")
bg.set_red_led(False)
bg.set_green_led(True)
os.system("sleep 2")
bg.set_green_led(False)


os.system("cp /usr/images/startingcamera.fb /dev/fb0")

# start the image stream