MareArts ANPR mobile app

Showing posts with label Sensor. Show all posts
Showing posts with label Sensor. Show all posts

2/03/2015

Two 3DM-GX3 data acquisition



Some students asked me how to get the two 3dm-gx3 data.
And he wants to save the data to the txt file at the same time.
He has no c ++ coding experience so request me a favor.

Refer to this page, how to get data from 3dm-gx3.
http://feelmare.blogspot.kr/2013/01/3dm-gx3-imu-sensor-data-acquisition.html


And this link is for him.
The program can get data from two imu sensors.
https://drive.google.com/file/d/0B7Z5A9fd6h29cnB6aHNuZmY0ZjA/view?usp=sharing
or
github url : https://github.com/MareArts/Two-3DM-GX3-data-acquisition

When you open a comport, data acquisition and write to txt file.
And when you close your comfort, the record is completed in a txt file.

I hope you applied again to the desired shape in the program.
Note that the method of serial communication with MATLAB also.

Thank you.





11/10/2013

Bumblebee housing & bracket

Bumblebee housing & bracket

The first version.
There are still many things need to be modified.







3/09/2013

SICK LMS511 sensor data acquisition interface (source code, C++/MFC)

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.
You can set sensor ip and test running by  sopas program.
The sopas program is included in the manual CD.



This movie is running test video.






LMS511 communication sample code (tcp/ip)

reference here
http://study.marearts.com/2013/03/sick-lms511-sensor-data-acquisition.html

Source code is here(github)
https://github.com/MareArts/LMS511-SICK-Laser-sensor-communication-tcp-ip

youtube
https://www.youtube.com/watch?v=2LTpaDGus1Y


Thank you.

1/10/2013

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.


3DM-GX3 IMU sensor - Data acquisition source code

3DM-GX3 IMU sensor - Data acquisition source code


Code is made by Visual studio 2008(C++).


There is "3DM_GX3_interface" class In the source code.
You can get IMU data easily using the class.



//Open Port 
CString strPort = "COM7";
int baudrate = 115200; //19200;
int data = 8;
int parity = 0;
int stop = 0;//1;
C3DM_GX3.OpenPort2(strPort,baudrate,data,parity,stop);


//Request Data to the IMU, This function need one time when start to acquisition.
C3DM_GX3.SendData()

//Get Data loop until end.
C3DM_GX3.ReceiveData.roll/3.14*180 ;
C3DM_GX3.ReceiveData.pitch/3.14*180 ;
C3DM_GX3.ReceiveData.yaw/3.14*180 ;

//Close Port
C3DM_GX3.ClosePort();




"How to change 4byte bit data to float" is used to get the roll, yaw, pitch.
The method is introduced on my blog here.


this code is useful to you.
Thank you.

4/25/2012

Convert from FlyCapture(Point grey) to OpenCV (Source code)

Convert from FlyCapture(Point grey) to OpenCV (Source code)

My environment :
FlyCapture 2.x
OpenCV 2.3
VS 2010


This source code is referred to this site (in korean).

*You have to set to use flycapture lib.

-Firstly, set "include, lib" directory on your vs studio.
I have set this path to my vs option.
"C:\Program Files (x86)\Point Grey Research\FlyCapture2\include"
"C:\Program Files (x86)\Point Grey Research\FlyCapture2\lib"

-Second, set Additional Dependencies on project property.
Add these libs
"flycapture2.lib FlyCapture2GUI.lib"

-Third, include this header file on your source code.
#include "FlyCapture2.h"
#include "FlyCapture2GUI.h"


Below source code is core part to convert flycaptuer to opencv.
This part is included in the linked surce code.
In detail, please refer to my source code.

Thank you.

[source code]




