stereolabs / zed-csharp-api

C# API for the ZED SDK
MIT License
10 stars 3 forks source link

Objects detection sample - Error CLR "ContextSwitchDeadlock" #2

Closed LudoTexx closed 4 years ago

LudoTexx commented 4 years ago

Hello, can we found somewhere a code sample for ObjectDetection in C# with box drawing please?

what i have actually :

` err = zedCamera3D.RetrieveObjectsDetectionData(ref objDetectRun, ref obje);

                    if ((err == ERROR_CODE.SUCCESS) && obje.numObject != 0)
                    {
                        Console.WriteLine(obje.numObject);

                        foreach(ObjectDataSDK ob in obje.objectData)
                        {
                            if(ob.obj_type == OBJECT_CLASS.PERSON)
                                Console.WriteLine(" PEOPLE : "+ob.id);
                            else if (ob.obj_type == OBJECT_CLASS.VEHICLE)
                                Console.WriteLine(" VEH : " + ob.id);

                          /*  foreach (Vector2 vectmp in ob.imageBoundingBox)
                            {
                                Console.WriteLine(vectmp.X);
                                Console.WriteLine(vectmp.Y);
                            }*/
                        }
                    }`

Thank you.

obraun-sl commented 4 years ago

Hi. It is planned to provide a C# sample for object detection but not ready yet. In the meantime, the Unity repository might help (https://github.com/stereolabs/zed-unity) You can also look at the OpenCV .NET wrapper that will allow you to use OpenCV in C#

LudoTexx commented 4 years ago

Hello,

From the last upadte, the streaming of ZED camera work nice and seems to be stable.

Sending from jetson - receiving on windows WPF.

But when i try to use object detection i got this error :

Assistance Manager 'ContextSwitchDeadlock' and a long french sentence about CLR.

This error come just after or during that : [ZED][Object Detection] Please wait while the AI model is being optimized for your graphics card

Did i do something wrong?

EDIT:

Well, i have restart the program some time later, do not change anything, and its works now..... any explicaton? IS fully stable en C#? Some time my stream crash after some seconds : CAMERA_NOT_INITIALIZED, and sometimes works for 12/14 hours (our need, manually stop)

LudoTexx commented 4 years ago

Any idea about this : CAMERA_NOT_INITIALIZED in the middle of runtime? Never got this error in c++, onyl in C#. Do you want to see some code maybe? Or you have an idea about that?

Thank you.

PS: Detection and drawing rectangle on mouving detected object work like charm.

obraun-sl commented 4 years ago

That error when using streaming input usually comes from a timeout on the receiving side (no packet received since a specific time). We will check the timeout, maybe it's too short depending on network. Anyway, I will try to reproduce that.

Did you draw the rectangle with WPF or OpenCV.NET ?

LudoTexx commented 4 years ago

Thank you,

its weird, because i have directly plug the jetson nano and my computer with brand new RJ45 cable, static IPV4 manually set, because i suspected a network problem.

Can i manually change the timeout delay? i will try with another brand new RJ45 cable.

For the rectangle i use a transparent "Canva" on top of my "Image" and draw 4 lines with object detected position.

My error CAMERA_NOT_INITIALIZED was here before i integrate the detection function, btw.

LudoTexx commented 4 years ago

Here a preview of the first test for multi objects detection with classic WPF canva.

https://www.youtube.com/watch?v=MDWfLz5A1DY