• 大小: 1.07MB
    文件类型: .gz
    金币: 1
    下载: 0 次
    发布日期: 2023-10-23
  • 语言: C/C++
  • 标签: opencv,C++  

资源简介

opencv视觉定位,C++编写的opencv视觉定位,C++编写的opencv视觉定位,C++编写的opencv视觉定位,C++编写的opencv视觉定位,C++编写的opencv视觉定位,C++编写的opencv视觉定位,C++编写的opencv视觉定位,C++编写的opencv视觉定位,C++编写的opencv视觉定位,C++编写的opencv视觉定位,C++编写的opencv视觉定位,C++编写的opencv视觉定位,C++编写的

资源截图

代码片段和文件信息

#include “sv_debayer.h“
#include “svgige.h“

#define CLIP(in out)\
   in = in < 0 ? 0 : in;\
   in = in > 255 ? 255 : in;\
   out=in;

void ClearBorders(unsigned char *rgb int sx int sy int w) {
   int i j;
   // black edges are added with a width w:
   i = 3 * sx * w - 1;
   j = 3 * sx * sy - 1;
   while (i >= 0) {
      rgb[i--] = 0;
      rgb[j--] = 0;
   }
   i = sx * (sy - 1) * 3 - 1 + w * 3;
   while (i > sx) {
      j = 6 * w;
      while (j > 0) {
         rgb[i--] = 0;
         j--;
      }
      i -= (sx - 2 * w) * 3;
   }
}

void simple(const unsigned char *bayer unsigned char *rgb int sx int sy int tile) {
    const int bayerStep = sx;
    const int rgbStep = 3 * sx;
    int width = sx;
    int height = sy;

    int blue = tile == GVSP_PIX_BAYBG8|| tile ==  GVSP_PIX_BAYGB8 || tile ==  GVSP_PIX_BAYBG12_PACKED || tile == GVSP_PIX_BAYGB12_PACKED ? -1 : 1;
    int start_with_green = tile == GVSP_PIX_BAYGB8 || tile ==GVSP_PIX_BAYGR8 || tile ==GVSP_PIX_BAYGB12_PACKED || tile ==GVSP_PIX_BAYGR12_PACKED;

    int i imax iinc;

    /* add black border */
    imax = sx * sy * 3;
    for (i = sx * (sy - 1) * 3; i < imax; i++) {
        rgb[i] = 0;
    }
    iinc = (sx - 1) * 3;
    for (i = (sx - 1) * 3; i < imax; i += iinc) {
        rgb[i++] = 0;
        rgb[i++] = 0;
        rgb[i++] = 0;
    }

    rgb += 1;
    width -= 1;
    height -= 1;

    for (; height--; bayer += bayerStep rgb += rgbStep) {
        const unsigned char *bayerEnd = bayer + width;

        if (start_with_green) {
            rgb[-blue] = bayer[1];
            rgb[0] = (bayer[0] + bayer[bayerStep + 1] + 1) >> 1;
            rgb[blue] = bayer[bayerStep];
            bayer++;
            rgb += 3;
        }

        if (blue > 0) {
            for (; bayer <= bayerEnd - 2; bayer += 2 rgb += 6) {
                rgb[-1] = bayer[0];
                rgb[0] = (bayer[1] + bayer[bayerStep] + 1) >> 1;
                rgb[1] = bayer[bayerStep + 1];

                rgb[2] = bayer[2];
                rgb[3] = (bayer[1] + bayer[bayerStep + 2] + 1) >> 1;
                rgb[4] = bayer[bayerStep + 1];
            }
        } else {
            for (; bayer <= bayerEnd - 2; bayer += 2 rgb += 6) {
                rgb[1] = bayer[0];
                rgb[0] = (bayer[1] + bayer[bayerStep] + 1) >> 1;
                rgb[-1] = bayer[bayerStep + 1];

                rgb[4] = bayer[2];
                rgb[3] = (bayer[1] + bayer[bayerStep + 2] + 1) >> 1;
                rgb[2] = bayer[bayerStep + 1];
            }
        }

        if (bayer < bayerEnd) {
            rgb[-blue] = bayer[0];
            rgb[0] = (bayer[1] + bayer[bayerStep] + 1) >> 1;
            rgb[blue] = bayer[bayerStep + 1];
            bayer++;
            rgb += 3;
        }

        bayer -= width;
        rgb -= width * 3;

        blue = -blue;
        start_with_green = !start_with_green;
    }
}

void HQLinear( unsigned char const * bayer unsigned char *rgb int sx int sy int tile) {
   const int bayer

评论

共有 条评论