Software Archive
Read-only legacy content

Getting error when creating two sensemanagers

Wezley_S_
New Contributor I
756 Views

Hello!

In my program I'm utilizing both hand tracking, and facial landmarking. My program makes both of these run at the same time on different threads.

I created two separation session instances and assign each component to their own session so they do not interfere with one another. Then run the components on separate threads.

When I run the program every now and then it'll work fine without a problem, but that's a 50/50 chance. The other times I get an exception and the program is forced to exit. I get this

'An unhandled exception of type 'System.AccessViolationException' occurred in libpxcclr.cs.dll.

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

and it's traced back to " PXCMSenseManager pipeman = mainForm.Session.CreateSenseManager(); and pipeman.Init()"

which is within my face tracking pipeline.

How do I fix this?

 

Thank you guys!

0 Kudos
4 Replies
Xusheng_L_Intel
Employee
756 Views

How did you dispose the sensemanager? As a good practice, always release PXCSenseManager/Session at the end. Please post your dispose code so I can help you further. Thanks!

0 Kudos
Wezley_S_
New Contributor I
756 Views

Hi David,

At the end of the while loop containing the pipeline logic I have this

 

"                  moduleConfiguration.Dispose();
                    pipeman.Close();
                    pipeman.Dispose();

"

 

so it is disposing of the sensemanager at the end of the pipeline.

 

0 Kudos
Xusheng_L_Intel
Employee
756 Views

Since your two threads shared the same camera. It will have problem when you created two session and did not sync them. For example, the first thread has dispose the senseManager and the camera will turn off but the second thread still want to read data from the camera. This will cause such error. Thanks!

0 Kudos
Wezley_S_
New Contributor I
756 Views

Thank you David! This sheds much light on my problem!

How would I go about sync'ing the two threads with the camera though? I need to have face tracking and hand tracking/gestures in different classes and be able to access both of them independently from one another due to the nature of my project.

Would it be possible for me to use one sense manager within my program's main class, initialize and dispose of it there, and then have it applied to both classes and have face tracking and hand tracking work simultaneously at the same?

I ask this, because last year the PerCSDK had a problem with gesture tracking and voice input being on the same thread due to the algorithms used. I don't want to put forth the work of this possible solution and have it return with another headache.

Thank you for your help!

0 Kudos
Reply