Ask Your Question
0

real_time_pose_estimation VS-c++ compiling issues

asked 2019-11-01 22:19:44 -0600

fabianc20 gravatar image

Dear Opencv'rs

I have been able to compile and execute every sample I have touched from the opencv 4.1.1 samples folder, including camera_calibration.

Now, with real_time_pose_etimation I have been facing a sturbon compiling issue -unsuccesfully troubleshooted it for days- so I must kindly ask for your help.

Opencv 4.1.1 Windows 10 Pro, have tried building both x86 and x64 VS 2019, ver 16.3.5 Code: C:\opencv\sources\samples\cpp\tutorial_code\calib3d\real_time_pose_estimation\src

What I usually do -not a cmaker user- is I CTRL+V into a new project source file the main cpp content and copy all the reamining .cpp and .h files to the include/opencv2.

In the case of real_time_pose_estimation I brought a copy of main_detection.cpp as my project main source. Everything else I've dumped into my local "..include/opencv2". I have copied the data folder to my project forlder. This is the way you -I succesfully have- build opencv modules (apps) in VS-c++.

All my include lines seem to be okay, as well as the access to files (as per the path environment var and project configurations require).

When I try to compile, I am getting 36 warnings -27 errors- most of which refer to type operator overflowing after regular math operations. There are many cpp libraries throwing the warnings, but just one line -which I believe and hoped- from the main_detection.cpp line 351 (in my VS editor)

int startX = (int)((widthSave - frame_vis.cols) / 2.0);

The warning(s) I am getting

Warning C26451 Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2)

I have looked for it in all available forums, which led me to try "Casting" in varies ways (one by one, and all possible combinations) the 3 operands in that line to make sure they are 8 byte values. I can not get out of this hole!.. sometimes I can bypass this line, particularly when I used

int startX = (int)(( intptr_t(widthSave) - intptr_t(frame_vis.cols)) / intptr_t(2.0));

then I get 'just' 35 Warnings, meaning the other .cpp libraries 'involved', keep comming back with the same

Warning C26451: Arithmetic overflow...

Thanks for your feedback

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-11-02 01:44:14 -0600

mvuori gravatar image

This is what compilers do nowadays to warn about _possible_problems. If the code works and the values do not really overflow (note that the compuler does not kniw about that), you can add casts (to int, not intptr_t as it is a pointer type) or just suppress the warnings with #pragma warning(disable: 26451) at the top of the file or by some setting in the IDE.

edit flag offensive delete link more

Comments

Dear mvuori, Thanks I had already tried that but with the scope of the main source. So I did this -for the whole project.

https://docs.microsoft.com/en-us/visu...

for this warning (error) codes: 26451;26812;26495;6294;6201;26439;26812

So not more warnings when building the again. But the door came into my face with 27 error messages, All of them in line 1 of the main.obj file... All of them "Linker Tools Error LNK2019" detailing varies unresolved external symbols...

So I will focus now in resolving that.

For the time being I am accepting and thaking you for your answer.

fabianc20 gravatar imagefabianc20 ( 2019-11-02 18:18:18 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-11-01 22:19:44 -0600

Seen: 346 times

Last updated: Nov 02 '19