'webots object recognition detect colors of object

I am trying to extract the colours of the recognised objects using the camera node in Webots when the object recognition is turned on the camera would recognise and draw a box around objects (object color recognition is also turned on) what I want is to extract the colours inside this box now, there is this "list" or "construct" (please forgive me c is not my strong suit) that seems like it allows to extract information of the recognised objects

#include <webots/camera_recognition_object.h>

typedef struct {
 int      id;
 double   position[3];
 double   orientation[4];
 double   size[2];
 int      position_on_image[2];
 int      size_on_image[2];
 int      number_of_colors;
 double  *colors;
 char    *model;
} WbCameraRecognitionObject; 

the error I am facing is in the initilzation of the camera recognition, here is how I am doing it

WbDeviceTag camera
camera = wb_robot_get_device("camera");
    wb_camera_enable(camera, time_step);
    width = wb_camera_get_width(camera);
    height = wb_camera_get_height(camera);
    wb_camera_has_recognition(camera);
    wb_camera_recognition_enable(camera,TIME_STEP);
    
    const WbCameraRecognitionObject objects =*wb_camera_recognition_get_objects(camera);

now this causes the compiler to give me this message.

WARNING: figure_8_square_pre: The process crashed some time after starting successfully.
WARNING: 'figure_8_square_pre' controller crashed.

if you can throw me a bone here, I know I am doing something wrong in camera initilzation that is causing this warning and "crash"

Using windows Webots R2022a I am afraid I neither know the version of C or the compiler used ("way above my level at the moment")



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source