00001 /****************************************************************************** 00002 * __ _ _ _ _ _ _____ * 00003 * | \ / | | | | | | | | | | ___| * 00004 * | \/ | | | | | | | | | | |_ * 00005 * | | | | | | | | | | | _| * 00006 * | |\/| | | | | |__ | |__ | | | |__ * 00007 * |_| |_| |_| |____| |____| |_| |____| * 00008 * __________________________________________________________________________ * 00009 * Multifunctional Library For Image Processing * 00010 * * 00011 * * 00012 * * 00013 * (c) Copyright 2007 by Humbert Florent * 00014 * * 00015 * This program is free software; you can redistribute it and/or modify * 00016 * it under the terms of the GNU General Public License as published by * 00017 * the Free Software Foundation; only version 2 of the License. * 00018 * * 00019 * This program is distributed in the hope that it will be useful, * 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00022 * GNU General Public License for more details. * 00023 * * 00024 * You should have received a copy of the GNU General Public License * 00025 * along with this program; if not, write to the Free Software * 00026 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 00027 * 02111-1307, USA. * 00028 ******************************************************************************/ 00029 00032 #include "Millie.hpp" 00033 00034 #include <iostream> 00035 #include <cassert> 00036 00037 #ifdef WIN32 00038 /* MS-Windows */ 00039 #include <windows.h> 00040 #define msleep(ms) Sleep(ms) 00041 #else 00042 /* unixoides */ 00043 #include <unistd.h> 00044 #define msleep(ms) usleep((ms * 1000)) 00045 #endif 00046 00047 using namespace Millie; 00048 00063 class MonThread : public GThread { 00064 00065 private: 00066 int n; 00067 00068 public: 00069 MonThread(int a) 00070 { 00071 n=a; 00072 } 00073 void run() 00074 { 00075 for(int j=0; j<5; j++) { 00076 for(int i = 0; i<1000;i++) { 00077 // sleep(1); 00078 std::cerr<<"Thread numero : "<<n<<std::endl; 00079 } 00080 00081 waitAllGroup(); 00082 } 00083 } 00084 00085 }; 00086 00087 00088 int main (int argc, char * argv[]) 00089 { 00090 00091 ThreadGroup group; 00092 /* MonThread t1(1); 00093 MonThread t2(2); 00094 00095 t1.start(); 00096 t2.start(); 00097 t1.join(); 00098 t2.join(); 00099 */ 00100 group.add(new MonThread(1)); 00101 group.add(new MonThread(2)); 00102 try { 00103 group.startAll(); 00104 } 00105 catch(std::exception & e) 00106 { 00107 std::cerr<<e.what(); 00108 //return EXIT_FAILURE; 00109 } 00110 00111 /*catch(Exception &e) 00112 { 00113 std::cerr<<e.what(); 00114 //return EXIT_FAILURE; 00115 }*/ 00116 //std::cerr<<"juste avant join"; 00117 //t1.join(); 00118 00119 /* std::cerr<<"Juste après start"<<std::endl; 00120 msleep(2000); 00121 std::cerr<<"on reveille"<<std::endl; 00122 */ 00123 //group.joinAll(); 00124 00125 /* ImageRGB im; 00126 ImageRGB save; 00127 00128 try 00129 { 00130 ImageIO::loadBMP(im, "images/millie.bmp"); 00131 } 00132 catch(Exception & e) 00133 { 00134 std::cerr<<e.what()<<std::endl; 00135 std::cerr<<"IO FAILURE"; 00136 return 0; 00137 } 00138 00139 CMaskFactoryGaussianBlur blur(0.1); 00140 CFilter filter(blur); 00141 filter.compute(save, im); 00142 00143 00144 ImageIO::saveBMP(save, "images/millieCorr.bmp"); 00145 */ 00146 return 0; 00147 } 00148 00149 /* 00150 GaussianRandomizer gauss(5, 0); 00151 int tab[50]; 00152 for(int i = 0; i<50;i++) 00153 tab[i] = 0; 00154 00155 for(int i = 0; i<500; i++) 00156 { 00157 float fget = gauss.get(); 00158 int iget = (int) fget + 25; 00159 if(iget>=0 && iget<50) 00160 tab[iget]++; 00161 std::cout<<gauss.get()<<std::endl; 00162 } 00163 int max = 0; 00164 00165 for(int i = 0; i<50;i++) 00166 { 00167 std::cout<<"i "<<i-25<<": "<<tab[i]<<std::endl; 00168 if(tab[i]>max) 00169 max =tab[i]; 00170 } 00171 00172 for(int j = max; j>=0;j--) 00173 { 00174 for(int i = 0; i<50;i++) 00175 if(tab[i]>j) 00176 std::cout<<"*"; 00177 else 00178 std::cout<<" "; 00179 00180 std::cout<<std::endl; 00181 } 00182 */