From: Dominic L. <ma...@us...> - 2004-06-13 20:06:04
|
Update of /cvsroot/robotflow/RobotFlow/Devices/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23670/src Modified Files: V4L2Capture.cc Log Message: should now be able to capture 24bpp images from capture card Index: V4L2Capture.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Devices/src/V4L2Capture.cc,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** V4L2Capture.cc 7 Apr 2004 13:12:10 -0000 1.11 --- V4L2Capture.cc 13 Jun 2004 20:05:55 -0000 1.12 *************** *** 49,52 **** --- 49,57 ---- * @parameter_description Height of the image. * + * @parameter_name FORMAT + * @parameter_type string + * @parameter_value RGB15 + * @parameter_description Format of image to be captured (RGB15, RGB24) + * * @parameter_name BRIGHTNESS * @parameter_type int *************** *** 95,98 **** --- 100,104 ---- int m_width; int m_height; + int m_pixelsize; String m_device; capture m_captureDevice; *************** *** 114,128 **** m_width = dereference_cast<int>(parameters.get("WIDTH")); m_height = dereference_cast<int>(parameters.get("HEIGHT")); - m_autoSoftBrightness = dereference_cast<bool>(parameters.get("AUTO_SOFT_BRIGHTNESS")); - - //initialize(char *device,int nwidth,int nheight,int nfmt); - if (!m_captureDevice.initialize(const_cast<char*>(m_device.c_str()), - m_width, - m_height, - V4L2_PIX_FMT_RGB555)) { ! throw new GeneralException(string("Unable to initialize V4L2 device : ") + m_device, __FILE__,__LINE__); } if (!m_captureDevice.set_contrast(m_contrast)) { --- 120,142 ---- m_width = dereference_cast<int>(parameters.get("WIDTH")); m_height = dereference_cast<int>(parameters.get("HEIGHT")); ! string format = object_cast<String>(parameters.get("FORMAT")); ! ! if (format == "RGB15") { ! m_pixelsize = 2; ! if (!m_captureDevice.initialize(m_device.c_str(),m_width,m_height,V4L2_PIX_FMT_RGB555)) { ! throw new GeneralException(string("Unable to initialize V4L2 device : ") + m_device, __FILE__,__LINE__); ! } ! } ! else if (format == "RGB24") { ! m_pixelsize = 3; ! if (!m_captureDevice.initialize(m_device.c_str(),m_width,m_height,V4L2_PIX_FMT_RGB24)) { ! throw new GeneralException(string("Unable to initialize V4L2 device : ") + m_device, __FILE__,__LINE__); ! } ! } else { ! throw new GeneralException("Image format must be RGB15 or RGB24 format",__FILE__,__LINE__); } + m_autoSoftBrightness = dereference_cast<bool>(parameters.get("AUTO_SOFT_BRIGHTNESS")); if (!m_captureDevice.set_contrast(m_contrast)) { *************** *** 150,154 **** virtual void calculate(int output_id, int count, Buffer &out) { ! Image *image = Image::alloc(m_width,m_height,2); //16 bits image // read(m_captureDevice.getFD(),image->get_data(),m_width * m_height * 2); --- 164,168 ---- virtual void calculate(int output_id, int count, Buffer &out) { ! Image *image = Image::alloc(m_width,m_height,m_pixelsize); //16 bits image // read(m_captureDevice.getFD(),image->get_data(),m_width * m_height * 2); *************** *** 156,160 **** //capture & cpy data ! memcpy(image->get_data(),m_captureDevice.captureFrame(index,field),m_width * m_height * 2); if (m_autoSoftBrightness) { --- 170,174 ---- //capture & cpy data ! memcpy(image->get_data(),m_captureDevice.captureFrame(index,field),m_width * m_height * m_pixelsize); if (m_autoSoftBrightness) { *************** *** 250,254 **** } ! bool capture::initialize(char *device,int nwidth,int nheight,int nfmt) { struct v4l2_requestbuffers req; --- 264,268 ---- } ! bool capture::initialize(const char *device,int nwidth,int nheight,int nfmt) { struct v4l2_requestbuffers req; |