国产探花免费观看_亚洲丰满少妇自慰呻吟_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`;

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

圖片精選

主站蜘蛛池模板: 井研县| 溧阳市| 景泰县| 息烽县| 光山县| 宜兴市| 涿州市| 西乡县| 弋阳县| 澎湖县| 滦平县| 裕民县| 齐齐哈尔市| 民乐县| 明光市| 武威市| 乐昌市| 厦门市| 乌拉特中旗| 会东县| 舞阳县| 沙河市| 体育| 新源县| 武功县| 长丰县| 镇康县| 葵青区| 库伦旗| 通海县| 竹北市| 疏勒县| 玛纳斯县| 白水县| 广南县| 朝阳市| 佛坪县| 洱源县| 平遥县| 长海县| 鹤壁市|