【OpenCV学习】错误处理机制

作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/

 

#include "cxcore.h"
#include <stdio.h>
#define FLAG 0
#define ERRMODE 0
void cvResizeDCT(CvMat *input_array,CvMat * output_array)
{
    CvMat * temp_array=0;
    CV_FUNCNAME("cvResizeDCT");
    /*#define CV_FUNCNAME( Name ) static char cvFuncName[] = Name*/
    //定义了这个函数的名字,其实就是一个字符数组
    __BEGIN__;
    if (!CV_IS_MAT(input_array) || !CV_IS_MAT(output_array))
    {
        CV_ERROR(CV_StsBadArg,"Invaild matrices!");
    }
    CV_ASSERT(input_array ->rows ==1 && output_array ->rows ==1);
    CV_CALL(temp_array = cvCreateMat(input_array ->rows,MAX(input_array->cols,
        output_array->cols),input_array->type));
    if (output_array->cols > input_array->cols)
    {
        CV_CALL(cvZero(temp_array));
    }
    temp_array->cols = input_array->cols;
    CV_CALL( cvDCT( input_array, temp_array, CV_DXT_FORWARD ));//离散馀弦变换
    temp_array->cols = output_array->cols;
    CV_CALL( cvDCT( temp_array, output_array, CV_DXT_INVERSE ));
    CV_CALL( cvScale( output_array, output_array, 1./sqrt((double)input_array->cols*output_array->cols), 0 ));
    __END__;
}
int main(void)
{
    CvMat *src = /blog.armyourlife.info/cvCreateMat(1,512,CV_32F);
#if    FLAG
    CvMat *dst = cvCreateMat(1,256,CV_32F);
#else
    CvMat *dst=0;
#endif
    cvSet(src,cvRealScalar(1.),0);
#if ERRMODE
    cvSetErrMode(CV_ErrModeSilent);
#endif
    cvResizeDCT(src,dst);
    if (cvGetErrStatus()<0)
    {
        printf("Some Error Occured!");
    }
    else
    {
        printf("Everything is OK!/n");
    }
    return 0;
}

作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/

posted @ 2012-10-09 20:04  gnuhpc  阅读(949)  评论(0编辑  收藏  举报