camera colour tracking error-invalid argument

2 replies [Last post]
APxenon
Title: NooBot
Joined: 03/28/2014
Posts:
BotPoints: 5
User offline. Last seen 3 years 36 weeks ago.

Whenever i run my program for the camera it keeps giving invalid argument and doesn't display anything else even though i've added the code to display the coordinates of the center.Here is the program-
int main()
{
int row=0,col=0;
camera_open();
camera_update();
if(get_object_count(0)>0)
{
row=get_object_center_row(0,0);
col=get_object_center_column(0,0);
printf("Blob is at (%i,%i)\n",row,col);
}
return 0;
}

Can anyone help me???
It would be really great if anyone could help me.

AttachmentSize
orange.c397 bytes
ruler501
ruler501's picture
Title: NooBot
Joined: 01/29/2012
Posts:
BotPoints: 367
User offline. Last seen 2 years 30 weeks ago.

You need a while loop arround your camera code. Something more like this

  1. int main(){
  2. int row=0,col=0;
  3. camera_open();
  4. while(!b_button()){
  5. camera_update();
  6. if(get_object_count(0)>0){
  7. row=get_object_center_row(0,0);
  8. col=get_object_center_column(0,0);
  9. printf("Blob is at (%i,%i)\n",row,col);
  10. }
  11. }
  12. return 0;
  13. }

APxenon
Title: NooBot
Joined: 03/28/2014
Posts:
BotPoints: 5
User offline. Last seen 3 years 36 weeks ago.

Thanks a lot!!!