我无法将图像格式SDK(Microsoft)转换为IplImage(OpenCV) [英] I can't get image form SDK(Microsoft) to IplImage(OpenCV)

查看:96
本文介绍了我无法将图像格式SDK(Microsoft)转换为IplImage(OpenCV)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将图像格式SDK(Microsoft)转换为IplImage(OpenCV)。

I can't get image form SDK(Microsoft) to IplImage(OpenCV).

函数cvSetData中的此错误(rgb32,& hr,rgb32-> widthStep);

this error in function cvSetData(rgb32, &hr, rgb32->widthStep);

帮助我PLZ。

 


#include "cv.h"
#include "cvaux.h"
#include "highgui.h"

#include "MSR_NuiApi.h"
#include "MSR_NuiSkeleton.h"
#include "MSR_NuiProps.h"
#include "MSR_NuiImageCamera.h"
#include "NuiImageBuffer.h"

#include <iostream>
#include <conio.h>

using namespace std;

int main(){
    HANDLE m_pVideoStreamHandle;
    HANDLE m_hNextVideoFrameEvent;
    HRESULT hr;

    const NUI_IMAGE_FRAME * pImageFrame = NULL;
    IplImage *rgb32 = cvCreateImageHeader(cvSize(640, 480), 8, 4);
    m_hNextVideoFrameEvent = CreateEvent( NULL, TRUE, FALSE, NULL );

    hr = NuiInitialize(NUI_INITIALIZE_FLAG_USES_COLOR);
    if( FAILED( hr ) ){
        cout << "Error : NuiInitialize" << endl;
        getch();
        return -1;
    }

    hr = NuiImageStreamOpen(NUI_IMAGE_TYPE_COLOR, NUI_IMAGE_RESOLUTION_640x480, 0, 2, m_hNextVideoFrameEvent, &m_pVideoStreamHandle );
    if( FAILED( hr ) ){
        cout << "Error : NuiImageStreamOpen" << endl;
        getch();
        return -1;
    }

    while(1){
        hr = NuiImageStreamGetNextFrame(m_pVideoStreamHandle, 0, &pImageFrame );
        if( FAILED( hr ) ){
            cout << "Error : NuiImageStreamGetNextFrame" << endl;
        }
        else{
            cout << "Success : NuiImageStreamGetNextFrame" << endl;
            cvSetData(rgb32, &hr, rgb32->widthStep);
            cvShowImage("Input", rgb32);
        }
        cvWaitKey(10);
    }

    cvWaitKey(0);
    return 0;
}

推荐答案

我们在此论坛中没有提供有关OpenCV的专家建议,所以您需要提供更多详细信息以便我们为您提供帮助:

We don't provide expert advice on OpenCV in this forum, so you have to give more details for us to be able to help you:

-  您看到了什么样的错误?

- 您使用过openCV吗?成功在其他应用程序?如果是这样,什么是最适合你的代码示例,例如,创建一个完全由红色像素组成的图像(所以我们可以看到一个简单的例子看起来像什么)?

- 我没有看到任何你似乎将数据从pImageFrame传输到你想用cvShowImage显示的图像rgb32的地方,所以,你期望看到什么?请参阅SkeletalViewer \CPP SDK
示例中的NuiImpl.cpp中的CSkeletalViewerApp :: Nui_GotVideoAlert,了解如何获取图像数据。特别是,调用pImageFrame-> LockRect并使用LockedRect.pBits。

- " hr"只是一个错误代码,所以当你把它传递给cvSetData时你会发生什么?

- What kind of error do you see?
- Have you used openCV successfully in other applications? if so, what is a minimal sample of code that works for you to, for example, create an image that is entirely composed of red pixels (so we can see what a simple example that works looks like)?
- I don't see any place where you seem to be transferring data from pImageFrame into the image rgb32 which you want to display using cvShowImage, so, what do you expect to see? See CSkeletalViewerApp::Nui_GotVideoAlert in NuiImpl.cpp in SkeletalViewer\CPP SDK sample to see how to obtain image data. In particular, call to pImageFrame->LockRect and use of LockedRect.pBits.
- "hr" is just an error code, so what do you expect to happen when you pass it to cvSetData?

Eddy


这篇关于我无法将图像格式SDK(Microsoft)转换为IplImage(OpenCV)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