cascade face detection C++ Opencv 3.0 - c++

I am trying to implement face detection mentioned in the tutorial
http://docs.opencv.org/3.0-beta/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.html#cascade-classifier
I am using OpenCV 3.0 on Ubuntu 14.04.
I downloaed the cascade xml files from here
https://github.com/opencv/opencv/tree/master/data/haarcascades
When I compile the code it gives me this error message:
OpenCV Error: Parsing error (/...../haarcascade_frontalcatface.xml(5): Valid XML should start with '<?xml ...?>') in icvXMLParse, file /home/taleb/opencv3/opencv/modules/core/src/persistence.cpp, line 2220
terminate called after throwing an instance of 'cv::Exception'
what(): /home/taleb/opencv3/opencv/modules/core/src/persistence.cpp:2220: error: (-212) /home/taleb/pythonproject/test1/haarcascade_frontalcatface.xml(5): Valid XML should start with '<?xml ...?>' in function icvXMLParse
Any suggestion?

I found a couple of fixes in stack overflow and other websites. They are as follows:
Change the character encoding from UTF-8 to ANSI with Notepad++.
Previous answer:
convert_cascade is for cascades trained by haartraining application and it does not support a format of cascades trained by traincascade application.
To do this with traincascade, just run opencv_traincascade again with
the same "-data" but set "-numStages" to the point you want to
generate up to. The application will load the trained stages, realize
that there is required number of stages, write the result cascade in
xml and finish a work. Interrupting the process during a stage could
result in corrupt data, so if you're best off deleting the stage in
completion.
refrence: https://stackoverflow.com/a/25831423/5671364.
XML Standard states:
if no encoding declaration is present in the XML document (and no
external encoding declaration mechanism such as the HTTP header is
available), the assumed encoding of an XML document depends on the
presence of the Byte-Order-Mark (BOM).
There are 3 ways to fix this:
Let OpenCV just put the ´encoding="ASCII"´ tag into the top root XML
tag.
Leave the top root XML tag, but encode everything as UTF-8
before writing it to file.
Do something else, with Byte-Order-Mark,
but keep it to the standard.
refrence: http://code.opencv.org/issues/976

Related

Can an ONNX network be incompatible with onnxruntime?

I am having trouble running inference on an ONNX model, either by making (tiny) adjustments to this Windows ML tutorial, or by implementing my own ONNX Runtime code following their MNIST Tutorial. As I understand it, Windows ML makes use of ONNX Runtime, so both efforts probably end up in the same place... and probably generating the same underlying exception for the same reason.
The exceptions thrown are either unintelligible (a second exception thrown during exception handling by the looks...) or not identified at all. It makes me wonder if the network itself is faulty or incompatible in some sense. The network was produced by taking a saved Tensorflow/Keras model and running this conversion:
python -m tf2onnx.convert --saved-model MyNet --output MyNet.onnx --inputs-as-nchw mobilenetv2_1_00_224_input:0
The result is a network that is rendered by Netron with the following input & output stages:
Is there anything about this network that is obviously incompatible with ONNX Runtime? Any suggestions on how to push past either/both of these exceptions?
Turns out that in my attempt to adapt Windows ML example, I had the output shape wrong - in that example, the output shape is 1 x 1000 x 1 x 1. I had copied/pasted this, and just modified the 1000 to suit. Clearly the network above needs a 1 x 10 shape....

Getting FR_3085 ERROR when working in Informatica

In a lot of the task flow jobs I'm running, I constantly am getting the
FR_3085 ERROR: Row [1]: 2-th character is a null character, which is
not allowed in a text input file
error. These occur usually in data synchronization tasks but I sometimes see this in mapping configurations as well. How do I resolve this error?
This error occurs when you have NULL characters in your flat file.
One way for doing this is using the OS utilities for removing the NULL characters from your flat file automatically and this will depend on what OS you're using.

GATE_Using for Thesis_Run-time Error

