- library : GitHub - cansik/deep-vision-processing: Deep computer-vision algorithms for the Processing framewo
import ch.bildspur.vision.*;
import ch.bildspur.vision.result.*;
DeepVision deepVision = new DeepVision(this);
YOLONetwork yolo;
ResultList<ObjectDetectionResult> detections;
PImage image;
import processing.video.*;
Movie movie;
void movieEvent(Movie m) { m.read();}
public void setup() {
size(1000, 800, FX2D);
colorMode(HSB, 360, 100, 100);
println("creating model...");
// yolo = deepVision.createYOLOv4();
yolo = deepVision.createYOLOv4Tiny();
println("loading yolo model...");
yolo.setup();
println("inferencing...");
movie = new Movie(this, "video3.mp4");
movie.loop();
}
int textSize = 12;
public void draw() {
background(55);
if (movie.width == 0) { return; }
// movie.resize(width,height); image(movie, 0, 0, width,height);
image(movie, 0, 0);
yolo.setConfidenceThreshold(0.2f);
detections = yolo.run(movie);
strokeWeight(3f);
textSize(textSize);
for (ObjectDetectionResult detection : detections) {
int hue = (int)(360.0 / yolo.getLabels().size() * detection.getClassId());
noFill();
stroke(hue, 80, 100);
rect(detection.getX(), detection.getY(), detection.getWidth(), detection.getHeight());
fill(hue, 80, 100);
rect(detection.getX(), detection.getY() - (textSize + 3), textWidth(detection.getClassName()) + 4, textSize + 3);
fill(0);
textAlign(LEFT, TOP);
text(detection.getClassName(), detection.getX() + 2, detection.getY() - textSize - 3);
}
surface.setTitle("Webcam YOLO Test - FPS: " + Math.round(frameRate));
}
Video size: 640 x 480
It works to some extent.
Video size: 1280 x 720
An error pops up and it doesn’t work.
RuntimeException: java.lang.Error: Invalid memory access
java.lang.RuntimeException: java.lang.Error: Invalid memory access
at processing.javafx.PSurfaceFX.lambda$0(PSurfaceFX.java:411)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.Error: Invalid memory access
at com.sun.jna.Native.invokePointer(Native Method)
at com.sun.jna.Function.invokePointer(Function.java:477)
at com.sun.jna.Function.invoke(Function.java:411)
at com.sun.jna.Function.invoke(Function.java:323)
at com.sun.jna.Library$Handler.invoke(Library.java:236)
at com.sun.proxy.$Proxy33.g_type_name(Unknown Source)
at org.gstreamer.lowlevel.GstTypes.find(GstTypes.java:58)
at org.gstreamer.lowlevel.GstTypes.classFor(GstTypes.java:90)
at org.gstreamer.ElementFactory.elementFor(ElementFactory.java:214)
at org.gstreamer.ElementFactory.make(ElementFactory.java:92)
RuntimeException: java.lang.Error: Invalid memory access
at org.gstreamer.elements.RGBDataAppSink.<init>(RGBDataAppSink.java:63)
at processing.video.Movie.initSink(Unknown Source)
at processing.video.Movie.play(Unknown Source)
at processing.video.Movie.loop(Unknown Source)
at YOLODetectObjects.setup(YOLODetectObjects.java:46)
at processing.core.PApplet.handleDraw(PApplet.java:2425)
at processing.javafx.PSurfaceFX$1.handle(PSurfaceFX.java:89)
at processing.javafx.PSurfaceFX$1.handle(PSurfaceFX.java:1)
at com.sun.scenario.animation.shared.TimelineClipCore.visitKeyFrame(TimelineClipCore.java:239)
at com.sun.scenario.animation.shared.TimelineClipCore.playTo(TimelineClipCore.java:197)
at javafx.animation.Timeline.impl_playTo(Timeline.java:176)
at javafx.animation.AnimationAccessorImpl.playTo(AnimationAccessorImpl.java:39)
at com.sun.scenario.animation.shared.InfiniteClipEnvelope.timePulse(InfiniteClipEnvelope.java:110)
at javafx.animation.Animation.impl_timePulse(Animation.java:1102)
at javafx.animation.Animation$1.lambda$timePulse$25(Animation.java:186)
at java.security.AccessController.doPrivileged(Native Method)
at javafx.animation.Animation$1.timePulse(Animation.java:185)
at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:344)
at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:267)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:514)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:498)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:491)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$408(QuantumToolkit.java:319)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177)
... 1 more
[My computer sepc]
- Windows 10 64bit
- Intel core i7-9700KF CPU @3.60GHz
- 32GB(RAM)
-
Is it a matter of my computer specs?
-
Is it a matter of the specification of the processing tool?