I’m currently working on a project to detect and track a color in the kinect image.
However when my program gets to the line:
color currentColor = img.pixels [loc];
It crashes and gives me the following error message:
ArrayIndexOutOfBoundsException: 825032704
I have tried everything and I am really stuck at how to fix this so any advice would be much appreciated. I’ve seen this line of code being used online in many examples so I cannot understand why it won’t work.
Many thanks!
My code is as follows:
import processing.video.*;
import org.openkinect.processing.*;
Kinect2 kinect2;
color trackColor;
void setup() {
size(526,424);
kinect2 = new Kinect2(this);
kinect2.initVideo();
kinect2.initRegistered();
kinect2.initDevice();
}
void draw(){
PImage img = kinect2.getRegisteredImage();
image(img,0,0);
int [] depth = kinect2.getRawDepth();
int avgX = 0;
int avgY = 0;
int count = 0;
for(int x =0; x <kinect2.depthWidth; x++) {
for(int y=0; y <kinect2.depthWidth; y++){
int loc = x +y*kinect2.depthWidth;
color currentColor = img.pixels [loc];
}
}
}
I added in that function but the program still freezes when I run that line of code.
img.loadPixels();
This is the message that I get in the console:
[Freenect2DeviceImpl] submitting usb transfers...
[RgbPacketStreamParser::onDataReceived] packetsize or sequence doesn't match!
[Freenect2DeviceImpl] started
Device Serial: 502554743142
Device Firmware: 4.3.3916.0.7
[DepthPacketStreamParser::onDataReceived] not all subsequences received 0
[TurboJpegRgbPacketProcessor::doProcess] Failed to decompress rgb image! TurboJPEG error: 'Corrupt JPEG data: premature end of data segment'
[DepthPacketStreamParser::onDataReceived] not all subsequences received 1022
[DepthPacketStreamParser::onDataReceived] not all subsequences received 512
[DepthPacketStreamParser::onDataReceived] not all subsequences received 959
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting.
But that has cleared up the ArrayIndexOutOfBoundsException error.
*****EDIT ***
Actually so I’m getting different error messages in the console each time but theyre something along the lines:
[TurboJpegRgbPacketProcessor::doProcess] Failed to decompress rgb image! TurboJPEG error: 'Corrupt JPEG data: 860 extraneous bytes before marker 0xd5'
or
[TurboJpegRgbPacketProcessor::doProcess] Failed to decompress rgb image! TurboJPEG error: 'Corrupt JPEG data: premature end of data segment'
The ArrayIndexOutOfBoundsException error is still coming up too.