Click here to Skip to main content
15,895,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone!

I'm working on a project, in VS2010, c# opencvsharp.(I am new in OpencvSharp)
I wanna detect object's lines on a image(in this case rectangle), I use the HoughLinetransform, but when I try to acquire the lines I get the following error:
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."



C#
unsafe
         {
             for (i = 0; i < Math.Min(lines.Total, 100); i++)
             {

                 float* line = (float*)lines.GetSeqElem<IntPtr>(i).Value.ToPointer();

                 float rho = line[0]; <= I got the error here

                 float theta = line[1];
                 CvPoint pt1, pt2;
                 double a = Math.Cos(theta);
                 double b = Math.Sin(theta);
                 double x0 = a * (rho);
                 double y0 = b * (rho);
                 pt1.X = Cv.Round(x0 + 1000 * (-b));
                 pt1.Y = Cv.Round(y0 + 1000 * (a));
                 pt2.X = Cv.Round(x0 - 1000 * (-b));
                 pt2.Y = Cv.Round(y0 - 1000 * (a));
                 Cv.Line(des, pt1, pt2, Cv.RGB(255, 255, 255), 3, Cv.AA, 0);


             }
Posted
Updated 9-Mar-12 23:21pm
v2

1 solution

It was a Vista Issue, what happens was that my App opens a web page that runs a java applet that opens a external IE webpage that runs a ActiveX app/script. When the ActiveX script tryes to update back in to the memory of the C# app the DEP "Data Execution Prevention" in Vista flags this operation as Hostile/virus and ends the program with the System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Fix is to run the command "bcdedit.exe /set {current} nx AlwaysOff" and reboot the machine
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900