// Camera GUID acquisition 카메라 GUID 획득
 m_error = m_BusManager.GetCameraFromIndex(0,&m_Guid);
 // Camera connection 카메라 연결
 m_error = m_Cam.Connect(&m_Guid);
 // Grap start 영상 획득 시작
 m_error = m_Cam.StartCapture();

 m_pDC=GetDC();
 m_pDC->SetStretchBltMode(COLORONCOLOR);
 m_bitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
 m_bitmapInfo.bmiHeader.biPlanes=1;
 m_bitmapInfo.bmiHeader.biCompression=BI_RGB;
 m_bitmapInfo.bmiHeader.biXPelsPerMeter=100;
 m_bitmapInfo.bmiHeader.biYPelsPerMeter=100;
 m_bitmapInfo.bmiHeader.biClrUsed=0;
 m_bitmapInfo.bmiHeader.biClrImportant=0;
 m_bitmapInfo.bmiHeader.biBitCount=24;
 m_bitmapInfo.bmiHeader.biSizeImage=0;


 while(m_ThreadContinue)
 {
  m_error = m_Cam.RetrieveBuffer(&m_Image);

  // convert to RGB type 획득한영상RGB 형태로변환
  m_error = m_Image.Convert(PIXEL_FORMAT_BGR, &m_ImageColor);

  if( CvImg == NULL)
   CvImg = cvCreateImage(cvSize(m_ImageColor.GetCols(),m_ImageColor.GetRows()),8,3);
  memcpy(CvImg->imageDataOrigin,m_ImageColor.GetData() ,m_ImageColor.GetCols()*m_ImageColor.GetRows()*3);
  
  /*
  //Simple Processing
  for(int i=0; iheight; ++i)
  {
   for(int j=0; jwidth; ++j)
   {
    CvImg->imageData[i*CvImg->widthStep+j*3+2] = 255 - CvImg->imageData[i*CvImg->widthStep+j*3+2];
    CvImg->imageData[i*CvImg->widthStep+j*3+1] = 255 - CvImg->imageData[i*CvImg->widthStep+j*3+1];
    CvImg->imageData[i*CvImg->widthStep+j*3+0] = 255 - CvImg->imageData[i*CvImg->widthStep+j*3+0];
   }
  }
  */

  m_bitmapInfo.bmiHeader.biWidth=m_Image.GetCols();
  m_bitmapInfo.bmiHeader.biHeight=-m_Image.GetRows();  
  StretchDIBits(m_pDC->GetSafeHdc(),0,0,320,240,0,0,m_ImageColor.GetCols(),m_ImageColor.GetRows(),CvImg->imageDataOrigin,&m_bitmapInfo,DIB_RGB_COLORS,SRCCOPY);
 }

 
 ReleaseDC(m_pDC);
 SetEvent(m_heventThreadDone);




2/29/2012

To convert from MyVisionUSB to OpenCV and Display (source code)



This is sample source to convert MyVision USB to OpenCV.
You need MyVision USB library to handle image buffer.

This link is included "MVULib.lib, MVULib.dll, MyVision.h".
Lib Download
And you can download driver file on the http://withrobot.com/157.


The below source is sample code to convert MyVision USB to OpenCV.
This code don't use memcpy. so it is little bit slow. The code needs upgrade to speed up.

#include < stdio.h >
#include < cv.h >
#include < cxcore.h >
#include < highgui.h >
#include < cvaux.h >
#include "MyVision.h"

using namespace std;

void main()
{

 //////////////////////////////////////////////////
 //MyVisionUSB Setting
 HBUF m_hBuf;
 HDIG m_hDig;
 char* ver = sysGetLibVer();
 if(strcmp(ver, MV_LIB_VER) != 0)
  printf("incorrect library version\n");
 m_hBuf = bufAlloc(640,480, MV_RGB32 | MV_DOUBLE);
 if(!m_hBuf)
  printf("Cann't Alloc Buffer\n");
 m_hDig = digAlloc(MV_DEV0);
 if(!m_hDig)
  printf("Cann't Alloc Digitizer");
 digGrabContinuous(m_hDig, m_hBuf);
 RGB32_T** pixel = (RGB32_T**)bufGetPtr2D(m_hBuf);
 ////////////////////////////////////////////////////



 //////////////////////////////////////////////////////////////////////////
 //OpenCV Setting
 cvNamedWindow("MyVisionUSBtoOpenCV",CV_WINDOW_AUTOSIZE);
 IplImage * img = cvCreateImage(cvSize(640,480), 8, 3);


 int color, R, G, B, c; 
 while(1)
 {  
  digGrabWait(m_hDig, MV_FIELD_EVEN);

  for(int i=0; i<480 color="color" for="for" i="i" int="int" j="j" r="RGB32_TO_R(color);" xff0000="xff0000">>16);
    G = RGB32_TO_G(color);  // (((color)&0x00ff00)>>8);
    B = RGB32_TO_B(color);  // (((color)&0x0000ff));

    img->imageData[i*img->widthStep+j*3+0] = B;
    img->imageData[i*img->widthStep+j*3+1] = G;
    img->imageData[i*img->widthStep+j*3+2] = R;
   }
  }

  cvShowImage("MyVisionUSBtoOpenCV",img);    
  if( cvWaitKey(10) > 0 )
   break;
 }


 //////////////////////////////////////////////////////////////////////////
 //release memory
 cvReleaseImage(&img);
 cvDestroyAllWindows();
 //
 digHalt(m_hDig);
 digFree(m_hDig);
 bufFree(m_hBuf);


}





