From: Dominic L. <ma...@us...> - 2004-08-13 16:26:51
|
Update of /cvsroot/robotflow/RobotFlow/Vision/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27603/src Modified Files: ColorTracker.cc ComponentsViewer.cc HoughTransform.cc Image.cc InverseHough.cc JPEGLoadMemory.cc MultiColorTracker.cc Posterize.cc Scale.cc SymbolExtractor.cc SymbolTracker.cc Log Message: removed all possible hard coded image size Index: JPEGLoadMemory.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Vision/src/JPEGLoadMemory.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** JPEGLoadMemory.cc 13 Jun 2004 19:44:11 -0000 1.2 --- JPEGLoadMemory.cc 13 Aug 2004 16:26:41 -0000 1.3 *************** *** 23,27 **** #include "Image.h" #include "BufferedNode.h" - #include "gdk-pixbuf/gdk-pixbuf.h" //forward declaration --- 23,26 ---- *************** *** 43,56 **** * @output_description The output image created from data * - * @parameter_name IMAGE_WIDTH - * @parameter_type int - * @parameter_value 320 - * @parameter_description the width of the image to create - * - * @parameter_name IMAGE_HEIGHT - * @parameter_type int - * @parameter_value 240 - * @parameter_description the height of the image to create - * END*/ --- 42,45 ---- *************** *** 62,75 **** int m_imageID; - GdkPixbuf *m_pixbuf; - - int m_width; - int m_height; - - public: JPEGLoadMemory(string nodeName, ParameterSet params) ! : BufferedNode(nodeName, params), m_pixbuf(NULL) { //input(s) --- 51,58 ---- int m_imageID; public: JPEGLoadMemory(string nodeName, ParameterSet params) ! : BufferedNode(nodeName, params) { //input(s) *************** *** 80,118 **** m_imageID = addOutput("IMAGE"); - //parameters(s) - m_width = dereference_cast<int>(parameters.get("IMAGE_WIDTH")); - m_height = dereference_cast<int>(parameters.get("IMAGE_HEIGHT")); - - g_type_init(); - } Image* create_image_from_data(String &image_data) { ! Image* output_image = NULL; ! ! GdkPixbufLoader* loader = gdk_pixbuf_loader_new_with_type("jpeg",NULL); ! gdk_pixbuf_loader_set_size(loader,m_width,m_height); ! gdk_pixbuf_loader_write(loader,(const guchar*) image_data.c_str(),image_data.size(),NULL); ! ! //close pixbuf loader, no more write ! gdk_pixbuf_loader_close(loader,NULL); ! ! //get pixbuf ! GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); ! ! if (pixbuf) { ! ! int num_channels = gdk_pixbuf_get_n_channels(pixbuf); ! unsigned char* pixbuf_ptr = gdk_pixbuf_get_pixels(pixbuf); ! output_image = Image::alloc(m_width,m_height,num_channels); ! memcpy(output_image->get_data(),gdk_pixbuf_get_pixels(pixbuf),m_width * m_height * num_channels); ! ! } ! ! g_object_unref(loader); - //delete pixbuf loader & pixbuf ? return output_image; } --- 63,74 ---- m_imageID = addOutput("IMAGE"); } Image* create_image_from_data(String &image_data) { ! Image* output_image = new Image; ! output_image->jpeg_decompress((unsigned char*) image_data.c_str(), image_data.size()); return output_image; } Index: HoughTransform.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Vision/src/HoughTransform.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** HoughTransform.cc 20 Jan 2003 20:21:52 -0000 1.3 --- HoughTransform.cc 13 Aug 2004 16:26:41 -0000 1.4 *************** *** 52,65 **** * @description Apply a hough transform on image * - * @parameter_name WIDTH - * @parameter_type int - * @parameter_value 320 - * @parameter_description Image Width - * - * @parameter_name HEIGHT - * @parameter_type int - * @parameter_value 240 - * @parameter_description Image Height - * * @input_name MAGNITUDEMAP * @input_type IMAGE --- 52,55 ---- *************** *** 111,123 **** m_imageoutid = addOutput("Transform"); - m_width = dereference_cast<int>(parameters.get("WIDTH")); - m_height = dereference_cast<int>(parameters.get("HEIGHT")); - - m_centerx = m_width / 2; - m_centery = m_height / 2; - - // distance maximale d'un point au centre - m_rmax = (int)(sqrt((float) (m_width * m_width + m_height * m_height) ) / 2.0); - // Création d'une table de sinus et cosinus, pour accélérer le traitement par la suite for (int omega = 0; omega < 360; omega++) --- 101,104 ---- *************** *** 131,136 **** void calculate(int output_id, int count, Buffer &out) { ! int angle = (int)object_cast<Int>(getInput(m_angleid,count)); ! int absangleprec = (int)object_cast<Int>(getInput(m_absangleprecid,count)); assert (absangleprec <= 90); --- 112,131 ---- void calculate(int output_id, int count, Buffer &out) { ! ! //get all inputs ! Image &input_image = object_cast<Image>(getInput(m_imageinid,count)); ! const greyscale * data = (greyscale *)input_image.get_data(); ! int angle = dereference_cast<int>(getInput(m_angleid,count)); ! int absangleprec = dereference_cast<int>(getInput(m_absangleprecid,count)); ! ! //initialize image data ! m_width = input_image.get_width(); ! m_height = input_image.get_height(); ! ! m_centerx = m_width / 2; ! m_centery = m_height / 2; ! ! // distance maximale d'un point au centre ! m_rmax = (int)(sqrt((float) (m_width * m_width + m_height * m_height) ) / 2.0); assert (absangleprec <= 90); *************** *** 141,147 **** int omegamax = angle + absangleprec; ! Image &input_image = object_cast<Image>(getInput(m_imageinid,count)); ! const greyscale * data = (greyscale *)input_image.get_data(); ! int omegawidth = omegamax - omegamin; Image * hough = Image::alloc(omegawidth, m_rmax, 1); --- 136,140 ---- int omegamax = angle + absangleprec; ! int omegawidth = omegamax - omegamin; Image * hough = Image::alloc(omegawidth, m_rmax, 1); Index: SymbolExtractor.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Vision/src/SymbolExtractor.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SymbolExtractor.cc 27 Jul 2004 20:32:34 -0000 1.2 --- SymbolExtractor.cc 13 Aug 2004 16:26:41 -0000 1.3 *************** *** 33,65 **** * @category RobotFlow:Vision * @description No description available ! * @parameter_name CHANNEL * @parameter_type int * @parameter_value 0 * @parameter_description Channel from which to extract the symbol ! ! * @parameter_name WIDTH ! * @parameter_type int ! * @parameter_value 320 ! * @parameter_description Width of the image (in pixels) ! ! * @parameter_name HEIGHT ! * @parameter_type int ! * @parameter_value 240 ! * @parameter_description Height of the image (in pixels) ! ! * @parameter_name DEPTH ! * @parameter_type int ! * @parameter_value 2 ! * @parameter_description Depth of the image (in bytes per pixel) ! * @input_name DATA * @input_description Extracted components data * @input_type ComponentsData ! * @input_name INDEX * @input_description Index of the symbol to extract * @input_type int ! * @output_name SYMBOL * @output_type CRect --- 33,50 ---- * @category RobotFlow:Vision * @description No description available ! * * @parameter_name CHANNEL * @parameter_type int * @parameter_value 0 * @parameter_description Channel from which to extract the symbol ! * * @input_name DATA * @input_description Extracted components data * @input_type ComponentsData ! * * @input_name INDEX * @input_description Index of the symbol to extract * @input_type int ! * * @output_name SYMBOL * @output_type CRect *************** *** 81,88 **** int m_width; int m_height; ! int m_depth; ! int m_channel; ! ! ObjectRef m_symbol; public: --- 66,72 ---- int m_width; int m_height; ! int m_channel; ! ! ObjectRef m_symbol; public: *************** *** 102,109 **** //parameters ! m_width = dereference_cast<int>(parameters.get("WIDTH")); ! m_height = dereference_cast<int>(parameters.get("HEIGHT")); ! m_depth = dereference_cast<int>(parameters.get("DEPTH")); ! m_channel = dereference_cast<int>(parameters.get("CHANNEL")); m_symbol = nilObject; } --- 86,91 ---- //parameters ! m_channel = dereference_cast<int>(parameters.get("CHANNEL")); ! m_symbol = nilObject; } *************** *** 118,121 **** --- 100,107 ---- ComponentsData &inData = object_cast<ComponentsData>(inputValue); + + m_width = inData.getWidth(); + m_height = inData.getHeight(); + int index = dereference_cast<int>(indexRef); Index: ComponentsViewer.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Vision/src/ComponentsViewer.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ComponentsViewer.cc 27 Jul 2004 20:32:34 -0000 1.3 --- ComponentsViewer.cc 13 Aug 2004 16:26:41 -0000 1.4 *************** *** 28,63 **** /*Node ! * @name ComponentsViewer * @category RobotFlow:Vision * @description No description available ! ! * @parameter_name WIDTH ! * @parameter_type int ! * @parameter_value 320 ! * @parameter_description Width of the image (in pixels) ! ! * @parameter_name HEIGHT ! * @parameter_type int ! * @parameter_value 240 ! * @parameter_description Height of the image (in pixels) ! ! * @parameter_name DEPTH ! * @parameter_type int ! * @parameter_value 2 ! * @parameter_description Depth of the image (in bytes per pixel) ! * @input_name LOOKUP * @input_type ColorLookup * @input_description Color Lookup Table to display components ! * @input_name DATA * @input_description Extracted components data * @input_type ComponentsData ! * @output_name IMAGE * @output_type Image * @output_description Random Image ! END*/ --- 28,48 ---- /*Node ! * * @name ComponentsViewer * @category RobotFlow:Vision * @description No description available ! * * @input_name LOOKUP * @input_type ColorLookup * @input_description Color Lookup Table to display components ! * * @input_name DATA * @input_description Extracted components data * @input_type ComponentsData ! * * @output_name IMAGE * @output_type Image * @output_description Random Image ! * END*/ *************** *** 92,102 **** imageID = addOutput("IMAGE"); - //parameters - m_width = dereference_cast<int>(parameters.get("WIDTH")); - m_height = dereference_cast<int>(parameters.get("HEIGHT")); - m_depth = dereference_cast<int>(parameters.get("DEPTH")); - - //allocating memory for image - m_image = ObjectRef(Image::alloc(m_width,m_height,m_depth)); } --- 77,80 ---- *************** *** 107,110 **** --- 85,96 ---- ComponentsData &my_data = object_cast<ComponentsData>(inputValue); + //get image parameters + m_width = my_data.getWidth(); + m_height = my_data.getHeight(); + m_depth = 2; + + //allocating memory for image + m_image = ObjectRef(Image::alloc(m_width,m_height,2)); + get_average_channel_value(count); Index: InverseHough.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Vision/src/InverseHough.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** InverseHough.cc 3 Jun 2002 19:03:23 -0000 1.2 --- InverseHough.cc 13 Aug 2004 16:26:41 -0000 1.3 *************** *** 45,58 **** * @description Reverts a hough transform * - * @parameter_name WIDTH - * @parameter_type int - * @parameter_value 320 - * @parameter_description Image Width - * - * @parameter_name HEIGHT - * @parameter_type int - * @parameter_value 240 - * @parameter_description Image Height - * * @input_name AbsAnglePrecision * @input_type int --- 45,48 ---- *************** *** 81,89 **** int m_linearrayid; int m_angleid; ! int m_absangleprecid; ! ! int m_width; ! int m_height; ! int m_centerx, m_centery, m_rmax; --- 71,75 ---- int m_linearrayid; int m_angleid; ! int m_absangleprecid; int m_centerx, m_centery, m_rmax; Index: Scale.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Vision/src/Scale.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Scale.cc 27 Jul 2004 20:32:34 -0000 1.2 --- Scale.cc 13 Aug 2004 16:26:41 -0000 1.3 *************** *** 80,84 **** m_width = dereference_cast<int>(parameters.get("WIDTH")); m_height = dereference_cast<int>(parameters.get("HEIGHT")); ! m_debug = dereference_cast<int>(parameters.get("DEBUG")); } --- 80,84 ---- m_width = dereference_cast<int>(parameters.get("WIDTH")); m_height = dereference_cast<int>(parameters.get("HEIGHT")); ! m_debug = dereference_cast<int>(parameters.get("DEBUG")); } *************** *** 100,112 **** for (int i = 0; i < m_height; i++) { ! for (int j = 0; j < m_width; j++) { ! if ((*my_vect)[pos++] > 0) { ! cerr<<(*my_vect)[pos -1]<<" "; ! } ! else { ! cerr<<" "; ! } ! } ! cerr<<endl; } } --- 100,112 ---- for (int i = 0; i < m_height; i++) { ! for (int j = 0; j < m_width; j++) { ! if ((*my_vect)[pos++] > 0) { ! cerr<<(*my_vect)[pos -1]<<" "; ! } ! else { ! cerr<<" "; ! } ! } ! cerr<<endl; } } Index: SymbolTracker.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Vision/src/SymbolTracker.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SymbolTracker.cc 6 Aug 2004 13:40:01 -0000 1.2 --- SymbolTracker.cc 13 Aug 2004 16:26:41 -0000 1.3 *************** *** 40,53 **** * @parameter_description The color number being tracked. * - * @parameter_name IMAGE_WIDTH - * @parameter_type int - * @parameter_value 320 - * @parameter_description The width of the image. - * - * @parameter_name IMAGE_HEIGHT - * @parameter_type int - * @parameter_value 240 - * @parameter_description The height of the image. - * * @input_name COMPONENTS * @input_type ComponentsData --- 40,43 ---- *************** *** 122,127 **** boundaryID = addOutput("BOUNDARY"); - m_width = dereference_cast<int>(parameters.get("IMAGE_WIDTH")); - m_height = dereference_cast<int>(parameters.get("IMAGE_HEIGHT")); m_foreground_color = dereference_cast<int>(parameters.get("FOREGROUND_COLOR_ID")); m_background_color = dereference_cast<int>(parameters.get("BACKGROUND_COLOR_ID")); --- 112,115 ---- *************** *** 143,146 **** --- 131,137 ---- ComponentsData &cData = object_cast<ComponentsData>(getInput(componentsID,count)); + m_width = cData.getWidth(); + m_height = cData.getHeight(); + //getting probable symbols list<pair<CRect*, CRect*> > symbol_list; Index: Image.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Vision/src/Image.cc,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Image.cc 27 Jul 2004 20:32:34 -0000 1.14 --- Image.cc 13 Aug 2004 16:26:41 -0000 1.15 *************** *** 532,538 **** void Image::save_jpeg(const std::string &jpegfile, int quality) { ! unsigned char buffer[320 * 240 * 3]; ! int size = jpeg_compress(buffer,320 * 240 * 3,quality); ofstream outfile(jpegfile.c_str(),ios::binary); --- 532,538 ---- void Image::save_jpeg(const std::string &jpegfile, int quality) { ! unsigned char buffer[m_width * m_height * 3]; ! int size = jpeg_compress(buffer,m_width * m_height * 3,quality); ofstream outfile(jpegfile.c_str(),ios::binary); Index: ColorTracker.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Vision/src/ColorTracker.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ColorTracker.cc 27 Jul 2004 20:32:34 -0000 1.5 --- ColorTracker.cc 13 Aug 2004 16:26:41 -0000 1.6 *************** *** 31,57 **** * @category RobotFlow:Vision * @description No description available ! * @input_name COLOR_ID * @input_type int * @input_description The color number being tracked. ! ! * @parameter_name IMAGE_WIDTH ! * @parameter_type int ! * @parameter_value 320 ! * @parameter_description The width of the image. ! ! * @parameter_name IMAGE_HEIGHT ! * @parameter_type int ! * @parameter_value 240 ! * @parameter_description The height of the image. ! * @input_name COMPONENTS * @input_type ComponentsData * @input_description The components from the image. ! * @output_name DELTA_X * @output_type float * @output_description The difference between the center of the image ant the biggest blob (x). ! * @output_name DELTA_Y * @output_type float --- 31,47 ---- * @category RobotFlow:Vision * @description No description available ! * * @input_name COLOR_ID * @input_type int * @input_description The color number being tracked. ! * * @input_name COMPONENTS * @input_type ComponentsData * @input_description The components from the image. ! * * @output_name DELTA_X * @output_type float * @output_description The difference between the center of the image ant the biggest blob (x). ! * * @output_name DELTA_Y * @output_type float *************** *** 118,124 **** boundaryID = addOutput("BOUNDARY"); ! m_width = dereference_cast<int>(parameters.get("IMAGE_WIDTH")); ! m_height = dereference_cast<int>(parameters.get("IMAGE_HEIGHT")); ! // Use to calculate the mean of width of the beacon m_pXMinCell = new int [m_height]; --- 108,112 ---- boundaryID = addOutput("BOUNDARY"); ! // Use to calculate the mean of width of the beacon m_pXMinCell = new int [m_height]; *************** *** 148,153 **** void calculate(int output_id, int count, Buffer &out) { ! ! m_color = dereference_cast<int>(getInput(colorID,count)); --- 136,140 ---- void calculate(int output_id, int count, Buffer &out) { ! m_color = dereference_cast<int>(getInput(colorID,count)); *************** *** 160,163 **** --- 147,156 ---- ComponentsData &cData = object_cast<ComponentsData>(getInput(componentsID,count)); + //update image width from components data + m_width = cData.getWidth(); + m_height = cData.getHeight(); + + cerr<<"Colortracker : "<<m_width <<" " <<m_height<<endl; + list<CRect*> &my_list = cData.get_color_components(m_color); Index: MultiColorTracker.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Vision/src/MultiColorTracker.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MultiColorTracker.cc 10 Dec 2003 20:05:45 -0000 1.6 --- MultiColorTracker.cc 13 Aug 2004 16:26:41 -0000 1.7 *************** *** 70,82 **** * @output_description number of color blobs processed * - * @parameter_name IMAGE_WIDTH - * @parameter_type int - * @parameter_value 320 - * @parameter_description Width of the image - * - * @parameter_name IMAGE_HEIGHT - * @parameter_type int - * @parameter_value 240 - * @parameter_description Height of the image * END*/ --- 70,73 ---- *************** *** 121,130 **** m_heightID = addOutput("HEIGHT"); m_boundaryID = addOutput("BOUNDARY"); ! m_nbBlobsID = addOutput("NB_BLOBS"); ! ! ! m_width = dereference_cast<int>(parameters.get("IMAGE_WIDTH")); ! m_height = dereference_cast<int>(parameters.get("IMAGE_HEIGHT")); ! } --- 112,116 ---- m_heightID = addOutput("HEIGHT"); m_boundaryID = addOutput("BOUNDARY"); ! m_nbBlobsID = addOutput("NB_BLOBS"); } *************** *** 141,145 **** RCPtr<Int> ColorValue = getInput(m_colorID,count); RCPtr<ComponentsData> ComponentsValue = getInput(m_componentsID,count); ! //getting color (int) int color = ColorValue->val(); --- 127,134 ---- RCPtr<Int> ColorValue = getInput(m_colorID,count); RCPtr<ComponentsData> ComponentsValue = getInput(m_componentsID,count); ! ! m_width = ComponentsValue->getWidth(); ! m_height = ComponentsValue->getHeight(); ! //getting color (int) int color = ColorValue->val(); Index: Posterize.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Vision/src/Posterize.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Posterize.cc 27 Jul 2004 20:32:34 -0000 1.2 --- Posterize.cc 13 Aug 2004 16:26:41 -0000 1.3 *************** *** 32,45 **** * @description Converts an image to solid color values * - * @parameter_name WIDTH - * @parameter_type int - * @parameter_value 320 - * @parameter_description Width of the image. - * - * @parameter_name HEIGHT - * @parameter_type int - * @parameter_value 240 - * @parameter_description Height of the image. - * * @parameter_name THRESHOLD * @parameter_type float --- 32,35 ---- *************** *** 85,93 **** //parameters - mWidth = dereference_cast<int>(parameters.get("WIDTH")); - mHeight = dereference_cast<int>(parameters.get("HEIGHT")); mThreshold = dereference_cast<float>(parameters.get("THRESHOLD")); - mpImage = Image::alloc(mWidth,mHeight,2); } --- 75,80 ---- *************** *** 96,99 **** --- 83,91 ---- // Acquiring image Image &image = object_cast<Image>(getInput(mImageInID,count)); + + mWidth = image.get_width(); + mHeight = image.get_height(); + mpImage = Image::alloc(mWidth,mHeight,2); + unsigned short *pSourceImage = (unsigned short*) image.get_data(); unsigned short *pDestinationImage = (unsigned short*)mpImage->get_data(); |