When I am trying to run corpus pipeline on language resources. It is throwing the below (even though I follow the order as Document reset, english tokeniser, sentence splitter)
Can someone help me with the process to debug this run-time error
Error:
gate.creole.ExecutionException: No sentences or tokens to process in document Password_Safe-window1.txt_0003E
Please run a sentence splitter and tokeniser first!
at gate.creole.POSTagger.execute(POSTagger.java:257)
at gate.util.Benchmark.executeWithBenchmarking(Benchmark.java:291)
at gate.creole.SerialController.runComponent(SerialController.java:225)
at gate.creole.SerialController.executeImpl(SerialController.java:157)
at gate.creole.SerialAnalyserController.executeImpl(SerialAnalyserController.java:223)
at gate.creole.SerialAnalyserController.execute(SerialAnalyserController.java:126)
at gate.util.Benchmark.executeWithBenchmarking(Benchmark.java:291)
at gate.gui.SerialControllerEditor$RunAction$1.run(SerialControllerEditor.java:1759)
at java.lang.Thread.run(Thread.java:745)
Edit:
The files are not empty. As i tried to implement #dedek's suggestion, it has thrown no errors. But raised one more problem as follows:
Exception in thread "ApplicationViewer1" java.lang.OutOfMemoryError: Java heap space
I think it is because your document is empty.
Can you confirm that?
There is a run-time param failOnMissingInputAnnotations of the POSTagger, set it to false and it should be ok.
See also the docs:
failOnMissingInputAnnotations - if set to false, the PR will not fail with an ExecutionException if no input Annotations are found and instead only log a single warning message per session and a debug message per document that has no input annotations (run-time, default = true).
Concerning the OutOfMemoryError: Java heap space
See following questions:
Getting OOM while using GATE on large data set
GATE PersistenceManager.loadObjectFromFile outofmemory error while loading .gapp files
JAVA PermGem memory

CImg Error : 'gm.exe' is not recognized as an internal or external command,

