国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C > 正文

實現opencv圖像裁剪分屏顯示示例

2020-01-26 15:32:47
字體:
來源:轉載
供稿:網友

使用OPENCV圖像處理庫,將圖片裁剪分屏顯示

復制代碼 代碼如下:

//#include "stdafx.h"
#include <opencv2/opencv.hpp>

//#include <opencv2/imgproc/imgproc.hpp>
//#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <vector>
using namespace std;
using namespace cv;


//剪切圖片為m * n 塊
void Cut_img(Mat src_img,int m,int n,Vector<Mat> ceil_img)
{

 int t = m * n;
 int height = src_img.rows;
 int width  = src_img.cols;

 int ceil_height = height/m;
 int ceil_width  = width/n;

 Mat roi_img,tmp_img;

 Point p1,p2;
 for(int i = 0;i<m;i++)
  for(int j = 0;j<n;j++){
   //p1 =
   Rect rect(i+j*ceil_width,j+i*ceil_height,ceil_width,ceil_height);

   src_img(rect).copyTo(roi_img);

   ceil_img.push_back(roi_img);
   imshow("roi_img",roi_img);
   //rectangle(i+j*ceil_width,j+i*ceil_height,);
  } 
 waitKey(0);
}

void show_images(Vector<Mat> imgs,int n){

     //do something
}

int main()
{
 Mat img = imread("airplane.jpg",1);
 imshow("src img",img);
 int m = 3;
 int n = 3;
 Vector<Mat> ceil_img = m*n;

 Cut_img(img,m,n,ceil_img);

 waitKey();
 return 0;
}

編譯命令: g++ -ggdb `pkg-config --cflags opencv` -o ImageTake ImageTake.cpp `pkg-config --libs opencv`;

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 库伦旗| 茶陵县| 亳州市| 白朗县| 谷城县| 连城县| 九龙坡区| 同德县| 大石桥市| 疏附县| 浙江省| 两当县| 平武县| 石柱| 繁昌县| 临高县| 南丹县| 东平县| 资阳市| 高雄市| 灌云县| 德州市| 宣化县| 栾城县| 资溪县| 龙川县| 湄潭县| 肇庆市| 漯河市| 兴国县| 精河县| 宁远县| 天长市| 蕲春县| 安徽省| 霍城县| 旬阳县| 定安县| 资源县| 尉犁县| 广灵县|