Softek Barcode C API:

Creating and Deleting a barcode session:

NAME:

STCreateBarCodeSession
STFreeBarCodeSession

SYNOPSIS:

#include "barcode.h"

void *hBarcode ;
hBarcode = STCreateBarCodeSession() ;
STFreeBarCodeSession(hBarcode) ;

DESCRIPTION:

STCreateBarCodeSession creates a new barcode session and returns a handle that
should then be used when making calls to the other functions in the library.

Call STFreeBarCodeSession to release the resources taken up by the specified
barcode handle.


Reading a Barcode:

NAME:

STReadBarCode

SYNOPSIS

#include "barcode.h"

int STReadBarCode(void *hBarcode, char *file, char *type, char ***bc, char ***bc_type) ;


DESCRIPTION

STReadBarCode scans an image file for barcodes and returns the number of 
barcodes found or an error number.

hBarcode         Handle to barcode session.
file             (input) is the name of the image file to scan.

type             (input) is the type of file ("jpg" or "tif"). If this value is 
                 set to NULL then the file type is determined from the file 
                 extension.

bc               (output) is a pointer to an array of character strings 
                 containing barcodes.

bc_type          (output) is a pointer to an array of character strings 
                 containing the barcode types in the bar_codes array.


RETURN VALUE

A negative number indicates an error (see below), other values inidicate the
number of barcodes found in the file.

ST_ERROR_FILE_OPEN        -1   Cannot open image file
ST_ERROR_MULTI_PLANE      -2   Multiplane images not supported
ST_ERROR_BITS_PER_SAMPLE  -3   Unsupported number of bits per sample
ST_ERROR_MALLOC           -4   Memory allocation error
ST_ERROR_COLOR_TIFF       -5   Color TIF compression not supported


EXAMPLE


char **bar_codes ;
char **bar_codes_type ;
bar_count = STReadBarCode(hBarcode, "file.jpg", 0, &bar_codes, &bar_codes_type) ; 


Getting the page number and position on the page of a barcode:

NAME:

STGetBarCodePos

SYNOPSIS:

int STGetBarCodePos (void *hBarcode, int nBarCode, uint32 *TopLeftX, uint32 *TopLeftY, uint32 *BotRightX, uint32 *BotRightY)

hBarcode                Handle to barcode session.
nBarCode                Index to barcode.
TopLeftX etc            Pointers to receive the coordinates of the rectangle.

DESCRIPTION:

Retrieves the coordinates of the rectangle bounding the barcode. The return
value is the page number of the barcode.


Getting the orientation of a barcode:

NAME:

STGetBarCodeDirection

SYNOPSIS:

int STGetBarCodeDirection (void *hBarcode, int nBarCode)

hBarcode                 Handle to barcode session.
nBarCode                 Index to barcode.

DESCRIPTION:

Returns a value which, when used as the value for ST_ORIENTATION_MASK, would
find the indexed barcode.



Getting and Changing settings:

NAME

STSetParameter
STGetParameter

SYNOPSIS

void	STSetParameter(hBarcode, uint16 param, void *value) ;
void	STGetParameter(hBarcode, uint16 param, void *value) ;

DESCRIPTION

STSetParameter and STGetParameter are used to set/get values for parameters 
for barcode recognition.

hBarcode is a handle to a barcode session (see STCreateBarCodeSession).

The data type pointed to by value is determined by the value of param:

Name                 Param           Value Type                   Default

ST_UPPER_RATIO       1               float *                      4.0

UpperRatio sets the upper acceptable limit for the ratio between the narrow and
wide stripes of a bar code.


ST_LOWER_RATIO       2               float *                      1.5

LowerRatio sets the lower acceptable limit for the ratio between the narrow and
wide stripes of a bar code. Code 39 only.


ST_LINE_JUMP         3               uint32 *                     9

The LineJump setting controls how many scan lines are missed between checks for
a barcode. A LineJump value of 1 means that every scan line in the image will 
be checked.


ST_MIN_OCCURRENCE    4               uint16 *                     2
ST_PREF_OCCURRENCE   8               uint16 *                     5

When the toolkit scans the image for barcode it counts the number of times each 
barcode string occurrs. If the count for a string is the same or greater than 
ST_PREF_OCCURRENCE then the barcode string is counted as a positive match. If 
no string can be found this way then the toolkit looks for strings that occurred
with a count of at least ST_MIN_OCCURRENCE and counts these as positive matches


ST_TIF_WARNINGS      5               uint16 *                     0

Display warnings issued by the libtif library.


ST_MULTIPLE_READ     6               uint16 *                     0

Normally the toolkit stops at the first positive match for a barcode. When 
ST_MULTIPLE_READ is TRUE the toolkit will check the entire image for barcode 
strings and record each positive match. 


