[openrtm-commit:01129] r99 - branches/newCMakeForVC2010/ImageProcessing/opencv/components/Binarization/src
openrtm @ openrtm.org
openrtm @ openrtm.org
2013年 9月 26日 (木) 17:22:12 JST
Author: kawauchi
Date: 2013-09-26 17:22:12 +0900 (Thu, 26 Sep 2013)
New Revision: 99
Modified:
branches/newCMakeForVC2010/ImageProcessing/opencv/components/Binarization/src/Binarization.cpp
Log:
Binarization component: Align the indentation, and converted to the UTF-8 character code. refs #2704
Modified: branches/newCMakeForVC2010/ImageProcessing/opencv/components/Binarization/src/Binarization.cpp
===================================================================
--- branches/newCMakeForVC2010/ImageProcessing/opencv/components/Binarization/src/Binarization.cpp 2013-09-26 04:39:49 UTC (rev 98)
+++ branches/newCMakeForVC2010/ImageProcessing/opencv/components/Binarization/src/Binarization.cpp 2013-09-26 08:22:12 UTC (rev 99)
@@ -9,7 +9,7 @@
#include "Binarization.h"
-#define THRESHOLD_MAX_VALUE 255 // 2l»ÌÛÉgp·éÅål
+#define THRESHOLD_MAX_VALUE 255 // 2å¤åã®éã«ä½¿ç¨ããæ大å¤
// Module specification
// <rtc-template block="module_spec">
@@ -57,7 +57,7 @@
{
}
-IplImage *sourceImage; // ³æpIplImage
+IplImage *sourceImage; // å
ç»åç¨IplImage
RTC::ReturnCode_t Binarization::onInitialize()
{
@@ -109,7 +109,7 @@
RTC::ReturnCode_t Binarization::onActivated(RTC::UniqueId ec_id)
{
- // C[WpÌmÛ
+ // ã¤ã¡ã¼ã¸ç¨ã¡ã¢ãªã®ç¢ºä¿
m_image_buff = NULL;
m_image_binary = NULL;
m_image_gray = NULL;
@@ -139,70 +139,69 @@
RTC::ReturnCode_t Binarization::onExecute(RTC::UniqueId ec_id)
{
- // Common CV process
- // Vµ¢f[^Ì`FbN
- if (m_image_origIn.isNew())
+ // Common CV process
+ // æ°ãããã¼ã¿ã®ãã§ãã¯
+ if (m_image_origIn.isNew())
+ {
+ // InPortãã¼ã¿ã®èªã¿è¾¼ã¿
+ m_image_origIn.read();
+
+ // ãµã¤ãºãå¤ãã£ãã¨ãã ãåçæãã
+ if(m_in_height != m_image_orig.height || m_in_width != m_image_orig.width)
{
- // InPortf[^ÌÇÝÝ
- m_image_origIn.read();
+ printf("[onExecute] Size of input image is not match!\n");
- // TCYªÏíÁ½Æ«¾¯Ä¶¬·é
- if(m_in_height != m_image_orig.height || m_in_width != m_image_orig.width)
- {
- printf("[onExecute] Size of input image is not match!\n");
+ m_in_height = m_image_orig.height;
+ m_in_width = m_image_orig.width;
- m_in_height = m_image_orig.height;
- m_in_width = m_image_orig.width;
-
- if(m_image_buff != NULL)
- cvReleaseImage(&m_image_buff);
- if(m_image_binary != NULL)
- cvReleaseImage(&m_image_binary);
- if(m_image_gray != NULL)
- cvReleaseImage(&m_image_gray);
- if(m_image_dest != NULL)
- cvReleaseImage(&m_image_dest);
+ if(m_image_buff != NULL)
+ cvReleaseImage(&m_image_buff);
+ if(m_image_binary != NULL)
+ cvReleaseImage(&m_image_binary);
+ if(m_image_gray != NULL)
+ cvReleaseImage(&m_image_gray);
+ if(m_image_dest != NULL)
+ cvReleaseImage(&m_image_dest);
+ // ãµã¤ãºå¤æã®ããTempã¡ã¢ãªã¼ããããã
+ m_image_buff = cvCreateImage(cvSize(m_in_width, m_in_height), IPL_DEPTH_8U, 3);
+ m_image_binary = cvCreateImage(cvSize(m_in_width, m_in_height), IPL_DEPTH_8U, 1);
+ m_image_gray = cvCreateImage(cvSize(m_in_width, m_in_height), IPL_DEPTH_8U, 1);
+ m_image_dest = cvCreateImage(cvSize(m_in_width, m_in_height), IPL_DEPTH_8U, 3);
+ }
- // TCYϷ̽ßTemp[ð梷é
- m_image_buff = cvCreateImage(cvSize(m_in_width, m_in_height), IPL_DEPTH_8U, 3);
- m_image_binary = cvCreateImage(cvSize(m_in_width, m_in_height), IPL_DEPTH_8U, 1);
- m_image_gray = cvCreateImage(cvSize(m_in_width, m_in_height), IPL_DEPTH_8U, 1);
- m_image_dest = cvCreateImage(cvSize(m_in_width, m_in_height), IPL_DEPTH_8U, 3);
- }
+ // InPortã®ç»åãã¼ã¿ãIplImageã®imageDataã«ã³ãã¼
+ memcpy(m_image_buff->imageData,(void *)&(m_image_orig.pixels[0]),m_image_orig.pixels.length());
- // InPortÌæf[^ðIplImageÌimageDataÉRs[
- memcpy(m_image_buff->imageData,(void *)&(m_image_orig.pixels[0]),m_image_orig.pixels.length());
+ // Anternative process
+ // BGRããã°ã¬ã¼ã¹ã±ã¼ã«ã«å¤æãã
+ cvCvtColor( m_image_buff, m_image_gray, CV_BGR2GRAY );
- // Anternative process
- // BGR©çO[XP[ÉÏ··é
- cvCvtColor( m_image_buff, m_image_gray, CV_BGR2GRAY );
+ // ã°ã¬ã¼ã¹ã±ã¼ã«ãã2å¤ã«å¤æãã
+ cvThreshold( m_image_gray, m_image_binary, m_nThresholdLv, THRESHOLD_MAX_VALUE, CV_THRESH_BINARY );
- // O[XP[©ç2lÉÏ··é
- cvThreshold( m_image_gray, m_image_binary, m_nThresholdLv, THRESHOLD_MAX_VALUE, CV_THRESH_BINARY );
+ // Convert to 3channel image
+ cvMerge(m_image_binary, m_image_binary, m_image_binary, NULL, m_image_dest);
- // Convert to 3channel image
- cvMerge(m_image_binary, m_image_binary, m_image_binary, NULL, m_image_dest);
+ // Common process
+ // ç»åãã¼ã¿ã®ãµã¤ãºåå¾
+ int len = m_image_dest->nChannels * m_image_dest->width * m_image_dest->height;
+
+ // ç»é¢ã®ãµã¤ãºæ
å ±ãå
¥ãã
+ m_image_output.pixels.length(len);
+ m_image_output.width = m_image_dest->width;
+ m_image_output.height = m_image_dest->height;
- // Common process
- // æf[^ÌTCYæ¾
- int len = m_image_dest->nChannels * m_image_dest->width * m_image_dest->height;
-
- // æÊÌTCYîñðüêé
- m_image_output.pixels.length(len);
- m_image_output.width = m_image_dest->width;
- m_image_output.height = m_image_dest->height;
+ // å転ããç»åãã¼ã¿ãOutPortã«ã³ãã¼
+ memcpy((void *)&(m_image_output.pixels[0]), m_image_dest->imageData,len);
- // ½]µ½æf[^ðOutPortÉRs[
- memcpy((void *)&(m_image_output.pixels[0]), m_image_dest->imageData,len);
+ // å転ããç»åãã¼ã¿ãOutPortããåºåããã
+ m_image_outputOut.write();
- // ½]µ½æf[^ðOutPort©çoÍ·éB
- m_image_outputOut.write();
+ //cvWaitKey( 0 );
+ }
- //cvWaitKey( 0 );
- }
-
- return RTC::RTC_OK;
+ return RTC::RTC_OK;
}
/*
More information about the openrtm-commit
mailing list