diff --git a/.gitignore b/.gitignore
index 5b7bb7e..6c45000 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@
ECTrainer2/Log*.csv
images/
ECTrainer2/snapshot.jpg
+ECTrainer2/remove/
diff --git a/ECTrainer2/ECTrainer2.vcxproj b/ECTrainer2/ECTrainer2.vcxproj
index 22eb324..c990c87 100644
--- a/ECTrainer2/ECTrainer2.vcxproj
+++ b/ECTrainer2/ECTrainer2.vcxproj
@@ -155,8 +155,8 @@
-
+
@@ -176,8 +176,8 @@
-
+
diff --git a/ECTrainer2/ECTrainer2.vcxproj.filters b/ECTrainer2/ECTrainer2.vcxproj.filters
index b1c4cf4..673a60d 100644
--- a/ECTrainer2/ECTrainer2.vcxproj.filters
+++ b/ECTrainer2/ECTrainer2.vcxproj.filters
@@ -66,10 +66,10 @@
ソース ファイル
-
+
ソース ファイル
-
+
ソース ファイル
@@ -131,10 +131,10 @@
ヘッダー ファイル
-
+
ヘッダー ファイル
-
+
ヘッダー ファイル
diff --git a/ECTrainer2/ECTrainerGUI.cpp b/ECTrainer2/ECTrainerGUI.cpp
index 87761e2..4d14b03 100644
--- a/ECTrainer2/ECTrainerGUI.cpp
+++ b/ECTrainer2/ECTrainerGUI.cpp
@@ -142,11 +142,11 @@
// 画像表示
cvui::text(_MainFrame, SCENE_BUFFER_POS.x, 100, "SCENE CAMERA");
- cv::Mat sceneResized = gocv::KeepAspectResize(sceneBuf, DISP_SIZE.width);
+ cv::Mat sceneResized = nkc::ocv::KeepAspectResize(sceneBuf, DISP_SIZE.width);
cvui::image(_MainFrame, SCENE_BUFFER_POS.x, SCENE_BUFFER_POS.y, sceneResized);
cvui::text(_MainFrame, DISP_IMAGE_POS.x, 100, "STIMULUS IMAGE");
- cv::Mat dispResized = gocv::KeepAspectResize(dispBuf, DISP_SIZE.width);
+ cv::Mat dispResized = nkc::ocv::KeepAspectResize(dispBuf, DISP_SIZE.width);
cvui::image(_MainFrame, DISP_IMAGE_POS.x, DISP_IMAGE_POS.y, dispResized);
// 動画の末尾まで再生チェック
diff --git a/ECTrainer2/ECTrainerGUI.h b/ECTrainer2/ECTrainerGUI.h
index f52950e..231d331 100644
--- a/ECTrainer2/ECTrainerGUI.h
+++ b/ECTrainer2/ECTrainerGUI.h
@@ -1,7 +1,7 @@
#pragma once
#include "BaseProcess.h"
-#include "GOpenCV.h"
+#include "nkcOpenCV.h"
#include
class ECTrainer;
diff --git a/ECTrainer2/EyeTrack.h b/ECTrainer2/EyeTrack.h
index 50d0a6b..5b9596c 100644
--- a/ECTrainer2/EyeTrack.h
+++ b/ECTrainer2/EyeTrack.h
@@ -1,7 +1,7 @@
#pragma once
#include "BaseProcess.h"
-#include "GOpenCV.h"
+#include "nkcOpenCV.h"
#include "RingBuffer.h"
#include "MeanBuffer.h"
diff --git a/ECTrainer2/GOpenCV.cpp b/ECTrainer2/GOpenCV.cpp
deleted file mode 100644
index 079c1d3..0000000
--- a/ECTrainer2/GOpenCV.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-#include "GOpenCV.h"
-#include
-
-namespace gocv {
-
-// 待たないwaitKey()
-int noWaitKey() {
- MSG msg;
- while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
- if (::GetMessage(&msg, NULL, 0, 0) == 0) {
- // WM_QUIT
- ::PostQuitMessage(msg.wParam);
- return 0;
- }
-
- if (msg.message == WM_CHAR) return (int)msg.wParam;
-
- ::TranslateMessage(&msg);
- ::DispatchMessage(&msg);
- }
- return -1;
-}
-
-// 複数画像を縦横に連結表示
-void imShowMulti(
- cv::String winname, std::vector& imgs, // 全ての表示画像(8bit 3ch or 8bit 1chのみ)
- unsigned int cols, // 横の連結数
- unsigned int rows, // 縦の連結数
- cv::Size imgsize, // 表示する画像サイズ
- unsigned int border) {
- if (imgs.size() < 1 || cols < 1 || rows < 1) return;
-
- unsigned int w = imgsize.width + border, h = imgsize.height + border;
- cv::Mat board(h * rows + border, w * cols + border, CV_8UC3, CV_RGB(128, 128, 128));
- for (unsigned int r = 0, i = 0; r < rows; r++) {
- for (unsigned int c = 0; c < cols; c++, i++) {
- cv::Rect roi_rect = cv::Rect(c * w + border, r * h + border, imgsize.width, imgsize.height);
- cv::Mat roi(board, roi_rect);
- if (i < imgs.size()) {
- if (imgs[i].type() == CV_8UC3) {
- resize(imgs[i], roi, imgsize);
- } else if (imgs[i].type() == CV_8UC1) {
- cv::Mat c3;
- cvtColor(imgs[i], c3, cv::COLOR_GRAY2BGR);
- resize(c3, roi, imgsize);
- } else {
- putText(roi, "Color mode not matched", cv::Point(20, 20), cv::FONT_HERSHEY_COMPLEX, 0.5, CV_RGB(0, 0, 0));
- }
- } else {
- putText(roi, "No image", cv::Point(20, 20), cv::FONT_HERSHEY_COMPLEX, 0.5, CV_RGB(0, 0, 0));
- }
- }
- }
- imshow(winname, board);
-}
-
-// 縦横比を保ったリサイズ
-cv::Mat KeepAspectResize(cv::Mat& img, int width, int height) {
- cv::Size outputSize;
- if (width > 0) {
- if (height > 0) {
- // 縦横指定(両サイズに収まるようにする)
- outputSize = cv::Size(height * img.cols / img.rows, width * img.rows / img.cols);
- if (outputSize.width > width) outputSize.width = width;
- else outputSize.height = height;
- } else {
- // 横幅指定
- outputSize = cv::Size(width, width * img.rows / img.cols);
- }
- } else {
- if (height > 0) {
- // 縦幅指定
- outputSize = cv::Size(height * img.cols / img.rows, height);
- } else {
- // 縦横どちらも指定無い場合は入力のコピーを返す
- return img.clone();
- }
- }
- cv::Mat resized;
- cv::resize(img, resized, outputSize);
- return resized;
-}
-
-}; // namespace gocv
diff --git a/ECTrainer2/GOpenCV.h b/ECTrainer2/GOpenCV.h
deleted file mode 100644
index 3232a4d..0000000
--- a/ECTrainer2/GOpenCV.h
+++ /dev/null
@@ -1,123 +0,0 @@
-
-// OpenCV 3系, 4系 共通ヘッダーファイル
-// T.Nakaguchi, CFME, Chiba Univ., 2019
-
-#pragma once
-
-// ヘッダーファイル
-#pragma warning(disable: 4819)
-#include
-#include
-#pragma warning(default: 4819)
-
-// バージョン取得
-#define CV_VERSION_STR CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) CVAUX_STR(CV_SUBMINOR_VERSION)
-
-// ビルドモード
-#ifdef _DEBUG
-#define CV_EXT_STR "d.lib"
-#else
-#define CV_EXT_STR ".lib"
-#endif
-
-// ライブラリのリンク(不要な物はコメントアウト)
-#define PRE_COMPILE 0 // インストール版なら 1 個別ライブラリ使用時は 0
-#define PREHEAD "opencv_"
-
-#if PRE_COMPILE
-// OpenCV3 インストール版
-#pragma comment(lib, PREHEAD "world" CV_VERSION_STR CV_EXT_STR) // 全て
-#pragma comment(lib, PREHEAD "ts" CV_VERSION_STR CV_EXT_STR) // 映像関連
-
-#else
-// 個別のライブラリ指定 (CmakeやStatic版使用時など)
-// 基本モジュール
-#pragma comment(lib, PREHEAD "core" CV_VERSION_STR CV_EXT_STR) // Core functionality
-#pragma comment(lib, PREHEAD "imgproc" CV_VERSION_STR CV_EXT_STR) // Image processing
-#pragma comment(lib, PREHEAD "imgcodecs" CV_VERSION_STR CV_EXT_STR) // Image file reading and writing
-#pragma comment(lib, PREHEAD "videoio" CV_VERSION_STR CV_EXT_STR) // Video I/O
-#pragma comment(lib, PREHEAD "highgui" CV_VERSION_STR CV_EXT_STR) // High-level GUI
-//#pragma comment(lib, PREHEAD "video" CV_VERSION_STR CV_EXT_STR) // Video Analysis
-#pragma comment(lib, PREHEAD "calib3d" CV_VERSION_STR CV_EXT_STR) // Camera Calibration and 3D Reconstruction
-//#pragma comment(lib, PREHEAD "features2d" CV_VERSION_STR CV_EXT_STR) // 2D Features Framework
-//#pragma comment(lib, PREHEAD "objdetect" CV_VERSION_STR CV_EXT_STR) // Object Detection
-//#pragma comment(lib, PREHEAD "dnn" CV_VERSION_STR CV_EXT_STR) // Deep Neural Network module
-//#pragma comment(lib, PREHEAD "ml" CV_VERSION_STR CV_EXT_STR) // Machine Learning
-//#pragma comment(lib, PREHEAD "flann" CV_VERSION_STR CV_EXT_STR) // Clustering and Search in Multi-Dimensional Spaces
-//#pragma comment(lib, PREHEAD "photo" CV_VERSION_STR CV_EXT_STR) // Computational Photography
-//#pragma comment(lib, PREHEAD "stitching" CV_VERSION_STR CV_EXT_STR) // Images stitching
-//#pragma comment(lib, PREHEAD "cudaarithm" CV_VERSION_STR CV_EXT_STR) // CUDA Operations on Matrices
-//#pragma comment(lib, PREHEAD "cudabgsegm" CV_VERSION_STR CV_EXT_STR) // CUDA Background Segmentation
-//#pragma comment(lib, PREHEAD "cudacodec" CV_VERSION_STR CV_EXT_STR) // CUDA Video Encoding/Decoding
-//#pragma comment(lib, PREHEAD "cudafeatures2d" CV_VERSION_STR CV_EXT_STR) // CUDA Feature Detection and Description
-//#pragma comment(lib, PREHEAD "cudafilters" CV_VERSION_STR CV_EXT_STR) // CUDA Image Filtering
-//#pragma comment(lib, PREHEAD "cudaimgproc" CV_VERSION_STR CV_EXT_STR) // CUDA Image Processing
-//#pragma comment(lib, PREHEAD "cudalegacy" CV_VERSION_STR CV_EXT_STR) // CUDA Legacy support
-//#pragma comment(lib, PREHEAD "cudaobjdetect" CV_VERSION_STR CV_EXT_STR) // CUDA Object Detection
-//#pragma comment(lib, PREHEAD "cudaoptflow" CV_VERSION_STR CV_EXT_STR) // CUDA Optical Flow
-//#pragma comment(lib, PREHEAD "cudastereo" CV_VERSION_STR CV_EXT_STR) // CUDA Stereo Correspondence
-//#pragma comment(lib, PREHEAD "cudawarping" CV_VERSION_STR CV_EXT_STR) // CUDA Image Warping
-//#pragma comment(lib, PREHEAD "cudev" CV_VERSION_STR CV_EXT_STR) // CUDA Device layer
-//#pragma comment(lib, PREHEAD "shape" CV_VERSION_STR CV_EXT_STR) // Shape Distance and Matching
-//#pragma comment(lib, PREHEAD "superres" CV_VERSION_STR CV_EXT_STR) // Super Resolution
-//#pragma comment(lib, PREHEAD "videostab" CV_VERSION_STR CV_EXT_STR) // Video Stabilization
-//#pragma comment(lib, PREHEAD "viz" CV_VERSION_STR CV_EXT_STR) // 3D Visualizer
-
-// 拡張モジュール
-#pragma comment(lib, PREHEAD "aruco" CV_VERSION_STR CV_EXT_STR) // ArUco Marker Detection
-//#pragma comment(lib, PREHEAD "bgsegm" CV_VERSION_STR CV_EXT_STR) // Improved Background-Foreground Segmentation Methods
-//#pragma comment(lib, PREHEAD "bioinspired" CV_VERSION_STR CV_EXT_STR) // Biologically inspired vision models and derivated tools
-//#pragma comment(lib, PREHEAD "ccalib" CV_VERSION_STR CV_EXT_STR) // Custom Calibration Pattern for 3D reconstruction
-//#pragma comment(lib, PREHEAD "cnn_3dobj" CV_VERSION_STR CV_EXT_STR) // 3D object recognition and pose estimation API
-//#pragma comment(lib, PREHEAD "cvv" CV_VERSION_STR CV_EXT_STR) // GUI for Interactive Visual Debugging of Computer Vision Programs
-//#pragma comment(lib, PREHEAD "datasets" CV_VERSION_STR CV_EXT_STR) // Framework for working with different datasets
-//#pragma comment(lib, PREHEAD "dnn_objdetect" CV_VERSION_STR CV_EXT_STR) // DNN used for object detection
-//#pragma comment(lib, PREHEAD "dpm" CV_VERSION_STR CV_EXT_STR) // Deformable Part-based Models
-//#pragma comment(lib, PREHEAD "face" CV_VERSION_STR CV_EXT_STR) // Face Analysis
-//#pragma comment(lib, PREHEAD "freetype" CV_VERSION_STR CV_EXT_STR) // Drawing UTF-8 strings with freetype/harfbuzz
-//#pragma comment(lib, PREHEAD "fuzzy" CV_VERSION_STR CV_EXT_STR) // Image processing based on fuzzy mathematics
-//#pragma comment(lib, PREHEAD "hdf" CV_VERSION_STR CV_EXT_STR) // Hierarchical Data Format I/O routines
-//#pragma comment(lib, PREHEAD "hfs" CV_VERSION_STR CV_EXT_STR) // Hierarchical Feature Selection for Efficient Image Segmentation
-//#pragma comment(lib, PREHEAD "img_hash" CV_VERSION_STR CV_EXT_STR) // The module brings implementations of different image hashing algorithms.
-//#pragma comment(lib, PREHEAD "line_descriptor" CV_VERSION_STR CV_EXT_STR) // Binary descriptors for lines extracted from an image
-//#pragma comment(lib, PREHEAD "matlab" CV_VERSION_STR CV_EXT_STR) // MATLAB Bridge
-//#pragma comment(lib, PREHEAD "optflow" CV_VERSION_STR CV_EXT_STR) // Optical Flow Algorithms
-//#pragma comment(lib, PREHEAD "ovis" CV_VERSION_STR CV_EXT_STR) // OGRE 3D Visualiser
-//#pragma comment(lib, PREHEAD "phase_unwrapping" CV_VERSION_STR CV_EXT_STR) // Phase Unwrapping API
-//#pragma comment(lib, PREHEAD "plot" CV_VERSION_STR CV_EXT_STR) // Plot function for Mat data
-//#pragma comment(lib, PREHEAD "reg" CV_VERSION_STR CV_EXT_STR) // Image Registration
-//#pragma comment(lib, PREHEAD "rgbd" CV_VERSION_STR CV_EXT_STR) // RGB-Depth Processing
-//#pragma comment(lib, PREHEAD "saliency" CV_VERSION_STR CV_EXT_STR) // Saliency API
-//#pragma comment(lib, PREHEAD "sfm" CV_VERSION_STR CV_EXT_STR) // Structure From Motion
-//#pragma comment(lib, PREHEAD "stereo" CV_VERSION_STR CV_EXT_STR) // Stereo Correspondance Algorithms
-//#pragma comment(lib, PREHEAD "structured_light" CV_VERSION_STR CV_EXT_STR) // Structured Light API
-//#pragma comment(lib, PREHEAD "surface_matching" CV_VERSION_STR CV_EXT_STR) // Surface Matching
-//#pragma comment(lib, PREHEAD "text" CV_VERSION_STR CV_EXT_STR) // Scene Text Detection and Recognition
-//#pragma comment(lib, PREHEAD "tracking" CV_VERSION_STR CV_EXT_STR) // Tracking API
-//#pragma comment(lib, PREHEAD "xfeatures2d" CV_VERSION_STR CV_EXT_STR) // Extra 2D Features Framework
-//#pragma comment(lib, PREHEAD "ximgproc" CV_VERSION_STR CV_EXT_STR) // Extended Image Processing
-//#pragma comment(lib, PREHEAD "xobjdetect" CV_VERSION_STR CV_EXT_STR) // Extended object detection
-//#pragma comment(lib, PREHEAD "xphoto" CV_VERSION_STR CV_EXT_STR) // Additional photo processing algorithms
-#endif
-
-//using namespace cv;
-
-
-namespace gocv {
-
-// 待たないwaitKey()
-// 戻り値:入力キーコード,キー入力なし -1,WM_QUIT受信 0
-int noWaitKey();
-
-// 複数画像を縦横に連結表示
-void imShowMulti(
- cv::String winname, std::vector& imgs, // 全ての表示画像(8bit 3ch or 8bit 1chのみ)
- unsigned int cols, // 横の連結数
- unsigned int rows, // 縦の連結数
- cv::Size imgsize, // 表示する画像サイズ
- unsigned int border);
-
-// 縦横比を保ったリサイズ
-cv::Mat KeepAspectResize(cv::Mat& img, int width = 0, int height = 0);
-
-}; // namespace gocv
diff --git a/ECTrainer2/ImageProc.h b/ECTrainer2/ImageProc.h
index 0d09f5c..2718d24 100644
--- a/ECTrainer2/ImageProc.h
+++ b/ECTrainer2/ImageProc.h
@@ -1,6 +1,6 @@
#pragma once
-#include "GOpenCV.h"
+#include "nkcOpenCV.h"
#include "BaseProcess.h"
#include "RingBuffer.h"
diff --git a/ECTrainer2/Marker.h b/ECTrainer2/Marker.h
index cc13262..16dcf61 100644
--- a/ECTrainer2/Marker.h
+++ b/ECTrainer2/Marker.h
@@ -1,6 +1,6 @@
#pragma once
-#include "GOpenCV.h"
+#include "nkcOpenCV.h"
#include "RingBuffer.h"
#include
diff --git a/ECTrainer2/MovieObject.cpp b/ECTrainer2/MovieObject.cpp
index faf4d91..82745ce 100644
--- a/ECTrainer2/MovieObject.cpp
+++ b/ECTrainer2/MovieObject.cpp
@@ -29,7 +29,7 @@
FrameInfo fi;
fi.eTime = (float)atof(table[r][0].c_str());
int nElements = (cols - 1) / 3;
- const double FixedArea = 200.F * 200.F;
+ const double FixedArea = 200.0 * 200.0;
double area = 0;
for (int e = 0; e < nElements; e++) {
double d = atof(table[r][(size_t)e * 3 + 3].c_str());
@@ -42,7 +42,7 @@
double adj = (area == 0 ? 0 : sqrt(FixedArea / area));
if (adj > 1.0) {
for (int e = 0; e < nElements; e++) {
- fi.elements[e].d *= adj;
+ fi.elements[e].d *= (float)adj;
}
}
_frame.push_back(fi);
diff --git a/ECTrainer2/MovieObject.h b/ECTrainer2/MovieObject.h
index 4b088f2..5af72b0 100644
--- a/ECTrainer2/MovieObject.h
+++ b/ECTrainer2/MovieObject.h
@@ -12,6 +12,7 @@
float y; // Y座標
float d; // サイズ
+ // コンストラクタ
Element(float X, float Y, float D) {
x = X;
y = Y;
@@ -23,6 +24,9 @@
struct FrameInfo {
float eTime; // 時間
std::vector elements; // 要素群
+
+ // コンストラクタ
+ FrameInfo() : eTime(0) {}
};
// 映像オブジェクトクラス
diff --git a/ECTrainer2/SceneCamera.h b/ECTrainer2/SceneCamera.h
index 00f7fed..5fdd5fc 100644
--- a/ECTrainer2/SceneCamera.h
+++ b/ECTrainer2/SceneCamera.h
@@ -1,6 +1,6 @@
#pragma once
-#include "GOpenCV.h"
+#include "nkcOpenCV.h"
#include "BaseProcess.h"
#include "RingBuffer.h"
diff --git a/ECTrainer2/Stimulus.h b/ECTrainer2/Stimulus.h
index b3c28d5..aeb88b6 100644
--- a/ECTrainer2/Stimulus.h
+++ b/ECTrainer2/Stimulus.h
@@ -4,7 +4,7 @@
#include
#include
#include
-#include "GOpenCV.h"
+#include "nkcOpenCV.h"
#include "RingBuffer.h"
#include "MovieObject.h"
#include "myWinUtils.h"
diff --git a/ECTrainer2/Worker.h b/ECTrainer2/Worker.h
index 9ed4095..3f27d11 100644
--- a/ECTrainer2/Worker.h
+++ b/ECTrainer2/Worker.h
@@ -3,7 +3,7 @@
#include
#include
#include
-#include "GOpenCV.h"
+#include "nkcOpenCV.h"
#include "RingBuffer.h"
#include "myWinUtils.h"
diff --git a/ECTrainer2/nkcOpenCV.cpp b/ECTrainer2/nkcOpenCV.cpp
new file mode 100644
index 0000000..09ef1cd
--- /dev/null
+++ b/ECTrainer2/nkcOpenCV.cpp
@@ -0,0 +1,92 @@
+#include "nkcOpenCV.h"
+#include
+
+namespace nkc {
+namespace ocv {
+
+// �҂��Ȃ�waitKey()
+int noWaitKey() {
+ MSG msg;
+ while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
+ if (::GetMessage(&msg, NULL, 0, 0) == 0) {
+ // WM_QUIT
+ ::PostQuitMessage(msg.wParam);
+ return 0;
+ }
+
+ if (msg.message == WM_CHAR) return (int)msg.wParam;
+
+ ::TranslateMessage(&msg);
+ ::DispatchMessage(&msg);
+ }
+ return -1;
+}
+
+// �����摜���c���ɘA���\��
+void imShowMulti(
+ cv::String winname, std::vector& imgs, // �S�Ă̕\���摜�i8bit 3ch or 8bit 1ch�̂�)
+ unsigned int cols, // ���̘A����
+ unsigned int rows, // �c�̘A����
+ cv::Size imgsize, // �\������摜�T�C�Y
+ unsigned int border) {
+ if (imgs.size() < 1 || cols < 1 || rows < 1) return;
+
+ unsigned int w = imgsize.width + border, h = imgsize.height + border;
+ cv::Mat board(h * rows + border, w * cols + border, CV_8UC3, CV_RGB(128, 128, 128));
+ for (unsigned int r = 0, i = 0; r < rows; r++) {
+ for (unsigned int c = 0; c < cols; c++, i++) {
+ cv::Rect roi_rect = cv::Rect(c * w + border, r * h + border, imgsize.width, imgsize.height);
+ cv::Mat roi(board, roi_rect);
+ if (i < imgs.size()) {
+ if (imgs[i].type() == CV_8UC3) {
+ resize(imgs[i], roi, imgsize);
+ } else if (imgs[i].type() == CV_8UC1) {
+ cv::Mat c3;
+ cvtColor(imgs[i], c3, cv::COLOR_GRAY2BGR);
+ resize(c3, roi, imgsize);
+ } else {
+ putText(roi, "Color mode not matched", cv::Point(20, 20), cv::FONT_HERSHEY_COMPLEX, 0.5, CV_RGB(0, 0, 0));
+ }
+ } else {
+ putText(roi, "No image", cv::Point(20, 20), cv::FONT_HERSHEY_COMPLEX, 0.5, CV_RGB(0, 0, 0));
+ }
+ }
+ }
+ imshow(winname, board);
+}
+
+// �c�����ۂ������T�C�Y
+cv::Mat KeepAspectResize(cv::Mat& img, int width, int height) {
+ cv::Size outputSize;
+ if (width > 0) {
+ if (height > 0) {
+ // �c���w��i���T�C�Y�Ɏ��܂�悤�ɂ���j
+ outputSize = cv::Size(height * img.cols / img.rows, width * img.rows / img.cols);
+ if (outputSize.width > width) outputSize.width = width;
+ else outputSize.height = height;
+ } else {
+ // �����w��
+ outputSize = cv::Size(width, width * img.rows / img.cols);
+ }
+ } else {
+ if (height > 0) {
+ // �c���w��
+ outputSize = cv::Size(height * img.cols / img.rows, height);
+ } else {
+ // �c���ǂ�����w�薳���ꍇ�͓��͂̃R�s�[��Ԃ�
+ return img.clone();
+ }
+ }
+ cv::Mat resized;
+ cv::resize(img, resized, outputSize);
+ return resized;
+}
+
+// �E�C���h�E�n���h�����擾
+HANDLE getWindowHandle(cv::String winname) {
+ return ::FindWindowA(NULL, winname.c_str());
+}
+
+
+}; // namespace ocv
+}; // namespace nkc
diff --git a/ECTrainer2/nkcOpenCV.h b/ECTrainer2/nkcOpenCV.h
new file mode 100644
index 0000000..1619766
--- /dev/null
+++ b/ECTrainer2/nkcOpenCV.h
@@ -0,0 +1,130 @@
+
+// OpenCV 3�n, 4�n ���ʃw�b�_�[�t�@�C��
+// T.Nakaguchi, CFME, Chiba Univ., 2019
+
+#pragma once
+
+// �w�b�_�[�t�@�C��
+#pragma warning(disable: 4819)
+#include
+#include
+#pragma warning(default: 4819)
+
+// �o�[�W�����擾
+#define CV_VERSION_STR CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) CVAUX_STR(CV_SUBMINOR_VERSION)
+
+// �r���h���[�h
+#ifdef _DEBUG
+#define CV_EXT_STR "d.lib"
+#else
+#define CV_EXT_STR ".lib"
+#endif
+
+// ���C�u�����̃����N�i�s�v�ȕ��̓R�����g�A�E�g�j
+#define PRE_COMPILE 0 // �C���X�g�[���łȂ� 1 �ʃ��C�u�����g�p���� 0
+#define PREHEAD "opencv_"
+
+#if PRE_COMPILE
+// OpenCV3 �C���X�g�[����
+#pragma comment(lib, PREHEAD "world" CV_VERSION_STR CV_EXT_STR) // �S��
+#pragma comment(lib, PREHEAD "ts" CV_VERSION_STR CV_EXT_STR) // �f���֘A
+
+#else
+// �ʂ̃��C�u�����w�� �iCmake��Static�Ŏg�p���Ȃǁj
+// ��{���W���[��
+#pragma comment(lib, PREHEAD "core" CV_VERSION_STR CV_EXT_STR) // Core functionality
+#pragma comment(lib, PREHEAD "imgproc" CV_VERSION_STR CV_EXT_STR) // Image processing
+#pragma comment(lib, PREHEAD "imgcodecs" CV_VERSION_STR CV_EXT_STR) // Image file reading and writing
+#pragma comment(lib, PREHEAD "videoio" CV_VERSION_STR CV_EXT_STR) // Video I/O
+#pragma comment(lib, PREHEAD "highgui" CV_VERSION_STR CV_EXT_STR) // High-level GUI
+//#pragma comment(lib, PREHEAD "video" CV_VERSION_STR CV_EXT_STR) // Video Analysis
+#pragma comment(lib, PREHEAD "calib3d" CV_VERSION_STR CV_EXT_STR) // Camera Calibration and 3D Reconstruction
+//#pragma comment(lib, PREHEAD "features2d" CV_VERSION_STR CV_EXT_STR) // 2D Features Framework
+//#pragma comment(lib, PREHEAD "objdetect" CV_VERSION_STR CV_EXT_STR) // Object Detection
+//#pragma comment(lib, PREHEAD "dnn" CV_VERSION_STR CV_EXT_STR) // Deep Neural Network module
+//#pragma comment(lib, PREHEAD "ml" CV_VERSION_STR CV_EXT_STR) // Machine Learning
+//#pragma comment(lib, PREHEAD "flann" CV_VERSION_STR CV_EXT_STR) // Clustering and Search in Multi-Dimensional Spaces
+//#pragma comment(lib, PREHEAD "photo" CV_VERSION_STR CV_EXT_STR) // Computational Photography
+//#pragma comment(lib, PREHEAD "stitching" CV_VERSION_STR CV_EXT_STR) // Images stitching
+//#pragma comment(lib, PREHEAD "cudaarithm" CV_VERSION_STR CV_EXT_STR) // CUDA Operations on Matrices
+//#pragma comment(lib, PREHEAD "cudabgsegm" CV_VERSION_STR CV_EXT_STR) // CUDA Background Segmentation
+//#pragma comment(lib, PREHEAD "cudacodec" CV_VERSION_STR CV_EXT_STR) // CUDA Video Encoding/Decoding
+//#pragma comment(lib, PREHEAD "cudafeatures2d" CV_VERSION_STR CV_EXT_STR) // CUDA Feature Detection and Description
+//#pragma comment(lib, PREHEAD "cudafilters" CV_VERSION_STR CV_EXT_STR) // CUDA Image Filtering
+//#pragma comment(lib, PREHEAD "cudaimgproc" CV_VERSION_STR CV_EXT_STR) // CUDA Image Processing
+//#pragma comment(lib, PREHEAD "cudalegacy" CV_VERSION_STR CV_EXT_STR) // CUDA Legacy support
+//#pragma comment(lib, PREHEAD "cudaobjdetect" CV_VERSION_STR CV_EXT_STR) // CUDA Object Detection
+//#pragma comment(lib, PREHEAD "cudaoptflow" CV_VERSION_STR CV_EXT_STR) // CUDA Optical Flow
+//#pragma comment(lib, PREHEAD "cudastereo" CV_VERSION_STR CV_EXT_STR) // CUDA Stereo Correspondence
+//#pragma comment(lib, PREHEAD "cudawarping" CV_VERSION_STR CV_EXT_STR) // CUDA Image Warping
+//#pragma comment(lib, PREHEAD "cudev" CV_VERSION_STR CV_EXT_STR) // CUDA Device layer
+//#pragma comment(lib, PREHEAD "shape" CV_VERSION_STR CV_EXT_STR) // Shape Distance and Matching
+//#pragma comment(lib, PREHEAD "superres" CV_VERSION_STR CV_EXT_STR) // Super Resolution
+//#pragma comment(lib, PREHEAD "videostab" CV_VERSION_STR CV_EXT_STR) // Video Stabilization
+//#pragma comment(lib, PREHEAD "viz" CV_VERSION_STR CV_EXT_STR) // 3D Visualizer
+
+// �g�����W���[��
+#pragma comment(lib, PREHEAD "aruco" CV_VERSION_STR CV_EXT_STR) // ArUco Marker Detection
+//#pragma comment(lib, PREHEAD "bgsegm" CV_VERSION_STR CV_EXT_STR) // Improved Background-Foreground Segmentation Methods
+//#pragma comment(lib, PREHEAD "bioinspired" CV_VERSION_STR CV_EXT_STR) // Biologically inspired vision models and derivated tools
+//#pragma comment(lib, PREHEAD "ccalib" CV_VERSION_STR CV_EXT_STR) // Custom Calibration Pattern for 3D reconstruction
+//#pragma comment(lib, PREHEAD "cnn_3dobj" CV_VERSION_STR CV_EXT_STR) // 3D object recognition and pose estimation API
+//#pragma comment(lib, PREHEAD "cvv" CV_VERSION_STR CV_EXT_STR) // GUI for Interactive Visual Debugging of Computer Vision Programs
+//#pragma comment(lib, PREHEAD "datasets" CV_VERSION_STR CV_EXT_STR) // Framework for working with different datasets
+//#pragma comment(lib, PREHEAD "dnn_objdetect" CV_VERSION_STR CV_EXT_STR) // DNN used for object detection
+//#pragma comment(lib, PREHEAD "dpm" CV_VERSION_STR CV_EXT_STR) // Deformable Part-based Models
+//#pragma comment(lib, PREHEAD "face" CV_VERSION_STR CV_EXT_STR) // Face Analysis
+//#pragma comment(lib, PREHEAD "freetype" CV_VERSION_STR CV_EXT_STR) // Drawing UTF-8 strings with freetype/harfbuzz
+//#pragma comment(lib, PREHEAD "fuzzy" CV_VERSION_STR CV_EXT_STR) // Image processing based on fuzzy mathematics
+//#pragma comment(lib, PREHEAD "hdf" CV_VERSION_STR CV_EXT_STR) // Hierarchical Data Format I/O routines
+//#pragma comment(lib, PREHEAD "hfs" CV_VERSION_STR CV_EXT_STR) // Hierarchical Feature Selection for Efficient Image Segmentation
+//#pragma comment(lib, PREHEAD "img_hash" CV_VERSION_STR CV_EXT_STR) // The module brings implementations of different image hashing algorithms.
+//#pragma comment(lib, PREHEAD "line_descriptor" CV_VERSION_STR CV_EXT_STR) // Binary descriptors for lines extracted from an image
+//#pragma comment(lib, PREHEAD "matlab" CV_VERSION_STR CV_EXT_STR) // MATLAB Bridge
+//#pragma comment(lib, PREHEAD "optflow" CV_VERSION_STR CV_EXT_STR) // Optical Flow Algorithms
+//#pragma comment(lib, PREHEAD "ovis" CV_VERSION_STR CV_EXT_STR) // OGRE 3D Visualiser
+//#pragma comment(lib, PREHEAD "phase_unwrapping" CV_VERSION_STR CV_EXT_STR) // Phase Unwrapping API
+//#pragma comment(lib, PREHEAD "plot" CV_VERSION_STR CV_EXT_STR) // Plot function for Mat data
+//#pragma comment(lib, PREHEAD "reg" CV_VERSION_STR CV_EXT_STR) // Image Registration
+//#pragma comment(lib, PREHEAD "rgbd" CV_VERSION_STR CV_EXT_STR) // RGB-Depth Processing
+//#pragma comment(lib, PREHEAD "saliency" CV_VERSION_STR CV_EXT_STR) // Saliency API
+//#pragma comment(lib, PREHEAD "sfm" CV_VERSION_STR CV_EXT_STR) // Structure From Motion
+//#pragma comment(lib, PREHEAD "stereo" CV_VERSION_STR CV_EXT_STR) // Stereo Correspondance Algorithms
+//#pragma comment(lib, PREHEAD "structured_light" CV_VERSION_STR CV_EXT_STR) // Structured Light API
+//#pragma comment(lib, PREHEAD "surface_matching" CV_VERSION_STR CV_EXT_STR) // Surface Matching
+//#pragma comment(lib, PREHEAD "text" CV_VERSION_STR CV_EXT_STR) // Scene Text Detection and Recognition
+//#pragma comment(lib, PREHEAD "tracking" CV_VERSION_STR CV_EXT_STR) // Tracking API
+//#pragma comment(lib, PREHEAD "xfeatures2d" CV_VERSION_STR CV_EXT_STR) // Extra 2D Features Framework
+//#pragma comment(lib, PREHEAD "ximgproc" CV_VERSION_STR CV_EXT_STR) // Extended Image Processing
+//#pragma comment(lib, PREHEAD "xobjdetect" CV_VERSION_STR CV_EXT_STR) // Extended object detection
+//#pragma comment(lib, PREHEAD "xphoto" CV_VERSION_STR CV_EXT_STR) // Additional photo processing algorithms
+#endif
+
+//using namespace cv;
+
+
+#include
+
+namespace nkc {
+namespace ocv {
+
+// �҂��Ȃ�waitKey()
+// �߂�l�F���̓L�[�R�[�h�C�L�[���͂Ȃ� -1�CWM_QUIT��M 0
+int noWaitKey();
+
+// �����摜���c���ɘA���\��
+void imShowMulti(
+ cv::String winname, std::vector& imgs, // �S�Ă̕\���摜�i8bit 3ch or 8bit 1ch�̂�)
+ unsigned int cols, // ���̘A����
+ unsigned int rows, // �c�̘A����
+ cv::Size imgsize, // �\������摜�T�C�Y
+ unsigned int border);
+
+// �c�����ۂ������T�C�Y
+cv::Mat KeepAspectResize(cv::Mat& img, int width = 0, int height = 0);
+
+// �E�C���h�E�n���h�����擾
+HANDLE getWindowHandle(cv::String winname);
+
+}; // namespace ocv
+}; // namespace nkc