1/03/2017
Get Mac Address in MFC
GetMacAddress in MFC
Get by using GetAdaptersInfo function
//
..
Get by using ip address
//If localhost -> GetMacAddress(_T("*"));
//if have ip -> GetMacAddress(_T("192.168.1.1"));//
..
1/02/2017
CString to string
..
string CstringToString(CString str) { CT2CA pszConvertedAnsiString(str); std::string s(pszConvertedAnsiString); return s; }..
12/29/2016
opencv mouse event example code
...
void CallBackFunc(int event, int x, int y, int flags, void* userdata) { if (event == EVENT_LBUTTONDOWN) { printf("lLBUTTONDOWN down %d, %d \n", x, y); circle((*(Mat*)userdata), Point(x, y), 2, CV_RGB(255, 0, 0), 3); } else if (event == EVENT_RBUTTONDOWN) { printf("RBUTTONDOWN down %d, %d \n", x, y); } else if (event == EVENT_MBUTTONDOWN) { printf("MBUTTONDOWN down %d, %d \n", x, y); } else if (event == EVENT_MOUSEMOVE) { printf("move %d, %d \n", x, y); } //imshow("img", (*(Mat*)userdata)); //show } int main(int, char) { namedWindow("img", 0); Mat img = imread("gh.jpg"); setMouseCallback("img", CallBackFunc, &img); while (1) { imshow("img", img); //show if (waitKey(10) > 0) break; } destroyAllWindows(); return 0; }...
findContours, drawContours example code
The code is various example code for drawing contours.
...

...
namedWindow("show1", 0);
namedWindow("threshold", 0);
namedWindow("contours", 0);
Mat img;
img = imread("pattern.jpg");
cvtColor(img, img, CV_RGB2GRAY);
imshow("show1", img);
threshold(img, img, 128, 255, CV_THRESH_BINARY);
imshow("threshold", img);
Mat dst = Mat::zeros(img.rows, img.cols, CV_8UC3);
vector< vector< Point> > contours;
vector< Vec4i> hierarchy;
findContours(img.clone(), contours, hierarchy,
RETR_CCOMP, CHAIN_APPROX_SIMPLE);
//ex 1)
drawContours(dst, contours, -1, CV_RGB(255,0,0), 1, 8, hierarchy);
// iterate through all the top-level contours,
// draw each connected component with its own random color
//ex 2)
int idx = 0;
for (; idx >= 0; idx = hierarchy[idx][0])
{
Scalar color(rand() & 255, rand() & 255, rand() & 255);
//drawContours(dst, contours, idx, color, FILLED, 8, hierarchy);
drawContours(dst, contours, idx, color, 1, 8, hierarchy);
}
//ex3
for (int i = 0; i < contours.size(); ++i)
{
for (int j = 0; j < contours[i].size() - 1; ++j)
{
line(dst, contours[i][j], contours[i][j + 1], CV_RGB(255, 0, 0), 1);
}
line(dst, contours[i][0], contours[i][contours[i].size()-1], CV_RGB(255, 0, 0), 1);
}
//ex4
for (int i = 0; i < contours.size(); ++i)
{
Scalar color(rand() & 255, rand() & 255, rand() & 255);
//drawContours(dst, contours, idx, color, FILLED, 8, hierarchy);
drawContours(dst, contours, i, color, 1, 8, hierarchy);
}
//imshow("show3", img);
imshow("contours", dst);
...12/28/2016
File exist check code
bool fileExists(const char* path)
{
FILE* file;
bool exists;
file = fileOpen(path, "r");
exists = file != 0;
if (file)
fclose(file);
return exists;
}
FILE* fileOpen(const char* path, const char* mode)
{
char path_[PATH_MAX];
assert(path);
resolvePath(path_, sizeof(path_), path);
FILE* fp;
fopen_s(&fp, path_, mode);
return fp;
}
explanation of _CRT_SECURE_NO_WARNINGS, VO_MSE_FUNC_THROUGH_POINTERS option in Visual Studio
I was then able to build your project proceeding as follows:
-in the Preprocessor Definitions, you did not add both compiler options _CRT_SECURE_NO_WARNINGS and VO_MSE_FUNC_THROUGH_POINTERS
_CRT_SECURE_NO_WARNINGS is necessary to use the strcpy function
VO_MSE_FUNC_THROUGH_POINTERS is needed to get the pointers to the exported functions of the libraries
-Also, as your code is c++, you need to add extern "C" to "voEngine engine = NULL;" and "#include"
// global engine (for the sake of readability)
extern "C" voEngine engine = NULL;
// common utility functions
extern "C" {
#include
}
-in the Preprocessor Definitions, you did not add both compiler options _CRT_SECURE_NO_WARNINGS and VO_MSE_FUNC_THROUGH_POINTERS
_CRT_SECURE_NO_WARNINGS is necessary to use the strcpy function
VO_MSE_FUNC_THROUGH_POINTERS is needed to get the pointers to the exported functions of the libraries
-Also, as your code is c++, you need to add extern "C" to "voEngine engine = NULL;" and "#include
// global engine (for the sake of readability)
extern "C" voEngine engine = NULL;
// common utility functions
extern "C" {
#include
}
12/19/2016
Rotation Matrix Convert : Rotation(3x1) -> Matrix(3x3) -> Quntenion(4x1) -> Matrix(3x3) -> Rotation(3x1)
Rotation convert Test
Rotation(3x1) -> Matrix(3x3) -> Quntenion(4x1) -> Matrix(3x3) ->Rotation(3x1)
///
Full source code is here
https://github.com/MareArts/Roation-Convert-Rotation-3x1---Matrix-3x3---Quntenion-4x1---Matrix-3x3---Rotation-3x1-
Rotation(3x1) -> Matrix(3x3) -> Quntenion(4x1) -> Matrix(3x3) ->Rotation(3x1)
///
clc; clear all; %Rotation(3x1) -> Matrix(3x3) -> Quntenion(4x1) -> Matrix(3x3) -> %Rotation(3x1) % Rotation vector of x,y,z axis. Rv = [13 20 50]; % 3x3 matrix of R vector (Results of the Rm1 and Rm2 is similar.) Rm1 = rodrigues(Rv*pi/180) Rm2 = mRotMat(Rv) % Quntenion vector of R matrix Rq1 = matrix2quaternion(Rm1) Rq2 = matrix2quaternion(Rm2) % R matrix of Q vector Rm1_1 = quaternion2matrix(Rq1) Rm2_2 = quaternion2matrix(Rq1) % R vector of R matrix Rv_1 = rodrigues(Rm1_1(1:3,1:3)) * 180/pi Rv_2 = rodrigues(Rm2_2(1:3,1:3)) * 180/pi///
Full source code is here
https://github.com/MareArts/Roation-Convert-Rotation-3x1---Matrix-3x3---Quntenion-4x1---Matrix-3x3---Rotation-3x1-
Subscribe to:
Posts (Atom)
-
Logistic Classifier The logistic classifier is similar to equation of the plane. W is weight vector, X is input vector and y is output...
-
This is data acquisition source code of LMS511(SICK co.) Source code is made by MFC(vs 2008). The sensor is communicated by TCP/IP. ...
-
Image size of origin is 320*240. Processing time is 30.96 second took. The result of stitching The resul...
-
RTSP(Real Time Streaming Protocol) is video streaming, it usually sent from network camera. VideoCapture function in opencv also can get r...
-
Background subtractor example souce code. OpenCV support about 3 types subtraction algorithm. Those are MOG, MOG2, GMG algorithms. Det...
-
Created Date : 2011.2 Language : C/C++ Tool : Microsoft Visual C++ 2010 Library & Utilized : OpenCV 2.2 Reference : Interent Refer...
-
This example source code is to extract HOG feature from images. And save descriptors to XML file. The source code explain how to use HOGD...
-
After training SVM, we should test the trained XML data is reliable or not.. The method to extract HOG feature is refer to -> http://fe...
-
EMD(earth mover distance) method is very good method to compare image similarity. But processing time is slow. For using the EMD compare, ...
-
Created Date : 2011.10 Language : C/C++ Tool : Microsoft Visual C++ 2008 Library & Utilized : OpenCV 2.3 Reference : SIFT referenc...