Error MSB8031, multi byte character set problem in vs 2013

error MSB8031: Building an MFC project for a non-Unicode character set is deprecated. You must change the project property to Unicode or download an additional library. See http://go.microsoft.com/fwlink/p/?LinkId=286820 for more information.

Don't worry about that.
VS 2013 is not support MFC library for MBCS.
They recommend unicode default.

So it can solve easily.
Go below url, download and install.


cvCvtPixToPlane, cvCvtPlaneToPix -> split, merge / example code and explanation

In previous version of oepncv which used iplImage, these functions are used -> cvCvtPixToPlane and cvCvtPlaneToPix.

This article introduces how this functions are used and what to use in the current version.

1. cvCvtPixToPlane

It is same with split function in current version.
So channels of the input image are seperately stored.

ex) old version
iplImage img; //BGR 3 colors image
iplImage B,G,R;
cvCvtPixToPlane(img, B, G, R, NULL);

ex) current version

Mat img; //BGR 3 colors image
vector< Mat > BGR(3);
split(img, BGR);
BGR[0]; //B Mat
BGR[1]; //G Mat
BGR[2]; //R Mat

2. cvCvtPlaneToPix
It is same with mere function in current version.
So each mat is merged into one Mat.

ex) old version

iplImage B,G,R;
iplImage BGR;
cvCvtPlaneToPix(B, G, R, NULL, BGR);

ex) current version
vector< Mat > BGR(3);
Mat img;
merge(BGR, img);

Thank you.

refer to gpu version split and merge example :


tip, CString token in MFC

refer to below code.

CString selectedModel;
m_ListBoxOfConnection.GetText(sel, selectedModel);
//selectedModel = "com1,model1,base";

CString comStr;
CString modelStr;
CString optionStr;

AfxExtractSubString(comStr, selectedModel, 0, ',');
AfxExtractSubString(modelStr, selectedModel, 1, ',');
AfxExtractSubString(optionStr, selectedModel, 2, ',');

//comStr = com1
//modelStr = model1
//optionStr = base

Thank you.


small tip, mfc listbox all delete



tip, CString to int, MFC

CString str; 
int integer; 

integer = _wtoi(str); // wide charater formats 
integer = _atoi(str); // otherwise

Thank you~!!


small tip : Convert char * to LPCTSTR


for example

char str[100];
sprintf(str, "str_%d", 100);
CString A = CA2W(str);



stl vector test for pop back and pop front

STL Vector test for pop_back, pop_back_n and pop front.

I wanted to erase first element.
but there is no inner function.
pop_back, pop_back_n is that erase last element in vectors.
The last sample is the method to pop front.

refer to this sample code.

< gist >

< /gist >


OpenMP Test on Visual Studio

To use OpenMP on Visual Studio IDE, we should set in tools->options like..

Below code is to calculate pi using loop logic.
There are 5 case code.
0 case is for testing, openMP running well or not.

1 case is no treading, else 2~4 case is some different OpenMP threading case.

I am also not friendly with openMP, so I will refer this code when not remember well.
And I will add more useful technical code..



The result image tells us, OpenMP is certainly faster than no threading.


for each, for_each, for auto - concept clean

Clean up the concept through below examples.

1. normal method : for, iterator

2. for auto loop

3. for each loop

4. for_each

refer to this example

It would be better if I could handle the parallel loop.
This is next time.

Thank you.

< gist >

< /gist >


two types of check sum function

First is intel method.
Second is motorora method.

Check sum used to check for packet confidence in serial communication.

refer to this below code




OpenCV Background subtraction 3.2 version example (for MOG, MOG2, GMG, KNN)

This is example for background subtraction on opencv 3.2 version

previously, I post 2.7 version example on here.

But some usage is changed, and knn subtraction method is added.

Many people ask that example based on opencv 3.2

refer to below source code

Thank you.

< gist code >

< /gist code >


floodFill opencv function example

floodFill function example

< gist >

< /gist >

CallBackFunc, EVENT_LBUTTONDOWN, setMouseCallback, rectangle, floodFill,

video show and write keeping original fps

When the video write, we can set parameter in following function..

outVideo.open(".\\outVideo.avi", askFileTypeBox, capture.get(CV_CAP_PROP_FPS), S, Color);

And we can control play speed by waitKey.

double fps = capture.get(CV_CAP_PROP_FPS);
delay Per Second = 1/fps
in milliseconds = 1/fps * 1000

