Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindCirclesGrid AccessViolation #106

Closed
nanostrukturtechniker opened this issue Jun 1, 2015 · 6 comments
Closed

FindCirclesGrid AccessViolation #106

nanostrukturtechniker opened this issue Jun 1, 2015 · 6 comments
Labels
bug Something isn't working wontfix

Comments

@nanostrukturtechniker
Copy link

I think, these are two different bugs, perhaps they mix up

Bug one was first mentioned in:
http://stackoverflow.com/questions/30004528/opencvsharp-accessviolationexception-in-findcirclesgrid

It seems that the call to the native function is ambiguous.

Bug two (if not the same as bug one or just masking it?)

If FindCirclesGrid is called in a function, the parameters seem to be garbage collected while still running. This leads to a AccessViolation. Accessing all parameters just after the whole detection seems to solve this.

@shimat shimat added the bug Something isn't working label Jun 3, 2015
@shimat
Copy link
Owner

shimat commented Jun 3, 2015

Thank you. The exception does not occur in my environment, but I agree with you.

I added GC.KeepAlive before the end of FindCirclesGrid.
cf88602

This means that I have to add GC.KeepAlive to most OpenCvSharp methods... 😱

@nanostrukturtechniker
Copy link
Author

You can try moving the whole calibration routine into an extra DLL and call this from the main program. This triggers an AccessViolation for sure (at least at my environment: Latest OpenCVSharp and VS2013 Update 4). Also the error is more likely, when the PC is not under load.
Atm, I try adding the GC.KeepAlive statements for all parameters after the call, but this did not help. The image is accessible (at least it can be displayed and accessed with other methods) and the other vars seem fine, too.
Unfortunately, this is company code and I cannot post it here and at home, I use plain C++...

@shimat
Copy link
Owner

shimat commented Jun 4, 2015

You can try moving the whole calibration routine into an extra DLL and call this from the main program. This triggers an AccessViolation for sure (at least at my environment: Latest OpenCVSharp and VS2013 Update 4).

I could demonstrate the error. thanks!

The AccessViolationException seems to be occurred by the ambiguity (you said 'bug one') of the native FindCirclesGrid invoker. After fixing the bug, the exception does not occur in my environment.

@nanostrukturtechniker
Copy link
Author

It seems to work for me now. Thank you very much!

@nanostrukturtechniker
Copy link
Author

Sorry, I have to reopen it: I used the function with no explicit blob detector called. When I use a SBD, the access violation occurs again (At least, when I'm using a grayscale image). If I use the same image after thresholding it (only one channel out of three used, the other two are zero, because there was an error in my routine), everythink works, so propably, the bug is in the SimpleBlobDetector?
Edit: When I just the BlobDetector with .detect(img), it crashes too, so perhaps move this comment to a new issue?
Edit2: I got the SBD to work with some parameters (filter by size turned on, circularity off, convexity off, color on), so it seems to be the SBD.

@stale
Copy link

stale bot commented Jul 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 24, 2020
@stale stale bot closed this as completed Jul 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix
Projects
None yet
Development

No branches or pull requests

2 participants