Check Image Encoding Parameter for ROS Image Message
This model shows how to access string parameters and use them to trigger subsystem operations. It gets an image format off the set up ROS parameter server. It is retrieved as a uint8 array that is compared using the strcmp MATLAB function block. When a new image is received from the Subscribe block and the format is uint8('jpeg'), it triggers the "Process Image" block to perform a task on the image data.
This model requires you to be connected to a ROS network. Call rosinit in the MATLAB® command window. The '/camera/rgb/image_raw/compressed/format' parameter must be set and the '/camera/rgb/image_raw/compressed' topic must have image messages being published. Use the buttons in the model to set the image format parameters to check the strcmp block. The eq output should be 1 when the parameter is set to 'jpeg'.