so we delay, waitKey( 1/fps * 1000 )

by the way, it is not exact fps. because it is delayed including other processing in the loop.
for example, data copy, sobel, imshow ...

< gist code >

< /gist code >





simple code for image coordinate to screen coordinate.

Arslan Ahmed, this is the post for you. ^^

< gist code start >

< gist code end >

mouse event, setMouseCallback, opencv, Total,


AMP dose run on my pc?, AMP(Accelerated Massive Parallelism)

AMP is abbreviation of Accelerated Massive Parallelism.
It is maintained by Microsoft and it run based on DirectX 11.
So as I know, AMP works in windows only, but there seems to be an attempt to run on other os.

Basically, AMP run on these environment
  • Windows 7, Windows 8, Windows Server 2008 R2, or Windows Server 2012 
  • DirectX 11 Feature Level 11.0 or later hardware 
  • For debugging on the software emulator, Windows 8 or Windows Server 2012 is required. For debugging on the hardware, you must install the drivers for your graphics card.
And no need to install for AMP, If you use Visual Studio.
So let's check your computer condition for parallel programming.

< code start >

< code end >

This is my condition.

We can check whether run or not by this.

if, accs.size() == 0, then there is no parallel machine.

I think AMP is easy and usefull to use parallel GPU programming.
This is useful for creating Windows applications.

reference site

Korean blog

MS site

MSDN AMP toturial


what is dp parameter in Hough Circle detection on opencv.

dp parameter is about resolution of voting space.
dp is larger, voting resolution is small compare to image size.
so dp is larger, circle detection accuracy is not exact.
but dp is smaller, voting resolution is higher and circle detection is more accurate but that sensitive with noise ex)other edge..
I increase dp from 1 to 5 step by 0.1..

refer to this source code on here.

< gist code >

< end gist >

and result image.


and other reference.
opencv org

stack overflow

python opencv tutorial

GaussianBlur, HoughCircles, CV_HOUGH_GRADIENT,


Refer to this setting when you build opencv with TBB

When you build opencv with checking with_tbb option, cmake ask crrect paths about tbb.

Refer to this setting.
note, this is set for vc12 and 32bit.






TBB doesn't have CMakelist.txt, go to here.

Intel Threading Building Blocks..

I downloaded the source code here -> https://www.threadingbuildingblocks.org/
and I want to build it with cmake.

But I meet this error -> ...does not appear to contain CMakeLists.txt

Looking for a long time to figure out what to do ..
I found this site -> https://github.com/wjakob/tbb

Thank you.


vtkStructuredGrid example for drawing fan shape grid.

This is example code for drawing fan shape grid using vtkStructuredGrid in vtk.

I've looked at a lot of examples that draw like this, but I could not find it.

So this example help for vtk beginner and want to drawing grid.

< code start >

< code end >

#vtkStructuredGrid, #vtk


class member thread using std

class member function threading

1. No argument
< code start >

< code end >

2. additional arguments
< code start >

< code end >

3. Lambda Express
std::thread t( [&] { x.greeting(); } ); //no argument
std::thread t( [&] { x.greeting( "goodbye" ); } ); //with argument

Static or global function threading

< code start >

< code end >

#thread, #std, #lambda


no override found for 'vtkPolyDataMapper'

When meet this error no override found for 'vtkPolyDataMapper' using VTK.
Add this code

#include "vtkAutoInit.h" 
VTK_MODULE_INIT(vtkRenderingOpenGL2); // VTK was built with vtkRenderingOpenGL2
#define vtkRenderingCore_AUTOINIT 2(vtkRenderingOpenGL2, vtkInteractionStyle)

More detail
refer to this url


Including VTK when building opencv

First, we download VTK and build it.

We set the path where VTK is built, when we build opencv.

Note that, we need to include the build path, not the installed path.

If you go to the above address, I have built VTK 7.1.
And new content will continue to be added.

Good luck!


In MFC, File exist check and delete the file, example source code.

If file exist then delete the file, example source code in MFC

< github code >

MFC Encode / Decode example souce code

WtoC function code is here

And refer to GetMacAddress code

Encode code


Decode code


Unicode CString convert to char *

The returned char * will need to be freed after use.

< gist code start >

< gist code end >

wchar_t, WtoC, WideCharToMultiByte, WideCharToMultiByte

useful site for CString converting


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(""));//