0

私は OpenCV で作業しており、画像テクスチャを追加したいウィンドウがあります。これまでの私のコード:

void display(void) {  
    GLuint texture[1];
    IplImage *image;

    image=cvLoadImage("Particle.png");

    if(!image){
        std::cout << "image empty" << std::endl;
    } else {
        glGenTextures(1, texture);
        glBindTexture(1,  GL_TEXTURE_2D );

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

        // Set texture clamping method
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    }

    cvReleaseImage(&image);
}

int main(int argc, char**argv)
{
    display();
}

//window to draw the texture on
cvNamedWindow("video");

私はOpenGLが初めてで、混乱しているので、改善する方法やここからどこへ行くべきか(ウィンドウに描画する方法)に関するヒントがあれば教えてください。

4

1 に答える 1

1

幸いなことに、ウィンドウに画像を描画するために OpenGL で作業を行う必要はありません。OpenCV では、関数 でこの機能が既に提供されていますcvShowImage()

ウィンドウを表示するコードは次のようになります。

if(!image)
{
    std::cout << "image empty" << std::endl;
}
else
{
    cvNamedWindow("image");      // Create the window
    cvShowImage("image", image); // Display image in the window
    cvWaitKey();                 // Display window until a key is pressed
}
于 2013-07-29T15:42:23.067 に答える