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

**URL:** <https://discourse.processing.org/t/yolo-error-msg-runtimeexception-java-lang-error-invalid-memory-access/31822>\
**Category:** Libraries\
**Created:** [August 21, 2021, 9:52am UTC](https://discourse.processing.org/t/yolo-error-msg-runtimeexception-java-lang-error-invalid-memory-access/31822 "2021-08-21T09:52:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [August 21, 2021, 9:52am UTC](https://discourse.processing.org/t/yolo-error-msg-runtimeexception-java-lang-error-invalid-memory-access/31822/1 "2021-08-21T09:52:14Z")

</div>

- library : [GitHub - cansik/deep-vision-processing: Deep computer-vision algorithms for the Processing framewo](https://github.com/cansik/deep-vision-processing)

```auto
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.

```auto
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?

---

<div class="post-metadata">

**Author:** ![BrendanL](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/brendanl/32/14076_2.png) [@BrendanL](https://discourse.processing.org/u/BrendanL)\
**Post date:** [August 21, 2021, 9:15pm UTC](https://discourse.processing.org/t/yolo-error-msg-runtimeexception-java-lang-error-invalid-memory-access/31822/2 "2021-08-21T21:15:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [August 22, 2021, 5:49am UTC](https://discourse.processing.org/t/yolo-error-msg-runtimeexception-java-lang-error-invalid-memory-access/31822/3 "2021-08-22T05:49:06Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [August 22, 2021, 12:20pm UTC](https://discourse.processing.org/t/yolo-error-msg-runtimeexception-java-lang-error-invalid-memory-access/31822/4 "2021-08-22T12:20:29Z")

</div>

Hello,

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`

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/767cb07e6aaa7b4b8e6a814dcb0908f9c22a8f68.png)

Nice formatting!

`:)`

---

<div class="post-metadata">

**Author:** ![cansik](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/cansik/32/8815_2.png) [@cansik](https://discourse.processing.org/u/cansik)\
**Post date:** [August 22, 2021, 4:59pm UTC](https://discourse.processing.org/t/yolo-error-msg-runtimeexception-java-lang-error-invalid-memory-access/31822/5 "2021-08-22T16:59:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [August 22, 2021, 11:49pm UTC](https://discourse.processing.org/t/yolo-error-msg-runtimeexception-java-lang-error-invalid-memory-access/31822/6 "2021-08-22T23:49:20Z")

</div>

@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.

movie.resize(width,height);

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

Does anyone know how to solve it?

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [August 27, 2021, 10:01pm UTC](https://discourse.processing.org/t/yolo-error-msg-runtimeexception-java-lang-error-invalid-memory-access/31822/7 "2021-08-27T22:01:36Z")

</div>

> [@GWAK](#):
>
> However, there seems to be a problem with the ‘resize’ function.
> 
> ```
> movie.resize(width,height);
> 
> ```
> 
> If the above function is used, no progress is made.

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

- [Movie / Libraries / Processing.org](https://processing.org/reference/libraries/video/Movie.html)

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…

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/23389/resizing-a-movie-possible-bug)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [August 29, 2021, 11:01pm UTC](https://discourse.processing.org/t/yolo-error-msg-runtimeexception-java-lang-error-invalid-memory-access/31822/8 "2021-08-29T23:01:17Z")

</div>

@jeremydouglass

Thank you. ^^
