Software Archive
Read-only legacy content
17061 Discussions

Problems getting tracked joints and landmark points with RealSense and Java

ThomasE
Beginner
848 Views

Hello together,

I'm currently facing massive problems using the Java API for tracking both face landmarks and hand joints. When tracking face landmarks, I get access violation exceptions. When trying to get the face landmarks, the field "confidenceWorld" cannot be found when creating the results.

Here is the example using tracked joints with the resulting access violation exception (as a comment):

package com.parrotsonjava.test;

import intel.rssdk.*;

public class HandsExample {
    public static void main(String[] args) {
        // Init
        PXCMSenseManager senseManager = PXCMSession.CreateInstance().CreateSenseManager();
        senseManager.EnableHand(null);
        senseManager.Init();

        // Configuration
        PXCMHandModule handModule = senseManager.QueryHand();
        PXCMHandConfiguration handConfig = handModule.CreateActiveConfiguration();
        handConfig.EnableTrackedJoints(true);
        handConfig.ApplyChanges();
        handConfig.Update();

        PXCMHandData handData = handModule.CreateOutput();
        while (true) {
            senseManager.AcquireFrame(true);
            senseManager.QueryHandSample();
            handData.Update();

            int numberOfHands = handData.QueryNumberOfHands();
            if (numberOfHands > 0) {
                PXCMHandData.IHand hand = new PXCMHandData.IHand();
                handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_NEAR_TO_FAR, 0, hand);

                PXCMHandData.JointData jointData = new PXCMHandData.JointData();

                // This call gives an access violation exception
                hand.QueryTrackedJoint(PXCMHandData.JointType.JOINT_CENTER, jointData);

                System.out.println(jointData.confidence);
            }

            senseManager.ReleaseFrame();
        }
    }

    /*
        Output:

        Connected to the target VM, address: '127.0.0.1:11677', transport: 'socket'
        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff99e41720a, pid=6140, tid=5016
        #
        # JRE version: Java(TM) SE Runtime Environment (7.0_65-b19) (build 1.7.0_65-b19)
        # Java VM: Java HotSpot(TM) 64-Bit Server VM (24.65-b04 mixed mode windows-amd64 compressed oops)
        # Problematic frame:
        # C  [libpxcclr.jni.dll+0x1720a]  Marshal::Copy_s+0x38a
        #
        # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
        #
        # An error report file with more information is saved as:
        # C:\Users\thoma_000\projects\intel-realsense-start-java\hs_err_pid6140.log
        #
        # If you would like to submit a bug report, please visit:
        #   http://bugreport.sun.com/bugreport/crash.jsp
        # The crash happened outside the Java Virtual Machine in native code.
        # See problematic frame for where to report the bug.
        #
        Disconnected from the target VM, address: '127.0.0.1:11677', transport: 'socket'

        Process finished with exit code 1
    */
}

And here is the landmark example with the resulting reflection exception:

package com.parrotsonjava.test;

import intel.rssdk.*;

public class FaceExample {

    public static void main(String[] args) {
        // Init
        PXCMSenseManager senseManager = PXCMSession.CreateInstance().CreateSenseManager();
        senseManager.EnableFace(null);
        senseManager.Init();

        PXCMFaceModule faceModule = senseManager.QueryFace();
        PXCMFaceData faceData = faceModule.CreateOutput();

        // Configuration
        PXCMFaceConfiguration moduleConfiguration = faceModule.CreateActiveConfiguration();
        moduleConfiguration.SetTrackingMode(PXCMFaceConfiguration.TrackingModeType.FACE_MODE_COLOR);
        moduleConfiguration.detection.isEnabled = true;
        moduleConfiguration.landmarks.isEnabled = true;
        moduleConfiguration.ApplyChanges();
        moduleConfiguration.close();

        while (true) {
            senseManager.AcquireFrame(true);
            senseManager.QueryFaceSample();
            faceData = faceModule.CreateOutput();
            faceData.Update();

            int numberOfFaces = faceData.QueryNumberOfDetectedFaces();
            if (numberOfFaces > 0) {
                PXCMFaceData.Face face = faceData.QueryFaceByIndex(0);
                PXCMFaceData.LandmarksData landmarks = face.QueryLandmarks();

                int numberOfPoints = landmarks.QueryNumPoints();    // 78
                PXCMFaceData.LandmarkPoint[] points = new PXCMFaceData.LandmarkPoint[numberOfPoints];
                for (int i = 0; i < points.length; i++) {
                    points = new PXCMFaceData.LandmarkPoint();
                }

                // This produces the conversion error
                landmarks.QueryPoints(points);
            }

            senseManager.ReleaseFrame();
        }
    }

    /*
        Output:

        Exception in thread "main" java.lang.NoSuchFieldError: confidenceWorld
            at intel.rssdk.PXCMFaceData$LandmarksData.PXCMFaceData_LandmarksData_QueryPoints(Native Method)
            at intel.rssdk.PXCMFaceData$LandmarksData.QueryPoints(PXCMFaceData.java:176)
            at com.parrotsonjava.test.FaceExample.main(FaceExample.java:42)
    */
}

