Index: branches/sanscv/lib/FlairVisionFilter/src/ImgThreshold.cpp
===================================================================
--- branches/sanscv/lib/FlairVisionFilter/src/ImgThreshold.cpp	(revision 324)
+++ branches/sanscv/lib/FlairVisionFilter/src/ImgThreshold.cpp	(revision 325)
@@ -13,8 +13,10 @@
 
 #include "ImgThreshold.h"
+#include "VisionFilter.h"
 #include <Image.h>
 #include <Layout.h>
 #include <GroupBox.h>
 #include <SpinBox.h>
+//#include <dspcv_gpp.h>
 #include <typeinfo>
 
@@ -23,50 +25,84 @@
 using namespace flair::gui;
 
+class ImgThreshold_impl {
+public:
+    ImgThreshold_impl(flair::filter::ImgThreshold *self,const LayoutPosition* position,string name):output(0) {
+        this->self=self;
+        
+        GroupBox* reglages_groupbox=new GroupBox(position,name);
+        threshold=new SpinBox(reglages_groupbox->NewRow(),"threshold:",0,255,1,127);
+
+        Printf("todo: pouvoir reutiliser la meme image en sortie\n");
+        try{
+            Image::Type const &imageType=dynamic_cast<Image::Type const &>(((IODevice*)(self->Parent()))->GetOutputDataType());
+            if(imageType.GetFormat()==Image::Type::Format::Gray) {
+                output=new Image(self,imageType.GetWidth(),imageType.GetHeight(),imageType.GetFormat(),"threshold");
+                //inIplImage = (IplImage*)AllocFunction(sizeof(IplImage));
+                //outIplImage = (IplImage*)AllocFunction(sizeof(IplImage));
+            } else {
+                self->Err("input image is not gray\n");
+            }
+        } catch(std::bad_cast& bc) {
+            self->Err("io type mismatch\n");
+        }
+
+        
+    }
+
+    ~ImgThreshold_impl() {
+        //FreeFunction((char*)(inIplImage));
+        //FreeFunction((char*)(outIplImage));
+    }
+    
+    void UpdateFrom(const io_data *data){
+        Image *img=(Image*)data;
+/*
+        data->GetMutex();
+        inIplImage->width=img->GetDataType().GetWidth();
+        inIplImage->height=img->GetDataType().GetHeight();
+        inIplImage->imageData=img->buffer;
+        
+        output->GetMutex();
+        outIplImage->width=output->GetDataType().GetWidth();
+        outIplImage->height=output->GetDataType().GetHeight();
+        outIplImage->imageData=output->buffer;
+                
+        dspThreshold(inIplImage,outIplImage, threshold->Value(), 255, CV_THRESH_BINARY);
+        output->ReleaseMutex();
+        data->ReleaseMutex();
+*/
+        output->SetDataTime(data->DataTime());
+    };
+    
+    Image *output;
+
+private:
+    flair::filter::ImgThreshold *self;
+    SpinBox *threshold;
+    //IplImage *inIplImage,*outIplImage;
+};
+
 namespace flair { namespace filter {
 
-ImgThreshold::ImgThreshold(const IODevice* parent,const LayoutPosition* position,string name) : IODevice(parent,name),output(0) {
-    GroupBox* reglages_groupbox=new GroupBox(position,name);
-    threshold=new SpinBox(reglages_groupbox->NewRow(),"threshold:",0,255,1,127);
-
-    Printf("todo: pouvoir reutiliser la meme image en sortie\n");
-    try{
-        Image::Type const &imageType=dynamic_cast<Image::Type const &>(parent->GetOutputDataType());
-        if(imageType.GetFormat()==Image::Type::Format::Gray) {
-            output=new Image(this,imageType.GetWidth(),imageType.GetHeight(),imageType.GetFormat(),"threshold");
-        } else {
-            Err("input image is not gray\n");
-            return;
-        }
-    } catch(std::bad_cast& bc) {
-        Err("io type mismatch\n");
-        return;
-    }
-    SetIsReady(true);
+ImgThreshold::ImgThreshold(const IODevice* parent,const LayoutPosition* position,string name) : IODevice(parent,name) {
+    pimpl_=new ImgThreshold_impl(this,position,name);
 }
 
 ImgThreshold::~ImgThreshold(void) {
+    delete pimpl_;
 }
 
 Image* ImgThreshold::Output(void) {
-    return output;
+    return pimpl_->output;
 }
 
 void ImgThreshold::UpdateFrom(const io_data *data) {
- /*   Image *cvImage=(Image*)data;
-    IplImage *gimg=cvImage->img;
-
-    data->GetMutex();
-    output->GetMutex();
-    dspThreshold(gimg, output->img, threshold->Value(), 255, CV_THRESH_BINARY);
-    output->ReleaseMutex();
-    data->ReleaseMutex();
-*/
-    output->SetDataTime(data->DataTime());
-    ProcessUpdate(output);
+    pimpl_->UpdateFrom(data);
+    ProcessUpdate(pimpl_->output);
 }
 
 DataType const &ImgThreshold::GetOutputDataType() const {
-    if(output!=NULL) {
-        return output->GetDataType();
+    if(pimpl_->output!=NULL) {
+        return pimpl_->output->GetDataType();
     } else {
         return dummyType;
