2/23/2012

(TIP) afxcontrolbars.h - No such file or directory Error!

If you meet this error message "afxcontrolbars.h - No such file or directory...", while complie on the VS C++.
You can solve this problem easily by installing Visual Studio Serviece Pack 1.0.

Download appropriate language version and install.

[vs90 sp1 English]
[vs90 sp1 Korea]

2/15/2012

(TIP) To get Color Information of specific pixel coordinate in the OpenGL

The method is simple to to get Color Information of specific pixel coordinate in the OpenGL is simple.
glReadPixels function enables these task.
The example source code is as follows.

struct{ GLubyte red, green, blue; } pixelColor;
glReadPixels(int(i), int(j), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pixelColor);

But the drawback is too slow and we can get exact color information after view rendering.
Thanks.


2/09/2012

To Save OpenGL ViewPort to Image File (glReadPixels, OpenGL->OpenCV)


You can save the Viewport of OpenGL to Image file using glReadPixels function.
And this code is example for saving image file using openCV.
Thank you.

void CaptureViewPort()
{
 
 GLubyte * bits; //RGB bits
 GLint viewport[4]; //current viewport
  
 //get current viewport
 glGetIntegerv(GL_VIEWPORT, viewport);

 int w = viewport[2];
 int h = viewport[3];
 
 bits = new GLubyte[w*3*h];

 //read pixel from frame buffer
 glFinish(); //finish all commands of OpenGL
 glPixelStorei(GL_PACK_ALIGNMENT,1); //or glPixelStorei(GL_PACK_ALIGNMENT,4);
 glPixelStorei(GL_PACK_ROW_LENGTH, 0);
 glPixelStorei(GL_PACK_SKIP_ROWS, 0);
 glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
 glReadPixels(0, 0, w, h, GL_BGR_EXT, GL_UNSIGNED_BYTE, bits);

 IplImage * capImg = cvCreateImage( cvSize(w,h), IPL_DEPTH_8U, 3);
 for(int i=0; i < h; ++i)
 {
  for(int j=0; j < w; ++j)
  {
   capImg->imageData[i*capImg->widthStep + j*3+0] = (unsigned char)(bits[(h-i-1)*3*w + j*3+0]);
   capImg->imageData[i*capImg->widthStep + j*3+1] = (unsigned char)(bits[(h-i-1)*3*w + j*3+1]);
   capImg->imageData[i*capImg->widthStep + j*3+2] = (unsigned char)(bits[(h-i-1)*3*w + j*3+2]);
  }
 }

 cvSaveImage("result.jpg",capImg); 
 cvReleaseImage(&capImg); 
 delete[] bits; 
 
}

2/07/2012

(TIP) Check the radio button control / MFC or API

[mfc case]
((CButton*)GetDlgItem(IDC_RADIO))->SetCheck(true);

[api case]
HWND hWnd;
hWnd = ::GetDlgItem(GetSafeHwnd(), IDC_RADIO_NOTIFY_ALL);
::CheckRadioButton(hWnd, IDC_RADIO_NOTIFY_ALL, IDC_RADIO_NOTIFY_CONTENTS, IDC_RADIO_NOTIFY_ALL);
::SendMessage(hWnd, BM_SETCHECK, (WPARAM)BST_CHECKED, NULL);

1/31/2012

Distance Tx, Ty according to Heading direction when you know the current point(x,y) - math note

Distance Tx, Ty according to Heading direction when you know the current point(x,y) - math note




Thank you~ ^^.

1/26/2012

(TIP) Maple 15 - The method of the Matrix multiply (3by3 Rotation matrix)

(TIP) Maple 15 - The method of the Matrix multiply

Show the below example~


or
We can use LinearAlgebra command. Using 'with(LinearAlgebra)' keyword
Show next example~



Thank you~ ^^

1/24/2012

(TIP) Maple 15 - the method of the matrix differential

(TIP) The method of the matrix differential in the Maple 15 math tool.
You should use "map" function. Show the below example.


Thanks you. ^^