I am doing a project on C# and emgu library.
My code works fine on my computer but when I try to run it on other computers it gives exception here:
haar = new HaarCascade("detector_best.xml");
exception is Unhandled type of exception in Sytem.Typeinitaialization occured in Emgu.CV.
Kindly help me I am giving system environment path and working on Windows. also my file detector_best.xml is in my project's debug folder.
Hope this helps
http://www.emgu.com/wiki/index.php/Setting_up_EMGU_C_Sharp
System.TypeInitializationException: Convertion from Image to Image is not supported by OpenCV
Where * is the the relavent image depth or data type.
This error is thrown up in version 2.3.* onwards and is caused by the programs inability to access opencv_imgproc***.dll or opencv_core***.dll even though they are present in the output "bin" directory.
There are two solutions, adding them to the project and set there properties to copy always as they are the two key files. Or by replacing the current ones in the Bin folder with new copies can also solve the problem.
If both methods fail then there may be a problem with the build so download a new copy from SourceForge and try again.
I hope this article sets you on the right path, Thanks for reading.
It works when i added all .dll files from C:\Emgu\emgucv-windows-universal-cuda 2.4.10.1940\bin to myproject\debug folderalso .dll from x86 and x64 from emgu Bin to my project debug like that,C:\Emgu\emgucv-windows-universal-cuda 2.4.10.1940\bin\x86 to myproject\debug\x86 and C:\Emgu\emgucv-windows-universal-cuda 2.4.10.1940\bin\x64 to myproject\debug\x64
Related
I'm coding a program that extract text from image using Tesseract .. The program should bring all images from a directory and put them one by one in a picture box and then extract the text from them. I have downloaded an English trained data from this link and put it inside Debug folder https://github.com/tesseract-ocr/tessdata/blob/master/eng.traineddata
The exception is:
Here's my code: Exception has been thrown by the target of an invocation.
and the inner exception indicated in catch was : Failed to find library "liblept172.dll" for platform x86.
private void button1_Click(object sender, EventArgs e)
{
Image image;
string[] images = Directory.GetFiles("E:\\Omar Project\\New", "*.png");
for (int i = 0; i < images.Length;i++)
{
image = Image.FromFile(images[i]);
pictureBox1.Image = image;
//ocr = new TesseractEngine(#"tessdata", "eng", EngineMode.Default);
using (var engine = new TesseractEngine("E:\\Omar Project\\Extracting Text From Image Using Microsoft Office\\Extracting Text From Image Using Microsoft Office\\bin\\Debug\\eng.traineddata", "eng", EngineMode.Default))
{
using(var img=Pix.LoadFromFile(images[i]))
{
using(var page=engine.Process(img))
{
richTextBox1.Text += page.GetText();
}
}
}
}
}
Create a folder "x64" or "x86" in your project directory (where your .csproj file is located) and copy liblept1760.so and libtesseract400.so into it. Now you should be able to see your both files in visual studio. You will have to set "copy to output directory" (is the property called like this in english?) for both files to "always"
Make sure you have the following packages installed inside your container
apt-get install -y libgif7 libjpeg62 libopenjp2-7 libpng16-16 libtiff5 libwebp6
Otherwise the dlopen command for liblept will fail and you will get your mentioned errormessage.
If you don't have the liblept package installed inside your container and only copied the .so file into the x64 directory, the open command for libtesseract will fail.
To fix this, you have to create a sym link to your liblept shared object.
Just run inside your container / Dockerfile
ln -s /app/x64/liblept1760.so /usr/lib/x86_64-linux-gnu/liblept.so.5
Make sure to use the correct source path. For default asp.net core docker images and my described way /app/x64/liblept1760.so should be working.
Wiki Tesseract
Common reasons for failure are:
The Visual Studio 2015 x86 & x64 Runtime is not installed, as detailed on the main readme page these can be found here.
The x86 and x64 versions leptonica (liblept172.dll) and tesseract (libtesseract304.dll) were not copied to their respective folders in the bin directory.
DotNet may be reporting the wrong architecture, for instance a known issue is that for an Application compiled using the prefer 32-bit flag will report it's running on x64 when running on windows 64-bit OS (see issue #55). A common workaround is to either change the cpu architecture to x86.
Your running this on an unsupported architecture (e.g. ARM).
Further diagnosis
Tesseract will write the detected architectures and paths searched to the System.Diagnostics source named "Tesseract" which will be helpful for figuring out what is going on. An example configuration is provided at the end of the page.
If the correct version of the library is being found but fails to load, the log will tell you if this is the case, then the next step is to enable logging of binding errors and check the fusion log. Note that it's been my experience that Windows may log these errors to the Windows Event Log so it might be worth checking that first. Further details can be found here:
https://blogs.msdn.microsoft.com/suzcook/2003/05/29/debugging-assembly-loading-failures/
http://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net
If you cannot resolve the issue please file a new issue including the library version, operating system your executing the code on, the target architecture for the entry program, and a copy of the full standard and trace outputs. Note you'll need to enable System.Diagnostics output for the Tesseract source as previously mentioned.
When I'm trying to debug my dump file I get an error:
mscoreei.dll not found
mscoreei.dll was not found in the minidump. You need to load the binary in order to find the source for the current stack frame.
I have a project in C# that can hang sometimes on other computer. Each time as it hangs, 'procdump' app creates minidump file for me. Previously, I could normally open this dump file in VS2015, which shows me a stuck place in the source code.
Everything works fine till I made a 'clean up' in the repository. I didn't add any line in the code, I just clean up repository and all my .pdb files were exterminated. I build project again to restore .pdb files. But now as I try to debug dump files, VS2015 shows me page "No Binary Found" with error message written above.
I didn't make any changes in the source code. I didn't modify my environment. Debugging stops working as I made repository clean up.
When I'm checking 'Stack Frame' list, then evrything that is coming after "mscoreei.dll!7311ffcc" have format "[Frames below may be incorrect and/or missing, no binaries loaded for filename]".
I found the problem. It turns out, that my environment changed. From the last build when debugging worked correctly, Windows Update service updated my .NET library. As result my new build is using updated .NET files, but dumps are created for old .NET. Restoring correct version of .NET helped me.
i am currently facing a really weird and annoying error message after migrating my Xamarin.IOS - Project to the 64bit unified - API. The exact error message is:
/Users/falcowinkler/Dev/AHK_App -Kopie/AHK_App_iOS/../ahk_app_ios/resources/.DS_Store:
Error: The path '../ahk_app_ios/resources/.DS_Store' would result
in a file outside of the app bundle and cannot be used. (AHK_App_iOS).
I get that error not only for .DS_Store but also for two other files.
Here are the things i tried.
Clean / Rebuild
delete bin / obj Folder and rebuild
I deleted the files that throw the error, just to get another message that the project is missing these files. I added them again after that, and got the same error as above again
I tried moving my project to other locations, but the error does not change in the slightest.
I tried to remove all problematic files, before migrating, which didn't work as well.
Does anybody know where all the file references are stored in Xamarin, so i can view/edit them to find out what the error is?
I mean the DS_Store file is just a tiny file from mac - finder architecture, is not even necessary for my project, but still it is referencing it, i will just have to kick out these references i guess.
If anybody encountered these issues as well, and has a solution, pls leave a quick post here, thanks :)
Update
I am now pretty sure that there are some misplaced references to files in my project, i saw a similar issue on git hub. But how can i wipe them out? I tried removing my entire resources Folder and adding it again, but it didn't help either. Error message now looks as follows:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets:
Error: Bundle Resource '../ahk_app_ios/resources/.DS_Store'
not found on disk (should be at '/Users/falcowinkler/Documents/AHKKopie/ahk_app_ios/resources/.DS_Store') (AHK_App_iOS)
If anyone else has this problem, just search your project files for the filename. The .csproj File will appear, where you will be able to wipe out the reference to the file, causing the problem.
If you are using Xamarin Studio, you can delete the .DS_Store under your Ios project [ProjectName.iOS] under the Resources folder
I'm trying to get started with this library: 32feet
I have a Broadcomm Bluetooth Stack and haven't been able to figure out how to get this library set up. When I run my code, I get:
Unhandled Exception: System.PlatformNotSupportedException: No supported Bluetooth protocol stack found.
After digging around on their site, I found this: Installation instructions
It says to copy the appropriate DLL's into the project and then run the Test32FeetWidcommWin32.exe. I've tried putting the files in every single folder in my Visual Studio project and then running that EXE, but I still get the same error. Initially I tried just adding the InTheHand.Net.Personal.dll file as a reference to my project, but that didn't work either.
What could I be doing wrong?
It may also simply be that BlueTooth is not turned on in Windows.
I was using the .NET InTheHand library, and received this message only because BlueTooth was turned off in Windows, and resolved it by activating BlueTooth.
I just solved this. I think the problem was an old reference in my project to the NETCF version of the DLL from when I was trying to brute-force a solution, so I wiped my project clean and then started adding everything again and it worked!
A helpful tool to those trying to figure out their problem with this is to copy and paste the app.config file into your release directory with the app you are creating, and change the name to <YOUREXENAME>.exe.config. When you then run your EXE file, it should create a more detailed trace file. For mine, I found that coredll.dll was the culprit by not loading and was masked by the Stack not supported exception. After an easy Google search I found the problem to be with NETCF.
edit: To be clear, after I cleaned out my project a bit I re-added the reference to the correct InTheHand.Net.Personal.dll file and also added the 32feetWidcomm.dll file to my Release folder.
I am running into issues building an existing 32-bit EmguCV (Version 2.3) into 64-bit using .net 4.0 and VS2010 on a W7/x64 OS. I have purchased a commercial license, if that matters and downloaded from the links provided in the receipt.
The error is
System.TypeInitializationException was unhandled
Message=The type initializer for 'Emgu.CV.CvInvoke' threw an exception.
Source=Emgu.CV
TypeName=Emgu.CV.CvInvoke
I followed the instructions provided in this article. In fact I used the samples projects in the article and they build fine with V2.2, but when I replace with V2.3 binaries (both emgu and opencv), run into the error.
Has anyone successfully built an Emgu (Version 2.3.x) x64 project? Please provide some guidance.
The cause of this error (should anyone else run into the same problem) is that the program cannot access opencv_imgproc231.dll or opencv_core231.dll even though they are present in the output "bin" directory.
There are two solutions:
Add them to the project and set their properties to copy always as they are EMGU's two key files.
If step 1 doesn't work, replace the current key files in the bin folder with new copies.
If both methods fail then there may be a problem with the build, so download a new copy of EMGU from Sourceforge and try again. The error will later be incorporated within an technical article in order to provide a clearer explanation of how to solve it.
Cheers,
Chris
No need to add them to the project; VS will not let you. Simply open FaceRecognizer.cs
at public static partial class CvInvoke and change:
[DllImport(CvInvoke.EXTERN_LIBRARY, CallingConvention = CvInvoke.CvCallingConvention)]
to:
[DllImport(Emgu.CV.CvInvoke.EXTERN_LIBRARY, CallingConvention = Emgu.CV.CvInvoke.CvCallingConvention)]
Ensure you change all of them.
First test this way: open a sample project from emgu cv installaiton directory and run it. for example, open hello world example and try to run it. if sample projects run with out problem then the installation is correct.
For emgu cv sample projects, value of Output Path option in Build settings of the project is set to '..\..\
bin'. To fix your project problem, open the project in visual studio and set value of Output Path option to 'C:\Emgu\emgucv 2.9\bin'. Try to run the project. It must run with success.
Now, set back the value of Output Path option to bin\Debug\. Then, add all DLL files in the 'C:\Emgu\emgucv 2.9\bin' folder to your project using ADD -> Existing Item menu. similarly, add all DLL files in the 'C:\Emgu\emgucv 2.9\bin\x64' folder to your project using ADD -> Existing Item menu. Now, go to properties window and set Copy to Output Directory option of all dll files to Copy Always. Finally, in the Configuration Manager window, create a new configuration for x64 platform.
Good Luck