Tool/software: Code Composer Studio
Hello Team,
I created simple CCS project for edge detection,i used .y extension file as input and generating .y output file which should detect the edge of image.
But when i try to see .y output which is generated image is not properly generated,so i opened same file editor so i came to know that file is not properly written.
Afterwards i used same .c file and run it on gcc platform and checked output file that file is properly generated and edges are also clearly visible in that.
So,can you suggest any pointer for running code on DSP core ....?
I am using cmd file from path "vision_sdk/ti_components/drivers/pdk_01_08_00_16/packages/ti/csl/example" : lnk_dsp.cmd
Please find attached source file for your reference.
#include <stdio.h>
#include <stdlib.h>
#define WIDTH 640
#define HEIGHT 480
void main()
{
int size,x,y,value;
unsigned int *data[2];
FILE *Fp_input;
FILE *Fp_output;
unsigned char buffer1[WIDTH];
unsigned char buffer2[WIDTH];
unsigned char *ptr1, *ptr2, *inptr1, *inptr2, *inptr3, *temp;
unsigned int WordWidth = sizeof(unsigned int);
data[0] = (unsigned int*)malloc(WIDTH*HEIGHT);
data[1] = (unsigned int*)malloc((WIDTH*HEIGHT)/2);
ptr1 = buffer1;
ptr2 = buffer2;
Fp_output = fopen("output.y","wb");
if ( Fp_output == 0 )
{
printf("couldn't write output file");
exit(EXIT_FAILURE);
}
Fp_input = fopen("VGA.y","rb");
if ( Fp_input == 0 )
{
printf("couldn't open input file");
exit(EXIT_FAILURE);
}
else
{
//while(!feof(Fp_input))
{
size = fread( data[0], WordWidth, (WIDTH*HEIGHT)/(WordWidth), Fp_input );
//size = fread( data[1], WordWidth, (WIDTH*HEIGHT)/(2*WordWidth), Fp_input );
inptr1 = data[0] ;
inptr2 = inptr1+WIDTH ;
inptr3 = inptr2+WIDTH ;
memcpy(ptr1 , inptr1 , WIDTH);
for ( y = 1; y < HEIGHT; ++y)
{
for ( x = 1; x < WIDTH; ++x)
{
value = *(inptr1+(x-1))*(-2) + *(inptr1+(x))*(-1) + *(inptr1+(x+1))*(-2) +
*(inptr2+(x-1))*(0) + *(inptr2+(x))*(0) + *(inptr2+(x+1))*(0) +
*(inptr3+(x-1))*(2) + *(inptr3+(x))*(1) + *(inptr3+(x+1))*(2) ;
if (value< 0)
value =0;
if (value>255)
value =255;
*(ptr2+x) = value;
}
memcpy(inptr1 , ptr1 ,WIDTH);
temp = ptr1;
ptr1 = ptr2;
ptr2= temp;
inptr1 += WIDTH;
inptr2 += WIDTH;
inptr3 += WIDTH;
}
fwrite( data[0], WordWidth, (WIDTH*HEIGHT)/WordWidth, Fp_output );
}
}
}
Regards,
Pritam




