Hello all,
I've been working on some code which tells the epuck to take a picture with its camera and then send it to my computer via bluetooth. The problem is that when the camera takes a picture, the data it creates is rubbish. I've looked at sample code in the library documentation and the epuck player drivers and I can't tell where my code is going wrong.
Anyway, this is the code that is running on the epuck:

#include <uart/e_uart_char.h>
#include <motor_led/e_init_port.h>
#include <camera/fast_2_timer/e_po3030k.h>

#define CAM_BUFFER_SIZE 80*60
unsigned char cam_buffer[CAM_BUFFER_SIZE];

void init_cam(void)
{
        e_po3030k_init_cam();
e_po3030k_config_cam(0, 0, ARRAY_WIDTH, ARRAY_HEIGHT, 8, 8, GREY_SCALE_MODE);
        e_po3030k_write_cam_registers();
        return;
}


void capture(void)
{
        e_po3030k_launch_capture((char *)cam_buffer);
        while(!e_po3030k_is_img_ready());
}


int main(void)
{               
        e_init_port();
        init_cam();
        e_init_uart1(); 

        e_send_uart1_char("photography ", 12);
        
        char ch;
        //get ch from uart until we receive an x
        while(ch != 'x')
        {
                //is_char checks for incoming data from uart1
                if(e_ischar_uart1())
                {
                        e_getchar_uart1(&ch);
                }
        }
        capture();
        
        //send buffer contents to bluetooth
        e_send_uart1_char((char *)cam_buffer, CAM_BUFFER_SIZE);
        
        //wait to finish sending
        while(e_uart1_sending()){}
        
                        
        return 0;
}

So the camera is taking a 640 x 480 greyscale image and scaling it down to an 80x60 image. This is then sent to my computer across uart1. On my computer I've tried reading the data through the terminal in TinyBld which gives me raw data which looks like:

ûûûû  ÿ ÿ etc. When I converted that to an image it was basically a black retangle with some lighter grey pixels. I thought maybe the problem was with the bluetooth connection, but when I try and use the data for other things in the epuck it's clear the camera isn't filling the buffer with data properly. I also tried running the BTcom/epuck monitor program, and with that code the camera worked properly so it's not a broken camera either.

I'm not sure what else the problem could be, does anyone here have any ideas?
Thanks,

Jenny

_______________________________________________
E-puck-user mailing list
E-puck-user@gna.org
https://mail.gna.org/listinfo/e-puck-user

Reply via email to