|
In the code that calls the method you are getting an exception in, put a breakpoint on the line that calls the method (you can do this by pressing F9). Run your program in debug mode and when the program hits the breakpoint, it will pause execution. At this point, press F11 to step into the method. Check that the parameters that you have passed in are what you would expect. Now, use the step over command (F10) to step over individual code lines, and use step into (F11) to inspect methods that are of interest to you.
Check the values of variables as you progress to determine where the calculation goes wrong (if that's what your problem is), and to check that the right value gets allocated to the right place. This is going to require a lot of patience on your part, so take your time. It also means that you are going to have to be aware of what values you should get at what point.
And that, in a nutshell, is how you debug it.
|
|
|
|
|
Sorry for the inconvenience
please try the program and debug the error then paste it here
thanx
|
|
|
|
|
That's not going to happen. YOU have to debug the program. We're telling you how to do that. It's up to YOU to do the work. We're not getting paid to do your job, YOU are.
|
|
|
|
|
I wish I'd realised that I never had to debug a program again, I could just post the code here and someone would do it for me. How exciting.
|
|
|
|
|
And it's FREE!! Why the Hell haven't we done this before!?
|
|
|
|
|
Did you know that if you put a scarf on a snowball, it stands a really good chance of surving in hades? Your chances of me debugging and working out what the problem is with your code is absolutely nil. Unless you're happy to pay my rates, which I have to warn you are very expensive.
|
|
|
|
|
i have a multi programs in c# that does not execute plz help me,,,i want to know the error in this programs
first:
/* SIFT.cs
* The SIFT algorithm class
* where all the algorithm specific methods
* are implemented
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
class SIFT
{ static double initDev = 1.6; // initial standard deviation variable
static public int OctavesCount = 2; // Octaves count for pyramid
static public int scalesPerOctave = 4; // scales(blurred images) count per octave
static double minDoG = 0.01; // minimal threshold of keypoint value
static public double norm; // normalization factor for kp coordinates
static double edgeRatio = 10; // minimal edge ratio for kp localization
public static double[][,] BuildGaussianBlurPyramid(Bitmap image) // method to build the Gaussian pyramid with bitmap input
{ int ind=1; // index variable to help for image indexing in pyramid
int imgCount = scalesPerOctave * OctavesCount; // calculate total image count
double deviation = initDev; // local initial deviation variable
double[][,] imgMatrix=new double[imgCount][,]; // array to store values of each image matrix in the pyramid
imgMatrix[0]=new double[image.Width,image.Height]; // image matrix initial dimension
imgMatrix[0]=ImageProcessing.BitmapToGrayscaleMatrix(image); // create grayscale image matrix from bitmap coloured image
for (int i = 0; i < OctavesCount; i++){
for (int j = 1; j < scalesPerOctave; j++){ // Build Gaussian blur with given image mtrx and deviation
imgMatrix[ind]=ImageProcessing.GaussianBlurBWMat(imgMatrix[ind-1], deviation);
deviation *= 2; // double the previous deviation
ind++; // increment current image index
}
if (ind<imgcount-1) check="" for="" current="" image="" index="" and="" build="" next="" octave
="" imgmatrix[ind]="ImageProcessing.SubSample(imgMatrix[ind-2]);" down-sample="" the="" by="" factor="" of="" 2="" octave=""
="" deviation="" =="" 3.2;="" divide="" to="" start="" from="" twice="" initial
="" ind++;="" increment="" index
="" }
="" return="" imgmatrix;="" resulting="" matrix="" pyramid="" array
="" }="" method="" dog="" pyramid
="" public="" static="" double[][,]="" builddogpyramid(double[][,]="" gaussianpyr)="" {="" int="" ind="0;" value="" controlling="" indxes="" resdog="new" double[(scalesperoctave="" -="" 1)="" *="" octavescount][,];
="" (int="" i="0;" <="" gaussianpyr.getlength(0)="" 1;="" +="1){
" if="" ((i="" %="" (scalesperoctave)="=" 0){="" go="" continue;
="" calculate="" matrix
="" resdog[ind]="ImageProcessing.CalculateDoGMatrix(gaussianPyr[i]," gaussianpyr[i="" 1]);
="" }
="" resdog;="" arraylist="" findkeypoints(double[][,]="" imgmatrixpyr)="" find="" keypoints
="" kpl="new" arraylist();="" create="" store="" double[][][,]="" imgmatrix="new" double[2][][,];="" array="" three="" level="" pyr="" img="" norm="3.0" (initdev="" 2);="" normalization="" factor
="" dogcount="(scalesPerOctave" octavescount;="" count="" total="" number="" images="" imgmatrix[0]="new" double[3][,];="" first="" imgmatrix[1]="new" second="" pyrl="0;" layer="" pyrim="0;" in="" layer
="" dogcount;="" i++){="" (i="=" 3){
="" pyrl++;="" assign="" zero="" dimension="" imgmatrix[pyrl][pyrim]="imgMatrixPyr[i];" copy="" pyr.="" 1="" dim="" dim.
="" pyrim++;="" min="1," max="1;" initialization
="" l="0;" imgmatrix.getlength(0);="" l++){
="" y="1;" imgmatrix[l][1].getlength(1)="" y++)
="" x="1;" imgmatrix[l][1].getlength(0)="" x++){
="" double="" point="imgMatrix[l][1][x," y];="" pick="" one="" central="" (math.abs(point)="" keypoint="" threshold
="" imgmatrix[l].getlength(0);="" i++){
="" maximum="" (max="=" &="" imgmatrix[l][i][x="" 1,="" 1]="" y]="" imgmatrix[l][i][x,="" point){
="" else="" minimum
="" (min="="> point & imgMatrix[l][i][x - 1, y] > point &
imgMatrix[l][i][x, y - 1] > point & imgMatrix[l][i][x, y] >= point & imgMatrix[l][i][x + 1, y + 1] > point &
imgMatrix[l][i][x + 1, y] > point & imgMatrix[l][i][x, y + 1] > point & imgMatrix[l][i][x - 1, y + 1] > point &
imgMatrix[l][i][x + 1, y - 1] > point){
min = 1; }
else min = 0;
}
if (max == 1 || min == 1){ // check if the point is max or min
Keypoint kp = new Keypoint(); // create keypoint object to
kp.x = x; // assign x coordinate of extreme point
kp.y = y; // assign y coordinate of extreme point
kp.value = point; // assign extreme point value
kp.layer = l; // assign layer of extreme point
KpL.Add(kp); } // add keypoint to arraylist
min = 1; max = 1; // reinitialize min and max values
}
}
return KpL; // return keypoint list
}
// method to localize keypoints for the given edge ratio
public static ArrayList KeypointLocalization(ArrayList initKpList, double[][,] DoGMatrix, int edgeRatio)
{ Keypoint initKp; // Keypoint object to store initial keypoints
ArrayList retKp = new ArrayList(); // create Arraylist to store refined keypoints
double Dxx, Dyy, Dxy, Trace, Det; // variables to store elements, trace and Det. of Hessian
double r = ((edgeRatio + 1) * (edgeRatio + 1)) / 2; // calculate the threshold from the edgratio
for (int i = 0; i < initKpList.Count; i++){
initKp = (Keypoint)initKpList[i]; // cast the value from Arraylist object to the Keypoint
int l = initKp.layer == 0 ? 1 : 4; // identify the current layer
if (initKp.x <= 0 || initKp.y <= 0 || // drop keypoints which are on the borders
initKp.x >= DoGMatrix[l].GetLength(0) - 1
|| initKp.y >= DoGMatrix[l].GetLength(0) - 1)
continue;
Dxx = DoGMatrix[l][initKp.x + 1, initKp.y] // calculate the x,x derivative by pixel differences
+ DoGMatrix[l][initKp.x - 1, initKp.y]
- 2.0 * DoGMatrix[l][initKp.x, initKp.y];
Dyy = DoGMatrix[l][initKp.x, initKp.y + 1] //calculate the y,y derivative by pixel differences
+ DoGMatrix[l][initKp.x, initKp.y - 1]
- 2.0 * DoGMatrix[l][initKp.x, initKp.y];
Dxy = 0.25 * ((DoGMatrix[l][initKp.x + 1, initKp.y + 1] // calculate the x,y derivative by pixel differences
- DoGMatrix[l][initKp.x + 1, initKp.y - 1]) -
(DoGMatrix[l][initKp.x - 1, initKp.y + 1]
- DoGMatrix[l][initKp.x - 1, initKp.y - 1]));
Trace = Dxx + Dyy; // calculate the trace of Hessian
Det = Dxx * Dyy - (Dxy * Dxy); // calculate the determinant of Hessian
if ((Trace * Trace) / Det > r) // drop the keypoints which contradict the given ratio
continue;
else
retKp.Add(initKp); // add the remaining keypoints
}
return retKp; // return the resulting Arraylist with localized keypoints
}
// method for orientation assignment
public static ArrayList AssignOrientations(ArrayList finKpList, double[][,] blurredMatrix)
{ Keypoint finKp; // keypoint variable to store localized keyoints
ArrayList orKp=new ArrayList(); // create arraylist to store keypoints with orientations
double binVal = 2 * Math.PI / 36; // calculate the angle value of one histogram bin
for (int i = 0; i < finKpList.Count; i++){
finKp = (Keypoint)finKpList[i]; // cast from array list object to keypoint object
finKp.scale = initDev*(finKp.layer + 1); // caclulate the keypoint scale
double[] histBin = new double[36]; // create the double array as a colour histogram
int kpReg=(int)(1.5*finKp.scale/2+0.5); // calculate the radius of the region around the keypoint
double SigmaFact=2*2.25*finKp.scale*finKp.scale; // caclutate the sigma factor for gaussian weight
int layer=finKp.layer==0?1:5; // identify the current keypoint layer
int regXSt=finKp.x-kpReg<1?1:finKp.x-kpReg; // calculate the x coordinate of the region start and end
int regXEnd = finKp.x + kpReg > blurredMatrix[layer].GetLength(0) ? blurredMatrix[layer].GetLength(0) : finKp.x + kpReg;
int regYSt = finKp.y - kpReg < 1 ? 1 : finKp.y - kpReg; // calculate the x coordinate of the region start and end
int regYEnd = finKp.y + kpReg > blurredMatrix[layer].GetLength(1) ? blurredMatrix[layer].GetLength(1) : finKp.y + kpReg;
for (int y=regYSt; y<regyend; y++)
="" for="" (int="" x="regXSt;" x<regxend;="" x++){="" calculate="" the="" gaussian="" wight=""
="" double="" gaussianwight="Math.Exp(-(Math.Pow(x" -="" finkp.x,="" 2)="" +="" math.pow(y="" finkp.y,="" sigmafact));
="" portion="" of="" direction="" angle="" in="" histogram
="" portinhist="(CalMagnitudeAndDirection(x,y," blurredmatrix[layer]).direction="" math.pi)="" (2="" *="" math.pi);
="" identify="" bin="" index="" current="" keypoint="" int="" ind="(int)(portInHist" 36="=" ?="" 0="" :="" 36);="" add="" magnitude="" weightened="" by="" to="" respective="" bin
="" histbin[ind]+="CalMagnitudeAndDirection(x,y,blurredMatrix[layer]).magnitude*gaussianWight;
" }
="" max="0.0;" initialize="" maximal="" value
="" maxbin="0;" index
="" bi="0;" <="" histbin.getlength(0);="" ++bi){
="" if="" (histbin[bi]=""> max){ // check if the next bin is bigger
max = histBin[bi]; // store new bin as the maximal
maxBin = bi; } // mark the new bin index as the index of the maximal bin
}
max = maxBin * binVal - Math.PI; // change angle range from [0, 2PI] to [-PI,PI]
max=max<-Math.PI?2*Math.PI+max:max; // check if angle is outside [-PI,PI]
max = max > Math.PI ? max - 2 * Math.PI : max; // check if angle is outside [-PI,PI]
finKp.orientation = max; // assign maximal bin direction as keypoint orientation
orKp.Add(finKp); // add keypoint with assign orientation
}
return orKp; // return keypoint list of keypoints with their orientations
}
// method to calculate keypoint magnitude and direction
static KpOrientPar CalMagnitudeAndDirection(int x, int y, double[,] blurredMatrix)
{ KpOrientPar kpO=new KpOrientPar(); // create orientation object for magnitude and direction pair
// calculate the keypoint magnitude by pixel differences
kpO.magnitude = Math.Sqrt (Math.Pow (blurredMatrix[x + 1, y] - blurredMatrix[x - 1, y], 2.0) +
Math.Pow (blurredMatrix[x, y + 1] - blurredMatrix[x, y - 1], 2.0));
// calculate the keypoint direction by pixel differences
kpO.direction = Math.Atan2(blurredMatrix[x, y + 1] - blurredMatrix[x, y - 1],
blurredMatrix[x + 1, y] - blurredMatrix[x - 1, y]);
return kpO; // return orientation object with magnitude and direction
}
public static ArrayList CreateDescriptor(ArrayList finKpList, double[][,] blurredMatrix)
{ int kpReg = 16; // region size around the keypoint
Keypoint finKp; // keypoint object to store input keypoint
ArrayList descKp=new ArrayList(); // arraylist keypoint to store descriptor assigned keypoints
double SigmaFact = 2*(kpReg / 2) * (kpReg / 2); // calculate the sigma factor for gaussian weight
for (int kpi = 0; kpi < finKpList.Count; kpi++){
finKp = (Keypoint)finKpList[kpi]; // cast from arraylist object to keypoint object
int regXSt = finKp.x - kpReg < 1 ? 1 : finKp.x - kpReg; // calculate x coordinate of keypoint region start
int regYSt = finKp.y - kpReg < 1 ? 1 : finKp.y - kpReg; // calculate y coordinate of keypoint region start
int regXEnd = regXSt + 4; // calculate x coordinate of keypoint region end
int regYEnd = regXSt + 4; // calculate y coordinate of keypoint region end
double[,][] desc = new double[4, 4][]; // create double array to store descriptor
for (int jj = 0; jj < 4; jj++)
for (int ii = 0; ii < 4; ii++ )
desc[ii,jj] = new double[8]; // initialize double array of descriptor
int layer = finKp.layer == 0 ? 1 : 5;
for (int i = 0; i <= 3; i++)
for (int j =0 ; j <= 3; j++)
for (int xi = regXSt; xi < regXEnd; xi++)
for (int yi = regYSt; yi < regYEnd; yi++){ // calculate current value of x and y coordinates
int x =xi+j*4 >= blurredMatrix[layer].GetLength(0)-1 ? blurredMatrix[layer].GetLength(0)-2 : xi+j*4;
int y = yi+i*4 >= blurredMatrix[layer].GetLength(1)-1 ? blurredMatrix[layer].GetLength(1)-2 : yi+i*4;
double yRot = Math.Sin(-finKp.orientation) * (x - finKp.x) +
Math.Cos(-finKp.orientation) * (y - finKp.y); // rotate x coordinate by keypoint orientation value
double xRot = Math.Cos(-finKp.orientation) * (x - finKp.x) -
Math.Sin(-finKp.orientation) * (y - finKp.y); // rotate y coordinate by keypoint orientation value
// calculate gaussian weight
double gaussianWight = Math.Exp(-(Math.Pow(xRot, 2) + Math.Pow(yRot, 2) / SigmaFact));
// calculate direction and rotate by keypoint orientation
double direction = CalMagnitudeAndDirection(x, y, blurredMatrix[layer]).direction - finKp.orientation;
if (direction < 0) // check if direction degree is out of [0,2PI] range
direction += 2.0 * Math.PI;
else if (direction > 2.0 * Math.PI)
direction -= 2.0 * Math.PI;
double portInHist = direction / (2 * Math.PI); // calculate the protion of the direction in the histogram
// idetify the index of orientation bin
int ind = (int)(portInHist * 8 == 8 ? 0 : portInHist * 8);
// add magn. weighted by gaussian to the resp.direction bin
desc[i, j][ind] += CalMagnitudeAndDirection(x, y, blurredMatrix[layer]).magnitude * gaussianWight;
}
finKp.descriptor=desc; // assign descriptor to keypoint object
descKp.Add(finKp); // add keypoint to the resulting arraylist object
}
return descKp; // return arraylist of keypoints with descriptors
}
}
class KpOrientPar // helper class to store magnitude and direction
{
public double magnitude; // double variable to store keypoint magnitude
public double direction; // double variable to store keypoint direction
}
|
|
|
|
|
First, when you put code into a forum message, please use the code button and choose the appropriate language. What you do is highlight the code you've inserted, click code and then choose C# from the drop down that appears. As it stands, we cannot even read your code.
Second, what do you mean by "it does not execute"? Do you mean you get compilation errors? Does the program start and then immediately stop? Does it have logic errors?
It's highly unlikely that anyone is going to take your code, drop it into a program and debug it for you. Now's the time for you to learn valuable debugging skills. Set breakpoints. Inspect variables, step through code and do all the other things that you will be expected to do as a professional coder.
|
|
|
|
|
|
sorry ,but how to use the code button i didn't know from it
|
|
|
|
|
There is a button that says 'code'...
|
|
|
|
|
Hello,
How can i create C like defines in C#.
What i did so far is:
1.I created class called Global
class Global
{
public const Int32 D_PARAMETER = 5;
public const Int32 NODE_SIZE = 2*D_PARAMETER;
public const Int32 NULL = -1;
}
2.When i want to use some of the const from the class i have to use it like this:
root.Parent = Global.NULL;
3.What can i do so i can only use
NULL and not
Global.NULL ?
Thanks.
|
|
|
|
|
You can't. When you think about it, you'll see why - everything in C# is object-oriented, so there has to be some ability to work with an object, whereas C does not have this restriction.
|
|
|
|
|
Well, think about your design. For me it looks like you want to port C code directly to C# without taking care of the designe (classes, objects, etc)
Anyway you can solve it this way:
static sealed class ConstContainer
{
public static readonly int FOO = 1;
}
And use it that way.
dummy.MyProperty = ConstContainer.FOO;
|
|
|
|
|
You can't, and that's one way in which C# improves on C/C++.
What happens in C/C++ when you include two different header files for two things you want to use that both define NULL, but define different values for it? It doesn't work. So more modern languages use namespaces and such so you can qualify a name when there's a collission.
See also this recent thread and see if there's anything you find helpfull: http://www.codeproject.com/Messages/4235173/Re-include-a-file.aspx[^]
|
|
|
|
|
The story is :
the customers have previous application and database (full with their specific data). Now a new version is ready and the customer gets the update. In the mean time we made some modification on DB (new table, columns, maybe an old column deleted, or whatever). I’m pretty new in Linq and also SQL databases and my first solution can be: I check the applications/databases version and implement all the changes step by step comparing all tables, columns, keys, constrains, etc. (all this new information I have in my dbml and the old I asked from the existing DB). And I’ll do this each time the version changed. But somehow I feel, this is NOT a smart solution so I look for a general solution of this problem.
|
|
|
|
|
A simple forum question is not the right place to answer this. What you are talking about is release management, and is a huge topic in its own right. You have so much to take into account, whether it's a desktop app or ASP.NET, and so on.
I'd suggest that you start with this[^] document.
|
|
|
|
|
i know that.
i have windows app.
what is the strategy?
|
|
|
|
|
As I said, it's more than you can get from a simple forum answer. Follow the link I set for you. Read up on Release and Change management.
If I remember rightly, you've been posting a variant of this question for the last month - in that time, if you'd done some research for yourself, you'd have a working strategy that you could go forward with and find out why you should not rely on client applications in a multi-user environment to update the server.
|
|
|
|
|
What you're talking about should NEVER be done at run-time. This is all install-time work for you server components. You do that stuff in your installer, not your application.
Seriously, read that document. You've wasted enough time plodding through the forums trying to piece this together from forum posts. Don't screw this up by guessing and overlooking the holes forum posts are going to leave in your "strategy".
|
|
|
|
|
I will be doing my final year project later this year and i want to develop an application. Almost everybody is developing a website. I want to do something different something like a distributed system using Preferably WCF or TCP/IP sockets using C#. Please guyz i need ideas i could implement using these tools.
Thanks
|
|
|
|
|
solomon201 wrote: Please guyz i need ideas i could implement using these tools
You and every other finals student on the planet, we see this question regularly and it usually gets a rehash of old ideas, do a search for project ideas or final exam and see what you get.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
.................
modified 16-May-12 3:26am.
|
|
|
|
|
Qismet, go find someone who can translate your requirements into english for you, your question makes absolutely no sense!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
(C#) language
i am making a website in which i want to added a facility in which if the user is idle for some minutes not at the time of working but if and only if idle then it redirect to the Login Page.
So please help me...
Mitesh
|
|
|
|
|