2/24/2012

Open Cv with Ip Camera (AXIS)

If your Ip camera production is AXIS, download Axis media control sdk on the this web page
http://www.axis.com/techsup/cam_servers/dev/activex.htm
And Install.

Add the axis control on you dlg box.
You can make the AxisMediaControl icon by choose items(right button click on the toolbox menu)->com components tap.
And add the AxisMediaControl on you dlg.

Plase refer to below video clip description of the rest steps. It is very useful video clip.
http://www.youtube.com/watch?v=g6lYJBABWRs&feature=player_detailpage


I am writing left article...

10/17/2011

BumBleBee 2D, 3D data acquisition source code / 범블비 2D, 3D 데이터 획득 소스

Created Date : 2009.10.
Language : C++
Tool : Visual Studio C++ 2008
Library & Utilized : Point Grey-FlyCapture, Triclops, OpenCV 2.1
Reference : PointGrey Bumblebee Reference, www.cylod.com, www.ptgrey.com/
Etc. : STL



BumBleBee Stereo Camera Data Acquisition Source code.



This is Stereo Camera. The name is BumBleBee. This is product of PointGrey Company.
This camera is IEEE 1394 capble type.
This camera can obtain 3D cloud data rapidly and continously.

I need 2 library for using this camera(Triclops SDK, FlyCapture).
You can download these libs on the www.ptgrey.com site(support).
You have to use my source after install libs. and you have to set path(To include directory, lib directory). and you also need opencv 2.1 lib.

I made the acquisition code as class. The class name is CSensorStereo2.
You can use this class like below source code.
The sequence is 'Open->GetData->Close'.
I did that 2D data save Iplimage in opencv and 3D depth data save as Txt file.
The source code is very easy to use ^^.
If you have any question, Plz give your comments to me.

Thank you.

source code is shared on Github
https://github.com/MareArts/Bumblebee_GetDataClass



#include <stdio.h>
#include "SensorStereo2.h"
#include <time.h>

void main()
{

int Width = 320;
int Height = 240; 

CSensorStereo2 CSS2;
CSS2.Initial(Width,Height); 
CSS2.Open();

cvNamedWindow("Reference");
char str[1000];

while(1) {

//get 1 frame data(Image, Depth information)
CSS2.GetData();

//Show Image
cvShowImage("Reference",CSS2.ImgReference); 

//Save Depth
sprintf(str,"./DepthData/%d_Depth.txt",time(0));
printf("%s\n", str);

FILE * fp; fp = fopen(str,"w");
for(int i=0; i<Width; ++i)
{ 
  for(int j=0; j<Height; ++j)
  {
    fprintf(fp,"%lf %lf %lf\n", CSS2.pDepth[i][j].x, CSS2.pDepth[i][j].y, CSS2.pDepth[i][j].z );
  } 
}

fclose(fp);

if(cvWaitKey(1) >= 0 )
   break;
}

cvDestroyWindow("Reference");
CSS2.Close();
}















 

9/02/2011

SICK LMS sensor communication interface / C++ source code (MFC) / SICK 레이져 센서 커뮤니케이션 소스


Created Date : 2010.6
Language : C++(MFC)
Tool : Visual C++ 6.0
Library & Utilized : -
Reference :  Sensor Manual, Internet Reference
etc. : SICK sensor, serial cable, power cable ... some equips about SICK









This program is SICK LMS communication application.
I made this code when I prepare 'Unmanned vehicle competition - hosted Hyundai-Kia'.
Communication method is Serial.
This zip file includes manual of SICK and useful site about LMS sensor.





reference is here http://study.marearts.com/2011/09/sick-lms-sensor-inteface-c-mfc.html

source code is here https://github.com/MareArts/LMS-Laser-sensor




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




SICK LMS센서와 Serial 통신을 통하여 포트를 열고,
LMS센서의 스캔 데이터를 받아서 화면에 그려주는 소스.
LMS의 보오드, 스캔 레졸루션, 단위를 설정할 수 있다.
마우스 휠을 통하여 그려주는 화면을 축소,확대 할 수 있다.
(SICK 메뉴얼 포함, LMS설명 관련 사이트 캡쳐 파일 포함)