Please can help me about the use of AddImageFileFromMemory in C++
In fact i have a segfault error when i try to use FRengine11 to process image from memory. My code is attached:
IplImage *bimg = cvLoadImage("01.Business_Card.jpg");
CSafePtr<IFRDocument> frDocument = 0;
CheckResult( FREngine->CreateFRDocument( &frDocument ));
CheckResult( frDocument->AddImageFileFromMemory((__int64*)bimg->imageData, bimg->imageSize, 0, 0, 0, 0));
CheckResult( frDocument->Process() );
// Save results
CBstr exportPath = "/tmp/Demo.rtf";
CheckResult( frDocument->Export( exportPath, FEF_RTF, 0 ) );
UnloadFREngine();
コメント
2件のコメント
As we discussed it in the email, OpenCV stores image in some shaped format and FRDocument::AddImageFileFromMemory expects image file loaded in memory in FRE inner format. So these formats are incompatible.
In order to use openCV image reader, you can use Engine::OpenBitMapBits method.
Example code looks as follows:
char* charPath = (char*) imageFilePath;
cv::String imagePath = cv::String(charPath);
cv::Mat testImage;
testImage = cv::imread(imagePath,CV_LOAD_IMAGE_COLOR);
CSafePtr<IImageDocument> documentImage;
CheckResult( FREngine->OpenBitmapBits( BBF_Color, testImage.cols, testImage.rows, testImage.step[0], 0, 0, (int64_t)testImage.data, 0, documentImage.GetBuffer() ) );
CheckResult( frDocument->AddImageDocument( documentImage ) );
Dear support,
Thank you very much for your reply. I really appreciate your help in resolving the problem.
Best regards;
サインインしてコメントを残してください。