Grove - Vision AI Module V2 Documentation
The Grove - Vision AI Module V2 is a powerful computer vision module designed for edge AI applications. It features a high-performance AI chip, a 2MP camera, and various interfaces for connecting to other devices. This module is capable of performing various computer vision tasks, including object detection, facial recognition, and image classification.
AI Chip: Kneron KL720
Camera: 2MP, 1600x1200 pixels, fixed focus
Interfaces: USB, UART, I2C, SPI, GPIO
Power Supply: 5V, 1A
Operating Temperature: -20C to 70C
The Grove - Vision AI Module V2 supports various programming languages, including Python, C++, and Java. The module comes with a range of pre-trained AI models and a software development kit (SDK) that provides APIs for developing custom applications.
### Example 1: Object Detection using Python
This example demonstrates how to use the Grove - Vision AI Module V2 for object detection using Python.
```python
import os
import cv2
from kvision import KVision
# Initialize the module
kv = KVision()
# Load the pre-trained object detection model
kv.load_model('object_detection')
# Capture an image from the camera
img = cv2.imread('image.jpg')
# Pre-process the image
img = cv2.resize(img, (300, 300))
img = img / 255.0
# Perform object detection
detections = kv.detect(img)
# Print the detection results
for detection in detections:
print(f'Class: {detection.class_id}, Confidence: {detection.confidence:.2f}, BBox: {detection.bbox}')
# Release the module
kv.release()
```
### Example 2: Facial Recognition using C++
This example demonstrates how to use the Grove - Vision AI Module V2 for facial recognition using C++.
```cpp
#include "kvision.h"
int main() {
// Initialize the module
KVision kv;
// Load the pre-trained facial recognition model
kv.load_model("facial_recognition");
// Capture an image from the camera
cv::Mat img = cv::imread("image.jpg");
// Pre-process the image
cv::resize(img, img, cv::Size(300, 300));
img.convertTo(img, CV_32F, 1/255.0);
// Perform facial recognition
std::vector<Face> faces;
kv.recognize(img, faces);
// Print the recognition results
for (const auto& face : faces) {
std::cout << "Face ID: " << face.id << ", Confidence: " << face.confidence << std::endl;
}
// Release the module
kv.release();
return 0;
}
```
### Example 3: Image Classification using Java
This example demonstrates how to use the Grove - Vision AI Module V2 for image classification using Java.
```java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.bytedeco.javacv.OpenCVFrameGrabber;
import org.bytedeco.javacv.FrameGrabber.Exception;
import com.kvision.KVision;
public class ImageClassifier {
public static void main(String[] args) throws Exception {
// Initialize the module
KVision kv = new KVision();
// Load the pre-trained image classification model
kv.load_model("image_classification");
// Capture an image from the camera
OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0);
grabber.start();
Frame frame = grabber.getFrame();
grabber.stop();
grabber.release();
// Pre-process the image
Mat img = new Mat(frame.height, frame.width, CV_8UC3);
img.put(0, 0, frame.imageData);
// Perform image classification
List<ClassificationResult> results = kv.classify(img);
// Print the classification results
for (ClassificationResult result : results) {
System.out.println("Class: " + result.className + ", Confidence: " + result.confidence);
}
// Release the module
kv.release();
}
}
```
These examples demonstrate how to use the Grove - Vision AI Module V2 for various computer vision tasks, including object detection, facial recognition, and image classification. By following these examples, developers can easily integrate this module into their IoT projects and build innovative AI-powered applications.