vectors RRS feed

  • Question

  • Ola, tenho este codigo onde faço um resize e pretendo copiar apos este copiar novamente as imagens para o mesmo vector (m_VectorImagesCaptured) mas estou com problemas, este carrega-me sempre a mesma imagem (a ultima que foi utilizada na função resize) podem ajudar-me

    #if !defined(AFX_CAPTURE_H__C52E0AB8_1F7D_4A84_BBC8_7CCA3B890D5B__INCLUDED_)
    #define AFX_CAPTURE_H__C52E0AB8_1F7D_4A84_BBC8_7CCA3B890D5B__INCLUDED_
    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    #include <vector>

    typedef std::vector< IplImage* >  VectorImagesCaptured;
    typedef std::vector< IplImage* >  VectorAux;

    class CCapture 
     IplImage* GetImage(int i);
     void ClearAll();
     VectorAux m_VectorAux; 
     VectorImagesCaptured m_VectorImagesCaptured;
     int index_VectorImagesCaptured;

    IplImage* img_neural_aux=cvCreateImage(cvSize(29,29),IPL_DEPTH_8U,0);//redimencionar a imagem para uma 29x29 pixeis
     IplImage *aux=cvCreateImage(cvSize(29,29),IPL_DEPTH_8U,0);
     char nomefile[40];
      for(int i=0;i<m_VectorImagesCaptured.size();i++)
      aux =cvCloneImage(img_neural_aux);


     for(int i=(m_VectorAux.size()-1);i>=0;i--)
    cvNamedWindow("imagem ",0);

    // img_neural_auxView=m_VectorAux[i];
    cvShowImage("imagem ",img_neural_auxView);//carrega a imagem coma estrutura
    //   cvShowImage("imagem a treinar na rede1",m_VectorAux[i]);//carrega a imagem coma estrutura
    Friday, November 21, 2008 10:41 AM


  • 1) You should post your questions in english.
    2) This is not a Visual C++ language question, it is an OpenCV question.

    The problem you have is that you are doing push_back of a pointer. In your first for loop you change the content of this pointer and not the pointer itself. I you use the debugger to watch the elements of m_VectorAux you'll see that you have the same value on each position.

    You should change,




    Other useful things: You shoud release your images in order to avoid memory leaks.
    • Marked as answer by Rong-Chun Zhang Wednesday, November 26, 2008 10:44 AM
    Friday, November 21, 2008 11:22 AM