MFC GUI を使用している opencv を使用するカメラ アプリケーションがあります。画像処理用の Opencv モジュール用に CImage を IplImage に変換し、ウィンドウに再度表示するために CImage に戻す必要があります。
私はこのトピックで調査しましたが、十分な例と解決策がありません.誰でもいくつかの提案があります.Thank
これは私のコードです...
void CChildView::OnFileOpenimage(void)
{
// TODO: Add your command handler code here
CString strFilter;
CSimpleArray<GUID> aguidFileTypes;
HRESULT hResult;
hResult = imgOriginal.GetExporterFilterString(strFilter,aguidFileTypes);
if (FAILED(hResult)) {
CString fmt;
fmt.Format("GetExporterFilter failed:\n%x - %s", hResult, _com_error(hResult).ErrorMessage());
::AfxMessageBox(fmt);
return;
}
CFileDialog dlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST, strFilter);
dlg.m_ofn.nFilterIndex = m_nFilterLoad;
hResult = (int)dlg.DoModal();
if(FAILED(hResult)) {
return;
}
m_nFilterLoad = dlg.m_ofn.nFilterIndex;
imgOriginal.Destroy();
CString pathval = dlg.GetPathName();
hResult = imgOriginal.Load(dlg.GetPathName());
if (FAILED(hResult)) {
CString fmt;
fmt.Format("Load image failed:\n%x - %s", hResult, _com_error(hResult).ErrorMessage());
::AfxMessageBox(fmt);
return;
}
// IplImage *img from imgOriginal; want to convert here for further processing.
m_nImageSize = SIZE_ORIGINAL;
Invalidate();
UpdateWindow();
}