Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# OpenCV
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."
 

 
 
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 10-Mar-12 0:09am
Edited 10-Mar-12 0:21am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

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

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 BillWoodruff 85
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 10 Mar 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100