acquire images from gige vision cameras -凯发k8网页登录

main content

acquire images from gige vision cameras

create the gigecam object

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 .

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 .

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.

acquire one image frame from a gige camera

use the snapshot function to acquire one image frame from a gige vision compliant camera.

  1. 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'
    
  2. 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.

  3. 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.

  4. 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 .

  5. optionally, use any of the gige camera commands that your camera supports.

    for more information, see .

  6. close the preview.

    closepreview(g)
  7. acquire a single image from the camera using the snapshot function, and assign it to the variable img

    img = snapshot(g);
  8. display the acquired image.

    imshow(img)
  9. clean up by clearing the object.

    clear g
网站地图