在OpenCv中,我们有时候需要查看CvRect变量的值,我们可以通过将其保存到文件来查看,保存的代码如下:

 

void writeCvRectToFile(CvRect &rect, const char *filename) {    
    CvFileStorage *fs = cvOpenFileStorage(filename, 0, CV_STORAGE_WRITE);
    if (!fs) {
        fprintf(stderr, "Could not open file ..\n");
        return;
    }
    cvStartWriteStruct(fs, "rect", CV_NODE_SEQ | CV_NODE_FLOW);
    cvWriteInt(fs, 0, rect.x); 
    cvWriteInt(fs, 0, rect.y); 
    cvWriteInt(fs, 0, rect.width); 
    cvWriteInt(fs, 0, rect.height);
    cvEndWriteStruct(fs);
    cvReleaseFileStorage(&fs);
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-03
  • 2021-12-09
  • 2022-12-23
  • 2021-11-13
  • 2021-07-09
  • 2022-12-23
猜你喜欢
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2021-06-19
  • 2021-12-06
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案