Ejemplo n.º 1
0
from pyv4l2.frame import Frame
from pyv4l2.control import Control

frame = Frame('/dev/video1')
frame_data = frame.get_frame()
control = Control("/dev/video1")
#control.get_controls()
#control.get_control_value(9963776)
#control.set_control_value(9963776, 8)

with open('test.raw', 'wb') as f:
    f.write(frame_data)
Ejemplo n.º 2
0
from pyv4l2.frame import Frame
from pyv4l2.control import Control

frame = Frame('/dev/video0')
frame_data = frame.get_frame()
control = Control("/dev/video0")
print(control.get_controls())
print(control.get_control_value(9963776))
print(control.set_control_value(9963776, 8))
Ejemplo n.º 3
0
def v4l2_video_capture():
    frame = Frame('/dev/video0')
    frame_data = frame.get_frame()
    while True:
        q.put(frame_data)
        q.get() if q.qsize() > 1 else time.sleep(0.01)
Ejemplo n.º 4
0
 def record(self):
     """ Start recording """
     self.frame = Frame(self.device_name)
Ejemplo n.º 5
0
parser.add_argument('--width', type=int, default=720)
parser.add_argument('--height', type=int, default=576)
parser.add_argument('--scale', type=float, default=1.)
parser.add_argument('--visdom-server', type=str, default='http://localhost')
parser.add_argument('--visdom', action='store_true')
parser.add_argument('--device', type=str, default='/dev/video0')

args = parser.parse_args()

w = int(args.width // args.scale)
h = int(args.height // args.scale)

os.system('v4l2-ctl -d {device} --set-fmt-video width={w},height={h}'.format(
    device=args.device, w=w, h=h))

frame = Frame(args.device)

if args.visdom:
    import visdom
    vis = visdom.Visdom(server=args.visdom_server)

pi = pigpio.pi()
if not pi.connected:
    print("could not connect spi")
    exit()
spi = pi.spi_open(0, 750000, 0)
SYNC_PIN = 24
pi.set_mode(SYNC_PIN, pigpio.INPUT)

NUM_LEDS_H = 16
NUM_LEDS_V = 24
Ejemplo n.º 6
0
 def get_picture(self, idx):
     frame = Frame('/dev/video%d' % idx)
     frame_data = frame.get_frame()
     print frame_data
Ejemplo n.º 7
0
* Also, set your video device (default /dev/video0)
* Hit h and l to adjust the threshold multiplier
  (Lower (h) gives more frequent updates
* While it waits for some initial frames, it otherwise
  begins right away, so it doesn't have a proper average for the
  brightness peaks. The end result is you get some images
  showing quickly, then they should reduce in frequency.
''')
avg_over=5 # Number of frames for averaging, to remove noise.
           # This same count is used for figuring out the
		   # threshold of peak brightness. (I currently keep
		   # those entire images, but I could just keep their
		   # sums for detecting peaks. Should fix that later.)


frame = Frame(vdev)
pltimg = None
plt.ion()
	#def __init__(self, dims=None, count=None, dtype=np.uint8):
imgsbuf = ImageBuf(dims=(ih,iw,3), count=avg_over)
diffbuf = ImageBuf(dims=(ih,iw,3), count=avg_over)
framecount=0
anomalycount=0
#thresh = 217000
tmult = 1.15
while True:
	imgd = frame.get_frame()
	framecount += 1
	img = np.frombuffer(imgd, dtype=np.uint8)
	img = img.reshape((ih,iw,3))
	imgsbuf.add(img)