1/31/2013

Drag and Save source code using openCV

When we study machine learning, we have to get a lot of image data.
And we should cut off only positive region on the image.

If we have many image to crop positive region, this source code is useful.

---------------------------------------------------------------------------------------------------
The method to use is..
1. input the path to crop image data.
2. number of image data 

On the image,
Click and Mouse drag ( green box line is drawn)
Space bar(save and next image)


----------------------------------------------------------------------------------------------------
environment
vs 2008
OpenCV 2.43

source code

1/25/2013

To save Txt file in the Matlab (dlmwrite function)

When you want to save vector values to Txt file, use dlmwrite function.
more detail information find in the matlab help file. (help dlmwrite)

-------------------------------------------------------
 simple example.
>>
>>dlmwrite('./saveV.txt', [1 2 3 4 5], 'delimiter', ' ');


 ->saveV.txt
1 2 3 4 5

--------------------------------------------------------

Thank you. ^^

1/13/2013

Car number plate image data

6 yeasrs ago, Han professor ask me. Don't open this image data.
But because a lot of time has passed.
I think sharing is not illegal. ^^


flate and car #1
flate and car #2
flate and car #3


346 images
< number flate only >

Image data of Car side view - 550

550 images of side view car

I don't remember how to get this images exactly.
I can not sure I made or get other site..

But this image will be useful to someone, so I share this images.

down >



1/12/2013

CvFilter2D example source code, various Filter masks

double K[] = { 1, 2, 1, 2, 4, 2, 1, 2, 1 };

float t=0;
for(int i=0; i< (3*3); ++i)
     t = t + K[i];
for(int i=0; i< (3*3); ++i)
     K[i] = K[i] / t;

CvMat Kernel=cvMat(3, 3, CV_64FC1, K); 
cvFilter2D(InputImg,OutputImg, &Kernel);


various type of filter mask
 
Gaussian Filter 
Average Filter
High pass Filter
Horizontal Prewitt Filter
Vertical Prewitt Filter
Horizontal Sobel Filter
Vertical Sobel Filter
Laplacian Filter
Sharpen Filter
 
Sharpen Low Filter

1/10/2013

C file Write, Read by Binary - example source code

C file Write, Read by Binary - example source code


#include < stdio.h >
#include < stdlib.h >
#include < time.h >


void main()
{


 //////////////////////////////////////////////////////////////////////////
 //File Write by binary
 srand( time(0));
 float feature[10];
 for(int i=0; i<10; ++i) 
  feature[i] = rand()/100; 

 //data confirm
 for(int i=0; i< 10; ++i) 
  printf("%lf\n", feature[i] );

 FILE * fp;
 fp = fopen("output.txt", "wb");
 fwrite(feature, sizeof(float), 10, fp);
 fclose(fp);

 printf("//////////////////////////////////////////////////////////////////////////\n");


 //////////////////////////////////////////////////////////////////////////
 //File Read by binary
 float feature_r[10];
 FILE* fp2;
 fp2 = fopen("output.txt", "rb");
 fread(feature_r, sizeof(float), 10, fp2);
 fclose(fp2);

 //data confirm
 for(int i=0; i< 10; ++i) 
  printf("%lf\n", feature_r[i] );
 //////////////////////////////////////////////////////////////////////////


}




881A sonar sensor - data acquisition source code

881A sonar sensor - data acquisition source code





source code >

This code is also made by VS 2008.
This source code included 'interface_881A' class.
You can get the data easily using the class.





//port open
CString strPort = "COM5";
int baudrate = 115200;
int data = 8;
int parity = 0;
int stop = 0;//1;
C881A.OpenPort2(strPort,baudrate,data,parity,stop);


//request data
C881A.SendData();


//data acquisition part
//The data is saved in the Command_881A_GetData struct
CString str;
 str.Format("%s", C881A.ReceiveData.DataHeader.c_str());
 m_List.AddString(str);

 str.Format("Head ID : %d", C881A.ReceiveData.HeadID);
 m_List.AddString(str);

 str.Format("Head Position : %lf", C881A.ReceiveData.HeadPosition);
 m_List.AddString(str);

 str.Format("Head direction : %d", C881A.ReceiveData.Direction);
 m_List.AddString(str);


 str.Format("Range : %d", C881A.ReceiveData.Range);
 m_List.AddString(str);

 str.Format("Profile Range : %d", C881A.ReceiveData.ProfileRange);
 m_List.AddString(str);

 str.Format("Data Byte : %d", C881A.ReceiveData.DataBytes);
 m_List.AddString(str);
 

 m_List10.ResetContent();
 for(int i=0; i< 500; ++i)
 {
  str.Format("[%d] = %d", i, C881A.ReceiveData.Data[i]);
  m_List10.AddString(str);
 }
 
///////////////////////////


//close port
C881A.ClosePort();



Thank you.