| ![]() |
2.5 Cameracamera_enable, camera_disablecamera_new_widget camera_get_fov, camera_set_fov camera_get_width, camera_get_height camera_get_type camera_get_image, camera_image_get_red, camera_image_get_green, camera_image_get_blue camera_enableNAMEcamera_enable, camera_disable -- enable and disable the camera measurementsSYNOPSIS#include <device/camera.h>void camera_enable (DeviceTag camera, guint16 ms); void camera_disable (DeviceTag camera); DESCRIPTIONcamera_enable allows the user to enable a camera measurement each ms milliseconds. camera_disable turns the camera off, saving computation time. camera_new_widgetNAMEcamera_new_widget -- create a GTK+ widget for displaying the camera viewSYNOPSIS#include <device/camera.h>GtkWidget *camera_new_widget (DeviceTag camera); DESCRIPTIONcamera_new_widget creates a new GTK+ widget for a camera. Creating such a widget is useful only if you want to embed it into your own graphical user interface, otherwise, if you don't create any camera widget, the controller library will do it automatically in a separate window. It is mandatory to have such a widget displayed to allow OpenGL rendering. This constraint is mainly due to 3D hardware which often cannot render an off screen image. camera_get_fovNAMEcamera_get_fov, camera_set_fov -- get and set field of view for a cameraSYNOPSIS#include <device/camera.h>gfloat camera_get_fov (DeviceTag camera); void camera_set_fov (DeviceTag camera, gfloat fov); DESCRIPTIONThese functions allow the controller to get and set the value for the field of view (fov) of a camera. The original value for this field of view is defined in the Camera node, as fieldOfView. Note however, that changing the field of view using camera_set_fov will not change the value of the fieldOfView field on the simulator side. It will only affect the controller side, making new rendered images use the specified field of view for the specified camera. camera_get_widthNAMEcamera_get_width, camera_get_height -- get the size of the camera imageSYNOPSIS#include <device/camera.h>guint16 camera_get_width (DeviceTag camera); guint16 camera_get_height (DeviceTag camera); DESCRIPTIONThese functions return the width and height of a camera image as defined in the corresponding Camera node. camera_get_typeNAMEcamera_get_type -- get the type of the cameraSYNOPSIS#include <device/camera.h>gchar camera_get_type (DeviceTag camera); DESCRIPTIONThis function returns the type of a camera as defined in the corresponding Camera node. If the type is "black and white" or "grey", then the return value is 'g', otherwise, the return value is 'c', standing for color. camera_get_imageNAMEcamera_get_image, camera_image_get_red, camera_image_get_green, camera_image_get_blue -- get the image data from a cameraSYNOPSIS#include <device/camera.h>guint8 *camera_get_image (DeviceTag camera); guint8 camera_image_get_red (image, width, x, y); guint8 camera_image_get_green (image, width, x, y); guint8 camera_image_get_blue (image, width, x, y); DESCRIPTIONThe camera_get_image function allows you to read the contents of the last image grabbed by the camera. The image is coded as a series of three bytes coding for the red, green and blue levels of a pixel. Pixels are stored in lines ranging from the bottom left hand side of the image up to top right hand side. The memory chunck returned by this function doesn't need to be released, as it is handled by the camera itself. The size in bytes of this memory chunk can be computed as follow: size = camera_width * camera_height * 3 Attempting to read outside the bounds of this chunk will cause an error. The camera_image_get_ macros are useful helpers for accessing directly the pixel colors from the pixel coordinates. They are defined as follow:
![]() ![]() ![]() ^ page top ^ |
E-mail to webmaster | Last updated: | Copyright © 2002 Cyberbotics Ltd. |