Blame |
Last modification |
View Log
| RSS feed
import numpy as np
#np.set_printoptions(threshold=np.nan)
import picamera
import picamera.array
import sys
import os
import time
import mmap
##>> Gain access to MMAP
##------------------------------------------------------------------------------------------------------
INDATAFILENAME = '/home/pi/ExPlat/input.dat'
LENGTHDATAMAP = 1024
inDataFile = open(INDATAFILENAME, 'r+')
inDataNo = inDataFile.fileno()
inDataMap = mmap.mmap(inDataNo, LENGTHDATAMAP, access=mmap.ACCESS_WRITE)
s = 0;
##>> Analyze Numpy Array and Print Motion Vector Data
##------------------------------------------------------------------------------------------------------
class AnalyzeArray(picamera.array.PiMotionAnalysis):
def analyse(self, a):
global s
global inDataMap
s += a[20,15][0]
#print s
inDataMap.seek(0)
inDataMap.write('%d' %s + '\n')
##>> Start Capture and call AnalyzeArray after every frame
##------------------------------------------------------------------------------------------------------
def get_values():
with picamera.PiCamera() as camera:
with AnalyzeArray(camera) as output:
camera.resolution = (640, 480)
camera.framerate = (20, 1)
camera.start_recording(
'/dev/null', format='h264', motion_output=output)
camera.wait_recording(0)
camera.stop_recording()