camSnapshotToFile (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

MX2/DX4/AX9 pro/MX2 turbo/encore/warp, AX9 turbo, NX-200, NX-400

Firmware version:

3.10 / 1.00.00


This function takes a snapshot picture from the camera module and save it in the file system.

The picture taken is in the industry standard JPEG format and multiple different resolutions are available.

 

The following resolutions are available on X32/NX32:

80 x 64 pixels.

160 x 128 pixels.

320 x 240 pixels.

640 x 480 pixels.

800 x 600 pixels.

1024 x 768 pixels.

1280 x 960 pixels.

1600 x 1200 pixels.

 

The following basic resolutions are available on NX32L:

320 x 240 pixels.

640 x 480 pixels.

800 x 600 pixels.

1280 x 720 pixels.

1920 x 1080 pixels.

The actual resolution used depends on the connected USB camera and may be smaller than the requested resolution, if the camera does not support it.

 

Note:

On X32/NX32, this function is only available for CAM-200 series camera.

 

 

 

Input:

res : INT

The resolution of the snapshot picture.

For X32/NX32:

1

80 x 64 pixels.

2

160 x 128 pixels.

3

320 x 240 pixels.

4

640 x 480 pixels.

5

800 x 600 pixels.

6

1024 x 768 pixels.

7

1280 x 960 pixels.

8

1600 x 1200 pixels

 

For NX32L:

3

320 x 240 pixels.

4

640 x 480 pixels.

5

800 x 600 pixels.

6

1280 x 720 pixels.

7

1920 x 1080 pixels.

 

filename : STRING

Name of the file to save image as. Both absolute and relative paths are allowed.

If file exists it will be overwritten.

 

 

Returns: DINT

The size of the picture snapshot or:

-1

- Failed (camera removed, communication problem, camera does not support MJPEG format(see camGetInfo)).

-3

- Invalid parameter.

-4

- Camera is currently recording.

-5

- Camera interface not open for CAM-200 series.

-6

- Failed to write image to file

 

 

Declaration:

FUNCTION camSnapshotToFile : DINT;
VAR_INPUT
  res       : INT;
  filename   : PTR;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
VAR_INPUT
  snapshot : BOOL R_EDGE;
END_VAR;
 
VAR
  size   : DINT;
END_VAR;
 
PROGRAM test;
 
  fsMediaOpen(media := 0); // Open the file system
  camOpen(type := 2);     // Open the camera library
 
BEGIN
  // Take a snapshot
  IF snapshot THEN
    // Is the camera module present?
     IF camPresent() THEN
        // Take a snapshot
        camSnapshotToFile(res := 3, filename := "A:\PIC.JPG");
     END_IF;
  END_IF;
END;
END_PROGRAM;