AravisDetectorPlugin#
-
class AravisDetectorPlugin : public FrameProcessorPlugin#
Public Functions
-
AravisDetectorPlugin()#
Constructor for the plugin.
Sets default values, starts the status monitoring thread and logger object Then it logs “AravisDetectorPlugin loaded”
-
virtual ~AravisDetectorPlugin()#
Class Destructor. Closes the Publish socket.
Push the frame to the next plugin.
No image processing is done here at the moment
- Parameters:
frame – [in] - pointer to frame object
-
void configure(OdinData::IpcMessage &config, OdinData::IpcMessage &reply)#
Implements json configurations.
- Parameters:
config – [in] - IpcMessage containing configuration data
reply – [out] - Response IpcMessage
-
void requestConfiguration(OdinData::IpcMessage &reply)#
Provides python client with current configuration data in json format.
- Parameters:
reply – [out] - Response IpcMessage
-
void status(OdinData::IpcMessage &status)#
Provides python client with current status of the camera in json format.
- Parameters:
status – - Response IpcMessage
-
bool reset_statistics()#
Reset stream statistics.
-
void status_task()#
Status execution thread for this class.
The thread executes in a continuous loop until the working_ flag is set to false. This thread queries the camera status
-
void callback_access(ArvStream *stream_temp)#
Provides the callback function with access to acquire_stream_buffer.
- Parameters:
stream_temp – pointer to currently used ArvStream object
-
int get_version_major()#
-
int get_version_minor()#
-
int get_version_patch()#
-
std::string get_version_short()#
-
std::string get_version_long()#
Public Static Attributes
-
static const std::string DEFAULT_CAMERA_IP = "127.0.0.1"#
Ip address of the current camera.
Default Config Values
Default config values
-
static const std::string DEFAULT_PIXEL_FORMAT = "Mono8"#
Default pixel encoding.
-
static const std::string DEFAULT_CAMERA_ID = ""#
Default camera ID.
-
static const std::string DEFAULT_CAMERA_SERIAL = ""#
Default serial number of camera.
-
static const std::string DEFAULT_CAMERA_MODEL = ""#
Default camera model.
-
static const std::string DEFAULT_FILE_PATH = "/"#
Default temporary file path.
-
static const std::string DEFAULT_DATASET = "data"#
Default data set name.
-
static const std::string DEFAULT_FILE_NAME = "test"#
Default data file name.
-
static const std::string DEFAULT_AQUISIT_MODE = "Continuous"#
Default acquisition mode.
-
static const double DEFAULT_EXPOSURE_TIME = 1000.0#
Exposure time in microseconds.
-
static const size_t DEFAULT_STATUS_FREQ = 1000#
Time between status checks in miliseconds.
-
static const double DEFAULT_FRAME_RATE = 5#
Frame rate in hertz.
-
static const unsigned int DEFAULT_FRAME_COUNT = 0#
Frame count.
-
static const int DEFAULT_EMPTY_BUFF = 50#
Number of empty buffers used to initialize the stream.
-
static const std::string START_STREAM = "start"#
starts continuos mode acquisition
Flags
Config names Flags
-
static const std::string STOP_STREAM = "stop"#
stops continuos mode acquisition
-
static const std::string LIST_DEVICES = "list_devices"#
list available devices
-
static const std::string ACQUIRE_BUFFER = "frames"#
acquire an image buffer from the camera
-
static const std::string READ_CONFIG#
returns config values for the current connected camera
Config names
-
static const std::string CONFIG_CAMERA_IP = "ip_address"#
set camera IP
Camera name
-
static const std::string CONFIG_EXPOSURE = "exposure_time"#
set exposure time in microseconds
Camera config
-
static const std::string CONFIG_FRAME_RATE = "frame_rate"#
set frame rate in hz
-
static const std::string CONFIG_FRAME_COUNT = "frame_count"#
set frame count
-
static const std::string CONFIG_PIXEL_FORMAT = "pixel_format"#
set pixel encoding Mono8/ 12bit/ etc
-
static const std::string CONFIG_ACQUISITION_MODE = "acquisition_mode"#
set the camera acquisition mode: “Continuous”, “SingleFrame”,”MultiFrame”
-
static const std::string CONFIG_CALLBACK#
Choose weather to activate the Aravis callback mechanism for frame acquisition.
-
static const std::string CONFIG_STATUS_FREQ = "status_frequency_ms"#
set the status polling frequency in miliseconds
-
static const std::string CONFIG_EMPTY_BUFF = "empty_buffers"#
number of empty buffers in a stream object
-
static const std::string CONFIG_CAMERA_ID = "camera_id"#
camera’s manufacturer id
-
static const std::string CONFIG_CAMERA_SERIAL = "camera_serial_number"#
camera’s serial number
-
static const std::string CONFIG_CAMERA_MODEL = "camera_model"#
camera’s model
-
static const std::string DATA_SET_NAME = "data_set_name"#
name of data set used in frame creation
Names and settings
-
static const std::string FILE_NAME = "file_name"#
file name used in frame creation
-
static const std::string COMPRESSION_TYPE = "compression"#
compression type used
-
static const std::string TEMP_FILES_PATH = "file_path"#
a location to store temporary files like camera xml
Frame creation
Private Functions
-
void log_error(std::string msg, OdinData::IpcMessage &reply)#
Send errors to the frame processor and set the Ipc reply.
-
void log_error(std::string msg)#
Overload for simple error logs.
-
void log_warning(std::string msg, OdinData::IpcMessage &reply)#
Send warning to the frame processor and set the Ipc reply.
-
void log_warning(std::string msg)#
Overload for simple warning logs.
-
void get_config(int32_t get_option)#
Populates config variables.
This function gets called periodically to set config variables that can be accessed by read_config.
- Parameters:
get_option – (int32_t): 0- all, 1- Camera init routine, 2- Camera parameter check, 3- Stream statistics, Others: error
-
void set_file_name(std::string file_id, OdinData::IpcMessage &reply)#
Change file name.
- Parameters:
file_id – string
reply – ipc message log
-
void set_file_path(std::string new_file_path, OdinData::IpcMessage &reply)#
Change file path.
- Parameters:
new_file_path – string. checked to be valid
reply – ipc message log
-
void set_dataset_name(std::string data_set_name, OdinData::IpcMessage &reply)#
Change data set name.
- Parameters:
data_set_name – string
reply – ipc message log
-
void set_compression_type(std::string compression_type, OdinData::IpcMessage &reply)#
Change compression type used.
- Parameters:
compression_type – string
reply – ipc message log
-
void set_status_poll_frequency(size_t new_frequency, OdinData::IpcMessage &reply)#
Change status polling frequency.
- Parameters:
status_freq_ms – size_t, in miliseconds
reply – ipc message log
-
void connect_aravis_camera(std::string ip, OdinData::IpcMessage &reply)#
Connects to a camera using the ip address.
Can in theory work with any of the following names:
<vendor>-<model>-<serial>
<vendor_alias>-<serial>
<vendor>-<serial>
<user_id>
<ip_address>
<mac_address>
The function checks for the number of devices connected. If it’s zero it logs an error. If not then it replaces the camera object with a new camera connection. Reports back if it was successful or not.
- Parameters:
ip_string – std::string of ip address
-
void check_connection()#
check that camera is still connected
-
void find_aravis_cameras(OdinData::IpcMessage &reply)#
Checks for available devices.
Displays in the console a list of all available cameras in the format:
[unsigned int] cameras were detected: Device index [int] has the id [str] and address [str]
-
void get_camera_serial()#
Get serial of the current connected camera.
Saved to camera_serial_
-
void get_camera_id()#
Get id of the current connected camera.
Saved to camera_id_
-
void set_acquisition_mode(std::string acq_mode, OdinData::IpcMessage &reply)#
Set acquisition mode for camera.
- Parameters:
acq_mode – std::string = one of the following: “Continuous”, “SingleFrame”,”MultiFrame”
-
void get_acquisition_mode()#
Get current acquisition mode.
Saves acquisition_mode_ as one of the following: “Continuous”, “SingleFrame”,”MultiFrame”
-
void set_exposure(double exposure_time_us, OdinData::IpcMessage &reply)#
Set exposure time in microseconds.
On success prints: Setting exposure time to <exposure_time_us> On failure: When setting exposure time the following error ocurred: <error.message()>
- Parameters:
exposure_time_us –
-
void get_exposure_bounds()#
Get exposure time bounds in microseconds Saves the values to min_exposure_time_ and max_exposure_time_.
-
void get_exposure()#
Get exposure time in microseconds.
On success prints: Saves the value to exposure_time_us_ On failure: When reading exposure time the following error ocurred: <error.message()>
-
void set_frame_rate(double frame_rate_hz, OdinData::IpcMessage &reply)#
Set frame rate in hertz.
Checks that it fits within the minimum and maximum frame rate.
On success prints: Setting frame rate to <frame_rate_hz> On failure: When setting frame rate the following error ocurred: <error.message()>
- Parameters:
frame_rate_hz – number of frames per second
-
void get_frame_rate_bounds()#
Read frame rate bounds from the camera Saves the values to min_frame_rate_ and max_frame_rate.
-
void get_frame_rate()#
Get frame rate in hertz.
On success prints: Saves frame rate value to frame_rate_hz_ On failure: When reading frame rate the following error ocurred: <error.message()>
-
void set_pixel_format(std::string pixel_format, OdinData::IpcMessage &reply)#
Set pixel format.
use read_config() to see which pixel formats are supported
- Parameters:
pixel_format – string representation of the format (eg, Mono8, Mono12, RGB8)
-
void get_available_pixel_formats()#
Get a list of available pixel formats.
the list is saved as a string with the values indexed and a separated by newline, eg: #1 Mono8 #2 Mono12 #3 RGB8
Saved in available_pixel_formats_
-
void get_pixel_format()#
Get currently used pixel format from the camera.
The pixel format is saved in pixel_format_ variable as a string
-
void get_frame_size()#
-
void start_stream(OdinData::IpcMessage &reply)#
Creates a stream object and starts camera acquisition.
This function does the following (in the order displayed):
Checks camera is connected
Deletes any previous stream objects
Initializes a new stream
Checks for errors
Adds buffers
starts camera acquisition and the buffer reading function
-
void stop_stream(OdinData::IpcMessage &reply)#
Stop acquisition and destruct stream.
use when Ipc Messages are required (config) otherwise use auto_stop_stream
- Parameters:
reply – Ipc Message from config
-
void auto_stop_stream()#
Stops stream without ipc message.
Identical to stop_stream but without a reply.
-
void set_frame_count(unsigned int frame_count, OdinData::IpcMessage &reply)#
Sets maximum number of frames taken in stream mode.
- Parameters:
frame_count – unsigned int: frame limit
-
void set_empty_buffers(int n_empty_buffers, OdinData::IpcMessage &reply)#
Sets maximum number of frames taken in stream mode.
- Parameters:
n_empty_buffers – unsigned int: frame limit
-
void acquire_n_buffer(unsigned int n_buffers, OdinData::IpcMessage &reply)#
processes a fixed number of buffers
-
void acquire_buffer()#
Captures a frame buffer.
-
bool buffer_is_valid(ArvBuffer *buffer)#
Captures one frame buffer from a continuos stream.
Checks the buffer for errors and sends it to the frame processor if it is ok.
Essentially calls arv_buffer_get_status and sends the result through a switch
-
void process_buffer(ArvBuffer *buffer)#
Changes buffer object to DataBlockFrame object pointer.
-
void get_stream_state()#
Saves information about the stream_.
Saves the number of input and output buffers as well as the number of successful, failed and underrun buffers to their respective class variables.
-
void save_genicam_xml(std::string filepath)#
Saves the xml file from camera_ into filepath/serial-number.xml.
-
DataType pixel_format_to_datatype(std::string pixel_form)#
Translates from the available pixel format to datatype.
TODO: add support for more pixel formats
- Parameters:
pixel_form –
- Returns:
DataType
Private Members
-
LoggerPtr logger_#
Pointer to logger object for displaying info in terminal.
-
boost::thread *thread_#
Pointer to status thread.
-
bool working_#
Is the status thread working?
-
bool streaming_#
Is the camera streaming data?
-
bool camera_connected_#
is the camera connected?
-
size_t status_freq_ms_ = {DEFAULT_STATUS_FREQ}#
delay between config queries in milliseconds
-
std::string temp_file_path_ = {DEFAULT_FILE_PATH}#
temporary file path for
-
ArvCamera *camera_#
Pointer to ArvCamera object.
-
int connected_devices_ = {0}#
-
std::map<std::string, std::pair<std::string, std::string>> available_cameras_#
camera index (camera id, ip address)
-
std::string camera_id_ = {DEFAULT_CAMERA_ID}#
camera device id
-
std::string camera_serial_ = {DEFAULT_CAMERA_SERIAL}#
camera serial number
-
std::string camera_address_ = {DEFAULT_CAMERA_IP}#
camera address
-
std::string camera_model_ = {DEFAULT_CAMERA_MODEL}#
camera model
-
double exposure_time_us_ = {DEFAULT_EXPOSURE_TIME}#
current exposure time in microseconds
-
double min_exposure_time_ = {}#
minimum exposure time in microseconds
-
double max_exposure_time_ = {}#
maximum exposure time in microseconds
-
double frame_rate_hz_ = {DEFAULT_FRAME_RATE}#
current frame rate in hertz, default to 5
-
double min_frame_rate_ = {}#
minimum frame rate in hertz
-
double max_frame_rate_ = {}#
maximum frame rate in hertz
-
unsigned int n_pixel_formats_ = {}#
total number of pixel formats
-
std::string available_pixel_formats_ = {}#
a set of available pixel formats in string form
-
std::string pixel_format_ = {DEFAULT_PIXEL_FORMAT}#
current pixel format
-
std::string acquisition_mode_ = {DEFAULT_AQUISIT_MODE}#
string describing current camera mode: “Continuous”, “SingleFrame”,”MultiFrame”
-
size_t payload_ = {}#
frame size in bytes
-
unsigned int frame_count_ = {DEFAULT_FRAME_COUNT}#
current frame count in MultiFrame mode
-
ArvStream *stream_#
Pointer to ArvStream object. For continuos frame acquisition.
-
DataType data_type_#
currently used data_type
-
CompressionType compression_type_#
currently used compression type
-
std::string data_set_name_ = {DEFAULT_DATASET}#
name of the data set the plugin is writing to
-
std::string file_id_ = {DEFAULT_FILE_NAME}#
name of the file the plugin is writing to
-
int image_data_offset_ = {0}#
size of buffer metadata (usually none)
-
long long n_frames_made_ = {0}#
Number of frames created from buffers.
-
int n_empty_buffers_ = {DEFAULT_EMPTY_BUFF}#
number of empty buffers to initialise the current stream with. Defaults to 50
-
int n_input_buff_ = {0}#
n of input buffers in the current stream
-
int n_output_buff_ = {0}#
n of output buffers in the current stream
-
long unsigned int n_completed_buff_ = {0}#
n of successful buffers
-
long unsigned int n_failed_buff_ = {0}#
n of failed buffers
-
long unsigned int n_underrun_buff_ = {0}#
n of buffers overwritten (stream ran out of empty buffers)
-
unsigned long long image_height_px_ = {0}#
image height in pixels
-
unsigned long long image_width_px_ = {0}#
image width in pixels
-
std::vector<unsigned long long> frame_dimensions_#
image dimensions for frame creation
-
AravisDetectorPlugin()#