PST SDK  5.2.0.0-0eac0f6
Getting camera images

As with the previous example, to receive image data it is important to make sure the server is started (required only once at the start or after PSTapi/Pause has been called in the meantime). In order to get the image stream, image transfer should be enabled on the PST Tracker first by using PSTapi/EnableImageTransfer. Enabling image transfer will ensure new images are pushed to the image stream buffer.

A typical call sequence in Curl

  curl --header "Content-Type: application/json" --request POST --data "{}" http://localhost:7278/PSTapi/Start 
  curl --header "Content-Type: application/json" --request POST --data "{\"Framerate\":30}"  http://localhost:7278/PSTapi/SetFramerate 
  curl -X GET http://localhost:7278/PSTapi/GetExposureRange 
  curl --header "Content-Type: application/json" --request POST --data "{\"Exposure\":0.0001189}"  http://localhost:7278/PSTapi/SetExposure
  curl --header "Content-Type: application/json" --request POST --data "{}" http://localhost:7278/PSTapi/EnableImageTransfer
  curl -X GET http://localhost:7278/PSTapi/StartRawImageDataStream
  
Note
The last two lines should be executed within 4 seconds from each other. Otherwise, EnableImageTransfer will time out and no images will be sent by the PST Tracker.
When too many streams are opened at the same time, PSTapi/StartRawImageDataStream returns a 429 too_many_requests status code. More information on how to handle this error can be found in the PSTapi/CloseImageStream documentation.
The output of the previous example in a Windows command prompt
Type message
COMMAND curl --header "Content-Type: application/json" --request POST --data "{}" http://localhost:7278/PSTapi/Start
RESPONSE {"message":"Server Started"}
COMMAND curl --header "Content-Type: application/json" --request POST --data "{\"Framerate\":30}" http://localhost:7278/PSTapi/SetFramerate
RESPONSE {"message":"Frame rate set successfully"}
COMMAND curl -X GET http://localhost:7278/PSTapi/GetExposureRange
RESPONSE {"ExposureRange":{"max":0.0024999999441206455,"min":9.9999997473787516e-05}}
COMMAND curl --header "Content-Type: application/json" --request POST --data "{\"Exposure\":0.0001189}" http://localhost:7278/PSTapi/SetExposure
RESPONSE {"message":"Exposure time set successfully"}
COMMAND curl --header "Content-Type: application/json" --request POST --data "{}" http://localhost:7278/PSTapi/EnableImageTransfer
RESPONSE {"message":"Image transfer enabled"}
COMMAND curl -X GET http://localhost:7278/PSTapi/StartRawImageDataStream
RESPONSE data: /9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgH...<rest of a base64 char array of the jpeg image 1, frame 0>
data: /9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgH...<rest of a base64 char array of the jpeg image 2, frame 0>

data: /9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgH...<rest of a base64 char array of the jpeg image 1, frame 1>
data: /9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAgGBgcGBQgH...<rest of a base64 char array of the jpeg image 2, frame 1>