Anchor script producing protected memory error
Posted: Tue May 24, 2011 10:07 pm
I am still doing an evaluation, so perhaps I just have the code wrong, but I wanted to use the anchor functionality to help improve my OMR. I took a look at some of the samples, but I am still not sure if I am right and I am getting an "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." error.
Here is my code snippet
As soon as I get to the last line of this snippet (FindAnchor), I get the error. "scanImageID" is set higher up in the script and it is working. Here is the trace:
To be honest, I am not even sure if I am using this functionality correct. I have the OMRDetectMarks method working just fine, but I wanted to take into account if scans had been upside-down in the scanner, etc. I figured this would help. Is the idea that you set the template, then search different regions of the image to test if that anchor is there? If it's found, do I have to do any transformations (e.g. flips) myself if I find the anchor in the upside-down position?
Thanks in advance,
Bryan
Here is my code snippet
Code: Select all
Dim templateImageID As Integer
Dim anchorTemplateID As Integer
Dim anchor_left As Integer = 0
Dim anchor_top As Integer = 0
Dim anchor_width As Integer = 0
Dim anchor_height As Integer = 0
Dim accuracy As Double = 0
Dim Mode As GdPicture.OMRMode = GdPicture.OMRMode.FavorSpeed
templateImageID = oGdPictureImaging.CreateGdPictureImageFromFile("d:\mypath\answer_sheet_template.png")
anchorTemplateID = oGdPictureImaging.CreateAnchorTemplate(templateImageID, 101, 101, 65, 71)
Dim anchorStatus As Integer = oGdPictureImaging.FindAnchor(scanImageID, templateImageID, Mode, 0, 0, 700, 700, anchor_left, anchor_top, anchor_width, anchor_height, accuracy)
Code: Select all
[AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.]
al.GDPICTUREOMR_Anchor(IntPtr A_0, IntPtr A_1, Int32 A_2, Int32 A_3, Int32 A_4, Int32 A_5, Int32 A_6, Int32 A_7, Int32 A_8, Int32 A_9, Int32& A_10, Int32& A_11, Int32& A_12, Int32& A_13, Double& A_14, Int32 A_15) +0
GdPicture.GdPictureImaging.FindAnchor(Int32 ImageID, Int32 AnchorTemplateID, OMRMode Mode, Int32 SearchLeft, Int32 SearchTop, Int32 SearchWidth, Int32 SearchHeight, Int32& PosLeft, Int32& PosTop, Int32& PosWidth, Int32& PosHeight, Double& Accuracy) +249
score.Page_Load(Object s, EventArgs e) +531
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Thanks in advance,
Bryan