什么叫网站策划书,wordpress个人版,东莞网络推广价格,a站全称用opencv绘制一个箭头#xff0c;沿着圆运动并留下运动轨迹#xff08;c#xff09;。基于该例程可以简单实现一个运动小车的模型。
using namespace cv;int main()
{// 创建一个黑色背景的图像#xff0c;大小为400*400Mat image(400, 400, CV_8UC3, Scalar(0, 0, 0));//…用opencv绘制一个箭头沿着圆运动并留下运动轨迹c。基于该例程可以简单实现一个运动小车的模型。
using namespace cv;int main()
{// 创建一个黑色背景的图像大小为400*400Mat image(400, 400, CV_8UC3, Scalar(0, 0, 0));//设置箭头的初始位置和方向Point2f arrow_center(200, 200); //箭头中心点double arrow_angle 0.0; //箭头角度弧度// 循环处理每帧图像while (true) {// 旋转箭头arrow_angle 0.1;if (arrow_angle 2 * CV_PI) {arrow_angle - 2 * CV_PI;}// 计算箭头的头和尾位置Point2f arrow_head(arrow_center.x 50 * cos(arrow_angle),arrow_center.y 50 * sin(arrow_angle));Point2f arrow_tail(arrow_center.x - 50 * cos(arrow_angle),arrow_center.y - 50 * sin(arrow_angle));// 绘制箭头arrowedLine(image, arrow_tail, arrow_head, Scalar(0, 0, 255), 3);// 将箭头中心向前移动10个像素arrow_center.x 10 * cos(arrow_angle);arrow_center.y 10 * sin(arrow_angle);// 如果箭头越过边界则将其移回中央if (arrow_center.x 0 || arrow_center.y 0 ||arrow_center.x image.rows || arrow_center.y image.cols) {arrow_center.x image.cols / 2;arrow_center.y image.rows / 2;}// 如果应该闪烁将箭头颜色改为绿色否则为红色// 显示图像imshow(Arrow, image);// 等待一会儿waitKey(100);//if ((int)(arrow_angle / CV_PI * 5) % 2 0) {arrowedLine(image, arrow_tail, arrow_head, Scalar(0, 255, 0), 3);//}imshow(Arrow, image);}return 0;
}