Hi Matthias,

first of all, you can use any thread implementation you like, but we dont claim 
every MITK class to be thread save. The DataStorage, however, should be thread 
safe by now.
I suspect the piece of code you pasted should just show the whole video stream 
but this is not this is not the right way to do it. Shame on me, i should have 
made some documentation on it. So this is the way to show videos in MITK (with 
the help of OpenCV):

mitk::OpenCVVideoSource::Pointer _VideoSource = mitk::OpenCVVideoSource::New();
_VideoSource ->SetVideoFileInput(...);
//_VideoSource->SetVideoCameraInput(...);
_VideoSource ->StartCapturing();

mitk::QmitkVideoBackground* _QmitkVideoBackground = new 
mitk::QmitkVideoBackground(m_VideoSource, 40); 
_QmitkVideoBackground ->AddRenderWindow(someRenderWindow);
_QmitkVideoBackground ->Enable();

This way you wont need any parallelization for a fluent video stream. The 
OpenCVVideoSource encapsulates a CvCapture object whereas a 
QmitkVideoBackground directly streams the frame buffer as OpenGL texture to 
some render window. You can use video files from disk with SetVideoFileInput() 
or you can directly use a frame grabber with SetVideoCameraInput().  
The OpenCVToMitkImageFilter was invented to do some MITK image processing on 
selected OpenCV frames, but not to do real time image processing. In that case 
you should stick to the OpenCV routines.

Have fun,
Michaek
________________________________________
Von: Matthias Mucha [[email protected]]
Gesendet: Donnerstag, 8. April 2010 18:08
An: [email protected]
Betreff: [mitk-users] OpenCVToMitkImageFilter- and Thread-Problem

Dear List,

I work with Stefan Dänzer at ICCAS-Leipzig on an Ultrasound-Project.
Recently I used the OpenCV-Modul to capture pictures (Ultrasound-Images) from a 
Frame-Grabber. It all works fine, but the OpenCVToMitkImageFilter slows down 
the hole grabbing-routine. Probably, I'm going to use threads with mutex in 
addition to parallelize the reading and writing from a queue. There is almost a 
linking-error when I use the BOOST-Library. Can I use threads (i.e. BOOST) in 
MITK and is there a possibility to fasten the grabbing-routine?

Source-Code:
if(m_CurrentCVFrame = m_GrabVideo->GetCurrentFrame())
    {
      m_Filter = mitk::OpenCVToMitkImageFilter::New();
      m_Filter->SetOpenCVImage(m_CurrentCVFrame);
      m_Filter->Update();
      m_CurrentMITKFrame = m_Filter->GetOutput(0); // here the program slows 
down


      if(!m_Node){
        m_Node = mitk::DataNode::New();
        m_Node->SetName("grabbedVideo");
        m_Node->SetData(m_CurrentMITKFrame);
        m_Ds->Add(m_Node);
        
mitk::RenderingManager::GetInstance()->InitializeViews(m_Ds->ComputeBoundingGeometry3D(m_Ds->GetAll()));
      }else {
        m_Ds->GetNamedNode(m_Node->GetName())->SetData(m_CurrentMITKFrame);
      }
      cvShowImage("video", m_CurrentCVFrame);   //display the current frame

    } else {

      CloseVideoGrabber();
      cout << "Capturing finished!" << endl;
    }


By the way, is the mitk::Image the right object to save the ultrasound-images 
as time-sliced data to build a 3D-Volume?

Best regards

Matthias Mucha
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to