Ask Your Question
0

entered numbers are overlapping

asked 2015-10-10 04:17:48 -0600

Berkay gravatar image
  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;
>         }
edit retag flag offensive close merge delete

Comments

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 at Point(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?

LorenaGdL gravatar imageLorenaGdL ( 2015-10-10 04:33:52 -0600 )edit

thank you...

Berkay gravatar imageBerkay ( 2015-10-10 04:59:39 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-10-10 04:37:20 -0600

LorenaGdL gravatar image

updated 2015-10-10 04:39:44 -0600

I'm guessing you're trying to get this:

for (int i=0; i < 4; i++){         
  for(int j=0; j < 3; j++){
    k++;
    Mat temp_small_image = small_image.clone();
    putText(temp_small_image, print_name(k), Point(45, 180), 
   FONT_HERSHEY_SCRIPT_SIMPLEX, 1, Scalar::all(255), 1,CV_AA);
    temp_small_image.copyTo(im_out(Rect(i*200,j*200,
   small_image.cols,small_image.rows)));
  }
}
edit flag offensive delete link more

Comments

@Berkay: Please, mark it as solved it if helped. Thanks.

LorenaGdL gravatar imageLorenaGdL ( 2015-10-10 06:21:19 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-10-10 04:17:48 -0600

Seen: 765 times

Last updated: Oct 10 '15