Erronious detection of missing comma when loading neural net configuration (Bug #969)


Added by Abe S. almost 14 years ago. Updated almost 14 years ago.


Status:Done Start date:
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:ml
Target version:-
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

I created a program to train a neural net and then write the resulting neural net configuration to a file for later use. This appears to work correctly.

When I attempt to load the configuration file, I get the error message:

OpenCV Error: Parsing error (./annParams(1267253): Missing , between the elements) in icvYMLParseValue, file cxcore/cxpersistence.cpp, line 1152
terminate called after throwing an instance of 'cv::Exception'
Aborted

The only information I have found on the web is a posting to the yahoo group from 2006: http://tech.groups.yahoo.com/group/OpenCV/message/41228

The symptom seems similar, as it appears to be icvYMLParseValue having a problem with a missing comma that is there when the file is inspected.

I am running Ubuntu 10.04 (Lucid) and installed OpenCV as the "libcv4" package.

The error message, version information, and my code are available here: http://aculei.net/~ams/opencv_trouble/ and attached.


Recognizer.cpp - Training and recognizing main file (6.4 kB) Abe S., 2011-03-28 07:18 pm

MoUT.cpp - Source for Museum of Useful Things (random utility header) (2.1 kB) Abe S., 2011-03-28 07:18 pm

MoUT.hpp - Museum of Useful Things header file (805 Bytes) Abe S., 2011-03-28 07:19 pm

other_files - URL where the other files can be found (129 Bytes) Abe S., 2011-03-28 07:20 pm


Associated revisions

Revision 47ea0614
Added by Roman Donchenko over 11 years ago

Merge pull request #969 from pengx17:2.4_binary_cache

Revision 13cd0a05
Added by Roman Donchenko over 11 years ago

Merge remote-tracking branch 'origin/2.4'

Original pull requests:
#996 from jet47:gpu-nvcuvid-libraries
#995 from jet47:fix-bug-2985
#999 from snosov1:unreliable-results-fix
#1005 from alekcac:doc_fix
#1004 from jet47:fix-bug-3068
#987 from jet47:bug-3085-fix
#969 from pengx17:2.4_binary_cache
#929 from dominikrose:mingw-libdc1394-2-windows
#1000 from ivan-korolev:fix_sift_bug_2892
#1001 from ivan-korolev:fix_stitching_bug_2405
#998 from asmorkalov:android_cmake_mips_fix
#993 from ivan-korolev:fix_videostab_bug_3023
#988 from snosov1:3071-fix
#986 from pengx17:2.4_initiated_context
#982 from pengx17:2.4_fix_two_bugs
#981 from SeninAndrew:ximea_camera_support_fix
#991 from asmorkalov:android_javadoc_fix
#972 from jet47:mog2-params-bug-2168
#980 from SpecLad:include-config
#973 from pengx17:2.4_oclclahe
#903 from aks2:2.4
#968 from asmorkalov:android_na_cproj_fix
#971 from SpecLad:matchers-ctor
#970 from asmorkalov:dshow_valid_check_fix
#965 from apavlenko:fix_java_empty_mats

Conflicts:
cmake/OpenCVModule.cmake
modules/core/src/matmul.cpp
modules/gpu/CMakeLists.txt
modules/ocl/include/opencv2/ocl/ocl.hpp
modules/ocl/perf/perf_imgproc.cpp
modules/ocl/src/imgproc.cpp
modules/ocl/src/initialization.cpp
modules/stitching/src/matchers.cpp
modules/video/src/video_init.cpp
modules/videostab/src/global_motion.cpp

History

Updated by Maria Dimashova almost 14 years ago

Thanks for the report.
I have found 2 bugs in your code:
1.) You don't release file storage after line 139 of Recognizer.cpp. So the file is written incorrectly (partially). See own saved file http://aculei.net/~ams/opencv_trouble/annParams, it is broken, it ends with a comma. To write file correctly, release the file storage:

brains.write(annOutFile, "annParams");
cvReleaseFileStorage( &annOutFile );
printf("Wrote to file.\n");

2.) You don't initialize CvFileNode* annInNode in line 150 of Recognizer.cpp, but it must point to the node with "annParams" tag (see line 139 of Recognizer.cpp). So, you need add the following initialization:

[[CvFileNode]]* annInNode = cvGetFileNodeByName( annInFile, 0, "annParams" );

Fixing these bugs in your code, you can save and load CvANN_MLP without crashes.

  • (deleted custom field) set to invalid

Also available in: Atom PDF