why does numbers of image titles overlap each other?
#include "stdafx.h"
> #include <opencv2/highgui/highgui.hpp>
> #include <opencv2/opencv.hpp>
> #include <iostream>
> #include <string>
>
> using namespace std;
> using namespace cv;
>
> string print_name(int x){
>
> char buffer[15];
> sprintf_s(buffer,"Resim %d",x);
> return buffer;
> }
>
> int main( int argc, char** argv ){
>
> int k=0;
>
> Mat small_image = imread("pluto.jpg");
>
> Mat im_out = Mat::zeros(600, 800, CV_8UC3);
>
> for (int i=0; i < 4; i++){
>
> for(int j=0; j < 3; j++){
> k++;
> putText(small_image, print_name(k), Point(45, 180),
> FONT_HERSHEY_SCRIPT_SIMPLEX, 1,
> Scalar::all(255), 1,CV_AA);
> small_image.copyTo(im_out(Rect(i*200,j*200,small_image.cols,
> small_image.rows)));
> }
> }
>
> imshow("window", im_out);
> waitKey(0);
> return 0;
> }
Because you're printing your text in the same position always. You call the
putText
function several times within the loops, but the text is always placed atPoint(45, 180)
, so it overlaps from call to call (in fact not just the numbers but all the string, though as the text is always the same you don't notice it). What are you trying to achieve?thank you...