I am new to c++ programming , today i was trying to save an image using CImg .
CImg is C++ Template Image Processing Library .
The basic code i wrote is(Please forgive any syntax erros , as copied part of my codes) :
#include "CImg.h"// Include CImg library header.
#include <iostream>
using namespace cimg_library;
using namespace std;
const int screen_size = 800;
//-------------------------------------------------------------------------------
// Main procedure
//-------------------------------------------------------------------------------
int main()
{
CImg<unsigned char> img(screen_size,screen_size,1,3,20);
CImgDisplay disp(img, "CImg Tutorial");
//Some drawing using img.draw_circle( 10, 10, 60, RED);
img.save("result.jpg"); // save the image
return 0;
}
But I cannot run my program as it says :
Invalid Parameter - 100%
'gm.exe' is not recognized as an internal or external command,
operable program or batch file.
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
[CImg] *** CImgIOException *** [instance(800,800,1,3,02150020,non-shared)] CImg<unsigned char>::save_other() : Failed to save file 'result.jpg'. Format is not natively supported, and no external commands succeeded.
terminate called after throwing an instance of 'cimg_library::CImgIOException'
what(): [instance(800,800,1,3,02150020,non-shared)] CImg<unsigned char>::save_other() : Failed to save file 'result.jpg'. Format is not natively supported, and no external commands succeeded.
Though i can see the image , I cannot save it.
After googling a bit i found people saying to install ImageMagick , i have installed it but no help .
Some of the Forum says to compile against libjpeg, libpng, libmagick++. But i don't know how to compile against those libraries.
I am using Eclipse CDT plugin to write C++ project .
Please help me .
I had the same error, and installing of GraphicsMagick (not ImageMagick) helped me.
I've downloaded and installed GraphicsMagick-1.3.26-Q8-win64-dll.exe from ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/windows/. You may choose another one, if you need:
Note that the QuantumDepth=8 version (Q8) which provides industry
standard 24/32 bit pixels consumes half the memory and about 30% less
CPU than the QuantumDepth=16 version (Q16) which provides 48/64 bit
pixels for high-resolution color. A Q8 version is fine for processing
typical photos intended for viewing on a computer screen. If you are
dealing with film, scientific, or medical images, use ICC color
profiles, or deal with images that have limited contrast, then the Q16
version is recommended.
Important: during installation, don't remove checkbox "Update executable search path", which updates environment variable %PATH%, making gm.exe available from any place.
In my case, it was also required to install Ghostscript - which is highly recommended to install by GraphicsMagick. There is a link to x64 Ghostscript: https://sourceforge.net/projects/ghostscript/files/GPL%20Ghostscript/9.09/gs909w64.exe/download (I've put it here, because links from the GraphicMagick websites leads you to 32-bit only).
After that, it worked fine for me.
For some image formats (as .jpg, .png, .tif and basically all formats that require data compression), CImg will try to use an external tool to save them (such as convert from ImageMagick or gm from GraphicsMagick).
If you don't have any installed, then you won't be able to save .jpg files without having to link your code with the libjpeg library, to get a native support for JPEG read/write (then, you'll need to #define cimg_use_jpeg before #include "CImg.h", to tell the library you want to use the libjpeg features).
If you want to keep things simpler, I'd recommend to save your image using another (non-compressed) image format, as .bmp or .ppm.
These formats are handled natively by CImg and do not require to link with external libraries.
I know this question is old, but I kept getting the same error on one project and not on another and this is the only thing on Google.
To get rid of it, you must do 2 things:
Install dynamic ImageMagick libraries for your appropriate OS and architecture(32/64). Link
I was using VisualStudio, and the character set must be set to "Unicode". The error would appear again when I reverted back to Multi-Byte character set. I guess this has something to do with the way CImg handles strings and miscompares them.

Strange semantic error

I have reinstalled emacs 24.2.50 on a new linux host and started a new dotEmacs config based on magnars emacs configuration. Since I have used CEDET to some success in my previous workflow I started configuring it. However, there is some strange behaviour whenever I load a C++ source file.
[This Part Is Solved]
As expected, semantic parses all included files (and during the initial setup parses all files specified by the semantic-add-system-include variables), but it prints this an error message that goes like this:
WARNING: semantic-find-file-noselect called for /usr/include/c++/4.7/vector while in set-auto-mode for /usr/include/c++/4.7/vector. You should call the responsible function into 'mode-local-init-hook'.
In the above example the error is printed for the STL vector but a corresponding error message is printed for every file included by the one I'm visiting and any subsequent includes. As a result it takes quite a long time to finish and unfortunately the process is repeated any type I open a new buffer.
[This Problem Is Solved Too]
Furthermore it looks like the parsing doesn't really work as when I place the point above a non-c primitive type (i.e. not int,double,float, etc) instead of printing the type's definition in the modeline an error message like
Idle Service Error semantic-idle-local-symbol-highlight-idle-function: "#<buffer DEPFETResolutionAnalysis.cc> - Wrong type argument: stringp, (((0) \"IndexMap\"))"
Idle Service Error semantic-idle-summary-idle-function: "#<buffer DEPFETResolutionAnalysis.cc> - Wrong type argument: stringp, ((\"fXBetween\" 0 nil nil))"
where DEPFETResolutionAnalysis.cc is the file & buffer I'm currently editing and IndexMap and fXBetween are types defined in files included by the file I'm editing/some file included by the file I'm editing.
I have not tested any further features of CEDET/semantic as the problem is pretty annoying. My cedet config can be found here.
EDIT: With the help of Alex Ott I kinda solved the first problem. It was due to my horrible cedet initialisation. See his first answer for the proper way to configure CEDET!
There still remains the problem with the Idle Service Error (which, when enabling global-semantic-idle-local-symbol-highlight-mode, occurs permanently, not only when checking the definition of the type at point).
And there is the new problem of how to disable the site-wise init file(s).
EDIT2: I have executed semantic-debug-idle-function in a buffer where the problem occurs and it produces a ~700kb [sic!] output. It looks like it is performing some operations on a data container which, by the looks of it, contains information on all the symbols defined in the files parsed. As I have parsed a rather large package (~20Mb source files) this table is rather large. Can semantic handle a database that large or is this impossible and the reason of my problem?
EDIT3: Deleting the content of ~/.semanticdb and reparsing all includes did the trick. I still need to disable the site-wise init files but as this is not related to CEDET I will close this question (the question related to the site-wise init files can be found here).
You need to change your init file so it will perform loading of CEDET only once, not in the hook that will be called for each .h/.hpp/.c/.cpp files. You can change this config as the base, and read more in following article.
The problem that you have is caused because Semantic is trying to analyze header files, and when it tries to open them, then its initialization routines are called again, and again...
The first problem was solved by correctly configuring CEDET which is discribed on Alex Ott's homepage. His answer solves this first problem. The config file specified in his answer is a great start for a nice config; I have used the very same to config CEDET for my needs.
The second problem vanished once I updated CEDET from 1.1 to the bazaar (repository) version, which is explained here and in Alex' article. Additionaly one must delete the content of the directory ~/.semanticdb (which contains the semantic database and was corrupted I guess).
I'd like to thank Alex Ott for his help and sticking with me throughout my journey to the solution :)