// Copy a file into a byte array:
using (Stream fs = m_camera.CreateFileStream( fileName, System.IO.FileAccess.Read ))
using (MemoryStream ms = new MemoryStream())
{
fs.CopyTo( ms );
byte [] Buffer = ms.ToArray();
}
camera.Parameters[PLCamera.Width].GetValue();
// Example
// Selects a USB camera with serial number 20399956
var cameraInfoFilter = new Dictionary<string, string>
{
{CameraInfoKey.SerialNumber, "20399956"},
{CameraInfoKey.DeviceType, DeviceType.Usb}
};
// Shown for demonstration purposes only.
// Selects a GigE camera with known IP Address "192.168.0.101"
var cameraInfoFilter2 = new Dictionary<string, string>
{
{CameraInfoKey.DeviceIpAddress, "192.168.0.101"},
{CameraInfoKey.DeviceType, DeviceType.GigE}
};
// Shown for demonstration purposes only.
// Selects a USB camera with DeviceUserID TopCamera
// See https://docs.baslerweb.com/#t=en%2Fdevice_information_parameters.htm
// or PLCamera.DeviceUserID for more information.
var cameraInfoFilter3 = new Dictionary<string, string>
{
{CameraInfoKey.UserDefinedName, "TopCamera"},
{CameraInfoKey.DeviceType, DeviceType.Usb}
};
// Shown for demonstration purposes only.
// Selects a GigE camera model acA1920-50gc having device DeviceUserID TopCamera
var cameraInfoFilter4 = new Dictionary<string, string>
{
{CameraInfoKey.ModelName, "acA1920-50gc"},
{CameraInfoKey.UserDefinedName, "TopCamera"},
{CameraInfoKey.DeviceType, DeviceType.GigE}
};
using (ICamera cameraTest = new Camera(cameraInfoFilter, CameraSelectionStrategy.Unambiguous))
{
//use the camera
}
// Example
// Selects a USB camera with serial number 20399956
var cameraInfoFilter = new Dictionary<string, string>
{
{CameraInfoKey.SerialNumber, "20399956"},
{CameraInfoKey.DeviceType, DeviceType.Usb}
};
// Shown for demonstration purposes only.
// Selects a GigE camera with known IP Address "192.168.0.101"
var cameraInfoFilter2 = new Dictionary<string, string>
{
{CameraInfoKey.DeviceIpAddress, "192.168.0.101"},
{CameraInfoKey.DeviceType, DeviceType.GigE}
};
// Shown for demonstration purposes only.
// Selects a USB camera with DeviceUserID TopCamera
// See https://docs.baslerweb.com/#t=en%2Fdevice_information_parameters.htm
// or PLCamera.DeviceUserID for more information.
var cameraInfoFilter3 = new Dictionary<string, string>
{
{CameraInfoKey.UserDefinedName, "TopCamera"},
{CameraInfoKey.DeviceType, DeviceType.Usb}
};
// Shown for demonstration purposes only.
// Selects a GigE camera model acA1920-50gc having device DeviceUserID TopCamera
var cameraInfoFilter4 = new Dictionary<string, string>
{
{CameraInfoKey.ModelName, "acA1920-50gc"},
{CameraInfoKey.UserDefinedName, "TopCamera"},
{CameraInfoKey.DeviceType, DeviceType.GigE}
};
using (ICamera cameraTest = new Camera(cameraInfoFilter, CameraSelectionStrategy.Unambiguous))
{
//use the camera
}
using (ICamera camera = new Camera(DeviceType.Usb, CameraSelectionStrategy.FirstFound))
{
//use the first found USB camera
}
using (ICamera camera = new Camera("20399956"))
{
//use the camera with serial number 20399956
}
videowriter.Parameters[PLVideoWriter.BytesWritten].GetValue();
Preconditions
- The file is open.
- The image is valid.
- The pixel type of the image is supported by pylon.
- The width and height of the image match the values passed when opening the video file.
camera.Parameters[PLFormatConverter.OutputPaddingX].GetValue();
mono = (0.25 * red) + (0.625 * green) + (0.125 * blue);
YUV formats are converted to 16 bit bit depth in an intermediate conversion step. This is why the output
is always aligned at the most significant bit when converting to 16 bit color output formats like RGB16packed.
interface.Parameters[PLInterface.InterfaceType].GetValue();
//grab one image
camera.StreamGrabber.Start(1, GrabStrategy.OneByOne, GrabLoop.ProvidedByUser);
//grab is stopped automatically due to maxImages = 1
return camera.StreamGrabber.RetrieveResult( timeoutMs, timeoutHandling);
private void OnImageGrabbed(Object sender, ImageGrabbedEventArgs e)
{
if (InvokeRequired)
{
// If called from a different thread, we must use the Invoke method to marshal the call to the proper thread.
BeginInvoke(new EventHandler<ImageGrabbedEventArgs>(OnImageGrabbed), sender, e.Clone());
return;
}
try
{
//do something
}
finally
{
e.DisposeGrabResultIfClone();
}
}
interface.Parameters[PLInterface.InterfaceType].GetValue();
// Retrieve a grab result and show all data components.
IGrabResult grabResult = camera.StreamGrabber.RetrieveResult( 5000, TimeoutHandling.ThrowException );
Console.WriteLine( "Found {0} components in the container.", grabResult.Container.Count );
// Display each component in a separate window.
int displayId = 1;
foreach( IDataComponent dataComponent in grabResult.Container )
{
if (dataComponent.IsValid)
{
Console.WriteLine( "Component type {0}", dataComponent.ComponentType.ToString() );
Console.WriteLine( "2D Size is {0}*{1} pixel", dataComponent.Width, dataComponent.Height );
Console.WriteLine( "Origins from ({0},{1})", dataComponent.OffsetX, dataComponent.OffsetY );
Console.WriteLine( "Pixel type is {0}", dataComponent.PixelTypeValue.ToString() );
Console.WriteLine( "Timestamp is {0}", dataComponent.Timestamp );
Console.WriteLine( "See image in display {0}:", displayId );
dataComponent.Display( displayId );
}
}
Preconditions
- The file is open.
- The image is valid.
- The pixel type of the image is supported by pylon.
- The width and height of the image match the values passed when opening the video file.
// Copy a file into a byte array:
using (Stream fs = m_camera.CreateFileStream( fileName, System.IO.FileAccess.Read ))
using (MemoryStream ms = new MemoryStream())
{
fs.CopyTo( ms );
byte [] Buffer = ms.ToArray();
}
camera.Parameters[PLCamera.Width].GetValue();
PixelType a = "Mono8".ToPixelType();