opencv 3.1 dnn (caffe) module model import fail - caffe

environment:
OS: win 10
IDE: Visual Studio 2013
opencv: 3.1 master from https://github.com/Itseez/opencv
opencv_contrib: from https://github.com/Itseez/opencv_contrib
graphic card: nvidia GeForce 610M
CUDA: tool kit v7.5 & cudnn is install
what I have done:
build the dll & lib by http://docs.opencv.org/3.1.0/de/d25/tutorial_dnn_build.html
and success
use the sample code (from http://docs.opencv.org/3.1.0/d5/de7/tutorial_dnn_googlenet.html)with the caffe model & prototxt (download in current folder) and build success
Question:
once I run my code. it will fail during import caffe model file
please point me out what wrong, thanks a lot....
the error is bellow:
[libprotobuf ERROR D:\openCV_root\opencv_contrib\modules\dnn\3rdparty\protobuf\src\google\protobuf\text_format.cc:245]
Error parsing text-format caffe.NetParameter: 6:15: Message type "caffe.LayerParameter" has no field named "input_param".
OpenCV Error: Unspecified error
(FAILED: ReadProtoFromTextFile(param_file, param).Failed to parse NetParameter file: ./bvlc_googlenet.prototxt)
in cv::dnn::ReadNetParamsFromTextFileOrDie, file D:\openCV_root\opencv_contrib\modules\dnn\src\caffe\caffe_io.cpp, line 1101
D:\openCV_root\opencv_contrib\modules\dnn\src\caffe\caffe_io.cpp:1101: error: (-2)
FAILED: ReadProtoFromTextFile(param_file, param).Failed to parse NetParameter file: ./bvlc_googlenet.prototxt
in function cv::dnn::ReadNetParamsFromTextFileOrDie

build opencv and opencv_contrib with the tag 3.1.0 works for opencv dnn

The DNN importer doesn't support some constructs of the caffe prototxt file. Nevertheless, you can modify and use it.
Link to issue on github.
Link to modified prototxt.

Related

OSError: libcurand.so.10: cannot open shared object file: No such file or directory

I am working on Nvidia Jetson Tx2 (with JETPACK 4.2) and installed the pytorch following this link.
When I am importing torch in python its giving me an error OSError: libcurand.so.10: cannot open shared object file: No such file or directory I have tried all the options but nothing worked.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.0/lib64
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda-10.0/lib64
export PATH=$PATH:/usr/local/cuda-10.0/lib64
Any guidance to debug the issue is requested. Thanks
emm
I found this answer as followed...
https://forums.developer.nvidia.com/t/mounting-cuda-onto-l4t-docker-image-issues-libcurand-so-10-cannot-open-no-such-file-or-directory/121545
The key is : "You can use JetPack4.4 for CUDA 10.2 and JetPack4.3 for CUDA 10.0."
Maybe downloading Pytorch v1.4.0 and Jetpack 4.2/4.3 would solve this question...
Anyway, it is helped for me... good luck
enter image description here

Build TensorFlow from the source

In the ./configure stage, after setting all the options by default, the terminal threw me this error:
As you required, here's the full outputs:
Please specify the location of python. [Default is /home/jingw222/anaconda3/bin/python]:
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:
Do you wish to use jemalloc as the malloc implementation? [Y/n]
jemalloc enabled
Do you wish to build TensorFlow with Google Cloud Platform support? [y/N]
No Google Cloud Platform support will be enabled for TensorFlow
Do you wish to build TensorFlow with Hadoop File System support? [y/N]
No Hadoop File System support will be enabled for TensorFlow
Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N]
No XLA support will be enabled for TensorFlow
Found possible Python library paths:
/home/jingw222/anaconda3/lib/python3.6/site-packages
Please input the desired Python library path to use. Default is [/home/jingw222/anaconda3/lib/python3.6/site-packages]
Using python library path: /home/jingw222/anaconda3/lib/python3.6/site-packages
Do you wish to build TensorFlow with OpenCL support? [y/N]
No OpenCL support will be enabled for TensorFlow
Do you wish to build TensorFlow with CUDA support? [y/N]
No CUDA support will be enabled for TensorFlow
Configuration finished
Extracting Bazel installation...
..................
unexpected pipe read status: (error: 2): No such file or directory
Server presumed dead. Now printing '/home/jingw222/.cache/bazel/_bazel_jingw222/ada033fd33c06190d78b77ab4907f1d0/server/jvm.out':
java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.ensureError(J9VMInternals.java:141)
at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:130)
at com.google.devtools.build.lib.skyframe.SkyframeExecutor.skyFunctions(SkyframeExecutor.java:348)
at com.google.devtools.build.lib.skyframe.SkyframeExecutor.init(SkyframeExecutor.java:586)
at com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor.init(SequencedSkyframeExecutor.java:252)
at com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor.create(SequencedSkyframeExecutor.java:211)
at com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutor.create(SequencedSkyframeExecutor.java:162)
at com.google.devtools.build.lib.skyframe.SequencedSkyframeExecutorFactory.create(SequencedSkyframeExecutorFactory.java:48)
at com.google.devtools.build.lib.runtime.WorkspaceBuilder.build(WorkspaceBuilder.java:81)
at com.google.devtools.build.lib.runtime.BlazeRuntime.initWorkspace(BlazeRuntime.java:204)
at com.google.devtools.build.lib.runtime.BlazeRuntime.newRuntime(BlazeRuntime.java:1023)
at com.google.devtools.build.lib.runtime.BlazeRuntime.createBlazeRPCServer(BlazeRuntime.java:850)
at com.google.devtools.build.lib.runtime.BlazeRuntime.serverMain(BlazeRuntime.java:789)
at com.google.devtools.build.lib.runtime.BlazeRuntime.main(BlazeRuntime.java:570)
at com.google.devtools.build.lib.bazel.BazelMain.main(BazelMain.java:56)
Caused by: java.lang.ClassCastException: com.ibm.lang.management.UnixExtendedOperatingSystem incompatible with com.sun.management.OperatingSystemMXBean
at com.google.devtools.build.lib.util.ResourceUsage.<clinit>(ResourceUsage.java:45)
... 13 more
So, basically, most of them are not enabled by default. How to approach problems like this?
Install jdk 8 manually:
sudo apt-get install openjdk-8-jdk
After that build again.
Check this issue for more info.

