• DepthAI
  • Win10 C++ demo ucrtbase.dll exceptions!


I have build the examples projects depth_preview in depthai-core/examples and generate VS2017 projects files by CMAKE(v3.21 windows) and the setting is for BUILD_ALL:

But I found many demo programs will break and mostly tracked to console I/O, as the first picture it breaked at console I/O.
INT 29 =>console I/O for DOS
And these exceptions usually appeared after one hour and are not easily found in minutes. I have tried open some python projects and have not found similar break in python programs.
It seems only windows C++ program will have these kind of I/O exceptions.
The openCV I am using is 4.0, and I think it's
cv::waitKey(1);
that let to this exception!
Does anyone have same problems? Or suggestions?

@frankshieh what does the exception message say?
You can try catching the exception using a try/catch statement and printing the what() message. Windows doesn't usually print these out nicely.

You may also try building the example as Debug to get a more informative stack trace.

    themarpe Hi as you see in assembly , the exception happened at INT29. That's DOS Fast Character I/O (https://stanislavs.org/helppc/int_29.html) that from cv::waitKey(1);
    So the exception came from here, I have tried to comment cv::waitKey(1), but the nothing displayed. It seems Opencv need cv::waitKey to do display. The Luxonis recommend using CV4. I am not sure if using CV3 will be better?
    For my application I do not need to check console I/O nor display the image, I will comment out them and go on.

      frankshieh Correct, waitKey is afaik the only way of updating the GUI loop in current OpenCV4 version.
      OpenCV4 is supported, but not required. One can omit opencv support and use almost all functionality without it (exception being helper functions in ImgFrame)

      Still wondering why the exception was raised and what it represents... Did you compile this example as part of project using -D DEPTHAI_BUILD_EXAMPLES=ON? And does same happen if you run the example outside of VS debug? (standalone)

        themarpe I am using VS projects build by windows CMAKE. I am using Anaconda power shell in Win10. And it seems depthai does not install cmake in command line. So I use CMMAKE GUI to generate and DEPTHAI_BUILD_EXAMPLES is checked:

        Both release mode and debug mode will break! And as I tried, mono images with 720p and more CV display streams will break more easily such as stereo_depth_video.exe

          frankshieh If you can compile in Debug configuration and try capturing the exception again, you can upload the dump file somewhere and send me the link - I'll give it a try and analyze to see why it came to this state.

          Check the following documentation for VS: https://docs.microsoft.com/en-us/visualstudio/debugger/using-dump-files?view=vs-2019#BKMK_Create_a_dump_file

          Also include the needed files (OpenCV dll, pdb & exe for the application you are debugging) as per: https://docs.microsoft.com/en-us/visualstudio/debugger/using-dump-files?view=vs-2019#BKMK_Find_binariessymbol_pdbfilesand_source_files

            frankshieh
            According to my checks, atleast the stereo_depth_video raises a "Communication Exception" which usually indicates FW (device side) crash/brownout (either a bug or power consumption issue)

            I suggest that you power your device (I presume OAK-D) with the provided 5V power supply along the USB connection as inadequate power supply capabilities by USB only is usually the cause for this exception to be raised.

            (More interpretation of the issue ahead)
            As for the exception and interpretation of it, I highly suspect that above screenshots don't point to IO exception as I've suggested before, but this is only where the programs execution was at the moment when an exception was raised (and was left unhandled, which made the program crash), which makes sense as a lot of time is spent waiting in that cv::waitKey function compared to the rest of the loop.

            To verify this, do modify an example and add a try/catch statement around the main loop which catches and prints the raised exception:

            try {
                ... // main example loop
            catch (const std::runtime_error& ex){
                std::cout << ex.what()
            }

              themarpe OK, I am not sure I used adaptor or not. But when I used adaptor and test:
              python3 depthai_demo.py -s left right -monor 400 -monof 110 -dnn -dd --xlink_chunk_size 0
              and it breaks after one night. I saved the python3.9.dmp at the same onedrive.
              I am comparing using C++ or Python which will be more stable. As all my privios tests before,
              python3 depthai_demo.py -s left right -monor 400 -monof 110 -dnn -dd
              had never broke. I will try this first then add your try/catch for C++ codes. Will post when I have results, and you can check the python dump file first.
              We are using OAD-D in products and have to be sure it's stable.

              Hi, I have tried :
              python3 depthai_demo.py -s left right -monor 400 -monof 110 -dnn -dd --xlink_chunk_size 0(dapthai 2.10.0) and
              python3 depthai_demo.py -s left right -monor 400 -monof 110 -dnn -dd (depthai 2.9.0) both on two PCs and with an adaptor. Both will break, some showed:
              Traceback (most recent call last):
              File "C:\Users\frank\depthai\depthai_demo.py", line 232, in <module>
              pv.prepare_frames(callback=callbacks.on_new_frame)
              File "C:\Users\frank\depthai\depthai_helpers\managers.py", line 261, in prepare_frames
              packet = queue.tryGet()
              RuntimeError: Communication exception - possible device error/misconfiguration. Original message 'Couldn't read data from stream: 'left' (X_LINK_ERROR)'
              and some showed Python3.9.exe's error and I have two dump files for you to check.
              It seems OAK-D's tested on PC WIN10 is less stable then Linux? Both C++ and pythons programs seems can not run for days using OAK-D. And even as I turn off depth ann AI, OAK-D consumes almost twice as much power as our VR camera. And when I tested with a laptop the CPU's frequence has to be fluctuated to save power.

                I have testes using our provious VR cam and OAK-D, attached them to same USB 3.0 hub and power OAK-D adaptor. I just catch both cameras with live video and display for hours. My previos VR does not break but OAK_D broke both with 2.9.0 and 2.10.0. Here are catched images:

                You can see I can get 200 fps and the CPU loading is not fluctuated.
                And for OAK-D:

                It seems to consume much more power as I expected with -dd -dnn and the CPU's clock is flactuated. I think there are still many parts inside nodes are not turn down even with -dd -dnn. But this flactuation only happens on NB so is not a problem.
                But OAK-D can not run for days is a big problem for me under win10 PC for both C++ and python evironments.

                frankshieh
                I don't see the python3.9.dmp in the onedrive folder - can you recheck?

                How does Linux stability compare to Windows?

                We are working hard to make sure our platform is stable across all platforms. I'll dive deeper into this issue.

                I understand you require stability in your case - I'd still suggest properly doing exception handling to cover for any exceptional events. On that note, you may also automatically recover if an Communication Exception is raised, by reconnecting to the device and continuing the execution of the pipeline. This of course depends on you use case if couple of seconds (3-4s) of downtime are permitted.

                Regarding power consumption, this is an area we haven't strongly optimized for yet. We do aim of reducing this after we have the base feature set covered.

                  themarpe The ondrive have synced these dump files now. I have tesed mono_preview with try/catch to get the 118 fps of left right videos and it worked over night.
                  I am not sure is the fps set to 120 and 118 will do any difference. Many tests I have done that break out using 120 fps which I know now it's beyond maximun 118 fps.
                  And I am developing on Win10 using c++ API, if I got many exeptions I will post them to let you know.