Hi,

I need to take an image from the e-puck camera and do some post-processing
with it. The post-processing needs to be done inside the e-puck.

To understand the image quality I used the matlab interface - epic - and
captured some images with it. The quality was alright.

Now my aim is to develop the post-processing using the images from the epic
program (MATLAB development). The developed algorithms should then be coded
to e-puck code.

So, in order to have the image matrix ready in the e-puck side (e-puck
code), I need to copycat, from the epic source code, two types of code:
     1 - code that capture an image from the camera sensor array. As I
understand the capturing process originate, as output, a linear buffer.
     2 - code that performs transformations to that buffer, in order to map
each position of the buffer to the image matrix.The algorithms should have
as input, the image matrix.

I discovered the buffer transformations to be in the epic tool, as MATLAB
code. I've also discovered that the image capture is done by the BTCom
program. Here are the code that I found in each sides:

1 - buffer transformations (epic/kernel/updateImage):

 % color ePic.value.image
            index = 1;
            for line=1:sizexy(1)
                for col=0:sizexy(2)-1
                    if index <= size(imgtmp,1)
                        % Get RGB 565 value
                        Pix_1 = uint8(imgtmp(index));
                        Pix_2 = uint8(imgtmp(index+1));

                        % Get values for R, G and B
                        Red_pix =  bitand(Pix_1,248);
                        Green_pix = bitshift(bitand(Pix_1,7),5)+
bitshift(bitand(Pix_2,224),-3);
                        Blue_pix = bitshift(bitand(Pix_2,31),3);

                        % Set color to the ePic.value.image matrix
                        ePic.value.image(sizexy(2)-col,line,1) =
double(Red_pix)/255.;
                        ePic.value.image(sizexy(2)-col,line,2) =
double(Green_pix)/255.;
                        ePic.value.image(sizexy(2)-col,line,3) =
double(Blue_pix)/255.;
                    end

                    % each pixel is coded with 2 bytes
                    index = index +2;
                 end
             end

2 - image capture (BTCom/BTCom.c):

    //configuring the camera
    cam_size=cam_width*cam_heigth*2;
    e_po3030k_init_cam();
    e_po3030k_config_cam((ARRAY_WIDTH -cam_width*cam_zoom)/2,(ARRAY_HEIGHT-
cam_heigth*cam_zoom)/2,

cam_width*cam_zoom,cam_heigth*cam_zoom,cam_zoom,cam_zoom,cam_mode);
    e_po3030k_set_mirror(1,1);
    e_po3030k_write_cam_registers();

I tried to isolate the image capture code and the buffer transformations. On
the e-puck side I put the BTCom code. On the MATLAB side I put the epic
code. The buffer transfer between the e-puck and the MATLAB I do using the
matlab library.

Since the model of the camera of the e-puck I'm using is a 6030, I use the
poxxxx library.

I tried to represent in MATLAB the image with the function image, imshow,
imagesc, ect. . . The image is somewhat similar with the reality (I can
destinguish me thinger), but the qualty/colors are awfull. I'm using a 40x40
image with a zoom of 1, 2, 4, 8 and in rgb565 mode (I assumed that this is
the mode the epic uses, from the code I listed before).

What could be the problem? Here is the e-puck code I'm using:

#define ZOOM_FACT_WIDTH 8
#define ZOOM_FACT_HEIGHT 8
#define ARRAY_SIZE_WIDTH 20
#define ARRAY_SIZE_HEIGHT 40

//buffer that will contain the image
char buffer[2*ARRAY_SIZE_WIDTH*ARRAY_SIZE_HEIGHT];

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

 //configuring the camera
   e_poxxxx_init_cam();
    e_poxxxx_config_cam((ARRAY_WIDTH-ARRAY_SIZE_WIDTH*ZOOM_FACT_WIDTH)/2,\

(ARRAY_HEIGHT-ARRAY_SIZE_HEIGHT*ZOOM_FACT_HEIGHT)/2,\
                        (ARRAY_SIZE_WIDTH*ZOOM_FACT_WIDTH),\
                        (ARRAY_SIZE_HEIGHT*ZOOM_FACT_HEIGHT),\
                        ZOOM_FACT_WIDTH,\
                        ZOOM_FACT_HEIGHT,\
                        RGB_565_MODE);
 e_poxxxx_set_mirror(1,1);
 e_poxxxx_write_cam_registers();

 //start capturing the image - the first image that will be captured
 e_poxxxx_launch_capture(buffer);

//sending several images
 while(1)
 {
   while(!e_poxxxx_is_img_ready())
   {
    //send the image to MATLAB
    e_send_char_to_matlab(buffer,2*ARRAY_SIZE_WIDTH*ARRAY_SIZE_HEIGHT);
    //start new capture
       e_poxxxx_launch_capture(buffer);
   }
  }
 }
 return 0;
}

Is the camera configuration need to be done diferently to 6030 models? I
don't know what is the code that is actualty being used in the epuck program
since I'm using the hex file in the epic/firmware/BTcom_20_LIS_rev84.hex,
that has no source coud available. I know it can be done. I just don't know
what I'm doing wrong. If someone have the source code to the
BTcom_20_LIS_rev84.hex I would appriciate that they coud share it with me.

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

Reply via email to