Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5118

Java • Processing and OpenCV

$
0
0
Now that I have a Pi5 I wanted to test some Computer Vision.
Been on my to do list for decades and I try every few years on Pi's.

A real pain to install Tensorflow, it needs X which needs Y which needs Z etc.
Tried many other ways that failed, the old Pip3 install methods don't work etc.

I had already tested Processing and was happy with how less slow it was than the last time I tested Java stuff on Pi's.
A bit of a search found this
https://www.youtube.com/watch?v=YX41KXbMf_U
A few minutes to install the library, finding a USB webcam and my face had a green box around it.

The quickest way ever to try OpenCV on a Pi5?
No compiling from source or missing libs, it just worked.
Probably not the fastest face recog but it sure was the easiest to get running.
And not much code :D

Code:

import gab.opencv.*;import processing.video.*;import java.awt.*;Capture video;OpenCV opencv;void setup() {  size(640, 480);  video = new Capture(this, 640/2, 480/2);  opencv = new OpenCV(this, 640/2, 480/2);  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);    video.start();}void draw() {  scale(2);  opencv.loadImage(video);  image(video, 0, 0 );  noFill();  stroke(0, 255, 0);  strokeWeight(3);  Rectangle[] faces = opencv.detect();    for (int i = 0; i < faces.length; i++) {    rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);  }}void captureEvent(Capture c) {  c.read();}
All I want to do is estimate and make a BVH pose from a single image, can this do it?

Statistics: Posted by Gavinmc42 — Tue Feb 20, 2024 12:04 pm



Viewing all articles
Browse latest Browse all 5118

Trending Articles