Go to Post Remember, there are many differents path to obtaining knowledge. There's no need to pigeonhole the process. - Karthik [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 19-02-2016, 19:25
thblackhelmetma's Avatar
thblackhelmetma thblackhelmetma is offline
Registered User
AKA: Aleksandar Antic
FRC #0670 (Homestead Robotics Team)
Team Role: CAD
 
Join Date: Feb 2016
Rookie Year: 2015
Location: Los Altos
Posts: 3
thblackhelmetma is an unknown quantity at this point
Question JavaCV Help

Hello fine members of Chief Delphi!

Team 670 is trying to use OpenCV for vision tracking of the goals, and for various reasons, we exclusively code in Java. Therefore, we are using JavaCV in order to do our tracking.

Our algorithm works fine when we use images and run it directly on our PC. However, when we upload the code to the roboRIO, we get an UnsatisfiedLinkError (Stack Trace Below). This error pops up whenever we call any method from any class in the OpenCV package.

Code:
ERROR Unhandled exception: java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path at
[java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857),
java.lang.Runtime.loadLibrary0(Runtime.java:870),
java.lang.System.loadLibrary(System.java:1119),
org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:597),
org.bytedeco.javacpp.Loader.load(Loader.java:438),
org.bytedeco.javacpp.Loader.load(Loader.java:381),
org.bytedeco.javacpp.opencv_core.<clinit>(opencv_core.java:10),
java.lang.Class.forName0(Native Method),
java.lang.Class.forName(Class.java:340),
org.bytedeco.javacpp.Loader.load(Loader.java:413),
org.bytedeco.javacpp.Loader.load(Loader.java:381),
org.bytedeco.javacpp.opencv_imgcodecs.<clinit>(opencv_imgcodecs.java:13),
org.usfirst.frc.team670.robot.Robot.process(Robot.java:85),
org.usfirst.frc.team670.robot.Robot.operatorControl(Robot.java:68),
edu.wpi.first.wpilibj.SampleRobot.startCompetition(SampleRobot.java:159),
edu.wpi.first.wpilibj.RobotBase.main(RobotBase.java:242)]
WARNING: Robots don't quit!
I have verified our build.properties and build.xml files many times, and they appear to be correct, but I will include them here anyway.

build.properties
Code:
# Project specific information
package=org.usfirst.frc.team670.robot
robot.class=${package}.Robot
userLibs = ${user.home}/wpilib/user/lib/javacpp.jar:${user.home}/wpilib/user/lib/opencv.jar:${user.home}/wpilib/user/lib/javacv.jar
build.xml
Code:
<project name="FRC Deployment" default="deploy">
    <property file="${user.home}/wpilib/wpilib.properties"/>
    <property file="build.properties"/>
    <property file="${user.home}/wpilib/java/${version}/ant/build.properties"/>
    <property name="classpath" value="${opencv.jar}:${javacpp.jar}:${javacv.jar}" />
    <import file="${wpilib.ant.dir}/build.xml"/>
</project>
So far, I have tried adding various native libraries to all of the different jars, in order to try and appease the UnsatisfiedLinkError, adding various dll files, and many other solutions recommended by the Internet. Nothing has worked thus far.

Could anyone help with this problem?
Reply With Quote
  #2   Spotlight this post!  
Unread 19-02-2016, 20:18
ThomasClark's Avatar
ThomasClark ThomasClark is offline
Registered User
FRC #0237
 
Join Date: Dec 2012
Location: Watertown, CT
Posts: 146
ThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud of
Re: JavaCV Help

JavaCV doesn't support the roboRIO out-of-the-box. You could grab the build that GRIP uses and save yourself the trouble of compiling it yourself.
__________________
GRIP (Graphically Represented Image Processing) - rapidly develop computer vision algorithms for FRC
Reply With Quote
  #3   Spotlight this post!  
Unread 19-02-2016, 22:03
Ozuru's Avatar
Ozuru Ozuru is offline
It's always the programmer's fault.
no team
 
Join Date: May 2013
Rookie Year: 2010
Location: Earth
Posts: 268
Ozuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to behold
Re: JavaCV Help

Running vision processing code on your roboRIO itself is generally a bad idea. You should simply intercept the images being sent and perform the analyses on your driver's station.
Reply With Quote
  #4   Spotlight this post!  