opencv 3.1 wxwidgets cv::imwrite error

I am building a project using Opencv 3.1 and wxwidgets 3.1. The code I use:
[wxOpenCv Demo1]
I try to add a write frame object, using the function cv::imwrite().
(I changed the c calls to c++ eg: cvQueryFrame( m_pCapture ) to m_pCapture >> m_CurFrame;)
I get this error:
Undefined symbols for architecture x86_64:
"cv::imwrite(cv::String const&, cv::_InputArray const&,
std::vector > const&)", referenced from:
CCamera::SaveFrame() in camera.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Without wxwidgets the opencv functions work fine. So its seems that it has to do with the combination of wxwidgets and opencv.
This works fine with wxwidgets and Opencv:
cv::imshow("tmp",m_CurFrame);
cv::waitKey(4);
// cv::imwrite(Tmp , m_CurFrame);
If I uncomment the last line, I get the error.
OS X: 10 Yosemite and I use the default compiler (Apple LLVM 7.0)
I have no idea what to do about this!
solved the problem (and more) by recompiling wxwidgets 3.1.0 and Opencv 3.1. I used these links to get it going.
Small guide to compiling wxWidgets, Opencv against C++ 11:
Compile wxwidgets 3.1.0: I followed the install.txt for OSX. And tweaked the ../configure call with help from this
I added: --enable-debug and changed the macosx version
../configure --disable-shared --enable-debug --enable-unicode --with-cocoa --with-macosx-version-min=10.7 --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk CXXFLAGS="-std=c++0x -stdlib=libc++" CPPFLAGS="-stdlib=libc++" LIBS=-lc++
Then with the help of this page I build a xcode project. Tweaking a few things:
(wxcocoa.xcodeproj and minimal.xcodeproj, and a all new projects)
Add to the Header Search Path: $(WXROOT)/build/osx (to find wx.xcconfig)
base SDK: latest OS X (10.11)
C language dialect: GNU 11(not sure if this is right)
C++ language dialect: GNU++11 [-std=gnu++11]
C++ Standard Library: libc++ (LLVM C++ standard library with C++ 11 support)
placed the WXROOT under “preference->locations->Source Trees. Not important, but seems to be a better location (restart xcode)
in wxcocoa.xcconfig I changed: MACOSX_DEPLOYMENT_TARGET = 10.10
Somehow I have to change the name of the created library from libwx_osx_cocoa_static.a to: lwx_osx_cocoa_static.a (why, I do not know)
I use GNU++ 11 and thus libc++ to be able to use new functionality like “future"
I then added OpenCV to my newly created wxXcode project:
Compile OpenCV following this: (search the web for: howto-install-build-and-use-opencv-macosx-10-10)
Make sure that the SDK is the right version (here was my biggest problem), matching the build of wxWidgets
The compiler settings same as for wxWidgets (see above)
(added:) To do this I added some lines to the CMakeLists.txt in the (Opencv-master folder). Below the line: # OpenCV compiler and linker options
(I found this trick here: search the web for: OpenCV with C++11 on OS X 10.8
message("Setting up Xcode for C++11 with libc++.")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++0x")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
Then follow this page to update the newly created wxWidgets xcode project (search the web for: howto-setup-xcode-6-1-to-work-with-opencv-libraries)
This should do the trick! I can now combine wxWidgets, OpenCV and the libc++
(multithreading, “future")
I hope this helps.
Please let me know if you found out more!

unable to open Cube language model params for hindi Language in tesseract

Tesseract unable to read cube language model.
tesseract 1.png output.txt -l hin
After above command execution following error occur.
Cube ERROR (CubeRecoContext::Load): unable to read cube language model params from /usr/share/tesseract-ocr/tessdata/hin.cube.lm
Cube ERROR (CubeRecoContext::Create): unable to init CubeRecoContext object
init_cube_objects(false, &tessdata_manager):Error:Assert failed:in file tessedit.cpp, line 207
Segmentation fault
Where I get hin.cube.lm file and how to deal with that file?
I fixed this error by installing the correct versions of the below files:
hin.cube.bigrams
hin.cube.fold
hin.cube.lm
hin.cube.nn
hin.cube.params
hin.cube.word-freq
hin.tesseract_cube.nn
Along with the correct versions of the Hindi AND English training data.
All above files are available at:
https://github.com/tesseract-ocr/tesseract/wiki/Data-Files#data-files-for-version-304305
I put these files under: /usr/local/share/tessdata
This is on CentOS 7.2

Error while building project with ExportSWC plugin in FlashDevelop

I am making a ActionScript library which is a Flex 4 project for my Adobe AIR Native Extension in FlashDevelop. When I build the project its successful, but when I try to build the project with ExportSWC plugin to get .swc file I get the following message:
Prebuilding config C:\Users\Osama Mohammed\Documents\AndroidSIPManager\obj\AndroidSIPManager.flex.compc.xml...
Configuration writen to: C:\Users\Osama Mohammed\Documents\AndroidSIPManager\obj\AndroidSIPManager.flex.compc.xml
Running Process:
"C:\Program Files (x86)\FlashDevelop\Tools\flexsdk\bin\compc.exe" -load-config+="C:\Users\Osama Mohammed\Documents\AndroidSIPManager\obj\AndroidSIPManager.flex.compc.xml"
Error loading: C:\Program Files\Java\jdk1.7.0_25\jre\bin\server\jvm.dll
Building AsDoc
AsDoc temp output: C:\Users\Osama Mohammed\AppData\Local\Temp\7827039c-c329-4b6d-acb7-447146a5f4fe
Start AsDoc: C:\Program Files (x86)\FlashDevelop\Tools\flexsdk\bin\asdoc.exe
-lenient=true -keep-xml=true -skip-xsl=true -output "C:\Users\Osama Mohammed\AppData\Local\Temp\7827039c-c329-4b6d-acb7-447146a5f4fe" -source-path "c:\users\osama mohammed\documents\androidsipmanager\src" -doc-classes com.innovative.androidsipmanager.AndroidSIPManager com.innovative.androidsipmanager.Main -exclude-dependencies=true -target-player=10.1
Following is the error:
Error loading: C:\Program Files\Java\jdk1.7.0_25\jre\bin\server\jvm.dll
AsDoc complete (6)
Build failed (6).
Please help me in solving this error.
I had to remove Java 64 bit & install Java 32 bit. Now it is working.