Go to Post Only one full day of brainstorming on the hint? Boy are they behind... This thread's been busy for a week! - EricH [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 30-12-2007, 07:32
tommy_chai tommy_chai is offline
Registered User
no team
 
Join Date: Oct 2007
Location: Msia
Posts: 12
tommy_chai is an unknown quantity at this point
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]);
:
:
}
Best regards,
Tommy
  #2   Spotlight this post!  
Unread 31-12-2007, 09:34
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
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
__________________
Trenton Tornadoes 381
2004 Philadelphia Regional Winners
2006 Xerox Creativity Award
---
My corner of the USPTO.
My favorite error message from gcc: main is usually a function
My favorite error message from Windows: There is not enough disk space available to delete this file.
  #3   Spotlight this post!  
Unread 31-12-2007, 21:16
tommy_chai tommy_chai is offline
Registered User
no team
 
Join Date: Oct 2007
Location: Msia
Posts: 12
tommy_chai is an unknown quantity at this point
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   Spotlight this post!  
Unread 31-12-2007, 21:38
TimCraig TimCraig is offline
Registered User
AKA: Tim Craig
no team
 
Join Date: Aug 2004
Rookie Year: 2003
Location: San Jose, CA
Posts: 221
TimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to behold
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   Spotlight this post!  
Unread 01-01-2008, 21:17
StevenB StevenB is offline
is having FRC withdrawal symptoms.
AKA: Steven Bell
no team
Team Role: College Student
 
Join Date: May 2005
Rookie Year: 2005
Location: Stanford, CA
Posts: 414
StevenB has a reputation beyond reputeStevenB has a reputation beyond reputeStevenB has a reputation beyond reputeStevenB has a reputation beyond reputeStevenB has a reputation beyond reputeStevenB has a reputation beyond reputeStevenB has a reputation beyond reputeStevenB has a reputation beyond reputeStevenB has a reputation beyond reputeStevenB has a reputation beyond reputeStevenB has a reputation beyond repute
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.
__________________
Need a physics refresher? Want to know if that motor is big enough for your arm? A FIRST Encounter with Physics

2005-2007: Student | Team #1519, Mechanical Mayhem | Milford, NH
2008-2011: Mentor | Team #2359, RoboLobos | Edmond, OK
2014-??: Mentor | Looking for a team...
  #6   Spotlight this post!  
Unread 06-01-2008, 03:24
tommy_chai tommy_chai is offline
Registered User
no team
 
Join Date: Oct 2007
Location: Msia
Posts: 12
tommy_chai is an unknown quantity at this point
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;
:
}
I have put the data into a header file which i can reuse it in try5.c However, I am still learning to save the related data into a header file by programming and not manually as i have tried. I don't know how to link multiple C files because i have just started my C programming 1 month ago. Mind showing some codes as example so that it is easier for me to understand and study?

Thanks.
  #7   Spotlight this post!  
Unread 06-01-2008, 11:00
CyDrive's Avatar
CyDrive CyDrive is offline
Registered User
FRC #1203 (pandemonium)
Team Role: Mentor
 
Join Date: Apr 2007
Rookie Year: 2007
Location: West Babylon
Posts: 26
CyDrive is an unknown quantity at this point
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   Spotlight this post!  
Unread 07-01-2008, 03:02
TimCraig TimCraig is offline
Registered User
AKA: Tim Craig
no team
 
Join Date: Aug 2004
Rookie Year: 2003
Location: San Jose, CA
Posts: 221
TimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to behold
Re: How to use the data obtain in one C file to another C file?

Quote:
Originally Posted by tommy_chai View Post
I don't know how to link multiple C files because i have just started my C programming 1 month ago.
What tools are you using to compile and link your code? I'm curious as to why you're working on such a compliacated problem if you're so inexperienced at C programming? It seems like you need to get through a lot more simple examples before tackling something as complicated as computer vision.

Quote:
Originally Posted by tommy_chai View Post
Code:
typedef struct
{int x,y,info,dx,dy,I;} CORNER_LIST[15000];
This is pretty ugly and potentially not that useful. I think most people would approach it more along the lines of:

Code:
typedef struct
   {
   int x;
   int y;
   int info;
   int dx;
   int dy;
   int I;
   } CORNER;
.
.
.
CORNER corner_list[15,000];
  #9   Spotlight this post!  
Unread 11-01-2008, 02:17
tommy_chai tommy_chai is offline
Registered User
no team
 
Join Date: Oct 2007
Location: Msia
Posts: 12
tommy_chai is an unknown quantity at this point
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.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 15:11.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi