6/29/2017

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.

6/26/2017

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 :
http://study.marearts.com/2014/11/opencv-gpu-3-channel-blur-example.html



6/19/2017

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, ',');


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


Thank you.



6/18/2017

small tip, mfc listbox all delete

ListBox.ResetContent();

^^

tip, CString to int, MFC

CString str; 
int integer; 

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


Thank you~!!


6/15/2017

small tip : Convert char * to LPCTSTR

CA2W(str)

for example

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

^^

6/14/2017

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 >


5/25/2017

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..

<gist>


</gist>


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



5/17/2017

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 >

5/15/2017

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

<gist>

</gist>

4/19/2017

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.
http://study.marearts.com/2014/04/opencv-study-background-subtractor-mog.html

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 >


4/17/2017

floodFill opencv function example

floodFill function example


< gist >

< /gist >






#tags
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 >




#tags

CV_CAP_PROP_FRAME_WIDTH, CV_CAP_PROP_FRAME_HEIGHT, VideoCapture, VideoWriter, waitKey

4/14/2017

3/24/2017

simple code for image coordinate to screen coordinate.


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

< gist code start >

< gist code end >




#Tags
mouse event, setMouseCallback, opencv, Total,

3/20/2017

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



3/14/2017

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

#tags
GaussianBlur, HoughCircles, CV_HOUGH_GRADIENT,

3/08/2017

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_ENV_INCLUDE :
/tbb2017_20170226oss_win/tbb2017_20170226oss/include

TBB_ENV_LIB :
/tbb2017_20170226oss_win/tbb2017_20170226oss/lib/ia32/vc12/tbb.lib

TBB_ENV_LIB_DEBUG :
/opencv/tbb2017_20170226oss_win/tbb2017_20170226oss/lib/ia32/vc12/tbb_debug.

TBB_VER_FILE :
/tbb2017_20170226oss_win/tbb2017_20170226oss/include/tbb/tbb_stddef.h


3/06/2017

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.


2/24/2017

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

2/23/2017

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

2/08/2017

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
VTK_MODULE_INIT(vtkInteractionStyle);
Or
#define vtkRenderingCore_AUTOINIT 2(vtkRenderingOpenGL2, vtkInteractionStyle)

More detail
refer to this url
http://stackoverflow.com/questions/18642155/no-override-found-for-vtkpolydatamapper

1/31/2017

Including VTK when building opencv

First, we download VTK and build it.
http://www.vtk.org/download/

and
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.

http://cvlecture.marearts.com/2016/12/opencv-build-shared-opencv.html
If you go to the above address, I have built VTK 7.1.
And new content will continue to be added.

Good luck!

1/03/2017

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
http://study.marearts.com/2017/01/unicode-cstring-convert-to-char.html

And refer to GetMacAddress code
http://study.marearts.com/2017/01/get-mac-address-in-mfc.html

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 >


#tags
wchar_t, WtoC, WideCharToMultiByte, WideCharToMultiByte

useful site for CString converting


http://www.flounder.com/cstring.htm#Converting%20a%20CString%20to%20an%20integer


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

..