|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
How to use the data obtain in one C file to another C file?
Hi guys,
First, I detect coordinates for left and right corners of a mouth in Corners.c and saved in struct Coordinate for 72 images. How can I able to link it to another C file, let's say try5.c so that it can be used for template matching purpose when i execute 72 images in a loop in try5.c? Sorry because I cannot provide the full program because it is a way too long to read. These are the parts which i think very important in order to solve the problem. Help from anyone will be appreciated. Thank you very much. Code:
Corners.c
struct Coordinate
{
int x;
int y;
};
susan_corners(in,r,bp,max_no,corner_list,x_size,y_size){
:
:
struct Coordinate left_corner, right_corner;
}
try5.c
:
:
#define NUM 72
:
main()
{
:
:
if((fp33 = fopen("facecolor_input.dat","r")) == NULL){
printf("File input filename2 can not open\n");
exit(1);
}
for(k=0;k<NUM;k++){
fscanf(fp33,"%s",filename33[k]);
}
fclose(fp33);
:
:
for(total = 0; total<NUM; total ++){
printf("\nimage==>%d\n",(total+1));
/** read the color data from the file of input face image **/
read_data_color(filename33[total],inpcolor);
:
:
/* Template Matching */
//example for eye template matching
XX1=56; // Left X coordinate for eye template
YY1=44;
XX2=164; //right X coordinate for eye template
YY2=44;
// plf_x, plf_y, prg_x, prg_y are the left and right x & y coordinates from the full input image which has been obtained in Corners.c
affine_recog_a(plf_x, plf_y, prg_x, prg_y, XX1, YY1, XX2, YY2);
cross_correlation_recog_a(TEMPLATE_a, image_out_a, &CC1[0]);
:
:
}
Tommy |
|
#2
|
|||||
|
|||||
|
Re: How to use the data obtain in one C file to another C file?
Hi Tommy,
Perhaps you can restate your question by first indicating how you hope to have the data flow in your program. It seems to start with a file containing a list of image file names, and then each image file is read in and processed somehow. But nothing in Corners.c seems to be involved in the processing in main() in try5.c. How does susan_corners() play a role in the flow of data? Or how would you like susan_corners() to play a role in the flow of data? -Norm |
|
#3
|
|||
|
|||
|
Re: How to use the data obtain in one C file to another C file?
Very sorry to cause such confusion. Susan_corners() is the subroutine to get the left and right corners' x&y coordinates. My problem is to reuse the struct data(corner's coordinates)from Corners.c in another file named "try5.c". Any idea my friend?
|
|
#4
|
|||
|
|||
|
Re: How to use the data obtain in one C file to another C file?
It appears that in corners.c a function called susan_corners gets called with a parameter named corner_list. A question is where and how is corner_list declared? I assume it's probably an array of Coordinate structures. Knowing this will tell his how available the data is to other compiled modules.
To back up a bit, do you understand how to compile and link multiple C modules into an project? Do you understand variable scope and linkage? Function parameter passing? |
|
#5
|
|||
|
|||
|
Re: How to use the data obtain in one C file to another C file?
tommy_chai: Just so you know, ChiefDelphi isn't primarily for programming questions, so you might get a faster and/or more complete response in a different forum. http://www.chiefdelphi.com/forums/sh...ad.php?t=29944
If you're using ANSI C, this is typically done using the extern keyword. The other option is to use "getter" functions, like you would in object-oriented programming. Note that you'll probably want to put the declaration of Coordinate and your functions into a header file, which you can include in both of your c files. Hope this helps. |
|
#6
|
|||
|
|||
|
Re: How to use the data obtain in one C file to another C file?
TimCraig: Sorry, it is my mistake, it is declared as:
Code:
typedef struct{int x,y,info,dx,dy,I;} CORNER_LIST[15000];
:
:
main(){
CORNER_LIST corner_list;
:
}
Thanks. |
|
#7
|
||||
|
||||
|
Re: How to use the data obtain in one C file to another C file?
if i understand what your saying and you have properly created a header file for you c files, then all you need to do is add the header file to any file you wish to call the functions in the c file from. Sorry if that sounds confusing. I'm not the best at explaining things.
|
|
#8
|
|||
|
|||
|
Re: How to use the data obtain in one C file to another C file?
Quote:
Quote:
Code:
typedef struct
{
int x;
int y;
int info;
int dx;
int dy;
int I;
} CORNER;
.
.
.
CORNER corner_list[15,000];
|
|
#9
|
|||
|
|||
|
Re: How to use the data obtain in one C file to another C file?
Hi all,
First thanks for the corrections. Yup, I have created a header file to keep the data and reused them in try5.c However, I entered those data into the header file manually since I don't know how to automatically save them from the struct into a header file. The above codes, I got from my supervisor so I am still in progress to understand it. Any idea on the coding to save the data values from struct to a header file? Thanks for all of the concerns and advices. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to write image data to binary PGM file format(P5)? | tommy_chai | Programming | 0 | 08-10-2007 08:22 |
| "Error.MCP" file after HEX file trans | iwdu15 | Programming | 1 | 24-01-2007 20:05 |
| Help! making an inventor file into an autodesk file | kjhobin | Inventor | 5 | 19-03-2006 23:04 |
| Reading binary data from a file and writing it in VB | complete | Programming | 1 | 02-01-2006 21:21 |
| How do we convert a modified user routines file into a valid .HEX file | HuskieRobotics | Programming | 13 | 28-02-2004 12:12 |