stereolabs / zed-yolo

3D Object detection using Yolo and the ZED in Python and C++
https://www.stereolabs.com/
MIT License
159 stars 68 forks source link

Error in sl/Camera.hpp #26

Closed JohnieBraaf closed 4 years ago

JohnieBraaf commented 4 years ago

I'm unable to compile darknet with ZED SDK 3.0.

It seems that GPU is already defined somewhere.

/usr/local/zed/include/sl/Camera.hpp: At global scope:

:0:5: error: expected identifier before numeric constant /usr/local/zed/include/sl/Camera.hpp:1952:9: note: in expansion of macro ?GPU? GPU /**< GPU Memory (Graphic card side).*/ This is the enum definition that fails: enum class MEM { CPU = 1, /**< CPU Memory (Processor side).*/ GPU = 2 /**< GPU Memory (Graphic card side).*/ };
adujardin commented 4 years ago

Darknet defines a GPU macro globally. By default since this is a macro, it replaces this enum value also. An undef was added here to try to limit this issue.

It seems it may not be enough sometimes, some users have reported this. As a workaround, you could add this #undef GPU directly into Camera.hpp for now (before the MEM enum).

We'll probably add this to the SDK if there are no side effects.

JohnieBraaf commented 4 years ago

Thnx for pointing me in the right direction. There were a couple of other small bits that needed adjustment. See below.

darknet/src/yolo_console_dll.cpp:99 MAT and MEM enums are changed MEASURE enum changed

Line 335: I think this needs some work as well, I have changed enums, but needed to comment out a couple of lines to get it to build.

#ifdef ZED_STEREO
                sl::InitParameters init_params;
                init_params.depth_minimum_distance = 0.5;
                init_params.depth_mode = sl::DEPTH_MODE::ULTRA;
                init_params.camera_resolution = sl::RESOLUTION::HD720;// sl::RESOLUTION_HD1080, sl::RESOLUTION_HD720
                init_params.coordinate_units = sl::UNIT::METER;
                //init_params.sdk_cuda_ctx = (CUcontext)detector.get_cuda_context();
                init_params.sdk_gpu_id = detector.cur_gpu_id;
                //init_params.camera_buffer_count_linux = 2;
                //if (file_ext == "svo") init_params.svo_input_filename.set(filename.c_str());**
                if (filename == "zed_camera" || file_ext == "svo") {
                    std::cout << "ZED 3D Camera " << zed.open(init_params) << std::endl;
                    if (!zed.isOpened()) {
                        std::cout << " Error: ZED Camera should be connected to USB 3.0. And ZED_SDK should be installed. \n";
                        getchar();
                        return 0;
                    }
                    cur_frame = zed_capture_rgb(zed);
                    use_zed_camera = true;
                }
#endif  // ZED_STEREO

Line 410: added ERROR_CODE::

if (use_zed_camera) {
                            while (zed.grab() != **sl::ERROR_CODE::SUCCESS**) std::this_thread::sleep_for(std::chrono::milliseconds(2));
                            detection_data.cap_frame = zed_capture_rgb(zed);
                            detection_data.zed_cloud = zed_capture_3d(zed);
                        }

I'm now able to build darknet, but still not able to run with command (might be an issue with my OpenCV though: LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH ./uselib data/coco.names cfg/yolov3.cfg yolov3.weights zed_camera

Output: input image or video filename: [ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (711) open OpenCV | GStreamer warning: Error opening bin: no element "zed_camera"

Does this issue need to be opened in the darknet repositiory?

I will have a go with the python example to see if I can get that working. (works with libdarknet)

adujardin commented 4 years ago

You should pull the latest master, this PR was merged recently and includes the SDK 3.0 compatibility fixes.

JohnieBraaf commented 4 years ago

Thnx, that fixed the build issues.

It is still needed to apply #undef GPU though.