EDT PDV SDK Documentation 6.1.0
simple_clsend.c File Reference

(git 551c36c, 2023-10-02)

#include "edtinc.h"
#include "clsim_lib.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tiffio.h>
Include dependency graph for simple_clsend.c:

Data Structures

struct  image_info_t
 

Functions

void usage (const char *progname, const char *errstr)
 
int get_image_info_file (const char *fname, image_info_t **imagelist)
 
ImgFmt check_extension (const char *fname)
 
int get_images_info_dir (const char *dirpath, image_info_t **imagelist)
 
int get_image_info (ImgFmt fmt, image_info_t *image_p)
 
int get_tif_info (image_info_t *img_details)
 
int is_valid_tiff (TIFF *image)
 
int get_gif_info (image_info_t *img_details)
 
int get_ras_info (image_info_t *img_details)
 
int get_raw_info (image_info_t *img_details)
 
int get_bmp_info (image_info_t *img_details)
 
int get_jpg_info (image_info_t *img_details)
 
char * strip_nl (char *s)
 
int comment_or_blank (const char *str)
 
void error_exit (const char *errstr)
 
void free_image_info_list (image_info_t *imagelist, const size_t cnt)
 
int check_image_sizes (image_info_t *list, unsigned int nimages)
 
int load_next_image (PdvDev pdv_p, unsigned int current_image, image_info_t *image_details, unsigned int total_images, u_char **buffers, unsigned int nbuffers, unsigned int buffer_size)
 
long unsigned int fill_buffer_tif (image_info_t *img_details, u_char *buffer, int max_size)
 
int fill_buffer_gif (image_info_t *img_details, u_char *buffer, int max_size)
 
int fill_buffer_bmp (image_info_t *img_details, u_char *buffer, int max_size)
 
int fill_buffer_jpg (image_info_t *img_details, u_char *buffer, int max_size)
 
int fill_buffer_ras (image_info_t *img_details, u_char *buffer, int max_size)
 
int fill_buffer_raw (image_info_t *img_details, u_char *buffer, int max_size)
 
unsigned int edt_min (unsigned int l, unsigned int r)
 
int main (int argc, const char *argv[])
 

Detailed Description

A utility / example program to send multiple TIFF format images through the EDT Camera Link Simulator (CLS) to a Camera Link frame grabber, such as the EDT VisionLink F4.

For a more complex application (including variable width images, left/right fill, etc) with the same purpose see: send_tiffs.c

See the EDT CLS Simulator users guide for detailed information on this application.

Prerequisites: Setup the CLS via the clsiminit application.

Function Documentation

◆ usage()

static void usage ( const char *  progname,
const char *  errmsg 
)

Display usage information.

Parameters
prognameThe name of this program.
errstrA discription of what is invalid about the call.

Display usage information.

Parameters
prognameThe name of this program.
errA description of what is invalid about the call.

Display usage information.

Parameters
prognameThe name of this program.
errmsgA description of what is invalid about the call.
Here is the caller graph for this function:

◆ get_image_info_file()

int get_image_info_file ( const char *  fname,
image_info_t **  imagelist 
)

Retrieve the specified image's information.

Parameters
fnameName of the image file whose information is to be gathered.
imagelistAn array of structures containing information about each image in the imagelist.
Returns
1 if specified file is found and meets format specs, otherwise -1.
Here is the call graph for this function:

◆ check_extension()

ImgFmt check_extension ( const char *  fname)

Validate image type of specified file, based on extension.

Parameters
fnameName of the image file to validate.
Returns
Enum representing the image type. fmt_unk if extension matches nothing.
Here is the caller graph for this function:

◆ get_images_info_dir()

int get_images_info_dir ( const char *  dirpath,
image_info_t **  imagelist 
)

Collect information for all valid images within a specified directory.

Uses the OS independent edt_* directory open / read / close functions.

Parameters
dirpathPath to a directory containing images to validate and collect information upon.
imagelistAn array of structures containing information about each image in the imagelist.

return number of images found, or -1 if error

◆ get_image_info()

int get_image_info ( ImgFmt  fmt,
image_info_t image_p 
)

Retrieve information for a specified image.

Parameters
fmtAn enum representing the image type.
image_pStorage for the image details. Must have pathname specified.
Returns
0 on successful retrieval.

◆ get_tif_info()

int get_tif_info ( image_info_t img_details)

Retrieve information for tiff image.

Parameters
img_detailsStorage for the image details. Must have pathname specified.
Returns
0 on successful retrieval.
Here is the call graph for this function:

◆ is_valid_tiff()

int is_valid_tiff ( TIFF *  image)

Validate the TIFF image; ensure it meets current requirements. Image must be <= 16 bits/pixel and 1 sample/pixel. Image must also define width and height.

Parameters
imageThe image to validate.
Returns
1 (True) if image is valid, 0 (False) otherwise.
Here is the caller graph for this function:

◆ get_gif_info()

int get_gif_info ( image_info_t img_details)

Retrieve information for gif image - STUB.

Parameters
img_detailsStorage for the image details. Must have filename specified.
Returns
1 (True) if image is valid, 0 (False) otherwise.

◆ get_ras_info()

int get_ras_info ( image_info_t img_details)

Retrieve information for ras image - STUB.

Parameters
img_detailsStorage for the image details. Must have filename specified.
Returns
1 (True) if image is valid, 0 (False) otherwise.

◆ get_raw_info()

int get_raw_info ( image_info_t img_details)

Retrieve information for raw image - STUB.

Parameters
img_detailsStorage for the image details. Must have filename specified.
Returns
1 (True) if image is valid, 0 (False) otherwise.

◆ get_bmp_info()

int get_bmp_info ( image_info_t img_details)

