首页 > 其他 > 详细

opencv图像切割

时间:2017-01-08 12:41:40      阅读:192      评论:0      收藏:0      [点我收藏+]
#include "opencv2/core/core.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"

#include <iostream>

using namespace std;
using namespace cv;

int main(int argc, char** argv)
{
    Mat src_img, left_img, right_img;
    int frame_id = 0;
    int framenumber = 100;

    int imageHeight;
    int imageWidth;

    while (frame_id < framenumber)
    {
        char filename[100], left_name[100], right_name[100];
        sprintf_s(filename, "E:/stereo_data/ZED/0105/zed-cali_1080/%02d.png", frame_id + 1);  //获取文件名
        cout << "filename is:" << filename << endl;

        src_img = imread(filename);
        if (src_img.empty())
        {
            fprintf(stderr, "Can not load image %s\n", filename);
            return -1;
        }
    
        //非必要i
     mageHeight
= src_img.rows; imageWidth = src_img.cols; printf("imageHeight = %d,imageWidth = %d \n", imageHeight,imageWidth); imshow("src_img", src_img); left_img = src_img(Range(0, 1080), Range(0, 1920)); //Range的两个参数范围为左包含,右不包含,0到1079行、0到1919列的矩形区域 right_img = src_img(Range(0, 1080), Range(1920, 3840)); imshow("left_img", left_img); imshow("right_img", right_img); //sprintf_s(left_name, "left_%02d.png", frame_id); //sprintf_s(right_name, "right_%02d.png", frame_id); imwrite(cv::format("left_name_%02d.png", frame_id), left_img); imwrite(cv::format("right_name_%02d.png", frame_id), right_img); frame_id++; } return 0; }

 

opencv图像切割

原文:http://www.cnblogs.com/shaogang/p/6261753.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!