Raspberry Pi Camera Module 3 NoIR
Raspberry Pi Camera Module 3 NoIR
Camera Module
The Raspberry Pi Camera Module 3 NoIR is a high-quality camera module specifically designed for use with Raspberry Pi single-board computers. This module is an upgraded version of the previous camera modules, offering improved performance, higher resolution, and enhanced features. The "NoIR" suffix indicates that this module does not have an infrared filter, making it ideal for applications that require night vision, surveillance, or sensing in low-light environments.
The Raspberry Pi Camera Module 3 NoIR is a small, compact camera module that can capture high-quality still images and video. It connects to the Raspberry Pi's Camera Serial Interface (CSI) port, allowing users to capture and process images using the Raspberry Pi's GPU. The camera module is designed to work seamlessly with the Raspberry Pi's operating system, enabling users to easily integrate camera functionality into their projects.
Sony IMX477
12 megapixels (4032 x 3024)
1.12 m x 1.12 m
77 diagonal
3.04 mm
No
Global
Adjustable
CSI-2
250 mA
25 mm x 24 mm x 9 mm
The Raspberry Pi Camera Module 3 NoIR is suitable for a wide range of applications, including |
Robotics and computer vision
Surveillance and security systems
Drones and aerial photography
Machine learning and AI projects
Home automation and IoT projects
Medical and scientific imaging applications
Raspberry Pi Camera Module 3 NoIR Documentation
Overview
The Raspberry Pi Camera Module 3 NoIR is a high-quality camera module designed specifically for the Raspberry Pi series of single-board computers. This camera module features a 12-megapixel Sony IMX708 sensor, capable of capturing high-resolution images and videos in low-light conditions. The "NoIR" suffix indicates that this module does not have an infrared filter, making it suitable for applications that require night vision or other IR-sensitive scenarios.
Technical Specifications
Sensor: Sony IMX708, 12-megapixel, 1/2.55" sensor size
Lens: 6mm, f/1.8
Resolution: Up to 4656 x 2592 pixels (12 megapixels)
Video: Up to 1080p at 30fps, 720p at 60fps
Interface: 15-pin MIPI CSI-2
Power consumption: Approximately 250mA at 5V
Operating temperature: -20C to 50C
Python Library: picamera
To use the Raspberry Pi Camera Module 3 NoIR with Python, you'll need to install the `picamera` library. You can install it using pip:
`sudo pip install picamera`
Code Examples
### Example 1: Capturing a Still Image
This example demonstrates how to capture a still image using the Raspberry Pi Camera Module 3 NoIR:
```python
import picamera
# Create a camera object
camera = picamera.PiCamera()
# Set the camera resolution and format
camera.resolution = (2592, 1944)
camera.format = 'jpg'
# Capture an image and save it to a file
camera.capture('image.jpg')
# Close the camera object
camera.close()
```
In this example, we create a `picamera.PiCamera()` object, set the camera resolution and format, and then capture an image using the `capture()` method. The image is saved to a file named `image.jpg`.
### Example 2: Streaming Video over HTTP
This example demonstrates how to stream video from the Raspberry Pi Camera Module 3 NoIR over HTTP using the `picamera` library and the `Flask` web framework:
```python
import picamera
from flask import Flask, Response
app = Flask(__name__)
# Create a camera object
camera = picamera.PiCamera()
# Set the camera resolution and format
camera.resolution = (640, 480)
camera.format = 'h264'
@app.route('/')
def index():
return '''
<html>
<body>
<h1>Raspberry Pi Camera Stream</h1>
<img src="/stream.mjpg" width="640" height="480" />
</body>
</html>
'''
@app.route('/stream.mjpg')
def stream():
return Response(gen(camera), mimetype='multipart/x-mixed-replace; boundary=frame')
def gen(camera):
while True:
yield b'--frame
'
yield b'Content-Type: image/jpeg
'
yield camera.get_frame()
yield b'
'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000)
```
In this example, we create a Flask web application that serves a simple HTML page with an `<img>` tag that requests the video stream from the camera. The `gen()` function generates a MIME multipart stream that sends JPEG frames from the camera to the client. The `stream()` function returns this stream as a response to the `/stream.mjpg` request.
### Example 3: Motion Detection using OpenCV
This example demonstrates how to use the Raspberry Pi Camera Module 3 NoIR to detect motion using OpenCV:
```python
import cv2
import picamera
# Create a camera object
camera = picamera.PiCamera()
# Set the camera resolution and format
camera.resolution = (640, 480)
camera.format = 'bgr'
# Create an OpenCV window
cv2.namedWindow('Motion Detection', cv2.WINDOW_NORMAL)
while True:
# Capture a frame from the camera
frame = camera.capture numpy.array(camera.capture()))
# Convert the frame to grayscale
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Apply Gaussian blur to reduce noise
blur = cv2.GaussianBlur(gray, (21, 21), 0)
# Calculate the absolute difference between the current frame and the previous frame
frame_delta = cv2.absdiff(blur, cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY))
# Threshold the frame delta to detect motion
thresh = cv2.threshold(frame_delta, 25, 255, cv2.THRESH_BINARY)[1]
# Draw contours around detected motion
contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for contour in contours:
cv2.drawContours(frame, [contour], -1, (0, 255, 0), 2)
# Display the output
cv2.imshow('Motion Detection', frame)
# Exit on key press
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release resources
cv2.destroyAllWindows()
camera.close()
```
In this example, we create a `picamera.PiCamera()` object and set the camera resolution and format. We then capture frames from the camera and process them using OpenCV to detect motion. The motion detection algorithm involves converting the frame to grayscale, applying Gaussian blur, calculating the absolute difference between the current frame and the previous frame, and thresholding the result to detect motion. We then draw contours around detected motion and display the output using OpenCV.