Output correct in console but wrong in cvui::printf

Values 9, 5 , 10 fine to console. printf vals of the same are all zeros.:

            double detObj = 9;
			double other_x = 5, other_y = 10;
			std::cout << "Object nums:" << detObj << std::endl;
            std::cout << "Other nums:" << other_x << other_y << std::endl;
			cvui::printf(frame, 360, 460, "detObj : %d", objsDetected, .5);
            cvui::printf(frame, 360, 500, "other output : %d and %d", other_x, other_y, .5);


When I execute the program the console shows 9, 5, 10 as expected. But if I printf the same values, they all turn up 0. I’m sure this is something simple, nonetheless -

  1. don’t expect support for cvui here. it’s a third party library.
  2. you aren’t showing what data type objsDetected is
  3. the format strings don’t match the data types
1 Like

Sorry, no problem, thanks for your time anyway. I will try to avoid that in the future, for sure.

I changed the data type-> objsDetected to detObj (above)and still the same output, corrected.

  1. the format strings don’t match the data types

Please tell me what do you mean here exactly? Am I making an error in prinft with %d as double?

Thanks in advance.

yes. %d isn’t “double”, it’s practically integer (“decimal”). if you want floats/doubles, you need a different format code. I won’t tell you because you should have looked up printf to learn about printf-style format strings


(%d is for integer, for double you want %f)

Worked great, thank you.