reference to `int64` is ambiguous error with Dlib and OpenCV

asked 2019-12-05 22:59:24 -0600

ronces gravatar image

updated 2019-12-09 07:58:41 -0600

Akhil Patel gravatar image

Hello, im using OpenCV 4.1.1 and dlib 19.17 on a recognition project with Qt Creator IDE, when compiling the project using Qmake, i got an error like this :

`In file included from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/dlib/opencv/cv_image.h:7:0, from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/recognition/ocr.h:23, from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/detection/detection.h:15, from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/detection/detection.cpp:19: /usr/local/include/opencv4/opencv2/core/core_c.h:2582:1: error: reference to ‘int64’ is ambiguous

CVAPI(int64) cvGetTickCount( void );

^

In file included from /usr/local/include/opencv4/opencv2/core/cvdef.h:165:0, from /usr/local/include/opencv4/opencv2/core.hpp:52, from /usr/local/include/opencv4/opencv2/opencv.hpp:52, from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/detection/detection.cpp:8:

/usr/local/include/opencv4/opencv2/core/hal/interface.h:61:20: note: candidates are: typedef int64_t int64 typedef int64_t int64; ^~~~~

In file included from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/dlib/cuda/../matrix/../algs.h:115:0, from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/dlib/cuda/../matrix/matrix_exp.h:6, from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/dlib/cuda/../matrix/matrix.h:6, from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/dlib/cuda/../matrix.h:6, from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/dlib/cuda/tensor.h:8, from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/dlib/dnn.h:12, from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/recognition/ocr.h:17, from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/detection/detection.h:15, from ../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/detection/detection.cpp:19:

../QTPROJECTSBACKUP/LPR+MVC_FINAL/LPR_TEST2/include/dlib/cuda/../matrix/../uintn.h:27:23: note: typedef long long int dlib::int64 typedef long long int64; ^~~~~`

I am calling the getTickCount that have int64 type, and dlib is also using that int64 type in 'uintn.h' header file. Here's a piece of code that use the getTickCount function:

void FrameSource::plates_processing(){
for (int p = 0; p < pt.plates_data.size(); p++)
{
    int id = pt.plates_data[p].id;   // Plate Id in frame
    //cout << "id: " << id << "    added plate: " << plates_data[id].added_plate << "  new_thread: " << plates_data[id].new_thread << endl;

    plates_data[id].lastTime = getTickCount() / getTickFrequency();
    plates_data[id].plate_type = pt.plates_data[p].plate;

    if (plates_data[id].added_plate)
        continue;

    //another code
}

}

The getTickCount function are defined in core_c.h

CVAPI(int64) cvGetTickCount;

This definition refers to interface.h file

typedef int64_t int64

Which conflicting with Dlib 19.17(compiled with CUDA support) in uintn.h

typedef long long int dlib:: int64

Is there any solution to fix this?

edit retag flag offensive close merge delete

Comments

1

which compiler, exactly ? dlib version ?

opencv's 1.0 C-api is no more maintained. you must not use it drectly.

I am calling the GetTickCount

show code, please. (edit your question)

also: https://github.com/opencv/opencv/issu...

berak gravatar imageberak ( 2019-12-06 01:59:55 -0600 )edit

Thanks for the reply berak,

i'm using gcc 7 in qt. I've updated the question. So, is there any alternatives regarding the getTickCount?

ronces gravatar imageronces ( 2019-12-06 03:20:33 -0600 )edit

use cv::getTickCount() (from the c++ api, and do NEVER include core_c.h (or any other deprecated xxx_c.h)

it might also be a problem with include order of headers. try moving the dlib headers clearly before or after the opencv ones

berak gravatar imageberak ( 2019-12-06 03:26:23 -0600 )edit

i've tried reodering the headers, and use cv:: prefix, but its no avail :( ill try to reinstall dlib and darknet with OPENCV 4.1.1 and see what happens :) cheers for your help berak.

ronces gravatar imageronces ( 2019-12-06 05:06:02 -0600 )edit