Last year we began work on porting OpenCV 4.5 to Xojo. This first involved the creation of a plain-C interface to OpenCV, which we have now open sourced, though it still requires some work to complete.
Today I’m open sourcing Xojo OpenCV-C. This is a Xojo project that wraps OpenCV-C, creating a Xojo Native interface to OpenCV. It is mostly complete, though there are some remaining issues that we just haven’t had time to deal with. I’m hoping someone here will be able to help out and make this a reality. Other obligations are keeping me from focusing on this, but a lot of hard work has been put into it so far.
If you’re able to help on either or both of these projects, please dive in!
Unfortunately, when trying to use OpenCV in my app I only get hard crashes.
Code:
dim theCVMat as openCV.CVCMat = openCV.Codecs.imDecode(MimeData, openCV.ImReadModes.Unchanged)
dim scaledSize As New openCV.CVCSize(myPreviewSize, myPreviewSize)
dim theCVMatNew as new openCV.CVCMat
openCV.imgProc.CVCresize(theCVMat, theCVMatNew, scaledSize, 0.0, 0.0, openCV.InterpolationFlags.Area)
PreviewPic = theCVMat.image
Error Formulating Crash Report:
dyld_process_snapshot_create_for_process failed with 5
Kernel Triage:
VM - Fault hit memory shortage
VM - Fault hit memory shortage
VM - Fault hit memory shortage
VM - Fault hit memory shortage
VM - Fault hit memory shortage
Sorry - I don’t. We’re in the middle of buying a new office and I’m up to my neck in wrangling lawyers, realtors, bankers, insurers, movers and also doing client work, while packing up 20 years of accumulated detritus.
I’d start with the xojo test application that’s in the github repo. Does that work? Most functions in that app should be fine, though some of the newer ones were still experimental and may require some additions to OpenCV-C. If not, it would suggest either an issue with newer versions of Xojo or perhaps with the dylib and the OS? I believe we tested on Big Sur and Catalina primarily, on Xojo 2021 2.1.
I don’t expect I’ll get a chance to do much of anything on this until at least September, given all we’re doing right now. If there is a bug though, and someone figures it out, feel free to contribute a fix!
I had a minute during lunch and took a quick look at your version of the project. I’m wondering if it has something to do with your mime encoded image? I don’t think we’ve tested that specifically, and I’m not even 100% sure how (or if) OpenCV would know what to do with that. I don’t really have any experience with mime encoded images, so I don’t know if there’s something there that might be tripping things up. All our testing was on “normal” image files. Perhaps if the mime-encoded file is converted to something like a bitmap first?
I’m also on 2021 r2.1 on this machine, so I get the usual errors about yours being made in a newer version of Xojo. So I wouldn’t expect the project to run on this version, but I did glance at the code and that was the first thing that stuck out to me.
Both CGImageSourceMBS and GMBlobMBS cope fine with the data. I just did a Base64Encoding with the data to copy-and-paste the data from my project. Code for CGImageSourceMBS:
dim options as new Dictionary
options.Value(CGImageSourceMBS.kCGImageSourceThumbnailMaxPixelSize) = myPreviewSize
options.Value(CGImageSourceMBS.kCGImageSourceCreateThumbnailFromImageIfAbsent) = true
options.Value(CGImageSourceMBS.kCGImageSourceCreateThumbnailWithTransform) = True
dim theCGImage as CGImageMBS = CGImageSourceMBS.CreateThumbnailMT(MimeData, 0, options)
I forget why we didn’t have that up there as a download, but there was a good reason at the time! It should just be a matter of opening the project up in Visual Studio and compiling though. We (finally) moved recently, but all the hardware I had for dev on this project is still packed up and it’ll be a few weeks before I get to setting that back up. I’ll look for the DLL when I get that out of storage and can put it up on github then. In the mean time, it should just be a compile away…