Unread 20-02-2016, 13:47
thblackhelmetma's Avatar
thblackhelmetma thblackhelmetma is offline
Registered User
AKA: Aleksandar Antic
FRC #0670 (Homestead Robotics Team)
Team Role: CAD
 
Join Date: Feb 2016
Rookie Year: 2015
Location: Los Altos
Posts: 3
thblackhelmetma is an unknown quantity at this point
Re: JavaCV Help

Quote:
Originally Posted by Ozuru View Post
Running vision processing code on your roboRIO itself is generally a bad idea. You should simply intercept the images being sent and perform the analyses on your driver's station.
Thanks for your input. Is there any particular way to intercept the images when using a USB camera?
Reply With Quote
  #5   Spotlight this post!  
Unread 21-02-2016, 23:56
Ozuru's Avatar
Ozuru Ozuru is offline
It's always the programmer's fault.
no team
 
Join Date: May 2013
Rookie Year: 2010
Location: Earth
Posts: 268
Ozuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to behold
Re: JavaCV Help

Quote:
Originally Posted by thblackhelmetma View Post
Thanks for your input. Is there any particular way to intercept the images when using a USB camera?
Yes. Since the SmartDashboard is in Java, it is easily decompileable with tools like JD-GUI. I looked at how the USB camera widget worked and made a public static function in it that allowed me to get the latest frame. In another widget, I had it call that function to get the image and then process it with OpenCV. If you have questions throughout the process, don't be afraid to PM me. It's taken about two seasons but I think I've finally got a grasp on how SmartDashboard's extension system works.

To start off, your SmartDashboard will probably be in C:/Users/<username>/wpilib/tools/SmartDashboard.jar. Open it up in JD-GUI and start poking around for something that resembles the USB camera widget. You'll know it when you find it:

Code:
public static final NAME = "USB Webcam Viewer";
Reply With Quote
  #6   Spotlight this post!  
Unread 22-02-2016, 00:04
ThomasClark's Avatar
ThomasClark ThomasClark is offline
Registered User
FRC #0237
 
Join Date: Dec 2012
Location: Watertown, CT
Posts: 146
ThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud of
Re: JavaCV Help

Quote:
Originally Posted by Ozuru View Post
Yes. Since the SmartDashboard is in Java, it is easily decompileable with tools like JD-GUI. I looked at how the USB camera widget worked and made a public static function in it that allowed me to get the latest frame. In another widget, I had it call that function to get the image and then process it with OpenCV. If you have questions throughout the process, don't be afraid to PM me. It's taken about two seasons but I think I've finally got a grasp on how SmartDashboard's extension system works.

To start off, your SmartDashboard will probably be in C:/Users/<username>/wpilib/tools/SmartDashboard.jar. Open it up in JD-GUI and start poking around for something that resembles the USB camera widget. You'll know it when you find it:

Code:
public static final NAME = "USB Webcam Viewer";
Or just make a TeamForge account and look at the source code? If you decompile the binary you'll lose all of the comments.

Here's another (simplified) reference for the protocol if you don't wanna make an account.
__________________
GRIP (Graphically Represented Image Processing) - rapidly develop computer vision algorithms for FRC
Reply With Quote
  #7   Spotlight this post!  
Unread 22-02-2016, 10:44
Ozuru's Avatar
Ozuru Ozuru is offline
It's always the programmer's fault.
no team
 
Join Date: May 2013
Rookie Year: 2010
Location: Earth
Posts: 268
Ozuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to beholdOzuru is a splendid one to behold
Re: JavaCV Help

Quote:
Originally Posted by ThomasClark View Post
Or just make a TeamForge account and look at the source code? If you decompile the binary you'll lose all of the comments.

Here's another (simplified) reference for the protocol if you don't wanna make an account.
That's interesting to know, thanks. I didn't know that you could get a TeamForge account and view the source code. Every time I attempted to view it, I was unable to.
Reply With Quote
  #8   Spotlight this post!  
Unread 22-02-2016, 15:43
fsilberberg fsilberberg is offline
WPILib Developer
AKA: Fred Silberberg
FRC #0190
Team Role: Alumni
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Redmond
Posts: 146
fsilberberg has a spectacular aura aboutfsilberberg has a spectacular aura aboutfsilberberg has a spectacular aura about
You don't even need an account: wpilib.screenstepslive.com/s/4485/m/wpilib_source/l/480945-getting-the-source.
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 22:43.

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