flutter_cv2\
*** version 0.0.1 ***
A custom Flutter plugin that bridges the power of OpenCV in C++ with real-time camera access in Flutter. Designed to enable real-time image streaming, frame analysis, and snapshot capturingโperfect for AI/ML projects focused on computer vision.
๐ Currently available on Linux with upcoming support for Web, Android, Windows, macOS, and iOS in weekly updates.
โจ Why I Built This
As a developer passionate about AI and computer vision, I constantly faced a pain point: lack of a cross-platform real-time camera plugin that works seamlessly with OpenCV and Flutter.
Most camera plugins are either platform-limited or lack direct access to frame buffers required for AI/ML models. So, I decided to step up and build my own solution โ one that combines the low-level power of C++ OpenCV with the flexibility of Flutter.
If you work with mobile or edge AI, this is the plugin you've been waiting for.
โ Features
- ๐ง Real-time camera feed powered by C++ OpenCV.
- ๐ฏ
Cv2Camera
widget to render frames in your Flutter app. - ๐ Frame subscription via
onFrame
(NumPy-array format). - ๐ผ๏ธ Access raw image bytes via
onByte
. - ๐ธ Snapshots with
onSnap
โ save or analyze. - ๐ Flip camera feed (horizontal/vertical/both).
- ๐ Built with FFI and native C++.
- ๐ป Linux supported now. Cross-platform rollout coming weekly.
๐ Getting Started
- Add to your
pubspec.yaml
:
dependencies:
flutter_cv2_camera:
git:
url: https://github.com/jamesadewara/flutter_cv2_camera
-
Linux prerequisites:
- Make sure you have OpenCV (
opencv4
) installed. - CMake >= 3.10.
- Make sure you have OpenCV (
-
Your Flutter app must run on Linux for now:
flutter run -d linux
Windows, Web, and Android support will be added soon โ follow the repo for updates.
๐ ๏ธ Usage
final controller = Cv2CameraController();
Cv2Camera(
controller: controller,
onFrame: (frame) {
// Access as NumPy array (in Uint8List form)
processFrame(frame.bytes);
},
onByte: (bytes) {
// Save or stream
upload(bytes);
},
flipCode: 0, // vertical: 0, horizontal: 1, both: -1
width: 300,
height: 250,
)
To capture a snapshot:
final bytes = await controller.takeSnap();
// Save or analyze
๐ท Screenshots / Demo
๐ค Contributing
I would love collaborators! If you:
- โค๏ธ OpenCV
- ๐ก Know Flutter + C++
- ๐ง Love AI or mobile edge computing
Letโs build the future of mobile-first AI vision systems together. PRs and issues are highly welcome.
๐ฎ Roadmap
- โ Linux support
- ๐ Web support
- ๐ Android support
- ๐ Windows support
- ๐ macOS & iOS
๐ฉ Stay Updated
Follow me on LinkedIn or GitHub for weekly updates.