codec engine 移植 opencv emcv 记录 cv相关文件

时间:2022-01-10 16:37:04

1.在int 中加括号

CV_INLINE  int  cvRound( double value )
{
    return  (int)(floor(value+0.5));
}


CV_INLINE  int  cvFloor( double value )
{
    return (int)(floor(value));
}


CV_INLINE  int  cvCeil( double value )
{
    return (int)(ceil(value));
}

可能是编译器的问题,(int)

2.把32去掉

CV_INLINE void* cvAlignPtr( const void* ptr, int align )//
{
    assert( (align & (align-1)) == 0 );
    return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) );
}

3.  size 赋值

CV_INLINE  CvSize  cvGetMatSize( const CvMat* mat )
{
   // CvSize size = { mat->width, mat->height };
      CvSize size;
   size.width =  mat->cols;
   size.height = mat->rows;
    return size;
}


4.去掉重复声明

/opt/DM3730/dvsdk/codec-engine_2_26_02_11/examples/ti/sdo/ce/examples/codecs/videnc_copy/EMCV/cxcore/cxmisc.h:724: error: redefinition of typedef 'CvFunc2DnC_1A1P'

#if 0
typedef CvStatus (CV_STDCALL *CvFunc2DnC_1A1P)( void* arr, int step, CvSize size,
                                                int cn, int coi, void* param );
#endif

typedef CvStatus (CV_STDCALL *CvFunc2DnC_1A1P)( void* arr, int step, CvSize size,
                                                int cn, int coi, void* param );



#if 0
typedef CvStatus (CV_STDCALL *CvFunc2DnC_2A1P)( void* arr0, int step0,
                                                void* arr1, int step1,
                                                CvSize size, int cn,
                                                int coi, void* param );
#endif
typedef CvStatus (CV_STDCALL *CvFunc2DnC_2A1P)( void* arr0, int step0,
                                                void* arr1, int step1,
                                                CvSize size, int cn,
                                                int coi, void* param );

5.去掉一些 dsp库的汇编函数

EMCV/cv/cvmorph.cpp:48: error: expected ',' or '...' before 'in_data'
EMCV/cv/cvmorph.cpp: In function 'void icvErode_8UC1(const unsigned char*)':
EMCV/cv/cvmorph.cpp:60: error: 'mask' was not declared in this scope
EMCV/cv/cvmorph.cpp:74: error: 'cols' was not declared in this scope
EMCV/cv/cvmorph.cpp:77: error: 'in_data' was not declared in this scope
EMCV/cv/cvmorph.cpp:77: error: '_mem4_const' was not declared in this scope
EMCV/cv/cvmorph.cpp:78: error: 'step' was not declared in this scope
EMCV/cv/cvmorph.cpp:86: error: '_minu4' was not declared in this scope
EMCV/cv/cvmorph.cpp:95: error: 'out_data' was not declared in this scope
EMCV/cv/cvmorph.cpp: At global scope:
EMCV/cv/cvmorph.cpp:102: error: expected ',' or '...' before 'in_data'
EMCV/cv/cvmorph.cpp: In function 'void icvDilate_8UC1(const unsigned char*)':
EMCV/cv/cvmorph.cpp:114: error: 'mask' was not declared in this scope
EMCV/cv/cvmorph.cpp:128: error: 'cols' was not declared in this scope
EMCV/cv/cvmorph.cpp:131: error: 'in_data' was not declared in this scope
EMCV/cv/cvmorph.cpp:131: error: '_mem4_const' was not declared in this scope
EMCV/cv/cvmorph.cpp:132: error: 'step' was not declared in this scope
EMCV/cv/cvmorph.cpp:140: error: '_maxu4' was not declared in this scope
EMCV/cv/cvmorph.cpp:149: error: 'out_data' was not declared in this scope
EMCV/cv/cvmorph.cpp: In function 'void icvMorphOp(const void*, void*, IplConvKernel*, int, int)':
EMCV/cv/cvmorph.cpp:53: error: too many arguments to function 'void icvErode_8UC1(const unsigned char*)'
EMCV/cv/cvmorph.cpp:247: error: at this point in file
EMCV/cv/cvmorph.cpp:107: error: too many arguments to function 'void icvDilate_8UC1(const unsigned char*)'
EMCV/cv/cvmorph.cpp:266: error: at this point in file

void icvErode_8UC1
(
    const unsigned char *restrict in_data,
    unsigned char       *restrict out_data,
    const char          *restrict mask,
    int cols,
    int step
)

去掉restrict,这不是c标准库的东西吗,怎么也不支持? 我用的是arm-arago-linux-gnueabi- 编译

 p0 = (_mem4_const(&in_data[i         ]));
        p3 = (_mem4_const(&in_data[i + step  ]));
        p6 = (_mem4_const(&in_data[i + step*2]));

        p1 = p0>>8;       p2 = p0>>16;
        p4 = p3>>8;       p5 = p3>>16;
        p7 = p6>>8;       p8 = p6>>16;

        result = p4 & 0xFFFF;
        result = m0 ? _minu4(result, p0) : result;
        result = m1 ? _minu4(result, p1) : result;
        result = m2 ? _minu4(result, p2) : result;
        result = m3 ? _minu4(result, p3) : result;
        result = m5 ? _minu4(result, p5) : result;
        result = m6 ? _minu4(result, p6) : result;
        result = m7 ? _minu4(result, p7) : result;
        result = m8 ? _minu4(result, p8) : result;

修改以上,用c的东西,不知道逻辑是不是对的,有待验证

for (i = 0; i < cols-2; i += 2)
    {
 
        p0 = ((in_data[i         ]));
        p3 = ((in_data[i + step  ]));
        p6 = ((in_data[i + step*2]));

        p1 = p0>>8;       p2 = p0>>16;
        p4 = p3>>8;       p5 = p3>>16;
        p7 = p6>>8;       p8 = p6>>16;

        result = p4 & 0xFFFF;
        result = m0 ? MIN(result, p0) : result;
        result = m1 ? MIN(result, p1) : result;
        result = m2 ? MIN(result, p2) : result;
        result = m3 ? MIN(result, p3) : result;
        result = m5 ? MIN(result, p5) : result;
        result = m6 ? MIN(result, p6) : result;
        result = m7 ? MIN(result, p7) : result;
        result = m8 ? MIN(result, p8) : result;

还有:

 for (i = 0; i < cols-2; i += 2)
    {
 
        p0 = ((in_data[i         ]));
        p3 = ((in_data[i + step  ]));
        p6 = ((in_data[i + step*2]));

        p1 = p0>>8;       p2 = p0>>16;
        p4 = p3>>8;       p5 = p3>>16;
        p7 = p6>>8;       p8 = p6>>16;

        result = p4 & 0xFFFF;
        result = m0 ? MAX(result, p0) : result;
        result = m1 ? MAX(result, p1) : result;
        result = m2 ? MAX(result, p2) : result;
        result = m3 ? MAX(result, p3) : result;
        result = m5 ? MAX(result, p5) : result;
        result = m6 ? MAX(result, p6) : result;
        result = m7 ? MAX(result, p7) : result;
        result = m8 ? MAX(result, p8) : result;

        out_data[i] = (result & 0xFF);
        out_data[i+1] = (result>>8 & 0xFF);


经过以上,cv相关文件,可以在codec engine中编译通过