Home > Net >  C # about halcon and DALSA industrial camera image for development
C # about halcon and DALSA industrial camera image for development

Time:02-26

Comment! On the Internet to find the demo, c # development, use halcon and DALSA DLL,
Now recognize the camera, camera information, connect the camera, all kinds of instantiation including real-time frame rate is OK, is the halcon to obtain image data is a problem,
Paste the code below:
Void m_Xfer_XferNotify (object sender, SapXferNotifyEventArgs argsNotify)
{
//first need to determine whether the frame is discarded frames, if return immediately, waiting for the next frame (but this sentence seems to sometimes m_Xfer. Snap (n) will result in the frame, can try commented out)
If (argsNotify. Trash) return;
//get m_Buffers address (pointer), as long as know the graphics memory address, actually can have ways to get out of the picture (for example to Bitmap)
IntPtr addr.
M_Buffers. GetAddress (out addr);
MessageBox. Show (" addr="+ addr);
//PixelFormat pf=PixelFormat. Format8bppIndexed;
//Bitmap BMP=new Bitmap (m_Buffers. Width, m_Buffers. Height, m_Buffers. Pitch, pf, addr);
Pictures of some of the properties of buffer//observation values, statements inside comments value is possible after
Int count=m_Buffers. Count;//2
SapFormat format=m_Buffers. Format;//Uint8
Double rate=m_Buffers. FrameRate; 30.0//acquisition frequency, continuous acquisition, this value can dynamically change
MessageBox. Show (" rate="+ rate);
Int height=m_Buffers. Height;//1000 high
Int width=m_Buffers. Width;//4096 wide
Int pixd=m_Buffers. PixelDepth;//8 depth, 8 b/pixel
//display real-time frame rate
UpdateFrameRate ();
Lbl_FrameRate. The BeginInvoke (new Action (()=& gt; {lbl_FrameRate. Text=m_Buffers. FrameRate. ToString (); }));
MessageBox. Show (" FrameRate="+ m_Buffers. FrameRate. ToString ());
//use halcon acquisition images from the memory and save
HObject ImageTemp=null;
HOperatorSet. GenImage1 (out ImageTemp, "byte", 4096, 1000, addr);//memory data, generate the image, halcon
MessageBox. Show ("==");
HWindowControl1. HalconWindow. SetPart (0, 0, 1000, 4096);
HOperatorSet. DispObj (ImageTemp, hWindowControl1 HalconWindow);
PicCountNum++;
HOperatorSet. WriteImage (ImageTemp, "BMP," 0, "D: \ \ imga \ " + picCountNum + ". BMP ");
}


A problem is the HOperatorSet. GenImage1 (out ImageTemp, "byte", 4096, 1000, addr); This line, don't play down box,
Also is a bit strange, according to the bullet box printing, I will perform twice, the first frequency as the default 30, update is 0, 0, the second frequency update for the actual frequency,
The main thing is that, in the hope that we can instruct me, why the program to GenImage1 not to perform, no show no picture preserved,
  •  Tags:  
  • C#
  • Related