If you want to try it out for yourself, just add the "libpxcclr.java.jar" (from folder C:\Program Files (x86)\Intel\RSSDK\framework\common\pxcclr.java\bin\x64) to your classpath. Then set the Java library path as a VM argument:

-Djava.library.path=folder/of/libpxcclr.jni.dll

When a face or a hand is found, the exceptions shown in the output will appear.

What can I do about this? Thanks in advance for your help.

0 Kudos
7 Replies
Nacho_C_
Beginner
848 Views

Hi Thomas,

the Java API looks very buggy. On the other hand, the Java wrapper that the guys from libGDX project made worked great with the previous release (https://github.com/libgdx/gdx-realsense) But since I upgraded to the R2 release of the SDK is not working any more.

How did you rebuild the jni, is its source available?

Regards.

0 Kudos
ThomasE
Beginner
848 Views

Hello,

We rebuilt it using the code from the "common" folder. There is a Visual Studio project containing the bindings which creates the .dll file and also some .java files for the jar file. We also saw that these files are not in sync with the C++/C# API anymore. I think that it might not be that hard to realign the APIs. If I have some time left within the next few weeks, I will have a look at that.

0 Kudos
Keith_H_
Beginner
848 Views

Hi Thomas - did you get a chance to realign the APIs. I've noticed other issues with the Java API e.g. implementing a PXCMSenseManager.Handler if I recall has similar issues. I also seem to get frequent

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffa45e24c20, pid=12420, tid=6272
#
# JRE version: Java(TM) SE Runtime Environment (8.0_31-b13) (build 1.8.0_31-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.31-b07 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [libpxcclr.jni.dll+0x4c20]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

 

0 Kudos
ThomasE
Beginner
848 Views

Unfortunately, I didn't find the time yet. However, the error you get seems quite familiar. I think that you get this error when the C object is smaller than the DLL wrapper for JNI is expecting it to be. The wrapper tries to load data from memory areas that don't belong to this data structure anymore. I think that this causes the problem. This could be the case when there are more properties specified in the wrapper project than available in the underlying C code.

0 Kudos
Xusheng_L_Intel
Employee
848 Views

This is a known bug. Same issue in the face reflection. We will fix in the next public release. Thanks!

0 Kudos
Mona_J_
Beginner
848 Views

When I am trying to run this code I get "Access Violation" error too. It is supposed to run as it is a tutorial. Any idea what is wrong?

 

Thanks,

Mona Jalal.

Here's the log I receive:

'WpfApplication2.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApplication2.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Users\Mona\Downloads\RealSenseFacialRecognition\WpfApplication4\WpfApplication2\bin\x64\Debug\WpfApplication2.exe'. Symbols loaded.
'WpfApplication2.exe' (CLR v4.0.30319: WpfApplication2.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApplication2.exe' (CLR v4.0.30319: WpfApplication2.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApplication2.exe' (CLR v4.0.30319: WpfApplication2.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApplication2.exe' (CLR v4.0.30319: WpfApplication2.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApplication2.exe' (CLR v4.0.30319: WpfApplication2.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Step into: Stepping over non-user code 'WpfApplication2.App..ctor'
'WpfApplication2.exe' (CLR v4.0.30319: WpfApplication2.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApplication2.exe' (CLR v4.0.30319: WpfApplication2.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Step into: Stepping over non-user code 'WpfApplication2.App.Main'
Step into: Stepping over non-user code 'WpfApplication2.App.InitializeComponent'
'WpfApplication2.exe' (CLR v4.0.30319: WpfApplication2.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Aero2\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Aero2.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApplication2.exe' (CLR v4.0.30319: WpfApplication2.exe): Loaded 'C:\Users\Mona\Downloads\RealSenseFacialRecognition\WpfApplication4\WpfApplication2\bin\x64\Debug\libpxcclr.cs.dll'. Cannot find or open the PDB file.
'WpfApplication2.exe' (CLR v4.0.30319: WpfApplication2.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\UIAutomationTypes\v4.0_4.0.0.0__31bf3856ad364e35\UIAutomationTypes.dll'. Cannot find or open the PDB file.
A first chance exception of type 'System.NullReferenceException' occurred in WpfApplication2.exe
'WpfApplication2.exe' (CLR v4.0.30319: WpfApplication2.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'. 
The program '[7972] WpfApplication2.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.

0 Kudos
Fabio_R_
Beginner
848 Views
Hi. I have the same problem.
They are still in development. How can I fix it .. I wait for an answer..

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff931c62632, pid=2916, tid=4316
#
# JRE version: Java(TM) SE Runtime Environment (8.0_40-b26) (build 1.8.0_40-b26)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.40-b25 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [libpxcclr.jni64.dll+0x12632]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\sviluppo\workspace\IntelRealsense\hs_err_pid2916.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.


thanks
0 Kudos
Reply