zoukankan      html  css  js  c++  java
  • opencv图像切割

    #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
    ", filename);
                return -1;
            }
        
            //非必要i
         mageHeight
    = src_img.rows; imageWidth = src_img.cols; printf("imageHeight = %d,imageWidth = %d ", 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; }
  • 相关阅读:
    五子棋项目
    判断是否是素数
    双链表
    九九乘法表
    栈和队列
    c排序
    蓝桥杯 接水问题 模拟
    蓝桥杯 调和数列问题
    蓝桥杯 Hanoi问题 递归
    蓝桥杯 排列问题
  • 原文地址:https://www.cnblogs.com/shaogang/p/6261753.html
Copyright © 2011-2022 走看看