Raspberry Pi 3 Camera Lamp Documentation
The Raspberry Pi 3 Camera Lamp is a versatile component that integrates a camera, LED lamp, and Raspberry Pi 3 single-board computer. This device enables various applications, including computer vision, machine learning, and robotics. The camera captures high-quality images and videos, while the LED lamp provides adjustable lighting for optimal image capture or ambient lighting.
Camera:
+ 8 megapixel Sony IMX219 camera sensor
+ 3280 x 2464 pixels resolution
+ 1080p video recording at 30fps
LED Lamp:
+ 3W LED with adjustable brightness
+ 3000K-5000K color temperature range
Raspberry Pi 3:
+ Quad-core Cortex-A53 CPU
+ 1GB RAM
+ Wi-Fi, Bluetooth, and Ethernet connectivity
The Raspberry Pi 3 Camera Lamp is compatible with various programming languages, including Python, Java, and C++. This documentation focuses on Python examples, as it is the most popular language used with Raspberry Pi.
Example 1: Basic Camera Capture
This example demonstrates how to capture a still image using the camera module in Python:
```python
import picamera
# Create a camera object
camera = picamera.PiCamera()
# Set camera settings
camera.resolution = (640, 480)
camera.framerate = 30
# Capture an image
camera.capture('image.jpg')
# Close the camera object
camera.close()
```
Example 2: Object Detection with OpenCV
This example showcases the use of OpenCV library to detect objects in real-time using the camera module:
```python
import cv2
# Create a camera object
cap = cv2.VideoCapture(0)
while True:
# Capture a frame
ret, frame = cap.read()
# Convert frame to gray scale
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Load OpenCV cascade classifier for face detection
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
# Detect faces in the frame
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5)
# Draw rectangles around detected faces
for (x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
# Display the output
cv2.imshow('face_detection', frame)
# Exit on pressing 'q'
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release resources
cap.release()
cv2.destroyAllWindows()
```
Example 3: LED Lamp Control
This example demonstrates how to control the LED lamp's brightness using Python:
```python
import RPi.GPIO as GPIO
# Set up GPIO mode
GPIO.setmode(GPIO.BCM)
# Define LED lamp pin
LED_PIN = 18
# Set up LED lamp pin as an output
GPIO.setup(LED_PIN, GPIO.OUT)
# Create a PWM object
pwm = GPIO.PWM(LED_PIN, 50) # 50 Hz frequency
# Set LED lamp brightness (0-100)
def set_brightness(brightness):
pwm.start(brightness)
pwm.ChangeDutyCycle(brightness)
# Example usage
set_brightness(50) # Set brightness to 50%
# Clean up
GPIO.cleanup()
```
These examples demonstrate the capabilities of the Raspberry Pi 3 Camera Lamp and provide a foundation for more complex projects.