opencv中的图像坐标

下图把Mat.at(x,y) , Point(x,y) ,Rect(x,y,w,h) 的坐标用程序生成的图像来表示;后面附有程序


int main()
{

Mat img = imread("D:\\image\\q2.jpg");

cv::putText(img,"the line is img.at<Vec3b>(100, : ) = Vec3b(255,255,255)",Point(0,80),1,0.8,Scalar(255,255,0));


for(int j=0;j<img.cols;j++){

string str;

stringstream ss;

if( j%100 == 0){

ss<<j;

ss>>str;

cv::putText(img,"Point("+str+",100)",Point(j,100),1,0.8,Scalar(0,255,0));

}

img.at<Vec3b>(100,j)=Vec3b(255,255,255);

}

cv::rectangle(img,Rect(0,50,300,150),Scalar(2,0,0));

cv::putText(img,"Rect(0,50,300,150)",Point(300,200),1,0.8,Scalar(5,5,0));


for(int i=-5;i<5;++i)

for(int j=-5;j<5;++j)

img.at<Vec3b>(Point(20+i,300+j))=255;

putText(img,"Point(20,300)",Point(20,300),1,1,Scalar(0,0,0));


imshow("ori",img);

waitKey(0);

return 0;

}


猜你喜欢

转载自blog.csdn.net/u010795146/article/details/24530467