victorabraham
11/24/2016 - 10:32 PM

piCamera Setup

raspistill -o test.jpg
raspivid -o video.h264 -t 10000
omxplayer video.h264

https://www.raspberrypi.org/blog/camera-board-available-for-sale/


nc -l 5001 | mplayer -fps 31 -cache 1024 -
raspivid -t 999999 -o – | nc [ip address of OSX] 5001
raspivid -t 999999 -o – | nc -v [you’re nc server address] 5001

from picamera import PiCamera
from time import sleep

camera = PiCamera()
camera.rotation = 180
#Maximum resolution is 2592 x 1944 for still photos and 1920 x 1080 for video recording.
#Alpha can vary from 0-255
#camera.resolution = (2592, 1944)
#camera.framerate = 15
#To Add text on top of the image
camera.annotate_text = "Victor"
#Brightness 0 to 100 with default 50
#camera.brightness = 70
camera.start_preview(alpha=230)
camera.start_recording('/home/pi/video.h264')
sleep(5)
camera.stop_recording()
for i in range(3):
    sleep(2)
    camera.capture('/home/pi/image%s.jpg' % i)
camera.stop_preview()



http://picamera.readthedocs.io/en/release-1.12/recipes1.html#capturing-to-a-network-stream
import io
import socket
import struct
import time
import picamera

# Connect a client socket to my_server:8000 
client_socket = socket.socket()
#USD11ABVICTMB2
client_socket.connect(('192.168.0.15', 8000))

# Make a file-like object out of the connection
connection = client_socket.makefile('wb')
try:
    camera = picamera.PiCamera()
    camera.resolution = (640, 480)
    # Start a preview and let the camera warm up for 2 seconds
    camera.start_preview()
    time.sleep(2)

    # Note the start time and construct a stream to hold image data
    # temporarily (we could write it directly to connection but in this
    # case we want to find out the size of each capture first to keep
    # our protocol simple)
    start = time.time()
    stream = io.BytesIO()
    for foo in camera.capture_continuous(stream, 'jpeg'):
        # Write the length of the capture to the stream and flush to
        # ensure it actually gets sent
        connection.write(struct.pack('<L', stream.tell()))
        connection.flush()
        # Rewind the stream and send the image data over the wire
        stream.seek(0)
        connection.write(stream.read())
        # If we've been capturing for more than 30 seconds, quit
        if time.time() - start > 30:
            break
        # Reset the stream for the next capture
        stream.seek(0)
        stream.truncate()
    # Write a length of zero to the stream to signal we're done
    connection.write(struct.pack('<L', 0))
finally:
    connection.close()
    client_socket.close()