[openrtm-commit:02384] r182 - in trunk/ImageProcessing/opencv/components: Affine/include/Affine Affine/src BackGroundSubtractionSimple/include/BackGroundSubtractionSimple BackGroundSubtractionSimple/src Binarization/include/Binarization Binarization/src CameraViewer/include/CameraViewer CameraViewer/src Chromakey/include/Chromakey Chromakey/src Dilationerosion/src Edge/include/Edge Edge/src Findcontour/include/Findcontour Findcontour/src Flip/include/Flip Flip/src Histogram/include/Histogram Histogram/src Houghline/include/Hough Houghline/src ObjectTracking/src Perspective/include/Perspective Perspective/src Rotate/include/Rotate Rotate/src Scale/include/Scale Scale/src Sepia/include/Sepia Sepia/src SubStractCaptureImage/include/SubStractCaptureImage SubStractCaptureImage/src Template/include/Template Template/src Translate/include/Translate Translate/src
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 2月 6日 (月) 15:57:53 JST
Author: miyamoto
Date: 2017-02-06 15:57:53 +0900 (Mon, 06 Feb 2017)
New Revision: 182
Modified:
trunk/ImageProcessing/opencv/components/Affine/include/Affine/Affine.h
trunk/ImageProcessing/opencv/components/Affine/src/Affine.cpp
trunk/ImageProcessing/opencv/components/BackGroundSubtractionSimple/include/BackGroundSubtractionSimple/BackGroundSubtractionSimple.h
trunk/ImageProcessing/opencv/components/BackGroundSubtractionSimple/src/BackGroundSubtractionSimple.cpp
trunk/ImageProcessing/opencv/components/Binarization/include/Binarization/Binarization.h
trunk/ImageProcessing/opencv/components/Binarization/src/Binarization.cpp
trunk/ImageProcessing/opencv/components/CameraViewer/include/CameraViewer/CameraViewer.h
trunk/ImageProcessing/opencv/components/CameraViewer/src/CameraViewer.cpp
trunk/ImageProcessing/opencv/components/Chromakey/include/Chromakey/Chromakey.h
trunk/ImageProcessing/opencv/components/Chromakey/src/Chromakey.cpp
trunk/ImageProcessing/opencv/components/Dilationerosion/src/DilationErosion.cpp
trunk/ImageProcessing/opencv/components/Edge/include/Edge/Edge.h
trunk/ImageProcessing/opencv/components/Edge/src/Edge.cpp
trunk/ImageProcessing/opencv/components/Findcontour/include/Findcontour/Findcontour.h
trunk/ImageProcessing/opencv/components/Findcontour/src/Findcontour.cpp
trunk/ImageProcessing/opencv/components/Flip/include/Flip/Flip.h
trunk/ImageProcessing/opencv/components/Flip/src/Flip.cpp
trunk/ImageProcessing/opencv/components/Histogram/include/Histogram/Histogram.h
trunk/ImageProcessing/opencv/components/Histogram/src/Histogram.cpp
trunk/ImageProcessing/opencv/components/Houghline/include/Hough/Hough.h
trunk/ImageProcessing/opencv/components/Houghline/src/Hough.cpp
trunk/ImageProcessing/opencv/components/ObjectTracking/src/ObjectTracking.cpp
trunk/ImageProcessing/opencv/components/Perspective/include/Perspective/Perspective.h
trunk/ImageProcessing/opencv/components/Perspective/src/Perspective.cpp
trunk/ImageProcessing/opencv/components/Rotate/include/Rotate/Rotate.h
trunk/ImageProcessing/opencv/components/Rotate/src/Rotate.cpp
trunk/ImageProcessing/opencv/components/Scale/include/Scale/Scale.h
trunk/ImageProcessing/opencv/components/Scale/src/Scale.cpp
trunk/ImageProcessing/opencv/components/Sepia/include/Sepia/Sepia.h
trunk/ImageProcessing/opencv/components/Sepia/src/Sepia.cpp
trunk/ImageProcessing/opencv/components/SubStractCaptureImage/include/SubStractCaptureImage/SubStractCaptureImage.h
trunk/ImageProcessing/opencv/components/SubStractCaptureImage/src/SubStractCaptureImage.cpp
trunk/ImageProcessing/opencv/components/Template/include/Template/Template.h
trunk/ImageProcessing/opencv/components/Template/src/Template.cpp
trunk/ImageProcessing/opencv/components/Translate/include/Translate/Translate.h
trunk/ImageProcessing/opencv/components/Translate/src/Translate.cpp
Log:
[bugfix] bug fix.
Modified: trunk/ImageProcessing/opencv/components/Affine/include/Affine/Affine.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Affine/include/Affine/Affine.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Affine/include/Affine/Affine.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -281,11 +281,11 @@
- cv::Mat m_image_buff; // Original Image
- cv::Mat m_image_dest; // 結果出力用IplImage
+ //cv::Mat m_image_buff; // Original Image
+ //cv::Mat m_image_dest; // 結果出力用IplImage
- int m_in_height; // 入力イメージのHeight
- int m_in_width; // 入力イメージのWidth
+ //int m_in_height; // 入力イメージのHeight
+ //int m_in_width; // 入力イメージのWidth
/* Configuration値が有効かをチェック */
bool isConfigurationValidated();
Modified: trunk/ImageProcessing/opencv/components/Affine/src/Affine.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Affine/src/Affine.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Affine/src/Affine.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -79,9 +79,7 @@
// <rtc-template block="initializer">
: RTC::DataFlowComponentBase(manager),
m_image_origIn("original_image", m_image_orig),
- m_image_affineOut("affined_image", m_image_affine),
- m_in_height(0),
- m_in_width(0)
+ m_image_affineOut("affined_image", m_image_affine)
// </rtc-template>
{
@@ -146,10 +144,7 @@
RTC::ReturnCode_t Affine::onActivated(RTC::UniqueId ec_id)
{
- /* イメージ用メモリの確保 */
- m_in_height = 0;
- m_in_width = 0;
@@ -161,14 +156,7 @@
{
- if (!m_image_buff.empty())
- {
- m_image_buff.release();
- }
- if (!m_image_dest.empty())
- {
- m_image_dest.release();
- }
+
return RTC::RTC_OK;
@@ -183,26 +171,13 @@
{
/* InPortデータの読み込み */
m_image_origIn.read();
+
- /* サイズが変わったときだけ再生成する */
- 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;
-
-
-
- /* サイズ変換のためTempメモリーを用意する */
- m_image_buff.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- m_image_dest.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
-
- }
-
+ cv::Mat m_image_buff(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0]));
/* InPortの画像データをIplImageのimageDataにコピー */
- memcpy(m_image_buff.data, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length());
-
+ //memcpy(m_image_buff.data, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length());
+
cv::Mat_<double> m_affineMatrix(2, 3);
/* 変換後の座標を設定する */
@@ -226,7 +201,7 @@
-
+ cv::Mat m_image_dest;
/* 変換行列を反映させる */
warpAffine(m_image_buff, m_image_dest, m_affineMatrix, m_image_dest.size());
Modified: trunk/ImageProcessing/opencv/components/BackGroundSubtractionSimple/include/BackGroundSubtractionSimple/BackGroundSubtractionSimple.h
===================================================================
--- trunk/ImageProcessing/opencv/components/BackGroundSubtractionSimple/include/BackGroundSubtractionSimple/BackGroundSubtractionSimple.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/BackGroundSubtractionSimple/include/BackGroundSubtractionSimple/BackGroundSubtractionSimple.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -321,11 +321,11 @@
void labDifference( void );
void grayScaleDifference( void );
- cv::Mat m_originalImage;
+
cv::Mat m_currentImage;
cv::Mat m_backgroundImage;
cv::Mat m_resultImage;
- cv::Mat m_outputImage;
+
int m_differenceMode; /* 差分の計算モード */
int m_noiseMode; /* ノイズを除去するモード */
Modified: trunk/ImageProcessing/opencv/components/BackGroundSubtractionSimple/src/BackGroundSubtractionSimple.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/BackGroundSubtractionSimple/src/BackGroundSubtractionSimple.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/BackGroundSubtractionSimple/src/BackGroundSubtractionSimple.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -110,11 +110,7 @@
bindParameter("threshold_level", m_nThresholdLv, "20");
// </rtc-template>
- m_originalImage = NULL;
- m_currentImage = NULL;
- m_backgroundImage = NULL;
- m_resultImage = NULL;
- m_outputImage = NULL;
+
return RTC::RTC_OK;
}
@@ -157,22 +153,7 @@
{
- if (!m_originalImage.empty())
- {
- m_originalImage.release();
- }
- if (!m_currentImage.empty())
- {
- m_currentImage.release();
- }
- if (!m_resultImage.empty())
- {
- m_resultImage.release();
- }
- if (!m_outputImage.empty())
- {
- m_outputImage.release();
- }
+
if (!m_backgroundImage.empty())
{
m_backgroundImage.release();
@@ -192,15 +173,9 @@
/* イメージRead */
m_img_origIn.read();
- if (m_originalImage.empty())
- {
- m_originalImage.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
- }
- if (m_currentImage.empty())
- {
- m_currentImage.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
- }
+
+
if(m_img_orig.width != m_temp_w || m_img_orig.height != m_temp_h){
if (m_backgroundImage.empty())
{
@@ -210,19 +185,15 @@
- if (m_resultImage.empty())
- {
- m_resultImage.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC1);
- }
+
- if (m_outputImage.empty())
- {
- m_outputImage.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
- }
-
/* InPortの映像の取得 */
- memcpy(m_originalImage.data,(void *)&(m_img_orig.pixels[0]),m_img_orig.pixels.length());
+ //memcpy(m_originalImage.data,(void *)&(m_img_orig.pixels[0]),m_img_orig.pixels.length());
+ cv::Mat m_originalImage(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3, (void *)&(m_img_orig.pixels[0]));
+
m_currentImage = m_originalImage.clone();
+
+ cv::Mat m_outputImage;
/* 差の計算方法の切り替え */
if( m_differenceMode == COLOR_DIFFERENCE ){
Modified: trunk/ImageProcessing/opencv/components/Binarization/include/Binarization/Binarization.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Binarization/include/Binarization/Binarization.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Binarization/include/Binarization/Binarization.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -277,15 +277,7 @@
// <rtc-template block="private_operation">
// </rtc-template>
- int m_in_height; // 入力イメージのHeight
- int m_in_width; // 入力イメージのWidth
- cv::Mat m_image_buff; // Original Image
-
- cv::Mat m_image_gray; // Grayscale image
- cv::Mat m_image_binary; // Binary image
-
- cv::Mat m_image_dest; // 結果出力用IplImage
};
Modified: trunk/ImageProcessing/opencv/components/Binarization/src/Binarization.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Binarization/src/Binarization.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Binarization/src/Binarization.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -111,33 +111,16 @@
{
- m_in_height = 0;
- m_in_width = 0;
+
return RTC::RTC_OK;
}
RTC::ReturnCode_t Binarization::onDeactivated(RTC::UniqueId ec_id)
{
- if (!m_image_buff.empty())
- {
- m_image_buff.release();
- }
- if (!m_image_binary.empty())
- {
- m_image_binary.release();
- }
- if (!m_image_gray.empty())
- {
- m_image_gray.release();
- }
- if (!m_image_dest.empty())
- {
- m_image_dest.release();
- }
-
+
return RTC::RTC_OK;
}
@@ -151,26 +134,14 @@
/* InPortデータの読み込み */
m_image_origIn.read();
- /* サイズが変わったときだけ再生成する */
- 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;
- /* サイズ変換のためTempメモリーをよいする */
- m_image_buff.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- m_image_binary.create(cv::Size(m_in_width, m_in_height), CV_8UC1);
- m_image_gray.create(cv::Size(m_in_width, m_in_height), CV_8UC1);
- m_image_dest.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
-
-
-
- }
-
/* InPortの画像データをIplImageのimageDataにコピー */
- memcpy(m_image_buff.data,(void *)&(m_image_orig.pixels[0]),m_image_orig.pixels.length());
+ //memcpy(m_image_buff.data,(void *)&(m_image_orig.pixels[0]),m_image_orig.pixels.length());
+ cv::Mat m_image_buff(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0]));
+ cv::Mat m_image_gray; // Grayscale image
+ cv::Mat m_image_binary; // Binary image
+ cv::Mat m_image_dest; // 結果出力用IplImage
/* Anternative process */
/* BGRからグレースケールに変換する */
Modified: trunk/ImageProcessing/opencv/components/CameraViewer/include/CameraViewer/CameraViewer.h
===================================================================
--- trunk/ImageProcessing/opencv/components/CameraViewer/include/CameraViewer/CameraViewer.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/CameraViewer/include/CameraViewer/CameraViewer.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -301,13 +301,12 @@
private:
int dummy;
- cv::Mat m_orig_img;
+
int m_nOldHeight; /* CFG更新チェック用 */
int m_nOldWidth;
- int m_in_height; /* 入力イメージのHeight */
- int m_in_width; /* 入力イメージのWidth */
+
bool isCFGChanged();
//void onMouse(int nEvent, int x, int y, int nFlags, void* param);
Modified: trunk/ImageProcessing/opencv/components/CameraViewer/src/CameraViewer.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/CameraViewer/src/CameraViewer.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/CameraViewer/src/CameraViewer.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -122,9 +122,8 @@
{
- m_in_height = 0;
- m_in_width = 0;
+
/* 画像表示用ウィンドウの作成 */
cv::namedWindow("CaptureImage", CV_WINDOW_AUTOSIZE);
cv::setMouseCallback("CaptureImage", onMouse, (void*)this);
@@ -136,10 +135,7 @@
RTC::ReturnCode_t CameraViewer::onDeactivated(RTC::UniqueId ec_id)
{
- if (!m_orig_img.empty())
- {
- m_orig_img.release();
- }
+
cv::destroyWindow("CaptureImage");
@@ -175,22 +171,11 @@
return RTC::RTC_OK;
}
- /* サイズが変わったときだけ再生成する */
- if(m_in_height != (int)m_in.height || m_in_width != (int)m_in.width)
- {
- printf("[onExecute] Size of input image is not match!\n");
-
- m_in_height = m_in.height;
- m_in_width = m_in.width;
-
- /* サイズ変換のためTempメモリーを用意する */
- m_orig_img.create(cv::Size(m_in.width, m_in.height), CV_8UC3);
- }
-
/* データコピー */
- memcpy(m_orig_img.data,(void *)&(m_in.pixels[0]), m_in.pixels.length());
+ cv::Mat m_orig_img(cv::Size(m_in.width, m_in.height), CV_8UC3, (void *)&(m_in.pixels[0]));
+
/* 画像表示 */
Modified: trunk/ImageProcessing/opencv/components/Chromakey/include/Chromakey/Chromakey.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Chromakey/include/Chromakey/Chromakey.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Chromakey/include/Chromakey/Chromakey.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -304,6 +304,7 @@
// </rtc-template>
private:
+ cv::Mat m_image_BG_in; // Background Input image
// <rtc-template block="private_attribute">
// </rtc-template>
@@ -312,25 +313,9 @@
// </rtc-template>
// Configuration fileds
- int m_in_height; // 入力イメージのHeight
- int m_in_width; // 入力イメージのWidth
- int m_in2_height; // Background入力イメージのHeight
- int m_in2_width; // Background入力イメージのWidth
- cv::Mat m_image_buff; // Original Image
- cv::Mat m_image_extracted; // Extracted Image
-
- cv::Mat m_image_mask; // Mask Image
- cv::Mat m_image_inverseMask; // Inverse Mask Image
-
- cv::Mat m_image_BG_in; // Background Input image
- cv::Mat m_image_BG; // Background Converted Image(Resized to Camera Image)
- cv::Mat m_image_extractedBG; // Extracted Background Image
-
- cv::Mat m_image_destination; // 結果出力用IplImage
-
};
Modified: trunk/ImageProcessing/opencv/components/Chromakey/src/Chromakey.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Chromakey/src/Chromakey.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Chromakey/src/Chromakey.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -130,10 +130,6 @@
RTC::ReturnCode_t Chromakey::onActivated(RTC::UniqueId ec_id)
{
- m_in_height = 0;
- m_in_width = 0;
- m_in2_height = 0;
- m_in2_width = 0;
return RTC::RTC_OK;
}
@@ -141,39 +137,6 @@
RTC::ReturnCode_t Chromakey::onDeactivated(RTC::UniqueId ec_id)
{
- /* イメージ用メモリの解放 */
- if (!m_image_buff.empty())
- {
- m_image_buff.release();
- }
- if (!m_image_extracted.empty())
- {
- m_image_extracted.release();
- }
- if (!m_image_mask.empty())
- {
- m_image_mask.release();
- }
- if (!m_image_inverseMask.empty())
- {
- m_image_inverseMask.release();
- }
- if (!m_image_BG_in.empty())
- {
- m_image_BG_in.release();
- }
- if (!m_image_BG.empty())
- {
- m_image_BG.release();
- }
- if (!m_image_extractedBG.empty())
- {
- m_image_extractedBG.release();
- }
- if (!m_image_destination.empty())
- {
- m_image_destination.release();
- }
return RTC::RTC_OK;
@@ -182,6 +145,19 @@
RTC::ReturnCode_t Chromakey::onExecute(RTC::UniqueId ec_id)
{
+ cv::Mat m_image_buff; // Original Image
+
+ cv::Mat m_image_extracted; // Extracted Image
+
+ cv::Mat m_image_mask; // Mask Image
+ cv::Mat m_image_inverseMask; // Inverse Mask Image
+
+
+ cv::Mat m_image_BG; // Background Converted Image(Resized to Camera Image)
+ cv::Mat m_image_extractedBG; // Extracted Background Image
+
+ cv::Mat m_image_destination; // 結果出力用IplImage
+
// Common CV actions
// Port for Background image
if (m_image_backIn.isNew())
@@ -189,23 +165,11 @@
/* InPortデータの読み込み */
m_image_backIn.read();
- /* サイズが変わったときだけ再生成する */
- if(m_in2_height != m_image_back.height || m_in2_width != m_image_back.width)
- {
- printf("[onExecute] Size of background image is not match!\n");
+
- m_in2_height = m_image_back.height;
- m_in2_width = m_image_back.width;
-
-
-
- /* サイズ変換のためTempメモリーを用意する */
- m_image_BG_in.create(cv::Size(m_in2_width, m_in2_height), CV_8UC3);
-
- }
-
+ m_image_BG_in = cv::Mat(cv::Size(m_image_back.width, m_image_back.height), CV_8UC3, (void *)&(m_image_back.pixels[0]));
/* InPortの画像データをIplImageのimageDataにコピー */
- memcpy(m_image_BG_in.data,(void *)&(m_image_back.pixels[0]), m_image_back.pixels.length());
+ // memcpy(m_image_BG_in.data,(void *)&(m_image_back.pixels[0]), m_image_back.pixels.length());
}
/* 新しいデータのチェック */
@@ -213,67 +177,53 @@
{
m_image_originalIn.read();
- /* サイズが変わったときだけ再生成する */
- if(m_in_height != m_image_original.height || m_in_width != m_image_original.width)
- {
- printf("[onExecute] Size of input image is not match!\n");
+
+ // Resize background image to fit Camera image
+ if (!m_image_BG_in.empty())
+ {
+
+ cv::resize(m_image_BG_in, m_image_BG, cv::Size(m_image_original.width, m_image_original.height));
- m_in_height = m_image_original.height;
- m_in_width = m_image_original.width;
+ m_image_buff = cv::Mat(cv::Size(m_image_original.width, m_image_original.height), CV_8UC3, (void *)&(m_image_original.pixels[0]));
+ //memcpy(m_image_buff.data,(void *)&(m_image_original.pixels[0]),m_image_original.pixels.length());
+ // Anternative actions
+ cv::Scalar lowerValue = cv::Scalar(m_nLowerBlue, m_nLowerGreen, m_nLowerRed);
+ cv::Scalar upperValue = cv::Scalar(m_nUpperBlue + 1, m_nUpperGreen + 1, m_nUpperRed + 1);
+ /* RGB各チャンネルごとに範囲内の値以外の画素をマスクに設定する */
+ cv::inRange(m_image_buff, lowerValue, upperValue, m_image_mask);
+ /* 背景画像のうち合成する物体部分の画素値を0にする */
+ m_image_extractedBG = cv::Mat::zeros(cv::Size(m_image_original.width, m_image_original.height), CV_8UC3);
+
+ m_image_BG.copyTo(m_image_extractedBG, m_image_mask);
- m_image_buff.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- m_image_extracted.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- m_image_mask.create(cv::Size(m_in_width, m_in_height), CV_8UC1);
- m_image_inverseMask.create(cv::Size(m_in_width, m_in_height), CV_8UC1);
- m_image_BG.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- m_image_extractedBG.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- m_image_destination.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- }
- // Resize background image to fit Camera image
- if(!m_image_BG_in.empty())
- cv::resize(m_image_BG_in, m_image_BG, m_image_BG.size());
+ /* マスク画像の0と1を反転する */
+ cv::bitwise_not(m_image_mask, m_image_inverseMask);
- memcpy(m_image_buff.data,(void *)&(m_image_original.pixels[0]),m_image_original.pixels.length());
- // Anternative actions
- cv::Scalar lowerValue = cv::Scalar(m_nLowerBlue, m_nLowerGreen, m_nLowerRed);
- cv::Scalar upperValue = cv::Scalar(m_nUpperBlue + 1, m_nUpperGreen + 1, m_nUpperRed + 1);
+ /* トラックバーの条件を満たす合成物体が抽出された画像を作成 */
+ m_image_extracted = cv::Mat::zeros(cv::Size(m_image_original.width, m_image_original.height), CV_8UC3);
+
+ m_image_buff.copyTo(m_image_extracted, m_image_inverseMask);
- /* RGB各チャンネルごとに範囲内の値以外の画素をマスクに設定する */
- cv::inRange(m_image_buff, lowerValue, upperValue, m_image_mask);
- /* 背景画像のうち合成する物体部分の画素値を0にする */
+ /* 背景画像と合成物体画像の合成 */
+ cv::add(m_image_extractedBG, m_image_extracted, m_image_destination);
- m_image_extractedBG = cv::Mat::zeros(m_image_extractedBG.size(), CV_8UC3);
- m_image_extractedBG.copyTo(m_image_BG, m_image_mask);
-
+ // Prepare to out data
+ int len = m_image_destination.channels() * m_image_destination.size().width * m_image_destination.size().height;
- /* マスク画像の0と1を反転する */
- cv::bitwise_not(m_image_mask, m_image_inverseMask);
-
+ m_image_output.pixels.length(len);
+ m_image_output.width = m_image_destination.size().width;
+ m_image_output.height = m_image_destination.size().height;
+ memcpy((void *)&(m_image_output.pixels[0]), m_image_destination.data, len);
- /* トラックバーの条件を満たす合成物体が抽出された画像を作成 */
- m_image_extracted = cv::Mat::zeros(m_image_extractedBG.size(), CV_8UC3);
- m_image_extracted.copyTo(m_image_buff, m_image_inverseMask);
-
-
- /* 背景画像と合成物体画像の合成 */
- cv::add( m_image_extractedBG, m_image_extracted, m_image_destination);
-
- // Prepare to out data
- int len = m_image_destination.channels() * m_image_destination.size().width * m_image_destination.size().height;
-
- m_image_output.pixels.length(len);
- m_image_output.width = m_image_destination.size().width;
- m_image_output.height = m_image_destination.size().height;
- memcpy((void *)&(m_image_output.pixels[0]), m_image_destination.data,len);
-
- m_image_outputOut.write();
+ m_image_outputOut.write();
+ }
}
return RTC::RTC_OK;
Modified: trunk/ImageProcessing/opencv/components/Dilationerosion/src/DilationErosion.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Dilationerosion/src/DilationErosion.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Dilationerosion/src/DilationErosion.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -188,23 +188,37 @@
m_img_origIn.read();
- m_image_buff.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
- m_gray_buff.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC1);
- m_binary_buff.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC1);
- m_dilation_buff.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC1);
- m_erosion_buff.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC1);
- m_output_image_buff.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
- m_merge_Image.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
- m_dilation_image.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC1);
- m_erosion_image.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC1);
- m_dila_merge_img.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
- m_ero_merge_img.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
- m_noise_merge_img.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
+ //m_image_buff.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
+ //m_gray_buff.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC1);
+ //m_binary_buff.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC1);
+ //m_dilation_buff.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC1);
+ //m_erosion_buff.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC1);
+
+ //m_merge_Image.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
+ //m_dilation_image.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC1);
+ //m_erosion_image.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC1);
+ //m_dila_merge_img.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
+ //m_ero_merge_img.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
+ //m_noise_merge_img.create(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
/* InPortの映像データ */
- memcpy(m_image_buff.data,(void *)&(m_img_orig.pixels[0]), m_img_orig.pixels.length());
+ cv::Mat m_image_buff(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3, (void *)&(m_img_orig.pixels[0]));
+
+
+ cv::Mat m_gray_buff;
+ cv::Mat m_binary_buff;
+ cv::Mat m_dilation_buff;
+ cv::Mat m_erosion_buff;
+ cv::Mat m_merge_Image;
+ cv::Mat m_dilation_image;
+ cv::Mat m_erosion_image;
+ cv::Mat m_dila_merge_img;
+ cv::Mat m_ero_merge_img;
+ cv::Mat m_noise_merge_img;
+ cv::Mat m_output_image_buff(cv::Size(m_img_orig.width, m_img_orig.height), CV_8UC3);
+ //memcpy(m_image_buff.data,(void *)&(m_img_orig.pixels[0]), m_img_orig.pixels.length());
/* BGRからグレースケールに変換する */
cvtColor(m_image_buff, m_gray_buff, cv::COLOR_BGR2GRAY);
Modified: trunk/ImageProcessing/opencv/components/Edge/include/Edge/Edge.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Edge/include/Edge/Edge.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Edge/include/Edge/Edge.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -301,13 +301,8 @@
// <rtc-template block="private_operation">
// </rtc-template>
- cv::Mat imageBuff;
- cv::Mat grayImage;
- cv::Mat destinationImage_x;
- cv::Mat destinationImage_y;
- cv::Mat destinationImage_LAPLACIAN;
- cv::Mat destinationEdge;
- cv::Mat edgeImage;
+ //cv::Mat imageBuff;
+
int len;
};
Modified: trunk/ImageProcessing/opencv/components/Edge/src/Edge.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Edge/src/Edge.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Edge/src/Edge.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -136,40 +136,9 @@
RTC::ReturnCode_t Edge::onDeactivated(RTC::UniqueId ec_id)
{
- if (!imageBuff.empty())
- {
- imageBuff.release();
- }
- if (!destinationImage_x.empty())
- {
- destinationImage_x.release();
- }
- if (!destinationImage_y.empty())
- {
- destinationImage_y.release();
- }
- if (!destinationImage_LAPLACIAN.empty())
- {
- destinationImage_LAPLACIAN.release();
- }
- if (!destinationEdge.empty())
- {
- destinationEdge.release();
- }
- if (!destinationEdge.empty())
- {
- destinationEdge.release();
- }
- if (!grayImage.empty())
- {
- grayImage.release();
- }
- if (!edgeImage.empty())
- {
- edgeImage.release();
- }
+
return RTC::RTC_OK;
}
@@ -181,28 +150,17 @@
/* InPortデータの読み込み */
m_image_origIn.read();
- /* InPortとOutPortの画面サイズ処理およびイメージ用メモリの確保 */
- if( m_image_orig.width != m_image_edge_sobel_x.width || m_image_orig.height != m_image_edge_sobel_x.height)
- {
- m_image_edge_sobel_x.width = m_image_edge_sobel_y.width = m_image_edge_LAPLACIAN.width = m_image_orig.width;
- m_image_edge_sobel_x.height = m_image_edge_sobel_y.height = m_image_edge_LAPLACIAN.height = m_image_orig.height;
-
- /* イメージ用メモリの確保 */
- imageBuff.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3);
- grayImage.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC1);
- destinationImage_x.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_16UC1);
- destinationImage_y.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_16UC1);
- destinationImage_LAPLACIAN.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_16UC1);
- destinationEdge.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC1);
- edgeImage.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3);
-
-
- }
-
/* InPortの画面データをコピー */
- memcpy( imageBuff.data, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length() );
+ cv::Mat imageBuff(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0]));
+ //memcpy( imageBuff.data, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length() );
+ cv::Mat grayImage;
+ cv::Mat destinationImage_x;
+ cv::Mat destinationImage_y;
+ cv::Mat destinationImage_LAPLACIAN;
+ cv::Mat destinationEdge;
+ cv::Mat edgeImage;
/* RGBからグレースケールに変換 */
cv::cvtColor( imageBuff, grayImage, CV_RGB2GRAY );
@@ -220,6 +178,9 @@
/* 画像データのサイズ取得 */
len = edgeImage.channels() * edgeImage.size().width * edgeImage.size().height;
+ m_image_edge_sobel_x.width = m_image_edge_sobel_y.width = m_image_edge_LAPLACIAN.width = m_image_orig.width;
+ m_image_edge_sobel_x.height = m_image_edge_sobel_y.height = m_image_edge_LAPLACIAN.height = m_image_orig.height;
+
m_image_edge_sobel_x.pixels.length(len);
/* 反転した画像データをOutPortにコピー */
Modified: trunk/ImageProcessing/opencv/components/Findcontour/include/Findcontour/Findcontour.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Findcontour/include/Findcontour/Findcontour.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Findcontour/include/Findcontour/Findcontour.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -297,14 +297,7 @@
// <rtc-template block="private_operation">
// </rtc-template>
- cv::Mat imageBuff;
- cv::Mat grayImage;
- cv::Mat binaryImage;
- cv::Mat contourImage;
- int find_contour_num;
- std::vector<std::vector<cv::Point>> find_contour;
- cv::Scalar red;
- cv::Scalar green;
+
};
Modified: trunk/ImageProcessing/opencv/components/Findcontour/src/Findcontour.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Findcontour/src/Findcontour.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Findcontour/src/Findcontour.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -120,14 +120,10 @@
{
- /* OutPort画面サイズの初期化 */
- m_image_contour.width = 0;
- m_image_contour.height = 0;
- find_contour.clear();
- red = cv::Scalar(255, 0, 0);
- green = cv::Scalar(0, 255, 0);
+
+
return RTC::RTC_OK;
}
@@ -136,30 +132,26 @@
{
- if (!imageBuff.empty())
- {
- imageBuff.release();
- }
- if (!grayImage.empty())
- {
- grayImage.release();
- }
- if (!binaryImage.empty())
- {
- binaryImage.release();
- }
- if (!contourImage.empty())
- {
- contourImage.release();
- }
+
return RTC::RTC_OK;
}
RTC::ReturnCode_t Findcontour::onExecute(RTC::UniqueId ec_id)
{
+ cv::Mat imageBuff;
+ cv::Mat grayImage;
+ cv::Mat binaryImage;
+ cv::Mat contourImage;
+ int find_contour_num;
+ std::vector<std::vector<cv::Point>> find_contour;
+ cv::Scalar red;
+ cv::Scalar green;
+ red = cv::Scalar(255, 0, 0);
+ green = cv::Scalar(0, 255, 0);
+
/* 新しいデータのチェック */
if(m_image_origIn.isNew())
{
@@ -167,26 +159,15 @@
m_image_origIn.read();
/* InPortとOutPortの画面サイズ処理およびイメージ用メモリ確保 */
- if( m_image_orig.width != m_image_contour.width || m_image_orig.height != m_image_contour.height)
- {
- m_image_contour.width = m_image_orig.width;
- m_image_contour.height = m_image_orig.height;
+ m_image_contour.width = m_image_orig.width;
+ m_image_contour.height = m_image_orig.height;
-
- /* イメージ用メモリの確保 */
-
- imageBuff.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3);
- grayImage.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC1);
- binaryImage.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC1);
- contourImage.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3);
-
- }
-
/* InPortの画面データをコピー */
- memcpy( imageBuff.data, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length() );
- memcpy( contourImage.data, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length() );
+ cv::Mat imageBuff(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0]));
+ cv::Mat contourImage(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0]));
+
/* RGBからグレースケールに変換 */
cv::cvtColor( imageBuff, grayImage, CV_RGB2GRAY);
Modified: trunk/ImageProcessing/opencv/components/Flip/include/Flip/Flip.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Flip/include/Flip/Flip.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Flip/include/Flip/Flip.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -278,8 +278,7 @@
// <rtc-template block="private_operation">
// </rtc-template>
- cv::Mat m_imageBuff;
- cv::Mat m_flipImageBuff;
+
};
Modified: trunk/ImageProcessing/opencv/components/Flip/src/Flip.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Flip/src/Flip.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Flip/src/Flip.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -121,13 +121,8 @@
RTC::ReturnCode_t Flip::onDeactivated(RTC::UniqueId ec_id)
{
- if (!m_imageBuff.empty())
- {
- // 画像用メモリの解放
- m_imageBuff.release();
- m_flipImageBuff.release();
- }
+
return RTC::RTC_OK;
}
@@ -145,14 +140,16 @@
m_image_flip.width = m_image_orig.width;
m_image_flip.height = m_image_orig.height;
- m_imageBuff.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3);
- m_flipImageBuff.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3);
+
}
+ cv::Mat m_imageBuff(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0]));
+ cv::Mat m_flipImageBuff;
+
// InPortの画像データをm_imageBuffにコピー
- memcpy(m_imageBuff.data, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length());
+ //memcpy(m_imageBuff.data, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length());
// InPortからの画像データを反転する。 m_flipMode 0: X軸周り, 1: Y軸周り, -1: 両方の軸周り
cv::flip(m_imageBuff, m_flipImageBuff, m_flip_mode);
Modified: trunk/ImageProcessing/opencv/components/Histogram/include/Histogram/Histogram.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Histogram/include/Histogram/Histogram.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Histogram/include/Histogram/Histogram.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -297,15 +297,9 @@
// <rtc-template block="private_operation">
// </rtc-template>
- cv::Mat imageBuff; /* カメラのイメージ */
- cv::Mat grayImage;
- cv::Mat destinationImage;
- cv::Mat histogramImage;
- cv::Mat histogramBarImage;
+ //cv::Mat imageBuff; /* カメラのイメージ */
+ cv::Mat lookUpTableMatrix; /* 濃度対応行列 */
- cv::MatND histogram;
- cv::Mat lookUpTableMatrix; /* 濃度対応行列 */
-
int histogramSize;
int bin_w;
Modified: trunk/ImageProcessing/opencv/components/Histogram/src/Histogram.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Histogram/src/Histogram.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Histogram/src/Histogram.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -118,11 +118,8 @@
/* OutPort画面サイズの初期化 */
- m_image_histogram.width = 0;
- m_image_histogram.height = 0;
- m_image_histogramImage.width = 0;
- m_image_histogramImage.height = 0;
+
/* ヒストグラムに描画される縦棒の数 */
//histogramSize = 128;
/* ヒストグラムの範囲 */
@@ -142,7 +139,8 @@
//histogram = cvCreateHist( DIMENSIONS, &histogramSize, CV_HIST_ARRAY, ranges, UNIFORM );
/* 行列を生成 */
- lookUpTableMatrix.create(cv::Size(1, 256), CV_8UC1);
+ lookUpTableMatrix.create(cv::Size(1, 256), CV_8UC1); /* 濃度対応行列 */
+
//lookUpTableMatrix = cvCreateMatHeader( 1, 256, CV_8UC1 );
/* 濃度対応行列に濃度対応表をセット */
@@ -159,28 +157,9 @@
- if (!imageBuff.empty())
- {
- imageBuff.release();
- }
- if (!grayImage.empty())
- {
- grayImage.release();
- }
- if (!destinationImage.empty())
- {
- destinationImage.release();
- }
- if (!histogramImage.empty())
- {
- histogramImage.release();
- }
- if (!histogramBarImage.empty())
- {
- histogramBarImage.release();
- }
+
return RTC::RTC_OK;
}
@@ -193,28 +172,27 @@
/* InPortデータの読み込み */
m_image_origIn.read();
- /* InPortとOutPortの画面サイズ処理およびイメージ用メモリ確保 */
- if(m_image_orig.width != m_image_histogram.width || m_image_orig.height != m_image_histogram.height)
- {
- m_image_histogram.width = m_image_histogramImage.width = m_image_orig.width;
- m_image_histogram.height = m_image_histogramImage.height = m_image_orig.height;
+ cv::Mat grayImage;
+ cv::Mat destinationImage;
+ cv::Mat histogramImage;
+ cv::Mat histogramBarImage(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3);
+ cv::MatND histogram;
+
+
+
+ m_image_histogram.width = m_image_histogramImage.width = m_image_orig.width;
+ m_image_histogram.height = m_image_histogramImage.height = m_image_orig.height;
+ bin_w = cvRound((double)histogramBarImage.size().width / histogramSize);
-
- /* イメージ用メモリの確保 */
- imageBuff.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3);
- grayImage.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC1);
- destinationImage.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC1);
- histogramBarImage.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3);
- imageBuff.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3);
- /* ヒストグラムの縦棒の横幅を計算する */
- bin_w = cvRound( ( double )histogramBarImage.size().width / histogramSize );
-
- }
-
/* InPortの画面データをコピー */
- memcpy(imageBuff.data,(void *)&(m_image_orig.pixels[0]),m_image_orig.pixels.length());
+ //memcpy(imageBuff.data,(void *)&(m_image_orig.pixels[0]),m_image_orig.pixels.length());
+ cv::Mat imageBuff(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0]));
+
+
+
+
/* RGBからグレースケールに変換 */
cv::cvtColor( imageBuff, grayImage, CV_RGB2GRAY);
Modified: trunk/ImageProcessing/opencv/components/Houghline/include/Hough/Hough.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Houghline/include/Hough/Hough.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Houghline/include/Hough/Hough.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -348,19 +348,15 @@
// <rtc-template block="private_operation">
// </rtc-template>
- cv::Mat imageBuff;
- cv::Mat grayImage;
- cv::Mat edgeImage;
- cv::Mat hough;
- cv::Mat houghImage;
- int len;
+ //cv::Mat imageBuff;
+
+
int debug_method; /* configuration切り替え時の確認用 */
int debug_type; /* configuration切り替え時の確認用 */
- int m_in_height; /* 入力イメージのHeight */
- int m_in_width; /* 入力イメージのWidth */
+
};
Modified: trunk/ImageProcessing/opencv/components/Houghline/src/Hough.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Houghline/src/Hough.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Houghline/src/Hough.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -143,11 +143,10 @@
{
- m_in_height = 0;
- m_in_width = 0;
- len=0;
+
+
debug_method = -1;
debug_type = -1;
@@ -159,28 +158,10 @@
{
- if (!imageBuff.empty())
- {
- imageBuff.release();
- }
- if (!grayImage.empty())
- {
- grayImage.release();
- }
- if (!edgeImage.empty())
- {
- edgeImage.release();
- }
- if (!hough.empty())
- {
- hough.release();
- }
- if (!houghImage.empty())
- {
- houghImage.release();
- }
+
+
return RTC::RTC_OK;
}
@@ -193,27 +174,16 @@
/* InPortデータの読み込み */
m_image_origIn.read();
- /* サイズが変わったときだけ再生成する */
- if(m_image_orig.width != m_in_width || m_image_orig.height != m_in_height)
- {
- m_in_width = m_image_orig.width;
- m_in_height = m_image_orig.height;
+ /* InPortの画面データをコピー */
+ cv::Mat imageBuff(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0]));
+ cv::Mat grayImage;
+ cv::Mat edgeImage;
+ cv::Mat hough;
+ cv::Mat houghImage;
+
+
-
- /* イメージ用メモリの確保 */
-
- imageBuff.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- grayImage.create(cv::Size(m_in_width, m_in_height), CV_8UC1);
- edgeImage.create(cv::Size(m_in_width, m_in_height), CV_8UC1);
- hough.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- houghImage.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
-
- }
-
- /* InPortの画面データをコピー */
- memcpy( imageBuff.data, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length() );
-
/* RGBからグレースケールに変換 */
cv::cvtColor( imageBuff, grayImage, CV_RGB2GRAY );
@@ -305,7 +275,7 @@
/* 画像データのサイズ取得 */
- len = houghImage.channels() * houghImage.size().width * houghImage.size().height;
+ int len = houghImage.channels() * houghImage.size().width * houghImage.size().height;
m_image_hough.pixels.length(len);
m_image_hough.width = houghImage.size().width;
m_image_hough.height = houghImage.size().height;
Modified: trunk/ImageProcessing/opencv/components/ObjectTracking/src/ObjectTracking.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/ObjectTracking/src/ObjectTracking.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/ObjectTracking/src/ObjectTracking.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -490,16 +490,16 @@
trackRegion = cv::CamShift(backprojectImage,
trackWindow,
trackComp);
- //cv::ellipse(resultImage, trackRegion, cv::Scalar(0, 0, 255), 3, cv::LINE_AA);
+ cv::ellipse(resultImage, trackRegion, cv::Scalar(0, 0, 255), 3, cv::LINE_AA);
//trackWindow = trackComp.rect;
/* SnakeImage用のグレースケール画像を作成する */
- cv::cvtColor(resultImage, grayImage, cv::COLOR_BGR2GRAY);
+ /*cv::cvtColor(resultImage, grayImage, cv::COLOR_BGR2GRAY);
if (backprojectMode == SHOW_BACKPROJECTION){
cv::cvtColor(backprojectImage, resultImage, CV_GRAY2BGR);
- }
+ }*/
//if (resultImage->origin == 1){
// trackRegion.angle = -trackRegion.angle;
//}
Modified: trunk/ImageProcessing/opencv/components/Perspective/include/Perspective/Perspective.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Perspective/include/Perspective/Perspective.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Perspective/include/Perspective/Perspective.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -271,11 +271,8 @@
// <rtc-template block="private_operation">
// </rtc-template>
- int m_in_height; /* 入力イメージのHeight */
- int m_in_width; /* 入力イメージのWidth */
- cv::Mat m_image_buff; /* Original Image */
- cv::Mat m_image_dest; /* 結果出力用IplImage */
+
cv::Mat m_perspectiveMatrix; /* 変換Matrix */
};
Modified: trunk/ImageProcessing/opencv/components/Perspective/src/Perspective.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Perspective/src/Perspective.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Perspective/src/Perspective.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -101,9 +101,8 @@
{
- m_in_height = 0;
- m_in_width = 0;
+
/* 行列を生成する */
m_perspectiveMatrix.create(cv::Size(3, 3), CV_8UC1);
@@ -115,14 +114,7 @@
{
- if (!m_image_buff.empty())
- {
- m_image_buff.release();
- }
- if (!m_image_dest.empty())
- {
- m_image_dest.release();
- }
+
if (!m_perspectiveMatrix.empty())
{
m_perspectiveMatrix.release();
@@ -142,24 +134,11 @@
/* InPortデータの読み込み */
m_image_origIn.read();
- /* サイズが変わったときだけ再生成する */
- 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;
+ cv::Mat m_image_dest; /* 結果出力用IplImage */
+ cv::Mat m_image_buff(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0]));
-
- /* サイズ変換のためTempメモリーを用意する */
- m_image_buff.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- m_image_dest.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- }
-
- /* InPortの画像データをIplImageのimageDataにコピー */
- memcpy(m_image_buff.data,(void *)&(m_image_orig.pixels[0]),m_image_orig.pixels.length());
-
// Anternative actions
std::vector<cv::Point2f> original; /* 変換前座標 */
std::vector<cv::Point2f> translate; /* 変換後座標 */
Modified: trunk/ImageProcessing/opencv/components/Rotate/include/Rotate/Rotate.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Rotate/include/Rotate/Rotate.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Rotate/include/Rotate/Rotate.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -283,13 +283,7 @@
// <rtc-template block="private_operation">
// </rtc-template>
- int m_in_height; /* 入力イメージのHeight */
- int m_in_width; /* 入力イメージのWidth */
- cv::Mat m_image_buff; /* Original Image */
-
- cv::Mat m_image_dest; /* 結果出力用IplImage */
-
cv::Mat m_transformMatrix;
};
Modified: trunk/ImageProcessing/opencv/components/Rotate/src/Rotate.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Rotate/src/Rotate.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Rotate/src/Rotate.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -109,13 +109,10 @@
RTC::ReturnCode_t Rotate::onActivated(RTC::UniqueId ec_id)
{
- /* イメージ用メモリの確保 */
- m_image_buff = NULL;
- m_image_dest = NULL;
- m_in_height = 0;
- m_in_width = 0;
+
+
/* 行列を生成する */
m_transformMatrix.create( 2, 3, CV_32FC1);
@@ -126,18 +123,6 @@
RTC::ReturnCode_t Rotate::onDeactivated(RTC::UniqueId ec_id)
{
- if (!m_image_buff.empty())
- {
- m_image_buff.release();
- }
- if (!m_image_dest.empty())
- {
- m_image_dest.release();
- }
- if (!m_transformMatrix.empty())
- {
- m_transformMatrix.release();
- }
@@ -154,23 +139,10 @@
/* InPortデータの読み込み */
m_image_origIn.read();
- /* サイズが変わったときだけ再生成する */
- 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;
+ cv::Mat m_image_buff(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0]));
+ cv::Mat m_image_dest;
-
- /* サイズ変換のためTempメモリーを用意する */
- m_image_buff.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- m_image_dest.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
-
- }
-
- memcpy(m_image_buff.data,(void *)&(m_image_orig.pixels[0]),m_image_orig.pixels.length());
-
/* Anternative process */
/* 回転中心 */
CvPoint2D32f center = cvPoint2D32f(m_image_buff.size().width / 2.0, m_image_buff.size().height / 2.0);
Modified: trunk/ImageProcessing/opencv/components/Scale/include/Scale/Scale.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Scale/include/Scale/Scale.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Scale/include/Scale/Scale.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -283,14 +283,9 @@
// <rtc-template block="private_operation">
// </rtc-template>
- cv::Mat m_image_buff; /* Original Image */
- cv::Mat m_image_dest; /* 結果出力用IplImage */
- double m_currentScaleX; /* 現在のX方向拡大比率 */
- double m_currentScaleY; /* 現在のY方向拡大比率 */
- int m_in_height; /* 入力イメージのHeight */
- int m_in_width; /* 入力イメージのWidth */
+
};
Modified: trunk/ImageProcessing/opencv/components/Scale/src/Scale.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Scale/src/Scale.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Scale/src/Scale.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -80,8 +80,7 @@
// Bind variables and configuration variable
bindParameter("output_scale_x", m_scale_x, "1.0");
bindParameter("output_scale_y", m_scale_y, "1.0");
- m_currentScaleX = 1.0;
- m_currentScaleY = 1.0;
+
// </rtc-template>
return RTC::RTC_OK;
@@ -111,15 +110,6 @@
RTC::ReturnCode_t Scale::onActivated(RTC::UniqueId ec_id)
{
- /* イメージ用メモリの確保 */
- m_image_buff = NULL;
- m_image_dest = NULL;
-
- m_currentScaleX = m_scale_x;
- m_currentScaleY = m_scale_y;
-
- m_in_height = 0;
- m_in_width = 0;
return RTC::RTC_OK;
}
@@ -128,14 +118,7 @@
RTC::ReturnCode_t Scale::onDeactivated(RTC::UniqueId ec_id)
{
- if (!m_image_buff.empty())
- {
- m_image_buff.release();
- }
- if (!m_image_dest.empty())
- {
- m_image_dest.release();
- }
+
return RTC::RTC_OK;
}
@@ -151,36 +134,13 @@
// Anternative actions
- /* サイズが変わったときだけ再生成する */
- 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_image_buff.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3);
- }
-
- /* InPortの画像データをIplImageのimageDataにコピー */
- memcpy(m_image_buff.data, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length());
-
- /* 拡大比率が更新されたら出力イメージ用メモリを再確保する */
- if(m_image_dest.empty() || m_currentScaleX != m_scale_x || m_currentScaleY != m_scale_y)
- {
- m_currentScaleX = m_scale_x;
- m_currentScaleY = m_scale_y;
-
- printf( "[onExecute] Sacle has been changed to (%f, %f)\n", m_scale_x, m_scale_y);
- printf( "[onExecute] Realloc memory for output-image by (%d, %d)\n", (int)(m_in_width * m_currentScaleX),
- (int)(m_in_height * m_currentScaleY));
-
- /* 既存のメモリを解放する */
- m_image_dest.create(cv::Size(m_in_width * m_currentScaleX, m_in_height * m_currentScaleY), CV_8UC3);
+
+ cv::Mat m_image_buff(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0]));
- }
+ cv::Mat m_image_dest(cv::Size(m_image_orig.width * m_scale_x, m_image_orig.height * m_scale_y), CV_8UC3); /* 結果出力用IplImage */
+
+
/* 画像の大きさを変換する */
cv::resize(m_image_buff, m_image_dest, m_image_dest.size(), CV_INTER_LINEAR);
Modified: trunk/ImageProcessing/opencv/components/Sepia/include/Sepia/Sepia.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Sepia/include/Sepia/Sepia.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Sepia/include/Sepia/Sepia.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -284,18 +284,9 @@
// </rtc-template>
- int m_in_height; /* 入力イメージのHeight */
- int m_in_width; /* 入力イメージのWidth */
- cv::Mat m_image_buff; /* Original Image */
- cv::Mat m_hsvImage; /* HSV画像用IplImage */
- cv::Mat m_hueImage; /* 色相(H)情報用IplImage */
- cv::Mat m_saturationImage; /* 彩度(S)情報用IplImage */
- cv::Mat m_valueImage; /* 明度(V)情報用IplImage */
- cv::Mat m_mergeImage; /* マージ用IplImage */
- cv::Mat m_destinationImage; /* 結果出力用IplImage */
};
Modified: trunk/ImageProcessing/opencv/components/Sepia/src/Sepia.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Sepia/src/Sepia.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Sepia/src/Sepia.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -111,8 +111,6 @@
{
- m_in_height = 0;
- m_in_width = 0;
return RTC::RTC_OK;
}
@@ -123,35 +121,8 @@
/* イメージ用メモリの解放 */
- if (!m_image_buff.empty())
- {
- m_image_buff.release();
- }
- if (!m_hsvImage.empty())
- {
- m_hsvImage.release();
- }
- if (!m_hueImage.empty())
- {
- m_hueImage.release();
- }
- if (!m_saturationImage.empty())
- {
- m_saturationImage.release();
- }
- if (!m_valueImage.empty())
- {
- m_valueImage.release();
- }
- if (!m_mergeImage.empty())
- {
- m_mergeImage.release();
- }
- if (!m_destinationImage.empty())
- {
- m_destinationImage.release();
- }
+
return RTC::RTC_OK;
}
@@ -166,28 +137,21 @@
m_image_origIn.read();
/* サイズが変わったときだけ再生成する */
- 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;
+ cv::Mat m_image_buff(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0])); /* Original Image */
+ cv::Mat m_hsvImage; /* HSV画像用IplImage */
+ cv::Mat m_hueImage; /* 色相(H)情報用IplImage */
+ cv::Mat m_saturationImage; /* 彩度(S)情報用IplImage */
+ cv::Mat m_valueImage; /* 明度(V)情報用IplImage */
-
-
- m_image_buff.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- m_hsvImage.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- m_hueImage.create(cv::Size(m_in_width, m_in_height), CV_8UC1);
- m_saturationImage.create(cv::Size(m_in_width, m_in_height), CV_8UC1);
- m_valueImage.create(cv::Size(m_in_width, m_in_height), CV_8UC1);
- m_mergeImage.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- m_destinationImage.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- }
+ cv::Mat m_mergeImage; /* マージ用IplImage */
+ cv::Mat m_destinationImage; /* 結果出力用IplImage */
/* InPortの画像データをIplImageのimageDataにコピー */
- memcpy(m_image_buff.data,(void *)&(m_image_orig.pixels[0]),m_image_orig.pixels.length());
+ // memcpy(m_image_buff.data,(void *)&(m_image_orig.pixels[0]),m_image_orig.pixels.length());
// Anternative actions
Modified: trunk/ImageProcessing/opencv/components/SubStractCaptureImage/include/SubStractCaptureImage/SubStractCaptureImage.h
===================================================================
--- trunk/ImageProcessing/opencv/components/SubStractCaptureImage/include/SubStractCaptureImage/SubStractCaptureImage.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/SubStractCaptureImage/include/SubStractCaptureImage/SubStractCaptureImage.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -303,7 +303,7 @@
// </rtc-template>
- cv::Mat inputImage;
+ //cv::Mat inputImage;
cv::Mat backgroundAverageImage; /* 背景の平均値保存用IplImage */
cv::Mat backgroundThresholdImage; /* 背景の閾値保存用IplImage */
cv::Mat stillObjectAverageImage; /* 静止物体の平均値保存用IplImage */
Modified: trunk/ImageProcessing/opencv/components/SubStractCaptureImage/src/SubStractCaptureImage.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/SubStractCaptureImage/src/SubStractCaptureImage.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/SubStractCaptureImage/src/SubStractCaptureImage.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -139,82 +139,7 @@
- if (!inputImage.empty())
- {
- inputImage.release();
- }
- if (!backgroundAverageImage.empty())
- {
- backgroundAverageImage.release();
- }
- if (!backgroundThresholdImage.empty())
- {
- backgroundThresholdImage.release();
- }
- if (!stillObjectAverageImage.empty())
- {
- stillObjectAverageImage.release();
- }
- if (!stillObjectThresholdImage.empty())
- {
- stillObjectThresholdImage.release();
- }
- if (!backgroundDifferenceImage.empty())
- {
- backgroundDifferenceImage.release();
- }
- if (!stillObjectDifferenceImage.empty())
- {
- stillObjectDifferenceImage.release();
- }
- if (!backgroundCopyMaskImage.empty())
- {
- backgroundCopyMaskImage.release();
- }
- if (!tmpMaskImage.empty())
- {
- tmpMaskImage.release();
- }
- if (!tmp2MaskImage.empty())
- {
- tmp2MaskImage.release();
- }
- if (!frameImage32.empty())
- {
- frameImage32.release();
- }
- if (!backgroundImage.empty())
- {
- backgroundImage.release();
- }
- if (!stillObjectImage.empty())
- {
- stillObjectImage.release();
- }
- if (!outputImage.empty())
- {
- outputImage.release();
- }
- if (!foreGroundMaskBuff.empty())
- {
- foreGroundMaskBuff.release();
- }
- if (!stillObjectMaskBuff.empty())
- {
- stillObjectMaskBuff.release();
- }
- if (!backGroundBuff.empty())
- {
- backGroundBuff.release();
- }
- if (!stillObjectImageBuff.empty())
- {
- stillObjectImageBuff.release();
- }
- if (!stillObjectCounterBuff.empty())
- {
- stillObjectCounterBuff.release();
- }
+
return RTC::RTC_OK;
@@ -235,7 +160,7 @@
/* 画像を生成する */
- inputImage.create(imageSize, CV_8UC3); /* 背景の平均値保存用IplImage */
+ //inputImage.create(imageSize, CV_8UC3); /* 背景の平均値保存用IplImage */
backgroundAverageImage.create(imageSize, CV_32FC3); /* 背景の閾値保存用IplImage */
backgroundThresholdImage.create(imageSize, CV_32FC3); /* 静止物体の平均値保存用IplImage */
stillObjectAverageImage.create(imageSize, CV_32FC3); /* 静止物体の閾値保存用IplImage */
@@ -264,7 +189,8 @@
stillObjectImageBuff.create(imageSize, CV_8UC3);
stillObjectCounterBuff.create(imageSize, CV_8UC3);
- memcpy(inputImage.data,(void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length());
+ cv::Mat inputImage(imageSize, CV_8UC3, (void *)&(m_image_orig.pixels[0]));
+ //memcpy(inputImage.data,(void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length());
/* 初期化する */
inputImage.convertTo(backgroundAverageImage, CV_32F);
@@ -288,8 +214,8 @@
if(g_temp_w == m_image_orig.width && g_temp_h == m_image_orig.height)
{
-
- memcpy(inputImage.data,(void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length());
+ cv::Mat inputImage(imageSize, CV_8UC3, (void *)&(m_image_orig.pixels[0]));
+ //memcpy(inputImage.data,(void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length());
/* float 32bitに変換する */
Modified: trunk/ImageProcessing/opencv/components/Template/include/Template/Template.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Template/include/Template/Template.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Template/include/Template/Template.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -296,13 +296,7 @@
cv::Mat templateGrayImage;
cv::Mat templateBinaryImage;
- cv::Mat imageBuff;
- cv::Mat sourceGrayImage;
- cv::Mat sourceBinaryImage;
-
- cv::Mat differenceMapImage;
- cv::Point minLocation;
int len;
Modified: trunk/ImageProcessing/opencv/components/Template/src/Template.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Template/src/Template.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Template/src/Template.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -134,23 +134,8 @@
RTC::ReturnCode_t Template::onDeactivated(RTC::UniqueId ec_id)
{
- if (!imageBuff.empty())
- {
- imageBuff.release();
- }
- if (!sourceGrayImage.empty())
- {
- sourceGrayImage.release();
- }
- if (!sourceBinaryImage.empty())
- {
- sourceBinaryImage.release();
- }
- if (!differenceMapImage.empty())
- {
- differenceMapImage.release();
- }
+
if (!templateImage.empty())
{
templateImage.release();
@@ -204,9 +189,8 @@
/* 対象画像用のメモリ確保 */
- templateGrayImage.create(templateImage.size(), CV_8UC1);
- templateBinaryImage.create(templateImage.size(), CV_8UC1);
+
cout << "templateID : "<<templateID<<endl;
cout << "template - width :"<<templateWidth<<endl;
cout << "template - height :"<<templateHeight<<endl;
@@ -223,24 +207,21 @@
}
/* InPortとOutPortの画面サイズ処理およびイメージ用メモリの確保(正しい対象画像が入れるとdifferenceMapImageが変換される-フラッグを見て判断) */
- if(m_image_orig.width != m_image_template.width || m_image_orig.height != m_image_template.height || flag == 1)
- {
- flag = 0;
- m_image_template.width = m_image_orig.width;
- m_image_template.height = m_image_orig.height;
+ m_image_template.width = m_image_orig.width;
+ m_image_template.height = m_image_orig.height;
-
- /* イメージ用メモリの確保 */
- imageBuff.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3);
- sourceGrayImage.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC1);
- sourceBinaryImage.create(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC1);
- differenceMapImage.create(cv::Size(m_image_orig.width - templateWidth + 1, m_image_orig.height - templateHeight + 1), CV_8UC1);
- }
-
/* InPortの画像データをコピー */
- memcpy( imageBuff.data, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length() );
+ cv::Mat imageBuff(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0]));
+
+ cv::Mat sourceGrayImage;
+ cv::Mat sourceBinaryImage;
- if( templateImage.empty() )
+ cv::Mat differenceMapImage;
+
+ cv::Point minLocation;
+ //memcpy( imageBuff.data, (void *)&(m_image_orig.pixels[0]), m_image_orig.pixels.length() );
+
+ if( !templateImage.empty() )
{
/* RGBからグレースケールに変換する */
cv::cvtColor( imageBuff, sourceGrayImage, CV_RGB2GRAY );
@@ -249,10 +230,13 @@
cv::threshold( sourceGrayImage, sourceBinaryImage, THRESHOLD, THRESHOLD_MAX_VALUE, cv::THRESH_BINARY );
/* テンプレートマッチングを行う */
- cv::matchTemplate( sourceBinaryImage, templateBinaryImage, differenceMapImage, CV_TM_SQDIFF );
+ cv::matchTemplate(sourceBinaryImage, templateBinaryImage, differenceMapImage, CV_TM_SQDIFF);
/* テンプレートが元画像のどの部分にあるのかという情報を得る */
- cv::minMaxLoc( differenceMapImage, NULL, NULL, &minLocation, NULL, NULL );
+ cv::Point max_pt;
+ double maxVal;
+ cv::minMaxLoc(differenceMapImage, NULL, NULL, &minLocation, NULL);
+ //cv::minMaxLoc( differenceMapImage, NULL, NULL, &minLocation, NULL, NULL );
/* 一致する場所を元画像に四角で描く */
cv::rectangle(
@@ -265,12 +249,13 @@
SHIFT
);
+
/* 画像データのサイズ取得 */
len = imageBuff.channels() * imageBuff.size().width * imageBuff.size().height;
m_image_template.pixels.length(len);
/* 反転した画像データをOutPortにコピー */
- memcpy( (void *)&(m_image_template.pixels[0]), imageBuff.data, len );
+ memcpy((void *)&(m_image_template.pixels[0]), imageBuff.data, len);
/* 反転した画像データをOutPortから出力 */
m_image_templateOut.write();
Modified: trunk/ImageProcessing/opencv/components/Translate/include/Translate/Translate.h
===================================================================
--- trunk/ImageProcessing/opencv/components/Translate/include/Translate/Translate.h 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Translate/include/Translate/Translate.h 2017-02-06 06:57:53 UTC (rev 182)
@@ -286,8 +286,6 @@
int m_in_height; /* 入力イメージのHeight */
int m_in_width; /* 入力イメージのWidth */
- cv::Mat m_image_buff; /* Original Image */
- cv::Mat m_image_dest; /* 結果出力用IplImage */
cv::Mat m_transformMatrix;
};
Modified: trunk/ImageProcessing/opencv/components/Translate/src/Translate.cpp
===================================================================
--- trunk/ImageProcessing/opencv/components/Translate/src/Translate.cpp 2017-02-02 00:05:08 UTC (rev 181)
+++ trunk/ImageProcessing/opencv/components/Translate/src/Translate.cpp 2017-02-06 06:57:53 UTC (rev 182)
@@ -109,11 +109,7 @@
RTC::ReturnCode_t Translate::onActivated(RTC::UniqueId ec_id)
{
- /* イメージ用メモリの確保 */
- m_in_height = 0;
- m_in_width = 0;
-
/* 行列を生成する */
m_transformMatrix.create( 2, 3, CV_32FC1);
@@ -125,19 +121,8 @@
{
- if (!m_image_buff.empty())
- {
- m_image_buff.release();
- }
- if (!m_image_dest.empty())
- {
- m_image_dest.release();
- }
- if (!m_transformMatrix.empty())
- {
- m_transformMatrix.release();
- }
+
return RTC::RTC_OK;
@@ -153,22 +138,16 @@
/* InPortデータの読み込み */
m_image_origIn.read();
- /* サイズが変わったときだけ再生成する */
- 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;
- /* サイズ変換のためTempメモリーを用意する */
- m_image_buff.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- m_image_dest.create(cv::Size(m_in_width, m_in_height), CV_8UC3);
- }
-
/* InPortの画像データをIplImageのimageDataにコピー */
- memcpy(m_image_buff.data,(void *)&(m_image_orig.pixels[0]),m_image_orig.pixels.length());
+ cv::Mat m_image_buff(cv::Size(m_image_orig.width, m_image_orig.height), CV_8UC3, (void *)&(m_image_orig.pixels[0]));
+ //memcpy(m_image_buff.data,(void *)&(m_image_orig.pixels[0]),m_image_orig.pixels.length());
+ cv::Mat m_image_dest; /* 結果出力用IplImage */
+ cv::Mat m_transformMatrix;
+
+
// Anternative process
cv::Point2f original[3]; /* 変換前座標 */
cv::Point2f Translate[3]; /* 変換後座標 */
More information about the openrtm-commit
mailing list