zoukankan      html  css  js  c++  java
  • opencv图片右转函数

    因为需要将函数进行右转,发现opencv自带 的过于麻烦。自己写了个右转的。可以根据这个想法写出任何方向的

     1 //函数功能,右转图片
     2 IplImage* convertImage(IplImage* image)
     3 {
     4     CvSize size = cvGetSize(image);
     5     IplImage* ori_image = cvCreateImage(cvSize(size.width / 2, size.height / 2), image->depth, image->nChannels);
     6     IplImage* cvt_image = cvCreateImage(cvSize(size.height / 2, size.width / 2), image->depth, image->nChannels);
     7     cvResize(image, ori_image);
     8     int x, y, w;
     9     for (y = ori_image->height; y >= 0; y--)
    10     {
    11         uchar* oriptr = (uchar*)(ori_image->imageData + y*ori_image->widthStep);
    12         for (x = 0; x < ori_image->width; x++)
    13         {
    14             uchar* curptr = (uchar*)(cvt_image->imageData + x*cvt_image->widthStep);
    15             curptr[3 * y] = oriptr[3 * x];
    16             curptr[3 * y + 1] = oriptr[3 * x + 1];
    17             curptr[3 * y + 2] = oriptr[3 * x + 2];
    18         }
    19     }
    20     cvReleaseImage(&image);
    21     cvReleaseImage(&ori_image);
    22     return cvt_image;
    23 }
  • 相关阅读:
    influxdb 使用
    【刷题】如何查找最长链
    学习中的开源框架和系统
    常见错误总结
    开发者必备网站
    计算机基础知识以及常用业务场景
    (1)、hive框架搭建和架构简介
    hadoop安装和配置
    linux基础
    UML学习目录
  • 原文地址:https://www.cnblogs.com/sytu/p/4472718.html
Copyright © 2011-2022 走看看