Go to Post Such is life in the fast-paced, laugh-in-the-face-of-adversity, never-let-them-see-you-sweat, sometimes-you're-the-windshield-sometimes-you're-the-bug world of FIRST Robotics! - Sean Schuff [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 11-06-2016, 12:58 PM
cnc4 cnc4 is offline
Registered User
FRC #2231
 
Join Date: Jul 2016
Location: Israel
Posts: 8
cnc4 is an unknown quantity at this point
Getting axisCamera image result in an exception somtimes

Hi all, my team and I are trying to make vision code for the robot.
The vision works great but sometimes we get an exception from the getImage method in the axisCamera class. After I get several exception I get an outOfMemory exception pointing on the getImage method. Those two exception are pointing on the native method that the getImage use.
Error:
Code:
_Priv_ReadJPEGString_C(image.getAddress(), getByteBufferAddress(string_buf), stringLength);
Line 29329 in NIVision.class.

I dont have the error text right now but this is an unkownError type. the error code is imaqError -123673104, I didnt find any help in the internet for this error.

Thanks in advance!

Last edited by cnc4 : 11-06-2016 at 01:55 PM.
Reply With Quote
  #2   Spotlight this post!  
Unread 11-07-2016, 07:20 AM
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 298
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Getting axisCamera image result in n ecxeption somtimes

That error code is undocumented. Can you post the full error text?
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #3   Spotlight this post!  
Unread 11-07-2016, 08:21 AM
cnc4 cnc4 is offline
Registered User
FRC #2231
 
Join Date: Jul 2016
Location: Israel
Posts: 8
cnc4 is an unknown quantity at this point
Re: Getting axisCamera image result in n ecxeption somtimes

Quote:
Originally Posted by euhlmann View Post
That error code is undocumented. Can you post the full error text?
Here you go, hope this help.

Thanks for your help!
Attached Thumbnails
Click image for larger version

Name:	vesion error.png
Views:	15
Size:	685.3 KB
ID:	21251  
Reply With Quote
  #4   Spotlight this post!  
Unread 11-07-2016, 11:09 AM
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 298
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Getting axisCamera image result in n ecxeption somtimes

Take screenshots please

So it's more than an undocumented error code, it seems WPILib is actually using NIVision black magic with a "private" function that's completely undocumented. You might be better off opening an issue on the WPILib repo. I can't help without documentation or source code
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote
  #5   Spotlight this post!  
Unread 11-07-2016, 11:00 PM
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Getting axisCamera image result in an exception somtimes

Quote:
Originally Posted by cnc4 View Post
Hi all, my team and I are trying to make vision code for the robot.
The vision works great but sometimes we get an exception from the getImage method in the axisCamera class. After I get several exception I get an outOfMemory exception pointing on the getImage method. Those two exception are pointing on the native method that the getImage use.
Error:
Code:
_Priv_ReadJPEGString_C(image.getAddress(), getByteBufferAddress(string_buf), stringLength);
Line 29329 in NIVision.class.

I dont have the error text right now but this is an unkownError type. the error code is imaqError -123673104, I didnt find any help in the internet for this error.

Thanks in advance!
My understanding of the NIVision code is that it's actually written in C++ natively and have a Java wrapper. Because of this, the Java garbage collector doesn't reclaim image buffers allocated by NIVision API. Therefore, if you allocate image buffer for every frame, you are going to run out of memory really fast if you don't explicitly release the buffer after it's done. There are a lot of discussion threads about this issue, you can probably find and read them in the forums here. There are two ways to fix this. You can either rewrite the code so it doesn't allocate a new image buffer on every frame you process (we rewrote our code that only uses two preallocated frame buffers), or you will need to call image.free() when you are done with the buffer (Please note that I don't have the NIVision documentation in front of me so the actual API name may be different).
__________________
Reply With Quote
  #6   Spotlight this post!  
Unread 11-07-2016, 11:32 PM
cnc4 cnc4 is offline
Registered User
FRC #2231
 
Join Date: Jul 2016
Location: Israel
Posts: 8
cnc4 is an unknown quantity at this point
Re: Getting axisCamera image result in an exception somtimes

Quote:
Originally Posted by mikets View Post
My understanding of the NIVision code is that it's actually written in C++ natively and have a Java wrapper. Because of this, the Java garbage collector doesn't reclaim image buffers allocated by NIVision API. Therefore, if you allocate image buffer for every frame, you are going to run out of memory really fast if you don't explicitly release the buffer after it's done. There are a lot of discussion threads about this issue, you can probably find and read them in the forums here. There are two ways to fix this. You can either rewrite the code so it doesn't allocate a new image buffer on every frame you process (we rewrote our code that only uses two preallocated frame buffers), or you will need to call image.free() when you are done with the buffer (Please note that I don't have the NIVision documentation in front of me so the actual API name may be different).
But the main issue is that I get an unkown exception. You thinks that the exception is cused by outOfBufferException in the native method?

Quote:
Originally Posted by euhlmann View Post
Take screenshots please

So it's more than an undocumented error code, it seems WPILib is actually using NIVision black magic with a "private" function that's completely undocumented. You might be better off opening an issue on the WPILib repo. I can't help without documentation or source code
I would of take screenshots but I did't had the computer neer me .

Ammm... so it never happend to other teams? No one ever reported this issue?
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:58 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi