list_files and tuple_regexp_select function

Keywords: data structure list

#Get image
read_image(Image,'E:/C/Halcon/1.jpg')
#Read images of the entire folder
#1 list the files in the specified path
list_files('E:/C/Halcon',['files','follow_links'],ImageFiles)
#2. Select qualified documents
tuple_regexp_select(ImageFiles,['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'],ImageFiles)
#3 cycle to read the image under the folder
for Index :=0 to |ImageFiles|-1 by 1
    read_image(Image,ImageFiles[Index])
endfor

Get a single:

#Get image
read_image(Image,'E:/C/Halcon/1.jpg')

Get the contents of an entire folder:

#Read images of the entire folder
#1 list the files in the specified path
list_files('E:/C/Halcon',['files','follow_links'],ImageFiles)
#2. Select qualified documents
tuple_regexp_select(ImageFiles,['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'],ImageFiles)
#3 cycle to read the image under the folder
for Index :=0 to |ImageFiles|-1 by 1
    read_image(Image,ImageFiles[Index])
endfor

Code interpretation:

list_files('E:/C/Halcon',['files','follow_links'],ImageFiles)

The list() method returns the file names of all files and directories in a directory, and returns a String array

The listFiles() method returns the absolute paths of all files and directories in a directory, and returns the File array

Function prototype: list_files(::Directory,Options:Files)

Function: lists all files in the directory

Parameter list:

The first parameter, Directory, is the input variable and the Directory name to be listed

The second parameter Options is the input variable. The default value is files. The recommended values are: 'files',' directories', 'recursive', 'follow'_ links', 'max_ Depth 5 '(traversal depth),' max_files 1000 '(maximum number of files read)

 

The third parameter, Files, is the output variable and the read file

tuple_regexp_select(ImageFiles,['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'],ImageFiles)

Prototype: tuple_regexp_select (:: data, expression: selection)

Function: file format filtering

Parameter list:

Data: array of selected file paths

Expression: filtering rules for file formats

 

Selection: array of selected file paths

Get real-time images

open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', 8, 'rgb', -1, 'false', 'default', '[0] Sunplus Camera', 0, -1, AcqHandle)
grab_image_start (AcqHandle, -1)
while (true)
    grab_image_async (Image, AcqHandle, -1)
    * Image Acquisition 01: Do something
endwhile
close_framegrabber (AcqHandle)

Code interpretation:

open_framegrabber ('DirectShow', 1, 1, 0, 0, 0, 0, 'default', 8, 'rgb', -1, 'false', 'default', '[0] Sunplus Camera', 0, -1, AcqHandle)

Prototype:

open_framegrabber ( : : Name, HorizontalResolution,

VerticalResolution, ImageWidth, ImageHeight, StartRow, StartColumn,

Field, BitsPerChannel, ColorSpace, Generic, ExternalTrigger,

CameraType, Device, Port, LineIn : AcqHandle )

Function: open the image acquisition device

Parameter information:

    Name: name of the image acquisition device

    HorizontalResolution and VerticalResolution: refer to the horizontal resolution and vertical resolution of the expected image acquisition interface, respectively

    ImageWidth and ImageHeight: refers to the width and height of the expected image. The default is 0

    StartRow and StartColumn: refers to the start coordinates of the display of the expected image                  Default 0

    Field: the expected image is a half image or a complete image    default,

    BitsPerChannel: bits per pixel and image channel    Default - 1

    ColorSpace: captured image of output color format {gray, raw, rgb, yuv, default} default,

    Generic: specific meaning of general parameters and equipment details. Default - 1

    ExternalTrigger: is there an external trigger

    CameraType: the type of camera used    default,

    Device: the device to which the image acquisition device is connected. The default is default. onfo_framegrabber can be used to query

    Port: the port to which the image acquisition device is connected. The default is - 1

    LineIn: multiplexer for camera input

    AcqHandle: Handle of image acquisition device

Set other parameters of the camera: Set_framegrabber_param

grab_image_start (AcqHandle, -1)

Asynchronous collection: not required   After collecting and processing, collect the next time

grab_image: collect the next time after collecting and processing

External trigger acquisition image:

Multi camera asynchronous acquisition and multi camera synchronous acquisition

Posted by plezops on Wed, 10 Nov 2021 07:13:45 -0800