opencv入手小训——画立体图形
项目要求
用opencv程在空图上(背景为0)上画出立方体并把一张图片分别紧贴。
项目代码
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/videoio.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
//Creating a new image Ret
Mat src(400, 400, CV_8UC3);
src.setTo(0);
//drawing a 3D cubic box
Point A(150, 300);
Point B(250, 300);
Point C(250, 200);
Point D(150, 200);
Point E(200, 150);
Point F(300, 150);
Point G(300, 250);
line(src, A, B, Scalar(155, 0, 0), 3, 0);
line(src, B, C, Scalar(155, 0, 0), 3, 0);
line(src, C, D, Scalar(155, 0, 0), 3, 0);
line(src, A, D, Scalar(155, 0, 0), 3, 0);
line(src, E, D, Scalar(155, 0, 0), 3, 0);
line(src, E, F, Scalar(155, 0, 0), 3, 0);
line(src, C, F, Scalar(155, 0, 0), 3, 0);
line(src, F, G, Scalar(