2016-05-22 81 views
0

WriteableBitmapをC++/cx Microsoftのユニバーサルアプリケーションでcv :: Matに変換しようとしました。私が作成したマットで進行しようとする。しかし、私は次のエラーを取得する:SoftwareBitmapまたはWriteableBitmapをC++/cxのcv :: Matに変換する

enter image description here

これは私のコードです:

void App1::MainPage::processImage(SoftwareBitmap^ bitmap) 
{ 
    WriteableBitmap^ wb = ref new WriteableBitmap(bitmap->PixelWidth, bitmap->PixelHeight); 
    bitmap->CopyToBuffer(wb->PixelBuffer); 
    Mat img_image(wb->PixelHeight, wb->PixelWidth, CV_8UC3,(void*)wb->PixelBuffer); 
    //next step results in error 
    cvtColor(img_image, img_image, CV_BGR2BGRA); 
    ... 
} 

だから私の最後の質問: SoftwareBitmapを変換する方法やWriteableBitmapをcv :: Matにする?

答えて

0

私はこの問題を解決するためにDataReaderを使用:

void App1::MainPage::processImage(SoftwareBitmap^ bitmap) 
{ 
    WriteableBitmap^ wb = ref new WriteableBitmap(bitmap->PixelWidth, bitmap->PixelHeight); 
    bitmap->CopyToBuffer(wb->PixelBuffer); 
    IBuffer^ buffer = wb->PixelBuffer; 
    auto reader = ::Windows::Storage::Streams::DataReader::FromBuffer(buffer); 
    BYTE *extracted = new BYTE[buffer->Length]; 
    reader->ReadBytes(Platform::ArrayReference<BYTE>(extracted, buffer->Length)); 
    Mat img_image(wb->PixelHeight, wb->PixelWidth, CV_8UC4, extracted); 
    cvtColor(img_image, img_image, CV_RGBA2BGRA); 
    ... 
} 

Thxをピータートルにヒントを。

関連する問題