[YOLO] Error msg : RuntimeException: java.lang.Error: Invalid memory access

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...");
  movie = new Movie(this, "video3.mp4");

int textSize = 12;

public void draw() {
  if (movie.width == 0) {    return;  }
  // movie.resize(width,height);  image(movie, 0, 0, width,height);
  image(movie, 0, 0);
  detections = yolo.run(movie);


  for (ObjectDetectionResult detection : detections) {
    int hue = (int)(360.0 / yolo.getLabels().size() * detection.getClassId());

    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);

    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)
  1. Is it a matter of my computer specs?

  2. Is it a matter of the specification of the processing tool?

1 Like

It’s not processing. I’ve created 2160p videos from frames generated in Processing. 2160p is 3840 x 2160.


@BrendanL Thanks for the reply.

  1. Simply ‘video’ operation is not affected by resolution.

  2. When using the ‘Deep Vision’ library together, an ‘error’ will occur.
    Is it just me?


Your code works for me.

Details (short list) of system:

  • W10 Pro 21H1

  • Intel(R) Core™ i7-6700 CPU @ 3.40GHz, 16GB ram

  • Processing 4.0b1

  • NVidia video card

  • 1280X720 MP4 video used

  • Library from:

  • The latest Sound and Video library from Contribution Manager.

The only hiccup was I had to remove FX2D and I also changed size:

size(1000, 800, FX2D); // I changed this

Nice formatting!



I am not at a computer atm, but your stacktrace does not show anything deep vision related if I read it correctly.

It sounds more like a timing (concurrency) problem…

Not sure what happens memorywise if you copy a PImage from gstreamer (should be in the GPU), but maybe it‘s solving the problem. Just try to copy the movie frame before feeding it into Deep Vision.

Or just removie the movieEvent and read the frame in the draw method directly, to being able to control the timing.


@glv, @cansik,

Thank you for quick response.
The ‘resolution problem’ was resolved through the ‘video library version’ update.

However, there seems to be a problem with the ‘resize’ function.


If the above function is used, no progress is made.

Does anyone know how to solve it?

Are you trying to change the size of movie playback for each frame?

If I recall right, the issue with resizing Movie frames is that you need to wait until the first frame actually has a width and height, after it has been decoded. See old discussion that might be relevant…




Thank you. ^^

1 Like