From picamera to numpy arrays - Raspberry Pi Forums


hi,
i'm trying use python capture video raspi camera processed later scikit-image, therefore save images numpy arrays.
important achieve highest possible framerate (1296x730, 49 fps it's best tradeoff attempts) , save timestamp of each frame.
i'm trying adapt following recipe picamera documentation:

code: select all

import time import picamera import picamera.array  picamera.picamera() camera:     picamera.array.pirgbarray(camera) stream:         camera.resolution = (100, 100)         camera.start_preview()         time.sleep(2)         camera.capture(stream, 'rgb')         # show size of rgb data         print(stream.array.shape)
it's not clear me:
1) how save file
2) how acquire continuously until key pressed (i using start_recording(), raw_input() , stop_recording...)

grateful suggestion!

cheers

to convert 2d numpy array, can use opencv use: (note reshape in h, w order.)
frame = np.frombuffer(stream, dtype=uint8, count=w*h).reshape(h, w)

store capture replacing stream "/path/to/file.rgb"
or if converted frame numpy, suppose numpy i/o save methods.

continuous capture done via sequence or using start_recording, in case you'll have manually read n bytes , convert those. going have hard time saving 1296x730 @ 49 fps in rgb on sd-card though.(or storage connected pi, really). that's 132 mb/sec. you're gonna have use h264. able read you'll need decoding though. use opencv's videodecoder, allow read frame frame. returned frames numpy arrays.

recording until key pressed, use raw_input - wait until return pressed..
raw_input("press enter stop..")
cam.stop_recording()

god need stop editing own posts.. 10th edit.


raspberrypi



Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support