ST_ORIENTATION       7               uint16 *                     0

This setting is now deprecated.

0 = Upright. 1 = 90 degrees clockwise. 2 = upside down. 3 = 270 degrees 
clockwise. This has been relpaced by ST_ORIENTATION_MASK


ST_ORIENTATION_MASK  28              uint16 *                     0

Mask specifying the directions to look for barcodes. 1 = Left to Right,
2 = Top to Bottom, 4 = Right to Left and 8 = Bottom to Top.

ST_ORIENTATION_MASK  28              uint16 *                     0

Mask specifying the directions to look for barcodes. 1 = Left to Right,
2 = Top to Bottom, 4 = Right to Left and 8 = Bottom to Top.

ST_SKEW_SETTING      36              uint16 *                     0

SkewTolerance controls the maximum angle from the horizontal or vertical at which a barcode will be recognised by the toolkit. 0 =  up to 5 degrees, 1 = 13 degrees, 2 = 21 degrees, 3 = 29 degrees, 4 = 37 degrees and 5 = 45 degrees.

ST_NOISEREDUCTION   10               uint16 *                     0

If the NoiseReduction property is none zero then the STReadBarCode function 
will run an image through a noise reduction filter before scanning for barcodes.
The filter removes marks from an image that are unlikely to be part of a barcode
. A larger value for NoiseReduction will remove larger marks from the image. 
This increases the chances of finding a barcode in a poor quality image but also
increases the time taken to process an image. A typical value for 
ST_NOISEREDUCTION is 10. 


ST_DESPECKLE         9               uint16 *                     0

If ST_NOISEREDUCTION is non-zero then setting ST_DESPECKLE to 1 will turn on
Advanced Noise Reduction that attempts to remove white as well as black
speckles.


ST_QUIET_SIZE       11               uint16 *                     0

The number of pixels of empty space surrounding a barcode. When set to 0 the
toolkit works out the size based on the image resolution.


ST_DEBUG            12               char *                       NULL

Name of debug file.


ST_PAGE_NO          13               uint16 *                     0

Page number in image to scan for barcodes. Default is to scan all pages.


ST_TIFF_SPLIT       14               char *                       NULL


Split a tif file into separate files. The first page of each new file contains 
a barcode.


ST_READ_CODE39      16               uint16                       1

When TRUE the toolkit will scan for type 39 barcodes.


ST_READ_CODE128     23               uint16                       1

When TRUE the toolkit will scan for type 128 barcodes.


ST_READ_CODE25      24               uint16                       1

When TRUE the toolkit will scan for type 2 of 5 interleaved barcodes.


ST_READ_CODE25_NI   37               uint16                       0

When TRUE the toolkit will scan for type 2 of 5 non-interleaved barcodes.


ST_READ_EAN13       17               uint16                       1

When TRUE the toolkit will scan for EAN-13 barcodes.

 
ST_READ_EAN8        18               uint16                       1

When TRUE the toolkit will scan for EAN-8 barcodes.


ST_READ_UPCA        19               uint16                       0

When TRUE the toolkit will scan for UPC-A barcodes. Note that UPC-A barcodes
are a subset of EAN-13 barcodes. When ST_READ_UPCA is set to TRUE the toolkit
will return UPC-A barcodes without the leading '0'.


ST_READ_UPCE        20               uint16                       1

When TRUE the toolkit will scan for EAN-E barcodes.


ST_SHOW_CHECK_DIGIT 21               uint16                       0

When TRUE the toolkit will also return the check digit as part of the bar code
string.


ST_USE_OVERSAMPLING 29               uint16                       0

When TRUE the toolkit will sample lines in blocks of 3, with the lines n
pixels apart. The value of n is determined by the ST_OVERSAMPLING_SEP value.

ST_OVERSAMPLING_SEP 30               uint16                       0

Distance between the lines when over sampling is use. Default of 3.

ST_TIFF_SPLIT_MODE                   uint16

Determines whether the toolkit splits with a barcode on the first or last page 
of each new image. 0 = first page and 1 = last page.

ST_READ_CODABAR                      uint16

When TRUE the toolkit will scan for Codabar type barcodes. Default is TRUE.

ST_CONVERT_UPCE_TO_UPCA              uint16

When TRUE the toolkit will convert UPC-E type barcodes to EAN-13. Default of 
TRUE. UPC-E barcode is a zero suppressed version of UPC-A, which is itself a
subset of EAN-13.

ST_CONTRAST 		             uint16

Contrast is the color value used by the control to decide whether a pixel should be considered to be black or white. The value should be in the range 0 to 255. Default value = 128.

