カメラを使用して数時間にわたって大量の画像を取得して保存する必要があります。私は BitFlow SDK を使用してカメラの取得を処理し、OpenCV を主に表示と画像処理に使用しています。このすべてのデータをコンパクトでアクセスしやすい形式で保存する方法を見つける必要があります (複数ページの tiff ファイルを作成することが最初の目的でしたが、それに関するサポートはほとんどありません)。
とにかく、OpenCV の FileStorage クラスを使用して複数の画像を 1 つの YAML ファイルに保存しようとしていますが、あまり成功していません。作成した YAML ファイルから1 つのイメージを正常に書き込み、読み取ることができますが、<< 演算子を使用してファイルに複数の Mat オブジェクトを配置しようとするとすぐに、次のエラーが発生します。
BFBi_test.exe の 0x74E2C42D での初回例外: Microsoft C++ 例外: cv::Exception at memory location 0x0045F6B4. BFBi_test.exe の 0x74E2C42D での初回例外: Microsoft C++ 例外: cv::Exception at memory location 0x0045F6B4. BFBi_test.exe の 0x74E2C42D で未処理の例外: Microsoft C++ 例外: cv::Exception メモリ位置 0x0045F6B4 で。
私のコードの一部:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include "resource.h"
#include "SequenceInterface.h"
#include "opencv2/core/core.hpp"
#include "persistence.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace std;
using namespace cv;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
// Control variables
BFU32 numBuffers = 10; // Allocate 10 buffers
BFU32 setupOptions = 0; // Use default setup options.
FileStorage firstImg("FirstImage.yml", FileStorage::WRITE);
FileStorage secondImg("SecondImage.yml", FileStorage::WRITE);
cout << "Creating instance of sequence interface." << endl;
SequenceInterface board(0, numBuffers, 0);
PBFU32* pBufferArray= board.getBufferArrayPointers();
Mat test(Size(1024, 1024),CV_8UC1, (void *)pBufferArray[0], (size_t)1024);
Mat test2(Size(1024, 1024),CV_8UC1, (void *)pBufferArray[1], (size_t)1024);
// -- Acquisition done here ---
...
...
// -- End of acquisition --
firstImg<<"firsttest"<< test;
firstImg<< "secondtest" << test2; // Runtime error on this line;
firstImg.release();
}
test2 を secondImg に書いても問題ありません。また、ランダムな文字列オブジェクトを firstImg に追加しようとしましたが、そこにも問題はありません。XML に切り替えても、何も変わりませんでした。YAML ファイルの最大サイズはありますか?それは、私の画像がその用途には大きすぎることを意味しますか?