To acquire images from a GigE Vision Compliant camera, you first
use the gigecam
function to create a GigE object.
You can use it in one of three ways:
Connect to the first or only camera, using no input arguments
Specify a camera by IP address, using the address (specified as a character vector) as an input argument
Specify a camera by the list order, using an index number as the input argument
Specify a camera by serial number, using the number (as a character vector) as an input argument
You can also optionally set a property when you create the object. For more information, see Set Properties for GigE Acquisition.
Note that you cannot create more than one object connected to the same device, and trying to do that generates an error.
After you create the object, you can preview and acquire images.
Note
The GigE Vision support requires that you download and install
the necessary files via MATLAB® Add-Ons. The GigE Vision Hardware
support package installs the files for both the gige
adaptor
for the videoinput
object and the gigecam
object.
For more information, see Installing the Support Packages for Image Acquisition Toolbox Adaptors.
Create a gigecam Object Using No Arguments
Use the gigecamlist
function to ensure that MATLAB is
discovering your camera.
gigecamlist
ans = Model Manufacturer IPAddress SerialNumber ____________________ ___________________ _______________ ______________ 'MV1-D1312-80-G2-12' 'Photonofocus AG' '169.254.192.165' '022600017445'
Using the gigecam
function with no arguments
creates the object, and connects to the single GigE Vision camera
on your system. If you have multiple cameras and you use the gigecam
function
with no input argument, it creates the object and connects it to the
first camera it finds listed in the output of the gigecamlist
function.
Create an object, g
.
g = gigecam
g = Display Summary for gigecam: DeviceModelName: 'MV1-D1312-80-G2-12' SerialNumber: '022600017445' IPAddress: '169.254.192.165' PixelFormat: 'Mono8' AvailablePixelFormats: {'Mono8' 'Mono10Packed' 'Mono12Packed' 'Mono10' 'Mono12'} Height: 1082 Width: 1312 Timeout: 10 Show Beginner, Expert, Guru properties. Show Commands.
Create a gigecam Object Using IP Address
Use the gigecam
function with the IP address
of the camera (specified as a character vector) as the input argument
to create the object and connect it to the camera with that address.
You can see the IP address for your camera in the list returned by
the gigecamlist
function.
Use the gigecamlist
function to ensure that MATLAB is
discovering your cameras.
gigecamlist
ans = Model Manufacturer IPAddress SerialNumber ____________________ ___________________ _______________ ______________ 'MV1-D1312-80-G2-12' 'Photonofocus AG' '169.254.192.165' '022600017445' 'mvBlueCOUGER-X120aG' 'MATRIX VISION GmbH' '169.254.242.122' 'GX000818'
Create an object, g
, using the IP address
of the camera.
g = gigecam('169.254.242.122')
g = Display Summary for gigecam: DeviceModelName: 'mvBlueCOUGER-X120aG' SerialNumber: 'GX000818' IPAddress: '169.254.242.122' PixelFormat: 'Mono8' AvailablePixelFormats: {'Mono8' 'Mono12' 'Mono14' 'Mono16' 'Mono12Packed' 'BayerGR8' 'BayerGR10' 'BayerGR12' 'BayerGR16' 'BayerGR12Packed' 'YUV422Packed' 'YUV422_YUYVPacked' 'YUV444Packed'} Height: 1082 Width: 1312 Timeout: 10 Show Beginner, Expert, Guru properties. Show Commands.
Create a gigecam Object Using Serial Number
You can also create the object in this same way using the serial number. You use the same syntax, but use a serial number instead of the IP address, also as a character vector.
g = gigecam('022600017445')
Create a gigecam Object Using Device Number as an Index
Use the gigecam
function with an index as
the input argument to create the object corresponding to that index
and connect it to that camera. The index corresponds to the order
of cameras in the table returned by gigecamlist
when
you have multiple cameras connected.
Use the gigecamlist
function to ensure that MATLAB is
discovering your cameras.
gigecamlist
ans = Model Manufacturer IPAddress SerialNumber ____________________ ___________________ _______________ ______________ 'MV1-D1312-80-G2-12' 'Photonofocus AG' '169.254.192.165' '022600017445' 'mvBlueCOUGER-X120aG' 'MATRIX VISION GmbH' '169.254.242.122' 'GX000818'
Create an object, g
, using the index number.
g = gigecam(2)
g = Display Summary for gigecam: DeviceModelName: 'mvBlueCOUGER-X120aG' SerialNumber: 'GX000818' IPAddress: '169.254.242.122' PixelFormat: 'Mono8' AvailablePixelFormats: {'Mono8' 'Mono12' 'Mono14' 'Mono16' 'Mono12Packed' 'BayerGR8' 'BayerGR10' 'BayerGR12' 'BayerGR16' 'BayerGR12Packed' 'YUV422Packed' 'YUV422_YUYVPacked' 'YUV444Packed'} Height: 1082 Width: 1312 Timeout: 10 Show Beginner, Expert, Guru properties. Show Commands.
It creates the object and connects it to the Matrix Vision camera
with that index number, in this case, the second one displayed by gigecamlist
.
If you only have one camera, you do not need to use the index.
Use the snapshot
function to acquire one
image frame from a GigE Vision Compliant camera.
Use the gigecamlist
function to
ensure that MATLAB is discovering your camera.
gigecamlist
ans = Model Manufacturer IPAddress SerialNumber ____________________ ___________________ _______________ ______________ 'MV1-D1312-80-G2-12' 'Photonofocus AG' '169.254.192.165' '022600017445'
Use the gigecam
function to create
the object and connect it to the camera.
g = gigecam
g = Display Summary for gigecam: DeviceModelName: 'MV1-D1312-80-G2-12' SerialNumber: '022600017445' IPAddress: '169.254.192.165' PixelFormat: 'Mono8' AvailablePixelFormats: {'Mono8' 'Mono10Packed' 'Mono12Packed' 'Mono10' 'Mono12'} Height: 1082 Width: 1312 Timeout: 10 Show Beginner, Expert, Guru properties. Show Commands.
It creates the object and connects it to the Photonofocus AG camera.
Preview the image from the camera.
preview(g)
The preview window displays live video stream from your camera. The preview dynamically updates, so if you change a property while previewing, the image changes to reflect the property change.
Optionally, set any properties. Properties are displayed
when you create the object, as shown in step 2. For example, you could
change the ExposureTime
setting.
g.ExposureTime = 20000
For more information, see Set Properties for GigE Acquisition.
Optionally, use any of the GigE camera commands that your camera supports.
For more information, see Set Properties for GigE Acquisition.
Close the preview.
closePreview(g)
Acquire a single image from the camera using the snapshot
function,
and assign it to the variable img
img = snapshot(g);
Display the acquired image.
imshow(img)
Clean up by clearing the object.
clear g