473,394 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Undeclared identifier

Thanks for the help so far.
I have some problems left. One of them is an undeclared identifier, but
it's unclear to me why the compiler fights with me. It says

"iter: undeclared identifier"

I thought that the
identifier was clear: "int", or is int just the declaration, and the
identifier is something else?
Thanks a lot.
Anna

//================================================== ==========================
int AAM_IC::Fit(const IplImage* image, AAM_Shape& Shape,
int max_iter /* = 30 */, bool showprocess /* = false */)
{
//initialize some stuff
double t = (double)cvGetTickCount();
CvMat p; cvGetCols(__search_pq, &p, 4, 4+__shape.nModes());
double e1(1e100), e2;
Shape.Point2Mat(__current_s);
const CvMat* A0 = __texture.GetMean();
SetAllParamsZero();
__shape.CalcParams(__current_s, __search_pq);
IplImage* Drawimg = 0;
char filename[100];

if(showprocess){
Drawimg = cvCreateImage(cvGetSize(image), image->depth,
image->nChannels);
mkdir("result");
cvCopy(image, Drawimg);
Draw(Drawimg, 2);
sprintf(filename, "result/Init.jpg");
cvSaveImage(filename, Drawimg);
}

for(int iter = 0; iter < max_iter; iter++)
{
//check the current shape
if(!AAM_IC::IsShapeWithinImage(__current_s, image->width, image->height)){
fprintf(stderr, "ERROR(%s, %d): Shape out of image\n",
__FILE__, __LINE__);
return iter;
}

//warp image to template image A0
__paw.FasterGetWarpTextureFromMatShape(__current_s , image, __warp_t,
true);
AAM_TDM::AlignTextureToRef(A0, __warp_t);

//calculate error image
cvSub(__warp_t, A0, __error_t);

if(showprocess){
cvCopy(image, Drawimg);
Draw(Drawimg, 2);
sprintf(filename, "result/Iter-%02d.jpg", iter+1);
cvSaveImage(filename, Drawimg);
}

//check for texture divergence
e2 = cvNorm(__error_t);
if(e2 < 0.01 || (iter>max_iter/3&&fabs(e2-e1)<0.01*e1)) break;
e1 = e2;

//1. calculate dot product of modified steepest descent images
// with error image
//2. calculate delta q and delta p by multiplying by inverse Hessian.
//In summary: we calculate parameters update
cvGEMM(__error_t, __G, 1, NULL, 1, __delta_pq, CV_GEMM_B_T);

//apply inverse compositional algorithm to update parameters
InverseCompose(__delta_pq, __current_s, __update_s);
//smooth shape
cvAddWeighted(__current_s, 0.4, __update_s, 0.6, 0, __update_s);
//update parameters
__shape.CalcParams(__update_s, __search_pq);
//calculate constrained new shape
__shape.CalcShape(__search_pq, __update_s);

//check for shape convergence
cvSub(__current_s, __update_s, __delta_s);
if(/*cvNorm(__delta_s)<0.01*/cvNorm(__delta_s, 0, CV_C) < 0.25) break;
else cvCopy(__update_s, __current_s);
}

Shape.Mat2Point(__current_s);

t = ((double)cvGetTickCount()-t)/(cvGetTickFrequency()*1000.);
printf("AAM IC Fitting time cost %.3f millisec\n", t);

cvReleaseImage(&Drawimg);

return iter;
}
Oct 23 '08 #1
3 3270
The last line is the problematic one:

return iter;
Oct 23 '08 #2
Anna Smidt wrote:
The last line is the problematic one:

return iter;
The iter is declared in "for" statement, so it's scope ends
with the for loop. This is the correct standard behavior.
Previous VC++ versions allowed to use variables declared this way
after the for loop, so this code would compile in those versions.

You have two choices: either move iter outside of the for loop,
or turn on the compiler option to enable the old (non-standard) behavior.

--PA
Oct 23 '08 #3
Thanks very much!
Anna
Oct 23 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Saurabh Aggrawal | last post by:
Hi, if (iter->m_name.compare(pstrName) == 0) { // Provide our object. *ppunkItem = iter->m_pUnknown; // Addref our object... iter->m_pUnknown->AddRef(); break; }
9
by: W. Van Hooste | last post by:
Just starting with C, can somebody explain why this does not work or point me in the right direction? I wrote some tools and did some coding but cant seem to get this one. I DID declare my FILE...
5
by: Marc Gustafson | last post by:
This function is executed when a application file is double-clicked to open in a VC++ application. Specifically, this function is enabled by RegisterShellFileTypes () in the application's...
0
by: Stephanie Doherty | last post by:
Hello World, I am trying to use a _spawnl function like this (and I have included the process.h file): _spawnl(_P_WAIT,iporgfile,iporgfile,NULL); It compiles with the following errors: ...
6
by: Peter Rothenbuecher | last post by:
Hello, when I try to compile the following code with g++ -o client client.c #include<sys/socket.h> #include<stdio.h> #include<stdlib.h> #define ADDRESS "mysocket"; #define MAXLEN 200;
10
by: teddarr | last post by:
I am trying to construct a class with several functions and identifiers. The identifier in question is static double AIR which will hold the value of the annual interest rate in the class. I have...
2
by: aarthi28 | last post by:
Hi, I have this code that I am trying to compile, but I am getting the following errors 'CoInitializeSecurity': identifier not found 'EOAC_NONE' : undeclared identifier I have pasted the...
5
by: vmagana | last post by:
First of all I would like to indicate that I am a newbie a programming. I am having a problem compiling a sample source code that I downloaded from microsoft. When I try to build the program I get...
1
by: LuxCkrown | last post by:
Hey everyone, i've been browsing for a fix to my problem 1>c:\documents and settings\user\desktop\judis_repack\judis repack\judis repack\maplestoryserver\inventory.cpp(386) : error C2065: 'amount'...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.