# Raspicam (obsolete)

Enable the camera using the <code>raspi-config</code> utility:

	$ sudo raspi-config


## Python example

This example simply send the images captured by the camera to the LCD display.

	$ sudo apt update
	$ sudo apt install -y python-picamera

Create a file called <code>camera.py</code> with this code inside:

	#!/usr/bin/python
	
	from picamera import PiCamera
	from time import sleep
	
	camera = PiCamera()
	
	camera.start_preview()
	sleep(5)
	camera.stop_preview()


Then launch it:

	$ chmod +x camera.py
	$ ./camera

## Python example

This example send the images captured by the camera to a web browser via TCP/IP.

	$ sudo apt install -y python-flask python-picamera git
	$ git clone https://github.com/miguelgrinberg/flask-video-streaming.git
	
	$ cd flask-video-streaming

Run command:

	$ CAMERA=pi python app.py

Open a browser on your PC and go to the URL:

	http://ip_address:5000


## MJPG streaming example

Install Python3 and Python3-picamera libraries

	sudo apt update
	sudo apt install python3
	sudo apt install python3-picamera

Save this small Python program [stream.py](./stream.py) in /home/pi directory:

	cd /home/pi
	wget https://www.acmesystems.it/www/CM3-PANEL-7-BASIC_raspicam/stream.py

Create this file:

	sudo nano /lib/systemd/system/stream.service

with this content:

	[Unit]
	Description=MJPG streaming with Raspicam
	After=systemd-user-sessions.service
	
	[Service]
	ExecStart=/usr/bin/python3 stream.py
	Restart=on-abort
	User=pi
	WorkingDirectory=/home/pi
	
	[Install]
	WantedBy=multi-user.target

save and launch the service:

	sudo systemctl daemon-reload
	sudo systemctl enable stream.service 
	sudo systemctl start stream.service 

Open a browser on a PC on this url:

* <http://cm3_ip_address:8001/stream.mjpg>

## Links

* [Picamera Basic Recipes](https://picamera.readthedocs.io/en/release-1.13/recipes1.html)
* [A graphical interface for programming the Raspberry Pi PiCamera](https://github.com/Billwilliams1952/PiCameraApp)


@include='adv_cmpanel' 
	
