Tracker-->update(frame,bbox) compilation failed : OPENCV C++

Hi
I’m trying to learn tracker using C++.
I have created code as shown in picture but the compilation showed failed in tracker->update(frame,bbox). I’m not sure what I’ve done wrong. I’m trying to find similar topic in this forum but found nothing. Please help.

And this is the compilation message

g++ $(pkg-config opencv4 --cflags --libs) -o g++ $(pkg-config raspicam --cflags --libs) -o TestTracking TestTracking.cpp (in directory: /home/pi/Desktop/OpenCV_Work)
TestTracking.cpp: In function ‘int main()’:
TestTracking.cpp:23:35: error: cannot bind non-const lvalue reference of type ‘cv::Rect&’ {aka ‘cv::Rect_<int>&’} to an rvalue of type ‘cv::Rect_<int>’
   bool ok = tracker->update(frame,trackingBox);
                                   ^~~~~~~~~~~
In file included from /usr/local/include/opencv4/opencv2/core.hpp:57,
                 from /usr/local/include/opencv4/opencv2/opencv.hpp:52,
                 from TestTracking.cpp:1:
/usr/local/include/opencv4/opencv2/core/types.hpp:1848:1: note:   after user-defined conversion: ‘cv::Rect_<_Tp>::operator cv::Rect_<_Tp2>() const [with _Tp2 = int; _Tp = double]’
 Rect_<_Tp>::operator Rect_<_Tp2>() const
 ^~~~~~~~~~
In file included from /usr/local/include/opencv4/opencv2/video.hpp:56,
                 from /usr/local/include/opencv4/opencv2/opencv.hpp:89,
                 from TestTracking.cpp:1:
/usr/local/include/opencv4/opencv2/video/tracking.hpp:737:10: note:   initializing argument 2 of ‘virtual bool cv::Tracker::update(cv::InputArray, cv::Rect&)’
     bool update(InputArray image, CV_OUT Rect& boundingBox) = 0;
          ^~~~~~
Compilation failed.

I’m using opencv 4.5.5 in raspberry pi with C++

Thank you very much
Best regard
acjoker

i general, please spare us images of code or error messages, please replace it with a TEXT version, so ppl can try your code, it can be archived for search, etc.

the, while there is a conversion between Rect2d and a const Rect& there’s no such thing for the non const version.

maybe the most simple fix for you is to use:

Rect trackingBox = selectROI(frame, false); // NOT Rect2d

related: c++ - Non const lvalue references - Stack Overflow

Rect seems to mean Rect2i (integer).

the error says that C++ refuses the type conversion that would be required to adapt your Rect2d (doubles) to the tracker API’s Rect_<int>

I just had to look that up too because C++, and compiler messages, can be just WTF sometimes. this one certainly is not succinct. the first line is mostly meaningless and the useful info is hidden at the end of some note