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

**URL:** <https://forum.opencv.org/t/tracker-update-frame-bbox-compilation-failed-opencv-c/7616>\
**Category:** C++\
**Tags:** tracking\
**Created:** [February 17, 2022, 9:32am UTC](https://forum.opencv.org/t/tracker-update-frame-bbox-compilation-failed-opencv-c/7616 "2022-02-17T09:32:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![acjoker](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/acjoker/32/4540_2.png) [@acjoker](https://forum.opencv.org/u/acjoker)\
**Post date:** [February 17, 2022, 9:32am UTC](https://forum.opencv.org/t/tracker-update-frame-bbox-compilation-failed-opencv-c/7616/1 "2022-02-17T09:32:04Z")

</div>

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.

 ![2022-02-17_15-42](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/3/34419bb78e7c229f692d583a5445305e6e0a1e24.png)

And this is the compilation message

```auto
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

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [February 17, 2022, 12:57pm UTC](https://forum.opencv.org/t/tracker-update-frame-bbox-compilation-failed-opencv-c/7616/2 "2022-02-17T12:57:52Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 17, 2022, 1:42pm UTC](https://forum.opencv.org/t/tracker-update-frame-bbox-compilation-failed-opencv-c/7616/3 "2022-02-17T13:42:13Z")

</div>

related: [c++ - Non const lvalue references - Stack Overflow](https://stackoverflow.com/questions/18565167/non-const-lvalue-references)

[`Rect` seems to mean `Rect2i` (integer).](https://docs.opencv.org/4.x/dc/d84/group __core__ basic.html#ga11d95de507098e90bad732b9345402e8)

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**
