应用介绍
机器人视觉模式识别项目.
#include <cv.h>
#include <highgui.h>
#pragma comment(lib,"cv.lib")
#pragma comment(lib,"cxcore.lib")
#pragma comment(lib,"highgui.lib")
#pragma comment(lib,"ml.lib")
#pragma comment(lib,"cvcam.lib")
int main (int argc, char **argv)
{
double angle = -45.0, scale = 1.0;
IplImage *src_img = 0, *dst_img = 0;
CvMat *map_matrix;
CvPoint2D32f center;
CvPoint pt1, pt2;
CvRect rect;
if (argc >= 2)
src_img = cvLoadImage (argv[1], CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR);
if (src_img == 0)
return -1;
rect.x = (int) (src_img->width * 0.25);
rect.y = (int) (src_img->height * 0.25);
rect.width = (int) (src_img->width * 0.5);
rect.height = (int) (src_img->height * 0.5);
cvSetImageROI (src_img, rect);
dst_img = cvCloneImage (src_img);
map_matrix = cvCreateMat (2, 3, CV_32FC1);
center = cvPoint2D32f (src_img->width * 0.25, src_img->height * 0.25);
cv2DRotationMatrix (center, angle, scale, map_matrix);
cvWarpAffine (src_img, dst_img, map_matrix, CV_INTER_LINEAR + CV_WARP_FILL_OUTLIERS, cvScalarAll (255));
cvResetImageROI (src_img);
cvResetImageROI (dst_img);
pt1 = cvPoint (rect.x, rect.y);
pt2 = cvPoint (rect.x + rect.width, rect.y + rect.height);
cvRectangle (src_img, pt1, pt2, CV_RGB (255, 0, 255), 2, 8, 0);
cvNamedWindow ("src", CV_WINDOW_AUTOSIZE);
cvNamedWindow ("dst", CV_WINDOW_AUTOSIZE);
cvShowImage ("src", src_img);
cvShowImage ("dst", dst_img);
cvWaitKey (0);
cvDestroyWindow ("src");
cvDestroyWindow ("dst");
cvReleaseImage (&src_img);
cvReleaseImage (&dst_img);
cvReleaseMat (&map_matrix);
return 1;
}
//end of rotate.cpp
想了解详情请下载附件。
©版权声明:本文内容由互联网用户自发贡献,版权归原创作者所有,本站不拥有所有权,也不承担相关法律责任。如果您发现本站中有涉嫌抄袭的内容,欢迎发送邮件至: [email protected] 进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。
转载请注明出处: apollocode » 机器人视觉模式识别
文件列表(部分)
名称 | 大小 | 修改日期 |
---|---|---|
binary.cpp | 0.54 KB | 2020-08-07 |
build.cpp | 0.33 KB | 2020-08-07 |
buildpyramid.cpp | 0.33 KB | 2020-08-07 |
CMakeLists.txt | 0.31 KB | 2015-01-12 |
color.cpp | 0.35 KB | 2020-08-07 |
gaussian.cpp | 0.33 KB | 2020-08-07 |
highgui_test.cpp | 0.33 KB | 2020-08-07 |
image_write.cpp | 0.35 KB | 2020-08-07 |
kmeans.c | 0.96 KB | 2020-08-07 |
line.cpp | 0.32 KB | 2020-08-07 |
mat.cpp | 0.24 KB | 2020-08-07 |
matrix.cpp | 0.49 KB | 2020-08-07 |
polylines.cpp | 0.44 KB | 2020-08-07 |
rect.cpp | 0.31 KB | 2020-08-07 |
svm.cpp | 1.05 KB | 2020-08-07 |
test_cam.cpp | 0.44 KB | 2015-01-12 |
transform.cpp | 0.28 KB | 2020-08-07 |
v.cpp | 3.26 KB | 2015-01-12 |
vertical.cpp | 0.33 KB | 2020-08-07 |
array.c | 1.49 KB | 2015-01-12 |
rotate.cpp | 0.68 KB | 2020-08-07 |
basic | 0.00 KB | 2020-08-07 |
opencv_lesson | 0.00 KB | 2015-01-12 |
opengl_lesson | 0.00 KB | 2015-01-12 |
VRRobots | 0.00 KB | 2020-08-07 |
发表评论 取消回复