Retrieve information for bmp image - STUB.

Parameters
img_detailsStorage for the image details. Must have filename specified.
Returns
1 (True) if image is valid, 0 (False) otherwise.

◆ get_jpg_info()

int get_jpg_info ( image_info_t img_details)

Retrieve information for jpg image - STUB.

Parameters
img_detailsStorage for the image details. Must have filename specified.
Returns
1 (True) if image is valid, 0 (False) otherwise.

◆ strip_nl()

char * strip_nl ( char *  s)

Strip the newline off a string by replacing any terminating (\r or
) with a NULL character.

Parameters
sString to strip any terminating characters from.
Returns
Same string pointer, with \r and
chars replaced.

◆ comment_or_blank()

int comment_or_blank ( const char *  str)

Check the specified string for comment or blank character.

Parameters
strThe string to check.
Returns
1 (True) if all blanks or first nonblank is '#', 0 (False) otherwise.

◆ error_exit()

void error_exit ( const char *  errstr)

Helper function to specify error string before exiting with failure.

Parameters
errstrString containing a specialized error message.
Here is the caller graph for this function:

◆ free_image_info_list()

void free_image_info_list ( image_info_t imagelist,
const size_t  cnt 
)

Free a list of images; all images within the list and then list itself.

Parameters
listThe list of images and their parameters.
cntThe number of images in the list.
Here is the call graph for this function:

◆ check_image_sizes()

int check_image_sizes ( image_info_t list,
unsigned int  nimages 
)

Verify that an image information list is (a) correctly sized to the expected image count and (b) all of the images within the list have the same dimensions.

Parameters
listThe list of images and their parameters.
nimagesThe expected image count.
Returns
1 (True) if the sizes match, 0 (False) otherwise.

◆ load_next_image()

int load_next_image ( PdvDev  pdv_p,
unsigned int  current_image,
image_info_t image_details,
unsigned int  total_images,
u_char **  buffers,
unsigned int  nbuffers,
unsigned int  buffer_size 
)

Load the current_image into memory OR the appropriate ring-buffer.

If the index of current_image is larger than total_images it will wrap around. (current_image = current_image % total_images)

Parameters
pdv_pValid EDT device pointer to the CLS.
current_imageThe index of the image to load into local buffer.
img_detailsList of structures containing image details.
total_imagesThe number of elements in image_details list.
buffersThe array of ring buffers in use.
nbuffersThe number of elements in buffers array.
buffer_sizeThe size of image data buffers to allocate, if buffers is NULL.
Returns
If successful the size of the image loaded, 0 on failure.
Here is the call graph for this function:

◆ fill_buffer_tif()

long unsigned int fill_buffer_tif ( image_info_t img_details,
u_char *  buffer,
int  max_size 
)

Stores the tiff image found in img_details->pathname to the specified buffer.

Parameters
img_detailsStorage for the image details. Must have pathname specified.
bufferA pointer to a buffer in which to store the image.
max_sizeThe size of the buffer in bytes.
Returns
The size in bytes of image loaded into buffer.
Here is the call graph for this function:

◆ fill_buffer_gif()

int fill_buffer_gif ( image_info_t img_details,
u_char *  buffer,
int  max_size 
)

Stores the gif image found in img_details->filename to the specified buffer - STUB.

Parameters
img_detailsStorage for the image details. Must have filename specified.
bufferA pointer to a buffer in which to store the image.
max_sizeThe size of the buffer in bytes.
Returns
The size in bytes of image loaded into buffer, -1 on error.

◆ fill_buffer_bmp()

int fill_buffer_bmp ( image_info_t img_details,
u_char *  buffer,
int  max_size 
)

Stores the bmp image found in img_details->filename to the specified buffer - STUB.

Parameters
img_detailsStorage for the image details. Must have filename specified.
bufferA pointer to a buffer in which to store the image.
max_sizeThe size of the buffer in bytes.
Returns
The size in bytes of image loaded into buffer, -1 on error.

◆ fill_buffer_jpg()

int fill_buffer_jpg ( image_info_t img_details,
u_char *  buffer,
int  max_size 
)

Stores the jpg image found in img_details->filename to the specified buffer - STUB.

Parameters
img_detailsStorage for the image details. Must have filename specified.
bufferA pointer to a buffer in which to store the image.
max_sizeThe size of the buffer in bytes.
Returns
The size in bytes of image loaded into buffer, -1 on error.

◆ fill_buffer_ras()

int fill_buffer_ras ( image_info_t img_details,
u_char *  buffer,
int  max_size 
)

Stores the ras image found in img_details->filename to the specified buffer - STUB.

Parameters
img_detailsStorage for the image details. Must have filename specified.
bufferA pointer to a buffer in which to store the image.
max_sizeThe size of the buffer in bytes.
Returns
The size in bytes of image loaded into buffer, -1 on error.

◆ fill_buffer_raw()

int fill_buffer_raw ( image_info_t img_details,
u_char *  buffer,
int  max_size 
)

Stores the raw image found in img_details->filename to the specified buffer - STUB.

Parameters
img_detailsStorage for the image details. Must have filename specified.
bufferA pointer to a buffer in which to store the image.
max_sizeThe size of the buffer in bytes.
Returns
The size in bytes of image loaded into buffer, -1 on error.

◆ edt_min()

unsigned int edt_min ( unsigned int  l,
unsigned int  r 
)

Determine the minimum value of the two specified.

Parameters
lOne of two integer values to determine the lesser of.
rThe other of two integer values to determine the lesser of.
Returns
The lesser of the two values.

◆ main()

int main ( int  argc,
const char *  argv[] 
)

Open a number of TIFF images and send them though the simulator.

Here is the call graph for this function: