No member named "centerX" or "centerY" error when trying to get object position from Vision Sensor

I have been trying to write a program that gives me the position of an object detected by the Vision Sensor however when using an instruction like
printf("%.2f", Vision10.objects.centerY);
however I get the error
“No member named centerY in 'vex::safearray<vex::vision::object, 16>”
Any help is appreciated.

vision::objects is an array that contains the largest objects. What you are probably looking for is vision::largestObject.

printf("%.2f", Vision10.largestObject.centerY);

Another method of doing this is to access the first element of the array

printf("%.2f", Vision10.objects[0].centerY);

Thank you, the code you gave me did not work until I tweaked it to make the output a double as shown below
printf("%.2f", (double)Vision10.largestObject.centerY);
and another instruction in the program has shown that the sensor is working as intended however the location text output rarely occurs and when it does, it is random.

Could you share more of the code surrounding the printf? It’s hard to tell what the exact cause of the issue is.

Some possibilities to consider:

  1. You probably want to call this in a loop so the value keeps updating
  2. You might need to flush the stream so the output shows up. This can be done by adding a \n after the %.2f.
  3. Make sure that your brain is connected to your computer through the USB cable. You should be able to do it with a controller, but you will get a better connection with the brain.

Here is some of the code as well as some of the output
#include “vex.h”

using namespace vex;

event checkRed = event();
event checkBlue = event();
event checkGreen = event();

void hasBlueCallback() {
Brain.Screen.clearLine(1, black);
Brain.Screen.setCursor(Brain.Screen.row(), 1);
Brain.Screen.setCursor(1, 1);
if (Vision10.objectCount > 0) {
Brain.Screen.print(“I see you”);
Controller1.Screen.print(“I see you”);
//printf("%.2f", (double)Vision10.objects[0].centerX);
printf("%.2f", (double)Vision10.largestObject.centerX);
//printf("%.2f", (double)Vision10.objects[0].centerY);
printf("%.2f", (double)Vision10.largestObject.centerY);
} else {
Brain.Screen.print(“No Blue Object”);
Controller1.Screen.print(“No Blue Object”);

int main() {
// Initializing Robot Configuration. DO NOT REMOVE!


while (true) {
wait(1, seconds);


I cannot check if there is a difference with using wired mode for a few days but I will see if there is a difference when I can, thanks for the support.
(PS: cant get the code to indent properly, sorry if that makes it harder to read)