removed contrib, legacy and softcsscade modules; removed latentsvm and datamatrix...
authorVadim Pisarevsky <vadim.pisarevsky@gmail.com>
Tue, 24 Jun 2014 15:18:51 +0000 (19:18 +0400)
committerVadim Pisarevsky <vadim.pisarevsky@gmail.com>
Tue, 24 Jun 2014 15:18:51 +0000 (19:18 +0400)
some of the stuff will be moved to opencv_contrib module.
in order to make this PR pass buildbot, please, comment off opencv_legacy, opencv_contrib and opencv_softcascade test runs.

398 files changed:
apps/CMakeLists.txt
apps/haartraining/CMakeLists.txt [deleted file]
apps/haartraining/_cvcommon.h [deleted file]
apps/haartraining/_cvhaartraining.h [deleted file]
apps/haartraining/createsamples.cpp [deleted file]
apps/haartraining/cvboost.cpp [deleted file]
apps/haartraining/cvclassifier.h [deleted file]
apps/haartraining/cvcommon.cpp [deleted file]
apps/haartraining/cvhaarclassifier.cpp [deleted file]
apps/haartraining/cvhaartraining.cpp [deleted file]
apps/haartraining/cvhaartraining.h [deleted file]
apps/haartraining/cvsamples.cpp [deleted file]
apps/haartraining/haartraining.cpp [deleted file]
apps/haartraining/performance.cpp [deleted file]
apps/sft/CMakeLists.txt [deleted file]
apps/sft/config.cpp [deleted file]
apps/sft/dataset.cpp [deleted file]
apps/sft/include/sft/common.hpp [deleted file]
apps/sft/include/sft/config.hpp [deleted file]
apps/sft/include/sft/dataset.hpp [deleted file]
apps/sft/sft.cpp [deleted file]
apps/traincascade/CMakeLists.txt
include/opencv/cv.h
include/opencv2/opencv.hpp
modules/contrib/CMakeLists.txt [deleted file]
modules/contrib/doc/contrib.rst [deleted file]
modules/contrib/doc/facerec/colormaps.rst [deleted file]
modules/contrib/doc/facerec/etc/at.txt [deleted file]
modules/contrib/doc/facerec/facerec_api.rst [deleted file]
modules/contrib/doc/facerec/facerec_changelog.rst [deleted file]
modules/contrib/doc/facerec/facerec_tutorial.rst [deleted file]
modules/contrib/doc/facerec/img/at_database_small_sample_size.png [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_autumn.jpg [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_bone.jpg [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_cool.jpg [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_hot.jpg [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_hsv.jpg [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_jet.jpg [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_mkpj1.jpg [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_mkpj2.jpg [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_ocean.jpg [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_pink.jpg [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_rainbow.jpg [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_spring.jpg [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_summer.jpg [deleted file]
modules/contrib/doc/facerec/img/colormaps/colorscale_winter.jpg [deleted file]
modules/contrib/doc/facerec/img/eigenface_reconstruction_opencv.png [deleted file]
modules/contrib/doc/facerec/img/eigenfaces_opencv.png [deleted file]
modules/contrib/doc/facerec/img/fisherface_reconstruction_opencv.png [deleted file]
modules/contrib/doc/facerec/img/fisherfaces_opencv.png [deleted file]
modules/contrib/doc/facerec/img/lbp/lbp.png [deleted file]
modules/contrib/doc/facerec/img/lbp/lbp_yale.jpg [deleted file]
modules/contrib/doc/facerec/img/lbp/patterns.png [deleted file]
modules/contrib/doc/facerec/img/tutorial/facerec_video/facerec_video.png [deleted file]
modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_10_10_200_200.jpg [deleted file]
modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_20_20_200_200.jpg [deleted file]
modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_20_20_70_70.jpg [deleted file]
modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_30_30_200_200.jpg [deleted file]
modules/contrib/doc/facerec/img/tutorial/gender_classification/clooney_set.png [deleted file]
modules/contrib/doc/facerec/img/tutorial/gender_classification/fisherface_0.png [deleted file]
modules/contrib/doc/facerec/img/tutorial/gender_classification/fisherface_reconstruction_0.png [deleted file]
modules/contrib/doc/facerec/img/tutorial/gender_classification/mean.png [deleted file]
modules/contrib/doc/facerec/index.rst [deleted file]
modules/contrib/doc/facerec/src/CMakeLists.txt [deleted file]
modules/contrib/doc/facerec/src/create_csv.py [deleted file]
modules/contrib/doc/facerec/src/crop_face.py [deleted file]
modules/contrib/doc/facerec/src/facerec_demo.cpp [deleted file]
modules/contrib/doc/facerec/src/facerec_eigenfaces.cpp [deleted file]
modules/contrib/doc/facerec/src/facerec_fisherfaces.cpp [deleted file]
modules/contrib/doc/facerec/src/facerec_lbph.cpp [deleted file]
modules/contrib/doc/facerec/src/facerec_save_load.cpp [deleted file]
modules/contrib/doc/facerec/src/facerec_video.cpp [deleted file]
modules/contrib/doc/facerec/tutorial/facerec_gender_classification.rst [deleted file]
modules/contrib/doc/facerec/tutorial/facerec_save_load.rst [deleted file]
modules/contrib/doc/facerec/tutorial/facerec_video_recognition.rst [deleted file]
modules/contrib/doc/openfabmap.rst [deleted file]
modules/contrib/doc/stereo.rst [deleted file]
modules/contrib/include/opencv2/contrib.hpp [deleted file]
modules/contrib/include/opencv2/contrib/compat.hpp [deleted file]
modules/contrib/include/opencv2/contrib/contrib.hpp [deleted file]
modules/contrib/include/opencv2/contrib/detection_based_tracker.hpp [deleted file]
modules/contrib/include/opencv2/contrib/hybridtracker.hpp [deleted file]
modules/contrib/include/opencv2/contrib/openfabmap.hpp [deleted file]
modules/contrib/src/adaptiveskindetector.cpp [deleted file]
modules/contrib/src/ba.cpp [deleted file]
modules/contrib/src/bowmsctrainer.cpp [deleted file]
modules/contrib/src/chamfermatching.cpp [deleted file]
modules/contrib/src/chowliutree.cpp [deleted file]
modules/contrib/src/colormap.cpp [deleted file]
modules/contrib/src/colortracker.cpp [deleted file]
modules/contrib/src/contrib_init.cpp [deleted file]
modules/contrib/src/detection_based_tracker.cpp [deleted file]
modules/contrib/src/facerec.cpp [deleted file]
modules/contrib/src/featuretracker.cpp [deleted file]
modules/contrib/src/fuzzymeanshifttracker.cpp [deleted file]
modules/contrib/src/gencolors.cpp [deleted file]
modules/contrib/src/hybridtracker.cpp [deleted file]
modules/contrib/src/inputoutput.cpp [deleted file]
modules/contrib/src/lda.cpp [deleted file]
modules/contrib/src/logpolar_bsm.cpp [deleted file]
modules/contrib/src/octree.cpp [deleted file]
modules/contrib/src/openfabmap.cpp [deleted file]
modules/contrib/src/polyfit.cpp [deleted file]
modules/contrib/src/precomp.hpp [deleted file]
modules/contrib/src/rgbdodometry.cpp [deleted file]
modules/contrib/src/selfsimilarity.cpp [deleted file]
modules/contrib/src/spinimages.cpp [deleted file]
modules/contrib/src/stereovar.cpp [deleted file]
modules/contrib/test/test_main.cpp [deleted file]
modules/contrib/test/test_precomp.hpp [deleted file]
modules/legacy/CMakeLists.txt [deleted file]
modules/legacy/doc/common_interfaces_of_descriptor_extractors.rst [deleted file]
modules/legacy/doc/common_interfaces_of_generic_descriptor_matchers.rst [deleted file]
modules/legacy/doc/expectation_maximization.rst [deleted file]
modules/legacy/doc/feature_detection_and_description.rst [deleted file]
modules/legacy/doc/histograms.rst [deleted file]
modules/legacy/doc/legacy.rst [deleted file]
modules/legacy/doc/motion_analysis.rst [deleted file]
modules/legacy/doc/pics/quadedge.png [deleted file]
modules/legacy/doc/pics/subdiv.png [deleted file]
modules/legacy/doc/planar_subdivisions.rst [deleted file]
modules/legacy/include/opencv2/legacy.hpp [deleted file]
modules/legacy/include/opencv2/legacy/blobtrack.hpp [deleted file]
modules/legacy/include/opencv2/legacy/compat.hpp [deleted file]
modules/legacy/include/opencv2/legacy/legacy.hpp [deleted file]
modules/legacy/include/opencv2/legacy/streams.hpp [deleted file]
modules/legacy/src/3dtracker.cpp [deleted file]
modules/legacy/src/_facedetection.h [deleted file]
modules/legacy/src/_featuretree.h [deleted file]
modules/legacy/src/_kdtree.hpp [deleted file]
modules/legacy/src/_matrix.h [deleted file]
modules/legacy/src/_vectrack.h [deleted file]
modules/legacy/src/_vm.h [deleted file]
modules/legacy/src/auxutils.cpp [deleted file]
modules/legacy/src/bgfg_acmmm2003.cpp [deleted file]
modules/legacy/src/bgfg_codebook.cpp [deleted file]
modules/legacy/src/bgfg_common.cpp [deleted file]
modules/legacy/src/bgfg_estimation.cpp [deleted file]
modules/legacy/src/bgfg_gaussmix.cpp [deleted file]
modules/legacy/src/blobtrack.cpp [deleted file]
modules/legacy/src/blobtrackanalysis.cpp [deleted file]
modules/legacy/src/blobtrackanalysishist.cpp [deleted file]
modules/legacy/src/blobtrackanalysisior.cpp [deleted file]
modules/legacy/src/blobtrackanalysistrackdist.cpp [deleted file]
modules/legacy/src/blobtrackgen1.cpp [deleted file]
modules/legacy/src/blobtrackgenyml.cpp [deleted file]
modules/legacy/src/blobtrackingauto.cpp [deleted file]
modules/legacy/src/blobtrackingcc.cpp [deleted file]
modules/legacy/src/blobtrackingccwithcr.cpp [deleted file]
modules/legacy/src/blobtrackinglist.cpp [deleted file]
modules/legacy/src/blobtrackingmsfg.cpp [deleted file]
modules/legacy/src/blobtrackingmsfgs.cpp [deleted file]
modules/legacy/src/blobtrackpostprockalman.cpp [deleted file]
modules/legacy/src/blobtrackpostproclinear.cpp [deleted file]
modules/legacy/src/blobtrackpostproclist.cpp [deleted file]
modules/legacy/src/calcimagehomography.cpp [deleted file]
modules/legacy/src/calibfilter.cpp [deleted file]
modules/legacy/src/calonder.cpp [deleted file]
modules/legacy/src/camshift.cpp [deleted file]
modules/legacy/src/clique.cpp [deleted file]
modules/legacy/src/compat.cpp [deleted file]
modules/legacy/src/condens.cpp [deleted file]
modules/legacy/src/contourtree.cpp [deleted file]
modules/legacy/src/correspond.cpp [deleted file]
modules/legacy/src/corrimages.cpp [deleted file]
modules/legacy/src/createhandmask.cpp [deleted file]
modules/legacy/src/decomppoly.cpp [deleted file]
modules/legacy/src/dominants.cpp [deleted file]
modules/legacy/src/dpstereo.cpp [deleted file]
modules/legacy/src/eigenobjects.cpp [deleted file]
modules/legacy/src/em.cpp [deleted file]
modules/legacy/src/enmin.cpp [deleted file]
modules/legacy/src/enteringblobdetection.cpp [deleted file]
modules/legacy/src/enteringblobdetectionreal.cpp [deleted file]
modules/legacy/src/epilines.cpp [deleted file]
modules/legacy/src/extendededges.cpp [deleted file]
modules/legacy/src/face.cpp [deleted file]
modules/legacy/src/face.h [deleted file]
modules/legacy/src/facedetection.cpp [deleted file]
modules/legacy/src/facedetection.h [deleted file]
modules/legacy/src/facetemplate.cpp [deleted file]
modules/legacy/src/facetemplate.h [deleted file]
modules/legacy/src/features2d.cpp [deleted file]
modules/legacy/src/featuretree.cpp [deleted file]
modules/legacy/src/findface.cpp [deleted file]
modules/legacy/src/findhandregion.cpp [deleted file]
modules/legacy/src/hmm.cpp [deleted file]
modules/legacy/src/hmm1d.cpp [deleted file]
modules/legacy/src/hmmobs.cpp [deleted file]
modules/legacy/src/image.cpp [deleted file]
modules/legacy/src/kdtree.cpp [deleted file]
modules/legacy/src/lcm.cpp [deleted file]
modules/legacy/src/lee.cpp [deleted file]
modules/legacy/src/levmar.cpp [deleted file]
modules/legacy/src/levmarprojbandle.cpp [deleted file]
modules/legacy/src/levmartrif.cpp [deleted file]
modules/legacy/src/lines.cpp [deleted file]
modules/legacy/src/lmeds.cpp [deleted file]
modules/legacy/src/lsh.cpp [deleted file]
modules/legacy/src/morphcontours.cpp [deleted file]
modules/legacy/src/morphing.cpp [deleted file]
modules/legacy/src/oneway.cpp [deleted file]
modules/legacy/src/optflowbm.cpp [deleted file]
modules/legacy/src/optflowhs.cpp [deleted file]
modules/legacy/src/optflowlk.cpp [deleted file]
modules/legacy/src/pgh.cpp [deleted file]
modules/legacy/src/planardetect.cpp [deleted file]
modules/legacy/src/precomp.hpp [deleted file]
modules/legacy/src/prewarp.cpp [deleted file]
modules/legacy/src/pyrsegmentation.cpp [deleted file]
modules/legacy/src/scanlines.cpp [deleted file]
modules/legacy/src/segment.cpp [deleted file]
modules/legacy/src/snakes.cpp [deleted file]
modules/legacy/src/spilltree.cpp [deleted file]
modules/legacy/src/stereogc.cpp [deleted file]
modules/legacy/src/subdiv2.cpp [deleted file]
modules/legacy/src/testseq.cpp [deleted file]
modules/legacy/src/texture.cpp [deleted file]
modules/legacy/src/trifocal.cpp [deleted file]
modules/legacy/src/vecfacetracking.cpp [deleted file]
modules/legacy/src/video.cpp [deleted file]
modules/legacy/test/test_bruteforcematcher.cpp [deleted file]
modules/legacy/test/test_em.cpp [deleted file]
modules/legacy/test/test_main.cpp [deleted file]
modules/legacy/test/test_nearestneighbors.cpp [deleted file]
modules/legacy/test/test_optflow.cpp [deleted file]
modules/legacy/test/test_precomp.hpp [deleted file]
modules/legacy/test/test_pyrsegmentation.cpp [deleted file]
modules/legacy/test/test_stereomatching.cpp [deleted file]
modules/legacy/test/test_subdivisions.cpp [deleted file]
modules/objdetect/include/opencv2/objdetect.hpp
modules/objdetect/include/opencv2/objdetect/objdetect_c.h
modules/objdetect/src/_latentsvm.h [deleted file]
modules/objdetect/src/_lsvm_distancetransform.h [deleted file]
modules/objdetect/src/_lsvm_error.h [deleted file]
modules/objdetect/src/_lsvm_fft.h [deleted file]
modules/objdetect/src/_lsvm_matching.h [deleted file]
modules/objdetect/src/_lsvm_resizeimg.h [deleted file]
modules/objdetect/src/_lsvm_routine.h [deleted file]
modules/objdetect/src/_lsvm_tbbversion.h [deleted file]
modules/objdetect/src/_lsvm_types.h [deleted file]
modules/objdetect/src/_lsvmparser.h [deleted file]
modules/objdetect/src/datamatrix.cpp [deleted file]
modules/objdetect/src/distancetransform.cpp [deleted file]
modules/objdetect/src/featurepyramid.cpp [deleted file]
modules/objdetect/src/fft.cpp [deleted file]
modules/objdetect/src/latentsvm.cpp [deleted file]
modules/objdetect/src/latentsvmdetector.cpp [deleted file]
modules/objdetect/src/lsvmparser.cpp [deleted file]
modules/objdetect/src/lsvmtbbversion.cpp [deleted file]
modules/objdetect/src/matching.cpp [deleted file]
modules/objdetect/src/resizeimg.cpp [deleted file]
modules/objdetect/src/routine.cpp [deleted file]
modules/objdetect/test/test_latentsvmdetector.cpp [deleted file]
modules/python/CMakeLists.txt
modules/python/src2/cv2.cpp
modules/python/src2/hdr_parser.py
modules/softcascade/CMakeLists.txt [deleted file]
modules/softcascade/doc/softcascade.rst [deleted file]
modules/softcascade/doc/softcascade_cuda.rst [deleted file]
modules/softcascade/doc/softcascade_detector.rst [deleted file]
modules/softcascade/doc/softcascade_training.rst [deleted file]
modules/softcascade/include/opencv2/softcascade.hpp [deleted file]
modules/softcascade/misc/detections2negatives.py [deleted file]
modules/softcascade/misc/roc_caltech.py [deleted file]
modules/softcascade/misc/roc_test.py [deleted file]
modules/softcascade/misc/scale_caltech.py [deleted file]
modules/softcascade/misc/scale_inria.py [deleted file]
modules/softcascade/misc/sft.py [deleted file]
modules/softcascade/perf/perf_cuda_softcascade.cpp [deleted file]
modules/softcascade/perf/perf_main.cpp [deleted file]
modules/softcascade/perf/perf_precomp.hpp [deleted file]
modules/softcascade/perf/perf_softcascade.cpp [deleted file]
modules/softcascade/src/cuda/channels.cu [deleted file]
modules/softcascade/src/cuda/icf-sc.cu [deleted file]
modules/softcascade/src/cuda_invoker.hpp [deleted file]
modules/softcascade/src/detector.cpp [deleted file]
modules/softcascade/src/detector_cuda.cpp [deleted file]
modules/softcascade/src/integral_channel_builder.cpp [deleted file]
modules/softcascade/src/octave.cpp [deleted file]
modules/softcascade/src/precomp.hpp [deleted file]
modules/softcascade/src/softcascade_init.cpp [deleted file]
modules/softcascade/test/test_channel_features.cpp [deleted file]
modules/softcascade/test/test_cuda_softcascade.cpp [deleted file]
modules/softcascade/test/test_main.cpp [deleted file]
modules/softcascade/test/test_precomp.hpp [deleted file]
modules/softcascade/test/test_softcascade.cpp [deleted file]
modules/softcascade/test/test_training.cpp [deleted file]
modules/softcascade/test/utility.cpp [deleted file]
modules/softcascade/test/utility.hpp [deleted file]
samples/CMakeLists.txt
samples/c/CMakeLists.txt [deleted file]
samples/c/JCB.png [deleted file]
samples/c/adaptiveskindetector.cpp [deleted file]
samples/c/baboon.jpg [deleted file]
samples/c/bgfg_codebook.cpp [deleted file]
samples/c/blobtrack_sample.cpp [deleted file]
samples/c/build_all.sh [deleted file]
samples/c/calonder_params.xml [deleted file]
samples/c/cat.jpg [deleted file]
samples/c/cat.xml [deleted file]
samples/c/contours.c [deleted file]
samples/c/convert_cascade.c [deleted file]
samples/c/cvsample.dsp [deleted file]
samples/c/cvsample.vs2005.vcproj [deleted file]
samples/c/delaunay.c [deleted file]
samples/c/example_cmake/CMakeLists.txt [deleted file]
samples/c/example_cmake/README.txt [deleted file]
samples/c/example_cmake/minarea.c [deleted file]
samples/c/facedetect.cmd [deleted file]
samples/c/fback_c.c [deleted file]
samples/c/find_obj.cpp [deleted file]
samples/c/find_obj_calonder.cpp [deleted file]
samples/c/find_obj_ferns.cpp [deleted file]
samples/c/fruits.jpg [deleted file]
samples/c/latentsvmdetect.cpp [deleted file]
samples/c/lena.jpg [deleted file]
samples/c/morphology.c [deleted file]
samples/c/mser_sample.cpp [deleted file]
samples/c/one_way_sample.cpp [deleted file]
samples/c/one_way_train_0000.jpg [deleted file]
samples/c/one_way_train_0001.jpg [deleted file]
samples/c/one_way_train_images.txt [deleted file]
samples/c/pyramid_segmentation.c [deleted file]
samples/c/stuff.jpg [deleted file]
samples/cpp/CMakeLists.txt
samples/cpp/Qt_sample/CMakeLists.txt [deleted file]
samples/cpp/Qt_sample/cube4.avi [deleted file]
samples/cpp/Qt_sample/qt_opengl.cpp [deleted file]
samples/cpp/agaricus-lepiota.data [moved from samples/c/agaricus-lepiota.data with 100% similarity]
samples/cpp/airplane.jpg [moved from samples/c/airplane.jpg with 100% similarity]
samples/cpp/baboon200.jpg [moved from samples/c/baboon200.jpg with 100% similarity]
samples/cpp/baboon200_rotated.jpg [moved from samples/c/baboon200_rotated.jpg with 100% similarity]
samples/cpp/bagofwords_classification.cpp
samples/cpp/box.png [moved from samples/c/box.png with 100% similarity]
samples/cpp/box_in_scene.png [moved from samples/c/box_in_scene.png with 100% similarity]
samples/cpp/brief_match_test.cpp [deleted file]
samples/cpp/build3dmodel.cpp [deleted file]
samples/cpp/calibration_artificial.cpp [deleted file]
samples/cpp/chamfer.cpp [deleted file]
samples/cpp/dbt_face_detection.cpp [deleted file]
samples/cpp/detection_based_tracker_sample.cpp [deleted file]
samples/cpp/detector_descriptor_evaluation.cpp [deleted file]
samples/cpp/detector_descriptor_matcher_evaluation.cpp [deleted file]
samples/cpp/em.cpp
samples/cpp/fabmap/stlucia_test_small0000.jpeg [deleted file]
samples/cpp/fabmap/stlucia_test_small0001.jpeg [deleted file]
samples/cpp/fabmap/stlucia_test_small0002.jpeg [deleted file]
samples/cpp/fabmap/stlucia_test_small0003.jpeg [deleted file]
samples/cpp/fabmap/stlucia_test_small0004.jpeg [deleted file]
samples/cpp/fabmap/stlucia_test_small0005.jpeg [deleted file]
samples/cpp/fabmap/stlucia_test_small0006.jpeg [deleted file]
samples/cpp/fabmap/stlucia_test_small0007.jpeg [deleted file]
samples/cpp/fabmap/stlucia_test_small0008.jpeg [deleted file]
samples/cpp/fabmap/stlucia_test_small0009.jpeg [deleted file]
samples/cpp/fabmap/train_data_small.yml [deleted file]
samples/cpp/fabmap/vocab_small.yml [deleted file]
samples/cpp/fabmap_sample.cpp [deleted file]
samples/cpp/facedetect.cpp [moved from samples/c/facedetect.cpp with 100% similarity]
samples/cpp/facerec_at_t.txt [deleted file]
samples/cpp/facerec_demo.cpp [deleted file]
samples/cpp/fern_params.xml [deleted file]
samples/cpp/freak_demo.cpp [deleted file]
samples/cpp/gencolors.cpp [deleted file]
samples/cpp/generic_descriptor_match.cpp [deleted file]
samples/cpp/hybridtrackingsample.cpp [deleted file]
samples/cpp/image.cpp
samples/cpp/intrinsics.yml [moved from samples/c/intrinsics.yml with 100% similarity]
samples/cpp/latentsvm_multidetect.cpp [deleted file]
samples/cpp/logpolar_bsm.cpp [deleted file]
samples/cpp/matcher_simple.cpp [deleted file]
samples/cpp/matching_to_many_images.cpp [deleted file]
samples/cpp/matching_to_many_images/query.png [deleted file]
samples/cpp/matching_to_many_images/train/1.png [deleted file]
samples/cpp/matching_to_many_images/train/2.png [deleted file]
samples/cpp/matching_to_many_images/train/3.png [deleted file]
samples/cpp/matching_to_many_images/train/trainImages.txt [deleted file]
samples/cpp/meanshift_segmentation.cpp [deleted file]
samples/cpp/motempl.cpp [moved from samples/c/motempl.c with 100% similarity]
samples/cpp/mushroom.cpp [moved from samples/c/mushroom.cpp with 100% similarity]
samples/cpp/peopledetect.cpp [deleted file]
samples/cpp/polar_transforms.cpp [moved from samples/c/polar_transforms.c with 100% similarity]
samples/cpp/puzzle.png [moved from samples/c/puzzle.png with 100% similarity]
samples/cpp/rgbdodometry.cpp [deleted file]
samples/cpp/rgbdodometry/depth_00000.png [deleted file]
samples/cpp/rgbdodometry/depth_00002.png [deleted file]
samples/cpp/rgbdodometry/image_00000.png [deleted file]
samples/cpp/rgbdodometry/image_00002.png [deleted file]
samples/cpp/scene_l.bmp [moved from samples/c/scene_l.bmp with 100% similarity]
samples/cpp/scene_r.bmp [moved from samples/c/scene_r.bmp with 100% similarity]
samples/cpp/smiledetect.cpp [moved from samples/c/smiledetect.cpp with 100% similarity]
samples/cpp/stereo_match.cpp
samples/cpp/tree.avi [moved from samples/c/tree.avi with 100% similarity]
samples/cpp/tree_engine.cpp [moved from samples/c/tree_engine.cpp with 100% similarity]
samples/cpp/video_dmtx.cpp [deleted file]
samples/cpp/waveform.data [moved from samples/c/waveform.data with 100% similarity]
samples/python2/facerec_demo.py [deleted file]
samples/python2/video_dmtx.py [deleted file]

index b1d7f42..1814efb 100644 (file)
@@ -1,6 +1,4 @@
 add_definitions(-D__OPENCV_BUILD=1)
 link_libraries(${OPENCV_LINKER_LIBS})
 
-add_subdirectory(haartraining)
 add_subdirectory(traincascade)
-add_subdirectory(sft)
diff --git a/apps/haartraining/CMakeLists.txt b/apps/haartraining/CMakeLists.txt
deleted file mode 100644 (file)
index 63bbff6..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-SET(OPENCV_HAARTRAINING_DEPS opencv_core opencv_imgproc opencv_photo opencv_ml opencv_highgui opencv_objdetect opencv_calib3d opencv_video opencv_features2d opencv_flann opencv_legacy)
-ocv_check_dependencies(${OPENCV_HAARTRAINING_DEPS})
-
-if(NOT OCV_DEPENDENCIES_FOUND)
-  return()
-endif()
-
-project(haartraining)
-
-ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
-ocv_include_modules(${OPENCV_HAARTRAINING_DEPS})
-
-if(WIN32)
-  link_directories(${CMAKE_CURRENT_BINARY_DIR})
-endif()
-
-link_libraries(${OPENCV_HAARTRAINING_DEPS} opencv_haartraining_engine)
-
-# -----------------------------------------------------------
-#  Library
-# -----------------------------------------------------------
-set(cvhaartraining_lib_src
-  _cvcommon.h
-  cvclassifier.h
-  _cvhaartraining.h
-  cvhaartraining.h
-  cvboost.cpp
-  cvcommon.cpp
-  cvhaarclassifier.cpp
-  cvhaartraining.cpp
-  cvsamples.cpp
-  )
-
-add_library(opencv_haartraining_engine STATIC ${cvhaartraining_lib_src})
-set_target_properties(opencv_haartraining_engine PROPERTIES
-                      DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
-                      ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
-                      RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
-                      INSTALL_NAME_DIR lib
-                     )
-
-# -----------------------------------------------------------
-#  haartraining
-# -----------------------------------------------------------
-
-add_executable(opencv_haartraining cvhaartraining.h haartraining.cpp)
-set_target_properties(opencv_haartraining PROPERTIES
-                      DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
-                      OUTPUT_NAME "opencv_haartraining")
-
-# -----------------------------------------------------------
-#  createsamples
-# -----------------------------------------------------------
-
-add_executable(opencv_createsamples cvhaartraining.h createsamples.cpp)
-set_target_properties(opencv_createsamples PROPERTIES
-                      DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
-                      OUTPUT_NAME "opencv_createsamples")
-
-# -----------------------------------------------------------
-#  performance
-# -----------------------------------------------------------
-add_executable(opencv_performance performance.cpp)
-set_target_properties(opencv_performance PROPERTIES
-                      DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
-                      OUTPUT_NAME "opencv_performance")
-
-# -----------------------------------------------------------
-#  Install part
-# -----------------------------------------------------------
-
-if(INSTALL_CREATE_DISTRIB)
-  if(BUILD_SHARED_LIBS)
-    install(TARGETS opencv_haartraining RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev)
-    install(TARGETS opencv_createsamples RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev)
-    install(TARGETS opencv_performance RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev)
-  endif()
-else()
-  install(TARGETS opencv_haartraining RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev)
-  install(TARGETS opencv_createsamples RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev)
-  install(TARGETS opencv_performance RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev)
-endif()
-
-if(ENABLE_SOLUTION_FOLDERS)
-  set_target_properties(opencv_performance PROPERTIES FOLDER "applications")
-  set_target_properties(opencv_createsamples PROPERTIES FOLDER "applications")
-  set_target_properties(opencv_haartraining PROPERTIES FOLDER "applications")
-  set_target_properties(opencv_haartraining_engine PROPERTIES FOLDER "applications")
-endif()
diff --git a/apps/haartraining/_cvcommon.h b/apps/haartraining/_cvcommon.h
deleted file mode 100644 (file)
index 92fee8e..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __CVCOMMON_H_
-#define __CVCOMMON_H_
-
-#include "opencv2/core.hpp"
-
-#include "cxcore.h"
-#include "cv.h"
-#include "cxmisc.h"
-
-#define __BEGIN__ __CV_BEGIN__
-#define __END__  __CV_END__
-#define EXIT __CV_EXIT__
-
-#ifndef PATH_MAX
-#define PATH_MAX 512
-#endif /* PATH_MAX */
-
-int icvMkDir( const char* filename );
-
-/* returns index at specified position from index matrix of any type.
-   if matrix is NULL, then specified position is returned */
-CV_INLINE
-int icvGetIdxAt( CvMat* idx, int pos );
-
-CV_INLINE
-int icvGetIdxAt( CvMat* idx, int pos )
-{
-    if( idx == NULL )
-    {
-        return pos;
-    }
-    else
-    {
-        CvScalar sc;
-        int type;
-
-        type = CV_MAT_TYPE( idx->type );
-        cvRawDataToScalar( idx->data.ptr + pos *
-            ( (idx->rows == 1) ? CV_ELEM_SIZE( type ) : idx->step ), type, &sc );
-
-        return (int) sc.val[0];
-    }
-}
-
-/* debug functions */
-
-#define CV_DEBUG_SAVE( ptr ) icvSave( ptr, __FILE__, __LINE__ );
-
-void icvSave( const CvArr* ptr, const char* filename, int line );
-
-#endif /* __CVCOMMON_H_ */
diff --git a/apps/haartraining/_cvhaartraining.h b/apps/haartraining/_cvhaartraining.h
deleted file mode 100644 (file)
index 459e6aa..0000000
+++ /dev/null
@@ -1,414 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
- * _cvhaartraining.h
- *
- * training of cascade of boosted classifiers based on haar features
- */
-
-#ifndef __CVHAARTRAINING_H_
-#define __CVHAARTRAINING_H_
-
-#include "_cvcommon.h"
-#include "cvclassifier.h"
-#include <cstring>
-#include <cstdio>
-
-/* parameters for tree cascade classifier training */
-
-/* max number of clusters */
-#define CV_MAX_CLUSTERS 3
-
-/* term criteria for K-Means */
-#define CV_TERM_CRITERIA() cvTermCriteria( CV_TERMCRIT_EPS, 1000, 1E-5 )
-
-/* print statistic info */
-#define CV_VERBOSE 1
-
-#define CV_STAGE_CART_FILE_NAME "AdaBoostCARTHaarClassifier.txt"
-
-#define CV_HAAR_FEATURE_MAX      3
-#define CV_HAAR_FEATURE_DESC_MAX 20
-
-typedef int    sum_type;
-typedef double sqsum_type;
-typedef short  idx_type;
-
-#define CV_SUM_MAT_TYPE CV_32SC1
-#define CV_SQSUM_MAT_TYPE CV_64FC1
-#define CV_IDX_MAT_TYPE CV_16SC1
-
-#define CV_STUMP_TRAIN_PORTION 100
-
-#define CV_THRESHOLD_EPS (0.00001F)
-
-typedef struct CvTHaarFeature
-{
-    char desc[CV_HAAR_FEATURE_DESC_MAX];
-    int  tilted;
-    struct
-    {
-        CvRect r;
-        float weight;
-    } rect[CV_HAAR_FEATURE_MAX];
-} CvTHaarFeature;
-
-typedef struct CvFastHaarFeature
-{
-    int tilted;
-    struct
-    {
-        int p0, p1, p2, p3;
-        float weight;
-    } rect[CV_HAAR_FEATURE_MAX];
-} CvFastHaarFeature;
-
-typedef struct CvIntHaarFeatures
-{
-    CvSize winsize;
-    int count;
-    CvTHaarFeature* feature;
-    CvFastHaarFeature* fastfeature;
-} CvIntHaarFeatures;
-
-CV_INLINE CvTHaarFeature cvHaarFeature( const char* desc,
-                            int x0, int y0, int w0, int h0, float wt0,
-                            int x1, int y1, int w1, int h1, float wt1,
-                            int x2 CV_DEFAULT( 0 ), int y2 CV_DEFAULT( 0 ),
-                            int w2 CV_DEFAULT( 0 ), int h2 CV_DEFAULT( 0 ),
-                            float wt2 CV_DEFAULT( 0.0F ) );
-
-CV_INLINE CvTHaarFeature cvHaarFeature( const char* desc,
-                            int x0, int y0, int w0, int h0, float wt0,
-                            int x1, int y1, int w1, int h1, float wt1,
-                            int x2, int y2, int w2, int h2, float wt2 )
-{
-    CvTHaarFeature hf;
-
-    assert( CV_HAAR_FEATURE_MAX >= 3 );
-    assert( strlen( desc ) < CV_HAAR_FEATURE_DESC_MAX );
-
-    strcpy( &(hf.desc[0]), desc );
-    hf.tilted = ( hf.desc[0] == 't' );
-
-    hf.rect[0].r.x = x0;
-    hf.rect[0].r.y = y0;
-    hf.rect[0].r.width  = w0;
-    hf.rect[0].r.height = h0;
-    hf.rect[0].weight   = wt0;
-
-    hf.rect[1].r.x = x1;
-    hf.rect[1].r.y = y1;
-    hf.rect[1].r.width  = w1;
-    hf.rect[1].r.height = h1;
-    hf.rect[1].weight   = wt1;
-
-    hf.rect[2].r.x = x2;
-    hf.rect[2].r.y = y2;
-    hf.rect[2].r.width  = w2;
-    hf.rect[2].r.height = h2;
-    hf.rect[2].weight   = wt2;
-
-    return hf;
-}
-
-/* Prepared for training samples */
-typedef struct CvHaarTrainingData
-{
-    CvSize winsize;     /* training image size */
-    int    maxnum;      /* maximum number of samples */
-    CvMat  sum;         /* sum images (each row represents image) */
-    CvMat  tilted;      /* tilted sum images (each row represents image) */
-    CvMat  normfactor;  /* normalization factor */
-    CvMat  cls;         /* classes. 1.0 - object, 0.0 - background */
-    CvMat  weights;     /* weights */
-
-    CvMat* valcache;    /* precalculated feature values (CV_32FC1) */
-    CvMat* idxcache;    /* presorted indices (CV_IDX_MAT_TYPE) */
-} CvHaarTrainigData;
-
-
-/* Passed to callback functions */
-typedef struct CvUserdata
-{
-    CvHaarTrainingData* trainingData;
-    CvIntHaarFeatures* haarFeatures;
-} CvUserdata;
-
-CV_INLINE
-CvUserdata cvUserdata( CvHaarTrainingData* trainingData,
-                       CvIntHaarFeatures* haarFeatures );
-
-CV_INLINE
-CvUserdata cvUserdata( CvHaarTrainingData* trainingData,
-                       CvIntHaarFeatures* haarFeatures )
-{
-    CvUserdata userdata;
-
-    userdata.trainingData = trainingData;
-    userdata.haarFeatures = haarFeatures;
-
-    return userdata;
-}
-
-
-#define CV_INT_HAAR_CLASSIFIER_FIELDS()                                 \
-    float (*eval)( CvIntHaarClassifier*, sum_type*, sum_type*, float ); \
-    void  (*save)( CvIntHaarClassifier*, FILE* file );                  \
-    void  (*release)( CvIntHaarClassifier** );
-
-/* internal weak classifier*/
-typedef struct CvIntHaarClassifier
-{
-    CV_INT_HAAR_CLASSIFIER_FIELDS()
-} CvIntHaarClassifier;
-
-/*
- * CART classifier
- */
-typedef struct CvCARTHaarClassifier
-{
-    CV_INT_HAAR_CLASSIFIER_FIELDS()
-
-    int count;
-    int* compidx;
-    CvTHaarFeature* feature;
-    CvFastHaarFeature* fastfeature;
-    float* threshold;
-    int* left;
-    int* right;
-    float* val;
-} CvCARTHaarClassifier;
-
-/* internal stage classifier */
-typedef struct CvStageHaarClassifier
-{
-    CV_INT_HAAR_CLASSIFIER_FIELDS()
-
-    int count;
-    float threshold;
-    CvIntHaarClassifier** classifier;
-} CvStageHaarClassifier;
-
-/* internal cascade classifier */
-typedef struct CvCascadeHaarClassifier
-{
-    CV_INT_HAAR_CLASSIFIER_FIELDS()
-
-    int count;
-    CvIntHaarClassifier** classifier;
-} CvCascadeHaarClassifier;
-
-
-/* internal tree cascade classifier node */
-typedef struct CvTreeCascadeNode
-{
-    CvStageHaarClassifier* stage;
-
-    struct CvTreeCascadeNode* next;
-    struct CvTreeCascadeNode* child;
-    struct CvTreeCascadeNode* parent;
-
-    struct CvTreeCascadeNode* next_same_level;
-    struct CvTreeCascadeNode* child_eval;
-    int idx;
-    int leaf;
-} CvTreeCascadeNode;
-
-/* internal tree cascade classifier */
-typedef struct CvTreeCascadeClassifier
-{
-    CV_INT_HAAR_CLASSIFIER_FIELDS()
-
-    CvTreeCascadeNode* root;      /* root of the tree */
-    CvTreeCascadeNode* root_eval; /* root node for the filtering */
-
-    int next_idx;
-} CvTreeCascadeClassifier;
-
-
-CV_INLINE float cvEvalFastHaarFeature( const CvFastHaarFeature* feature,
-                                       const sum_type* sum, const sum_type* tilted )
-{
-    const sum_type* img = feature->tilted ? tilted : sum;
-    float ret = feature->rect[0].weight*
-        (img[feature->rect[0].p0] - img[feature->rect[0].p1] -
-         img[feature->rect[0].p2] + img[feature->rect[0].p3]) +
-         feature->rect[1].weight*
-        (img[feature->rect[1].p0] - img[feature->rect[1].p1] -
-         img[feature->rect[1].p2] + img[feature->rect[1].p3]);
-
-    if( feature->rect[2].weight != 0.0f )
-        ret += feature->rect[2].weight *
-            ( img[feature->rect[2].p0] - img[feature->rect[2].p1] -
-              img[feature->rect[2].p2] + img[feature->rect[2].p3] );
-    return ret;
-}
-
-
-typedef struct CvSampleDistortionData
-{
-    IplImage* src;
-    IplImage* erode;
-    IplImage* dilate;
-    IplImage* mask;
-    IplImage* img;
-    IplImage* maskimg;
-    int dx;
-    int dy;
-    int bgcolor;
-} CvSampleDistortionData;
-
-/*
- * icvConvertToFastHaarFeature
- *
- * Convert to fast representation of haar features
- *
- * haarFeature     - input array
- * fastHaarFeature - output array
- * size            - size of arrays
- * step            - row step for the integral image
- */
-void icvConvertToFastHaarFeature( CvTHaarFeature* haarFeature,
-                                  CvFastHaarFeature* fastHaarFeature,
-                                  int size, int step );
-
-
-void icvWriteVecHeader( FILE* file, int count, int width, int height );
-void icvWriteVecSample( FILE* file, CvArr* sample );
-void icvPlaceDistortedSample( CvArr* background,
-                              int inverse, int maxintensitydev,
-                              double maxxangle, double maxyangle, double maxzangle,
-                              int inscribe, double maxshiftf, double maxscalef,
-                              CvSampleDistortionData* data );
-void icvEndSampleDistortion( CvSampleDistortionData* data );
-
-int icvStartSampleDistortion( const char* imgfilename, int bgcolor, int bgthreshold,
-                              CvSampleDistortionData* data );
-
-typedef int (*CvGetHaarTrainingDataCallback)( CvMat* img, void* userdata );
-
-typedef struct CvVecFile
-{
-    FILE*  input;
-    int    count;
-    int    vecsize;
-    int    last;
-    short* vector;
-} CvVecFile;
-
-int icvGetHaarTraininDataFromVecCallback( CvMat* img, void* userdata );
-
-/*
- * icvGetHaarTrainingDataFromVec
- *
- * Fill <data> with samples from .vec file, passed <cascade>
-int icvGetHaarTrainingDataFromVec( CvHaarTrainingData* data, int first, int count,
-                                   CvIntHaarClassifier* cascade,
-                                   const char* filename,
-                                   int* consumed );
- */
-
-CvIntHaarClassifier* icvCreateCARTHaarClassifier( int count );
-
-void icvReleaseHaarClassifier( CvIntHaarClassifier** classifier );
-
-void icvInitCARTHaarClassifier( CvCARTHaarClassifier* carthaar, CvCARTClassifier* cart,
-                                CvIntHaarFeatures* intHaarFeatures );
-
-float icvEvalCARTHaarClassifier( CvIntHaarClassifier* classifier,
-                                 sum_type* sum, sum_type* tilted, float normfactor );
-
-CvIntHaarClassifier* icvCreateStageHaarClassifier( int count, float threshold );
-
-void icvReleaseStageHaarClassifier( CvIntHaarClassifier** classifier );
-
-float icvEvalStageHaarClassifier( CvIntHaarClassifier* classifier,
-                                  sum_type* sum, sum_type* tilted, float normfactor );
-
-CvIntHaarClassifier* icvCreateCascadeHaarClassifier( int count );
-
-void icvReleaseCascadeHaarClassifier( CvIntHaarClassifier** classifier );
-
-float icvEvalCascadeHaarClassifier( CvIntHaarClassifier* classifier,
-                                    sum_type* sum, sum_type* tilted, float normfactor );
-
-void icvSaveHaarFeature( CvTHaarFeature* feature, FILE* file );
-
-void icvLoadHaarFeature( CvTHaarFeature* feature, FILE* file );
-
-void icvSaveCARTHaarClassifier( CvIntHaarClassifier* classifier, FILE* file );
-
-CvIntHaarClassifier* icvLoadCARTHaarClassifier( FILE* file, int step );
-
-void icvSaveStageHaarClassifier( CvIntHaarClassifier* classifier, FILE* file );
-
-CvIntHaarClassifier* icvLoadCARTStageHaarClassifier( const char* filename, int step );
-
-
-/* tree cascade classifier */
-
-float icvEvalTreeCascadeClassifier( CvIntHaarClassifier* classifier,
-                                    sum_type* sum, sum_type* tilted, float normfactor );
-
-void icvSetLeafNode( CvTreeCascadeClassifier* tree, CvTreeCascadeNode* leaf );
-
-float icvEvalTreeCascadeClassifierFilter( CvIntHaarClassifier* classifier, sum_type* sum,
-                                          sum_type* tilted, float normfactor );
-
-CvTreeCascadeNode* icvCreateTreeCascadeNode();
-
-void icvReleaseTreeCascadeNodes( CvTreeCascadeNode** node );
-
-void icvReleaseTreeCascadeClassifier( CvIntHaarClassifier** classifier );
-
-/* Prints out current tree structure to <stdout> */
-void icvPrintTreeCascade( CvTreeCascadeNode* root );
-
-/* Loads tree cascade classifier */
-CvIntHaarClassifier* icvLoadTreeCascadeClassifier( const char* filename, int step,
-                                                   int* splits );
-
-/* Finds leaves belonging to maximal level and connects them via leaf->next_same_level */
-CvTreeCascadeNode* icvFindDeepestLeaves( CvTreeCascadeClassifier* tree );
-
-#endif /* __CVHAARTRAINING_H_ */
diff --git a/apps/haartraining/createsamples.cpp b/apps/haartraining/createsamples.cpp
deleted file mode 100644 (file)
index 2e86cca..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
- * createsamples.cpp
- *
- * Create test/training samples
- */
-
-#include <cstdio>
-#include <cstring>
-#include <cstdlib>
-#include <cmath>
-#include <ctime>
-
-using namespace std;
-
-#include "cvhaartraining.h"
-
-int main( int argc, char* argv[] )
-{
-    int i = 0;
-    char* nullname   = (char*)"(NULL)";
-    char* vecname    = NULL; /* .vec file name */
-    char* infoname   = NULL; /* file name with marked up image descriptions */
-    char* imagename  = NULL; /* single sample image */
-    char* bgfilename = NULL; /* background */
-    int num = 1000;
-    int bgcolor = 0;
-    int bgthreshold = 80;
-    int invert = 0;
-    int maxintensitydev = 40;
-    double maxxangle = 1.1;
-    double maxyangle = 1.1;
-    double maxzangle = 0.5;
-    int showsamples = 0;
-    /* the samples are adjusted to this scale in the sample preview window */
-    double scale = 4.0;
-    int width  = 24;
-    int height = 24;
-
-    srand((unsigned int)time(0));
-
-    if( argc == 1 )
-    {
-        printf( "Usage: %s\n  [-info <collection_file_name>]\n"
-                "  [-img <image_file_name>]\n"
-                "  [-vec <vec_file_name>]\n"
-                "  [-bg <background_file_name>]\n  [-num <number_of_samples = %d>]\n"
-                "  [-bgcolor <background_color = %d>]\n"
-                "  [-inv] [-randinv] [-bgthresh <background_color_threshold = %d>]\n"
-                "  [-maxidev <max_intensity_deviation = %d>]\n"
-                "  [-maxxangle <max_x_rotation_angle = %f>]\n"
-                "  [-maxyangle <max_y_rotation_angle = %f>]\n"
-                "  [-maxzangle <max_z_rotation_angle = %f>]\n"
-                "  [-show [<scale = %f>]]\n"
-                "  [-w <sample_width = %d>]\n  [-h <sample_height = %d>]\n",
-                argv[0], num, bgcolor, bgthreshold, maxintensitydev,
-                maxxangle, maxyangle, maxzangle, scale, width, height );
-
-        return 0;
-    }
-
-    for( i = 1; i < argc; ++i )
-    {
-        if( !strcmp( argv[i], "-info" ) )
-        {
-            infoname = argv[++i];
-        }
-        else if( !strcmp( argv[i], "-img" ) )
-        {
-            imagename = argv[++i];
-        }
-        else if( !strcmp( argv[i], "-vec" ) )
-        {
-            vecname = argv[++i];
-        }
-        else if( !strcmp( argv[i], "-bg" ) )
-        {
-            bgfilename = argv[++i];
-        }
-        else if( !strcmp( argv[i], "-num" ) )
-        {
-            num = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-bgcolor" ) )
-        {
-            bgcolor = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-bgthresh" ) )
-        {
-            bgthreshold = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-inv" ) )
-        {
-            invert = 1;
-        }
-        else if( !strcmp( argv[i], "-randinv" ) )
-        {
-            invert = CV_RANDOM_INVERT;
-        }
-        else if( !strcmp( argv[i], "-maxidev" ) )
-        {
-            maxintensitydev = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-maxxangle" ) )
-        {
-            maxxangle = atof( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-maxyangle" ) )
-        {
-            maxyangle = atof( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-maxzangle" ) )
-        {
-            maxzangle = atof( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-show" ) )
-        {
-            showsamples = 1;
-            if( i+1 < argc && strlen( argv[i+1] ) > 0 && argv[i+1][0] != '-' )
-            {
-                double d;
-                d = strtod( argv[i+1], 0 );
-                if( d != -HUGE_VAL && d != HUGE_VAL && d > 0 ) scale = d;
-                ++i;
-            }
-        }
-        else if( !strcmp( argv[i], "-w" ) )
-        {
-            width = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-h" ) )
-        {
-            height = atoi( argv[++i] );
-        }
-    }
-
-    printf( "Info file name: %s\n", ((infoname == NULL) ?   nullname : infoname ) );
-    printf( "Img file name: %s\n",  ((imagename == NULL) ?  nullname : imagename ) );
-    printf( "Vec file name: %s\n",  ((vecname == NULL) ?    nullname : vecname ) );
-    printf( "BG  file name: %s\n",  ((bgfilename == NULL) ? nullname : bgfilename ) );
-    printf( "Num: %d\n", num );
-    printf( "BG color: %d\n", bgcolor );
-    printf( "BG threshold: %d\n", bgthreshold );
-    printf( "Invert: %s\n", (invert == CV_RANDOM_INVERT) ? "RANDOM"
-                                : ( (invert) ? "TRUE" : "FALSE" ) );
-    printf( "Max intensity deviation: %d\n", maxintensitydev );
-    printf( "Max x angle: %g\n", maxxangle );
-    printf( "Max y angle: %g\n", maxyangle );
-    printf( "Max z angle: %g\n", maxzangle );
-    printf( "Show samples: %s\n", (showsamples) ? "TRUE" : "FALSE" );
-    if( showsamples )
-    {
-        printf( "Scale: %g\n", scale );
-    }
-    printf( "Width: %d\n", width );
-    printf( "Height: %d\n", height );
-
-    /* determine action */
-    if( imagename && vecname )
-    {
-        printf( "Create training samples from single image applying distortions...\n" );
-
-        cvCreateTrainingSamples( vecname, imagename, bgcolor, bgthreshold, bgfilename,
-                                 num, invert, maxintensitydev,
-                                 maxxangle, maxyangle, maxzangle,
-                                 showsamples, width, height );
-
-        printf( "Done\n" );
-    }
-    else if( imagename && bgfilename && infoname )
-    {
-        printf( "Create test samples from single image applying distortions...\n" );
-
-        cvCreateTestSamples( infoname, imagename, bgcolor, bgthreshold, bgfilename, num,
-            invert, maxintensitydev,
-            maxxangle, maxyangle, maxzangle, showsamples, width, height );
-
-        printf( "Done\n" );
-    }
-    else if( infoname && vecname )
-    {
-        int total;
-
-        printf( "Create training samples from images collection...\n" );
-
-        total = cvCreateTrainingSamplesFromInfo( infoname, vecname, num, showsamples,
-                                                 width, height );
-
-        printf( "Done. Created %d samples\n", total );
-    }
-    else if( vecname )
-    {
-        printf( "View samples from vec file (press ESC to exit)...\n" );
-
-        cvShowVecSamples( vecname, width, height, scale );
-
-        printf( "Done\n" );
-    }
-    else
-    {
-        printf( "Nothing to do\n" );
-    }
-
-    return 0;
-}
diff --git a/apps/haartraining/cvboost.cpp b/apps/haartraining/cvboost.cpp
deleted file mode 100644 (file)
index 4b9f24f..0000000
+++ /dev/null
@@ -1,3789 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "cvconfig.h"
-
-#ifdef HAVE_MALLOC_H
-  #include <malloc.h>
-#endif
-
-#ifdef HAVE_MEMORY_H
-  #include <memory.h>
-#endif
-
-#ifdef _OPENMP
-  #include <omp.h>
-#endif /* _OPENMP */
-
-#include <cstdio>
-#include <cfloat>
-#include <cmath>
-#include <ctime>
-#include <climits>
-
-#include "_cvcommon.h"
-#include "cvclassifier.h"
-
-#ifdef _OPENMP
-#include "omp.h"
-#endif
-
-#define CV_BOOST_IMPL
-
-typedef struct CvValArray
-{
-    uchar* data;
-    size_t step;
-} CvValArray;
-
-template<typename T, typename Idx>
-class LessThanValArray
-{
-public:
-    LessThanValArray( const T* _aux ) : aux(_aux) {}
-    bool operator()(Idx a, Idx b) const
-    {
-        return *( (float*) (aux->data + ((int) (a)) * aux->step ) ) <
-               *( (float*) (aux->data + ((int) (b)) * aux->step ) );
-    }
-    const T* aux;
-};
-
-CV_BOOST_IMPL
-void cvGetSortedIndices( CvMat* val, CvMat* idx, int sortcols )
-{
-    int idxtype = 0;
-    size_t istep = 0;
-    size_t jstep = 0;
-
-    int i = 0;
-    int j = 0;
-
-    CvValArray va;
-
-    CV_Assert( idx != NULL );
-    CV_Assert( val != NULL );
-
-    idxtype = CV_MAT_TYPE( idx->type );
-    CV_Assert( idxtype == CV_16SC1 || idxtype == CV_32SC1 || idxtype == CV_32FC1 );
-    CV_Assert( CV_MAT_TYPE( val->type ) == CV_32FC1 );
-    if( sortcols )
-    {
-        CV_Assert( idx->rows == val->cols );
-        CV_Assert( idx->cols == val->rows );
-        istep = CV_ELEM_SIZE( val->type );
-        jstep = val->step;
-    }
-    else
-    {
-        CV_Assert( idx->rows == val->rows );
-        CV_Assert( idx->cols == val->cols );
-        istep = val->step;
-        jstep = CV_ELEM_SIZE( val->type );
-    }
-
-    va.data = val->data.ptr;
-    va.step = jstep;
-    switch( idxtype )
-    {
-        case CV_16SC1:
-            for( i = 0; i < idx->rows; i++ )
-            {
-                for( j = 0; j < idx->cols; j++ )
-                {
-                    CV_MAT_ELEM( *idx, short, i, j ) = (short) j;
-                }
-                std::sort((short*) (idx->data.ptr + (size_t)i * idx->step),
-                          (short*) (idx->data.ptr + (size_t)i * idx->step) + idx->cols,
-                          LessThanValArray<CvValArray, short>(&va));
-                va.data += istep;
-            }
-            break;
-
-        case CV_32SC1:
-            for( i = 0; i < idx->rows; i++ )
-            {
-                for( j = 0; j < idx->cols; j++ )
-                {
-                    CV_MAT_ELEM( *idx, int, i, j ) = j;
-                }
-                std::sort((int*) (idx->data.ptr + (size_t)i * idx->step),
-                          (int*) (idx->data.ptr + (size_t)i * idx->step) + idx->cols,
-                          LessThanValArray<CvValArray, int>(&va));
-                va.data += istep;
-            }
-            break;
-
-        case CV_32FC1:
-            for( i = 0; i < idx->rows; i++ )
-            {
-                for( j = 0; j < idx->cols; j++ )
-                {
-                    CV_MAT_ELEM( *idx, float, i, j ) = (float) j;
-                }
-                std::sort((float*) (idx->data.ptr + (size_t)i * idx->step),
-                          (float*) (idx->data.ptr + (size_t)i * idx->step) + idx->cols,
-                          LessThanValArray<CvValArray, float>(&va));
-                va.data += istep;
-            }
-            break;
-
-        default:
-            assert( 0 );
-            break;
-    }
-}
-
-CV_BOOST_IMPL
-void cvReleaseStumpClassifier( CvClassifier** classifier )
-{
-    cvFree( classifier );
-    *classifier = 0;
-}
-
-CV_BOOST_IMPL
-float cvEvalStumpClassifier( CvClassifier* classifier, CvMat* sample )
-{
-    assert( classifier != NULL );
-    assert( sample != NULL );
-    assert( CV_MAT_TYPE( sample->type ) == CV_32FC1 );
-
-    if( (CV_MAT_ELEM( (*sample), float, 0,
-            ((CvStumpClassifier*) classifier)->compidx )) <
-        ((CvStumpClassifier*) classifier)->threshold )
-        return ((CvStumpClassifier*) classifier)->left;
-    return ((CvStumpClassifier*) classifier)->right;
-}
-
-#define ICV_DEF_FIND_STUMP_THRESHOLD( suffix, type, error )                              \
-static int icvFindStumpThreshold_##suffix(                                               \
-        uchar* data, size_t datastep,                                                    \
-        uchar* wdata, size_t wstep,                                                      \
-        uchar* ydata, size_t ystep,                                                      \
-        uchar* idxdata, size_t idxstep, int num,                                         \
-        float* lerror,                                                                   \
-        float* rerror,                                                                   \
-        float* threshold, float* left, float* right,                                     \
-        float* sumw, float* sumwy, float* sumwyy )                                       \
-{                                                                                        \
-    int found = 0;                                                                       \
-    float wyl  = 0.0F;                                                                   \
-    float wl   = 0.0F;                                                                   \
-    float wyyl = 0.0F;                                                                   \
-    float wyr  = 0.0F;                                                                   \
-    float wr   = 0.0F;                                                                   \
-                                                                                         \
-    float curleft  = 0.0F;                                                               \
-    float curright = 0.0F;                                                               \
-    float* prevval = NULL;                                                               \
-    float* curval  = NULL;                                                               \
-    float curlerror = 0.0F;                                                              \
-    float currerror = 0.0F;                                                              \
-                                                                                         \
-    int i = 0;                                                                           \
-    int idx = 0;                                                                         \
-                                                                                         \
-    if( *sumw == FLT_MAX )                                                               \
-    {                                                                                    \
-        /* calculate sums */                                                             \
-        float *y = NULL;                                                                 \
-        float *w = NULL;                                                                 \
-        float wy = 0.0F;                                                                 \
-                                                                                         \
-        *sumw   = 0.0F;                                                                  \
-        *sumwy  = 0.0F;                                                                  \
-        *sumwyy = 0.0F;                                                                  \
-        for( i = 0; i < num; i++ )                                                       \
-        {                                                                                \
-            idx = (int) ( *((type*) (idxdata + i*idxstep)) );                            \
-            w = (float*) (wdata + idx * wstep);                                          \
-            *sumw += *w;                                                                 \
-            y = (float*) (ydata + idx * ystep);                                          \
-            wy = (*w) * (*y);                                                            \
-            *sumwy += wy;                                                                \
-            *sumwyy += wy * (*y);                                                        \
-        }                                                                                \
-    }                                                                                    \
-                                                                                         \
-    for( i = 0; i < num; i++ )                                                           \
-    {                                                                                    \
-        idx = (int) ( *((type*) (idxdata + i*idxstep)) );                                \
-        curval = (float*) (data + idx * datastep);                                       \
-         /* for debug purpose */                                                         \
-        if( i > 0 ) assert( (*prevval) <= (*curval) );                                   \
-                                                                                         \
-        wyr  = *sumwy - wyl;                                                             \
-        wr   = *sumw  - wl;                                                              \
-                                                                                         \
-        if( wl > 0.0 ) curleft = wyl / wl;                                               \
-        else curleft = 0.0F;                                                             \
-                                                                                         \
-        if( wr > 0.0 ) curright = wyr / wr;                                              \
-        else curright = 0.0F;                                                            \
-                                                                                         \
-        error                                                                            \
-                                                                                         \
-        if( curlerror + currerror < (*lerror) + (*rerror) )                              \
-        {                                                                                \
-            (*lerror) = curlerror;                                                       \
-            (*rerror) = currerror;                                                       \
-            *threshold = *curval;                                                        \
-            if( i > 0 ) {                                                                \
-                *threshold = 0.5F * (*threshold + *prevval);                             \
-            }                                                                            \
-            *left  = curleft;                                                            \
-            *right = curright;                                                           \
-            found = 1;                                                                   \
-        }                                                                                \
-                                                                                         \
-        do                                                                               \
-        {                                                                                \
-            wl  += *((float*) (wdata + idx * wstep));                                    \
-            wyl += (*((float*) (wdata + idx * wstep)))                                   \
-                * (*((float*) (ydata + idx * ystep)));                                   \
-            wyyl += *((float*) (wdata + idx * wstep))                                    \
-                * (*((float*) (ydata + idx * ystep)))                                    \
-                * (*((float*) (ydata + idx * ystep)));                                   \
-        }                                                                                \
-        while( (++i) < num &&                                                            \
-            ( *((float*) (data + (idx =                                                  \
-                (int) ( *((type*) (idxdata + i*idxstep))) ) * datastep))                 \
-                == *curval ) );                                                          \
-        --i;                                                                             \
-        prevval = curval;                                                                \
-    } /* for each value */                                                               \
-                                                                                         \
-    return found;                                                                        \
-}
-
-/* misclassification error
- * err = MIN( wpos, wneg );
- */
-#define ICV_DEF_FIND_STUMP_THRESHOLD_MISC( suffix, type )                                \
-    ICV_DEF_FIND_STUMP_THRESHOLD( misc_##suffix, type,                                   \
-        float wposl = 0.5F * ( wl + wyl );                                               \
-        float wposr = 0.5F * ( wr + wyr );                                               \
-        curleft = 0.5F * ( 1.0F + curleft );                                             \
-        curright = 0.5F * ( 1.0F + curright );                                           \
-        curlerror = MIN( wposl, wl - wposl );                                            \
-        currerror = MIN( wposr, wr - wposr );                                            \
-    )
-
-/* gini error
- * err = 2 * wpos * wneg /(wpos + wneg)
- */
-#define ICV_DEF_FIND_STUMP_THRESHOLD_GINI( suffix, type )                                \
-    ICV_DEF_FIND_STUMP_THRESHOLD( gini_##suffix, type,                                   \
-        float wposl = 0.5F * ( wl + wyl );                                               \
-        float wposr = 0.5F * ( wr + wyr );                                               \
-        curleft = 0.5F * ( 1.0F + curleft );                                             \
-        curright = 0.5F * ( 1.0F + curright );                                           \
-        curlerror = 2.0F * wposl * ( 1.0F - curleft );                                   \
-        currerror = 2.0F * wposr * ( 1.0F - curright );                                  \
-    )
-
-#define CV_ENTROPY_THRESHOLD FLT_MIN
-
-/* entropy error
- * err = - wpos * log(wpos / (wpos + wneg)) - wneg * log(wneg / (wpos + wneg))
- */
-#define ICV_DEF_FIND_STUMP_THRESHOLD_ENTROPY( suffix, type )                             \
-    ICV_DEF_FIND_STUMP_THRESHOLD( entropy_##suffix, type,                                \
-        float wposl = 0.5F * ( wl + wyl );                                               \
-        float wposr = 0.5F * ( wr + wyr );                                               \
-        curleft = 0.5F * ( 1.0F + curleft );                                             \
-        curright = 0.5F * ( 1.0F + curright );                                           \
-        curlerror = currerror = 0.0F;                                                    \
-        if( curleft > CV_ENTROPY_THRESHOLD )                                             \
-            curlerror -= wposl * logf( curleft );                                        \
-        if( curleft < 1.0F - CV_ENTROPY_THRESHOLD )                                      \
-            curlerror -= (wl - wposl) * logf( 1.0F - curleft );                          \
-                                                                                         \
-        if( curright > CV_ENTROPY_THRESHOLD )                                            \
-            currerror -= wposr * logf( curright );                                       \
-        if( curright < 1.0F - CV_ENTROPY_THRESHOLD )                                     \
-            currerror -= (wr - wposr) * logf( 1.0F - curright );                         \
-    )
-
-/* least sum of squares error */
-#define ICV_DEF_FIND_STUMP_THRESHOLD_SQ( suffix, type )                                  \
-    ICV_DEF_FIND_STUMP_THRESHOLD( sq_##suffix, type,                                     \
-        /* calculate error (sum of squares)          */                                  \
-        /* err = sum( w * (y - left(rigt)Val)^2 )    */                                  \
-        curlerror = wyyl + curleft * curleft * wl - 2.0F * curleft * wyl;                \
-        currerror = (*sumwyy) - wyyl + curright * curright * wr - 2.0F * curright * wyr; \
-    )
-
-ICV_DEF_FIND_STUMP_THRESHOLD_MISC( 16s, short )
-
-ICV_DEF_FIND_STUMP_THRESHOLD_MISC( 32s, int )
-
-ICV_DEF_FIND_STUMP_THRESHOLD_MISC( 32f, float )
-
-
-ICV_DEF_FIND_STUMP_THRESHOLD_GINI( 16s, short )
-
-ICV_DEF_FIND_STUMP_THRESHOLD_GINI( 32s, int )
-
-ICV_DEF_FIND_STUMP_THRESHOLD_GINI( 32f, float )
-
-
-ICV_DEF_FIND_STUMP_THRESHOLD_ENTROPY( 16s, short )
-
-ICV_DEF_FIND_STUMP_THRESHOLD_ENTROPY( 32s, int )
-
-ICV_DEF_FIND_STUMP_THRESHOLD_ENTROPY( 32f, float )
-
-
-ICV_DEF_FIND_STUMP_THRESHOLD_SQ( 16s, short )
-
-ICV_DEF_FIND_STUMP_THRESHOLD_SQ( 32s, int )
-
-ICV_DEF_FIND_STUMP_THRESHOLD_SQ( 32f, float )
-
-typedef int (*CvFindThresholdFunc)( uchar* data, size_t datastep,
-                                    uchar* wdata, size_t wstep,
-                                    uchar* ydata, size_t ystep,
-                                    uchar* idxdata, size_t idxstep, int num,
-                                    float* lerror,
-                                    float* rerror,
-                                    float* threshold, float* left, float* right,
-                                    float* sumw, float* sumwy, float* sumwyy );
-
-CvFindThresholdFunc findStumpThreshold_16s[4] = {
-        icvFindStumpThreshold_misc_16s,
-        icvFindStumpThreshold_gini_16s,
-        icvFindStumpThreshold_entropy_16s,
-        icvFindStumpThreshold_sq_16s
-    };
-
-CvFindThresholdFunc findStumpThreshold_32s[4] = {
-        icvFindStumpThreshold_misc_32s,
-        icvFindStumpThreshold_gini_32s,
-        icvFindStumpThreshold_entropy_32s,
-        icvFindStumpThreshold_sq_32s
-    };
-
-CvFindThresholdFunc findStumpThreshold_32f[4] = {
-        icvFindStumpThreshold_misc_32f,
-        icvFindStumpThreshold_gini_32f,
-        icvFindStumpThreshold_entropy_32f,
-        icvFindStumpThreshold_sq_32f
-    };
-
-CV_BOOST_IMPL
-CvClassifier* cvCreateStumpClassifier( CvMat* trainData,
-                      int flags,
-                      CvMat* trainClasses,
-                      CvMat* /*typeMask*/,
-                      CvMat* missedMeasurementsMask,
-                      CvMat* compIdx,
-                      CvMat* sampleIdx,
-                      CvMat* weights,
-                      CvClassifierTrainParams* trainParams
-                    )
-{
-    CvStumpClassifier* stump = NULL;
-    int m = 0; /* number of samples */
-    int n = 0; /* number of components */
-    uchar* data = NULL;
-    int cstep   = 0;
-    int sstep   = 0;
-    uchar* ydata = NULL;
-    int ystep    = 0;
-    uchar* idxdata = NULL;
-    int idxstep    = 0;
-    int l = 0; /* number of indices */
-    uchar* wdata = NULL;
-    int wstep    = 0;
-
-    int* idx = NULL;
-    int i = 0;
-
-    float sumw   = FLT_MAX;
-    float sumwy  = FLT_MAX;
-    float sumwyy = FLT_MAX;
-
-    CV_Assert( trainData != NULL );
-    CV_Assert( CV_MAT_TYPE( trainData->type ) == CV_32FC1 );
-    CV_Assert( trainClasses != NULL );
-    CV_Assert( CV_MAT_TYPE( trainClasses->type ) == CV_32FC1 );
-    CV_Assert( missedMeasurementsMask == NULL );
-    CV_Assert( compIdx == NULL );
-    CV_Assert( weights != NULL );
-    CV_Assert( CV_MAT_TYPE( weights->type ) == CV_32FC1 );
-    CV_Assert( trainParams != NULL );
-
-    data = trainData->data.ptr;
-    if( CV_IS_ROW_SAMPLE( flags ) )
-    {
-        cstep = CV_ELEM_SIZE( trainData->type );
-        sstep = trainData->step;
-        m = trainData->rows;
-        n = trainData->cols;
-    }
-    else
-    {
-        sstep = CV_ELEM_SIZE( trainData->type );
-        cstep = trainData->step;
-        m = trainData->cols;
-        n = trainData->rows;
-    }
-
-    ydata = trainClasses->data.ptr;
-    if( trainClasses->rows == 1 )
-    {
-        assert( trainClasses->cols == m );
-        ystep = CV_ELEM_SIZE( trainClasses->type );
-    }
-    else
-    {
-        assert( trainClasses->rows == m );
-        ystep = trainClasses->step;
-    }
-
-    wdata = weights->data.ptr;
-    if( weights->rows == 1 )
-    {
-        assert( weights->cols == m );
-        wstep = CV_ELEM_SIZE( weights->type );
-    }
-    else
-    {
-        assert( weights->rows == m );
-        wstep = weights->step;
-    }
-
-    l = m;
-    if( sampleIdx != NULL )
-    {
-        assert( CV_MAT_TYPE( sampleIdx->type ) == CV_32FC1 );
-
-        idxdata = sampleIdx->data.ptr;
-        if( sampleIdx->rows == 1 )
-        {
-            l = sampleIdx->cols;
-            idxstep = CV_ELEM_SIZE( sampleIdx->type );
-        }
-        else
-        {
-            l = sampleIdx->rows;
-            idxstep = sampleIdx->step;
-        }
-        assert( l <= m );
-    }
-
-    idx = (int*) cvAlloc( l * sizeof( int ) );
-    stump = (CvStumpClassifier*) cvAlloc( sizeof( CvStumpClassifier) );
-
-    /* START */
-    memset( (void*) stump, 0, sizeof( CvStumpClassifier ) );
-
-    stump->eval = cvEvalStumpClassifier;
-    stump->tune = NULL;
-    stump->save = NULL;
-    stump->release = cvReleaseStumpClassifier;
-
-    stump->lerror = FLT_MAX;
-    stump->rerror = FLT_MAX;
-    stump->left  = 0.0F;
-    stump->right = 0.0F;
-
-    /* copy indices */
-    if( sampleIdx != NULL )
-    {
-        for( i = 0; i < l; i++ )
-        {
-            idx[i] = (int) *((float*) (idxdata + i*idxstep));
-        }
-    }
-    else
-    {
-        for( i = 0; i < l; i++ )
-        {
-            idx[i] = i;
-        }
-    }
-
-    for( i = 0; i < n; i++ )
-    {
-        CvValArray va;
-
-        va.data = data + i * ((size_t) cstep);
-        va.step = sstep;
-        std::sort(idx, idx + l, LessThanValArray<CvValArray, int>(&va));
-        if( findStumpThreshold_32s[(int) ((CvStumpTrainParams*) trainParams)->error]
-              ( data + i * ((size_t) cstep), sstep,
-                wdata, wstep, ydata, ystep, (uchar*) idx, sizeof( int ), l,
-                &(stump->lerror), &(stump->rerror),
-                &(stump->threshold), &(stump->left), &(stump->right),
-                &sumw, &sumwy, &sumwyy ) )
-        {
-            stump->compidx = i;
-        }
-    } /* for each component */
-
-    /* END */
-
-    cvFree( &idx );
-
-    if( ((CvStumpTrainParams*) trainParams)->type == CV_CLASSIFICATION_CLASS )
-    {
-        stump->left = 2.0F * (stump->left >= 0.5F) - 1.0F;
-        stump->right = 2.0F * (stump->right >= 0.5F) - 1.0F;
-    }
-
-    return (CvClassifier*) stump;
-}
-
-/*
- * cvCreateMTStumpClassifier
- *
- * Multithreaded stump classifier constructor
- * Includes huge train data support through callback function
- */
-CV_BOOST_IMPL
-CvClassifier* cvCreateMTStumpClassifier( CvMat* trainData,
-                      int flags,
-                      CvMat* trainClasses,
-                      CvMat* /*typeMask*/,
-                      CvMat* missedMeasurementsMask,
-                      CvMat* compIdx,
-                      CvMat* sampleIdx,
-                      CvMat* weights,
-                      CvClassifierTrainParams* trainParams )
-{
-    CvStumpClassifier* stump = NULL;
-    int m = 0; /* number of samples */
-    int n = 0; /* number of components */
-    uchar* data = NULL;
-    size_t cstep   = 0;
-    size_t sstep   = 0;
-    int    datan   = 0; /* num components */
-    uchar* ydata = NULL;
-    size_t ystep = 0;
-    uchar* idxdata = NULL;
-    size_t idxstep = 0;
-    int    l = 0; /* number of indices */
-    uchar* wdata = NULL;
-    size_t wstep = 0;
-
-    uchar* sorteddata = NULL;
-    int    sortedtype    = 0;
-    size_t sortedcstep   = 0; /* component step */
-    size_t sortedsstep   = 0; /* sample step */
-    int    sortedn       = 0; /* num components */
-    int    sortedm       = 0; /* num samples */
-
-    char* filter = NULL;
-    int i = 0;
-
-    int compidx = 0;
-    int stumperror;
-    int portion;
-
-    /* private variables */
-    CvMat mat;
-    CvValArray va;
-    float lerror;
-    float rerror;
-    float left;
-    float right;
-    float threshold;
-    int optcompidx;
-
-    float sumw;
-    float sumwy;
-    float sumwyy;
-
-    int t_compidx;
-    int t_n;
-
-    int ti;
-    int tj;
-    int tk;
-
-    uchar* t_data;
-    size_t t_cstep;
-    size_t t_sstep;
-
-    size_t matcstep;
-    size_t matsstep;
-
-    int* t_idx;
-    /* end private variables */
-
-    CV_Assert( trainParams != NULL );
-    CV_Assert( trainClasses != NULL );
-    CV_Assert( CV_MAT_TYPE( trainClasses->type ) == CV_32FC1 );
-    CV_Assert( missedMeasurementsMask == NULL );
-    CV_Assert( compIdx == NULL );
-
-    stumperror = (int) ((CvMTStumpTrainParams*) trainParams)->error;
-
-    ydata = trainClasses->data.ptr;
-    if( trainClasses->rows == 1 )
-    {
-        m = trainClasses->cols;
-        ystep = CV_ELEM_SIZE( trainClasses->type );
-    }
-    else
-    {
-        m = trainClasses->rows;
-        ystep = trainClasses->step;
-    }
-
-    wdata = weights->data.ptr;
-    if( weights->rows == 1 )
-    {
-        CV_Assert( weights->cols == m );
-        wstep = CV_ELEM_SIZE( weights->type );
-    }
-    else
-    {
-        CV_Assert( weights->rows == m );
-        wstep = weights->step;
-    }
-
-    if( ((CvMTStumpTrainParams*) trainParams)->sortedIdx != NULL )
-    {
-        sortedtype =
-            CV_MAT_TYPE( ((CvMTStumpTrainParams*) trainParams)->sortedIdx->type );
-        assert( sortedtype == CV_16SC1 || sortedtype == CV_32SC1
-                || sortedtype == CV_32FC1 );
-        sorteddata = ((CvMTStumpTrainParams*) trainParams)->sortedIdx->data.ptr;
-        sortedsstep = CV_ELEM_SIZE( sortedtype );
-        sortedcstep = ((CvMTStumpTrainParams*) trainParams)->sortedIdx->step;
-        sortedn = ((CvMTStumpTrainParams*) trainParams)->sortedIdx->rows;
-        sortedm = ((CvMTStumpTrainParams*) trainParams)->sortedIdx->cols;
-    }
-
-    if( trainData == NULL )
-    {
-        assert( ((CvMTStumpTrainParams*) trainParams)->getTrainData != NULL );
-        n = ((CvMTStumpTrainParams*) trainParams)->numcomp;
-        assert( n > 0 );
-    }
-    else
-    {
-        assert( CV_MAT_TYPE( trainData->type ) == CV_32FC1 );
-        data = trainData->data.ptr;
-        if( CV_IS_ROW_SAMPLE( flags ) )
-        {
-            cstep = CV_ELEM_SIZE( trainData->type );
-            sstep = trainData->step;
-            assert( m == trainData->rows );
-            datan = n = trainData->cols;
-        }
-        else
-        {
-            sstep = CV_ELEM_SIZE( trainData->type );
-            cstep = trainData->step;
-            assert( m == trainData->cols );
-            datan = n = trainData->rows;
-        }
-        if( ((CvMTStumpTrainParams*) trainParams)->getTrainData != NULL )
-        {
-            n = ((CvMTStumpTrainParams*) trainParams)->numcomp;
-        }
-    }
-    assert( datan <= n );
-
-    if( sampleIdx != NULL )
-    {
-        assert( CV_MAT_TYPE( sampleIdx->type ) == CV_32FC1 );
-        idxdata = sampleIdx->data.ptr;
-        idxstep = ( sampleIdx->rows == 1 )
-            ? CV_ELEM_SIZE( sampleIdx->type ) : sampleIdx->step;
-        l = ( sampleIdx->rows == 1 ) ? sampleIdx->cols : sampleIdx->rows;
-
-        if( sorteddata != NULL )
-        {
-            filter = (char*) cvAlloc( sizeof( char ) * m );
-            memset( (void*) filter, 0, sizeof( char ) * m );
-            for( i = 0; i < l; i++ )
-            {
-                filter[(int) *((float*) (idxdata + i * idxstep))] = (char) 1;
-            }
-        }
-    }
-    else
-    {
-        l = m;
-    }
-
-    stump = (CvStumpClassifier*) cvAlloc( sizeof( CvStumpClassifier) );
-
-    /* START */
-    memset( (void*) stump, 0, sizeof( CvStumpClassifier ) );
-
-    portion = ((CvMTStumpTrainParams*)trainParams)->portion;
-
-    if( portion < 1 )
-    {
-        /* auto portion */
-        portion = n;
-        #ifdef _OPENMP
-        portion /= omp_get_max_threads();
-        #endif /* _OPENMP */
-    }
-
-    stump->eval = cvEvalStumpClassifier;
-    stump->tune = NULL;
-    stump->save = NULL;
-    stump->release = cvReleaseStumpClassifier;
-
-    stump->lerror = FLT_MAX;
-    stump->rerror = FLT_MAX;
-    stump->left  = 0.0F;
-    stump->right = 0.0F;
-
-    compidx = 0;
-    #ifdef _OPENMP
-    #pragma omp parallel private(mat, va, lerror, rerror, left, right, threshold, \
-                                 optcompidx, sumw, sumwy, sumwyy, t_compidx, t_n, \
-                                 ti, tj, tk, t_data, t_cstep, t_sstep, matcstep,  \
-                                 matsstep, t_idx)
-    #endif /* _OPENMP */
-    {
-        lerror = FLT_MAX;
-        rerror = FLT_MAX;
-        left  = 0.0F;
-        right = 0.0F;
-        threshold = 0.0F;
-        optcompidx = 0;
-
-        sumw   = FLT_MAX;
-        sumwy  = FLT_MAX;
-        sumwyy = FLT_MAX;
-
-        t_compidx = 0;
-        t_n = 0;
-
-        ti = 0;
-        tj = 0;
-        tk = 0;
-
-        t_data = NULL;
-        t_cstep = 0;
-        t_sstep = 0;
-
-        matcstep = 0;
-        matsstep = 0;
-
-        t_idx = NULL;
-
-        mat.data.ptr = NULL;
-
-        if( datan < n )
-        {
-            /* prepare matrix for callback */
-            if( CV_IS_ROW_SAMPLE( flags ) )
-            {
-                mat = cvMat( m, portion, CV_32FC1, 0 );
-                matcstep = CV_ELEM_SIZE( mat.type );
-                matsstep = mat.step;
-            }
-            else
-            {
-                mat = cvMat( portion, m, CV_32FC1, 0 );
-                matcstep = mat.step;
-                matsstep = CV_ELEM_SIZE( mat.type );
-            }
-            mat.data.ptr = (uchar*) cvAlloc( sizeof( float ) * mat.rows * mat.cols );
-        }
-
-        if( filter != NULL || sortedn < n )
-        {
-            t_idx = (int*) cvAlloc( sizeof( int ) * m );
-            if( sortedn == 0 || filter == NULL )
-            {
-                if( idxdata != NULL )
-                {
-                    for( ti = 0; ti < l; ti++ )
-                    {
-                        t_idx[ti] = (int) *((float*) (idxdata + ti * idxstep));
-                    }
-                }
-                else
-                {
-                    for( ti = 0; ti < l; ti++ )
-                    {
-                        t_idx[ti] = ti;
-                    }
-                }
-            }
-        }
-
-        #ifdef _OPENMP
-        #pragma omp critical(c_compidx)
-        #endif /* _OPENMP */
-        {
-            t_compidx = compidx;
-            compidx += portion;
-        }
-        while( t_compidx < n )
-        {
-            t_n = portion;
-            if( t_compidx < datan )
-            {
-                t_n = ( t_n < (datan - t_compidx) ) ? t_n : (datan - t_compidx);
-                t_data = data;
-                t_cstep = cstep;
-                t_sstep = sstep;
-            }
-            else
-            {
-                t_n = ( t_n < (n - t_compidx) ) ? t_n : (n - t_compidx);
-                t_cstep = matcstep;
-                t_sstep = matsstep;
-                t_data = mat.data.ptr - t_compidx * ((size_t) t_cstep );
-
-                /* calculate components */
-                ((CvMTStumpTrainParams*)trainParams)->getTrainData( &mat,
-                        sampleIdx, compIdx, t_compidx, t_n,
-                        ((CvMTStumpTrainParams*)trainParams)->userdata );
-            }
-
-            if( sorteddata != NULL )
-            {
-                if( filter != NULL )
-                {
-                    /* have sorted indices and filter */
-                    switch( sortedtype )
-                    {
-                        case CV_16SC1:
-                            for( ti = t_compidx; ti < MIN( sortedn, t_compidx + t_n ); ti++ )
-                            {
-                                tk = 0;
-                                for( tj = 0; tj < sortedm; tj++ )
-                                {
-                                    int curidx = (int) ( *((short*) (sorteddata
-                                            + ti * sortedcstep + tj * sortedsstep)) );
-                                    if( filter[curidx] != 0 )
-                                    {
-                                        t_idx[tk++] = curidx;
-                                    }
-                                }
-                                if( findStumpThreshold_32s[stumperror](
-                                        t_data + ti * t_cstep, t_sstep,
-                                        wdata, wstep, ydata, ystep,
-                                        (uchar*) t_idx, sizeof( int ), tk,
-                                        &lerror, &rerror,
-                                        &threshold, &left, &right,
-                                        &sumw, &sumwy, &sumwyy ) )
-                                {
-                                    optcompidx = ti;
-                                }
-                            }
-                            break;
-                        case CV_32SC1:
-                            for( ti = t_compidx; ti < MIN( sortedn, t_compidx + t_n ); ti++ )
-                            {
-                                tk = 0;
-                                for( tj = 0; tj < sortedm; tj++ )
-                                {
-                                    int curidx = (int) ( *((int*) (sorteddata
-                                            + ti * sortedcstep + tj * sortedsstep)) );
-                                    if( filter[curidx] != 0 )
-                                    {
-                                        t_idx[tk++] = curidx;
-                                    }
-                                }
-                                if( findStumpThreshold_32s[stumperror](
-                                        t_data + ti * t_cstep, t_sstep,
-                                        wdata, wstep, ydata, ystep,
-                                        (uchar*) t_idx, sizeof( int ), tk,
-                                        &lerror, &rerror,
-                                        &threshold, &left, &right,
-                                        &sumw, &sumwy, &sumwyy ) )
-                                {
-                                    optcompidx = ti;
-                                }
-                            }
-                            break;
-                        case CV_32FC1:
-                            for( ti = t_compidx; ti < MIN( sortedn, t_compidx + t_n ); ti++ )
-                            {
-                                tk = 0;
-                                for( tj = 0; tj < sortedm; tj++ )
-                                {
-                                    int curidx = (int) ( *((float*) (sorteddata
-                                            + ti * sortedcstep + tj * sortedsstep)) );
-                                    if( filter[curidx] != 0 )
-                                    {
-                                        t_idx[tk++] = curidx;
-                                    }
-                                }
-                                if( findStumpThreshold_32s[stumperror](
-                                        t_data + ti * t_cstep, t_sstep,
-                                        wdata, wstep, ydata, ystep,
-                                        (uchar*) t_idx, sizeof( int ), tk,
-                                        &lerror, &rerror,
-                                        &threshold, &left, &right,
-                                        &sumw, &sumwy, &sumwyy ) )
-                                {
-                                    optcompidx = ti;
-                                }
-                            }
-                            break;
-                        default:
-                            assert( 0 );
-                            break;
-                    }
-                }
-                else
-                {
-                    /* have sorted indices */
-                    switch( sortedtype )
-                    {
-                        case CV_16SC1:
-                            for( ti = t_compidx; ti < MIN( sortedn, t_compidx + t_n ); ti++ )
-                            {
-                                if( findStumpThreshold_16s[stumperror](
-                                        t_data + ti * t_cstep, t_sstep,
-                                        wdata, wstep, ydata, ystep,
-                                        sorteddata + ti * sortedcstep, sortedsstep, sortedm,
-                                        &lerror, &rerror,
-                                        &threshold, &left, &right,
-                                        &sumw, &sumwy, &sumwyy ) )
-                                {
-                                    optcompidx = ti;
-                                }
-                            }
-                            break;
-                        case CV_32SC1:
-                            for( ti = t_compidx; ti < MIN( sortedn, t_compidx + t_n ); ti++ )
-                            {
-                                if( findStumpThreshold_32s[stumperror](
-                                        t_data + ti * t_cstep, t_sstep,
-                                        wdata, wstep, ydata, ystep,
-                                        sorteddata + ti * sortedcstep, sortedsstep, sortedm,
-                                        &lerror, &rerror,
-                                        &threshold, &left, &right,
-                                        &sumw, &sumwy, &sumwyy ) )
-                                {
-                                    optcompidx = ti;
-                                }
-                            }
-                            break;
-                        case CV_32FC1:
-                            for( ti = t_compidx; ti < MIN( sortedn, t_compidx + t_n ); ti++ )
-                            {
-                                if( findStumpThreshold_32f[stumperror](
-                                        t_data + ti * t_cstep, t_sstep,
-                                        wdata, wstep, ydata, ystep,
-                                        sorteddata + ti * sortedcstep, sortedsstep, sortedm,
-                                        &lerror, &rerror,
-                                        &threshold, &left, &right,
-                                        &sumw, &sumwy, &sumwyy ) )
-                                {
-                                    optcompidx = ti;
-                                }
-                            }
-                            break;
-                        default:
-                            assert( 0 );
-                            break;
-                    }
-                }
-            }
-
-            ti = MAX( t_compidx, MIN( sortedn, t_compidx + t_n ) );
-            for( ; ti < t_compidx + t_n; ti++ )
-            {
-                va.data = t_data + ti * t_cstep;
-                va.step = t_sstep;
-                std::sort(t_idx, t_idx + l, LessThanValArray<CvValArray, int>(&va));
-                if( findStumpThreshold_32s[stumperror](
-                        t_data + ti * t_cstep, t_sstep,
-                        wdata, wstep, ydata, ystep,
-                        (uchar*)t_idx, sizeof( int ), l,
-                        &lerror, &rerror,
-                        &threshold, &left, &right,
-                        &sumw, &sumwy, &sumwyy ) )
-                {
-                    optcompidx = ti;
-                }
-            }
-            #ifdef _OPENMP
-            #pragma omp critical(c_compidx)
-            #endif /* _OPENMP */
-            {
-                t_compidx = compidx;
-                compidx += portion;
-            }
-        } /* while have training data */
-
-        /* get the best classifier */
-        #ifdef _OPENMP
-        #pragma omp critical(c_beststump)
-        #endif /* _OPENMP */
-        {
-            if( lerror + rerror < stump->lerror + stump->rerror )
-            {
-                stump->lerror    = lerror;
-                stump->rerror    = rerror;
-                stump->compidx   = optcompidx;
-                stump->threshold = threshold;
-                stump->left      = left;
-                stump->right     = right;
-            }
-        }
-
-        /* free allocated memory */
-        if( mat.data.ptr != NULL )
-        {
-            cvFree( &(mat.data.ptr) );
-        }
-        if( t_idx != NULL )
-        {
-            cvFree( &t_idx );
-        }
-    } /* end of parallel region */
-
-    /* END */
-
-    /* free allocated memory */
-    if( filter != NULL )
-    {
-        cvFree( &filter );
-    }
-
-    if( ((CvMTStumpTrainParams*) trainParams)->type == CV_CLASSIFICATION_CLASS )
-    {
-        stump->left = 2.0F * (stump->left >= 0.5F) - 1.0F;
-        stump->right = 2.0F * (stump->right >= 0.5F) - 1.0F;
-    }
-
-    return (CvClassifier*) stump;
-}
-
-CV_BOOST_IMPL
-float cvEvalCARTClassifier( CvClassifier* classifier, CvMat* sample )
-{
-    CV_FUNCNAME( "cvEvalCARTClassifier" );
-
-    int idx = 0;
-
-    __BEGIN__;
-
-
-    CV_ASSERT( classifier != NULL );
-    CV_ASSERT( sample != NULL );
-    CV_ASSERT( CV_MAT_TYPE( sample->type ) == CV_32FC1 );
-    CV_ASSERT( sample->rows == 1 || sample->cols == 1 );
-
-    if( sample->rows == 1 )
-    {
-        do
-        {
-            if( (CV_MAT_ELEM( (*sample), float, 0,
-                    ((CvCARTClassifier*) classifier)->compidx[idx] )) <
-                ((CvCARTClassifier*) classifier)->threshold[idx] )
-            {
-                idx = ((CvCARTClassifier*) classifier)->left[idx];
-            }
-            else
-            {
-                idx = ((CvCARTClassifier*) classifier)->right[idx];
-            }
-        } while( idx > 0 );
-    }
-    else
-    {
-        do
-        {
-            if( (CV_MAT_ELEM( (*sample), float,
-                    ((CvCARTClassifier*) classifier)->compidx[idx], 0 )) <
-                ((CvCARTClassifier*) classifier)->threshold[idx] )
-            {
-                idx = ((CvCARTClassifier*) classifier)->left[idx];
-            }
-            else
-            {
-                idx = ((CvCARTClassifier*) classifier)->right[idx];
-            }
-        } while( idx > 0 );
-    }
-
-    __END__;
-
-    return ((CvCARTClassifier*) classifier)->val[-idx];
-}
-
-static
-float cvEvalCARTClassifierIdx( CvClassifier* classifier, CvMat* sample )
-{
-    CV_FUNCNAME( "cvEvalCARTClassifierIdx" );
-
-    int idx = 0;
-
-    __BEGIN__;
-
-
-    CV_ASSERT( classifier != NULL );
-    CV_ASSERT( sample != NULL );
-    CV_ASSERT( CV_MAT_TYPE( sample->type ) == CV_32FC1 );
-    CV_ASSERT( sample->rows == 1 || sample->cols == 1 );
-
-    if( sample->rows == 1 )
-    {
-        do
-        {
-            if( (CV_MAT_ELEM( (*sample), float, 0,
-                    ((CvCARTClassifier*) classifier)->compidx[idx] )) <
-                ((CvCARTClassifier*) classifier)->threshold[idx] )
-            {
-                idx = ((CvCARTClassifier*) classifier)->left[idx];
-            }
-            else
-            {
-                idx = ((CvCARTClassifier*) classifier)->right[idx];
-            }
-        } while( idx > 0 );
-    }
-    else
-    {
-        do
-        {
-            if( (CV_MAT_ELEM( (*sample), float,
-                    ((CvCARTClassifier*) classifier)->compidx[idx], 0 )) <
-                ((CvCARTClassifier*) classifier)->threshold[idx] )
-            {
-                idx = ((CvCARTClassifier*) classifier)->left[idx];
-            }
-            else
-            {
-                idx = ((CvCARTClassifier*) classifier)->right[idx];
-            }
-        } while( idx > 0 );
-    }
-
-    __END__;
-
-    return (float) (-idx);
-}
-
-CV_BOOST_IMPL
-void cvReleaseCARTClassifier( CvClassifier** classifier )
-{
-    cvFree( classifier );
-    *classifier = NULL;
-}
-
-static void CV_CDECL icvDefaultSplitIdx_R( int compidx, float threshold,
-                                    CvMat* idx, CvMat** left, CvMat** right,
-                                    void* userdata )
-{
-    CvMat* trainData = (CvMat*) userdata;
-    int i = 0;
-
-    *left = cvCreateMat( 1, trainData->rows, CV_32FC1 );
-    *right = cvCreateMat( 1, trainData->rows, CV_32FC1 );
-    (*left)->cols = (*right)->cols = 0;
-    if( idx == NULL )
-    {
-        for( i = 0; i < trainData->rows; i++ )
-        {
-            if( CV_MAT_ELEM( *trainData, float, i, compidx ) < threshold )
-            {
-                (*left)->data.fl[(*left)->cols++] = (float) i;
-            }
-            else
-            {
-                (*right)->data.fl[(*right)->cols++] = (float) i;
-            }
-        }
-    }
-    else
-    {
-        uchar* idxdata;
-        int idxnum;
-        int idxstep;
-        int index;
-
-        idxdata = idx->data.ptr;
-        idxnum = (idx->rows == 1) ? idx->cols : idx->rows;
-        idxstep = (idx->rows == 1) ? CV_ELEM_SIZE( idx->type ) : idx->step;
-        for( i = 0; i < idxnum; i++ )
-        {
-            index = (int) *((float*) (idxdata + i * idxstep));
-            if( CV_MAT_ELEM( *trainData, float, index, compidx ) < threshold )
-            {
-                (*left)->data.fl[(*left)->cols++] = (float) index;
-            }
-            else
-            {
-                (*right)->data.fl[(*right)->cols++] = (float) index;
-            }
-        }
-    }
-}
-
-static void CV_CDECL icvDefaultSplitIdx_C( int compidx, float threshold,
-                                    CvMat* idx, CvMat** left, CvMat** right,
-                                    void* userdata )
-{
-    CvMat* trainData = (CvMat*) userdata;
-    int i = 0;
-
-    *left = cvCreateMat( 1, trainData->cols, CV_32FC1 );
-    *right = cvCreateMat( 1, trainData->cols, CV_32FC1 );
-    (*left)->cols = (*right)->cols = 0;
-    if( idx == NULL )
-    {
-        for( i = 0; i < trainData->cols; i++ )
-        {
-            if( CV_MAT_ELEM( *trainData, float, compidx, i ) < threshold )
-            {
-                (*left)->data.fl[(*left)->cols++] = (float) i;
-            }
-            else
-            {
-                (*right)->data.fl[(*right)->cols++] = (float) i;
-            }
-        }
-    }
-    else
-    {
-        uchar* idxdata;
-        int idxnum;
-        int idxstep;
-        int index;
-
-        idxdata = idx->data.ptr;
-        idxnum = (idx->rows == 1) ? idx->cols : idx->rows;
-        idxstep = (idx->rows == 1) ? CV_ELEM_SIZE( idx->type ) : idx->step;
-        for( i = 0; i < idxnum; i++ )
-        {
-            index = (int) *((float*) (idxdata + i * idxstep));
-            if( CV_MAT_ELEM( *trainData, float, compidx, index ) < threshold )
-            {
-                (*left)->data.fl[(*left)->cols++] = (float) index;
-            }
-            else
-            {
-                (*right)->data.fl[(*right)->cols++] = (float) index;
-            }
-        }
-    }
-}
-
-/* internal structure used in CART creation */
-typedef struct CvCARTNode
-{
-    CvMat* sampleIdx;
-    CvStumpClassifier* stump;
-    int parent;
-    int leftflag;
-    float errdrop;
-} CvCARTNode;
-
-CV_BOOST_IMPL
-CvClassifier* cvCreateCARTClassifier( CvMat* trainData,
-                     int flags,
-                     CvMat* trainClasses,
-                     CvMat* typeMask,
-                     CvMat* missedMeasurementsMask,
-                     CvMat* compIdx,
-                     CvMat* sampleIdx,
-                     CvMat* weights,
-                     CvClassifierTrainParams* trainParams )
-{
-    CvCARTClassifier* cart = NULL;
-    size_t datasize = 0;
-    int count = 0;
-    int i = 0;
-    int j = 0;
-
-    CvCARTNode* intnode = NULL;
-    CvCARTNode* list = NULL;
-    int listcount = 0;
-    CvMat* lidx = NULL;
-    CvMat* ridx = NULL;
-
-    float maxerrdrop = 0.0F;
-    int idx = 0;
-
-    void (*splitIdxCallback)( int compidx, float threshold,
-                              CvMat* idx, CvMat** left, CvMat** right,
-                              void* userdata );
-    void* userdata;
-
-    count = ((CvCARTTrainParams*) trainParams)->count;
-
-    assert( count > 0 );
-
-    datasize = sizeof( *cart ) + (sizeof( float ) + 3 * sizeof( int )) * count +
-        sizeof( float ) * (count + 1);
-
-    cart = (CvCARTClassifier*) cvAlloc( datasize );
-    memset( cart, 0, datasize );
-
-    cart->count = count;
-
-    cart->eval = cvEvalCARTClassifier;
-    cart->save = NULL;
-    cart->release = cvReleaseCARTClassifier;
-
-    cart->compidx = (int*) (cart + 1);
-    cart->threshold = (float*) (cart->compidx + count);
-    cart->left  = (int*) (cart->threshold + count);
-    cart->right = (int*) (cart->left + count);
-    cart->val = (float*) (cart->right + count);
-
-    datasize = sizeof( CvCARTNode ) * (count + count);
-    intnode = (CvCARTNode*) cvAlloc( datasize );
-    memset( intnode, 0, datasize );
-    list = (CvCARTNode*) (intnode + count);
-
-    splitIdxCallback = ((CvCARTTrainParams*) trainParams)->splitIdx;
-    userdata = ((CvCARTTrainParams*) trainParams)->userdata;
-    if( splitIdxCallback == NULL )
-    {
-        splitIdxCallback = ( CV_IS_ROW_SAMPLE( flags ) )
-            ? icvDefaultSplitIdx_R : icvDefaultSplitIdx_C;
-        userdata = trainData;
-    }
-
-    /* create root of the tree */
-    intnode[0].sampleIdx = sampleIdx;
-    intnode[0].stump = (CvStumpClassifier*)
-        ((CvCARTTrainParams*) trainParams)->stumpConstructor( trainData, flags,
-            trainClasses, typeMask, missedMeasurementsMask, compIdx, sampleIdx, weights,
-            ((CvCARTTrainParams*) trainParams)->stumpTrainParams );
-    cart->left[0] = cart->right[0] = 0;
-
-    /* build tree */
-    listcount = 0;
-    for( i = 1; i < count; i++ )
-    {
-        /* split last added node */
-        splitIdxCallback( intnode[i-1].stump->compidx, intnode[i-1].stump->threshold,
-            intnode[i-1].sampleIdx, &lidx, &ridx, userdata );
-
-        if( intnode[i-1].stump->lerror != 0.0F )
-        {
-            list[listcount].sampleIdx = lidx;
-            list[listcount].stump = (CvStumpClassifier*)
-                ((CvCARTTrainParams*) trainParams)->stumpConstructor( trainData, flags,
-                    trainClasses, typeMask, missedMeasurementsMask, compIdx,
-                    list[listcount].sampleIdx,
-                    weights, ((CvCARTTrainParams*) trainParams)->stumpTrainParams );
-            list[listcount].errdrop = intnode[i-1].stump->lerror
-                - (list[listcount].stump->lerror + list[listcount].stump->rerror);
-            list[listcount].leftflag = 1;
-            list[listcount].parent = i-1;
-            listcount++;
-        }
-        else
-        {
-            cvReleaseMat( &lidx );
-        }
-        if( intnode[i-1].stump->rerror != 0.0F )
-        {
-            list[listcount].sampleIdx = ridx;
-            list[listcount].stump = (CvStumpClassifier*)
-                ((CvCARTTrainParams*) trainParams)->stumpConstructor( trainData, flags,
-                    trainClasses, typeMask, missedMeasurementsMask, compIdx,
-                    list[listcount].sampleIdx,
-                    weights, ((CvCARTTrainParams*) trainParams)->stumpTrainParams );
-            list[listcount].errdrop = intnode[i-1].stump->rerror
-                - (list[listcount].stump->lerror + list[listcount].stump->rerror);
-            list[listcount].leftflag = 0;
-            list[listcount].parent = i-1;
-            listcount++;
-        }
-        else
-        {
-            cvReleaseMat( &ridx );
-        }
-
-        if( listcount == 0 ) break;
-
-        /* find the best node to be added to the tree */
-        idx = 0;
-        maxerrdrop = list[idx].errdrop;
-        for( j = 1; j < listcount; j++ )
-        {
-            if( list[j].errdrop > maxerrdrop )
-            {
-                idx = j;
-                maxerrdrop = list[j].errdrop;
-            }
-        }
-        intnode[i] = list[idx];
-        if( list[idx].leftflag )
-        {
-            cart->left[list[idx].parent] = i;
-        }
-        else
-        {
-            cart->right[list[idx].parent] = i;
-        }
-        if( idx != (listcount - 1) )
-        {
-            list[idx] = list[listcount - 1];
-        }
-        listcount--;
-    }
-
-    /* fill <cart> fields */
-    j = 0;
-    cart->count = 0;
-    for( i = 0; i < count && (intnode[i].stump != NULL); i++ )
-    {
-        cart->count++;
-        cart->compidx[i] = intnode[i].stump->compidx;
-        cart->threshold[i] = intnode[i].stump->threshold;
-
-        /* leaves */
-        if( cart->left[i] <= 0 )
-        {
-            cart->left[i] = -j;
-            cart->val[j] = intnode[i].stump->left;
-            j++;
-        }
-        if( cart->right[i] <= 0 )
-        {
-            cart->right[i] = -j;
-            cart->val[j] = intnode[i].stump->right;
-            j++;
-        }
-    }
-
-    /* CLEAN UP */
-    for( i = 0; i < count && (intnode[i].stump != NULL); i++ )
-    {
-        intnode[i].stump->release( (CvClassifier**) &(intnode[i].stump) );
-        if( i != 0 )
-        {
-            cvReleaseMat( &(intnode[i].sampleIdx) );
-        }
-    }
-    for( i = 0; i < listcount; i++ )
-    {
-        list[i].stump->release( (CvClassifier**) &(list[i].stump) );
-        cvReleaseMat( &(list[i].sampleIdx) );
-    }
-
-    cvFree( &intnode );
-
-    return (CvClassifier*) cart;
-}
-
-/****************************************************************************************\
-*                                        Boosting                                        *
-\****************************************************************************************/
-
-typedef struct CvBoostTrainer
-{
-    CvBoostType type;
-    int count;             /* (idx) ? number_of_indices : number_of_samples */
-    int* idx;
-    float* F;
-} CvBoostTrainer;
-
-/*
- * cvBoostStartTraining, cvBoostNextWeakClassifier, cvBoostEndTraining
- *
- * These functions perform training of 2-class boosting classifier
- * using ANY appropriate weak classifier
- */
-
-static
-CvBoostTrainer* icvBoostStartTraining( CvMat* trainClasses,
-                                       CvMat* weakTrainVals,
-                                       CvMat* /*weights*/,
-                                       CvMat* sampleIdx,
-                                       CvBoostType type )
-{
-    uchar* ydata;
-    int ystep;
-    int m;
-    uchar* traindata;
-    int trainstep;
-    int trainnum;
-    int i;
-    int idx;
-
-    size_t datasize;
-    CvBoostTrainer* ptr;
-
-    int idxnum;
-    int idxstep;
-    uchar* idxdata;
-
-    assert( trainClasses != NULL );
-    assert( CV_MAT_TYPE( trainClasses->type ) == CV_32FC1 );
-    assert( weakTrainVals != NULL );
-    assert( CV_MAT_TYPE( weakTrainVals->type ) == CV_32FC1 );
-
-    CV_MAT2VEC( *trainClasses, ydata, ystep, m );
-    CV_MAT2VEC( *weakTrainVals, traindata, trainstep, trainnum );
-
-    CV_Assert( m == trainnum );
-
-    idxnum = 0;
-    idxstep = 0;
-    idxdata = NULL;
-    if( sampleIdx )
-    {
-        CV_MAT2VEC( *sampleIdx, idxdata, idxstep, idxnum );
-    }
-
-    datasize = sizeof( *ptr ) + sizeof( *ptr->idx ) * idxnum;
-    ptr = (CvBoostTrainer*) cvAlloc( datasize );
-    memset( ptr, 0, datasize );
-    ptr->F = NULL;
-    ptr->idx = NULL;
-
-    ptr->count = m;
-    ptr->type = type;
-
-    if( idxnum > 0 )
-    {
-        CvScalar s;
-
-        ptr->idx = (int*) (ptr + 1);
-        ptr->count = idxnum;
-        for( i = 0; i < ptr->count; i++ )
-        {
-            cvRawDataToScalar( idxdata + i*idxstep, CV_MAT_TYPE( sampleIdx->type ), &s );
-            ptr->idx[i] = (int) s.val[0];
-        }
-    }
-    for( i = 0; i < ptr->count; i++ )
-    {
-        idx = (ptr->idx) ? ptr->idx[i] : i;
-
-        *((float*) (traindata + idx * trainstep)) =
-            2.0F * (*((float*) (ydata + idx * ystep))) - 1.0F;
-    }
-
-    return ptr;
-}
-
-/*
- *
- * Discrete AdaBoost functions
- *
- */
-static
-float icvBoostNextWeakClassifierDAB( CvMat* weakEvalVals,
-                                     CvMat* trainClasses,
-                                     CvMat* /*weakTrainVals*/,
-                                     CvMat* weights,
-                                     CvBoostTrainer* trainer )
-{
-    uchar* evaldata;
-    int evalstep;
-    int m;
-    uchar* ydata;
-    int ystep;
-    int ynum;
-    uchar* wdata;
-    int wstep;
-    int wnum;
-
-    float sumw;
-    float err;
-    int i;
-    int idx;
-
-    CV_Assert( weakEvalVals != NULL );
-    CV_Assert( CV_MAT_TYPE( weakEvalVals->type ) == CV_32FC1 );
-    CV_Assert( trainClasses != NULL );
-    CV_Assert( CV_MAT_TYPE( trainClasses->type ) == CV_32FC1 );
-    CV_Assert( weights != NULL );
-    CV_Assert( CV_MAT_TYPE( weights ->type ) == CV_32FC1 );
-
-    CV_MAT2VEC( *weakEvalVals, evaldata, evalstep, m );
-    CV_MAT2VEC( *trainClasses, ydata, ystep, ynum );
-    CV_MAT2VEC( *weights, wdata, wstep, wnum );
-
-    CV_Assert( m == ynum );
-    CV_Assert( m == wnum );
-
-    sumw = 0.0F;
-    err = 0.0F;
-    for( i = 0; i < trainer->count; i++ )
-    {
-        idx = (trainer->idx) ? trainer->idx[i] : i;
-
-        sumw += *((float*) (wdata + idx*wstep));
-        err += (*((float*) (wdata + idx*wstep))) *
-            ( (*((float*) (evaldata + idx*evalstep))) !=
-                2.0F * (*((float*) (ydata + idx*ystep))) - 1.0F );
-    }
-    err /= sumw;
-    err = -cvLogRatio( err );
-
-    for( i = 0; i < trainer->count; i++ )
-    {
-        idx = (trainer->idx) ? trainer->idx[i] : i;
-
-        *((float*) (wdata + idx*wstep)) *= expf( err *
-            ((*((float*) (evaldata + idx*evalstep))) !=
-                2.0F * (*((float*) (ydata + idx*ystep))) - 1.0F) );
-        sumw += *((float*) (wdata + idx*wstep));
-    }
-    for( i = 0; i < trainer->count; i++ )
-    {
-        idx = (trainer->idx) ? trainer->idx[i] : i;
-
-        *((float*) (wdata + idx * wstep)) /= sumw;
-    }
-
-    return err;
-}
-
-/*
- *
- * Real AdaBoost functions
- *
- */
-static
-float icvBoostNextWeakClassifierRAB( CvMat* weakEvalVals,
-                                     CvMat* trainClasses,
-                                     CvMat* /*weakTrainVals*/,
-                                     CvMat* weights,
-                                     CvBoostTrainer* trainer )
-{
-    uchar* evaldata;
-    int evalstep;
-    int m;
-    uchar* ydata;
-    int ystep;
-    int ynum;
-    uchar* wdata;
-    int wstep;
-    int wnum;
-
-    float sumw;
-    int i, idx;
-
-    CV_Assert( weakEvalVals != NULL );
-    CV_Assert( CV_MAT_TYPE( weakEvalVals->type ) == CV_32FC1 );
-    CV_Assert( trainClasses != NULL );
-    CV_Assert( CV_MAT_TYPE( trainClasses->type ) == CV_32FC1 );
-    CV_Assert( weights != NULL );
-    CV_Assert( CV_MAT_TYPE( weights ->type ) == CV_32FC1 );
-
-    CV_MAT2VEC( *weakEvalVals, evaldata, evalstep, m );
-    CV_MAT2VEC( *trainClasses, ydata, ystep, ynum );
-    CV_MAT2VEC( *weights, wdata, wstep, wnum );
-
-    CV_Assert( m == ynum );
-    CV_Assert( m == wnum );
-
-
-    sumw = 0.0F;
-    for( i = 0; i < trainer->count; i++ )
-    {
-        idx = (trainer->idx) ? trainer->idx[i] : i;
-
-        *((float*) (wdata + idx*wstep)) *= expf( (-(*((float*) (ydata + idx*ystep))) + 0.5F)
-            * cvLogRatio( *((float*) (evaldata + idx*evalstep)) ) );
-        sumw += *((float*) (wdata + idx*wstep));
-    }
-    for( i = 0; i < trainer->count; i++ )
-    {
-        idx = (trainer->idx) ? trainer->idx[i] : i;
-
-        *((float*) (wdata + idx*wstep)) /= sumw;
-    }
-
-    return 1.0F;
-}
-
-/*
- *
- * LogitBoost functions
- *
- */
-#define CV_LB_PROB_THRESH      0.01F
-#define CV_LB_WEIGHT_THRESHOLD 0.0001F
-
-static
-void icvResponsesAndWeightsLB( int num, uchar* wdata, int wstep,
-                               uchar* ydata, int ystep,
-                               uchar* fdata, int fstep,
-                               uchar* traindata, int trainstep,
-                               int* indices )
-{
-    int i, idx;
-    float p;
-
-    for( i = 0; i < num; i++ )
-    {
-        idx = (indices) ? indices[i] : i;
-
-        p = 1.0F / (1.0F + expf( -(*((float*) (fdata + idx*fstep)))) );
-        *((float*) (wdata + idx*wstep)) = MAX( p * (1.0F - p), CV_LB_WEIGHT_THRESHOLD );
-        if( *((float*) (ydata + idx*ystep)) == 1.0F )
-        {
-            *((float*) (traindata + idx*trainstep)) =
-                1.0F / (MAX( p, CV_LB_PROB_THRESH ));
-        }
-        else
-        {
-            *((float*) (traindata + idx*trainstep)) =
-                -1.0F / (MAX( 1.0F - p, CV_LB_PROB_THRESH ));
-        }
-    }
-}
-
-static
-CvBoostTrainer* icvBoostStartTrainingLB( CvMat* trainClasses,
-                                         CvMat* weakTrainVals,
-                                         CvMat* weights,
-                                         CvMat* sampleIdx,
-                                         CvBoostType type )
-{
-    size_t datasize;
-    CvBoostTrainer* ptr;
-
-    uchar* ydata;
-    int ystep;
-    int m;
-    uchar* traindata;
-    int trainstep;
-    int trainnum;
-    uchar* wdata;
-    int wstep;
-    int wnum;
-    int i;
-
-    int idxnum;
-    int idxstep;
-    uchar* idxdata;
-
-    assert( trainClasses != NULL );
-    assert( CV_MAT_TYPE( trainClasses->type ) == CV_32FC1 );
-    assert( weakTrainVals != NULL );
-    assert( CV_MAT_TYPE( weakTrainVals->type ) == CV_32FC1 );
-    assert( weights != NULL );
-    assert( CV_MAT_TYPE( weights->type ) == CV_32FC1 );
-
-    CV_MAT2VEC( *trainClasses, ydata, ystep, m );
-    CV_MAT2VEC( *weakTrainVals, traindata, trainstep, trainnum );
-    CV_MAT2VEC( *weights, wdata, wstep, wnum );
-
-    CV_Assert( m == trainnum );
-    CV_Assert( m == wnum );
-
-
-    idxnum = 0;
-    idxstep = 0;
-    idxdata = NULL;
-    if( sampleIdx )
-    {
-        CV_MAT2VEC( *sampleIdx, idxdata, idxstep, idxnum );
-    }
-
-    datasize = sizeof( *ptr ) + sizeof( *ptr->F ) * m + sizeof( *ptr->idx ) * idxnum;
-    ptr = (CvBoostTrainer*) cvAlloc( datasize );
-    memset( ptr, 0, datasize );
-    ptr->F = (float*) (ptr + 1);
-    ptr->idx = NULL;
-
-    ptr->count = m;
-    ptr->type = type;
-
-    if( idxnum > 0 )
-    {
-        CvScalar s;
-
-        ptr->idx = (int*) (ptr->F + m);
-        ptr->count = idxnum;
-        for( i = 0; i < ptr->count; i++ )
-        {
-            cvRawDataToScalar( idxdata + i*idxstep, CV_MAT_TYPE( sampleIdx->type ), &s );
-            ptr->idx[i] = (int) s.val[0];
-        }
-    }
-
-    for( i = 0; i < m; i++ )
-    {
-        ptr->F[i] = 0.0F;
-    }
-
-    icvResponsesAndWeightsLB( ptr->count, wdata, wstep, ydata, ystep,
-                              (uchar*) ptr->F, sizeof( *ptr->F ),
-                              traindata, trainstep, ptr->idx );
-
-    return ptr;
-}
-
-static
-float icvBoostNextWeakClassifierLB( CvMat* weakEvalVals,
-                                    CvMat* trainClasses,
-                                    CvMat* weakTrainVals,
-                                    CvMat* weights,
-                                    CvBoostTrainer* trainer )
-{
-    uchar* evaldata;
-    int evalstep;
-    int m;
-    uchar* ydata;
-    int ystep;
-    int ynum;
-    uchar* traindata;
-    int trainstep;
-    int trainnum;
-    uchar* wdata;
-    int wstep;
-    int wnum;
-    int i, idx;
-
-    assert( weakEvalVals != NULL );
-    assert( CV_MAT_TYPE( weakEvalVals->type ) == CV_32FC1 );
-    assert( trainClasses != NULL );
-    assert( CV_MAT_TYPE( trainClasses->type ) == CV_32FC1 );
-    assert( weakTrainVals != NULL );
-    assert( CV_MAT_TYPE( weakTrainVals->type ) == CV_32FC1 );
-    assert( weights != NULL );
-    assert( CV_MAT_TYPE( weights ->type ) == CV_32FC1 );
-
-    CV_MAT2VEC( *weakEvalVals, evaldata, evalstep, m );
-    CV_MAT2VEC( *trainClasses, ydata, ystep, ynum );
-    CV_MAT2VEC( *weakTrainVals, traindata, trainstep, trainnum );
-    CV_MAT2VEC( *weights, wdata, wstep, wnum );
-
-    CV_Assert( m == ynum );
-    CV_Assert( m == wnum );
-    CV_Assert( m == trainnum );
-    //assert( m == trainer->count );
-
-    for( i = 0; i < trainer->count; i++ )
-    {
-        idx = (trainer->idx) ? trainer->idx[i] : i;
-
-        trainer->F[idx] += *((float*) (evaldata + idx * evalstep));
-    }
-
-    icvResponsesAndWeightsLB( trainer->count, wdata, wstep, ydata, ystep,
-                              (uchar*) trainer->F, sizeof( *trainer->F ),
-                              traindata, trainstep, trainer->idx );
-
-    return 1.0F;
-}
-
-/*
- *
- * Gentle AdaBoost
- *
- */
-static
-float icvBoostNextWeakClassifierGAB( CvMat* weakEvalVals,
-                                     CvMat* trainClasses,
-                                     CvMat* /*weakTrainVals*/,
-                                     CvMat* weights,
-                                     CvBoostTrainer* trainer )
-{
-    uchar* evaldata;
-    int evalstep;
-    int m;
-    uchar* ydata;
-    int ystep;
-    int ynum;
-    uchar* wdata;
-    int wstep;
-    int wnum;
-
-    int i, idx;
-    float sumw;
-
-    CV_Assert( weakEvalVals != NULL );
-    CV_Assert( CV_MAT_TYPE( weakEvalVals->type ) == CV_32FC1 );
-    CV_Assert( trainClasses != NULL );
-    CV_Assert( CV_MAT_TYPE( trainClasses->type ) == CV_32FC1 );
-    CV_Assert( weights != NULL );
-    CV_Assert( CV_MAT_TYPE( weights->type ) == CV_32FC1 );
-
-    CV_MAT2VEC( *weakEvalVals, evaldata, evalstep, m );
-    CV_MAT2VEC( *trainClasses, ydata, ystep, ynum );
-    CV_MAT2VEC( *weights, wdata, wstep, wnum );
-
-    CV_Assert( m == ynum );
-    CV_Assert( m == wnum );
-
-    sumw = 0.0F;
-    for( i = 0; i < trainer->count; i++ )
-    {
-        idx = (trainer->idx) ? trainer->idx[i] : i;
-
-        *((float*) (wdata + idx*wstep)) *=
-            expf( -(*((float*) (evaldata + idx*evalstep)))
-                  * ( 2.0F * (*((float*) (ydata + idx*ystep))) - 1.0F ) );
-        sumw += *((float*) (wdata + idx*wstep));
-    }
-
-    for( i = 0; i < trainer->count; i++ )
-    {
-        idx = (trainer->idx) ? trainer->idx[i] : i;
-
-        *((float*) (wdata + idx*wstep)) /= sumw;
-    }
-
-    return 1.0F;
-}
-
-typedef CvBoostTrainer* (*CvBoostStartTraining)( CvMat* trainClasses,
-                                                 CvMat* weakTrainVals,
-                                                 CvMat* weights,
-                                                 CvMat* sampleIdx,
-                                                 CvBoostType type );
-
-typedef float (*CvBoostNextWeakClassifier)( CvMat* weakEvalVals,
-                                            CvMat* trainClasses,
-                                            CvMat* weakTrainVals,
-                                            CvMat* weights,
-                                            CvBoostTrainer* data );
-
-CvBoostStartTraining startTraining[4] = {
-        icvBoostStartTraining,
-        icvBoostStartTraining,
-        icvBoostStartTrainingLB,
-        icvBoostStartTraining
-    };
-
-CvBoostNextWeakClassifier nextWeakClassifier[4] = {
-        icvBoostNextWeakClassifierDAB,
-        icvBoostNextWeakClassifierRAB,
-        icvBoostNextWeakClassifierLB,
-        icvBoostNextWeakClassifierGAB
-    };
-
-/*
- *
- * Dispatchers
- *
- */
-CV_BOOST_IMPL
-CvBoostTrainer* cvBoostStartTraining( CvMat* trainClasses,
-                                      CvMat* weakTrainVals,
-                                      CvMat* weights,
-                                      CvMat* sampleIdx,
-                                      CvBoostType type )
-{
-    return startTraining[type]( trainClasses, weakTrainVals, weights, sampleIdx, type );
-}
-
-CV_BOOST_IMPL
-void cvBoostEndTraining( CvBoostTrainer** trainer )
-{
-    cvFree( trainer );
-    *trainer = NULL;
-}
-
-CV_BOOST_IMPL
-float cvBoostNextWeakClassifier( CvMat* weakEvalVals,
-                                 CvMat* trainClasses,
-                                 CvMat* weakTrainVals,
-                                 CvMat* weights,
-                                 CvBoostTrainer* trainer )
-{
-    return nextWeakClassifier[trainer->type]( weakEvalVals, trainClasses,
-        weakTrainVals, weights, trainer    );
-}
-
-/****************************************************************************************\
-*                                    Boosted tree models                                 *
-\****************************************************************************************/
-
-typedef struct CvBtTrainer
-{
-    /* {{ external */
-    CvMat* trainData;
-    int flags;
-
-    CvMat* trainClasses;
-    int m;
-    uchar* ydata;
-    int ystep;
-
-    CvMat* sampleIdx;
-    int numsamples;
-
-    float param[2];
-    CvBoostType type;
-    int numclasses;
-    /* }} external */
-
-    CvMTStumpTrainParams stumpParams;
-    CvCARTTrainParams  cartParams;
-
-    float* f;          /* F_(m-1) */
-    CvMat* y;          /* yhat    */
-    CvMat* weights;
-    CvBoostTrainer* boosttrainer;
-} CvBtTrainer;
-
-/*
- * cvBtStart, cvBtNext, cvBtEnd
- *
- * These functions perform iterative training of
- * 2-class (CV_DABCLASS - CV_GABCLASS, CV_L2CLASS), K-class (CV_LKCLASS) classifier
- * or fit regression model (CV_LSREG, CV_LADREG, CV_MREG)
- * using decision tree as a weak classifier.
- */
-
-typedef void (*CvZeroApproxFunc)( float* approx, CvBtTrainer* trainer );
-
-/* Mean zero approximation */
-static void icvZeroApproxMean( float* approx, CvBtTrainer* trainer )
-{
-    int i;
-    int idx;
-
-    approx[0] = 0.0F;
-    for( i = 0; i < trainer->numsamples; i++ )
-    {
-        idx = icvGetIdxAt( trainer->sampleIdx, i );
-        approx[0] += *((float*) (trainer->ydata + idx * trainer->ystep));
-    }
-    approx[0] /= (float) trainer->numsamples;
-}
-
-/*
- * Median zero approximation
- */
-static void icvZeroApproxMed( float* approx, CvBtTrainer* trainer )
-{
-    int i;
-    int idx;
-
-    for( i = 0; i < trainer->numsamples; i++ )
-    {
-        idx = icvGetIdxAt( trainer->sampleIdx, i );
-        trainer->f[i] = *((float*) (trainer->ydata + idx * trainer->ystep));
-    }
-
-    std::sort(trainer->f, trainer->f + trainer->numsamples);
-    approx[0] = trainer->f[trainer->numsamples / 2];
-}
-
-/*
- * 0.5 * log( mean(y) / (1 - mean(y)) ) where y in {0, 1}
- */
-static void icvZeroApproxLog( float* approx, CvBtTrainer* trainer )
-{
-    float y_mean;
-
-    icvZeroApproxMean( &y_mean, trainer );
-    approx[0] = 0.5F * cvLogRatio( y_mean );
-}
-
-/*
- * 0 zero approximation
- */
-static void icvZeroApprox0( float* approx, CvBtTrainer* trainer )
-{
-    int i;
-
-    for( i = 0; i < trainer->numclasses; i++ )
-    {
-        approx[i] = 0.0F;
-    }
-}
-
-static CvZeroApproxFunc icvZeroApproxFunc[] =
-{
-    icvZeroApprox0,    /* CV_DABCLASS */
-    icvZeroApprox0,    /* CV_RABCLASS */
-    icvZeroApprox0,    /* CV_LBCLASS  */
-    icvZeroApprox0,    /* CV_GABCLASS */
-    icvZeroApproxLog,  /* CV_L2CLASS  */
-    icvZeroApprox0,    /* CV_LKCLASS  */
-    icvZeroApproxMean, /* CV_LSREG    */
-    icvZeroApproxMed,  /* CV_LADREG   */
-    icvZeroApproxMed,  /* CV_MREG     */
-};
-
-CV_BOOST_IMPL
-void cvBtNext( CvCARTClassifier** trees, CvBtTrainer* trainer );
-
-static
-CvBtTrainer* cvBtStart( CvCARTClassifier** trees,
-                        CvMat* trainData,
-                        int flags,
-                        CvMat* trainClasses,
-                        CvMat* sampleIdx,
-                        int numsplits,
-                        CvBoostType type,
-                        int numclasses,
-                        float* param )
-{
-    CvBtTrainer* ptr = 0;
-
-    CV_FUNCNAME( "cvBtStart" );
-
-    __BEGIN__;
-
-    size_t data_size;
-    float* zero_approx;
-    int m;
-    int i, j;
-
-    if( trees == NULL )
-    {
-        CV_ERROR( CV_StsNullPtr, "Invalid trees parameter" );
-    }
-
-    if( type < CV_DABCLASS || type > CV_MREG )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Unsupported type parameter" );
-    }
-    if( type == CV_LKCLASS )
-    {
-        CV_ASSERT( numclasses >= 2 );
-    }
-    else
-    {
-        numclasses = 1;
-    }
-
-    m = MAX( trainClasses->rows, trainClasses->cols );
-    ptr = NULL;
-    data_size = sizeof( *ptr );
-    if( type > CV_GABCLASS )
-    {
-        data_size += m * numclasses * sizeof( *(ptr->f) );
-    }
-    CV_CALL( ptr = (CvBtTrainer*) cvAlloc( data_size ) );
-    memset( ptr, 0, data_size );
-    ptr->f = (float*) (ptr + 1);
-
-    ptr->trainData = trainData;
-    ptr->flags = flags;
-    ptr->trainClasses = trainClasses;
-    CV_MAT2VEC( *trainClasses, ptr->ydata, ptr->ystep, ptr->m );
-
-    memset( &(ptr->cartParams), 0, sizeof( ptr->cartParams ) );
-    memset( &(ptr->stumpParams), 0, sizeof( ptr->stumpParams ) );
-
-    switch( type )
-    {
-        case CV_DABCLASS:
-            ptr->stumpParams.error = CV_MISCLASSIFICATION;
-            ptr->stumpParams.type  = CV_CLASSIFICATION_CLASS;
-            break;
-        case CV_RABCLASS:
-            ptr->stumpParams.error = CV_GINI;
-            ptr->stumpParams.type  = CV_CLASSIFICATION;
-            break;
-        default:
-            ptr->stumpParams.error = CV_SQUARE;
-            ptr->stumpParams.type  = CV_REGRESSION;
-    }
-    ptr->cartParams.count = numsplits;
-    ptr->cartParams.stumpTrainParams = (CvClassifierTrainParams*) &(ptr->stumpParams);
-    ptr->cartParams.stumpConstructor = cvCreateMTStumpClassifier;
-
-    ptr->param[0] = param[0];
-    ptr->param[1] = param[1];
-    ptr->type = type;
-    ptr->numclasses = numclasses;
-
-    CV_CALL( ptr->y = cvCreateMat( 1, m, CV_32FC1 ) );
-    ptr->sampleIdx = sampleIdx;
-    ptr->numsamples = ( sampleIdx == NULL ) ? ptr->m
-                             : MAX( sampleIdx->rows, sampleIdx->cols );
-
-    ptr->weights = cvCreateMat( 1, m, CV_32FC1 );
-    cvSet( ptr->weights, cvScalar( 1.0 ) );
-
-    if( type <= CV_GABCLASS )
-    {
-        ptr->boosttrainer = cvBoostStartTraining( ptr->trainClasses, ptr->y,
-            ptr->weights, NULL, type );
-
-        CV_CALL( cvBtNext( trees, ptr ) );
-    }
-    else
-    {
-        data_size = sizeof( *zero_approx ) * numclasses;
-        CV_CALL( zero_approx = (float*) cvAlloc( data_size ) );
-        icvZeroApproxFunc[type]( zero_approx, ptr );
-        for( i = 0; i < m; i++ )
-        {
-            for( j = 0; j < numclasses; j++ )
-            {
-                ptr->f[i * numclasses + j] = zero_approx[j];
-            }
-        }
-
-        CV_CALL( cvBtNext( trees, ptr ) );
-
-        for( i = 0; i < numclasses; i++ )
-        {
-            for( j = 0; j <= trees[i]->count; j++ )
-            {
-                trees[i]->val[j] += zero_approx[i];
-            }
-        }
-        CV_CALL( cvFree( &zero_approx ) );
-    }
-
-    __END__;
-
-    return ptr;
-}
-
-static void icvBtNext_LSREG( CvCARTClassifier** trees, CvBtTrainer* trainer )
-{
-    int i;
-
-    /* yhat_i = y_i - F_(m-1)(x_i) */
-    for( i = 0; i < trainer->m; i++ )
-    {
-        trainer->y->data.fl[i] =
-            *((float*) (trainer->ydata + i * trainer->ystep)) - trainer->f[i];
-    }
-
-    trees[0] = (CvCARTClassifier*) cvCreateCARTClassifier( trainer->trainData,
-        trainer->flags,
-        trainer->y, NULL, NULL, NULL, trainer->sampleIdx, trainer->weights,
-        (CvClassifierTrainParams*) &trainer->cartParams );
-}
-
-
-static void icvBtNext_LADREG( CvCARTClassifier** trees, CvBtTrainer* trainer )
-{
-    CvCARTClassifier* ptr;
-    int i, j;
-    CvMat sample;
-    int sample_step;
-    uchar* sample_data;
-    int index;
-
-    int data_size;
-    int* idx;
-    float* resp;
-    int respnum;
-    float val;
-
-    data_size = trainer->m * sizeof( *idx );
-    idx = (int*) cvAlloc( data_size );
-    data_size = trainer->m * sizeof( *resp );
-    resp = (float*) cvAlloc( data_size );
-
-    /* yhat_i = sign(y_i - F_(m-1)(x_i)) */
-    for( i = 0; i < trainer->numsamples; i++ )
-    {
-        index = icvGetIdxAt( trainer->sampleIdx, i );
-        trainer->y->data.fl[index] = (float)
-             CV_SIGN( *((float*) (trainer->ydata + index * trainer->ystep))
-                     - trainer->f[index] );
-    }
-
-    ptr = (CvCARTClassifier*) cvCreateCARTClassifier( trainer->trainData, trainer->flags,
-        trainer->y, NULL, NULL, NULL, trainer->sampleIdx, trainer->weights,
-        (CvClassifierTrainParams*) &trainer->cartParams );
-
-    CV_GET_SAMPLE( *trainer->trainData, trainer->flags, 0, sample );
-    CV_GET_SAMPLE_STEP( *trainer->trainData, trainer->flags, sample_step );
-    sample_data = sample.data.ptr;
-    for( i = 0; i < trainer->numsamples; i++ )
-    {
-        index = icvGetIdxAt( trainer->sampleIdx, i );
-        sample.data.ptr = sample_data + index * sample_step;
-        idx[index] = (int) cvEvalCARTClassifierIdx( (CvClassifier*) ptr, &sample );
-    }
-    for( j = 0; j <= ptr->count; j++ )
-    {
-        respnum = 0;
-        for( i = 0; i < trainer->numsamples; i++ )
-        {
-            index = icvGetIdxAt( trainer->sampleIdx, i );
-            if( idx[index] == j )
-            {
-                resp[respnum++] = *((float*) (trainer->ydata + index * trainer->ystep))
-                                  - trainer->f[index];
-            }
-        }
-        if( respnum > 0 )
-        {
-            std::sort(resp, resp + respnum);
-            val = resp[respnum / 2];
-        }
-        else
-        {
-            val = 0.0F;
-        }
-        ptr->val[j] = val;
-    }
-
-    cvFree( &idx );
-    cvFree( &resp );
-
-    trees[0] = ptr;
-}
-
-
-static void icvBtNext_MREG( CvCARTClassifier** trees, CvBtTrainer* trainer )
-{
-    CvCARTClassifier* ptr;
-    int i, j;
-    CvMat sample;
-    int sample_step;
-    uchar* sample_data;
-
-    int data_size;
-    int* idx;
-    float* resid;
-    float* resp;
-    int respnum;
-    float rhat;
-    float val;
-    float delta;
-    int index;
-
-    data_size = trainer->m * sizeof( *idx );
-    idx = (int*) cvAlloc( data_size );
-    data_size = trainer->m * sizeof( *resp );
-    resp = (float*) cvAlloc( data_size );
-    data_size = trainer->m * sizeof( *resid );
-    resid = (float*) cvAlloc( data_size );
-
-    /* resid_i = (y_i - F_(m-1)(x_i)) */
-    for( i = 0; i < trainer->numsamples; i++ )
-    {
-        index = icvGetIdxAt( trainer->sampleIdx, i );
-        resid[index] = *((float*) (trainer->ydata + index * trainer->ystep))
-                       - trainer->f[index];
-        /* for delta */
-        resp[i] = (float) fabs( resid[index] );
-    }
-
-    /* delta = quantile_alpha{abs(resid_i)} */
-    std::sort(resp, resp + trainer->numsamples);
-    delta = resp[(int)(trainer->param[1] * (trainer->numsamples - 1))];
-
-    /* yhat_i */
-    for( i = 0; i < trainer->numsamples; i++ )
-    {
-        index = icvGetIdxAt( trainer->sampleIdx, i );
-        trainer->y->data.fl[index] = MIN( delta, ((float) fabs( resid[index] )) ) *
-                                 CV_SIGN( resid[index] );
-    }
-
-    ptr = (CvCARTClassifier*) cvCreateCARTClassifier( trainer->trainData, trainer->flags,
-        trainer->y, NULL, NULL, NULL, trainer->sampleIdx, trainer->weights,
-        (CvClassifierTrainParams*) &trainer->cartParams );
-
-    CV_GET_SAMPLE( *trainer->trainData, trainer->flags, 0, sample );
-    CV_GET_SAMPLE_STEP( *trainer->trainData, trainer->flags, sample_step );
-    sample_data = sample.data.ptr;
-    for( i = 0; i < trainer->numsamples; i++ )
-    {
-        index = icvGetIdxAt( trainer->sampleIdx, i );
-        sample.data.ptr = sample_data + index * sample_step;
-        idx[index] = (int) cvEvalCARTClassifierIdx( (CvClassifier*) ptr, &sample );
-    }
-    for( j = 0; j <= ptr->count; j++ )
-    {
-        respnum = 0;
-
-        for( i = 0; i < trainer->numsamples; i++ )
-        {
-            index = icvGetIdxAt( trainer->sampleIdx, i );
-            if( idx[index] == j )
-            {
-                resp[respnum++] = *((float*) (trainer->ydata + index * trainer->ystep))
-                                  - trainer->f[index];
-            }
-        }
-        if( respnum > 0 )
-        {
-            /* rhat = median(y_i - F_(m-1)(x_i)) */
-            std::sort(resp, resp + respnum);
-            rhat = resp[respnum / 2];
-
-            /* val = sum{sign(r_i - rhat_i) * min(delta, abs(r_i - rhat_i)}
-             * r_i = y_i - F_(m-1)(x_i)
-             */
-            val = 0.0F;
-            for( i = 0; i < respnum; i++ )
-            {
-                val += CV_SIGN( resp[i] - rhat )
-                       * MIN( delta, (float) fabs( resp[i] - rhat ) );
-            }
-
-            val = rhat + val / (float) respnum;
-        }
-        else
-        {
-            val = 0.0F;
-        }
-
-        ptr->val[j] = val;
-
-    }
-
-    cvFree( &resid );
-    cvFree( &resp );
-    cvFree( &idx );
-
-    trees[0] = ptr;
-}
-
-//#define CV_VAL_MAX 1e304
-
-//#define CV_LOG_VAL_MAX 700.0
-
-#define CV_VAL_MAX 1e+8
-
-#define CV_LOG_VAL_MAX 18.0
-
-static void icvBtNext_L2CLASS( CvCARTClassifier** trees, CvBtTrainer* trainer )
-{
-    CvCARTClassifier* ptr;
-    int i, j;
-    CvMat sample;
-    int sample_step;
-    uchar* sample_data;
-
-    int data_size;
-    int* idx;
-    int respnum;
-    float val;
-    double val_f;
-
-    float sum_weights;
-    float* weights;
-    float* sorted_weights;
-    CvMat* trimmed_idx;
-    CvMat* sample_idx;
-    int index;
-    int trimmed_num;
-
-    data_size = trainer->m * sizeof( *idx );
-    idx = (int*) cvAlloc( data_size );
-
-    data_size = trainer->m * sizeof( *weights );
-    weights = (float*) cvAlloc( data_size );
-    data_size = trainer->m * sizeof( *sorted_weights );
-    sorted_weights = (float*) cvAlloc( data_size );
-
-    /* yhat_i = (4 * y_i - 2) / ( 1 + exp( (4 * y_i - 2) * F_(m-1)(x_i) ) ).
-     *   y_i in {0, 1}
-     */
-    sum_weights = 0.0F;
-    for( i = 0; i < trainer->numsamples; i++ )
-    {
-        index = icvGetIdxAt( trainer->sampleIdx, i );
-        val = 4.0F * (*((float*) (trainer->ydata + index * trainer->ystep))) - 2.0F;
-        val_f = val * trainer->f[index];
-        val_f = ( val_f < CV_LOG_VAL_MAX ) ? exp( val_f ) : CV_LOG_VAL_MAX;
-        val = (float) ( (double) val / ( 1.0 + val_f ) );
-        trainer->y->data.fl[index] = val;
-        val = (float) fabs( val );
-        weights[index] = val * (2.0F - val);
-        sorted_weights[i] = weights[index];
-        sum_weights += sorted_weights[i];
-    }
-
-    trimmed_idx = NULL;
-    sample_idx = trainer->sampleIdx;
-    trimmed_num = trainer->numsamples;
-    if( trainer->param[1] < 1.0F )
-    {
-        /* perform weight trimming */
-
-        float threshold;
-        int count;
-
-        std::sort(sorted_weights, sorted_weights + trainer->numsamples);
-
-        sum_weights *= (1.0F - trainer->param[1]);
-
-        i = -1;
-        do { sum_weights -= sorted_weights[++i]; }
-        while( sum_weights > 0.0F && i < (trainer->numsamples - 1) );
-
-        threshold = sorted_weights[i];
-
-        while( i > 0 && sorted_weights[i-1] == threshold ) i--;
-
-        if( i > 0 )
-        {
-            trimmed_num = trainer->numsamples - i;
-            trimmed_idx = cvCreateMat( 1, trimmed_num, CV_32FC1 );
-            count = 0;
-            for( i = 0; i < trainer->numsamples; i++ )
-            {
-                index = icvGetIdxAt( trainer->sampleIdx, i );
-                if( weights[index] >= threshold )
-                {
-                    CV_MAT_ELEM( *trimmed_idx, float, 0, count ) = (float) index;
-                    count++;
-                }
-            }
-
-            assert( count == trimmed_num );
-
-            sample_idx = trimmed_idx;
-
-            printf( "Used samples %%: %g\n",
-                (float) trimmed_num / (float) trainer->numsamples * 100.0F );
-        }
-    }
-
-    ptr = (CvCARTClassifier*) cvCreateCARTClassifier( trainer->trainData, trainer->flags,
-        trainer->y, NULL, NULL, NULL, sample_idx, trainer->weights,
-        (CvClassifierTrainParams*) &trainer->cartParams );
-
-    CV_GET_SAMPLE( *trainer->trainData, trainer->flags, 0, sample );
-    CV_GET_SAMPLE_STEP( *trainer->trainData, trainer->flags, sample_step );
-    sample_data = sample.data.ptr;
-    for( i = 0; i < trimmed_num; i++ )
-    {
-        index = icvGetIdxAt( sample_idx, i );
-        sample.data.ptr = sample_data + index * sample_step;
-        idx[index] = (int) cvEvalCARTClassifierIdx( (CvClassifier*) ptr, &sample );
-    }
-    for( j = 0; j <= ptr->count; j++ )
-    {
-        respnum = 0;
-        val = 0.0F;
-        sum_weights = 0.0F;
-        for( i = 0; i < trimmed_num; i++ )
-        {
-            index = icvGetIdxAt( sample_idx, i );
-            if( idx[index] == j )
-            {
-                val += trainer->y->data.fl[index];
-                sum_weights += weights[index];
-                respnum++;
-            }
-        }
-        if( sum_weights > 0.0F )
-        {
-            val /= sum_weights;
-        }
-        else
-        {
-            val = 0.0F;
-        }
-        ptr->val[j] = val;
-    }
-
-    if( trimmed_idx != NULL ) cvReleaseMat( &trimmed_idx );
-    cvFree( &sorted_weights );
-    cvFree( &weights );
-    cvFree( &idx );
-
-    trees[0] = ptr;
-}
-
-static void icvBtNext_LKCLASS( CvCARTClassifier** trees, CvBtTrainer* trainer )
-{
-    int i, j, k, kk, num;
-    CvMat sample;
-    int sample_step;
-    uchar* sample_data;
-
-    int data_size;
-    int* idx;
-    int respnum;
-    float val;
-
-    float sum_weights;
-    float* weights;
-    float* sorted_weights;
-    CvMat* trimmed_idx;
-    CvMat* sample_idx;
-    int index;
-    int trimmed_num;
-    double sum_exp_f;
-    double exp_f;
-    double f_k;
-
-    data_size = trainer->m * sizeof( *idx );
-    idx = (int*) cvAlloc( data_size );
-    data_size = trainer->m * sizeof( *weights );
-    weights = (float*) cvAlloc( data_size );
-    data_size = trainer->m * sizeof( *sorted_weights );
-    sorted_weights = (float*) cvAlloc( data_size );
-    trimmed_idx = cvCreateMat( 1, trainer->numsamples, CV_32FC1 );
-
-    for( k = 0; k < trainer->numclasses; k++ )
-    {
-        /* yhat_i = y_i - p_k(x_i), y_i in {0, 1}      */
-        /* p_k(x_i) = exp(f_k(x_i)) / (sum_exp_f(x_i)) */
-        sum_weights = 0.0F;
-        for( i = 0; i < trainer->numsamples; i++ )
-        {
-            index = icvGetIdxAt( trainer->sampleIdx, i );
-            /* p_k(x_i) = 1 / (1 + sum(exp(f_kk(x_i) - f_k(x_i)))), kk != k */
-            num = index * trainer->numclasses;
-            f_k = (double) trainer->f[num + k];
-            sum_exp_f = 1.0;
-            for( kk = 0; kk < trainer->numclasses; kk++ )
-            {
-                if( kk == k ) continue;
-                exp_f = (double) trainer->f[num + kk] - f_k;
-                exp_f = (exp_f < CV_LOG_VAL_MAX) ? exp( exp_f ) : CV_VAL_MAX;
-                if( exp_f == CV_VAL_MAX || exp_f >= (CV_VAL_MAX - sum_exp_f) )
-                {
-                    sum_exp_f = CV_VAL_MAX;
-                    break;
-                }
-                sum_exp_f += exp_f;
-            }
-
-            val = (float) ( (*((float*) (trainer->ydata + index * trainer->ystep)))
-                            == (float) k );
-            val -= (float) ( (sum_exp_f == CV_VAL_MAX) ? 0.0 : ( 1.0 / sum_exp_f ) );
-
-            assert( val >= -1.0F );
-            assert( val <= 1.0F );
-
-            trainer->y->data.fl[index] = val;
-            val = (float) fabs( val );
-            weights[index] = val * (1.0F - val);
-            sorted_weights[i] = weights[index];
-            sum_weights += sorted_weights[i];
-        }
-
-        sample_idx = trainer->sampleIdx;
-        trimmed_num = trainer->numsamples;
-        if( trainer->param[1] < 1.0F )
-        {
-            /* perform weight trimming */
-
-            float threshold;
-            int count;
-
-            std::sort(sorted_weights, sorted_weights + trainer->numsamples);
-
-            sum_weights *= (1.0F - trainer->param[1]);
-
-            i = -1;
-            do { sum_weights -= sorted_weights[++i]; }
-            while( sum_weights > 0.0F && i < (trainer->numsamples - 1) );
-
-            threshold = sorted_weights[i];
-
-            while( i > 0 && sorted_weights[i-1] == threshold ) i--;
-
-            if( i > 0 )
-            {
-                trimmed_num = trainer->numsamples - i;
-                trimmed_idx->cols = trimmed_num;
-                count = 0;
-                for( i = 0; i < trainer->numsamples; i++ )
-                {
-                    index = icvGetIdxAt( trainer->sampleIdx, i );
-                    if( weights[index] >= threshold )
-                    {
-                        CV_MAT_ELEM( *trimmed_idx, float, 0, count ) = (float) index;
-                        count++;
-                    }
-                }
-
-                assert( count == trimmed_num );
-
-                sample_idx = trimmed_idx;
-
-                printf( "k: %d Used samples %%: %g\n", k,
-                    (float) trimmed_num / (float) trainer->numsamples * 100.0F );
-            }
-        } /* weight trimming */
-
-        trees[k] = (CvCARTClassifier*) cvCreateCARTClassifier( trainer->trainData,
-            trainer->flags, trainer->y, NULL, NULL, NULL, sample_idx, trainer->weights,
-            (CvClassifierTrainParams*) &trainer->cartParams );
-
-        CV_GET_SAMPLE( *trainer->trainData, trainer->flags, 0, sample );
-        CV_GET_SAMPLE_STEP( *trainer->trainData, trainer->flags, sample_step );
-        sample_data = sample.data.ptr;
-        for( i = 0; i < trimmed_num; i++ )
-        {
-            index = icvGetIdxAt( sample_idx, i );
-            sample.data.ptr = sample_data + index * sample_step;
-            idx[index] = (int) cvEvalCARTClassifierIdx( (CvClassifier*) trees[k],
-                                                        &sample );
-        }
-        for( j = 0; j <= trees[k]->count; j++ )
-        {
-            respnum = 0;
-            val = 0.0F;
-            sum_weights = 0.0F;
-            for( i = 0; i < trimmed_num; i++ )
-            {
-                index = icvGetIdxAt( sample_idx, i );
-                if( idx[index] == j )
-                {
-                    val += trainer->y->data.fl[index];
-                    sum_weights += weights[index];
-                    respnum++;
-                }
-            }
-            if( sum_weights > 0.0F )
-            {
-                val = ((float) (trainer->numclasses - 1)) * val /
-                      ((float) (trainer->numclasses)) / sum_weights;
-            }
-            else
-            {
-                val = 0.0F;
-            }
-            trees[k]->val[j] = val;
-        }
-    } /* for each class */
-
-    cvReleaseMat( &trimmed_idx );
-    cvFree( &sorted_weights );
-    cvFree( &weights );
-    cvFree( &idx );
-}
-
-
-static void icvBtNext_XXBCLASS( CvCARTClassifier** trees, CvBtTrainer* trainer )
-{
-    float alpha;
-    int i;
-    CvMat* weak_eval_vals;
-    CvMat* sample_idx;
-    int num_samples;
-    CvMat sample;
-    uchar* sample_data;
-    int sample_step;
-
-    weak_eval_vals = cvCreateMat( 1, trainer->m, CV_32FC1 );
-
-    sample_idx = cvTrimWeights( trainer->weights, trainer->sampleIdx,
-                                trainer->param[1] );
-    num_samples = ( sample_idx == NULL )
-        ? trainer->m : MAX( sample_idx->rows, sample_idx->cols );
-
-    printf( "Used samples %%: %g\n",
-        (float) num_samples / (float) trainer->numsamples * 100.0F );
-
-    trees[0] = (CvCARTClassifier*) cvCreateCARTClassifier( trainer->trainData,
-        trainer->flags, trainer->y, NULL, NULL, NULL,
-        sample_idx, trainer->weights,
-        (CvClassifierTrainParams*) &trainer->cartParams );
-
-    /* evaluate samples */
-    CV_GET_SAMPLE( *trainer->trainData, trainer->flags, 0, sample );
-    CV_GET_SAMPLE_STEP( *trainer->trainData, trainer->flags, sample_step );
-    sample_data = sample.data.ptr;
-
-    for( i = 0; i < trainer->m; i++ )
-    {
-        sample.data.ptr = sample_data + i * sample_step;
-        weak_eval_vals->data.fl[i] = trees[0]->eval( (CvClassifier*) trees[0], &sample );
-    }
-
-    alpha = cvBoostNextWeakClassifier( weak_eval_vals, trainer->trainClasses,
-        trainer->y, trainer->weights, trainer->boosttrainer );
-
-    /* multiply tree by alpha */
-    for( i = 0; i <= trees[0]->count; i++ )
-    {
-        trees[0]->val[i] *= alpha;
-    }
-    if( trainer->type == CV_RABCLASS )
-    {
-        for( i = 0; i <= trees[0]->count; i++ )
-        {
-            trees[0]->val[i] = cvLogRatio( trees[0]->val[i] );
-        }
-    }
-
-    if( sample_idx != NULL && sample_idx != trainer->sampleIdx )
-    {
-        cvReleaseMat( &sample_idx );
-    }
-    cvReleaseMat( &weak_eval_vals );
-}
-
-typedef void (*CvBtNextFunc)( CvCARTClassifier** trees, CvBtTrainer* trainer );
-
-static CvBtNextFunc icvBtNextFunc[] =
-{
-    icvBtNext_XXBCLASS,
-    icvBtNext_XXBCLASS,
-    icvBtNext_XXBCLASS,
-    icvBtNext_XXBCLASS,
-    icvBtNext_L2CLASS,
-    icvBtNext_LKCLASS,
-    icvBtNext_LSREG,
-    icvBtNext_LADREG,
-    icvBtNext_MREG
-};
-
-CV_BOOST_IMPL
-void cvBtNext( CvCARTClassifier** trees, CvBtTrainer* trainer )
-{
-    int i, j;
-    int index;
-    CvMat sample;
-    int sample_step;
-    uchar* sample_data;
-
-    icvBtNextFunc[trainer->type]( trees, trainer );
-
-    /* shrinkage */
-    if( trainer->param[0] != 1.0F )
-    {
-        for( j = 0; j < trainer->numclasses; j++ )
-        {
-            for( i = 0; i <= trees[j]->count; i++ )
-            {
-                trees[j]->val[i] *= trainer->param[0];
-            }
-        }
-    }
-
-    if( trainer->type > CV_GABCLASS )
-    {
-        /* update F_(m-1) */
-        CV_GET_SAMPLE( *(trainer->trainData), trainer->flags, 0, sample );
-        CV_GET_SAMPLE_STEP( *(trainer->trainData), trainer->flags, sample_step );
-        sample_data = sample.data.ptr;
-        for( i = 0; i < trainer->numsamples; i++ )
-        {
-            index = icvGetIdxAt( trainer->sampleIdx, i );
-            sample.data.ptr = sample_data + index * sample_step;
-            for( j = 0; j < trainer->numclasses; j++ )
-            {
-                trainer->f[index * trainer->numclasses + j] +=
-                    trees[j]->eval( (CvClassifier*) (trees[j]), &sample );
-            }
-        }
-    }
-}
-
-static
-void cvBtEnd( CvBtTrainer** trainer )
-{
-    CV_FUNCNAME( "cvBtEnd" );
-
-    __BEGIN__;
-
-    if( trainer == NULL || (*trainer) == NULL )
-    {
-        CV_ERROR( CV_StsNullPtr, "Invalid trainer parameter" );
-    }
-
-    if( (*trainer)->y != NULL )
-    {
-        CV_CALL( cvReleaseMat( &((*trainer)->y) ) );
-    }
-    if( (*trainer)->weights != NULL )
-    {
-        CV_CALL( cvReleaseMat( &((*trainer)->weights) ) );
-    }
-    if( (*trainer)->boosttrainer != NULL )
-    {
-        CV_CALL( cvBoostEndTraining( &((*trainer)->boosttrainer) ) );
-    }
-    CV_CALL( cvFree( trainer ) );
-
-    __END__;
-}
-
-/****************************************************************************************\
-*                         Boosted tree model as a classifier                             *
-\****************************************************************************************/
-
-static
-float cvEvalBtClassifier( CvClassifier* classifier, CvMat* sample )
-{
-    float val;
-
-    CV_FUNCNAME( "cvEvalBtClassifier" );
-
-    __BEGIN__;
-
-    int i;
-
-    val = 0.0F;
-    if( CV_IS_TUNABLE( classifier->flags ) )
-    {
-        CvSeqReader reader;
-        CvCARTClassifier* tree;
-
-        CV_CALL( cvStartReadSeq( ((CvBtClassifier*) classifier)->seq, &reader ) );
-        for( i = 0; i < ((CvBtClassifier*) classifier)->numiter; i++ )
-        {
-            CV_READ_SEQ_ELEM( tree, reader );
-            val += tree->eval( (CvClassifier*) tree, sample );
-        }
-    }
-    else
-    {
-        CvCARTClassifier** ptree;
-
-        ptree = ((CvBtClassifier*) classifier)->trees;
-        for( i = 0; i < ((CvBtClassifier*) classifier)->numiter; i++ )
-        {
-            val += (*ptree)->eval( (CvClassifier*) (*ptree), sample );
-            ptree++;
-        }
-    }
-
-    __END__;
-
-    return val;
-}
-
-static
-float cvEvalBtClassifier2( CvClassifier* classifier, CvMat* sample )
-{
-    float val;
-
-    CV_FUNCNAME( "cvEvalBtClassifier2" );
-
-    __BEGIN__;
-
-    CV_CALL( val = cvEvalBtClassifier( classifier, sample ) );
-
-    __END__;
-
-    return (float) (val >= 0.0F);
-}
-
-static
-float cvEvalBtClassifierK( CvClassifier* classifier, CvMat* sample )
-{
-    int cls = 0;
-
-    CV_FUNCNAME( "cvEvalBtClassifierK" );
-
-    __BEGIN__;
-
-    int i, k;
-    float max_val;
-    int numclasses;
-
-    float* vals;
-    size_t data_size;
-
-    numclasses = ((CvBtClassifier*) classifier)->numclasses;
-    data_size = sizeof( *vals ) * numclasses;
-    CV_CALL( vals = (float*) cvAlloc( data_size ) );
-    memset( vals, 0, data_size );
-
-    if( CV_IS_TUNABLE( classifier->flags ) )
-    {
-        CvSeqReader reader;
-        CvCARTClassifier* tree;
-
-        CV_CALL( cvStartReadSeq( ((CvBtClassifier*) classifier)->seq, &reader ) );
-        for( i = 0; i < ((CvBtClassifier*) classifier)->numiter; i++ )
-        {
-            for( k = 0; k < numclasses; k++ )
-            {
-                CV_READ_SEQ_ELEM( tree, reader );
-                vals[k] += tree->eval( (CvClassifier*) tree, sample );
-            }
-        }
-
-    }
-    else
-    {
-        CvCARTClassifier** ptree;
-
-        ptree = ((CvBtClassifier*) classifier)->trees;
-        for( i = 0; i < ((CvBtClassifier*) classifier)->numiter; i++ )
-        {
-            for( k = 0; k < numclasses; k++ )
-            {
-                vals[k] += (*ptree)->eval( (CvClassifier*) (*ptree), sample );
-                ptree++;
-            }
-        }
-    }
-
-    max_val = vals[cls];
-    for( k = 1; k < numclasses; k++ )
-    {
-        if( vals[k] > max_val )
-        {
-            max_val = vals[k];
-            cls = k;
-        }
-    }
-
-    CV_CALL( cvFree( &vals ) );
-
-    __END__;
-
-    return (float) cls;
-}
-
-typedef float (*CvEvalBtClassifier)( CvClassifier* classifier, CvMat* sample );
-
-static CvEvalBtClassifier icvEvalBtClassifier[] =
-{
-    cvEvalBtClassifier2,
-    cvEvalBtClassifier2,
-    cvEvalBtClassifier2,
-    cvEvalBtClassifier2,
-    cvEvalBtClassifier2,
-    cvEvalBtClassifierK,
-    cvEvalBtClassifier,
-    cvEvalBtClassifier,
-    cvEvalBtClassifier
-};
-
-static
-int cvSaveBtClassifier( CvClassifier* classifier, const char* filename )
-{
-    CV_FUNCNAME( "cvSaveBtClassifier" );
-
-    __BEGIN__;
-
-    FILE* file;
-    int i, j;
-    CvSeqReader reader;
-    memset(&reader, 0, sizeof(reader));
-    CvCARTClassifier* tree;
-
-    CV_ASSERT( classifier );
-    CV_ASSERT( filename );
-
-    if( !icvMkDir( filename ) || (file = fopen( filename, "w" )) == 0 )
-    {
-        CV_ERROR( CV_StsError, "Unable to create file" );
-    }
-
-    if( CV_IS_TUNABLE( classifier->flags ) )
-    {
-        CV_CALL( cvStartReadSeq( ((CvBtClassifier*) classifier)->seq, &reader ) );
-    }
-    fprintf( file, "%d %d\n%d\n%d\n", (int) ((CvBtClassifier*) classifier)->type,
-                                      ((CvBtClassifier*) classifier)->numclasses,
-                                      ((CvBtClassifier*) classifier)->numfeatures,
-                                      ((CvBtClassifier*) classifier)->numiter );
-
-    for( i = 0; i < ((CvBtClassifier*) classifier)->numclasses *
-                    ((CvBtClassifier*) classifier)->numiter; i++ )
-    {
-        if( CV_IS_TUNABLE( classifier->flags ) )
-        {
-            CV_READ_SEQ_ELEM( tree, reader );
-        }
-        else
-        {
-            tree = ((CvBtClassifier*) classifier)->trees[i];
-        }
-
-        fprintf( file, "%d\n", tree->count );
-        for( j = 0; j < tree->count; j++ )
-        {
-            fprintf( file, "%d %g %d %d\n", tree->compidx[j],
-                                            tree->threshold[j],
-                                            tree->left[j],
-                                            tree->right[j] );
-        }
-        for( j = 0; j <= tree->count; j++ )
-        {
-            fprintf( file, "%g ", tree->val[j] );
-        }
-        fprintf( file, "\n" );
-    }
-
-    fclose( file );
-
-    __END__;
-
-    return 1;
-}
-
-
-static
-void cvReleaseBtClassifier( CvClassifier** ptr )
-{
-    CV_FUNCNAME( "cvReleaseBtClassifier" );
-
-    __BEGIN__;
-
-    int i;
-
-    if( ptr == NULL || *ptr == NULL )
-    {
-        CV_ERROR( CV_StsNullPtr, "" );
-    }
-    if( CV_IS_TUNABLE( (*ptr)->flags ) )
-    {
-        CvSeqReader reader;
-        CvCARTClassifier* tree;
-
-        CV_CALL( cvStartReadSeq( ((CvBtClassifier*) *ptr)->seq, &reader ) );
-        for( i = 0; i < ((CvBtClassifier*) *ptr)->numclasses *
-                        ((CvBtClassifier*) *ptr)->numiter; i++ )
-        {
-            CV_READ_SEQ_ELEM( tree, reader );
-            tree->release( (CvClassifier**) (&tree) );
-        }
-        CV_CALL( cvReleaseMemStorage( &(((CvBtClassifier*) *ptr)->seq->storage) ) );
-    }
-    else
-    {
-        CvCARTClassifier** ptree;
-
-        ptree = ((CvBtClassifier*) *ptr)->trees;
-        for( i = 0; i < ((CvBtClassifier*) *ptr)->numclasses *
-                        ((CvBtClassifier*) *ptr)->numiter; i++ )
-        {
-            (*ptree)->release( (CvClassifier**) ptree );
-            ptree++;
-        }
-    }
-
-    CV_CALL( cvFree( ptr ) );
-    *ptr = NULL;
-
-    __END__;
-}
-
-static void cvTuneBtClassifier( CvClassifier* classifier, CvMat*, int flags,
-                         CvMat*, CvMat* , CvMat*, CvMat*, CvMat* )
-{
-    CV_FUNCNAME( "cvTuneBtClassifier" );
-
-    __BEGIN__;
-
-    size_t data_size;
-
-    if( CV_IS_TUNABLE( flags ) )
-    {
-        if( !CV_IS_TUNABLE( classifier->flags ) )
-        {
-            CV_ERROR( CV_StsUnsupportedFormat,
-                      "Classifier does not support tune function" );
-        }
-        else
-        {
-            /* tune classifier */
-            CvCARTClassifier** trees;
-
-            printf( "Iteration %d\n", ((CvBtClassifier*) classifier)->numiter + 1 );
-
-            data_size = sizeof( *trees ) * ((CvBtClassifier*) classifier)->numclasses;
-            CV_CALL( trees = (CvCARTClassifier**) cvAlloc( data_size ) );
-            CV_CALL( cvBtNext( trees,
-                (CvBtTrainer*) ((CvBtClassifier*) classifier)->trainer ) );
-            CV_CALL( cvSeqPushMulti( ((CvBtClassifier*) classifier)->seq,
-                trees, ((CvBtClassifier*) classifier)->numclasses ) );
-            CV_CALL( cvFree( &trees ) );
-            ((CvBtClassifier*) classifier)->numiter++;
-        }
-    }
-    else
-    {
-        if( CV_IS_TUNABLE( classifier->flags ) )
-        {
-            /* convert */
-            void* ptr;
-
-            assert( ((CvBtClassifier*) classifier)->seq->total ==
-                        ((CvBtClassifier*) classifier)->numiter *
-                        ((CvBtClassifier*) classifier)->numclasses );
-
-            data_size = sizeof( ((CvBtClassifier*) classifier)->trees[0] ) *
-                ((CvBtClassifier*) classifier)->seq->total;
-            CV_CALL( ptr = cvAlloc( data_size ) );
-            CV_CALL( cvCvtSeqToArray( ((CvBtClassifier*) classifier)->seq, ptr ) );
-            CV_CALL( cvReleaseMemStorage(
-                    &(((CvBtClassifier*) classifier)->seq->storage) ) );
-            ((CvBtClassifier*) classifier)->trees = (CvCARTClassifier**) ptr;
-            classifier->flags &= ~CV_TUNABLE;
-            CV_CALL( cvBtEnd( (CvBtTrainer**)
-                &(((CvBtClassifier*) classifier)->trainer )) );
-            ((CvBtClassifier*) classifier)->trainer = NULL;
-        }
-    }
-
-    __END__;
-}
-
-static CvBtClassifier* icvAllocBtClassifier( CvBoostType type, int flags, int numclasses,
-                                      int numiter )
-{
-    CvBtClassifier* ptr;
-    size_t data_size;
-
-    assert( numclasses >= 1 );
-    assert( numiter >= 0 );
-    assert( ( numclasses == 1 ) || (type == CV_LKCLASS) );
-
-    data_size = sizeof( *ptr );
-    ptr = (CvBtClassifier*) cvAlloc( data_size );
-    memset( ptr, 0, data_size );
-
-    if( CV_IS_TUNABLE( flags ) )
-    {
-        ptr->seq = cvCreateSeq( 0, sizeof( *(ptr->seq) ), sizeof( *(ptr->trees) ),
-                                cvCreateMemStorage() );
-        ptr->numiter = 0;
-    }
-    else
-    {
-        data_size = numclasses * numiter * sizeof( *(ptr->trees) );
-        ptr->trees = (CvCARTClassifier**) cvAlloc( data_size );
-        memset( ptr->trees, 0, data_size );
-
-        ptr->numiter = numiter;
-    }
-
-    ptr->flags = flags;
-    ptr->numclasses = numclasses;
-    ptr->type = type;
-
-    ptr->eval = icvEvalBtClassifier[(int) type];
-    ptr->tune = cvTuneBtClassifier;
-    ptr->save = cvSaveBtClassifier;
-    ptr->release = cvReleaseBtClassifier;
-
-    return ptr;
-}
-
-CV_BOOST_IMPL
-CvClassifier* cvCreateBtClassifier( CvMat* trainData,
-                                    int flags,
-                                    CvMat* trainClasses,
-                                    CvMat* typeMask,
-                                    CvMat* missedMeasurementsMask,
-                                    CvMat* compIdx,
-                                    CvMat* sampleIdx,
-                                    CvMat* weights,
-                                    CvClassifierTrainParams* trainParams )
-{
-    CvBtClassifier* ptr = 0;
-
-    CV_FUNCNAME( "cvCreateBtClassifier" );
-
-    __BEGIN__;
-    CvBoostType type;
-    int num_classes;
-    int num_iter;
-    int i;
-    CvCARTClassifier** trees;
-    size_t data_size;
-
-    CV_ASSERT( trainData != NULL );
-    CV_ASSERT( trainClasses != NULL );
-    CV_ASSERT( typeMask == NULL );
-    CV_ASSERT( missedMeasurementsMask == NULL );
-    CV_ASSERT( compIdx == NULL );
-    CV_ASSERT( weights == NULL );
-    CV_ASSERT( trainParams != NULL );
-
-    type = ((CvBtClassifierTrainParams*) trainParams)->type;
-
-    if( type >= CV_DABCLASS && type <= CV_GABCLASS && sampleIdx )
-    {
-        CV_ERROR( CV_StsBadArg, "Sample indices are not supported for this type" );
-    }
-
-    if( type == CV_LKCLASS )
-    {
-        double min_val;
-        double max_val;
-
-        cvMinMaxLoc( trainClasses, &min_val, &max_val );
-        num_classes = (int) (max_val + 1.0);
-
-        CV_ASSERT( num_classes >= 2 );
-    }
-    else
-    {
-        num_classes = 1;
-    }
-    num_iter = ((CvBtClassifierTrainParams*) trainParams)->numiter;
-
-    CV_ASSERT( num_iter > 0 );
-
-    ptr = icvAllocBtClassifier( type, CV_TUNABLE | flags, num_classes, num_iter );
-    ptr->numfeatures = (CV_IS_ROW_SAMPLE( flags )) ? trainData->cols : trainData->rows;
-
-    i = 0;
-
-    printf( "Iteration %d\n", 1 );
-
-    data_size = sizeof( *trees ) * ptr->numclasses;
-    CV_CALL( trees = (CvCARTClassifier**) cvAlloc( data_size ) );
-
-    CV_CALL( ptr->trainer = cvBtStart( trees, trainData, flags, trainClasses, sampleIdx,
-        ((CvBtClassifierTrainParams*) trainParams)->numsplits, type, num_classes,
-        &(((CvBtClassifierTrainParams*) trainParams)->param[0]) ) );
-
-    CV_CALL( cvSeqPushMulti( ptr->seq, trees, ptr->numclasses ) );
-    CV_CALL( cvFree( &trees ) );
-    ptr->numiter++;
-
-    for( i = 1; i < num_iter; i++ )
-    {
-        ptr->tune( (CvClassifier*) ptr, NULL, CV_TUNABLE, NULL, NULL, NULL, NULL, NULL );
-    }
-    if( !CV_IS_TUNABLE( flags ) )
-    {
-        /* convert */
-        ptr->tune( (CvClassifier*) ptr, NULL, 0, NULL, NULL, NULL, NULL, NULL );
-    }
-
-    __END__;
-
-    return (CvClassifier*) ptr;
-}
-
-CV_BOOST_IMPL
-CvClassifier* cvCreateBtClassifierFromFile( const char* filename )
-{
-    CvBtClassifier* ptr = 0;
-
-    CV_FUNCNAME( "cvCreateBtClassifierFromFile" );
-
-    __BEGIN__;
-
-    FILE* file;
-    int i, j;
-    int data_size;
-    int num_classifiers;
-    int num_features;
-    int num_classes;
-    int type;
-    int values_read = -1;
-
-    CV_ASSERT( filename != NULL );
-
-    ptr = NULL;
-    file = fopen( filename, "r" );
-    if( !file )
-    {
-        CV_ERROR( CV_StsError, "Unable to open file" );
-    }
-
-    values_read = fscanf( file, "%d %d %d %d", &type, &num_classes, &num_features, &num_classifiers );
-    CV_Assert(values_read == 4);
-
-    CV_ASSERT( type >= (int) CV_DABCLASS && type <= (int) CV_MREG );
-    CV_ASSERT( num_features > 0 );
-    CV_ASSERT( num_classifiers > 0 );
-
-    if( (CvBoostType) type != CV_LKCLASS )
-    {
-        num_classes = 1;
-    }
-    ptr = icvAllocBtClassifier( (CvBoostType) type, 0, num_classes, num_classifiers );
-    ptr->numfeatures = num_features;
-
-    for( i = 0; i < num_classes * num_classifiers; i++ )
-    {
-        int count;
-        CvCARTClassifier* tree;
-
-        values_read = fscanf( file, "%d", &count );
-        CV_Assert(values_read == 1);
-
-        data_size = sizeof( *tree )
-            + count * ( sizeof( *(tree->compidx) ) + sizeof( *(tree->threshold) ) +
-                        sizeof( *(tree->right) ) + sizeof( *(tree->left) ) )
-            + (count + 1) * ( sizeof( *(tree->val) ) );
-        CV_CALL( tree = (CvCARTClassifier*) cvAlloc( data_size ) );
-        memset( tree, 0, data_size );
-        tree->eval = cvEvalCARTClassifier;
-        tree->tune = NULL;
-        tree->save = NULL;
-        tree->release = cvReleaseCARTClassifier;
-        tree->compidx = (int*) ( tree + 1 );
-        tree->threshold = (float*) ( tree->compidx + count );
-        tree->left = (int*) ( tree->threshold + count );
-        tree->right = (int*) ( tree->left + count );
-        tree->val = (float*) ( tree->right + count );
-
-        tree->count = count;
-        for( j = 0; j < tree->count; j++ )
-        {
-            values_read = fscanf( file, "%d %g %d %d", &(tree->compidx[j]),
-                                         &(tree->threshold[j]),
-                                         &(tree->left[j]),
-                                         &(tree->right[j]) );
-            CV_Assert(values_read == 4);
-        }
-        for( j = 0; j <= tree->count; j++ )
-        {
-            values_read = fscanf( file, "%g", &(tree->val[j]) );
-            CV_Assert(values_read == 1);
-        }
-        ptr->trees[i] = tree;
-    }
-
-    fclose( file );
-
-    __END__;
-
-    return (CvClassifier*) ptr;
-}
-
-/****************************************************************************************\
-*                                    Utility functions                                   *
-\****************************************************************************************/
-
-CV_BOOST_IMPL
-CvMat* cvTrimWeights( CvMat* weights, CvMat* idx, float factor )
-{
-    CvMat* ptr = 0;
-
-    CV_FUNCNAME( "cvTrimWeights" );
-    __BEGIN__;
-    int i, index, num;
-    float sum_weights;
-    uchar* wdata;
-    size_t wstep;
-    int wnum;
-    float threshold;
-    int count;
-    float* sorted_weights;
-
-    CV_ASSERT( CV_MAT_TYPE( weights->type ) == CV_32FC1 );
-
-    ptr = idx;
-    sorted_weights = NULL;
-
-    if( factor > 0.0F && factor < 1.0F )
-    {
-        size_t data_size;
-
-        CV_MAT2VEC( *weights, wdata, wstep, wnum );
-        num = ( idx == NULL ) ? wnum : MAX( idx->rows, idx->cols );
-
-        data_size = num * sizeof( *sorted_weights );
-        sorted_weights = (float*) cvAlloc( data_size );
-        memset( sorted_weights, 0, data_size );
-
-        sum_weights = 0.0F;
-        for( i = 0; i < num; i++ )
-        {
-            index = icvGetIdxAt( idx, i );
-            sorted_weights[i] = *((float*) (wdata + index * wstep));
-            sum_weights += sorted_weights[i];
-        }
-
-        std::sort(sorted_weights, sorted_weights + num);
-
-        sum_weights *= (1.0F - factor);
-
-        i = -1;
-        do { sum_weights -= sorted_weights[++i]; }
-        while( sum_weights > 0.0F && i < (num - 1) );
-
-        threshold = sorted_weights[i];
-
-        while( i > 0 && sorted_weights[i-1] == threshold ) i--;
-
-        if( i > 0 || ( idx != NULL && CV_MAT_TYPE( idx->type ) != CV_32FC1 ) )
-        {
-            CV_CALL( ptr = cvCreateMat( 1, num - i, CV_32FC1 ) );
-            count = 0;
-            for( i = 0; i < num; i++ )
-            {
-                index = icvGetIdxAt( idx, i );
-                if( *((float*) (wdata + index * wstep)) >= threshold )
-                {
-                    CV_MAT_ELEM( *ptr, float, 0, count ) = (float) index;
-                    count++;
-                }
-            }
-
-            assert( count == ptr->cols );
-        }
-        cvFree( &sorted_weights );
-    }
-
-    __END__;
-
-    return ptr;
-}
-
-
-CV_BOOST_IMPL
-void cvReadTrainData( const char* filename, int flags,
-                      CvMat** trainData,
-                      CvMat** trainClasses )
-{
-
-    CV_FUNCNAME( "cvReadTrainData" );
-
-    __BEGIN__;
-
-    FILE* file;
-    int m, n;
-    int i, j;
-    float val;
-    int values_read = -1;
-
-    if( filename == NULL )
-    {
-        CV_ERROR( CV_StsNullPtr, "filename must be specified" );
-    }
-    if( trainData == NULL )
-    {
-        CV_ERROR( CV_StsNullPtr, "trainData must be not NULL" );
-    }
-    if( trainClasses == NULL )
-    {
-        CV_ERROR( CV_StsNullPtr, "trainClasses must be not NULL" );
-    }
-
-    *trainData = NULL;
-    *trainClasses = NULL;
-    file = fopen( filename, "r" );
-    if( !file )
-    {
-        CV_ERROR( CV_StsError, "Unable to open file" );
-    }
-
-    values_read = fscanf( file, "%d %d", &m, &n );
-    CV_Assert(values_read == 2);
-
-    if( CV_IS_ROW_SAMPLE( flags ) )
-    {
-        CV_CALL( *trainData = cvCreateMat( m, n, CV_32FC1 ) );
-    }
-    else
-    {
-        CV_CALL( *trainData = cvCreateMat( n, m, CV_32FC1 ) );
-    }
-
-    CV_CALL( *trainClasses = cvCreateMat( 1, m, CV_32FC1 ) );
-
-    for( i = 0; i < m; i++ )
-    {
-        for( j = 0; j < n; j++ )
-        {
-            values_read = fscanf( file, "%f", &val );
-            CV_Assert(values_read == 1);
-            if( CV_IS_ROW_SAMPLE( flags ) )
-            {
-                CV_MAT_ELEM( **trainData, float, i, j ) = val;
-            }
-            else
-            {
-                CV_MAT_ELEM( **trainData, float, j, i ) = val;
-            }
-        }
-        values_read = fscanf( file, "%f", &val );
-        CV_Assert(values_read == 2);
-        CV_MAT_ELEM( **trainClasses, float, 0, i ) = val;
-    }
-
-    fclose( file );
-
-    __END__;
-
-}
-
-CV_BOOST_IMPL
-void cvWriteTrainData( const char* filename, int flags,
-                       CvMat* trainData, CvMat* trainClasses, CvMat* sampleIdx )
-{
-    CV_FUNCNAME( "cvWriteTrainData" );
-
-    __BEGIN__;
-
-    FILE* file;
-    int m, n;
-    int i, j;
-    int clsrow;
-    int count;
-    int idx;
-    CvScalar sc;
-
-    if( filename == NULL )
-    {
-        CV_ERROR( CV_StsNullPtr, "filename must be specified" );
-    }
-    if( trainData == NULL || CV_MAT_TYPE( trainData->type ) != CV_32FC1 )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Invalid trainData" );
-    }
-    if( CV_IS_ROW_SAMPLE( flags ) )
-    {
-        m = trainData->rows;
-        n = trainData->cols;
-    }
-    else
-    {
-        n = trainData->rows;
-        m = trainData->cols;
-    }
-    if( trainClasses == NULL || CV_MAT_TYPE( trainClasses->type ) != CV_32FC1 ||
-        MIN( trainClasses->rows, trainClasses->cols ) != 1 )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Invalid trainClasses" );
-    }
-    clsrow = (trainClasses->rows == 1);
-    if( m != ( (clsrow) ? trainClasses->cols : trainClasses->rows ) )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Incorrect trainData and trainClasses sizes" );
-    }
-
-    if( sampleIdx != NULL )
-    {
-        count = (sampleIdx->rows == 1) ? sampleIdx->cols : sampleIdx->rows;
-    }
-    else
-    {
-        count = m;
-    }
-
-
-    file = fopen( filename, "w" );
-    if( !file )
-    {
-        CV_ERROR( CV_StsError, "Unable to create file" );
-    }
-
-    fprintf( file, "%d %d\n", count, n );
-
-    for( i = 0; i < count; i++ )
-    {
-        if( sampleIdx )
-        {
-            if( sampleIdx->rows == 1 )
-            {
-                sc = cvGet2D( sampleIdx, 0, i );
-            }
-            else
-            {
-                sc = cvGet2D( sampleIdx, i, 0 );
-            }
-            idx = (int) sc.val[0];
-        }
-        else
-        {
-            idx = i;
-        }
-        for( j = 0; j < n; j++ )
-        {
-            fprintf( file, "%g ", ( (CV_IS_ROW_SAMPLE( flags ))
-                                    ? CV_MAT_ELEM( *trainData, float, idx, j )
-                                    : CV_MAT_ELEM( *trainData, float, j, idx ) ) );
-        }
-        fprintf( file, "%g\n", ( (clsrow)
-                                ? CV_MAT_ELEM( *trainClasses, float, 0, idx )
-                                : CV_MAT_ELEM( *trainClasses, float, idx, 0 ) ) );
-    }
-
-    fclose( file );
-
-    __END__;
-}
-
-
-#define ICV_RAND_SHUFFLE( suffix, type )                                                 \
-static void icvRandShuffle_##suffix( uchar* data, size_t step, int num )                 \
-{                                                                                        \
-    time_t seed;                                                                         \
-    type tmp;                                                                            \
-    int i;                                                                               \
-    float rn;                                                                            \
-                                                                                         \
-    time( &seed );                                                                       \
-    CvRNG state = cvRNG((int)seed);                                                      \
-                                                                                         \
-    for( i = 0; i < (num-1); i++ )                                                       \
-    {                                                                                    \
-        rn = ((float) cvRandInt( &state )) / (1.0F + UINT_MAX);                          \
-        CV_SWAP( *((type*)(data + i * step)),                                            \
-                 *((type*)(data + ( i + (int)( rn * (num - i ) ) )* step)),              \
-                 tmp );                                                                  \
-    }                                                                                    \
-}
-
-ICV_RAND_SHUFFLE( 8U, uchar )
-
-ICV_RAND_SHUFFLE( 16S, short )
-
-ICV_RAND_SHUFFLE( 32S, int )
-
-ICV_RAND_SHUFFLE( 32F, float )
-
-CV_BOOST_IMPL
-void cvRandShuffleVec( CvMat* mat )
-{
-    CV_FUNCNAME( "cvRandShuffle" );
-
-    __BEGIN__;
-
-    uchar* data;
-    size_t step;
-    int num;
-
-    if( (mat == NULL) || !CV_IS_MAT( mat ) || MIN( mat->rows, mat->cols ) != 1 )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "" );
-    }
-
-    CV_MAT2VEC( *mat, data, step, num );
-    switch( CV_MAT_TYPE( mat->type ) )
-    {
-        case CV_8UC1:
-            icvRandShuffle_8U( data, step, num);
-            break;
-        case CV_16SC1:
-            icvRandShuffle_16S( data, step, num);
-            break;
-        case CV_32SC1:
-            icvRandShuffle_32S( data, step, num);
-            break;
-        case CV_32FC1:
-            icvRandShuffle_32F( data, step, num);
-            break;
-        default:
-            CV_ERROR( CV_StsUnsupportedFormat, "" );
-    }
-
-    __END__;
-}
-
-/* End of file. */
diff --git a/apps/haartraining/cvclassifier.h b/apps/haartraining/cvclassifier.h
deleted file mode 100644 (file)
index c1ae7f5..0000000
+++ /dev/null
@@ -1,729 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
- * File cvclassifier.h
- *
- * Classifier types
- */
-
-#ifndef _CVCLASSIFIER_H_
-#define _CVCLASSIFIER_H_
-
-#include <cmath>
-#include "cxcore.h"
-
-#define CV_BOOST_API
-
-/* Convert matrix to vector */
-#define CV_MAT2VEC( mat, vdata, vstep, num )       \
-    assert( (mat).rows == 1 || (mat).cols == 1 );  \
-    (vdata) = ((mat).data.ptr);                    \
-    if( (mat).rows == 1 )                          \
-    {                                              \
-        (vstep) = CV_ELEM_SIZE( (mat).type );      \
-        (num) = (mat).cols;                        \
-    }                                              \
-    else                                           \
-    {                                              \
-        (vstep) = (mat).step;                      \
-        (num) = (mat).rows;                        \
-    }
-
-/* Set up <sample> matrix header to be <num> sample of <trainData> samples matrix */
-#define CV_GET_SAMPLE( trainData, tdflags, num, sample )                                 \
-if( CV_IS_ROW_SAMPLE( tdflags ) )                                                        \
-{                                                                                        \
-    cvInitMatHeader( &(sample), 1, (trainData).cols,                                     \
-                     CV_MAT_TYPE( (trainData).type ),                                    \
-                     ((trainData).data.ptr + (num) * (trainData).step),                  \
-                     (trainData).step );                                                 \
-}                                                                                        \
-else                                                                                     \
-{                                                                                        \
-    cvInitMatHeader( &(sample), (trainData).rows, 1,                                     \
-                     CV_MAT_TYPE( (trainData).type ),                                    \
-                     ((trainData).data.ptr + (num) * CV_ELEM_SIZE( (trainData).type )),  \
-                     (trainData).step );                                                 \
-}
-
-#define CV_GET_SAMPLE_STEP( trainData, tdflags, sstep )                                  \
-(sstep) = ( ( CV_IS_ROW_SAMPLE( tdflags ) )                                              \
-           ? (trainData).step : CV_ELEM_SIZE( (trainData).type ) );
-
-
-#define CV_LOGRATIO_THRESHOLD 0.00001F
-
-/* log( val / (1 - val ) ) */
-CV_INLINE float cvLogRatio( float val );
-
-CV_INLINE float cvLogRatio( float val )
-{
-    float tval;
-
-    tval = MAX(CV_LOGRATIO_THRESHOLD, MIN( 1.0F - CV_LOGRATIO_THRESHOLD, (val) ));
-    return logf( tval / (1.0F - tval) );
-}
-
-
-/* flags values for classifier consturctor flags parameter */
-
-/* each trainData matrix column is a sample */
-#define CV_COL_SAMPLE 0
-
-/* each trainData matrix row is a sample */
-#define CV_ROW_SAMPLE 1
-
-#ifndef CV_IS_ROW_SAMPLE
-#  define CV_IS_ROW_SAMPLE( flags ) ( ( flags ) & CV_ROW_SAMPLE )
-#endif
-
-/* Classifier supports tune function */
-#define CV_TUNABLE    (1 << 1)
-
-#define CV_IS_TUNABLE( flags ) ( (flags) & CV_TUNABLE )
-
-
-/* classifier fields common to all classifiers */
-#define CV_CLASSIFIER_FIELDS()                                                           \
-    int flags;                                                                           \
-    float(*eval)( struct CvClassifier*, CvMat* );                                        \
-    void (*tune)( struct CvClassifier*, CvMat*, int flags, CvMat*, CvMat*, CvMat*,       \
-                  CvMat*, CvMat* );                                                      \
-    int  (*save)( struct CvClassifier*, const char* file_name );                         \
-    void (*release)( struct CvClassifier** );
-
-typedef struct CvClassifier
-{
-    CV_CLASSIFIER_FIELDS()
-} CvClassifier;
-
-#define CV_CLASSIFIER_TRAIN_PARAM_FIELDS()
-typedef struct CvClassifierTrainParams
-{
-    CV_CLASSIFIER_TRAIN_PARAM_FIELDS()
-} CvClassifierTrainParams;
-
-
-/*
- Common classifier constructor:
- CvClassifier* cvCreateMyClassifier( CvMat* trainData,
-                     int flags,
-                     CvMat* trainClasses,
-                     CvMat* typeMask,
-                      CvMat* missedMeasurementsMask CV_DEFAULT(0),
-                      CvCompIdx* compIdx CV_DEFAULT(0),
-                      CvMat* sampleIdx CV_DEFAULT(0),
-                      CvMat* weights CV_DEFAULT(0),
-                      CvClassifierTrainParams* trainParams CV_DEFAULT(0)
-                    )
-
- */
-
-typedef CvClassifier* (*CvClassifierConstructor)( CvMat*, int, CvMat*, CvMat*, CvMat*,
-                                                  CvMat*, CvMat*, CvMat*,
-                                                  CvClassifierTrainParams* );
-
-typedef enum CvStumpType
-{
-    CV_CLASSIFICATION       = 0,
-    CV_CLASSIFICATION_CLASS = 1,
-    CV_REGRESSION           = 2
-} CvStumpType;
-
-typedef enum CvStumpError
-{
-    CV_MISCLASSIFICATION = 0,
-    CV_GINI              = 1,
-    CV_ENTROPY           = 2,
-    CV_SQUARE            = 3
-} CvStumpError;
-
-
-typedef struct CvStumpTrainParams
-{
-    CV_CLASSIFIER_TRAIN_PARAM_FIELDS()
-    CvStumpType  type;
-    CvStumpError error;
-} CvStumpTrainParams;
-
-typedef struct CvMTStumpTrainParams
-{
-    CV_CLASSIFIER_TRAIN_PARAM_FIELDS()
-    CvStumpType  type;
-    CvStumpError error;
-    int portion; /* number of components calculated in each thread */
-    int numcomp; /* total number of components */
-
-    /* callback which fills <mat> with components [first, first+num[ */
-    void (*getTrainData)( CvMat* mat, CvMat* sampleIdx, CvMat* compIdx,
-                          int first, int num, void* userdata );
-    CvMat* sortedIdx; /* presorted samples indices */
-    void* userdata; /* passed to callback */
-} CvMTStumpTrainParams;
-
-typedef struct CvStumpClassifier
-{
-    CV_CLASSIFIER_FIELDS()
-    int compidx;
-
-    float lerror; /* impurity of the right node */
-    float rerror; /* impurity of the left  node */
-
-    float threshold;
-    float left;
-    float right;
-} CvStumpClassifier;
-
-typedef struct CvCARTTrainParams
-{
-    CV_CLASSIFIER_TRAIN_PARAM_FIELDS()
-    /* desired number of internal nodes */
-    int count;
-    CvClassifierTrainParams* stumpTrainParams;
-    CvClassifierConstructor  stumpConstructor;
-
-    /*
-     * Split sample indices <idx>
-     * on the "left" indices <left> and "right" indices <right>
-     * according to samples components <compidx> values and <threshold>.
-     *
-     * NOTE: Matrices <left> and <right> must be allocated using cvCreateMat function
-     *   since they are freed using cvReleaseMat function
-     *
-     * If it is NULL then the default implementation which evaluates training
-     * samples from <trainData> passed to classifier constructor is used
-     */
-    void (*splitIdx)( int compidx, float threshold,
-                      CvMat* idx, CvMat** left, CvMat** right,
-                      void* userdata );
-    void* userdata;
-} CvCARTTrainParams;
-
-typedef struct CvCARTClassifier
-{
-    CV_CLASSIFIER_FIELDS()
-    /* number of internal nodes */
-    int count;
-
-    /* internal nodes (each array of <count> elements) */
-    int* compidx;
-    float* threshold;
-    int* left;
-    int* right;
-
-    /* leaves (array of <count>+1 elements) */
-    float* val;
-} CvCARTClassifier;
-
-CV_BOOST_API
-void cvGetSortedIndices( CvMat* val, CvMat* idx, int sortcols CV_DEFAULT( 0 ) );
-
-CV_BOOST_API
-void cvReleaseStumpClassifier( CvClassifier** classifier );
-
-CV_BOOST_API
-float cvEvalStumpClassifier( CvClassifier* classifier, CvMat* sample );
-
-CV_BOOST_API
-CvClassifier* cvCreateStumpClassifier( CvMat* trainData,
-                                       int flags,
-                                       CvMat* trainClasses,
-                                       CvMat* typeMask,
-                                       CvMat* missedMeasurementsMask CV_DEFAULT(0),
-                                       CvMat* compIdx CV_DEFAULT(0),
-                                       CvMat* sampleIdx CV_DEFAULT(0),
-                                       CvMat* weights CV_DEFAULT(0),
-                                       CvClassifierTrainParams* trainParams CV_DEFAULT(0) );
-
-/*
- * cvCreateMTStumpClassifier
- *
- * Multithreaded stump classifier constructor
- * Includes huge train data support through callback function
- */
-CV_BOOST_API
-CvClassifier* cvCreateMTStumpClassifier( CvMat* trainData,
-                                         int flags,
-                                         CvMat* trainClasses,
-                                         CvMat* typeMask,
-                                         CvMat* missedMeasurementsMask,
-                                         CvMat* compIdx,
-                                         CvMat* sampleIdx,
-                                         CvMat* weights,
-                                         CvClassifierTrainParams* trainParams );
-
-/*
- * cvCreateCARTClassifier
- *
- * CART classifier constructor
- */
-CV_BOOST_API
-CvClassifier* cvCreateCARTClassifier( CvMat* trainData,
-                                      int flags,
-                                      CvMat* trainClasses,
-                                      CvMat* typeMask,
-                                      CvMat* missedMeasurementsMask,
-                                      CvMat* compIdx,
-                                      CvMat* sampleIdx,
-                                      CvMat* weights,
-                                      CvClassifierTrainParams* trainParams );
-
-CV_BOOST_API
-void cvReleaseCARTClassifier( CvClassifier** classifier );
-
-CV_BOOST_API
-float cvEvalCARTClassifier( CvClassifier* classifier, CvMat* sample );
-
-/****************************************************************************************\
-*                                        Boosting                                        *
-\****************************************************************************************/
-
-/*
- * CvBoostType
- *
- * The CvBoostType enumeration specifies the boosting type.
- *
- * Remarks
- *   Four different boosting variants for 2 class classification problems are supported:
- *   Discrete AdaBoost, Real AdaBoost, LogitBoost and Gentle AdaBoost.
- *   The L2 (2 class classification problems) and LK (K class classification problems)
- *   algorithms are close to LogitBoost but more numerically stable than last one.
- *   For regression three different loss functions are supported:
- *   Least square, least absolute deviation and huber loss.
- */
-typedef enum CvBoostType
-{
-    CV_DABCLASS = 0, /* 2 class Discrete AdaBoost           */
-    CV_RABCLASS = 1, /* 2 class Real AdaBoost               */
-    CV_LBCLASS  = 2, /* 2 class LogitBoost                  */
-    CV_GABCLASS = 3, /* 2 class Gentle AdaBoost             */
-    CV_L2CLASS  = 4, /* classification (2 class problem)    */
-    CV_LKCLASS  = 5, /* classification (K class problem)    */
-    CV_LSREG    = 6, /* least squares regression            */
-    CV_LADREG   = 7, /* least absolute deviation regression */
-    CV_MREG     = 8  /* M-regression (Huber loss)           */
-} CvBoostType;
-
-/****************************************************************************************\
-*                             Iterative training functions                               *
-\****************************************************************************************/
-
-/*
- * CvBoostTrainer
- *
- * The CvBoostTrainer structure represents internal boosting trainer.
- */
-typedef struct CvBoostTrainer CvBoostTrainer;
-
-/*
- * cvBoostStartTraining
- *
- * The cvBoostStartTraining function starts training process and calculates
- * response values and weights for the first weak classifier training.
- *
- * Parameters
- *   trainClasses
- *     Vector of classes of training samples classes. Each element must be 0 or 1 and
- *     of type CV_32FC1.
- *   weakTrainVals
- *     Vector of response values for the first trained weak classifier.
- *     Must be of type CV_32FC1.
- *   weights
- *     Weight vector of training samples for the first trained weak classifier.
- *     Must be of type CV_32FC1.
- *   type
- *     Boosting type. CV_DABCLASS, CV_RABCLASS, CV_LBCLASS, CV_GABCLASS
- *     types are supported.
- *
- * Return Values
- *   The return value is a pointer to internal trainer structure which is used
- *   to perform next training iterations.
- *
- * Remarks
- *   weakTrainVals and weights must be allocated before calling the function
- *   and of the same size as trainingClasses. Usually weights should be initialized
- *   with 1.0 value.
- *   The function calculates response values and weights for the first weak
- *   classifier training and stores them into weakTrainVals and weights
- *   respectively.
- *   Note, the training of the weak classifier using weakTrainVals, weight,
- *   trainingData is outside of this function.
- */
-CV_BOOST_API
-CvBoostTrainer* cvBoostStartTraining( CvMat* trainClasses,
-                                      CvMat* weakTrainVals,
-                                      CvMat* weights,
-                                      CvMat* sampleIdx,
-                                      CvBoostType type );
-/*
- * cvBoostNextWeakClassifier
- *
- * The cvBoostNextWeakClassifier function performs next training
- * iteration and caluclates response values and weights for the next weak
- * classifier training.
- *
- * Parameters
- *   weakEvalVals
- *     Vector of values obtained by evaluation of each sample with
- *     the last trained weak classifier (iteration i). Must be of CV_32FC1 type.
- *   trainClasses
- *     Vector of classes of training samples. Each element must be 0 or 1,
- *     and of type CV_32FC1.
- *   weakTrainVals
- *     Vector of response values for the next weak classifier training
- *     (iteration i+1). Must be of type CV_32FC1.
- *   weights
- *     Weight vector of training samples for the next weak classifier training
- *     (iteration i+1). Must be of type CV_32FC1.
- *   trainer
- *     A pointer to internal trainer returned by the cvBoostStartTraining
- *     function call.
- *
- * Return Values
- *   The return value is the coefficient for the last trained weak classifier.
- *
- * Remarks
- *   weakTrainVals and weights must be exactly the same vectors as used in
- *   the cvBoostStartTraining function call and should not be modified.
- *   The function calculates response values and weights for the next weak
- *   classifier training and stores them into weakTrainVals and weights
- *   respectively.
- *   Note, the training of the weak classifier of iteration i+1 using
- *   weakTrainVals, weight, trainingData is outside of this function.
- */
-CV_BOOST_API
-float cvBoostNextWeakClassifier( CvMat* weakEvalVals,
-                                 CvMat* trainClasses,
-                                 CvMat* weakTrainVals,
-                                 CvMat* weights,
-                                 CvBoostTrainer* trainer );
-
-/*
- * cvBoostEndTraining
- *
- * The cvBoostEndTraining function finishes training process and releases
- * internally allocated memory.
- *
- * Parameters
- *   trainer
- *     A pointer to a pointer to internal trainer returned by the cvBoostStartTraining
- *     function call.
- */
-CV_BOOST_API
-void cvBoostEndTraining( CvBoostTrainer** trainer );
-
-/****************************************************************************************\
-*                                    Boosted tree models                                 *
-\****************************************************************************************/
-
-/*
- * CvBtClassifier
- *
- * The CvBtClassifier structure represents boosted tree model.
- *
- * Members
- *   flags
- *     Flags. If CV_IS_TUNABLE( flags ) != 0 then the model supports tuning.
- *   eval
- *     Evaluation function. Returns sample predicted class (0, 1, etc.)
- *     for classification or predicted value for regression.
- *   tune
- *     Tune function. If the model supports tuning then tune call performs
- *     one more boosting iteration if passed to the function flags parameter
- *     is CV_TUNABLE otherwise releases internally allocated for tuning memory
- *     and makes the model untunable.
- *     NOTE: Since tuning uses the pointers to parameters,
- *     passed to the cvCreateBtClassifier function, they should not be modified
- *     or released between tune calls.
- *   save
- *     This function stores the model into given file.
- *   release
- *     This function releases the model.
- *   type
- *     Boosted tree model type.
- *   numclasses
- *     Number of classes for CV_LKCLASS type or 1 for all other types.
- *   numiter
- *     Number of iterations. Number of weak classifiers is equal to number
- *     of iterations for all types except CV_LKCLASS. For CV_LKCLASS type
- *     number of weak classifiers is (numiter * numclasses).
- *   numfeatures
- *     Number of features in sample.
- *   trees
- *     Stores weak classifiers when the model does not support tuning.
- *   seq
- *     Stores weak classifiers when the model supports tuning.
- *   trainer
- *     Pointer to internal tuning parameters if the model supports tuning.
- */
-typedef struct CvBtClassifier
-{
-    CV_CLASSIFIER_FIELDS()
-
-    CvBoostType type;
-    int numclasses;
-    int numiter;
-    int numfeatures;
-    union
-    {
-        CvCARTClassifier** trees;
-        CvSeq* seq;
-    };
-    void* trainer;
-} CvBtClassifier;
-
-/*
- * CvBtClassifierTrainParams
- *
- * The CvBtClassifierTrainParams structure stores training parameters for
- * boosted tree model.
- *
- * Members
- *   type
- *     Boosted tree model type.
- *   numiter
- *     Desired number of iterations.
- *   param
- *     Parameter   Model Type    Parameter Meaning
- *     param[0]    Any           Shrinkage factor
- *     param[1]    CV_MREG       alpha. (1-alpha) determines "break-down" point of
- *                               the training procedure, i.e. the fraction of samples
- *                               that can be arbitrary modified without serious
- *                               degrading the quality of the result.
- *                 CV_DABCLASS,  Weight trimming factor.
- *                 CV_RABCLASS,
- *                 CV_LBCLASS,
- *                 CV_GABCLASS,
- *                 CV_L2CLASS,
- *                 CV_LKCLASS
- *   numsplits
- *     Desired number of splits in each tree.
- */
-typedef struct CvBtClassifierTrainParams
-{
-    CV_CLASSIFIER_TRAIN_PARAM_FIELDS()
-
-    CvBoostType type;
-    int numiter;
-    float param[2];
-    int numsplits;
-} CvBtClassifierTrainParams;
-
-/*
- * cvCreateBtClassifier
- *
- * The cvCreateBtClassifier function creates boosted tree model.
- *
- * Parameters
- *   trainData
- *     Matrix of feature values. Must have CV_32FC1 type.
- *   flags
- *     Determines how samples are stored in trainData.
- *     One of CV_ROW_SAMPLE or CV_COL_SAMPLE.
- *     Optionally may be combined with CV_TUNABLE to make tunable model.
- *   trainClasses
- *     Vector of responses for regression or classes (0, 1, 2, etc.) for classification.
- *   typeMask,
- *   missedMeasurementsMask,
- *   compIdx
- *     Not supported. Must be NULL.
- *   sampleIdx
- *     Indices of samples used in training. If NULL then all samples are used.
- *     For CV_DABCLASS, CV_RABCLASS, CV_LBCLASS and CV_GABCLASS must be NULL.
- *   weights
- *     Not supported. Must be NULL.
- *   trainParams
- *     A pointer to CvBtClassifierTrainParams structure. Training parameters.
- *     See CvBtClassifierTrainParams description for details.
- *
- * Return Values
- *   The return value is a pointer to created boosted tree model of type CvBtClassifier.
- *
- * Remarks
- *     The function performs trainParams->numiter training iterations.
- *     If CV_TUNABLE flag is specified then created model supports tuning.
- *     In this case additional training iterations may be performed by
- *     tune function call.
- */
-CV_BOOST_API
-CvClassifier* cvCreateBtClassifier( CvMat* trainData,
-                                    int flags,
-                                    CvMat* trainClasses,
-                                    CvMat* typeMask,
-                                    CvMat* missedMeasurementsMask,
-                                    CvMat* compIdx,
-                                    CvMat* sampleIdx,
-                                    CvMat* weights,
-                                    CvClassifierTrainParams* trainParams );
-
-/*
- * cvCreateBtClassifierFromFile
- *
- * The cvCreateBtClassifierFromFile function restores previously saved
- * boosted tree model from file.
- *
- * Parameters
- *   filename
- *     The name of the file with boosted tree model.
- *
- * Remarks
- *   The restored model does not support tuning.
- */
-CV_BOOST_API
-CvClassifier* cvCreateBtClassifierFromFile( const char* filename );
-
-/****************************************************************************************\
-*                                    Utility functions                                   *
-\****************************************************************************************/
-
-/*
- * cvTrimWeights
- *
- * The cvTrimWeights function performs weight trimming.
- *
- * Parameters
- *   weights
- *     Weights vector.
- *   idx
- *     Indices vector of weights that should be considered.
- *     If it is NULL then all weights are used.
- *   factor
- *     Weight trimming factor. Must be in [0, 1] range.
- *
- * Return Values
- *   The return value is a vector of indices. If all samples should be used then
- *   it is equal to idx. In other case the cvReleaseMat function should be called
- *   to release it.
- *
- * Remarks
- */
-CV_BOOST_API
-CvMat* cvTrimWeights( CvMat* weights, CvMat* idx, float factor );
-
-/*
- * cvReadTrainData
- *
- * The cvReadTrainData function reads feature values and responses from file.
- *
- * Parameters
- *   filename
- *     The name of the file to be read.
- *   flags
- *     One of CV_ROW_SAMPLE or CV_COL_SAMPLE. Determines how feature values
- *     will be stored.
- *   trainData
- *     A pointer to a pointer to created matrix with feature values.
- *     cvReleaseMat function should be used to destroy created matrix.
- *   trainClasses
- *     A pointer to a pointer to created matrix with response values.
- *     cvReleaseMat function should be used to destroy created matrix.
- *
- * Remarks
- *   File format:
- *   ============================================
- *   m n
- *   value_1_1 value_1_2 ... value_1_n response_1
- *   value_2_1 value_2_2 ... value_2_n response_2
- *   ...
- *   value_m_1 value_m_2 ... value_m_n response_m
- *   ============================================
- *   m
- *     Number of samples
- *   n
- *     Number of features in each sample
- *   value_i_j
- *     Value of j-th feature of i-th sample
- *   response_i
- *     Response value of i-th sample
- *     For classification problems responses represent classes (0, 1, etc.)
- *   All values and classes are integer or real numbers.
- */
-CV_BOOST_API
-void cvReadTrainData( const char* filename,
-                      int flags,
-                      CvMat** trainData,
-                      CvMat** trainClasses );
-
-
-/*
- * cvWriteTrainData
- *
- * The cvWriteTrainData function stores feature values and responses into file.
- *
- * Parameters
- *   filename
- *     The name of the file.
- *   flags
- *     One of CV_ROW_SAMPLE or CV_COL_SAMPLE. Determines how feature values
- *     are stored.
- *   trainData
- *     Feature values matrix.
- *   trainClasses
- *     Response values vector.
- *   sampleIdx
- *     Vector of idicies of the samples that should be stored. If it is NULL
- *     then all samples will be stored.
- *
- * Remarks
- *   See the cvReadTrainData function for file format description.
- */
-CV_BOOST_API
-void cvWriteTrainData( const char* filename,
-                       int flags,
-                       CvMat* trainData,
-                       CvMat* trainClasses,
-                       CvMat* sampleIdx );
-
-/*
- * cvRandShuffle
- *
- * The cvRandShuffle function perfroms random shuffling of given vector.
- *
- * Parameters
- *   vector
- *     Vector that should be shuffled.
- *     Must have CV_8UC1, CV_16SC1, CV_32SC1 or CV_32FC1 type.
- */
-CV_BOOST_API
-void cvRandShuffleVec( CvMat* vector );
-
-#endif /* _CVCLASSIFIER_H_ */
diff --git a/apps/haartraining/cvcommon.cpp b/apps/haartraining/cvcommon.cpp
deleted file mode 100644 (file)
index e23fab2..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "_cvcommon.h"
-
-#include <cstring>
-#include <ctime>
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#ifdef _WIN32
-#include <direct.h>
-#endif /* _WIN32 */
-
-int icvMkDir( const char* filename )
-{
-    char path[PATH_MAX];
-    char* p;
-    int pos;
-
-#ifdef _WIN32
-    struct _stat st;
-#else /* _WIN32 */
-    struct stat st;
-    mode_t mode;
-
-    mode = 0755;
-#endif /* _WIN32 */
-
-    strcpy( path, filename );
-
-    p = path;
-    for( ; ; )
-    {
-        pos = (int)strcspn( p, "/\\" );
-
-        if( pos == (int) strlen( p ) ) break;
-        if( pos != 0 )
-        {
-            p[pos] = '\0';
-
-#ifdef _WIN32
-            if( p[pos-1] != ':' )
-            {
-                if( _stat( path, &st ) != 0 )
-                {
-                    if( _mkdir( path ) != 0 ) return 0;
-                }
-            }
-#else /* _WIN32 */
-            if( stat( path, &st ) != 0 )
-            {
-                if( mkdir( path, mode ) != 0 ) return 0;
-            }
-#endif /* _WIN32 */
-        }
-
-        p[pos] = '/';
-
-        p += pos + 1;
-    }
-
-    return 1;
-}
-
-#if 0
-/* debug functions */
-void icvSave( const CvArr* ptr, const char* filename, int line )
-{
-    CvFileStorage* fs;
-    char buf[PATH_MAX];
-    const char* name;
-
-    name = strrchr( filename, '\\' );
-    if( !name ) name = strrchr( filename, '/' );
-    if( !name ) name = filename;
-    else name++; /* skip '/' or '\\' */
-
-    sprintf( buf, "%s-%d-%d", name, line, time( NULL ) );
-    fs = cvOpenFileStorage( buf, NULL, CV_STORAGE_WRITE_TEXT );
-    if( !fs ) return;
-    cvWrite( fs, "debug", ptr );
-    cvReleaseFileStorage( &fs );
-}
-#endif // #if 0
-
-/* End of file. */
diff --git a/apps/haartraining/cvhaarclassifier.cpp b/apps/haartraining/cvhaarclassifier.cpp
deleted file mode 100644 (file)
index f217976..0000000
+++ /dev/null
@@ -1,835 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
- * cvhaarclassifier.cpp
- *
- * haar classifiers (stump, CART, stage, cascade)
- */
-
-#include "_cvhaartraining.h"
-
-
-CvIntHaarClassifier* icvCreateCARTHaarClassifier( int count )
-{
-    CvCARTHaarClassifier* cart;
-    size_t datasize;
-
-    datasize = sizeof( *cart ) +
-        ( sizeof( int ) +
-          sizeof( CvTHaarFeature ) + sizeof( CvFastHaarFeature ) +
-          sizeof( float ) + sizeof( int ) + sizeof( int ) ) * count +
-        sizeof( float ) * (count + 1);
-
-    cart = (CvCARTHaarClassifier*) cvAlloc( datasize );
-    memset( cart, 0, datasize );
-
-    cart->feature = (CvTHaarFeature*) (cart + 1);
-    cart->fastfeature = (CvFastHaarFeature*) (cart->feature + count);
-    cart->threshold = (float*) (cart->fastfeature + count);
-    cart->left = (int*) (cart->threshold + count);
-    cart->right = (int*) (cart->left + count);
-    cart->val = (float*) (cart->right + count);
-    cart->compidx = (int*) (cart->val + count + 1 );
-    cart->count = count;
-    cart->eval = icvEvalCARTHaarClassifier;
-    cart->save = icvSaveCARTHaarClassifier;
-    cart->release = icvReleaseHaarClassifier;
-
-    return (CvIntHaarClassifier*) cart;
-}
-
-
-void icvReleaseHaarClassifier( CvIntHaarClassifier** classifier )
-{
-    cvFree( classifier );
-    *classifier = NULL;
-}
-
-
-void icvInitCARTHaarClassifier( CvCARTHaarClassifier* carthaar, CvCARTClassifier* cart,
-                                CvIntHaarFeatures* intHaarFeatures )
-{
-    int i;
-
-    for( i = 0; i < cart->count; i++ )
-    {
-        carthaar->feature[i] = intHaarFeatures->feature[cart->compidx[i]];
-        carthaar->fastfeature[i] = intHaarFeatures->fastfeature[cart->compidx[i]];
-        carthaar->threshold[i] = cart->threshold[i];
-        carthaar->left[i] = cart->left[i];
-        carthaar->right[i] = cart->right[i];
-        carthaar->val[i] = cart->val[i];
-        carthaar->compidx[i] = cart->compidx[i];
-    }
-    carthaar->count = cart->count;
-    carthaar->val[cart->count] = cart->val[cart->count];
-}
-
-
-float icvEvalCARTHaarClassifier( CvIntHaarClassifier* classifier,
-                                 sum_type* sum, sum_type* tilted, float normfactor )
-{
-    int idx = 0;
-
-    do
-    {
-        if( cvEvalFastHaarFeature(
-                ((CvCARTHaarClassifier*) classifier)->fastfeature + idx, sum, tilted )
-              < (((CvCARTHaarClassifier*) classifier)->threshold[idx] * normfactor) )
-        {
-            idx = ((CvCARTHaarClassifier*) classifier)->left[idx];
-        }
-        else
-        {
-            idx = ((CvCARTHaarClassifier*) classifier)->right[idx];
-        }
-    } while( idx > 0 );
-
-    return ((CvCARTHaarClassifier*) classifier)->val[-idx];
-}
-
-
-CvIntHaarClassifier* icvCreateStageHaarClassifier( int count, float threshold )
-{
-    CvStageHaarClassifier* stage;
-    size_t datasize;
-
-    datasize = sizeof( *stage ) + sizeof( CvIntHaarClassifier* ) * count;
-    stage = (CvStageHaarClassifier*) cvAlloc( datasize );
-    memset( stage, 0, datasize );
-
-    stage->count = count;
-    stage->threshold = threshold;
-    stage->classifier = (CvIntHaarClassifier**) (stage + 1);
-
-    stage->eval = icvEvalStageHaarClassifier;
-    stage->save = icvSaveStageHaarClassifier;
-    stage->release = icvReleaseStageHaarClassifier;
-
-    return (CvIntHaarClassifier*) stage;
-}
-
-
-void icvReleaseStageHaarClassifier( CvIntHaarClassifier** classifier )
-{
-    int i;
-
-    for( i = 0; i < ((CvStageHaarClassifier*) *classifier)->count; i++ )
-    {
-        if( ((CvStageHaarClassifier*) *classifier)->classifier[i] != NULL )
-        {
-            ((CvStageHaarClassifier*) *classifier)->classifier[i]->release(
-                &(((CvStageHaarClassifier*) *classifier)->classifier[i]) );
-        }
-    }
-
-    cvFree( classifier );
-    *classifier = NULL;
-}
-
-
-float icvEvalStageHaarClassifier( CvIntHaarClassifier* classifier,
-                                  sum_type* sum, sum_type* tilted, float normfactor )
-{
-    int i;
-    float stage_sum;
-
-    stage_sum = 0.0F;
-    for( i = 0; i < ((CvStageHaarClassifier*) classifier)->count; i++ )
-    {
-        stage_sum +=
-            ((CvStageHaarClassifier*) classifier)->classifier[i]->eval(
-                ((CvStageHaarClassifier*) classifier)->classifier[i],
-                sum, tilted, normfactor );
-    }
-
-    return stage_sum;
-}
-
-
-CvIntHaarClassifier* icvCreateCascadeHaarClassifier( int count )
-{
-    CvCascadeHaarClassifier* ptr;
-    size_t datasize;
-
-    datasize = sizeof( *ptr ) + sizeof( CvIntHaarClassifier* ) * count;
-    ptr = (CvCascadeHaarClassifier*) cvAlloc( datasize );
-    memset( ptr, 0, datasize );
-
-    ptr->count = count;
-    ptr->classifier = (CvIntHaarClassifier**) (ptr + 1);
-
-    ptr->eval = icvEvalCascadeHaarClassifier;
-    ptr->save = NULL;
-    ptr->release = icvReleaseCascadeHaarClassifier;
-
-    return (CvIntHaarClassifier*) ptr;
-}
-
-
-void icvReleaseCascadeHaarClassifier( CvIntHaarClassifier** classifier )
-{
-    int i;
-
-    for( i = 0; i < ((CvCascadeHaarClassifier*) *classifier)->count; i++ )
-    {
-        if( ((CvCascadeHaarClassifier*) *classifier)->classifier[i] != NULL )
-        {
-            ((CvCascadeHaarClassifier*) *classifier)->classifier[i]->release(
-                &(((CvCascadeHaarClassifier*) *classifier)->classifier[i]) );
-        }
-    }
-
-    cvFree( classifier );
-    *classifier = NULL;
-}
-
-
-float icvEvalCascadeHaarClassifier( CvIntHaarClassifier* classifier,
-                                    sum_type* sum, sum_type* tilted, float normfactor )
-{
-    int i;
-
-    for( i = 0; i < ((CvCascadeHaarClassifier*) classifier)->count; i++ )
-    {
-        if( ((CvCascadeHaarClassifier*) classifier)->classifier[i]->eval(
-                    ((CvCascadeHaarClassifier*) classifier)->classifier[i],
-                    sum, tilted, normfactor )
-            < ( ((CvStageHaarClassifier*)
-                    ((CvCascadeHaarClassifier*) classifier)->classifier[i])->threshold
-                            - CV_THRESHOLD_EPS) )
-        {
-            return 0.0;
-        }
-    }
-
-    return 1.0;
-}
-
-
-void icvSaveHaarFeature( CvTHaarFeature* feature, FILE* file )
-{
-    fprintf( file, "%d\n", ( ( feature->rect[2].weight == 0.0F ) ? 2 : 3) );
-    fprintf( file, "%d %d %d %d %d %d\n",
-        feature->rect[0].r.x,
-        feature->rect[0].r.y,
-        feature->rect[0].r.width,
-        feature->rect[0].r.height,
-        0,
-        (int) (feature->rect[0].weight) );
-    fprintf( file, "%d %d %d %d %d %d\n",
-        feature->rect[1].r.x,
-        feature->rect[1].r.y,
-        feature->rect[1].r.width,
-        feature->rect[1].r.height,
-        0,
-        (int) (feature->rect[1].weight) );
-    if( feature->rect[2].weight != 0.0F )
-    {
-        fprintf( file, "%d %d %d %d %d %d\n",
-            feature->rect[2].r.x,
-            feature->rect[2].r.y,
-            feature->rect[2].r.width,
-            feature->rect[2].r.height,
-            0,
-            (int) (feature->rect[2].weight) );
-    }
-    fprintf( file, "%s\n", &(feature->desc[0]) );
-}
-
-
-void icvLoadHaarFeature( CvTHaarFeature* feature, FILE* file )
-{
-    int nrect;
-    int j;
-    int tmp;
-    int weight;
-
-    nrect = 0;
-    int values_read = fscanf( file, "%d", &nrect );
-    CV_Assert(values_read == 1);
-
-    assert( nrect <= CV_HAAR_FEATURE_MAX );
-
-    for( j = 0; j < nrect; j++ )
-    {
-        values_read = fscanf( file, "%d %d %d %d %d %d",
-            &(feature->rect[j].r.x),
-            &(feature->rect[j].r.y),
-            &(feature->rect[j].r.width),
-            &(feature->rect[j].r.height),
-            &tmp, &weight );
-        CV_Assert(values_read == 6);
-        feature->rect[j].weight = (float) weight;
-    }
-    for( j = nrect; j < CV_HAAR_FEATURE_MAX; j++ )
-    {
-        feature->rect[j].r.x = 0;
-        feature->rect[j].r.y = 0;
-        feature->rect[j].r.width = 0;
-        feature->rect[j].r.height = 0;
-        feature->rect[j].weight = 0.0f;
-    }
-    values_read = fscanf( file, "%s", &(feature->desc[0]) );
-    CV_Assert(values_read == 1);
-    feature->tilted = ( feature->desc[0] == 't' );
-}
-
-
-void icvSaveCARTHaarClassifier( CvIntHaarClassifier* classifier, FILE* file )
-{
-    int i;
-    int count;
-
-    count = ((CvCARTHaarClassifier*) classifier)->count;
-    fprintf( file, "%d\n", count );
-    for( i = 0; i < count; i++ )
-    {
-        icvSaveHaarFeature( &(((CvCARTHaarClassifier*) classifier)->feature[i]), file );
-        fprintf( file, "%e %d %d\n",
-            ((CvCARTHaarClassifier*) classifier)->threshold[i],
-            ((CvCARTHaarClassifier*) classifier)->left[i],
-            ((CvCARTHaarClassifier*) classifier)->right[i] );
-    }
-    for( i = 0; i <= count; i++ )
-    {
-        fprintf( file, "%e ", ((CvCARTHaarClassifier*) classifier)->val[i] );
-    }
-    fprintf( file, "\n" );
-}
-
-
-CvIntHaarClassifier* icvLoadCARTHaarClassifier( FILE* file, int step )
-{
-    CvCARTHaarClassifier* ptr;
-    int i;
-    int count;
-
-    ptr = NULL;
-    int values_read = fscanf( file, "%d", &count );
-    CV_Assert(values_read == 1);
-
-    if( count > 0 )
-    {
-        ptr = (CvCARTHaarClassifier*) icvCreateCARTHaarClassifier( count );
-        for( i = 0; i < count; i++ )
-        {
-            icvLoadHaarFeature( &(ptr->feature[i]), file );
-            values_read = fscanf( file, "%f %d %d", &(ptr->threshold[i]), &(ptr->left[i]),
-                                      &(ptr->right[i]) );
-            CV_Assert(values_read == 3);
-        }
-        for( i = 0; i <= count; i++ )
-        {
-            values_read = fscanf( file, "%f", &(ptr->val[i]) );
-            CV_Assert(values_read == 1);
-        }
-        icvConvertToFastHaarFeature( ptr->feature, ptr->fastfeature, ptr->count, step );
-    }
-
-    return (CvIntHaarClassifier*) ptr;
-}
-
-
-void icvSaveStageHaarClassifier( CvIntHaarClassifier* classifier, FILE* file )
-{
-    int count;
-    int i;
-    float threshold;
-
-    count = ((CvStageHaarClassifier*) classifier)->count;
-    fprintf( file, "%d\n", count );
-    for( i = 0; i < count; i++ )
-    {
-        ((CvStageHaarClassifier*) classifier)->classifier[i]->save(
-            ((CvStageHaarClassifier*) classifier)->classifier[i], file );
-    }
-
-    threshold = ((CvStageHaarClassifier*) classifier)->threshold;
-
-    /* to be compatible with the previous implementation */
-    /* threshold = 2.0F * ((CvStageHaarClassifier*) classifier)->threshold - count; */
-
-    fprintf( file, "%e\n", threshold );
-}
-
-
-
-static CvIntHaarClassifier* icvLoadCARTStageHaarClassifierF( FILE* file, int step )
-{
-    CvStageHaarClassifier* ptr = NULL;
-
-    //CV_FUNCNAME( "icvLoadCARTStageHaarClassifierF" );
-
-    __BEGIN__;
-
-    if( file != NULL )
-    {
-        int count;
-        int i;
-        float threshold;
-
-        count = 0;
-        int values_read = fscanf( file, "%d", &count );
-        CV_Assert(values_read == 1);
-        if( count > 0 )
-        {
-            ptr = (CvStageHaarClassifier*) icvCreateStageHaarClassifier( count, 0.0F );
-            for( i = 0; i < count; i++ )
-            {
-                ptr->classifier[i] = icvLoadCARTHaarClassifier( file, step );
-            }
-
-            values_read = fscanf( file, "%f", &threshold );
-            CV_Assert(values_read == 1);
-
-            ptr->threshold = threshold;
-            /* to be compatible with the previous implementation */
-            /* ptr->threshold = 0.5F * (threshold + count); */
-        }
-        if( feof( file ) )
-        {
-            ptr->release( (CvIntHaarClassifier**) &ptr );
-            ptr = NULL;
-        }
-    }
-
-    __END__;
-
-    return (CvIntHaarClassifier*) ptr;
-}
-
-
-CvIntHaarClassifier* icvLoadCARTStageHaarClassifier( const char* filename, int step )
-{
-    CvIntHaarClassifier* ptr = NULL;
-
-    CV_FUNCNAME( "icvLoadCARTStageHaarClassifier" );
-
-    __BEGIN__;
-
-    FILE* file;
-
-    file = fopen( filename, "r" );
-    if( file )
-    {
-        CV_CALL( ptr = icvLoadCARTStageHaarClassifierF( file, step ) );
-        fclose( file );
-    }
-
-    __END__;
-
-    return ptr;
-}
-
-/* tree cascade classifier */
-
-/* evaluates a tree cascade classifier */
-
-float icvEvalTreeCascadeClassifier( CvIntHaarClassifier* classifier,
-                                    sum_type* sum, sum_type* tilted, float normfactor )
-{
-    CvTreeCascadeNode* ptr;
-
-    ptr = ((CvTreeCascadeClassifier*) classifier)->root;
-
-    while( ptr )
-    {
-        if( ptr->stage->eval( (CvIntHaarClassifier*) ptr->stage,
-                              sum, tilted, normfactor )
-                >= ptr->stage->threshold - CV_THRESHOLD_EPS )
-        {
-            ptr = ptr->child;
-        }
-        else
-        {
-            while( ptr && ptr->next == NULL ) ptr = ptr->parent;
-            if( ptr == NULL ) return 0.0F;
-            ptr = ptr->next;
-        }
-    }
-
-    return 1.0F;
-}
-
-/* sets path int the tree form the root to the leaf node */
-
-void icvSetLeafNode( CvTreeCascadeClassifier* tcc, CvTreeCascadeNode* leaf )
-{
-    CV_FUNCNAME( "icvSetLeafNode" );
-
-    __BEGIN__;
-
-    CvTreeCascadeNode* ptr;
-
-    ptr = NULL;
-    while( leaf )
-    {
-        leaf->child_eval = ptr;
-        ptr = leaf;
-        leaf = leaf->parent;
-    }
-
-    leaf = tcc->root;
-    while( leaf && leaf != ptr ) leaf = leaf->next;
-    if( leaf != ptr )
-        CV_ERROR( CV_StsError, "Invalid tcc or leaf node." );
-
-    tcc->root_eval = ptr;
-
-    __END__;
-}
-
-/* evaluates a tree cascade classifier. used in filtering */
-
-float icvEvalTreeCascadeClassifierFilter( CvIntHaarClassifier* classifier, sum_type* sum,
-                                          sum_type* tilted, float normfactor )
-{
-    CvTreeCascadeNode* ptr;
-    //CvTreeCascadeClassifier* tree;
-
-    //tree = (CvTreeCascadeClassifier*) classifier;
-
-
-
-    ptr = ((CvTreeCascadeClassifier*) classifier)->root_eval;
-    while( ptr )
-    {
-        if( ptr->stage->eval( (CvIntHaarClassifier*) ptr->stage,
-                              sum, tilted, normfactor )
-                < ptr->stage->threshold - CV_THRESHOLD_EPS )
-        {
-            return 0.0F;
-        }
-        ptr = ptr->child_eval;
-    }
-
-    return 1.0F;
-}
-
-/* creates tree cascade node */
-
-CvTreeCascadeNode* icvCreateTreeCascadeNode()
-{
-    CvTreeCascadeNode* ptr = NULL;
-
-    CV_FUNCNAME( "icvCreateTreeCascadeNode" );
-
-    __BEGIN__;
-    size_t data_size;
-
-    data_size = sizeof( *ptr );
-    CV_CALL( ptr = (CvTreeCascadeNode*) cvAlloc( data_size ) );
-    memset( ptr, 0, data_size );
-
-    __END__;
-
-    return ptr;
-}
-
-/* releases all tree cascade nodes accessible via links */
-
-void icvReleaseTreeCascadeNodes( CvTreeCascadeNode** node )
-{
-    //CV_FUNCNAME( "icvReleaseTreeCascadeNodes" );
-
-    __BEGIN__;
-
-    if( node && *node )
-    {
-        CvTreeCascadeNode* ptr;
-        CvTreeCascadeNode* ptr_;
-
-        ptr = *node;
-
-        while( ptr )
-        {
-            while( ptr->child ) ptr = ptr->child;
-
-            if( ptr->stage ) ptr->stage->release( (CvIntHaarClassifier**) &ptr->stage );
-            ptr_ = ptr;
-
-            while( ptr && ptr->next == NULL ) ptr = ptr->parent;
-            if( ptr ) ptr = ptr->next;
-
-            cvFree( &ptr_ );
-        }
-    }
-
-    __END__;
-}
-
-
-/* releases tree cascade classifier */
-
-void icvReleaseTreeCascadeClassifier( CvIntHaarClassifier** classifier )
-{
-    if( classifier && *classifier )
-    {
-        icvReleaseTreeCascadeNodes( &((CvTreeCascadeClassifier*) *classifier)->root );
-        cvFree( classifier );
-        *classifier = NULL;
-    }
-}
-
-
-void icvPrintTreeCascade( CvTreeCascadeNode* root )
-{
-    //CV_FUNCNAME( "icvPrintTreeCascade" );
-
-    __BEGIN__;
-
-    CvTreeCascadeNode* node;
-    CvTreeCascadeNode* n;
-    char buf0[256];
-    char buf[256];
-    int level;
-    int i;
-    int max_level;
-
-    node = root;
-    level = max_level = 0;
-    while( node )
-    {
-        while( node->child ) { node = node->child; level++; }
-        if( level > max_level ) { max_level = level; }
-        while( node && !node->next ) { node = node->parent; level--; }
-        if( node ) node = node->next;
-    }
-
-    printf( "\nTree Classifier\n" );
-    printf( "Stage\n" );
-    for( i = 0; i <= max_level; i++ ) printf( "+---" );
-    printf( "+\n" );
-    for( i = 0; i <= max_level; i++ ) printf( "|%3d", i );
-    printf( "|\n" );
-    for( i = 0; i <= max_level; i++ ) printf( "+---" );
-    printf( "+\n\n" );
-
-    node = root;
-
-    buf[0] = 0;
-    while( node )
-    {
-        sprintf( buf + strlen( buf ), "%3d", node->idx );
-        while( node->child )
-        {
-            node = node->child;
-            sprintf( buf + strlen( buf ),
-                ((node->idx < 10) ? "---%d" : ((node->idx < 100) ? "--%d" : "-%d")),
-                node->idx );
-        }
-        printf( " %s\n", buf );
-
-        while( node && !node->next ) { node = node->parent; }
-        if( node )
-        {
-            node = node->next;
-
-            n = node->parent;
-            buf[0] = 0;
-            while( n )
-            {
-                if( n->next )
-                    sprintf( buf0, "  | %s", buf );
-                else
-                    sprintf( buf0, "    %s", buf );
-                strcpy( buf, buf0 );
-                n = n->parent;
-            }
-            printf( " %s  |\n", buf );
-        }
-    }
-    printf( "\n" );
-    fflush( stdout );
-
-    __END__;
-}
-
-
-
-CvIntHaarClassifier* icvLoadTreeCascadeClassifier( const char* filename, int step,
-                                                   int* splits )
-{
-    CvTreeCascadeClassifier* ptr = NULL;
-    CvTreeCascadeNode** nodes = NULL;
-
-    CV_FUNCNAME( "icvLoadTreeCascadeClassifier" );
-
-    __BEGIN__;
-
-    size_t data_size;
-    CvStageHaarClassifier* stage;
-    char stage_name[PATH_MAX];
-    char* suffix;
-    int i, num;
-    FILE* f;
-    int result, parent=0, next=0;
-    int stub;
-
-    if( !splits ) splits = &stub;
-
-    *splits = 0;
-
-    data_size = sizeof( *ptr );
-
-    CV_CALL( ptr = (CvTreeCascadeClassifier*) cvAlloc( data_size ) );
-    memset( ptr, 0, data_size );
-
-    ptr->eval = icvEvalTreeCascadeClassifier;
-    ptr->release = icvReleaseTreeCascadeClassifier;
-
-    sprintf( stage_name, "%s/", filename );
-    suffix = stage_name + strlen( stage_name );
-
-    for( i = 0; ; i++ )
-    {
-        sprintf( suffix, "%d/%s", i, CV_STAGE_CART_FILE_NAME );
-        f = fopen( stage_name, "r" );
-        if( !f ) break;
-        fclose( f );
-    }
-    num = i;
-
-    if( num < 1 ) EXIT;
-
-    data_size = sizeof( *nodes ) * num;
-    CV_CALL( nodes = (CvTreeCascadeNode**) cvAlloc( data_size ) );
-
-    for( i = 0; i < num; i++ )
-    {
-        sprintf( suffix, "%d/%s", i, CV_STAGE_CART_FILE_NAME );
-        f = fopen( stage_name, "r" );
-        CV_CALL( stage = (CvStageHaarClassifier*)
-            icvLoadCARTStageHaarClassifierF( f, step ) );
-
-        result = ( f && stage ) ? fscanf( f, "%d%d", &parent, &next ) : 0;
-        if( f ) fclose( f );
-
-        if( result != 2 )
-        {
-            num = i;
-            break;
-        }
-
-        printf( "Stage %d loaded\n", i );
-
-        if( parent >= i || (next != -1 && next != i + 1) )
-            CV_ERROR( CV_StsError, "Invalid tree links" );
-
-        CV_CALL( nodes[i] = icvCreateTreeCascadeNode() );
-        nodes[i]->stage = stage;
-        nodes[i]->idx = i;
-        nodes[i]->parent = (parent != -1 ) ? nodes[parent] : NULL;
-        nodes[i]->next = ( next != -1 ) ? nodes[i] : NULL;
-        nodes[i]->child = NULL;
-    }
-    for( i = 0; i < num; i++ )
-    {
-        if( nodes[i]->next )
-        {
-            (*splits)++;
-            nodes[i]->next = nodes[i+1];
-        }
-        if( nodes[i]->parent && nodes[i]->parent->child == NULL )
-        {
-            nodes[i]->parent->child = nodes[i];
-        }
-    }
-    ptr->root = nodes[0];
-    ptr->next_idx = num;
-
-    __END__;
-
-    cvFree( &nodes );
-
-    return (CvIntHaarClassifier*) ptr;
-}
-
-
-CvTreeCascadeNode* icvFindDeepestLeaves( CvTreeCascadeClassifier* tcc )
-{
-    CvTreeCascadeNode* leaves;
-
-    //CV_FUNCNAME( "icvFindDeepestLeaves" );
-
-    __BEGIN__;
-
-    int level, cur_level;
-    CvTreeCascadeNode* ptr;
-    CvTreeCascadeNode* last;
-
-    leaves = last = NULL;
-
-    ptr = tcc->root;
-    level = -1;
-    cur_level = 0;
-
-    /* find leaves with maximal level */
-    while( ptr )
-    {
-        if( ptr->child ) { ptr = ptr->child; cur_level++; }
-        else
-        {
-            if( cur_level == level )
-            {
-                last->next_same_level = ptr;
-                ptr->next_same_level = NULL;
-                last = ptr;
-            }
-            if( cur_level > level )
-            {
-                level = cur_level;
-                leaves = last = ptr;
-                ptr->next_same_level = NULL;
-            }
-            while( ptr && ptr->next == NULL ) { ptr = ptr->parent; cur_level--; }
-            if( ptr ) ptr = ptr->next;
-        }
-    }
-
-    __END__;
-
-    return leaves;
-}
-
-/* End of file. */
diff --git a/apps/haartraining/cvhaartraining.cpp b/apps/haartraining/cvhaartraining.cpp
deleted file mode 100644 (file)
index 2fcf76a..0000000
+++ /dev/null
@@ -1,3060 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
- * cvhaartraining.cpp
- *
- * training of cascade of boosted classifiers based on haar features
- */
-
-#include "cvhaartraining.h"
-#include "_cvhaartraining.h"
-
-#include <cstdio>
-#include <cstdlib>
-#include <cmath>
-#include <climits>
-#include <ctype.h>
-
-#include "highgui.h"
-
-#ifdef CV_VERBOSE
-#include <ctime>
-
-#ifdef _WIN32
-/* use clock() function insted of time() */
-#define TIME( arg ) (((double) clock()) / CLOCKS_PER_SEC)
-#else
-#define TIME( arg ) (time( arg ))
-#endif /* _WIN32 */
-
-#endif /* CV_VERBOSE */
-
-#if defined CV_OPENMP && (defined _MSC_VER || defined CV_ICC)
-#define CV_OPENMP 1
-#else
-#undef CV_OPENMP
-#endif
-
-typedef struct CvBackgroundData
-{
-    int    count;
-    char** filename;
-    int    last;
-    int    round;
-    CvSize winsize;
-} CvBackgroundData;
-
-typedef struct CvBackgroundReader
-{
-    CvMat   src;
-    CvMat   img;
-    CvPoint offset;
-    float   scale;
-    float   scalefactor;
-    float   stepfactor;
-    CvPoint point;
-} CvBackgroundReader;
-
-/*
- * Background reader
- * Created in each thread
- */
-CvBackgroundReader* cvbgreader = NULL;
-
-#if defined CV_OPENMP
-#pragma omp threadprivate(cvbgreader)
-#endif
-
-CvBackgroundData* cvbgdata = NULL;
-
-
-/*
- * get sum image offsets for <rect> corner points
- * step - row step (measured in image pixels!) of sum image
- */
-#define CV_SUM_OFFSETS( p0, p1, p2, p3, rect, step )                      \
-    /* (x, y) */                                                          \
-    (p0) = (rect).x + (step) * (rect).y;                                  \
-    /* (x + w, y) */                                                      \
-    (p1) = (rect).x + (rect).width + (step) * (rect).y;                   \
-    /* (x + w, y) */                                                      \
-    (p2) = (rect).x + (step) * ((rect).y + (rect).height);                \
-    /* (x + w, y + h) */                                                  \
-    (p3) = (rect).x + (rect).width + (step) * ((rect).y + (rect).height);
-
-/*
- * get tilted image offsets for <rect> corner points
- * step - row step (measured in image pixels!) of tilted image
- */
-#define CV_TILTED_OFFSETS( p0, p1, p2, p3, rect, step )                   \
-    /* (x, y) */                                                          \
-    (p0) = (rect).x + (step) * (rect).y;                                  \
-    /* (x - h, y + h) */                                                  \
-    (p1) = (rect).x - (rect).height + (step) * ((rect).y + (rect).height);\
-    /* (x + w, y + w) */                                                  \
-    (p2) = (rect).x + (rect).width + (step) * ((rect).y + (rect).width);  \
-    /* (x + w - h, y + w + h) */                                          \
-    (p3) = (rect).x + (rect).width - (rect).height                        \
-           + (step) * ((rect).y + (rect).width + (rect).height);
-
-
-/*
- * icvCreateIntHaarFeatures
- *
- * Create internal representation of haar features
- *
- * mode:
- *  0 - BASIC = Viola
- *  1 - CORE  = All upright
- *  2 - ALL   = All features
- */
-static
-CvIntHaarFeatures* icvCreateIntHaarFeatures( CvSize winsize,
-                                             int mode,
-                                             int symmetric )
-{
-    CvIntHaarFeatures* features = NULL;
-    CvTHaarFeature haarFeature;
-
-    CvMemStorage* storage = NULL;
-    CvSeq* seq = NULL;
-    CvSeqWriter writer;
-
-    int s0 = 36; /* minimum total area size of basic haar feature     */
-    int s1 = 12; /* minimum total area size of tilted haar features 2 */
-    int s2 = 18; /* minimum total area size of tilted haar features 3 */
-    int s3 = 24; /* minimum total area size of tilted haar features 4 */
-
-    int x  = 0;
-    int y  = 0;
-    int dx = 0;
-    int dy = 0;
-
-#if 0
-    float factor = 1.0F;
-
-    factor = ((float) winsize.width) * winsize.height / (24 * 24);
-
-    s0 = (int) (s0 * factor);
-    s1 = (int) (s1 * factor);
-    s2 = (int) (s2 * factor);
-    s3 = (int) (s3 * factor);
-#else
-    s0 = 1;
-    s1 = 1;
-    s2 = 1;
-    s3 = 1;
-#endif
-
-    /* CV_VECTOR_CREATE( vec, CvIntHaarFeature, size, maxsize ) */
-    storage = cvCreateMemStorage();
-    cvStartWriteSeq( 0, sizeof( CvSeq ), sizeof( haarFeature ), storage, &writer );
-
-    for( x = 0; x < winsize.width; x++ )
-    {
-        for( y = 0; y < winsize.height; y++ )
-        {
-            for( dx = 1; dx <= winsize.width; dx++ )
-            {
-                for( dy = 1; dy <= winsize.height; dy++ )
-                {
-                    // haar_x2
-                    if ( (x+dx*2 <= winsize.width) && (y+dy <= winsize.height) ) {
-                        if (dx*2*dy < s0) continue;
-                        if (!symmetric || (x+x+dx*2 <=winsize.width)) {
-                            haarFeature = cvHaarFeature( "haar_x2",
-                                x,    y, dx*2, dy, -1,
-                                x+dx, y, dx  , dy, +2 );
-                            /* CV_VECTOR_PUSH( vec, CvIntHaarFeature, haarFeature, size, maxsize, step ) */
-                            CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                        }
-                    }
-
-                    // haar_y2
-                    if ( (x+dx <= winsize.width) && (y+dy*2 <= winsize.height) ) {
-                        if (dx*2*dy < s0) continue;
-                        if (!symmetric || (x+x+dx <= winsize.width)) {
-                            haarFeature = cvHaarFeature( "haar_y2",
-                                x, y,    dx, dy*2, -1,
-                                x, y+dy, dx, dy,   +2 );
-                            CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                        }
-                    }
-
-                    // haar_x3
-                    if ( (x+dx*3 <= winsize.width) && (y+dy <= winsize.height) ) {
-                        if (dx*3*dy < s0) continue;
-                        if (!symmetric || (x+x+dx*3 <=winsize.width)) {
-                            haarFeature = cvHaarFeature( "haar_x3",
-                                x,    y, dx*3, dy, -1,
-                                x+dx, y, dx,   dy, +3 );
-                            CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                        }
-                    }
-
-                    // haar_y3
-                    if ( (x+dx <= winsize.width) && (y+dy*3 <= winsize.height) ) {
-                        if (dx*3*dy < s0) continue;
-                        if (!symmetric || (x+x+dx <= winsize.width)) {
-                            haarFeature = cvHaarFeature( "haar_y3",
-                                x, y,    dx, dy*3, -1,
-                                x, y+dy, dx, dy,   +3 );
-                            CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                        }
-                    }
-
-                    if( mode != 0 /*BASIC*/ ) {
-                        // haar_x4
-                        if ( (x+dx*4 <= winsize.width) && (y+dy <= winsize.height) ) {
-                            if (dx*4*dy < s0) continue;
-                            if (!symmetric || (x+x+dx*4 <=winsize.width)) {
-                                haarFeature = cvHaarFeature( "haar_x4",
-                                    x,    y, dx*4, dy, -1,
-                                    x+dx, y, dx*2, dy, +2 );
-                                CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                            }
-                        }
-
-                        // haar_y4
-                        if ( (x+dx <= winsize.width ) && (y+dy*4 <= winsize.height) ) {
-                            if (dx*4*dy < s0) continue;
-                            if (!symmetric || (x+x+dx   <=winsize.width)) {
-                                haarFeature = cvHaarFeature( "haar_y4",
-                                    x, y,    dx, dy*4, -1,
-                                    x, y+dy, dx, dy*2, +2 );
-                                CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                            }
-                        }
-                    }
-
-                    // x2_y2
-                    if ( (x+dx*2 <= winsize.width) && (y+dy*2 <= winsize.height) ) {
-                        if (dx*4*dy < s0) continue;
-                        if (!symmetric || (x+x+dx*2 <=winsize.width)) {
-                            haarFeature = cvHaarFeature( "haar_x2_y2",
-                                x   , y,    dx*2, dy*2, -1,
-                                x   , y   , dx  , dy,   +2,
-                                x+dx, y+dy, dx  , dy,   +2 );
-                            CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                        }
-                    }
-
-                    if (mode != 0 /*BASIC*/) {
-                        // point
-                        if ( (x+dx*3 <= winsize.width) && (y+dy*3 <= winsize.height) ) {
-                            if (dx*9*dy < s0) continue;
-                            if (!symmetric || (x+x+dx*3 <=winsize.width))  {
-                                haarFeature = cvHaarFeature( "haar_point",
-                                    x   , y,    dx*3, dy*3, -1,
-                                    x+dx, y+dy, dx  , dy  , +9);
-                                CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                            }
-                        }
-                    }
-
-                    if (mode == 2 /*ALL*/) {
-                        // tilted haar_x2                                      (x, y, w, h, b, weight)
-                        if ( (x+2*dx <= winsize.width) && (y+2*dx+dy <= winsize.height) && (x-dy>= 0) ) {
-                            if (dx*2*dy < s1) continue;
-
-                            if (!symmetric || (x <= (winsize.width / 2) )) {
-                                haarFeature = cvHaarFeature( "tilted_haar_x2",
-                                    x, y, dx*2, dy, -1,
-                                    x, y, dx  , dy, +2 );
-                                CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                            }
-                        }
-
-                        // tilted haar_y2                                      (x, y, w, h, b, weight)
-                        if ( (x+dx <= winsize.width) && (y+dx+2*dy <= winsize.height) && (x-2*dy>= 0) ) {
-                            if (dx*2*dy < s1) continue;
-
-                            if (!symmetric || (x <= (winsize.width / 2) )) {
-                                haarFeature = cvHaarFeature( "tilted_haar_y2",
-                                    x, y, dx, 2*dy, -1,
-                                    x, y, dx,   dy, +2 );
-                                CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                            }
-                        }
-
-                        // tilted haar_x3                                   (x, y, w, h, b, weight)
-                        if ( (x+3*dx <= winsize.width) && (y+3*dx+dy <= winsize.height) && (x-dy>= 0) ) {
-                            if (dx*3*dy < s2) continue;
-
-                            if (!symmetric || (x <= (winsize.width / 2) )) {
-                                haarFeature = cvHaarFeature( "tilted_haar_x3",
-                                    x,    y,    dx*3, dy, -1,
-                                    x+dx, y+dx, dx  , dy, +3 );
-                                CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                            }
-                        }
-
-                        // tilted haar_y3                                      (x, y, w, h, b, weight)
-                        if ( (x+dx <= winsize.width) && (y+dx+3*dy <= winsize.height) && (x-3*dy>= 0) ) {
-                            if (dx*3*dy < s2) continue;
-
-                            if (!symmetric || (x <= (winsize.width / 2) )) {
-                                haarFeature = cvHaarFeature( "tilted_haar_y3",
-                                    x,    y,    dx, 3*dy, -1,
-                                    x-dy, y+dy, dx,   dy, +3 );
-                                CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                            }
-                        }
-
-
-                        // tilted haar_x4                                   (x, y, w, h, b, weight)
-                        if ( (x+4*dx <= winsize.width) && (y+4*dx+dy <= winsize.height) && (x-dy>= 0) ) {
-                            if (dx*4*dy < s3) continue;
-
-                            if (!symmetric || (x <= (winsize.width / 2) )) {
-                                haarFeature = cvHaarFeature( "tilted_haar_x4",
-
-
-                                    x,    y,    dx*4, dy, -1,
-                                    x+dx, y+dx, dx*2, dy, +2 );
-                                CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                            }
-                        }
-
-                        // tilted haar_y4                                      (x, y, w, h, b, weight)
-                        if ( (x+dx <= winsize.width) && (y+dx+4*dy <= winsize.height) && (x-4*dy>= 0) ) {
-                            if (dx*4*dy < s3) continue;
-
-                            if (!symmetric || (x <= (winsize.width / 2) )) {
-                                haarFeature = cvHaarFeature( "tilted_haar_y4",
-                                    x,    y,    dx, 4*dy, -1,
-                                    x-dy, y+dy, dx, 2*dy, +2 );
-                                CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                            }
-                        }
-
-
-                        /*
-
-                          // tilted point
-                          if ( (x+dx*3 <= winsize.width - 1) && (y+dy*3 <= winsize.height - 1) && (x-3*dy>= 0)) {
-                          if (dx*9*dy < 36) continue;
-                          if (!symmetric || (x <= (winsize.width / 2) ))  {
-                            haarFeature = cvHaarFeature( "tilted_haar_point",
-                                x, y,    dx*3, dy*3, -1,
-                                x, y+dy, dx  , dy,   +9 );
-                                CV_WRITE_SEQ_ELEM( haarFeature, writer );
-                          }
-                          }
-                        */
-                    }
-                }
-            }
-        }
-    }
-
-    seq = cvEndWriteSeq( &writer );
-    features = (CvIntHaarFeatures*) cvAlloc( sizeof( CvIntHaarFeatures ) +
-        ( sizeof( CvTHaarFeature ) + sizeof( CvFastHaarFeature ) ) * seq->total );
-    features->feature = (CvTHaarFeature*) (features + 1);
-    features->fastfeature = (CvFastHaarFeature*) ( features->feature + seq->total );
-    features->count = seq->total;
-    features->winsize = winsize;
-    cvCvtSeqToArray( seq, (CvArr*) features->feature );
-    cvReleaseMemStorage( &storage );
-
-    icvConvertToFastHaarFeature( features->feature, features->fastfeature,
-                                 features->count, (winsize.width + 1) );
-
-    return features;
-}
-
-static
-void icvReleaseIntHaarFeatures( CvIntHaarFeatures** intHaarFeatures )
-{
-    if( intHaarFeatures != NULL && (*intHaarFeatures) != NULL )
-    {
-        cvFree( intHaarFeatures );
-        (*intHaarFeatures) = NULL;
-    }
-}
-
-
-void icvConvertToFastHaarFeature( CvTHaarFeature* haarFeature,
-                                  CvFastHaarFeature* fastHaarFeature,
-                                  int size, int step )
-{
-    int i = 0;
-    int j = 0;
-
-    for( i = 0; i < size; i++ )
-    {
-        fastHaarFeature[i].tilted = haarFeature[i].tilted;
-        if( !fastHaarFeature[i].tilted )
-        {
-            for( j = 0; j < CV_HAAR_FEATURE_MAX; j++ )
-            {
-                fastHaarFeature[i].rect[j].weight = haarFeature[i].rect[j].weight;
-                if( fastHaarFeature[i].rect[j].weight == 0.0F )
-                {
-                    break;
-                }
-                CV_SUM_OFFSETS( fastHaarFeature[i].rect[j].p0,
-                                fastHaarFeature[i].rect[j].p1,
-                                fastHaarFeature[i].rect[j].p2,
-                                fastHaarFeature[i].rect[j].p3,
-                                haarFeature[i].rect[j].r, step )
-            }
-
-        }
-        else
-        {
-            for( j = 0; j < CV_HAAR_FEATURE_MAX; j++ )
-            {
-                fastHaarFeature[i].rect[j].weight = haarFeature[i].rect[j].weight;
-                if( fastHaarFeature[i].rect[j].weight == 0.0F )
-                {
-                    break;
-                }
-                CV_TILTED_OFFSETS( fastHaarFeature[i].rect[j].p0,
-                                   fastHaarFeature[i].rect[j].p1,
-                                   fastHaarFeature[i].rect[j].p2,
-                                   fastHaarFeature[i].rect[j].p3,
-                                   haarFeature[i].rect[j].r, step )
-            }
-        }
-    }
-}
-
-
-/*
- * icvCreateHaarTrainingData
- *
- * Create haar training data used in stage training
- */
-static
-CvHaarTrainigData* icvCreateHaarTrainingData( CvSize winsize, int maxnumsamples )
-{
-    CvHaarTrainigData* data;
-
-    CV_FUNCNAME( "icvCreateHaarTrainingData" );
-
-    __BEGIN__;
-
-    data = NULL;
-    uchar* ptr = NULL;
-    size_t datasize = 0;
-
-    datasize = sizeof( CvHaarTrainigData ) +
-          /* sum and tilted */
-        ( 2 * (winsize.width + 1) * (winsize.height + 1) * sizeof( sum_type ) +
-          sizeof( float ) +      /* normfactor */
-          sizeof( float ) +      /* cls */
-          sizeof( float )        /* weight */
-        ) * maxnumsamples;
-
-    CV_CALL( data = (CvHaarTrainigData*) cvAlloc( datasize ) );
-    memset( (void*)data, 0, datasize );
-    data->maxnum = maxnumsamples;
-    data->winsize = winsize;
-    ptr = (uchar*)(data + 1);
-    data->sum = cvMat( maxnumsamples, (winsize.width + 1) * (winsize.height + 1),
-                       CV_SUM_MAT_TYPE, (void*) ptr );
-    ptr += sizeof( sum_type ) * maxnumsamples * (winsize.width+1) * (winsize.height+1);
-    data->tilted = cvMat( maxnumsamples, (winsize.width + 1) * (winsize.height + 1),
-                       CV_SUM_MAT_TYPE, (void*) ptr );
-    ptr += sizeof( sum_type ) * maxnumsamples * (winsize.width+1) * (winsize.height+1);
-    data->normfactor = cvMat( 1, maxnumsamples, CV_32FC1, (void*) ptr );
-    ptr += sizeof( float ) * maxnumsamples;
-    data->cls = cvMat( 1, maxnumsamples, CV_32FC1, (void*) ptr );
-    ptr += sizeof( float ) * maxnumsamples;
-    data->weights = cvMat( 1, maxnumsamples, CV_32FC1, (void*) ptr );
-
-    data->valcache = NULL;
-    data->idxcache = NULL;
-
-    __END__;
-
-    return data;
-}
-
-static
-void icvReleaseHaarTrainingDataCache( CvHaarTrainigData** haarTrainingData )
-{
-    if( haarTrainingData != NULL && (*haarTrainingData) != NULL )
-    {
-        if( (*haarTrainingData)->valcache != NULL )
-        {
-            cvReleaseMat( &(*haarTrainingData)->valcache );
-            (*haarTrainingData)->valcache = NULL;
-        }
-        if( (*haarTrainingData)->idxcache != NULL )
-        {
-            cvReleaseMat( &(*haarTrainingData)->idxcache );
-            (*haarTrainingData)->idxcache = NULL;
-        }
-    }
-}
-
-static
-void icvReleaseHaarTrainingData( CvHaarTrainigData** haarTrainingData )
-{
-    if( haarTrainingData != NULL && (*haarTrainingData) != NULL )
-    {
-        icvReleaseHaarTrainingDataCache( haarTrainingData );
-
-        cvFree( haarTrainingData );
-    }
-}
-
-static
-void icvGetTrainingDataCallback( CvMat* mat, CvMat* sampleIdx, CvMat*,
-                                 int first, int num, void* userdata )
-{
-    int i = 0;
-    int j = 0;
-    float val = 0.0F;
-    float normfactor = 0.0F;
-
-    CvHaarTrainingData* training_data;
-    CvIntHaarFeatures* haar_features;
-
-#ifdef CV_COL_ARRANGEMENT
-    assert( mat->rows >= num );
-#else
-    assert( mat->cols >= num );
-#endif
-
-    training_data = ((CvUserdata*) userdata)->trainingData;
-    haar_features = ((CvUserdata*) userdata)->haarFeatures;
-    if( sampleIdx == NULL )
-    {
-        int num_samples;
-
-#ifdef CV_COL_ARRANGEMENT
-        num_samples = mat->cols;
-#else
-        num_samples = mat->rows;
-#endif
-        for( i = 0; i < num_samples; i++ )
-        {
-            for( j = 0; j < num; j++ )
-            {
-                val = cvEvalFastHaarFeature(
-                        ( haar_features->fastfeature
-                            + first + j ),
-                        (sum_type*) (training_data->sum.data.ptr
-                            + i * training_data->sum.step),
-                        (sum_type*) (training_data->tilted.data.ptr
-                            + i * training_data->tilted.step) );
-                normfactor = training_data->normfactor.data.fl[i];
-                val = ( normfactor == 0.0F ) ? 0.0F : (val / normfactor);
-
-#ifdef CV_COL_ARRANGEMENT
-                CV_MAT_ELEM( *mat, float, j, i ) = val;
-#else
-                CV_MAT_ELEM( *mat, float, i, j ) = val;
-#endif
-            }
-        }
-    }
-    else
-    {
-        uchar* idxdata = NULL;
-        size_t step    = 0;
-        int    numidx  = 0;
-        int    idx     = 0;
-
-        assert( CV_MAT_TYPE( sampleIdx->type ) == CV_32FC1 );
-
-        idxdata = sampleIdx->data.ptr;
-        if( sampleIdx->rows == 1 )
-        {
-            step = sizeof( float );
-            numidx = sampleIdx->cols;
-        }
-        else
-        {
-            step = sampleIdx->step;
-            numidx = sampleIdx->rows;
-        }
-
-        for( i = 0; i < numidx; i++ )
-        {
-            for( j = 0; j < num; j++ )
-            {
-                idx = (int)( *((float*) (idxdata + i * step)) );
-                val = cvEvalFastHaarFeature(
-                        ( haar_features->fastfeature
-                            + first + j ),
-                        (sum_type*) (training_data->sum.data.ptr
-                            + idx * training_data->sum.step),
-                        (sum_type*) (training_data->tilted.data.ptr
-                            + idx * training_data->tilted.step) );
-                normfactor = training_data->normfactor.data.fl[idx];
-                val = ( normfactor == 0.0F ) ? 0.0F : (val / normfactor);
-
-#ifdef CV_COL_ARRANGEMENT
-                CV_MAT_ELEM( *mat, float, j, idx ) = val;
-#else
-                CV_MAT_ELEM( *mat, float, idx, j ) = val;
-#endif
-
-            }
-        }
-    }
-#if 0 /*def CV_VERBOSE*/
-    if( first % 5000 == 0 )
-    {
-        fprintf( stderr, "%3d%%\r", (int) (100.0 * first /
-            haar_features->count) );
-        fflush( stderr );
-    }
-#endif /* CV_VERBOSE */
-}
-
-static
-void icvPrecalculate( CvHaarTrainingData* data, CvIntHaarFeatures* haarFeatures,
-                      int numprecalculated )
-{
-    CV_FUNCNAME( "icvPrecalculate" );
-
-    __BEGIN__;
-
-    icvReleaseHaarTrainingDataCache( &data );
-
-    numprecalculated -= numprecalculated % CV_STUMP_TRAIN_PORTION;
-    numprecalculated = MIN( numprecalculated, haarFeatures->count );
-
-    if( numprecalculated > 0 )
-    {
-        //size_t datasize;
-        int m;
-        CvUserdata userdata;
-
-        /* private variables */
-        #ifdef CV_OPENMP
-        CvMat t_data;
-        CvMat t_idx;
-        int first;
-        int t_portion;
-        int portion = CV_STUMP_TRAIN_PORTION;
-        #endif /* CV_OPENMP */
-
-        m = data->sum.rows;
-
-#ifdef CV_COL_ARRANGEMENT
-        CV_CALL( data->valcache = cvCreateMat( numprecalculated, m, CV_32FC1 ) );
-#else
-        CV_CALL( data->valcache = cvCreateMat( m, numprecalculated, CV_32FC1 ) );
-#endif
-        CV_CALL( data->idxcache = cvCreateMat( numprecalculated, m, CV_IDX_MAT_TYPE ) );
-
-        userdata = cvUserdata( data, haarFeatures );
-
-        #ifdef CV_OPENMP
-        #pragma omp parallel for private(t_data, t_idx, first, t_portion)
-        for( first = 0; first < numprecalculated; first += portion )
-        {
-            t_data = *data->valcache;
-            t_idx = *data->idxcache;
-            t_portion = MIN( portion, (numprecalculated - first) );
-
-            /* indices */
-            t_idx.rows = t_portion;
-            t_idx.data.ptr = data->idxcache->data.ptr + first * ((size_t)t_idx.step);
-
-            /* feature values */
-#ifdef CV_COL_ARRANGEMENT
-            t_data.rows = t_portion;
-            t_data.data.ptr = data->valcache->data.ptr +
-                first * ((size_t) t_data.step );
-#else
-            t_data.cols = t_portion;
-            t_data.data.ptr = data->valcache->data.ptr +
-                first * ((size_t) CV_ELEM_SIZE( t_data.type ));
-#endif
-            icvGetTrainingDataCallback( &t_data, NULL, NULL, first, t_portion,
-                                        &userdata );
-#ifdef CV_COL_ARRANGEMENT
-            cvGetSortedIndices( &t_data, &t_idx, 0 );
-#else
-            cvGetSortedIndices( &t_data, &t_idx, 1 );
-#endif
-
-#ifdef CV_VERBOSE
-            putc( '.', stderr );
-            fflush( stderr );
-#endif /* CV_VERBOSE */
-
-        }
-
-#ifdef CV_VERBOSE
-        fprintf( stderr, "\n" );
-        fflush( stderr );
-#endif /* CV_VERBOSE */
-
-        #else
-        icvGetTrainingDataCallback( data->valcache, NULL, NULL, 0, numprecalculated,
-                                    &userdata );
-#ifdef CV_COL_ARRANGEMENT
-        cvGetSortedIndices( data->valcache, data->idxcache, 0 );
-#else
-        cvGetSortedIndices( data->valcache, data->idxcache, 1 );
-#endif
-        #endif /* CV_OPENMP */
-    }
-
-    __END__;
-}
-
-static
-void icvSplitIndicesCallback( int compidx, float threshold,
-                              CvMat* idx, CvMat** left, CvMat** right,
-                              void* userdata )
-{
-    CvHaarTrainingData* data;
-    CvIntHaarFeatures* haar_features;
-    int i;
-    int m;
-    CvFastHaarFeature* fastfeature;
-
-    data = ((CvUserdata*) userdata)->trainingData;
-    haar_features = ((CvUserdata*) userdata)->haarFeatures;
-    fastfeature = &haar_features->fastfeature[compidx];
-
-    m = data->sum.rows;
-    *left = cvCreateMat( 1, m, CV_32FC1 );
-    *right = cvCreateMat( 1, m, CV_32FC1 );
-    (*left)->cols = (*right)->cols = 0;
-    if( idx == NULL )
-    {
-        for( i = 0; i < m; i++ )
-        {
-            if( cvEvalFastHaarFeature( fastfeature,
-                    (sum_type*) (data->sum.data.ptr + i * data->sum.step),
-                    (sum_type*) (data->tilted.data.ptr + i * data->tilted.step) )
-                < threshold * data->normfactor.data.fl[i] )
-            {
-                (*left)->data.fl[(*left)->cols++] = (float) i;
-            }
-            else
-            {
-                (*right)->data.fl[(*right)->cols++] = (float) i;
-            }
-        }
-    }
-    else
-    {
-        uchar* idxdata;
-        int    idxnum;
-        size_t idxstep;
-        int    index;
-
-        idxdata = idx->data.ptr;
-        idxnum = (idx->rows == 1) ? idx->cols : idx->rows;
-        idxstep = (idx->rows == 1) ? CV_ELEM_SIZE( idx->type ) : idx->step;
-        for( i = 0; i < idxnum; i++ )
-        {
-            index = (int) *((float*) (idxdata + i * idxstep));
-            if( cvEvalFastHaarFeature( fastfeature,
-                    (sum_type*) (data->sum.data.ptr + index * data->sum.step),
-                    (sum_type*) (data->tilted.data.ptr + index * data->tilted.step) )
-                < threshold * data->normfactor.data.fl[index] )
-            {
-                (*left)->data.fl[(*left)->cols++] = (float) index;
-            }
-            else
-            {
-                (*right)->data.fl[(*right)->cols++] = (float) index;
-            }
-        }
-    }
-}
-
-/*
- * icvCreateCARTStageClassifier
- *
- * Create stage classifier with trees as weak classifiers
- * data             - haar training data. It must be created and filled before call
- * minhitrate       - desired min hit rate
- * maxfalsealarm    - desired max false alarm rate
- * symmetric        - if not 0 it is assumed that samples are vertically symmetric
- * numprecalculated - number of features that will be precalculated. Each precalculated
- *   feature need (number_of_samples*(sizeof( float ) + sizeof( short ))) bytes of memory
- * weightfraction   - weight trimming parameter
- * numsplits        - number of binary splits in each tree
- * boosttype        - type of applied boosting algorithm
- * stumperror       - type of used error if Discrete AdaBoost algorithm is applied
- * maxsplits        - maximum total number of splits in all weak classifiers.
- *   If it is not 0 then NULL returned if total number of splits exceeds <maxsplits>.
- */
-static
-CvIntHaarClassifier* icvCreateCARTStageClassifier( CvHaarTrainingData* data,
-                                                   CvMat* sampleIdx,
-                                                   CvIntHaarFeatures* haarFeatures,
-                                                   float minhitrate,
-                                                   float maxfalsealarm,
-                                                   int   symmetric,
-                                                   float weightfraction,
-                                                   int numsplits,
-                                                   CvBoostType boosttype,
-                                                   CvStumpError stumperror,
-                                                   int maxsplits )
-{
-
-#ifdef CV_COL_ARRANGEMENT
-    int flags = CV_COL_SAMPLE;
-#else
-    int flags = CV_ROW_SAMPLE;
-#endif
-
-    CvStageHaarClassifier* stage = NULL;
-    CvBoostTrainer* trainer;
-    CvCARTClassifier* cart = NULL;
-    CvCARTTrainParams trainParams;
-    CvMTStumpTrainParams stumpTrainParams;
-    //CvMat* trainData = NULL;
-    //CvMat* sortedIdx = NULL;
-    CvMat eval;
-    int n = 0;
-    int m = 0;
-    int numpos = 0;
-    int numneg = 0;
-    int numfalse = 0;
-    float sum_stage = 0.0F;
-    float threshold = 0.0F;
-    float falsealarm = 0.0F;
-
-    //CvMat* sampleIdx = NULL;
-    CvMat* trimmedIdx;
-    //float* idxdata = NULL;
-    //float* tempweights = NULL;
-    //int    idxcount = 0;
-    CvUserdata userdata;
-
-    int i = 0;
-    int j = 0;
-    int idx;
-    int numsamples;
-    int numtrimmed;
-
-    CvCARTHaarClassifier* classifier;
-    CvSeq* seq = NULL;
-    CvMemStorage* storage = NULL;
-    CvMat* weakTrainVals;
-    float alpha;
-    float sumalpha;
-    int num_splits; /* total number of splits in all weak classifiers */
-
-#ifdef CV_VERBOSE
-    printf( "+----+----+-+---------+---------+---------+---------+\n" );
-    printf( "|  N |%%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|\n" );
-    printf( "+----+----+-+---------+---------+---------+---------+\n" );
-#endif /* CV_VERBOSE */
-
-    n = haarFeatures->count;
-    m = data->sum.rows;
-    numsamples = (sampleIdx) ? MAX( sampleIdx->rows, sampleIdx->cols ) : m;
-
-    userdata = cvUserdata( data, haarFeatures );
-
-    stumpTrainParams.type = ( boosttype == CV_DABCLASS )
-        ? CV_CLASSIFICATION_CLASS : CV_REGRESSION;
-    stumpTrainParams.error = ( boosttype == CV_LBCLASS || boosttype == CV_GABCLASS )
-        ? CV_SQUARE : stumperror;
-    stumpTrainParams.portion = CV_STUMP_TRAIN_PORTION;
-    stumpTrainParams.getTrainData = icvGetTrainingDataCallback;
-    stumpTrainParams.numcomp = n;
-    stumpTrainParams.userdata = &userdata;
-    stumpTrainParams.sortedIdx = data->idxcache;
-
-    trainParams.count = numsplits;
-    trainParams.stumpTrainParams = (CvClassifierTrainParams*) &stumpTrainParams;
-    trainParams.stumpConstructor = cvCreateMTStumpClassifier;
-    trainParams.splitIdx = icvSplitIndicesCallback;
-    trainParams.userdata = &userdata;
-
-    eval = cvMat( 1, m, CV_32FC1, cvAlloc( sizeof( float ) * m ) );
-
-    storage = cvCreateMemStorage();
-    seq = cvCreateSeq( 0, sizeof( *seq ), sizeof( classifier ), storage );
-
-    weakTrainVals = cvCreateMat( 1, m, CV_32FC1 );
-    trainer = cvBoostStartTraining( &data->cls, weakTrainVals, &data->weights,
-                                    sampleIdx, boosttype );
-    num_splits = 0;
-    sumalpha = 0.0F;
-    do
-    {
-
-#ifdef CV_VERBOSE
-        int v_wt = 0;
-        int v_flipped = 0;
-#endif /* CV_VERBOSE */
-
-        trimmedIdx = cvTrimWeights( &data->weights, sampleIdx, weightfraction );
-        numtrimmed = (trimmedIdx) ? MAX( trimmedIdx->rows, trimmedIdx->cols ) : m;
-
-#ifdef CV_VERBOSE
-        v_wt = 100 * numtrimmed / numsamples;
-        v_flipped = 0;
-
-#endif /* CV_VERBOSE */
-
-        cart = (CvCARTClassifier*) cvCreateCARTClassifier( data->valcache,
-                        flags,
-                        weakTrainVals, 0, 0, 0, trimmedIdx,
-                        &(data->weights),
-                        (CvClassifierTrainParams*) &trainParams );
-
-        classifier = (CvCARTHaarClassifier*) icvCreateCARTHaarClassifier( numsplits );
-        icvInitCARTHaarClassifier( classifier, cart, haarFeatures );
-
-        num_splits += classifier->count;
-
-        cart->release( (CvClassifier**) &cart );
-
-        if( symmetric && (seq->total % 2) )
-        {
-            float normfactor = 0.0F;
-            CvStumpClassifier* stump;
-
-            /* flip haar features */
-            for( i = 0; i < classifier->count; i++ )
-            {
-                if( classifier->feature[i].desc[0] == 'h' )
-                {
-                    for( j = 0; j < CV_HAAR_FEATURE_MAX &&
-                                    classifier->feature[i].rect[j].weight != 0.0F; j++ )
-                    {
-                        classifier->feature[i].rect[j].r.x = data->winsize.width -
-                            classifier->feature[i].rect[j].r.x -
-                            classifier->feature[i].rect[j].r.width;
-                    }
-                }
-                else
-                {
-                    int tmp = 0;
-
-                    /* (x,y) -> (24-x,y) */
-                    /* w -> h; h -> w    */
-                    for( j = 0; j < CV_HAAR_FEATURE_MAX &&
-                                    classifier->feature[i].rect[j].weight != 0.0F; j++ )
-                    {
-                        classifier->feature[i].rect[j].r.x = data->winsize.width -
-                            classifier->feature[i].rect[j].r.x;
-                        CV_SWAP( classifier->feature[i].rect[j].r.width,
-                                 classifier->feature[i].rect[j].r.height, tmp );
-                    }
-                }
-            }
-            icvConvertToFastHaarFeature( classifier->feature,
-                                         classifier->fastfeature,
-                                         classifier->count, data->winsize.width + 1 );
-
-            stumpTrainParams.getTrainData = NULL;
-            stumpTrainParams.numcomp = 1;
-            stumpTrainParams.userdata = NULL;
-            stumpTrainParams.sortedIdx = NULL;
-
-            for( i = 0; i < classifier->count; i++ )
-            {
-                for( j = 0; j < numtrimmed; j++ )
-                {
-                    idx = icvGetIdxAt( trimmedIdx, j );
-
-                    eval.data.fl[idx] = cvEvalFastHaarFeature( &classifier->fastfeature[i],
-                        (sum_type*) (data->sum.data.ptr + idx * data->sum.step),
-                        (sum_type*) (data->tilted.data.ptr + idx * data->tilted.step) );
-                    normfactor = data->normfactor.data.fl[idx];
-                    eval.data.fl[idx] = ( normfactor == 0.0F )
-                        ? 0.0F : (eval.data.fl[idx] / normfactor);
-                }
-
-                stump = (CvStumpClassifier*) trainParams.stumpConstructor( &eval,
-                    CV_COL_SAMPLE,
-                    weakTrainVals, 0, 0, 0, trimmedIdx,
-                    &(data->weights),
-                    trainParams.stumpTrainParams );
-
-                classifier->threshold[i] = stump->threshold;
-                if( classifier->left[i] <= 0 )
-                {
-                    classifier->val[-classifier->left[i]] = stump->left;
-                }
-                if( classifier->right[i] <= 0 )
-                {
-                    classifier->val[-classifier->right[i]] = stump->right;
-                }
-
-                stump->release( (CvClassifier**) &stump );
-
-            }
-
-            stumpTrainParams.getTrainData = icvGetTrainingDataCallback;
-            stumpTrainParams.numcomp = n;
-            stumpTrainParams.userdata = &userdata;
-            stumpTrainParams.sortedIdx = data->idxcache;
-
-#ifdef CV_VERBOSE
-            v_flipped = 1;
-#endif /* CV_VERBOSE */
-
-        } /* if symmetric */
-        if( trimmedIdx != sampleIdx )
-        {
-            cvReleaseMat( &trimmedIdx );
-            trimmedIdx = NULL;
-        }
-
-        for( i = 0; i < numsamples; i++ )
-        {
-            idx = icvGetIdxAt( sampleIdx, i );
-
-            eval.data.fl[idx] = classifier->eval( (CvIntHaarClassifier*) classifier,
-                (sum_type*) (data->sum.data.ptr + idx * data->sum.step),
-                (sum_type*) (data->tilted.data.ptr + idx * data->tilted.step),
-                data->normfactor.data.fl[idx] );
-        }
-
-        alpha = cvBoostNextWeakClassifier( &eval, &data->cls, weakTrainVals,
-                                           &data->weights, trainer );
-        sumalpha += alpha;
-
-        for( i = 0; i <= classifier->count; i++ )
-        {
-            if( boosttype == CV_RABCLASS )
-            {
-                classifier->val[i] = cvLogRatio( classifier->val[i] );
-            }
-            classifier->val[i] *= alpha;
-        }
-
-        cvSeqPush( seq, (void*) &classifier );
-
-        numpos = 0;
-        for( i = 0; i < numsamples; i++ )
-        {
-            idx = icvGetIdxAt( sampleIdx, i );
-
-            if( data->cls.data.fl[idx] == 1.0F )
-            {
-                eval.data.fl[numpos] = 0.0F;
-                for( j = 0; j < seq->total; j++ )
-                {
-                    classifier = *((CvCARTHaarClassifier**) cvGetSeqElem( seq, j ));
-                    eval.data.fl[numpos] += classifier->eval(
-                        (CvIntHaarClassifier*) classifier,
-                        (sum_type*) (data->sum.data.ptr + idx * data->sum.step),
-                        (sum_type*) (data->tilted.data.ptr + idx * data->tilted.step),
-                        data->normfactor.data.fl[idx] );
-                }
-                /* eval.data.fl[numpos] = 2.0F * eval.data.fl[numpos] - seq->total; */
-                numpos++;
-            }
-        }
-        std::sort(eval.data.fl, eval.data.fl + numpos);
-        threshold = eval.data.fl[(int) ((1.0F - minhitrate) * numpos)];
-
-        numneg = 0;
-        numfalse = 0;
-        for( i = 0; i < numsamples; i++ )
-        {
-            idx = icvGetIdxAt( sampleIdx, i );
-
-            if( data->cls.data.fl[idx] == 0.0F )
-            {
-                numneg++;
-                sum_stage = 0.0F;
-                for( j = 0; j < seq->total; j++ )
-                {
-                   classifier = *((CvCARTHaarClassifier**) cvGetSeqElem( seq, j ));
-                   sum_stage += classifier->eval( (CvIntHaarClassifier*) classifier,
-                        (sum_type*) (data->sum.data.ptr + idx * data->sum.step),
-                        (sum_type*) (data->tilted.data.ptr + idx * data->tilted.step),
-                        data->normfactor.data.fl[idx] );
-                }
-                /* sum_stage = 2.0F * sum_stage - seq->total; */
-                if( sum_stage >= (threshold - CV_THRESHOLD_EPS) )
-                {
-                    numfalse++;
-                }
-            }
-        }
-        falsealarm = ((float) numfalse) / ((float) numneg);
-
-#ifdef CV_VERBOSE
-        {
-            float v_hitrate    = 0.0F;
-            float v_falsealarm = 0.0F;
-            /* expected error of stage classifier regardless threshold */
-            float v_experr = 0.0F;
-
-            for( i = 0; i < numsamples; i++ )
-            {
-                idx = icvGetIdxAt( sampleIdx, i );
-
-                sum_stage = 0.0F;
-                for( j = 0; j < seq->total; j++ )
-                {
-                    classifier = *((CvCARTHaarClassifier**) cvGetSeqElem( seq, j ));
-                    sum_stage += classifier->eval( (CvIntHaarClassifier*) classifier,
-                        (sum_type*) (data->sum.data.ptr + idx * data->sum.step),
-                        (sum_type*) (data->tilted.data.ptr + idx * data->tilted.step),
-                        data->normfactor.data.fl[idx] );
-                }
-                /* sum_stage = 2.0F * sum_stage - seq->total; */
-                if( sum_stage >= (threshold - CV_THRESHOLD_EPS) )
-                {
-                    if( data->cls.data.fl[idx] == 1.0F )
-                    {
-                        v_hitrate += 1.0F;
-                    }
-                    else
-                    {
-                        v_falsealarm += 1.0F;
-                    }
-                }
-                if( ( sum_stage >= 0.0F ) != (data->cls.data.fl[idx] == 1.0F) )
-                {
-                    v_experr += 1.0F;
-                }
-            }
-            v_experr /= numsamples;
-            printf( "|%4d|%3d%%|%c|%9f|%9f|%9f|%9f|\n",
-                seq->total, v_wt, ( (v_flipped) ? '+' : '-' ),
-                threshold, v_hitrate / numpos, v_falsealarm / numneg,
-                v_experr );
-            printf( "+----+----+-+---------+---------+---------+---------+\n" );
-            fflush( stdout );
-        }
-#endif /* CV_VERBOSE */
-
-    } while( falsealarm > maxfalsealarm && (!maxsplits || (num_splits < maxsplits) ) );
-    cvBoostEndTraining( &trainer );
-
-    if( falsealarm > maxfalsealarm )
-    {
-        stage = NULL;
-    }
-    else
-    {
-        stage = (CvStageHaarClassifier*) icvCreateStageHaarClassifier( seq->total,
-                                                                       threshold );
-        cvCvtSeqToArray( seq, (CvArr*) stage->classifier );
-    }
-
-    /* CLEANUP */
-    cvReleaseMemStorage( &storage );
-    cvReleaseMat( &weakTrainVals );
-    cvFree( &(eval.data.ptr) );
-
-    return (CvIntHaarClassifier*) stage;
-}
-
-
-static
-CvBackgroundData* icvCreateBackgroundData( const char* filename, CvSize winsize )
-{
-    CvBackgroundData* data = NULL;
-
-    const char* dir = NULL;
-    char full[PATH_MAX];
-    char* imgfilename = NULL;
-    size_t datasize = 0;
-    int    count = 0;
-    FILE*  input = NULL;
-    char*  tmp   = NULL;
-    int    len   = 0;
-
-    assert( filename != NULL );
-
-    dir = strrchr( filename, '\\' );
-    if( dir == NULL )
-    {
-        dir = strrchr( filename, '/' );
-    }
-    if( dir == NULL )
-    {
-        imgfilename = &(full[0]);
-    }
-    else
-    {
-        strncpy( &(full[0]), filename, (dir - filename + 1) );
-        imgfilename = &(full[(dir - filename + 1)]);
-    }
-
-    input = fopen( filename, "r" );
-    if( input != NULL )
-    {
-        count = 0;
-        datasize = 0;
-
-        /* count */
-        while( !feof( input ) )
-        {
-            *imgfilename = '\0';
-            if( !fgets( imgfilename, PATH_MAX - (int)(imgfilename - full) - 1, input ))
-                break;
-            len = (int)strlen( imgfilename );
-            for( ; len > 0 && isspace(imgfilename[len-1]); len-- )
-                imgfilename[len-1] = '\0';
-            if( len > 0 )
-            {
-                if( (*imgfilename) == '#' ) continue; /* comment */
-                count++;
-                datasize += sizeof( char ) * (strlen( &(full[0]) ) + 1);
-            }
-        }
-        if( count > 0 )
-        {
-            //rewind( input );
-            fseek( input, 0, SEEK_SET );
-            datasize += sizeof( *data ) + sizeof( char* ) * count;
-            data = (CvBackgroundData*) cvAlloc( datasize );
-            memset( (void*) data, 0, datasize );
-            data->count = count;
-            data->filename = (char**) (data + 1);
-            data->last = 0;
-            data->round = 0;
-            data->winsize = winsize;
-            tmp = (char*) (data->filename + data->count);
-            count = 0;
-            while( !feof( input ) )
-            {
-                *imgfilename = '\0';
-                if( !fgets( imgfilename, PATH_MAX - (int)(imgfilename - full) - 1, input ))
-                    break;
-                len = (int)strlen( imgfilename );
-                if( len > 0 && imgfilename[len-1] == '\n' )
-                    imgfilename[len-1] = 0, len--;
-                if( len > 0 )
-                {
-                    if( (*imgfilename) == '#' ) continue; /* comment */
-                    data->filename[count++] = tmp;
-                    strcpy( tmp, &(full[0]) );
-                    tmp += strlen( &(full[0]) ) + 1;
-                }
-            }
-        }
-        fclose( input );
-    }
-
-    return data;
-}
-
-static
-void icvReleaseBackgroundData( CvBackgroundData** data )
-{
-    assert( data != NULL && (*data) != NULL );
-
-    cvFree( data );
-}
-
-static
-CvBackgroundReader* icvCreateBackgroundReader()
-{
-    CvBackgroundReader* reader = NULL;
-
-    reader = (CvBackgroundReader*) cvAlloc( sizeof( *reader ) );
-    memset( (void*) reader, 0, sizeof( *reader ) );
-    reader->src = cvMat( 0, 0, CV_8UC1, NULL );
-    reader->img = cvMat( 0, 0, CV_8UC1, NULL );
-    reader->offset = cvPoint( 0, 0 );
-    reader->scale       = 1.0F;
-    reader->scalefactor = 1.4142135623730950488016887242097F;
-    reader->stepfactor  = 0.5F;
-    reader->point = reader->offset;
-
-    return reader;
-}
-
-static
-void icvReleaseBackgroundReader( CvBackgroundReader** reader )
-{
-    assert( reader != NULL && (*reader) != NULL );
-
-    if( (*reader)->src.data.ptr != NULL )
-    {
-        cvFree( &((*reader)->src.data.ptr) );
-    }
-    if( (*reader)->img.data.ptr != NULL )
-    {
-        cvFree( &((*reader)->img.data.ptr) );
-    }
-
-    cvFree( reader );
-}
-
-static
-void icvGetNextFromBackgroundData( CvBackgroundData* data,
-                                   CvBackgroundReader* reader )
-{
-    IplImage* img = NULL;
-    size_t datasize = 0;
-    int round = 0;
-    int i = 0;
-    CvPoint offset = cvPoint(0,0);
-
-    assert( data != NULL && reader != NULL );
-
-    if( reader->src.data.ptr != NULL )
-    {
-        cvFree( &(reader->src.data.ptr) );
-        reader->src.data.ptr = NULL;
-    }
-    if( reader->img.data.ptr != NULL )
-    {
-        cvFree( &(reader->img.data.ptr) );
-        reader->img.data.ptr = NULL;
-    }
-
-    #ifdef CV_OPENMP
-    #pragma omp critical(c_background_data)
-    #endif /* CV_OPENMP */
-    {
-        for( i = 0; i < data->count; i++ )
-        {
-            round = data->round;
-
-//#ifdef CV_VERBOSE
-//            printf( "Open background image: %s\n", data->filename[data->last] );
-//#endif /* CV_VERBOSE */
-
-            data->last = rand() % data->count;
-            data->last %= data->count;
-            img = cvLoadImage( data->filename[data->last], 0 );
-            if( !img )
-                continue;
-            data->round += data->last / data->count;
-            data->round = data->round % (data->winsize.width * data->winsize.height);
-
-            offset.x = round % data->winsize.width;
-            offset.y = round / data->winsize.width;
-
-            offset.x = MIN( offset.x, img->width - data->winsize.width );
-            offset.y = MIN( offset.y, img->height - data->winsize.height );
-
-            if( img != NULL && img->depth == IPL_DEPTH_8U && img->nChannels == 1 &&
-                offset.x >= 0 && offset.y >= 0 )
-            {
-                break;
-            }
-            if( img != NULL )
-                cvReleaseImage( &img );
-            img = NULL;
-        }
-    }
-    if( img == NULL )
-    {
-        /* no appropriate image */
-
-#ifdef CV_VERBOSE
-        printf( "Invalid background description file.\n" );
-#endif /* CV_VERBOSE */
-
-        assert( 0 );
-        exit( 1 );
-    }
-    datasize = sizeof( uchar ) * img->width * img->height;
-    reader->src = cvMat( img->height, img->width, CV_8UC1, (void*) cvAlloc( datasize ) );
-    cvCopy( img, &reader->src, NULL );
-    cvReleaseImage( &img );
-    img = NULL;
-
-    //reader->offset.x = round % data->winsize.width;
-    //reader->offset.y = round / data->winsize.width;
-    reader->offset = offset;
-    reader->point = reader->offset;
-    reader->scale = MAX(
-        ((float) data->winsize.width + reader->point.x) / ((float) reader->src.cols),
-        ((float) data->winsize.height + reader->point.y) / ((float) reader->src.rows) );
-
-    reader->img = cvMat( (int) (reader->scale * reader->src.rows + 0.5F),
-                         (int) (reader->scale * reader->src.cols + 0.5F),
-                          CV_8UC1, (void*) cvAlloc( datasize ) );
-    cvResize( &(reader->src), &(reader->img) );
-}
-
-
-/*
- * icvGetBackgroundImage
- *
- * Get an image from background
- * <img> must be allocated and have size, previously passed to icvInitBackgroundReaders
- *
- * Usage example:
- * icvInitBackgroundReaders( "bg.txt", cvSize( 24, 24 ) );
- * ...
- * #pragma omp parallel
- * {
- *     ...
- *     icvGetBackgourndImage( cvbgdata, cvbgreader, img );
- *     ...
- * }
- * ...
- * icvDestroyBackgroundReaders();
- */
-static
-void icvGetBackgroundImage( CvBackgroundData* data,
-                            CvBackgroundReader* reader,
-                            CvMat* img )
-{
-    CvMat mat;
-
-    assert( data != NULL && reader != NULL && img != NULL );
-    assert( CV_MAT_TYPE( img->type ) == CV_8UC1 );
-    assert( img->cols == data->winsize.width );
-    assert( img->rows == data->winsize.height );
-
-    if( reader->img.data.ptr == NULL )
-    {
-        icvGetNextFromBackgroundData( data, reader );
-    }
-
-    mat = cvMat( data->winsize.height, data->winsize.width, CV_8UC1 );
-    cvSetData( &mat, (void*) (reader->img.data.ptr + reader->point.y * reader->img.step
-                              + reader->point.x * sizeof( uchar )), reader->img.step );
-
-    cvCopy( &mat, img, 0 );
-    if( (int) ( reader->point.x + (1.0F + reader->stepfactor ) * data->winsize.width )
-            < reader->img.cols )
-    {
-        reader->point.x += (int) (reader->stepfactor * data->winsize.width);
-    }
-    else
-    {
-        reader->point.x = reader->offset.x;
-        if( (int) ( reader->point.y + (1.0F + reader->stepfactor ) * data->winsize.height )
-                < reader->img.rows )
-        {
-            reader->point.y += (int) (reader->stepfactor * data->winsize.height);
-        }
-        else
-        {
-            reader->point.y = reader->offset.y;
-            reader->scale *= reader->scalefactor;
-            if( reader->scale <= 1.0F )
-            {
-                reader->img = cvMat( (int) (reader->scale * reader->src.rows),
-                                     (int) (reader->scale * reader->src.cols),
-                                      CV_8UC1, (void*) (reader->img.data.ptr) );
-                cvResize( &(reader->src), &(reader->img) );
-            }
-            else
-            {
-                icvGetNextFromBackgroundData( data, reader );
-            }
-        }
-    }
-}
-
-
-/*
- * icvInitBackgroundReaders
- *
- * Initialize background reading process.
- * <cvbgreader> and <cvbgdata> are initialized.
- * Must be called before any usage of background
- *
- * filename - name of background description file
- * winsize  - size of images will be obtained from background
- *
- * return 1 on success, 0 otherwise.
- */
-static
-int icvInitBackgroundReaders( const char* filename, CvSize winsize )
-{
-    if( cvbgdata == NULL && filename != NULL )
-    {
-        cvbgdata = icvCreateBackgroundData( filename, winsize );
-    }
-
-    if( cvbgdata )
-    {
-
-        #ifdef CV_OPENMP
-        #pragma omp parallel
-        #endif /* CV_OPENMP */
-        {
-            #ifdef CV_OPENMP
-            #pragma omp critical(c_create_bg_data)
-            #endif /* CV_OPENMP */
-            {
-                if( cvbgreader == NULL )
-                {
-                    cvbgreader = icvCreateBackgroundReader();
-                }
-            }
-        }
-
-    }
-
-    return (cvbgdata != NULL);
-}
-
-
-/*
- * icvDestroyBackgroundReaders
- *
- * Finish backgournd reading process
- */
-static
-void icvDestroyBackgroundReaders()
-{
-    /* release background reader in each thread */
-    #ifdef CV_OPENMP
-    #pragma omp parallel
-    #endif /* CV_OPENMP */
-    {
-        #ifdef CV_OPENMP
-        #pragma omp critical(c_release_bg_data)
-        #endif /* CV_OPENMP */
-        {
-            if( cvbgreader != NULL )
-            {
-                icvReleaseBackgroundReader( &cvbgreader );
-                cvbgreader = NULL;
-            }
-        }
-    }
-
-    if( cvbgdata != NULL )
-    {
-        icvReleaseBackgroundData( &cvbgdata );
-        cvbgdata = NULL;
-    }
-}
-
-
-/*
- * icvGetAuxImages
- *
- * Get sum, tilted, sqsum images and calculate normalization factor
- * All images must be allocated.
- */
-static
-void icvGetAuxImages( CvMat* img, CvMat* sum, CvMat* tilted,
-                      CvMat* sqsum, float* normfactor )
-{
-    CvRect normrect;
-    int p0, p1, p2, p3;
-    sum_type   valsum   = 0;
-    sqsum_type valsqsum = 0;
-    double area = 0.0;
-
-    cvIntegral( img, sum, sqsum, tilted );
-    normrect = cvRect( 1, 1, img->cols - 2, img->rows - 2 );
-    CV_SUM_OFFSETS( p0, p1, p2, p3, normrect, img->cols + 1 )
-
-    area = normrect.width * normrect.height;
-    valsum = ((sum_type*) (sum->data.ptr))[p0] - ((sum_type*) (sum->data.ptr))[p1]
-           - ((sum_type*) (sum->data.ptr))[p2] + ((sum_type*) (sum->data.ptr))[p3];
-    valsqsum = ((sqsum_type*) (sqsum->data.ptr))[p0]
-             - ((sqsum_type*) (sqsum->data.ptr))[p1]
-             - ((sqsum_type*) (sqsum->data.ptr))[p2]
-             + ((sqsum_type*) (sqsum->data.ptr))[p3];
-
-    /* sqrt( valsqsum / area - ( valsum / are )^2 ) * area */
-    (*normfactor) = (float) sqrt( (double) (area * valsqsum - (double)valsum * valsum) );
-}
-
-
-/* consumed counter */
-typedef uint64 ccounter_t;
-
-#define CCOUNTER_MAX CV_BIG_UINT(0xffffffffffffffff)
-#define CCOUNTER_SET_ZERO(cc) ((cc) = 0)
-#define CCOUNTER_INC(cc) ( (CCOUNTER_MAX > (cc) ) ? (++(cc)) : (CCOUNTER_MAX) )
-#define CCOUNTER_ADD(cc0, cc1) ( ((CCOUNTER_MAX-(cc1)) > (cc0) ) ? ((cc0) += (cc1)) : ((cc0) = CCOUNTER_MAX) )
-#define CCOUNTER_DIV(cc0, cc1) ( ((cc1) == 0) ? 0 : ( ((double)(cc0))/(double)(int64)(cc1) ) )
-
-
-
-/*
- * icvGetHaarTrainingData
- *
- * Unified method that can now be used for vec file, bg file and bg vec file
- *
- * Fill <data> with samples, passed <cascade>
- */
-static
-int icvGetHaarTrainingData( CvHaarTrainingData* data, int first, int count,
-                            CvIntHaarClassifier* cascade,
-                            CvGetHaarTrainingDataCallback callback, void* userdata,
-                            int* consumed, double* acceptance_ratio )
-{
-    int i = 0;
-    ccounter_t getcount = 0;
-    ccounter_t thread_getcount = 0;
-    ccounter_t consumed_count;
-    ccounter_t thread_consumed_count;
-
-    /* private variables */
-    CvMat img;
-    CvMat sum;
-    CvMat tilted;
-    CvMat sqsum;
-
-    sum_type* sumdata;
-    sum_type* tilteddata;
-    float*    normfactor;
-
-    /* end private variables */
-
-    assert( data != NULL );
-    assert( first + count <= data->maxnum );
-    assert( cascade != NULL );
-    assert( callback != NULL );
-
-    // if( !cvbgdata ) return 0; this check needs to be done in the callback for BG
-
-    CCOUNTER_SET_ZERO(getcount);
-    CCOUNTER_SET_ZERO(thread_getcount);
-    CCOUNTER_SET_ZERO(consumed_count);
-    CCOUNTER_SET_ZERO(thread_consumed_count);
-
-    #ifdef CV_OPENMP
-    #pragma omp parallel private(img, sum, tilted, sqsum, sumdata, tilteddata, \
-                                 normfactor, thread_consumed_count, thread_getcount)
-    #endif /* CV_OPENMP */
-    {
-        sumdata    = NULL;
-        tilteddata = NULL;
-        normfactor = NULL;
-
-        CCOUNTER_SET_ZERO(thread_getcount);
-        CCOUNTER_SET_ZERO(thread_consumed_count);
-        int ok = 1;
-
-        img = cvMat( data->winsize.height, data->winsize.width, CV_8UC1,
-            cvAlloc( sizeof( uchar ) * data->winsize.height * data->winsize.width ) );
-        sum = cvMat( data->winsize.height + 1, data->winsize.width + 1,
-                     CV_SUM_MAT_TYPE, NULL );
-        tilted = cvMat( data->winsize.height + 1, data->winsize.width + 1,
-                        CV_SUM_MAT_TYPE, NULL );
-        sqsum = cvMat( data->winsize.height + 1, data->winsize.width + 1, CV_SQSUM_MAT_TYPE,
-                       cvAlloc( sizeof( sqsum_type ) * (data->winsize.height + 1)
-                                                     * (data->winsize.width + 1) ) );
-
-        #ifdef CV_OPENMP
-        #pragma omp for schedule(static, 1)
-        #endif /* CV_OPENMP */
-        for( i = first; (i < first + count); i++ )
-        {
-            if( !ok )
-                continue;
-            for( ; ; )
-            {
-                ok = callback( &img, userdata );
-                if( !ok )
-                    break;
-
-                CCOUNTER_INC(thread_consumed_count);
-
-                sumdata = (sum_type*) (data->sum.data.ptr + i * data->sum.step);
-                tilteddata = (sum_type*) (data->tilted.data.ptr + i * data->tilted.step);
-                normfactor = data->normfactor.data.fl + i;
-                sum.data.ptr = (uchar*) sumdata;
-                tilted.data.ptr = (uchar*) tilteddata;
-                icvGetAuxImages( &img, &sum, &tilted, &sqsum, normfactor );
-                if( cascade->eval( cascade, sumdata, tilteddata, *normfactor ) != 0.0F )
-                {
-                    CCOUNTER_INC(thread_getcount);
-                    break;
-                }
-            }
-
-#ifdef CV_VERBOSE
-            if( (i - first) % 500 == 0 )
-            {
-                fprintf( stderr, "%3d%%\r", (int) ( 100.0 * (i - first) / count ) );
-                fflush( stderr );
-            }
-#endif /* CV_VERBOSE */
-        }
-
-        cvFree( &(img.data.ptr) );
-        cvFree( &(sqsum.data.ptr) );
-
-        #ifdef CV_OPENMP
-        #pragma omp critical (c_consumed_count)
-        #endif /* CV_OPENMP */
-        {
-            /* consumed_count += thread_consumed_count; */
-            CCOUNTER_ADD(getcount, thread_getcount);
-            CCOUNTER_ADD(consumed_count, thread_consumed_count);
-        }
-    } /* omp parallel */
-
-    if( consumed != NULL )
-    {
-        *consumed = (int)consumed_count;
-    }
-
-    if( acceptance_ratio != NULL )
-    {
-        /* *acceptance_ratio = ((double) count) / consumed_count; */
-        *acceptance_ratio = CCOUNTER_DIV(count, consumed_count);
-    }
-
-    return static_cast<int>(getcount);
-}
-
-/*
- * icvGetHaarTrainingDataFromBG
- *
- * Fill <data> with background samples, passed <cascade>
- * Background reading process must be initialized before call.
- */
-//static
-//int icvGetHaarTrainingDataFromBG( CvHaarTrainingData* data, int first, int count,
-//                                  CvIntHaarClassifier* cascade, double* acceptance_ratio )
-//{
-//    int i = 0;
-//    ccounter_t consumed_count;
-//    ccounter_t thread_consumed_count;
-//
-//    /* private variables */
-//    CvMat img;
-//    CvMat sum;
-//    CvMat tilted;
-//    CvMat sqsum;
-//
-//    sum_type* sumdata;
-//    sum_type* tilteddata;
-//    float*    normfactor;
-//
-//    /* end private variables */
-//
-//    assert( data != NULL );
-//    assert( first + count <= data->maxnum );
-//    assert( cascade != NULL );
-//
-//    if( !cvbgdata ) return 0;
-//
-//    CCOUNTER_SET_ZERO(consumed_count);
-//    CCOUNTER_SET_ZERO(thread_consumed_count);
-//
-//    #ifdef CV_OPENMP
-//    #pragma omp parallel private(img, sum, tilted, sqsum, sumdata, tilteddata,
-//                                 normfactor, thread_consumed_count)
-//    #endif /* CV_OPENMP */
-//    {
-//        sumdata    = NULL;
-//        tilteddata = NULL;
-//        normfactor = NULL;
-//
-//        CCOUNTER_SET_ZERO(thread_consumed_count);
-//
-//        img = cvMat( data->winsize.height, data->winsize.width, CV_8UC1,
-//            cvAlloc( sizeof( uchar ) * data->winsize.height * data->winsize.width ) );
-//        sum = cvMat( data->winsize.height + 1, data->winsize.width + 1,
-//                     CV_SUM_MAT_TYPE, NULL );
-//        tilted = cvMat( data->winsize.height + 1, data->winsize.width + 1,
-//                        CV_SUM_MAT_TYPE, NULL );
-//        sqsum = cvMat( data->winsize.height + 1, data->winsize.width + 1,
-//                       CV_SQSUM_MAT_TYPE,
-//                       cvAlloc( sizeof( sqsum_type ) * (data->winsize.height + 1)
-//                                                     * (data->winsize.width + 1) ) );
-//
-//        #ifdef CV_OPENMP
-//        #pragma omp for schedule(static, 1)
-//        #endif /* CV_OPENMP */
-//        for( i = first; i < first + count; i++ )
-//        {
-//            for( ; ; )
-//            {
-//                icvGetBackgroundImage( cvbgdata, cvbgreader, &img );
-//
-//                CCOUNTER_INC(thread_consumed_count);
-//
-//                sumdata = (sum_type*) (data->sum.data.ptr + i * data->sum.step);
-//                tilteddata = (sum_type*) (data->tilted.data.ptr + i * data->tilted.step);
-//                normfactor = data->normfactor.data.fl + i;
-//                sum.data.ptr = (uchar*) sumdata;
-//                tilted.data.ptr = (uchar*) tilteddata;
-//                icvGetAuxImages( &img, &sum, &tilted, &sqsum, normfactor );
-//                if( cascade->eval( cascade, sumdata, tilteddata, *normfactor ) != 0.0F )
-//                {
-//                    break;
-//                }
-//            }
-//
-//#ifdef CV_VERBOSE
-//            if( (i - first) % 500 == 0 )
-//            {
-//                fprintf( stderr, "%3d%%\r", (int) ( 100.0 * (i - first) / count ) );
-//                fflush( stderr );
-//            }
-//#endif /* CV_VERBOSE */
-//
-//        }
-//
-//        cvFree( &(img.data.ptr) );
-//        cvFree( &(sqsum.data.ptr) );
-//
-//        #ifdef CV_OPENMP
-//        #pragma omp critical (c_consumed_count)
-//        #endif /* CV_OPENMP */
-//        {
-//            /* consumed_count += thread_consumed_count; */
-//            CCOUNTER_ADD(consumed_count, thread_consumed_count);
-//        }
-//    } /* omp parallel */
-//
-//    if( acceptance_ratio != NULL )
-//    {
-//        /* *acceptance_ratio = ((double) count) / consumed_count; */
-//        *acceptance_ratio = CCOUNTER_DIV(count, consumed_count);
-//    }
-//
-//    return count;
-//}
-
-int icvGetHaarTraininDataFromVecCallback( CvMat* img, void* userdata )
-{
-    uchar tmp = 0;
-    int r = 0;
-    int c = 0;
-
-    assert( img->rows * img->cols == ((CvVecFile*) userdata)->vecsize );
-
-    size_t elements_read = fread( &tmp, sizeof( tmp ), 1, ((CvVecFile*) userdata)->input );
-    CV_Assert(elements_read == 1);
-    elements_read = fread( ((CvVecFile*) userdata)->vector, sizeof( short ),
-           ((CvVecFile*) userdata)->vecsize, ((CvVecFile*) userdata)->input );
-    CV_Assert(elements_read == (size_t)((CvVecFile*) userdata)->vecsize);
-
-    if( feof( ((CvVecFile*) userdata)->input ) ||
-        (((CvVecFile*) userdata)->last)++ >= ((CvVecFile*) userdata)->count )
-    {
-        return 0;
-    }
-
-    for( r = 0; r < img->rows; r++ )
-    {
-        for( c = 0; c < img->cols; c++ )
-        {
-            CV_MAT_ELEM( *img, uchar, r, c ) =
-                (uchar) ( ((CvVecFile*) userdata)->vector[r * img->cols + c] );
-        }
-    }
-
-    return 1;
-}
-
-static int icvGetHaarTrainingDataFromBGCallback ( CvMat* img, void* /*userdata*/ )
-{
-    if (! cvbgdata)
-      return 0;
-
-    if (! cvbgreader)
-      return 0;
-
-    // just in case icvGetBackgroundImage is not thread-safe ...
-    #ifdef CV_OPENMP
-    #pragma omp critical (get_background_image_callback)
-    #endif /* CV_OPENMP */
-    {
-      icvGetBackgroundImage( cvbgdata, cvbgreader, img );
-    }
-
-    return 1;
-}
-
-/*
- * icvGetHaarTrainingDataFromVec
- * Get training data from .vec file
- */
-static
-int icvGetHaarTrainingDataFromVec( CvHaarTrainingData* data, int first, int count,
-                                   CvIntHaarClassifier* cascade,
-                                   const char* filename,
-                                   int* consumed )
-{
-    int getcount = 0;
-
-    CV_FUNCNAME( "icvGetHaarTrainingDataFromVec" );
-
-    __BEGIN__;
-
-    CvVecFile file;
-    short tmp = 0;
-
-    file.input = NULL;
-    if( filename ) file.input = fopen( filename, "rb" );
-
-    if( file.input != NULL )
-    {
-        size_t elements_read1 = fread( &file.count, sizeof( file.count ), 1, file.input );
-        size_t elements_read2 = fread( &file.vecsize, sizeof( file.vecsize ), 1, file.input );
-        size_t elements_read3 = fread( &tmp, sizeof( tmp ), 1, file.input );
-        size_t elements_read4 = fread( &tmp, sizeof( tmp ), 1, file.input );
-        CV_Assert(elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1);
-
-        if( !feof( file.input ) )
-        {
-            if( file.vecsize != data->winsize.width * data->winsize.height )
-            {
-                fclose( file.input );
-                CV_ERROR( CV_StsError, "Vec file sample size mismatch" );
-            }
-
-            file.last = 0;
-            file.vector = (short*) cvAlloc( sizeof( *file.vector ) * file.vecsize );
-            getcount = icvGetHaarTrainingData( data, first, count, cascade,
-                icvGetHaarTraininDataFromVecCallback, &file, consumed, NULL);
-            cvFree( &file.vector );
-        }
-        fclose( file.input );
-    }
-
-    __END__;
-
-    return getcount;
-}
-
-/*
- * icvGetHaarTrainingDataFromBG
- *
- * Fill <data> with background samples, passed <cascade>
- * Background reading process must be initialized before call, alternaly, a file
- * name to a vec file may be passed, a NULL filename indicates old behaviour
- */
-static
-int icvGetHaarTrainingDataFromBG( CvHaarTrainingData* data, int first, int count,
-                                  CvIntHaarClassifier* cascade, double* acceptance_ratio, const char * filename = NULL )
-{
-    CV_FUNCNAME( "icvGetHaarTrainingDataFromBG" );
-
-    __BEGIN__;
-
-    if (filename)
-    {
-        CvVecFile file;
-        short tmp = 0;
-
-        file.input = NULL;
-        if( filename ) file.input = fopen( filename, "rb" );
-
-        if( file.input != NULL )
-        {
-            size_t elements_read1 = fread( &file.count, sizeof( file.count ), 1, file.input );
-            size_t elements_read2 = fread( &file.vecsize, sizeof( file.vecsize ), 1, file.input );
-            size_t elements_read3 = fread( &tmp, sizeof( tmp ), 1, file.input );
-            size_t elements_read4 = fread( &tmp, sizeof( tmp ), 1, file.input );
-            CV_Assert(elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1);
-            if( !feof( file.input ) )
-            {
-                if( file.vecsize != data->winsize.width * data->winsize.height )
-                {
-                    fclose( file.input );
-                    CV_ERROR( CV_StsError, "Vec file sample size mismatch" );
-                }
-
-                file.last = 0;
-                file.vector = (short*) cvAlloc( sizeof( *file.vector ) * file.vecsize );
-                icvGetHaarTrainingData( data, first, count, cascade,
-                    icvGetHaarTraininDataFromVecCallback, &file, NULL, acceptance_ratio);
-                cvFree( &file.vector );
-            }
-            fclose( file.input );
-        }
-    }
-    else
-    {
-        icvGetHaarTrainingData( data, first, count, cascade,
-            icvGetHaarTrainingDataFromBGCallback, NULL, NULL, acceptance_ratio);
-    }
-
-    __END__;
-
-    return count;
-}
-
-void cvCreateCascadeClassifier( const char* dirname,
-                                const char* vecfilename,
-                                const char* bgfilename,
-                                int npos, int nneg, int nstages,
-                                int numprecalculated,
-                                int numsplits,
-                                float minhitrate, float maxfalsealarm,
-                                float weightfraction,
-                                int mode, int symmetric,
-                                int equalweights,
-                                int winwidth, int winheight,
-                                int boosttype, int stumperror )
-{
-    CvCascadeHaarClassifier* cascade = NULL;
-    CvHaarTrainingData* data = NULL;
-    CvIntHaarFeatures* haar_features;
-    CvSize winsize;
-    int i = 0;
-    int j = 0;
-    int poscount = 0;
-    int negcount = 0;
-    int consumed = 0;
-    double false_alarm = 0;
-    char stagename[PATH_MAX];
-    float posweight = 1.0F;
-    float negweight = 1.0F;
-    FILE* file;
-
-#ifdef CV_VERBOSE
-    double proctime = 0.0F;
-#endif /* CV_VERBOSE */
-
-    assert( dirname != NULL );
-    assert( bgfilename != NULL );
-    assert( vecfilename != NULL );
-    assert( nstages > 0 );
-
-    winsize = cvSize( winwidth, winheight );
-
-    cascade = (CvCascadeHaarClassifier*) icvCreateCascadeHaarClassifier( nstages );
-    cascade->count = 0;
-
-    if( icvInitBackgroundReaders( bgfilename, winsize ) )
-    {
-        data = icvCreateHaarTrainingData( winsize, npos + nneg );
-        haar_features = icvCreateIntHaarFeatures( winsize, mode, symmetric );
-
-#ifdef CV_VERBOSE
-        printf("Number of features used : %d\n", haar_features->count);
-#endif /* CV_VERBOSE */
-
-        for( i = 0; i < nstages; i++, cascade->count++ )
-        {
-            sprintf( stagename, "%s%d/%s", dirname, i, CV_STAGE_CART_FILE_NAME );
-            cascade->classifier[i] =
-                icvLoadCARTStageHaarClassifier( stagename, winsize.width + 1 );
-
-            if( !icvMkDir( stagename ) )
-            {
-
-#ifdef CV_VERBOSE
-                printf( "UNABLE TO CREATE DIRECTORY: %s\n", stagename );
-#endif /* CV_VERBOSE */
-
-                break;
-            }
-            if( cascade->classifier[i] != NULL )
-            {
-
-#ifdef CV_VERBOSE
-                printf( "STAGE: %d LOADED.\n", i );
-#endif /* CV_VERBOSE */
-
-                continue;
-            }
-
-#ifdef CV_VERBOSE
-            printf( "STAGE: %d\n", i );
-#endif /* CV_VERBOSE */
-
-            poscount = icvGetHaarTrainingDataFromVec( data, 0, npos,
-                (CvIntHaarClassifier*) cascade, vecfilename, &consumed );
-#ifdef CV_VERBOSE
-            printf( "POS: %d %d %f\n", poscount, consumed,
-                    ((float) poscount) / consumed );
-#endif /* CV_VERBOSE */
-
-            if( poscount <= 0 )
-            {
-
-#ifdef CV_VERBOSE
-            printf( "UNABLE TO OBTAIN POS SAMPLES\n" );
-#endif /* CV_VERBOSE */
-
-                break;
-            }
-
-#ifdef CV_VERBOSE
-            proctime = -TIME( 0 );
-#endif /* CV_VERBOSE */
-
-            negcount = icvGetHaarTrainingDataFromBG( data, poscount, nneg,
-                (CvIntHaarClassifier*) cascade, &false_alarm );
-#ifdef CV_VERBOSE
-            printf( "NEG: %d %g\n", negcount, false_alarm );
-            printf( "BACKGROUND PROCESSING TIME: %.2f\n",
-                (proctime + TIME( 0 )) );
-#endif /* CV_VERBOSE */
-
-            if( negcount <= 0 )
-            {
-
-#ifdef CV_VERBOSE
-            printf( "UNABLE TO OBTAIN NEG SAMPLES\n" );
-#endif /* CV_VERBOSE */
-
-                break;
-            }
-
-            data->sum.rows = data->tilted.rows = poscount + negcount;
-            data->normfactor.cols = data->weights.cols = data->cls.cols =
-                    poscount + negcount;
-
-            posweight = (equalweights) ? 1.0F / (poscount + negcount) : (0.5F / poscount);
-            negweight = (equalweights) ? 1.0F / (poscount + negcount) : (0.5F / negcount);
-            for( j = 0; j < poscount; j++ )
-            {
-                data->weights.data.fl[j] = posweight;
-                data->cls.data.fl[j] = 1.0F;
-
-            }
-            for( j = poscount; j < poscount + negcount; j++ )
-            {
-                data->weights.data.fl[j] = negweight;
-                data->cls.data.fl[j] = 0.0F;
-            }
-
-#ifdef CV_VERBOSE
-            proctime = -TIME( 0 );
-#endif /* CV_VERBOSE */
-
-            icvPrecalculate( data, haar_features, numprecalculated );
-
-#ifdef CV_VERBOSE
-            printf( "PRECALCULATION TIME: %.2f\n", (proctime + TIME( 0 )) );
-#endif /* CV_VERBOSE */
-
-#ifdef CV_VERBOSE
-            proctime = -TIME( 0 );
-#endif /* CV_VERBOSE */
-
-            cascade->classifier[i] = icvCreateCARTStageClassifier(  data, NULL,
-                haar_features, minhitrate, maxfalsealarm, symmetric, weightfraction,
-                numsplits, (CvBoostType) boosttype, (CvStumpError) stumperror, 0 );
-
-#ifdef CV_VERBOSE
-            printf( "STAGE TRAINING TIME: %.2f\n", (proctime + TIME( 0 )) );
-#endif /* CV_VERBOSE */
-
-            file = fopen( stagename, "w" );
-            if( file != NULL )
-            {
-                cascade->classifier[i]->save(
-                    (CvIntHaarClassifier*) cascade->classifier[i], file );
-                fclose( file );
-            }
-            else
-            {
-
-#ifdef CV_VERBOSE
-                printf( "FAILED TO SAVE STAGE CLASSIFIER IN FILE %s\n", stagename );
-#endif /* CV_VERBOSE */
-
-            }
-
-        }
-        icvReleaseIntHaarFeatures( &haar_features );
-        icvReleaseHaarTrainingData( &data );
-
-        if( i == nstages )
-        {
-            char xml_path[1024];
-            int len = (int)strlen(dirname);
-            CvHaarClassifierCascade* cascade1 = 0;
-            strcpy( xml_path, dirname );
-            if( xml_path[len-1] == '\\' || xml_path[len-1] == '/' )
-                len--;
-            strcpy( xml_path + len, ".xml" );
-            cascade1 = cvLoadHaarClassifierCascade( dirname, cvSize(winwidth,winheight) );
-            if( cascade1 )
-                cvSave( xml_path, cascade1 );
-            cvReleaseHaarClassifierCascade( &cascade1 );
-        }
-    }
-    else
-    {
-#ifdef CV_VERBOSE
-        printf( "FAILED TO INITIALIZE BACKGROUND READERS\n" );
-#endif /* CV_VERBOSE */
-    }
-
-    /* CLEAN UP */
-    icvDestroyBackgroundReaders();
-    cascade->release( (CvIntHaarClassifier**) &cascade );
-}
-
-/* tree cascade classifier */
-
-static int icvNumSplits( CvStageHaarClassifier* stage )
-{
-    int i;
-    int num;
-
-    num = 0;
-    for( i = 0; i < stage->count; i++ )
-    {
-        num += ((CvCARTHaarClassifier*) stage->classifier[i])->count;
-    }
-
-    return num;
-}
-
-static void icvSetNumSamples( CvHaarTrainingData* training_data, int num )
-{
-    assert( num <= training_data->maxnum );
-
-    training_data->sum.rows = training_data->tilted.rows = num;
-    training_data->normfactor.cols = num;
-    training_data->cls.cols = training_data->weights.cols = num;
-}
-
-static void icvSetWeightsAndClasses( CvHaarTrainingData* training_data,
-                              int num1, float weight1, float cls1,
-                              int num2, float weight2, float cls2 )
-{
-    int j;
-
-    assert( num1 + num2 <= training_data->maxnum );
-
-    for( j = 0; j < num1; j++ )
-    {
-        training_data->weights.data.fl[j] = weight1;
-        training_data->cls.data.fl[j] = cls1;
-    }
-    for( j = num1; j < num1 + num2; j++ )
-    {
-        training_data->weights.data.fl[j] = weight2;
-        training_data->cls.data.fl[j] = cls2;
-    }
-}
-
-static CvMat* icvGetUsedValues( CvHaarTrainingData* training_data,
-                         int start, int num,
-                         CvIntHaarFeatures* haar_features,
-                         CvStageHaarClassifier* stage )
-{
-    CvMat* ptr = NULL;
-    CvMat* feature_idx = NULL;
-
-    CV_FUNCNAME( "icvGetUsedValues" );
-
-    __BEGIN__;
-
-    int num_splits;
-    int i, j;
-    int r;
-    int total, last;
-
-    num_splits = icvNumSplits( stage );
-
-    CV_CALL( feature_idx = cvCreateMat( 1, num_splits, CV_32SC1 ) );
-
-    total = 0;
-    for( i = 0; i < stage->count; i++ )
-    {
-        CvCARTHaarClassifier* cart;
-
-        cart = (CvCARTHaarClassifier*) stage->classifier[i];
-        for( j = 0; j < cart->count; j++ )
-        {
-            feature_idx->data.i[total++] = cart->compidx[j];
-        }
-    }
-    std::sort(feature_idx->data.i, feature_idx->data.i + total);
-
-    last = 0;
-    for( i = 1; i < total; i++ )
-    {
-        if( feature_idx->data.i[i] != feature_idx->data.i[last] )
-        {
-            feature_idx->data.i[++last] = feature_idx->data.i[i];
-        }
-    }
-    total = last + 1;
-    CV_CALL( ptr = cvCreateMat( num, total, CV_32FC1 ) );
-
-
-    #ifdef CV_OPENMP
-    #pragma omp parallel for
-    #endif
-    for( r = start; r < start + num; r++ )
-    {
-        int c;
-
-        for( c = 0; c < total; c++ )
-        {
-            float val, normfactor;
-            int fnum;
-
-            fnum = feature_idx->data.i[c];
-
-            val = cvEvalFastHaarFeature( haar_features->fastfeature + fnum,
-                (sum_type*) (training_data->sum.data.ptr
-                        + r * training_data->sum.step),
-                (sum_type*) (training_data->tilted.data.ptr
-                        + r * training_data->tilted.step) );
-            normfactor = training_data->normfactor.data.fl[r];
-            val = ( normfactor == 0.0F ) ? 0.0F : (val / normfactor);
-            CV_MAT_ELEM( *ptr, float, r - start, c ) = val;
-        }
-    }
-
-    __END__;
-
-    cvReleaseMat( &feature_idx );
-
-    return ptr;
-}
-
-/* possible split in the tree */
-typedef struct CvSplit
-{
-    CvTreeCascadeNode* parent;
-    CvTreeCascadeNode* single_cluster;
-    CvTreeCascadeNode* multiple_clusters;
-    int num_clusters;
-    float single_multiple_ratio;
-
-    struct CvSplit* next;
-} CvSplit;
-
-
-void cvCreateTreeCascadeClassifier( const char* dirname,
-                                    const char* vecfilename,
-                                    const char* bgfilename,
-                                    int npos, int nneg, int nstages,
-                                    int numprecalculated,
-                                    int numsplits,
-                                    float minhitrate, float maxfalsealarm,
-                                    float weightfraction,
-                                    int mode, int symmetric,
-                                    int equalweights,
-                                    int winwidth, int winheight,
-                                    int boosttype, int stumperror,
-                                    int maxtreesplits, int minpos, bool bg_vecfile )
-{
-    CvTreeCascadeClassifier* tcc = NULL;
-    CvIntHaarFeatures* haar_features = NULL;
-    CvHaarTrainingData* training_data = NULL;
-    CvMat* vals = NULL;
-    CvMat* cluster_idx = NULL;
-    CvMat* idx = NULL;
-    CvMat* features_idx = NULL;
-
-    CV_FUNCNAME( "cvCreateTreeCascadeClassifier" );
-
-    __BEGIN__;
-
-    int i, k;
-    CvTreeCascadeNode* leaves;
-    int best_num, cur_num;
-    CvSize winsize;
-    char stage_name[PATH_MAX];
-    char buf[PATH_MAX];
-    char* suffix;
-    int total_splits;
-
-    int poscount;
-    int negcount;
-    int consumed;
-    double false_alarm;
-    double proctime;
-
-    int nleaves;
-    double required_leaf_fa_rate;
-    float neg_ratio;
-
-    int max_clusters;
-
-    max_clusters = CV_MAX_CLUSTERS;
-    neg_ratio = (float) nneg / npos;
-
-    nleaves = 1 + MAX( 0, maxtreesplits );
-    required_leaf_fa_rate = pow( (double) maxfalsealarm, (double) nstages ) / nleaves;
-
-    printf( "Required leaf false alarm rate: %g\n", required_leaf_fa_rate );
-
-    total_splits = 0;
-
-    winsize = cvSize( winwidth, winheight );
-
-    CV_CALL( cluster_idx = cvCreateMat( 1, npos + nneg, CV_32SC1 ) );
-    CV_CALL( idx = cvCreateMat( 1, npos + nneg, CV_32SC1 ) );
-
-    CV_CALL( tcc = (CvTreeCascadeClassifier*)
-        icvLoadTreeCascadeClassifier( dirname, winwidth + 1, &total_splits ) );
-    CV_CALL( leaves = icvFindDeepestLeaves( tcc ) );
-
-    CV_CALL( icvPrintTreeCascade( tcc->root ) );
-
-    haar_features = icvCreateIntHaarFeatures( winsize, mode, symmetric );
-
-    printf( "Number of features used : %d\n", haar_features->count );
-
-    training_data = icvCreateHaarTrainingData( winsize, npos + nneg );
-
-    sprintf( stage_name, "%s/", dirname );
-    suffix = stage_name + strlen( stage_name );
-
-    if (! bg_vecfile)
-      if( !icvInitBackgroundReaders( bgfilename, winsize ) && nstages > 0 )
-          CV_ERROR( CV_StsError, "Unable to read negative images" );
-
-    if( nstages > 0 )
-    {
-        /* width-first search in the tree */
-        do
-        {
-            CvSplit* first_split;
-            CvSplit* last_split;
-            CvSplit* cur_split;
-
-            CvTreeCascadeNode* parent;
-            CvTreeCascadeNode* cur_node;
-            CvTreeCascadeNode* last_node;
-
-            first_split = last_split = cur_split = NULL;
-            parent = leaves;
-            leaves = NULL;
-            do
-            {
-                int best_clusters; /* best selected number of clusters */
-                float posweight, negweight;
-                double leaf_fa_rate;
-
-                if( parent ) sprintf( buf, "%d", parent->idx );
-                else sprintf( buf, "NULL" );
-                printf( "\nParent node: %s\n\n", buf );
-
-                printf( "*** 1 cluster ***\n" );
-
-                tcc->eval = icvEvalTreeCascadeClassifierFilter;
-                /* find path from the root to the node <parent> */
-                icvSetLeafNode( tcc, parent );
-
-                /* load samples */
-                consumed = 0;
-                poscount = icvGetHaarTrainingDataFromVec( training_data, 0, npos,
-                    (CvIntHaarClassifier*) tcc, vecfilename, &consumed );
-
-                printf( "POS: %d %d %f\n", poscount, consumed, ((double) poscount)/consumed );
-
-                if( poscount <= 0 )
-                    CV_ERROR( CV_StsError, "Unable to obtain positive samples" );
-
-                fflush( stdout );
-
-                proctime = -TIME( 0 );
-
-                nneg = (int) (neg_ratio * poscount);
-                negcount = icvGetHaarTrainingDataFromBG( training_data, poscount, nneg,
-                    (CvIntHaarClassifier*) tcc, &false_alarm, bg_vecfile ? bgfilename : NULL );
-                printf( "NEG: %d %g\n", negcount, false_alarm );
-
-                printf( "BACKGROUND PROCESSING TIME: %.2f\n", (proctime + TIME( 0 )) );
-
-                if( negcount <= 0 )
-                    CV_ERROR( CV_StsError, "Unable to obtain negative samples" );
-
-                leaf_fa_rate = false_alarm;
-                if( leaf_fa_rate <= required_leaf_fa_rate )
-                {
-                    printf( "Required leaf false alarm rate achieved. "
-                            "Branch training terminated.\n" );
-                }
-                else if( nleaves == 1 && tcc->next_idx == nstages )
-                {
-                    printf( "Required number of stages achieved. "
-                            "Branch training terminated.\n" );
-                }
-                else
-                {
-                    CvTreeCascadeNode* single_cluster;
-                    CvTreeCascadeNode* multiple_clusters;
-                    int single_num;
-
-                    icvSetNumSamples( training_data, poscount + negcount );
-                    posweight = (equalweights) ? 1.0F / (poscount + negcount) : (0.5F/poscount);
-                    negweight = (equalweights) ? 1.0F / (poscount + negcount) : (0.5F/negcount);
-                    icvSetWeightsAndClasses( training_data,
-                        poscount, posweight, 1.0F, negcount, negweight, 0.0F );
-
-                    fflush( stdout );
-
-                    /* precalculate feature values */
-                    proctime = -TIME( 0 );
-                    icvPrecalculate( training_data, haar_features, numprecalculated );
-                    printf( "Precalculation time: %.2f\n", (proctime + TIME( 0 )) );
-
-                    /* train stage classifier using all positive samples */
-                    CV_CALL( single_cluster = icvCreateTreeCascadeNode() );
-                    fflush( stdout );
-
-                    proctime = -TIME( 0 );
-                    single_cluster->stage =
-                        (CvStageHaarClassifier*) icvCreateCARTStageClassifier(
-                            training_data, NULL, haar_features,
-                            minhitrate, maxfalsealarm, symmetric,
-                            weightfraction, numsplits, (CvBoostType) boosttype,
-                            (CvStumpError) stumperror, 0 );
-                    printf( "Stage training time: %.2f\n", (proctime + TIME( 0 )) );
-
-                    single_num = icvNumSplits( single_cluster->stage );
-                    best_num = single_num;
-                    best_clusters = 1;
-                    multiple_clusters = NULL;
-
-                    printf( "Number of used features: %d\n", single_num );
-
-                    if( maxtreesplits >= 0 )
-                    {
-                        max_clusters = MIN( max_clusters, maxtreesplits - total_splits + 1 );
-                    }
-
-                    /* try clustering */
-                    vals = NULL;
-                    for( k = 2; k <= max_clusters; k++ )
-                    {
-                        int cluster;
-                        int stop_clustering;
-
-                        printf( "*** %d clusters ***\n", k );
-
-                        /* check whether clusters are big enough */
-                        stop_clustering = ( k * minpos > poscount );
-                        if( !stop_clustering )
-                        {
-                            int num[CV_MAX_CLUSTERS];
-
-                            if( k == 2 )
-                            {
-                                proctime = -TIME( 0 );
-                                CV_CALL( vals = icvGetUsedValues( training_data, 0, poscount,
-                                    haar_features, single_cluster->stage ) );
-                                printf( "Getting values for clustering time: %.2f\n", (proctime + TIME(0)) );
-                                printf( "Value matirx size: %d x %d\n", vals->rows, vals->cols );
-                                fflush( stdout );
-
-                                cluster_idx->cols = vals->rows;
-                                for( i = 0; i < negcount; i++ ) idx->data.i[i] = poscount + i;
-                            }
-
-                            proctime = -TIME( 0 );
-
-                            CV_CALL( cvKMeans2( vals, k, cluster_idx, CV_TERM_CRITERIA() ) );
-
-                            printf( "Clustering time: %.2f\n", (proctime + TIME( 0 )) );
-
-                            for( cluster = 0; cluster < k; cluster++ ) num[cluster] = 0;
-                            for( i = 0; i < cluster_idx->cols; i++ )
-                                num[cluster_idx->data.i[i]]++;
-                            for( cluster = 0; cluster < k; cluster++ )
-                            {
-                                if( num[cluster] < minpos )
-                                {
-                                    stop_clustering = 1;
-                                    break;
-                                }
-                            }
-                        }
-
-                        if( stop_clustering )
-                        {
-                            printf( "Clusters are too small. Clustering aborted.\n" );
-                            break;
-                        }
-
-                        cur_num = 0;
-                        cur_node = last_node = NULL;
-                        for( cluster = 0; (cluster < k) && (cur_num < best_num); cluster++ )
-                        {
-                            CvTreeCascadeNode* new_node;
-
-                            int num_splits;
-                            int last_pos;
-                            int total_pos;
-
-                            printf( "Cluster: %d\n", cluster );
-
-                            last_pos = negcount;
-                            for( i = 0; i < cluster_idx->cols; i++ )
-                            {
-                                if( cluster_idx->data.i[i] == cluster )
-                                {
-                                    idx->data.i[last_pos++] = i;
-                                }
-                            }
-                            idx->cols = last_pos;
-
-                            total_pos = idx->cols - negcount;
-                            printf( "# pos: %d of %d. (%d%%)\n", total_pos, poscount,
-                                100 * total_pos / poscount );
-
-                            CV_CALL( new_node = icvCreateTreeCascadeNode() );
-                            if( last_node ) last_node->next = new_node;
-                            else cur_node = new_node;
-                            last_node = new_node;
-
-                            posweight = (equalweights)
-                                ? 1.0F / (total_pos + negcount) : (0.5F / total_pos);
-                            negweight = (equalweights)
-                                ? 1.0F / (total_pos + negcount) : (0.5F / negcount);
-
-                            icvSetWeightsAndClasses( training_data,
-                                poscount, posweight, 1.0F, negcount, negweight, 0.0F );
-
-                            /* CV_DEBUG_SAVE( idx ); */
-
-                            fflush( stdout );
-
-                            proctime = -TIME( 0 );
-                            new_node->stage = (CvStageHaarClassifier*)
-                                icvCreateCARTStageClassifier( training_data, idx, haar_features,
-                                    minhitrate, maxfalsealarm, symmetric,
-                                    weightfraction, numsplits, (CvBoostType) boosttype,
-                                    (CvStumpError) stumperror, best_num - cur_num );
-                            printf( "Stage training time: %.2f\n", (proctime + TIME( 0 )) );
-
-                            if( !(new_node->stage) )
-                            {
-                                printf( "Stage training aborted.\n" );
-                                cur_num = best_num + 1;
-                            }
-                            else
-                            {
-                                num_splits = icvNumSplits( new_node->stage );
-                                cur_num += num_splits;
-
-                                printf( "Number of used features: %d\n", num_splits );
-                            }
-                        } /* for each cluster */
-
-                        if( cur_num < best_num )
-                        {
-                            icvReleaseTreeCascadeNodes( &multiple_clusters );
-                            best_num = cur_num;
-                            best_clusters = k;
-                            multiple_clusters = cur_node;
-                        }
-                        else
-                        {
-                            icvReleaseTreeCascadeNodes( &cur_node );
-                        }
-                    } /* try different number of clusters */
-                    cvReleaseMat( &vals );
-
-                    CvSplit* curSplit;
-                    CV_CALL( curSplit = (CvSplit*) cvAlloc( sizeof( *curSplit ) ) );
-                    memset(curSplit, 0, sizeof(*curSplit));
-
-                    if( last_split ) last_split->next = curSplit;
-                    else first_split = curSplit;
-                    last_split = curSplit;
-
-                    curSplit->single_cluster = single_cluster;
-                    curSplit->multiple_clusters = multiple_clusters;
-                    curSplit->num_clusters = best_clusters;
-                    curSplit->parent = parent;
-                    curSplit->single_multiple_ratio = (float) single_num / best_num;
-                }
-
-                if( parent ) parent = parent->next_same_level;
-            } while( parent );
-
-            /* choose which nodes should be splitted */
-            do
-            {
-                float max_single_multiple_ratio;
-
-                cur_split = NULL;
-                max_single_multiple_ratio = 0.0F;
-                last_split = first_split;
-                while( last_split )
-                {
-                    if( last_split->single_cluster && last_split->multiple_clusters &&
-                        last_split->single_multiple_ratio > max_single_multiple_ratio )
-                    {
-                        max_single_multiple_ratio = last_split->single_multiple_ratio;
-                        cur_split = last_split;
-                    }
-                    last_split = last_split->next;
-                }
-                if( cur_split )
-                {
-                    if( maxtreesplits < 0 ||
-                        cur_split->num_clusters <= maxtreesplits - total_splits + 1 )
-                    {
-                        cur_split->single_cluster = NULL;
-                        total_splits += cur_split->num_clusters - 1;
-                    }
-                    else
-                    {
-                        icvReleaseTreeCascadeNodes( &(cur_split->multiple_clusters) );
-                        cur_split->multiple_clusters = NULL;
-                    }
-                }
-            } while( cur_split );
-
-            /* attach new nodes to the tree */
-            leaves = last_node = NULL;
-            last_split = first_split;
-            while( last_split )
-            {
-                cur_node = (last_split->multiple_clusters)
-                    ? last_split->multiple_clusters : last_split->single_cluster;
-                parent = last_split->parent;
-                if( parent ) parent->child = cur_node;
-
-                /* connect leaves via next_same_level and save them */
-                for( ; cur_node; cur_node = cur_node->next )
-                {
-                    FILE* file;
-
-                    if( last_node ) last_node->next_same_level = cur_node;
-                    else leaves = cur_node;
-                    last_node = cur_node;
-                    cur_node->parent = parent;
-
-                    cur_node->idx = tcc->next_idx;
-                    tcc->next_idx++;
-                    sprintf( suffix, "%d/%s", cur_node->idx, CV_STAGE_CART_FILE_NAME );
-                    file = NULL;
-                    if( icvMkDir( stage_name ) && (file = fopen( stage_name, "w" )) != 0 )
-                    {
-                        cur_node->stage->save( (CvIntHaarClassifier*) cur_node->stage, file );
-                        fprintf( file, "\n%d\n%d\n",
-                            ((parent) ? parent->idx : -1),
-                            ((cur_node->next) ? tcc->next_idx : -1) );
-                    }
-                    else
-                    {
-                        printf( "Failed to save classifier into %s\n", stage_name );
-                    }
-                    if( file ) fclose( file );
-                }
-
-                if( parent ) sprintf( buf, "%d", parent->idx );
-                else sprintf( buf, "NULL" );
-                printf( "\nParent node: %s\n", buf );
-                printf( "Chosen number of splits: %d\n\n", (last_split->multiple_clusters)
-                    ? (last_split->num_clusters - 1) : 0 );
-
-                cur_split = last_split;
-                last_split = last_split->next;
-                cvFree( &cur_split );
-            } /* for each split point */
-
-            printf( "Total number of splits: %d\n", total_splits );
-
-            if( !(tcc->root) ) tcc->root = leaves;
-            CV_CALL( icvPrintTreeCascade( tcc->root ) );
-
-        } while( leaves );
-
-        /* save the cascade to xml file */
-        {
-            char xml_path[1024];
-            int len = (int)strlen(dirname);
-            CvHaarClassifierCascade* cascade = 0;
-            strcpy( xml_path, dirname );
-            if( xml_path[len-1] == '\\' || xml_path[len-1] == '/' )
-                len--;
-            strcpy( xml_path + len, ".xml" );
-            cascade = cvLoadHaarClassifierCascade( dirname, cvSize(winwidth,winheight) );
-            if( cascade )
-                cvSave( xml_path, cascade );
-            cvReleaseHaarClassifierCascade( &cascade );
-        }
-
-    } /* if( nstages > 0 ) */
-
-    /* check cascade performance */
-    printf( "\nCascade performance\n" );
-
-    tcc->eval = icvEvalTreeCascadeClassifier;
-
-    /* load samples */
-    consumed = 0;
-    poscount = icvGetHaarTrainingDataFromVec( training_data, 0, npos,
-        (CvIntHaarClassifier*) tcc, vecfilename, &consumed );
-
-    printf( "POS: %d %d %f\n", poscount, consumed,
-        (consumed > 0) ? (((float) poscount)/consumed) : 0 );
-
-    if( poscount <= 0 )
-        fprintf( stderr, "Warning: unable to obtain positive samples\n" );
-
-    proctime = -TIME( 0 );
-
-    negcount = icvGetHaarTrainingDataFromBG( training_data, poscount, nneg,
-        (CvIntHaarClassifier*) tcc, &false_alarm, bg_vecfile ? bgfilename : NULL );
-
-    printf( "NEG: %d %g\n", negcount, false_alarm );
-
-    printf( "BACKGROUND PROCESSING TIME: %.2f\n", (proctime + TIME( 0 )) );
-
-    if( negcount <= 0 )
-        fprintf( stderr, "Warning: unable to obtain negative samples\n" );
-
-    __END__;
-
-    if (! bg_vecfile)
-      icvDestroyBackgroundReaders();
-
-    if( tcc ) tcc->release( (CvIntHaarClassifier**) &tcc );
-    icvReleaseIntHaarFeatures( &haar_features );
-    icvReleaseHaarTrainingData( &training_data );
-    cvReleaseMat( &cluster_idx );
-    cvReleaseMat( &idx );
-    cvReleaseMat( &vals );
-    cvReleaseMat( &features_idx );
-}
-
-
-
-void cvCreateTrainingSamples( const char* filename,
-                              const char* imgfilename, int bgcolor, int bgthreshold,
-                              const char* bgfilename, int count,
-                              int invert, int maxintensitydev,
-                              double maxxangle, double maxyangle, double maxzangle,
-                              int showsamples,
-                              int winwidth, int winheight )
-{
-    CvSampleDistortionData data;
-
-    assert( filename != NULL );
-    assert( imgfilename != NULL );
-
-    if( !icvMkDir( filename ) )
-    {
-        fprintf( stderr, "Unable to create output file: %s\n", filename );
-        return;
-    }
-    if( icvStartSampleDistortion( imgfilename, bgcolor, bgthreshold, &data ) )
-    {
-        FILE* output = NULL;
-
-        output = fopen( filename, "wb" );
-        if( output != NULL )
-        {
-            int hasbg;
-            int i;
-            CvMat sample;
-            int inverse;
-
-            hasbg = 0;
-            hasbg = (bgfilename != NULL && icvInitBackgroundReaders( bgfilename,
-                     cvSize( winwidth,winheight ) ) );
-
-            sample = cvMat( winheight, winwidth, CV_8UC1, cvAlloc( sizeof( uchar ) *
-                            winheight * winwidth ) );
-
-            icvWriteVecHeader( output, count, sample.cols, sample.rows );
-
-            if( showsamples )
-            {
-                cvNamedWindow( "Sample", CV_WINDOW_AUTOSIZE );
-            }
-
-            inverse = invert;
-            for( i = 0; i < count; i++ )
-            {
-                if( hasbg )
-                {
-                    icvGetBackgroundImage( cvbgdata, cvbgreader, &sample );
-                }
-                else
-                {
-                    cvSet( &sample, cvScalar( bgcolor ) );
-                }
-
-                if( invert == CV_RANDOM_INVERT )
-                {
-                    inverse = (rand() > (RAND_MAX/2));
-                }
-                icvPlaceDistortedSample( &sample, inverse, maxintensitydev,
-                    maxxangle, maxyangle, maxzangle,
-                    0   /* nonzero means placing image without cut offs */,
-                    0.0 /* nozero adds random shifting                  */,
-                    0.0 /* nozero adds random scaling                   */,
-                    &data );
-
-                if( showsamples )
-                {
-                    cvShowImage( "Sample", &sample );
-                    if( cvWaitKey( 0 ) == 27 )
-                    {
-                        showsamples = 0;
-                    }
-                }
-
-                icvWriteVecSample( output, &sample );
-
-#ifdef CV_VERBOSE
-                if( i % 500 == 0 )
-                {
-                    printf( "\r%3d%%", 100 * i / count );
-                }
-#endif /* CV_VERBOSE */
-            }
-            icvDestroyBackgroundReaders();
-            cvFree( &(sample.data.ptr) );
-            fclose( output );
-        } /* if( output != NULL ) */
-
-        icvEndSampleDistortion( &data );
-    }
-
-#ifdef CV_VERBOSE
-    printf( "\r      \r" );
-#endif /* CV_VERBOSE */
-
-}
-
-#define CV_INFO_FILENAME "info.dat"
-
-
-void cvCreateTestSamples( const char* infoname,
-                          const char* imgfilename, int bgcolor, int bgthreshold,
-                          const char* bgfilename, int count,
-                          int invert, int maxintensitydev,
-                          double maxxangle, double maxyangle, double maxzangle,
-                          int showsamples,
-                          int winwidth, int winheight )
-{
-    CvSampleDistortionData data;
-
-    assert( infoname != NULL );
-    assert( imgfilename != NULL );
-    assert( bgfilename != NULL );
-
-    if( !icvMkDir( infoname ) )
-    {
-
-#if CV_VERBOSE
-        fprintf( stderr, "Unable to create directory hierarchy: %s\n", infoname );
-#endif /* CV_VERBOSE */
-
-        return;
-    }
-    if( icvStartSampleDistortion( imgfilename, bgcolor, bgthreshold, &data ) )
-    {
-        char fullname[PATH_MAX];
-        char* filename;
-        CvMat win;
-        FILE* info;
-
-        if( icvInitBackgroundReaders( bgfilename, cvSize( 10, 10 ) ) )
-        {
-            int i;
-            int x, y, width, height;
-            float scale;
-            float maxscale;
-            int inverse;
-
-            if( showsamples )
-            {
-                cvNamedWindow( "Image", CV_WINDOW_AUTOSIZE );
-            }
-
-            info = fopen( infoname, "w" );
-            strcpy( fullname, infoname );
-            filename = strrchr( fullname, '\\' );
-            if( filename == NULL )
-            {
-                filename = strrchr( fullname, '/' );
-            }
-            if( filename == NULL )
-            {
-                filename = fullname;
-            }
-            else
-            {
-                filename++;
-            }
-
-            count = MIN( count, cvbgdata->count );
-            inverse = invert;
-            for( i = 0; i < count; i++ )
-            {
-                icvGetNextFromBackgroundData( cvbgdata, cvbgreader );
-
-                maxscale = MIN( 0.7F * cvbgreader->src.cols / winwidth,
-                                   0.7F * cvbgreader->src.rows / winheight );
-                if( maxscale < 1.0F ) continue;
-
-                scale = (maxscale - 1.0F) * rand() / RAND_MAX + 1.0F;
-                width = (int) (scale * winwidth);
-                height = (int) (scale * winheight);
-                x = (int) ((0.1+0.8 * rand()/RAND_MAX) * (cvbgreader->src.cols - width));
-                y = (int) ((0.1+0.8 * rand()/RAND_MAX) * (cvbgreader->src.rows - height));
-
-                cvGetSubArr( &cvbgreader->src, &win, cvRect( x, y ,width, height ) );
-                if( invert == CV_RANDOM_INVERT )
-                {
-                    inverse = (rand() > (RAND_MAX/2));
-                }
-                icvPlaceDistortedSample( &win, inverse, maxintensitydev,
-                                         maxxangle, maxyangle, maxzangle,
-                                         1, 0.0, 0.0, &data );
-
-
-                sprintf( filename, "%04d_%04d_%04d_%04d_%04d.jpg",
-                         (i + 1), x, y, width, height );
-
-                if( info )
-                {
-                    fprintf( info, "%s %d %d %d %d %d\n",
-                        filename, 1, x, y, width, height );
-                }
-
-                cvSaveImage( fullname, &cvbgreader->src );
-                if( showsamples )
-                {
-                    cvShowImage( "Image", &cvbgreader->src );
-                    if( cvWaitKey( 0 ) == 27 )
-                    {
-                        showsamples = 0;
-                    }
-                }
-            }
-            if( info ) fclose( info );
-            icvDestroyBackgroundReaders();
-        }
-        icvEndSampleDistortion( &data );
-    }
-}
-
-
-/* End of file. */
diff --git a/apps/haartraining/cvhaartraining.h b/apps/haartraining/cvhaartraining.h
deleted file mode 100644 (file)
index 5a57e17..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
- * cvhaartraining.h
- *
- * haar training functions
- */
-
-#ifndef _CVHAARTRAINING_H_
-#define _CVHAARTRAINING_H_
-
-/*
- * cvCreateTrainingSamples
- *
- * Create training samples applying random distortions to sample image and
- * store them in .vec file
- *
- * filename        - .vec file name
- * imgfilename     - sample image file name
- * bgcolor         - background color for sample image
- * bgthreshold     - background color threshold. Pixels those colors are in range
- *   [bgcolor-bgthreshold, bgcolor+bgthreshold] are considered as transparent
- * bgfilename      - background description file name. If not NULL samples
- *   will be put on arbitrary background
- * count           - desired number of samples
- * invert          - if not 0 sample foreground pixels will be inverted
- *   if invert == CV_RANDOM_INVERT then samples will be inverted randomly
- * maxintensitydev - desired max intensity deviation of foreground samples pixels
- * maxxangle       - max rotation angles
- * maxyangle
- * maxzangle
- * showsamples     - if not 0 samples will be shown
- * winwidth        - desired samples width
- * winheight       - desired samples height
- */
-#define CV_RANDOM_INVERT 0x7FFFFFFF
-
-void cvCreateTrainingSamples( const char* filename,
-                              const char* imgfilename, int bgcolor, int bgthreshold,
-                              const char* bgfilename, int count,
-                              int invert = 0, int maxintensitydev = 40,
-                              double maxxangle = 1.1,
-                              double maxyangle = 1.1,
-                              double maxzangle = 0.5,
-                              int showsamples = 0,
-                              int winwidth = 24, int winheight = 24 );
-
-void cvCreateTestSamples( const char* infoname,
-                          const char* imgfilename, int bgcolor, int bgthreshold,
-                          const char* bgfilename, int count,
-                          int invert, int maxintensitydev,
-                          double maxxangle, double maxyangle, double maxzangle,
-                          int showsamples,
-                          int winwidth, int winheight );
-
-/*
- * cvCreateTrainingSamplesFromInfo
- *
- * Create training samples from a set of marked up images and store them into .vec file
- * infoname    - file in which marked up image descriptions are stored
- * num         - desired number of samples
- * showsamples - if not 0 samples will be shown
- * winwidth    - sample width
- * winheight   - sample height
- *
- * Return number of successfully created samples
- */
-int cvCreateTrainingSamplesFromInfo( const char* infoname, const char* vecfilename,
-                                     int num,
-                                     int showsamples,
-                                     int winwidth, int winheight );
-
-/*
- * cvShowVecSamples
- *
- * Shows samples stored in .vec file
- *
- * filename
- *   .vec file name
- * winwidth
- *   sample width
- * winheight
- *   sample height
- * scale
- *   the scale each sample is adjusted to
- */
-void cvShowVecSamples( const char* filename, int winwidth, int winheight, double scale );
-
-
-/*
- * cvCreateCascadeClassifier
- *
- * Create cascade classifier
- * dirname          - directory name in which cascade classifier will be created.
- *   It must exist and contain subdirectories 0, 1, 2, ... (nstages-1).
- * vecfilename      - name of .vec file with object's images
- * bgfilename       - name of background description file
- * bg_vecfile       - true if bgfilename represents a vec file with discrete negatives
- * npos             - number of positive samples used in training of each stage
- * nneg             - number of negative samples used in training of each stage
- * nstages          - number of stages
- * numprecalculated - number of features being precalculated. Each precalculated feature
- *   requires (number_of_samples*(sizeof( float ) + sizeof( short ))) bytes of memory
- * numsplits        - number of binary splits in each weak classifier
- *   1 - stumps, 2 and more - trees.
- * minhitrate       - desired min hit rate of each stage
- * maxfalsealarm    - desired max false alarm of each stage
- * weightfraction   - weight trimming parameter
- * mode             - 0 - BASIC = Viola
- *                    1 - CORE  = All upright
- *                    2 - ALL   = All features
- * symmetric        - if not 0 vertical symmetry is assumed
- * equalweights     - if not 0 initial weights of all samples will be equal
- * winwidth         - sample width
- * winheight        - sample height
- * boosttype        - type of applied boosting algorithm
- *   0 - Discrete AdaBoost
- *   1 - Real AdaBoost
- *   2 - LogitBoost
- *   3 - Gentle AdaBoost
- * stumperror       - type of used error if Discrete AdaBoost algorithm is applied
- *   0 - misclassification error
- *   1 - gini error
- *   2 - entropy error
- */
-void cvCreateCascadeClassifier( const char* dirname,
-                                const char* vecfilename,
-                                const char* bgfilename,
-                                int npos, int nneg, int nstages,
-                                int numprecalculated,
-                                int numsplits,
-                                float minhitrate = 0.995F, float maxfalsealarm = 0.5F,
-                                float weightfraction = 0.95F,
-                                int mode = 0, int symmetric = 1,
-                                int equalweights = 1,
-                                int winwidth = 24, int winheight = 24,
-                                int boosttype = 3, int stumperror = 0 );
-
-void cvCreateTreeCascadeClassifier( const char* dirname,
-                                    const char* vecfilename,
-                                    const char* bgfilename,
-                                    int npos, int nneg, int nstages,
-                                    int numprecalculated,
-                                    int numsplits,
-                                    float minhitrate, float maxfalsealarm,
-                                    float weightfraction,
-                                    int mode, int symmetric,
-                                    int equalweights,
-                                    int winwidth, int winheight,
-                                    int boosttype, int stumperror,
-                                    int maxtreesplits, int minpos, bool bg_vecfile = false );
-
-#endif /* _CVHAARTRAINING_H_ */
diff --git a/apps/haartraining/cvsamples.cpp b/apps/haartraining/cvsamples.cpp
deleted file mode 100644 (file)
index b477b92..0000000
+++ /dev/null
@@ -1,953 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
- * cvsamples.cpp
- *
- * support functions for training and test samples creation.
- */
-
-#include "cvhaartraining.h"
-#include "_cvhaartraining.h"
-
-/* if ipl.h file is included then iplWarpPerspectiveQ function
-   is used for image transformation during samples creation;
-   otherwise internal cvWarpPerspective function is used */
-
-//#include <ipl.h>
-
-#include "cv.h"
-#include "highgui.h"
-
-/* Calculates coefficients of perspective transformation
- * which maps <quad> into rectangle ((0,0), (w,0), (w,h), (h,0)):
- *
- *      c00*xi + c01*yi + c02
- * ui = ---------------------
- *      c20*xi + c21*yi + c22
- *
- *      c10*xi + c11*yi + c12
- * vi = ---------------------
- *      c20*xi + c21*yi + c22
- *
- * Coefficients are calculated by solving linear system:
- * / x0 y0  1  0  0  0 -x0*u0 -y0*u0 \ /c00\ /u0\
- * | x1 y1  1  0  0  0 -x1*u1 -y1*u1 | |c01| |u1|
- * | x2 y2  1  0  0  0 -x2*u2 -y2*u2 | |c02| |u2|
- * | x3 y3  1  0  0  0 -x3*u3 -y3*u3 |.|c10|=|u3|,
- * |  0  0  0 x0 y0  1 -x0*v0 -y0*v0 | |c11| |v0|
- * |  0  0  0 x1 y1  1 -x1*v1 -y1*v1 | |c12| |v1|
- * |  0  0  0 x2 y2  1 -x2*v2 -y2*v2 | |c20| |v2|
- * \  0  0  0 x3 y3  1 -x3*v3 -y3*v3 / \c21/ \v3/
- *
- * where:
- *   (xi, yi) = (quad[i][0], quad[i][1])
- *        cij - coeffs[i][j], coeffs[2][2] = 1
- *   (ui, vi) - rectangle vertices
- */
-static void cvGetPerspectiveTransform( CvSize src_size, double quad[4][2],
-                                double coeffs[3][3] )
-{
-    //CV_FUNCNAME( "cvWarpPerspective" );
-
-    __BEGIN__;
-
-    double a[8][8];
-    double b[8];
-
-    CvMat A = cvMat( 8, 8, CV_64FC1, a );
-    CvMat B = cvMat( 8, 1, CV_64FC1, b );
-    CvMat X = cvMat( 8, 1, CV_64FC1, coeffs );
-
-    int i;
-    for( i = 0; i < 4; ++i )
-    {
-        a[i][0] = quad[i][0]; a[i][1] = quad[i][1]; a[i][2] = 1;
-        a[i][3] = a[i][4] = a[i][5] = a[i][6] = a[i][7] = 0;
-        b[i] = 0;
-    }
-    for( i = 4; i < 8; ++i )
-    {
-        a[i][3] = quad[i-4][0]; a[i][4] = quad[i-4][1]; a[i][5] = 1;
-        a[i][0] = a[i][1] = a[i][2] = a[i][6] = a[i][7] = 0;
-        b[i] = 0;
-    }
-
-    int u = src_size.width - 1;
-    int v = src_size.height - 1;
-
-    a[1][6] = -quad[1][0] * u; a[1][7] = -quad[1][1] * u;
-    a[2][6] = -quad[2][0] * u; a[2][7] = -quad[2][1] * u;
-    b[1] = b[2] = u;
-
-    a[6][6] = -quad[2][0] * v; a[6][7] = -quad[2][1] * v;
-    a[7][6] = -quad[3][0] * v; a[7][7] = -quad[3][1] * v;
-    b[6] = b[7] = v;
-
-    cvSolve( &A, &B, &X );
-
-    coeffs[2][2] = 1;
-
-    __END__;
-}
-
-/* Warps source into destination by a perspective transform */
-static void cvWarpPerspective( CvArr* src, CvArr* dst, double quad[4][2] )
-{
-    CV_FUNCNAME( "cvWarpPerspective" );
-
-    __BEGIN__;
-
-#ifdef __IPL_H__
-    IplImage src_stub, dst_stub;
-    IplImage* src_img;
-    IplImage* dst_img;
-    CV_CALL( src_img = cvGetImage( src, &src_stub ) );
-    CV_CALL( dst_img = cvGetImage( dst, &dst_stub ) );
-    iplWarpPerspectiveQ( src_img, dst_img, quad, IPL_WARP_R_TO_Q,
-                         IPL_INTER_CUBIC | IPL_SMOOTH_EDGE );
-#else
-
-    int fill_value = 0;
-
-    double c[3][3]; /* transformation coefficients */
-    double q[4][2]; /* rearranged quad */
-
-    int left = 0;
-    int right = 0;
-    int next_right = 0;
-    int next_left = 0;
-    double y_min = 0;
-    double y_max = 0;
-    double k_left, b_left, k_right, b_right;
-
-    uchar* src_data;
-    int src_step;
-    CvSize src_size;
-
-    uchar* dst_data;
-    int dst_step;
-    CvSize dst_size;
-
-    double d = 0;
-    int direction = 0;
-    int i;
-
-    if( !src || (!CV_IS_IMAGE( src ) && !CV_IS_MAT( src )) ||
-        cvGetElemType( src ) != CV_8UC1 ||
-        cvGetDims( src ) != 2 )
-    {
-        CV_ERROR( CV_StsBadArg,
-            "Source must be two-dimensional array of CV_8UC1 type." );
-    }
-    if( !dst || (!CV_IS_IMAGE( dst ) && !CV_IS_MAT( dst )) ||
-        cvGetElemType( dst ) != CV_8UC1 ||
-        cvGetDims( dst ) != 2 )
-    {
-        CV_ERROR( CV_StsBadArg,
-            "Destination must be two-dimensional array of CV_8UC1 type." );
-    }
-
-    CV_CALL( cvGetRawData( src, &src_data, &src_step, &src_size ) );
-    CV_CALL( cvGetRawData( dst, &dst_data, &dst_step, &dst_size ) );
-
-    CV_CALL( cvGetPerspectiveTransform( src_size, quad, c ) );
-
-    /* if direction > 0 then vertices in quad follow in a CW direction,
-       otherwise they follow in a CCW direction */
-    direction = 0;
-    for( i = 0; i < 4; ++i )
-    {
-        int ni = i + 1; if( ni == 4 ) ni = 0;
-        int pi = i - 1; if( pi == -1 ) pi = 3;
-
-        d = (quad[i][0] - quad[pi][0])*(quad[ni][1] - quad[i][1]) -
-            (quad[i][1] - quad[pi][1])*(quad[ni][0] - quad[i][0]);
-        int cur_direction = CV_SIGN(d);
-        if( direction == 0 )
-        {
-            direction = cur_direction;
-        }
-        else if( direction * cur_direction < 0 )
-        {
-            direction = 0;
-            break;
-        }
-    }
-    if( direction == 0 )
-    {
-        CV_ERROR( CV_StsBadArg, "Quadrangle is nonconvex or degenerated." );
-    }
-
-    /* <left> is the index of the topmost quad vertice
-       if there are two such vertices <left> is the leftmost one */
-    left = 0;
-    for( i = 1; i < 4; ++i )
-    {
-        if( (quad[i][1] < quad[left][1]) ||
-            ((quad[i][1] == quad[left][1]) && (quad[i][0] < quad[left][0])) )
-        {
-            left = i;
-        }
-    }
-    /* rearrange <quad> vertices in such way that they follow in a CW
-       direction and the first vertice is the topmost one and put them
-       into <q> */
-    if( direction > 0 )
-    {
-        for( i = left; i < 4; ++i )
-        {
-            q[i-left][0] = quad[i][0];
-            q[i-left][1] = quad[i][1];
-        }
-        for( i = 0; i < left; ++i )
-        {
-            q[4-left+i][0] = quad[i][0];
-            q[4-left+i][1] = quad[i][1];
-        }
-    }
-    else
-    {
-        for( i = left; i >= 0; --i )
-        {
-            q[left-i][0] = quad[i][0];
-            q[left-i][1] = quad[i][1];
-        }
-        for( i = 3; i > left; --i )
-        {
-            q[4+left-i][0] = quad[i][0];
-            q[4+left-i][1] = quad[i][1];
-        }
-    }
-
-    left = right = 0;
-    /* if there are two topmost points, <right> is the index of the rightmost one
-       otherwise <right> */
-    if( q[left][1] == q[left+1][1] )
-    {
-        right = 1;
-    }
-
-    /* <next_left> follows <left> in a CCW direction */
-    next_left = 3;
-    /* <next_right> follows <right> in a CW direction */
-    next_right = right + 1;
-
-    /* subtraction of 1 prevents skipping of the first row */
-    y_min = q[left][1] - 1;
-
-    /* left edge equation: y = k_left * x + b_left */
-    k_left = (q[left][0] - q[next_left][0]) /
-               (q[left][1] - q[next_left][1]);
-    b_left = (q[left][1] * q[next_left][0] -
-               q[left][0] * q[next_left][1]) /
-                 (q[left][1] - q[next_left][1]);
-
-    /* right edge equation: y = k_right * x + b_right */
-    k_right = (q[right][0] - q[next_right][0]) /
-               (q[right][1] - q[next_right][1]);
-    b_right = (q[right][1] * q[next_right][0] -
-               q[right][0] * q[next_right][1]) /
-                 (q[right][1] - q[next_right][1]);
-
-    for(;;)
-    {
-        int x, y;
-
-        y_max = MIN( q[next_left][1], q[next_right][1] );
-
-        int iy_min = MAX( cvRound(y_min), 0 ) + 1;
-        int iy_max = MIN( cvRound(y_max), dst_size.height - 1 );
-
-        double x_min = k_left * iy_min + b_left;
-        double x_max = k_right * iy_min + b_right;
-
-        /* walk through the destination quadrangle row by row */
-        for( y = iy_min; y <= iy_max; ++y )
-        {
-            int ix_min = MAX( cvRound( x_min ), 0 );
-            int ix_max = MIN( cvRound( x_max ), dst_size.width - 1 );
-
-            for( x = ix_min; x <= ix_max; ++x )
-            {
-                /* calculate coordinates of the corresponding source array point */
-                double div = (c[2][0] * x + c[2][1] * y + c[2][2]);
-                double src_x = (c[0][0] * x + c[0][1] * y + c[0][2]) / div;
-                double src_y = (c[1][0] * x + c[1][1] * y + c[1][2]) / div;
-
-                int isrc_x = cvFloor( src_x );
-                int isrc_y = cvFloor( src_y );
-                double delta_x = src_x - isrc_x;
-                double delta_y = src_y - isrc_y;
-
-                uchar* s = src_data + isrc_y * src_step + isrc_x;
-
-                int i00, i10, i01, i11;
-                i00 = i10 = i01 = i11 = (int) fill_value;
-
-                /* linear interpolation using 2x2 neighborhood */
-                if( isrc_x >= 0 && isrc_x <= src_size.width &&
-                    isrc_y >= 0 && isrc_y <= src_size.height )
-                {
-                    i00 = s[0];
-                }
-                if( isrc_x >= -1 && isrc_x < src_size.width &&
-                    isrc_y >= 0 && isrc_y <= src_size.height )
-                {
-                    i10 = s[1];
-                }
-                if( isrc_x >= 0 && isrc_x <= src_size.width &&
-                    isrc_y >= -1 && isrc_y < src_size.height )
-                {
-                    i01 = s[src_step];
-                }
-                if( isrc_x >= -1 && isrc_x < src_size.width &&
-                    isrc_y >= -1 && isrc_y < src_size.height )
-                {
-                    i11 = s[src_step+1];
-                }
-
-                double i0 = i00 + (i10 - i00)*delta_x;
-                double i1 = i01 + (i11 - i01)*delta_x;
-
-                ((uchar*)(dst_data + y * dst_step))[x] = (uchar) (i0 + (i1 - i0)*delta_y);
-            }
-            x_min += k_left;
-            x_max += k_right;
-        }
-
-        if( (next_left == next_right) ||
-            (next_left+1 == next_right && q[next_left][1] == q[next_right][1]) )
-        {
-            break;
-        }
-
-        if( y_max == q[next_left][1] )
-        {
-            left = next_left;
-            next_left = left - 1;
-
-            k_left = (q[left][0] - q[next_left][0]) /
-                       (q[left][1] - q[next_left][1]);
-            b_left = (q[left][1] * q[next_left][0] -
-                       q[left][0] * q[next_left][1]) /
-                         (q[left][1] - q[next_left][1]);
-        }
-        if( y_max == q[next_right][1] )
-        {
-            right = next_right;
-            next_right = right + 1;
-
-            k_right = (q[right][0] - q[next_right][0]) /
-                       (q[right][1] - q[next_right][1]);
-            b_right = (q[right][1] * q[next_right][0] -
-                       q[right][0] * q[next_right][1]) /
-                         (q[right][1] - q[next_right][1]);
-        }
-        y_min = y_max;
-    }
-#endif /* #ifndef __IPL_H__ */
-
-    __END__;
-}
-
-static
-void icvRandomQuad( int width, int height, double quad[4][2],
-                    double maxxangle,
-                    double maxyangle,
-                    double maxzangle )
-{
-    double distfactor = 3.0;
-    double distfactor2 = 1.0;
-
-    double halfw, halfh;
-    int i;
-
-    double rotVectData[3];
-    double vectData[3];
-    double rotMatData[9];
-
-    CvMat rotVect;
-    CvMat rotMat;
-    CvMat vect;
-
-    double d;
-
-    rotVect = cvMat( 3, 1, CV_64FC1, &rotVectData[0] );
-    rotMat = cvMat( 3, 3, CV_64FC1, &rotMatData[0] );
-    vect = cvMat( 3, 1, CV_64FC1, &vectData[0] );
-
-    rotVectData[0] = maxxangle * (2.0 * rand() / RAND_MAX - 1.0);
-    rotVectData[1] = ( maxyangle - fabs( rotVectData[0] ) )
-        * (2.0 * rand() / RAND_MAX - 1.0);
-    rotVectData[2] = maxzangle * (2.0 * rand() / RAND_MAX - 1.0);
-    d = (distfactor + distfactor2 * (2.0 * rand() / RAND_MAX - 1.0)) * width;
-
-/*
-    rotVectData[0] = maxxangle;
-    rotVectData[1] = maxyangle;
-    rotVectData[2] = maxzangle;
-
-    d = distfactor * width;
-*/
-
-    cvRodrigues2( &rotVect, &rotMat );
-
-    halfw = 0.5 * width;
-    halfh = 0.5 * height;
-
-    quad[0][0] = -halfw;
-    quad[0][1] = -halfh;
-    quad[1][0] =  halfw;
-    quad[1][1] = -halfh;
-    quad[2][0] =  halfw;
-    quad[2][1] =  halfh;
-    quad[3][0] = -halfw;
-    quad[3][1] =  halfh;
-
-    for( i = 0; i < 4; i++ )
-    {
-        rotVectData[0] = quad[i][0];
-        rotVectData[1] = quad[i][1];
-        rotVectData[2] = 0.0;
-        cvMatMulAdd( &rotMat, &rotVect, 0, &vect );
-        quad[i][0] = vectData[0] * d / (d + vectData[2]) + halfw;
-        quad[i][1] = vectData[1] * d / (d + vectData[2]) + halfh;
-
-        /*
-        quad[i][0] += halfw;
-        quad[i][1] += halfh;
-        */
-    }
-}
-
-
-int icvStartSampleDistortion( const char* imgfilename, int bgcolor, int bgthreshold,
-                              CvSampleDistortionData* data )
-{
-    memset( data, 0, sizeof( *data ) );
-    data->src = cvLoadImage( imgfilename, 0 );
-    if( data->src != NULL && data->src->nChannels == 1
-        && data->src->depth == IPL_DEPTH_8U )
-    {
-        int r, c;
-        uchar* pmask;
-        uchar* psrc;
-        uchar* perode;
-        uchar* pdilate;
-        uchar dd, de;
-
-        data->dx = data->src->width / 2;
-        data->dy = data->src->height / 2;
-        data->bgcolor = bgcolor;
-
-        data->mask = cvCloneImage( data->src );
-        data->erode = cvCloneImage( data->src );
-        data->dilate = cvCloneImage( data->src );
-
-        /* make mask image */
-        for( r = 0; r < data->mask->height; r++ )
-        {
-            for( c = 0; c < data->mask->width; c++ )
-            {
-                pmask = ( (uchar*) (data->mask->imageData + r * data->mask->widthStep)
-                        + c );
-                if( bgcolor - bgthreshold <= (int) (*pmask) &&
-                    (int) (*pmask) <= bgcolor + bgthreshold )
-                {
-                    *pmask = (uchar) 0;
-                }
-                else
-                {
-                    *pmask = (uchar) 255;
-                }
-            }
-        }
-
-        /* extend borders of source image */
-        cvErode( data->src, data->erode, 0, 1 );
-        cvDilate( data->src, data->dilate, 0, 1 );
-        for( r = 0; r < data->mask->height; r++ )
-        {
-            for( c = 0; c < data->mask->width; c++ )
-            {
-                pmask = ( (uchar*) (data->mask->imageData + r * data->mask->widthStep)
-                        + c );
-                if( (*pmask) == 0 )
-                {
-                    psrc = ( (uchar*) (data->src->imageData + r * data->src->widthStep)
-                           + c );
-                    perode =
-                        ( (uchar*) (data->erode->imageData + r * data->erode->widthStep)
-                                + c );
-                    pdilate =
-                        ( (uchar*)(data->dilate->imageData + r * data->dilate->widthStep)
-                                + c );
-                    de = (uchar)(bgcolor - (*perode));
-                    dd = (uchar)((*pdilate) - bgcolor);
-                    if( de >= dd && de > bgthreshold )
-                    {
-                        (*psrc) = (*perode);
-                    }
-                    if( dd > de && dd > bgthreshold )
-                    {
-                        (*psrc) = (*pdilate);
-                    }
-                }
-            }
-        }
-
-        data->img = cvCreateImage( cvSize( data->src->width + 2 * data->dx,
-                                           data->src->height + 2 * data->dy ),
-                                   IPL_DEPTH_8U, 1 );
-        data->maskimg = cvCloneImage( data->img );
-
-        return 1;
-    }
-
-    return 0;
-}
-
-void icvPlaceDistortedSample( CvArr* background,
-                              int inverse, int maxintensitydev,
-                              double maxxangle, double maxyangle, double maxzangle,
-                              int inscribe, double maxshiftf, double maxscalef,
-                              CvSampleDistortionData* data )
-{
-    double quad[4][2];
-    int r, c;
-    uchar* pimg;
-    uchar* pbg;
-    uchar* palpha;
-    uchar chartmp;
-    int forecolordev;
-    float scale;
-    IplImage* img;
-    IplImage* maskimg;
-    CvMat  stub;
-    CvMat* bgimg;
-
-    CvRect cr;
-    CvRect roi;
-
-    double xshift, yshift, randscale;
-
-    icvRandomQuad( data->src->width, data->src->height, quad,
-                   maxxangle, maxyangle, maxzangle );
-    quad[0][0] += (double) data->dx;
-    quad[0][1] += (double) data->dy;
-    quad[1][0] += (double) data->dx;
-    quad[1][1] += (double) data->dy;
-    quad[2][0] += (double) data->dx;
-    quad[2][1] += (double) data->dy;
-    quad[3][0] += (double) data->dx;
-    quad[3][1] += (double) data->dy;
-
-    cvSet( data->img, cvScalar( data->bgcolor ) );
-    cvSet( data->maskimg, cvScalar( 0.0 ) );
-
-    cvWarpPerspective( data->src, data->img, quad );
-    cvWarpPerspective( data->mask, data->maskimg, quad );
-
-    cvSmooth( data->maskimg, data->maskimg, CV_GAUSSIAN, 3, 3 );
-
-    bgimg = cvGetMat( background, &stub );
-
-    cr.x = data->dx;
-    cr.y = data->dy;
-    cr.width = data->src->width;
-    cr.height = data->src->height;
-
-    if( inscribe )
-    {
-        /* quad's circumscribing rectangle */
-        cr.x = (int) MIN( quad[0][0], quad[3][0] );
-        cr.y = (int) MIN( quad[0][1], quad[1][1] );
-        cr.width  = (int) (MAX( quad[1][0], quad[2][0] ) + 0.5F ) - cr.x;
-        cr.height = (int) (MAX( quad[2][1], quad[3][1] ) + 0.5F ) - cr.y;
-    }
-
-    xshift = maxshiftf * rand() / RAND_MAX;
-    yshift = maxshiftf * rand() / RAND_MAX;
-
-    cr.x -= (int) ( xshift * cr.width  );
-    cr.y -= (int) ( yshift * cr.height );
-    cr.width  = (int) ((1.0 + maxshiftf) * cr.width );
-    cr.height = (int) ((1.0 + maxshiftf) * cr.height);
-
-    randscale = maxscalef * rand() / RAND_MAX;
-    cr.x -= (int) ( 0.5 * randscale * cr.width  );
-    cr.y -= (int) ( 0.5 * randscale * cr.height );
-    cr.width  = (int) ((1.0 + randscale) * cr.width );
-    cr.height = (int) ((1.0 + randscale) * cr.height);
-
-    scale = MAX( ((float) cr.width) / bgimg->cols, ((float) cr.height) / bgimg->rows );
-
-    roi.x = (int) (-0.5F * (scale * bgimg->cols - cr.width) + cr.x);
-    roi.y = (int) (-0.5F * (scale * bgimg->rows - cr.height) + cr.y);
-    roi.width  = (int) (scale * bgimg->cols);
-    roi.height = (int) (scale * bgimg->rows);
-
-    img = cvCreateImage( cvSize( bgimg->cols, bgimg->rows ), IPL_DEPTH_8U, 1 );
-    maskimg = cvCreateImage( cvSize( bgimg->cols, bgimg->rows ), IPL_DEPTH_8U, 1 );
-
-    cvSetImageROI( data->img, roi );
-    cvResize( data->img, img );
-    cvResetImageROI( data->img );
-    cvSetImageROI( data->maskimg, roi );
-    cvResize( data->maskimg, maskimg );
-    cvResetImageROI( data->maskimg );
-
-    forecolordev = (int) (maxintensitydev * (2.0 * rand() / RAND_MAX - 1.0));
-
-    for( r = 0; r < img->height; r++ )
-    {
-        for( c = 0; c < img->width; c++ )
-        {
-            pimg = (uchar*) img->imageData + r * img->widthStep + c;
-            pbg = (uchar*) bgimg->data.ptr + r * bgimg->step + c;
-            palpha = (uchar*) maskimg->imageData + r * maskimg->widthStep + c;
-            chartmp = (uchar) MAX( 0, MIN( 255, forecolordev + (*pimg) ) );
-            if( inverse )
-            {
-                chartmp ^= 0xFF;
-            }
-            *pbg = (uchar) (( chartmp*(*palpha )+(255 - (*palpha) )*(*pbg) ) / 255);
-        }
-    }
-
-    cvReleaseImage( &img );
-    cvReleaseImage( &maskimg );
-}
-
-void icvEndSampleDistortion( CvSampleDistortionData* data )
-{
-    if( data->src )
-    {
-        cvReleaseImage( &data->src );
-    }
-    if( data->mask )
-    {
-        cvReleaseImage( &data->mask );
-    }
-    if( data->erode )
-    {
-        cvReleaseImage( &data->erode );
-    }
-    if( data->dilate )
-    {
-        cvReleaseImage( &data->dilate );
-    }
-    if( data->img )
-    {
-        cvReleaseImage( &data->img );
-    }
-    if( data->maskimg )
-    {
-        cvReleaseImage( &data->maskimg );
-    }
-}
-
-void icvWriteVecHeader( FILE* file, int count, int width, int height )
-{
-    int vecsize;
-    short tmp;
-
-    /* number of samples */
-    fwrite( &count, sizeof( count ), 1, file );
-    /* vector size */
-    vecsize = width * height;
-    fwrite( &vecsize, sizeof( vecsize ), 1, file );
-    /* min/max values */
-    tmp = 0;
-    fwrite( &tmp, sizeof( tmp ), 1, file );
-    fwrite( &tmp, sizeof( tmp ), 1, file );
-}
-
-void icvWriteVecSample( FILE* file, CvArr* sample )
-{
-    CvMat* mat, stub;
-    int r, c;
-    short tmp;
-    uchar chartmp;
-
-    mat = cvGetMat( sample, &stub );
-    chartmp = 0;
-    fwrite( &chartmp, sizeof( chartmp ), 1, file );
-    for( r = 0; r < mat->rows; r++ )
-    {
-        for( c = 0; c < mat->cols; c++ )
-        {
-            tmp = (short) (CV_MAT_ELEM( *mat, uchar, r, c ));
-            fwrite( &tmp, sizeof( tmp ), 1, file );
-        }
-    }
-}
-
-
-int cvCreateTrainingSamplesFromInfo( const char* infoname, const char* vecfilename,
-                                     int num,
-                                     int showsamples,
-                                     int winwidth, int winheight )
-{
-    char fullname[PATH_MAX];
-    char* filename;
-
-    FILE* info;
-    FILE* vec;
-    IplImage* src=0;
-    IplImage* sample;
-    int line;
-    int error;
-    int i;
-    int x, y, width, height;
-    int total;
-
-    assert( infoname != NULL );
-    assert( vecfilename != NULL );
-
-    total = 0;
-    if( !icvMkDir( vecfilename ) )
-    {
-
-#if CV_VERBOSE
-        fprintf( stderr, "Unable to create directory hierarchy: %s\n", vecfilename );
-#endif /* CV_VERBOSE */
-
-        return total;
-    }
-
-    info = fopen( infoname, "r" );
-    if( info == NULL )
-    {
-
-#if CV_VERBOSE
-        fprintf( stderr, "Unable to open file: %s\n", infoname );
-#endif /* CV_VERBOSE */
-
-        return total;
-    }
-
-    vec = fopen( vecfilename, "wb" );
-    if( vec == NULL )
-    {
-
-#if CV_VERBOSE
-        fprintf( stderr, "Unable to open file: %s\n", vecfilename );
-#endif /* CV_VERBOSE */
-
-        fclose( info );
-
-        return total;
-    }
-
-    sample = cvCreateImage( cvSize( winwidth, winheight ), IPL_DEPTH_8U, 1 );
-
-    icvWriteVecHeader( vec, num, sample->width, sample->height );
-
-    if( showsamples )
-    {
-        cvNamedWindow( "Sample", CV_WINDOW_AUTOSIZE );
-    }
-
-    strcpy( fullname, infoname );
-    filename = strrchr( fullname, '\\' );
-    if( filename == NULL )
-    {
-        filename = strrchr( fullname, '/' );
-    }
-    if( filename == NULL )
-    {
-        filename = fullname;
-    }
-    else
-    {
-        filename++;
-    }
-
-    for( line = 1, error = 0, total = 0; total < num ;line++ )
-    {
-        int count;
-
-        error = ( fscanf( info, "%s %d", filename, &count ) != 2 );
-        if( !error )
-        {
-            src = cvLoadImage( fullname, 0 );
-            error = ( src == NULL );
-            if( error )
-            {
-
-#if CV_VERBOSE
-                fprintf( stderr, "Unable to open image: %s\n", fullname );
-#endif /* CV_VERBOSE */
-
-            }
-        }
-        for( i = 0; (i < count) && (total < num); i++, total++ )
-        {
-            error = ( fscanf( info, "%d %d %d %d", &x, &y, &width, &height ) != 4 );
-            if( error ) break;
-            cvSetImageROI( src, cvRect( x, y, width, height ) );
-            cvResize( src, sample, width >= sample->width &&
-                      height >= sample->height ? CV_INTER_AREA : CV_INTER_LINEAR );
-
-            if( showsamples )
-            {
-                cvShowImage( "Sample", sample );
-                if( cvWaitKey( 0 ) == 27 )
-                {
-                    showsamples = 0;
-                }
-            }
-            icvWriteVecSample( vec, sample );
-        }
-
-        if( src )
-        {
-            cvReleaseImage( &src );
-        }
-
-        if( error )
-        {
-
-#if CV_VERBOSE
-            fprintf( stderr, "%s(%d) : parse error", infoname, line );
-#endif /* CV_VERBOSE */
-
-            break;
-        }
-    }
-
-    if( sample )
-    {
-        cvReleaseImage( &sample );
-    }
-
-    fclose( vec );
-    fclose( info );
-
-    return total;
-}
-
-
-void cvShowVecSamples( const char* filename, int winwidth, int winheight,
-                       double scale )
-{
-    CvVecFile file;
-    short tmp;
-    int i;
-    CvMat* sample;
-
-    tmp = 0;
-    file.input = fopen( filename, "rb" );
-
-    if( file.input != NULL )
-    {
-        size_t elements_read1 = fread( &file.count, sizeof( file.count ), 1, file.input );
-        size_t elements_read2 = fread( &file.vecsize, sizeof( file.vecsize ), 1, file.input );
-        size_t elements_read3 = fread( &tmp, sizeof( tmp ), 1, file.input );
-        size_t elements_read4 = fread( &tmp, sizeof( tmp ), 1, file.input );
-        CV_Assert(elements_read1 == 1 && elements_read2 == 1 && elements_read3 == 1 && elements_read4 == 1);
-
-        if( file.vecsize != winwidth * winheight )
-        {
-            int guessed_w = 0;
-            int guessed_h = 0;
-
-            fprintf( stderr, "Warning: specified sample width=%d and height=%d "
-                "does not correspond to .vec file vector size=%d.\n",
-                winwidth, winheight, file.vecsize );
-            if( file.vecsize > 0 )
-            {
-                guessed_w = cvFloor( sqrt( (float) file.vecsize ) );
-                if( guessed_w > 0 )
-                {
-                    guessed_h = file.vecsize / guessed_w;
-                }
-            }
-
-            if( guessed_w <= 0 || guessed_h <= 0 || guessed_w * guessed_h != file.vecsize)
-            {
-                fprintf( stderr, "Error: failed to guess sample width and height\n" );
-                fclose( file.input );
-
-                return;
-            }
-            else
-            {
-                winwidth = guessed_w;
-                winheight = guessed_h;
-                fprintf( stderr, "Guessed width=%d, guessed height=%d\n",
-                    winwidth, winheight );
-            }
-        }
-
-        if( !feof( file.input ) && scale > 0 )
-        {
-            CvMat* scaled_sample = 0;
-
-            file.last = 0;
-            file.vector = (short*) cvAlloc( sizeof( *file.vector ) * file.vecsize );
-            sample = scaled_sample = cvCreateMat( winheight, winwidth, CV_8UC1 );
-            if( scale != 1.0 )
-            {
-                scaled_sample = cvCreateMat( MAX( 1, cvCeil( scale * winheight ) ),
-                                             MAX( 1, cvCeil( scale * winwidth ) ),
-                                             CV_8UC1 );
-            }
-            cvNamedWindow( "Sample", CV_WINDOW_AUTOSIZE );
-            for( i = 0; i < file.count; i++ )
-            {
-                icvGetHaarTraininDataFromVecCallback( sample, &file );
-                if( scale != 1.0 ) cvResize( sample, scaled_sample, CV_INTER_LINEAR);
-                cvShowImage( "Sample", scaled_sample );
-                if( cvWaitKey( 0 ) == 27 ) break;
-            }
-            if( scaled_sample && scaled_sample != sample ) cvReleaseMat( &scaled_sample );
-            cvReleaseMat( &sample );
-            cvFree( &file.vector );
-        }
-        fclose( file.input );
-    }
-}
-
-
-/* End of file. */
diff --git a/apps/haartraining/haartraining.cpp b/apps/haartraining/haartraining.cpp
deleted file mode 100644 (file)
index f85a3c1..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
- * haartraining.cpp
- *
- * Train cascade classifier
- */
-
-#include <cstdio>
-#include <cstring>
-#include <cstdlib>
-
-using namespace std;
-
-#include "cvhaartraining.h"
-
-int main( int argc, char* argv[] )
-{
-    int i = 0;
-    char* nullname = (char*)"(NULL)";
-
-    char* vecname = NULL;
-    char* dirname = NULL;
-    char* bgname  = NULL;
-
-    bool bg_vecfile = false;
-    int npos    = 2000;
-    int nneg    = 2000;
-    int nstages = 14;
-    int mem     = 200;
-    int nsplits = 1;
-    float minhitrate     = 0.995F;
-    float maxfalsealarm  = 0.5F;
-    float weightfraction = 0.95F;
-    int mode         = 0;
-    int symmetric    = 1;
-    int equalweights = 0;
-    int width  = 24;
-    int height = 24;
-    const char* boosttypes[] = { "DAB", "RAB", "LB", "GAB" };
-    int boosttype = 3;
-    const char* stumperrors[] = { "misclass", "gini", "entropy" };
-    int stumperror = 0;
-    int maxtreesplits = 0;
-    int minpos = 500;
-
-    if( argc == 1 )
-    {
-        printf( "Usage: %s\n  -data <dir_name>\n"
-                "  -vec <vec_file_name>\n"
-                "  -bg <background_file_name>\n"
-                "  [-bg-vecfile]\n"
-                "  [-npos <number_of_positive_samples = %d>]\n"
-                "  [-nneg <number_of_negative_samples = %d>]\n"
-                "  [-nstages <number_of_stages = %d>]\n"
-                "  [-nsplits <number_of_splits = %d>]\n"
-                "  [-mem <memory_in_MB = %d>]\n"
-                "  [-sym (default)] [-nonsym]\n"
-                "  [-minhitrate <min_hit_rate = %f>]\n"
-                "  [-maxfalsealarm <max_false_alarm_rate = %f>]\n"
-                "  [-weighttrimming <weight_trimming = %f>]\n"
-                "  [-eqw]\n"
-                "  [-mode <BASIC (default) | CORE | ALL>]\n"
-                "  [-w <sample_width = %d>]\n"
-                "  [-h <sample_height = %d>]\n"
-                "  [-bt <DAB | RAB | LB | GAB (default)>]\n"
-                "  [-err <misclass (default) | gini | entropy>]\n"
-                "  [-maxtreesplits <max_number_of_splits_in_tree_cascade = %d>]\n"
-                "  [-minpos <min_number_of_positive_samples_per_cluster = %d>]\n",
-                argv[0], npos, nneg, nstages, nsplits, mem,
-                minhitrate, maxfalsealarm, weightfraction, width, height,
-                maxtreesplits, minpos );
-
-        return 0;
-    }
-
-    for( i = 1; i < argc; i++ )
-    {
-        if( !strcmp( argv[i], "-data" ) )
-        {
-            dirname = argv[++i];
-        }
-        else if( !strcmp( argv[i], "-vec" ) )
-        {
-            vecname = argv[++i];
-        }
-        else if( !strcmp( argv[i], "-bg" ) )
-        {
-            bgname = argv[++i];
-        }
-        else if( !strcmp( argv[i], "-bg-vecfile" ) )
-        {
-            bg_vecfile = true;
-        }
-        else if( !strcmp( argv[i], "-npos" ) )
-        {
-            npos = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-nneg" ) )
-        {
-            nneg = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-nstages" ) )
-        {
-            nstages = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-nsplits" ) )
-        {
-            nsplits = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-mem" ) )
-        {
-            mem = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-sym" ) )
-        {
-            symmetric = 1;
-        }
-        else if( !strcmp( argv[i], "-nonsym" ) )
-        {
-            symmetric = 0;
-        }
-        else if( !strcmp( argv[i], "-minhitrate" ) )
-        {
-            minhitrate = (float) atof( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-maxfalsealarm" ) )
-        {
-            maxfalsealarm = (float) atof( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-weighttrimming" ) )
-        {
-            weightfraction = (float) atof( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-eqw" ) )
-        {
-            equalweights = 1;
-        }
-        else if( !strcmp( argv[i], "-mode" ) )
-        {
-            char* tmp = argv[++i];
-
-            if( !strcmp( tmp, "CORE" ) )
-            {
-                mode = 1;
-            }
-            else if( !strcmp( tmp, "ALL" ) )
-            {
-                mode = 2;
-            }
-            else
-            {
-                mode = 0;
-            }
-        }
-        else if( !strcmp( argv[i], "-w" ) )
-        {
-            width = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-h" ) )
-        {
-            height = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-bt" ) )
-        {
-            i++;
-            if( !strcmp( argv[i], boosttypes[0] ) )
-            {
-                boosttype = 0;
-            }
-            else if( !strcmp( argv[i], boosttypes[1] ) )
-            {
-                boosttype = 1;
-            }
-            else if( !strcmp( argv[i], boosttypes[2] ) )
-            {
-                boosttype = 2;
-            }
-            else
-            {
-                boosttype = 3;
-            }
-        }
-        else if( !strcmp( argv[i], "-err" ) )
-        {
-            i++;
-            if( !strcmp( argv[i], stumperrors[0] ) )
-            {
-                stumperror = 0;
-            }
-            else if( !strcmp( argv[i], stumperrors[1] ) )
-            {
-                stumperror = 1;
-            }
-            else
-            {
-                stumperror = 2;
-            }
-        }
-        else if( !strcmp( argv[i], "-maxtreesplits" ) )
-        {
-            maxtreesplits = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-minpos" ) )
-        {
-            minpos = atoi( argv[++i] );
-        }
-    }
-
-    printf( "Data dir name: %s\n", ((dirname == NULL) ? nullname : dirname ) );
-    printf( "Vec file name: %s\n", ((vecname == NULL) ? nullname : vecname ) );
-    printf( "BG  file name: %s, is a vecfile: %s\n", ((bgname == NULL) ? nullname : bgname ), bg_vecfile ? "yes" : "no" );
-    printf( "Num pos: %d\n", npos );
-    printf( "Num neg: %d\n", nneg );
-    printf( "Num stages: %d\n", nstages );
-    printf( "Num splits: %d (%s as weak classifier)\n", nsplits,
-        (nsplits == 1) ? "stump" : "tree" );
-    printf( "Mem: %d MB\n", mem );
-    printf( "Symmetric: %s\n", (symmetric) ? "TRUE" : "FALSE" );
-    printf( "Min hit rate: %f\n", minhitrate );
-    printf( "Max false alarm rate: %f\n", maxfalsealarm );
-    printf( "Weight trimming: %f\n", weightfraction );
-    printf( "Equal weights: %s\n", (equalweights) ? "TRUE" : "FALSE" );
-    printf( "Mode: %s\n", ( (mode == 0) ? "BASIC" : ( (mode == 1) ? "CORE" : "ALL") ) );
-    printf( "Width: %d\n", width );
-    printf( "Height: %d\n", height );
-    //printf( "Max num of precalculated features: %d\n", numprecalculated );
-    printf( "Applied boosting algorithm: %s\n", boosttypes[boosttype] );
-    printf( "Error (valid only for Discrete and Real AdaBoost): %s\n",
-            stumperrors[stumperror] );
-
-    printf( "Max number of splits in tree cascade: %d\n", maxtreesplits );
-    printf( "Min number of positive samples per cluster: %d\n", minpos );
-
-    cvCreateTreeCascadeClassifier( dirname, vecname, bgname,
-                               npos, nneg, nstages, mem,
-                               nsplits,
-                               minhitrate, maxfalsealarm, weightfraction,
-                               mode, symmetric,
-                               equalweights, width, height,
-                               boosttype, stumperror,
-                               maxtreesplits, minpos, bg_vecfile );
-
-    return 0;
-}
diff --git a/apps/haartraining/performance.cpp b/apps/haartraining/performance.cpp
deleted file mode 100644 (file)
index cb8dda1..0000000
+++ /dev/null
@@ -1,377 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
- * performance.cpp
- *
- * Measure performance of classifier
- */
-#include "opencv2/core.hpp"
-
-#include "cv.h"
-#include "highgui.h"
-
-#include <cstdio>
-#include <cmath>
-#include <ctime>
-
-#ifdef _WIN32
-/* use clock() function insted of time() */
-#define time( arg ) (((double) clock()) / CLOCKS_PER_SEC)
-#endif /* _WIN32 */
-
-#ifndef PATH_MAX
-#define PATH_MAX 512
-#endif /* PATH_MAX */
-
-typedef struct HidCascade
-{
-    int size;
-    int count;
-} HidCascade;
-
-typedef struct ObjectPos
-{
-    float x;
-    float y;
-    float width;
-    int found;    /* for reference */
-    int neghbors;
-} ObjectPos;
-
-int main( int argc, char* argv[] )
-{
-    int i, j;
-    char* classifierdir = NULL;
-    //char* samplesdir    = NULL;
-
-    int saveDetected = 1;
-    double scale_factor = 1.2;
-    float maxSizeDiff = 1.5F;
-    float maxPosDiff  = 0.3F;
-
-    /* number of stages. if <=0 all stages are used */
-    int nos = -1, nos0;
-
-    int width  = 24;
-    int height = 24;
-
-    int rocsize;
-
-    FILE* info;
-    char* infoname;
-    char fullname[PATH_MAX];
-    char detfilename[PATH_MAX];
-    char* filename;
-    char detname[] = "det-";
-
-    CvHaarClassifierCascade* cascade;
-    CvMemStorage* storage;
-    CvSeq* objects;
-
-    double totaltime;
-
-    infoname = (char*)"";
-    rocsize = 40;
-    if( argc == 1 )
-    {
-        printf( "Usage: %s\n  -data <classifier_directory_name>\n"
-                "  -info <collection_file_name>\n"
-                "  [-maxSizeDiff <max_size_difference = %f>]\n"
-                "  [-maxPosDiff <max_position_difference = %f>]\n"
-                "  [-sf <scale_factor = %f>]\n"
-                "  [-ni]\n"
-                "  [-nos <number_of_stages = %d>]\n"
-                "  [-rs <roc_size = %d>]\n"
-                "  [-w <sample_width = %d>]\n"
-                "  [-h <sample_height = %d>]\n",
-                argv[0], maxSizeDiff, maxPosDiff, scale_factor, nos, rocsize,
-                width, height );
-
-        return 0;
-    }
-
-    for( i = 1; i < argc; i++ )
-    {
-        if( !strcmp( argv[i], "-data" ) )
-        {
-            classifierdir = argv[++i];
-        }
-        else if( !strcmp( argv[i], "-info" ) )
-        {
-            infoname = argv[++i];
-        }
-        else if( !strcmp( argv[i], "-maxSizeDiff" ) )
-        {
-            maxSizeDiff = (float) atof( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-maxPosDiff" ) )
-        {
-            maxPosDiff = (float) atof( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-sf" ) )
-        {
-            scale_factor = atof( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-ni" ) )
-        {
-            saveDetected = 0;
-        }
-        else if( !strcmp( argv[i], "-nos" ) )
-        {
-            nos = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-rs" ) )
-        {
-            rocsize = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-w" ) )
-        {
-            width = atoi( argv[++i] );
-        }
-        else if( !strcmp( argv[i], "-h" ) )
-        {
-            height = atoi( argv[++i] );
-        }
-    }
-
-    cascade = cvLoadHaarClassifierCascade( classifierdir, cvSize( width, height ) );
-    if( cascade == NULL )
-    {
-        printf( "Unable to load classifier from %s\n", classifierdir );
-
-        return 1;
-    }
-
-    int* numclassifiers = new int[cascade->count];
-    numclassifiers[0] = cascade->stage_classifier[0].count;
-    for( i = 1; i < cascade->count; i++ )
-    {
-        numclassifiers[i] = numclassifiers[i-1] + cascade->stage_classifier[i].count;
-    }
-
-    storage = cvCreateMemStorage();
-
-    nos0 = cascade->count;
-    if( nos <= 0 )
-        nos = nos0;
-
-    strcpy( fullname, infoname );
-    filename = strrchr( fullname, '\\' );
-    if( filename == NULL )
-    {
-        filename = strrchr( fullname, '/' );
-    }
-    if( filename == NULL )
-    {
-        filename = fullname;
-    }
-    else
-    {
-        filename++;
-    }
-
-    info = fopen( infoname, "r" );
-    totaltime = 0.0;
-    if( info != NULL )
-    {
-        int x, y;
-        IplImage* img;
-        int hits, missed, falseAlarms;
-        int totalHits, totalMissed, totalFalseAlarms;
-        int found;
-        float distance;
-
-        int refcount;
-        ObjectPos* ref;
-        int detcount;
-        ObjectPos* det;
-        int error=0;
-
-        int* pos;
-        int* neg;
-
-        pos = (int*) cvAlloc( rocsize * sizeof( *pos ) );
-        neg = (int*) cvAlloc( rocsize * sizeof( *neg ) );
-        for( i = 0; i < rocsize; i++ ) { pos[i] = neg[i] = 0; }
-
-        printf( "+================================+======+======+======+\n" );
-        printf( "|            File Name           | Hits |Missed| False|\n" );
-        printf( "+================================+======+======+======+\n" );
-
-        totalHits = totalMissed = totalFalseAlarms = 0;
-        while( !feof( info ) )
-        {
-            if( fscanf( info, "%s %d", filename, &refcount ) != 2 || refcount <= 0 ) break;
-
-            img = cvLoadImage( fullname );
-            if( !img ) continue;
-
-            ref = (ObjectPos*) cvAlloc( refcount * sizeof( *ref ) );
-            for( i = 0; i < refcount; i++ )
-            {
-                int w, h;
-                error = (fscanf( info, "%d %d %d %d", &x, &y, &w, &h ) != 4);
-                if( error ) break;
-                ref[i].x = 0.5F * w  + x;
-                ref[i].y = 0.5F * h + y;
-                ref[i].width = sqrtf( 0.5F * (w * w + h * h) );
-                ref[i].found = 0;
-                ref[i].neghbors = 0;
-            }
-            if( !error )
-            {
-                cvClearMemStorage( storage );
-
-                cascade->count = nos;
-                totaltime -= time( 0 );
-                objects = cvHaarDetectObjects( img, cascade, storage, scale_factor, 1 );
-                totaltime += time( 0 );
-                cascade->count = nos0;
-
-                detcount = ( objects ? objects->total : 0);
-                det = (detcount > 0) ?
-                    ( (ObjectPos*)cvAlloc( detcount * sizeof( *det )) ) : NULL;
-                hits = missed = falseAlarms = 0;
-                for( i = 0; i < detcount; i++ )
-                {
-                    CvAvgComp r = *((CvAvgComp*) cvGetSeqElem( objects, i ));
-                    det[i].x = 0.5F * r.rect.width  + r.rect.x;
-                    det[i].y = 0.5F * r.rect.height + r.rect.y;
-                    det[i].width = sqrtf( 0.5F * (r.rect.width * r.rect.width +
-                                                  r.rect.height * r.rect.height) );
-                    det[i].neghbors = r.neighbors;
-
-                    if( saveDetected )
-                    {
-                        cvRectangle( img, cvPoint( r.rect.x, r.rect.y ),
-                            cvPoint( r.rect.x + r.rect.width, r.rect.y + r.rect.height ),
-                            CV_RGB( 255, 0, 0 ), 3 );
-                    }
-
-                    found = 0;
-                    for( j = 0; j < refcount; j++ )
-                    {
-                        distance = sqrtf( (det[i].x - ref[j].x) * (det[i].x - ref[j].x) +
-                                          (det[i].y - ref[j].y) * (det[i].y - ref[j].y) );
-                        if( (distance < ref[j].width * maxPosDiff) &&
-                            (det[i].width > ref[j].width / maxSizeDiff) &&
-                            (det[i].width < ref[j].width * maxSizeDiff) )
-                        {
-                            ref[j].found = 1;
-                            ref[j].neghbors = MAX( ref[j].neghbors, det[i].neghbors );
-                            found = 1;
-                        }
-                    }
-                    if( !found )
-                    {
-                        falseAlarms++;
-                        neg[MIN(det[i].neghbors, rocsize - 1)]++;
-                    }
-                }
-                for( j = 0; j < refcount; j++ )
-                {
-                    if( ref[j].found )
-                    {
-                        hits++;
-                        pos[MIN(ref[j].neghbors, rocsize - 1)]++;
-                    }
-                    else
-                    {
-                        missed++;
-                    }
-                }
-
-                totalHits += hits;
-                totalMissed += missed;
-                totalFalseAlarms += falseAlarms;
-                printf( "|%32.32s|%6d|%6d|%6d|\n", filename, hits, missed, falseAlarms );
-                printf( "+--------------------------------+------+------+------+\n" );
-                fflush( stdout );
-
-                if( saveDetected )
-                {
-                    strcpy( detfilename, detname );
-                    strcat( detfilename, filename );
-                    strcpy( filename, detfilename );
-                    cvvSaveImage( fullname, img );
-                }
-
-                if( det ) { cvFree( &det ); det = NULL; }
-            } /* if( !error ) */
-
-            cvReleaseImage( &img );
-            cvFree( &ref );
-        }
-        fclose( info );
-
-        printf( "|%32.32s|%6d|%6d|%6d|\n", "Total",
-                totalHits, totalMissed, totalFalseAlarms );
-        printf( "+================================+======+======+======+\n" );
-        printf( "Number of stages: %d\n", nos );
-        printf( "Number of weak classifiers: %d\n", numclassifiers[nos - 1] );
-        printf( "Total time: %f\n", totaltime );
-
-        /* print ROC to stdout */
-        for( i = rocsize - 1; i > 0; i-- )
-        {
-            pos[i-1] += pos[i];
-            neg[i-1] += neg[i];
-        }
-        fprintf( stderr, "%d\n", nos );
-        for( i = 0; i < rocsize; i++ )
-        {
-            fprintf( stderr, "\t%d\t%d\t%f\t%f\n", pos[i], neg[i],
-                ((float)pos[i]) / (totalHits + totalMissed),
-                ((float)neg[i]) / (totalHits + totalMissed) );
-        }
-
-        cvFree( &pos );
-        cvFree( &neg );
-    }
-
-    delete[] numclassifiers;
-
-    cvReleaseHaarClassifierCascade( &cascade );
-    cvReleaseMemStorage( &storage );
-
-    return 0;
-}
diff --git a/apps/sft/CMakeLists.txt b/apps/sft/CMakeLists.txt
deleted file mode 100644 (file)
index 05bd337..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-set(name sft)
-set(the_target opencv_${name})
-
-set(OPENCV_${the_target}_DEPS opencv_core opencv_softcascade opencv_highgui opencv_imgproc opencv_ml)
-ocv_check_dependencies(${OPENCV_${the_target}_DEPS})
-
-if(NOT OCV_DEPENDENCIES_FOUND)
-  return()
-endif()
-
-project(${the_target})
-
-ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include" "${OpenCV_SOURCE_DIR}/include/opencv")
-ocv_include_modules(${OPENCV_${the_target}_DEPS})
-
-file(GLOB ${the_target}_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
-
-add_executable(${the_target} ${${the_target}_SOURCES})
-
-target_link_libraries(${the_target} ${OPENCV_${the_target}_DEPS})
-
-set_target_properties(${the_target} PROPERTIES
-                      DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
-                      ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
-                      RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
-                      INSTALL_NAME_DIR lib
-                      OUTPUT_NAME "opencv_trainsoftcascade")
-
-if(ENABLE_SOLUTION_FOLDERS)
-  set_target_properties(${the_target} PROPERTIES FOLDER "applications")
-endif()
-
-install(TARGETS ${the_target} RUNTIME DESTINATION bin COMPONENT main)
diff --git a/apps/sft/config.cpp b/apps/sft/config.cpp
deleted file mode 100644 (file)
index 9157575..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include <sft/config.hpp>
-#include <iomanip>
-
-sft::Config::Config(): seed(0) {}
-
-void sft::Config::write(cv::FileStorage& fs) const
-{
-    fs << "{"
-       << "trainPath"    << trainPath
-       << "testPath"     << testPath
-
-       << "modelWinSize" << modelWinSize
-       << "offset"       << offset
-       << "octaves"      << octaves
-
-       << "positives"    << positives
-       << "negatives"    << negatives
-       << "btpNegatives" << btpNegatives
-
-       << "shrinkage"    << shrinkage
-
-       << "treeDepth"    << treeDepth
-       << "weaks"        << weaks
-       << "poolSize"     << poolSize
-
-       << "cascadeName"  << cascadeName
-       << "outXmlPath"   << outXmlPath
-
-       << "seed"         << seed
-       << "featureType"  << featureType
-       << "}";
-}
-
-void sft::Config::read(const cv::FileNode& node)
-{
-    trainPath = (string)node["trainPath"];
-    testPath  = (string)node["testPath"];
-
-    cv::FileNodeIterator  nIt = node["modelWinSize"].end();
-    modelWinSize = cv::Size((int)*(--nIt), (int)*(--nIt));
-
-    nIt = node["offset"].end();
-    offset = cv::Point2i((int)*(--nIt), (int)*(--nIt));
-
-    node["octaves"] >> octaves;
-
-    positives =    (int)node["positives"];
-    negatives =    (int)node["negatives"];
-    btpNegatives = (int)node["btpNegatives"];
-
-    shrinkage = (int)node["shrinkage"];
-
-    treeDepth = (int)node["treeDepth"];
-    weaks =     (int)node["weaks"];
-    poolSize =  (int)node["poolSize"];
-
-    cascadeName = (std::string)node["cascadeName"];
-    outXmlPath =  (std::string)node["outXmlPath"];
-
-    seed = (int)node["seed"];
-    featureType = (std::string)node["featureType"];
-}
-
-void sft::write(cv::FileStorage& fs, const string&, const Config& x)
-{
-    x.write(fs);
-}
-
-void sft::read(const cv::FileNode& node, Config& x, const Config& default_value)
-{
-    x = default_value;
-
-    if(!node.empty())
-        x.read(node);
-}
-
-namespace {
-
-struct Out
-{
-    Out(std::ostream& _out): out(_out) {}
-    template<typename T>
-    void operator ()(const T a) const {out << a << " ";}
-
-    std::ostream& out;
-private:
-    Out& operator=(Out const& other);
-};
-}
-
-std::ostream& sft::operator<<(std::ostream& out, const Config& m)
-{
-    out << std::setw(14) << std::left << "trainPath"    << m.trainPath     << std::endl
-        << std::setw(14) << std::left << "testPath"     << m.testPath      << std::endl
-
-        << std::setw(14) << std::left << "modelWinSize" << m.modelWinSize  << std::endl
-        << std::setw(14) << std::left << "offset"       << m.offset        << std::endl
-        << std::setw(14) << std::left << "octaves";
-
-    Out o(out);
-    for_each(m.octaves.begin(), m.octaves.end(), o);
-
-    out << std::endl
-        << std::setw(14) << std::left  << "positives"    << m.positives    << std::endl
-        << std::setw(14) << std::left  << "negatives"    << m.negatives    << std::endl
-        << std::setw(14) << std::left  << "btpNegatives" << m.btpNegatives << std::endl
-
-        << std::setw(14) << std::left  << "shrinkage"    << m.shrinkage    << std::endl
-
-        << std::setw(14) << std::left  << "treeDepth"    << m.treeDepth    << std::endl
-        << std::setw(14) << std::left  << "weaks"        << m.weaks        << std::endl
-        << std::setw(14) << std::left  << "poolSize"     << m.poolSize     << std::endl
-
-        << std::setw(14) << std::left  << "cascadeName"  << m.cascadeName  << std::endl
-        << std::setw(14) << std::left  << "outXmlPath"   << m.outXmlPath   << std::endl
-        << std::setw(14) << std::left  << "seed"         << m.seed         << std::endl
-        << std::setw(14) << std::left  << "featureType"  << m.featureType  << std::endl;
-
-    return out;
-}
diff --git a/apps/sft/dataset.cpp b/apps/sft/dataset.cpp
deleted file mode 100644 (file)
index dd4ba59..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include <sft/dataset.hpp>
-#include <opencv2/highgui.hpp>
-
-#include <iostream>
-#include <queue>
-
-// in the default case data folders should be aligned as following:
-// 1. positives: <train or test path>/octave_<octave number>/pos/*.png
-// 2. negatives: <train or test path>/octave_<octave number>/neg/*.png
-sft::ScaledDataset::ScaledDataset(const string& path, const int oct)
-{
-    dprintf("%s\n", "get dataset file names...");
-    dprintf("%s\n", "Positives globing...");
-    cv::glob(path + "/pos/octave_" + cv::format("%d", oct) + "/*.png", pos);
-
-    dprintf("%s\n", "Negatives globing...");
-    cv::glob(path + "/neg/octave_" + cv::format("%d", oct) + "/*.png", neg);
-
-    // Check: files not empty
-    CV_Assert(pos.size() != size_t(0));
-    CV_Assert(neg.size() != size_t(0));
-}
-
-cv::Mat sft::ScaledDataset::get(SampleType type, int idx) const
-{
-    const std::string& src = (type == POSITIVE)? pos[idx]: neg[idx];
-    return cv::imread(src);
-}
-
-int sft::ScaledDataset::available(SampleType type) const
-{
-    return (int)((type == POSITIVE)? pos.size():neg.size());
-}
-
-sft::ScaledDataset::~ScaledDataset(){}
diff --git a/apps/sft/include/sft/common.hpp b/apps/sft/include/sft/common.hpp
deleted file mode 100644 (file)
index 5c142a7..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __SFT_COMMON_HPP__
-#define __SFT_COMMON_HPP__
-
-#include <opencv2/core.hpp>
-#include <opencv2/core/utility.hpp>
-#include <opencv2/softcascade.hpp>
-
-namespace cv {using namespace softcascade;}
-namespace sft
-{
-
-    using cv::Mat;
-    struct ICF;
-
-    typedef cv::String   string;
-
-    typedef std::vector<ICF>           Icfvector;
-    typedef std::vector<sft::string>   svector;
-    typedef std::vector<int>           ivector;
-}
-
-// used for noisy printfs
-//#define WITH_DEBUG_OUT
-
-#if defined WITH_DEBUG_OUT
-# include <stdio.h>
-# define dprintf(format, ...)  printf(format, ##__VA_ARGS__)
-#else
-# define dprintf(format, ...)
-#endif
-
-#endif
diff --git a/apps/sft/include/sft/config.hpp b/apps/sft/include/sft/config.hpp
deleted file mode 100644 (file)
index c6e85b2..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __SFT_CONFIG_HPP__
-#define __SFT_CONFIG_HPP__
-
-#include <sft/common.hpp>
-
-#include <ostream>
-
-namespace sft {
-
-struct Config
-{
-    Config();
-
-    void write(cv::FileStorage& fs) const;
-
-    void read(const cv::FileNode& node);
-
-    // Scaled and shrunk model size.
-    cv::Size model(ivector::const_iterator it) const
-    {
-        float octave = powf(2.f, (float)(*it));
-        return cv::Size( cvRound(modelWinSize.width  * octave) / shrinkage,
-                         cvRound(modelWinSize.height * octave) / shrinkage );
-    }
-
-    // Scaled but, not shrunk bounding box for object in sample image.
-    cv::Rect bbox(ivector::const_iterator it) const
-    {
-        float octave = powf(2.f, (float)(*it));
-        return cv::Rect( cvRound(offset.x * octave), cvRound(offset.y * octave),
-            cvRound(modelWinSize.width  * octave), cvRound(modelWinSize.height * octave));
-    }
-
-    string resPath(ivector::const_iterator it) const
-    {
-        return cv::format("%s%d.xml",cascadeName.c_str(), *it);
-    }
-
-    // Paths to a rescaled data
-    string trainPath;
-    string testPath;
-
-    // Original model size.
-    cv::Size modelWinSize;
-
-    // example offset into positive image
-    cv::Point2i offset;
-
-    // List of octaves for which have to be trained cascades (a list of powers of two)
-    ivector octaves;
-
-    // Maximum number of positives that should be used during training
-    int positives;
-
-    // Initial number of negatives used during training.
-    int negatives;
-
-    // Number of weak negatives to add each bootstrapping step.
-    int btpNegatives;
-
-    // Inverse of scale for feature resizing
-    int shrinkage;
-
-    // Depth on weak classifier's decision tree
-    int treeDepth;
-
-    // Weak classifiers number in resulted cascade
-    int weaks;
-
-    // Feature random pool size
-    int poolSize;
-
-    // file name to store cascade
-    string cascadeName;
-
-    // path to resulting cascade
-    string outXmlPath;
-
-    // seed for random generation
-    int seed;
-
-    // channel feature type
-    string featureType;
-
-    // // bounding rectangle for actual example into example window
-    // cv::Rect exampleWindow;
-};
-
-// required for cv::FileStorage serialization
-void write(cv::FileStorage& fs, const string&, const Config& x);
-void read(const cv::FileNode& node, Config& x, const Config& default_value);
-std::ostream& operator<<(std::ostream& out, const Config& m);
-
-}
-
-#endif
diff --git a/apps/sft/include/sft/dataset.hpp b/apps/sft/include/sft/dataset.hpp
deleted file mode 100644 (file)
index 7504f40..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __SFT_OCTAVE_HPP__
-#define __SFT_OCTAVE_HPP__
-
-#include <sft/common.hpp>
-namespace sft
-{
-
-using cv::softcascade::Dataset;
-
-class ScaledDataset : public Dataset
-{
-public:
-    ScaledDataset(const sft::string& path, const int octave);
-
-    virtual cv::Mat get(SampleType type, int idx) const;
-    virtual int available(SampleType type) const;
-    virtual ~ScaledDataset();
-
-private:
-    svector pos;
-    svector neg;
-};
-}
-
-#endif
diff --git a/apps/sft/sft.cpp b/apps/sft/sft.cpp
deleted file mode 100644 (file)
index 79d4103..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-// Training application for Soft Cascades.
-
-#include <sft/common.hpp>
-#include <iostream>
-#include <sft/dataset.hpp>
-#include <sft/config.hpp>
-
-#include <opencv2/core/core_c.h>
-
-int main(int argc, char** argv)
-{
-    using namespace sft;
-
-    const string keys =
-        "{help h usage ? |      | print this message              }"
-        "{config c       |      | path to configuration xml       }"
-    ;
-
-    cv::CommandLineParser parser(argc, argv, keys);
-    parser.about("Soft cascade training application.");
-
-    if (parser.has("help"))
-    {
-        parser.printMessage();
-        return 0;
-    }
-
-    if (!parser.check())
-    {
-        parser.printErrors();
-        return 1;
-    }
-
-    string configPath = parser.get<string>("config");
-    if (configPath.empty())
-    {
-        std::cout << "Configuration file is missing or empty. Could not start training." << std::endl;
-        return 0;
-    }
-
-    std::cout << "Read configuration from file " << configPath << std::endl;
-    cv::FileStorage fs(configPath, cv::FileStorage::READ);
-    if(!fs.isOpened())
-    {
-        std::cout << "Configuration file " << configPath << " can't be opened." << std::endl;
-        return 1;
-    }
-
-    // 1. load config
-    sft::Config cfg;
-    fs["config"] >> cfg;
-    std::cout << std::endl << "Training will be executed for configuration:" << std::endl << cfg << std::endl;
-
-    // 2. check and open output file
-    cv::FileStorage fso(cfg.outXmlPath, cv::FileStorage::WRITE);
-    if(!fso.isOpened())
-    {
-        std::cout << "Training stopped. Output classifier Xml file " << cfg.outXmlPath << " can't be opened." << std::endl;
-        return 1;
-    }
-
-    fso << cfg.cascadeName
-        << "{"
-        << "stageType"   << "BOOST"
-        << "featureType" << cfg.featureType
-        << "octavesNum"  << (int)cfg.octaves.size()
-        << "width"       << cfg.modelWinSize.width
-        << "height"      << cfg.modelWinSize.height
-        << "shrinkage"   << cfg.shrinkage
-        << "octaves"     << "[";
-
-    // 3. Train all octaves
-    for (ivector::const_iterator it = cfg.octaves.begin(); it != cfg.octaves.end(); ++it)
-    {
-        // a. create random feature pool
-        int nfeatures  = cfg.poolSize;
-        cv::Size model = cfg.model(it);
-        std::cout << "Model " << model << std::endl;
-
-        int nchannels = (cfg.featureType == "HOG6MagLuv") ? 10: 8;
-
-        std::cout << "number of feature channels is " << nchannels << std::endl;
-
-        cv::Ptr<cv::FeaturePool> pool = cv::FeaturePool::create(model, nfeatures, nchannels);
-        nfeatures = pool->size();
-
-
-        int npositives = cfg.positives;
-        int nnegatives = cfg.negatives;
-        int shrinkage  = cfg.shrinkage;
-        cv::Rect boundingBox = cfg.bbox(it);
-        std::cout << "Object bounding box" << boundingBox << std::endl;
-
-        typedef cv::Octave Octave;
-
-        cv::Ptr<cv::ChannelFeatureBuilder> builder = cv::ChannelFeatureBuilder::create(cfg.featureType);
-        std::cout << "Channel builder " << builder->info()->name() << std::endl;
-        cv::Ptr<Octave> boost = Octave::create(boundingBox, npositives, nnegatives, *it, shrinkage, builder);
-
-        std::string path = cfg.trainPath;
-        sft::ScaledDataset dataset(path, *it);
-
-        if (boost->train(&dataset, pool, cfg.weaks, cfg.treeDepth))
-        {
-            CvFileStorage* fout = cvOpenFileStorage(cfg.resPath(it).c_str(), 0, CV_STORAGE_WRITE);
-            boost->write(fout, cfg.cascadeName);
-
-            cvReleaseFileStorage( &fout);
-
-            cv::Mat thresholds;
-            boost->setRejectThresholds(thresholds);
-
-            boost->write(fso, pool, thresholds);
-
-            cv::FileStorage tfs(("thresholds." + cfg.resPath(it)).c_str(), cv::FileStorage::WRITE);
-            tfs << "thresholds" << thresholds;
-
-            std::cout << "Octave " << *it << " was successfully trained..." << std::endl;
-        }
-    }
-
-    fso << "]" << "}";
-    fso.release();
-    std::cout << "Training complete..." << std::endl;
-    return 0;
-}
index f36e4b2..e560ed8 100644 (file)
@@ -1,4 +1,4 @@
-set(OPENCV_TRAINCASCADE_DEPS opencv_core opencv_ml opencv_imgproc opencv_photo opencv_objdetect opencv_highgui opencv_calib3d opencv_video opencv_features2d opencv_flann opencv_legacy)
+set(OPENCV_TRAINCASCADE_DEPS opencv_core opencv_ml opencv_imgproc opencv_photo opencv_objdetect opencv_highgui opencv_calib3d opencv_video opencv_features2d)
 ocv_check_dependencies(${OPENCV_TRAINCASCADE_DEPS})
 
 if(NOT OCV_DEPENDENCIES_FOUND)
@@ -20,7 +20,7 @@ set(traincascade_files traincascade.cpp
 
 set(the_target opencv_traincascade)
 add_executable(${the_target} ${traincascade_files})
-target_link_libraries(${the_target} ${OPENCV_TRAINCASCADE_DEPS} opencv_haartraining_engine)
+target_link_libraries(${the_target} ${OPENCV_TRAINCASCADE_DEPS})
 
 set_target_properties(${the_target} PROPERTIES
                       DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
index 1ed020a..0aefc6d 100644 (file)
@@ -65,8 +65,6 @@
 #include "opencv2/photo/photo_c.h"
 #include "opencv2/video/tracking_c.h"
 #include "opencv2/objdetect/objdetect_c.h"
-#include "opencv2/legacy.hpp"
-#include "opencv2/legacy/compat.hpp"
 
 #if !defined(CV_IMPL)
 #define CV_IMPL extern "C"
index 020a453..b7c290a 100644 (file)
@@ -51,7 +51,6 @@
 #include "opencv2/objdetect.hpp"
 #include "opencv2/calib3d.hpp"
 #include "opencv2/highgui.hpp"
-#include "opencv2/contrib.hpp"
 #include "opencv2/ml.hpp"
 
 #endif
diff --git a/modules/contrib/CMakeLists.txt b/modules/contrib/CMakeLists.txt
deleted file mode 100644 (file)
index 120301b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ocv_define_module(contrib opencv_imgproc opencv_calib3d opencv_ml opencv_video opencv_objdetect OPTIONAL opencv_highgui opencv_nonfree)
diff --git a/modules/contrib/doc/contrib.rst b/modules/contrib/doc/contrib.rst
deleted file mode 100644 (file)
index de14d33..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-***************************************
-contrib. Contributed/Experimental Stuff
-***************************************
-
-The module contains some recently added functionality that has not been stabilized, or functionality that is considered optional.
-
-.. toctree::
-    :maxdepth: 2
-
-    stereo
-    FaceRecognizer Documentation <facerec/index>
-    openfabmap
diff --git a/modules/contrib/doc/facerec/colormaps.rst b/modules/contrib/doc/facerec/colormaps.rst
deleted file mode 100644 (file)
index 95750ab..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-ColorMaps in OpenCV
-===================
-
-applyColorMap
----------------------
-
-Applies a GNU Octave/MATLAB equivalent colormap on a given image.
-
-.. ocv:function:: void applyColorMap(InputArray src, OutputArray dst, int colormap)
-
-    :param src: The source image, grayscale or colored does not matter.
-    :param dst: The result is the colormapped source image. Note: :ocv:func:`Mat::create` is called on dst.
-    :param colormap: The colormap to apply, see the list of available colormaps below.
-
-Currently the following GNU Octave/MATLAB equivalent colormaps are implemented:
-
-.. code-block:: cpp
-
-    enum
-    {
-        COLORMAP_AUTUMN = 0,
-        COLORMAP_BONE = 1,
-        COLORMAP_JET = 2,
-        COLORMAP_WINTER = 3,
-        COLORMAP_RAINBOW = 4,
-        COLORMAP_OCEAN = 5,
-        COLORMAP_SUMMER = 6,
-        COLORMAP_SPRING = 7,
-        COLORMAP_COOL = 8,
-        COLORMAP_HSV = 9,
-        COLORMAP_PINK = 10,
-        COLORMAP_HOT = 11
-    }
-
-
-Description
------------
-
-The human perception isn't built for observing fine changes in grayscale images. Human eyes are more sensitive to observing changes between colors, so you often need to recolor your grayscale images to get a clue about them. OpenCV now comes with various colormaps to enhance the visualization in your computer vision application.
-
-In OpenCV 2.4 you only need :ocv:func:`applyColorMap` to apply a colormap on a given image. The following sample code reads the path to an image from command line, applies a Jet colormap on it and shows the result:
-
-.. code-block:: cpp
-
-    #include <opencv2/contrib.hpp>
-    #include <opencv2/core.hpp>
-    #include <opencv2/highgui.hpp>
-
-    using namespace cv;
-
-    int main(int argc, const char *argv[]) {
-        // Get the path to the image, if it was given
-        // if no arguments were given.
-        String filename;
-        if (argc > 1) {
-            filename = String(argv[1]);
-        }
-        // The following lines show how to apply a colormap on a given image
-        // and show it with cv::imshow example with an image. An exception is
-        // thrown if the path to the image is invalid.
-        if(!filename.empty()) {
-            Mat img0 = imread(filename);
-            // Throw an exception, if the image can't be read:
-            if(img0.empty()) {
-                CV_Error(CV_StsBadArg, "Sample image is empty. Please adjust your path, so it points to a valid input image!");
-            }
-            // Holds the colormap version of the image:
-            Mat cm_img0;
-            // Apply the colormap:
-            applyColorMap(img0, cm_img0, COLORMAP_JET);
-            // Show the result:
-            imshow("cm_img0", cm_img0);
-            waitKey(0);
-        }
-
-        return 0;
-    }
-
-And here are the color scales for each of the available colormaps:
-
-+-----------------------+---------------------------------------------------+
-| Class                 | Scale                                             |
-+=======================+===================================================+
-| COLORMAP_AUTUMN       | .. image:: img/colormaps/colorscale_autumn.jpg    |
-+-----------------------+---------------------------------------------------+
-| COLORMAP_BONE         | .. image:: img/colormaps/colorscale_bone.jpg      |
-+-----------------------+---------------------------------------------------+
-| COLORMAP_COOL         | .. image:: img/colormaps/colorscale_cool.jpg      |
-+-----------------------+---------------------------------------------------+
-| COLORMAP_HOT          | .. image:: img/colormaps/colorscale_hot.jpg       |
-+-----------------------+---------------------------------------------------+
-| COLORMAP_HSV          | .. image:: img/colormaps/colorscale_hsv.jpg       |
-+-----------------------+---------------------------------------------------+
-| COLORMAP_JET          | .. image:: img/colormaps/colorscale_jet.jpg       |
-+-----------------------+---------------------------------------------------+
-| COLORMAP_OCEAN        | .. image:: img/colormaps/colorscale_ocean.jpg     |
-+-----------------------+---------------------------------------------------+
-| COLORMAP_PINK         | .. image:: img/colormaps/colorscale_pink.jpg      |
-+-----------------------+---------------------------------------------------+
-| COLORMAP_RAINBOW      | .. image:: img/colormaps/colorscale_rainbow.jpg   |
-+-----------------------+---------------------------------------------------+
-| COLORMAP_SPRING       | .. image:: img/colormaps/colorscale_spring.jpg    |
-+-----------------------+---------------------------------------------------+
-| COLORMAP_SUMMER       | .. image:: img/colormaps/colorscale_summer.jpg    |
-+-----------------------+---------------------------------------------------+
-| COLORMAP_WINTER       | .. image:: img/colormaps/colorscale_winter.jpg    |
-+-----------------------+---------------------------------------------------+
diff --git a/modules/contrib/doc/facerec/etc/at.txt b/modules/contrib/doc/facerec/etc/at.txt
deleted file mode 100644 (file)
index 3d76326..0000000
+++ /dev/null
@@ -1,400 +0,0 @@
-/home/philipp/facerec/data/at/s13/2.pgm;12
-/home/philipp/facerec/data/at/s13/7.pgm;12
-/home/philipp/facerec/data/at/s13/6.pgm;12
-/home/philipp/facerec/data/at/s13/9.pgm;12
-/home/philipp/facerec/data/at/s13/5.pgm;12
-/home/philipp/facerec/data/at/s13/3.pgm;12
-/home/philipp/facerec/data/at/s13/4.pgm;12
-/home/philipp/facerec/data/at/s13/10.pgm;12
-/home/philipp/facerec/data/at/s13/8.pgm;12
-/home/philipp/facerec/data/at/s13/1.pgm;12
-/home/philipp/facerec/data/at/s17/2.pgm;16
-/home/philipp/facerec/data/at/s17/7.pgm;16
-/home/philipp/facerec/data/at/s17/6.pgm;16
-/home/philipp/facerec/data/at/s17/9.pgm;16
-/home/philipp/facerec/data/at/s17/5.pgm;16
-/home/philipp/facerec/data/at/s17/3.pgm;16
-/home/philipp/facerec/data/at/s17/4.pgm;16
-/home/philipp/facerec/data/at/s17/10.pgm;16
-/home/philipp/facerec/data/at/s17/8.pgm;16
-/home/philipp/facerec/data/at/s17/1.pgm;16
-/home/philipp/facerec/data/at/s32/2.pgm;31
-/home/philipp/facerec/data/at/s32/7.pgm;31
-/home/philipp/facerec/data/at/s32/6.pgm;31
-/home/philipp/facerec/data/at/s32/9.pgm;31
-/home/philipp/facerec/data/at/s32/5.pgm;31
-/home/philipp/facerec/data/at/s32/3.pgm;31
-/home/philipp/facerec/data/at/s32/4.pgm;31
-/home/philipp/facerec/data/at/s32/10.pgm;31
-/home/philipp/facerec/data/at/s32/8.pgm;31
-/home/philipp/facerec/data/at/s32/1.pgm;31
-/home/philipp/facerec/data/at/s10/2.pgm;9
-/home/philipp/facerec/data/at/s10/7.pgm;9
-/home/philipp/facerec/data/at/s10/6.pgm;9
-/home/philipp/facerec/data/at/s10/9.pgm;9
-/home/philipp/facerec/data/at/s10/5.pgm;9
-/home/philipp/facerec/data/at/s10/3.pgm;9
-/home/philipp/facerec/data/at/s10/4.pgm;9
-/home/philipp/facerec/data/at/s10/10.pgm;9
-/home/philipp/facerec/data/at/s10/8.pgm;9
-/home/philipp/facerec/data/at/s10/1.pgm;9
-/home/philipp/facerec/data/at/s27/2.pgm;26
-/home/philipp/facerec/data/at/s27/7.pgm;26
-/home/philipp/facerec/data/at/s27/6.pgm;26
-/home/philipp/facerec/data/at/s27/9.pgm;26
-/home/philipp/facerec/data/at/s27/5.pgm;26
-/home/philipp/facerec/data/at/s27/3.pgm;26
-/home/philipp/facerec/data/at/s27/4.pgm;26
-/home/philipp/facerec/data/at/s27/10.pgm;26
-/home/philipp/facerec/data/at/s27/8.pgm;26
-/home/philipp/facerec/data/at/s27/1.pgm;26
-/home/philipp/facerec/data/at/s5/2.pgm;4
-/home/philipp/facerec/data/at/s5/7.pgm;4
-/home/philipp/facerec/data/at/s5/6.pgm;4
-/home/philipp/facerec/data/at/s5/9.pgm;4
-/home/philipp/facerec/data/at/s5/5.pgm;4
-/home/philipp/facerec/data/at/s5/3.pgm;4
-/home/philipp/facerec/data/at/s5/4.pgm;4
-/home/philipp/facerec/data/at/s5/10.pgm;4
-/home/philipp/facerec/data/at/s5/8.pgm;4
-/home/philipp/facerec/data/at/s5/1.pgm;4
-/home/philipp/facerec/data/at/s20/2.pgm;19
-/home/philipp/facerec/data/at/s20/7.pgm;19
-/home/philipp/facerec/data/at/s20/6.pgm;19
-/home/philipp/facerec/data/at/s20/9.pgm;19
-/home/philipp/facerec/data/at/s20/5.pgm;19
-/home/philipp/facerec/data/at/s20/3.pgm;19
-/home/philipp/facerec/data/at/s20/4.pgm;19
-/home/philipp/facerec/data/at/s20/10.pgm;19
-/home/philipp/facerec/data/at/s20/8.pgm;19
-/home/philipp/facerec/data/at/s20/1.pgm;19
-/home/philipp/facerec/data/at/s30/2.pgm;29
-/home/philipp/facerec/data/at/s30/7.pgm;29
-/home/philipp/facerec/data/at/s30/6.pgm;29
-/home/philipp/facerec/data/at/s30/9.pgm;29
-/home/philipp/facerec/data/at/s30/5.pgm;29
-/home/philipp/facerec/data/at/s30/3.pgm;29
-/home/philipp/facerec/data/at/s30/4.pgm;29
-/home/philipp/facerec/data/at/s30/10.pgm;29
-/home/philipp/facerec/data/at/s30/8.pgm;29
-/home/philipp/facerec/data/at/s30/1.pgm;29
-/home/philipp/facerec/data/at/s39/2.pgm;38
-/home/philipp/facerec/data/at/s39/7.pgm;38
-/home/philipp/facerec/data/at/s39/6.pgm;38
-/home/philipp/facerec/data/at/s39/9.pgm;38
-/home/philipp/facerec/data/at/s39/5.pgm;38
-/home/philipp/facerec/data/at/s39/3.pgm;38
-/home/philipp/facerec/data/at/s39/4.pgm;38
-/home/philipp/facerec/data/at/s39/10.pgm;38
-/home/philipp/facerec/data/at/s39/8.pgm;38
-/home/philipp/facerec/data/at/s39/1.pgm;38
-/home/philipp/facerec/data/at/s35/2.pgm;34
-/home/philipp/facerec/data/at/s35/7.pgm;34
-/home/philipp/facerec/data/at/s35/6.pgm;34
-/home/philipp/facerec/data/at/s35/9.pgm;34
-/home/philipp/facerec/data/at/s35/5.pgm;34
-/home/philipp/facerec/data/at/s35/3.pgm;34
-/home/philipp/facerec/data/at/s35/4.pgm;34
-/home/philipp/facerec/data/at/s35/10.pgm;34
-/home/philipp/facerec/data/at/s35/8.pgm;34
-/home/philipp/facerec/data/at/s35/1.pgm;34
-/home/philipp/facerec/data/at/s23/2.pgm;22
-/home/philipp/facerec/data/at/s23/7.pgm;22
-/home/philipp/facerec/data/at/s23/6.pgm;22
-/home/philipp/facerec/data/at/s23/9.pgm;22
-/home/philipp/facerec/data/at/s23/5.pgm;22
-/home/philipp/facerec/data/at/s23/3.pgm;22
-/home/philipp/facerec/data/at/s23/4.pgm;22
-/home/philipp/facerec/data/at/s23/10.pgm;22
-/home/philipp/facerec/data/at/s23/8.pgm;22
-/home/philipp/facerec/data/at/s23/1.pgm;22
-/home/philipp/facerec/data/at/s4/2.pgm;3
-/home/philipp/facerec/data/at/s4/7.pgm;3
-/home/philipp/facerec/data/at/s4/6.pgm;3
-/home/philipp/facerec/data/at/s4/9.pgm;3
-/home/philipp/facerec/data/at/s4/5.pgm;3
-/home/philipp/facerec/data/at/s4/3.pgm;3
-/home/philipp/facerec/data/at/s4/4.pgm;3
-/home/philipp/facerec/data/at/s4/10.pgm;3
-/home/philipp/facerec/data/at/s4/8.pgm;3
-/home/philipp/facerec/data/at/s4/1.pgm;3
-/home/philipp/facerec/data/at/s9/2.pgm;8
-/home/philipp/facerec/data/at/s9/7.pgm;8
-/home/philipp/facerec/data/at/s9/6.pgm;8
-/home/philipp/facerec/data/at/s9/9.pgm;8
-/home/philipp/facerec/data/at/s9/5.pgm;8
-/home/philipp/facerec/data/at/s9/3.pgm;8
-/home/philipp/facerec/data/at/s9/4.pgm;8
-/home/philipp/facerec/data/at/s9/10.pgm;8
-/home/philipp/facerec/data/at/s9/8.pgm;8
-/home/philipp/facerec/data/at/s9/1.pgm;8
-/home/philipp/facerec/data/at/s37/2.pgm;36
-/home/philipp/facerec/data/at/s37/7.pgm;36
-/home/philipp/facerec/data/at/s37/6.pgm;36
-/home/philipp/facerec/data/at/s37/9.pgm;36
-/home/philipp/facerec/data/at/s37/5.pgm;36
-/home/philipp/facerec/data/at/s37/3.pgm;36
-/home/philipp/facerec/data/at/s37/4.pgm;36
-/home/philipp/facerec/data/at/s37/10.pgm;36
-/home/philipp/facerec/data/at/s37/8.pgm;36
-/home/philipp/facerec/data/at/s37/1.pgm;36
-/home/philipp/facerec/data/at/s24/2.pgm;23
-/home/philipp/facerec/data/at/s24/7.pgm;23
-/home/philipp/facerec/data/at/s24/6.pgm;23
-/home/philipp/facerec/data/at/s24/9.pgm;23
-/home/philipp/facerec/data/at/s24/5.pgm;23
-/home/philipp/facerec/data/at/s24/3.pgm;23
-/home/philipp/facerec/data/at/s24/4.pgm;23
-/home/philipp/facerec/data/at/s24/10.pgm;23
-/home/philipp/facerec/data/at/s24/8.pgm;23
-/home/philipp/facerec/data/at/s24/1.pgm;23
-/home/philipp/facerec/data/at/s19/2.pgm;18
-/home/philipp/facerec/data/at/s19/7.pgm;18
-/home/philipp/facerec/data/at/s19/6.pgm;18
-/home/philipp/facerec/data/at/s19/9.pgm;18
-/home/philipp/facerec/data/at/s19/5.pgm;18
-/home/philipp/facerec/data/at/s19/3.pgm;18
-/home/philipp/facerec/data/at/s19/4.pgm;18
-/home/philipp/facerec/data/at/s19/10.pgm;18
-/home/philipp/facerec/data/at/s19/8.pgm;18
-/home/philipp/facerec/data/at/s19/1.pgm;18
-/home/philipp/facerec/data/at/s8/2.pgm;7
-/home/philipp/facerec/data/at/s8/7.pgm;7
-/home/philipp/facerec/data/at/s8/6.pgm;7
-/home/philipp/facerec/data/at/s8/9.pgm;7
-/home/philipp/facerec/data/at/s8/5.pgm;7
-/home/philipp/facerec/data/at/s8/3.pgm;7
-/home/philipp/facerec/data/at/s8/4.pgm;7
-/home/philipp/facerec/data/at/s8/10.pgm;7
-/home/philipp/facerec/data/at/s8/8.pgm;7
-/home/philipp/facerec/data/at/s8/1.pgm;7
-/home/philipp/facerec/data/at/s21/2.pgm;20
-/home/philipp/facerec/data/at/s21/7.pgm;20
-/home/philipp/facerec/data/at/s21/6.pgm;20
-/home/philipp/facerec/data/at/s21/9.pgm;20
-/home/philipp/facerec/data/at/s21/5.pgm;20
-/home/philipp/facerec/data/at/s21/3.pgm;20
-/home/philipp/facerec/data/at/s21/4.pgm;20
-/home/philipp/facerec/data/at/s21/10.pgm;20
-/home/philipp/facerec/data/at/s21/8.pgm;20
-/home/philipp/facerec/data/at/s21/1.pgm;20
-/home/philipp/facerec/data/at/s1/2.pgm;0
-/home/philipp/facerec/data/at/s1/7.pgm;0
-/home/philipp/facerec/data/at/s1/6.pgm;0
-/home/philipp/facerec/data/at/s1/9.pgm;0
-/home/philipp/facerec/data/at/s1/5.pgm;0
-/home/philipp/facerec/data/at/s1/3.pgm;0
-/home/philipp/facerec/data/at/s1/4.pgm;0
-/home/philipp/facerec/data/at/s1/10.pgm;0
-/home/philipp/facerec/data/at/s1/8.pgm;0
-/home/philipp/facerec/data/at/s1/1.pgm;0
-/home/philipp/facerec/data/at/s7/2.pgm;6
-/home/philipp/facerec/data/at/s7/7.pgm;6
-/home/philipp/facerec/data/at/s7/6.pgm;6
-/home/philipp/facerec/data/at/s7/9.pgm;6
-/home/philipp/facerec/data/at/s7/5.pgm;6
-/home/philipp/facerec/data/at/s7/3.pgm;6
-/home/philipp/facerec/data/at/s7/4.pgm;6
-/home/philipp/facerec/data/at/s7/10.pgm;6
-/home/philipp/facerec/data/at/s7/8.pgm;6
-/home/philipp/facerec/data/at/s7/1.pgm;6
-/home/philipp/facerec/data/at/s16/2.pgm;15
-/home/philipp/facerec/data/at/s16/7.pgm;15
-/home/philipp/facerec/data/at/s16/6.pgm;15
-/home/philipp/facerec/data/at/s16/9.pgm;15
-/home/philipp/facerec/data/at/s16/5.pgm;15
-/home/philipp/facerec/data/at/s16/3.pgm;15
-/home/philipp/facerec/data/at/s16/4.pgm;15
-/home/philipp/facerec/data/at/s16/10.pgm;15
-/home/philipp/facerec/data/at/s16/8.pgm;15
-/home/philipp/facerec/data/at/s16/1.pgm;15
-/home/philipp/facerec/data/at/s36/2.pgm;35
-/home/philipp/facerec/data/at/s36/7.pgm;35
-/home/philipp/facerec/data/at/s36/6.pgm;35
-/home/philipp/facerec/data/at/s36/9.pgm;35
-/home/philipp/facerec/data/at/s36/5.pgm;35
-/home/philipp/facerec/data/at/s36/3.pgm;35
-/home/philipp/facerec/data/at/s36/4.pgm;35
-/home/philipp/facerec/data/at/s36/10.pgm;35
-/home/philipp/facerec/data/at/s36/8.pgm;35
-/home/philipp/facerec/data/at/s36/1.pgm;35
-/home/philipp/facerec/data/at/s25/2.pgm;24
-/home/philipp/facerec/data/at/s25/7.pgm;24
-/home/philipp/facerec/data/at/s25/6.pgm;24
-/home/philipp/facerec/data/at/s25/9.pgm;24
-/home/philipp/facerec/data/at/s25/5.pgm;24
-/home/philipp/facerec/data/at/s25/3.pgm;24
-/home/philipp/facerec/data/at/s25/4.pgm;24
-/home/philipp/facerec/data/at/s25/10.pgm;24
-/home/philipp/facerec/data/at/s25/8.pgm;24
-/home/philipp/facerec/data/at/s25/1.pgm;24
-/home/philipp/facerec/data/at/s14/2.pgm;13
-/home/philipp/facerec/data/at/s14/7.pgm;13
-/home/philipp/facerec/data/at/s14/6.pgm;13
-/home/philipp/facerec/data/at/s14/9.pgm;13
-/home/philipp/facerec/data/at/s14/5.pgm;13
-/home/philipp/facerec/data/at/s14/3.pgm;13
-/home/philipp/facerec/data/at/s14/4.pgm;13
-/home/philipp/facerec/data/at/s14/10.pgm;13
-/home/philipp/facerec/data/at/s14/8.pgm;13
-/home/philipp/facerec/data/at/s14/1.pgm;13
-/home/philipp/facerec/data/at/s34/2.pgm;33
-/home/philipp/facerec/data/at/s34/7.pgm;33
-/home/philipp/facerec/data/at/s34/6.pgm;33
-/home/philipp/facerec/data/at/s34/9.pgm;33
-/home/philipp/facerec/data/at/s34/5.pgm;33
-/home/philipp/facerec/data/at/s34/3.pgm;33
-/home/philipp/facerec/data/at/s34/4.pgm;33
-/home/philipp/facerec/data/at/s34/10.pgm;33
-/home/philipp/facerec/data/at/s34/8.pgm;33
-/home/philipp/facerec/data/at/s34/1.pgm;33
-/home/philipp/facerec/data/at/s11/2.pgm;10
-/home/philipp/facerec/data/at/s11/7.pgm;10
-/home/philipp/facerec/data/at/s11/6.pgm;10
-/home/philipp/facerec/data/at/s11/9.pgm;10
-/home/philipp/facerec/data/at/s11/5.pgm;10
-/home/philipp/facerec/data/at/s11/3.pgm;10
-/home/philipp/facerec/data/at/s11/4.pgm;10
-/home/philipp/facerec/data/at/s11/10.pgm;10
-/home/philipp/facerec/data/at/s11/8.pgm;10
-/home/philipp/facerec/data/at/s11/1.pgm;10
-/home/philipp/facerec/data/at/s26/2.pgm;25
-/home/philipp/facerec/data/at/s26/7.pgm;25
-/home/philipp/facerec/data/at/s26/6.pgm;25
-/home/philipp/facerec/data/at/s26/9.pgm;25
-/home/philipp/facerec/data/at/s26/5.pgm;25
-/home/philipp/facerec/data/at/s26/3.pgm;25
-/home/philipp/facerec/data/at/s26/4.pgm;25
-/home/philipp/facerec/data/at/s26/10.pgm;25
-/home/philipp/facerec/data/at/s26/8.pgm;25
-/home/philipp/facerec/data/at/s26/1.pgm;25
-/home/philipp/facerec/data/at/s18/2.pgm;17
-/home/philipp/facerec/data/at/s18/7.pgm;17
-/home/philipp/facerec/data/at/s18/6.pgm;17
-/home/philipp/facerec/data/at/s18/9.pgm;17
-/home/philipp/facerec/data/at/s18/5.pgm;17
-/home/philipp/facerec/data/at/s18/3.pgm;17
-/home/philipp/facerec/data/at/s18/4.pgm;17
-/home/philipp/facerec/data/at/s18/10.pgm;17
-/home/philipp/facerec/data/at/s18/8.pgm;17
-/home/philipp/facerec/data/at/s18/1.pgm;17
-/home/philipp/facerec/data/at/s29/2.pgm;28
-/home/philipp/facerec/data/at/s29/7.pgm;28
-/home/philipp/facerec/data/at/s29/6.pgm;28
-/home/philipp/facerec/data/at/s29/9.pgm;28
-/home/philipp/facerec/data/at/s29/5.pgm;28
-/home/philipp/facerec/data/at/s29/3.pgm;28
-/home/philipp/facerec/data/at/s29/4.pgm;28
-/home/philipp/facerec/data/at/s29/10.pgm;28
-/home/philipp/facerec/data/at/s29/8.pgm;28
-/home/philipp/facerec/data/at/s29/1.pgm;28
-/home/philipp/facerec/data/at/s33/2.pgm;32
-/home/philipp/facerec/data/at/s33/7.pgm;32
-/home/philipp/facerec/data/at/s33/6.pgm;32
-/home/philipp/facerec/data/at/s33/9.pgm;32
-/home/philipp/facerec/data/at/s33/5.pgm;32
-/home/philipp/facerec/data/at/s33/3.pgm;32
-/home/philipp/facerec/data/at/s33/4.pgm;32
-/home/philipp/facerec/data/at/s33/10.pgm;32
-/home/philipp/facerec/data/at/s33/8.pgm;32
-/home/philipp/facerec/data/at/s33/1.pgm;32
-/home/philipp/facerec/data/at/s12/2.pgm;11
-/home/philipp/facerec/data/at/s12/7.pgm;11
-/home/philipp/facerec/data/at/s12/6.pgm;11
-/home/philipp/facerec/data/at/s12/9.pgm;11
-/home/philipp/facerec/data/at/s12/5.pgm;11
-/home/philipp/facerec/data/at/s12/3.pgm;11
-/home/philipp/facerec/data/at/s12/4.pgm;11
-/home/philipp/facerec/data/at/s12/10.pgm;11
-/home/philipp/facerec/data/at/s12/8.pgm;11
-/home/philipp/facerec/data/at/s12/1.pgm;11
-/home/philipp/facerec/data/at/s6/2.pgm;5
-/home/philipp/facerec/data/at/s6/7.pgm;5
-/home/philipp/facerec/data/at/s6/6.pgm;5
-/home/philipp/facerec/data/at/s6/9.pgm;5
-/home/philipp/facerec/data/at/s6/5.pgm;5
-/home/philipp/facerec/data/at/s6/3.pgm;5
-/home/philipp/facerec/data/at/s6/4.pgm;5
-/home/philipp/facerec/data/at/s6/10.pgm;5
-/home/philipp/facerec/data/at/s6/8.pgm;5
-/home/philipp/facerec/data/at/s6/1.pgm;5
-/home/philipp/facerec/data/at/s22/2.pgm;21
-/home/philipp/facerec/data/at/s22/7.pgm;21
-/home/philipp/facerec/data/at/s22/6.pgm;21
-/home/philipp/facerec/data/at/s22/9.pgm;21
-/home/philipp/facerec/data/at/s22/5.pgm;21
-/home/philipp/facerec/data/at/s22/3.pgm;21
-/home/philipp/facerec/data/at/s22/4.pgm;21
-/home/philipp/facerec/data/at/s22/10.pgm;21
-/home/philipp/facerec/data/at/s22/8.pgm;21
-/home/philipp/facerec/data/at/s22/1.pgm;21
-/home/philipp/facerec/data/at/s15/2.pgm;14
-/home/philipp/facerec/data/at/s15/7.pgm;14
-/home/philipp/facerec/data/at/s15/6.pgm;14
-/home/philipp/facerec/data/at/s15/9.pgm;14
-/home/philipp/facerec/data/at/s15/5.pgm;14
-/home/philipp/facerec/data/at/s15/3.pgm;14
-/home/philipp/facerec/data/at/s15/4.pgm;14
-/home/philipp/facerec/data/at/s15/10.pgm;14
-/home/philipp/facerec/data/at/s15/8.pgm;14
-/home/philipp/facerec/data/at/s15/1.pgm;14
-/home/philipp/facerec/data/at/s2/2.pgm;1
-/home/philipp/facerec/data/at/s2/7.pgm;1
-/home/philipp/facerec/data/at/s2/6.pgm;1
-/home/philipp/facerec/data/at/s2/9.pgm;1
-/home/philipp/facerec/data/at/s2/5.pgm;1
-/home/philipp/facerec/data/at/s2/3.pgm;1
-/home/philipp/facerec/data/at/s2/4.pgm;1
-/home/philipp/facerec/data/at/s2/10.pgm;1
-/home/philipp/facerec/data/at/s2/8.pgm;1
-/home/philipp/facerec/data/at/s2/1.pgm;1
-/home/philipp/facerec/data/at/s31/2.pgm;30
-/home/philipp/facerec/data/at/s31/7.pgm;30
-/home/philipp/facerec/data/at/s31/6.pgm;30
-/home/philipp/facerec/data/at/s31/9.pgm;30
-/home/philipp/facerec/data/at/s31/5.pgm;30
-/home/philipp/facerec/data/at/s31/3.pgm;30
-/home/philipp/facerec/data/at/s31/4.pgm;30
-/home/philipp/facerec/data/at/s31/10.pgm;30
-/home/philipp/facerec/data/at/s31/8.pgm;30
-/home/philipp/facerec/data/at/s31/1.pgm;30
-/home/philipp/facerec/data/at/s28/2.pgm;27
-/home/philipp/facerec/data/at/s28/7.pgm;27
-/home/philipp/facerec/data/at/s28/6.pgm;27
-/home/philipp/facerec/data/at/s28/9.pgm;27
-/home/philipp/facerec/data/at/s28/5.pgm;27
-/home/philipp/facerec/data/at/s28/3.pgm;27
-/home/philipp/facerec/data/at/s28/4.pgm;27
-/home/philipp/facerec/data/at/s28/10.pgm;27
-/home/philipp/facerec/data/at/s28/8.pgm;27
-/home/philipp/facerec/data/at/s28/1.pgm;27
-/home/philipp/facerec/data/at/s40/2.pgm;39
-/home/philipp/facerec/data/at/s40/7.pgm;39
-/home/philipp/facerec/data/at/s40/6.pgm;39
-/home/philipp/facerec/data/at/s40/9.pgm;39
-/home/philipp/facerec/data/at/s40/5.pgm;39
-/home/philipp/facerec/data/at/s40/3.pgm;39
-/home/philipp/facerec/data/at/s40/4.pgm;39
-/home/philipp/facerec/data/at/s40/10.pgm;39
-/home/philipp/facerec/data/at/s40/8.pgm;39
-/home/philipp/facerec/data/at/s40/1.pgm;39
-/home/philipp/facerec/data/at/s3/2.pgm;2
-/home/philipp/facerec/data/at/s3/7.pgm;2
-/home/philipp/facerec/data/at/s3/6.pgm;2
-/home/philipp/facerec/data/at/s3/9.pgm;2
-/home/philipp/facerec/data/at/s3/5.pgm;2
-/home/philipp/facerec/data/at/s3/3.pgm;2
-/home/philipp/facerec/data/at/s3/4.pgm;2
-/home/philipp/facerec/data/at/s3/10.pgm;2
-/home/philipp/facerec/data/at/s3/8.pgm;2
-/home/philipp/facerec/data/at/s3/1.pgm;2
-/home/philipp/facerec/data/at/s38/2.pgm;37
-/home/philipp/facerec/data/at/s38/7.pgm;37
-/home/philipp/facerec/data/at/s38/6.pgm;37
-/home/philipp/facerec/data/at/s38/9.pgm;37
-/home/philipp/facerec/data/at/s38/5.pgm;37
-/home/philipp/facerec/data/at/s38/3.pgm;37
-/home/philipp/facerec/data/at/s38/4.pgm;37
-/home/philipp/facerec/data/at/s38/10.pgm;37
-/home/philipp/facerec/data/at/s38/8.pgm;37
-/home/philipp/facerec/data/at/s38/1.pgm;37
diff --git a/modules/contrib/doc/facerec/facerec_api.rst b/modules/contrib/doc/facerec/facerec_api.rst
deleted file mode 100644 (file)
index d8fdde6..0000000
+++ /dev/null
@@ -1,377 +0,0 @@
-FaceRecognizer
-==============
-
-.. highlight:: cpp
-
-.. Sample code::
-
-   * An example using the FaceRecognizer class can be found at opencv_source_code/samples/cpp/facerec_demo.cpp
-
-   * (Python)  An example using the FaceRecognizer class can be found at opencv_source_code/samples/python2/facerec_demo.py
-
-FaceRecognizer
---------------
-
-.. ocv:class:: FaceRecognizer : public Algorithm
-
-All face recognition models in OpenCV are derived from the abstract base class :ocv:class:`FaceRecognizer`, which provides
-a unified access to all face recongition algorithms in OpenCV. ::
-
-  class FaceRecognizer : public Algorithm
-  {
-  public:
-      //! virtual destructor
-      virtual ~FaceRecognizer() {}
-
-      // Trains a FaceRecognizer.
-      virtual void train(InputArray src, InputArray labels) = 0;
-
-      // Updates a FaceRecognizer.
-      virtual void update(InputArrayOfArrays src, InputArray labels);
-
-      // Gets a prediction from a FaceRecognizer.
-      virtual int predict(InputArray src) const = 0;
-
-      // Predicts the label and confidence for a given sample.
-      virtual void predict(InputArray src, int &label, double &confidence) const = 0;
-
-      // Serializes this object to a given filename.
-      virtual void save(const String& filename) const;
-
-      // Deserializes this object from a given filename.
-      virtual void load(const String& filename);
-
-      // Serializes this object to a given cv::FileStorage.
-      virtual void save(FileStorage& fs) const = 0;
-
-      // Deserializes this object from a given cv::FileStorage.
-      virtual void load(const FileStorage& fs) = 0;
-  };
-
-
-Description
-+++++++++++
-
-I'll go a bit more into detail explaining :ocv:class:`FaceRecognizer`, because it doesn't look like a powerful interface at first sight. But: Every :ocv:class:`FaceRecognizer` is an :ocv:class:`Algorithm`, so you can easily get/set all model internals (if allowed by the implementation). :ocv:class:`Algorithm` is a relatively new OpenCV concept, which is available since the 2.4 release. I suggest you take a look at its description.
-
-:ocv:class:`Algorithm` provides the following features for all derived classes:
-
-* So called “virtual constructor”. That is, each Algorithm derivative is registered at program start and you can get the list of registered algorithms and create instance of a particular algorithm by its name (see :ocv:func:`Algorithm::create`). If you plan to add your own algorithms, it is good practice to add a unique prefix to your algorithms to distinguish them from other algorithms.
-
-* Setting/Retrieving algorithm parameters by name. If you used video capturing functionality from OpenCV highgui module, you are probably familar with :ocv:cfunc:`cvSetCaptureProperty`, :ocv:cfunc:`cvGetCaptureProperty`, :ocv:func:`VideoCapture::set` and :ocv:func:`VideoCapture::get`. :ocv:class:`Algorithm` provides similar method where instead of integer id's you specify the parameter names as text Strings. See :ocv:func:`Algorithm::set` and :ocv:func:`Algorithm::get` for details.
-
-* Reading and writing parameters from/to XML or YAML files. Every Algorithm derivative can store all its parameters and then read them back. There is no need to re-implement it each time.
-
-Moreover every :ocv:class:`FaceRecognizer` supports the:
-
-* **Training** of a :ocv:class:`FaceRecognizer` with :ocv:func:`FaceRecognizer::train` on a given set of images (your face database!).
-
-* **Prediction** of a given sample image, that means a face. The image is given as a :ocv:class:`Mat`.
-
-* **Loading/Saving** the model state from/to a given XML or YAML.
-
-.. note:: When using the FaceRecognizer interface in combination with Python, please stick to Python 2. Some underlying scripts like create_csv will not work in other versions, like Python 3.
-
-Setting the Thresholds
-+++++++++++++++++++++++
-
-Sometimes you run into the situation, when you want to apply a threshold on the prediction. A common scenario in face recognition is to tell, whether a face belongs to the training dataset or if it is unknown. You might wonder, why there's no public API in :ocv:class:`FaceRecognizer` to set the threshold for the prediction, but rest assured: It's supported. It just means there's no generic way in an abstract class to provide an interface for setting/getting the thresholds of *every possible* :ocv:class:`FaceRecognizer` algorithm. The appropriate place to set the thresholds is in the constructor of the specific :ocv:class:`FaceRecognizer` and since every :ocv:class:`FaceRecognizer` is a :ocv:class:`Algorithm` (see above), you can get/set the thresholds at runtime!
-
-Here is an example of setting a threshold for the Eigenfaces method, when creating the model:
-
-.. code-block:: cpp
-
-    // Let's say we want to keep 10 Eigenfaces and have a threshold value of 10.0
-    int num_components = 10;
-    double threshold = 10.0;
-    // Then if you want to have a cv::FaceRecognizer with a confidence threshold,
-    // create the concrete implementation with the appropiate parameters:
-    Ptr<FaceRecognizer> model = createEigenFaceRecognizer(num_components, threshold);
-
-Sometimes it's impossible to train the model, just to experiment with threshold values. Thanks to :ocv:class:`Algorithm` it's possible to set internal model thresholds during runtime. Let's see how we would set/get the prediction for the Eigenface model, we've created above:
-
-.. code-block:: cpp
-
-    // The following line reads the threshold from the Eigenfaces model:
-    double current_threshold = model->getDouble("threshold");
-    // And this line sets the threshold to 0.0:
-    model->set("threshold", 0.0);
-
-If you've set the threshold to ``0.0`` as we did above, then:
-
-.. code-block:: cpp
-
-    //
-    Mat img = imread("person1/3.jpg", CV_LOAD_IMAGE_GRAYSCALE);
-    // Get a prediction from the model. Note: We've set a threshold of 0.0 above,
-    // since the distance is almost always larger than 0.0, you'll get -1 as
-    // label, which indicates, this face is unknown
-    int predicted_label = model->predict(img);
-    // ...
-
-is going to yield ``-1`` as predicted label, which states this face is unknown.
-
-Getting the name of a FaceRecognizer
-+++++++++++++++++++++++++++++++++++++
-
-Since every :ocv:class:`FaceRecognizer` is a :ocv:class:`Algorithm`, you can use :ocv:func:`Algorithm::name` to get the name of a :ocv:class:`FaceRecognizer`:
-
-.. code-block:: cpp
-
-    // Create a FaceRecognizer:
-    Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
-    // And here's how to get its name:
-    String name = model->name();
-
-
-FaceRecognizer::train
----------------------
-
-Trains a FaceRecognizer with given data and associated labels.
-
-.. ocv:function:: void FaceRecognizer::train( InputArrayOfArrays src, InputArray labels ) = 0
-
-    :param src: The training images, that means the faces you want to learn. The data has to be given as a ``vector<Mat>``.
-
-    :param labels: The labels corresponding to the images have to be given either as a ``vector<int>`` or a
-
-The following source code snippet shows you how to learn a Fisherfaces model on a given set of images. The images are read with :ocv:func:`imread` and pushed into a ``std::vector<Mat>``. The labels of each image are stored within a ``std::vector<int>`` (you could also use a :ocv:class:`Mat` of type `CV_32SC1`). Think of the label as the subject (the person) this image belongs to, so same subjects (persons) should have the same label. For the available :ocv:class:`FaceRecognizer` you don't have to pay any attention to the order of the labels, just make sure same persons have the same label:
-
-.. code-block:: cpp
-
-    // holds images and labels
-    vector<Mat> images;
-    vector<int> labels;
-    // images for first person
-    images.push_back(imread("person0/0.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
-    images.push_back(imread("person0/1.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
-    images.push_back(imread("person0/2.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
-    // images for second person
-    images.push_back(imread("person1/0.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(1);
-    images.push_back(imread("person1/1.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(1);
-    images.push_back(imread("person1/2.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(1);
-
-Now that you have read some images, we can create a new :ocv:class:`FaceRecognizer`. In this example I'll create a Fisherfaces model and decide to keep all of the possible Fisherfaces:
-
-.. code-block:: cpp
-
-    // Create a new Fisherfaces model and retain all available Fisherfaces,
-    // this is the most common usage of this specific FaceRecognizer:
-    //
-    Ptr<FaceRecognizer> model =  createFisherFaceRecognizer();
-
-And finally train it on the given dataset (the face images and labels):
-
-.. code-block:: cpp
-
-    // This is the common interface to train all of the available cv::FaceRecognizer
-    // implementations:
-    //
-    model->train(images, labels);
-
-FaceRecognizer::update
-----------------------
-
-Updates a FaceRecognizer with given data and associated labels.
-
-.. ocv:function:: void FaceRecognizer::update( InputArrayOfArrays src, InputArray labels )
-
-    :param src: The training images, that means the faces you want to learn. The data has to be given as a ``vector<Mat>``.
-
-    :param labels: The labels corresponding to the images have to be given either as a ``vector<int>`` or a
-
-This method updates a (probably trained) :ocv:class:`FaceRecognizer`, but only if the algorithm supports it. The Local Binary Patterns Histograms (LBPH) recognizer (see :ocv:func:`createLBPHFaceRecognizer`) can be updated. For the Eigenfaces and Fisherfaces method, this is algorithmically not possible and you have to re-estimate the model with :ocv:func:`FaceRecognizer::train`. In any case, a call to train empties the existing model and learns a new model, while update does not delete any model data.
-
-.. code-block:: cpp
-
-    // Create a new LBPH model (it can be updated) and use the default parameters,
-    // this is the most common usage of this specific FaceRecognizer:
-    //
-    Ptr<FaceRecognizer> model =  createLBPHFaceRecognizer();
-    // This is the common interface to train all of the available cv::FaceRecognizer
-    // implementations:
-    //
-    model->train(images, labels);
-    // Some containers to hold new image:
-    vector<Mat> newImages;
-    vector<int> newLabels;
-    // You should add some images to the containers:
-    //
-    // ...
-    //
-    // Now updating the model is as easy as calling:
-    model->update(newImages,newLabels);
-    // This will preserve the old model data and extend the existing model
-    // with the new features extracted from newImages!
-
-Calling update on an Eigenfaces model (see :ocv:func:`createEigenFaceRecognizer`), which doesn't support updating, will throw an error similar to:
-
-.. code-block:: none
-
-    OpenCV Error: The function/feature is not implemented (This FaceRecognizer (FaceRecognizer.Eigenfaces) does not support updating, you have to use FaceRecognizer::train to update it.) in update, file /home/philipp/git/opencv/modules/contrib/src/facerec.cpp, line 305
-    terminate called after throwing an instance of 'cv::Exception'
-
-Please note: The :ocv:class:`FaceRecognizer` does not store your training images, because this would be very memory intense and it's not the responsibility of te :ocv:class:`FaceRecognizer` to do so. The caller is responsible for maintaining the dataset, he want to work with.
-
-FaceRecognizer::predict
------------------------
-
-.. ocv:function:: int FaceRecognizer::predict( InputArray src ) const = 0
-.. ocv:function:: void FaceRecognizer::predict( InputArray src, int & label, double & confidence ) const = 0
-
-    Predicts a label and associated confidence (e.g. distance) for a given input image.
-
-    :param src: Sample image to get a prediction from.
-    :param label: The predicted label for the given image.
-    :param confidence: Associated confidence (e.g. distance) for the predicted label.
-
-The suffix ``const`` means that prediction does not affect the internal model
-state, so the method can be safely called from within different threads.
-
-The following example shows how to get a prediction from a trained model:
-
-.. code-block:: cpp
-
-    using namespace cv;
-    // Do your initialization here (create the cv::FaceRecognizer model) ...
-    // ...
-    // Read in a sample image:
-    Mat img = imread("person1/3.jpg", CV_LOAD_IMAGE_GRAYSCALE);
-    // And get a prediction from the cv::FaceRecognizer:
-    int predicted = model->predict(img);
-
-Or to get a prediction and the associated confidence (e.g. distance):
-
-.. code-block:: cpp
-
-    using namespace cv;
-    // Do your initialization here (create the cv::FaceRecognizer model) ...
-    // ...
-    Mat img = imread("person1/3.jpg", CV_LOAD_IMAGE_GRAYSCALE);
-    // Some variables for the predicted label and associated confidence (e.g. distance):
-    int predicted_label = -1;
-    double predicted_confidence = 0.0;
-    // Get the prediction and associated confidence from the model
-    model->predict(img, predicted_label, predicted_confidence);
-
-FaceRecognizer::save
---------------------
-
-Saves a :ocv:class:`FaceRecognizer` and its model state.
-
-.. ocv:function:: void FaceRecognizer::save(const String& filename) const
-
-    Saves this model to a given filename, either as XML or YAML.
-
-    :param filename: The filename to store this :ocv:class:`FaceRecognizer` to (either XML/YAML).
-
-.. ocv:function:: void FaceRecognizer::save(FileStorage& fs) const
-
-    Saves this model to a given :ocv:class:`FileStorage`.
-
-    :param fs: The :ocv:class:`FileStorage` to store this :ocv:class:`FaceRecognizer` to.
-
-
-Every :ocv:class:`FaceRecognizer` overwrites ``FaceRecognizer::save(FileStorage& fs)``
-to save the internal model state. ``FaceRecognizer::save(const String& filename)`` saves
-the state of a model to the given filename.
-
-The suffix ``const`` means that prediction does not affect the internal model
-state, so the method can be safely called from within different threads.
-
-FaceRecognizer::load
---------------------
-
-Loads a :ocv:class:`FaceRecognizer` and its model state.
-
-.. ocv:function:: void FaceRecognizer::load( const String& filename )
-.. ocv:function:: void FaceRecognizer::load( const FileStorage& fs ) = 0
-
-Loads a persisted model and state from a given XML or YAML file . Every
-:ocv:class:`FaceRecognizer` has to overwrite ``FaceRecognizer::load(FileStorage& fs)``
-to enable loading the model state. ``FaceRecognizer::load(FileStorage& fs)`` in
-turn gets called by ``FaceRecognizer::load(const String& filename)``, to ease
-saving a model.
-
-createEigenFaceRecognizer
--------------------------
-
-.. ocv:function:: Ptr<FaceRecognizer> createEigenFaceRecognizer(int num_components = 0, double threshold = DBL_MAX)
-
-    :param num_components: The number of components (read: Eigenfaces) kept for this Prinicpal Component Analysis. As a hint: There's no rule how many components (read: Eigenfaces) should be kept for good reconstruction capabilities. It is based on your input data, so experiment with the number. Keeping 80 components should almost always be sufficient.
-
-    :param threshold: The threshold applied in the prediciton.
-
-Notes:
-++++++
-
-* Training and prediction must be done on grayscale images, use :ocv:func:`cvtColor` to convert between the color spaces.
-* **THE EIGENFACES METHOD MAKES THE ASSUMPTION, THAT THE TRAINING AND TEST IMAGES ARE OF EQUAL SIZE.** (caps-lock, because I got so many mails asking for this). You have to make sure your input data has the correct shape, else a meaningful exception is thrown. Use :ocv:func:`resize` to resize the images.
-* This model does not support updating.
-
-Model internal data:
-++++++++++++++++++++
-
-* ``num_components`` see :ocv:func:`createEigenFaceRecognizer`.
-* ``threshold`` see :ocv:func:`createEigenFaceRecognizer`.
-* ``eigenvalues`` The eigenvalues for this Principal Component Analysis (ordered descending).
-* ``eigenvectors`` The eigenvectors for this Principal Component Analysis (ordered by their eigenvalue).
-* ``mean`` The sample mean calculated from the training data.
-* ``projections`` The projections of the training data.
-* ``labels`` The threshold applied in the prediction. If the distance to the nearest neighbor is larger than the threshold, this method returns -1.
-
-createFisherFaceRecognizer
---------------------------
-
-.. ocv:function:: Ptr<FaceRecognizer> createFisherFaceRecognizer(int num_components = 0, double threshold = DBL_MAX)
-
-    :param num_components: The number of components (read: Fisherfaces) kept for this Linear Discriminant Analysis with the Fisherfaces criterion. It's useful to keep all components, that means the number of your classes ``c`` (read: subjects, persons you want to recognize). If you leave this at the default (``0``) or set it to a value  less-equal ``0`` or greater ``(c-1)``, it will be set to the correct number ``(c-1)`` automatically.
-
-    :param threshold: The threshold applied in the prediction. If the distance to the nearest neighbor is larger than the threshold, this method returns -1.
-
-Notes:
-++++++
-
-* Training and prediction must be done on grayscale images, use :ocv:func:`cvtColor` to convert between the color spaces.
-* **THE FISHERFACES METHOD MAKES THE ASSUMPTION, THAT THE TRAINING AND TEST IMAGES ARE OF EQUAL SIZE.** (caps-lock, because I got so many mails asking for this). You have to make sure your input data has the correct shape, else a meaningful exception is thrown. Use :ocv:func:`resize` to resize the images.
-* This model does not support updating.
-
-Model internal data:
-++++++++++++++++++++
-
-* ``num_components`` see :ocv:func:`createFisherFaceRecognizer`.
-* ``threshold`` see :ocv:func:`createFisherFaceRecognizer`.
-* ``eigenvalues`` The eigenvalues for this Linear Discriminant Analysis (ordered descending).
-* ``eigenvectors`` The eigenvectors for this Linear Discriminant Analysis (ordered by their eigenvalue).
-* ``mean`` The sample mean calculated from the training data.
-* ``projections`` The projections of the training data.
-* ``labels`` The labels corresponding to the projections.
-
-
-createLBPHFaceRecognizer
--------------------------
-
-.. ocv:function:: Ptr<FaceRecognizer> createLBPHFaceRecognizer(int radius=1, int neighbors=8, int grid_x=8, int grid_y=8, double threshold = DBL_MAX)
-
-    :param radius: The radius used for building the Circular Local Binary Pattern. The greater the radius, the
-    :param neighbors: The number of sample points to build a Circular Local Binary Pattern from. An appropriate value is to use `` 8`` sample points. Keep in mind: the more sample points you include, the higher the computational cost.
-    :param grid_x: The number of cells in the horizontal direction, ``8`` is a common value used in publications. The more cells, the finer the grid, the higher the dimensionality of the resulting feature vector.
-    :param grid_y: The number of cells in the vertical direction, ``8`` is a common value used in publications. The more cells, the finer the grid, the higher the dimensionality of the resulting feature vector.
-    :param threshold: The threshold applied in the prediction. If the distance to the nearest neighbor is larger than the threshold, this method returns -1.
-
-Notes:
-++++++
-
-* The Circular Local Binary Patterns (used in training and prediction) expect the data given as grayscale images, use :ocv:func:`cvtColor` to convert between the color spaces.
-* This model supports updating.
-
-Model internal data:
-++++++++++++++++++++
-
-* ``radius`` see :ocv:func:`createLBPHFaceRecognizer`.
-* ``neighbors`` see :ocv:func:`createLBPHFaceRecognizer`.
-* ``grid_x`` see :ocv:func:`createLBPHFaceRecognizer`.
-* ``grid_y`` see :ocv:func:`createLBPHFaceRecognizer`.
-* ``threshold`` see :ocv:func:`createLBPHFaceRecognizer`.
-* ``histograms`` Local Binary Patterns Histograms calculated from the given training data (empty if none was given).
-* ``labels`` Labels corresponding to the calculated Local Binary Patterns Histograms.
diff --git a/modules/contrib/doc/facerec/facerec_changelog.rst b/modules/contrib/doc/facerec/facerec_changelog.rst
deleted file mode 100644 (file)
index 1071358..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-Changelog
-=========
-
-Release 0.05
-------------
-
-This library is now included in the official OpenCV distribution (from 2.4 on).
-The :ocv:class`FaceRecognizer` is now an :ocv:class:`Algorithm`, which better fits into the overall
-OpenCV API.
-
-To reduce the confusion on user side and minimize my work, libfacerec and OpenCV
-have been synchronized and are now based on the same interfaces and implementation.
-
-The library now has an extensive documentation:
-
-* The API is explained in detail and with a lot of code examples.
-* The face recognition guide I had written for Python and GNU Octave/MATLAB has been adapted to the new OpenCV C++ ``cv::FaceRecognizer``.
-* A tutorial for gender classification with Fisherfaces.
-* A tutorial for face recognition in videos (e.g. webcam).
-
-
-Release highlights
-++++++++++++++++++
-
-* There are no single highlights to pick from, this release is a highlight itself.
-
-Release 0.04
-------------
-
-This version is fully Windows-compatible and works with OpenCV 2.3.1. Several
-bugfixes, but none influenced the recognition rate.
-
-Release highlights
-++++++++++++++++++
-
-* A whole lot of exceptions with meaningful error messages.
-* A tutorial for Windows users: `http://bytefish.de/blog/opencv_visual_studio_and_libfacerec <http://bytefish.de/blog/opencv_visual_studio_and_libfacerec>`_
-
-
-Release 0.03
-------------
-
-Reworked the library to provide separate implementations in cpp files, because
-it's the preferred way of contributing OpenCV libraries. This means the library
-is not header-only anymore. Slight API changes were done, please see the
-documentation for details.
-
-Release highlights
-++++++++++++++++++
-
-* New Unit Tests (for LBP Histograms) make the library more robust.
-* Added more documentation.
-
-
-Release 0.02
-------------
-
-Reworked the library to provide separate implementations in cpp files, because
-it's the preferred way of contributing OpenCV libraries. This means the library
-is not header-only anymore. Slight API changes were done, please see the
-documentation for details.
-
-Release highlights
-++++++++++++++++++
-
-* New Unit Tests (for LBP Histograms) make the library more robust.
-* Added a documentation and changelog in reStructuredText.
-
-Release 0.01
-------------
-
-Initial release as header-only library.
-
-Release highlights
-++++++++++++++++++
-
-* Colormaps for OpenCV to enhance the visualization.
-* Face Recognition algorithms implemented:
-
-  * Eigenfaces [TP91]_
-  * Fisherfaces [BHK97]_
-  * Local Binary Patterns Histograms [AHP04]_
-
-* Added persistence facilities to store the models with a common API.
-* Unit Tests (using `gtest <http://code.google.com/p/googletest/>`_).
-* Providing a CMakeLists.txt to enable easy cross-platform building.
diff --git a/modules/contrib/doc/facerec/facerec_tutorial.rst b/modules/contrib/doc/facerec/facerec_tutorial.rst
deleted file mode 100644 (file)
index cbfb417..0000000
+++ /dev/null
@@ -1,628 +0,0 @@
-Face Recognition with OpenCV
-############################
-
-.. contents:: Table of Contents
-   :depth: 3
-
-Introduction
-============
-
-`OpenCV (Open Source Computer Vision) <http://opencv.org>`_ is a popular computer vision library started by `Intel <http://www.intel.com>`_ in 1999. The cross-platform library sets its focus on real-time image processing and includes patent-free implementations of the latest computer vision algorithms. In 2008 `Willow Garage <http://www.willowgarage.com>`_ took over support and OpenCV 2.3.1 now comes with a programming interface to C, C++, `Python <http://www.python.org>`_ and `Android <http://www.android.com>`_. OpenCV is released under a BSD license so it is used in academic projects and commercial products alike.
-
-OpenCV 2.4 now comes with the very new :ocv:class:`FaceRecognizer` class for face recognition, so you can start experimenting with face recognition right away. This document is the guide I've wished for, when I was working myself into face recognition. It shows you how to perform face recognition with :ocv:class:`FaceRecognizer` in OpenCV (with full source code listings) and gives you an introduction into the algorithms behind. I'll also show how to create the visualizations you can find in many publications, because a lot of people asked for.
-
-The currently available algorithms are:
-
-* Eigenfaces (see :ocv:func:`createEigenFaceRecognizer`)
-* Fisherfaces (see :ocv:func:`createFisherFaceRecognizer`)
-* Local Binary Patterns Histograms (see :ocv:func:`createLBPHFaceRecognizer`)
-
-You don't need to copy and paste the source code examples from this page, because they are available in the ``src`` folder coming with this documentation. If you have built OpenCV with the samples turned on, chances are good you have them compiled already! Although it might be interesting for very advanced users, I've decided to leave the implementation details out as I am afraid they confuse new users.
-
-All code in this document is released under the `BSD license <http://www.opensource.org/licenses/bsd-license>`_, so feel free to use it for your projects.
-
-Face Recognition
-================
-
-Face recognition is an easy task for humans. Experiments in [Tu06]_ have shown, that even one to three day old babies are able to distinguish between known faces. So how hard could it be for a computer? It turns out we know little about human recognition to date. Are inner features (eyes, nose, mouth) or outer features (head shape, hairline) used for a successful face recognition? How do we analyze an image and how does the brain encode it? It was shown by `David Hubel <http://en.wikipedia.org/wiki/David_H._Hubel>`_ and `Torsten Wiesel <http://en.wikipedia.org/wiki/Torsten_Wiesel>`_, that our brain has specialized nerve cells responding to specific local features of a scene, such as lines, edges, angles or movement. Since we don't see the world as scattered pieces, our visual cortex must somehow combine the different sources of information into useful patterns. Automatic face recognition is all about extracting those meaningful features from an image, putting them into a useful representation and performing some kind of classification on them.
-
-Face recognition based on the geometric features of a face is probably the most intuitive approach to face recognition. One of the first automated face recognition systems was described in [Kanade73]_: marker points (position of eyes, ears, nose, ...) were used to build a feature vector (distance between the points, angle between them, ...). The recognition was performed by calculating the euclidean distance between feature vectors of a probe and reference image. Such a method is robust against changes in illumination by its nature, but has a huge drawback: the accurate registration of the marker points is complicated, even with state of the art algorithms. Some of the latest work on geometric face recognition was carried out in [Bru92]_. A 22-dimensional feature vector was used and experiments on large datasets have shown, that geometrical features alone my not carry enough information for face recognition.
-
-The Eigenfaces method described in [TP91]_ took a holistic approach to face recognition: A facial image is a point from a high-dimensional image space and a lower-dimensional representation is found, where classification becomes easy. The lower-dimensional subspace is found with Principal Component Analysis, which identifies the axes with maximum variance. While this kind of transformation is optimal from a reconstruction standpoint, it doesn't take any class labels into account. Imagine a situation where the variance is generated from external sources, let it be light. The axes with maximum variance do not necessarily contain any discriminative information at all, hence a classification becomes impossible. So a class-specific projection with a Linear Discriminant Analysis was applied to face recognition in [BHK97]_. The basic idea is to minimize the variance within a class, while maximizing the variance between the classes at the same time.
-
-Recently various methods for a local feature extraction emerged. To avoid the high-dimensionality of the input data only local regions of an image are described, the extracted features are (hopefully) more robust against partial occlusion, illumation and small sample size. Algorithms used for a local feature extraction are Gabor Wavelets ([Wiskott97]_), Discrete Cosinus Transform ([Messer06]_) and Local Binary Patterns ([AHP04]_). It's still an open research question what's the best way to preserve spatial information when applying a local feature extraction, because spatial information is potentially useful information.
-
-Face Database
-==============
-
-Let's get some data to experiment with first. I don't want to do a toy example here. We are doing face recognition, so you'll need some face images! You can either create your own dataset or start with one of the available face databases, `http://face-rec.org/databases/ <http://face-rec.org/databases>`_ gives you an up-to-date overview. Three interesting databases are (parts of the description are quoted from `http://face-rec.org <http://face-rec.org>`_):
-
-* `AT&T Facedatabase <http://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html>`_ The AT&T Facedatabase, sometimes also referred to as *ORL Database of Faces*, contains ten different images of each of 40 distinct subjects. For some subjects, the images were taken at different times, varying the lighting, facial expressions (open / closed eyes, smiling / not smiling) and facial details (glasses / no glasses). All the images were taken against a dark homogeneous background with the subjects in an upright, frontal position (with tolerance for some side movement).
-
-* `Yale Facedatabase A <http://vision.ucsd.edu/content/yale-face-database>`_, also known as Yalefaces. The AT&T Facedatabase is good for initial tests, but it's a fairly easy database. The Eigenfaces method already has a 97% recognition rate on it, so you won't see any great improvements with other algorithms. The Yale Facedatabase A (also known as Yalefaces) is a more appropriate dataset for initial experiments, because the recognition problem is harder. The database consists of 15 people (14 male, 1 female) each with 11 grayscale images sized :math:`320 \times 243` pixel. There are changes in the light conditions (center light, left light, right light), facial expressions (happy, normal, sad, sleepy, surprised, wink) and glasses (glasses, no-glasses).
-
-  The original images are not cropped and aligned. Please look into the :ref:`appendixft` for a Python script, that does the job for you.
-
-* `Extended Yale Facedatabase B <http://vision.ucsd.edu/~leekc/ExtYaleDatabase/ExtYaleB.html>`_ The Extended Yale Facedatabase B contains 2414 images of 38 different people in its cropped version. The focus of this database is set on extracting features that are robust to illumination, the images have almost no variation in emotion/occlusion/... . I personally think, that this dataset is too large for the experiments I perform in this document. You better use the `AT&T Facedatabase <http://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html>`_ for intial testing. A first version of the Yale Facedatabase B was used in [BHK97]_ to see how the Eigenfaces and Fisherfaces method perform under heavy illumination changes. [Lee05]_ used the same setup to take 16128 images of 28 people. The Extended Yale Facedatabase B is the merge of the two databases, which is now known as Extended Yalefacedatabase B.
-
-Preparing the data
--------------------
-
-Once we have acquired some data, we'll need to read it in our program. In the demo applications I have decided to read the images from a very simple CSV file. Why? Because it's the simplest platform-independent approach I can think of. However, if you know a simpler solution please ping me about it. Basically all the CSV file needs to contain are lines composed of a ``filename`` followed by a ``;`` followed by the ``label`` (as *integer number*), making up a line like this:
-
-.. code-block:: none
-
-    /path/to/image.ext;0
-
-Let's dissect the line. ``/path/to/image.ext`` is the path to an image, probably something like this if you are in Windows: ``C:/faces/person0/image0.jpg``. Then there is the separator ``;`` and finally we assign the label ``0`` to the image. Think of the label as the subject (the person) this image belongs to, so same subjects (persons) should have the same label.
-
-Download the AT&T Facedatabase from AT&T Facedatabase and the corresponding CSV file from at.txt, which looks like this (file is without ... of course):
-
-.. code-block:: none
-
-    ./at/s1/1.pgm;0
-    ./at/s1/2.pgm;0
-    ...
-    ./at/s2/1.pgm;1
-    ./at/s2/2.pgm;1
-    ...
-    ./at/s40/1.pgm;39
-    ./at/s40/2.pgm;39
-
-Imagine I have extracted the files to ``D:/data/at`` and have downloaded the CSV file to ``D:/data/at.txt``. Then you would simply need to Search & Replace ``./`` with ``D:/data/``. You can do that in an editor of your choice, every sufficiently advanced editor can do this. Once you have a CSV file with valid filenames and labels, you can run any of the demos by passing the path to the CSV file as parameter:
-
-.. code-block:: none
-
-    facerec_demo.exe D:/data/at.txt
-
-Creating the CSV File
-+++++++++++++++++++++
-
-You don't really want to create the CSV file by hand. I have prepared you a little Python script ``create_csv.py`` (you find it at ``src/create_csv.py`` coming with this tutorial) that automatically creates you a CSV file. If you have your images in hierarchie like this (``/basepath/<subject>/<image.ext>``):
-
-.. code-block:: none
-
-    philipp@mango:~/facerec/data/at$ tree
-    .
-    |-- s1
-    |   |-- 1.pgm
-    |   |-- ...
-    |   |-- 10.pgm
-    |-- s2
-    |   |-- 1.pgm
-    |   |-- ...
-    |   |-- 10.pgm
-    ...
-    |-- s40
-    |   |-- 1.pgm
-    |   |-- ...
-    |   |-- 10.pgm
-
-
-Then simply call create_csv.py with the path to the folder, just like this and you could save the output:
-
-.. code-block:: none
-
-    philipp@mango:~/facerec/data$ python create_csv.py
-    at/s13/2.pgm;0
-    at/s13/7.pgm;0
-    at/s13/6.pgm;0
-    at/s13/9.pgm;0
-    at/s13/5.pgm;0
-    at/s13/3.pgm;0
-    at/s13/4.pgm;0
-    at/s13/10.pgm;0
-    at/s13/8.pgm;0
-    at/s13/1.pgm;0
-    at/s17/2.pgm;1
-    at/s17/7.pgm;1
-    at/s17/6.pgm;1
-    at/s17/9.pgm;1
-    at/s17/5.pgm;1
-    at/s17/3.pgm;1
-    [...]
-
-Please see the :ref:`appendixft` for additional informations.
-
-Eigenfaces
-==========
-
-The problem with the image representation we are given is its high dimensionality. Two-dimensional :math:`p \times q` grayscale images span a :math:`m = pq`-dimensional vector space, so an image with :math:`100 \times 100` pixels lies in a :math:`10,000`-dimensional image space already. The question is: Are all dimensions equally useful for us? We can only make a decision if there's any variance in data, so what we are looking for are the components that account for most of the information. The Principal Component Analysis (PCA) was independently proposed by `Karl Pearson <http://en.wikipedia.org/wiki/Karl_Pearson>`_ (1901) and `Harold Hotelling <http://en.wikipedia.org/wiki/Harold_Hotelling>`_ (1933) to turn a set of possibly correlated variables into a smaller set of uncorrelated variables. The idea is, that a high-dimensional dataset is often described by correlated variables and therefore only a few meaningful dimensions account for most of the information. The PCA method finds the directions with the greatest variance in the data, called principal components.
-
-Algorithmic Description
------------------------
-
-Let :math:`X = \{ x_{1}, x_{2}, \ldots, x_{n} \}` be a random vector with observations :math:`x_i \in R^{d}`.
-
-1. Compute the mean :math:`\mu`
-
-  .. math::
-
-    \mu = \frac{1}{n} \sum_{i=1}^{n} x_{i}
-
-2. Compute the the Covariance Matrix `S`
-
-  .. math::
-
-    S = \frac{1}{n} \sum_{i=1}^{n} (x_{i} - \mu) (x_{i} - \mu)^{T}`
-
-3. Compute the eigenvalues :math:`\lambda_{i}` and eigenvectors :math:`v_{i}` of :math:`S`
-
-  .. math::
-
-    S v_{i} = \lambda_{i} v_{i}, i=1,2,\ldots,n
-
-4. Order the eigenvectors descending by their eigenvalue. The :math:`k` principal components are the eigenvectors corresponding to the :math:`k` largest eigenvalues.
-
-The :math:`k` principal components of the observed vector :math:`x` are then given by:
-
-.. math::
-
-    y = W^{T} (x - \mu)
-
-
-where :math:`W = (v_{1}, v_{2}, \ldots, v_{k})`.
-
-The reconstruction from the PCA basis is given by:
-
-.. math::
-
-    x = W y + \mu
-
-where :math:`W = (v_{1}, v_{2}, \ldots, v_{k})`.
-
-
-The Eigenfaces method then performs face recognition by:
-
-* Projecting all training samples into the PCA subspace.
-* Projecting the query image into the PCA subspace.
-* Finding the nearest neighbor between the projected training images and the projected query image.
-
-Still there's one problem left to solve. Imagine we are given :math:`400` images sized :math:`100 \times 100` pixel. The Principal Component Analysis solves the covariance matrix :math:`S = X X^{T}`, where :math:`{size}(X) = 10000 \times 400` in our example. You would end up with a :math:`10000 \times 10000` matrix, roughly :math:`0.8 GB`. Solving this problem isn't feasible, so we'll need to apply a trick. From your linear algebra lessons you know that a :math:`M \times N` matrix with :math:`M > N` can only have :math:`N - 1` non-zero eigenvalues. So it's possible to take the eigenvalue decomposition :math:`S = X^{T} X` of size :math:`N \times N` instead:
-
-.. math::
-
-    X^{T} X v_{i} = \lambda_{i} v{i}
-
-
-and get the original eigenvectors of :math:`S = X X^{T}` with a left multiplication of the data matrix:
-
-.. math::
-
-    X X^{T} (X v_{i}) = \lambda_{i} (X v_{i})
-
-The resulting eigenvectors are orthogonal, to get orthonormal eigenvectors they need to be normalized to unit length. I don't want to turn this into a publication, so please look into [Duda01]_ for the derivation and proof of the equations.
-
-Eigenfaces in OpenCV
---------------------
-
-For the first source code example, I'll go through it with you. I am first giving you the whole source code listing, and after this we'll look at the most important lines in detail. Please note: every source code listing is commented in detail, so you should have no problems following it.
-
-.. literalinclude:: src/facerec_eigenfaces.cpp
-   :language: cpp
-   :linenos:
-
-The source code for this demo application is also available in the ``src`` folder coming with this documentation:
-
-* :download:`src/facerec_eigenfaces.cpp <src/facerec_eigenfaces.cpp>`
-
-
-I've used the jet colormap, so you can see how the grayscale values are distributed within the specific Eigenfaces. You can see, that the Eigenfaces do not only encode facial features, but also the illumination in the images (see the left light in Eigenface \#4, right light in Eigenfaces \#5):
-
-.. image:: img/eigenfaces_opencv.png
-    :align: center
-
-We've already seen, that we can reconstruct a face from its lower dimensional approximation. So let's see how many Eigenfaces are needed for a good reconstruction. I'll do a subplot with :math:`10,30,\ldots,310` Eigenfaces:
-
-.. code-block:: cpp
-
-    // Display or save the image reconstruction at some predefined steps:
-    for(int num_components = 10; num_components < 300; num_components+=15) {
-        // slice the eigenvectors from the model
-        Mat evs = Mat(W, Range::all(), Range(0, num_components));
-        Mat projection = subspaceProject(evs, mean, images[0].reshape(1,1));
-        Mat reconstruction = subspaceReconstruct(evs, mean, projection);
-        // Normalize the result:
-        reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
-        // Display or save:
-        if(argc == 2) {
-            imshow(format("eigenface_reconstruction_%d", num_components), reconstruction);
-        } else {
-            imwrite(format("%s/eigenface_reconstruction_%d.png", output_folder.c_str(), num_components), reconstruction);
-        }
-    }
-
-10 Eigenvectors are obviously not sufficient for a good image reconstruction, 50 Eigenvectors may already be sufficient to encode important facial features. You'll get a good reconstruction with approximately 300 Eigenvectors for the AT&T Facedatabase. There are rule of thumbs how many Eigenfaces you should choose for a successful face recognition, but it heavily depends on the input data. [Zhao03]_ is the perfect point to start researching for this:
-
-.. image:: img/eigenface_reconstruction_opencv.png
-    :align: center
-
-
-Fisherfaces
-============
-
-The Principal Component Analysis (PCA), which is the core of the Eigenfaces method, finds a linear combination of features that maximizes the total variance in data. While this is clearly a powerful way to represent data, it doesn't consider any classes and so a lot of discriminative information *may* be lost when throwing components away. Imagine a situation where the variance in your data is generated by an external source, let it be the light. The components identified by a PCA do not necessarily contain any discriminative information at all, so the projected samples are smeared together and a classification becomes impossible (see `http://www.bytefish.de/wiki/pca_lda_with_gnu_octave <http://www.bytefish.de/wiki/pca_lda_with_gnu_octave>`_ for an example).
-
-The Linear Discriminant Analysis performs a class-specific dimensionality reduction and was invented by the great statistician `Sir R. A. Fisher <http://en.wikipedia.org/wiki/Ronald_Fisher>`_. He successfully used it for classifying flowers in his 1936 paper *The use of multiple measurements in taxonomic problems* [Fisher36]_. In order to find the combination of features that separates best between classes the Linear Discriminant Analysis maximizes the ratio of between-classes to within-classes scatter, instead of maximizing the overall scatter. The idea is simple: same classes should cluster tightly together, while different classes are as far away as possible from each other in the lower-dimensional representation. This was also recognized by `Belhumeur <http://www.cs.columbia.edu/~belhumeur/>`_, `Hespanha <http://www.ece.ucsb.edu/~hespanha/>`_ and `Kriegman <http://cseweb.ucsd.edu/~kriegman/>`_ and so they applied a Discriminant Analysis to face recognition in [BHK97]_.
-
-Algorithmic Description
------------------------
-
-Let :math:`X` be a random vector with samples drawn from :math:`c` classes:
-
-
-.. math::
-    :nowrap:
-
-    \begin{align*}
-        X & = & \{X_1,X_2,\ldots,X_c\} \\
-        X_i & = & \{x_1, x_2, \ldots, x_n\}
-    \end{align*}
-
-
-The scatter matrices :math:`S_{B}` and `S_{W}` are calculated as:
-
-.. math::
-    :nowrap:
-
-    \begin{align*}
-        S_{B} & = & \sum_{i=1}^{c} N_{i} (\mu_i - \mu)(\mu_i - \mu)^{T} \\
-        S_{W} & = & \sum_{i=1}^{c} \sum_{x_{j} \in X_{i}} (x_j - \mu_i)(x_j - \mu_i)^{T}
-    \end{align*}
-
-, where :math:`\mu` is the total mean:
-
-.. math::
-
-        \mu = \frac{1}{N} \sum_{i=1}^{N} x_i
-
-And :math:`\mu_i` is the mean of class :math:`i \in \{1,\ldots,c\}`:
-
-.. math::
-
-        \mu_i = \frac{1}{|X_i|} \sum_{x_j \in X_i} x_j
-
-Fisher's classic algorithm now looks for a projection :math:`W`, that maximizes the class separability criterion:
-
-.. math::
-
-        W_{opt} = \operatorname{arg\,max}_{W} \frac{|W^T S_B W|}{|W^T S_W W|}
-
-
-Following [BHK97]_, a solution for this optimization problem is given by solving the General Eigenvalue Problem:
-
-.. math::
-    :nowrap:
-
-    \begin{align*}
-        S_{B} v_{i} & = & \lambda_{i} S_w v_{i} \nonumber \\
-        S_{W}^{-1} S_{B} v_{i} & = & \lambda_{i} v_{i}
-    \end{align*}
-
-There's one problem left to solve: The rank of :math:`S_{W}` is at most :math:`(N-c)`, with :math:`N` samples and :math:`c` classes. In pattern recognition problems the number of samples :math:`N` is almost always samller than the dimension of the input data (the number of pixels), so the scatter matrix :math:`S_{W}` becomes singular (see [RJ91]_). In [BHK97]_ this was solved by performing a Principal Component Analysis on the data and projecting the samples into the :math:`(N-c)`-dimensional space. A Linear Discriminant Analysis was then performed on the reduced data, because :math:`S_{W}` isn't singular anymore.
-
-The optimization problem can then be rewritten as:
-
-.. math::
-    :nowrap:
-
-    \begin{align*}
-        W_{pca} & = & \operatorname{arg\,max}_{W} |W^T S_T W| \\
-        W_{fld} & = & \operatorname{arg\,max}_{W} \frac{|W^T W_{pca}^T S_{B} W_{pca} W|}{|W^T W_{pca}^T S_{W} W_{pca} W|}
-    \end{align*}
-
-The transformation matrix :math:`W`, that projects a sample into the :math:`(c-1)`-dimensional space is then given by:
-
-.. math::
-
-        W = W_{fld}^{T} W_{pca}^{T}
-
-Fisherfaces in OpenCV
----------------------
-
-.. literalinclude:: src/facerec_fisherfaces.cpp
-   :language: cpp
-   :linenos:
-
-The source code for this demo application is also available in the ``src`` folder coming with this documentation:
-
-* :download:`src/facerec_fisherfaces.cpp <src/facerec_fisherfaces.cpp>`
-
-
-For this example I am going to use the Yale Facedatabase A, just because the plots are nicer. Each Fisherface has the same length as an original image, thus it can be displayed as an image. The demo shows (or saves) the first, at most 16 Fisherfaces:
-
-.. image:: img/fisherfaces_opencv.png
-    :align: center
-
-The Fisherfaces method learns a class-specific transformation matrix, so the they do not capture illumination as obviously as the Eigenfaces method. The Discriminant Analysis instead finds the facial features to discriminate between the persons. It's important to mention, that the performance of the Fisherfaces heavily depends on the input data as well. Practically said: if you learn the Fisherfaces for well-illuminated pictures only and you try to recognize faces in bad-illuminated scenes, then method is likely to find the wrong components (just because those features may not be predominant on bad illuminated images). This is somewhat logical, since the method had no chance to learn the illumination.
-
-The Fisherfaces allow a reconstruction of the projected image, just like the Eigenfaces did. But since we only identified the features to distinguish between subjects, you can't expect a nice reconstruction of the original image. For the Fisherfaces method we'll project the sample image onto each of the Fisherfaces instead. So you'll have a nice visualization, which feature each of the Fisherfaces describes:
-
-.. code-block:: cpp
-
-    // Display or save the image reconstruction at some predefined steps:
-    for(int num_component = 0; num_component < min(16, W.cols); num_component++) {
-        // Slice the Fisherface from the model:
-        Mat ev = W.col(num_component);
-        Mat projection = subspaceProject(ev, mean, images[0].reshape(1,1));
-        Mat reconstruction = subspaceReconstruct(ev, mean, projection);
-        // Normalize the result:
-        reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
-        // Display or save:
-        if(argc == 2) {
-            imshow(format("fisherface_reconstruction_%d", num_component), reconstruction);
-        } else {
-            imwrite(format("%s/fisherface_reconstruction_%d.png", output_folder.c_str(), num_component), reconstruction);
-        }
-    }
-
-The differences may be subtle for the human eyes, but you should be able to see some differences:
-
-.. image:: img/fisherface_reconstruction_opencv.png
-    :align: center
-
-
-Local Binary Patterns Histograms
-================================
-
-Eigenfaces and Fisherfaces take a somewhat holistic approach to face recognition. You treat your data as a vector somewhere in a high-dimensional image space. We all know high-dimensionality is bad, so a lower-dimensional subspace is identified, where (probably) useful information is preserved. The Eigenfaces approach maximizes the total scatter, which can lead to problems if the variance is generated by an external source, because components with a maximum variance over all classes aren't necessarily useful for classification (see `http://www.bytefish.de/wiki/pca_lda_with_gnu_octave <http://www.bytefish.de/wiki/pca_lda_with_gnu_octave>`_). So to preserve some discriminative information we applied a Linear Discriminant Analysis and optimized as described in the Fisherfaces method. The Fisherfaces method worked great... at least for the constrained scenario we've assumed in our model.
-
-Now real life isn't perfect. You simply can't guarantee perfect light settings in your images or 10 different images of a person. So what if there's only one image for each person? Our covariance estimates for the subspace *may* be horribly wrong, so will the recognition. Remember the Eigenfaces method had a 96% recognition rate on the AT&T Facedatabase? How many images do we actually need to get such useful estimates? Here are the Rank-1 recognition rates of the Eigenfaces and Fisherfaces method on the AT&T Facedatabase, which is a fairly easy image database:
-
-.. image:: img/at_database_small_sample_size.png
-    :scale: 60%
-    :align: center
-
-So in order to get good recognition rates you'll need at least 8(+-1) images for each person and the Fisherfaces method doesn't really help here. The above experiment is a 10-fold cross validated result carried out with the facerec framework at: `https://github.com/bytefish/facerec <https://github.com/bytefish/facerec>`_. This is not a publication, so I won't back these figures with a deep mathematical analysis. Please have a look into [KM01]_ for a detailed analysis of both methods, when it comes to small training datasets.
-
-So some research concentrated on extracting local features from images. The idea is to not look at the whole image as a high-dimensional vector, but describe only local features of an object. The features you extract this way will have a low-dimensionality implicitly. A fine idea! But you'll soon observe the image representation we are given doesn't only suffer from illumination variations. Think of things like scale, translation or rotation in images - your local description has to be at least a bit robust against those things. Just like :ocv:class:`SIFT`, the Local Binary Patterns methodology has its roots in 2D texture analysis. The basic idea of Local Binary Patterns is to summarize the local structure in an image by comparing each pixel with its neighborhood. Take a pixel as center and threshold its neighbors against. If the intensity of the center pixel is greater-equal its neighbor, then denote it with 1 and 0 if not. You'll end up with a binary number for each pixel, just like 11001111. So with 8 surrounding pixels you'll end up with 2^8 possible combinations, called *Local Binary Patterns* or sometimes referred to as *LBP codes*. The first LBP operator described in literature actually used a fixed 3 x 3 neighborhood just like this:
-
-.. image:: img/lbp/lbp.png
-    :scale: 80%
-    :align: center
-
-Algorithmic Description
------------------------
-
-A more formal description of the LBP operator can be given as:
-
-.. math::
-
-    LBP(x_c, y_c) = \sum_{p=0}^{P-1} 2^p s(i_p - i_c)
-
-, with :math:`(x_c, y_c)` as central pixel with intensity :math:`i_c`; and :math:`i_n` being the intensity of the the neighbor pixel. :math:`s` is the sign function defined as:
-
-.. math::
-    :nowrap:
-
-    \begin{equation}
-    s(x) =
-    \begin{cases}
-    1 & \text{if $x \geq 0$}\\
-    0 & \text{else}
-    \end{cases}
-    \end{equation}
-
-This description enables you to capture very fine grained details in images. In fact the authors were able to compete with state of the art results for texture classification. Soon after the operator was published it was noted, that a fixed neighborhood fails to encode details differing in scale. So the operator was extended to use a variable neighborhood in [AHP04]_. The idea is to align an abritrary number of neighbors on a circle with a variable radius, which enables to capture the following neighborhoods:
-
-.. image:: img/lbp/patterns.png
-    :scale: 80%
-    :align: center
-
-For a given Point :math:`(x_c,y_c)` the position of the neighbor :math:`(x_p,y_p), p \in P` can be calculated by:
-
-.. math::
-    :nowrap:
-
-    \begin{align*}
-    x_{p} & = & x_c + R \cos({\frac{2\pi p}{P}})\\
-    y_{p} & = & y_c - R \sin({\frac{2\pi p}{P}})
-    \end{align*}
-
-Where :math:`R` is the radius of the circle and :math:`P` is the number of sample points.
-
-The operator is an extension to the original LBP codes, so it's sometimes called *Extended LBP* (also referred to as *Circular LBP*) . If a points coordinate on the circle doesn't correspond to image coordinates, the point get's interpolated. Computer science has a bunch of clever interpolation schemes, the OpenCV implementation does a bilinear interpolation:
-
-.. math::
-    :nowrap:
-
-    \begin{align*}
-    f(x,y) \approx \begin{bmatrix}
-        1-x & x \end{bmatrix} \begin{bmatrix}
-        f(0,0) & f(0,1) \\
-        f(1,0) & f(1,1) \end{bmatrix} \begin{bmatrix}
-        1-y \\
-        y \end{bmatrix}.
-    \end{align*}
-
-By definition the LBP operator is robust against monotonic gray scale transformations. We can easily verify this by looking at the LBP image of an artificially modified image (so you see what an LBP image looks like!):
-
-.. image:: img/lbp/lbp_yale.jpg
-    :scale: 60%
-    :align: center
-
-So what's left to do is how to incorporate the spatial information in the face recognition model. The representation proposed by Ahonen et. al [AHP04]_ is to divide the LBP image into :math:`m` local regions and extract a histogram from each. The spatially enhanced feature vector is then obtained by concatenating the local histograms (**not merging them**). These histograms are called *Local Binary Patterns Histograms*.
-
-Local Binary Patterns Histograms in OpenCV
-------------------------------------------
-
-.. literalinclude:: src/facerec_lbph.cpp
-   :language: cpp
-   :linenos:
-
-The source code for this demo application is also available in the ``src`` folder coming with this documentation:
-
-* :download:`src/facerec_lbph.cpp <src/facerec_lbph.cpp>`
-
-Conclusion
-==========
-
-You've learned how to use the new :ocv:class:`FaceRecognizer` in real applications. After reading the document you also know how the algorithms work, so now it's time for you to experiment with the available algorithms. Use them, improve them and let the OpenCV community participate!
-
-Credits
-=======
-
-This document wouldn't be possible without the kind permission to use the face images of the *AT&T Database of Faces* and the *Yale Facedatabase A/B*.
-
-The Database of Faces
----------------------
-
-** Important: when using these images, please give credit to "AT&T Laboratories, Cambridge." **
-
-The Database of Faces, formerly *The ORL Database of Faces*, contains a set of face images taken between April 1992 and April 1994. The database was used in the context of a face recognition project carried out in collaboration with the Speech, Vision and Robotics Group of the Cambridge University Engineering Department.
-
-There are ten different images of each of 40 distinct subjects. For some subjects, the images were taken at different times, varying the lighting, facial expressions (open / closed eyes, smiling / not smiling) and facial details (glasses / no glasses). All the images were taken against a dark homogeneous background with the subjects in an upright, frontal position (with tolerance for some side movement).
-
-The files are in PGM format. The size of each image is 92x112 pixels, with 256 grey levels per pixel. The images are organised in 40 directories (one for each subject), which have names of the form sX, where X indicates the subject number (between 1 and 40). In each of these directories, there are ten different images of that subject, which have names of the form Y.pgm, where Y is the image number for that subject (between 1 and 10).
-
-A copy of the database can be retrieved from: `http://www.cl.cam.ac.uk/research/dtg/attarchive/pub/data/att_faces.zip <http://www.cl.cam.ac.uk/research/dtg/attarchive/pub/data/att_faces.zip>`_.
-
-Yale Facedatabase A
--------------------
-
-*With the permission of the authors I am allowed to show a small number of images (say subject 1 and all the variations) and all images such as Fisherfaces and Eigenfaces from either Yale Facedatabase A or the Yale Facedatabase B.*
-
-The Yale Face Database A (size 6.4MB) contains 165 grayscale images in GIF format of 15 individuals. There are 11 images per subject, one per different facial expression or configuration: center-light, w/glasses, happy, left-light, w/no glasses, normal, right-light, sad, sleepy, surprised, and wink. (Source: `http://cvc.yale.edu/projects/yalefaces/yalefaces.html <http://cvc.yale.edu/projects/yalefaces/yalefaces.html>`_)
-
-Yale Facedatabase B
---------------------
-
-*With the permission of the authors I am allowed to show a small number of images (say subject 1 and all the variations) and all images such as Fisherfaces and Eigenfaces from either Yale Facedatabase A or the Yale Facedatabase B.*
-
-The extended Yale Face Database B contains 16128 images of 28 human subjects under 9 poses and 64 illumination conditions. The data format of this database is the same as the Yale Face Database B. Please refer to the homepage of the Yale Face Database B (or one copy of this page) for more detailed information of the data format.
-
-You are free to use the extended Yale Face Database B for research purposes. All publications which use this database should acknowledge the use of "the Exteded Yale Face Database B" and reference Athinodoros Georghiades, Peter Belhumeur, and David Kriegman's paper, "From Few to Many: Illumination Cone Models for Face Recognition under Variable Lighting and Pose", PAMI, 2001, `[bibtex] <http://vision.ucsd.edu/~leekc/ExtYaleDatabase/athosref.html>`_.
-
-The extended database as opposed to the original Yale Face Database B with 10 subjects was first reported by Kuang-Chih Lee, Jeffrey Ho, and David Kriegman in "Acquiring Linear Subspaces for Face Recognition under Variable Lighting, PAMI, May, 2005 `[pdf] <http://vision.ucsd.edu/~leekc/papers/9pltsIEEE.pdf>`_." All test image data used in the experiments are manually aligned, cropped, and then re-sized to 168x192 images. If you publish your experimental results with the cropped images, please reference the PAMI2005 paper as well. (Source: `http://vision.ucsd.edu/~leekc/ExtYaleDatabase/ExtYaleB.html <http://vision.ucsd.edu/~leekc/ExtYaleDatabase/ExtYaleB.html>`_)
-
-Literature
-==========
-
-.. [AHP04] Ahonen, T., Hadid, A., and Pietikainen, M. *Face Recognition with Local Binary Patterns.* Computer Vision - ECCV 2004 (2004), 469–481.
-
-.. [BHK97] Belhumeur, P. N., Hespanha, J., and Kriegman, D. *Eigenfaces vs. Fisherfaces: Recognition Using Class Specific Linear Projection.* IEEE Transactions on Pattern Analysis and Machine Intelligence 19, 7 (1997), 711–720.
-
-.. [Bru92] Brunelli, R., Poggio, T. *Face Recognition through Geometrical Features.* European Conference on Computer Vision (ECCV) 1992, S. 792–800.
-
-.. [Duda01] Duda, Richard O. and Hart, Peter E. and Stork, David G., *Pattern Classification* (2nd Edition) 2001.
-
-.. [Fisher36] Fisher, R. A. *The use of multiple measurements in taxonomic problems.* Annals Eugen. 7 (1936), 179–188.
-
-.. [GBK01] Georghiades, A.S. and Belhumeur, P.N. and Kriegman, D.J., *From Few to Many: Illumination Cone Models for Face Recognition under Variable Lighting and Pose* IEEE Transactions on Pattern Analysis and Machine Intelligence 23, 6 (2001), 643-660.
-
-.. [Kanade73] Kanade, T. *Picture processing system by computer complex and recognition of human faces.* PhD thesis, Kyoto University, November 1973
-
-.. [KM01] Martinez, A and Kak, A. *PCA versus LDA* IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 23, No.2, pp. 228-233, 2001.
-
-.. [Lee05] Lee, K., Ho, J., Kriegman, D. *Acquiring Linear Subspaces for Face Recognition under Variable Lighting.* In: IEEE Transactions on Pattern Analysis and Machine Intelligence (PAMI) 27 (2005), Nr. 5
-
-.. [Messer06] Messer, K. et al. *Performance Characterisation of Face Recognition Algorithms and Their Sensitivity to Severe Illumination Changes.* In: In: ICB, 2006, S. 1–11.
-
-.. [RJ91] S. Raudys and  A.K. Jain.  *Small  sample  size  effects in statistical  pattern  recognition: Recommendations for  practitioneers.* - IEEE Transactions on Pattern Analysis and Machine Intelligence 13, 3 (1991), 252-264.
-
-.. [Tan10] Tan, X., and Triggs, B. *Enhanced local texture feature sets for face recognition under difficult lighting conditions.* IEEE Transactions on Image Processing 19 (2010), 1635–650.
-
-.. [TP91] Turk, M., and Pentland, A. *Eigenfaces for recognition.* Journal of Cognitive Neuroscience 3 (1991), 71–86.
-
-.. [Tu06] Chiara Turati, Viola Macchi Cassia, F. S., and Leo, I. *Newborns face recognition: Role of inner and outer facial features. Child Development* 77, 2 (2006), 297–311.
-
-.. [Wiskott97] Wiskott, L., Fellous, J., Krüger, N., Malsburg, C. *Face Recognition By Elastic Bunch Graph Matching.* IEEE Transactions on Pattern Analysis and Machine Intelligence 19 (1997), S. 775–779
-
-.. [Zhao03] Zhao, W., Chellappa, R., Phillips, P., and Rosenfeld, A. Face recognition: A literature survey. ACM Computing Surveys (CSUR) 35, 4 (2003), 399–458.
-
-.. _appendixft:
-
-Appendix
-========
-
-Creating the CSV File
----------------------
-
-You don't really want to create the CSV file by hand. I have prepared you a little Python script ``create_csv.py`` (you find it at ``/src/create_csv.py`` coming with this tutorial) that automatically creates you a CSV file. If you have your images in hierarchie like this (``/basepath/<subject>/<image.ext>``):
-
-.. code-block:: none
-
-    philipp@mango:~/facerec/data/at$ tree
-    .
-    |-- s1
-    |   |-- 1.pgm
-    |   |-- ...
-    |   |-- 10.pgm
-    |-- s2
-    |   |-- 1.pgm
-    |   |-- ...
-    |   |-- 10.pgm
-    ...
-    |-- s40
-    |   |-- 1.pgm
-    |   |-- ...
-    |   |-- 10.pgm
-
-
-Then simply call ``create_csv.py`` with the path to the folder, just like this and you could save the output:
-
-.. code-block:: none
-
-    philipp@mango:~/facerec/data$ python create_csv.py
-    at/s13/2.pgm;0
-    at/s13/7.pgm;0
-    at/s13/6.pgm;0
-    at/s13/9.pgm;0
-    at/s13/5.pgm;0
-    at/s13/3.pgm;0
-    at/s13/4.pgm;0
-    at/s13/10.pgm;0
-    at/s13/8.pgm;0
-    at/s13/1.pgm;0
-    at/s17/2.pgm;1
-    at/s17/7.pgm;1
-    at/s17/6.pgm;1
-    at/s17/9.pgm;1
-    at/s17/5.pgm;1
-    at/s17/3.pgm;1
-    [...]
-
-Here is the script, if you can't find it:
-
-.. literalinclude:: ./src/create_csv.py
-   :language: python
-   :linenos:
-
-Aligning Face Images
----------------------
-
-An accurate alignment of your image data is especially important in tasks like emotion detection, were you need as much detail as possible. Believe me... You don't want to do this by hand. So I've prepared you a tiny Python script. The code is really easy to use. To scale, rotate and crop the face image you just need to call *CropFace(image, eye_left, eye_right, offset_pct, dest_sz)*, where:
-
-* *eye_left* is the position of the left eye
-* *eye_right* is the position of the right eye
-* *offset_pct* is the percent of the image you want to keep next to the eyes (horizontal, vertical direction)
-* *dest_sz* is the size of the output image
-
-If you are using the same *offset_pct* and *dest_sz* for your images, they are all aligned at the eyes.
-
-.. literalinclude:: ./src/crop_face.py
-   :language: python
-   :linenos:
-
-Imagine we are given `this photo of Arnold Schwarzenegger <http://en.wikipedia.org/wiki/File:Arnold_Schwarzenegger_edit%28ws%29.jpg>`_, which is under a Public Domain license. The (x,y)-position of the eyes is approximately *(252,364)* for the left and *(420,366)* for the right eye. Now you only need to define the horizontal offset, vertical offset and the size your scaled, rotated & cropped face should have.
-
-Here are some examples:
-
-+---------------------------------+----------------------------------------------------------------------------+
-| Configuration                   | Cropped, Scaled, Rotated Face                                              |
-+=================================+============================================================================+
-| 0.1 (10%), 0.1 (10%), (200,200) | .. image:: ./img/tutorial/gender_classification/arnie_10_10_200_200.jpg    |
-+---------------------------------+----------------------------------------------------------------------------+
-| 0.2 (20%), 0.2 (20%), (200,200) | .. image:: ./img/tutorial/gender_classification/arnie_20_20_200_200.jpg    |
-+---------------------------------+----------------------------------------------------------------------------+
-| 0.3 (30%), 0.3 (30%), (200,200) | .. image:: ./img/tutorial/gender_classification/arnie_30_30_200_200.jpg    |
-+---------------------------------+----------------------------------------------------------------------------+
-| 0.2 (20%), 0.2 (20%), (70,70)   | .. image:: ./img/tutorial/gender_classification/arnie_20_20_70_70.jpg      |
-+---------------------------------+----------------------------------------------------------------------------+
-
-CSV for the AT&T Facedatabase
-------------------------------
-
-.. literalinclude:: etc/at.txt
-   :language: none
-   :linenos:
diff --git a/modules/contrib/doc/facerec/img/at_database_small_sample_size.png b/modules/contrib/doc/facerec/img/at_database_small_sample_size.png
deleted file mode 100644 (file)
index 92143c1..0000000
Binary files a/modules/contrib/doc/facerec/img/at_database_small_sample_size.png and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_autumn.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_autumn.jpg
deleted file mode 100644 (file)
index 0c1c8a2..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_autumn.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_bone.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_bone.jpg
deleted file mode 100644 (file)
index 7dbf766..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_bone.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_cool.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_cool.jpg
deleted file mode 100644 (file)
index 4253efb..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_cool.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_hot.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_hot.jpg
deleted file mode 100644 (file)
index cf78700..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_hot.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_hsv.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_hsv.jpg
deleted file mode 100644 (file)
index 6032b87..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_hsv.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_jet.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_jet.jpg
deleted file mode 100644 (file)
index ea273a5..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_jet.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_mkpj1.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_mkpj1.jpg
deleted file mode 100644 (file)
index d7e9363..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_mkpj1.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_mkpj2.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_mkpj2.jpg
deleted file mode 100644 (file)
index 40b067a..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_mkpj2.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_ocean.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_ocean.jpg
deleted file mode 100644 (file)
index 11d771f..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_ocean.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_pink.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_pink.jpg
deleted file mode 100644 (file)
index 8fad88c..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_pink.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_rainbow.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_rainbow.jpg
deleted file mode 100644 (file)
index 9565527..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_rainbow.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_spring.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_spring.jpg
deleted file mode 100644 (file)
index ada03a1..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_spring.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_summer.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_summer.jpg
deleted file mode 100644 (file)
index 10cb35c..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_summer.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/colormaps/colorscale_winter.jpg b/modules/contrib/doc/facerec/img/colormaps/colorscale_winter.jpg
deleted file mode 100644 (file)
index f775354..0000000
Binary files a/modules/contrib/doc/facerec/img/colormaps/colorscale_winter.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/eigenface_reconstruction_opencv.png b/modules/contrib/doc/facerec/img/eigenface_reconstruction_opencv.png
deleted file mode 100644 (file)
index 3ef469e..0000000
Binary files a/modules/contrib/doc/facerec/img/eigenface_reconstruction_opencv.png and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/eigenfaces_opencv.png b/modules/contrib/doc/facerec/img/eigenfaces_opencv.png
deleted file mode 100644 (file)
index a1ff4dc..0000000
Binary files a/modules/contrib/doc/facerec/img/eigenfaces_opencv.png and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/fisherface_reconstruction_opencv.png b/modules/contrib/doc/facerec/img/fisherface_reconstruction_opencv.png
deleted file mode 100644 (file)
index 7f0762d..0000000
Binary files a/modules/contrib/doc/facerec/img/fisherface_reconstruction_opencv.png and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/fisherfaces_opencv.png b/modules/contrib/doc/facerec/img/fisherfaces_opencv.png
deleted file mode 100644 (file)
index 0b41650..0000000
Binary files a/modules/contrib/doc/facerec/img/fisherfaces_opencv.png and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/lbp/lbp.png b/modules/contrib/doc/facerec/img/lbp/lbp.png
deleted file mode 100644 (file)
index fa181d3..0000000
Binary files a/modules/contrib/doc/facerec/img/lbp/lbp.png and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/lbp/lbp_yale.jpg b/modules/contrib/doc/facerec/img/lbp/lbp_yale.jpg
deleted file mode 100644 (file)
index b412921..0000000
Binary files a/modules/contrib/doc/facerec/img/lbp/lbp_yale.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/lbp/patterns.png b/modules/contrib/doc/facerec/img/lbp/patterns.png
deleted file mode 100644 (file)
index 0142bb1..0000000
Binary files a/modules/contrib/doc/facerec/img/lbp/patterns.png and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/tutorial/facerec_video/facerec_video.png b/modules/contrib/doc/facerec/img/tutorial/facerec_video/facerec_video.png
deleted file mode 100644 (file)
index 6481882..0000000
Binary files a/modules/contrib/doc/facerec/img/tutorial/facerec_video/facerec_video.png and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_10_10_200_200.jpg b/modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_10_10_200_200.jpg
deleted file mode 100644 (file)
index 9632087..0000000
Binary files a/modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_10_10_200_200.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_20_20_200_200.jpg b/modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_20_20_200_200.jpg
deleted file mode 100644 (file)
index 2fe6633..0000000
Binary files a/modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_20_20_200_200.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_20_20_70_70.jpg b/modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_20_20_70_70.jpg
deleted file mode 100644 (file)
index d8464ea..0000000
Binary files a/modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_20_20_70_70.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_30_30_200_200.jpg b/modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_30_30_200_200.jpg
deleted file mode 100644 (file)
index 58827f2..0000000
Binary files a/modules/contrib/doc/facerec/img/tutorial/gender_classification/arnie_30_30_200_200.jpg and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/tutorial/gender_classification/clooney_set.png b/modules/contrib/doc/facerec/img/tutorial/gender_classification/clooney_set.png
deleted file mode 100644 (file)
index f05e447..0000000
Binary files a/modules/contrib/doc/facerec/img/tutorial/gender_classification/clooney_set.png and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/tutorial/gender_classification/fisherface_0.png b/modules/contrib/doc/facerec/img/tutorial/gender_classification/fisherface_0.png
deleted file mode 100644 (file)
index 672a197..0000000
Binary files a/modules/contrib/doc/facerec/img/tutorial/gender_classification/fisherface_0.png and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/tutorial/gender_classification/fisherface_reconstruction_0.png b/modules/contrib/doc/facerec/img/tutorial/gender_classification/fisherface_reconstruction_0.png
deleted file mode 100644 (file)
index 168acad..0000000
Binary files a/modules/contrib/doc/facerec/img/tutorial/gender_classification/fisherface_reconstruction_0.png and /dev/null differ
diff --git a/modules/contrib/doc/facerec/img/tutorial/gender_classification/mean.png b/modules/contrib/doc/facerec/img/tutorial/gender_classification/mean.png
deleted file mode 100644 (file)
index f853694..0000000
Binary files a/modules/contrib/doc/facerec/img/tutorial/gender_classification/mean.png and /dev/null differ
diff --git a/modules/contrib/doc/facerec/index.rst b/modules/contrib/doc/facerec/index.rst
deleted file mode 100644 (file)
index b871448..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-FaceRecognizer - Face Recognition with OpenCV
-##############################################
-
-OpenCV 2.4 now comes with the very new :ocv:class:`FaceRecognizer` class for face recognition. This documentation is going to explain you :doc:`the API <facerec_api>` in detail and it will give you a lot of help to get started (full source code examples). :doc:`Face Recognition with OpenCV <facerec_tutorial>` is the definite guide to the new :ocv:class:`FaceRecognizer`. There's also a :doc:`tutorial on gender classification <tutorial/facerec_gender_classification>`, a :doc:`tutorial for face recognition in videos <tutorial/facerec_video_recognition>` and it's shown :doc:`how to load & save your results <tutorial/facerec_save_load>`.
-
-These documents are the help I have wished for, when I was working myself into face recognition. I hope you also think the new :ocv:class:`FaceRecognizer` is a useful addition to OpenCV.
-
-Please issue any feature requests and/or bugs on the official OpenCV bug tracker at:
-
-  * http://code.opencv.org/projects/opencv/issues
-
-Contents
-========
-
-
-.. toctree::
-   :maxdepth: 1
-
-   FaceRecognizer API <facerec_api>
-   Guide to Face Recognition with OpenCV <facerec_tutorial>
-   Tutorial on Gender Classification <tutorial/facerec_gender_classification>
-   Tutorial on Face Recognition in Videos <tutorial/facerec_video_recognition>
-   Tutorial On Saving & Loading a FaceRecognizer <tutorial/facerec_save_load>
-   How to use Colormaps in OpenCV <colormaps>
-   Changelog <facerec_changelog>
-
-Indices and tables
-==================
-
-* :ref:`genindex`
-* :ref:`modindex`
-* :ref:`search`
diff --git a/modules/contrib/doc/facerec/src/CMakeLists.txt b/modules/contrib/doc/facerec/src/CMakeLists.txt
deleted file mode 100644 (file)
index 94aa36f..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-
-set(name "facerec")
-project(facerec_cpp_samples)
-
-#SET(OpenCV_DIR /path/to/your/opencv/installation)
-
-# packages
-find_package(OpenCV REQUIRED) # http://opencv.org
-
-# probably you should loop through the sample files here
-add_executable(facerec_demo facerec_demo.cpp)
-target_link_libraries(facerec_demo opencv_core opencv_contrib opencv_imgproc opencv_highgui)
-
-add_executable(facerec_video facerec_video.cpp)
-target_link_libraries(facerec_video opencv_contrib opencv_core opencv_imgproc opencv_highgui opencv_objdetect opencv_imgproc)
-
-add_executable(facerec_eigenfaces facerec_eigenfaces.cpp)
-target_link_libraries(facerec_eigenfaces opencv_contrib opencv_core opencv_imgproc opencv_highgui)
-
-add_executable(facerec_fisherfaces facerec_fisherfaces.cpp)
-target_link_libraries(facerec_fisherfaces opencv_contrib opencv_core opencv_imgproc opencv_highgui)
-
-add_executable(facerec_lbph facerec_lbph.cpp)
-target_link_libraries(facerec_lbph opencv_contrib opencv_core opencv_imgproc opencv_highgui)
diff --git a/modules/contrib/doc/facerec/src/create_csv.py b/modules/contrib/doc/facerec/src/create_csv.py
deleted file mode 100755 (executable)
index c4de778..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import os.path
-
-# This is a tiny script to help you creating a CSV file from a face
-# database with a similar hierarchie:
-#
-#  philipp@mango:~/facerec/data/at$ tree
-#  .
-#  |-- README
-#  |-- s1
-#  |   |-- 1.pgm
-#  |   |-- ...
-#  |   |-- 10.pgm
-#  |-- s2
-#  |   |-- 1.pgm
-#  |   |-- ...
-#  |   |-- 10.pgm
-#  ...
-#  |-- s40
-#  |   |-- 1.pgm
-#  |   |-- ...
-#  |   |-- 10.pgm
-#
-
-if __name__ == "__main__":
-
-    if len(sys.argv) != 2:
-        print "usage: create_csv <base_path>"
-        sys.exit(1)
-
-    BASE_PATH=sys.argv[1]
-    SEPARATOR=";"
-
-    label = 0
-    for dirname, dirnames, filenames in os.walk(BASE_PATH):
-        for subdirname in dirnames:
-            subject_path = os.path.join(dirname, subdirname)
-            for filename in os.listdir(subject_path):
-                abs_path = "%s/%s" % (subject_path, filename)
-                print "%s%s%d" % (abs_path, SEPARATOR, label)
-            label = label + 1
diff --git a/modules/contrib/doc/facerec/src/crop_face.py b/modules/contrib/doc/facerec/src/crop_face.py
deleted file mode 100755 (executable)
index 11472a9..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/usr/bin/env python
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2012, Philipp Wagner
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#  * Redistributions of source code must retain the above copyright
-#    notice, this list of conditions and the following disclaimer.
-#  * Redistributions in binary form must reproduce the above
-#    copyright notice, this list of conditions and the following
-#    disclaimer in the documentation and/or other materials provided
-#    with the distribution.
-#  * Neither the name of the author nor the names of its
-#    contributors may be used to endorse or promote products derived
-#    from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-import sys, math, Image
-
-def Distance(p1,p2):
-  dx = p2[0] - p1[0]
-  dy = p2[1] - p1[1]
-  return math.sqrt(dx*dx+dy*dy)
-
-def ScaleRotateTranslate(image, angle, center = None, new_center = None, scale = None, resample=Image.BICUBIC):
-  if (scale is None) and (center is None):
-    return image.rotate(angle=angle, resample=resample)
-  nx,ny = x,y = center
-  sx=sy=1.0
-  if new_center:
-    (nx,ny) = new_center
-  if scale:
-    (sx,sy) = (scale, scale)
-  cosine = math.cos(angle)
-  sine = math.sin(angle)
-  a = cosine/sx
-  b = sine/sx
-  c = x-nx*a-ny*b
-  d = -sine/sy
-  e = cosine/sy
-  f = y-nx*d-ny*e
-  return image.transform(image.size, Image.AFFINE, (a,b,c,d,e,f), resample=resample)
-
-def CropFace(image, eye_left=(0,0), eye_right=(0,0), offset_pct=(0.2,0.2), dest_sz = (70,70)):
-  # calculate offsets in original image
-  offset_h = math.floor(float(offset_pct[0])*dest_sz[0])
-  offset_v = math.floor(float(offset_pct[1])*dest_sz[1])
-  # get the direction
-  eye_direction = (eye_right[0] - eye_left[0], eye_right[1] - eye_left[1])
-  # calc rotation angle in radians
-  rotation = -math.atan2(float(eye_direction[1]),float(eye_direction[0]))
-  # distance between them
-  dist = Distance(eye_left, eye_right)
-  # calculate the reference eye-width
-  reference = dest_sz[0] - 2.0*offset_h
-  # scale factor
-  scale = float(dist)/float(reference)
-  # rotate original around the left eye
-  image = ScaleRotateTranslate(image, center=eye_left, angle=rotation)
-  # crop the rotated image
-  crop_xy = (eye_left[0] - scale*offset_h, eye_left[1] - scale*offset_v)
-  crop_size = (dest_sz[0]*scale, dest_sz[1]*scale)
-  image = image.crop((int(crop_xy[0]), int(crop_xy[1]), int(crop_xy[0]+crop_size[0]), int(crop_xy[1]+crop_size[1])))
-  # resize it
-  image = image.resize(dest_sz, Image.ANTIALIAS)
-  return image
-
-def readFileNames():
-    try:
-        inFile = open('path_to_created_csv_file.csv')
-    except:
-        raise IOError('There is no file named path_to_created_csv_file.csv in current directory.')
-        return False
-
-    picPath = []
-    picIndex = []
-
-    for line in inFile.readlines():
-        if line != '':
-            fields = line.rstrip().split(';')
-            picPath.append(fields[0])
-            picIndex.append(int(fields[1]))
-
-    return (picPath, picIndex)
-
-
-if __name__ == "__main__":
-  [images, indexes]=readFileNames()
-if not os.path.exists("modified"):
-    os.makedirs("modified")
-for img in images:
-    image =  Image.open(img)
-    CropFace(image, eye_left=(252,364), eye_right=(420,366), offset_pct=(0.1,0.1), dest_sz=(200,200)).save("modified/"+img.rstrip().split('/')[1]+"_10_10_200_200.jpg")
-    CropFace(image, eye_left=(252,364), eye_right=(420,366), offset_pct=(0.2,0.2), dest_sz=(200,200)).save("modified/"+img.rstrip().split('/')[1]+"_20_20_200_200.jpg")
-    CropFace(image, eye_left=(252,364), eye_right=(420,366), offset_pct=(0.3,0.3), dest_sz=(200,200)).save("modified/"+img.rstrip().split('/')[1]+"_30_30_200_200.jpg")
-    CropFace(image, eye_left=(252,364), eye_right=(420,366), offset_pct=(0.2,0.2)).save("modified/"+img.rstrip().split('/')[1]+"_20_20_70_70.jpg")
diff --git a/modules/contrib/doc/facerec/src/facerec_demo.cpp b/modules/contrib/doc/facerec/src/facerec_demo.cpp
deleted file mode 100644 (file)
index e3d82b6..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>.
- * Released to public domain under terms of the BSD Simplified license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of the organization nor the names of its contributors
- *     may be used to endorse or promote products derived from this software
- *     without specific prior written permission.
- *
- *   See <http://www.opensource.org/licenses/bsd-license>
- */
-
-#include "opencv2/core.hpp"
-#include "opencv2/contrib.hpp"
-#include "opencv2/highgui.hpp"
-
-
-#include <iostream>
-#include <fstream>
-#include <sstream>
-
-using namespace cv;
-using namespace std;
-
-static Mat norm_0_255(InputArray _src) {
-    Mat src = _src.getMat();
-    // Create and return normalized image:
-    Mat dst;
-    switch(src.channels()) {
-    case 1:
-        cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
-        break;
-    case 3:
-        cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC3);
-        break;
-    default:
-        src.copyTo(dst);
-        break;
-    }
-    return dst;
-}
-
-static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
-    std::ifstream file(filename.c_str(), ifstream::in);
-    if (!file) {
-        string error_message = "No valid input file was given, please check the given filename.";
-        CV_Error(CV_StsBadArg, error_message);
-    }
-    string line, path, classlabel;
-    while (getline(file, line)) {
-        stringstream liness(line);
-        getline(liness, path, separator);
-        getline(liness, classlabel);
-        if(!path.empty() && !classlabel.empty()) {
-            images.push_back(imread(path, 0));
-            labels.push_back(atoi(classlabel.c_str()));
-        }
-    }
-}
-
-int main(int argc, const char *argv[]) {
-    // Check for valid command line arguments, print usage
-    // if no arguments were given.
-    if (argc != 2) {
-        cout << "usage: " << argv[0] << " <csv.ext>" << endl;
-        exit(1);
-    }
-    // Get the path to your CSV.
-    string fn_csv = string(argv[1]);
-    // These vectors hold the images and corresponding labels.
-    vector<Mat> images;
-    vector<int> labels;
-    // Read in the data. This can fail if no valid
-    // input filename is given.
-    try {
-        read_csv(fn_csv, images, labels);
-    } catch (cv::Exception& e) {
-        cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
-        // nothing more we can do
-        exit(1);
-    }
-    // Quit if there are not enough images for this demo.
-    if(images.size() <= 1) {
-        string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
-        CV_Error(CV_StsError, error_message);
-    }
-    // Get the height from the first image. We'll need this
-    // later in code to reshape the images to their original
-    // size:
-    int height = images[0].rows;
-    // The following lines simply get the last images from
-    // your dataset and remove it from the vector. This is
-    // done, so that the training data (which we learn the
-    // cv::FaceRecognizer on) and the test data we test
-    // the model with, do not overlap.
-    Mat testSample = images[images.size() - 1];
-    int testLabel = labels[labels.size() - 1];
-    images.pop_back();
-    labels.pop_back();
-    // The following lines create an Eigenfaces model for
-    // face recognition and train it with the images and
-    // labels read from the given CSV file.
-    // This here is a full PCA, if you just want to keep
-    // 10 principal components (read Eigenfaces), then call
-    // the factory method like this:
-    //
-    //      cv::createEigenFaceRecognizer(10);
-    //
-    // If you want to create a FaceRecognizer with a
-    // confidennce threshold, call it with:
-    //
-    //      cv::createEigenFaceRecognizer(10, 123.0);
-    //
-    Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
-    model->train(images, labels);
-    // The following line predicts the label of a given
-    // test image:
-    int predictedLabel = model->predict(testSample);
-    //
-    // To get the confidence of a prediction call the model with:
-    //
-    //      int predictedLabel = -1;
-    //      double confidence = 0.0;
-    //      model->predict(testSample, predictedLabel, confidence);
-    //
-    string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
-    cout << result_message << endl;
-    // Sometimes you'll need to get/set internal model data,
-    // which isn't exposed by the public cv::FaceRecognizer.
-    // Since each cv::FaceRecognizer is derived from a
-    // cv::Algorithm, you can query the data.
-    //
-    // First we'll use it to set the threshold of the FaceRecognizer
-    // to 0.0 without retraining the model. This can be useful if
-    // you are evaluating the model:
-    //
-    model->set("threshold", 0.0);
-    // Now the threshold of this model is set to 0.0. A prediction
-    // now returns -1, as it's impossible to have a distance below
-    // it
-    predictedLabel = model->predict(testSample);
-    cout << "Predicted class = " << predictedLabel << endl;
-    // Here is how to get the eigenvalues of this Eigenfaces model:
-    Mat eigenvalues = model->getMat("eigenvalues");
-    // And we can do the same to display the Eigenvectors (read Eigenfaces):
-    Mat W = model->getMat("eigenvectors");
-    // From this we will display the (at most) first 10 Eigenfaces:
-    for (int i = 0; i < min(10, W.cols); i++) {
-        string msg = format("Eigenvalue #%d = %.5f", i, eigenvalues.at<double>(i));
-        cout << msg << endl;
-        // get eigenvector #i
-        Mat ev = W.col(i).clone();
-        // Reshape to original size & normalize to [0...255] for imshow.
-        Mat grayscale = norm_0_255(ev.reshape(1, height));
-        // Show the image & apply a Jet colormap for better sensing.
-        Mat cgrayscale;
-        applyColorMap(grayscale, cgrayscale, COLORMAP_JET);
-        imshow(format("%d", i), cgrayscale);
-    }
-    waitKey(0);
-
-    return 0;
-}
diff --git a/modules/contrib/doc/facerec/src/facerec_eigenfaces.cpp b/modules/contrib/doc/facerec/src/facerec_eigenfaces.cpp
deleted file mode 100644 (file)
index 8115467..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>.
- * Released to public domain under terms of the BSD Simplified license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of the organization nor the names of its contributors
- *     may be used to endorse or promote products derived from this software
- *     without specific prior written permission.
- *
- *   See <http://www.opensource.org/licenses/bsd-license>
- */
-
-#include "opencv2/core.hpp"
-#include "opencv2/contrib.hpp"
-#include "opencv2/highgui.hpp"
-
-#include <iostream>
-#include <fstream>
-#include <sstream>
-
-using namespace cv;
-using namespace std;
-
-static Mat norm_0_255(InputArray _src) {
-    Mat src = _src.getMat();
-    // Create and return normalized image:
-    Mat dst;
-    switch(src.channels()) {
-    case 1:
-        cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
-        break;
-    case 3:
-        cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC3);
-        break;
-    default:
-        src.copyTo(dst);
-        break;
-    }
-    return dst;
-}
-
-static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
-    std::ifstream file(filename.c_str(), ifstream::in);
-    if (!file) {
-        string error_message = "No valid input file was given, please check the given filename.";
-        CV_Error(CV_StsBadArg, error_message);
-    }
-    string line, path, classlabel;
-    while (getline(file, line)) {
-        stringstream liness(line);
-        getline(liness, path, separator);
-        getline(liness, classlabel);
-        if(!path.empty() && !classlabel.empty()) {
-            images.push_back(imread(path, 0));
-            labels.push_back(atoi(classlabel.c_str()));
-        }
-    }
-}
-
-int main(int argc, const char *argv[]) {
-    // Check for valid command line arguments, print usage
-    // if no arguments were given.
-    if (argc < 2) {
-        cout << "usage: " << argv[0] << " <csv.ext> <output_folder> " << endl;
-        exit(1);
-    }
-    string output_folder = ".";
-    if (argc == 3) {
-        output_folder = string(argv[2]);
-    }
-    // Get the path to your CSV.
-    string fn_csv = string(argv[1]);
-    // These vectors hold the images and corresponding labels.
-    vector<Mat> images;
-    vector<int> labels;
-    // Read in the data. This can fail if no valid
-    // input filename is given.
-    try {
-        read_csv(fn_csv, images, labels);
-    } catch (cv::Exception& e) {
-        cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
-        // nothing more we can do
-        exit(1);
-    }
-    // Quit if there are not enough images for this demo.
-    if(images.size() <= 1) {
-        string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
-        CV_Error(CV_StsError, error_message);
-    }
-    // Get the height from the first image. We'll need this
-    // later in code to reshape the images to their original
-    // size:
-    int height = images[0].rows;
-    // The following lines simply get the last images from
-    // your dataset and remove it from the vector. This is
-    // done, so that the training data (which we learn the
-    // cv::FaceRecognizer on) and the test data we test
-    // the model with, do not overlap.
-    Mat testSample = images[images.size() - 1];
-    int testLabel = labels[labels.size() - 1];
-    images.pop_back();
-    labels.pop_back();
-    // The following lines create an Eigenfaces model for
-    // face recognition and train it with the images and
-    // labels read from the given CSV file.
-    // This here is a full PCA, if you just want to keep
-    // 10 principal components (read Eigenfaces), then call
-    // the factory method like this:
-    //
-    //      cv::createEigenFaceRecognizer(10);
-    //
-    // If you want to create a FaceRecognizer with a
-    // confidence threshold (e.g. 123.0), call it with:
-    //
-    //      cv::createEigenFaceRecognizer(10, 123.0);
-    //
-    // If you want to use _all_ Eigenfaces and have a threshold,
-    // then call the method like this:
-    //
-    //      cv::createEigenFaceRecognizer(0, 123.0);
-    //
-    Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
-    model->train(images, labels);
-    // The following line predicts the label of a given
-    // test image:
-    int predictedLabel = model->predict(testSample);
-    //
-    // To get the confidence of a prediction call the model with:
-    //
-    //      int predictedLabel = -1;
-    //      double confidence = 0.0;
-    //      model->predict(testSample, predictedLabel, confidence);
-    //
-    string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
-    cout << result_message << endl;
-    // Here is how to get the eigenvalues of this Eigenfaces model:
-    Mat eigenvalues = model->getMat("eigenvalues");
-    // And we can do the same to display the Eigenvectors (read Eigenfaces):
-    Mat W = model->getMat("eigenvectors");
-    // Get the sample mean from the training data
-    Mat mean = model->getMat("mean");
-    // Display or save:
-    if(argc == 2) {
-        imshow("mean", norm_0_255(mean.reshape(1, images[0].rows)));
-    } else {
-        imwrite(format("%s/mean.png", output_folder.c_str()), norm_0_255(mean.reshape(1, images[0].rows)));
-    }
-    // Display or save the Eigenfaces:
-    for (int i = 0; i < min(10, W.cols); i++) {
-        string msg = format("Eigenvalue #%d = %.5f", i, eigenvalues.at<double>(i));
-        cout << msg << endl;
-        // get eigenvector #i
-        Mat ev = W.col(i).clone();
-        // Reshape to original size & normalize to [0...255] for imshow.
-        Mat grayscale = norm_0_255(ev.reshape(1, height));
-        // Show the image & apply a Jet colormap for better sensing.
-        Mat cgrayscale;
-        applyColorMap(grayscale, cgrayscale, COLORMAP_JET);
-        // Display or save:
-        if(argc == 2) {
-            imshow(format("eigenface_%d", i), cgrayscale);
-        } else {
-            imwrite(format("%s/eigenface_%d.png", output_folder.c_str(), i), norm_0_255(cgrayscale));
-        }
-    }
-
-    // Display or save the image reconstruction at some predefined steps:
-    for(int num_components = min(W.cols, 10); num_components < min(W.cols, 300); num_components+=15) {
-        // slice the eigenvectors from the model
-        Mat evs = Mat(W, Range::all(), Range(0, num_components));
-        Mat projection = subspaceProject(evs, mean, images[0].reshape(1,1));
-        Mat reconstruction = subspaceReconstruct(evs, mean, projection);
-        // Normalize the result:
-        reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
-        // Display or save:
-        if(argc == 2) {
-            imshow(format("eigenface_reconstruction_%d", num_components), reconstruction);
-        } else {
-            imwrite(format("%s/eigenface_reconstruction_%d.png", output_folder.c_str(), num_components), reconstruction);
-        }
-    }
-    // Display if we are not writing to an output folder:
-    if(argc == 2) {
-        waitKey(0);
-    }
-    return 0;
-}
diff --git a/modules/contrib/doc/facerec/src/facerec_fisherfaces.cpp b/modules/contrib/doc/facerec/src/facerec_fisherfaces.cpp
deleted file mode 100644 (file)
index 0b20789..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>.
- * Released to public domain under terms of the BSD Simplified license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of the organization nor the names of its contributors
- *     may be used to endorse or promote products derived from this software
- *     without specific prior written permission.
- *
- *   See <http://www.opensource.org/licenses/bsd-license>
- */
-
-#include "opencv2/core.hpp"
-#include "opencv2/contrib.hpp"
-#include "opencv2/highgui.hpp"
-
-#include <iostream>
-#include <fstream>
-#include <sstream>
-
-using namespace cv;
-using namespace std;
-
-static Mat norm_0_255(InputArray _src) {
-    Mat src = _src.getMat();
-    // Create and return normalized image:
-    Mat dst;
-    switch(src.channels()) {
-    case 1:
-        cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
-        break;
-    case 3:
-        cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC3);
-        break;
-    default:
-        src.copyTo(dst);
-        break;
-    }
-    return dst;
-}
-
-static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
-    std::ifstream file(filename.c_str(), ifstream::in);
-    if (!file) {
-        string error_message = "No valid input file was given, please check the given filename.";
-        CV_Error(CV_StsBadArg, error_message);
-    }
-    string line, path, classlabel;
-    while (getline(file, line)) {
-        stringstream liness(line);
-        getline(liness, path, separator);
-        getline(liness, classlabel);
-        if(!path.empty() && !classlabel.empty()) {
-            images.push_back(imread(path, 0));
-            labels.push_back(atoi(classlabel.c_str()));
-        }
-    }
-}
-
-int main(int argc, const char *argv[]) {
-    // Check for valid command line arguments, print usage
-    // if no arguments were given.
-    if (argc < 2) {
-        cout << "usage: " << argv[0] << " <csv.ext> <output_folder> " << endl;
-        exit(1);
-    }
-    string output_folder = ".";
-    if (argc == 3) {
-        output_folder = string(argv[2]);
-    }
-    // Get the path to your CSV.
-    string fn_csv = string(argv[1]);
-    // These vectors hold the images and corresponding labels.
-    vector<Mat> images;
-    vector<int> labels;
-    // Read in the data. This can fail if no valid
-    // input filename is given.
-    try {
-        read_csv(fn_csv, images, labels);
-    } catch (cv::Exception& e) {
-        cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
-        // nothing more we can do
-        exit(1);
-    }
-    // Quit if there are not enough images for this demo.
-    if(images.size() <= 1) {
-        string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
-        CV_Error(CV_StsError, error_message);
-    }
-    // Get the height from the first image. We'll need this
-    // later in code to reshape the images to their original
-    // size:
-    int height = images[0].rows;
-    // The following lines simply get the last images from
-    // your dataset and remove it from the vector. This is
-    // done, so that the training data (which we learn the
-    // cv::FaceRecognizer on) and the test data we test
-    // the model with, do not overlap.
-    Mat testSample = images[images.size() - 1];
-    int testLabel = labels[labels.size() - 1];
-    images.pop_back();
-    labels.pop_back();
-    // The following lines create an Fisherfaces model for
-    // face recognition and train it with the images and
-    // labels read from the given CSV file.
-    // If you just want to keep 10 Fisherfaces, then call
-    // the factory method like this:
-    //
-    //      cv::createFisherFaceRecognizer(10);
-    //
-    // However it is not useful to discard Fisherfaces! Please
-    // always try to use _all_ available Fisherfaces for
-    // classification.
-    //
-    // If you want to create a FaceRecognizer with a
-    // confidence threshold (e.g. 123.0) and use _all_
-    // Fisherfaces, then call it with:
-    //
-    //      cv::createFisherFaceRecognizer(0, 123.0);
-    //
-    Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
-    model->train(images, labels);
-    // The following line predicts the label of a given
-    // test image:
-    int predictedLabel = model->predict(testSample);
-    //
-    // To get the confidence of a prediction call the model with:
-    //
-    //      int predictedLabel = -1;
-    //      double confidence = 0.0;
-    //      model->predict(testSample, predictedLabel, confidence);
-    //
-    string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
-    cout << result_message << endl;
-    // Here is how to get the eigenvalues of this Eigenfaces model:
-    Mat eigenvalues = model->getMat("eigenvalues");
-    // And we can do the same to display the Eigenvectors (read Eigenfaces):
-    Mat W = model->getMat("eigenvectors");
-    // Get the sample mean from the training data
-    Mat mean = model->getMat("mean");
-    // Display or save:
-    if(argc == 2) {
-        imshow("mean", norm_0_255(mean.reshape(1, images[0].rows)));
-    } else {
-        imwrite(format("%s/mean.png", output_folder.c_str()), norm_0_255(mean.reshape(1, images[0].rows)));
-    }
-    // Display or save the first, at most 16 Fisherfaces:
-    for (int i = 0; i < min(16, W.cols); i++) {
-        string msg = format("Eigenvalue #%d = %.5f", i, eigenvalues.at<double>(i));
-        cout << msg << endl;
-        // get eigenvector #i
-        Mat ev = W.col(i).clone();
-        // Reshape to original size & normalize to [0...255] for imshow.
-        Mat grayscale = norm_0_255(ev.reshape(1, height));
-        // Show the image & apply a Bone colormap for better sensing.
-        Mat cgrayscale;
-        applyColorMap(grayscale, cgrayscale, COLORMAP_BONE);
-        // Display or save:
-        if(argc == 2) {
-            imshow(format("fisherface_%d", i), cgrayscale);
-        } else {
-            imwrite(format("%s/fisherface_%d.png", output_folder.c_str(), i), norm_0_255(cgrayscale));
-        }
-    }
-    // Display or save the image reconstruction at some predefined steps:
-    for(int num_component = 0; num_component < min(16, W.cols); num_component++) {
-        // Slice the Fisherface from the model:
-        Mat ev = W.col(num_component);
-        Mat projection = subspaceProject(ev, mean, images[0].reshape(1,1));
-        Mat reconstruction = subspaceReconstruct(ev, mean, projection);
-        // Normalize the result:
-        reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
-        // Display or save:
-        if(argc == 2) {
-            imshow(format("fisherface_reconstruction_%d", num_component), reconstruction);
-        } else {
-            imwrite(format("%s/fisherface_reconstruction_%d.png", output_folder.c_str(), num_component), reconstruction);
-        }
-    }
-    // Display if we are not writing to an output folder:
-    if(argc == 2) {
-        waitKey(0);
-    }
-    return 0;
-}
diff --git a/modules/contrib/doc/facerec/src/facerec_lbph.cpp b/modules/contrib/doc/facerec/src/facerec_lbph.cpp
deleted file mode 100644 (file)
index 1477777..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>.
- * Released to public domain under terms of the BSD Simplified license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of the organization nor the names of its contributors
- *     may be used to endorse or promote products derived from this software
- *     without specific prior written permission.
- *
- *   See <http://www.opensource.org/licenses/bsd-license>
- */
-
-#include "opencv2/core.hpp"
-#include "opencv2/contrib.hpp"
-#include "opencv2/highgui.hpp"
-
-#include <iostream>
-#include <fstream>
-#include <sstream>
-
-using namespace cv;
-using namespace std;
-
-static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
-    std::ifstream file(filename.c_str(), ifstream::in);
-    if (!file) {
-        string error_message = "No valid input file was given, please check the given filename.";
-        CV_Error(CV_StsBadArg, error_message);
-    }
-    string line, path, classlabel;
-    while (getline(file, line)) {
-        stringstream liness(line);
-        getline(liness, path, separator);
-        getline(liness, classlabel);
-        if(!path.empty() && !classlabel.empty()) {
-            images.push_back(imread(path, 0));
-            labels.push_back(atoi(classlabel.c_str()));
-        }
-    }
-}
-
-int main(int argc, const char *argv[]) {
-    // Check for valid command line arguments, print usage
-    // if no arguments were given.
-    if (argc != 2) {
-        cout << "usage: " << argv[0] << " <csv.ext>" << endl;
-        exit(1);
-    }
-    // Get the path to your CSV.
-    string fn_csv = string(argv[1]);
-    // These vectors hold the images and corresponding labels.
-    vector<Mat> images;
-    vector<int> labels;
-    // Read in the data. This can fail if no valid
-    // input filename is given.
-    try {
-        read_csv(fn_csv, images, labels);
-    } catch (cv::Exception& e) {
-        cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
-        // nothing more we can do
-        exit(1);
-    }
-    // Quit if there are not enough images for this demo.
-    if(images.size() <= 1) {
-        string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
-        CV_Error(CV_StsError, error_message);
-    }
-    // Get the height from the first image. We'll need this
-    // later in code to reshape the images to their original
-    // size:
-    int height = images[0].rows;
-    // The following lines simply get the last images from
-    // your dataset and remove it from the vector. This is
-    // done, so that the training data (which we learn the
-    // cv::FaceRecognizer on) and the test data we test
-    // the model with, do not overlap.
-    Mat testSample = images[images.size() - 1];
-    int testLabel = labels[labels.size() - 1];
-    images.pop_back();
-    labels.pop_back();
-    // The following lines create an LBPH model for
-    // face recognition and train it with the images and
-    // labels read from the given CSV file.
-    //
-    // The LBPHFaceRecognizer uses Extended Local Binary Patterns
-    // (it's probably configurable with other operators at a later
-    // point), and has the following default values
-    //
-    //      radius = 1
-    //      neighbors = 8
-    //      grid_x = 8
-    //      grid_y = 8
-    //
-    // So if you want a LBPH FaceRecognizer using a radius of
-    // 2 and 16 neighbors, call the factory method with:
-    //
-    //      cv::createLBPHFaceRecognizer(2, 16);
-    //
-    // And if you want a threshold (e.g. 123.0) call it with its default values:
-    //
-    //      cv::createLBPHFaceRecognizer(1,8,8,8,123.0)
-    //
-    Ptr<FaceRecognizer> model = createLBPHFaceRecognizer();
-    model->train(images, labels);
-    // The following line predicts the label of a given
-    // test image:
-    int predictedLabel = model->predict(testSample);
-    //
-    // To get the confidence of a prediction call the model with:
-    //
-    //      int predictedLabel = -1;
-    //      double confidence = 0.0;
-    //      model->predict(testSample, predictedLabel, confidence);
-    //
-    string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
-    cout << result_message << endl;
-    // Sometimes you'll need to get/set internal model data,
-    // which isn't exposed by the public cv::FaceRecognizer.
-    // Since each cv::FaceRecognizer is derived from a
-    // cv::Algorithm, you can query the data.
-    //
-    // First we'll use it to set the threshold of the FaceRecognizer
-    // to 0.0 without retraining the model. This can be useful if
-    // you are evaluating the model:
-    //
-    model->set("threshold", 0.0);
-    // Now the threshold of this model is set to 0.0. A prediction
-    // now returns -1, as it's impossible to have a distance below
-    // it
-    predictedLabel = model->predict(testSample);
-    cout << "Predicted class = " << predictedLabel << endl;
-    // Show some informations about the model, as there's no cool
-    // Model data to display as in Eigenfaces/Fisherfaces.
-    // Due to efficiency reasons the LBP images are not stored
-    // within the model:
-    cout << "Model Information:" << endl;
-    string model_info = format("\tLBPH(radius=%i, neighbors=%i, grid_x=%i, grid_y=%i, threshold=%.2f)",
-            model->getInt("radius"),
-            model->getInt("neighbors"),
-            model->getInt("grid_x"),
-            model->getInt("grid_y"),
-            model->getDouble("threshold"));
-    cout << model_info << endl;
-    // We could get the histograms for example:
-    vector<Mat> histograms = model->getMatVector("histograms");
-    // But should I really visualize it? Probably the length is interesting:
-    cout << "Size of the histograms: " << histograms[0].total() << endl;
-    return 0;
-}
diff --git a/modules/contrib/doc/facerec/src/facerec_save_load.cpp b/modules/contrib/doc/facerec/src/facerec_save_load.cpp
deleted file mode 100644 (file)
index 4db2d66..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>.
- * Released to public domain under terms of the BSD Simplified license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of the organization nor the names of its contributors
- *     may be used to endorse or promote products derived from this software
- *     without specific prior written permission.
- *
- *   See <http://www.opensource.org/licenses/bsd-license>
- */
-
-#include "opencv2/contrib.hpp"
-#include "opencv2/core.hpp"
-#include "opencv2/highgui.hpp"
-
-#include <iostream>
-#include <fstream>
-#include <sstream>
-
-using namespace cv;
-using namespace std;
-
-static Mat norm_0_255(InputArray _src) {
-    Mat src = _src.getMat();
-    // Create and return normalized image:
-    Mat dst;
-    switch(src.channels()) {
-    case 1:
-        cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
-        break;
-    case 3:
-        cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC3);
-        break;
-    default:
-        src.copyTo(dst);
-        break;
-    }
-    return dst;
-}
-
-static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
-    std::ifstream file(filename.c_str(), ifstream::in);
-    if (!file) {
-        string error_message = "No valid input file was given, please check the given filename.";
-        CV_Error(CV_StsBadArg, error_message);
-    }
-    string line, path, classlabel;
-    while (getline(file, line)) {
-        stringstream liness(line);
-        getline(liness, path, separator);
-        getline(liness, classlabel);
-        if(!path.empty() && !classlabel.empty()) {
-            images.push_back(imread(path, 0));
-            labels.push_back(atoi(classlabel.c_str()));
-        }
-    }
-}
-
-int main(int argc, const char *argv[]) {
-    // Check for valid command line arguments, print usage
-    // if no arguments were given.
-    if (argc < 2) {
-        cout << "usage: " << argv[0] << " <csv.ext> <output_folder> " << endl;
-        exit(1);
-    }
-    string output_folder = ".";
-    if (argc == 3) {
-        output_folder = string(argv[2]);
-    }
-    // Get the path to your CSV.
-    string fn_csv = string(argv[1]);
-    // These vectors hold the images and corresponding labels.
-    vector<Mat> images;
-    vector<int> labels;
-    // Read in the data. This can fail if no valid
-    // input filename is given.
-    try {
-        read_csv(fn_csv, images, labels);
-    } catch (cv::Exception& e) {
-        cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
-        // nothing more we can do
-        exit(1);
-    }
-    // Quit if there are not enough images for this demo.
-    if(images.size() <= 1) {
-        string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
-        CV_Error(CV_StsError, error_message);
-    }
-    // Get the height from the first image. We'll need this
-    // later in code to reshape the images to their original
-    // size:
-    int height = images[0].rows;
-    // The following lines simply get the last images from
-    // your dataset and remove it from the vector. This is
-    // done, so that the training data (which we learn the
-    // cv::FaceRecognizer on) and the test data we test
-    // the model with, do not overlap.
-    Mat testSample = images[images.size() - 1];
-    int testLabel = labels[labels.size() - 1];
-    images.pop_back();
-    labels.pop_back();
-    // The following lines create an Eigenfaces model for
-    // face recognition and train it with the images and
-    // labels read from the given CSV file.
-    // This here is a full PCA, if you just want to keep
-    // 10 principal components (read Eigenfaces), then call
-    // the factory method like this:
-    //
-    //      cv::createEigenFaceRecognizer(10);
-    //
-    // If you want to create a FaceRecognizer with a
-    // confidence threshold (e.g. 123.0), call it with:
-    //
-    //      cv::createEigenFaceRecognizer(10, 123.0);
-    //
-    // If you want to use _all_ Eigenfaces and have a threshold,
-    // then call the method like this:
-    //
-    //      cv::createEigenFaceRecognizer(0, 123.0);
-    //
-    Ptr<FaceRecognizer> model0 = createEigenFaceRecognizer();
-    model0->train(images, labels);
-    // save the model to eigenfaces_at.yaml
-    model0->save("eigenfaces_at.yml");
-    //
-    //
-    // Now create a new Eigenfaces Recognizer
-    //
-    Ptr<FaceRecognizer> model1 = createEigenFaceRecognizer();
-    model1->load("eigenfaces_at.yml");
-    // The following line predicts the label of a given
-    // test image:
-    int predictedLabel = model1->predict(testSample);
-    //
-    // To get the confidence of a prediction call the model with:
-    //
-    //      int predictedLabel = -1;
-    //      double confidence = 0.0;
-    //      model->predict(testSample, predictedLabel, confidence);
-    //
-    string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
-    cout << result_message << endl;
-    // Here is how to get the eigenvalues of this Eigenfaces model:
-    Mat eigenvalues = model1->getMat("eigenvalues");
-    // And we can do the same to display the Eigenvectors (read Eigenfaces):
-    Mat W = model1->getMat("eigenvectors");
-    // Get the sample mean from the training data
-    Mat mean = model1->getMat("mean");
-    // Display or save:
-    if(argc == 2) {
-        imshow("mean", norm_0_255(mean.reshape(1, images[0].rows)));
-    } else {
-        imwrite(format("%s/mean.png", output_folder.c_str()), norm_0_255(mean.reshape(1, images[0].rows)));
-    }
-    // Display or save the Eigenfaces:
-    for (int i = 0; i < min(10, W.cols); i++) {
-        string msg = format("Eigenvalue #%d = %.5f", i, eigenvalues.at<double>(i));
-        cout << msg << endl;
-        // get eigenvector #i
-        Mat ev = W.col(i).clone();
-        // Reshape to original size & normalize to [0...255] for imshow.
-        Mat grayscale = norm_0_255(ev.reshape(1, height));
-        // Show the image & apply a Jet colormap for better sensing.
-        Mat cgrayscale;
-        applyColorMap(grayscale, cgrayscale, COLORMAP_JET);
-        // Display or save:
-        if(argc == 2) {
-            imshow(format("eigenface_%d", i), cgrayscale);
-        } else {
-            imwrite(format("%s/eigenface_%d.png", output_folder.c_str(), i), norm_0_255(cgrayscale));
-        }
-    }
-    // Display or save the image reconstruction at some predefined steps:
-    for(int num_components = 10; num_components < 300; num_components+=15) {
-        // slice the eigenvectors from the model
-        Mat evs = Mat(W, Range::all(), Range(0, num_components));
-        Mat projection = subspaceProject(evs, mean, images[0].reshape(1,1));
-        Mat reconstruction = subspaceReconstruct(evs, mean, projection);
-        // Normalize the result:
-        reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
-        // Display or save:
-        if(argc == 2) {
-            imshow(format("eigenface_reconstruction_%d", num_components), reconstruction);
-        } else {
-            imwrite(format("%s/eigenface_reconstruction_%d.png", output_folder.c_str(), num_components), reconstruction);
-        }
-    }
-    // Display if we are not writing to an output folder:
-    if(argc == 2) {
-        waitKey(0);
-    }
-    return 0;
-}
diff --git a/modules/contrib/doc/facerec/src/facerec_video.cpp b/modules/contrib/doc/facerec/src/facerec_video.cpp
deleted file mode 100644 (file)
index c22e416..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>.
- * Released to public domain under terms of the BSD Simplified license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of the organization nor the names of its contributors
- *     may be used to endorse or promote products derived from this software
- *     without specific prior written permission.
- *
- *   See <http://www.opensource.org/licenses/bsd-license>
- */
-
-#include "opencv2/core.hpp"
-#include "opencv2/contrib.hpp"
-#include "opencv2/highgui.hpp"
-#include "opencv2/imgproc.hpp"
-#include "opencv2/objdetect.hpp"
-
-#include <iostream>
-#include <fstream>
-#include <sstream>
-
-using namespace cv;
-using namespace std;
-
-static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
-    std::ifstream file(filename.c_str(), ifstream::in);
-    if (!file) {
-        string error_message = "No valid input file was given, please check the given filename.";
-        CV_Error(CV_StsBadArg, error_message);
-    }
-    string line, path, classlabel;
-    while (getline(file, line)) {
-        stringstream liness(line);
-        getline(liness, path, separator);
-        getline(liness, classlabel);
-        if(!path.empty() && !classlabel.empty()) {
-            images.push_back(imread(path, 0));
-            labels.push_back(atoi(classlabel.c_str()));
-        }
-    }
-}
-
-int main(int argc, const char *argv[]) {
-    // Check for valid command line arguments, print usage
-    // if no arguments were given.
-    if (argc != 4) {
-        cout << "usage: " << argv[0] << " </path/to/haar_cascade> </path/to/csv.ext> </path/to/device id>" << endl;
-        cout << "\t </path/to/haar_cascade> -- Path to the Haar Cascade for face detection." << endl;
-        cout << "\t </path/to/csv.ext> -- Path to the CSV file with the face database." << endl;
-        cout << "\t <device id> -- The webcam device id to grab frames from." << endl;
-        exit(1);
-    }
-    // Get the path to your CSV:
-    string fn_haar = string(argv[1]);
-    string fn_csv = string(argv[2]);
-    int deviceId = atoi(argv[3]);
-    // These vectors hold the images and corresponding labels:
-    vector<Mat> images;
-    vector<int> labels;
-    // Read in the data (fails if no valid input filename is given, but you'll get an error message):
-    try {
-        read_csv(fn_csv, images, labels);
-    } catch (cv::Exception& e) {
-        cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
-        // nothing more we can do
-        exit(1);
-    }
-    // Get the height from the first image. We'll need this
-    // later in code to reshape the images to their original
-    // size AND we need to reshape incoming faces to this size:
-    int im_width = images[0].cols;
-    int im_height = images[0].rows;
-    // Create a FaceRecognizer and train it on the given images:
-    Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
-    model->train(images, labels);
-    // That's it for learning the Face Recognition model. You now
-    // need to create the classifier for the task of Face Detection.
-    // We are going to use the haar cascade you have specified in the
-    // command line arguments:
-    //
-    CascadeClassifier haar_cascade;
-    haar_cascade.load(fn_haar);
-    // Get a handle to the Video device:
-    VideoCapture cap(deviceId);
-    // Check if we can use this device at all:
-    if(!cap.isOpened()) {
-        cerr << "Capture Device ID " << deviceId << "cannot be opened." << endl;
-        return -1;
-    }
-    // Holds the current frame from the Video device:
-    Mat frame;
-    for(;;) {
-        cap >> frame;
-        // Clone the current frame:
-        Mat original = frame.clone();
-        // Convert the current frame to grayscale:
-        Mat gray;
-        cvtColor(original, gray, CV_BGR2GRAY);
-        // Find the faces in the frame:
-        vector< Rect_<int> > faces;
-        haar_cascade.detectMultiScale(gray, faces);
-        // At this point you have the position of the faces in
-        // faces. Now we'll get the faces, make a prediction and
-        // annotate it in the video. Cool or what?
-        for(int i = 0; i < faces.size(); i++) {
-            // Process face by face:
-            Rect face_i = faces[i];
-            // Crop the face from the image. So simple with OpenCV C++:
-            Mat face = gray(face_i);
-            // Resizing the face is necessary for Eigenfaces and Fisherfaces. You can easily
-            // verify this, by reading through the face recognition tutorial coming with OpenCV.
-            // Resizing IS NOT NEEDED for Local Binary Patterns Histograms, so preparing the
-            // input data really depends on the algorithm used.
-            //
-            // I strongly encourage you to play around with the algorithms. See which work best
-            // in your scenario, LBPH should always be a contender for robust face recognition.
-            //
-            // Since I am showing the Fisherfaces algorithm here, I also show how to resize the
-            // face you have just found:
-            Mat face_resized;
-            cv::resize(face, face_resized, Size(im_width, im_height), 1.0, 1.0, INTER_CUBIC);
-            // Now perform the prediction, see how easy that is:
-            int prediction = model->predict(face_resized);
-            // And finally write all we've found out to the original image!
-            // First of all draw a green rectangle around the detected face:
-            rectangle(original, face_i, CV_RGB(0, 255,0), 1);
-            // Create the text we will annotate the box with:
-            string box_text = format("Prediction = %d", prediction);
-            // Calculate the position for annotated text (make sure we don't
-            // put illegal values in there):
-            int pos_x = std::max(face_i.tl().x - 10, 0);
-            int pos_y = std::max(face_i.tl().y - 10, 0);
-            // And now put it into the image:
-            putText(original, box_text, Point(pos_x, pos_y), FONT_HERSHEY_PLAIN, 1.0, CV_RGB(0,255,0), 2.0);
-        }
-        // Show the result:
-        imshow("face_recognizer", original);
-        // And display it:
-        char key = (char) waitKey(20);
-        // Exit this loop on escape:
-        if(key == 27)
-            break;
-    }
-    return 0;
-}
diff --git a/modules/contrib/doc/facerec/tutorial/facerec_gender_classification.rst b/modules/contrib/doc/facerec/tutorial/facerec_gender_classification.rst
deleted file mode 100644 (file)
index 95c8212..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-Gender Classification with OpenCV
-=================================
-
-.. contents:: Table of Contents
-   :depth: 3
-
-Introduction
-------------
-
-A lot of people interested in face recognition, also want to know how to perform image classification tasks like:
-
-* Gender Classification (Gender Detection)
-* Emotion Classification (Emotion Detection)
-* Glasses Classification (Glasses Detection)
-* ...
-
-This is has become very, very easy with the new :ocv:class:`FaceRecognizer` class. In this tutorial I'll show you how to perform gender classification with OpenCV on a set of face images. You'll also learn how to align your images to enhance the recognition results. If you want to do emotion classification instead of gender classification, all you need to do is to update is your training data and the configuration you pass to the demo.
-
-Prerequisites
---------------
-
-For gender classification of faces, you'll need some images of male and female faces first. I've decided to search faces of celebrities using `Google Images <http://www.google.com/images>`_ with the faces filter turned on (my god, they have great algorithms at `Google <http://www.google.com>`_!). My database has 8 male and 5 female subjects, each with 10 images. Here are the names, if you don't know who to search:
-
-* Angelina Jolie
-* Arnold Schwarzenegger
-* Brad Pitt
-* Emma Watson
-* George Clooney
-* Jennifer Lopez
-* Johnny Depp
-* Justin Timberlake
-* Katy Perry
-* Keanu Reeves
-* Naomi Watts
-* Patrick Stewart
-* Tom Cruise
-
-Once you have acquired some images, you'll need to read them. In the demo application I have decided to read the images from a very simple CSV file. Why? Because it's the simplest platform-independent approach I can think of. However, if you know a simpler solution please ping me about it. Basically all the CSV file needs to contain are lines composed of a ``filename`` followed by a ``;`` followed by the ``label`` (as *integer number*), making up a line like this:
-
-.. code-block:: none
-
-    /path/to/image.ext;0
-
-Let's dissect the line. ``/path/to/image.ext`` is the path to an image, probably something like this if you are in Windows: ``C:/faces/person0/image0.jpg``. Then there is the separator ``;`` and finally we assign a label ``0`` to the image. Think of the label as the subject (the person, the gender or whatever comes to your mind). In the gender classification scenario, the label is the gender the person has. I'll give the label ``0`` to *male* persons and the label ``1`` is for *female* subjects. So my CSV file looks like this:
-
-.. code-block:: none
-
-  /home/philipp/facerec/data/gender/male/keanu_reeves/keanu_reeves_01.jpg;0
-  /home/philipp/facerec/data/gender/male/keanu_reeves/keanu_reeves_02.jpg;0
-  /home/philipp/facerec/data/gender/male/keanu_reeves/keanu_reeves_03.jpg;0
-  ...
-  /home/philipp/facerec/data/gender/female/katy_perry/katy_perry_01.jpg;1
-  /home/philipp/facerec/data/gender/female/katy_perry/katy_perry_02.jpg;1
-  /home/philipp/facerec/data/gender/female/katy_perry/katy_perry_03.jpg;1
-  ...
-  /home/philipp/facerec/data/gender/male/brad_pitt/brad_pitt_01.jpg;0
-  /home/philipp/facerec/data/gender/male/brad_pitt/brad_pitt_02.jpg;0
-  /home/philipp/facerec/data/gender/male/brad_pitt/brad_pitt_03.jpg;0
-  ...
-  /home/philipp/facerec/data/gender/female/emma_watson/emma_watson_08.jpg;1
-  /home/philipp/facerec/data/gender/female/emma_watson/emma_watson_02.jpg;1
-  /home/philipp/facerec/data/gender/female/emma_watson/emma_watson_03.jpg;1
-
-All images for this example were chosen to have a frontal face perspective. They have been cropped, scaled and rotated to be aligned at the eyes, just like this set of George Clooney images:
-
-.. image:: ../img/tutorial/gender_classification/clooney_set.png
-    :align: center
-
-You really don't want to create the CSV file by hand. And you really don't want scale, rotate & translate the images manually. I have prepared you two Python scripts ``create_csv.py`` and ``crop_face.py``, you can find them in the ``src`` folder coming with this documentation. You'll see how to use them in the :ref:`appendixfgc`.
-
-Fisherfaces for Gender Classification
---------------------------------------
-
-If you want to decide whether a person is *male* or *female*, you have to learn the discriminative features of both classes. The Eigenfaces method is based on the Principal Component Analysis, which is an unsupervised statistical model and not suitable for this task. Please see the Face Recognition tutorial for insights into the algorithms. The Fisherfaces instead yields a class-specific linear projection, so it is much better suited for the gender classification task. `http://www.bytefish.de/blog/gender_classification <http://www.bytefish.de/blog/gender_classification>`_  shows the recognition rate of the Fisherfaces method for gender classification.
-
-The Fisherfaces method achieves a 98% recognition rate in a subject-independent cross-validation. A subject-independent cross-validation means *images of the person under test are never used for learning the model*. And could you believe it: you can simply use the facerec_fisherfaces demo, that's inlcuded in OpenCV.
-
-Fisherfaces in OpenCV
----------------------
-
-The source code for this demo application is also available in the ``src`` folder coming with this documentation:
-
-* :download:`src/facerec_fisherfaces.cpp <../src/facerec_fisherfaces.cpp>`
-
-.. literalinclude:: ../src/facerec_fisherfaces.cpp
-   :language: cpp
-   :linenos:
-
-Running the Demo
-----------------
-
-If you are in Windows, then simply start the demo by running (from command line):
-
-.. code-block:: none
-
-    facerec_fisherfaces.exe C:/path/to/your/csv.ext
-
-If you are in Linux, then simply start the demo by running:
-
-.. code-block:: none
-
-    ./facerec_fisherfaces /path/to/your/csv.ext
-
-If you don't want to display the images, but save them, then pass the desired path to the demo. It works like this in Windows:
-
-.. code-block:: none
-
-    facerec_fisherfaces.exe C:/path/to/your/csv.ext C:/path/to/store/results/at
-
-And in Linux:
-
-.. code-block:: none
-
-    ./facerec_fisherfaces /path/to/your/csv.ext /path/to/store/results/at
-
-Results
--------
-
-If you run the program with your CSV file as parameter, you'll see the Fisherface that separates between male and female images. I've decided to apply a Jet colormap in this demo, so you can see which features the method identifies:
-
-.. image:: ../img/tutorial/gender_classification/fisherface_0.png
-
-The demo also shows the average face of the male and female training images you have passed:
-
-.. image:: ../img/tutorial/gender_classification/mean.png
-
-Moreover it the demo should yield the prediction for the correct gender:
-
-.. code-block:: none
-
-    Predicted class = 1 / Actual class = 1.
-
-And for advanced users I have also shown the Eigenvalue for the Fisherface:
-
-.. code-block:: none
-
-    Eigenvalue #0 = 152.49493
-
-And the Fisherfaces reconstruction:
-
-.. image:: ../img/tutorial/gender_classification/fisherface_reconstruction_0.png
-
-I hope this gives you an idea how to approach gender classification and the other image classification tasks.
-
-.. _appendixfgc:
-
-Appendix
---------
-
-Creating the CSV File
-+++++++++++++++++++++
-
-You don't really want to create the CSV file by hand. I have prepared you a little Python script ``create_csv.py`` (you find it at ``/src/create_csv.py`` coming with this tutorial) that automatically creates you a CSV file. If you have your images in hierarchie like this (``/basepath/<subject>/<image.ext>``):
-
-.. code-block:: none
-
-    philipp@mango:~/facerec/data/at$ tree
-    .
-    |-- s1
-    |   |-- 1.pgm
-    |   |-- ...
-    |   |-- 10.pgm
-    |-- s2
-    |   |-- 1.pgm
-    |   |-- ...
-    |   |-- 10.pgm
-    ...
-    |-- s40
-    |   |-- 1.pgm
-    |   |-- ...
-    |   |-- 10.pgm
-
-
-Then simply call ``create_csv.py`` with the path to the folder, just like this and you could save the output:
-
-.. code-block:: none
-
-    philipp@mango:~/facerec/data$ python create_csv.py
-    at/s13/2.pgm;0
-    at/s13/7.pgm;0
-    at/s13/6.pgm;0
-    at/s13/9.pgm;0
-    at/s13/5.pgm;0
-    at/s13/3.pgm;0
-    at/s13/4.pgm;0
-    at/s13/10.pgm;0
-    at/s13/8.pgm;0
-    at/s13/1.pgm;0
-    at/s17/2.pgm;1
-    at/s17/7.pgm;1
-    at/s17/6.pgm;1
-    at/s17/9.pgm;1
-    at/s17/5.pgm;1
-    at/s17/3.pgm;1
-    [...]
-
-Here is the script, if you can't find it:
-
-.. literalinclude:: ../src/create_csv.py
-   :language: python
-   :linenos:
-
-Aligning Face Images
-++++++++++++++++++++
-
-An accurate alignment of your image data is especially important in tasks like emotion detection, were you need as much detail as possible. Believe me... You don't want to do this by hand. So I've prepared you a tiny Python script. The code is really easy to use. To scale, rotate and crop the face image you just need to call *CropFace(image, eye_left, eye_right, offset_pct, dest_sz)*, where:
-
-* *eye_left* is the position of the left eye
-* *eye_right* is the position of the right eye
-* *offset_pct* is the percent of the image you want to keep next to the eyes (horizontal, vertical direction)
-* *dest_sz* is the size of the output image
-
-If you are using the same *offset_pct* and *dest_sz* for your images, they are all aligned at the eyes.
-
-.. literalinclude:: ../src/crop_face.py
-   :language: python
-   :linenos:
-
-Imagine we are given `this photo of Arnold Schwarzenegger <http://en.wikipedia.org/wiki/File:Arnold_Schwarzenegger_edit%28ws%29.jpg>`_, which is under a Public Domain license. The (x,y)-position of the eyes is approximately *(252,364)* for the left and *(420,366)* for the right eye. Now you only need to define the horizontal offset, vertical offset and the size your scaled, rotated & cropped face should have.
-
-Here are some examples:
-
-+---------------------------------+----------------------------------------------------------------------------+
-| Configuration                   | Cropped, Scaled, Rotated Face                                              |
-+=================================+============================================================================+
-| 0.1 (10%), 0.1 (10%), (200,200) | .. image:: ../img/tutorial/gender_classification/arnie_10_10_200_200.jpg   |
-+---------------------------------+----------------------------------------------------------------------------+
-| 0.2 (20%), 0.2 (20%), (200,200) | .. image:: ../img/tutorial/gender_classification/arnie_20_20_200_200.jpg   |
-+---------------------------------+----------------------------------------------------------------------------+
-| 0.3 (30%), 0.3 (30%), (200,200) | .. image:: ../img/tutorial/gender_classification/arnie_30_30_200_200.jpg   |
-+---------------------------------+----------------------------------------------------------------------------+
-| 0.2 (20%), 0.2 (20%), (70,70)   | .. image:: ../img/tutorial/gender_classification/arnie_20_20_70_70.jpg     |
-+---------------------------------+----------------------------------------------------------------------------+
diff --git a/modules/contrib/doc/facerec/tutorial/facerec_save_load.rst b/modules/contrib/doc/facerec/tutorial/facerec_save_load.rst
deleted file mode 100644 (file)
index 2d0b65d..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-Saving and Loading a FaceRecognizer
-===================================
-
-Introduction
-------------
-
-Saving and loading a :ocv:class:`FaceRecognizer` is very important. Training a FaceRecognizer can be a very time-intense task, plus it's often impossible to ship the whole face database to the user of your product. The task of saving and loading a FaceRecognizer is easy with :ocv:class:`FaceRecognizer`. You only have to call :ocv:func:`FaceRecognizer::load` for loading and :ocv:func:`FaceRecognizer::save` for saving a :ocv:class:`FaceRecognizer`.
-
-I'll adapt the Eigenfaces example from the :doc:`../facerec_tutorial`: Imagine we want to learn the Eigenfaces of the `AT&T Facedatabase <http://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html>`_, store the model to a YAML file and then load it again.
-
-From the loaded model, we'll get a prediction, show the mean, Eigenfaces and the image reconstruction.
-
-Using FaceRecognizer::save and FaceRecognizer::load
------------------------------------------------------
-
-The source code for this demo application is also available in the ``src`` folder coming with this documentation:
-
-* :download:`src/facerec_save_load.cpp <../src/facerec_save_load.cpp>`
-
-.. literalinclude:: ../src/facerec_save_load.cpp
-   :language: cpp
-   :linenos:
-
-Results
--------
-
-``eigenfaces_at.yml`` then contains the model state, we'll simply look at the first 10 lines with ``head eigenfaces_at.yml``:
-
-.. code-block:: none
-
-  philipp@mango:~/github/libfacerec-build$ head eigenfaces_at.yml
-  %YAML:1.0
-  num_components: 399
-  mean: !!opencv-matrix
-     rows: 1
-     cols: 10304
-     dt: d
-     data: [ 8.5558897243107765e+01, 8.5511278195488714e+01,
-         8.5854636591478695e+01, 8.5796992481203006e+01,
-         8.5952380952380949e+01, 8.6162907268170414e+01,
-         8.6082706766917283e+01, 8.5776942355889716e+01,
-
-And here is the Reconstruction, which is the same as the original:
-
-.. image:: ../img/eigenface_reconstruction_opencv.png
-    :align: center
diff --git a/modules/contrib/doc/facerec/tutorial/facerec_video_recognition.rst b/modules/contrib/doc/facerec/tutorial/facerec_video_recognition.rst
deleted file mode 100644 (file)
index 76e76ee..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-Face Recognition in Videos with OpenCV
-=======================================
-
-.. contents:: Table of Contents
-   :depth: 3
-
-Introduction
-------------
-
-Whenever you hear the term *face recognition*, you instantly think of surveillance in videos. So performing face recognition in videos (e.g. webcam) is one of the most requested features I have got. I have heard your cries, so here it is. An application, that shows you how to do face recognition in videos! For the face detection part we'll use the awesome :ocv:class:`CascadeClassifier` and we'll use :ocv:class:`FaceRecognizer` for face recognition. This example uses the Fisherfaces method for face recognition, because it is robust against large changes in illumination.
-
-Here is what the final application looks like. As you can see I am only writing the id of the recognized person above the detected face (by the way this id is Arnold Schwarzenegger for my data set):
-
-.. image:: ../img/tutorial/facerec_video/facerec_video.png
-    :align: center
-    :scale: 70%
-
-This demo is a basis for your research and it shows you how to implement face recognition in videos. You probably want to extend the application and make it more sophisticated: You could combine the id with the name, then show the confidence of the prediction, recognize the emotion... and and and. But before you send mails, asking what these Haar-Cascade thing is or what a CSV is: Make sure you have read the entire tutorial. It's all explained in here. If you just want to scroll down to the code, please note:
-
-* The available Haar-Cascades for face detection are located in the ``data`` folder of your OpenCV installation! One of the available Haar-Cascades for face detection is for example ``/path/to/opencv/data/haarcascades/haarcascade_frontalface_default.xml``.
-
-I encourage you to experiment with the application. Play around with the available :ocv:class:`FaceRecognizer` implementations, try the available cascades in OpenCV and see if you can improve your results!
-
-Prerequisites
---------------
-
-You want to do face recognition, so you need some face images to learn a :ocv:class:`FaceRecognizer` on. I have decided to reuse the images from the gender classification example: :doc:`facerec_gender_classification`.
-
-I have the following celebrities in my training data set:
-
-* Angelina Jolie
-* Arnold Schwarzenegger
-* Brad Pitt
-* George Clooney
-* Johnny Depp
-* Justin Timberlake
-* Katy Perry
-* Keanu Reeves
-* Patrick Stewart
-* Tom Cruise
-
-In the demo I have decided to read the images from a very simple CSV file. Why? Because it's the simplest platform-independent approach I can think of. However, if you know a simpler solution please ping me about it. Basically all the CSV file needs to contain are lines composed of a ``filename`` followed by a ``;`` followed by the ``label`` (as *integer number*), making up a line like this:
-
-.. code-block:: none
-
-    /path/to/image.ext;0
-
-Let's dissect the line. ``/path/to/image.ext`` is the path to an image, probably something like this if you are in Windows: ``C:/faces/person0/image0.jpg``. Then there is the separator ``;`` and finally we assign a label ``0`` to the image. Think of the label as the subject (the person, the gender or whatever comes to your mind). In the face recognition scenario, the label is the person this image belongs to. In the gender classification scenario, the label is the gender the person has. So my CSV file looks like this:
-
-.. code-block:: none
-
-    /home/philipp/facerec/data/c/keanu_reeves/keanu_reeves_01.jpg;0
-    /home/philipp/facerec/data/c/keanu_reeves/keanu_reeves_02.jpg;0
-    /home/philipp/facerec/data/c/keanu_reeves/keanu_reeves_03.jpg;0
-    ...
-    /home/philipp/facerec/data/c/katy_perry/katy_perry_01.jpg;1
-    /home/philipp/facerec/data/c/katy_perry/katy_perry_02.jpg;1
-    /home/philipp/facerec/data/c/katy_perry/katy_perry_03.jpg;1
-    ...
-    /home/philipp/facerec/data/c/brad_pitt/brad_pitt_01.jpg;2
-    /home/philipp/facerec/data/c/brad_pitt/brad_pitt_02.jpg;2
-    /home/philipp/facerec/data/c/brad_pitt/brad_pitt_03.jpg;2
-    ...
-    /home/philipp/facerec/data/c1/crop_arnold_schwarzenegger/crop_08.jpg;6
-    /home/philipp/facerec/data/c1/crop_arnold_schwarzenegger/crop_05.jpg;6
-    /home/philipp/facerec/data/c1/crop_arnold_schwarzenegger/crop_02.jpg;6
-    /home/philipp/facerec/data/c1/crop_arnold_schwarzenegger/crop_03.jpg;6
-
-All images for this example were chosen to have a frontal face perspective. They have been cropped, scaled and rotated to be aligned at the eyes, just like this set of George Clooney images:
-
-.. image:: ../img/tutorial/gender_classification/clooney_set.png
-    :align: center
-
-Face Recongition from Videos
------------------------------
-
-The source code for the demo is available in the ``src`` folder coming with this documentation:
-
-* :download:`src/facerec_video.cpp <../src/facerec_video.cpp>`
-
-This demo uses the :ocv:class:`CascadeClassifier`:
-
-.. literalinclude:: ../src/facerec_video.cpp
-   :language: cpp
-   :linenos:
-
-Running the Demo
-----------------
-
-You'll need:
-
-* The path to a valid Haar-Cascade for detecting a face with a :ocv:class:`CascadeClassifier`.
-* The path to a valid CSV File for learning a :ocv:class:`FaceRecognizer`.
-* A webcam and its device id (you don't know the device id? Simply start from 0 on and see what happens).
-
-If you are in Windows, then simply start the demo by running (from command line):
-
-.. code-block:: none
-
-    facerec_video.exe <C:/path/to/your/haar_cascade.xml> <C:/path/to/your/csv.ext> <video device>
-
-If you are in Linux, then simply start the demo by running:
-
-.. code-block:: none
-
-    ./facerec_video </path/to/your/haar_cascade.xml> </path/to/your/csv.ext> <video device>
-
-An example. If the haar-cascade is at ``C:/opencv/data/haarcascades/haarcascade_frontalface_default.xml``, the CSV file is at ``C:/facerec/data/celebrities.txt`` and I have a webcam with deviceId ``1``, then I would call the demo with:
-
-.. code-block:: none
-
-    facerec_video.exe C:/opencv/data/haarcascades/haarcascade_frontalface_default.xml C:/facerec/data/celebrities.txt 1
-
-That's it.
-
-Results
--------
-
-Enjoy!
-
-Appendix
---------
-
-Creating the CSV File
-+++++++++++++++++++++
-
-You don't really want to create the CSV file by hand. I have prepared you a little Python script ``create_csv.py`` (you find it at ``/src/create_csv.py`` coming with this tutorial) that automatically creates you a CSV file. If you have your images in hierarchie like this (``/basepath/<subject>/<image.ext>``):
-
-.. code-block:: none
-
-    philipp@mango:~/facerec/data/at$ tree
-    .
-    |-- s1
-    |   |-- 1.pgm
-    |   |-- ...
-    |   |-- 10.pgm
-    |-- s2
-    |   |-- 1.pgm
-    |   |-- ...
-    |   |-- 10.pgm
-    ...
-    |-- s40
-    |   |-- 1.pgm
-    |   |-- ...
-    |   |-- 10.pgm
-
-
-Then simply call ``create_csv.py`` with the path to the folder, just like this and you could save the output:
-
-.. code-block:: none
-
-    philipp@mango:~/facerec/data$ python create_csv.py
-    at/s13/2.pgm;0
-    at/s13/7.pgm;0
-    at/s13/6.pgm;0
-    at/s13/9.pgm;0
-    at/s13/5.pgm;0
-    at/s13/3.pgm;0
-    at/s13/4.pgm;0
-    at/s13/10.pgm;0
-    at/s13/8.pgm;0
-    at/s13/1.pgm;0
-    at/s17/2.pgm;1
-    at/s17/7.pgm;1
-    at/s17/6.pgm;1
-    at/s17/9.pgm;1
-    at/s17/5.pgm;1
-    at/s17/3.pgm;1
-    [...]
-
-Here is the script, if you can't find it:
-
-.. literalinclude:: ../src/create_csv.py
-   :language: python
-   :linenos:
-
-Aligning Face Images
-++++++++++++++++++++
-
-An accurate alignment of your image data is especially important in tasks like emotion detection, were you need as much detail as possible. Believe me... You don't want to do this by hand. So I've prepared you a tiny Python script. The code is really easy to use. To scale, rotate and crop the face image you just need to call *CropFace(image, eye_left, eye_right, offset_pct, dest_sz)*, where:
-
-* *eye_left* is the position of the left eye
-* *eye_right* is the position of the right eye
-* *offset_pct* is the percent of the image you want to keep next to the eyes (horizontal, vertical direction)
-* *dest_sz* is the size of the output image
-
-If you are using the same *offset_pct* and *dest_sz* for your images, they are all aligned at the eyes.
-
-.. literalinclude:: ../src/crop_face.py
-   :language: python
-   :linenos:
-
-Imagine we are given `this photo of Arnold Schwarzenegger <http://en.wikipedia.org/wiki/File:Arnold_Schwarzenegger_edit%28ws%29.jpg>`_, which is under a Public Domain license. The (x,y)-position of the eyes is approximately *(252,364)* for the left and *(420,366)* for the right eye. Now you only need to define the horizontal offset, vertical offset and the size your scaled, rotated & cropped face should have.
-
-Here are some examples:
-
-+---------------------------------+----------------------------------------------------------------------------+
-| Configuration                   | Cropped, Scaled, Rotated Face                                              |
-+=================================+============================================================================+
-| 0.1 (10%), 0.1 (10%), (200,200) | .. image:: ../img/tutorial/gender_classification/arnie_10_10_200_200.jpg   |
-+---------------------------------+----------------------------------------------------------------------------+
-| 0.2 (20%), 0.2 (20%), (200,200) | .. image:: ../img/tutorial/gender_classification/arnie_20_20_200_200.jpg   |
-+---------------------------------+----------------------------------------------------------------------------+
-| 0.3 (30%), 0.3 (30%), (200,200) | .. image:: ../img/tutorial/gender_classification/arnie_30_30_200_200.jpg   |
-+---------------------------------+----------------------------------------------------------------------------+
-| 0.2 (20%), 0.2 (20%), (70,70)   | .. image:: ../img/tutorial/gender_classification/arnie_20_20_70_70.jpg     |
-+---------------------------------+----------------------------------------------------------------------------+
diff --git a/modules/contrib/doc/openfabmap.rst b/modules/contrib/doc/openfabmap.rst
deleted file mode 100644 (file)
index e2f157a..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-OpenFABMAP
-========================================
-
-.. highlight:: cpp
-
-The openFABMAP package has been integrated into OpenCV from the openFABMAP <http://code.google.com/p/openfabmap/> project [ICRA2011]_. OpenFABMAP is an open and modifiable code-source which implements the Fast Appearance-based Mapping algorithm (FAB-MAP) developed by Mark Cummins and Paul Newman. The algorithms used in openFABMAP were developed using only the relevant FAB-MAP publications.
-
-FAB-MAP is an approach to appearance-based place recognition. FAB-MAP compares images of locations that have been visited and determines the probability of re-visiting a location, as well as providing a measure of the probability of being at a new, previously unvisited location. Camera images form the sole input to the system, from which visual bag-of-words models are formed through the extraction of appearance-based (e.g. SURF) features.
-
-openFABMAP requires training data (e.g. a collection of images from a similar but not identical environment) to construct a visual vocabulary for the visual bag-of-words model, along with a Chow-Liu tree representation of feature likelihood and for use in the Sampled new place method (see below).
-
-.. note::
-
-   * An example using the openFABMAP package can be found at opencv_source_code/samples/cpp/fabmap_sample.cpp
-
-of2::FabMap
---------------------
-
-.. ocv:class:: of2::FabMap
-
-The main FabMap class performs the comparison between visual bags-of-words extracted from one or more images. The FabMap class is instantiated as one of the four inherited FabMap classes (FabMap1, FabMapLUT, FabMapFBO, FabMap2). Each inherited class performs the comparison differently based on algorithm iterations as published (see each class below for specifics). A Chow-Liu tree, detector model parameters and some option flags are common to all Fabmap variants and are supplied on class creation. Training data (visual bag-of-words) is supplied to the class if using the SAMPLED new place method. Test data (visual bag-of-words) is supplied as images to which query bag-of-words are compared against. The common flags are listed below: ::
-
-    enum {
-        MEAN_FIELD,
-        SAMPLED,
-        NAIVE_BAYES,
-        CHOW_LIU,
-        MOTION_MODEL
-    };
-
-#. MEAN_FIELD: Use the Mean Field approximation to determine the new place likelihood (cannot be used for FabMap2).
-#. SAMPLED: Use the Sampled approximation to determine the new place likelihood. Requires training data (see below).
-#. NAIVE_BAYES: Assume a naive Bayes approximation to feature distribution (i.e. all features are independent). Note that a Chow-Liu tree is still required but only the absolute word probabilities are used, feature co-occurrance information is discarded.
-#. CHOW_LIU: Use the full Chow-Liu tree to approximate feature distribution.
-#. MOTION_MODEL: Update the location distribution using the previous distribution as a (weak) prior. Used for matching in sequences (i.e. successive video frames).
-
-Training Data
-++++++++++++++++++++
-
-Training data is required to use the SAMPLED new place method. The SAMPLED method was shown to have improved performance over the alternative MEAN_FIELD method. Training data can be added singularly or as a batch.
-
-.. ocv:function:: virtual void addTraining(const Mat& queryImgDescriptor)
-
-    :param queryImgDescriptor: bag-of-words image descriptors stored as rows in a Mat
-
-.. ocv:function:: virtual void addTraining(const vector<Mat>& queryImgDescriptors)
-
-    :param queryImgDescriptors: a vector containing multiple bag-of-words image descriptors
-
-.. ocv:function:: const vector<Mat>& getTrainingImgDescriptors() const
-
-    Returns a vector containing multiple bag-of-words image descriptors
-
-Test Data
-++++++++++++++++++++
-
-Test Data is the database of images represented using bag-of-words models. When a compare function is called, each query point is compared to the test data.
-
-.. ocv:function:: virtual void add(const Mat& queryImgDescriptor)
-
-    :param queryImgDescriptor: bag-of-words image descriptors stored as rows in a Mat
-
-.. ocv:function:: virtual void add(const vector<Mat>& queryImgDescriptors)
-
-    :param queryImgDescriptors: a vector containing multiple bag-of-words image descriptors
-
-.. ocv:function:: const vector<Mat>& getTestImgDescriptors() const
-
-    Returns a vector containing multiple bag-of-words image descriptors
-
-Image Comparison
-++++++++++++++++++++
-
-Image matching is performed calling the compare function. Query bag-of-words image descriptors are provided and compared to test data added to the FabMap class. Alternatively test data can be provided with the call to compare to which the comparison is performed. Results are written to the 'matches' argument.
-
-.. ocv:function:: void compare(const Mat& queryImgDescriptor, vector<IMatch>& matches, bool addQuery = false, const Mat& mask = Mat())
-
-    :param queryImgDescriptor: bag-of-words image descriptors stored as rows in a Mat
-
-    :param matches: a vector of image match probabilities
-
-    :param addQuery: if true the queryImg Descriptor is added to the test data after the comparison is performed.
-
-    :param mask: *not implemented*
-
-.. ocv:function:: void compare(const Mat& queryImgDescriptor, const Mat& testImgDescriptors, vector<IMatch>& matches, const Mat& mask = Mat())
-
-    :param testImgDescriptors: bag-of-words image descriptors stored as rows in a Mat
-
-.. ocv:function:: void compare(const Mat& queryImgDescriptor, const vector<Mat>& testImgDescriptors, vector<IMatch>& matches, const Mat& mask = Mat())
-
-    :param testImgDescriptors:  a vector of multiple bag-of-words image descriptors
-
-.. ocv:function:: void compare(const vector<Mat>& queryImgDescriptors, vector<IMatch>& matches, bool addQuery = false, const Mat& mask = Mat())
-
-    :param queryImgDescriptors: a vector of multiple bag-of-words image descriptors
-
-.. ocv:function:: void compare(const vector<Mat>& queryImgDescriptors, const vector<Mat>& testImgDescriptors, vector<IMatch>& matches, const Mat& mask = Mat())
-
-
-
-FabMap classes
-++++++++++++++++++++
-
-.. ocv:class:: FabMap1 : public FabMap
-
-The original FAB-MAP algorithm without any computational improvements as published in [IJRR2008]_
-
-.. ocv:function:: FabMap1::FabMap1(const Mat& clTree, double PzGe, double PzGNe, int flags, int numSamples = 0)
-
-    :param clTree: a Chow-Liu tree class
-
-    :param PzGe: the dector model recall. The probability of the feature detector extracting a feature from an object given it is in the scene. This is used to account for detector noise.
-
-    :param PzGNe: the dector model precision. The probability of the feature detector falsing extracting a feature representing an object that is not in the scene.
-
-    :param numSamples: the number of samples to use for the SAMPLED new place calculation
-
-.. ocv:class:: FabMapLUT : public FabMap
-
-The original FAB-MAP algorithm implemented as a look-up table for speed enhancements [ICRA2011]_
-
-.. ocv:function:: FabMapLUT::FabMapLUT(const Mat& clTree, double PzGe, double PzGNe, int flags, int numSamples = 0, int precision = 6)
-
-    :param precision: the precision with which to store the pre-computed likelihoods
-
-.. ocv:class:: FabMapFBO : public FabMap
-
-The accelerated FAB-MAP using a 'fast bail-out' approach as in [TRO2010]_
-
-.. ocv:function:: FabMapFBO::FabMapFBO(const Mat& clTree, double PzGe, double PzGNe, int flags, int numSamples = 0, double rejectionThreshold = 1e-8, double PsGd = 1e-8, int bisectionStart = 512, int bisectionIts = 9)
-
-    :param rejectionThreshold: images are not considered a match when the likelihood falls below the Bennett bound by the amount given by the rejectionThreshold. The threshold provides a speed/accuracy trade-off. A lower bound will be more accurate
-
-    :param PsGd: used to calculate the Bennett bound. Provides a speed/accuracy trade-off. A lower bound will be more accurate
-
-    :param bisectionStart: Used to estimate the bound using the bisection method. Must be larger than the largest expected difference between maximum and minimum image likelihoods
-
-    :param bisectionIts: The number of iterations for which to perform the bisection method
-
-
-.. ocv:class:: FabMap2 : public FabMap
-
-The inverted index FAB-MAP as in [IJRR2010]_. This version of FAB-MAP is the fastest without any loss of accuracy.
-
-.. ocv:function:: FabMap2::FabMap2(const Mat& clTree, double PzGe, double PzGNe, int flags)
-
-.. [IJRR2008] M. Cummins and P. Newman, "FAB-MAP: Probabilistic Localization and Mapping in the Space of Appearance," The International Journal of Robotics Research, vol. 27(6), pp. 647-665, 2008
-
-.. [TRO2010] M. Cummins and P. Newman, "Accelerating FAB-MAP with concentration inequalities," IEEE Transactions on Robotics, vol. 26(6), pp. 1042-1050, 2010
-
-.. [IJRR2010] M. Cummins and P. Newman, "Appearance-only SLAM at large scale with FAB-MAP 2.0," The International Journal of Robotics Research, vol. 30(9), pp. 1100-1123, 2010
-
-.. [ICRA2011] A. Glover, et al., "OpenFABMAP: An Open Source Toolbox for Appearance-based Loop Closure Detection," in IEEE International Conference on Robotics and Automation, St Paul, Minnesota, 2011
-
-of2::IMatch
---------------------
-
-.. ocv:struct:: of2::IMatch
-
-FAB-MAP comparison results are stored in a vector of IMatch structs. Each IMatch structure provides the index of the provided query bag-of-words, the index of the test bag-of-words, the raw log-likelihood of the match (independent of other comparisons), and the match probability (normalised over other comparison likelihoods).
-
-::
-
-    struct IMatch {
-
-        IMatch() :
-            queryIdx(-1), imgIdx(-1), likelihood(-DBL_MAX), match(-DBL_MAX) {
-        }
-        IMatch(int _queryIdx, int _imgIdx, double _likelihood, double _match) :
-            queryIdx(_queryIdx), imgIdx(_imgIdx), likelihood(_likelihood), match(
-                    _match) {
-        }
-
-        int queryIdx;    //query index
-        int imgIdx;      //test index
-
-        double likelihood;  //raw loglikelihood
-        double match;      //normalised probability
-
-        bool operator<(const IMatch& m) const {
-            return match < m.match;
-        }
-
-    };
-
-of2::ChowLiuTree
---------------------
-
-.. ocv:class:: of2::ChowLiuTree
-
-The Chow-Liu tree is a probabilistic model of the environment in terms of feature occurance and co-occurance. The Chow-Liu tree is a form of Bayesian network. FAB-MAP uses the model when calculating bag-of-words similarity by taking into account feature saliency. Training data is provided to the ChowLiuTree class in the form of bag-of-words image descriptors. The make function produces a cv::Mat that encodes the tree structure.
-
-.. ocv:function:: of2::ChowLiuTree::ChowLiuTree()
-
-.. ocv:function:: void of2::ChowLiuTree::add(const Mat& imgDescriptor)
-
-    :param imgDescriptor:  bag-of-words image descriptors stored as rows in a Mat
-
-.. ocv:function:: void of2::ChowLiuTree::add(const vector<Mat>& imgDescriptors)
-
-    :param imgDescriptors: a vector containing multiple bag-of-words image descriptors
-
-.. ocv:function:: const vector<Mat>& of2::ChowLiuTree::getImgDescriptors() const
-
-    Returns a vector containing multiple bag-of-words image descriptors
-
-.. ocv:function:: Mat of2::ChowLiuTree::make(double infoThreshold = 0.0)
-
-    :param infoThreshold: a threshold can be set to reduce the amount of memory used when making the Chow-Liu tree, which can occur with large vocabulary sizes. This function can fail if the threshold is set too high. If memory is an issue the value must be set by trial and error (~0.0005)
-
-
-of2::BOWMSCTrainer
---------------------
-
-.. ocv:class:: of2::BOWMSCTrainer : public of2::BOWTrainer
-
-BOWMSCTrainer is a custom clustering algorithm used to produce the feature vocabulary required to create bag-of-words representations. The algorithm is an implementation of [AVC2007]_. Arguments against using K-means for the FAB-MAP algorithm are discussed in [IJRR2010]_. The BOWMSCTrainer inherits from the cv::BOWTrainer class, overwriting the cluster function.
-
-.. ocv:function::   of2::BOWMSCTrainer::BOWMSCTrainer(double clusterSize = 0.4)
-
-    :param clusterSize: the specificity of the vocabulary produced. A smaller cluster size will instigate a larger vocabulary.
-
-.. ocv:function::  virtual Mat of2::BOWMSCTrainer::cluster() const
-
-Cluster using features added to the class
-
-.. ocv:function:: virtual Mat of2::BOWMSCTrainer::cluster(const Mat& descriptors) const
-
-    :param descriptors: feature descriptors provided as rows of the Mat.
-
-.. [AVC2007] Alexandra Teynor and Hans Burkhardt, "Fast Codebook Generation by Sequential Data Analysis for Object Classification", in Advances in Visual Computing, pp. 610-620, 2007
diff --git a/modules/contrib/doc/stereo.rst b/modules/contrib/doc/stereo.rst
deleted file mode 100644 (file)
index 103bd0f..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-Stereo Correspondence
-========================================
-
-.. highlight:: cpp
-
-StereoVar
-----------
-
-.. ocv:class:: StereoVar
-
-Class for computing stereo correspondence using the variational matching algorithm ::
-
-    class StereoVar
-    {
-        StereoVar();
-        StereoVar(    int levels, double pyrScale,
-                                        int nIt, int minDisp, int maxDisp,
-                                        int poly_n, double poly_sigma, float fi,
-                                        float lambda, int penalization, int cycle,
-                                        int flags);
-        virtual ~StereoVar();
-
-        virtual void operator()(InputArray left, InputArray right, OutputArray disp);
-
-        int        levels;
-        double    pyrScale;
-        int        nIt;
-        int        minDisp;
-        int        maxDisp;
-        int        poly_n;
-        double    poly_sigma;
-        float    fi;
-        float    lambda;
-        int        penalization;
-        int        cycle;
-        int        flags;
-
-        ...
-    };
-
-The class implements the modified S. G. Kosov algorithm [Publication] that differs from the original one as follows:
-
- * The automatic initialization of method's parameters is added.
-
- * The method of Smart Iteration Distribution (SID) is implemented.
-
- * The support of Multi-Level Adaptation Technique (MLAT) is not included.
-
- * The method of dynamic adaptation of method's parameters is not included.
-
-StereoVar::StereoVar
---------------------------
-
-.. ocv:function:: StereoVar::StereoVar()
-
-.. ocv:function:: StereoVar::StereoVar( int levels, double pyrScale, int nIt, int minDisp, int maxDisp, int poly_n, double poly_sigma, float fi, float lambda, int penalization, int cycle, int flags )
-
-    The constructor
-
-    :param levels: The number of pyramid layers, including the initial image. levels=1 means that no extra layers are created and only the original images are used. This parameter is ignored if flag USE_AUTO_PARAMS is set.
-
-    :param pyrScale: Specifies the image scale (<1) to build the pyramids for each image. pyrScale=0.5 means the classical pyramid, where each next layer is twice smaller than the previous. (This parameter is ignored if flag USE_AUTO_PARAMS is set).
-
-    :param nIt: The number of iterations the algorithm does at each pyramid level. (If the flag USE_SMART_ID is set, the number of iterations will be redistributed in such a way, that more iterations will be done on more coarser levels.)
-
-    :param minDisp: Minimum possible disparity value. Could be negative in case the left and right input images change places.
-
-    :param maxDisp: Maximum possible disparity value.
-
-    :param poly_n: Size of the pixel neighbourhood used to find polynomial expansion in each pixel. The larger values mean that the image will be approximated with smoother surfaces, yielding more robust algorithm and more blurred motion field. Typically, poly_n = 3, 5 or 7
-
-    :param poly_sigma: Standard deviation of the Gaussian that is used to smooth derivatives that are used as a basis for the polynomial expansion. For poly_n=5 you can set poly_sigma=1.1 , for poly_n=7 a good value would be poly_sigma=1.5
-
-    :param fi: The smoothness parameter, ot the weight coefficient for the smoothness term.
-
-    :param lambda: The threshold parameter for edge-preserving smoothness. (This parameter is ignored if PENALIZATION_CHARBONNIER or PENALIZATION_PERONA_MALIK is used.)
-
-    :param penalization: Possible values: PENALIZATION_TICHONOV - linear smoothness; PENALIZATION_CHARBONNIER - non-linear edge preserving smoothness; PENALIZATION_PERONA_MALIK - non-linear edge-enhancing smoothness. (This parameter is ignored if flag USE_AUTO_PARAMS is set).
-
-    :param cycle: Type of the multigrid cycle. Possible values: CYCLE_O and CYCLE_V for null- and v-cycles respectively. (This parameter is ignored if flag USE_AUTO_PARAMS is set).
-
-    :param flags: The operation flags; can be a combination of the following:
-
-        * USE_INITIAL_DISPARITY: Use the input flow as the initial flow approximation.
-
-        * USE_EQUALIZE_HIST: Use the histogram equalization in the pre-processing phase.
-
-        * USE_SMART_ID: Use the smart iteration distribution (SID).
-
-        * USE_AUTO_PARAMS: Allow the method to initialize the main parameters.
-
-        * USE_MEDIAN_FILTERING: Use the median filer of the solution in the post processing phase.
-
-The first constructor initializes ``StereoVar`` with all the default parameters. So, you only have to set ``StereoVar::maxDisp`` and / or ``StereoVar::minDisp`` at minimum. The second constructor enables you to set each parameter to a custom value.
-
-
-
-StereoVar::operator ()
------------------------
-
-.. ocv:function:: void StereoVar::operator()( const Mat& left, const Mat& right, Mat& disp )
-
-    Computes disparity using the variational algorithm for a rectified stereo pair.
-
-    :param left: Left 8-bit single-channel or 3-channel image.
-
-    :param right: Right image of the same size and the same type as the left one.
-
-    :param disp: Output disparity map. It is a 8-bit signed single-channel image of the same size as the input image.
-
-The method executes the variational algorithm on a rectified stereo pair. See ``stereo_match.cpp`` OpenCV sample on how to prepare images and call the method.
-
-**Note**:
-
-The method is not constant, so you should not use the same ``StereoVar`` instance from different threads simultaneously.
diff --git a/modules/contrib/include/opencv2/contrib.hpp b/modules/contrib/include/opencv2/contrib.hpp
deleted file mode 100644 (file)
index 1770c0b..0000000
+++ /dev/null
@@ -1,638 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_CONTRIB_HPP__
-#define __OPENCV_CONTRIB_HPP__
-
-#include "opencv2/core.hpp"
-#include "opencv2/imgproc.hpp"
-#include "opencv2/features2d.hpp"
-#include "opencv2/objdetect.hpp"
-
-namespace cv
-{
-class CV_EXPORTS Octree
-{
-public:
-    struct Node
-    {
-        Node() { memset(this, 0, sizeof(Node)); }
-        int begin, end;
-        float x_min, x_max, y_min, y_max, z_min, z_max;
-        int maxLevels;
-        bool isLeaf;
-        int children[8];
-    };
-
-    Octree();
-    Octree( const std::vector<Point3f>& points, int maxLevels = 10, int minPoints = 20 );
-    virtual ~Octree();
-
-    virtual void buildTree( const std::vector<Point3f>& points, int maxLevels = 10, int minPoints = 20 );
-    virtual void getPointsWithinSphere( const Point3f& center, float radius,
-                                       std::vector<Point3f>& points ) const;
-    const std::vector<Node>& getNodes() const { return nodes; }
-private:
-    int minPoints;
-    std::vector<Point3f> points;
-    std::vector<Node> nodes;
-
-    virtual void buildNext(size_t node_ind);
-};
-
-
-class CV_EXPORTS Mesh3D
-{
-public:
-    struct EmptyMeshException {};
-
-    Mesh3D();
-    Mesh3D(const std::vector<Point3f>& vtx);
-    ~Mesh3D();
-
-    void buildOctree();
-    void clearOctree();
-    float estimateResolution(float tryRatio = 0.1f);
-    void computeNormals(float normalRadius, int minNeighbors = 20);
-    void computeNormals(const std::vector<int>& subset, float normalRadius, int minNeighbors = 20);
-
-    void writeAsVrml(const String& file, const std::vector<Scalar>& colors = std::vector<Scalar>()) const;
-
-    std::vector<Point3f> vtx;
-    std::vector<Point3f> normals;
-    float resolution;
-    Octree octree;
-
-    const static Point3f allzero;
-};
-
-class CV_EXPORTS SpinImageModel
-{
-public:
-
-    /* model parameters, leave unset for default or auto estimate */
-    float normalRadius;
-    int minNeighbors;
-
-    float binSize;
-    int imageWidth;
-
-    float lambda;
-    float gamma;
-
-    float T_GeometriccConsistency;
-    float T_GroupingCorespondances;
-
-    /* public interface */
-    SpinImageModel();
-    explicit SpinImageModel(const Mesh3D& mesh);
-    ~SpinImageModel();
-
-    void selectRandomSubset(float ratio);
-    void setSubset(const std::vector<int>& subset);
-    void compute();
-
-    void match(const SpinImageModel& scene, std::vector< std::vector<Vec2i> >& result);
-
-    Mat packRandomScaledSpins(bool separateScale = false, size_t xCount = 10, size_t yCount = 10) const;
-
-    size_t getSpinCount() const { return spinImages.rows; }
-    Mat getSpinImage(size_t index) const { return spinImages.row((int)index); }
-    const Point3f& getSpinVertex(size_t index) const { return mesh.vtx[subset[index]]; }
-    const Point3f& getSpinNormal(size_t index) const { return mesh.normals[subset[index]]; }
-
-    const Mesh3D& getMesh() const { return mesh; }
-    Mesh3D& getMesh() { return mesh; }
-
-    /* static utility functions */
-    static bool spinCorrelation(const Mat& spin1, const Mat& spin2, float lambda, float& result);
-
-    static Point2f calcSpinMapCoo(const Point3f& point, const Point3f& vertex, const Point3f& normal);
-
-    static float geometricConsistency(const Point3f& pointScene1, const Point3f& normalScene1,
-                                      const Point3f& pointModel1, const Point3f& normalModel1,
-                                      const Point3f& pointScene2, const Point3f& normalScene2,
-                                      const Point3f& pointModel2, const Point3f& normalModel2);
-
-    static float groupingCreteria(const Point3f& pointScene1, const Point3f& normalScene1,
-                                  const Point3f& pointModel1, const Point3f& normalModel1,
-                                  const Point3f& pointScene2, const Point3f& normalScene2,
-                                  const Point3f& pointModel2, const Point3f& normalModel2,
-                                  float gamma);
-protected:
-    void defaultParams();
-
-    void matchSpinToModel(const Mat& spin, std::vector<int>& indeces,
-                          std::vector<float>& corrCoeffs, bool useExtremeOutliers = true) const;
-
-    void repackSpinImages(const std::vector<uchar>& mask, Mat& spinImages, bool reAlloc = true) const;
-
-    std::vector<int> subset;
-    Mesh3D mesh;
-    Mat spinImages;
-};
-
-class CV_EXPORTS TickMeter
-{
-public:
-    TickMeter();
-    void start();
-    void stop();
-
-    int64 getTimeTicks() const;
-    double getTimeMicro() const;
-    double getTimeMilli() const;
-    double getTimeSec()   const;
-    int64 getCounter() const;
-
-    void reset();
-private:
-    int64 counter;
-    int64 sumTime;
-    int64 startTime;
-};
-
-//CV_EXPORTS std::ostream& operator<<(std::ostream& out, const TickMeter& tm);
-
-class CV_EXPORTS SelfSimDescriptor
-{
-public:
-    SelfSimDescriptor();
-    SelfSimDescriptor(int _ssize, int _lsize,
-                      int _startDistanceBucket=DEFAULT_START_DISTANCE_BUCKET,
-                      int _numberOfDistanceBuckets=DEFAULT_NUM_DISTANCE_BUCKETS,
-                      int _nangles=DEFAULT_NUM_ANGLES);
-    SelfSimDescriptor(const SelfSimDescriptor& ss);
-    virtual ~SelfSimDescriptor();
-    SelfSimDescriptor& operator = (const SelfSimDescriptor& ss);
-
-    size_t getDescriptorSize() const;
-    Size getGridSize( Size imgsize, Size winStride ) const;
-
-    virtual void compute(const Mat& img, std::vector<float>& descriptors, Size winStride=Size(),
-                         const std::vector<Point>& locations=std::vector<Point>()) const;
-    virtual void computeLogPolarMapping(Mat& mappingMask) const;
-    virtual void SSD(const Mat& img, Point pt, Mat& ssd) const;
-
-    int smallSize;
-    int largeSize;
-    int startDistanceBucket;
-    int numberOfDistanceBuckets;
-    int numberOfAngles;
-
-    enum { DEFAULT_SMALL_SIZE = 5, DEFAULT_LARGE_SIZE = 41,
-        DEFAULT_NUM_ANGLES = 20, DEFAULT_START_DISTANCE_BUCKET = 3,
-        DEFAULT_NUM_DISTANCE_BUCKETS = 7 };
-};
-
-
-CV_EXPORTS_W int chamerMatching( Mat& img, Mat& templ,
-                              CV_OUT std::vector<std::vector<Point> >& results, CV_OUT std::vector<float>& cost,
-                              double templScale=1, int maxMatches = 20,
-                              double minMatchDistance = 1.0, int padX = 3,
-                              int padY = 3, int scales = 5, double minScale = 0.6, double maxScale = 1.6,
-                              double orientationWeight = 0.5, double truncate = 20);
-
-
-class CV_EXPORTS_W StereoVar
-{
-public:
-    // Flags
-    enum {USE_INITIAL_DISPARITY = 1, USE_EQUALIZE_HIST = 2, USE_SMART_ID = 4, USE_AUTO_PARAMS = 8, USE_MEDIAN_FILTERING = 16};
-    enum {CYCLE_O, CYCLE_V};
-    enum {PENALIZATION_TICHONOV, PENALIZATION_CHARBONNIER, PENALIZATION_PERONA_MALIK};
-
-    //! the default constructor
-    CV_WRAP StereoVar();
-
-    //! the full constructor taking all the necessary algorithm parameters
-    CV_WRAP StereoVar(int levels, double pyrScale, int nIt, int minDisp, int maxDisp, int poly_n, double poly_sigma, float fi, float lambda, int penalization, int cycle, int flags);
-
-    //! the destructor
-    virtual ~StereoVar();
-
-    //! the stereo correspondence operator that computes disparity map for the specified rectified stereo pair
-    CV_WRAP_AS(compute) virtual void operator()(const Mat& left, const Mat& right, CV_OUT Mat& disp);
-
-    CV_PROP_RW int      levels;
-    CV_PROP_RW double   pyrScale;
-    CV_PROP_RW int      nIt;
-    CV_PROP_RW int      minDisp;
-    CV_PROP_RW int      maxDisp;
-    CV_PROP_RW int      poly_n;
-    CV_PROP_RW double   poly_sigma;
-    CV_PROP_RW float    fi;
-    CV_PROP_RW float    lambda;
-    CV_PROP_RW int      penalization;
-    CV_PROP_RW int      cycle;
-    CV_PROP_RW int      flags;
-
-private:
-    void autoParams();
-    void FMG(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level);
-    void VCycle_MyFAS(Mat &I1_h, Mat &I2_h, Mat &I2x_h, Mat &u_h, int level);
-    void VariationalSolver(Mat &I1_h, Mat &I2_h, Mat &I2x_h, Mat &u_h, int level);
-};
-
-CV_EXPORTS void polyfit(const Mat& srcx, const Mat& srcy, Mat& dst, int order);
-
-class CV_EXPORTS Directory
-{
-    public:
-        static std::vector<String> GetListFiles  ( const String& path, const String & exten = "*", bool addPath = true );
-        static std::vector<String> GetListFilesR ( const String& path, const String & exten = "*", bool addPath = true );
-        static std::vector<String> GetListFolders( const String& path, const String & exten = "*", bool addPath = true );
-};
-
-/*
- * Generation of a set of different colors by the following way:
- * 1) generate more then need colors (in "factor" times) in RGB,
- * 2) convert them to Lab,
- * 3) choose the needed count of colors from the set that are more different from
- *    each other,
- * 4) convert the colors back to RGB
- */
-CV_EXPORTS void generateColors( std::vector<Scalar>& colors, size_t count, size_t factor=100 );
-
-
-/*
- *  Estimate the rigid body motion from frame0 to frame1. The method is based on the paper
- *  "Real-Time Visual Odometry from Dense RGB-D Images", F. Steinbucker, J. Strum, D. Cremers, ICCV, 2011.
- */
-enum { ROTATION          = 1,
-       TRANSLATION       = 2,
-       RIGID_BODY_MOTION = 4
-     };
-CV_EXPORTS bool RGBDOdometry( Mat& Rt, const Mat& initRt,
-                              const Mat& image0, const Mat& depth0, const Mat& mask0,
-                              const Mat& image1, const Mat& depth1, const Mat& mask1,
-                              const Mat& cameraMatrix, float minDepth=0.f, float maxDepth=4.f, float maxDepthDiff=0.07f,
-                              const std::vector<int>& iterCounts=std::vector<int>(),
-                              const std::vector<float>& minGradientMagnitudes=std::vector<float>(),
-                              int transformType=RIGID_BODY_MOTION );
-
-/**
-*Bilinear interpolation technique.
-*
-*The value of a desired cortical pixel is obtained through a bilinear interpolation of the values
-*of the four nearest neighbouring Cartesian pixels to the center of the RF.
-*The same principle is applied to the inverse transformation.
-*
-*More details can be found in http://dx.doi.org/10.1007/978-3-642-23968-7_5
-*/
-class CV_EXPORTS LogPolar_Interp
-{
-public:
-
-    LogPolar_Interp() {}
-
-    /**
-    *Constructor
-    *\param w the width of the input image
-    *\param h the height of the input image
-    *\param center the transformation center: where the output precision is maximal
-    *\param R the number of rings of the cortical image (default value 70 pixel)
-    *\param ro0 the radius of the blind spot (default value 3 pixel)
-    *\param full \a 1 (default value) means that the retinal image (the inverse transform) is computed within the circumscribing circle.
-    *            \a 0 means that the retinal image is computed within the inscribed circle.
-    *\param S the number of sectors of the cortical image (default value 70 pixel).
-    *         Its value is usually internally computed to obtain a pixel aspect ratio equals to 1.
-    *\param sp \a 1 (default value) means that the parameter \a S is internally computed.
-    *          \a 0 means that the parameter \a S is provided by the user.
-    */
-    LogPolar_Interp(int w, int h, Point2i center, int R=70, double ro0=3.0,
-                    int interp=INTER_LINEAR, int full=1, int S=117, int sp=1);
-    /**
-    *Transformation from Cartesian image to cortical (log-polar) image.
-    *\param source the Cartesian image
-    *\return the transformed image (cortical image)
-    */
-    const Mat to_cortical(const Mat &source);
-    /**
-    *Transformation from cortical image to retinal (inverse log-polar) image.
-    *\param source the cortical image
-    *\return the transformed image (retinal image)
-    */
-    const Mat to_cartesian(const Mat &source);
-    /**
-    *Destructor
-    */
-    ~LogPolar_Interp();
-
-protected:
-
-    Mat Rsri;
-    Mat Csri;
-
-    int S, R, M, N;
-    int top, bottom,left,right;
-    double ro0, romax, a, q;
-    int interp;
-
-    Mat ETAyx;
-    Mat CSIyx;
-
-    void create_map(int M, int N, int R, int S, double ro0);
-};
-
-/**
-*Overlapping circular receptive fields technique
-*
-*The Cartesian plane is divided in two regions: the fovea and the periphery.
-*The fovea (oversampling) is handled by using the bilinear interpolation technique described above, whereas in
-*the periphery we use the overlapping Gaussian circular RFs.
-*
-*More details can be found in http://dx.doi.org/10.1007/978-3-642-23968-7_5
-*/
-class CV_EXPORTS LogPolar_Overlapping
-{
-public:
-    LogPolar_Overlapping() {}
-
-    /**
-    *Constructor
-    *\param w the width of the input image
-    *\param h the height of the input image
-    *\param center the transformation center: where the output precision is maximal
-    *\param R the number of rings of the cortical image (default value 70 pixel)
-    *\param ro0 the radius of the blind spot (default value 3 pixel)
-    *\param full \a 1 (default value) means that the retinal image (the inverse transform) is computed within the circumscribing circle.
-    *            \a 0 means that the retinal image is computed within the inscribed circle.
-    *\param S the number of sectors of the cortical image (default value 70 pixel).
-    *         Its value is usually internally computed to obtain a pixel aspect ratio equals to 1.
-    *\param sp \a 1 (default value) means that the parameter \a S is internally computed.
-    *          \a 0 means that the parameter \a S is provided by the user.
-    */
-    LogPolar_Overlapping(int w, int h, Point2i center, int R=70,
-                         double ro0=3.0, int full=1, int S=117, int sp=1);
-    /**
-    *Transformation from Cartesian image to cortical (log-polar) image.
-    *\param source the Cartesian image
-    *\return the transformed image (cortical image)
-    */
-    const Mat to_cortical(const Mat &source);
-    /**
-    *Transformation from cortical image to retinal (inverse log-polar) image.
-    *\param source the cortical image
-    *\return the transformed image (retinal image)
-    */
-    const Mat to_cartesian(const Mat &source);
-    /**
-    *Destructor
-    */
-    ~LogPolar_Overlapping();
-
-protected:
-
-    Mat Rsri;
-    Mat Csri;
-    std::vector<int> Rsr;
-    std::vector<int> Csr;
-    std::vector<double> Wsr;
-
-    int S, R, M, N, ind1;
-    int top, bottom,left,right;
-    double ro0, romax, a, q;
-
-    struct kernel
-    {
-        kernel() { w = 0; }
-        std::vector<double> weights;
-        int w;
-    };
-
-    Mat ETAyx;
-    Mat CSIyx;
-    std::vector<kernel> w_ker_2D;
-
-    void create_map(int M, int N, int R, int S, double ro0);
-};
-
-/**
-* Adjacent receptive fields technique
-*
-*All the Cartesian pixels, whose coordinates in the cortical domain share the same integer part, are assigned to the same RF.
-*The precision of the boundaries of the RF can be improved by breaking each pixel into subpixels and assigning each of them to the correct RF.
-*This technique is implemented from: Traver, V., Pla, F.: Log-polar mapping template design: From task-level requirements
-*to geometry parameters. Image Vision Comput. 26(10) (2008) 1354-1370
-*
-*More details can be found in http://dx.doi.org/10.1007/978-3-642-23968-7_5
-*/
-class CV_EXPORTS LogPolar_Adjacent
-{
-public:
-    LogPolar_Adjacent() {}
-
-    /**
-     *Constructor
-     *\param w the width of the input image
-     *\param h the height of the input image
-     *\param center the transformation center: where the output precision is maximal
-     *\param R the number of rings of the cortical image (default value 70 pixel)
-     *\param ro0 the radius of the blind spot (default value 3 pixel)
-     *\param smin the size of the subpixel (default value 0.25 pixel)
-     *\param full \a 1 (default value) means that the retinal image (the inverse transform) is computed within the circumscribing circle.
-     *            \a 0 means that the retinal image is computed within the inscribed circle.
-     *\param S the number of sectors of the cortical image (default value 70 pixel).
-     *         Its value is usually internally computed to obtain a pixel aspect ratio equals to 1.
-     *\param sp \a 1 (default value) means that the parameter \a S is internally computed.
-     *          \a 0 means that the parameter \a S is provided by the user.
-     */
-    LogPolar_Adjacent(int w, int h, Point2i center, int R=70, double ro0=3.0, double smin=0.25, int full=1, int S=117, int sp=1);
-    /**
-     *Transformation from Cartesian image to cortical (log-polar) image.
-     *\param source the Cartesian image
-     *\return the transformed image (cortical image)
-     */
-    const Mat to_cortical(const Mat &source);
-    /**
-     *Transformation from cortical image to retinal (inverse log-polar) image.
-     *\param source the cortical image
-     *\return the transformed image (retinal image)
-     */
-    const Mat to_cartesian(const Mat &source);
-    /**
-     *Destructor
-     */
-    ~LogPolar_Adjacent();
-
-protected:
-    struct pixel
-    {
-        pixel() { u = v = 0; a = 0.; }
-        int u;
-        int v;
-        double a;
-    };
-    int S, R, M, N;
-    int top, bottom,left,right;
-    double ro0, romax, a, q;
-    std::vector<std::vector<pixel> > L;
-    std::vector<double> A;
-
-    void subdivide_recursively(double x, double y, int i, int j, double length, double smin);
-    bool get_uv(double x, double y, int&u, int&v);
-    void create_map(int M, int N, int R, int S, double ro0, double smin);
-};
-
-CV_EXPORTS Mat subspaceProject(InputArray W, InputArray mean, InputArray src);
-CV_EXPORTS Mat subspaceReconstruct(InputArray W, InputArray mean, InputArray src);
-
-class CV_EXPORTS LDA
-{
-public:
-    // Initializes a LDA with num_components (default 0) and specifies how
-    // samples are aligned (default dataAsRow=true).
-    LDA(int num_components = 0) :
-        _num_components(num_components) { }
-
-    // Initializes and performs a Discriminant Analysis with Fisher's
-    // Optimization Criterion on given data in src and corresponding labels
-    // in labels. If 0 (or less) number of components are given, they are
-    // automatically determined for given data in computation.
-    LDA(InputArrayOfArrays src, InputArray labels,
-            int num_components = 0) :
-                _num_components(num_components)
-    {
-        this->compute(src, labels); //! compute eigenvectors and eigenvalues
-    }
-
-    // Serializes this object to a given filename.
-    void save(const String& filename) const;
-
-    // Deserializes this object from a given filename.
-    void load(const String& filename);
-
-    // Serializes this object to a given cv::FileStorage.
-    void save(FileStorage& fs) const;
-
-        // Deserializes this object from a given cv::FileStorage.
-    void load(const FileStorage& node);
-
-    // Destructor.
-    ~LDA() {}
-
-    //! Compute the discriminants for data in src and labels.
-    void compute(InputArrayOfArrays src, InputArray labels);
-
-    // Projects samples into the LDA subspace.
-    Mat project(InputArray src);
-
-    // Reconstructs projections from the LDA subspace.
-    Mat reconstruct(InputArray src);
-
-    // Returns the eigenvectors of this LDA.
-    Mat eigenvectors() const { return _eigenvectors; }
-
-    // Returns the eigenvalues of this LDA.
-    Mat eigenvalues() const { return _eigenvalues; }
-
-protected:
-    bool _dataAsRow;
-    int _num_components;
-    Mat _eigenvectors;
-    Mat _eigenvalues;
-
-    void lda(InputArrayOfArrays src, InputArray labels);
-};
-
-class CV_EXPORTS_W FaceRecognizer : public Algorithm
-{
-public:
-    //! virtual destructor
-    virtual ~FaceRecognizer() {}
-
-    // Trains a FaceRecognizer.
-    CV_WRAP virtual void train(InputArrayOfArrays src, InputArray labels) = 0;
-
-    // Updates a FaceRecognizer.
-    CV_WRAP virtual void update(InputArrayOfArrays src, InputArray labels);
-
-    // Gets a prediction from a FaceRecognizer.
-    virtual int predict(InputArray src) const = 0;
-
-    // Predicts the label and confidence for a given sample.
-    CV_WRAP virtual void predict(InputArray src, CV_OUT int &label, CV_OUT double &confidence) const = 0;
-
-    // Serializes this object to a given filename.
-    CV_WRAP virtual void save(const String& filename) const;
-
-    // Deserializes this object from a given filename.
-    CV_WRAP virtual void load(const String& filename);
-
-    // Serializes this object to a given cv::FileStorage.
-    virtual void save(FileStorage& fs) const = 0;
-
-    // Deserializes this object from a given cv::FileStorage.
-    virtual void load(const FileStorage& fs) = 0;
-
-};
-
-CV_EXPORTS_W Ptr<FaceRecognizer> createEigenFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
-CV_EXPORTS_W Ptr<FaceRecognizer> createFisherFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
-CV_EXPORTS_W Ptr<FaceRecognizer> createLBPHFaceRecognizer(int radius=1, int neighbors=8,
-                                                        int grid_x=8, int grid_y=8, double threshold = DBL_MAX);
-
-enum
-{
-    COLORMAP_AUTUMN = 0,
-    COLORMAP_BONE = 1,
-    COLORMAP_JET = 2,
-    COLORMAP_WINTER = 3,
-    COLORMAP_RAINBOW = 4,
-    COLORMAP_OCEAN = 5,
-    COLORMAP_SUMMER = 6,
-    COLORMAP_SPRING = 7,
-    COLORMAP_COOL = 8,
-    COLORMAP_HSV = 9,
-    COLORMAP_PINK = 10,
-    COLORMAP_HOT = 11
-};
-
-CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, int colormap);
-
-CV_EXPORTS bool initModule_contrib();
-}
-
-#include "opencv2/contrib/openfabmap.hpp"
-
-#endif
diff --git a/modules/contrib/include/opencv2/contrib/compat.hpp b/modules/contrib/include/opencv2/contrib/compat.hpp
deleted file mode 100644 (file)
index ba758c2..0000000
+++ /dev/null
@@ -1,384 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_CONTRIB_COMPAT_HPP__
-#define __OPENCV_CONTRIB_COMPAT_HPP__
-
-#include "opencv2/core/core_c.h"
-
-#ifdef __cplusplus
-
-/****************************************************************************************\
-*                                   Adaptive Skin Detector                               *
-\****************************************************************************************/
-
-class CV_EXPORTS CvAdaptiveSkinDetector
-{
-private:
-    enum {
-        GSD_HUE_LT = 3,
-        GSD_HUE_UT = 33,
-        GSD_INTENSITY_LT = 15,
-        GSD_INTENSITY_UT = 250
-    };
-
-    class CV_EXPORTS Histogram
-    {
-    private:
-        enum {
-            HistogramSize = (GSD_HUE_UT - GSD_HUE_LT + 1)
-        };
-
-    protected:
-        int findCoverageIndex(double surfaceToCover, int defaultValue = 0);
-
-    public:
-        CvHistogram *fHistogram;
-        Histogram();
-        virtual ~Histogram();
-
-        void findCurveThresholds(int &x1, int &x2, double percent = 0.05);
-        void mergeWith(Histogram *source, double weight);
-    };
-
-    int nStartCounter, nFrameCount, nSkinHueLowerBound, nSkinHueUpperBound, nMorphingMethod, nSamplingDivider;
-    double fHistogramMergeFactor, fHuePercentCovered;
-    Histogram histogramHueMotion, skinHueHistogram;
-    IplImage *imgHueFrame, *imgSaturationFrame, *imgLastGrayFrame, *imgMotionFrame, *imgFilteredFrame;
-    IplImage *imgShrinked, *imgTemp, *imgGrayFrame, *imgHSVFrame;
-
-protected:
-    void initData(IplImage *src, int widthDivider, int heightDivider);
-    void adaptiveFilter();
-
-public:
-
-    enum {
-        MORPHING_METHOD_NONE = 0,
-        MORPHING_METHOD_ERODE = 1,
-        MORPHING_METHOD_ERODE_ERODE = 2,
-        MORPHING_METHOD_ERODE_DILATE = 3
-    };
-
-    CvAdaptiveSkinDetector(int samplingDivider = 1, int morphingMethod = MORPHING_METHOD_NONE);
-    virtual ~CvAdaptiveSkinDetector();
-
-    virtual void process(IplImage *inputBGRImage, IplImage *outputHueMask);
-};
-
-
-/****************************************************************************************\
- *                                  Fuzzy MeanShift Tracker                               *
- \****************************************************************************************/
-
-class CV_EXPORTS CvFuzzyPoint {
-public:
-    double x, y, value;
-
-    CvFuzzyPoint(double _x, double _y);
-};
-
-class CV_EXPORTS CvFuzzyCurve {
-private:
-    std::vector<CvFuzzyPoint> points;
-    double value, centre;
-
-    bool between(double x, double x1, double x2);
-
-public:
-    CvFuzzyCurve();
-    ~CvFuzzyCurve();
-
-    void setCentre(double _centre);
-    double getCentre();
-    void clear();
-    void addPoint(double x, double y);
-    double calcValue(double param);
-    double getValue();
-    void setValue(double _value);
-};
-
-class CV_EXPORTS CvFuzzyFunction {
-public:
-    std::vector<CvFuzzyCurve> curves;
-
-    CvFuzzyFunction();
-    ~CvFuzzyFunction();
-    void addCurve(CvFuzzyCurve *curve, double value = 0);
-    void resetValues();
-    double calcValue();
-    CvFuzzyCurve *newCurve();
-};
-
-class CV_EXPORTS CvFuzzyRule {
-private:
-    CvFuzzyCurve *fuzzyInput1, *fuzzyInput2;
-    CvFuzzyCurve *fuzzyOutput;
-public:
-    CvFuzzyRule();
-    ~CvFuzzyRule();
-    void setRule(CvFuzzyCurve *c1, CvFuzzyCurve *c2, CvFuzzyCurve *o1);
-    double calcValue(double param1, double param2);
-    CvFuzzyCurve *getOutputCurve();
-};
-
-class CV_EXPORTS CvFuzzyController {
-private:
-    std::vector<CvFuzzyRule*> rules;
-public:
-    CvFuzzyController();
-    ~CvFuzzyController();
-    void addRule(CvFuzzyCurve *c1, CvFuzzyCurve *c2, CvFuzzyCurve *o1);
-    double calcOutput(double param1, double param2);
-};
-
-class CV_EXPORTS CvFuzzyMeanShiftTracker
-{
-private:
-    class FuzzyResizer
-    {
-    private:
-        CvFuzzyFunction iInput, iOutput;
-        CvFuzzyController fuzzyController;
-    public:
-        FuzzyResizer();
-        int calcOutput(double edgeDensity, double density);
-    };
-
-    class SearchWindow
-    {
-    public:
-        FuzzyResizer *fuzzyResizer;
-        int x, y;
-        int width, height, maxWidth, maxHeight, ellipseHeight, ellipseWidth;
-        int ldx, ldy, ldw, ldh, numShifts, numIters;
-        int xGc, yGc;
-        long m00, m01, m10, m11, m02, m20;
-        double ellipseAngle;
-        double density;
-        unsigned int depthLow, depthHigh;
-        int verticalEdgeLeft, verticalEdgeRight, horizontalEdgeTop, horizontalEdgeBottom;
-
-        SearchWindow();
-        ~SearchWindow();
-        void setSize(int _x, int _y, int _width, int _height);
-        void initDepthValues(IplImage *maskImage, IplImage *depthMap);
-        bool shift();
-        void extractInfo(IplImage *maskImage, IplImage *depthMap, bool initDepth);
-        void getResizeAttribsEdgeDensityLinear(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh);
-        void getResizeAttribsInnerDensity(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh);
-        void getResizeAttribsEdgeDensityFuzzy(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh);
-        bool meanShift(IplImage *maskImage, IplImage *depthMap, int maxIteration, bool initDepth);
-    };
-
-public:
-    enum TrackingState
-    {
-        tsNone          = 0,
-        tsSearching     = 1,
-        tsTracking      = 2,
-        tsSetWindow     = 3,
-        tsDisabled      = 10
-    };
-
-    enum ResizeMethod {
-        rmEdgeDensityLinear     = 0,
-        rmEdgeDensityFuzzy      = 1,
-        rmInnerDensity          = 2
-    };
-
-    enum {
-        MinKernelMass           = 1000
-    };
-
-    SearchWindow kernel;
-    int searchMode;
-
-private:
-    enum
-    {
-        MaxMeanShiftIteration   = 5,
-        MaxSetSizeIteration     = 5
-    };
-
-    void findOptimumSearchWindow(SearchWindow &searchWindow, IplImage *maskImage, IplImage *depthMap, int maxIteration, int resizeMethod, bool initDepth);
-
-public:
-    CvFuzzyMeanShiftTracker();
-    ~CvFuzzyMeanShiftTracker();
-
-    void track(IplImage *maskImage, IplImage *depthMap, int resizeMethod, bool resetSearch, int minKernelMass = MinKernelMass);
-};
-
-
-namespace cv
-{
-
-typedef bool (*BundleAdjustCallback)(int iteration, double norm_error, void* user_data);
-
-class CV_EXPORTS LevMarqSparse {
-public:
-    LevMarqSparse();
-    LevMarqSparse(int npoints, // number of points
-                  int ncameras, // number of cameras
-                  int nPointParams, // number of params per one point  (3 in case of 3D points)
-                  int nCameraParams, // number of parameters per one camera
-                  int nErrParams, // number of parameters in measurement vector
-                  // for 1 point at one camera (2 in case of 2D projections)
-                  Mat& visibility, // visibility matrix. rows correspond to points, columns correspond to cameras
-                  // 1 - point is visible for the camera, 0 - invisible
-                  Mat& P0, // starting vector of parameters, first cameras then points
-                  Mat& X, // measurements, in order of visibility. non visible cases are skipped
-                  TermCriteria criteria, // termination criteria
-
-                  // callback for estimation of Jacobian matrices
-                  void (*fjac)(int i, int j, Mat& point_params,
-                                         Mat& cam_params, Mat& A, Mat& B, void* data),
-                  // callback for estimation of backprojection errors
-                  void (*func)(int i, int j, Mat& point_params,
-                                         Mat& cam_params, Mat& estim, void* data),
-                  void* data, // user-specific data passed to the callbacks
-                  BundleAdjustCallback cb, void* user_data
-                  );
-
-    virtual ~LevMarqSparse();
-
-    virtual void run( int npoints, // number of points
-                     int ncameras, // number of cameras
-                     int nPointParams, // number of params per one point  (3 in case of 3D points)
-                     int nCameraParams, // number of parameters per one camera
-                     int nErrParams, // number of parameters in measurement vector
-                     // for 1 point at one camera (2 in case of 2D projections)
-                     Mat& visibility, // visibility matrix. rows correspond to points, columns correspond to cameras
-                     // 1 - point is visible for the camera, 0 - invisible
-                     Mat& P0, // starting vector of parameters, first cameras then points
-                     Mat& X, // measurements, in order of visibility. non visible cases are skipped
-                     TermCriteria criteria, // termination criteria
-
-                     // callback for estimation of Jacobian matrices
-                     void (CV_CDECL * fjac)(int i, int j, Mat& point_params,
-                                            Mat& cam_params, Mat& A, Mat& B, void* data),
-                     // callback for estimation of backprojection errors
-                     void (CV_CDECL * func)(int i, int j, Mat& point_params,
-                                            Mat& cam_params, Mat& estim, void* data),
-                     void* data // user-specific data passed to the callbacks
-                     );
-
-    virtual void clear();
-
-    // useful function to do simple bundle adjustment tasks
-    static void bundleAdjust(std::vector<Point3d>& points, // positions of points in global coordinate system (input and output)
-                             const std::vector<std::vector<Point2d> >& imagePoints, // projections of 3d points for every camera
-                             const std::vector<std::vector<int> >& visibility, // visibility of 3d points for every camera
-                             std::vector<Mat>& cameraMatrix, // intrinsic matrices of all cameras (input and output)
-                             std::vector<Mat>& R, // rotation matrices of all cameras (input and output)
-                             std::vector<Mat>& T, // translation vector of all cameras (input and output)
-                             std::vector<Mat>& distCoeffs, // distortion coefficients of all cameras (input and output)
-                             const TermCriteria& criteria=
-                             TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, DBL_EPSILON),
-                             BundleAdjustCallback cb = 0, void* user_data = 0);
-
-public:
-    virtual void optimize(CvMat &_vis); //main function that runs minimization
-
-    //iteratively asks for measurement for visible camera-point pairs
-    void ask_for_proj(CvMat &_vis,bool once=false);
-    //iteratively asks for Jacobians for every camera_point pair
-    void ask_for_projac(CvMat &_vis);
-
-    CvMat* err; //error X-hX
-    double prevErrNorm, errNorm;
-    double lambda;
-    CvTermCriteria criteria;
-    int iters;
-
-    CvMat** U; //size of array is equal to number of cameras
-    CvMat** V; //size of array is equal to number of points
-    CvMat** inv_V_star; //inverse of V*
-
-    CvMat** A;
-    CvMat** B;
-    CvMat** W;
-
-    CvMat* X; //measurement
-    CvMat* hX; //current measurement extimation given new parameter vector
-
-    CvMat* prevP; //current already accepted parameter.
-    CvMat* P; // parameters used to evaluate function with new params
-    // this parameters may be rejected
-
-    CvMat* deltaP; //computed increase of parameters (result of normal system solution )
-
-    CvMat** ea; // sum_i  AijT * e_ij , used as right part of normal equation
-    // length of array is j = number of cameras
-    CvMat** eb; // sum_j  BijT * e_ij , used as right part of normal equation
-    // length of array is i = number of points
-
-    CvMat** Yj; //length of array is i = num_points
-
-    CvMat* S; //big matrix of block Sjk  , each block has size num_cam_params x num_cam_params
-
-    CvMat* JtJ_diag; //diagonal of JtJ,  used to backup diagonal elements before augmentation
-
-    CvMat* Vis_index; // matrix which element is index of measurement for point i and camera j
-
-    int num_cams;
-    int num_points;
-    int num_err_param;
-    int num_cam_param;
-    int num_point_param;
-
-    //target function and jacobian pointers, which needs to be initialized
-    void (*fjac)(int i, int j, Mat& point_params, Mat& cam_params, Mat& A, Mat& B, void* data);
-    void (*func)(int i, int j, Mat& point_params, Mat& cam_params, Mat& estim, void* data);
-
-    void* data;
-
-    BundleAdjustCallback cb;
-    void* user_data;
-};
-
-} // cv
-
-#endif /* __cplusplus */
-
-#endif /* __OPENCV_CONTRIB_COMPAT_HPP__ */
diff --git a/modules/contrib/include/opencv2/contrib/contrib.hpp b/modules/contrib/include/opencv2/contrib/contrib.hpp
deleted file mode 100644 (file)
index b9edf94..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                          License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifdef __OPENCV_BUILD
-#error this is a compatibility header which should not be used inside the OpenCV library
-#endif
-
-#include "opencv2/contrib.hpp"
diff --git a/modules/contrib/include/opencv2/contrib/detection_based_tracker.hpp b/modules/contrib/include/opencv2/contrib/detection_based_tracker.hpp
deleted file mode 100644 (file)
index c11904e..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-#pragma once
-
-#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(__ANDROID__)
-
-#include <opencv2/core.hpp>
-#include <opencv2/objdetect.hpp>
-
-#include <vector>
-
-namespace cv
-{
-class CV_EXPORTS DetectionBasedTracker
-{
-    public:
-        struct Parameters
-        {
-            int maxTrackLifetime;
-            int minDetectionPeriod; //the minimal time between run of the big object detector (on the whole frame) in ms (1000 mean 1 sec), default=0
-
-            Parameters();
-        };
-
-        class IDetector
-        {
-            public:
-                IDetector():
-                    minObjSize(96, 96),
-                    maxObjSize(INT_MAX, INT_MAX),
-                    minNeighbours(2),
-                    scaleFactor(1.1f)
-                {}
-
-                virtual void detect(const cv::Mat& image, std::vector<cv::Rect>& objects) = 0;
-
-                void setMinObjectSize(const cv::Size& min)
-                {
-                    minObjSize = min;
-                }
-                void setMaxObjectSize(const cv::Size& max)
-                {
-                    maxObjSize = max;
-                }
-                cv::Size getMinObjectSize() const
-                {
-                    return minObjSize;
-                }
-                cv::Size getMaxObjectSize() const
-                {
-                    return maxObjSize;
-                }
-                float getScaleFactor()
-                {
-                    return scaleFactor;
-                }
-                void setScaleFactor(float value)
-                {
-                    scaleFactor = value;
-                }
-                int getMinNeighbours()
-                {
-                    return minNeighbours;
-                }
-                void setMinNeighbours(int value)
-                {
-                    minNeighbours = value;
-                }
-                virtual ~IDetector() {}
-
-            protected:
-                cv::Size minObjSize;
-                cv::Size maxObjSize;
-                int minNeighbours;
-                float scaleFactor;
-        };
-
-        DetectionBasedTracker(cv::Ptr<IDetector> mainDetector, cv::Ptr<IDetector> trackingDetector, const Parameters& params);
-        virtual ~DetectionBasedTracker();
-
-        virtual bool run();
-        virtual void stop();
-        virtual void resetTracking();
-
-        virtual void process(const cv::Mat& imageGray);
-
-        bool setParameters(const Parameters& params);
-        const Parameters& getParameters() const;
-
-
-        typedef std::pair<cv::Rect, int> Object;
-        virtual void getObjects(std::vector<cv::Rect>& result) const;
-        virtual void getObjects(std::vector<Object>& result) const;
-
-        enum ObjectStatus
-        {
-            DETECTED_NOT_SHOWN_YET,
-            DETECTED,
-            DETECTED_TEMPORARY_LOST,
-            WRONG_OBJECT
-        };
-        struct ExtObject
-        {
-            int id;
-            cv::Rect location;
-            ObjectStatus status;
-            ExtObject(int _id, cv::Rect _location, ObjectStatus _status)
-                :id(_id), location(_location), status(_status)
-            {
-            }
-        };
-        virtual void getObjects(std::vector<ExtObject>& result) const;
-
-
-        virtual int addObject(const cv::Rect& location); //returns id of the new object
-
-    protected:
-        class SeparateDetectionWork;
-        cv::Ptr<SeparateDetectionWork> separateDetectionWork;
-        friend void* workcycleObjectDetectorFunction(void* p);
-
-        struct InnerParameters
-        {
-            int numLastPositionsToTrack;
-            int numStepsToWaitBeforeFirstShow;
-            int numStepsToTrackWithoutDetectingIfObjectHasNotBeenShown;
-            int numStepsToShowWithoutDetecting;
-
-            float coeffTrackingWindowSize;
-            float coeffObjectSizeToTrack;
-            float coeffObjectSpeedUsingInPrediction;
-
-            InnerParameters();
-        };
-        Parameters parameters;
-        InnerParameters innerParameters;
-
-        struct TrackedObject
-        {
-            typedef std::vector<cv::Rect> PositionsVector;
-
-            PositionsVector lastPositions;
-
-            int numDetectedFrames;
-            int numFramesNotDetected;
-            int id;
-
-            TrackedObject(const cv::Rect& rect):numDetectedFrames(1), numFramesNotDetected(0)
-            {
-                lastPositions.push_back(rect);
-                id=getNextId();
-            };
-
-            static int getNextId()
-            {
-                static int _id=0;
-                return _id++;
-            }
-        };
-
-        int numTrackedSteps;
-        std::vector<TrackedObject> trackedObjects;
-
-        std::vector<float> weightsPositionsSmoothing;
-        std::vector<float> weightsSizesSmoothing;
-
-        cv::Ptr<IDetector> cascadeForTracking;
-
-        void updateTrackedObjects(const std::vector<cv::Rect>& detectedObjects);
-        cv::Rect calcTrackedObjectPositionToShow(int i) const;
-        cv::Rect calcTrackedObjectPositionToShow(int i, ObjectStatus& status) const;
-        void detectInRegion(const cv::Mat& img, const cv::Rect& r, std::vector<cv::Rect>& detectedObjectsInRegions);
-};
-} //end of cv namespace
-#endif
diff --git a/modules/contrib/include/opencv2/contrib/hybridtracker.hpp b/modules/contrib/include/opencv2/contrib/hybridtracker.hpp
deleted file mode 100644 (file)
index 20f9224..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-//*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                                License Agreement
-//                       For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_HYBRIDTRACKER_H_
-#define __OPENCV_HYBRIDTRACKER_H_
-
-#include "opencv2/core.hpp"
-#include "opencv2/imgproc.hpp"
-#include "opencv2/features2d.hpp"
-#include "opencv2/video/tracking.hpp"
-#include "opencv2/ml.hpp"
-
-#ifdef __cplusplus
-
-namespace cv
-{
-
-// Motion model for tracking algorithm. Currently supports objects that do not move much.
-// To add Kalman filter
-struct CV_EXPORTS CvMotionModel
-{
-    enum {LOW_PASS_FILTER = 0, KALMAN_FILTER = 1, EM = 2};
-
-    CvMotionModel()
-    {
-    }
-
-    float low_pass_gain;    // low pass gain
-};
-
-// Mean Shift Tracker parameters for specifying use of HSV channel and CamShift parameters.
-struct CV_EXPORTS CvMeanShiftTrackerParams
-{
-    enum {  H = 0, HS = 1, HSV = 2  };
-    CvMeanShiftTrackerParams(int tracking_type = CvMeanShiftTrackerParams::HS,
-            CvTermCriteria term_crit = CvTermCriteria());
-
-    int tracking_type;
-    std::vector<float> h_range;
-    std::vector<float> s_range;
-    std::vector<float> v_range;
-    CvTermCriteria term_crit;
-};
-
-// Feature tracking parameters
-struct CV_EXPORTS CvFeatureTrackerParams
-{
-    enum {  SIFT = 0, SURF = 1, OPTICAL_FLOW = 2 };
-    CvFeatureTrackerParams(int featureType = 0, int windowSize = 0)
-    {
-        feature_type = featureType;
-        window_size = windowSize;
-    }
-
-    int feature_type; // Feature type to use
-    int window_size; // Window size in pixels around which to search for new window
-};
-
-// Hybrid Tracking parameters for specifying weights of individual trackers and motion model.
-struct CV_EXPORTS CvHybridTrackerParams
-{
-    CvHybridTrackerParams(float ft_tracker_weight = 0.5, float ms_tracker_weight = 0.5,
-            CvFeatureTrackerParams ft_params = CvFeatureTrackerParams(),
-            CvMeanShiftTrackerParams ms_params = CvMeanShiftTrackerParams(),
-            CvMotionModel model = CvMotionModel());
-
-    float ft_tracker_weight;
-    float ms_tracker_weight;
-    CvFeatureTrackerParams ft_params;
-    CvMeanShiftTrackerParams ms_params;
-    int motion_model;
-    float low_pass_gain;
-};
-
-// Performs Camshift using parameters from MeanShiftTrackerParams
-class CV_EXPORTS CvMeanShiftTracker
-{
-private:
-    Mat hsv, hue;
-    Mat backproj;
-    Mat mask, maskroi;
-    MatND hist;
-    Rect prev_trackwindow;
-    RotatedRect prev_trackbox;
-    Point2f prev_center;
-
-public:
-    CvMeanShiftTrackerParams params;
-
-    CvMeanShiftTracker();
-    explicit CvMeanShiftTracker(CvMeanShiftTrackerParams _params);
-    ~CvMeanShiftTracker();
-    void newTrackingWindow(Mat image, Rect selection);
-    RotatedRect updateTrackingWindow(Mat image);
-    Mat getHistogramProjection(int type);
-    void setTrackingWindow(Rect _window);
-    Rect getTrackingWindow();
-    RotatedRect getTrackingEllipse();
-    Point2f getTrackingCenter();
-};
-
-// Performs SIFT/SURF feature tracking using parameters from FeatureTrackerParams
-class CV_EXPORTS CvFeatureTracker
-{
-private:
-    Ptr<Feature2D> dd;
-    Ptr<DescriptorMatcher> matcher;
-    std::vector<DMatch> matches;
-
-    Mat prev_image;
-    Mat prev_image_bw;
-    Rect prev_trackwindow;
-    Point2d prev_center;
-
-    int ittr;
-    std::vector<Point2f> features[2];
-
-public:
-    Mat disp_matches;
-    CvFeatureTrackerParams params;
-
-    CvFeatureTracker();
-    explicit CvFeatureTracker(CvFeatureTrackerParams params);
-    ~CvFeatureTracker();
-    void newTrackingWindow(Mat image, Rect selection);
-    Rect updateTrackingWindow(Mat image);
-    Rect updateTrackingWindowWithSIFT(Mat image);
-    Rect updateTrackingWindowWithFlow(Mat image);
-    void setTrackingWindow(Rect _window);
-    Rect getTrackingWindow();
-    Point2f getTrackingCenter();
-};
-
-// Performs Hybrid Tracking and combines individual trackers using EM or filters
-class CV_EXPORTS CvHybridTracker
-{
-private:
-    CvMeanShiftTracker* mstracker;
-    CvFeatureTracker* fttracker;
-
-    CvMat* samples;
-    CvMat* labels;
-
-    Rect prev_window;
-    Point2f prev_center;
-    Mat prev_proj;
-    RotatedRect trackbox;
-
-    int ittr;
-    Point2f curr_center;
-
-    inline float getL2Norm(Point2f p1, Point2f p2);
-    Mat getDistanceProjection(Mat image, Point2f center);
-    Mat getGaussianProjection(Mat image, int ksize, double sigma, Point2f center);
-    void updateTrackerWithEM(Mat image);
-    void updateTrackerWithLowPassFilter(Mat image);
-
-public:
-    CvHybridTrackerParams params;
-    CvHybridTracker();
-    explicit CvHybridTracker(CvHybridTrackerParams params);
-    ~CvHybridTracker();
-
-    void newTracker(Mat image, Rect selection);
-    void updateTracker(Mat image);
-    Rect getTrackingWindow();
-};
-
-typedef CvMotionModel MotionModel;
-typedef CvMeanShiftTrackerParams MeanShiftTrackerParams;
-typedef CvFeatureTrackerParams FeatureTrackerParams;
-typedef CvHybridTrackerParams HybridTrackerParams;
-typedef CvMeanShiftTracker MeanShiftTracker;
-typedef CvFeatureTracker FeatureTracker;
-typedef CvHybridTracker HybridTracker;
-}
-
-#endif
-
-#endif
diff --git a/modules/contrib/include/opencv2/contrib/openfabmap.hpp b/modules/contrib/include/opencv2/contrib/openfabmap.hpp
deleted file mode 100644 (file)
index 3859775..0000000
+++ /dev/null
@@ -1,401 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-// This file originates from the openFABMAP project:
-// [http://code.google.com/p/openfabmap/]
-//
-// For published work which uses all or part of OpenFABMAP, please cite:
-// [http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6224843]
-//
-// Original Algorithm by Mark Cummins and Paul Newman:
-// [http://ijr.sagepub.com/content/27/6/647.short]
-// [http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5613942]
-// [http://ijr.sagepub.com/content/30/9/1100.abstract]
-//
-//                           License Agreement
-//
-// Copyright (C) 2012 Arren Glover [aj.glover@qut.edu.au] and
-//                    Will Maddern [w.maddern@qut.edu.au], all rights reserved.
-//
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_OPENFABMAP_H_
-#define __OPENCV_OPENFABMAP_H_
-
-#include "opencv2/core.hpp"
-#include "opencv2/features2d.hpp"
-
-#include <vector>
-#include <list>
-#include <map>
-#include <set>
-#include <valarray>
-
-namespace cv {
-
-namespace of2 {
-
-/*
-    Return data format of a FABMAP compare call
-*/
-struct CV_EXPORTS IMatch {
-
-    IMatch() :
-        queryIdx(-1), imgIdx(-1), likelihood(-DBL_MAX), match(-DBL_MAX) {
-    }
-    IMatch(int _queryIdx, int _imgIdx, double _likelihood, double _match) :
-        queryIdx(_queryIdx), imgIdx(_imgIdx), likelihood(_likelihood), match(
-                _match) {
-    }
-
-    int queryIdx;    //query index
-    int imgIdx;      //test index
-
-    double likelihood;  //raw loglikelihood
-    double match;      //normalised probability
-
-    bool operator<(const IMatch& m) const {
-        return match < m.match;
-    }
-
-};
-
-/*
-    Base FabMap class. Each FabMap method inherits from this class.
-*/
-class CV_EXPORTS FabMap {
-public:
-
-    //FabMap options
-    enum {
-        MEAN_FIELD = 1,
-        SAMPLED = 2,
-        NAIVE_BAYES = 4,
-        CHOW_LIU = 8,
-        MOTION_MODEL = 16
-    };
-
-    FabMap(const Mat& clTree, double PzGe, double PzGNe, int flags,
-            int numSamples = 0);
-    virtual ~FabMap();
-
-    //methods to add training data for sampling method
-    virtual void addTraining(const Mat& queryImgDescriptor);
-    virtual void addTraining(const std::vector<Mat>& queryImgDescriptors);
-
-    //methods to add to the test data
-    virtual void add(const Mat& queryImgDescriptor);
-    virtual void add(const std::vector<Mat>& queryImgDescriptors);
-
-    //accessors
-    const std::vector<Mat>& getTrainingImgDescriptors() const;
-    const std::vector<Mat>& getTestImgDescriptors() const;
-
-    //Main FabMap image comparison
-    void compare(const Mat& queryImgDescriptor,
-            std::vector<IMatch>& matches, bool addQuery = false,
-            const Mat& mask = Mat());
-    void compare(const Mat& queryImgDescriptor,
-            const Mat& testImgDescriptors, std::vector<IMatch>& matches,
-            const Mat& mask = Mat());
-    void compare(const Mat& queryImgDescriptor,
-            const std::vector<Mat>& testImgDescriptors,
-            std::vector<IMatch>& matches, const Mat& mask = Mat());
-    void compare(const std::vector<Mat>& queryImgDescriptors, std::vector<
-            IMatch>& matches, bool addQuery = false, const Mat& mask =
-            Mat());
-    void compare(const std::vector<Mat>& queryImgDescriptors,
-            const std::vector<Mat>& testImgDescriptors,
-            std::vector<IMatch>& matches, const Mat& mask = Mat());
-
-protected:
-
-    void compareImgDescriptor(const Mat& queryImgDescriptor,
-            int queryIndex, const std::vector<Mat>& testImgDescriptors,
-            std::vector<IMatch>& matches);
-
-    void addImgDescriptor(const Mat& queryImgDescriptor);
-
-    //the getLikelihoods method is overwritten for each different FabMap
-    //method.
-    virtual void getLikelihoods(const Mat& queryImgDescriptor,
-            const std::vector<Mat>& testImgDescriptors,
-            std::vector<IMatch>& matches);
-    virtual double getNewPlaceLikelihood(const Mat& queryImgDescriptor);
-
-    //turn likelihoods into probabilities (also add in motion model if used)
-    void normaliseDistribution(std::vector<IMatch>& matches);
-
-    //Chow-Liu Tree
-    int pq(int q);
-    double Pzq(int q, bool zq);
-    double PzqGzpq(int q, bool zq, bool zpq);
-
-    //FAB-MAP Core
-    double PzqGeq(bool zq, bool eq);
-    double PeqGL(int q, bool Lzq, bool eq);
-    double PzqGL(int q, bool zq, bool zpq, bool Lzq);
-    double PzqGzpqL(int q, bool zq, bool zpq, bool Lzq);
-    double (FabMap::*PzGL)(int q, bool zq, bool zpq, bool Lzq);
-
-    //data
-    Mat clTree;
-    std::vector<Mat> trainingImgDescriptors;
-    std::vector<Mat> testImgDescriptors;
-    std::vector<IMatch> priorMatches;
-
-    //parameters
-    double PzGe;
-    double PzGNe;
-    double Pnew;
-
-    double mBias;
-    double sFactor;
-
-    int flags;
-    int numSamples;
-
-};
-
-/*
-    The original FAB-MAP algorithm, developed based on:
-    http://ijr.sagepub.com/content/27/6/647.short
-*/
-class CV_EXPORTS FabMap1: public FabMap {
-public:
-    FabMap1(const Mat& clTree, double PzGe, double PzGNe, int flags,
-            int numSamples = 0);
-    virtual ~FabMap1();
-protected:
-
-    //FabMap1 implementation of likelihood comparison
-    void getLikelihoods(const Mat& queryImgDescriptor, const std::vector<
-            Mat>& testImgDescriptors, std::vector<IMatch>& matches);
-};
-
-/*
-    A computationally faster version of the original FAB-MAP algorithm. A look-
-    up-table is used to precompute many of the reoccuring calculations
-*/
-class CV_EXPORTS FabMapLUT: public FabMap {
-public:
-    FabMapLUT(const Mat& clTree, double PzGe, double PzGNe,
-            int flags, int numSamples = 0, int precision = 6);
-    virtual ~FabMapLUT();
-protected:
-
-    //FabMap look-up-table implementation of the likelihood comparison
-    void getLikelihoods(const Mat& queryImgDescriptor, const std::vector<
-            Mat>& testImgDescriptors, std::vector<IMatch>& matches);
-
-    //precomputed data
-    int (*table)[8];
-
-    //data precision
-    int precision;
-};
-
-/*
-    The Accelerated FAB-MAP algorithm, developed based on:
-    http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5613942
-*/
-class CV_EXPORTS FabMapFBO: public FabMap {
-public:
-    FabMapFBO(const Mat& clTree, double PzGe, double PzGNe, int flags,
-            int numSamples = 0, double rejectionThreshold = 1e-8, double PsGd =
-                    1e-8, int bisectionStart = 512, int bisectionIts = 9);
-    virtual ~FabMapFBO();
-
-protected:
-
-    //FabMap Fast Bail-out implementation of the likelihood comparison
-    void getLikelihoods(const Mat& queryImgDescriptor, const std::vector<
-            Mat>& testImgDescriptors, std::vector<IMatch>& matches);
-
-    //stucture used to determine word comparison order
-    struct WordStats {
-        WordStats() :
-            q(0), info(0), V(0), M(0) {
-        }
-
-        WordStats(int _q, double _info) :
-            q(_q), info(_info), V(0), M(0) {
-        }
-
-        int q;
-        double info;
-        mutable double V;
-        mutable double M;
-
-        bool operator<(const WordStats& w) const {
-            return info < w.info;
-        }
-
-    };
-
-    //private fast bail-out necessary functions
-    void setWordStatistics(const Mat& queryImgDescriptor, std::multiset<WordStats>& wordData);
-    double limitbisection(double v, double m);
-    double bennettInequality(double v, double m, double delta);
-    static bool compInfo(const WordStats& first, const WordStats& second);
-
-    //parameters
-    double PsGd;
-    double rejectionThreshold;
-    int bisectionStart;
-    int bisectionIts;
-};
-
-/*
-    The FAB-MAP2.0 algorithm, developed based on:
-    http://ijr.sagepub.com/content/30/9/1100.abstract
-*/
-class CV_EXPORTS FabMap2: public FabMap {
-public:
-
-    FabMap2(const Mat& clTree, double PzGe, double PzGNe, int flags);
-    virtual ~FabMap2();
-
-    //FabMap2 builds the inverted index and requires an additional training/test
-    //add function
-    void addTraining(const Mat& queryImgDescriptors) {
-        FabMap::addTraining(queryImgDescriptors);
-    }
-    void addTraining(const std::vector<Mat>& queryImgDescriptors);
-
-    void add(const Mat& queryImgDescriptors) {
-        FabMap::add(queryImgDescriptors);
-    }
-    void add(const std::vector<Mat>& queryImgDescriptors);
-
-protected:
-
-    //FabMap2 implementation of the likelihood comparison
-    void getLikelihoods(const Mat& queryImgDescriptor, const std::vector<
-            Mat>& testImgDescriptors, std::vector<IMatch>& matches);
-    double getNewPlaceLikelihood(const Mat& queryImgDescriptor);
-
-    //the likelihood function using the inverted index
-    void getIndexLikelihoods(const Mat& queryImgDescriptor, std::vector<
-                             double>& defaults, std::map<int, std::vector<int> >& invertedMap,
-            std::vector<IMatch>& matches);
-    void addToIndex(const Mat& queryImgDescriptor,
-            std::vector<double>& defaults,
-            std::map<int, std::vector<int> >& invertedMap);
-
-    //data
-    std::vector<double> d1, d2, d3, d4;
-    std::vector<std::vector<int> > children;
-
-    // TODO: inverted map a vector?
-
-    std::vector<double> trainingDefaults;
-    std::map<int, std::vector<int> > trainingInvertedMap;
-
-    std::vector<double> testDefaults;
-    std::map<int, std::vector<int> > testInvertedMap;
-
-};
-/*
-    A Chow-Liu tree is required by FAB-MAP. The Chow-Liu tree provides an
-    estimate of the full distribution of visual words using a minimum spanning
-    tree. The tree is generated through training data.
-*/
-class CV_EXPORTS ChowLiuTree {
-public:
-    ChowLiuTree();
-    virtual ~ChowLiuTree();
-
-    //add data to the chow-liu tree before calling make
-    void add(const Mat& imgDescriptor);
-    void add(const std::vector<Mat>& imgDescriptors);
-
-    const std::vector<Mat>& getImgDescriptors() const;
-
-    Mat make(double infoThreshold = 0.0);
-
-private:
-    std::vector<Mat> imgDescriptors;
-    Mat mergedImgDescriptors;
-
-    typedef struct info {
-        float score;
-        short word1;
-        short word2;
-    } info;
-
-    //probabilities extracted from mergedImgDescriptors
-    double P(int a, bool za);
-    double JP(int a, bool za, int b, bool zb); //a & b
-    double CP(int a, bool za, int b, bool zb); // a | b
-
-    //calculating mutual information of all edges
-    void createBaseEdges(std::list<info>& edges, double infoThreshold);
-    double calcMutInfo(int word1, int word2);
-    static bool sortInfoScores(const info& first, const info& second);
-
-    //selecting minimum spanning egdges with maximum information
-    bool reduceEdgesToMinSpan(std::list<info>& edges);
-
-    //building the tree sctructure
-    Mat buildTree(int root_word, std::list<info> &edges);
-    void recAddToTree(Mat &cltree, int q, int pq,
-        std::list<info> &remaining_edges);
-    std::vector<int> extractChildren(std::list<info> &remaining_edges, int q);
-
-};
-
-/*
-    A custom vocabulary training method based on:
-    http://www.springerlink.com/content/d1h6j8x552532003/
-*/
-class CV_EXPORTS BOWMSCTrainer: public BOWTrainer {
-public:
-    BOWMSCTrainer(double clusterSize = 0.4);
-    virtual ~BOWMSCTrainer();
-
-    // Returns trained vocabulary (i.e. cluster centers).
-    virtual Mat cluster() const;
-    virtual Mat cluster(const Mat& descriptors) const;
-
-protected:
-
-    double clusterSize;
-
-};
-
-}
-
-}
-
-#endif /* OPENFABMAP_H_ */
diff --git a/modules/contrib/src/adaptiveskindetector.cpp b/modules/contrib/src/adaptiveskindetector.cpp
deleted file mode 100644 (file)
index c4fbbe0..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install, copy or use the software.
-//
-// Copyright (C) 2009, Farhad Dadgostar
-// Intel Corporation and third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "opencv2/imgproc/imgproc_c.h"
-#include "opencv2/contrib/compat.hpp"
-
-#define ASD_INTENSITY_SET_PIXEL(pointer, qq) {(*pointer) = (unsigned char)qq;}
-
-#define ASD_IS_IN_MOTION(pointer, v, threshold)        ((abs((*(pointer)) - (v)) > (threshold)) ? true : false)
-
-void CvAdaptiveSkinDetector::initData(IplImage *src, int widthDivider, int heightDivider)
-{
-    CvSize imageSize = cvSize(src->width/widthDivider, src->height/heightDivider);
-
-    imgHueFrame = cvCreateImage(imageSize, IPL_DEPTH_8U, 1);
-    imgShrinked = cvCreateImage(imageSize, IPL_DEPTH_8U, src->nChannels);
-    imgSaturationFrame = cvCreateImage(imageSize, IPL_DEPTH_8U, 1);
-    imgMotionFrame = cvCreateImage(imageSize, IPL_DEPTH_8U, 1);
-    imgTemp = cvCreateImage(imageSize, IPL_DEPTH_8U, 1);
-    imgFilteredFrame = cvCreateImage(imageSize, IPL_DEPTH_8U, 1);
-    imgGrayFrame = cvCreateImage(imageSize, IPL_DEPTH_8U, 1);
-    imgLastGrayFrame = cvCreateImage(imageSize, IPL_DEPTH_8U, 1);
-    imgHSVFrame = cvCreateImage(imageSize, IPL_DEPTH_8U, 3);
-}
-
-CvAdaptiveSkinDetector::CvAdaptiveSkinDetector(int samplingDivider, int morphingMethod)
-{
-    nSkinHueLowerBound = GSD_HUE_LT;
-    nSkinHueUpperBound = GSD_HUE_UT;
-
-    fHistogramMergeFactor = 0.05;      // empirical result
-    fHuePercentCovered = 0.95;         // empirical result
-
-    nMorphingMethod = morphingMethod;
-    nSamplingDivider = samplingDivider;
-
-    nFrameCount = 0;
-    nStartCounter = 0;
-
-    imgHueFrame = NULL;
-    imgMotionFrame = NULL;
-    imgTemp = NULL;
-    imgFilteredFrame = NULL;
-    imgShrinked = NULL;
-    imgGrayFrame = NULL;
-    imgLastGrayFrame = NULL;
-    imgSaturationFrame = NULL;
-    imgHSVFrame = NULL;
-}
-
-CvAdaptiveSkinDetector::~CvAdaptiveSkinDetector()
-{
-    cvReleaseImage(&imgHueFrame);
-    cvReleaseImage(&imgSaturationFrame);
-    cvReleaseImage(&imgMotionFrame);
-    cvReleaseImage(&imgTemp);
-    cvReleaseImage(&imgFilteredFrame);
-    cvReleaseImage(&imgShrinked);
-    cvReleaseImage(&imgGrayFrame);
-    cvReleaseImage(&imgLastGrayFrame);
-    cvReleaseImage(&imgHSVFrame);
-}
-
-void CvAdaptiveSkinDetector::process(IplImage *inputBGRImage, IplImage *outputHueMask)
-{
-    IplImage *src = inputBGRImage;
-
-    int h, v, i, l;
-    bool isInit = false;
-
-    nFrameCount++;
-
-    if (imgHueFrame == NULL)
-    {
-        isInit = true;
-        initData(src, nSamplingDivider, nSamplingDivider);
-    }
-
-    unsigned char *pShrinked, *pHueFrame, *pMotionFrame, *pLastGrayFrame, *pFilteredFrame, *pGrayFrame;
-    pShrinked = (unsigned char *)imgShrinked->imageData;
-    pHueFrame = (unsigned char *)imgHueFrame->imageData;
-    pMotionFrame = (unsigned char *)imgMotionFrame->imageData;
-    pLastGrayFrame = (unsigned char *)imgLastGrayFrame->imageData;
-    pFilteredFrame = (unsigned char *)imgFilteredFrame->imageData;
-    pGrayFrame = (unsigned char *)imgGrayFrame->imageData;
-
-    if ((src->width != imgHueFrame->width) || (src->height != imgHueFrame->height))
-    {
-        cvResize(src, imgShrinked);
-        cvCvtColor(imgShrinked, imgHSVFrame, CV_BGR2HSV);
-    }
-    else
-    {
-        cvCvtColor(src, imgHSVFrame, CV_BGR2HSV);
-    }
-
-    cvSplit(imgHSVFrame, imgHueFrame, imgSaturationFrame, imgGrayFrame, 0);
-
-    cvSetZero(imgMotionFrame);
-    cvSetZero(imgFilteredFrame);
-
-    l = imgHueFrame->height * imgHueFrame->width;
-
-    for (i = 0; i < l; i++)
-    {
-        v = (*pGrayFrame);
-        if ((v >= GSD_INTENSITY_LT) && (v <= GSD_INTENSITY_UT))
-        {
-            h = (*pHueFrame);
-            if ((h >= GSD_HUE_LT) && (h <= GSD_HUE_UT))
-            {
-                if ((h >= nSkinHueLowerBound) && (h <= nSkinHueUpperBound))
-                    ASD_INTENSITY_SET_PIXEL(pFilteredFrame, h);
-
-                if (ASD_IS_IN_MOTION(pLastGrayFrame, v, 7))
-                    ASD_INTENSITY_SET_PIXEL(pMotionFrame, h);
-            }
-        }
-        pShrinked += 3;
-        pGrayFrame++;
-        pLastGrayFrame++;
-        pMotionFrame++;
-        pHueFrame++;
-        pFilteredFrame++;
-    }
-
-    if (isInit)
-        cvCalcHist(&imgHueFrame, skinHueHistogram.fHistogram);
-
-    cvCopy(imgGrayFrame, imgLastGrayFrame);
-
-    cvErode(imgMotionFrame, imgTemp);  // eliminate disperse pixels, which occur because of the camera noise
-    cvDilate(imgTemp, imgMotionFrame);
-
-    cvCalcHist(&imgMotionFrame, histogramHueMotion.fHistogram);
-
-    skinHueHistogram.mergeWith(&histogramHueMotion, fHistogramMergeFactor);
-
-    skinHueHistogram.findCurveThresholds(nSkinHueLowerBound, nSkinHueUpperBound, 1 - fHuePercentCovered);
-
-    switch (nMorphingMethod)
-    {
-        case MORPHING_METHOD_ERODE :
-            cvErode(imgFilteredFrame, imgTemp);
-            cvCopy(imgTemp, imgFilteredFrame);
-            break;
-        case MORPHING_METHOD_ERODE_ERODE :
-            cvErode(imgFilteredFrame, imgTemp);
-            cvErode(imgTemp, imgFilteredFrame);
-            break;
-        case MORPHING_METHOD_ERODE_DILATE :
-            cvErode(imgFilteredFrame, imgTemp);
-            cvDilate(imgTemp, imgFilteredFrame);
-            break;
-    }
-
-    if (outputHueMask != NULL)
-        cvCopy(imgFilteredFrame, outputHueMask);
-}
-
-
-//------------------------- Histogram for Adaptive Skin Detector -------------------------//
-
-CvAdaptiveSkinDetector::Histogram::Histogram()
-{
-    int histogramSize[] = { HistogramSize };
-    float range[] = { GSD_HUE_LT, GSD_HUE_UT };
-    float *ranges[] = { range };
-    fHistogram = cvCreateHist(1, histogramSize, CV_HIST_ARRAY, ranges, 1);
-    cvClearHist(fHistogram);
-}
-
-CvAdaptiveSkinDetector::Histogram::~Histogram()
-{
-    cvReleaseHist(&fHistogram);
-}
-
-int CvAdaptiveSkinDetector::Histogram::findCoverageIndex(double surfaceToCover, int defaultValue)
-{
-    double s = 0;
-    for (int i = 0; i < HistogramSize; i++)
-    {
-        s += cvGetReal1D( fHistogram->bins, i );
-        if (s >= surfaceToCover)
-        {
-            return i;
-        }
-    }
-    return defaultValue;
-}
-
-void CvAdaptiveSkinDetector::Histogram::findCurveThresholds(int &x1, int &x2, double percent)
-{
-    double sum = 0;
-
-    for (int i = 0; i < HistogramSize; i++)
-    {
-        sum += cvGetReal1D( fHistogram->bins, i );
-    }
-
-    x1 = findCoverageIndex(sum * percent, -1);
-    x2 = findCoverageIndex(sum * (1-percent), -1);
-
-    if (x1 == -1)
-        x1 = GSD_HUE_LT;
-    else
-        x1 += GSD_HUE_LT;
-
-    if (x2 == -1)
-        x2 = GSD_HUE_UT;
-    else
-        x2 += GSD_HUE_LT;
-}
-
-void CvAdaptiveSkinDetector::Histogram::mergeWith(CvAdaptiveSkinDetector::Histogram *source, double weight)
-{
-    float myweight = (float)(1-weight);
-    float maxVal1 = 0, maxVal2 = 0, *f1, *f2, ff1, ff2;
-
-    cvGetMinMaxHistValue(source->fHistogram, NULL, &maxVal2);
-
-    if (maxVal2 > 0 )
-    {
-        cvGetMinMaxHistValue(fHistogram, NULL, &maxVal1);
-        if (maxVal1 <= 0)
-        {
-            for (int i = 0; i < HistogramSize; i++)
-            {
-                f1 = (float*)cvPtr1D(fHistogram->bins, i);
-                f2 = (float*)cvPtr1D(source->fHistogram->bins, i);
-                (*f1) = (*f2);
-            }
-        }
-        else
-        {
-            for (int i = 0; i < HistogramSize; i++)
-            {
-                f1 = (float*)cvPtr1D(fHistogram->bins, i);
-                f2 = (float*)cvPtr1D(source->fHistogram->bins, i);
-
-                ff1 = ((*f1)/maxVal1)*myweight;
-                if (ff1 < 0)
-                    ff1 = -ff1;
-
-                ff2 = (float)(((*f2)/maxVal2)*weight);
-                if (ff2 < 0)
-                    ff2 = -ff2;
-
-                (*f1) = (ff1 + ff2);
-
-            }
-        }
-    }
-}
diff --git a/modules/contrib/src/ba.cpp b/modules/contrib/src/ba.cpp
deleted file mode 100644 (file)
index d8ed2f9..0000000
+++ /dev/null
@@ -1,1128 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                         License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2009, PhaseSpace Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The names of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "opencv2/calib3d.hpp"
-#include "opencv2/contrib/compat.hpp"
-#include "opencv2/calib3d/calib3d_c.h"
-#include <iostream>
-
-using namespace cv;
-
-LevMarqSparse::LevMarqSparse() {
-  Vis_index = X = prevP = P = deltaP = err = JtJ_diag = S = hX = NULL;
-  U = ea = V = inv_V_star = eb = Yj = NULL;
-  num_cams = 0,   num_points = 0,   num_err_param = 0;
-  num_cam_param = 0,  num_point_param = 0;
-  A = B = W = NULL;
-}
-
-LevMarqSparse::~LevMarqSparse() {
-  clear();
-}
-
-LevMarqSparse::LevMarqSparse(int npoints, // number of points
-           int ncameras, // number of cameras
-           int nPointParams, // number of params per one point  (3 in case of 3D points)
-           int nCameraParams, // number of parameters per one camera
-           int nErrParams, // number of parameters in measurement vector
-           // for 1 point at one camera (2 in case of 2D projections)
-           Mat& visibility, // visibility matrix. rows correspond to points, columns correspond to cameras
-           // 1 - point is visible for the camera, 0 - invisible
-           Mat& P0, // starting vector of parameters, first cameras then points
-           Mat& X_, // measurements, in order of visibility. non visible cases are skipped
-           TermCriteria _criteria, // termination criteria
-
-           // callback for estimation of Jacobian matrices
-           void (CV_CDECL * _fjac)(int i, int j, Mat& point_params,
-                Mat& cam_params, Mat& A, Mat& B, void* data),
-           // callback for estimation of backprojection errors
-           void (CV_CDECL * _func)(int i, int j, Mat& point_params,
-                Mat& cam_params, Mat& estim, void* data),
-           void* _data, // user-specific data passed to the callbacks
-           BundleAdjustCallback _cb, void* _user_data
-           ) {
-  Vis_index = X = prevP = P = deltaP = err = JtJ_diag = S = hX = NULL;
-  U = ea = V = inv_V_star = eb = Yj = NULL;
-  A = B = W = NULL;
-
-  cb = _cb;
-  user_data = _user_data;
-
-  run(npoints, ncameras, nPointParams, nCameraParams, nErrParams, visibility,
-      P0, X_, _criteria, _fjac, _func, _data);
-}
-
-void LevMarqSparse::clear() {
-  for( int i = 0; i < num_points; i++ ) {
-    for(int j = 0; j < num_cams; j++ ) {
-      //CvMat* tmp = ((CvMat**)(A->data.ptr + i * A->step))[j];
-      CvMat* tmp = A[j+i*num_cams];
-      if (tmp)
-  cvReleaseMat( &tmp );
-
-      //tmp = ((CvMat**)(B->data.ptr + i * B->step))[j];
-      tmp  = B[j+i*num_cams];
-      if (tmp)
-  cvReleaseMat( &tmp );
-
-      //tmp = ((CvMat**)(W->data.ptr + j * W->step))[i];
-      tmp  = W[j+i*num_cams];
-      if (tmp)
-  cvReleaseMat( &tmp );
-    }
-  }
-  delete A; //cvReleaseMat(&A);
-  delete B;//cvReleaseMat(&B);
-  delete W;//cvReleaseMat(&W);
-  cvReleaseMat( &Vis_index);
-
-  for( int j = 0; j < num_cams; j++ ) {
-    cvReleaseMat( &U[j] );
-  }
-  delete U;
-
-  for( int j = 0; j < num_cams; j++ ) {
-    cvReleaseMat( &ea[j] );
-  }
-  delete ea;
-
-  //allocate V and inv_V_star
-  for( int i = 0; i < num_points; i++ ) {
-    cvReleaseMat(&V[i]);
-    cvReleaseMat(&inv_V_star[i]);
-  }
-  delete V;
-  delete inv_V_star;
-
-  for( int i = 0; i < num_points; i++ ) {
-    cvReleaseMat(&eb[i]);
-  }
-  delete eb;
-
-  for( int i = 0; i < num_points; i++ ) {
-    cvReleaseMat(&Yj[i]);
-  }
-  delete Yj;
-
-  cvReleaseMat(&X);
-  cvReleaseMat(&prevP);
-  cvReleaseMat(&P);
-  cvReleaseMat(&deltaP);
-
-  cvReleaseMat(&err);
-
-  cvReleaseMat(&JtJ_diag);
-  cvReleaseMat(&S);
-  cvReleaseMat(&hX);
-}
-
-//A params correspond to  Cameras
-//B params correspont to  Points
-
-//num_cameras  - total number of cameras
-//num_points   - total number of points
-
-//num_par_per_camera - number of parameters per camera
-//num_par_per_point - number of parameters per point
-
-//num_errors - number of measurements.
-
-void LevMarqSparse::run( int num_points_, //number of points
-       int num_cams_, //number of cameras
-       int num_point_param_, //number of params per one point  (3 in case of 3D points)
-       int num_cam_param_, //number of parameters per one camera
-       int num_err_param_, //number of parameters in measurement vector for 1 point at one camera (2 in case of 2D projections)
-       Mat& visibility,   //visibility matrix . rows correspond to points, columns correspond to cameras
-       // 0 - point is visible for the camera, 0 - invisible
-       Mat& P0, //starting vector of parameters, first cameras then points
-       Mat& X_init, //measurements, in order of visibility. non visible cases are skipped
-       TermCriteria criteria_init,
-       void (*fjac_)(int i, int j, Mat& point_params, Mat& cam_params, Mat& A, Mat& B, void* data),
-       void (*func_)(int i, int j, Mat& point_params, Mat& cam_params, Mat& estim, void* data),
-       void* data_
-       ) { //termination criteria
-  //clear();
-
-  func = func_; //assign evaluation function
-  fjac = fjac_; //assign jacobian
-  data = data_;
-
-  num_cams = num_cams_;
-  num_points = num_points_;
-  num_err_param = num_err_param_;
-  num_cam_param = num_cam_param_;
-  num_point_param = num_point_param_;
-
-  //compute all sizes
-  int Aij_width = num_cam_param;
-  int Aij_height = num_err_param;
-
-  int Bij_width = num_point_param;
-  int Bij_height = num_err_param;
-
-  int U_size = Aij_width;
-  int V_size = Bij_width;
-
-  int Wij_height = Aij_width;
-  int Wij_width = Bij_width;
-
-  //allocate memory for all Aij, Bij, U, V, W
-
-  //allocate num_points*num_cams matrices A
-
-  //Allocate matrix A whose elements are nointers to Aij
-  //if Aij is zero (point i is not visible in camera j) then A(i,j) contains NULL
-  //A = cvCreateMat( num_points, num_cams, CV_32S /*pointer is stored here*/ );
-  //B = cvCreateMat( num_points, num_cams, CV_32S /*pointer is stored here*/ );
-  //W = cvCreateMat( num_cams, num_points, CV_32S /*pointer is stored here*/ );
-
-  A = new CvMat* [num_points * num_cams];
-  B = new CvMat* [num_points * num_cams];
-  W = new CvMat* [num_cams * num_points];
-  Vis_index = cvCreateMat( num_points, num_cams, CV_32S /*integer index is stored here*/ );
-  //cvSetZero( A );
-  //cvSetZero( B );
-  //cvSetZero( W );
-  cvSet( Vis_index, cvScalar(-1) );
-
-  //fill matrices A and B based on visibility
-  CvMat _vis = visibility;
-  int index = 0;
-  for (int i = 0; i < num_points; i++ ) {
-    for (int j = 0; j < num_cams; j++ ) {
-      if (((int*)(_vis.data.ptr+ i * _vis.step))[j] ) {
-  ((int*)(Vis_index->data.ptr + i * Vis_index->step))[j] = index;
-  index += num_err_param;
-
-  //create matrices Aij, Bij
-  CvMat* tmp = cvCreateMat(Aij_height, Aij_width, CV_64F );
-  //((CvMat**)(A->data.ptr + i * A->step))[j] = tmp;
-  cvSet(tmp,cvScalar(1.0,1.0,1.0,1.0));
-  A[j+i*num_cams] = tmp;
-
-  tmp = cvCreateMat( Bij_height, Bij_width, CV_64F );
-  //((CvMat**)(B->data.ptr + i * B->step))[j] = tmp;
-  cvSet(tmp,cvScalar(1.0,1.0,1.0,1.0));
-  B[j+i*num_cams] = tmp;
-
-  tmp = cvCreateMat( Wij_height, Wij_width, CV_64F );
-  //((CvMat**)(W->data.ptr + j * W->step))[i] = tmp;  //note indices i and j swapped
-  cvSet(tmp,cvScalar(1.0,1.0,1.0,1.0));
-  W[j+i*num_cams] = tmp;
-      } else{
-  A[j+i*num_cams] = NULL;
-  B[j+i*num_cams] = NULL;
-  W[j+i*num_cams] = NULL;
-      }
-    }
-  }
-
-  //allocate U
-  U = new CvMat* [num_cams];
-  for (int j = 0; j < num_cams; j++ ) {
-    U[j] = cvCreateMat( U_size, U_size, CV_64F );
-    cvSetZero(U[j]);
-
-  }
-  //allocate ea
-  ea = new CvMat* [num_cams];
-  for (int j = 0; j < num_cams; j++ ) {
-    ea[j] = cvCreateMat( U_size, 1, CV_64F );
-    cvSetZero(ea[j]);
-  }
-
-  //allocate V and inv_V_star
-  V = new CvMat* [num_points];
-  inv_V_star = new CvMat* [num_points];
-  for (int i = 0; i < num_points; i++ ) {
-    V[i] = cvCreateMat( V_size, V_size, CV_64F );
-    inv_V_star[i] = cvCreateMat( V_size, V_size, CV_64F );
-    cvSetZero(V[i]);
-    cvSetZero(inv_V_star[i]);
-  }
-
-  //allocate eb
-  eb = new CvMat* [num_points];
-  for (int i = 0; i < num_points; i++ ) {
-    eb[i] = cvCreateMat( V_size, 1, CV_64F );
-    cvSetZero(eb[i]);
-  }
-
-  //allocate Yj
-  Yj = new CvMat* [num_points];
-  for (int i = 0; i < num_points; i++ ) {
-    Yj[i] = cvCreateMat( Wij_height, Wij_width, CV_64F );  //Yij has the same size as Wij
-    cvSetZero(Yj[i]);
-  }
-
-  //allocate matrix S
-  S = cvCreateMat( num_cams * num_cam_param, num_cams * num_cam_param, CV_64F);
-  cvSetZero(S);
-  JtJ_diag = cvCreateMat( num_cams * num_cam_param + num_points * num_point_param, 1, CV_64F );
-  cvSetZero(JtJ_diag);
-
-  //set starting parameters
-  CvMat _tmp_ = CvMat(P0);
-  prevP = cvCloneMat( &_tmp_ );
-  P = cvCloneMat( &_tmp_ );
-  deltaP = cvCloneMat( &_tmp_ );
-
-  //set measurements
-  _tmp_ = CvMat(X_init);
-  X = cvCloneMat( &_tmp_ );
-  //create vector for estimated measurements
-  hX = cvCreateMat( X->rows, X->cols, CV_64F );
-  cvSetZero(hX);
-  //create error vector
-  err = cvCreateMat( X->rows, X->cols, CV_64F );
-  cvSetZero(err);
-  ask_for_proj(_vis);
-  //compute initial error
-  cvSub(X, hX, err );
-
-  /*
-    assert(X->rows == hX->rows);
-    std::cerr<<"X size = "<<X->rows<<" "<<X->cols<<std::endl;
-    std::cerr<<"hX size = "<<hX->rows<<" "<<hX->cols<<std::endl;
-    for (int j=0;j<X->rows;j+=2) {
-    double Xj1 = *(double*)(X->data.ptr + j * X->step);
-    double hXj1 = *(double*)(hX->data.ptr + j * hX->step);
-    double err1 = *(double*)(err->data.ptr + j * err->step);
-    double Xj2 = *(double*)(X->data.ptr + (j+1) * X->step);
-    double hXj2 = *(double*)(hX->data.ptr + (j+1) * hX->step);
-    double err2 = *(double*)(err->data.ptr + (j+1) * err->step);
-    std::cerr<<"("<<Xj1<<","<<Xj2<<") -> ("<<hXj1<<","<<hXj2<<"). err = ("<<err1<<","<<err2<<")"<<std::endl;
-    }
-  */
-
-  prevErrNorm = cvNorm( err, 0,  CV_L2 );
-  //    std::cerr<<"prevErrNorm = "<<prevErrNorm<<std::endl;
-  iters = 0;
-  criteria = criteria_init;
-
-  optimize(_vis);
-
-  ask_for_proj(_vis,true);
-  cvSub(X, hX, err );
-  errNorm = cvNorm( err, 0,  CV_L2 );
-}
-
-void LevMarqSparse::ask_for_proj(CvMat &/*_vis*/,bool once) {
-    (void)once;
-    //given parameter P, compute measurement hX
-    int ind = 0;
-    for (int i = 0; i < num_points; i++ ) {
-        CvMat point_mat;
-        cvGetSubRect( P, &point_mat, cvRect( 0, num_cams * num_cam_param + num_point_param * i, 1, num_point_param ));
-        for (int j = 0; j < num_cams; j++ ) {
-            //CvMat* Aij = ((CvMat**)(A->data.ptr + A->step * i))[j];
-            CvMat* Aij = A[j+i*num_cams];
-            if (Aij ) { //visible
-                CvMat cam_mat;
-                cvGetSubRect( P, &cam_mat, cvRect( 0, j * num_cam_param, 1, num_cam_param ));
-                CvMat measur_mat;
-                cvGetSubRect( hX, &measur_mat, cvRect( 0, ind * num_err_param, 1, num_err_param ));
-                Mat _point_mat = cv::cvarrToMat(&point_mat), _cam_mat = cv::cvarrToMat(&cam_mat), _measur_mat = cv::cvarrToMat(&measur_mat);
-                func( i, j, _point_mat, _cam_mat, _measur_mat, data);
-                assert( ind*num_err_param == ((int*)(Vis_index->data.ptr + i * Vis_index->step))[j]);
-                ind+=1;
-            }
-        }
-    }
-}
-
-//iteratively asks for Jacobians for every camera_point pair
-void LevMarqSparse::ask_for_projac(CvMat &/*_vis*/)   //should be evaluated at point prevP
-{
-    // compute jacobians Aij and Bij
-    for (int i = 0; i < num_points; i++ )
-    {
-        CvMat point_mat;
-        cvGetSubRect( prevP, &point_mat, cvRect( 0, num_cams * num_cam_param + num_point_param * i, 1, num_point_param ));
-
-        //CvMat** A_line = (CvMat**)(A->data.ptr + A->step * i);
-        //CvMat** B_line = (CvMat**)(B->data.ptr + B->step * i);
-        for( int j = 0; j < num_cams; j++ )
-        {
-            //CvMat* Aij = A_line[j];
-            //if( Aij ) //Aij is not zero
-            CvMat* Aij = A[j+i*num_cams];
-            CvMat* Bij = B[j+i*num_cams];
-            if(Aij)
-            {
-                //CvMat** A_line = (CvMat**)(A->data.ptr + A->step * i);
-                //CvMat** B_line = (CvMat**)(B->data.ptr + B->step * i);
-
-                //CvMat* Aij = A_line[j];
-                //CvMat* Aij = ((CvMat**)(A->data.ptr + A->step * i))[j];
-
-                CvMat cam_mat;
-                cvGetSubRect( prevP, &cam_mat, cvRect( 0, j * num_cam_param, 1, num_cam_param ));
-
-                //CvMat* Bij = B_line[j];
-                //CvMat* Bij = ((CvMat**)(B->data.ptr + B->step * i))[j];
-                Mat _point_mat = cv::cvarrToMat(&point_mat), _cam_mat = cv::cvarrToMat(&cam_mat), _Aij = cv::cvarrToMat(Aij), _Bij = cv::cvarrToMat(Bij);
-                (*fjac)(i, j, _point_mat, _cam_mat, _Aij, _Bij, data);
-            }
-        }
-    }
-}
-
-void LevMarqSparse::optimize(CvMat &_vis) { //main function that runs minimization
-  bool done = false;
-
-  CvMat* YWt = cvCreateMat( num_cam_param, num_cam_param, CV_64F ); //this matrix used to store Yij*Wik'
-  CvMat* E = cvCreateMat( S->height, 1 , CV_64F ); //this is right part of system with S
-  cvSetZero(YWt);
-  cvSetZero(E);
-
-  while(!done) {
-    // compute jacobians Aij and Bij
-    ask_for_projac(_vis);
-    int invisible_count=0;
-    //compute U_j  and  ea_j
-    for (int j = 0; j < num_cams; j++ ) {
-      cvSetZero(U[j]);
-      cvSetZero(ea[j]);
-      //summ by i (number of points)
-      for (int i = 0; i < num_points; i++ ) {
-  //get Aij
-  //CvMat* Aij = ((CvMat**)(A->data.ptr + A->step * i))[j];
-  CvMat* Aij = A[j+i*num_cams];
-  if (Aij ) {
-    //Uj+= AijT*Aij
-    cvGEMM( Aij, Aij, 1, U[j], 1, U[j], CV_GEMM_A_T );
-    //ea_j += AijT * e_ij
-    CvMat eij;
-
-    int index = ((int*)(Vis_index->data.ptr + i * Vis_index->step))[j];
-
-    cvGetSubRect( err, &eij, cvRect( 0, index, 1, Aij->height  ) ); //width of transposed Aij
-    cvGEMM( Aij, &eij, 1, ea[j], 1, ea[j], CV_GEMM_A_T );
-  }
-  else
-    invisible_count++;
-      }
-    } //U_j and ea_j computed for all j
-
-    //    if (!(iters%100))
-    {
-      int nviz = X->rows / num_err_param;
-      double e2 = prevErrNorm*prevErrNorm, e2n = e2 / nviz;
-      std::cerr<<"Iteration: "<<iters<<", normError: "<<e2<<" ("<<e2n<<")"<<std::endl;
-    }
-    if (cb)
-      cb(iters, prevErrNorm, user_data);
-    //compute V_i  and  eb_i
-    for (int i = 0; i < num_points; i++ ) {
-      cvSetZero(V[i]);
-      cvSetZero(eb[i]);
-
-      //summ by i (number of points)
-      for( int j = 0; j < num_cams; j++ ) {
-  //get Bij
-  //CvMat* Bij = ((CvMat**)(B->data.ptr + B->step * i))[j];
-  CvMat* Bij = B[j+i*num_cams];
-  if (Bij ) {
-    //Vi+= BijT*Bij
-    cvGEMM( Bij, Bij, 1, V[i], 1, V[i], CV_GEMM_A_T );
-
-    //eb_i += BijT * e_ij
-    int index = ((int*)(Vis_index->data.ptr + i * Vis_index->step))[j];
-
-    CvMat eij;
-    cvGetSubRect( err, &eij, cvRect( 0, index, 1, Bij->height  ) ); //width of transposed Bij
-    cvGEMM( Bij, &eij, 1, eb[i], 1, eb[i], CV_GEMM_A_T );
-  }
-      }
-    } //V_i and eb_i computed for all i
-
-      //compute W_ij
-    for( int i = 0; i < num_points; i++ ) {
-      for( int j = 0; j < num_cams; j++ ) {
-  //CvMat* Aij = ((CvMat**)(A->data.ptr + A->step * i))[j];
-  CvMat* Aij = A[j+i*num_cams];
-  if( Aij ) { //visible
-    //CvMat* Bij = ((CvMat**)(B->data.ptr + B->step * i))[j];
-    CvMat* Bij = B[j+i*num_cams];
-    //CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
-    CvMat* Wij = W[j+i*num_cams];
-
-    //multiply
-    cvGEMM( Aij, Bij, 1, NULL, 0, Wij, CV_GEMM_A_T );
-  }
-      }
-    } //Wij computed
-
-      //backup diagonal of JtJ before we start augmenting it
-    {
-      CvMat dia;
-      CvMat subr;
-      for( int j = 0; j < num_cams; j++ ) {
-  cvGetDiag(U[j], &dia);
-  cvGetSubRect(JtJ_diag, &subr,
-         cvRect(0, j*num_cam_param, 1, num_cam_param ));
-  cvCopy( &dia, &subr );
-      }
-      for( int i = 0; i < num_points; i++ ) {
-  cvGetDiag(V[i], &dia);
-  cvGetSubRect(JtJ_diag, &subr,
-         cvRect(0, num_cams*num_cam_param + i * num_point_param, 1, num_point_param ));
-  cvCopy( &dia, &subr );
-      }
-    }
-
-    if( iters == 0 ) {
-      //initialize lambda. It is set to 1e-3 * average diagonal element in JtJ
-      double average_diag = 0;
-      for( int j = 0; j < num_cams; j++ ) {
-  average_diag += cvTrace( U[j] ).val[0];
-      }
-      for( int i = 0; i < num_points; i++ ) {
-  average_diag += cvTrace( V[i] ).val[0];
-      }
-      average_diag /= (num_cams*num_cam_param + num_points * num_point_param );
-
-      //      lambda = 1e-3 * average_diag;
-      lambda = 1e-3 * average_diag;
-      lambda = 0.245560;
-    }
-
-    //now we are going to find good step and make it
-    for(;;) {
-      //augmentation of diagonal
-      for(int j = 0; j < num_cams; j++ ) {
-  CvMat diag;
-  cvGetDiag( U[j], &diag );
-#if 1
-  cvAddS( &diag, cvScalar( lambda ), &diag );
-#else
-  cvScale( &diag, &diag, 1 + lambda );
-#endif
-      }
-      for(int i = 0; i < num_points; i++ ) {
-  CvMat diag;
-  cvGetDiag( V[i], &diag );
-#if 1
-  cvAddS( &diag, cvScalar( lambda ), &diag );
-#else
-  cvScale( &diag, &diag, 1 + lambda );
-#endif
-      }
-      bool error = false;
-      //compute inv(V*)
-      bool inverted_ok = true;
-      for(int i = 0; i < num_points; i++ ) {
-  double det = cvInvert( V[i], inv_V_star[i] );
-
-  if( fabs(det) <= FLT_EPSILON )  {
-    inverted_ok = false;
-    std::cerr<<"V["<<i<<"] failed"<<std::endl;
-    break;
-  } //means we did wrong augmentation, try to choose different lambda
-      }
-
-      if( inverted_ok ) {
-  cvSetZero( E );
-  //loop through cameras, compute upper diagonal blocks of matrix S
-  for( int j = 0; j < num_cams; j++ ) {
-    //compute Yij = Wij (V*_i)^-1  for all i   (if Wij exists/nonzero)
-    for( int i = 0; i < num_points; i++ ) {
-      //
-      //CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
-      CvMat* Wij = W[j+i*num_cams];
-      if( Wij ) {
-        cvMatMul( Wij, inv_V_star[i], Yj[i] );
-      }
-    }
-
-    //compute Sjk   for k>=j  (because Sjk = Skj)
-    for( int k = j; k < num_cams; k++ ) {
-      cvSetZero( YWt );
-      for( int i = 0; i < num_points; i++ ) {
-        //check that both Wij and Wik exist
-        // CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
-        CvMat* Wij = W[j+i*num_cams];
-        //CvMat* Wik = ((CvMat**)(W->data.ptr + W->step * k))[i];
-        CvMat* Wik = W[k+i*num_cams];
-
-        if( Wij && Wik ) {
-    //multiply YWt += Yj[i]*Wik'
-    cvGEMM( Yj[i], Wik, 1, YWt, 1, YWt, CV_GEMM_B_T  ); ///*transpose Wik
-        }
-      }
-
-      //copy result to matrix S
-
-      CvMat Sjk;
-      //extract submat
-      cvGetSubRect( S, &Sjk, cvRect( k * num_cam_param, j * num_cam_param, num_cam_param, num_cam_param ));
-
-
-      //if j==k, add diagonal
-      if( j != k ) {
-        //just copy with minus
-        cvScale( YWt, &Sjk, -1 ); //if we set initial S to zero then we can use cvSub( Sjk, YWt, Sjk);
-      } else {
-        //add diagonal value
-
-        //subtract YWt from augmented Uj
-        cvSub( U[j], YWt, &Sjk );
-      }
-    }
-
-    //compute right part of equation involving matrix S
-    // e_j=ea_j - \sum_i Y_ij eb_i
-    {
-      CvMat e_j;
-
-      //select submat
-      cvGetSubRect( E, &e_j, cvRect( 0, j * num_cam_param, 1, num_cam_param ) );
-
-      for( int i = 0; i < num_points; i++ ) {
-        //CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
-        CvMat* Wij = W[j+i*num_cams];
-        if( Wij )
-    cvMatMulAdd( Yj[i], eb[i], &e_j, &e_j );
-      }
-
-      cvSub( ea[j], &e_j, &e_j );
-    }
-
-  }
-  //fill below diagonal elements of matrix S
-  cvCompleteSymm( S,  0  ); ///*from upper to low //operation may be done by nonzero blocks or during upper diagonal computation
-
-  //Solve linear system  S * deltaP_a = E
-  CvMat dpa;
-  cvGetSubRect( deltaP, &dpa, cvRect(0, 0, 1, S->width ) );
-  int res = cvSolve( S, E, &dpa, CV_CHOLESKY );
-
-  if( res ) { //system solved ok
-    //compute db_i
-    for( int i = 0; i < num_points; i++ ) {
-      CvMat dbi;
-      cvGetSubRect( deltaP, &dbi, cvRect( 0, dpa.height + i * num_point_param, 1, num_point_param ) );
-
-      // compute \sum_j W_ij^T da_j
-      for( int j = 0; j < num_cams; j++ ) {
-        //get Wij
-        //CvMat* Wij = ((CvMat**)(W->data.ptr + W->step * j))[i];
-        CvMat* Wij = W[j+i*num_cams];
-        if( Wij ) {
-    //get da_j
-    CvMat daj;
-    cvGetSubRect( &dpa, &daj, cvRect( 0, j * num_cam_param, 1, num_cam_param ));
-    cvGEMM( Wij, &daj, 1, &dbi, 1, &dbi, CV_GEMM_A_T  ); ///* transpose Wij
-        }
-      }
-      //finalize dbi
-      cvSub( eb[i], &dbi, &dbi );
-      cvMatMul(inv_V_star[i], &dbi, &dbi );  //here we get final dbi
-    }  //now we computed whole deltaP
-
-    //add deltaP to delta
-    cvAdd( prevP, deltaP, P );
-
-    //evaluate  function with new parameters
-    ask_for_proj(_vis); // func( P, hX );
-
-    //compute error
-    errNorm = cvNorm( X, hX, CV_L2 );
-
-  } else {
-    error = true;
-  }
-      } else {
-  error = true;
-      }
-      //check solution
-      if( error || ///* singularities somewhere
-    errNorm > prevErrNorm )  { //step was not accepted
-  //increase lambda and reject change
-  lambda *= 10;
-  {
-    int nviz = X->rows / num_err_param;
-    double e2 = errNorm*errNorm, e2_prev = prevErrNorm*prevErrNorm;
-    double e2n = e2/nviz, e2n_prev = e2_prev/nviz;
-    std::cerr<<"move failed: lambda = "<<lambda<<", e2 = "<<e2<<" ("<<e2n<<") > "<<e2_prev<<" ("<<e2n_prev<<")"<<std::endl;
-  }
-
-  //restore diagonal from backup
-  {
-    CvMat dia;
-    CvMat subr;
-    for( int j = 0; j < num_cams; j++ ) {
-      cvGetDiag(U[j], &dia);
-      cvGetSubRect(JtJ_diag, &subr,
-       cvRect(0, j*num_cam_param, 1, num_cam_param ));
-      cvCopy( &subr, &dia );
-    }
-    for( int i = 0; i < num_points; i++ ) {
-      cvGetDiag(V[i], &dia);
-      cvGetSubRect(JtJ_diag, &subr,
-       cvRect(0, num_cams*num_cam_param + i * num_point_param, 1, num_point_param ));
-      cvCopy( &subr, &dia );
-    }
-  }
-      } else {  //all is ok
-  //accept change and decrease lambda
-  lambda /= 10;
-  lambda = MAX(lambda, 1e-16);
-  std::cerr<<"decreasing lambda to "<<lambda<<std::endl;
-  prevErrNorm = errNorm;
-
-  //compute new projection error vector
-  cvSub(  X, hX, err );
-  break;
-      }
-    }
-    iters++;
-
-    double param_change_norm = cvNorm(P, prevP, CV_RELATIVE_L2);
-    //check termination criteria
-    if( (criteria.type&CV_TERMCRIT_ITER && iters > criteria.max_iter ) ||
-  (criteria.type&CV_TERMCRIT_EPS && param_change_norm < criteria.epsilon) ) {
-      //      std::cerr<<"relative norm change "<<param_change_norm<<" lower than eps "<<criteria.epsilon<<", stopping"<<std::endl;
-      done = true;
-      break;
-    } else {
-      //copy new params and continue iterations
-      cvCopy( P, prevP );
-    }
-  }
-  cvReleaseMat(&YWt);
-  cvReleaseMat(&E);
-}
-
-//Utilities
-
-static void fjac(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, CvMat* A, CvMat* B, void* /*data*/) {
-  //compute jacobian per camera parameters (i.e. Aij)
-  //take i-th point 3D current coordinates
-
-  CvMat _Mi;
-  cvReshape(point_params, &_Mi, 3, 1 );
-
-  CvMat* _mp = cvCreateMat(1, 1, CV_64FC2 ); //projection of the point
-
-  //split camera params into different matrices
-  CvMat _ri, _ti, _k = cvMat(0, 0, CV_64F, NULL); // dummy initialization to fix warning of cl.exe
-  cvGetRows( cam_params, &_ri, 0, 3 );
-  cvGetRows( cam_params, &_ti, 3, 6 );
-
-  double intr_data[9] = {0, 0, 0, 0, 0, 0, 0, 0, 1};
-  intr_data[0] = cam_params->data.db[6];
-  intr_data[4] = cam_params->data.db[7];
-  intr_data[2] = cam_params->data.db[8];
-  intr_data[5] = cam_params->data.db[9];
-
-  CvMat _A = cvMat(3,3, CV_64F, intr_data );
-
-  CvMat _dpdr, _dpdt, _dpdf, _dpdc, _dpdk;
-
-  bool have_dk = cam_params->height - 10 ? true : false;
-
-  cvGetCols( A, &_dpdr, 0, 3 );
-  cvGetCols( A, &_dpdt, 3, 6 );
-  cvGetCols( A, &_dpdf, 6, 8 );
-  cvGetCols( A, &_dpdc, 8, 10 );
-
-  if( have_dk ) {
-    cvGetRows( cam_params, &_k, 10, cam_params->height );
-    cvGetCols( A, &_dpdk, 10, A->width );
-  }
-  cvProjectPoints2(&_Mi, &_ri, &_ti, &_A, have_dk ? &_k : NULL, _mp, &_dpdr, &_dpdt,
-       &_dpdf, &_dpdc, have_dk ? &_dpdk : NULL, 0);
-
-  cvReleaseMat( &_mp );
-
-  //compute jacobian for point params
-  //compute dMeasure/dPoint3D
-
-  // x = (r11 * X + r12 * Y + r13 * Z + t1)
-  // y = (r21 * X + r22 * Y + r23 * Z + t2)
-  // z = (r31 * X + r32 * Y + r33 * Z + t3)
-
-  // x' = x/z
-  // y' = y/z
-
-  //d(x') = ( dx*z - x*dz)/(z*z)
-  //d(y') = ( dy*z - y*dz)/(z*z)
-
-  //g = 1 + k1*r_2 + k2*r_4 + k3*r_6
-  //r_2 = x'*x' + y'*y'
-
-  //d(r_2) = 2*x'*dx' + 2*y'*dy'
-
-  //dg = k1* d(r_2) + k2*2*r_2*d(r_2) + k3*3*r_2*r_2*d(r_2)
-
-  //x" = x'*g + 2*p1*x'*y' + p2(r_2+2*x'_2)
-  //y" = y'*g + p1(r_2+2*y'_2) + 2*p2*x'*y'
-
-  //d(x") = d(x') * g + x' * d(g) + 2*p1*( d(x')*y' + x'*dy) + p2*(d(r_2) + 2*2*x'* dx')
-  //d(y") = d(y') * g + y' * d(g) + 2*p2*( d(x')*y' + x'*dy) + p1*(d(r_2) + 2*2*y'* dy')
-
-  // u = fx*( x") + cx
-  // v = fy*( y") + cy
-
-  // du = fx * d(x")  = fx * ( dx*z - x*dz)/ (z*z)
-  // dv = fy * d(y")  = fy * ( dy*z - y*dz)/ (z*z)
-
-  // dx/dX = r11,  dx/dY = r12, dx/dZ = r13
-  // dy/dX = r21,  dy/dY = r22, dy/dZ = r23
-  // dz/dX = r31,  dz/dY = r32, dz/dZ = r33
-
-  // du/dX = fx*(r11*z-x*r31)/(z*z)
-  // du/dY = fx*(r12*z-x*r32)/(z*z)
-  // du/dZ = fx*(r13*z-x*r33)/(z*z)
-
-  // dv/dX = fy*(r21*z-y*r31)/(z*z)
-  // dv/dY = fy*(r22*z-y*r32)/(z*z)
-  // dv/dZ = fy*(r23*z-y*r33)/(z*z)
-
-  //get rotation matrix
-  double R[9], t[3], fx = intr_data[0], fy = intr_data[4];
-  CvMat _R = cvMat( 3, 3, CV_64F, R );
-  cvRodrigues2(&_ri, &_R);
-
-  double X,Y,Z;
-  X = point_params->data.db[0];
-  Y = point_params->data.db[1];
-  Z = point_params->data.db[2];
-
-  t[0] = _ti.data.db[0];
-  t[1] = _ti.data.db[1];
-  t[2] = _ti.data.db[2];
-
-  //compute x,y,z
-  double x = R[0] * X + R[1] * Y + R[2] * Z + t[0];
-  double y = R[3] * X + R[4] * Y + R[5] * Z + t[1];
-  double z = R[6] * X + R[7] * Y + R[8] * Z + t[2];
-
-#if 1
-  //compute x',y'
-  double x_strike = x/z;
-  double y_strike = y/z;
-  //compute dx',dy'  matrix
-  //
-  //    dx'/dX  dx'/dY dx'/dZ    =
-  //    dy'/dX  dy'/dY dy'/dZ
-
-  double coeff[6] = { z, 0, -x,
-          0, z, -y };
-  CvMat coeffmat = cvMat( 2, 3, CV_64F, coeff );
-
-  CvMat* dstrike_dbig = cvCreateMat(2,3,CV_64F);
-  cvMatMul(&coeffmat, &_R, dstrike_dbig);
-  cvScale(dstrike_dbig, dstrike_dbig, 1/(z*z) );
-
-  if( have_dk ) {
-    double strike_[2] = {x_strike, y_strike};
-    CvMat strike = cvMat(1, 2, CV_64F, strike_);
-
-    //compute r_2
-    double r_2 = x_strike*x_strike + y_strike*y_strike;
-    double r_4 = r_2*r_2;
-    double r_6 = r_4*r_2;
-
-    //compute d(r_2)/dbig
-    CvMat* dr2_dbig = cvCreateMat(1,3,CV_64F);
-    cvMatMul( &strike, dstrike_dbig, dr2_dbig);
-    cvScale( dr2_dbig, dr2_dbig, 2 );
-
-    double& k1 = _k.data.db[0];
-    double& k2 = _k.data.db[1];
-    double& p1 = _k.data.db[2];
-    double& p2 = _k.data.db[3];
-    double k3 = 0;
-
-    if( _k.cols*_k.rows == 5 ) {
-      k3 = _k.data.db[4];
-    }
-    //compute dg/dbig
-    double dg_dr2 = k1 + k2*2*r_2 + k3*3*r_4;
-    double g = 1+k1*r_2+k2*r_4+k3*r_6;
-
-    CvMat* dg_dbig = cvCreateMat(1,3,CV_64F);
-    cvScale( dr2_dbig, dg_dbig, dg_dr2 );
-
-    CvMat* tmp = cvCreateMat( 2, 3, CV_64F );
-    CvMat* dstrike2_dbig = cvCreateMat( 2, 3, CV_64F );
-
-    double c[4] = { g+2*p1*y_strike+4*p2*x_strike,       2*p1*x_strike,
-        2*p2*y_strike,                 g+2*p2*x_strike + 4*p1*y_strike };
-
-    CvMat coeffmat2 = cvMat(2,2,CV_64F, c );
-
-    cvMatMul(&coeffmat2, dstrike_dbig, dstrike2_dbig );
-
-    cvGEMM( &strike, dg_dbig, 1, NULL, 0, tmp, CV_GEMM_A_T );
-    cvAdd( dstrike2_dbig, tmp, dstrike2_dbig );
-
-    double p[2] = { p2, p1 };
-    CvMat pmat = cvMat(2, 1, CV_64F, p );
-
-    cvMatMul( &pmat, dr2_dbig ,tmp);
-    cvAdd( dstrike2_dbig, tmp, dstrike2_dbig );
-
-    cvCopy( dstrike2_dbig, B );
-
-    cvReleaseMat(&dr2_dbig);
-    cvReleaseMat(&dg_dbig);
-
-    cvReleaseMat(&tmp);
-    cvReleaseMat(&dstrike2_dbig);
-    cvReleaseMat(&tmp);
-  } else {
-    cvCopy(dstrike_dbig, B);
-  }
-  //multiply by fx, fy
-  CvMat row;
-  cvGetRows( B, &row, 0, 1 );
-  cvScale( &row, &row, fx );
-
-  cvGetRows( B, &row, 1, 2 );
-  cvScale( &row, &row, fy );
-
-#else
-
-  double k = fx/(z*z);
-
-  cvmSet( B, 0, 0, k*(R[0]*z-x*R[6]));
-  cvmSet( B, 0, 1, k*(R[1]*z-x*R[7]));
-  cvmSet( B, 0, 2, k*(R[2]*z-x*R[8]));
-
-  k = fy/(z*z);
-
-  cvmSet( B, 1, 0, k*(R[3]*z-y*R[6]));
-  cvmSet( B, 1, 1, k*(R[4]*z-y*R[7]));
-  cvmSet( B, 1, 2, k*(R[5]*z-y*R[8]));
-
-#endif
-
-}
-static void func(int /*i*/, int /*j*/, CvMat *point_params, CvMat* cam_params, CvMat* estim, void* /*data*/) {
-  //just do projections
-  CvMat _Mi;
-  cvReshape( point_params, &_Mi, 3, 1 );
-
-  CvMat* _mp = cvCreateMat(1, 1, CV_64FC2 ); //projection of the point
-  CvMat* _mp2 = cvCreateMat(1, 2, CV_64F ); //projection of the point
-
-  //split camera params into different matrices
-  CvMat _ri, _ti, _k;
-
-  cvGetRows( cam_params, &_ri, 0, 3 );
-  cvGetRows( cam_params, &_ti, 3, 6 );
-
-  double intr_data[9] = {0, 0, 0, 0, 0, 0, 0, 0, 1};
-  intr_data[0] = cam_params->data.db[6];
-  intr_data[4] = cam_params->data.db[7];
-  intr_data[2] = cam_params->data.db[8];
-  intr_data[5] = cam_params->data.db[9];
-
-  CvMat _A = cvMat(3,3, CV_64F, intr_data );
-
-  //int cn = CV_MAT_CN(_Mi.type);
-
-  bool have_dk = cam_params->height - 10 ? true : false;
-
-  if( have_dk ) {
-    cvGetRows( cam_params, &_k, 10, cam_params->height );
-  }
-  cvProjectPoints2( &_Mi, &_ri, &_ti, &_A, have_dk ? &_k : NULL, _mp, NULL, NULL,
-        NULL, NULL, NULL, 0);
-  //    std::cerr<<"_mp = "<<_mp->data.db[0]<<","<<_mp->data.db[1]<<std::endl;
-  //
-  _mp2->data.db[0] = _mp->data.db[0];
-  _mp2->data.db[1] = _mp->data.db[1];
-  cvTranspose( _mp2, estim );
-  cvReleaseMat( &_mp );
-  cvReleaseMat( &_mp2 );
-}
-
-static void fjac_new(int i, int j, Mat& point_params, Mat& cam_params, Mat& A, Mat& B, void* data) {
-  CvMat _point_params = point_params, _cam_params = cam_params, _Al = A, _Bl = B;
-  fjac(i,j, &_point_params, &_cam_params, &_Al, &_Bl, data);
-}
-
-static void func_new(int i, int j, Mat& point_params, Mat& cam_params, Mat& estim, void* data)  {
-  CvMat _point_params = point_params, _cam_params = cam_params, _estim = estim;
-  func(i,j,&_point_params,&_cam_params,&_estim,data);
-}
-
-void LevMarqSparse::bundleAdjust( std::vector<Point3d>& points, //positions of points in global coordinate system (input and output)
-          const std::vector<std::vector<Point2d> >& imagePoints, //projections of 3d points for every camera
-          const std::vector<std::vector<int> >& visibility, //visibility of 3d points for every camera
-          std::vector<Mat>& cameraMatrix, //intrinsic matrices of all cameras (input and output)
-          std::vector<Mat>& R, //rotation matrices of all cameras (input and output)
-          std::vector<Mat>& T, //translation vector of all cameras (input and output)
-          std::vector<Mat>& distCoeffs, //distortion coefficients of all cameras (input and output)
-          const TermCriteria& criteria,
-          BundleAdjustCallback cb, void* user_data) {
-  //,enum{MOTION_AND_STRUCTURE,MOTION,STRUCTURE})
-  int num_points = (int)points.size();
-  int num_cameras = (int)cameraMatrix.size();
-
-  CV_Assert( imagePoints.size() == (size_t)num_cameras &&
-       visibility.size() == (size_t)num_cameras &&
-       R.size() == (size_t)num_cameras &&
-       T.size() == (size_t)num_cameras &&
-       (distCoeffs.size() == (size_t)num_cameras || distCoeffs.size() == 0) );
-
-  int numdist = distCoeffs.size() ? (distCoeffs[0].rows * distCoeffs[0].cols) : 0;
-
-  int num_cam_param = 3 /* rotation vector */ + 3 /* translation vector */
-    + 2 /* fx, fy */ + 2 /* cx, cy */ + numdist;
-
-  int num_point_param = 3;
-
-  //collect camera parameters into vector
-  Mat params( num_cameras * num_cam_param + num_points * num_point_param, 1, CV_64F );
-
-  //fill camera params
-  for( int i = 0; i < num_cameras; i++ ) {
-    //rotation
-    Mat rot_vec; Rodrigues( R[i], rot_vec );
-    Mat dst = params.rowRange(i*num_cam_param, i*num_cam_param+3);
-    rot_vec.copyTo(dst);
-
-    //translation
-    dst = params.rowRange(i*num_cam_param + 3, i*num_cam_param+6);
-    T[i].copyTo(dst);
-
-    //intrinsic camera matrix
-    double* intr_data = (double*)cameraMatrix[i].data;
-    double* intr = (double*)(params.data + params.step * (i*num_cam_param+6));
-    //focals
-    intr[0] = intr_data[0];  //fx
-    intr[1] = intr_data[4];  //fy
-    //center of projection
-    intr[2] = intr_data[2];  //cx
-    intr[3] = intr_data[5];  //cy
-
-    //add distortion if exists
-    if( distCoeffs.size() ) {
-      dst = params.rowRange(i*num_cam_param + 10, i*num_cam_param+10+numdist);
-      distCoeffs[i].copyTo(dst);
-    }
-  }
-
-  //fill point params
-  Mat ptparams(num_points, 1, CV_64FC3, params.data + num_cameras*num_cam_param*params.step);
-  Mat _points(points);
-  CV_Assert(_points.size() == ptparams.size() && _points.type() == ptparams.type());
-  _points.copyTo(ptparams);
-
-  //convert visibility vectors to visibility matrix
-  Mat vismat(num_points, num_cameras, CV_32S);
-  for( int i = 0; i < num_cameras; i++ ) {
-    //get row
-    Mat col = vismat.col(i);
-    Mat((int)visibility[i].size(), 1, vismat.type(), (void*)&visibility[i][0]).copyTo( col );
-  }
-
-  int num_proj = countNonZero(vismat); //total number of points projections
-
-  //collect measurements
-  Mat X(num_proj*2,1,CV_64F); //measurement vector
-
-  int counter = 0;
-  for(int i = 0; i < num_points; i++ ) {
-    for(int j = 0; j < num_cameras; j++ ) {
-      //check visibility
-      if( visibility[j][i] ) {
-  //extract point and put tu vector
-  Point2d p = imagePoints[j][i];
-  ((double*)(X.data))[counter] = p.x;
-  ((double*)(X.data))[counter+1] = p.y;
-  assert(p.x != -1 || p.y != -1);
-  counter+=2;
-      }
-    }
-  }
-
-  LevMarqSparse levmar( num_points, num_cameras, num_point_param, num_cam_param, 2, vismat, params, X,
-      TermCriteria(criteria), fjac_new, func_new, NULL,
-      cb, user_data);
-  //extract results
-  //fill point params
-  /*Mat final_points(num_points, 1, CV_64FC3,
-    levmar.P->data.db + num_cameras*num_cam_param *levmar.P->step);
-    CV_Assert(_points.size() == final_points.size() && _points.type() == final_points.type());
-    final_points.copyTo(_points);*/
-
-  points.clear();
-  for( int i = 0; i < num_points; i++ ) {
-    CvMat point_mat;
-    cvGetSubRect( levmar.P, &point_mat, cvRect( 0, levmar.num_cams * levmar.num_cam_param+ levmar.num_point_param * i, 1, levmar.num_point_param ));
-    CvScalar x = cvGet2D(&point_mat,0,0); CvScalar y = cvGet2D(&point_mat,1,0); CvScalar z = cvGet2D(&point_mat,2,0);
-    points.push_back(Point3d(x.val[0],y.val[0],z.val[0]));
-    //std::cerr<<"point"<<points[points.size()-1].x<<","<<points[points.size()-1].y<<","<<points[points.size()-1].z<<std::endl;
-  }
-  //fill camera params
-  //R.clear();T.clear();cameraMatrix.clear();
-  Mat levmarP = cv::cvarrToMat(levmar.P);
-  for( int i = 0; i < num_cameras; i++ ) {
-    //rotation
-    Mat rot_vec = levmarP.rowRange(i*num_cam_param, i*num_cam_param+3);
-    Rodrigues( rot_vec, R[i] );
-    //translation
-    levmarP.rowRange(i*num_cam_param + 3, i*num_cam_param+6).copyTo(T[i]);
-
-    //intrinsic camera matrix
-    double* intr_data = (double*)cameraMatrix[i].data;
-    double* intr = (double*)(levmarP.data +levmarP.step * (i*num_cam_param+6));
-    //focals
-    intr_data[0] = intr[0];  //fx
-    intr_data[4] = intr[1];  //fy
-    //center of projection
-    intr_data[2] = intr[2];  //cx
-    intr_data[5] = intr[3];  //cy
-
-    //add distortion if exists
-    if( distCoeffs.size() ) {
-      levmarP.rowRange(i*num_cam_param + 10, i*num_cam_param+10+numdist).copyTo(distCoeffs[i]);
-    }
-  }
-}
diff --git a/modules/contrib/src/bowmsctrainer.cpp b/modules/contrib/src/bowmsctrainer.cpp
deleted file mode 100644 (file)
index 3057691..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-// This file originates from the openFABMAP project:
-// [http://code.google.com/p/openfabmap/]
-//
-// For published work which uses all or part of OpenFABMAP, please cite:
-// [http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6224843]
-//
-// Original Algorithm by Mark Cummins and Paul Newman:
-// [http://ijr.sagepub.com/content/27/6/647.short]
-// [http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5613942]
-// [http://ijr.sagepub.com/content/30/9/1100.abstract]
-//
-//                           License Agreement
-//
-// Copyright (C) 2012 Arren Glover [aj.glover@qut.edu.au] and
-//                    Will Maddern [w.maddern@qut.edu.au], all rights reserved.
-//
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "opencv2/contrib/openfabmap.hpp"
-
-namespace cv {
-
-namespace of2 {
-
-BOWMSCTrainer::BOWMSCTrainer(double _clusterSize) :
-    clusterSize(_clusterSize) {
-}
-
-BOWMSCTrainer::~BOWMSCTrainer() {
-}
-
-Mat BOWMSCTrainer::cluster() const {
-    CV_Assert(!descriptors.empty());
-    int descCount = 0;
-    for(size_t i = 0; i < descriptors.size(); i++)
-    descCount += descriptors[i].rows;
-
-    Mat mergedDescriptors(descCount, descriptors[0].cols,
-        descriptors[0].type());
-    for(size_t i = 0, start = 0; i < descriptors.size(); i++)
-    {
-        Mat submut = mergedDescriptors.rowRange((int)start,
-            (int)(start + descriptors[i].rows));
-        descriptors[i].copyTo(submut);
-        start += descriptors[i].rows;
-    }
-    return cluster(mergedDescriptors);
-}
-
-Mat BOWMSCTrainer::cluster(const Mat& _descriptors) const {
-
-    CV_Assert(!_descriptors.empty());
-
-    // TODO: sort the descriptors before clustering.
-
-
-    Mat icovar = Mat::eye(_descriptors.cols,_descriptors.cols,_descriptors.type());
-
-    std::vector<Mat> initialCentres;
-    initialCentres.push_back(_descriptors.row(0));
-    for (int i = 1; i < _descriptors.rows; i++) {
-        double minDist = DBL_MAX;
-        for (size_t j = 0; j < initialCentres.size(); j++) {
-            minDist = std::min(minDist,
-                cv::Mahalanobis(_descriptors.row(i),initialCentres[j],
-                icovar));
-        }
-        if (minDist > clusterSize)
-            initialCentres.push_back(_descriptors.row(i));
-    }
-
-    std::vector<std::list<cv::Mat> > clusters;
-    clusters.resize(initialCentres.size());
-    for (int i = 0; i < _descriptors.rows; i++) {
-        int index = 0; double dist = 0, minDist = DBL_MAX;
-        for (size_t j = 0; j < initialCentres.size(); j++) {
-            dist = cv::Mahalanobis(_descriptors.row(i),initialCentres[j],icovar);
-            if (dist < minDist) {
-                minDist = dist;
-                index = (int)j;
-            }
-        }
-        clusters[index].push_back(_descriptors.row(i));
-    }
-
-    // TODO: throw away small clusters.
-
-    Mat vocabulary;
-    Mat centre = Mat::zeros(1,_descriptors.cols,_descriptors.type());
-    for (size_t i = 0; i < clusters.size(); i++) {
-        centre.setTo(0);
-        for (std::list<cv::Mat>::iterator Ci = clusters[i].begin(); Ci != clusters[i].end(); Ci++) {
-            centre += *Ci;
-        }
-        centre /= (double)clusters[i].size();
-        vocabulary.push_back(centre);
-    }
-
-    return vocabulary;
-}
-
-}
-
-}
diff --git a/modules/contrib/src/chamfermatching.cpp b/modules/contrib/src/chamfermatching.cpp
deleted file mode 100644 (file)
index d60a73d..0000000
+++ /dev/null
@@ -1,1411 +0,0 @@
-/*********************************************************************
- * Software License Agreement (BSD License)
- *
- *  Copyright (c) 2008-2010, Willow Garage, Inc.
- *  All rights reserved.
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions
- *  are met:
- *
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above
- *     copyright notice, this list of conditions and the following
- *     disclaimer in the documentation and/or other materials provided
- *     with the distribution.
- *   * Neither the name of the Willow Garage nor the names of its
- *     contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- *  POSSIBILITY OF SUCH DAMAGE.
- *********************************************************************/
-
-//
-// The original code was written by
-//          Marius Muja
-// and later modified and prepared
-//  for integration into OpenCV by
-//        Antonella Cascitelli,
-//        Marco Di Stefano and
-//          Stefano Fabri
-//        from Univ. of Rome
-//
-
-#include "precomp.hpp"
-#include "opencv2/opencv_modules.hpp"
-#ifdef HAVE_OPENCV_HIGHGUI
-#  include "opencv2/highgui.hpp"
-#endif
-#include <iostream>
-#include <queue>
-
-namespace cv
-{
-
-typedef std::pair<int,int> coordinate_t;
-typedef float orientation_t;
-typedef std::vector<coordinate_t> template_coords_t;
-typedef std::vector<orientation_t> template_orientations_t;
-typedef std::pair<Point, float> location_scale_t;
-
-class ChamferMatcher
-{
-
-private:
-    class Matching;
-    int max_matches_;
-    float min_match_distance_;
-
-    ///////////////////////// Image iterators ////////////////////////////
-
-    class ImageIterator
-    {
-    public:
-        virtual ~ImageIterator() {}
-        virtual bool hasNext() const = 0;
-        virtual location_scale_t next() = 0;
-    };
-
-    class ImageRange
-    {
-    public:
-        virtual ImageIterator* iterator() const = 0;
-        virtual ~ImageRange() {}
-    };
-
-    // Sliding window
-
-    class SlidingWindowImageRange : public ImageRange
-    {
-        int width_;
-        int height_;
-        int x_step_;
-        int y_step_;
-        int scales_;
-        float min_scale_;
-        float max_scale_;
-
-    public:
-        SlidingWindowImageRange(int width, int height, int x_step = 3, int y_step = 3, int _scales = 5, float min_scale = 0.6, float max_scale = 1.6) :
-        width_(width), height_(height), x_step_(x_step),y_step_(y_step), scales_(_scales), min_scale_(min_scale), max_scale_(max_scale)
-        {
-        }
-
-
-        ImageIterator* iterator() const;
-    };
-
-    class LocationImageRange : public ImageRange
-    {
-        const std::vector<Point>& locations_;
-
-        int scales_;
-        float min_scale_;
-        float max_scale_;
-
-        LocationImageRange(const LocationImageRange&);
-        LocationImageRange& operator=(const LocationImageRange&);
-
-    public:
-        LocationImageRange(const std::vector<Point>& locations, int _scales = 5, float min_scale = 0.6, float max_scale = 1.6) :
-        locations_(locations), scales_(_scales), min_scale_(min_scale), max_scale_(max_scale)
-        {
-        }
-
-        ImageIterator* iterator() const
-        {
-            return new LocationImageIterator(locations_, scales_, min_scale_, max_scale_);
-        }
-    };
-
-
-    class LocationScaleImageRange : public ImageRange
-    {
-        const std::vector<Point>& locations_;
-        const std::vector<float>& scales_;
-
-        LocationScaleImageRange(const LocationScaleImageRange&);
-        LocationScaleImageRange& operator=(const LocationScaleImageRange&);
-    public:
-        LocationScaleImageRange(const std::vector<Point>& locations, const std::vector<float>& _scales) :
-        locations_(locations), scales_(_scales)
-        {
-            CV_Assert(locations.size()==_scales.size());
-        }
-
-        ImageIterator* iterator() const
-        {
-            return new LocationScaleImageIterator(locations_, scales_);
-        }
-    };
-
-
-
-
-public:
-    /**
-     * Class that represents a template for chamfer matching.
-     */
-    class Template
-    {
-        friend class ChamferMatcher::Matching;
-        friend class ChamferMatcher;
-
-
-    public:
-        std::vector<Template*> scaled_templates;
-        std::vector<int> addr;
-        int addr_width;
-        float scale;
-        template_coords_t coords;
-
-        template_orientations_t orientations;
-        Size size;
-        Point center;
-
-    public:
-        Template() : addr_width(-1)
-        {
-        }
-
-        Template(Mat& edge_image, float scale_ = 1);
-
-        ~Template()
-        {
-            for (size_t i=0;i<scaled_templates.size();++i) {
-                delete scaled_templates[i];
-            }
-            scaled_templates.clear();
-            coords.clear();
-            orientations.clear();
-        }
-        void show() const;
-
-
-
-    private:
-        /**
-         * Resizes a template
-         *
-         * @param scale Scale to be resized to
-         */
-        Template* rescale(float scale);
-
-        std::vector<int>& getTemplateAddresses(int width);
-    };
-
-
-
-    /**
-     * Used to represent a matching result.
-     */
-
-    class Match
-    {
-    public:
-        float cost;
-        Point offset;
-        const Template* tpl;
-    };
-
-    typedef std::vector<Match> Matches;
-
-private:
-    /**
-     * Implements the chamfer matching algorithm on images taking into account both distance from
-     * the template pixels to the nearest pixels and orientation alignment between template and image
-     * contours.
-     */
-    class Matching
-    {
-        float truncate_;
-        bool use_orientation_;
-
-        std::vector<Template*> templates;
-    public:
-        Matching(bool use_orientation = true, float _truncate = 10) : truncate_(_truncate), use_orientation_(use_orientation)
-        {
-        }
-
-        ~Matching()
-        {
-            for (size_t i = 0; i<templates.size(); i++) {
-                delete templates[i];
-            }
-        }
-
-        /**
-         * Add a template to the detector from an edge image.
-         * @param templ An edge image
-         */
-        void addTemplateFromImage(Mat& templ, float scale = 1.0);
-
-        /**
-         * Run matching using an edge image.
-         * @param edge_img Edge image
-         * @return a match object
-         */
-        ChamferMatcher::Matches* matchEdgeImage(Mat& edge_img, const ImageRange& range, float orientation_weight = 0.5, int max_matches = 20, float min_match_distance = 10.0);
-
-        void addTemplate(Template& template_);
-
-    private:
-
-        float orientation_diff(float o1, float o2)
-        {
-            return fabs(o1-o2);
-        }
-
-        /**
-         * Computes the chamfer matching cost for one position in the target image.
-         * @param offset Offset where to compute cost
-         * @param dist_img Distance transform image.
-         * @param orientation_img Orientation image.
-         * @param tpl Template
-         * @param templ_orientations Orientations of the target points.
-         * @return matching result
-         */
-        ChamferMatcher::Match* localChamferDistance(Point offset, Mat& dist_img, Mat& orientation_img, Template* tpl,  float orientation_weight);
-
-    private:
-        /**
-         * Matches all templates.
-         * @param dist_img Distance transform image.
-         * @param orientation_img Orientation image.
-         */
-        ChamferMatcher::Matches* matchTemplates(Mat& dist_img, Mat& orientation_img, const ImageRange& range, float orientation_weight);
-
-        void computeDistanceTransform(Mat& edges_img, Mat& dist_img, Mat& annotate_img, float truncate_dt, float a, float b);
-        void computeEdgeOrientations(Mat& edge_img, Mat& orientation_img);
-        void fillNonContourOrientations(Mat& annotated_img, Mat& orientation_img);
-
-
-    public:
-        /**
-         * Finds a contour in an edge image. The original image is altered by removing the found contour.
-         * @param templ_img Edge image
-         * @param coords Coordinates forming the contour.
-         * @return True while a contour is still found in the image.
-         */
-        static bool findContour(Mat& templ_img, template_coords_t& coords);
-
-        /**
-         * Computes contour points orientations using the approach from:
-         *
-         * Matas, Shao and Kittler - Estimation of Curvature and Tangent Direction by
-         * Median Filtered Differencing
-         *
-         * @param coords Contour points
-         * @param orientations Contour points orientations
-         */
-        static void findContourOrientations(const template_coords_t& coords, template_orientations_t& orientations);
-
-
-        /**
-         * Computes the angle of a line segment.
-         *
-         * @param a One end of the line segment
-         * @param b The other end.
-         * @param dx
-         * @param dy
-         * @return Angle in radians.
-         */
-        static float getAngle(coordinate_t a, coordinate_t b, int& dx, int& dy);
-
-        /**
-         * Finds a point in the image from which to start contour following.
-         * @param templ_img
-         * @param p
-         * @return
-         */
-
-        static bool findFirstContourPoint(Mat& templ_img, coordinate_t& p);
-        /**
-         * Method that extracts a single continuous contour from an image given a starting point.
-         * When it extracts the contour it tries to maintain the same direction (at a T-join for example).
-         *
-         * @param templ_
-         * @param coords
-         * @param direction
-         */
-        static void followContour(Mat& templ_img, template_coords_t& coords, int direction);
-
-
-    };
-
-
-
-
-    class LocationImageIterator : public ImageIterator
-    {
-        const std::vector<Point>& locations_;
-
-        size_t iter_;
-
-        int scales_;
-        float min_scale_;
-        float max_scale_;
-
-        float scale_;
-        float scale_step_;
-        int scale_cnt_;
-
-        bool has_next_;
-
-        LocationImageIterator(const LocationImageIterator&);
-        LocationImageIterator& operator=(const LocationImageIterator&);
-
-    public:
-        LocationImageIterator(const std::vector<Point>& locations, int _scales, float min_scale, float max_scale);
-
-        bool hasNext() const {
-            return has_next_;
-        }
-
-        location_scale_t next();
-    };
-
-    class LocationScaleImageIterator : public ImageIterator
-    {
-        const std::vector<Point>& locations_;
-        const std::vector<float>& scales_;
-
-        size_t iter_;
-
-        bool has_next_;
-
-        LocationScaleImageIterator(const LocationScaleImageIterator&);
-        LocationScaleImageIterator& operator=(const LocationScaleImageIterator&);
-
-    public:
-        LocationScaleImageIterator(const std::vector<Point>& locations, const std::vector<float>& _scales) :
-        locations_(locations), scales_(_scales)
-        {
-            CV_Assert(locations.size()==_scales.size());
-            reset();
-        }
-
-        void reset()
-        {
-            iter_ = 0;
-            has_next_ = (locations_.size()==0 ? false : true);
-        }
-
-        bool hasNext() const {
-            return has_next_;
-        }
-
-        location_scale_t next();
-    };
-
-    class SlidingWindowImageIterator : public ImageIterator
-    {
-        int x_;
-        int y_;
-        float scale_;
-        float scale_step_;
-        int scale_cnt_;
-
-        bool has_next_;
-
-        int width_;
-        int height_;
-        int x_step_;
-        int y_step_;
-        int scales_;
-        float min_scale_;
-        float max_scale_;
-
-
-    public:
-
-        SlidingWindowImageIterator(int width, int height, int x_step, int y_step, int scales, float min_scale, float max_scale);
-
-        bool hasNext() const {
-            return has_next_;
-        }
-
-        location_scale_t next();
-    };
-
-
-
-
-    int count;
-    Matches matches;
-    int pad_x;
-    int pad_y;
-    int scales;
-    float minScale;
-    float maxScale;
-    float orientation_weight;
-    float truncate;
-    Matching * chamfer_;
-
-public:
-    ChamferMatcher(int _max_matches = 20, float _min_match_distance = 1.0, int _pad_x = 3,
-                   int _pad_y = 3, int _scales = 5, float _minScale = 0.6, float _maxScale = 1.6,
-                   float _orientation_weight = 0.5, float _truncate = 20)
-    {
-        max_matches_ = _max_matches;
-        min_match_distance_ = _min_match_distance;
-        pad_x = _pad_x;
-        pad_y = _pad_y;
-        scales = _scales;
-        minScale = _minScale;
-        maxScale = _maxScale;
-        orientation_weight = _orientation_weight;
-        truncate = _truncate;
-        count = 0;
-
-        matches.resize(max_matches_);
-        chamfer_ = new Matching(true);
-    }
-
-    ~ChamferMatcher()
-    {
-        delete chamfer_;
-    }
-
-    void showMatch(Mat& img, int index = 0);
-    void showMatch(Mat& img, Match match_);
-
-    const Matches& matching(Template&, Mat&);
-
-private:
-    ChamferMatcher(const ChamferMatcher&);
-    ChamferMatcher& operator=(const ChamferMatcher&);
-    void addMatch(float cost, Point offset, const Template* tpl);
-
-
-};
-
-
-///////////////////// implementation ///////////////////////////
-
-ChamferMatcher::SlidingWindowImageIterator::SlidingWindowImageIterator( int width,
-                                                                        int height,
-                                                                        int x_step = 3,
-                                                                        int y_step = 3,
-                                                                        int _scales = 5,
-                                                                        float min_scale = 0.6,
-                                                                        float max_scale = 1.6) :
-
-                                                                            width_(width),
-                                                                            height_(height),
-                                                                            x_step_(x_step),
-                                                                            y_step_(y_step),
-                                                                            scales_(_scales),
-                                                                            min_scale_(min_scale),
-                                                                            max_scale_(max_scale)
-{
-    x_ = 0;
-    y_ = 0;
-    scale_cnt_ = 0;
-    scale_ = min_scale_;
-    has_next_ = true;
-    scale_step_ = (max_scale_-min_scale_)/scales_;
-}
-
-location_scale_t ChamferMatcher::SlidingWindowImageIterator::next()
-{
-    location_scale_t next_val = std::make_pair(Point(x_,y_),scale_);
-
-    x_ += x_step_;
-
-    if (x_ >= width_) {
-        x_ = 0;
-        y_ += y_step_;
-
-        if (y_ >= height_) {
-            y_ = 0;
-            scale_ += scale_step_;
-            scale_cnt_++;
-
-            if (scale_cnt_ == scales_) {
-                has_next_ = false;
-                scale_cnt_ = 0;
-                scale_ = min_scale_;
-            }
-        }
-    }
-
-    return next_val;
-}
-
-
-
-ChamferMatcher::ImageIterator* ChamferMatcher::SlidingWindowImageRange::iterator() const
-{
-    return new SlidingWindowImageIterator(width_, height_, x_step_, y_step_, scales_, min_scale_, max_scale_);
-}
-
-
-
-ChamferMatcher::LocationImageIterator::LocationImageIterator(const std::vector<Point>& locations,
-                                                                int _scales = 5,
-                                                                float min_scale = 0.6,
-                                                                float max_scale = 1.6) :
-                                                                    locations_(locations),
-                                                                    scales_(_scales),
-                                                                    min_scale_(min_scale),
-                                                                    max_scale_(max_scale)
-{
-    iter_ = 0;
-    scale_cnt_ = 0;
-    scale_ = min_scale_;
-    has_next_ = (locations_.size()==0 ? false : true);
-    scale_step_ = (max_scale_-min_scale_)/scales_;
-}
-
-location_scale_t ChamferMatcher::LocationImageIterator:: next()
-{
-    location_scale_t next_val = std::make_pair(locations_[iter_],scale_);
-
-    iter_ ++;
-    if (iter_==locations_.size()) {
-        iter_ = 0;
-        scale_ += scale_step_;
-        scale_cnt_++;
-
-        if (scale_cnt_ == scales_) {
-            has_next_ = false;
-            scale_cnt_ = 0;
-            scale_ = min_scale_;
-        }
-    }
-
-    return next_val;
-}
-
-
-location_scale_t ChamferMatcher::LocationScaleImageIterator::next()
-{
-    location_scale_t next_val = std::make_pair(locations_[iter_],scales_[iter_]);
-
-    iter_ ++;
-    if (iter_==locations_.size()) {
-        iter_ = 0;
-
-        has_next_ = false;
-    }
-
-    return next_val;
-}
-
-
-
-bool ChamferMatcher::Matching::findFirstContourPoint(Mat& templ_img, coordinate_t& p)
-{
-    for (int y=0;y<templ_img.rows;++y) {
-        for (int x=0;x<templ_img.cols;++x) {
-            if (templ_img.at<uchar>(y,x)!=0) {
-                p.first = x;
-                p.second = y;
-                return true;
-            }
-        }
-    }
-    return false;
-}
-
-
-
-void ChamferMatcher::Matching::followContour(Mat& templ_img, template_coords_t& coords, int direction = -1)
-{
-    const int dir[][2] = { {-1,-1}, {-1,0}, {-1,1}, {0,1}, {1,1}, {1,0}, {1,-1}, {0,-1} };
-    coordinate_t next;
-    unsigned char ptr;
-
-    CV_Assert (direction==-1 || !coords.empty());
-
-    coordinate_t crt = coords.back();
-
-    // mark the current pixel as visited
-    templ_img.at<uchar>(crt.second,crt.first) = 0;
-    if (direction==-1) {
-        for (int j = 0; j<7; ++j) {
-            next.first = crt.first + dir[j][1];
-            next.second = crt.second + dir[j][0];
-            if (next.first >= 0 && next.first < templ_img.cols &&
-                next.second >= 0 && next.second < templ_img.rows){
-                ptr = templ_img.at<uchar>(next.second, next.first);
-                if (ptr!=0) {
-                    coords.push_back(next);
-                    followContour(templ_img, coords,j);
-                    // try to continue contour in the other direction
-                    reverse(coords.begin(), coords.end());
-                    followContour(templ_img, coords, (j+4)%8);
-                    break;
-                }
-            }
-        }
-    }
-    else {
-        int k = direction;
-        int k_cost = 3;
-        next.first = crt.first + dir[k][1];
-        next.second = crt.second + dir[k][0];
-        if (next.first >= 0 && next.first < templ_img.cols &&
-                next.second >= 0 && next.second < templ_img.rows){
-            ptr = templ_img.at<uchar>(next.second, next.first);
-            if (ptr!=0) {
-                k_cost = std::abs(dir[k][1]) + std::abs(dir[k][0]);
-            }
-            int p = k;
-            int n = k;
-
-            for (int j = 0 ;j<3; ++j) {
-                p = (p + 7) % 8;
-                n = (n + 1) % 8;
-                next.first = crt.first + dir[p][1];
-                next.second = crt.second + dir[p][0];
-                if (next.first >= 0 && next.first < templ_img.cols &&
-                    next.second >= 0 && next.second < templ_img.rows){
-                    ptr = templ_img.at<uchar>(next.second, next.first);
-                    if (ptr!=0) {
-                        int p_cost = std::abs(dir[p][1]) + std::abs(dir[p][0]);
-                        if (p_cost<k_cost) {
-                            k_cost = p_cost;
-                            k = p;
-                        }
-                    }
-                    next.first = crt.first + dir[n][1];
-                    next.second = crt.second + dir[n][0];
-                    if (next.first >= 0 && next.first < templ_img.cols &&
-                    next.second >= 0 && next.second < templ_img.rows){
-                        ptr = templ_img.at<uchar>(next.second, next.first);
-                        if (ptr!=0) {
-                            int n_cost = std::abs(dir[n][1]) + std::abs(dir[n][0]);
-                            if (n_cost<k_cost) {
-                                k_cost = n_cost;
-                                k = n;
-                            }
-                        }
-                    }
-                }
-            }
-
-            if (k_cost!=3) {
-                next.first = crt.first + dir[k][1];
-                next.second = crt.second + dir[k][0];
-                if (next.first >= 0 && next.first < templ_img.cols &&
-                    next.second >= 0 && next.second < templ_img.rows) {
-                    coords.push_back(next);
-                    followContour(templ_img, coords, k);
-                }
-            }
-        }
-    }
-}
-
-
-bool ChamferMatcher::Matching::findContour(Mat& templ_img, template_coords_t& coords)
-{
-    coordinate_t start_point;
-
-    bool found = findFirstContourPoint(templ_img,start_point);
-    if (found) {
-        coords.push_back(start_point);
-        followContour(templ_img, coords);
-        return true;
-    }
-
-    return false;
-}
-
-
-float ChamferMatcher::Matching::getAngle(coordinate_t a, coordinate_t b, int& dx, int& dy)
-{
-    dx = b.first-a.first;
-    dy = -(b.second-a.second);  // in image coordinated Y axis points downward
-        float angle = atan2((float)dy,(float)dx);
-
-    if (angle<0) {
-                angle+=(float)CV_PI;
-    }
-
-    return angle;
-}
-
-
-
-void ChamferMatcher::Matching::findContourOrientations(const template_coords_t& coords, template_orientations_t& orientations)
-{
-    const int M = 5;
-    int coords_size = (int)coords.size();
-
-    std::vector<float> angles(2*M);
-        orientations.insert(orientations.begin(), coords_size, float(-3*CV_PI)); // mark as invalid in the beginning
-
-    if (coords_size<2*M+1) {  // if contour not long enough to estimate orientations, abort
-        return;
-    }
-
-    for (int i=M;i<coords_size-M;++i) {
-        coordinate_t crt = coords[i];
-        coordinate_t other;
-        int k = 0;
-        int dx, dy;
-        // compute previous M angles
-        for (int j=M;j>0;--j) {
-            other = coords[i-j];
-            angles[k++] = getAngle(other,crt, dx, dy);
-        }
-        // compute next M angles
-        for (int j=1;j<=M;++j) {
-            other = coords[i+j];
-            angles[k++] = getAngle(crt, other, dx, dy);
-        }
-
-        // get the middle two angles
-        std::nth_element(angles.begin(), angles.begin()+M-1,  angles.end());
-        std::nth_element(angles.begin()+M-1, angles.begin()+M,  angles.end());
-        //        sort(angles.begin(), angles.end());
-
-        // average them to compute tangent
-        orientations[i] = (angles[M-1]+angles[M])/2;
-    }
-}
-
-//////////////////////// Template /////////////////////////////////////
-
-ChamferMatcher::Template::Template(Mat& edge_image, float scale_) : addr_width(-1), scale(scale_)
-{
-    template_coords_t local_coords;
-    template_orientations_t local_orientations;
-
-    while (ChamferMatcher::Matching::findContour(edge_image, local_coords)) {
-        ChamferMatcher::Matching::findContourOrientations(local_coords, local_orientations);
-
-        coords.insert(coords.end(), local_coords.begin(), local_coords.end());
-        orientations.insert(orientations.end(), local_orientations.begin(), local_orientations.end());
-        local_coords.clear();
-        local_orientations.clear();
-    }
-
-
-    size = edge_image.size();
-    Point min, max;
-    min.x = size.width;
-    min.y = size.height;
-    max.x = 0;
-    max.y = 0;
-
-    center = Point(0,0);
-    for (size_t i=0;i<coords.size();++i) {
-        center.x += coords[i].first;
-        center.y += coords[i].second;
-
-        if (min.x>coords[i].first) min.x = coords[i].first;
-        if (min.y>coords[i].second) min.y = coords[i].second;
-        if (max.x<coords[i].first) max.x = coords[i].first;
-        if (max.y<coords[i].second) max.y = coords[i].second;
-    }
-
-    size.width = max.x - min.x;
-    size.height = max.y - min.y;
-    int coords_size = (int)coords.size();
-
-    center.x /= MAX(coords_size, 1);
-    center.y /= MAX(coords_size, 1);
-
-    for (int i=0;i<coords_size;++i) {
-        coords[i].first -= center.x;
-        coords[i].second -= center.y;
-    }
-}
-
-
-std::vector<int>& ChamferMatcher::Template::getTemplateAddresses(int width)
-{
-    if (addr_width!=width) {
-        addr.resize(coords.size());
-        addr_width = width;
-
-        for (size_t i=0; i<coords.size();++i) {
-            addr[i] = coords[i].second*width+coords[i].first;
-        }
-    }
-    return addr;
-}
-
-
-/**
- * Resizes a template
- *
- * @param scale Scale to be resized to
- */
-ChamferMatcher::Template* ChamferMatcher::Template::rescale(float new_scale)
-{
-
-    if (fabs(scale-new_scale)<1e-6) return this;
-
-    for (size_t i=0;i<scaled_templates.size();++i) {
-        if (fabs(scaled_templates[i]->scale-new_scale)<1e-6) {
-            return scaled_templates[i];
-        }
-    }
-
-    float scale_factor = new_scale/scale;
-
-    Template* tpl = new Template();
-    tpl->scale = new_scale;
-
-    tpl->center.x = int(center.x*scale_factor+0.5);
-    tpl->center.y = int(center.y*scale_factor+0.5);
-
-    tpl->size.width = int(size.width*scale_factor+0.5);
-    tpl->size.height = int(size.height*scale_factor+0.5);
-
-    tpl->coords.resize(coords.size());
-    tpl->orientations.resize(orientations.size());
-    for (size_t i=0;i<coords.size();++i) {
-        tpl->coords[i].first = int(coords[i].first*scale_factor+0.5);
-        tpl->coords[i].second = int(coords[i].second*scale_factor+0.5);
-        tpl->orientations[i] = orientations[i];
-    }
-    scaled_templates.push_back(tpl);
-
-    return tpl;
-
-}
-
-
-
-void ChamferMatcher::Template::show() const
-{
-    int pad = 50;
-    //Attention size is not correct
-    Mat templ_color (Size(size.width+(pad*2), size.height+(pad*2)), CV_8UC3);
-    templ_color.setTo(0);
-
-    for (size_t i=0;i<coords.size();++i) {
-
-        int x = center.x+coords[i].first+pad;
-        int y = center.y+coords[i].second+pad;
-        templ_color.at<Vec3b>(y,x)[1]=255;
-        //CV_PIXEL(unsigned char, templ_color,x,y)[1] = 255;
-
-        if (i%3==0) {
-                        if (orientations[i] < -CV_PI) {
-                continue;
-            }
-            Point p1;
-            p1.x = x;
-            p1.y = y;
-            Point p2;
-            p2.x = x + pad*(int)(sin(orientations[i])*100)/100;
-            p2.y = y + pad*(int)(cos(orientations[i])*100)/100;
-
-            line(templ_color, p1,p2, Scalar(255,0,0));
-        }
-    }
-
-    circle(templ_color,Point(center.x + pad, center.y + pad),1,Scalar(0,255,0));
-
-#ifdef HAVE_OPENCV_HIGHGUI
-    namedWindow("templ",1);
-    imshow("templ",templ_color);
-    waitKey();
-#else
-    CV_Error(Error::StsNotImplemented, "OpenCV has been compiled without GUI support");
-#endif
-
-    templ_color.release();
-}
-
-
-//////////////////////// Matching /////////////////////////////////////
-
-
-void ChamferMatcher::Matching::addTemplateFromImage(Mat& templ, float scale)
-{
-    Template* cmt = new Template(templ, scale);
-    templates.clear();
-    templates.push_back(cmt);
-    cmt->show();
-}
-
-void ChamferMatcher::Matching::addTemplate(Template& template_){
-    templates.clear();
-    templates.push_back(&template_);
-}
-/**
- * Alternative version of computeDistanceTransform, will probably be used to compute distance
- * transform annotated with edge orientation.
- */
-void ChamferMatcher::Matching::computeDistanceTransform(Mat& edges_img, Mat& dist_img, Mat& annotate_img, float truncate_dt, float a = 1.0, float b = 1.5)
-{
-    int d[][2] = { {-1,-1}, { 0,-1}, { 1,-1},
-            {-1,0},          { 1,0},
-            {-1,1}, { 0,1}, { 1,1} };
-
-
-    Size s = edges_img.size();
-    int w = s.width;
-    int h = s.height;
-    // set distance to the edge pixels to 0 and put them in the queue
-    std::queue<std::pair<int,int> > q;
-
-    for (int y=0;y<h;++y) {
-        for (int x=0;x<w;++x) {
-            // initialize
-            if (&annotate_img!=NULL) {
-                annotate_img.at<Vec2i>(y,x)[0]=x;
-                annotate_img.at<Vec2i>(y,x)[1]=y;
-            }
-
-            uchar edge_val = edges_img.at<uchar>(y,x);
-            if( (edge_val!=0) ) {
-                q.push(std::make_pair(x,y));
-                dist_img.at<float>(y,x)= 0;
-            }
-            else {
-                dist_img.at<float>(y,x)=-1;
-            }
-        }
-    }
-
-    // breadth first computation of distance transform
-    std::pair<int,int> crt;
-    while (!q.empty()) {
-        crt = q.front();
-        q.pop();
-
-        int x = crt.first;
-        int y = crt.second;
-
-        float dist_orig = dist_img.at<float>(y,x);
-        float dist;
-
-        for (size_t i=0;i<sizeof(d)/sizeof(d[0]);++i) {
-            int nx = x + d[i][0];
-            int ny = y + d[i][1];
-
-            if (nx<0 || ny<0 || nx>=w || ny>=h) continue;
-
-            if (std::abs(d[i][0]+d[i][1])==1) {
-                dist = (dist_orig)+a;
-            }
-            else {
-                dist = (dist_orig)+b;
-            }
-
-            float dt = dist_img.at<float>(ny,nx);
-
-            if (dt==-1 || dt>dist) {
-                dist_img.at<float>(ny,nx) = dist;
-                q.push(std::make_pair(nx,ny));
-
-                if (&annotate_img!=NULL) {
-                    annotate_img.at<Vec2i>(ny,nx)[0]=annotate_img.at<Vec2i>(y,x)[0];
-                    annotate_img.at<Vec2i>(ny,nx)[1]=annotate_img.at<Vec2i>(y,x)[1];
-                }
-            }
-        }
-    }
-    // truncate dt
-
-    if (truncate_dt>0) {
-        Mat dist_img_thr = dist_img.clone();
-        threshold(dist_img, dist_img_thr, truncate_dt,0.0 ,THRESH_TRUNC);
-        dist_img_thr.copyTo(dist_img);
-    }
-}
-
-
-void ChamferMatcher::Matching::computeEdgeOrientations(Mat& edge_img, Mat& orientation_img)
-{
-    Mat contour_img(edge_img.size(), CV_8UC1);
-
-        orientation_img.setTo(3*(-CV_PI));
-    template_coords_t coords;
-    template_orientations_t orientations;
-
-    while (ChamferMatcher::Matching::findContour(edge_img, coords)) {
-
-        ChamferMatcher::Matching::findContourOrientations(coords, orientations);
-
-        // set orientation pixel in orientation image
-        for (size_t i = 0; i<coords.size();++i) {
-            int x = coords[i].first;
-            int y = coords[i].second;
-                        //            if (orientations[i]>-CV_PI)
-            //    {
-            //CV_PIXEL(unsigned char, contour_img, x, y)[0] = 255;
-            contour_img.at<uchar>(y,x)=255;
-            //    }
-            //CV_PIXEL(float, orientation_img, x, y)[0] = orientations[i];
-            orientation_img.at<float>(y,x)=orientations[i];
-        }
-
-
-        coords.clear();
-        orientations.clear();
-    }
-
-    //imwrite("contours.pgm", contour_img);
-}
-
-
-void ChamferMatcher::Matching::fillNonContourOrientations(Mat& annotated_img, Mat& orientation_img)
-{
-    int cols = annotated_img.cols;
-    int rows = annotated_img.rows;
-
-    CV_Assert(orientation_img.cols==cols && orientation_img.rows==rows);
-
-    for (int y=0;y<rows;++y) {
-        for (int x=0;x<cols;++x) {
-            int xorig = annotated_img.at<Vec2i>(y,x)[0];
-            int yorig = annotated_img.at<Vec2i>(y,x)[1];
-
-            if (x!=xorig || y!=yorig) {
-                //orientation_img.at<float>(yorig,xorig)=orientation_img.at<float>(y,x);
-                orientation_img.at<float>(y,x)=orientation_img.at<float>(yorig,xorig);
-            }
-        }
-    }
-}
-
-
-ChamferMatcher::Match* ChamferMatcher::Matching::localChamferDistance(Point offset, Mat& dist_img, Mat& orientation_img,
-        ChamferMatcher::Template* tpl, float alpha)
-{
-    int x = offset.x;
-    int y = offset.y;
-
-    float beta = 1-alpha;
-
-    std::vector<int>& addr = tpl->getTemplateAddresses(dist_img.cols);
-
-    float* ptr = dist_img.ptr<float>(y)+x;
-
-
-    float sum_distance = 0;
-    for (size_t i=0; i<addr.size();++i) {
-        if(addr[i] < (dist_img.cols*dist_img.rows) - (offset.y*dist_img.cols + offset.x)){
-            sum_distance += *(ptr+addr[i]);
-        }
-    }
-
-    float cost = (sum_distance/truncate_)/addr.size();
-
-
-    if (&orientation_img!=NULL) {
-        float* optr = orientation_img.ptr<float>(y)+x;
-        float sum_orientation = 0;
-        int cnt_orientation = 0;
-
-        for (size_t i=0;i<addr.size();++i) {
-
-            if(addr[i] < (orientation_img.cols*orientation_img.rows) - (offset.y*orientation_img.cols + offset.x)){
-                                if (tpl->orientations[i]>=-CV_PI && (*(optr+addr[i]))>=-CV_PI) {
-                    sum_orientation += orientation_diff(tpl->orientations[i], (*(optr+addr[i])));
-                    cnt_orientation++;
-                }
-            }
-        }
-
-        if (cnt_orientation>0) {
-                        cost = (float)(beta*cost+alpha*(sum_orientation/(2*CV_PI))/cnt_orientation);
-        }
-
-    }
-
-    if(cost > 0){
-        ChamferMatcher::Match* istance = new ChamferMatcher::Match();
-        istance->cost = cost;
-        istance->offset = offset;
-        istance->tpl = tpl;
-
-        return istance;
-    }
-
-    return NULL;
-}
-
-
-ChamferMatcher::Matches* ChamferMatcher::Matching::matchTemplates(Mat& dist_img, Mat& orientation_img, const ImageRange& range, float _orientation_weight)
-{
-
-    ChamferMatcher::Matches* pmatches(new Matches());
-    // try each template
-    for(size_t i = 0; i < templates.size(); i++) {
-        ImageIterator* it = range.iterator();
-        while (it->hasNext()) {
-            location_scale_t crt = it->next();
-
-            Point loc = crt.first;
-            float scale = crt.second;
-            Template* tpl = templates[i]->rescale(scale);
-
-
-            if (loc.x-tpl->center.x<0 || loc.x+tpl->size.width/2>=dist_img.cols) continue;
-            if (loc.y-tpl->center.y<0 || loc.y+tpl->size.height/2>=dist_img.rows) continue;
-
-            ChamferMatcher::Match* is = localChamferDistance(loc, dist_img, orientation_img, tpl, _orientation_weight);
-            if(is)
-            {
-                pmatches->push_back(*is);
-                delete is;
-            }
-        }
-
-        delete it;
-    }
-    return pmatches;
-}
-
-
-
-/**
- * Run matching using an edge image.
- * @param edge_img Edge image
- * @return a match object
- */
-ChamferMatcher::Matches* ChamferMatcher::Matching::matchEdgeImage(Mat& edge_img, const ImageRange& range,
-                    float _orientation_weight, int /*max_matches*/, float /*min_match_distance*/)
-{
-    CV_Assert(edge_img.channels()==1);
-
-    Mat dist_img;
-    Mat annotated_img;
-    Mat orientation_img;
-
-    annotated_img.create(edge_img.size(), CV_32SC2);
-    dist_img.create(edge_img.size(),CV_32FC1);
-    dist_img.setTo(0);
-    // Computing distance transform
-    computeDistanceTransform(edge_img,dist_img, annotated_img, truncate_);
-
-
-    //orientation_img = NULL;
-    if (use_orientation_) {
-        orientation_img.create(edge_img.size(), CV_32FC1);
-        orientation_img.setTo(0);
-        Mat edge_clone = edge_img.clone();
-        computeEdgeOrientations(edge_clone, orientation_img );
-        edge_clone.release();
-        fillNonContourOrientations(annotated_img, orientation_img);
-    }
-
-
-    // Template matching
-    ChamferMatcher::Matches* pmatches = matchTemplates(    dist_img,
-                                                        orientation_img,
-                                                        range,
-                                                        _orientation_weight);
-
-
-    if (use_orientation_) {
-        orientation_img.release();
-    }
-    dist_img.release();
-    annotated_img.release();
-
-    return pmatches;
-}
-
-
-void ChamferMatcher::addMatch(float cost, Point offset, const Template* tpl)
-{
-    bool new_match = true;
-    for (int i=0; i<count; ++i) {
-        if (std::abs(matches[i].offset.x-offset.x)+std::abs(matches[i].offset.y-offset.y)<min_match_distance_) {
-            // too close, not a new match
-            new_match = false;
-            // if better cost, replace existing match
-            if (cost<matches[i].cost) {
-                matches[i].cost = cost;
-                matches[i].offset = offset;
-                matches[i].tpl = tpl;
-            }
-            // re-bubble to keep ordered
-            int k = i;
-            while (k>0) {
-                if (matches[k-1].cost>matches[k].cost) {
-                    std::swap(matches[k-1],matches[k]);
-                }
-                k--;
-            }
-
-            break;
-        }
-    }
-
-    if (new_match) {
-        // if we don't have enough matches yet, add it to the array
-        if (count<max_matches_) {
-            matches[count].cost = cost;
-            matches[count].offset = offset;
-            matches[count].tpl = tpl;
-            count++;
-        }
-        // otherwise find the right position to insert it
-        else {
-            // if higher cost than the worst current match, just ignore it
-            if (matches[count-1].cost<cost) {
-                return;
-            }
-
-            int j = 0;
-            // skip all matches better than current one
-            while (matches[j].cost<cost) j++;
-
-            // shift matches one position
-            int k = count-2;
-            while (k>=j) {
-                matches[k+1] = matches[k];
-                k--;
-            }
-
-            matches[j].cost = cost;
-            matches[j].offset = offset;
-            matches[j].tpl = tpl;
-        }
-    }
-}
-
-void ChamferMatcher::showMatch(Mat& img, int index)
-{
-    if (index>=count) {
-        std::cout << "Index too big.\n" << std::endl;
-    }
-
-    CV_Assert(img.channels()==3);
-
-    Match match = matches[index];
-
-    const template_coords_t& templ_coords = match.tpl->coords;
-    int x, y;
-    for (size_t i=0;i<templ_coords.size();++i) {
-        x = match.offset.x + templ_coords[i].first;
-        y = match.offset.y + templ_coords[i].second;
-
-        if ( x > img.cols-1 || x < 0 || y > img.rows-1 || y < 0) continue;
-        img.at<Vec3b>(y,x)[0]=0;
-        img.at<Vec3b>(y,x)[2]=0;
-        img.at<Vec3b>(y,x)[1]=255;
-    }
-}
-
-void ChamferMatcher::showMatch(Mat& img, Match match)
-{
-    CV_Assert(img.channels()==3);
-
-    const template_coords_t& templ_coords = match.tpl->coords;
-    for (size_t i=0;i<templ_coords.size();++i) {
-        int x = match.offset.x + templ_coords[i].first;
-        int y = match.offset.y + templ_coords[i].second;
-        if ( x > img.cols-1 || x < 0 || y > img.rows-1 || y < 0) continue;
-        img.at<Vec3b>(y,x)[0]=0;
-        img.at<Vec3b>(y,x)[2]=0;
-        img.at<Vec3b>(y,x)[1]=255;
-    }
-    match.tpl->show();
-}
-
-const ChamferMatcher::Matches& ChamferMatcher::matching(Template& tpl, Mat& image_){
-    chamfer_->addTemplate(tpl);
-
-    matches.clear();
-    matches.resize(max_matches_);
-    count = 0;
-
-
-    Matches* matches_ = chamfer_->matchEdgeImage(    image_,
-                                                    ChamferMatcher::
-                                                        SlidingWindowImageRange(image_.cols,
-                                                                                image_.rows,
-                                                                                pad_x,
-                                                                                pad_y,
-                                                                                scales,
-                                                                                minScale,
-                                                                                maxScale),
-                                                    orientation_weight,
-                                                    max_matches_,
-                                                    min_match_distance_);
-
-
-
-    for(int i = 0; i < (int)matches_->size(); i++){
-        addMatch(matches_->at(i).cost, matches_->at(i).offset, matches_->at(i).tpl);
-    }
-
-    matches_->clear();
-    delete matches_;
-    matches_ = NULL;
-
-    matches.resize(count);
-
-
-    return matches;
-
-}
-
-
-int chamerMatching( Mat& img, Mat& templ,
-                    std::vector<std::vector<Point> >& results, std::vector<float>& costs,
-                    double templScale, int maxMatches, double minMatchDistance, int padX,
-                    int padY, int scales, double minScale, double maxScale,
-                    double orientationWeight, double truncate )
-{
-    CV_Assert(img.type() == CV_8UC1 && templ.type() == CV_8UC1);
-
-    ChamferMatcher matcher_(maxMatches, (float)minMatchDistance, padX, padY, scales,
-                            (float)minScale, (float)maxScale,
-                            (float)orientationWeight, (float)truncate);
-
-    ChamferMatcher::Template template_(templ, (float)templScale);
-    ChamferMatcher::Matches match_instances = matcher_.matching(template_, img);
-
-    size_t i, nmatches = match_instances.size();
-
-    results.resize(nmatches);
-    costs.resize(nmatches);
-
-    int bestIdx = -1;
-    double minCost = DBL_MAX;
-
-    for( i = 0; i < nmatches; i++ )
-    {
-        const ChamferMatcher::Match& match = match_instances[i];
-        double cval = match.cost;
-        if( cval < minCost)
-        {
-            minCost = cval;
-            bestIdx = (int)i;
-        }
-        costs[i] = (float)cval;
-
-        const template_coords_t& templ_coords = match.tpl->coords;
-        std::vector<Point>& templPoints = results[i];
-        size_t j, npoints = templ_coords.size();
-        templPoints.resize(npoints);
-
-        for (j = 0; j < npoints; j++ )
-        {
-            int x = match.offset.x + templ_coords[j].first;
-            int y = match.offset.y + templ_coords[j].second;
-            templPoints[j] = Point(x,y);
-        }
-    }
-
-    return bestIdx;
-}
-
-}
diff --git a/modules/contrib/src/chowliutree.cpp b/modules/contrib/src/chowliutree.cpp
deleted file mode 100644 (file)
index d4aed53..0000000
+++ /dev/null
@@ -1,289 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-// This file originates from the openFABMAP project:
-// [http://code.google.com/p/openfabmap/]
-//
-// For published work which uses all or part of OpenFABMAP, please cite:
-// [http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6224843]
-//
-// Original Algorithm by Mark Cummins and Paul Newman:
-// [http://ijr.sagepub.com/content/27/6/647.short]
-// [http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5613942]
-// [http://ijr.sagepub.com/content/30/9/1100.abstract]
-//
-//                           License Agreement
-//
-// Copyright (C) 2012 Arren Glover [aj.glover@qut.edu.au] and
-//                    Will Maddern [w.maddern@qut.edu.au], all rights reserved.
-//
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "opencv2/contrib/openfabmap.hpp"
-
-namespace cv {
-
-namespace of2 {
-
-ChowLiuTree::ChowLiuTree() {
-}
-
-ChowLiuTree::~ChowLiuTree() {
-}
-
-void ChowLiuTree::add(const Mat& imgDescriptor) {
-    CV_Assert(!imgDescriptor.empty());
-    if (!imgDescriptors.empty()) {
-        CV_Assert(imgDescriptors[0].cols == imgDescriptor.cols);
-        CV_Assert(imgDescriptors[0].type() == imgDescriptor.type());
-    }
-
-    imgDescriptors.push_back(imgDescriptor);
-
-}
-
-void ChowLiuTree::add(const std::vector<Mat>& _imgDescriptors) {
-    for (size_t i = 0; i < _imgDescriptors.size(); i++) {
-        add(_imgDescriptors[i]);
-    }
-}
-
-const std::vector<cv::Mat>& ChowLiuTree::getImgDescriptors() const {
-    return imgDescriptors;
-}
-
-Mat ChowLiuTree::make(double infoThreshold) {
-    CV_Assert(!imgDescriptors.empty());
-
-    unsigned int descCount = 0;
-    for (size_t i = 0; i < imgDescriptors.size(); i++)
-        descCount += imgDescriptors[i].rows;
-
-    mergedImgDescriptors = cv::Mat(descCount, imgDescriptors[0].cols,
-        imgDescriptors[0].type());
-    for (size_t i = 0, start = 0; i < imgDescriptors.size(); i++)
-    {
-        Mat submut = mergedImgDescriptors.rowRange((int)start,
-            (int)(start + imgDescriptors[i].rows));
-        imgDescriptors[i].copyTo(submut);
-        start += imgDescriptors[i].rows;
-    }
-
-    std::list<info> edges;
-    createBaseEdges(edges, infoThreshold);
-
-    // TODO: if it cv_asserts here they really won't know why.
-
-    CV_Assert(reduceEdgesToMinSpan(edges));
-
-    return buildTree(edges.front().word1, edges);
-}
-
-double ChowLiuTree::P(int a, bool za) {
-
-    if(za) {
-        return (0.98 * cv::countNonZero(mergedImgDescriptors.col(a)) /
-            mergedImgDescriptors.rows) + 0.01;
-    } else {
-        return 1 - ((0.98 * cv::countNonZero(mergedImgDescriptors.col(a)) /
-            mergedImgDescriptors.rows) + 0.01);
-    }
-
-}
-double ChowLiuTree::JP(int a, bool za, int b, bool zb) {
-
-    double count = 0;
-    for(int i = 0; i < mergedImgDescriptors.rows; i++) {
-        if((mergedImgDescriptors.at<float>(i,a) > 0) == za &&
-            (mergedImgDescriptors.at<float>(i,b) > 0) == zb) {
-                count++;
-        }
-    }
-    return count / mergedImgDescriptors.rows;
-
-}
-double ChowLiuTree::CP(int a, bool za, int b, bool zb){
-
-    int count = 0, total = 0;
-    for(int i = 0; i < mergedImgDescriptors.rows; i++) {
-        if((mergedImgDescriptors.at<float>(i,b) > 0) == zb) {
-            total++;
-            if((mergedImgDescriptors.at<float>(i,a) > 0) == za) {
-                count++;
-            }
-        }
-    }
-    if(total) {
-        return (double)(0.98 * count)/total + 0.01;
-    } else {
-        return (za) ? 0.01 : 0.99;
-    }
-}
-
-cv::Mat ChowLiuTree::buildTree(int root_word, std::list<info> &edges) {
-
-    int q = root_word;
-    cv::Mat cltree(4, (int)edges.size()+1, CV_64F);
-
-    cltree.at<double>(0, q) = q;
-    cltree.at<double>(1, q) = P(q, true);
-    cltree.at<double>(2, q) = P(q, true);
-    cltree.at<double>(3, q) = P(q, true);
-    //setting P(zq|zpq) to P(zq) gives the root node of the chow-liu
-    //independence from a parent node.
-
-    //find all children and do the same
-    std::vector<int> nextqs = extractChildren(edges, q);
-
-    int pq = q;
-    std::vector<int>::iterator nextq;
-    for(nextq = nextqs.begin(); nextq != nextqs.end(); nextq++) {
-        recAddToTree(cltree, *nextq, pq, edges);
-    }
-
-    return cltree;
-
-
-}
-
-void ChowLiuTree::recAddToTree(cv::Mat &cltree, int q, int pq,
-                               std::list<info>& remaining_edges) {
-
-    cltree.at<double>(0, q) = pq;
-    cltree.at<double>(1, q) = P(q, true);
-    cltree.at<double>(2, q) = CP(q, true, pq, true);
-    cltree.at<double>(3, q) = CP(q, true, pq, false);
-
-    //find all children and do the same
-    std::vector<int> nextqs = extractChildren(remaining_edges, q);
-
-    pq = q;
-    std::vector<int>::iterator nextq;
-    for(nextq = nextqs.begin(); nextq != nextqs.end(); nextq++) {
-        recAddToTree(cltree, *nextq, pq, remaining_edges);
-    }
-}
-
-std::vector<int> ChowLiuTree::extractChildren(std::list<info> &remaining_edges, int q) {
-
-    std::vector<int> children;
-    std::list<info>::iterator edge = remaining_edges.begin();
-
-    while(edge != remaining_edges.end()) {
-        if(edge->word1 == q) {
-            children.push_back(edge->word2);
-            edge = remaining_edges.erase(edge);
-            continue;
-        }
-        if(edge->word2 == q) {
-            children.push_back(edge->word1);
-            edge = remaining_edges.erase(edge);
-            continue;
-        }
-        edge++;
-    }
-
-    return children;
-}
-
-bool ChowLiuTree::sortInfoScores(const info& first, const info& second) {
-    return first.score > second.score;
-}
-
-double ChowLiuTree::calcMutInfo(int word1, int word2) {
-    double accumulation = 0;
-
-    double P00 = JP(word1, false, word2, false);
-    if(P00) accumulation += P00 * std::log(P00 / (P(word1, false)*P(word2, false)));
-
-    double P01 = JP(word1, false, word2, true);
-    if(P01) accumulation += P01 * std::log(P01 / (P(word1, false)*P(word2, true)));
-
-    double P10 = JP(word1, true, word2, false);
-    if(P10) accumulation += P10 * std::log(P10 / (P(word1, true)*P(word2, false)));
-
-    double P11 = JP(word1, true, word2, true);
-    if(P11) accumulation += P11 * std::log(P11 / (P(word1, true)*P(word2, true)));
-
-    return accumulation;
-}
-
-void ChowLiuTree::createBaseEdges(std::list<info>& edges, double infoThreshold) {
-
-    int nWords = imgDescriptors[0].cols;
-    info mutInfo;
-
-    for(int word1 = 0; word1 < nWords; word1++) {
-        for(int word2 = word1 + 1; word2 < nWords; word2++) {
-            mutInfo.word1 = (short)word1;
-            mutInfo.word2 = (short)word2;
-            mutInfo.score = (float)calcMutInfo(word1, word2);
-            if(mutInfo.score >= infoThreshold)
-            edges.push_back(mutInfo);
-        }
-    }
-    edges.sort(sortInfoScores);
-}
-
-bool ChowLiuTree::reduceEdgesToMinSpan(std::list<info>& edges) {
-
-    std::map<int, int> groups;
-    std::map<int, int>::iterator groupIt;
-    for(int i = 0; i < imgDescriptors[0].cols; i++) groups[i] = i;
-    int group1, group2;
-
-    std::list<info>::iterator edge = edges.begin();
-    while(edge != edges.end()) {
-        if(groups[edge->word1] != groups[edge->word2]) {
-            group1 = groups[edge->word1];
-            group2 = groups[edge->word2];
-            for(groupIt = groups.begin(); groupIt != groups.end(); groupIt++)
-            if(groupIt->second == group2) groupIt->second = group1;
-            edge++;
-        } else {
-            edge = edges.erase(edge);
-        }
-    }
-
-    if(edges.size() != (unsigned int)imgDescriptors[0].cols - 1) {
-        return false;
-    } else {
-        return true;
-    }
-
-}
-
-}
-
-}
diff --git a/modules/contrib/src/colormap.cpp b/modules/contrib/src/colormap.cpp
deleted file mode 100644 (file)
index 08ff44a..0000000
+++ /dev/null
@@ -1,530 +0,0 @@
-/*
- * Copyright (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>.
- * Released to public domain under terms of the BSD Simplified license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of the organization nor the names of its contributors
- *     may be used to endorse or promote products derived from this software
- *     without specific prior written permission.
- *
- *   See <http://www.opensource.org/licenses/bsd-license>
- */
-#include "precomp.hpp"
-#include <iostream>
-
-#ifdef _MSC_VER
-#pragma warning( disable: 4305 )
-#endif
-
-namespace cv
-{
-
-static Mat linspace(float x0, float x1, int n)
-{
-    Mat pts(n, 1, CV_32FC1);
-    float step = (x1-x0)/(n-1);
-    for(int i = 0; i < n; i++)
-        pts.at<float>(i,0) = x0+i*step;
-    return pts;
-}
-
-//------------------------------------------------------------------------------
-// cv::sortMatrixRowsByIndices
-//------------------------------------------------------------------------------
-static void sortMatrixRowsByIndices(InputArray _src, InputArray _indices, OutputArray _dst)
-{
-    if(_indices.getMat().type() != CV_32SC1)
-        CV_Error(Error::StsUnsupportedFormat, "cv::sortRowsByIndices only works on integer indices!");
-    Mat src = _src.getMat();
-    std::vector<int> indices = _indices.getMat();
-    _dst.create(src.rows, src.cols, src.type());
-    Mat dst = _dst.getMat();
-    for(size_t idx = 0; idx < indices.size(); idx++) {
-        Mat originalRow = src.row(indices[idx]);
-        Mat sortedRow = dst.row((int)idx);
-        originalRow.copyTo(sortedRow);
-    }
-}
-
-static Mat sortMatrixRowsByIndices(InputArray src, InputArray indices)
-{
-    Mat dst;
-    sortMatrixRowsByIndices(src, indices, dst);
-    return dst;
-}
-
-
-static Mat argsort(InputArray _src, bool ascending=true)
-{
-    Mat src = _src.getMat();
-    if (src.rows != 1 && src.cols != 1)
-        CV_Error(Error::StsBadArg, "cv::argsort only sorts 1D matrices.");
-    int flags = SORT_EVERY_ROW | (ascending ? SORT_ASCENDING : SORT_DESCENDING);
-    Mat sorted_indices;
-    sortIdx(src.reshape(1,1),sorted_indices,flags);
-    return sorted_indices;
-}
-
-template <typename _Tp> static
-Mat interp1_(const Mat& X_, const Mat& Y_, const Mat& XI)
-{
-    int n = XI.rows;
-    // sort input table
-    std::vector<int> sort_indices = argsort(X_);
-
-    Mat X = sortMatrixRowsByIndices(X_,sort_indices);
-    Mat Y = sortMatrixRowsByIndices(Y_,sort_indices);
-    // interpolated values
-    Mat yi = Mat::zeros(XI.size(), XI.type());
-    for(int i = 0; i < n; i++) {
-        int c = 0;
-        int low = 0;
-        int high = X.rows - 1;
-        // set bounds
-        if(XI.at<_Tp>(i,0) < X.at<_Tp>(low, 0))
-            high = 1;
-        if(XI.at<_Tp>(i,0) > X.at<_Tp>(high, 0))
-            low = high - 1;
-        // binary search
-        while((high-low)>1) {
-            c = low + ((high - low) >> 1);
-            if(XI.at<_Tp>(i,0) > X.at<_Tp>(c,0)) {
-                low = c;
-            } else {
-                high = c;
-            }
-        }
-        // linear interpolation
-        yi.at<_Tp>(i,0) += Y.at<_Tp>(low,0)
-        + (XI.at<_Tp>(i,0) - X.at<_Tp>(low,0))
-        * (Y.at<_Tp>(high,0) - Y.at<_Tp>(low,0))
-        / (X.at<_Tp>(high,0) - X.at<_Tp>(low,0));
-    }
-    return yi;
-}
-
-static Mat interp1(InputArray _x, InputArray _Y, InputArray _xi)
-{
-    // get matrices
-    Mat x = _x.getMat();
-    Mat Y = _Y.getMat();
-    Mat xi = _xi.getMat();
-    // check types & alignment
-    CV_Assert((x.type() == Y.type()) && (Y.type() == xi.type()));
-    CV_Assert((x.cols == 1) && (x.rows == Y.rows) && (x.cols == Y.cols));
-    // call templated interp1
-    switch(x.type()) {
-        case CV_8SC1: return interp1_<char>(x,Y,xi); break;
-        case CV_8UC1: return interp1_<unsigned char>(x,Y,xi); break;
-        case CV_16SC1: return interp1_<short>(x,Y,xi); break;
-        case CV_16UC1: return interp1_<unsigned short>(x,Y,xi); break;
-        case CV_32SC1: return interp1_<int>(x,Y,xi); break;
-        case CV_32FC1: return interp1_<float>(x,Y,xi); break;
-        case CV_64FC1: return interp1_<double>(x,Y,xi); break;
-        default: CV_Error(Error::StsUnsupportedFormat, ""); break;
-    }
-    return Mat();
-}
-
-namespace colormap
-{
-
-    class ColorMap {
-
-    protected:
-        Mat _lut;
-
-    public:
-        virtual ~ColorMap() {}
-
-        // Applies the colormap on a given image.
-        //
-        // This function expects BGR-aligned data of type CV_8UC1 or
-        // CV_8UC3. If the wrong image type is given, the original image
-        // will be returned.
-        //
-        // Throws an error for wrong-aligned lookup table, which must be
-        // of size 256 in the latest OpenCV release (2.3.1).
-        void operator()(InputArray src, OutputArray dst) const;
-
-        // Setup base map to interpolate from.
-        virtual void init(int n) = 0;
-
-        // Interpolates from a base colormap.
-        static Mat linear_colormap(InputArray X,
-                InputArray r, InputArray g, InputArray b,
-                int n) {
-            return linear_colormap(X,r,g,b,linspace(0,1,n));
-        }
-
-        // Interpolates from a base colormap.
-        static Mat linear_colormap(InputArray X,
-                InputArray r, InputArray g, InputArray b,
-                float begin, float end, float n) {
-            return linear_colormap(X,r,g,b,linspace(begin,end, cvRound(n)));
-        }
-
-        // Interpolates from a base colormap.
-        static Mat linear_colormap(InputArray X,
-                InputArray r, InputArray g, InputArray b,
-                InputArray xi);
-    };
-
-    // Equals the GNU Octave colormap "autumn".
-    class Autumn : public ColorMap {
-    public:
-        Autumn() : ColorMap() {
-            init(256);
-        }
-
-        Autumn(int n) : ColorMap() {
-            init(n);
-        }
-
-        void init(int n) {
-            float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
-            float g[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
-            float b[] = {  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-            Mat X = linspace(0,1,64);
-            this->_lut = ColorMap::linear_colormap(X,
-                    Mat(64,1, CV_32FC1, r).clone(), // red
-                    Mat(64,1, CV_32FC1, g).clone(), // green
-                    Mat(64,1, CV_32FC1, b).clone(), // blue
-                    n);  // number of sample points
-        }
-    };
-
-    // Equals the GNU Octave colormap "bone".
-    class Bone : public ColorMap {
-    public:
-        Bone() : ColorMap() {
-            init(256);
-        }
-
-        Bone(int n) : ColorMap() {
-            init(n);
-        }
-
-        void init(int n) {
-            float r[] = { 0, 0.01388888888888889, 0.02777777777777778, 0.04166666666666666, 0.05555555555555555, 0.06944444444444445, 0.08333333333333333, 0.09722222222222221, 0.1111111111111111, 0.125, 0.1388888888888889, 0.1527777777777778, 0.1666666666666667, 0.1805555555555556, 0.1944444444444444, 0.2083333333333333, 0.2222222222222222, 0.2361111111111111, 0.25, 0.2638888888888889, 0.2777777777777778, 0.2916666666666666, 0.3055555555555555, 0.3194444444444444, 0.3333333333333333, 0.3472222222222222, 0.3611111111111111, 0.375, 0.3888888888888888, 0.4027777777777777, 0.4166666666666666, 0.4305555555555555, 0.4444444444444444, 0.4583333333333333, 0.4722222222222222, 0.4861111111111112, 0.5, 0.5138888888888888, 0.5277777777777778, 0.5416666666666667, 0.5555555555555556, 0.5694444444444444, 0.5833333333333333, 0.5972222222222222, 0.611111111111111, 0.6249999999999999, 0.6388888888888888, 0.6527777777777778, 0.6726190476190474, 0.6944444444444442, 0.7162698412698412, 0.7380952380952381, 0.7599206349206349, 0.7817460317460316, 0.8035714285714286, 0.8253968253968254, 0.8472222222222221, 0.8690476190476188, 0.8908730158730158, 0.9126984126984128, 0.9345238095238095, 0.9563492063492063, 0.978174603174603, 1};
-            float g[] = { 0, 0.01388888888888889, 0.02777777777777778, 0.04166666666666666, 0.05555555555555555, 0.06944444444444445, 0.08333333333333333, 0.09722222222222221, 0.1111111111111111, 0.125, 0.1388888888888889, 0.1527777777777778, 0.1666666666666667, 0.1805555555555556, 0.1944444444444444, 0.2083333333333333, 0.2222222222222222, 0.2361111111111111, 0.25, 0.2638888888888889, 0.2777777777777778, 0.2916666666666666, 0.3055555555555555, 0.3194444444444444, 0.3353174603174602, 0.3544973544973544, 0.3736772486772486, 0.3928571428571428, 0.412037037037037, 0.4312169312169312, 0.4503968253968254, 0.4695767195767195, 0.4887566137566137, 0.5079365079365078, 0.5271164021164021, 0.5462962962962963, 0.5654761904761904, 0.5846560846560845, 0.6038359788359787, 0.623015873015873, 0.6421957671957671, 0.6613756613756612, 0.6805555555555555, 0.6997354497354497, 0.7189153439153438, 0.7380952380952379, 0.7572751322751322, 0.7764550264550264, 0.7916666666666666, 0.8055555555555555, 0.8194444444444444, 0.8333333333333334, 0.8472222222222222, 0.861111111111111, 0.875, 0.8888888888888888, 0.9027777777777777, 0.9166666666666665, 0.9305555555555555, 0.9444444444444444, 0.9583333333333333, 0.9722222222222221, 0.986111111111111, 1};
-            float b[] = { 0, 0.01917989417989418, 0.03835978835978836, 0.05753968253968253, 0.07671957671957672, 0.09589947089947089, 0.1150793650793651, 0.1342592592592592, 0.1534391534391534, 0.1726190476190476, 0.1917989417989418, 0.210978835978836, 0.2301587301587301, 0.2493386243386243, 0.2685185185185185, 0.2876984126984127, 0.3068783068783069, 0.326058201058201, 0.3452380952380952, 0.3644179894179894, 0.3835978835978835, 0.4027777777777777, 0.4219576719576719, 0.4411375661375661, 0.4583333333333333, 0.4722222222222222, 0.4861111111111111, 0.5, 0.5138888888888888, 0.5277777777777777, 0.5416666666666666, 0.5555555555555556, 0.5694444444444444, 0.5833333333333333, 0.5972222222222222, 0.6111111111111112, 0.625, 0.6388888888888888, 0.6527777777777778, 0.6666666666666667, 0.6805555555555556, 0.6944444444444444, 0.7083333333333333, 0.7222222222222222, 0.736111111111111, 0.7499999999999999, 0.7638888888888888, 0.7777777777777778, 0.7916666666666666, 0.8055555555555555, 0.8194444444444444, 0.8333333333333334, 0.8472222222222222, 0.861111111111111, 0.875, 0.8888888888888888, 0.9027777777777777, 0.9166666666666665, 0.9305555555555555, 0.9444444444444444, 0.9583333333333333, 0.9722222222222221, 0.986111111111111, 1};
-            Mat X = linspace(0,1,64);
-            this->_lut = ColorMap::linear_colormap(X,
-                    Mat(64,1, CV_32FC1, r).clone(), // red
-                    Mat(64,1, CV_32FC1, g).clone(), // green
-                    Mat(64,1, CV_32FC1, b).clone(), // blue
-                    n);  // number of sample points
-        }
-    };
-
-
-
-
-    // Equals the GNU Octave colormap "jet".
-    class Jet : public ColorMap {
-
-    public:
-        Jet() {
-            init(256);
-        }
-        Jet(int n) : ColorMap() {
-            init(n);
-        }
-
-        void init(int n) {
-            // breakpoints
-            Mat X = linspace(0,1,256);
-            // define the basemap
-            float r[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.00588235294117645,0.02156862745098032,0.03725490196078418,0.05294117647058827,0.06862745098039214,0.084313725490196,0.1000000000000001,0.115686274509804,0.1313725490196078,0.1470588235294117,0.1627450980392156,0.1784313725490196,0.1941176470588235,0.2098039215686274,0.2254901960784315,0.2411764705882353,0.2568627450980392,0.2725490196078431,0.2882352941176469,0.303921568627451,0.3196078431372549,0.3352941176470587,0.3509803921568628,0.3666666666666667,0.3823529411764706,0.3980392156862744,0.4137254901960783,0.4294117647058824,0.4450980392156862,0.4607843137254901,0.4764705882352942,0.4921568627450981,0.5078431372549019,0.5235294117647058,0.5392156862745097,0.5549019607843135,0.5705882352941174,0.5862745098039217,0.6019607843137256,0.6176470588235294,0.6333333333333333,0.6490196078431372,0.664705882352941,0.6803921568627449,0.6960784313725492,0.7117647058823531,0.7274509803921569,0.7431372549019608,0.7588235294117647,0.7745098039215685,0.7901960784313724,0.8058823529411763,0.8215686274509801,0.8372549019607844,0.8529411764705883,0.8686274509803922,0.884313725490196,0.8999999999999999,0.9156862745098038,0.9313725490196076,0.947058823529412,0.9627450980392158,0.9784313725490197,0.9941176470588236,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.9862745098039216,0.9705882352941178,0.9549019607843139,0.93921568627451,0.9235294117647062,0.9078431372549018,0.892156862745098,0.8764705882352941,0.8607843137254902,0.8450980392156864,0.8294117647058825,0.8137254901960786,0.7980392156862743,0.7823529411764705,0.7666666666666666,0.7509803921568627,0.7352941176470589,0.719607843137255,0.7039215686274511,0.6882352941176473,0.6725490196078434,0.6568627450980391,0.6411764705882352,0.6254901960784314,0.6098039215686275,0.5941176470588236,0.5784313725490198,0.5627450980392159,0.5470588235294116,0.5313725490196077,0.5156862745098039,0.5};
-            float g[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.001960784313725483,0.01764705882352935,0.03333333333333333,0.0490196078431373,0.06470588235294117,0.08039215686274503,0.09607843137254901,0.111764705882353,0.1274509803921569,0.1431372549019607,0.1588235294117647,0.1745098039215687,0.1901960784313725,0.2058823529411764,0.2215686274509804,0.2372549019607844,0.2529411764705882,0.2686274509803921,0.2843137254901961,0.3,0.3156862745098039,0.3313725490196078,0.3470588235294118,0.3627450980392157,0.3784313725490196,0.3941176470588235,0.4098039215686274,0.4254901960784314,0.4411764705882353,0.4568627450980391,0.4725490196078431,0.4882352941176471,0.503921568627451,0.5196078431372548,0.5352941176470587,0.5509803921568628,0.5666666666666667,0.5823529411764705,0.5980392156862746,0.6137254901960785,0.6294117647058823,0.6450980392156862,0.6607843137254901,0.6764705882352942,0.692156862745098,0.7078431372549019,0.723529411764706,0.7392156862745098,0.7549019607843137,0.7705882352941176,0.7862745098039214,0.8019607843137255,0.8176470588235294,0.8333333333333333,0.8490196078431373,0.8647058823529412,0.8803921568627451,0.8960784313725489,0.9117647058823528,0.9274509803921569,0.9431372549019608,0.9588235294117646,0.9745098039215687,0.9901960784313726,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.9901960784313726,0.9745098039215687,0.9588235294117649,0.943137254901961,0.9274509803921571,0.9117647058823528,0.8960784313725489,0.8803921568627451,0.8647058823529412,0.8490196078431373,0.8333333333333335,0.8176470588235296,0.8019607843137253,0.7862745098039214,0.7705882352941176,0.7549019607843137,0.7392156862745098,0.723529411764706,0.7078431372549021,0.6921568627450982,0.6764705882352944,0.6607843137254901,0.6450980392156862,0.6294117647058823,0.6137254901960785,0.5980392156862746,0.5823529411764707,0.5666666666666669,0.5509803921568626,0.5352941176470587,0.5196078431372548,0.503921568627451,0.4882352941176471,0.4725490196078432,0.4568627450980394,0.4411764705882355,0.4254901960784316,0.4098039215686273,0.3941176470588235,0.3784313725490196,0.3627450980392157,0.3470588235294119,0.331372549019608,0.3156862745098041,0.2999999999999998,0.284313725490196,0.2686274509803921,0.2529411764705882,0.2372549019607844,0.2215686274509805,0.2058823529411766,0.1901960784313728,0.1745098039215689,0.1588235294117646,0.1431372549019607,0.1274509803921569,0.111764705882353,0.09607843137254912,0.08039215686274526,0.06470588235294139,0.04901960784313708,0.03333333333333321,0.01764705882352935,0.001960784313725483,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-            float b[] = {0.5,0.5156862745098039,0.5313725490196078,0.5470588235294118,0.5627450980392157,0.5784313725490196,0.5941176470588235,0.6098039215686275,0.6254901960784314,0.6411764705882352,0.6568627450980392,0.6725490196078432,0.6882352941176471,0.7039215686274509,0.7196078431372549,0.7352941176470589,0.7509803921568627,0.7666666666666666,0.7823529411764706,0.7980392156862746,0.8137254901960784,0.8294117647058823,0.8450980392156863,0.8607843137254902,0.8764705882352941,0.892156862745098,0.907843137254902,0.9235294117647059,0.9392156862745098,0.9549019607843137,0.9705882352941176,0.9862745098039216,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.9941176470588236,0.9784313725490197,0.9627450980392158,0.9470588235294117,0.9313725490196079,0.915686274509804,0.8999999999999999,0.884313725490196,0.8686274509803922,0.8529411764705883,0.8372549019607844,0.8215686274509804,0.8058823529411765,0.7901960784313726,0.7745098039215685,0.7588235294117647,0.7431372549019608,0.7274509803921569,0.7117647058823531,0.696078431372549,0.6803921568627451,0.6647058823529413,0.6490196078431372,0.6333333333333333,0.6176470588235294,0.6019607843137256,0.5862745098039217,0.5705882352941176,0.5549019607843138,0.5392156862745099,0.5235294117647058,0.5078431372549019,0.4921568627450981,0.4764705882352942,0.4607843137254903,0.4450980392156865,0.4294117647058826,0.4137254901960783,0.3980392156862744,0.3823529411764706,0.3666666666666667,0.3509803921568628,0.335294117647059,0.3196078431372551,0.3039215686274508,0.2882352941176469,0.2725490196078431,0.2568627450980392,0.2411764705882353,0.2254901960784315,0.2098039215686276,0.1941176470588237,0.1784313725490199,0.1627450980392156,0.1470588235294117,0.1313725490196078,0.115686274509804,0.1000000000000001,0.08431372549019622,0.06862745098039236,0.05294117647058805,0.03725490196078418,0.02156862745098032,0.00588235294117645,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-            // now build lookup table
-            this->_lut = ColorMap::linear_colormap(X,
-                    Mat(256,1, CV_32FC1, r).clone(), // red
-                    Mat(256,1, CV_32FC1, g).clone(), // green
-                    Mat(256,1, CV_32FC1, b).clone(), // blue
-                    n);
-        }
-    };
-
-    // Equals the GNU Octave colormap "winter".
-    class Winter : public ColorMap {
-    public:
-        Winter() : ColorMap() {
-            init(256);
-        }
-
-        Winter(int n) : ColorMap() {
-            init(n);
-        }
-
-        void init(int n) {
-            float r[] = {0.0, 0.0,  0.0, 0.0,  0.0, 0.0,  0.0, 0.0,  0.0, 0.0,  0.0};
-            float g[] = {0.0, 0.1,  0.2, 0.3,  0.4, 0.5,  0.6, 0.7,  0.8, 0.9,  1.0};
-            float b[] = {1.0, 0.95, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5};
-            Mat X = linspace(0,1,11);
-            this->_lut = ColorMap::linear_colormap(X,
-                    Mat(11,1, CV_32FC1, r).clone(), // red
-                    Mat(11,1, CV_32FC1, g).clone(), // green
-                    Mat(11,1, CV_32FC1, b).clone(), // blue
-                    n);  // number of sample points
-        }
-    };
-
-    // Equals the GNU Octave colormap "rainbow".
-    class Rainbow : public ColorMap {
-    public:
-        Rainbow() : ColorMap() {
-            init(256);
-        }
-
-        Rainbow(int n) : ColorMap() {
-            init(n);
-        }
-
-        void init(int n) {
-            float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9365079365079367, 0.8571428571428572, 0.7777777777777777, 0.6984126984126986, 0.6190476190476191, 0.53968253968254, 0.4603174603174605, 0.3809523809523814, 0.3015873015873018, 0.2222222222222223, 0.1428571428571432, 0.06349206349206415, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03174603174603208, 0.08465608465608465, 0.1375661375661377, 0.1904761904761907, 0.2433862433862437, 0.2962962962962963, 0.3492063492063493, 0.4021164021164023, 0.4550264550264553, 0.5079365079365079, 0.5608465608465609, 0.6137566137566139, 0.666666666666667};
-            float g[] = { 0, 0.03968253968253968, 0.07936507936507936, 0.119047619047619, 0.1587301587301587, 0.1984126984126984, 0.2380952380952381, 0.2777777777777778, 0.3174603174603174, 0.3571428571428571, 0.3968253968253968, 0.4365079365079365, 0.4761904761904762, 0.5158730158730158, 0.5555555555555556, 0.5952380952380952, 0.6349206349206349, 0.6746031746031745, 0.7142857142857142, 0.753968253968254, 0.7936507936507936, 0.8333333333333333, 0.873015873015873, 0.9126984126984127, 0.9523809523809523, 0.992063492063492, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9841269841269842, 0.9047619047619047, 0.8253968253968256, 0.7460317460317465, 0.666666666666667, 0.587301587301587, 0.5079365079365079, 0.4285714285714288, 0.3492063492063493, 0.2698412698412698, 0.1904761904761907, 0.1111111111111116, 0.03174603174603208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-            float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01587301587301582, 0.09523809523809534, 0.1746031746031744, 0.2539682539682535, 0.333333333333333, 0.412698412698413, 0.4920634920634921, 0.5714285714285712, 0.6507936507936507, 0.7301587301587302, 0.8095238095238093, 0.8888888888888884, 0.9682539682539679, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
-            Mat X = linspace(0,1,64);
-            this->_lut = ColorMap::linear_colormap(X,
-                    Mat(64,1, CV_32FC1, r).clone(), // red
-                    Mat(64,1, CV_32FC1, g).clone(), // green
-                    Mat(64,1, CV_32FC1, b).clone(), // blue
-                    n);  // number of sample points
-        }
-    };
-
-    // Equals the GNU Octave colormap "ocean".
-    class Ocean : public ColorMap {
-    public:
-        Ocean() : ColorMap() {
-            init(256);
-        }
-
-        Ocean(int n) : ColorMap() {
-            init(n);
-        }
-
-        void init(int n) {
-            float r[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.04761904761904762, 0.09523809523809523, 0.1428571428571428, 0.1904761904761905, 0.2380952380952381, 0.2857142857142857, 0.3333333333333333, 0.3809523809523809, 0.4285714285714285, 0.4761904761904762, 0.5238095238095238, 0.5714285714285714, 0.6190476190476191, 0.6666666666666666, 0.7142857142857143, 0.7619047619047619, 0.8095238095238095, 0.8571428571428571, 0.9047619047619048, 0.9523809523809523, 1};
-            float g[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.02380952380952381, 0.04761904761904762, 0.07142857142857142, 0.09523809523809523, 0.119047619047619, 0.1428571428571428, 0.1666666666666667, 0.1904761904761905, 0.2142857142857143, 0.2380952380952381, 0.2619047619047619, 0.2857142857142857, 0.3095238095238095, 0.3333333333333333, 0.3571428571428572, 0.3809523809523809, 0.4047619047619048, 0.4285714285714285, 0.4523809523809524, 0.4761904761904762, 0.5, 0.5238095238095238, 0.5476190476190477, 0.5714285714285714, 0.5952380952380952, 0.6190476190476191, 0.6428571428571429, 0.6666666666666666, 0.6904761904761905, 0.7142857142857143, 0.7380952380952381, 0.7619047619047619, 0.7857142857142857, 0.8095238095238095, 0.8333333333333334, 0.8571428571428571, 0.8809523809523809, 0.9047619047619048, 0.9285714285714286, 0.9523809523809523, 0.9761904761904762, 1};
-            float b[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
-            Mat X = linspace(0,1,64);
-            this->_lut = ColorMap::linear_colormap(X,
-                    Mat(64,1, CV_32FC1, r).clone(), // red
-                    Mat(64,1, CV_32FC1, g).clone(), // green
-                    Mat(64,1, CV_32FC1, b).clone(), // blue
-                    n);  // number of sample points
-        }
-    };
-
-    // Equals the GNU Octave colormap "summer".
-    class Summer : public ColorMap {
-    public:
-        Summer() : ColorMap() {
-            init(256);
-        }
-
-        Summer(int n) : ColorMap() {
-            init(n);
-        }
-
-        void init(int n) {
-            float r[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
-            float g[] = { 0.5, 0.5079365079365079, 0.5158730158730158, 0.5238095238095238, 0.5317460317460317, 0.5396825396825397, 0.5476190476190477, 0.5555555555555556, 0.5634920634920635, 0.5714285714285714, 0.5793650793650793, 0.5873015873015873, 0.5952380952380952, 0.6031746031746031, 0.6111111111111112, 0.6190476190476191, 0.626984126984127, 0.6349206349206349, 0.6428571428571428, 0.6507936507936508, 0.6587301587301587, 0.6666666666666666, 0.6746031746031746, 0.6825396825396826, 0.6904761904761905, 0.6984126984126984, 0.7063492063492063, 0.7142857142857143, 0.7222222222222222, 0.7301587301587301, 0.7380952380952381, 0.746031746031746, 0.753968253968254, 0.7619047619047619, 0.7698412698412698, 0.7777777777777778, 0.7857142857142857, 0.7936507936507937, 0.8015873015873016, 0.8095238095238095, 0.8174603174603174, 0.8253968253968254, 0.8333333333333333, 0.8412698412698413, 0.8492063492063492, 0.8571428571428572, 0.8650793650793651, 0.873015873015873, 0.8809523809523809, 0.8888888888888888, 0.8968253968253967, 0.9047619047619048, 0.9126984126984127, 0.9206349206349207, 0.9285714285714286, 0.9365079365079365, 0.9444444444444444, 0.9523809523809523, 0.9603174603174602, 0.9682539682539683, 0.9761904761904762, 0.9841269841269842, 0.9920634920634921, 1};
-            float b[] = { 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4};
-            Mat X = linspace(0,1,64);
-            this->_lut = ColorMap::linear_colormap(X,
-                    Mat(64,1, CV_32FC1, r).clone(), // red
-                    Mat(64,1, CV_32FC1, g).clone(), // green
-                    Mat(64,1, CV_32FC1, b).clone(), // blue
-                    n);  // number of sample points
-        }
-    };
-
-    // Equals the GNU Octave colormap "spring".
-    class Spring : public ColorMap {
-    public:
-        Spring() : ColorMap() {
-            init(256);
-        }
-
-        Spring(int n) : ColorMap() {
-            init(n);
-        }
-
-        void init(int n) {
-            float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
-            float g[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
-            float b[] = { 1, 0.9841269841269842, 0.9682539682539683, 0.9523809523809523, 0.9365079365079365, 0.9206349206349207, 0.9047619047619048, 0.8888888888888888, 0.873015873015873, 0.8571428571428572, 0.8412698412698413, 0.8253968253968254, 0.8095238095238095, 0.7936507936507937, 0.7777777777777778, 0.7619047619047619, 0.746031746031746, 0.7301587301587302, 0.7142857142857143, 0.6984126984126984, 0.6825396825396826, 0.6666666666666667, 0.6507936507936508, 0.6349206349206349, 0.6190476190476191, 0.6031746031746033, 0.5873015873015873, 0.5714285714285714, 0.5555555555555556, 0.5396825396825398, 0.5238095238095238, 0.5079365079365079, 0.4920634920634921, 0.4761904761904762, 0.4603174603174603, 0.4444444444444444, 0.4285714285714286, 0.4126984126984127, 0.3968253968253969, 0.3809523809523809, 0.3650793650793651, 0.3492063492063492, 0.3333333333333334, 0.3174603174603174, 0.3015873015873016, 0.2857142857142857, 0.2698412698412699, 0.253968253968254, 0.2380952380952381, 0.2222222222222222, 0.2063492063492064, 0.1904761904761905, 0.1746031746031746, 0.1587301587301587, 0.1428571428571429, 0.126984126984127, 0.1111111111111112, 0.09523809523809523, 0.07936507936507942, 0.06349206349206349, 0.04761904761904767, 0.03174603174603174, 0.01587301587301593, 0};
-            Mat X = linspace(0,1,64);
-            this->_lut = ColorMap::linear_colormap(X,
-                    Mat(64,1, CV_32FC1, r).clone(), // red
-                    Mat(64,1, CV_32FC1, g).clone(), // green
-                    Mat(64,1, CV_32FC1, b).clone(), // blue
-                    n);  // number of sample points
-        }
-    };
-
-    // Equals the GNU Octave colormap "cool".
-    class Cool : public ColorMap {
-    public:
-        Cool() : ColorMap() {
-            init(256);
-        }
-
-        Cool(int n) : ColorMap() {
-            init(n);
-        }
-
-        void init(int n) {
-            float r[] = { 0, 0.01587301587301587, 0.03174603174603174, 0.04761904761904762, 0.06349206349206349, 0.07936507936507936, 0.09523809523809523, 0.1111111111111111, 0.126984126984127, 0.1428571428571428, 0.1587301587301587, 0.1746031746031746, 0.1904761904761905, 0.2063492063492063, 0.2222222222222222, 0.2380952380952381, 0.253968253968254, 0.2698412698412698, 0.2857142857142857, 0.3015873015873016, 0.3174603174603174, 0.3333333333333333, 0.3492063492063492, 0.3650793650793651, 0.3809523809523809, 0.3968253968253968, 0.4126984126984127, 0.4285714285714285, 0.4444444444444444, 0.4603174603174603, 0.4761904761904762, 0.492063492063492, 0.5079365079365079, 0.5238095238095238, 0.5396825396825397, 0.5555555555555556, 0.5714285714285714, 0.5873015873015873, 0.6031746031746031, 0.6190476190476191, 0.6349206349206349, 0.6507936507936508, 0.6666666666666666, 0.6825396825396826, 0.6984126984126984, 0.7142857142857143, 0.7301587301587301, 0.746031746031746, 0.7619047619047619, 0.7777777777777778, 0.7936507936507936, 0.8095238095238095, 0.8253968253968254, 0.8412698412698413, 0.8571428571428571, 0.873015873015873, 0.8888888888888888, 0.9047619047619048, 0.9206349206349206, 0.9365079365079365, 0.9523809523809523, 0.9682539682539683, 0.9841269841269841, 1};
-            float g[] = { 1, 0.9841269841269842, 0.9682539682539683, 0.9523809523809523, 0.9365079365079365, 0.9206349206349207, 0.9047619047619048, 0.8888888888888888, 0.873015873015873, 0.8571428571428572, 0.8412698412698413, 0.8253968253968254, 0.8095238095238095, 0.7936507936507937, 0.7777777777777778, 0.7619047619047619, 0.746031746031746, 0.7301587301587302, 0.7142857142857143, 0.6984126984126984, 0.6825396825396826, 0.6666666666666667, 0.6507936507936508, 0.6349206349206349, 0.6190476190476191, 0.6031746031746033, 0.5873015873015873, 0.5714285714285714, 0.5555555555555556, 0.5396825396825398, 0.5238095238095238, 0.5079365079365079, 0.4920634920634921, 0.4761904761904762, 0.4603174603174603, 0.4444444444444444, 0.4285714285714286, 0.4126984126984127, 0.3968253968253969, 0.3809523809523809, 0.3650793650793651, 0.3492063492063492, 0.3333333333333334, 0.3174603174603174, 0.3015873015873016, 0.2857142857142857, 0.2698412698412699, 0.253968253968254, 0.2380952380952381, 0.2222222222222222, 0.2063492063492064, 0.1904761904761905, 0.1746031746031746, 0.1587301587301587, 0.1428571428571429, 0.126984126984127, 0.1111111111111112, 0.09523809523809523, 0.07936507936507942, 0.06349206349206349, 0.04761904761904767, 0.03174603174603174, 0.01587301587301593, 0};
-            float b[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
-            Mat X = linspace(0,1,64);
-            this->_lut = ColorMap::linear_colormap(X,
-                    Mat(64,1, CV_32FC1, r).clone(), // red
-                    Mat(64,1, CV_32FC1, g).clone(), // green
-                    Mat(64,1, CV_32FC1, b).clone(), // blue
-                    n);  // number of sample points
-        }
-    };
-
-    // Equals the GNU Octave colormap "hsv".
-    class HSV : public ColorMap {
-    public:
-        HSV() : ColorMap() {
-            init(256);
-        }
-
-        HSV(int n) : ColorMap() {
-            init(n);
-        }
-
-        void init(int n) {
-            float r[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9523809523809526, 0.8571428571428568, 0.7619047619047614, 0.6666666666666665, 0.5714285714285716, 0.4761904761904763, 0.3809523809523805, 0.2857142857142856, 0.1904761904761907, 0.0952380952380949, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.09523809523809557, 0.1904761904761905, 0.2857142857142854, 0.3809523809523809, 0.4761904761904765, 0.5714285714285714, 0.6666666666666663, 0.7619047619047619, 0.8571428571428574, 0.9523809523809523, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
-            float g[] = { 0, 0.09523809523809523, 0.1904761904761905, 0.2857142857142857, 0.3809523809523809, 0.4761904761904762, 0.5714285714285714, 0.6666666666666666, 0.7619047619047619, 0.8571428571428571, 0.9523809523809523, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9523809523809526, 0.8571428571428577, 0.7619047619047619, 0.6666666666666665, 0.5714285714285716, 0.4761904761904767, 0.3809523809523814, 0.2857142857142856, 0.1904761904761907, 0.09523809523809579, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-            float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.09523809523809523, 0.1904761904761905, 0.2857142857142857, 0.3809523809523809, 0.4761904761904762, 0.5714285714285714, 0.6666666666666666, 0.7619047619047619, 0.8571428571428571, 0.9523809523809523, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9523809523809526, 0.8571428571428577, 0.7619047619047614, 0.6666666666666665, 0.5714285714285716, 0.4761904761904767, 0.3809523809523805, 0.2857142857142856, 0.1904761904761907, 0.09523809523809579, 0};
-            Mat X = linspace(0,1,64);
-            this->_lut = ColorMap::linear_colormap(X,
-                    Mat(64,1, CV_32FC1, r).clone(), // red
-                    Mat(64,1, CV_32FC1, g).clone(), // green
-                    Mat(64,1, CV_32FC1, b).clone(), // blue
-                    n);  // number of sample points
-        }
-    };
-
-    // Equals the GNU Octave colormap "pink".
-    class Pink : public ColorMap {
-    public:
-        Pink() : ColorMap() {
-            init(256);
-        }
-
-        Pink(int n) : ColorMap() {
-            init(n);
-        }
-
-        void init(int n) {
-            float r[] = { 0, 0.1571348402636772, 0.2222222222222222, 0.2721655269759087, 0.3142696805273544, 0.3513641844631533, 0.3849001794597505, 0.415739709641549, 0.4444444444444444, 0.4714045207910317, 0.4969039949999532, 0.5211573066470477, 0.5443310539518174, 0.5665577237325317, 0.5879447357921312, 0.6085806194501846, 0.6285393610547089, 0.6478835438717, 0.6666666666666666, 0.6849348892187751, 0.7027283689263065, 0.7200822998230956, 0.7370277311900888, 0.753592220347252, 0.7663560447348133, 0.7732293307186413, 0.7800420555749596, 0.7867957924694432, 0.7934920476158722, 0.8001322641986387, 0.8067178260046388, 0.8132500607904444, 0.8197302434079591, 0.8261595987094034, 0.8325393042503717, 0.8388704928078611, 0.8451542547285166, 0.8513916401208816, 0.8575836609041332, 0.8637312927246217, 0.8698354767504924, 0.8758971213537393, 0.8819171036881968, 0.8878962711712378, 0.8938354428762595, 0.8997354108424372, 0.9055969413076769, 0.9114207758701963, 0.9172076325837248, 0.9229582069908971, 0.9286731730990523, 0.9343531843023135, 0.9399988742535192, 0.9456108576893002, 0.9511897312113418, 0.9567360740266436, 0.9622504486493763, 0.9677334015667416, 0.9731854638710686, 0.9786071518602129, 0.9839989676081821, 0.9893613995077727, 0.9946949227868761, 1};
-            float g[] = { 0, 0.1028688999747279, 0.1454785934906616, 0.1781741612749496, 0.2057377999494559, 0.2300218531141181, 0.2519763153394848, 0.2721655269759087, 0.2909571869813232, 0.3086066999241838, 0.3253000243161777, 0.3411775438127727, 0.3563483225498992, 0.3708990935094579, 0.3849001794597505, 0.3984095364447979, 0.4114755998989117, 0.4241393401869012, 0.4364357804719847, 0.4483951394230328, 0.4600437062282361, 0.4714045207910317, 0.4824979096371639, 0.4933419132673033, 0.5091750772173156, 0.5328701692569688, 0.5555555555555556, 0.5773502691896257, 0.5983516452371671, 0.6186404847588913, 0.6382847385042254, 0.6573421981221795, 0.6758625033664688, 0.6938886664887108, 0.7114582486036499, 0.7286042804780002, 0.7453559924999299, 0.7617394000445604, 0.7777777777777778, 0.7934920476158723, 0.8089010988089465, 0.8240220541217402, 0.8388704928078611, 0.8534606386520677, 0.8678055195451838, 0.8819171036881968, 0.8958064164776166, 0.9094836413191612, 0.9172076325837248, 0.9229582069908971, 0.9286731730990523, 0.9343531843023135, 0.9399988742535192, 0.9456108576893002, 0.9511897312113418, 0.9567360740266436, 0.9622504486493763, 0.9677334015667416, 0.9731854638710686, 0.9786071518602129, 0.9839989676081821, 0.9893613995077727, 0.9946949227868761, 1};
-            float b[] = { 0, 0.1028688999747279, 0.1454785934906616, 0.1781741612749496, 0.2057377999494559, 0.2300218531141181, 0.2519763153394848, 0.2721655269759087, 0.2909571869813232, 0.3086066999241838, 0.3253000243161777, 0.3411775438127727, 0.3563483225498992, 0.3708990935094579, 0.3849001794597505, 0.3984095364447979, 0.4114755998989117, 0.4241393401869012, 0.4364357804719847, 0.4483951394230328, 0.4600437062282361, 0.4714045207910317, 0.4824979096371639, 0.4933419132673033, 0.5039526306789697, 0.5143444998736397, 0.5245305283129621, 0.5345224838248488, 0.5443310539518174, 0.5539659798925444, 0.563436169819011, 0.5727497953228163, 0.5819143739626463, 0.5909368402852788, 0.5998236072282915, 0.6085806194501846, 0.6172133998483676, 0.6257270902992705, 0.6341264874742278, 0.642416074439621, 0.6506000486323554, 0.6586823467062358, 0.6666666666666666, 0.6745564876468501, 0.6823550876255453, 0.6900655593423541, 0.6976908246297114, 0.7052336473499384, 0.7237468644557459, 0.7453559924999298, 0.7663560447348133, 0.7867957924694432, 0.8067178260046388, 0.8261595987094034, 0.8451542547285166, 0.8637312927246217, 0.8819171036881968, 0.8997354108424372, 0.9172076325837248, 0.9343531843023135, 0.9511897312113418, 0.9677334015667416, 0.9839989676081821, 1};
-            Mat X = linspace(0,1,64);
-            this->_lut = ColorMap::linear_colormap(X,
-                    Mat(64,1, CV_32FC1, r).clone(), // red
-                    Mat(64,1, CV_32FC1, g).clone(), // green
-                    Mat(64,1, CV_32FC1, b).clone(), // blue
-                    n);  // number of sample points
-        }
-    };
-
-    // Equals the GNU Octave colormap "hot".
-    class Hot : public ColorMap {
-    public:
-        Hot() : ColorMap() {
-            init(256);
-        }
-
-        Hot(int n) : ColorMap() {
-            init(n);
-        }
-
-        void init(int n) {
-            float r[] = { 0, 0.03968253968253968, 0.07936507936507936, 0.119047619047619, 0.1587301587301587, 0.1984126984126984, 0.2380952380952381, 0.2777777777777778, 0.3174603174603174, 0.3571428571428571, 0.3968253968253968, 0.4365079365079365, 0.4761904761904762, 0.5158730158730158, 0.5555555555555556, 0.5952380952380952, 0.6349206349206349, 0.6746031746031745, 0.7142857142857142, 0.753968253968254, 0.7936507936507936, 0.8333333333333333, 0.873015873015873, 0.9126984126984127, 0.9523809523809523, 0.992063492063492, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
-            float g[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03174603174603163, 0.0714285714285714, 0.1111111111111112, 0.1507936507936507, 0.1904761904761905, 0.23015873015873, 0.2698412698412698, 0.3095238095238093, 0.3492063492063491, 0.3888888888888888, 0.4285714285714284, 0.4682539682539679, 0.5079365079365079, 0.5476190476190477, 0.5873015873015872, 0.6269841269841268, 0.6666666666666665, 0.7063492063492065, 0.746031746031746, 0.7857142857142856, 0.8253968253968254, 0.8650793650793651, 0.9047619047619047, 0.9444444444444442, 0.984126984126984, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
-            float b[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.04761904761904745, 0.1269841269841265, 0.2063492063492056, 0.2857142857142856, 0.3650793650793656, 0.4444444444444446, 0.5238095238095237, 0.6031746031746028, 0.6825396825396828, 0.7619047619047619, 0.8412698412698409, 0.92063492063492, 1};
-            Mat X = linspace(0,1,64);
-            this->_lut = ColorMap::linear_colormap(X,
-                    Mat(64,1, CV_32FC1, r).clone(), // red
-                    Mat(64,1, CV_32FC1, g).clone(), // green
-                    Mat(64,1, CV_32FC1, b).clone(), // blue
-                    n);  // number of sample points
-        }
-    };
-
-    void ColorMap::operator()(InputArray _src, OutputArray _dst) const
-    {
-        if(_lut.total() != 256)
-            CV_Error(Error::StsAssert, "cv::LUT only supports tables of size 256.");
-        Mat src = _src.getMat();
-        // Return original matrix if wrong type is given (is fail loud better here?)
-        if(src.type() != CV_8UC1 && src.type() != CV_8UC3)
-        {
-            src.copyTo(_dst);
-            return;
-        }
-        // Turn into a BGR matrix into its grayscale representation.
-        if(src.type() == CV_8UC3)
-            cvtColor(src.clone(), src, COLOR_BGR2GRAY);
-        cvtColor(src.clone(), src, COLOR_GRAY2BGR);
-        // Apply the ColorMap.
-        LUT(src, _lut, _dst);
-    }
-
-    Mat ColorMap::linear_colormap(InputArray X,
-            InputArray r, InputArray g, InputArray b,
-            InputArray xi) {
-        Mat lut, lut8;
-        Mat planes[] = {
-                interp1(X, b, xi),
-                interp1(X, g, xi),
-                interp1(X, r, xi)};
-        merge(planes, 3, lut);
-        lut.convertTo(lut8, CV_8U, 255.);
-        return lut8;
-    }
-
-    }
-
-    void applyColorMap(InputArray src, OutputArray dst, int colormap)
-    {
-        colormap::ColorMap* cm =
-            colormap == COLORMAP_AUTUMN ? (colormap::ColorMap*)(new colormap::Autumn) :
-            colormap == COLORMAP_BONE ? (colormap::ColorMap*)(new colormap::Bone) :
-            colormap == COLORMAP_COOL ? (colormap::ColorMap*)(new colormap::Cool) :
-            colormap == COLORMAP_HOT ? (colormap::ColorMap*)(new colormap::Hot) :
-            colormap == COLORMAP_HSV ? (colormap::ColorMap*)(new colormap::HSV) :
-            colormap == COLORMAP_JET ? (colormap::ColorMap*)(new colormap::Jet) :
-            colormap == COLORMAP_OCEAN ? (colormap::ColorMap*)(new colormap::Ocean) :
-            colormap == COLORMAP_PINK ? (colormap::ColorMap*)(new colormap::Pink) :
-            colormap == COLORMAP_RAINBOW ? (colormap::ColorMap*)(new colormap::Rainbow) :
-            colormap == COLORMAP_SPRING ? (colormap::ColorMap*)(new colormap::Spring) :
-            colormap == COLORMAP_SUMMER ? (colormap::ColorMap*)(new colormap::Summer) :
-            colormap == COLORMAP_WINTER ? (colormap::ColorMap*)(new colormap::Winter) : 0;
-
-        if( !cm )
-            CV_Error( Error::StsBadArg, "Unknown colormap id; use one of COLORMAP_*");
-
-        (*cm)(src, dst);
-
-        delete cm;
-    }
-}
diff --git a/modules/contrib/src/colortracker.cpp b/modules/contrib/src/colortracker.cpp
deleted file mode 100644 (file)
index a3eeb05..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-//*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                                License Agreement
-//                       For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-#include "opencv2/contrib/hybridtracker.hpp"
-
-using namespace cv;
-
-CvMeanShiftTracker::CvMeanShiftTracker(CvMeanShiftTrackerParams _params) : params(_params)
-{
-}
-
-CvMeanShiftTracker::~CvMeanShiftTracker()
-{
-}
-
-void CvMeanShiftTracker::newTrackingWindow(Mat image, Rect selection)
-{
-    hist.release();
-    int channels[] = { 0, 0 , 1, 1};
-    float hrange[] = { 0, 180 };
-    float srange[] = { 0, 1 };
-    const float* ranges[] = {hrange, srange};
-
-    cvtColor(image, hsv, COLOR_BGR2HSV);
-    inRange(hsv, Scalar(0, 30, MIN(10, 256)), Scalar(180, 256, MAX(10, 256)), mask);
-
-    hue.create(hsv.size(), CV_8UC2);
-    mixChannels(&hsv, 1, &hue, 1, channels, 2);
-
-    Mat roi(hue, selection);
-    Mat mskroi(mask, selection);
-    int ch[] = {0, 1};
-    int chsize[] = {32, 32};
-    calcHist(&roi, 1, ch, mskroi, hist, 1, chsize, ranges);
-    normalize(hist, hist, 0, 255, CV_MINMAX);
-
-    prev_trackwindow = selection;
-}
-
-RotatedRect CvMeanShiftTracker::updateTrackingWindow(Mat image)
-{
-    int channels[] = { 0, 0 , 1, 1};
-    float hrange[] = { 0, 180 };
-    float srange[] = { 0, 1 };
-    const float* ranges[] = {hrange, srange};
-
-    cvtColor(image, hsv, COLOR_BGR2HSV);
-    inRange(hsv, Scalar(0, 30, MIN(10, 256)), Scalar(180, 256, MAX(10, 256)), mask);
-    hue.create(hsv.size(), CV_8UC2);
-    mixChannels(&hsv, 1, &hue, 1, channels, 2);
-    int ch[] = {0, 1};
-    calcBackProject(&hue, 1, ch, hist, backproj, ranges);
-    backproj &= mask;
-
-    prev_trackbox = CamShift(backproj, prev_trackwindow, TermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 10, 1));
-    int cols = backproj.cols, rows = backproj.rows, r = (MIN(cols, rows) + 5) / 6;
-    prev_trackwindow = Rect(prev_trackwindow.x - r, prev_trackwindow.y - r, prev_trackwindow.x + r,
-            prev_trackwindow.y + r) & Rect(0, 0, cols, rows);
-
-    prev_center.x = (float)(prev_trackwindow.x + prev_trackwindow.width / 2);
-    prev_center.y = (float)(prev_trackwindow.y + prev_trackwindow.height / 2);
-
-#ifdef DEBUG_HYTRACKER
-    ellipse(image, prev_trackbox, Scalar(0, 0, 255), 1, CV_AA);
-#endif
-
-    return prev_trackbox;
-}
-
-Mat CvMeanShiftTracker::getHistogramProjection(int type)
-{
-    Mat ms_backproj_f(backproj.size(), type);
-    backproj.convertTo(ms_backproj_f, type);
-    return ms_backproj_f;
-}
-
-void CvMeanShiftTracker::setTrackingWindow(Rect window)
-{
-    prev_trackwindow = window;
-}
-
-Rect CvMeanShiftTracker::getTrackingWindow()
-{
-    return prev_trackwindow;
-}
-
-RotatedRect CvMeanShiftTracker::getTrackingEllipse()
-{
-    return prev_trackbox;
-}
-
-Point2f CvMeanShiftTracker::getTrackingCenter()
-{
-    return prev_center;
-}
diff --git a/modules/contrib/src/contrib_init.cpp b/modules/contrib/src/contrib_init.cpp
deleted file mode 100644 (file)
index 317867a..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                          License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
diff --git a/modules/contrib/src/detection_based_tracker.cpp b/modules/contrib/src/detection_based_tracker.cpp
deleted file mode 100644 (file)
index f84bc32..0000000
+++ /dev/null
@@ -1,877 +0,0 @@
-#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(ANDROID)
-#include "opencv2/contrib/detection_based_tracker.hpp"
-#include "opencv2/core/utility.hpp"
-
-#include <pthread.h>
-
-#if defined(DEBUG) || defined(_DEBUG)
-#undef DEBUGLOGS
-#define DEBUGLOGS 1
-#endif
-
-#ifndef DEBUGLOGS
-#define DEBUGLOGS 0
-#endif
-
-#ifdef ANDROID
-#include <android/log.h>
-#define LOG_TAG "OBJECT_DETECTOR"
-#define LOGD0(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
-#define LOGI0(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
-#define LOGW0(...) ((void)__android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
-#define LOGE0(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
-#else
-
-#include <stdio.h>
-
-#define LOGD0(_str, ...) do{printf(_str , ## __VA_ARGS__); printf("\n");fflush(stdout);} while(0)
-#define LOGI0(_str, ...) do{printf(_str , ## __VA_ARGS__); printf("\n");fflush(stdout);} while(0)
-#define LOGW0(_str, ...) do{printf(_str , ## __VA_ARGS__); printf("\n");fflush(stdout);} while(0)
-#define LOGE0(_str, ...) do{printf(_str , ## __VA_ARGS__); printf("\n");fflush(stdout);} while(0)
-#endif
-
-#if DEBUGLOGS
-#define LOGD(_str, ...) LOGD0(_str , ## __VA_ARGS__)
-#define LOGI(_str, ...) LOGI0(_str , ## __VA_ARGS__)
-#define LOGW(_str, ...) LOGW0(_str , ## __VA_ARGS__)
-#define LOGE(_str, ...) LOGE0(_str , ## __VA_ARGS__)
-#else
-#define LOGD(...) do{} while(0)
-#define LOGI(...) do{} while(0)
-#define LOGW(...) do{} while(0)
-#define LOGE(...) do{} while(0)
-#endif
-
-
-using namespace cv;
-
-static inline cv::Point2f centerRect(const cv::Rect& r)
-{
-    return cv::Point2f(r.x+((float)r.width)/2, r.y+((float)r.height)/2);
-}
-
-static inline cv::Rect scale_rect(const cv::Rect& r, float scale)
-{
-    cv::Point2f m=centerRect(r);
-    float width  = r.width  * scale;
-    float height = r.height * scale;
-    int x=cvRound(m.x - width/2);
-    int y=cvRound(m.y - height/2);
-
-    return cv::Rect(x, y, cvRound(width), cvRound(height));
-}
-
-namespace cv
-{
-    void* workcycleObjectDetectorFunction(void* p);
-}
-
-class cv::DetectionBasedTracker::SeparateDetectionWork
-{
-    public:
-        SeparateDetectionWork(cv::DetectionBasedTracker& _detectionBasedTracker, cv::Ptr<DetectionBasedTracker::IDetector> _detector);
-        virtual ~SeparateDetectionWork();
-        bool communicateWithDetectingThread(const Mat& imageGray, std::vector<Rect>& rectsWhereRegions);
-        bool run();
-        void stop();
-        void resetTracking();
-
-        inline bool isWorking()
-        {
-            return (stateThread==STATE_THREAD_WORKING_SLEEPING) || (stateThread==STATE_THREAD_WORKING_WITH_IMAGE);
-        }
-        inline void lock()
-        {
-            pthread_mutex_lock(&mutex);
-        }
-        inline void unlock()
-        {
-            pthread_mutex_unlock(&mutex);
-        }
-
-    protected:
-
-        DetectionBasedTracker& detectionBasedTracker;
-        cv::Ptr<DetectionBasedTracker::IDetector> cascadeInThread;
-
-        pthread_t second_workthread;
-        pthread_mutex_t mutex;
-        pthread_cond_t objectDetectorRun;
-        pthread_cond_t objectDetectorThreadStartStop;
-
-        std::vector<cv::Rect> resultDetect;
-        volatile bool isObjectDetectingReady;
-        volatile bool shouldObjectDetectingResultsBeForgot;
-
-        enum StateSeparatedThread {
-            STATE_THREAD_STOPPED=0,
-            STATE_THREAD_WORKING_SLEEPING,
-            STATE_THREAD_WORKING_WITH_IMAGE,
-            STATE_THREAD_WORKING,
-            STATE_THREAD_STOPPING
-        };
-        volatile StateSeparatedThread stateThread;
-
-        cv::Mat imageSeparateDetecting;
-
-        void workcycleObjectDetector();
-        friend void* workcycleObjectDetectorFunction(void* p);
-
-        long long  timeWhenDetectingThreadStartedWork;
-};
-
-cv::DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork(DetectionBasedTracker& _detectionBasedTracker, cv::Ptr<DetectionBasedTracker::IDetector> _detector)
-    :detectionBasedTracker(_detectionBasedTracker),
-    cascadeInThread(),
-    isObjectDetectingReady(false),
-    shouldObjectDetectingResultsBeForgot(false),
-    stateThread(STATE_THREAD_STOPPED),
-    timeWhenDetectingThreadStartedWork(-1)
-{
-    CV_Assert(_detector);
-
-    cascadeInThread = _detector;
-
-    int res=0;
-    res=pthread_mutex_init(&mutex, NULL);//TODO: should be attributes?
-    if (res) {
-        LOGE("ERROR in DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork in pthread_mutex_init(&mutex, NULL) is %d", res);
-        throw(std::exception());
-    }
-    res=pthread_cond_init (&objectDetectorRun, NULL);
-    if (res) {
-        LOGE("ERROR in DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork in pthread_cond_init(&objectDetectorRun,, NULL) is %d", res);
-        pthread_mutex_destroy(&mutex);
-        throw(std::exception());
-    }
-    res=pthread_cond_init (&objectDetectorThreadStartStop, NULL);
-    if (res) {
-        LOGE("ERROR in DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork in pthread_cond_init(&objectDetectorThreadStartStop,, NULL) is %d", res);
-        pthread_cond_destroy(&objectDetectorRun);
-        pthread_mutex_destroy(&mutex);
-        throw(std::exception());
-    }
-}
-
-cv::DetectionBasedTracker::SeparateDetectionWork::~SeparateDetectionWork()
-{
-    if(stateThread!=STATE_THREAD_STOPPED) {
-        LOGE("\n\n\nATTENTION!!! dangerous algorithm error: destructor DetectionBasedTracker::DetectionBasedTracker::~SeparateDetectionWork is called before stopping the workthread");
-    }
-
-    pthread_cond_destroy(&objectDetectorThreadStartStop);
-    pthread_cond_destroy(&objectDetectorRun);
-    pthread_mutex_destroy(&mutex);
-}
-bool cv::DetectionBasedTracker::SeparateDetectionWork::run()
-{
-    LOGD("DetectionBasedTracker::SeparateDetectionWork::run() --- start");
-    pthread_mutex_lock(&mutex);
-    if (stateThread != STATE_THREAD_STOPPED) {
-        LOGE("DetectionBasedTracker::SeparateDetectionWork::run is called while the previous run is not stopped");
-        pthread_mutex_unlock(&mutex);
-        return false;
-    }
-    stateThread=STATE_THREAD_WORKING_SLEEPING;
-    pthread_create(&second_workthread, NULL, workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
-    pthread_cond_wait(&objectDetectorThreadStartStop, &mutex);
-    pthread_mutex_unlock(&mutex);
-    LOGD("DetectionBasedTracker::SeparateDetectionWork::run --- end");
-    return true;
-}
-
-#define CATCH_ALL_AND_LOG(_block)                                                           \
-do {                                                                                        \
-    try {                                                                                   \
-        _block;                                                                             \
-        break;                                                                              \
-    }                                                                                       \
-    catch(cv::Exception& e) {                                                               \
-        LOGE0("\n %s: ERROR: OpenCV Exception caught: \n'%s'\n\n", CV_Func, e.what());     \
-    } catch(std::exception& e) {                                                            \
-        LOGE0("\n %s: ERROR: Exception caught: \n'%s'\n\n", CV_Func, e.what());            \
-    } catch(...) {                                                                          \
-        LOGE0("\n %s: ERROR: UNKNOWN Exception caught\n\n", CV_Func);                      \
-    }                                                                                       \
-} while(0)
-
-void* cv::workcycleObjectDetectorFunction(void* p)
-{
-    CATCH_ALL_AND_LOG({ ((cv::DetectionBasedTracker::SeparateDetectionWork*)p)->workcycleObjectDetector(); });
-    try{
-        ((cv::DetectionBasedTracker::SeparateDetectionWork*)p)->stateThread = cv::DetectionBasedTracker::SeparateDetectionWork::STATE_THREAD_STOPPED;
-    } catch(...) {
-        LOGE0("DetectionBasedTracker: workcycleObjectDetectorFunction: ERROR concerning pointer, received as the function parameter");
-    }
-    return NULL;
-}
-
-void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()
-{
-    static double freq = getTickFrequency();
-    LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- start");
-    std::vector<Rect> objects;
-
-    CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
-    pthread_mutex_lock(&mutex);
-    {
-        pthread_cond_signal(&objectDetectorThreadStartStop);
-
-        LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- before waiting");
-        CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
-        pthread_cond_wait(&objectDetectorRun, &mutex);
-        if (isWorking()) {
-            stateThread=STATE_THREAD_WORKING_WITH_IMAGE;
-        }
-        LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- after waiting");
-    }
-    pthread_mutex_unlock(&mutex);
-
-    bool isFirstStep=true;
-
-    isObjectDetectingReady=false;
-
-    while(isWorking())
-    {
-        LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- next step");
-
-        if (! isFirstStep) {
-            LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- before waiting");
-            CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
-
-            pthread_mutex_lock(&mutex);
-            if (!isWorking()) {//it is a rare case, but may cause a crash
-                LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- go out from the workcycle from inner part of lock just before waiting");
-                pthread_mutex_unlock(&mutex);
-                break;
-            }
-            CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
-            pthread_cond_wait(&objectDetectorRun, &mutex);
-            if (isWorking()) {
-                stateThread=STATE_THREAD_WORKING_WITH_IMAGE;
-            }
-            pthread_mutex_unlock(&mutex);
-
-            LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- after waiting");
-        } else {
-            isFirstStep=false;
-        }
-
-        if (!isWorking()) {
-            LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- go out from the workcycle just after waiting");
-            break;
-        }
-
-
-        if (imageSeparateDetecting.empty()) {
-            LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- imageSeparateDetecting is empty, continue");
-            continue;
-        }
-        LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- start handling imageSeparateDetecting, img.size=%dx%d, img.data=0x%p",
-                imageSeparateDetecting.size().width, imageSeparateDetecting.size().height, (void*)imageSeparateDetecting.data);
-
-
-        int64 t1_detect=getTickCount();
-
-        cascadeInThread->detect(imageSeparateDetecting, objects);
-
-        /*cascadeInThread.detectMultiScale( imageSeparateDetecting, objects,
-                detectionBasedTracker.parameters.scaleFactor, detectionBasedTracker.parameters.minNeighbors, 0
-                |CV_HAAR_SCALE_IMAGE
-                ,
-                min_objectSize,
-                max_objectSize
-                );
-        */
-
-        LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- end handling imageSeparateDetecting");
-
-        if (!isWorking()) {
-            LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- go out from the workcycle just after detecting");
-            break;
-        }
-
-        int64 t2_detect = getTickCount();
-        int64 dt_detect = t2_detect-t1_detect;
-        double dt_detect_ms=((double)dt_detect)/freq * 1000.0;
-        (void)(dt_detect_ms);
-
-        LOGI("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- objects num==%d, t_ms=%.4f", (int)objects.size(), dt_detect_ms);
-
-        pthread_mutex_lock(&mutex);
-        if (!shouldObjectDetectingResultsBeForgot) {
-            resultDetect=objects;
-            isObjectDetectingReady=true;
-        } else { //shouldObjectDetectingResultsBeForgot==true
-            resultDetect.clear();
-            isObjectDetectingReady=false;
-            shouldObjectDetectingResultsBeForgot=false;
-        }
-        if(isWorking()) {
-            stateThread=STATE_THREAD_WORKING_SLEEPING;
-        }
-        pthread_mutex_unlock(&mutex);
-
-        objects.clear();
-    }// while(isWorking())
-
-
-    pthread_mutex_lock(&mutex);
-
-    stateThread=STATE_THREAD_STOPPED;
-
-    isObjectDetectingReady=false;
-    shouldObjectDetectingResultsBeForgot=false;
-
-    pthread_cond_signal(&objectDetectorThreadStartStop);
-
-    pthread_mutex_unlock(&mutex);
-
-    LOGI("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector: Returning");
-}
-
-void cv::DetectionBasedTracker::SeparateDetectionWork::stop()
-{
-    //FIXME: TODO: should add quickStop functionality
-    pthread_mutex_lock(&mutex);
-    if (!isWorking()) {
-        pthread_mutex_unlock(&mutex);
-        LOGE("SimpleHighguiDemoCore::stop is called but the SimpleHighguiDemoCore pthread is not active");
-        return;
-    }
-    stateThread=STATE_THREAD_STOPPING;
-    LOGD("DetectionBasedTracker::SeparateDetectionWork::stop: before going to sleep to wait for the signal from the workthread");
-    pthread_cond_signal(&objectDetectorRun);
-    pthread_cond_wait(&objectDetectorThreadStartStop, &mutex);
-    LOGD("DetectionBasedTracker::SeparateDetectionWork::stop: after receiving the signal from the workthread, stateThread=%d", (int)stateThread);
-    pthread_mutex_unlock(&mutex);
-}
-
-void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking()
-{
-    LOGD("DetectionBasedTracker::SeparateDetectionWork::resetTracking");
-    pthread_mutex_lock(&mutex);
-
-    if (stateThread == STATE_THREAD_WORKING_WITH_IMAGE) {
-        LOGD("DetectionBasedTracker::SeparateDetectionWork::resetTracking: since workthread is detecting objects at the moment, we should make cascadeInThread stop detecting and forget the detecting results");
-        shouldObjectDetectingResultsBeForgot=true;
-        //cascadeInThread.setStopFlag();//FIXME: TODO: this feature also should be contributed to OpenCV
-    } else {
-        LOGD("DetectionBasedTracker::SeparateDetectionWork::resetTracking: since workthread is NOT detecting objects at the moment, we should NOT make any additional actions");
-    }
-
-    resultDetect.clear();
-    isObjectDetectingReady=false;
-
-
-    pthread_mutex_unlock(&mutex);
-
-}
-
-bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread(const Mat& imageGray, std::vector<Rect>& rectsWhereRegions)
-{
-    static double freq = getTickFrequency();
-
-    bool shouldCommunicateWithDetectingThread = (stateThread==STATE_THREAD_WORKING_SLEEPING);
-    LOGD("DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread: shouldCommunicateWithDetectingThread=%d", (shouldCommunicateWithDetectingThread?1:0));
-
-    if (!shouldCommunicateWithDetectingThread) {
-        return false;
-    }
-
-    bool shouldHandleResult = false;
-    pthread_mutex_lock(&mutex);
-
-    if (isObjectDetectingReady) {
-        shouldHandleResult=true;
-        rectsWhereRegions = resultDetect;
-        isObjectDetectingReady=false;
-
-        double lastBigDetectionDuration = 1000.0 * (((double)(getTickCount()  - timeWhenDetectingThreadStartedWork )) / freq);
-        (void)(lastBigDetectionDuration);
-        LOGD("DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread: lastBigDetectionDuration=%f ms", (double)lastBigDetectionDuration);
-    }
-
-    bool shouldSendNewDataToWorkThread = true;
-    if (timeWhenDetectingThreadStartedWork > 0) {
-        double time_from_previous_launch_in_ms=1000.0 * (((double)(getTickCount()  - timeWhenDetectingThreadStartedWork )) / freq); //the same formula as for lastBigDetectionDuration
-        shouldSendNewDataToWorkThread = (time_from_previous_launch_in_ms >= detectionBasedTracker.parameters.minDetectionPeriod);
-        LOGD("DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread: shouldSendNewDataToWorkThread was 1, now it is %d, since time_from_previous_launch_in_ms=%.2f, minDetectionPeriod=%d",
-                (shouldSendNewDataToWorkThread?1:0), time_from_previous_launch_in_ms, detectionBasedTracker.parameters.minDetectionPeriod);
-    }
-
-    if (shouldSendNewDataToWorkThread) {
-
-        imageSeparateDetecting.create(imageGray.size(), CV_8UC1);
-
-        imageGray.copyTo(imageSeparateDetecting);//may change imageSeparateDetecting ptr. But should not.
-
-
-        timeWhenDetectingThreadStartedWork = getTickCount() ;
-
-        pthread_cond_signal(&objectDetectorRun);
-    }
-
-    pthread_mutex_unlock(&mutex);
-    LOGD("DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread: result: shouldHandleResult=%d", (shouldHandleResult?1:0));
-
-    return shouldHandleResult;
-}
-
-cv::DetectionBasedTracker::Parameters::Parameters()
-{
-    maxTrackLifetime=5;
-    minDetectionPeriod=0;
-}
-
-cv::DetectionBasedTracker::InnerParameters::InnerParameters()
-{
-    numLastPositionsToTrack=4;
-    numStepsToWaitBeforeFirstShow=6;
-    numStepsToTrackWithoutDetectingIfObjectHasNotBeenShown=3;
-    numStepsToShowWithoutDetecting=3;
-
-    coeffTrackingWindowSize=2.0;
-    coeffObjectSizeToTrack=0.85;
-    coeffObjectSpeedUsingInPrediction=0.8;
-
-}
-
-cv::DetectionBasedTracker::DetectionBasedTracker(cv::Ptr<IDetector> mainDetector, cv::Ptr<IDetector> trackingDetector, const Parameters& params)
-    :separateDetectionWork(),
-    parameters(params),
-    innerParameters(),
-    numTrackedSteps(0),
-    cascadeForTracking(trackingDetector)
-{
-    CV_Assert( (params.maxTrackLifetime >= 0)
-//            && mainDetector
-            && trackingDetector );
-
-    if (mainDetector) {
-        separateDetectionWork.reset(new SeparateDetectionWork(*this, mainDetector));
-    }
-
-    weightsPositionsSmoothing.push_back(1);
-    weightsSizesSmoothing.push_back(0.5);
-    weightsSizesSmoothing.push_back(0.3);
-    weightsSizesSmoothing.push_back(0.2);
-}
-
-cv::DetectionBasedTracker::~DetectionBasedTracker()
-{
-}
-
-void DetectionBasedTracker::process(const Mat& imageGray)
-{
-    CV_Assert(imageGray.type()==CV_8UC1);
-
-    if ( separateDetectionWork && !separateDetectionWork->isWorking() ) {
-        separateDetectionWork->run();
-    }
-
-    static double freq = getTickFrequency();
-    static long long time_when_last_call_started=getTickCount();
-
-    {
-        double delta_time_from_prev_call=1000.0 * (((double)(getTickCount()  - time_when_last_call_started)) / freq);
-        (void)(delta_time_from_prev_call);
-        LOGD("DetectionBasedTracker::process: time from the previous call is %f ms", (double)delta_time_from_prev_call);
-        time_when_last_call_started=getTickCount();
-    }
-
-    Mat imageDetect=imageGray;
-
-    std::vector<Rect> rectsWhereRegions;
-    bool shouldHandleResult=false;
-    if (separateDetectionWork) {
-        shouldHandleResult = separateDetectionWork->communicateWithDetectingThread(imageGray, rectsWhereRegions);
-    }
-
-    if (shouldHandleResult) {
-        LOGD("DetectionBasedTracker::process: get _rectsWhereRegions were got from resultDetect");
-    } else {
-        LOGD("DetectionBasedTracker::process: get _rectsWhereRegions from previous positions");
-        for(size_t i = 0; i < trackedObjects.size(); i++) {
-            int n = trackedObjects[i].lastPositions.size();
-            CV_Assert(n > 0);
-
-            Rect r = trackedObjects[i].lastPositions[n-1];
-            if(r.area() == 0) {
-                LOGE("DetectionBasedTracker::process: ERROR: ATTENTION: strange algorithm's behavior: trackedObjects[i].rect() is empty");
-                continue;
-            }
-
-            //correction by speed of rectangle
-            if (n > 1) {
-                Point2f center = centerRect(r);
-                Point2f center_prev = centerRect(trackedObjects[i].lastPositions[n-2]);
-                Point2f shift = (center - center_prev) * innerParameters.coeffObjectSpeedUsingInPrediction;
-
-                r.x += cvRound(shift.x);
-                r.y += cvRound(shift.y);
-            }
-
-
-            rectsWhereRegions.push_back(r);
-        }
-    }
-    LOGI("DetectionBasedTracker::process: tracked objects num==%d", (int)trackedObjects.size());
-
-    std::vector<Rect> detectedObjectsInRegions;
-
-    LOGD("DetectionBasedTracker::process: rectsWhereRegions.size()=%d", (int)rectsWhereRegions.size());
-    for(size_t i=0; i < rectsWhereRegions.size(); i++) {
-        Rect r = rectsWhereRegions[i];
-
-        detectInRegion(imageDetect, r, detectedObjectsInRegions);
-    }
-    LOGD("DetectionBasedTracker::process: detectedObjectsInRegions.size()=%d", (int)detectedObjectsInRegions.size());
-
-    updateTrackedObjects(detectedObjectsInRegions);
-}
-
-void cv::DetectionBasedTracker::getObjects(std::vector<cv::Rect>& result) const
-{
-    result.clear();
-
-    for(size_t i=0; i < trackedObjects.size(); i++) {
-        Rect r=calcTrackedObjectPositionToShow(i);
-        if (r.area()==0) {
-            continue;
-        }
-        result.push_back(r);
-        LOGD("DetectionBasedTracker::process: found a object with SIZE %d x %d, rect={%d, %d, %d x %d}", r.width, r.height, r.x, r.y, r.width, r.height);
-    }
-}
-
-void cv::DetectionBasedTracker::getObjects(std::vector<Object>& result) const
-{
-    result.clear();
-
-    for(size_t i=0; i < trackedObjects.size(); i++) {
-        Rect r=calcTrackedObjectPositionToShow(i);
-        if (r.area()==0) {
-            continue;
-        }
-        result.push_back(Object(r, trackedObjects[i].id));
-        LOGD("DetectionBasedTracker::process: found a object with SIZE %d x %d, rect={%d, %d, %d x %d}", r.width, r.height, r.x, r.y, r.width, r.height);
-    }
-}
-void cv::DetectionBasedTracker::getObjects(std::vector<ExtObject>& result) const
-{
-    result.clear();
-
-    for(size_t i=0; i < trackedObjects.size(); i++) {
-        ObjectStatus status;
-        Rect r=calcTrackedObjectPositionToShow(i, status);
-        result.push_back(ExtObject(trackedObjects[i].id, r, status));
-        LOGD("DetectionBasedTracker::process: found a object with SIZE %d x %d, rect={%d, %d, %d x %d}, status = %d", r.width, r.height, r.x, r.y, r.width, r.height, (int)status);
-    }
-}
-
-bool cv::DetectionBasedTracker::run()
-{
-    if (separateDetectionWork) {
-        return separateDetectionWork->run();
-    }
-    return false;
-}
-
-void cv::DetectionBasedTracker::stop()
-{
-    if (separateDetectionWork) {
-        separateDetectionWork->stop();
-    }
-}
-
-void cv::DetectionBasedTracker::resetTracking()
-{
-    if (separateDetectionWork) {
-        separateDetectionWork->resetTracking();
-    }
-    trackedObjects.clear();
-}
-
-void cv::DetectionBasedTracker::updateTrackedObjects(const std::vector<Rect>& detectedObjects)
-{
-    enum {
-        NEW_RECTANGLE=-1,
-        INTERSECTED_RECTANGLE=-2
-    };
-
-    int N1=trackedObjects.size();
-    int N2=detectedObjects.size();
-    LOGD("DetectionBasedTracker::updateTrackedObjects: N1=%d, N2=%d", N1, N2);
-
-    for(int i=0; i < N1; i++) {
-        trackedObjects[i].numDetectedFrames++;
-    }
-
-    std::vector<int> correspondence(detectedObjects.size(), NEW_RECTANGLE);
-    correspondence.clear();
-    correspondence.resize(detectedObjects.size(), NEW_RECTANGLE);
-
-    for(int i=0; i < N1; i++) {
-        LOGD("DetectionBasedTracker::updateTrackedObjects: i=%d", i);
-        TrackedObject& curObject=trackedObjects[i];
-
-        int bestIndex=-1;
-        int bestArea=-1;
-
-        int numpositions=curObject.lastPositions.size();
-        CV_Assert(numpositions > 0);
-        Rect prevRect=curObject.lastPositions[numpositions-1];
-        LOGD("DetectionBasedTracker::updateTrackedObjects: prevRect[%d]={%d, %d, %d x %d}", i, prevRect.x, prevRect.y, prevRect.width, prevRect.height);
-
-        for(int j=0; j < N2; j++) {
-            LOGD("DetectionBasedTracker::updateTrackedObjects: j=%d", j);
-            if (correspondence[j] >= 0) {
-                LOGD("DetectionBasedTracker::updateTrackedObjects: j=%d is rejected, because it has correspondence=%d", j, correspondence[j]);
-                continue;
-            }
-            if (correspondence[j] !=NEW_RECTANGLE) {
-                LOGD("DetectionBasedTracker::updateTrackedObjects: j=%d is rejected, because it is intersected with another rectangle", j);
-                continue;
-            }
-            LOGD("DetectionBasedTracker::updateTrackedObjects: detectedObjects[%d]={%d, %d, %d x %d}",
-                    j, detectedObjects[j].x, detectedObjects[j].y, detectedObjects[j].width, detectedObjects[j].height);
-
-            Rect r=prevRect & detectedObjects[j];
-            if ( (r.width > 0) && (r.height > 0) ) {
-                LOGD("DetectionBasedTracker::updateTrackedObjects: There is intersection between prevRect and detectedRect, r={%d, %d, %d x %d}",
-                        r.x, r.y, r.width, r.height);
-                correspondence[j]=INTERSECTED_RECTANGLE;
-
-                if ( r.area() > bestArea) {
-                    LOGD("DetectionBasedTracker::updateTrackedObjects: The area of intersection is %d, it is better than bestArea=%d", r.area(), bestArea);
-                    bestIndex=j;
-                    bestArea=r.area();
-                }
-            }
-        }
-        if (bestIndex >= 0) {
-            LOGD("DetectionBasedTracker::updateTrackedObjects: The best correspondence for i=%d is j=%d", i, bestIndex);
-            correspondence[bestIndex]=i;
-
-            for(int j=0; j < N2; j++) {
-                if (correspondence[j] >= 0)
-                    continue;
-
-                Rect r=detectedObjects[j] & detectedObjects[bestIndex];
-                if ( (r.width > 0) && (r.height > 0) ) {
-                    LOGD("DetectionBasedTracker::updateTrackedObjects: Found intersection between "
-                            "rectangles j=%d and bestIndex=%d, rectangle j=%d is marked as intersected", j, bestIndex, j);
-                    correspondence[j]=INTERSECTED_RECTANGLE;
-                }
-            }
-        } else {
-            LOGD("DetectionBasedTracker::updateTrackedObjects: There is no correspondence for i=%d ", i);
-            curObject.numFramesNotDetected++;
-        }
-    }
-
-    LOGD("DetectionBasedTracker::updateTrackedObjects: start second cycle");
-    for(int j=0; j < N2; j++) {
-        LOGD("DetectionBasedTracker::updateTrackedObjects: j=%d", j);
-        int i=correspondence[j];
-        if (i >= 0) {//add position
-            LOGD("DetectionBasedTracker::updateTrackedObjects: add position");
-            trackedObjects[i].lastPositions.push_back(detectedObjects[j]);
-            while ((int)trackedObjects[i].lastPositions.size() > (int) innerParameters.numLastPositionsToTrack) {
-                trackedObjects[i].lastPositions.erase(trackedObjects[i].lastPositions.begin());
-            }
-            trackedObjects[i].numFramesNotDetected=0;
-        } else if (i==NEW_RECTANGLE){ //new object
-            LOGD("DetectionBasedTracker::updateTrackedObjects: new object");
-            trackedObjects.push_back(detectedObjects[j]);
-        } else {
-            LOGD("DetectionBasedTracker::updateTrackedObjects: was auxiliary intersection");
-        }
-    }
-
-    std::vector<TrackedObject>::iterator it=trackedObjects.begin();
-    while( it != trackedObjects.end() ) {
-        if ( (it->numFramesNotDetected > parameters.maxTrackLifetime)
-                ||
-                (
-                 (it->numDetectedFrames <= innerParameters.numStepsToWaitBeforeFirstShow)
-                 &&
-                 (it->numFramesNotDetected > innerParameters.numStepsToTrackWithoutDetectingIfObjectHasNotBeenShown)
-                )
-           )
-        {
-            int numpos=it->lastPositions.size();
-            CV_Assert(numpos > 0);
-            Rect r = it->lastPositions[numpos-1];
-            (void)(r);
-            LOGD("DetectionBasedTracker::updateTrackedObjects: deleted object {%d, %d, %d x %d}",
-                    r.x, r.y, r.width, r.height);
-            it=trackedObjects.erase(it);
-        } else {
-            it++;
-        }
-    }
-}
-
-int cv::DetectionBasedTracker::addObject(const Rect& location)
-{
-    LOGD("DetectionBasedTracker::addObject: new object {%d, %d %dx%d}",location.x, location.y, location.width, location.height);
-    trackedObjects.push_back(TrackedObject(location));
-    int newId = trackedObjects.back().id;
-    LOGD("DetectionBasedTracker::addObject: newId = %d", newId);
-    return newId;
-}
-
-Rect cv::DetectionBasedTracker::calcTrackedObjectPositionToShow(int i) const
-{
-    ObjectStatus status;
-    return calcTrackedObjectPositionToShow(i, status);
-}
-Rect cv::DetectionBasedTracker::calcTrackedObjectPositionToShow(int i, ObjectStatus& status) const
-{
-    if ( (i < 0) || (i >= (int)trackedObjects.size()) ) {
-        LOGE("DetectionBasedTracker::calcTrackedObjectPositionToShow: ERROR: wrong i=%d", i);
-        status = WRONG_OBJECT;
-        return Rect();
-    }
-    if (trackedObjects[i].numDetectedFrames <= innerParameters.numStepsToWaitBeforeFirstShow){
-        LOGI("DetectionBasedTracker::calcTrackedObjectPositionToShow: trackedObjects[%d].numDetectedFrames=%d <= numStepsToWaitBeforeFirstShow=%d --- return empty Rect()",
-                i, trackedObjects[i].numDetectedFrames, innerParameters.numStepsToWaitBeforeFirstShow);
-        status = DETECTED_NOT_SHOWN_YET;
-        return Rect();
-    }
-    if (trackedObjects[i].numFramesNotDetected > innerParameters.numStepsToShowWithoutDetecting) {
-        status = DETECTED_TEMPORARY_LOST;
-        return Rect();
-    }
-
-    const TrackedObject::PositionsVector& lastPositions=trackedObjects[i].lastPositions;
-
-    int N=lastPositions.size();
-    if (N<=0) {
-        LOGE("DetectionBasedTracker::calcTrackedObjectPositionToShow: ERROR: no positions for i=%d", i);
-        status = WRONG_OBJECT;
-        return Rect();
-    }
-
-    int Nsize=std::min(N, (int)weightsSizesSmoothing.size());
-    int Ncenter= std::min(N, (int)weightsPositionsSmoothing.size());
-
-    Point2f center;
-    double w=0, h=0;
-    if (Nsize > 0) {
-        double sum=0;
-        for(int j=0; j < Nsize; j++) {
-            int k=N-j-1;
-            w += lastPositions[k].width  * weightsSizesSmoothing[j];
-            h += lastPositions[k].height * weightsSizesSmoothing[j];
-            sum+=weightsSizesSmoothing[j];
-        }
-        w /= sum;
-        h /= sum;
-    } else {
-        w=lastPositions[N-1].width;
-        h=lastPositions[N-1].height;
-    }
-
-    if (Ncenter > 0) {
-        double sum=0;
-        for(int j=0; j < Ncenter; j++) {
-            int k=N-j-1;
-            Point tl(lastPositions[k].tl());
-            Point br(lastPositions[k].br());
-            Point2f c1;
-            c1=tl;
-            c1=c1* 0.5f;
-            Point2f c2;
-            c2=br;
-            c2=c2*0.5f;
-            c1=c1+c2;
-
-            center=center+  (c1  * weightsPositionsSmoothing[j]);
-            sum+=weightsPositionsSmoothing[j];
-        }
-        center *= (float)(1 / sum);
-    } else {
-        int k=N-1;
-        Point tl(lastPositions[k].tl());
-        Point br(lastPositions[k].br());
-        Point2f c1;
-        c1=tl;
-        c1=c1* 0.5f;
-        Point2f c2;
-        c2=br;
-        c2=c2*0.5f;
-
-        center=c1+c2;
-    }
-    Point2f tl=center-(Point2f(w,h)*0.5);
-    Rect res(cvRound(tl.x), cvRound(tl.y), cvRound(w), cvRound(h));
-    LOGD("DetectionBasedTracker::calcTrackedObjectPositionToShow: Result for i=%d: {%d, %d, %d x %d}", i, res.x, res.y, res.width, res.height);
-
-    status = DETECTED;
-    return res;
-}
-
-void cv::DetectionBasedTracker::detectInRegion(const Mat& img, const Rect& r, std::vector<Rect>& detectedObjectsInRegions)
-{
-    Rect r0(Point(), img.size());
-    Rect r1 = scale_rect(r, innerParameters.coeffTrackingWindowSize);
-    r1 = r1 & r0;
-
-    if ( (r1.width <=0) || (r1.height <= 0) ) {
-        LOGD("DetectionBasedTracker::detectInRegion: Empty intersection");
-        return;
-    }
-
-    int d = cvRound(std::min(r.width, r.height) * innerParameters.coeffObjectSizeToTrack);
-
-    std::vector<Rect> tmpobjects;
-
-    Mat img1(img, r1);//subimage for rectangle -- without data copying
-    LOGD("DetectionBasedTracker::detectInRegion: img1.size()=%d x %d, d=%d",
-            img1.size().width, img1.size().height, d);
-
-    cascadeForTracking->setMinObjectSize(Size(d, d));
-    cascadeForTracking->detect(img1, tmpobjects);
-            /*
-            detectMultiScale( img1, tmpobjects,
-            parameters.scaleFactor, parameters.minNeighbors, 0
-            |CV_HAAR_FIND_BIGGEST_OBJECT
-            |CV_HAAR_SCALE_IMAGE
-            ,
-            Size(d,d),
-            max_objectSize
-            );*/
-
-    for(size_t i=0; i < tmpobjects.size(); i++) {
-        Rect curres(tmpobjects[i].tl() + r1.tl(), tmpobjects[i].size());
-        detectedObjectsInRegions.push_back(curres);
-    }
-}
-
-bool cv::DetectionBasedTracker::setParameters(const Parameters& params)
-{
-    if ( params.maxTrackLifetime < 0 )
-    {
-        LOGE("DetectionBasedTracker::setParameters: ERROR: wrong parameters value");
-        return false;
-    }
-
-    if (separateDetectionWork) {
-        separateDetectionWork->lock();
-    }
-    parameters=params;
-    if (separateDetectionWork) {
-        separateDetectionWork->unlock();
-    }
-    return true;
-}
-
-const cv::DetectionBasedTracker::Parameters& DetectionBasedTracker::getParameters() const
-{
-    return parameters;
-}
-
-#endif
diff --git a/modules/contrib/src/facerec.cpp b/modules/contrib/src/facerec.cpp
deleted file mode 100644 (file)
index c6f154a..0000000
+++ /dev/null
@@ -1,901 +0,0 @@
-/*
- * Copyright (c) 2011,2012. Philipp Wagner <bytefish[at]gmx[dot]de>.
- * Released to public domain under terms of the BSD Simplified license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of the organization nor the names of its contributors
- *     may be used to endorse or promote products derived from this software
- *     without specific prior written permission.
- *
- *   See <http://www.opensource.org/licenses/bsd-license>
- */
-#include "precomp.hpp"
-#include <set>
-#include <limits>
-
-namespace cv
-{
-
-// Reads a sequence from a FileNode::SEQ with type _Tp into a result vector.
-template<typename _Tp>
-inline void readFileNodeList(const FileNode& fn, std::vector<_Tp>& result) {
-    if (fn.type() == FileNode::SEQ) {
-        for (FileNodeIterator it = fn.begin(); it != fn.end();) {
-            _Tp item;
-            it >> item;
-            result.push_back(item);
-        }
-    }
-}
-
-// Writes the a list of given items to a cv::FileStorage.
-template<typename _Tp>
-inline void writeFileNodeList(FileStorage& fs, const String& name,
-                              const std::vector<_Tp>& items) {
-    // typedefs
-    typedef typename std::vector<_Tp>::const_iterator constVecIterator;
-    // write the elements in item to fs
-    fs << name << "[";
-    for (constVecIterator it = items.begin(); it != items.end(); ++it) {
-        fs << *it;
-    }
-    fs << "]";
-}
-
-static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) {
-    // make sure the input data is a vector of matrices or vector of vector
-    if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) {
-        String error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).";
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // number of samples
-    size_t n = src.total();
-    // return empty matrix if no matrices given
-    if(n == 0)
-        return Mat();
-    // dimensionality of (reshaped) samples
-    size_t d = src.getMat(0).total();
-    // create data matrix
-    Mat data((int)n, (int)d, rtype);
-    // now copy data
-    for(unsigned int i = 0; i < n; i++) {
-        // make sure data can be reshaped, throw exception if not!
-        if(src.getMat(i).total() != d) {
-            String error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, d, src.getMat(i).total());
-            CV_Error(Error::StsBadArg, error_message);
-        }
-        // get a hold of the current row
-        Mat xi = data.row(i);
-        // make reshape happy by cloning for non-continuous matrices
-        if(src.getMat(i).isContinuous()) {
-            src.getMat(i).reshape(1, 1).convertTo(xi, rtype, alpha, beta);
-        } else {
-            src.getMat(i).clone().reshape(1, 1).convertTo(xi, rtype, alpha, beta);
-        }
-    }
-    return data;
-}
-
-
-// Removes duplicate elements in a given vector.
-template<typename _Tp>
-inline std::vector<_Tp> remove_dups(const std::vector<_Tp>& src) {
-    typedef typename std::set<_Tp>::const_iterator constSetIterator;
-    typedef typename std::vector<_Tp>::const_iterator constVecIterator;
-    std::set<_Tp> set_elems;
-    for (constVecIterator it = src.begin(); it != src.end(); ++it)
-        set_elems.insert(*it);
-    std::vector<_Tp> elems;
-    for (constSetIterator it = set_elems.begin(); it != set_elems.end(); ++it)
-        elems.push_back(*it);
-    return elems;
-}
-
-
-// Turk, M., and Pentland, A. "Eigenfaces for recognition.". Journal of
-// Cognitive Neuroscience 3 (1991), 71–86.
-class Eigenfaces : public FaceRecognizer
-{
-private:
-    int _num_components;
-    double _threshold;
-    std::vector<Mat> _projections;
-    Mat _labels;
-    Mat _eigenvectors;
-    Mat _eigenvalues;
-    Mat _mean;
-
-public:
-    using FaceRecognizer::save;
-    using FaceRecognizer::load;
-
-    // Initializes an empty Eigenfaces model.
-    Eigenfaces(int num_components = 0, double threshold = DBL_MAX) :
-        _num_components(num_components),
-        _threshold(threshold) {}
-
-    // Initializes and computes an Eigenfaces model with images in src and
-    // corresponding labels in labels. num_components will be kept for
-    // classification.
-    Eigenfaces(InputArrayOfArrays src, InputArray labels,
-            int num_components = 0, double threshold = DBL_MAX) :
-        _num_components(num_components),
-        _threshold(threshold) {
-        train(src, labels);
-    }
-
-    // Computes an Eigenfaces model with images in src and corresponding labels
-    // in labels.
-    void train(InputArrayOfArrays src, InputArray labels);
-
-    // Predicts the label of a query image in src.
-    int predict(InputArray src) const;
-
-    // Predicts the label and confidence for a given sample.
-    void predict(InputArray _src, int &label, double &dist) const;
-
-    // See FaceRecognizer::load.
-    void load(const FileStorage& fs);
-
-    // See FaceRecognizer::save.
-    void save(FileStorage& fs) const;
-
-    AlgorithmInfo* info() const;
-};
-
-// Belhumeur, P. N., Hespanha, J., and Kriegman, D. "Eigenfaces vs. Fisher-
-// faces: Recognition using class specific linear projection.". IEEE
-// Transactions on Pattern Analysis and Machine Intelligence 19, 7 (1997),
-// 711–720.
-class Fisherfaces: public FaceRecognizer
-{
-private:
-    int _num_components;
-    double _threshold;
-    Mat _eigenvectors;
-    Mat _eigenvalues;
-    Mat _mean;
-    std::vector<Mat> _projections;
-    Mat _labels;
-
-public:
-    using FaceRecognizer::save;
-    using FaceRecognizer::load;
-
-    // Initializes an empty Fisherfaces model.
-    Fisherfaces(int num_components = 0, double threshold = DBL_MAX) :
-        _num_components(num_components),
-        _threshold(threshold) {}
-
-    // Initializes and computes a Fisherfaces model with images in src and
-    // corresponding labels in labels. num_components will be kept for
-    // classification.
-    Fisherfaces(InputArrayOfArrays src, InputArray labels,
-            int num_components = 0, double threshold = DBL_MAX) :
-        _num_components(num_components),
-        _threshold(threshold) {
-        train(src, labels);
-    }
-
-    ~Fisherfaces() {}
-
-    // Computes a Fisherfaces model with images in src and corresponding labels
-    // in labels.
-    void train(InputArrayOfArrays src, InputArray labels);
-
-    // Predicts the label of a query image in src.
-    int predict(InputArray src) const;
-
-    // Predicts the label and confidence for a given sample.
-    void predict(InputArray _src, int &label, double &dist) const;
-
-    // See FaceRecognizer::load.
-    void load(const FileStorage& fs);
-
-    // See FaceRecognizer::save.
-    void save(FileStorage& fs) const;
-
-    AlgorithmInfo* info() const;
-};
-
-// Face Recognition based on Local Binary Patterns.
-//
-//  Ahonen T, Hadid A. and Pietikäinen M. "Face description with local binary
-//  patterns: Application to face recognition." IEEE Transactions on Pattern
-//  Analysis and Machine Intelligence, 28(12):2037-2041.
-//
-class LBPH : public FaceRecognizer
-{
-private:
-    int _grid_x;
-    int _grid_y;
-    int _radius;
-    int _neighbors;
-    double _threshold;
-
-    std::vector<Mat> _histograms;
-    Mat _labels;
-
-    // Computes a LBPH model with images in src and
-    // corresponding labels in labels, possibly preserving
-    // old model data.
-    void train(InputArrayOfArrays src, InputArray labels, bool preserveData);
-
-
-public:
-    using FaceRecognizer::save;
-    using FaceRecognizer::load;
-
-    // Initializes this LBPH Model. The current implementation is rather fixed
-    // as it uses the Extended Local Binary Patterns per default.
-    //
-    // radius, neighbors are used in the local binary patterns creation.
-    // grid_x, grid_y control the grid size of the spatial histograms.
-    LBPH(int radius_=1, int neighbors_=8,
-            int gridx=8, int gridy=8,
-            double threshold = DBL_MAX) :
-        _grid_x(gridx),
-        _grid_y(gridy),
-        _radius(radius_),
-        _neighbors(neighbors_),
-        _threshold(threshold) {}
-
-    // Initializes and computes this LBPH Model. The current implementation is
-    // rather fixed as it uses the Extended Local Binary Patterns per default.
-    //
-    // (radius=1), (neighbors=8) are used in the local binary patterns creation.
-    // (grid_x=8), (grid_y=8) controls the grid size of the spatial histograms.
-    LBPH(InputArrayOfArrays src,
-            InputArray labels,
-            int radius_=1, int neighbors_=8,
-            int gridx=8, int gridy=8,
-            double threshold = DBL_MAX) :
-                _grid_x(gridx),
-                _grid_y(gridy),
-                _radius(radius_),
-                _neighbors(neighbors_),
-                _threshold(threshold) {
-        train(src, labels);
-    }
-
-    ~LBPH() { }
-
-    // Computes a LBPH model with images in src and
-    // corresponding labels in labels.
-    void train(InputArrayOfArrays src, InputArray labels);
-
-    // Updates this LBPH model with images in src and
-    // corresponding labels in labels.
-    void update(InputArrayOfArrays src, InputArray labels);
-
-    // Predicts the label of a query image in src.
-    int predict(InputArray src) const;
-
-    // Predicts the label and confidence for a given sample.
-    void predict(InputArray _src, int &label, double &dist) const;
-
-    // See FaceRecognizer::load.
-    void load(const FileStorage& fs);
-
-    // See FaceRecognizer::save.
-    void save(FileStorage& fs) const;
-
-    // Getter functions.
-    int neighbors() const { return _neighbors; }
-    int radius() const { return _radius; }
-    int grid_x() const { return _grid_x; }
-    int grid_y() const { return _grid_y; }
-
-    AlgorithmInfo* info() const;
-};
-
-
-//------------------------------------------------------------------------------
-// FaceRecognizer
-//------------------------------------------------------------------------------
-void FaceRecognizer::update(InputArrayOfArrays src, InputArray labels ) {
-    if( dynamic_cast<LBPH*>(this) != 0 )
-    {
-        dynamic_cast<LBPH*>(this)->update( src, labels );
-        return;
-    }
-
-    String error_msg = format("This FaceRecognizer (%s) does not support updating, you have to use FaceRecognizer::train to update it.", this->name().c_str());
-    CV_Error(Error::StsNotImplemented, error_msg);
-}
-
-void FaceRecognizer::save(const String& filename) const {
-    FileStorage fs(filename, FileStorage::WRITE);
-    if (!fs.isOpened())
-        CV_Error(Error::StsError, "File can't be opened for writing!");
-    this->save(fs);
-    fs.release();
-}
-
-void FaceRecognizer::load(const String& filename) {
-    FileStorage fs(filename, FileStorage::READ);
-    if (!fs.isOpened())
-        CV_Error(Error::StsError, "File can't be opened for writing!");
-    this->load(fs);
-    fs.release();
-}
-
-//------------------------------------------------------------------------------
-// Eigenfaces
-//------------------------------------------------------------------------------
-void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) {
-    if(_src.total() == 0) {
-        String error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
-        CV_Error(Error::StsBadArg, error_message);
-    } else if(_local_labels.getMat().type() != CV_32SC1) {
-        String error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _local_labels.type());
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // make sure data has correct size
-    if(_src.total() > 1) {
-        for(int i = 1; i < static_cast<int>(_src.total()); i++) {
-            if(_src.getMat(i-1).total() != _src.getMat(i).total()) {
-                String error_message = format("In the Eigenfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", _src.getMat(i-1).total(), _src.getMat(i).total());
-                CV_Error(Error::StsUnsupportedFormat, error_message);
-            }
-        }
-    }
-    // get labels
-    Mat labels = _local_labels.getMat();
-    // observations in row
-    Mat data = asRowMatrix(_src, CV_64FC1);
-
-    // number of samples
-   int n = data.rows;
-    // assert there are as much samples as labels
-    if(static_cast<int>(labels.total()) != n) {
-        String error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", n, labels.total());
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // clear existing model data
-    _labels.release();
-    _projections.clear();
-    // clip number of components to be valid
-    if((_num_components <= 0) || (_num_components > n))
-        _num_components = n;
-
-    // perform the PCA
-    PCA pca(data, Mat(), PCA::DATA_AS_ROW, _num_components);
-    // copy the PCA results
-    _mean = pca.mean.reshape(1,1); // store the mean vector
-    _eigenvalues = pca.eigenvalues.clone(); // eigenvalues by row
-    transpose(pca.eigenvectors, _eigenvectors); // eigenvectors by column
-    // store labels for prediction
-    _labels = labels.clone();
-    // save projections
-    for(int sampleIdx = 0; sampleIdx < data.rows; sampleIdx++) {
-        Mat p = subspaceProject(_eigenvectors, _mean, data.row(sampleIdx));
-        _projections.push_back(p);
-    }
-}
-
-void Eigenfaces::predict(InputArray _src, int &minClass, double &minDist) const {
-    // get data
-    Mat src = _src.getMat();
-    // make sure the user is passing correct data
-    if(_projections.empty()) {
-        // throw error if no data (or simply return -1?)
-        String error_message = "This Eigenfaces model is not computed yet. Did you call Eigenfaces::train?";
-        CV_Error(Error::StsError, error_message);
-    } else if(_eigenvectors.rows != static_cast<int>(src.total())) {
-        // check data alignment just for clearer exception messages
-        String error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total());
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // project into PCA subspace
-    Mat q = subspaceProject(_eigenvectors, _mean, src.reshape(1,1));
-    minDist = DBL_MAX;
-    minClass = -1;
-    for(size_t sampleIdx = 0; sampleIdx < _projections.size(); sampleIdx++) {
-        double dist = norm(_projections[sampleIdx], q, NORM_L2);
-        if((dist < minDist) && (dist < _threshold)) {
-            minDist = dist;
-            minClass = _labels.at<int>((int)sampleIdx);
-        }
-    }
-}
-
-int Eigenfaces::predict(InputArray _src) const {
-    int label;
-    double dummy;
-    predict(_src, label, dummy);
-    return label;
-}
-
-void Eigenfaces::load(const FileStorage& fs) {
-    //read matrices
-    fs["num_components"] >> _num_components;
-    fs["mean"] >> _mean;
-    fs["eigenvalues"] >> _eigenvalues;
-    fs["eigenvectors"] >> _eigenvectors;
-    // read sequences
-    readFileNodeList(fs["projections"], _projections);
-    fs["labels"] >> _labels;
-}
-
-void Eigenfaces::save(FileStorage& fs) const {
-    // write matrices
-    fs << "num_components" << _num_components;
-    fs << "mean" << _mean;
-    fs << "eigenvalues" << _eigenvalues;
-    fs << "eigenvectors" << _eigenvectors;
-    // write sequences
-    writeFileNodeList(fs, "projections", _projections);
-    fs << "labels" << _labels;
-}
-
-//------------------------------------------------------------------------------
-// Fisherfaces
-//------------------------------------------------------------------------------
-void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) {
-    if(src.total() == 0) {
-        String error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
-        CV_Error(Error::StsBadArg, error_message);
-    } else if(_lbls.getMat().type() != CV_32SC1) {
-        String error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _lbls.type());
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // make sure data has correct size
-    if(src.total() > 1) {
-        for(int i = 1; i < static_cast<int>(src.total()); i++) {
-            if(src.getMat(i-1).total() != src.getMat(i).total()) {
-                String error_message = format("In the Fisherfaces method all input samples (training images) must be of equal size! Expected %d pixels, but was %d pixels.", src.getMat(i-1).total(), src.getMat(i).total());
-                CV_Error(Error::StsUnsupportedFormat, error_message);
-            }
-        }
-    }
-    // get data
-    Mat labels = _lbls.getMat();
-    Mat data = asRowMatrix(src, CV_64FC1);
-    // number of samples
-    int N = data.rows;
-    // make sure labels are passed in correct shape
-    if(labels.total() != (size_t) N) {
-        String error_message = format("The number of samples (src) must equal the number of labels (labels)! len(src)=%d, len(labels)=%d.", N, labels.total());
-        CV_Error(Error::StsBadArg, error_message);
-    } else if(labels.rows != 1 && labels.cols != 1) {
-        String error_message = format("Expected the labels in a matrix with one row or column! Given dimensions are rows=%s, cols=%d.", labels.rows, labels.cols);
-       CV_Error(Error::StsBadArg, error_message);
-    }
-    // clear existing model data
-    _labels.release();
-    _projections.clear();
-    // safely copy from cv::Mat to std::vector
-    std::vector<int> ll;
-    for(unsigned int i = 0; i < labels.total(); i++) {
-        ll.push_back(labels.at<int>(i));
-    }
-    // get the number of unique classes
-    int C = (int) remove_dups(ll).size();
-    // clip number of components to be a valid number
-    if((_num_components <= 0) || (_num_components > (C-1)))
-        _num_components = (C-1);
-    // perform a PCA and keep (N-C) components
-    PCA pca(data, Mat(), PCA::DATA_AS_ROW, (N-C));
-    // project the data and perform a LDA on it
-    LDA lda(pca.project(data),labels, _num_components);
-    // store the total mean vector
-    _mean = pca.mean.reshape(1,1);
-    // store labels
-    _labels = labels.clone();
-    // store the eigenvalues of the discriminants
-    lda.eigenvalues().convertTo(_eigenvalues, CV_64FC1);
-    // Now calculate the projection matrix as pca.eigenvectors * lda.eigenvectors.
-    // Note: OpenCV stores the eigenvectors by row, so we need to transpose it!
-    gemm(pca.eigenvectors, lda.eigenvectors(), 1.0, Mat(), 0.0, _eigenvectors, GEMM_1_T);
-    // store the projections of the original data
-    for(int sampleIdx = 0; sampleIdx < data.rows; sampleIdx++) {
-        Mat p = subspaceProject(_eigenvectors, _mean, data.row(sampleIdx));
-        _projections.push_back(p);
-    }
-}
-
-void Fisherfaces::predict(InputArray _src, int &minClass, double &minDist) const {
-    Mat src = _src.getMat();
-    // check data alignment just for clearer exception messages
-    if(_projections.empty()) {
-        // throw error if no data (or simply return -1?)
-        String error_message = "This Fisherfaces model is not computed yet. Did you call Fisherfaces::train?";
-        CV_Error(Error::StsBadArg, error_message);
-    } else if(src.total() != (size_t) _eigenvectors.rows) {
-        String error_message = format("Wrong input image size. Reason: Training and Test images must be of equal size! Expected an image with %d elements, but got %d.", _eigenvectors.rows, src.total());
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // project into LDA subspace
-    Mat q = subspaceProject(_eigenvectors, _mean, src.reshape(1,1));
-    // find 1-nearest neighbor
-    minDist = DBL_MAX;
-    minClass = -1;
-    for(size_t sampleIdx = 0; sampleIdx < _projections.size(); sampleIdx++) {
-        double dist = norm(_projections[sampleIdx], q, NORM_L2);
-        if((dist < minDist) && (dist < _threshold)) {
-            minDist = dist;
-            minClass = _labels.at<int>((int)sampleIdx);
-        }
-    }
-}
-
-int Fisherfaces::predict(InputArray _src) const {
-    int label;
-    double dummy;
-    predict(_src, label, dummy);
-    return label;
-}
-
-// See FaceRecognizer::load.
-void Fisherfaces::load(const FileStorage& fs) {
-    //read matrices
-    fs["num_components"] >> _num_components;
-    fs["mean"] >> _mean;
-    fs["eigenvalues"] >> _eigenvalues;
-    fs["eigenvectors"] >> _eigenvectors;
-    // read sequences
-    readFileNodeList(fs["projections"], _projections);
-    fs["labels"] >> _labels;
-}
-
-// See FaceRecognizer::save.
-void Fisherfaces::save(FileStorage& fs) const {
-    // write matrices
-    fs << "num_components" << _num_components;
-    fs << "mean" << _mean;
-    fs << "eigenvalues" << _eigenvalues;
-    fs << "eigenvectors" << _eigenvectors;
-    // write sequences
-    writeFileNodeList(fs, "projections", _projections);
-    fs << "labels" << _labels;
-}
-
-//------------------------------------------------------------------------------
-// LBPH
-//------------------------------------------------------------------------------
-
-template <typename _Tp> static
-void olbp_(InputArray _src, OutputArray _dst) {
-    // get matrices
-    Mat src = _src.getMat();
-    // allocate memory for result
-    _dst.create(src.rows-2, src.cols-2, CV_8UC1);
-    Mat dst = _dst.getMat();
-    // zero the result matrix
-    dst.setTo(0);
-    // calculate patterns
-    for(int i=1;i<src.rows-1;i++) {
-        for(int j=1;j<src.cols-1;j++) {
-            _Tp center = src.at<_Tp>(i,j);
-            unsigned char code = 0;
-            code |= (src.at<_Tp>(i-1,j-1) >= center) << 7;
-            code |= (src.at<_Tp>(i-1,j) >= center) << 6;
-            code |= (src.at<_Tp>(i-1,j+1) >= center) << 5;
-            code |= (src.at<_Tp>(i,j+1) >= center) << 4;
-            code |= (src.at<_Tp>(i+1,j+1) >= center) << 3;
-            code |= (src.at<_Tp>(i+1,j) >= center) << 2;
-            code |= (src.at<_Tp>(i+1,j-1) >= center) << 1;
-            code |= (src.at<_Tp>(i,j-1) >= center) << 0;
-            dst.at<unsigned char>(i-1,j-1) = code;
-        }
-    }
-}
-
-//------------------------------------------------------------------------------
-// cv::elbp
-//------------------------------------------------------------------------------
-template <typename _Tp> static
-inline void elbp_(InputArray _src, OutputArray _dst, int radius, int neighbors) {
-    //get matrices
-    Mat src = _src.getMat();
-    // allocate memory for result
-    _dst.create(src.rows-2*radius, src.cols-2*radius, CV_32SC1);
-    Mat dst = _dst.getMat();
-    // zero
-    dst.setTo(0);
-    for(int n=0; n<neighbors; n++) {
-        // sample points
-        float x = static_cast<float>(radius * cos(2.0*CV_PI*n/static_cast<float>(neighbors)));
-        float y = static_cast<float>(-radius * sin(2.0*CV_PI*n/static_cast<float>(neighbors)));
-        // relative indices
-        int fx = static_cast<int>(floor(x));
-        int fy = static_cast<int>(floor(y));
-        int cx = static_cast<int>(ceil(x));
-        int cy = static_cast<int>(ceil(y));
-        // fractional part
-        float ty = y - fy;
-        float tx = x - fx;
-        // set interpolation weights
-        float w1 = (1 - tx) * (1 - ty);
-        float w2 =      tx  * (1 - ty);
-        float w3 = (1 - tx) *      ty;
-        float w4 =      tx  *      ty;
-        // iterate through your data
-        for(int i=radius; i < src.rows-radius;i++) {
-            for(int j=radius;j < src.cols-radius;j++) {
-                // calculate interpolated value
-                float t = static_cast<float>(w1*src.at<_Tp>(i+fy,j+fx) + w2*src.at<_Tp>(i+fy,j+cx) + w3*src.at<_Tp>(i+cy,j+fx) + w4*src.at<_Tp>(i+cy,j+cx));
-                // floating point precision, so check some machine-dependent epsilon
-                dst.at<int>(i-radius,j-radius) += ((t > src.at<_Tp>(i,j)) || (std::abs(t-src.at<_Tp>(i,j)) < std::numeric_limits<float>::epsilon())) << n;
-            }
-        }
-    }
-}
-
-static void elbp(InputArray src, OutputArray dst, int radius, int neighbors)
-{
-    int type = src.type();
-    switch (type) {
-    case CV_8SC1:   elbp_<char>(src,dst, radius, neighbors); break;
-    case CV_8UC1:   elbp_<unsigned char>(src, dst, radius, neighbors); break;
-    case CV_16SC1:  elbp_<short>(src,dst, radius, neighbors); break;
-    case CV_16UC1:  elbp_<unsigned short>(src,dst, radius, neighbors); break;
-    case CV_32SC1:  elbp_<int>(src,dst, radius, neighbors); break;
-    case CV_32FC1:  elbp_<float>(src,dst, radius, neighbors); break;
-    case CV_64FC1:  elbp_<double>(src,dst, radius, neighbors); break;
-    default:
-        String error_msg = format("Using Original Local Binary Patterns for feature extraction only works on single-channel images (given %d). Please pass the image data as a grayscale image!", type);
-        CV_Error(Error::StsNotImplemented, error_msg);
-        break;
-    }
-}
-
-static Mat
-histc_(const Mat& src, int minVal=0, int maxVal=255, bool normed=false)
-{
-    Mat result;
-    // Establish the number of bins.
-    int histSize = maxVal-minVal+1;
-    // Set the ranges.
-    float range[] = { static_cast<float>(minVal), static_cast<float>(maxVal+1) };
-    const float* histRange = { range };
-    // calc histogram
-    calcHist(&src, 1, 0, Mat(), result, 1, &histSize, &histRange, true, false);
-    // normalize
-    if(normed) {
-        result /= (int)src.total();
-    }
-    return result.reshape(1,1);
-}
-
-static Mat histc(InputArray _src, int minVal, int maxVal, bool normed)
-{
-    Mat src = _src.getMat();
-    switch (src.type()) {
-        case CV_8SC1:
-            return histc_(Mat_<float>(src), minVal, maxVal, normed);
-            break;
-        case CV_8UC1:
-            return histc_(src, minVal, maxVal, normed);
-            break;
-        case CV_16SC1:
-            return histc_(Mat_<float>(src), minVal, maxVal, normed);
-            break;
-        case CV_16UC1:
-            return histc_(src, minVal, maxVal, normed);
-            break;
-        case CV_32SC1:
-            return histc_(Mat_<float>(src), minVal, maxVal, normed);
-            break;
-        case CV_32FC1:
-            return histc_(src, minVal, maxVal, normed);
-            break;
-        default:
-            CV_Error(Error::StsUnmatchedFormats, "This type is not implemented yet."); break;
-    }
-    return Mat();
-}
-
-
-static Mat spatial_histogram(InputArray _src, int numPatterns,
-                             int grid_x, int grid_y, bool /*normed*/)
-{
-    Mat src = _src.getMat();
-    // calculate LBP patch size
-    int width = src.cols/grid_x;
-    int height = src.rows/grid_y;
-    // allocate memory for the spatial histogram
-    Mat result = Mat::zeros(grid_x * grid_y, numPatterns, CV_32FC1);
-    // return matrix with zeros if no data was given
-    if(src.empty())
-        return result.reshape(1,1);
-    // initial result_row
-    int resultRowIdx = 0;
-    // iterate through grid
-    for(int i = 0; i < grid_y; i++) {
-        for(int j = 0; j < grid_x; j++) {
-            Mat src_cell = Mat(src, Range(i*height,(i+1)*height), Range(j*width,(j+1)*width));
-            Mat cell_hist = histc(src_cell, 0, (numPatterns-1), true);
-            // copy to the result matrix
-            Mat result_row = result.row(resultRowIdx);
-            cell_hist.reshape(1,1).convertTo(result_row, CV_32FC1);
-            // increase row count in result matrix
-            resultRowIdx++;
-        }
-    }
-    // return result as reshaped feature vector
-    return result.reshape(1,1);
-}
-
-//------------------------------------------------------------------------------
-// wrapper to cv::elbp (extended local binary patterns)
-//------------------------------------------------------------------------------
-
-static Mat elbp(InputArray src, int radius, int neighbors) {
-    Mat dst;
-    elbp(src, dst, radius, neighbors);
-    return dst;
-}
-
-void LBPH::load(const FileStorage& fs) {
-    fs["radius"] >> _radius;
-    fs["neighbors"] >> _neighbors;
-    fs["grid_x"] >> _grid_x;
-    fs["grid_y"] >> _grid_y;
-    //read matrices
-    readFileNodeList(fs["histograms"], _histograms);
-    fs["labels"] >> _labels;
-}
-
-// See FaceRecognizer::save.
-void LBPH::save(FileStorage& fs) const {
-    fs << "radius" << _radius;
-    fs << "neighbors" << _neighbors;
-    fs << "grid_x" << _grid_x;
-    fs << "grid_y" << _grid_y;
-    // write matrices
-    writeFileNodeList(fs, "histograms", _histograms);
-    fs << "labels" << _labels;
-}
-
-void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels) {
-    this->train(_in_src, _in_labels, false);
-}
-
-void LBPH::update(InputArrayOfArrays _in_src, InputArray _in_labels) {
-    // got no data, just return
-    if(_in_src.total() == 0)
-        return;
-
-    this->train(_in_src, _in_labels, true);
-}
-
-void LBPH::train(InputArrayOfArrays _in_src, InputArray _in_labels, bool preserveData) {
-    if(_in_src.kind() != _InputArray::STD_VECTOR_MAT && _in_src.kind() != _InputArray::STD_VECTOR_VECTOR) {
-        String error_message = "The images are expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).";
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    if(_in_src.total() == 0) {
-        String error_message = format("Empty training data was given. You'll need more than one sample to learn a model.");
-        CV_Error(Error::StsUnsupportedFormat, error_message);
-    } else if(_in_labels.getMat().type() != CV_32SC1) {
-        String error_message = format("Labels must be given as integer (CV_32SC1). Expected %d, but was %d.", CV_32SC1, _in_labels.type());
-        CV_Error(Error::StsUnsupportedFormat, error_message);
-    }
-    // get the vector of matrices
-    std::vector<Mat> src;
-    _in_src.getMatVector(src);
-    // get the label matrix
-    Mat labels = _in_labels.getMat();
-    // check if data is well- aligned
-    if(labels.total() != src.size()) {
-        String error_message = format("The number of samples (src) must equal the number of labels (labels). Was len(samples)=%d, len(labels)=%d.", src.size(), _labels.total());
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // if this model should be trained without preserving old data, delete old model data
-    if(!preserveData) {
-        _labels.release();
-        _histograms.clear();
-    }
-    // append labels to _labels matrix
-    for(size_t labelIdx = 0; labelIdx < labels.total(); labelIdx++) {
-        _labels.push_back(labels.at<int>((int)labelIdx));
-    }
-    // store the spatial histograms of the original data
-    for(size_t sampleIdx = 0; sampleIdx < src.size(); sampleIdx++) {
-        // calculate lbp image
-        Mat lbp_image = elbp(src[sampleIdx], _radius, _neighbors);
-        // get spatial histogram from this lbp image
-        Mat p = spatial_histogram(
-                lbp_image, /* lbp_image */
-                static_cast<int>(std::pow(2.0, static_cast<double>(_neighbors))), /* number of possible patterns */
-                _grid_x, /* grid size x */
-                _grid_y, /* grid size y */
-                true);
-        // add to templates
-        _histograms.push_back(p);
-    }
-}
-
-void LBPH::predict(InputArray _src, int &minClass, double &minDist) const {
-    if(_histograms.empty()) {
-        // throw error if no data (or simply return -1?)
-        String error_message = "This LBPH model is not computed yet. Did you call the train method?";
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    Mat src = _src.getMat();
-    // get the spatial histogram from input image
-    Mat lbp_image = elbp(src, _radius, _neighbors);
-    Mat query = spatial_histogram(
-            lbp_image, /* lbp_image */
-            static_cast<int>(std::pow(2.0, static_cast<double>(_neighbors))), /* number of possible patterns */
-            _grid_x, /* grid size x */
-            _grid_y, /* grid size y */
-            true /* normed histograms */);
-    // find 1-nearest neighbor
-    minDist = DBL_MAX;
-    minClass = -1;
-    for(size_t sampleIdx = 0; sampleIdx < _histograms.size(); sampleIdx++) {
-        double dist = compareHist(_histograms[sampleIdx], query, HISTCMP_CHISQR_ALT);
-        if((dist < minDist) && (dist < _threshold)) {
-            minDist = dist;
-            minClass = _labels.at<int>((int) sampleIdx);
-        }
-    }
-}
-
-int LBPH::predict(InputArray _src) const {
-    int label;
-    double dummy;
-    predict(_src, label, dummy);
-    return label;
-}
-
-
-Ptr<FaceRecognizer> createEigenFaceRecognizer(int num_components, double threshold)
-{
-    return makePtr<Eigenfaces>(num_components, threshold);
-}
-
-Ptr<FaceRecognizer> createFisherFaceRecognizer(int num_components, double threshold)
-{
-    return makePtr<Fisherfaces>(num_components, threshold);
-}
-
-Ptr<FaceRecognizer> createLBPHFaceRecognizer(int radius, int neighbors,
-                                             int grid_x, int grid_y, double threshold)
-{
-    return makePtr<LBPH>(radius, neighbors, grid_x, grid_y, threshold);
-}
-
-CV_INIT_ALGORITHM(Eigenfaces, "FaceRecognizer.Eigenfaces",
-                  obj.info()->addParam(obj, "ncomponents", obj._num_components);
-                  obj.info()->addParam(obj, "threshold", obj._threshold);
-                  obj.info()->addParam(obj, "projections", obj._projections, true);
-                  obj.info()->addParam(obj, "labels", obj._labels, true);
-                  obj.info()->addParam(obj, "eigenvectors", obj._eigenvectors, true);
-                  obj.info()->addParam(obj, "eigenvalues", obj._eigenvalues, true);
-                  obj.info()->addParam(obj, "mean", obj._mean, true))
-
-CV_INIT_ALGORITHM(Fisherfaces, "FaceRecognizer.Fisherfaces",
-                  obj.info()->addParam(obj, "ncomponents", obj._num_components);
-                  obj.info()->addParam(obj, "threshold", obj._threshold);
-                  obj.info()->addParam(obj, "projections", obj._projections, true);
-                  obj.info()->addParam(obj, "labels", obj._labels, true);
-                  obj.info()->addParam(obj, "eigenvectors", obj._eigenvectors, true);
-                  obj.info()->addParam(obj, "eigenvalues", obj._eigenvalues, true);
-                  obj.info()->addParam(obj, "mean", obj._mean, true))
-
-CV_INIT_ALGORITHM(LBPH, "FaceRecognizer.LBPH",
-                  obj.info()->addParam(obj, "radius", obj._radius);
-                  obj.info()->addParam(obj, "neighbors", obj._neighbors);
-                  obj.info()->addParam(obj, "grid_x", obj._grid_x);
-                  obj.info()->addParam(obj, "grid_y", obj._grid_y);
-                  obj.info()->addParam(obj, "threshold", obj._threshold);
-                  obj.info()->addParam(obj, "histograms", obj._histograms, true);
-                  obj.info()->addParam(obj, "labels", obj._labels, true))
-
-bool initModule_contrib()
-{
-    Ptr<Algorithm> efaces = createEigenfaces_ptr_hidden(), ffaces = createFisherfaces_ptr_hidden(), lbph = createLBPH_ptr_hidden();
-    return efaces->info() != 0 && ffaces->info() != 0 && lbph->info() != 0;
-}
-
-}
diff --git a/modules/contrib/src/featuretracker.cpp b/modules/contrib/src/featuretracker.cpp
deleted file mode 100644 (file)
index cdf5348..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-//*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                                License Agreement
-//                       For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-#include <stdio.h>
-#include <iostream>
-#include "opencv2/calib3d.hpp"
-#include "opencv2/contrib/hybridtracker.hpp"
-
-#ifdef HAVE_OPENCV_NONFREE
-#include "opencv2/nonfree/nonfree.hpp"
-
-static bool makeUseOfNonfree = initModule_nonfree();
-#endif
-
-using namespace cv;
-
-CvFeatureTracker::CvFeatureTracker(CvFeatureTrackerParams _params) :
-    params(_params)
-{
-    switch (params.feature_type)
-    {
-    case CvFeatureTrackerParams::SIFT:
-        dd = Algorithm::create<Feature2D>("Feature2D.SIFT");
-        if( !dd )
-            CV_Error(CV_StsNotImplemented, "OpenCV has been compiled without SIFT support");
-        dd->set("nOctaveLayers", 5);
-        dd->set("contrastThreshold", 0.04);
-        dd->set("edgeThreshold", 10.7);
-        break;
-    case CvFeatureTrackerParams::SURF:
-        dd = Algorithm::create<Feature2D>("Feature2D.SURF");
-        if( !dd )
-            CV_Error(CV_StsNotImplemented, "OpenCV has been compiled without SURF support");
-        dd->set("hessianThreshold", 400);
-        dd->set("nOctaves", 3);
-        dd->set("nOctaveLayers", 4);
-        break;
-    default:
-        CV_Error(CV_StsBadArg, "Unknown feature type");
-        break;
-    }
-
-    matcher = makePtr<BFMatcher>(int(NORM_L2));
-}
-
-CvFeatureTracker::~CvFeatureTracker()
-{
-}
-
-void CvFeatureTracker::newTrackingWindow(Mat image, Rect selection)
-{
-    image.copyTo(prev_image);
-    cvtColor(prev_image, prev_image_bw, COLOR_BGR2GRAY);
-    prev_trackwindow = selection;
-    prev_center.x = selection.x;
-    prev_center.y = selection.y;
-    ittr = 0;
-}
-
-Rect CvFeatureTracker::updateTrackingWindow(Mat image)
-{
-    if(params.feature_type == CvFeatureTrackerParams::OPTICAL_FLOW)
-        return updateTrackingWindowWithFlow(image);
-    else
-        return updateTrackingWindowWithSIFT(image);
-}
-
-Rect CvFeatureTracker::updateTrackingWindowWithSIFT(Mat image)
-{
-    ittr++;
-    std::vector<KeyPoint> prev_keypoints, curr_keypoints;
-    std::vector<Point2f> prev_keys, curr_keys;
-    Mat prev_desc, curr_desc;
-
-    Rect window = prev_trackwindow;
-    Mat mask = Mat::zeros(image.size(), CV_8UC1);
-    rectangle(mask, Point(window.x, window.y), Point(window.x + window.width,
-            window.y + window.height), Scalar(255), CV_FILLED);
-
-    dd->operator()(prev_image, mask, prev_keypoints, prev_desc);
-
-    window.x -= params.window_size;
-    window.y -= params.window_size;
-    window.width += params.window_size;
-    window.height += params.window_size;
-    rectangle(mask, Point(window.x, window.y), Point(window.x + window.width,
-            window.y + window.height), Scalar(255), CV_FILLED);
-
-    dd->operator()(image, mask, curr_keypoints, curr_desc);
-
-    if (prev_keypoints.size() > 4 && curr_keypoints.size() > 4)
-    {
-        //descriptor->compute(prev_image, prev_keypoints, prev_desc);
-        //descriptor->compute(image, curr_keypoints, curr_desc);
-
-        matcher->match(prev_desc, curr_desc, matches);
-
-        for (int i = 0; i < (int)matches.size(); i++)
-        {
-            prev_keys.push_back(prev_keypoints[matches[i].queryIdx].pt);
-            curr_keys.push_back(curr_keypoints[matches[i].trainIdx].pt);
-        }
-
-        Mat T = findHomography(prev_keys, curr_keys, LMEDS);
-
-        prev_trackwindow.x += cvRound(T.at<double> (0, 2));
-        prev_trackwindow.y += cvRound(T.at<double> (1, 2));
-    }
-
-    prev_center.x = prev_trackwindow.x;
-    prev_center.y = prev_trackwindow.y;
-    prev_image = image;
-    return prev_trackwindow;
-}
-
-Rect CvFeatureTracker::updateTrackingWindowWithFlow(Mat image)
-{
-    ittr++;
-    Size subPixWinSize(10,10), winSize(31,31);
-    Mat image_bw;
-    TermCriteria termcrit(TermCriteria::COUNT | TermCriteria::EPS, 20, 0.03);
-    std::vector<uchar> status;
-    std::vector<float> err;
-
-    cvtColor(image, image_bw, COLOR_BGR2GRAY);
-    cvtColor(prev_image, prev_image_bw, COLOR_BGR2GRAY);
-
-    if (ittr == 1)
-    {
-        Mat mask = Mat::zeros(image.size(), CV_8UC1);
-        rectangle(mask, Point(prev_trackwindow.x, prev_trackwindow.y), Point(
-                prev_trackwindow.x + prev_trackwindow.width, prev_trackwindow.y
-                        + prev_trackwindow.height), Scalar(255), CV_FILLED);
-        goodFeaturesToTrack(image_bw, features[1], 500, 0.01, 20, mask, 3, 0, 0.04);
-        cornerSubPix(image_bw, features[1], subPixWinSize, Size(-1, -1), termcrit);
-    }
-    else
-    {
-        calcOpticalFlowPyrLK(prev_image_bw, image_bw, features[0], features[1],
-                status, err, winSize, 3, termcrit);
-
-        Point2f feature0_center(0, 0);
-        Point2f feature1_center(0, 0);
-        int goodtracks = 0;
-        for (int i = 0; i < (int)features[1].size(); i++)
-        {
-            if (status[i] == 1)
-            {
-                feature0_center.x += features[0][i].x;
-                feature0_center.y += features[0][i].y;
-                feature1_center.x += features[1][i].x;
-                feature1_center.y += features[1][i].y;
-                goodtracks++;
-            }
-        }
-
-        feature0_center.x /= goodtracks;
-        feature0_center.y /= goodtracks;
-        feature1_center.x /= goodtracks;
-        feature1_center.y /= goodtracks;
-
-        prev_center.x += (feature1_center.x - feature0_center.x);
-        prev_center.y += (feature1_center.y - feature0_center.y);
-
-        prev_trackwindow.x = (int)prev_center.x;
-        prev_trackwindow.y = (int)prev_center.y;
-    }
-
-    swap(features[0], features[1]);
-    image.copyTo(prev_image);
-    return prev_trackwindow;
-}
-
-void CvFeatureTracker::setTrackingWindow(Rect _window)
-{
-    prev_trackwindow = _window;
-}
-
-Rect CvFeatureTracker::getTrackingWindow()
-{
-    return prev_trackwindow;
-}
-
-Point2f CvFeatureTracker::getTrackingCenter()
-{
-    Point2f center(0, 0);
-    center.x = (float)(prev_center.x + prev_trackwindow.width/2.0);
-    center.y = (float)(prev_center.y + prev_trackwindow.height/2.0);
-    return center;
-}
diff --git a/modules/contrib/src/fuzzymeanshifttracker.cpp b/modules/contrib/src/fuzzymeanshifttracker.cpp
deleted file mode 100644 (file)
index ce247d9..0000000
+++ /dev/null
@@ -1,721 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install, copy or use the software.
-//
-// Copyright (C) 2009, Farhad Dadgostar
-// Intel Corporation and third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "opencv2/contrib/compat.hpp"
-
-CvFuzzyPoint::CvFuzzyPoint(double _x, double _y)
-{
-    x = _x;
-    y = _y;
-}
-
-bool CvFuzzyCurve::between(double x, double x1, double x2)
-{
-    if ((x >= x1) && (x <= x2))
-        return true;
-    else if ((x >= x2) && (x <= x1))
-        return true;
-
-    return false;
-}
-
-CvFuzzyCurve::CvFuzzyCurve()
-{
-    value = 0;
-}
-
-CvFuzzyCurve::~CvFuzzyCurve()
-{
-    // nothing to do
-}
-
-void CvFuzzyCurve::setCentre(double _centre)
-{
-    centre = _centre;
-}
-
-double CvFuzzyCurve::getCentre()
-{
-    return centre;
-}
-
-void CvFuzzyCurve::clear()
-{
-    points.clear();
-}
-
-void CvFuzzyCurve::addPoint(double x, double y)
-{
-    points.push_back(CvFuzzyPoint(x, y));
-}
-
-double CvFuzzyCurve::calcValue(double param)
-{
-    int size = (int)points.size();
-    double x1, y1, x2, y2, m, y;
-    for (int i = 1; i < size; i++)
-    {
-        x1 = points[i-1].x;
-        x2 = points[i].x;
-        if (between(param, x1, x2)) {
-            y1 = points[i-1].y;
-            y2 = points[i].y;
-            if (x2 == x1)
-                return y2;
-            m = (y2-y1)/(x2-x1);
-            y = m*(param-x1)+y1;
-            return y;
-        }
-    }
-    return 0;
-}
-
-double CvFuzzyCurve::getValue()
-{
-    return value;
-}
-
-void CvFuzzyCurve::setValue(double _value)
-{
-    value = _value;
-}
-
-
-CvFuzzyFunction::CvFuzzyFunction()
-{
-    // nothing to do
-}
-
-CvFuzzyFunction::~CvFuzzyFunction()
-{
-    curves.clear();
-}
-
-void CvFuzzyFunction::addCurve(CvFuzzyCurve *curve, double value)
-{
-    curves.push_back(*curve);
-    curve->setValue(value);
-}
-
-void CvFuzzyFunction::resetValues()
-{
-    int numCurves = (int)curves.size();
-    for (int i = 0; i < numCurves; i++)
-        curves[i].setValue(0);
-}
-
-double CvFuzzyFunction::calcValue()
-{
-    double s1 = 0, s2 = 0, v;
-    int numCurves = (int)curves.size();
-    for (int i = 0; i < numCurves; i++)
-    {
-        v = curves[i].getValue();
-        s1 += curves[i].getCentre() * v;
-        s2 += v;
-    }
-
-    if (s2 != 0)
-        return s1/s2;
-    else
-        return 0;
-}
-
-CvFuzzyCurve *CvFuzzyFunction::newCurve()
-{
-    CvFuzzyCurve *c;
-    c = new CvFuzzyCurve();
-    addCurve(c);
-    return c;
-}
-
-CvFuzzyRule::CvFuzzyRule()
-{
-    fuzzyInput1 = NULL;
-    fuzzyInput2 = NULL;
-    fuzzyOutput = NULL;
-}
-
-CvFuzzyRule::~CvFuzzyRule()
-{
-    if (fuzzyInput1 != NULL)
-        delete fuzzyInput1;
-
-    if (fuzzyInput2 != NULL)
-        delete fuzzyInput2;
-
-    if (fuzzyOutput != NULL)
-        delete fuzzyOutput;
-}
-
-void CvFuzzyRule::setRule(CvFuzzyCurve *c1, CvFuzzyCurve *c2, CvFuzzyCurve *o1)
-{
-    fuzzyInput1 = c1;
-    fuzzyInput2 = c2;
-    fuzzyOutput = o1;
-}
-
-double CvFuzzyRule::calcValue(double param1, double param2)
-{
-    double v1, v2;
-    v1 = fuzzyInput1->calcValue(param1);
-    if (fuzzyInput2 != NULL)
-    {
-        v2 = fuzzyInput2->calcValue(param2);
-        if (v1 < v2)
-            return v1;
-        else
-            return v2;
-    }
-    else
-        return v1;
-}
-
-CvFuzzyCurve *CvFuzzyRule::getOutputCurve()
-{
-    return fuzzyOutput;
-}
-
-CvFuzzyController::CvFuzzyController()
-{
-    // nothing to do
-}
-
-CvFuzzyController::~CvFuzzyController()
-{
-    int size = (int)rules.size();
-    for(int i = 0; i < size; i++)
-        delete rules[i];
-}
-
-void CvFuzzyController::addRule(CvFuzzyCurve *c1, CvFuzzyCurve *c2, CvFuzzyCurve *o1)
-{
-    CvFuzzyRule *f = new CvFuzzyRule();
-    rules.push_back(f);
-    f->setRule(c1, c2, o1);
-}
-
-double CvFuzzyController::calcOutput(double param1, double param2)
-{
-    double v;
-    CvFuzzyFunction list;
-    int size = (int)rules.size();
-
-    for(int i = 0; i < size; i++)
-    {
-        v = rules[i]->calcValue(param1, param2);
-        if (v != 0)
-            list.addCurve(rules[i]->getOutputCurve(), v);
-    }
-    v = list.calcValue();
-    return v;
-}
-
-CvFuzzyMeanShiftTracker::FuzzyResizer::FuzzyResizer()
-{
-    CvFuzzyCurve *i1L, *i1M, *i1H;
-    CvFuzzyCurve *oS, *oZE, *oE;
-    CvFuzzyCurve *c;
-
-    double MedStart = 0.1, MedWidth = 0.15;
-
-    c = iInput.newCurve();
-    c->addPoint(0, 1);
-    c->addPoint(0.1, 0);
-    c->setCentre(0);
-    i1L = c;
-
-    c = iInput.newCurve();
-    c->addPoint(0.05, 0);
-    c->addPoint(MedStart, 1);
-    c->addPoint(MedStart+MedWidth, 1);
-    c->addPoint(MedStart+MedWidth+0.05, 0);
-    c->setCentre(MedStart+(MedWidth/2));
-    i1M = c;
-
-    c = iInput.newCurve();
-    c->addPoint(MedStart+MedWidth, 0);
-    c->addPoint(1, 1);
-    c->addPoint(1000, 1);
-    c->setCentre(1);
-    i1H = c;
-
-    c = iOutput.newCurve();
-    c->addPoint(-10000, 1);
-    c->addPoint(-5, 1);
-    c->addPoint(-0.5, 0);
-    c->setCentre(-5);
-    oS = c;
-
-    c = iOutput.newCurve();
-    c->addPoint(-1, 0);
-    c->addPoint(-0.05, 1);
-    c->addPoint(0.05, 1);
-    c->addPoint(1, 0);
-    c->setCentre(0);
-    oZE = c;
-
-    c = iOutput.newCurve();
-    c->addPoint(-0.5, 0);
-    c->addPoint(5, 1);
-    c->addPoint(1000, 1);
-    c->setCentre(5);
-    oE = c;
-
-    fuzzyController.addRule(i1L, NULL, oS);
-    fuzzyController.addRule(i1M, NULL, oZE);
-    fuzzyController.addRule(i1H, NULL, oE);
-}
-
-int CvFuzzyMeanShiftTracker::FuzzyResizer::calcOutput(double edgeDensity, double density)
-{
-    return (int)fuzzyController.calcOutput(edgeDensity, density);
-}
-
-CvFuzzyMeanShiftTracker::SearchWindow::SearchWindow()
-{
-    x = 0;
-    y = 0;
-    width = 0;
-    height = 0;
-    maxWidth = 0;
-    maxHeight = 0;
-    xGc = 0;
-    yGc = 0;
-    m00 = 0;
-    m01 = 0;
-    m10 = 0;
-    m11 = 0;
-    m02 = 0;
-    m20 = 0;
-    ellipseHeight = 0;
-    ellipseWidth = 0;
-    ellipseAngle = 0;
-    density = 0;
-    depthLow = 0;
-    depthHigh = 0;
-    fuzzyResizer = NULL;
-}
-
-CvFuzzyMeanShiftTracker::SearchWindow::~SearchWindow()
-{
-    if (fuzzyResizer != NULL)
-        delete fuzzyResizer;
-}
-
-void CvFuzzyMeanShiftTracker::SearchWindow::setSize(int _x, int _y, int _width, int _height)
-{
-    x = _x;
-    y = _y;
-    width = _width;
-    height = _height;
-
-    if (x < 0)
-        x = 0;
-
-    if (y < 0)
-        y = 0;
-
-    if (x + width > maxWidth)
-        width = maxWidth - x;
-
-    if (y + height > maxHeight)
-        height = maxHeight - y;
-}
-
-void CvFuzzyMeanShiftTracker::SearchWindow::initDepthValues(IplImage *maskImage, IplImage *depthMap)
-{
-    unsigned int d=0, mind = 0xFFFF, maxd = 0, m0 = 0, m1 = 0, mc, dd;
-    unsigned char *data = NULL;
-    unsigned short *depthData = NULL;
-
-    for (int j = 0; j < height; j++)
-    {
-        data = (unsigned char *)(maskImage->imageData + (maskImage->widthStep * (j + y)) + x);
-        if (depthMap)
-            depthData = (unsigned short *)(depthMap->imageData + (depthMap->widthStep * (j + y)) + x);
-
-        for (int i = 0; i < width; i++)
-        {
-            if (*data)
-            {
-                m0 += 1;
-
-                if (depthData)
-                {
-                    if (*depthData)
-                    {
-                        d = *depthData;
-                        m1 += d;
-                        if (d < mind)
-                            mind = d;
-                        if (d > maxd)
-                            maxd = d;
-                    }
-                    depthData++;
-                }
-            }
-            data++;
-        }
-    }
-
-    if (m0 > 0)
-    {
-        mc = m1/m0;
-        if ((mc - mind) > (maxd - mc))
-            dd = maxd - mc;
-        else
-            dd = mc - mind;
-        dd = dd - dd/10;
-        depthHigh = mc + dd;
-        depthLow = mc - dd;
-    }
-    else
-    {
-        depthHigh = 32000;
-        depthLow = 0;
-    }
-}
-
-bool CvFuzzyMeanShiftTracker::SearchWindow::shift()
-{
-    if ((xGc != (width/2)) || (yGc != (height/2)))
-    {
-        setSize(x + (xGc-(width/2)), y + (yGc-(height/2)), width, height);
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
-
-void CvFuzzyMeanShiftTracker::SearchWindow::extractInfo(IplImage *maskImage, IplImage *depthMap, bool initDepth)
-{
-    m00 = 0;
-    m10 = 0;
-    m01 = 0;
-    m11 = 0;
-    density = 0;
-    m02 = 0;
-    m20 = 0;
-    ellipseHeight = 0;
-    ellipseWidth = 0;
-
-    maxWidth = maskImage->width;
-    maxHeight = maskImage->height;
-
-    if (initDepth)
-        initDepthValues(maskImage, depthMap);
-
-    unsigned char *maskData = NULL;
-    unsigned short *depthData = NULL, depth;
-    bool isOk;
-    unsigned long count;
-
-    verticalEdgeLeft = 0;
-    verticalEdgeRight = 0;
-    horizontalEdgeTop = 0;
-    horizontalEdgeBottom = 0;
-
-    for (int j = 0; j < height; j++)
-    {
-        maskData = (unsigned char *)(maskImage->imageData + (maskImage->widthStep * (j + y)) + x);
-        if (depthMap)
-            depthData = (unsigned short *)(depthMap->imageData + (depthMap->widthStep * (j + y)) + x);
-
-        count = 0;
-        for (int i = 0; i < width; i++)
-        {
-            if (*maskData)
-            {
-                isOk = true;
-                if (depthData)
-                {
-                    depth = (*depthData);
-                    if ((depth > depthHigh) || (depth < depthLow))
-                        isOk = false;
-
-                    depthData++;
-                }
-
-                if (isOk)
-                {
-                    m00++;
-                    m01 += j;
-                    m10 += i;
-                    m02 += (j * j);
-                    m20 += (i * i);
-                    m11 += (j * i);
-
-                    if (i == 0)
-                        verticalEdgeLeft++;
-                    else if (i == width-1)
-                        verticalEdgeRight++;
-                    else if (j == 0)
-                        horizontalEdgeTop++;
-                    else if (j == height-1)
-                        horizontalEdgeBottom++;
-
-                    count++;
-                }
-            }
-            maskData++;
-        }
-    }
-
-    if (m00 > 0)
-    {
-        xGc = (m10 / m00);
-        yGc = (m01 / m00);
-
-        double a, b, c, e1, e2, e3;
-        a = ((double)m20/(double)m00)-(xGc * xGc);
-        b = 2*(((double)m11/(double)m00)-(xGc * yGc));
-        c = ((double)m02/(double)m00)-(yGc * yGc);
-        e1 = a+c;
-        e3 = a-c;
-        e2 = sqrt((b*b)+(e3*e3));
-        ellipseHeight = int(sqrt(0.5*(e1+e2)));
-        ellipseWidth = int(sqrt(0.5*(e1-e2)));
-        if (e3 == 0)
-            ellipseAngle = 0;
-        else
-            ellipseAngle = 0.5*atan(b/e3);
-
-        density = (double)m00/(double)(width * height);
-    }
-    else
-    {
-        xGc = width / 2;
-        yGc = height / 2;
-        ellipseHeight = 0;
-        ellipseWidth = 0;
-        ellipseAngle = 0;
-        density = 0;
-    }
-}
-
-void CvFuzzyMeanShiftTracker::SearchWindow::getResizeAttribsEdgeDensityLinear(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh) {
-    int x1 = horizontalEdgeTop;
-    int x2 = horizontalEdgeBottom;
-    int y1 = verticalEdgeLeft;
-    int y2 = verticalEdgeRight;
-    int gx = (width*2)/5;
-    int gy = (height*2)/5;
-    int lx = width/10;
-    int ly = height/10;
-
-    resizeDy = 0;
-    resizeDh = 0;
-    resizeDx = 0;
-    resizeDw = 0;
-
-    if (x1 > gx) {
-        resizeDy = -1;
-    } else if (x1 < lx) {
-        resizeDy = +1;
-    }
-
-    if (x2 > gx) {
-        resizeDh = resizeDy + 1;
-    } else if (x2 < lx) {
-        resizeDh = - (resizeDy + 1);
-    } else {
-        resizeDh = - resizeDy;
-    }
-
-    if (y1 > gy) {
-        resizeDx = -1;
-    } else if (y1 < ly) {
-        resizeDx = +1;
-    }
-
-    if (y2 > gy) {
-        resizeDw = resizeDx + 1;
-    } else if (y2 < ly) {
-        resizeDw = - (resizeDx + 1);
-    } else {
-        resizeDw = - resizeDx;
-    }
-}
-
-void CvFuzzyMeanShiftTracker::SearchWindow::getResizeAttribsInnerDensity(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh)
-{
-    int newWidth, newHeight, dx, dy;
-    double px, py;
-    newWidth = int(sqrt(double(m00)*1.3));
-    newHeight = int(newWidth*1.2);
-    dx = (newWidth - width);
-    dy = (newHeight - height);
-    px = (double)xGc/(double)width;
-    py = (double)yGc/(double)height;
-    resizeDx = (int)(px*dx);
-    resizeDy = (int)(py*dy);
-    resizeDw = (int)((1-px)*dx);
-    resizeDh = (int)((1-py)*dy);
-}
-
-void CvFuzzyMeanShiftTracker::SearchWindow::getResizeAttribsEdgeDensityFuzzy(int &resizeDx, int &resizeDy, int &resizeDw, int &resizeDh)
-{
-    double dx1=0, dx2, dy1, dy2;
-
-    resizeDy = 0;
-    resizeDh = 0;
-    resizeDx = 0;
-    resizeDw = 0;
-
-    if (fuzzyResizer == NULL)
-        fuzzyResizer = new FuzzyResizer();
-
-    dx2 = fuzzyResizer->calcOutput(double(verticalEdgeRight)/double(height), density);
-    if (dx1 == dx2)
-    {
-        resizeDx = int(-dx1);
-        resizeDw = int(dx1+dx2);
-    }
-
-    dy1 = fuzzyResizer->calcOutput(double(horizontalEdgeTop)/double(width), density);
-    dy2 = fuzzyResizer->calcOutput(double(horizontalEdgeBottom)/double(width), density);
-
-    dx1 = fuzzyResizer->calcOutput(double(verticalEdgeLeft)/double(height), density);
-    dx2 = fuzzyResizer->calcOutput(double(verticalEdgeRight)/double(height), density);
-    //if (dx1 == dx2)
-    {
-        resizeDx = int(-dx1);
-        resizeDw = int(dx1+dx2);
-    }
-
-    dy1 = fuzzyResizer->calcOutput(double(horizontalEdgeTop)/double(width), density);
-    dy2 = fuzzyResizer->calcOutput(double(horizontalEdgeBottom)/double(width), density);
-    //if (dy1 == dy2)
-    {
-        resizeDy = int(-dy1);
-        resizeDh = int(dy1+dy2);
-    }
-}
-
-bool CvFuzzyMeanShiftTracker::SearchWindow::meanShift(IplImage *maskImage, IplImage *depthMap, int maxIteration, bool initDepth)
-{
-    numShifts = 0;
-    do
-    {
-        extractInfo(maskImage, depthMap, initDepth);
-        if (! shift())
-            return true;
-    } while (++numShifts < maxIteration);
-
-    return false;
-}
-
-void CvFuzzyMeanShiftTracker::findOptimumSearchWindow(SearchWindow &searchWindow, IplImage *maskImage, IplImage *depthMap, int maxIteration, int resizeMethod, bool initDepth)
-{
-    int resizeDx, resizeDy, resizeDw, resizeDh;
-    resizeDx = 0;
-    resizeDy = 0;
-    resizeDw = 0;
-    resizeDh = 0;
-    searchWindow.numIters = 0;
-    for (int i = 0; i < maxIteration; i++)
-    {
-        searchWindow.numIters++;
-        searchWindow.meanShift(maskImage, depthMap, MaxMeanShiftIteration, initDepth);
-        switch (resizeMethod)
-        {
-            case rmEdgeDensityLinear :
-                searchWindow.getResizeAttribsEdgeDensityLinear(resizeDx, resizeDy, resizeDw, resizeDh);
-                break;
-            case rmEdgeDensityFuzzy :
-                //searchWindow.getResizeAttribsEdgeDensityLinear(resizeDx, resizeDy, resizeDw, resizeDh);
-                searchWindow.getResizeAttribsEdgeDensityFuzzy(resizeDx, resizeDy, resizeDw, resizeDh);
-                break;
-            case rmInnerDensity :
-                searchWindow.getResizeAttribsInnerDensity(resizeDx, resizeDy, resizeDw, resizeDh);
-                break;
-            default:
-                searchWindow.getResizeAttribsEdgeDensityLinear(resizeDx, resizeDy, resizeDw, resizeDh);
-        }
-
-        searchWindow.ldx = resizeDx;
-        searchWindow.ldy = resizeDy;
-        searchWindow.ldw = resizeDw;
-        searchWindow.ldh = resizeDh;
-
-        if ((resizeDx == 0) && (resizeDy == 0) && (resizeDw == 0) && (resizeDh == 0))
-            break;
-
-        searchWindow.setSize(searchWindow.x + resizeDx, searchWindow.y + resizeDy, searchWindow.width + resizeDw, searchWindow.height + resizeDh);
-    }
-}
-
-CvFuzzyMeanShiftTracker::CvFuzzyMeanShiftTracker()
-{
-    searchMode = tsSetWindow;
-}
-
-CvFuzzyMeanShiftTracker::~CvFuzzyMeanShiftTracker()
-{
-    // nothing to do
-}
-
-void CvFuzzyMeanShiftTracker::track(IplImage *maskImage, IplImage *depthMap, int resizeMethod, bool resetSearch, int minKernelMass)
-{
-    bool initDepth = false;
-
-    if (resetSearch)
-        searchMode = tsSetWindow;
-
-    switch (searchMode)
-    {
-        case tsDisabled:
-            return;
-        case tsSearching:
-            return;
-        case tsSetWindow:
-            kernel.maxWidth = maskImage->width;
-            kernel.maxHeight = maskImage->height;
-            kernel.setSize(0, 0, maskImage->width, maskImage->height);
-            initDepth = true;
-        case tsTracking:
-            searchMode = tsSearching;
-            findOptimumSearchWindow(kernel, maskImage, depthMap, MaxSetSizeIteration, resizeMethod, initDepth);
-            if ((kernel.density == 0) || (kernel.m00 < minKernelMass))
-                searchMode = tsSetWindow;
-            else
-                searchMode = tsTracking;
-    }
-}
diff --git a/modules/contrib/src/gencolors.cpp b/modules/contrib/src/gencolors.cpp
deleted file mode 100644 (file)
index 24796ec..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-#include <iostream>
-
-using namespace cv;
-
-static void downsamplePoints( const Mat& src, Mat& dst, size_t count )
-{
-    CV_Assert( count >= 2 );
-    CV_Assert( src.cols == 1 || src.rows == 1 );
-    CV_Assert( src.total() >= count );
-    CV_Assert( src.type() == CV_8UC3);
-
-    dst.create( 1, (int)count, CV_8UC3 );
-    //TODO: optimize by exploiting symmetry in the distance matrix
-    Mat dists( (int)src.total(), (int)src.total(), CV_32FC1, Scalar(0) );
-    if( dists.empty() )
-        std::cerr << "Such big matrix cann't be created." << std::endl;
-
-    for( int i = 0; i < dists.rows; i++ )
-    {
-        for( int j = i; j < dists.cols; j++ )
-        {
-            float dist = (float)norm(src.at<Point3_<uchar> >(i) - src.at<Point3_<uchar> >(j));
-            dists.at<float>(j, i) = dists.at<float>(i, j) = dist;
-        }
-    }
-
-    double maxVal;
-    Point maxLoc;
-    minMaxLoc(dists, 0, &maxVal, 0, &maxLoc);
-
-    dst.at<Point3_<uchar> >(0) = src.at<Point3_<uchar> >(maxLoc.x);
-    dst.at<Point3_<uchar> >(1) = src.at<Point3_<uchar> >(maxLoc.y);
-
-    Mat activedDists( 0, dists.cols, dists.type() );
-    Mat candidatePointsMask( 1, dists.cols, CV_8UC1, Scalar(255) );
-    activedDists.push_back( dists.row(maxLoc.y) );
-    candidatePointsMask.at<uchar>(0, maxLoc.y) = 0;
-
-    for( size_t i = 2; i < count; i++ )
-    {
-        activedDists.push_back(dists.row(maxLoc.x));
-        candidatePointsMask.at<uchar>(0, maxLoc.x) = 0;
-
-        Mat minDists;
-        reduce( activedDists, minDists, 0, REDUCE_MIN );
-        minMaxLoc( minDists, 0, &maxVal, 0, &maxLoc, candidatePointsMask );
-        dst.at<Point3_<uchar> >((int)i) = src.at<Point3_<uchar> >(maxLoc.x);
-    }
-}
-
-void cv::generateColors( std::vector<Scalar>& colors, size_t count, size_t factor )
-{
-    if( count < 1 )
-        return;
-
-    colors.resize(count);
-
-    if( count == 1 )
-    {
-        colors[0] = Scalar(0,0,255); // red
-        return;
-    }
-    if( count == 2 )
-    {
-        colors[0] = Scalar(0,0,255); // red
-        colors[1] = Scalar(0,255,0); // green
-        return;
-    }
-
-    // Generate a set of colors in RGB space. A size of the set is severel times (=factor) larger then
-    // the needed count of colors.
-    Mat bgr( 1, (int)(count*factor), CV_8UC3 );
-    randu( bgr, 0, 256 );
-
-    // Convert the colors set to Lab space.
-    // Distances between colors in this space correspond a human perception.
-    Mat lab;
-    cvtColor( bgr, lab, COLOR_BGR2Lab);
-
-    // Subsample colors from the generated set so that
-    // to maximize the minimum distances between each other.
-    // Douglas-Peucker algorithm is used for this.
-    Mat lab_subset;
-    downsamplePoints( lab, lab_subset, count );
-
-    // Convert subsampled colors back to RGB
-    Mat bgr_subset;
-    cvtColor( lab_subset, bgr_subset, COLOR_Lab2BGR );
-
-    CV_Assert( bgr_subset.total() == count );
-    for( size_t i = 0; i < count; i++ )
-    {
-        Point3_<uchar> c = bgr_subset.at<Point3_<uchar> >((int)i);
-        colors[i] = Scalar(c.x, c.y, c.z);
-    }
-}
diff --git a/modules/contrib/src/hybridtracker.cpp b/modules/contrib/src/hybridtracker.cpp
deleted file mode 100644 (file)
index d93f76d..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-//*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                                License Agreement
-//                       For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-#include "opencv2/contrib/hybridtracker.hpp"
-
-using namespace cv;
-
-CvHybridTrackerParams::CvHybridTrackerParams(float _ft_tracker_weight, float _ms_tracker_weight,
-            CvFeatureTrackerParams _ft_params,
-            CvMeanShiftTrackerParams _ms_params,
-            CvMotionModel)
-{
-    ft_tracker_weight = _ft_tracker_weight;
-    ms_tracker_weight = _ms_tracker_weight;
-    ft_params = _ft_params;
-    ms_params = _ms_params;
-}
-
-CvMeanShiftTrackerParams::CvMeanShiftTrackerParams(int _tracking_type, CvTermCriteria _term_crit)
-{
-    tracking_type = _tracking_type;
-    term_crit = _term_crit;
-}
-
-CvHybridTracker::CvHybridTracker() {
-
-}
-
-CvHybridTracker::CvHybridTracker(HybridTrackerParams _params) :
-    params(_params) {
-    params.ft_params.feature_type = CvFeatureTrackerParams::SIFT;
-    mstracker = new CvMeanShiftTracker(params.ms_params);
-    fttracker = new CvFeatureTracker(params.ft_params);
-}
-
-CvHybridTracker::~CvHybridTracker() {
-    if (mstracker != NULL)
-        delete mstracker;
-    if (fttracker != NULL)
-        delete fttracker;
-}
-
-inline float CvHybridTracker::getL2Norm(Point2f p1, Point2f p2) {
-    float distance = (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y
-            - p2.y);
-    return std::sqrt(distance);
-}
-
-Mat CvHybridTracker::getDistanceProjection(Mat image, Point2f center) {
-    Mat hist(image.size(), CV_64F);
-
-    double lu = getL2Norm(Point(0, 0), center);
-    double ru = getL2Norm(Point(0, image.size().width), center);
-    double rd = getL2Norm(Point(image.size().height, image.size().width),
-            center);
-    double ld = getL2Norm(Point(image.size().height, 0), center);
-
-    double max = (lu < ru) ? lu : ru;
-    max = (max < rd) ? max : rd;
-    max = (max < ld) ? max : ld;
-
-    for (int i = 0; i < hist.rows; i++)
-        for (int j = 0; j < hist.cols; j++)
-            hist.at<double> (i, j) = 1.0 - (getL2Norm(Point(i, j), center)
-                    / max);
-
-    return hist;
-}
-
-Mat CvHybridTracker::getGaussianProjection(Mat image, int ksize, double sigma,
-        Point2f center) {
-    Mat kernel = getGaussianKernel(ksize, sigma, CV_64F);
-    double max = kernel.at<double> (ksize / 2);
-
-    Mat hist(image.size(), CV_64F);
-    for (int i = 0; i < hist.rows; i++)
-        for (int j = 0; j < hist.cols; j++) {
-            int pos = cvRound(getL2Norm(Point(i, j), center));
-            if (pos < ksize / 2.0)
-                hist.at<double> (i, j) = 1.0 - (kernel.at<double> (pos) / max);
-        }
-
-    return hist;
-}
-
-void CvHybridTracker::newTracker(Mat image, Rect selection) {
-    prev_proj = Mat::zeros(image.size(), CV_64FC1);
-    prev_center = Point2f(selection.x + selection.width / 2.0f, selection.y
-            + selection.height / 2.0f);
-    prev_window = selection;
-
-    mstracker->newTrackingWindow(image, selection);
-    fttracker->newTrackingWindow(image, selection);
-
-    samples = cvCreateMat(2, 1, CV_32FC1);
-    labels = cvCreateMat(2, 1, CV_32SC1);
-
-    ittr = 0;
-}
-
-void CvHybridTracker::updateTracker(Mat image) {
-    ittr++;
-
-    //copy over clean images: TODO
-    mstracker->updateTrackingWindow(image);
-    fttracker->updateTrackingWindowWithFlow(image);
-
-    if (params.motion_model == CvMotionModel::EM)
-        updateTrackerWithEM(image);
-    else
-        updateTrackerWithLowPassFilter(image);
-
-    // Regression to find new weights
-    Point2f ms_center = mstracker->getTrackingEllipse().center;
-    Point2f ft_center = fttracker->getTrackingCenter();
-
-#ifdef DEBUG_HYTRACKER
-    circle(image, ms_center, 3, Scalar(0, 0, 255), -1, 8);
-    circle(image, ft_center, 3, Scalar(255, 0, 0), -1, 8);
-    putText(image, "ms", Point(ms_center.x+2, ms_center.y), FONT_HERSHEY_PLAIN, 0.75, Scalar(255, 255, 255));
-    putText(image, "ft", Point(ft_center.x+2, ft_center.y), FONT_HERSHEY_PLAIN, 0.75, Scalar(255, 255, 255));
-#endif
-
-    double ms_len = getL2Norm(ms_center, curr_center);
-    double ft_len = getL2Norm(ft_center, curr_center);
-    double total_len = ms_len + ft_len;
-
-    params.ms_tracker_weight *= (ittr - 1);
-    params.ms_tracker_weight += (float)((ms_len / total_len));
-    params.ms_tracker_weight /= ittr;
-    params.ft_tracker_weight *= (ittr - 1);
-    params.ft_tracker_weight += (float)((ft_len / total_len));
-    params.ft_tracker_weight /= ittr;
-
-    circle(image, prev_center, 3, Scalar(0, 0, 0), -1, 8);
-    circle(image, curr_center, 3, Scalar(255, 255, 255), -1, 8);
-
-    prev_center = curr_center;
-    prev_window.x = (int)(curr_center.x-prev_window.width/2.0);
-    prev_window.y = (int)(curr_center.y-prev_window.height/2.0);
-
-    mstracker->setTrackingWindow(prev_window);
-    fttracker->setTrackingWindow(prev_window);
-}
-
-void CvHybridTracker::updateTrackerWithEM(Mat image) {
-    Mat ms_backproj = mstracker->getHistogramProjection(CV_64F);
-    Mat ms_distproj = getDistanceProjection(image, mstracker->getTrackingCenter());
-    Mat ms_proj = ms_backproj.mul(ms_distproj);
-
-    float dist_err = getL2Norm(mstracker->getTrackingCenter(), fttracker->getTrackingCenter());
-    Mat ft_gaussproj = getGaussianProjection(image, cvRound(dist_err), -1, fttracker->getTrackingCenter());
-    Mat ft_distproj = getDistanceProjection(image, fttracker->getTrackingCenter());
-    Mat ft_proj = ft_gaussproj.mul(ft_distproj);
-
-    Mat proj = params.ms_tracker_weight * ms_proj + params.ft_tracker_weight * ft_proj + prev_proj;
-
-    int sample_count = countNonZero(proj);
-    cvReleaseMat(&samples);
-    cvReleaseMat(&labels);
-    samples = cvCreateMat(sample_count, 2, CV_32FC1);
-    labels = cvCreateMat(sample_count, 1, CV_32SC1);
-
-    int count = 0;
-    for (int i = 0; i < proj.rows; i++)
-        for (int j = 0; j < proj.cols; j++)
-            if (proj.at<double> (i, j) > 0) {
-                samples->data.fl[count * 2] = (float)i;
-                samples->data.fl[count * 2 + 1] = (float)j;
-                count++;
-            }
-
-    cv::Mat lbls;
-
-    EM em_model(1, EM::COV_MAT_SPHERICAL, TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 10000, 0.001));
-    em_model.train(cvarrToMat(samples), noArray(), lbls);
-    if(labels)
-        lbls.copyTo(cvarrToMat(labels));
-
-    Mat em_means = em_model.get<Mat>("means");
-    curr_center.x = (float)em_means.at<float>(0, 0);
-    curr_center.y = (float)em_means.at<float>(0, 1);
-}
-
-void CvHybridTracker::updateTrackerWithLowPassFilter(Mat) {
-    RotatedRect ms_track = mstracker->getTrackingEllipse();
-    Point2f ft_center = fttracker->getTrackingCenter();
-
-    float a = params.low_pass_gain;
-    curr_center.x = (1 - a) * prev_center.x + a * (params.ms_tracker_weight * ms_track.center.x + params.ft_tracker_weight * ft_center.x);
-    curr_center.y = (1 - a) * prev_center.y + a * (params.ms_tracker_weight * ms_track.center.y + params.ft_tracker_weight * ft_center.y);
-}
-
-Rect CvHybridTracker::getTrackingWindow() {
-    return prev_window;
-}
diff --git a/modules/contrib/src/inputoutput.cpp b/modules/contrib/src/inputoutput.cpp
deleted file mode 100644 (file)
index 7f58355..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-#include "opencv2/contrib.hpp"
-#include "cvconfig.h"
-
-#if defined(WIN32) || defined(_WIN32)
-    #include <windows.h>
-    #include <tchar.h>
-#else
-    #include <dirent.h>
-#endif
-
-namespace cv
-{
-    std::vector<String> Directory::GetListFiles( const String& path, const String & exten, bool addPath )
-    {
-        std::vector<String> list;
-        list.clear();
-        String path_f = path + "/" + exten;
-        #ifdef WIN32
-        #ifdef HAVE_WINRT
-            WIN32_FIND_DATAW FindFileData;
-        #else
-            WIN32_FIND_DATAA FindFileData;
-        #endif
-        HANDLE hFind;
-
-        #ifdef HAVE_WINRT
-            wchar_t wpath[MAX_PATH];
-            size_t copied = mbstowcs(wpath, path_f.c_str(), MAX_PATH);
-            CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
-            hFind = FindFirstFileExW(wpath, FindExInfoStandard, &FindFileData, FindExSearchNameMatch, NULL, 0);
-        #else
-            hFind = FindFirstFileA((LPCSTR)path_f.c_str(), &FindFileData);
-        #endif
-            if (hFind == INVALID_HANDLE_VALUE)
-            {
-                return list;
-            }
-            else
-            {
-                do
-                {
-                    if (FindFileData.dwFileAttributes == FILE_ATTRIBUTE_NORMAL  ||
-                        FindFileData.dwFileAttributes == FILE_ATTRIBUTE_ARCHIVE ||
-                        FindFileData.dwFileAttributes == FILE_ATTRIBUTE_HIDDEN  ||
-                        FindFileData.dwFileAttributes == FILE_ATTRIBUTE_SYSTEM  ||
-                        FindFileData.dwFileAttributes == FILE_ATTRIBUTE_READONLY)
-                    {
-                        char* fname;
-                    #ifdef HAVE_WINRT
-                        char fname_tmp[MAX_PATH] = {0};
-                        size_t copied = wcstombs(fname_tmp, FindFileData.cFileName, MAX_PATH);
-                        CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
-                        fname = fname_tmp;
-                    #else
-                        fname = FindFileData.cFileName;
-                    #endif
-                        if (addPath)
-                            list.push_back(path + "/" + String(fname));
-                        else
-                            list.push_back(String(fname));
-                    }
-                }
-            #ifdef HAVE_WINRT
-                while(FindNextFileW(hFind, &FindFileData));
-            #else
-                while(FindNextFileA(hFind, &FindFileData));
-            #endif
-                FindClose(hFind);
-            }
-        #else
-            (void)addPath;
-            DIR *dp;
-            struct dirent *dirp;
-            if((dp = opendir(path.c_str())) == NULL)
-            {
-                return list;
-            }
-
-            while ((dirp = readdir(dp)) != NULL)
-            {
-                if (dirp->d_type == DT_REG)
-                {
-                    if (exten.compare("*") == 0)
-                        list.push_back(static_cast<String>(dirp->d_name));
-                    else
-                        if (String(dirp->d_name).find(exten) != String::npos)
-                            list.push_back(static_cast<String>(dirp->d_name));
-                }
-            }
-            closedir(dp);
-        #endif
-
-        return list;
-    }
-
-    std::vector<String> Directory::GetListFolders( const String& path, const String & exten, bool addPath )
-    {
-        std::vector<String> list;
-        String path_f = path + "/" + exten;
-        list.clear();
-        #ifdef WIN32
-        #ifdef HAVE_WINRT
-            WIN32_FIND_DATAW FindFileData;
-        #else
-            WIN32_FIND_DATAA FindFileData;
-        #endif
-            HANDLE hFind;
-
-        #ifdef HAVE_WINRT
-            wchar_t wpath [MAX_PATH];
-            size_t copied = mbstowcs(wpath, path_f.c_str(), path_f.size());
-            CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
-
-            hFind = FindFirstFileExW(wpath, FindExInfoStandard, &FindFileData, FindExSearchNameMatch, NULL, 0);
-        #else
-            hFind = FindFirstFileA((LPCSTR)path_f.c_str(), &FindFileData);
-        #endif
-            if (hFind == INVALID_HANDLE_VALUE)
-            {
-                return list;
-            }
-            else
-            {
-                do
-                {
-#ifdef HAVE_WINRT
-                    if (FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY &&
-                        wcscmp(FindFileData.cFileName, L".") != 0 &&
-                        wcscmp(FindFileData.cFileName, L"..") != 0)
-#else
-                    if (FindFileData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY &&
-                        strcmp(FindFileData.cFileName, ".") != 0 &&
-                        strcmp(FindFileData.cFileName, "..") != 0)
-#endif
-                    {
-                        char* fname;
-                    #ifdef HAVE_WINRT
-                        char fname_tmp[MAX_PATH];
-                        size_t copied = wcstombs(fname_tmp, FindFileData.cFileName, MAX_PATH);
-                        CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
-                        fname = fname_tmp;
-                    #else
-                        fname = FindFileData.cFileName;
-                    #endif
-
-                        if (addPath)
-                            list.push_back(path + "/" + String(fname));
-                        else
-                            list.push_back(String(fname));
-                    }
-                }
-            #ifdef HAVE_WINRT
-                while(FindNextFileW(hFind, &FindFileData));
-            #else
-                while(FindNextFileA(hFind, &FindFileData));
-            #endif
-                FindClose(hFind);
-            }
-
-        #else
-            (void)addPath;
-            DIR *dp;
-            struct dirent *dirp;
-            if((dp = opendir(path_f.c_str())) == NULL)
-            {
-                return list;
-            }
-
-            while ((dirp = readdir(dp)) != NULL)
-            {
-                if (dirp->d_type == DT_DIR &&
-                    strcmp(dirp->d_name, ".") != 0 &&
-                    strcmp(dirp->d_name, "..") != 0 )
-                {
-                    if (exten.compare("*") == 0)
-                        list.push_back(static_cast<String>(dirp->d_name));
-                    else
-                        if (String(dirp->d_name).find(exten) != String::npos)
-                            list.push_back(static_cast<String>(dirp->d_name));
-                }
-            }
-            closedir(dp);
-        #endif
-
-        return list;
-    }
-
-    std::vector<String> Directory::GetListFilesR ( const String& path, const String & exten, bool addPath )
-    {
-        std::vector<String> list = Directory::GetListFiles(path, exten, addPath);
-
-        std::vector<String> dirs = Directory::GetListFolders(path, exten, addPath);
-
-        std::vector<String>::const_iterator it;
-        for (it = dirs.begin(); it != dirs.end(); ++it)
-        {
-            std::vector<String> cl = Directory::GetListFiles(*it, exten, addPath);
-            list.insert(list.end(), cl.begin(), cl.end());
-        }
-
-        return list;
-    }
-
-}
diff --git a/modules/contrib/src/lda.cpp b/modules/contrib/src/lda.cpp
deleted file mode 100644 (file)
index 68f923f..0000000
+++ /dev/null
@@ -1,1108 +0,0 @@
-/*
- * Copyright (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>.
- * Released to public domain under terms of the BSD Simplified license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of the organization nor the names of its contributors
- *     may be used to endorse or promote products derived from this software
- *     without specific prior written permission.
- *
- *   See <http://www.opensource.org/licenses/bsd-license>
- */
-
-#include "precomp.hpp"
-#include <iostream>
-#include <map>
-#include <set>
-
-namespace cv
-{
-
-// Removes duplicate elements in a given vector.
-template<typename _Tp>
-inline std::vector<_Tp> remove_dups(const std::vector<_Tp>& src) {
-    typedef typename std::set<_Tp>::const_iterator constSetIterator;
-    typedef typename std::vector<_Tp>::const_iterator constVecIterator;
-    std::set<_Tp> set_elems;
-    for (constVecIterator it = src.begin(); it != src.end(); ++it)
-        set_elems.insert(*it);
-    std::vector<_Tp> elems;
-    for (constSetIterator it = set_elems.begin(); it != set_elems.end(); ++it)
-        elems.push_back(*it);
-    return elems;
-}
-
-static Mat argsort(InputArray _src, bool ascending=true)
-{
-    Mat src = _src.getMat();
-    if (src.rows != 1 && src.cols != 1) {
-        String error_message = "Wrong shape of input matrix! Expected a matrix with one row or column.";
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    int flags = SORT_EVERY_ROW | (ascending ? SORT_ASCENDING : SORT_DESCENDING);
-    Mat sorted_indices;
-    sortIdx(src.reshape(1,1),sorted_indices,flags);
-    return sorted_indices;
-}
-
-static Mat asRowMatrix(InputArrayOfArrays src, int rtype, double alpha=1, double beta=0) {
-    // make sure the input data is a vector of matrices or vector of vector
-    if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) {
-        String error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).";
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // number of samples
-    size_t n = src.total();
-    // return empty matrix if no matrices given
-    if(n == 0)
-        return Mat();
-    // dimensionality of (reshaped) samples
-    size_t d = src.getMat(0).total();
-    // create data matrix
-    Mat data((int)n, (int)d, rtype);
-    // now copy data
-    for(int i = 0; i < (int)n; i++) {
-        // make sure data can be reshaped, throw exception if not!
-        if(src.getMat(i).total() != d) {
-            String error_message = format("Wrong number of elements in matrix #%d! Expected %d was %d.", i, (int)d, (int)src.getMat(i).total());
-            CV_Error(Error::StsBadArg, error_message);
-        }
-        // get a hold of the current row
-        Mat xi = data.row(i);
-        // make reshape happy by cloning for non-continuous matrices
-        if(src.getMat(i).isContinuous()) {
-            src.getMat(i).reshape(1, 1).convertTo(xi, rtype, alpha, beta);
-        } else {
-            src.getMat(i).clone().reshape(1, 1).convertTo(xi, rtype, alpha, beta);
-        }
-    }
-    return data;
-}
-
-static void sortMatrixColumnsByIndices(InputArray _src, InputArray _indices, OutputArray _dst) {
-    if(_indices.getMat().type() != CV_32SC1) {
-        CV_Error(Error::StsUnsupportedFormat, "cv::sortColumnsByIndices only works on integer indices!");
-    }
-    Mat src = _src.getMat();
-    std::vector<int> indices = _indices.getMat();
-    _dst.create(src.rows, src.cols, src.type());
-    Mat dst = _dst.getMat();
-    for(size_t idx = 0; idx < indices.size(); idx++) {
-        Mat originalCol = src.col(indices[idx]);
-        Mat sortedCol = dst.col((int)idx);
-        originalCol.copyTo(sortedCol);
-    }
-}
-
-static Mat sortMatrixColumnsByIndices(InputArray src, InputArray indices) {
-    Mat dst;
-    sortMatrixColumnsByIndices(src, indices, dst);
-    return dst;
-}
-
-
-template<typename _Tp> static bool
-isSymmetric_(InputArray src) {
-    Mat _src = src.getMat();
-    if(_src.cols != _src.rows)
-        return false;
-    for (int i = 0; i < _src.rows; i++) {
-        for (int j = 0; j < _src.cols; j++) {
-            _Tp a = _src.at<_Tp> (i, j);
-            _Tp b = _src.at<_Tp> (j, i);
-            if (a != b) {
-                return false;
-            }
-        }
-    }
-    return true;
-}
-
-template<typename _Tp> static bool
-isSymmetric_(InputArray src, double eps) {
-    Mat _src = src.getMat();
-    if(_src.cols != _src.rows)
-        return false;
-    for (int i = 0; i < _src.rows; i++) {
-        for (int j = 0; j < _src.cols; j++) {
-            _Tp a = _src.at<_Tp> (i, j);
-            _Tp b = _src.at<_Tp> (j, i);
-            if (std::abs(a - b) > eps) {
-                return false;
-            }
-        }
-    }
-    return true;
-}
-
-static bool isSymmetric(InputArray src, double eps=1e-16)
-{
-    Mat m = src.getMat();
-    switch (m.type()) {
-        case CV_8SC1: return isSymmetric_<char>(m); break;
-        case CV_8UC1:
-            return isSymmetric_<unsigned char>(m); break;
-        case CV_16SC1:
-            return isSymmetric_<short>(m); break;
-        case CV_16UC1:
-            return isSymmetric_<unsigned short>(m); break;
-        case CV_32SC1:
-            return isSymmetric_<int>(m); break;
-        case CV_32FC1:
-            return isSymmetric_<float>(m, eps); break;
-        case CV_64FC1:
-            return isSymmetric_<double>(m, eps); break;
-        default:
-            break;
-    }
-    return false;
-}
-
-
-//------------------------------------------------------------------------------
-// cv::subspaceProject
-//------------------------------------------------------------------------------
-Mat subspaceProject(InputArray _W, InputArray _mean, InputArray _src) {
-    // get data matrices
-    Mat W = _W.getMat();
-    Mat mean = _mean.getMat();
-    Mat src = _src.getMat();
-    // get number of samples and dimension
-    int n = src.rows;
-    int d = src.cols;
-    // make sure the data has the correct shape
-    if(W.rows != d) {
-        String error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols);
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // make sure mean is correct if not empty
-    if(!mean.empty() && (mean.total() != (size_t) d)) {
-        String error_message = format("Wrong mean shape for the given data matrix. Expected %d, but was %d.", d, mean.total());
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // create temporary matrices
-    Mat X, Y;
-    // make sure you operate on correct type
-    src.convertTo(X, W.type());
-    // safe to do, because of above assertion
-    if(!mean.empty()) {
-        for(int i=0; i<n; i++) {
-            Mat r_i = X.row(i);
-            subtract(r_i, mean.reshape(1,1), r_i);
-        }
-    }
-    // finally calculate projection as Y = (X-mean)*W
-    gemm(X, W, 1.0, Mat(), 0.0, Y);
-    return Y;
-}
-
-//------------------------------------------------------------------------------
-// cv::subspaceReconstruct
-//------------------------------------------------------------------------------
-Mat subspaceReconstruct(InputArray _W, InputArray _mean, InputArray _src)
-{
-    // get data matrices
-    Mat W = _W.getMat();
-    Mat mean = _mean.getMat();
-    Mat src = _src.getMat();
-    // get number of samples and dimension
-    int n = src.rows;
-    int d = src.cols;
-    // make sure the data has the correct shape
-    if(W.cols != d) {
-        String error_message = format("Wrong shapes for given matrices. Was size(src) = (%d,%d), size(W) = (%d,%d).", src.rows, src.cols, W.rows, W.cols);
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // make sure mean is correct if not empty
-    if(!mean.empty() && (mean.total() != (size_t) W.rows)) {
-        String error_message = format("Wrong mean shape for the given eigenvector matrix. Expected %d, but was %d.", W.cols, mean.total());
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // initialize temporary matrices
-    Mat X, Y;
-    // copy data & make sure we are using the correct type
-    src.convertTo(Y, W.type());
-    // calculate the reconstruction
-    gemm(Y, W, 1.0, Mat(), 0.0, X, GEMM_2_T);
-    // safe to do because of above assertion
-    if(!mean.empty()) {
-        for(int i=0; i<n; i++) {
-            Mat r_i = X.row(i);
-            add(r_i, mean.reshape(1,1), r_i);
-        }
-    }
-    return X;
-}
-
-
-class EigenvalueDecomposition {
-private:
-
-    // Holds the data dimension.
-    int n;
-
-    // Stores real/imag part of a complex division.
-    double cdivr, cdivi;
-
-    // Pointer to internal memory.
-    double *d, *e, *ort;
-    double **V, **H;
-
-    // Holds the computed eigenvalues.
-    Mat _eigenvalues;
-
-    // Holds the computed eigenvectors.
-    Mat _eigenvectors;
-
-    // Allocates memory.
-    template<typename _Tp>
-    _Tp *alloc_1d(int m) {
-        return new _Tp[m];
-    }
-
-    // Allocates memory.
-    template<typename _Tp>
-    _Tp *alloc_1d(int m, _Tp val) {
-        _Tp *arr = alloc_1d<_Tp> (m);
-        for (int i = 0; i < m; i++)
-            arr[i] = val;
-        return arr;
-    }
-
-    // Allocates memory.
-    template<typename _Tp>
-    _Tp **alloc_2d(int m, int _n) {
-        _Tp **arr = new _Tp*[m];
-        for (int i = 0; i < m; i++)
-            arr[i] = new _Tp[_n];
-        return arr;
-    }
-
-    // Allocates memory.
-    template<typename _Tp>
-    _Tp **alloc_2d(int m, int _n, _Tp val) {
-        _Tp **arr = alloc_2d<_Tp> (m, _n);
-        for (int i = 0; i < m; i++) {
-            for (int j = 0; j < _n; j++) {
-                arr[i][j] = val;
-            }
-        }
-        return arr;
-    }
-
-    void cdiv(double xr, double xi, double yr, double yi) {
-        double r, dv;
-        if (std::abs(yr) > std::abs(yi)) {
-            r = yi / yr;
-            dv = yr + r * yi;
-            cdivr = (xr + r * xi) / dv;
-            cdivi = (xi - r * xr) / dv;
-        } else {
-            r = yr / yi;
-            dv = yi + r * yr;
-            cdivr = (r * xr + xi) / dv;
-            cdivi = (r * xi - xr) / dv;
-        }
-    }
-
-    // Nonsymmetric reduction from Hessenberg to real Schur form.
-
-    void hqr2() {
-
-        //  This is derived from the Algol procedure hqr2,
-        //  by Martin and Wilkinson, Handbook for Auto. Comp.,
-        //  Vol.ii-Linear Algebra, and the corresponding
-        //  Fortran subroutine in EISPACK.
-
-        // Initialize
-        int nn = this->n;
-        int n1 = nn - 1;
-        int low = 0;
-        int high = nn - 1;
-        double eps = std::pow(2.0, -52.0);
-        double exshift = 0.0;
-        double p = 0, q = 0, r = 0, s = 0, z = 0, t, w, x, y;
-
-        // Store roots isolated by balanc and compute matrix norm
-
-        double norm = 0.0;
-        for (int i = 0; i < nn; i++) {
-            if (i < low || i > high) {
-                d[i] = H[i][i];
-                e[i] = 0.0;
-            }
-            for (int j = std::max(i - 1, 0); j < nn; j++) {
-                norm = norm + std::abs(H[i][j]);
-            }
-        }
-
-        // Outer loop over eigenvalue index
-        int iter = 0;
-        while (n1 >= low) {
-
-            // Look for single small sub-diagonal element
-            int l = n1;
-            while (l > low) {
-                s = std::abs(H[l - 1][l - 1]) + std::abs(H[l][l]);
-                if (s == 0.0) {
-                    s = norm;
-                }
-                if (std::abs(H[l][l - 1]) < eps * s) {
-                    break;
-                }
-                l--;
-            }
-
-            // Check for convergence
-            // One root found
-
-            if (l == n1) {
-                H[n1][n1] = H[n1][n1] + exshift;
-                d[n1] = H[n1][n1];
-                e[n1] = 0.0;
-                n1--;
-                iter = 0;
-
-                // Two roots found
-
-            } else if (l == n1 - 1) {
-                w = H[n1][n1 - 1] * H[n1 - 1][n1];
-                p = (H[n1 - 1][n1 - 1] - H[n1][n1]) / 2.0;
-                q = p * p + w;
-                z = std::sqrt(std::abs(q));
-                H[n1][n1] = H[n1][n1] + exshift;
-                H[n1 - 1][n1 - 1] = H[n1 - 1][n1 - 1] + exshift;
-                x = H[n1][n1];
-
-                // Real pair
-
-                if (q >= 0) {
-                    if (p >= 0) {
-                        z = p + z;
-                    } else {
-                        z = p - z;
-                    }
-                    d[n1 - 1] = x + z;
-                    d[n1] = d[n1 - 1];
-                    if (z != 0.0) {
-                        d[n1] = x - w / z;
-                    }
-                    e[n1 - 1] = 0.0;
-                    e[n1] = 0.0;
-                    x = H[n1][n1 - 1];
-                    s = std::abs(x) + std::abs(z);
-                    p = x / s;
-                    q = z / s;
-                    r = std::sqrt(p * p + q * q);
-                    p = p / r;
-                    q = q / r;
-
-                    // Row modification
-
-                    for (int j = n1 - 1; j < nn; j++) {
-                        z = H[n1 - 1][j];
-                        H[n1 - 1][j] = q * z + p * H[n1][j];
-                        H[n1][j] = q * H[n1][j] - p * z;
-                    }
-
-                    // Column modification
-
-                    for (int i = 0; i <= n1; i++) {
-                        z = H[i][n1 - 1];
-                        H[i][n1 - 1] = q * z + p * H[i][n1];
-                        H[i][n1] = q * H[i][n1] - p * z;
-                    }
-
-                    // Accumulate transformations
-
-                    for (int i = low; i <= high; i++) {
-                        z = V[i][n1 - 1];
-                        V[i][n1 - 1] = q * z + p * V[i][n1];
-                        V[i][n1] = q * V[i][n1] - p * z;
-                    }
-
-                    // Complex pair
-
-                } else {
-                    d[n1 - 1] = x + p;
-                    d[n1] = x + p;
-                    e[n1 - 1] = z;
-                    e[n1] = -z;
-                }
-                n1 = n1 - 2;
-                iter = 0;
-
-                // No convergence yet
-
-            } else {
-
-                // Form shift
-
-                x = H[n1][n1];
-                y = 0.0;
-                w = 0.0;
-                if (l < n1) {
-                    y = H[n1 - 1][n1 - 1];
-                    w = H[n1][n1 - 1] * H[n1 - 1][n1];
-                }
-
-                // Wilkinson's original ad hoc shift
-
-                if (iter == 10) {
-                    exshift += x;
-                    for (int i = low; i <= n1; i++) {
-                        H[i][i] -= x;
-                    }
-                    s = std::abs(H[n1][n1 - 1]) + std::abs(H[n1 - 1][n1 - 2]);
-                    x = y = 0.75 * s;
-                    w = -0.4375 * s * s;
-                }
-
-                // MATLAB's new ad hoc shift
-
-                if (iter == 30) {
-                    s = (y - x) / 2.0;
-                    s = s * s + w;
-                    if (s > 0) {
-                        s = std::sqrt(s);
-                        if (y < x) {
-                            s = -s;
-                        }
-                        s = x - w / ((y - x) / 2.0 + s);
-                        for (int i = low; i <= n1; i++) {
-                            H[i][i] -= s;
-                        }
-                        exshift += s;
-                        x = y = w = 0.964;
-                    }
-                }
-
-                iter = iter + 1; // (Could check iteration count here.)
-
-                // Look for two consecutive small sub-diagonal elements
-                int m = n1 - 2;
-                while (m >= l) {
-                    z = H[m][m];
-                    r = x - z;
-                    s = y - z;
-                    p = (r * s - w) / H[m + 1][m] + H[m][m + 1];
-                    q = H[m + 1][m + 1] - z - r - s;
-                    r = H[m + 2][m + 1];
-                    s = std::abs(p) + std::abs(q) + std::abs(r);
-                    p = p / s;
-                    q = q / s;
-                    r = r / s;
-                    if (m == l) {
-                        break;
-                    }
-                    if (std::abs(H[m][m - 1]) * (std::abs(q) + std::abs(r)) < eps * (std::abs(p)
-                                                                                     * (std::abs(H[m - 1][m - 1]) + std::abs(z) + std::abs(
-                                                                                                                                           H[m + 1][m + 1])))) {
-                        break;
-                    }
-                    m--;
-                }
-
-                for (int i = m + 2; i <= n1; i++) {
-                    H[i][i - 2] = 0.0;
-                    if (i > m + 2) {
-                        H[i][i - 3] = 0.0;
-                    }
-                }
-
-                // Double QR step involving rows l:n and columns m:n
-
-                for (int k = m; k <= n1 - 1; k++) {
-                    bool notlast = (k != n1 - 1);
-                    if (k != m) {
-                        p = H[k][k - 1];
-                        q = H[k + 1][k - 1];
-                        r = (notlast ? H[k + 2][k - 1] : 0.0);
-                        x = std::abs(p) + std::abs(q) + std::abs(r);
-                        if (x != 0.0) {
-                            p = p / x;
-                            q = q / x;
-                            r = r / x;
-                        }
-                    }
-                    if (x == 0.0) {
-                        break;
-                    }
-                    s = std::sqrt(p * p + q * q + r * r);
-                    if (p < 0) {
-                        s = -s;
-                    }
-                    if (s != 0) {
-                        if (k != m) {
-                            H[k][k - 1] = -s * x;
-                        } else if (l != m) {
-                            H[k][k - 1] = -H[k][k - 1];
-                        }
-                        p = p + s;
-                        x = p / s;
-                        y = q / s;
-                        z = r / s;
-                        q = q / p;
-                        r = r / p;
-
-                        // Row modification
-
-                        for (int j = k; j < nn; j++) {
-                            p = H[k][j] + q * H[k + 1][j];
-                            if (notlast) {
-                                p = p + r * H[k + 2][j];
-                                H[k + 2][j] = H[k + 2][j] - p * z;
-                            }
-                            H[k][j] = H[k][j] - p * x;
-                            H[k + 1][j] = H[k + 1][j] - p * y;
-                        }
-
-                        // Column modification
-
-                        for (int i = 0; i <= std::min(n1, k + 3); i++) {
-                            p = x * H[i][k] + y * H[i][k + 1];
-                            if (notlast) {
-                                p = p + z * H[i][k + 2];
-                                H[i][k + 2] = H[i][k + 2] - p * r;
-                            }
-                            H[i][k] = H[i][k] - p;
-                            H[i][k + 1] = H[i][k + 1] - p * q;
-                        }
-
-                        // Accumulate transformations
-
-                        for (int i = low; i <= high; i++) {
-                            p = x * V[i][k] + y * V[i][k + 1];
-                            if (notlast) {
-                                p = p + z * V[i][k + 2];
-                                V[i][k + 2] = V[i][k + 2] - p * r;
-                            }
-                            V[i][k] = V[i][k] - p;
-                            V[i][k + 1] = V[i][k + 1] - p * q;
-                        }
-                    } // (s != 0)
-                } // k loop
-            } // check convergence
-        } // while (n1 >= low)
-
-        // Backsubstitute to find vectors of upper triangular form
-
-        if (norm == 0.0) {
-            return;
-        }
-
-        for (n1 = nn - 1; n1 >= 0; n1--) {
-            p = d[n1];
-            q = e[n1];
-
-            // Real vector
-
-            if (q == 0) {
-                int l = n1;
-                H[n1][n1] = 1.0;
-                for (int i = n1 - 1; i >= 0; i--) {
-                    w = H[i][i] - p;
-                    r = 0.0;
-                    for (int j = l; j <= n1; j++) {
-                        r = r + H[i][j] * H[j][n1];
-                    }
-                    if (e[i] < 0.0) {
-                        z = w;
-                        s = r;
-                    } else {
-                        l = i;
-                        if (e[i] == 0.0) {
-                            if (w != 0.0) {
-                                H[i][n1] = -r / w;
-                            } else {
-                                H[i][n1] = -r / (eps * norm);
-                            }
-
-                            // Solve real equations
-
-                        } else {
-                            x = H[i][i + 1];
-                            y = H[i + 1][i];
-                            q = (d[i] - p) * (d[i] - p) + e[i] * e[i];
-                            t = (x * s - z * r) / q;
-                            H[i][n1] = t;
-                            if (std::abs(x) > std::abs(z)) {
-                                H[i + 1][n1] = (-r - w * t) / x;
-                            } else {
-                                H[i + 1][n1] = (-s - y * t) / z;
-                            }
-                        }
-
-                        // Overflow control
-
-                        t = std::abs(H[i][n1]);
-                        if ((eps * t) * t > 1) {
-                            for (int j = i; j <= n1; j++) {
-                                H[j][n1] = H[j][n1] / t;
-                            }
-                        }
-                    }
-                }
-                // Complex vector
-            } else if (q < 0) {
-                int l = n1 - 1;
-
-                // Last vector component imaginary so matrix is triangular
-
-                if (std::abs(H[n1][n1 - 1]) > std::abs(H[n1 - 1][n1])) {
-                    H[n1 - 1][n1 - 1] = q / H[n1][n1 - 1];
-                    H[n1 - 1][n1] = -(H[n1][n1] - p) / H[n1][n1 - 1];
-                } else {
-                    cdiv(0.0, -H[n1 - 1][n1], H[n1 - 1][n1 - 1] - p, q);
-                    H[n1 - 1][n1 - 1] = cdivr;
-                    H[n1 - 1][n1] = cdivi;
-                }
-                H[n1][n1 - 1] = 0.0;
-                H[n1][n1] = 1.0;
-                for (int i = n1 - 2; i >= 0; i--) {
-                    double ra, sa, vr, vi;
-                    ra = 0.0;
-                    sa = 0.0;
-                    for (int j = l; j <= n1; j++) {
-                        ra = ra + H[i][j] * H[j][n1 - 1];
-                        sa = sa + H[i][j] * H[j][n1];
-                    }
-                    w = H[i][i] - p;
-
-                    if (e[i] < 0.0) {
-                        z = w;
-                        r = ra;
-                        s = sa;
-                    } else {
-                        l = i;
-                        if (e[i] == 0) {
-                            cdiv(-ra, -sa, w, q);
-                            H[i][n1 - 1] = cdivr;
-                            H[i][n1] = cdivi;
-                        } else {
-
-                            // Solve complex equations
-
-                            x = H[i][i + 1];
-                            y = H[i + 1][i];
-                            vr = (d[i] - p) * (d[i] - p) + e[i] * e[i] - q * q;
-                            vi = (d[i] - p) * 2.0 * q;
-                            if (vr == 0.0 && vi == 0.0) {
-                                vr = eps * norm * (std::abs(w) + std::abs(q) + std::abs(x)
-                                                   + std::abs(y) + std::abs(z));
-                            }
-                            cdiv(x * r - z * ra + q * sa,
-                                 x * s - z * sa - q * ra, vr, vi);
-                            H[i][n1 - 1] = cdivr;
-                            H[i][n1] = cdivi;
-                            if (std::abs(x) > (std::abs(z) + std::abs(q))) {
-                                H[i + 1][n1 - 1] = (-ra - w * H[i][n1 - 1] + q
-                                                   * H[i][n1]) / x;
-                                H[i + 1][n1] = (-sa - w * H[i][n1] - q * H[i][n1
-                                                                            - 1]) / x;
-                            } else {
-                                cdiv(-r - y * H[i][n1 - 1], -s - y * H[i][n1], z,
-                                     q);
-                                H[i + 1][n1 - 1] = cdivr;
-                                H[i + 1][n1] = cdivi;
-                            }
-                        }
-
-                        // Overflow control
-
-                        t = std::max(std::abs(H[i][n1 - 1]), std::abs(H[i][n1]));
-                        if ((eps * t) * t > 1) {
-                            for (int j = i; j <= n1; j++) {
-                                H[j][n1 - 1] = H[j][n1 - 1] / t;
-                                H[j][n1] = H[j][n1] / t;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        // Vectors of isolated roots
-
-        for (int i = 0; i < nn; i++) {
-            if (i < low || i > high) {
-                for (int j = i; j < nn; j++) {
-                    V[i][j] = H[i][j];
-                }
-            }
-        }
-
-        // Back transformation to get eigenvectors of original matrix
-
-        for (int j = nn - 1; j >= low; j--) {
-            for (int i = low; i <= high; i++) {
-                z = 0.0;
-                for (int k = low; k <= std::min(j, high); k++) {
-                    z = z + V[i][k] * H[k][j];
-                }
-                V[i][j] = z;
-            }
-        }
-    }
-
-    // Nonsymmetric reduction to Hessenberg form.
-    void orthes() {
-        //  This is derived from the Algol procedures orthes and ortran,
-        //  by Martin and Wilkinson, Handbook for Auto. Comp.,
-        //  Vol.ii-Linear Algebra, and the corresponding
-        //  Fortran subroutines in EISPACK.
-        int low = 0;
-        int high = n - 1;
-
-        for (int m = low + 1; m <= high - 1; m++) {
-
-            // Scale column.
-
-            double scale = 0.0;
-            for (int i = m; i <= high; i++) {
-                scale = scale + std::abs(H[i][m - 1]);
-            }
-            if (scale != 0.0) {
-
-                // Compute Householder transformation.
-
-                double h = 0.0;
-                for (int i = high; i >= m; i--) {
-                    ort[i] = H[i][m - 1] / scale;
-                    h += ort[i] * ort[i];
-                }
-                double g = std::sqrt(h);
-                if (ort[m] > 0) {
-                    g = -g;
-                }
-                h = h - ort[m] * g;
-                ort[m] = ort[m] - g;
-
-                // Apply Householder similarity transformation
-                // H = (I-u*u'/h)*H*(I-u*u')/h)
-
-                for (int j = m; j < n; j++) {
-                    double f = 0.0;
-                    for (int i = high; i >= m; i--) {
-                        f += ort[i] * H[i][j];
-                    }
-                    f = f / h;
-                    for (int i = m; i <= high; i++) {
-                        H[i][j] -= f * ort[i];
-                    }
-                }
-
-                for (int i = 0; i <= high; i++) {
-                    double f = 0.0;
-                    for (int j = high; j >= m; j--) {
-                        f += ort[j] * H[i][j];
-                    }
-                    f = f / h;
-                    for (int j = m; j <= high; j++) {
-                        H[i][j] -= f * ort[j];
-                    }
-                }
-                ort[m] = scale * ort[m];
-                H[m][m - 1] = scale * g;
-            }
-        }
-
-        // Accumulate transformations (Algol's ortran).
-
-        for (int i = 0; i < n; i++) {
-            for (int j = 0; j < n; j++) {
-                V[i][j] = (i == j ? 1.0 : 0.0);
-            }
-        }
-
-        for (int m = high - 1; m >= low + 1; m--) {
-            if (H[m][m - 1] != 0.0) {
-                for (int i = m + 1; i <= high; i++) {
-                    ort[i] = H[i][m - 1];
-                }
-                for (int j = m; j <= high; j++) {
-                    double g = 0.0;
-                    for (int i = m; i <= high; i++) {
-                        g += ort[i] * V[i][j];
-                    }
-                    // Double division avoids possible underflow
-                    g = (g / ort[m]) / H[m][m - 1];
-                    for (int i = m; i <= high; i++) {
-                        V[i][j] += g * ort[i];
-                    }
-                }
-            }
-        }
-    }
-
-    // Releases all internal working memory.
-    void release() {
-        // releases the working data
-        delete[] d;
-        delete[] e;
-        delete[] ort;
-        for (int i = 0; i < n; i++) {
-            delete[] H[i];
-            delete[] V[i];
-        }
-        delete[] H;
-        delete[] V;
-    }
-
-    // Computes the Eigenvalue Decomposition for a matrix given in H.
-    void compute() {
-        // Allocate memory for the working data.
-        V = alloc_2d<double> (n, n, 0.0);
-        d = alloc_1d<double> (n);
-        e = alloc_1d<double> (n);
-        ort = alloc_1d<double> (n);
-        // Reduce to Hessenberg form.
-        orthes();
-        // Reduce Hessenberg to real Schur form.
-        hqr2();
-        // Copy eigenvalues to OpenCV Matrix.
-        _eigenvalues.create(1, n, CV_64FC1);
-        for (int i = 0; i < n; i++) {
-            _eigenvalues.at<double> (0, i) = d[i];
-        }
-        // Copy eigenvectors to OpenCV Matrix.
-        _eigenvectors.create(n, n, CV_64FC1);
-        for (int i = 0; i < n; i++)
-            for (int j = 0; j < n; j++)
-                _eigenvectors.at<double> (i, j) = V[i][j];
-        // Deallocate the memory by releasing all internal working data.
-        release();
-    }
-
-public:
-    EigenvalueDecomposition()
-    : n(0) { }
-
-    // Initializes & computes the Eigenvalue Decomposition for a general matrix
-    // given in src. This function is a port of the EigenvalueSolver in JAMA,
-    // which has been released to public domain by The MathWorks and the
-    // National Institute of Standards and Technology (NIST).
-    EigenvalueDecomposition(InputArray src) {
-        compute(src);
-    }
-
-    // This function computes the Eigenvalue Decomposition for a general matrix
-    // given in src. This function is a port of the EigenvalueSolver in JAMA,
-    // which has been released to public domain by The MathWorks and the
-    // National Institute of Standards and Technology (NIST).
-    void compute(InputArray src)
-    {
-        if(isSymmetric(src)) {
-            // Fall back to OpenCV for a symmetric matrix!
-            cv::eigen(src, _eigenvalues, _eigenvectors);
-        } else {
-            Mat tmp;
-            // Convert the given input matrix to double. Is there any way to
-            // prevent allocating the temporary memory? Only used for copying
-            // into working memory and deallocated after.
-            src.getMat().convertTo(tmp, CV_64FC1);
-            // Get dimension of the matrix.
-            this->n = tmp.cols;
-            // Allocate the matrix data to work on.
-            this->H = alloc_2d<double> (n, n);
-            // Now safely copy the data.
-            for (int i = 0; i < tmp.rows; i++) {
-                for (int j = 0; j < tmp.cols; j++) {
-                    this->H[i][j] = tmp.at<double>(i, j);
-                }
-            }
-            // Deallocates the temporary matrix before computing.
-            tmp.release();
-            // Performs the eigenvalue decomposition of H.
-            compute();
-        }
-    }
-
-    ~EigenvalueDecomposition() {}
-
-    // Returns the eigenvalues of the Eigenvalue Decomposition.
-    Mat eigenvalues() {    return _eigenvalues; }
-    // Returns the eigenvectors of the Eigenvalue Decomposition.
-    Mat eigenvectors() { return _eigenvectors; }
-};
-
-
-//------------------------------------------------------------------------------
-// Linear Discriminant Analysis implementation
-//------------------------------------------------------------------------------
-void LDA::save(const String& filename) const {
-    FileStorage fs(filename, FileStorage::WRITE);
-    if (!fs.isOpened()) {
-        CV_Error(Error::StsError, "File can't be opened for writing!");
-    }
-    this->save(fs);
-    fs.release();
-}
-
-// Deserializes this object from a given filename.
-void LDA::load(const String& filename) {
-    FileStorage fs(filename, FileStorage::READ);
-    if (!fs.isOpened())
-       CV_Error(Error::StsError, "File can't be opened for writing!");
-    this->load(fs);
-    fs.release();
-}
-
-// Serializes this object to a given FileStorage.
-void LDA::save(FileStorage& fs) const {
-    // write matrices
-    fs << "num_components" << _num_components;
-    fs << "eigenvalues" << _eigenvalues;
-    fs << "eigenvectors" << _eigenvectors;
-}
-
-// Deserializes this object from a given FileStorage.
-void LDA::load(const FileStorage& fs) {
-    //read matrices
-    fs["num_components"] >> _num_components;
-    fs["eigenvalues"] >> _eigenvalues;
-    fs["eigenvectors"] >> _eigenvectors;
-}
-
-void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) {
-    // get data
-    Mat src = _src.getMat();
-    std::vector<int> labels;
-    // safely copy the labels
-    {
-        Mat tmp = _lbls.getMat();
-        for(unsigned int i = 0; i < tmp.total(); i++) {
-            labels.push_back(tmp.at<int>(i));
-        }
-    }
-    // turn into row sampled matrix
-    Mat data;
-    // ensure working matrix is double precision
-    src.convertTo(data, CV_64FC1);
-    // maps the labels, so they're ascending: [0,1,...,C]
-    std::vector<int> mapped_labels(labels.size());
-    std::vector<int> num2label = remove_dups(labels);
-    std::map<int, int> label2num;
-    for (int i = 0; i < (int)num2label.size(); i++)
-        label2num[num2label[i]] = i;
-    for (size_t i = 0; i < labels.size(); i++)
-        mapped_labels[i] = label2num[labels[i]];
-    // get sample size, dimension
-    int N = data.rows;
-    int D = data.cols;
-    // number of unique labels
-    int C = (int)num2label.size();
-    // we can't do a LDA on one class, what do you
-    // want to separate from each other then?
-    if(C == 1) {
-        String error_message = "At least two classes are needed to perform a LDA. Reason: Only one class was given!";
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // throw error if less labels, than samples
-    if (labels.size() != static_cast<size_t>(N)) {
-        String error_message = format("The number of samples must equal the number of labels. Given %d labels, %d samples. ", labels.size(), N);
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    // warn if within-classes scatter matrix becomes singular
-    if (N < D) {
-        std::cout << "Warning: Less observations than feature dimension given!"
-                  << "Computation will probably fail."
-                  << std::endl;
-    }
-    // clip number of components to be a valid number
-    if ((_num_components <= 0) || (_num_components > (C - 1))) {
-        _num_components = (C - 1);
-    }
-    // holds the mean over all classes
-    Mat meanTotal = Mat::zeros(1, D, data.type());
-    // holds the mean for each class
-    std::vector<Mat> meanClass(C);
-    std::vector<int> numClass(C);
-    // initialize
-    for (int i = 0; i < C; i++) {
-        numClass[i] = 0;
-        meanClass[i] = Mat::zeros(1, D, data.type()); //! Dx1 image vector
-    }
-    // calculate sums
-    for (int i = 0; i < N; i++) {
-        Mat instance = data.row(i);
-        int classIdx = mapped_labels[i];
-        add(meanTotal, instance, meanTotal);
-        add(meanClass[classIdx], instance, meanClass[classIdx]);
-        numClass[classIdx]++;
-    }
-    // calculate total mean
-    meanTotal.convertTo(meanTotal, meanTotal.type(), 1.0 / static_cast<double> (N));
-    // calculate class means
-    for (int i = 0; i < C; i++) {
-        meanClass[i].convertTo(meanClass[i], meanClass[i].type(), 1.0 / static_cast<double> (numClass[i]));
-    }
-    // subtract class means
-    for (int i = 0; i < N; i++) {
-        int classIdx = mapped_labels[i];
-        Mat instance = data.row(i);
-        subtract(instance, meanClass[classIdx], instance);
-    }
-    // calculate within-classes scatter
-    Mat Sw = Mat::zeros(D, D, data.type());
-    mulTransposed(data, Sw, true);
-    // calculate between-classes scatter
-    Mat Sb = Mat::zeros(D, D, data.type());
-    for (int i = 0; i < C; i++) {
-        Mat tmp;
-        subtract(meanClass[i], meanTotal, tmp);
-        mulTransposed(tmp, tmp, true);
-        add(Sb, tmp, Sb);
-    }
-    // invert Sw
-    Mat Swi = Sw.inv();
-    // M = inv(Sw)*Sb
-    Mat M;
-    gemm(Swi, Sb, 1.0, Mat(), 0.0, M);
-    EigenvalueDecomposition es(M);
-    _eigenvalues = es.eigenvalues();
-    _eigenvectors = es.eigenvectors();
-    // reshape eigenvalues, so they are stored by column
-    _eigenvalues = _eigenvalues.reshape(1, 1);
-    // get sorted indices descending by their eigenvalue
-    std::vector<int> sorted_indices = argsort(_eigenvalues, false);
-    // now sort eigenvalues and eigenvectors accordingly
-    _eigenvalues = sortMatrixColumnsByIndices(_eigenvalues, sorted_indices);
-    _eigenvectors = sortMatrixColumnsByIndices(_eigenvectors, sorted_indices);
-    // and now take only the num_components and we're out!
-    _eigenvalues = Mat(_eigenvalues, Range::all(), Range(0, _num_components));
-    _eigenvectors = Mat(_eigenvectors, Range::all(), Range(0, _num_components));
-}
-
-void LDA::compute(InputArrayOfArrays _src, InputArray _lbls) {
-    switch(_src.kind()) {
-    case _InputArray::STD_VECTOR_MAT:
-        lda(asRowMatrix(_src, CV_64FC1), _lbls);
-        break;
-    case _InputArray::MAT:
-        lda(_src.getMat(), _lbls);
-        break;
-    default:
-        String error_message= format("InputArray Datatype %d is not supported.", _src.kind());
-        CV_Error(Error::StsBadArg, error_message);
-        break;
-    }
-}
-
-// Projects samples into the LDA subspace.
-Mat LDA::project(InputArray src) {
-   return subspaceProject(_eigenvectors, Mat(), _dataAsRow ? src : src.getMat().t());
-}
-
-// Reconstructs projections from the LDA subspace.
-Mat LDA::reconstruct(InputArray src) {
-   return subspaceReconstruct(_eigenvectors, Mat(), _dataAsRow ? src : src.getMat().t());
-}
-
-}
diff --git a/modules/contrib/src/logpolar_bsm.cpp b/modules/contrib/src/logpolar_bsm.cpp
deleted file mode 100644 (file)
index 8327b0a..0000000
+++ /dev/null
@@ -1,651 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                         License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2012, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The names of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*******************************************************************************************
-
-The LogPolar Blind Spot Model code has been contributed by Fabio Solari and Manuela Chessa.
-
-More details can be found in:
-
-M. Chessa, S. P. Sabatini, F. Solari and F. Tatti (2011)
-A Quantitative Comparison of Speed and Reliability for Log-Polar Mapping Techniques,
-Computer Vision Systems - 8th International Conference,
-ICVS 2011, Sophia Antipolis, France, September 20-22, 2011
-(http://dx.doi.org/10.1007/978-3-642-23968-7_5)
-
-********************************************************************************************/
-
-#include "precomp.hpp"
-
-#include <cmath>
-#include <vector>
-
-namespace cv
-{
-
-//------------------------------------interp-------------------------------------------
-LogPolar_Interp::LogPolar_Interp(int w, int h, Point2i center, int _R, double _ro0, int _interp, int full, int _s, int sp)
-{
-    if ( (center.x!=w/2 || center.y!=h/2) && full==0) full=1;
-
-    if (center.x<0) center.x=0;
-    if (center.y<0) center.y=0;
-    if (center.x>=w) center.x=w-1;
-    if (center.y>=h) center.y=h-1;
-
-    if (full){
-        int rtmp;
-
-        if (center.x<=w/2 && center.y>=h/2)
-            rtmp=(int)std::sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x));
-        else if (center.x>=w/2 && center.y>=h/2)
-            rtmp=(int)std::sqrt((float)center.y*center.y + (float)center.x*center.x);
-        else if (center.x>=w/2 && center.y<=h/2)
-            rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x);
-        else //if (center.x<=w/2 && center.y<=h/2)
-            rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x));
-
-        M=2*rtmp; N=2*rtmp;
-
-        top = M/2 - center.y;
-        bottom = M/2 - (h-center.y);
-        left = M/2 - center.x;
-        right = M/2 - (w - center.x);
-
-    }else{
-        top=bottom=left=right=0;
-        M=w; N=h;
-    }
-
-    if (sp){
-        int jc=M/2-1, ic=N/2-1;
-        int _romax=std::min(ic, jc);
-        double _a=std::exp(std::log((double)(_romax/2-1)/(double)ro0)/(double)R);
-        S=(int) floor(2*CV_PI/(_a-1)+0.5);
-    }
-
-    interp=_interp;
-
-    create_map(M, N, _R, _s, _ro0);
-}
-
-void LogPolar_Interp::create_map(int _M, int _n, int _R, int _s, double _ro0)
-{
-    M=_M;
-    N=_n;
-    R=_R;
-    S=_s;
-    ro0=_ro0;
-
-    int jc=N/2-1, ic=M/2-1;
-    romax=std::min(ic, jc);
-    a=std::exp(std::log((double)romax/(double)ro0)/(double)R);
-    q=((double)S)/(2*CV_PI);
-
-    Rsri = Mat::zeros(S,R,CV_32FC1);
-    Csri = Mat::zeros(S,R,CV_32FC1);
-    ETAyx = Mat::zeros(N,M,CV_32FC1);
-    CSIyx = Mat::zeros(N,M,CV_32FC1);
-
-    for(int v=0; v<S; v++)
-    {
-        for(int u=0; u<R; u++)
-        {
-            Rsri.at<float>(v,u)=(float)(ro0*std::pow(a,u)*sin(v/q)+jc);
-            Csri.at<float>(v,u)=(float)(ro0*std::pow(a,u)*cos(v/q)+ic);
-        }
-    }
-
-    for(int j=0; j<N; j++)
-    {
-        for(int i=0; i<M; i++)
-        {
-            double theta;
-            if(i>=ic)
-                theta=atan((double)(j-jc)/(double)(i-ic));
-            else
-                theta=atan((double)(j-jc)/(double)(i-ic))+CV_PI;
-
-            if(theta<0)
-                theta+=2*CV_PI;
-
-            ETAyx.at<float>(j,i)=(float)(q*theta);
-
-            double ro2=(j-jc)*(j-jc)+(i-ic)*(i-ic);
-            CSIyx.at<float>(j,i)=(float)(0.5*std::log(ro2/(ro0*ro0))/std::log(a));
-        }
-    }
-}
-
-const Mat LogPolar_Interp::to_cortical(const Mat &source)
-{
-    Mat out(S,R,CV_8UC1,Scalar(0));
-
-    Mat source_border;
-    copyMakeBorder(source,source_border,top,bottom,left,right,BORDER_CONSTANT,Scalar(0));
-
-    remap(source_border,out,Csri,Rsri,interp);
-
-    return out;
-}
-
-
-const Mat LogPolar_Interp::to_cartesian(const Mat &source)
-{
-    Mat out(N,M,CV_8UC1,Scalar(0));
-
-    Mat source_border;
-
-    if (interp==INTER_NEAREST || interp==INTER_LINEAR){
-        copyMakeBorder(source,source_border,0,1,0,0,BORDER_CONSTANT,Scalar(0));
-        Mat rowS0 = source_border.row(S);
-        source_border.row(0).copyTo(rowS0);
-    } else if (interp==INTER_CUBIC){
-        copyMakeBorder(source,source_border,0,2,0,0,BORDER_CONSTANT,Scalar(0));
-        Mat rowS0 = source_border.row(S);
-        Mat rowS1 = source_border.row(S+1);
-        source_border.row(0).copyTo(rowS0);
-        source_border.row(1).copyTo(rowS1);
-    } else if (interp==INTER_LANCZOS4){
-        copyMakeBorder(source,source_border,0,4,0,0,BORDER_CONSTANT,Scalar(0));
-        Mat rowS0 = source_border.row(S);
-        Mat rowS1 = source_border.row(S+1);
-        Mat rowS2 = source_border.row(S+2);
-        Mat rowS3 = source_border.row(S+3);
-        source_border.row(0).copyTo(rowS0);
-        source_border.row(1).copyTo(rowS1);
-        source_border.row(2).copyTo(rowS2);
-        source_border.row(3).copyTo(rowS3);
-    }
-    remap(source_border,out,CSIyx,ETAyx,interp);
-
-    Mat out_cropped=out(Range(top,N-1-bottom),Range(left,M-1-right));
-
-    return out_cropped;
-}
-
-LogPolar_Interp::~LogPolar_Interp()
-{
-}
-
-//------------------------------------overlapping----------------------------------
-
-LogPolar_Overlapping::LogPolar_Overlapping(int w, int h, Point2i center, int _R, double _ro0, int full, int _s, int sp)
-{
-    if ( (center.x!=w/2 || center.y!=h/2) && full==0) full=1;
-
-    if (center.x<0) center.x=0;
-    if (center.y<0) center.y=0;
-    if (center.x>=w) center.x=w-1;
-    if (center.y>=h) center.y=h-1;
-
-    if (full){
-        int rtmp;
-
-        if (center.x<=w/2 && center.y>=h/2)
-            rtmp=(int)std::sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x));
-        else if (center.x>=w/2 && center.y>=h/2)
-            rtmp=(int)std::sqrt((float)center.y*center.y + (float)center.x*center.x);
-        else if (center.x>=w/2 && center.y<=h/2)
-            rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x);
-        else //if (center.x<=w/2 && center.y<=h/2)
-            rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x));
-
-        M=2*rtmp; N=2*rtmp;
-
-        top = M/2 - center.y;
-        bottom = M/2 - (h-center.y);
-        left = M/2 - center.x;
-        right = M/2 - (w - center.x);
-
-    }else{
-        top=bottom=left=right=0;
-        M=w; N=h;
-    }
-
-
-    if (sp){
-        int jc=M/2-1, ic=N/2-1;
-        int _romax=std::min(ic, jc);
-        double _a=std::exp(std::log((double)(_romax/2-1)/(double)ro0)/(double)R);
-        S=(int) floor(2*CV_PI/(_a-1)+0.5);
-    }
-
-    create_map(M, N, _R, _s, _ro0);
-}
-
-void LogPolar_Overlapping::create_map(int _M, int _n, int _R, int _s, double _ro0)
-{
-    M=_M;
-    N=_n;
-    R=_R;
-    S=_s;
-    ro0=_ro0;
-
-    int jc=N/2-1, ic=M/2-1;
-    romax=std::min(ic, jc);
-    a=std::exp(std::log((double)romax/(double)ro0)/(double)R);
-    q=((double)S)/(2*CV_PI);
-    ind1=0;
-
-    Rsri=Mat::zeros(S,R,CV_32FC1);
-    Csri=Mat::zeros(S,R,CV_32FC1);
-    ETAyx=Mat::zeros(N,M,CV_32FC1);
-    CSIyx=Mat::zeros(N,M,CV_32FC1);
-    Rsr.resize(R*S);
-    Csr.resize(R*S);
-    Wsr.resize(R);
-    w_ker_2D.resize(R*S);
-
-    for(int v=0; v<S; v++)
-    {
-        for(int u=0; u<R; u++)
-        {
-            Rsri.at<float>(v,u)=(float)(ro0*std::pow(a,u)*sin(v/q)+jc);
-            Csri.at<float>(v,u)=(float)(ro0*std::pow(a,u)*cos(v/q)+ic);
-            Rsr[v*R+u]=(int)floor(Rsri.at<float>(v,u));
-            Csr[v*R+u]=(int)floor(Csri.at<float>(v,u));
-        }
-    }
-
-    bool done=false;
-
-    for(int i=0; i<R; i++)
-    {
-        Wsr[i]=ro0*(a-1)*std::pow(a,i-1);
-        if((Wsr[i]>1)&&(done==false))
-        {
-            ind1=i;
-            done =true;
-        }
-    }
-
-    for(int j=0; j<N; j++)
-    {
-        for(int i=0; i<M; i++)//mdf
-        {
-            double theta;
-            if(i>=ic)
-                theta=atan((double)(j-jc)/(double)(i-ic));
-            else
-                theta=atan((double)(j-jc)/(double)(i-ic))+CV_PI;
-
-            if(theta<0)
-                theta+=2*CV_PI;
-
-            ETAyx.at<float>(j,i)=(float)(q*theta);
-
-            double ro2=(j-jc)*(j-jc)+(i-ic)*(i-ic);
-            CSIyx.at<float>(j,i)=(float)(0.5*std::log(ro2/(ro0*ro0))/std::log(a));
-        }
-    }
-
-    for(int v=0; v<S; v++)
-        for(int u=ind1; u<R; u++)
-        {
-            //double sigma=Wsr[u]/2.0;
-            double sigma=Wsr[u]/3.0;//modf
-            int w=(int) floor(3*sigma+0.5);
-            w_ker_2D[v*R+u].w=w;
-            w_ker_2D[v*R+u].weights.resize((2*w+1)*(2*w+1));
-            double dx=Csri.at<float>(v,u)-Csr[v*R+u];
-            double dy=Rsri.at<float>(v,u)-Rsr[v*R+u];
-            double tot=0;
-            for(int j=0; j<2*w+1; j++)
-                for(int i=0; i<2*w+1; i++)
-                {
-                    (w_ker_2D[v*R+u].weights)[j*(2*w+1)+i]=std::exp(-(std::pow(i-w-dx, 2)+std::pow(j-w-dy, 2))/(2*sigma*sigma));
-                    tot+=(w_ker_2D[v*R+u].weights)[j*(2*w+1)+i];
-                }
-            for(int j=0; j<(2*w+1); j++)
-                for(int i=0; i<(2*w+1); i++)
-                    (w_ker_2D[v*R+u].weights)[j*(2*w+1)+i]/=tot;
-        }
-}
-
-const Mat LogPolar_Overlapping::to_cortical(const Mat &source)
-{
-    Mat out(S,R,CV_8UC1,Scalar(0));
-
-    Mat source_border;
-    copyMakeBorder(source,source_border,top,bottom,left,right,BORDER_CONSTANT,Scalar(0));
-
-    remap(source_border,out,Csri,Rsri,INTER_LINEAR);
-
-    int wm=w_ker_2D[R-1].w;
-    std::vector<int> IMG((M+2*wm+1)*(N+2*wm+1), 0);
-
-    for(int j=0; j<N; j++)
-        for(int i=0; i<M; i++)
-            IMG[(M+2*wm+1)*(j+wm)+i+wm]=source_border.at<uchar>(j,i);
-
-    for(int v=0; v<S; v++)
-        for(int u=ind1; u<R; u++)
-        {
-            int w=w_ker_2D[v*R+u].w;
-            double tmp=0;
-            for(int rf=0; rf<(2*w+1); rf++)
-            {
-                for(int cf=0; cf<(2*w+1); cf++)
-                {
-                    double weight=(w_ker_2D[v*R+u]).weights[rf*(2*w+1)+cf];
-                    tmp+=IMG[(M+2*wm+1)*((rf-w)+Rsr[v*R+u]+wm)+((cf-w)+Csr[v*R+u]+wm)]*weight;
-                }
-            }
-            out.at<uchar>(v,u)=(uchar) floor(tmp+0.5);
-        }
-
-    return out;
-}
-
-const Mat LogPolar_Overlapping::to_cartesian(const Mat &source)
-{
-    Mat out(N,M,CV_8UC1,Scalar(0));
-
-    Mat source_border;
-    copyMakeBorder(source,source_border,0,1,0,0,BORDER_CONSTANT,Scalar(0));
-    Mat rowS = source_border.row(S);
-    source_border.row(0).copyTo(rowS);
-    remap(source_border,out,CSIyx,ETAyx,INTER_LINEAR);
-
-    int wm=w_ker_2D[R-1].w;
-
-    std::vector<double> IMG((N+2*wm+1)*(M+2*wm+1), 0.);
-    std::vector<double> NOR((N+2*wm+1)*(M+2*wm+1), 0.);
-
-    for(int v=0; v<S; v++)
-        for(int u=ind1; u<R; u++)
-        {
-            int w=w_ker_2D[v*R+u].w;
-            for(int j=0; j<(2*w+1); j++)
-            {
-                for(int i=0; i<(2*w+1); i++)
-                {
-                    int ind=(M+2*wm+1)*((j-w)+Rsr[v*R+u]+wm)+(i-w)+Csr[v*R+u]+wm;
-                    IMG[ind]+=((w_ker_2D[v*R+u]).weights[j*(2*w+1)+i])*source.at<uchar>(v, u);
-                    NOR[ind]+=((w_ker_2D[v*R+u]).weights[j*(2*w+1)+i]);
-                }
-            }
-        }
-
-    for(int i=0; i<((N+2*wm+1)*(M+2*wm+1)); i++)
-        IMG[i]/=NOR[i];
-
-    //int xc=M/2-1, yc=N/2-1;
-
-    for(int j=wm; j<N+wm; j++)
-        for(int i=wm; i<M+wm; i++)
-        {
-            /*if(NOR[(M+2*wm+1)*j+i]>0)
-                ret[M*(j-wm)+i-wm]=(int) floor(IMG[(M+2*wm+1)*j+i]+0.5);*/
-            //int ro=(int)floor(std::sqrt((double)((j-wm-yc)*(j-wm-yc)+(i-wm-xc)*(i-wm-xc))));
-            int csi=(int) floor(CSIyx.at<float>(j-wm,i-wm));
-
-            if((csi>=(ind1-(w_ker_2D[ind1]).w))&&(csi<R))
-                out.at<uchar>(j-wm,i-wm)=(uchar) floor(IMG[(M+2*wm+1)*j+i]+0.5);
-        }
-
-    Mat out_cropped=out(Range(top,N-1-bottom),Range(left,M-1-right));
-    return out_cropped;
-}
-
-LogPolar_Overlapping::~LogPolar_Overlapping()
-{
-}
-
-//----------------------------------------adjacent---------------------------------------
-
-LogPolar_Adjacent::LogPolar_Adjacent(int w, int h, Point2i center, int _R, double _ro0, double smin, int full, int _s, int sp)
-{
-    if ( (center.x!=w/2 || center.y!=h/2) && full==0) full=1;
-
-    if (center.x<0) center.x=0;
-    if (center.y<0) center.y=0;
-    if (center.x>=w) center.x=w-1;
-    if (center.y>=h) center.y=h-1;
-
-    if (full){
-        int rtmp;
-
-        if (center.x<=w/2 && center.y>=h/2)
-            rtmp=(int)std::sqrt((float)center.y*center.y + (float)(w-center.x)*(w-center.x));
-        else if (center.x>=w/2 && center.y>=h/2)
-            rtmp=(int)std::sqrt((float)center.y*center.y + (float)center.x*center.x);
-        else if (center.x>=w/2 && center.y<=h/2)
-            rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)center.x*center.x);
-        else //if (center.x<=w/2 && center.y<=h/2)
-            rtmp=(int)std::sqrt((float)(h-center.y)*(h-center.y) + (float)(w-center.x)*(w-center.x));
-
-        M=2*rtmp; N=2*rtmp;
-
-        top = M/2 - center.y;
-        bottom = M/2 - (h-center.y);
-        left = M/2 - center.x;
-        right = M/2 - (w - center.x);
-
-    }else{
-        top=bottom=left=right=0;
-        M=w; N=h;
-    }
-
-    if (sp){
-        int jc=M/2-1, ic=N/2-1;
-        int _romax=std::min(ic, jc);
-        double _a=std::exp(std::log((double)(_romax/2-1)/(double)ro0)/(double)R);
-        S=(int) floor(2*CV_PI/(_a-1)+0.5);
-    }
-
-    create_map(M, N, _R, _s, _ro0, smin);
-}
-
-
-void LogPolar_Adjacent::create_map(int _M, int _n, int _R, int _s, double _ro0, double smin)
-{
-    M=_M;
-    N=_n;
-    R=_R;
-    S=_s;
-    ro0=_ro0;
-    romax=std::min(M/2.0, N/2.0);
-
-    a=std::exp(std::log(romax/ro0)/(double)R);
-    q=S/(2*CV_PI);
-
-    A.resize(R*S);
-    L.resize(M*N);
-
-    for(int i=0; i<R*S; i++)
-        A[i]=0;
-
-    double xc=M/2.0, yc=N/2.0;
-
-    for(int j=0; j<N; j++)
-        for(int i=0; i<M; i++)
-        {
-            double x=i+0.5-xc, y=j+0.5-yc;
-            subdivide_recursively(x, y, i, j, 1, smin);
-        }
-}
-
-
-void LogPolar_Adjacent::subdivide_recursively(double x, double y, int i, int j, double length, double smin)
-{
-    if(length<=smin)
-    {
-        int u, v;
-        if(get_uv(x, y, u, v))
-        {
-            pixel p;
-            p.u=u;
-            p.v=v;
-            p.a=length*length;
-            L[M*j+i].push_back(p);
-            A[v*R+u]+=length*length;
-        }
-    }
-
-    if(length>smin)
-    {
-        double xs[4], ys[4];
-        int us[4], vs[4];
-
-        xs[0]=xs[3]=x+length/4.0;
-        xs[1]=xs[2]=x-length/4.0;
-        ys[1]=ys[0]=y+length/4.0;
-        ys[2]=ys[3]=y-length/4.0;
-
-        for(int z=0; z<4; z++)
-            get_uv(xs[z], ys[z], us[z], vs[z]);
-
-        bool c=true;
-        for(int w=1; w<4; w++)
-        {
-            if(us[w]!=us[w-1])
-                c=false;
-            if(vs[w]!=vs[w-1])
-                c=false;
-        }
-
-        if(c)
-        {
-            if(us[0]!=-1)
-            {
-                pixel p;
-                p.u=us[0];
-                p.v=vs[0];
-                p.a=length*length;
-                L[M*j+i].push_back(p);
-                A[vs[0]*R+us[0]]+=length*length;
-            }
-        }
-
-        else
-        {
-            for(int z=0; z<4; z++)
-                if(us[z]!=-1)
-                    subdivide_recursively(xs[z], ys[z], i, j, length/2.0, smin);
-        }
-    }
-}
-
-
-const Mat LogPolar_Adjacent::to_cortical(const Mat &source)
-{
-    Mat source_border;
-    copyMakeBorder(source,source_border,top,bottom,left,right,BORDER_CONSTANT,Scalar(0));
-
-    std::vector<double> map(R*S, 0.);
-
-    for(int j=0; j<N; j++)
-        for(int i=0; i<M; i++)
-        {
-            for(size_t z=0; z<(L[M*j+i]).size(); z++)
-            {
-                map[R*((L[M*j+i])[z].v)+((L[M*j+i])[z].u)]+=((L[M*j+i])[z].a)*(source_border.at<uchar>(j,i));
-            }
-        }
-
-    for(int i=0; i<R*S; i++)
-        map[i]/=A[i];
-
-    Mat out(S,R,CV_8UC1,Scalar(0));
-
-    for(int i=0; i<S; i++)
-        for(int j=0;j<R;j++)
-            out.at<uchar>(i,j)=(uchar) floor(map[i*R+j]+0.5);
-
-    return out;
-}
-
-const Mat LogPolar_Adjacent::to_cartesian(const Mat &source)
-{
-    std::vector<double> map(M*N, 0.);
-
-    for(int j=0; j<N; j++)
-        for(int i=0; i<M; i++)
-        {
-            for(size_t z=0; z<(L[M*j+i]).size(); z++)
-            {
-                map[M*j+i]+=(L[M*j+i])[z].a*source.at<uchar>((L[M*j+i])[z].v,(L[M*j+i])[z].u);
-            }
-        }
-
-    Mat out(N,M,CV_8UC1,Scalar(0));
-
-    for(int i=0; i<N; i++)
-        for(int j=0; j<M; j++)
-            out.at<uchar>(i,j)=(uchar) floor(map[i*M+j]+0.5);
-
-    Mat out_cropped=out(Range(top,N-1-bottom),Range(left,M-1-right));
-    return out_cropped;
-}
-
-
-bool LogPolar_Adjacent::get_uv(double x, double y, int&u, int&v)
-{
-    double ro=std::sqrt(x*x+y*y), theta;
-    if(x>0)
-        theta=atan(y/x);
-    else
-        theta=atan(y/x)+CV_PI;
-
-    if(ro<ro0||ro>romax)
-    {
-        u=-1;
-        v=-1;
-        return false;
-    }
-    else
-    {
-        u= (int) floor(std::log(ro/ro0)/std::log(a));
-        if(theta>=0)
-            v= (int) floor(q*theta);
-        else
-            v= (int) floor(q*(theta+2*CV_PI));
-        return true;
-    }
-}
-
-LogPolar_Adjacent::~LogPolar_Adjacent()
-{
-}
-
-}
diff --git a/modules/contrib/src/octree.cpp b/modules/contrib/src/octree.cpp
deleted file mode 100644 (file)
index b612372..0000000
+++ /dev/null
@@ -1,344 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include <limits>
-
-namespace
-{
-    using namespace cv;
-    const size_t MAX_STACK_SIZE = 255;
-    const size_t MAX_LEAFS = 8;
-
-    bool checkIfNodeOutsideSphere(const Octree::Node& node, const Point3f& c, float r)
-    {
-        if (node.x_max < (c.x - r) ||  node.y_max < (c.y - r) || node.z_max < (c.z - r))
-            return true;
-
-        if ((c.x + r) < node.x_min || (c.y + r) < node.y_min || (c.z + r) < node.z_min)
-            return true;
-
-        return false;
-    }
-
-    bool checkIfNodeInsideSphere(const Octree::Node& node, const Point3f& c, float r)
-    {
-        r *= r;
-
-        float d2_xmin = (node.x_min - c.x) * (node.x_min - c.x);
-        float d2_ymin = (node.y_min - c.y) * (node.y_min - c.y);
-        float d2_zmin = (node.z_min - c.z) * (node.z_min - c.z);
-
-        if (d2_xmin + d2_ymin + d2_zmin > r)
-            return false;
-
-        float d2_zmax = (node.z_max - c.z) * (node.z_max - c.z);
-
-        if (d2_xmin + d2_ymin + d2_zmax > r)
-            return false;
-
-        float d2_ymax = (node.y_max - c.y) * (node.y_max - c.y);
-
-        if (d2_xmin + d2_ymax + d2_zmin > r)
-            return false;
-
-        if (d2_xmin + d2_ymax + d2_zmax > r)
-            return false;
-
-        float d2_xmax = (node.x_max - c.x) * (node.x_max - c.x);
-
-        if (d2_xmax + d2_ymin + d2_zmin > r)
-            return false;
-
-        if (d2_xmax + d2_ymin + d2_zmax > r)
-            return false;
-
-        if (d2_xmax + d2_ymax + d2_zmin > r)
-            return false;
-
-        if (d2_xmax + d2_ymax + d2_zmax > r)
-            return false;
-
-        return true;
-    }
-
-    void fillMinMax(const std::vector<Point3f>& points, Octree::Node& node)
-    {
-        node.x_max = node.y_max = node.z_max = std::numeric_limits<float>::min();
-        node.x_min = node.y_min = node.z_min = std::numeric_limits<float>::max();
-
-        for (size_t i = 0; i < points.size(); ++i)
-        {
-            const Point3f& point = points[i];
-
-            if (node.x_max < point.x)
-                node.x_max = point.x;
-
-            if (node.y_max < point.y)
-                node.y_max = point.y;
-
-            if (node.z_max < point.z)
-                node.z_max = point.z;
-
-            if (node.x_min > point.x)
-                node.x_min = point.x;
-
-            if (node.y_min > point.y)
-                node.y_min = point.y;
-
-            if (node.z_min > point.z)
-                node.z_min = point.z;
-        }
-    }
-
-    size_t findSubboxForPoint(const Point3f& point, const Octree::Node& node)
-    {
-        size_t ind_x = point.x < (node.x_max + node.x_min) / 2 ? 0 : 1;
-        size_t ind_y = point.y < (node.y_max + node.y_min) / 2 ? 0 : 1;
-        size_t ind_z = point.z < (node.z_max + node.z_min) / 2 ? 0 : 1;
-
-        return (ind_x << 2) + (ind_y << 1) + (ind_z << 0);
-    }
-    void initChildBox(const Octree::Node& parent, size_t boxIndex, Octree::Node& child)
-    {
-        child.x_min = child.x_max = (parent.x_max + parent.x_min) / 2;
-        child.y_min = child.y_max = (parent.y_max + parent.y_min) / 2;
-        child.z_min = child.z_max = (parent.z_max + parent.z_min) / 2;
-
-        if ((boxIndex >> 0) & 1)
-            child.z_max = parent.z_max;
-        else
-            child.z_min = parent.z_min;
-
-        if ((boxIndex >> 1) & 1)
-            child.y_max = parent.y_max;
-        else
-            child.y_min = parent.y_min;
-
-        if ((boxIndex >> 2) & 1)
-            child.x_max = parent.x_max;
-        else
-            child.x_min = parent.x_min;
-    }
-
-}//namespace
-
-////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////       Octree       //////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////
-namespace cv
-{
-    Octree::Octree()
-    {
-    }
-
-    Octree::Octree(const std::vector<Point3f>& points3d, int maxLevels, int _minPoints)
-    {
-        buildTree(points3d, maxLevels, _minPoints);
-    }
-
-    Octree::~Octree()
-    {
-    }
-
-    void Octree::getPointsWithinSphere(const Point3f& center, float radius, std::vector<Point3f>& out) const
-    {
-        out.clear();
-
-        if (nodes.empty())
-            return;
-
-        int stack[MAX_STACK_SIZE];
-        int pos = 0;
-        stack[pos] = 0;
-
-        while (pos >= 0)
-        {
-            const Node& cur = nodes[stack[pos--]];
-
-            if (checkIfNodeOutsideSphere(cur, center, radius))
-                continue;
-
-            if (checkIfNodeInsideSphere(cur, center, radius))
-            {
-                size_t sz = out.size();
-                out.resize(sz + cur.end - cur.begin);
-                for (int i = cur.begin; i < cur.end; ++i)
-                    out[sz++] = points[i];
-                continue;
-            }
-
-            if (cur.isLeaf)
-            {
-                double r2 = radius * radius;
-                size_t sz = out.size();
-                out.resize(sz + (cur.end - cur.begin));
-
-                for (int i = cur.begin; i < cur.end; ++i)
-                {
-                    const Point3f& point = points[i];
-
-                    double dx = (point.x - center.x);
-                    double dy = (point.y - center.y);
-                    double dz = (point.z - center.z);
-
-                    double dist2 = dx * dx + dy * dy + dz * dz;
-
-                    if (dist2 < r2)
-                        out[sz++] = point;
-                };
-                out.resize(sz);
-                continue;
-            }
-
-            if (cur.children[0])
-                stack[++pos] = cur.children[0];
-
-            if (cur.children[1])
-                stack[++pos] = cur.children[1];
-
-            if (cur.children[2])
-                stack[++pos] = cur.children[2];
-
-            if (cur.children[3])
-                stack[++pos] = cur.children[3];
-
-            if (cur.children[4])
-                stack[++pos] = cur.children[4];
-
-            if (cur.children[5])
-                stack[++pos] = cur.children[5];
-
-            if (cur.children[6])
-                stack[++pos] = cur.children[6];
-
-            if (cur.children[7])
-                stack[++pos] = cur.children[7];
-        }
-    }
-
-    void Octree::buildTree(const std::vector<Point3f>& points3d, int maxLevels, int _minPoints)
-    {
-        CV_Assert((size_t)maxLevels * 8 < MAX_STACK_SIZE);
-        points.resize(points3d.size());
-        std::copy(points3d.begin(), points3d.end(), points.begin());
-        minPoints = _minPoints;
-
-        nodes.clear();
-        nodes.push_back(Node());
-        Node& root = nodes[0];
-        fillMinMax(points, root);
-
-        root.isLeaf = true;
-        root.maxLevels = maxLevels;
-        root.begin = 0;
-        root.end = (int)points.size();
-        for (size_t i = 0; i < MAX_LEAFS; i++)
-            root.children[i] = 0;
-
-        if (maxLevels != 1 && (root.end - root.begin) > _minPoints)
-        {
-            root.isLeaf = false;
-            buildNext(0);
-        }
-    }
-
-    void  Octree::buildNext(size_t nodeInd)
-    {
-        size_t size = nodes[nodeInd].end - nodes[nodeInd].begin;
-
-        std::vector<size_t> boxBorders(MAX_LEAFS+1, 0);
-        std::vector<size_t> boxIndices(size);
-        std::vector<Point3f> tempPoints(size);
-
-        for (int i = nodes[nodeInd].begin, j = 0; i < nodes[nodeInd].end; ++i, ++j)
-        {
-            const Point3f& p = points[i];
-
-            size_t subboxInd = findSubboxForPoint(p, nodes[nodeInd]);
-
-            boxBorders[subboxInd+1]++;
-            boxIndices[j] = subboxInd;
-            tempPoints[j] = p;
-        }
-
-        for (size_t i = 1; i < boxBorders.size(); ++i)
-            boxBorders[i] += boxBorders[i-1];
-
-        std::vector<size_t> writeInds(boxBorders.begin(), boxBorders.end());
-
-        for (size_t i = 0; i < size; ++i)
-        {
-            size_t boxIndex = boxIndices[i];
-            Point3f& curPoint = tempPoints[i];
-
-            size_t copyTo = nodes[nodeInd].begin + writeInds[boxIndex]++;
-            points[copyTo] = curPoint;
-        }
-
-        for (size_t i = 0; i < MAX_LEAFS; ++i)
-        {
-            if (boxBorders[i] == boxBorders[i+1])
-                continue;
-
-            nodes.push_back(Node());
-            Node& child = nodes.back();
-            initChildBox(nodes[nodeInd], i, child);
-
-            child.isLeaf = true;
-            child.maxLevels = nodes[nodeInd].maxLevels - 1;
-            child.begin = nodes[nodeInd].begin + (int)boxBorders[i+0];
-            child.end   = nodes[nodeInd].begin + (int)boxBorders[i+1];
-            for (size_t k = 0; k < MAX_LEAFS; k++)
-                child.children[k] = 0;
-
-            nodes[nodeInd].children[i] = (int)(nodes.size() - 1);
-
-            if (child.maxLevels != 1 && (child.end - child.begin) > minPoints)
-            {
-                child.isLeaf = false;
-                buildNext(nodes.size() - 1);
-            }
-        }
-    }
-
-}
diff --git a/modules/contrib/src/openfabmap.cpp b/modules/contrib/src/openfabmap.cpp
deleted file mode 100644 (file)
index fbc8aee..0000000
+++ /dev/null
@@ -1,778 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-// This file originates from the openFABMAP project:
-// [http://code.google.com/p/openfabmap/]
-//
-// For published work which uses all or part of OpenFABMAP, please cite:
-// [http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6224843]
-//
-// Original Algorithm by Mark Cummins and Paul Newman:
-// [http://ijr.sagepub.com/content/27/6/647.short]
-// [http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5613942]
-// [http://ijr.sagepub.com/content/30/9/1100.abstract]
-//
-//                           License Agreement
-//
-// Copyright (C) 2012 Arren Glover [aj.glover@qut.edu.au] and
-//                    Will Maddern [w.maddern@qut.edu.au], all rights reserved.
-//
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "opencv2/contrib/openfabmap.hpp"
-
-
-/*
-    Calculate the sum of two log likelihoods
-*/
-namespace cv {
-
-namespace of2 {
-
-static double logsumexp(double a, double b) {
-    return a > b ? std::log(1 + std::exp(b - a)) + a : std::log(1 + std::exp(a - b)) + b;
-}
-
-FabMap::FabMap(const Mat& _clTree, double _PzGe,
-        double _PzGNe, int _flags, int _numSamples) :
-    clTree(_clTree), PzGe(_PzGe), PzGNe(_PzGNe), flags(
-            _flags), numSamples(_numSamples) {
-
-    CV_Assert(flags & MEAN_FIELD || flags & SAMPLED);
-    CV_Assert(flags & NAIVE_BAYES || flags & CHOW_LIU);
-    if (flags & NAIVE_BAYES) {
-        PzGL = &FabMap::PzqGL;
-    } else {
-        PzGL = &FabMap::PzqGzpqL;
-    }
-
-    //check for a valid Chow-Liu tree
-    CV_Assert(clTree.type() == CV_64FC1);
-    cv::checkRange(clTree.row(0), false, NULL, 0, clTree.cols);
-    cv::checkRange(clTree.row(1), false, NULL, DBL_MIN, 1);
-    cv::checkRange(clTree.row(2), false, NULL, DBL_MIN, 1);
-    cv::checkRange(clTree.row(3), false, NULL, DBL_MIN, 1);
-
-    // TODO: Add default values for member variables
-    Pnew = 0.9;
-    sFactor = 0.99;
-    mBias = 0.5;
-}
-
-FabMap::~FabMap() {
-}
-
-const std::vector<cv::Mat>& FabMap::getTrainingImgDescriptors() const {
-    return trainingImgDescriptors;
-}
-
-const std::vector<cv::Mat>& FabMap::getTestImgDescriptors() const {
-    return testImgDescriptors;
-}
-
-void FabMap::addTraining(const Mat& queryImgDescriptor) {
-    CV_Assert(!queryImgDescriptor.empty());
-    std::vector<Mat> queryImgDescriptors;
-    for (int i = 0; i < queryImgDescriptor.rows; i++) {
-        queryImgDescriptors.push_back(queryImgDescriptor.row(i));
-    }
-    addTraining(queryImgDescriptors);
-}
-
-void FabMap::addTraining(const std::vector<Mat>& queryImgDescriptors) {
-    for (size_t i = 0; i < queryImgDescriptors.size(); i++) {
-        CV_Assert(!queryImgDescriptors[i].empty());
-        CV_Assert(queryImgDescriptors[i].rows == 1);
-        CV_Assert(queryImgDescriptors[i].cols == clTree.cols);
-        CV_Assert(queryImgDescriptors[i].type() == CV_32F);
-        trainingImgDescriptors.push_back(queryImgDescriptors[i]);
-    }
-}
-
-void FabMap::add(const cv::Mat& queryImgDescriptor) {
-    CV_Assert(!queryImgDescriptor.empty());
-    std::vector<Mat> queryImgDescriptors;
-    for (int i = 0; i < queryImgDescriptor.rows; i++) {
-        queryImgDescriptors.push_back(queryImgDescriptor.row(i));
-    }
-    add(queryImgDescriptors);
-}
-
-void FabMap::add(const std::vector<cv::Mat>& queryImgDescriptors) {
-    for (size_t i = 0; i < queryImgDescriptors.size(); i++) {
-        CV_Assert(!queryImgDescriptors[i].empty());
-        CV_Assert(queryImgDescriptors[i].rows == 1);
-        CV_Assert(queryImgDescriptors[i].cols == clTree.cols);
-        CV_Assert(queryImgDescriptors[i].type() == CV_32F);
-        testImgDescriptors.push_back(queryImgDescriptors[i]);
-    }
-}
-
-void FabMap::compare(const Mat& queryImgDescriptor,
-            std::vector<IMatch>& matches, bool addQuery,
-            const Mat& mask) {
-    CV_Assert(!queryImgDescriptor.empty());
-    std::vector<Mat> queryImgDescriptors;
-    for (int i = 0; i < queryImgDescriptor.rows; i++) {
-        queryImgDescriptors.push_back(queryImgDescriptor.row(i));
-    }
-    compare(queryImgDescriptors,matches,addQuery,mask);
-}
-
-void FabMap::compare(const Mat& queryImgDescriptor,
-            const Mat& testImgDescriptor, std::vector<IMatch>& matches,
-            const Mat& mask) {
-    CV_Assert(!queryImgDescriptor.empty());
-    std::vector<Mat> queryImgDescriptors;
-    for (int i = 0; i < queryImgDescriptor.rows; i++) {
-        queryImgDescriptors.push_back(queryImgDescriptor.row(i));
-    }
-
-    CV_Assert(!testImgDescriptor.empty());
-    std::vector<Mat> _testImgDescriptors;
-    for (int i = 0; i < testImgDescriptor.rows; i++) {
-        _testImgDescriptors.push_back(testImgDescriptor.row(i));
-    }
-    compare(queryImgDescriptors,_testImgDescriptors,matches,mask);
-
-}
-
-void FabMap::compare(const Mat& queryImgDescriptor,
-        const std::vector<Mat>& _testImgDescriptors,
-        std::vector<IMatch>& matches, const Mat& mask) {
-    CV_Assert(!queryImgDescriptor.empty());
-    std::vector<Mat> queryImgDescriptors;
-    for (int i = 0; i < queryImgDescriptor.rows; i++) {
-        queryImgDescriptors.push_back(queryImgDescriptor.row(i));
-    }
-    compare(queryImgDescriptors,_testImgDescriptors,matches,mask);
-}
-
-void FabMap::compare(const std::vector<Mat>& queryImgDescriptors,
-                     std::vector<IMatch>& matches, bool addQuery, const Mat& /*mask*/) {
-
-    // TODO: add first query if empty (is this necessary)
-
-    for (size_t i = 0; i < queryImgDescriptors.size(); i++) {
-        CV_Assert(!queryImgDescriptors[i].empty());
-        CV_Assert(queryImgDescriptors[i].rows == 1);
-        CV_Assert(queryImgDescriptors[i].cols == clTree.cols);
-        CV_Assert(queryImgDescriptors[i].type() == CV_32F);
-
-        // TODO: add mask
-
-        compareImgDescriptor(queryImgDescriptors[i],
-                             (int)i, testImgDescriptors, matches);
-        if (addQuery)
-            add(queryImgDescriptors[i]);
-    }
-}
-
-void FabMap::compare(const std::vector<Mat>& queryImgDescriptors,
-        const std::vector<Mat>& _testImgDescriptors,
-        std::vector<IMatch>& matches, const Mat& /*mask*/) {
-
-    CV_Assert(!(flags & MOTION_MODEL));
-    for (size_t i = 0; i < _testImgDescriptors.size(); i++) {
-        CV_Assert(!_testImgDescriptors[i].empty());
-        CV_Assert(_testImgDescriptors[i].rows == 1);
-        CV_Assert(_testImgDescriptors[i].cols == clTree.cols);
-        CV_Assert(_testImgDescriptors[i].type() == CV_32F);
-    }
-
-    for (size_t i = 0; i < queryImgDescriptors.size(); i++) {
-        CV_Assert(!queryImgDescriptors[i].empty());
-        CV_Assert(queryImgDescriptors[i].rows == 1);
-        CV_Assert(queryImgDescriptors[i].cols == clTree.cols);
-        CV_Assert(queryImgDescriptors[i].type() == CV_32F);
-
-        // TODO: add mask
-
-        compareImgDescriptor(queryImgDescriptors[i],
-                (int)i, _testImgDescriptors, matches);
-    }
-}
-
-void FabMap::compareImgDescriptor(const Mat& queryImgDescriptor,
-        int queryIndex, const std::vector<Mat>& _testImgDescriptors,
-        std::vector<IMatch>& matches) {
-
-    std::vector<IMatch> queryMatches;
-    queryMatches.push_back(IMatch(queryIndex,-1,
-        getNewPlaceLikelihood(queryImgDescriptor),0));
-    getLikelihoods(queryImgDescriptor,_testImgDescriptors,queryMatches);
-    normaliseDistribution(queryMatches);
-    for (size_t j = 1; j < queryMatches.size(); j++) {
-        queryMatches[j].queryIdx = queryIndex;
-    }
-    matches.insert(matches.end(), queryMatches.begin(), queryMatches.end());
-}
-
-void FabMap::getLikelihoods(const Mat& /*queryImgDescriptor*/,
-        const std::vector<Mat>& /*testImgDescriptors*/, std::vector<IMatch>& /*matches*/) {
-
-}
-
-double FabMap::getNewPlaceLikelihood(const Mat& queryImgDescriptor) {
-    if (flags & MEAN_FIELD) {
-        double logP = 0;
-        bool zq, zpq;
-        if(flags & NAIVE_BAYES) {
-            for (int q = 0; q < clTree.cols; q++) {
-                zq = queryImgDescriptor.at<float>(0,q) > 0;
-
-                logP += std::log(Pzq(q, false) * PzqGeq(zq, false) +
-                        Pzq(q, true) * PzqGeq(zq, true));
-            }
-        } else {
-            for (int q = 0; q < clTree.cols; q++) {
-                zq = queryImgDescriptor.at<float>(0,q) > 0;
-                zpq = queryImgDescriptor.at<float>(0,pq(q)) > 0;
-
-                double alpha, beta, p;
-                alpha = Pzq(q, zq) * PzqGeq(!zq, false) * PzqGzpq(q, !zq, zpq);
-                beta = Pzq(q, !zq) * PzqGeq(zq, false) * PzqGzpq(q, zq, zpq);
-                p = Pzq(q, false) * beta / (alpha + beta);
-
-                alpha = Pzq(q, zq) * PzqGeq(!zq, true) * PzqGzpq(q, !zq, zpq);
-                beta = Pzq(q, !zq) * PzqGeq(zq, true) * PzqGzpq(q, zq, zpq);
-                p += Pzq(q, true) * beta / (alpha + beta);
-
-                logP += std::log(p);
-            }
-        }
-        return logP;
-    }
-
-    if (flags & SAMPLED) {
-        CV_Assert(!trainingImgDescriptors.empty());
-        CV_Assert(numSamples > 0);
-
-        std::vector<Mat> sampledImgDescriptors;
-
-        // TODO: this method can result in the same sample being added
-        // multiple times. Is this desired?
-
-        for (int i = 0; i < numSamples; i++) {
-            int index = rand() % trainingImgDescriptors.size();
-            sampledImgDescriptors.push_back(trainingImgDescriptors[index]);
-        }
-
-        std::vector<IMatch> matches;
-        getLikelihoods(queryImgDescriptor,sampledImgDescriptors,matches);
-
-        double averageLogLikelihood = -DBL_MAX + matches.front().likelihood + 1;
-        for (int i = 0; i < numSamples; i++) {
-            averageLogLikelihood =
-                logsumexp(matches[i].likelihood, averageLogLikelihood);
-        }
-
-        return averageLogLikelihood - std::log((double)numSamples);
-    }
-    return 0;
-}
-
-void FabMap::normaliseDistribution(std::vector<IMatch>& matches) {
-    CV_Assert(!matches.empty());
-
-    if (flags & MOTION_MODEL) {
-
-        matches[0].match = matches[0].likelihood + std::log(Pnew);
-
-        if (priorMatches.size() > 2) {
-            matches[1].match = matches[1].likelihood;
-            matches[1].match += std::log(
-                (2 * (1-mBias) * priorMatches[1].match +
-                priorMatches[1].match +
-                2 * mBias * priorMatches[2].match) / 3);
-            for (size_t i = 2; i < priorMatches.size()-1; i++) {
-                matches[i].match = matches[i].likelihood;
-                matches[i].match += std::log(
-                    (2 * (1-mBias) * priorMatches[i-1].match +
-                    priorMatches[i].match +
-                    2 * mBias * priorMatches[i+1].match)/3);
-            }
-            matches[priorMatches.size()-1].match =
-                matches[priorMatches.size()-1].likelihood;
-            matches[priorMatches.size()-1].match += std::log(
-                (2 * (1-mBias) * priorMatches[priorMatches.size()-2].match +
-                priorMatches[priorMatches.size()-1].match +
-                2 * mBias * priorMatches[priorMatches.size()-1].match)/3);
-
-            for(size_t i = priorMatches.size(); i < matches.size(); i++) {
-                matches[i].match = matches[i].likelihood;
-            }
-        } else {
-            for(size_t i = 1; i < matches.size(); i++) {
-                matches[i].match = matches[i].likelihood;
-            }
-        }
-
-        double logsum = -DBL_MAX + matches.front().match + 1;
-
-        //calculate the normalising constant
-        for (size_t i = 0; i < matches.size(); i++) {
-            logsum = logsumexp(logsum, matches[i].match);
-        }
-
-        //normalise
-        for (size_t i = 0; i < matches.size(); i++) {
-            matches[i].match = std::exp(matches[i].match - logsum);
-        }
-
-        //smooth final probabilities
-        for (size_t i = 0; i < matches.size(); i++) {
-            matches[i].match = sFactor*matches[i].match +
-            (1 - sFactor)/matches.size();
-        }
-
-        //update our location priors
-        priorMatches = matches;
-
-    } else {
-
-        double logsum = -DBL_MAX + matches.front().likelihood + 1;
-
-        for (size_t i = 0; i < matches.size(); i++) {
-            logsum = logsumexp(logsum, matches[i].likelihood);
-        }
-        for (size_t i = 0; i < matches.size(); i++) {
-            matches[i].match = std::exp(matches[i].likelihood - logsum);
-        }
-        for (size_t i = 0; i < matches.size(); i++) {
-            matches[i].match = sFactor*matches[i].match +
-            (1 - sFactor)/matches.size();
-        }
-    }
-}
-
-int FabMap::pq(int q) {
-    return (int)clTree.at<double>(0,q);
-}
-
-double FabMap::Pzq(int q, bool zq) {
-    return (zq) ? clTree.at<double>(1,q) : 1 - clTree.at<double>(1,q);
-}
-
-double FabMap::PzqGzpq(int q, bool zq, bool zpq) {
-    if (zpq) {
-        return (zq) ? clTree.at<double>(2,q) : 1 - clTree.at<double>(2,q);
-    } else {
-        return (zq) ? clTree.at<double>(3,q) : 1 - clTree.at<double>(3,q);
-    }
-}
-
-double FabMap::PzqGeq(bool zq, bool eq) {
-    if (eq) {
-        return (zq) ? PzGe : 1 - PzGe;
-    } else {
-        return (zq) ? PzGNe : 1 - PzGNe;
-    }
-}
-
-double FabMap::PeqGL(int q, bool Lzq, bool eq) {
-    double alpha, beta;
-    alpha = PzqGeq(Lzq, true) * Pzq(q, true);
-    beta = PzqGeq(Lzq, false) * Pzq(q, false);
-
-    if (eq) {
-        return alpha / (alpha + beta);
-    } else {
-        return 1 - (alpha / (alpha + beta));
-    }
-}
-
-double FabMap::PzqGL(int q, bool zq, bool /*zpq*/, bool Lzq) {
-    return PeqGL(q, Lzq, false) * PzqGeq(zq, false) +
-        PeqGL(q, Lzq, true) * PzqGeq(zq, true);
-}
-
-
-double FabMap::PzqGzpqL(int q, bool zq, bool zpq, bool Lzq) {
-    double p;
-    double alpha, beta;
-
-    alpha = Pzq(q,  zq) * PzqGeq(!zq, false) * PzqGzpq(q, !zq, zpq);
-    beta  = Pzq(q, !zq) * PzqGeq( zq, false) * PzqGzpq(q,  zq, zpq);
-    p = PeqGL(q, Lzq, false) * beta / (alpha + beta);
-
-    alpha = Pzq(q,  zq) * PzqGeq(!zq, true) * PzqGzpq(q, !zq, zpq);
-    beta  = Pzq(q, !zq) * PzqGeq( zq, true) * PzqGzpq(q,  zq, zpq);
-    p += PeqGL(q, Lzq, true) * beta / (alpha + beta);
-
-    return p;
-}
-
-
-FabMap1::FabMap1(const Mat& _clTree, double _PzGe, double _PzGNe, int _flags,
-        int _numSamples) : FabMap(_clTree, _PzGe, _PzGNe, _flags,
-                _numSamples) {
-}
-
-FabMap1::~FabMap1() {
-}
-
-void FabMap1::getLikelihoods(const Mat& queryImgDescriptor,
-        const std::vector<Mat>& testImageDescriptors, std::vector<IMatch>& matches) {
-
-    for (size_t i = 0; i < testImageDescriptors.size(); i++) {
-        bool zq, zpq, Lzq;
-        double logP = 0;
-        for (int q = 0; q < clTree.cols; q++) {
-
-            zq = queryImgDescriptor.at<float>(0,q) > 0;
-            zpq = queryImgDescriptor.at<float>(0,pq(q)) > 0;
-            Lzq = testImageDescriptors[i].at<float>(0,q) > 0;
-
-            logP += std::log((this->*PzGL)(q, zq, zpq, Lzq));
-
-        }
-        matches.push_back(IMatch(0,(int)i,logP,0));
-    }
-}
-
-FabMapLUT::FabMapLUT(const Mat& _clTree, double _PzGe, double _PzGNe,
-        int _flags, int _numSamples, int _precision) :
-FabMap(_clTree, _PzGe, _PzGNe, _flags, _numSamples), precision(_precision) {
-
-    int nWords = clTree.cols;
-    double precFactor = (double)std::pow(10.0, precision);
-
-    table = new int[nWords][8];
-
-    for (int q = 0; q < nWords; q++) {
-        for (unsigned char i = 0; i < 8; i++) {
-
-            bool Lzq = (bool) ((i >> 2) & 0x01);
-            bool zq = (bool) ((i >> 1) & 0x01);
-            bool zpq = (bool) (i & 1);
-
-            table[q][i] = -(int)(std::log((this->*PzGL)(q, zq, zpq, Lzq))
-                    * precFactor);
-        }
-    }
-}
-
-FabMapLUT::~FabMapLUT() {
-    delete[] table;
-}
-
-void FabMapLUT::getLikelihoods(const Mat& queryImgDescriptor,
-        const std::vector<Mat>& testImageDescriptors, std::vector<IMatch>& matches) {
-
-    double precFactor = (double)std::pow(10.0, -precision);
-
-    for (size_t i = 0; i < testImageDescriptors.size(); i++) {
-        unsigned long long int logP = 0;
-        for (int q = 0; q < clTree.cols; q++) {
-            logP += table[q][(queryImgDescriptor.at<float>(0,pq(q)) > 0) +
-            ((queryImgDescriptor.at<float>(0, q) > 0) << 1) +
-            ((testImageDescriptors[i].at<float>(0,q) > 0) << 2)];
-        }
-        matches.push_back(IMatch(0,(int)i,-precFactor*(double)logP,0));
-    }
-}
-
-FabMapFBO::FabMapFBO(const Mat& _clTree, double _PzGe, double _PzGNe,
-        int _flags, int _numSamples, double _rejectionThreshold,
-        double _PsGd, int _bisectionStart, int _bisectionIts) :
-FabMap(_clTree, _PzGe, _PzGNe, _flags, _numSamples), PsGd(_PsGd),
-    rejectionThreshold(_rejectionThreshold), bisectionStart(_bisectionStart),
-        bisectionIts(_bisectionIts) {
-}
-
-
-FabMapFBO::~FabMapFBO() {
-}
-
-void FabMapFBO::getLikelihoods(const Mat& queryImgDescriptor,
-        const std::vector<Mat>& testImageDescriptors, std::vector<IMatch>& matches) {
-
-    std::multiset<WordStats> wordData;
-    setWordStatistics(queryImgDescriptor, wordData);
-
-    std::vector<int> matchIndices;
-    std::vector<IMatch> queryMatches;
-
-    for (size_t i = 0; i < testImageDescriptors.size(); i++) {
-        queryMatches.push_back(IMatch(0,(int)i,0,0));
-        matchIndices.push_back((int)i);
-    }
-
-    double currBest  = -DBL_MAX;
-    double bailedOut = DBL_MAX;
-
-    for (std::multiset<WordStats>::iterator wordIter = wordData.begin();
-            wordIter != wordData.end(); wordIter++) {
-        bool zq = queryImgDescriptor.at<float>(0,wordIter->q) > 0;
-        bool zpq = queryImgDescriptor.at<float>(0,pq(wordIter->q)) > 0;
-
-        currBest = -DBL_MAX;
-
-        for (size_t i = 0; i < matchIndices.size(); i++) {
-            bool Lzq =
-                testImageDescriptors[matchIndices[i]].at<float>(0,wordIter->q) > 0;
-            queryMatches[matchIndices[i]].likelihood +=
-                std::log((this->*PzGL)(wordIter->q,zq,zpq,Lzq));
-            currBest =
-                std::max(queryMatches[matchIndices[i]].likelihood, currBest);
-        }
-
-        if (matchIndices.size() == 1)
-            continue;
-
-        double delta = std::max(limitbisection(wordIter->V, wordIter->M),
-            -std::log(rejectionThreshold));
-
-        std::vector<int>::iterator matchIter = matchIndices.begin();
-        while (matchIter != matchIndices.end()) {
-            if (currBest - queryMatches[*matchIter].likelihood > delta) {
-                queryMatches[*matchIter].likelihood = bailedOut;
-                matchIter = matchIndices.erase(matchIter);
-            } else {
-                matchIter++;
-            }
-        }
-    }
-
-    for (size_t i = 0; i < queryMatches.size(); i++) {
-        if (queryMatches[i].likelihood == bailedOut) {
-            queryMatches[i].likelihood = currBest + std::log(rejectionThreshold);
-        }
-    }
-    matches.insert(matches.end(), queryMatches.begin(), queryMatches.end());
-
-}
-
-void FabMapFBO::setWordStatistics(const Mat& queryImgDescriptor,
-        std::multiset<WordStats>& wordData) {
-    //words are sorted according to information = -ln(P(zq|zpq))
-    //in non-log format this is lowest probability first
-    for (int q = 0; q < clTree.cols; q++) {
-        wordData.insert(WordStats(q,PzqGzpq(q,
-                queryImgDescriptor.at<float>(0,q) > 0,
-                queryImgDescriptor.at<float>(0,pq(q)) > 0)));
-    }
-
-    double d = 0, V = 0, M = 0;
-    bool zq, zpq;
-
-    for (std::multiset<WordStats>::reverse_iterator wordIter =
-            wordData.rbegin();
-            wordIter != wordData.rend(); wordIter++) {
-
-        zq = queryImgDescriptor.at<float>(0,wordIter->q) > 0;
-        zpq = queryImgDescriptor.at<float>(0,pq(wordIter->q)) > 0;
-
-        d = std::log((this->*PzGL)(wordIter->q, zq, zpq, true)) -
-            std::log((this->*PzGL)(wordIter->q, zq, zpq, false));
-
-        V += std::pow(d, 2.0) * 2 *
-            (Pzq(wordIter->q, true) - std::pow(Pzq(wordIter->q, true), 2.0));
-        M = std::max(M, fabs(d));
-
-        wordIter->V = V;
-        wordIter->M = M;
-    }
-}
-
-double FabMapFBO::limitbisection(double v, double m) {
-    double midpoint, left_val, mid_val;
-    double left = 0, right = bisectionStart;
-
-    left_val = bennettInequality(v, m, left) - PsGd;
-
-    for(int i = 0; i < bisectionIts; i++) {
-
-        midpoint = (left + right)*0.5;
-        mid_val = bennettInequality(v, m, midpoint)- PsGd;
-
-        if(left_val * mid_val > 0) {
-            left = midpoint;
-            left_val = mid_val;
-        } else {
-            right = midpoint;
-        }
-    }
-
-    return (right + left) * 0.5;
-}
-
-double FabMapFBO::bennettInequality(double v, double m, double delta) {
-    double DMonV = delta * m / v;
-    double f_delta = std::log(DMonV + std::sqrt(std::pow(DMonV, 2.0) + 1));
-    return std::exp((v / std::pow(m, 2.0))*(cosh(f_delta) - 1 - DMonV * f_delta));
-}
-
-bool FabMapFBO::compInfo(const WordStats& first, const WordStats& second) {
-    return first.info < second.info;
-}
-
-FabMap2::FabMap2(const Mat& _clTree, double _PzGe, double _PzGNe,
-        int _flags) :
-FabMap(_clTree, _PzGe, _PzGNe, _flags) {
-    CV_Assert(flags & SAMPLED);
-
-    children.resize(clTree.cols);
-
-    for (int q = 0; q < clTree.cols; q++) {
-        d1.push_back(std::log((this->*PzGL)(q, false, false, true) /
-                (this->*PzGL)(q, false, false, false)));
-        d2.push_back(std::log((this->*PzGL)(q, false, true, true) /
-                (this->*PzGL)(q, false, true, false)) - d1[q]);
-        d3.push_back(std::log((this->*PzGL)(q, true, false, true) /
-                (this->*PzGL)(q, true, false, false))- d1[q]);
-        d4.push_back(std::log((this->*PzGL)(q, true, true, true) /
-                (this->*PzGL)(q, true, true, false))- d1[q]);
-        children[pq(q)].push_back(q);
-    }
-
-}
-
-FabMap2::~FabMap2() {
-}
-
-
-void FabMap2::addTraining(const std::vector<Mat>& queryImgDescriptors) {
-    for (size_t i = 0; i < queryImgDescriptors.size(); i++) {
-        CV_Assert(!queryImgDescriptors[i].empty());
-        CV_Assert(queryImgDescriptors[i].rows == 1);
-        CV_Assert(queryImgDescriptors[i].cols == clTree.cols);
-        CV_Assert(queryImgDescriptors[i].type() == CV_32F);
-        trainingImgDescriptors.push_back(queryImgDescriptors[i]);
-        addToIndex(queryImgDescriptors[i], trainingDefaults, trainingInvertedMap);
-    }
-}
-
-
-void FabMap2::add(const std::vector<Mat>& queryImgDescriptors) {
-    for (size_t i = 0; i < queryImgDescriptors.size(); i++) {
-        CV_Assert(!queryImgDescriptors[i].empty());
-        CV_Assert(queryImgDescriptors[i].rows == 1);
-        CV_Assert(queryImgDescriptors[i].cols == clTree.cols);
-        CV_Assert(queryImgDescriptors[i].type() == CV_32F);
-        testImgDescriptors.push_back(queryImgDescriptors[i]);
-        addToIndex(queryImgDescriptors[i], testDefaults, testInvertedMap);
-    }
-}
-
-void FabMap2::getLikelihoods(const Mat& queryImgDescriptor,
-        const std::vector<Mat>& testImageDescriptors, std::vector<IMatch>& matches) {
-
-    if (&testImageDescriptors == &testImgDescriptors) {
-        getIndexLikelihoods(queryImgDescriptor, testDefaults, testInvertedMap,
-            matches);
-    } else {
-        CV_Assert(!(flags & MOTION_MODEL));
-        std::vector<double> defaults;
-        std::map<int, std::vector<int> > invertedMap;
-        for (size_t i = 0; i < testImageDescriptors.size(); i++) {
-            addToIndex(testImageDescriptors[i],defaults,invertedMap);
-        }
-        getIndexLikelihoods(queryImgDescriptor, defaults, invertedMap, matches);
-    }
-}
-
-double FabMap2::getNewPlaceLikelihood(const Mat& queryImgDescriptor) {
-
-    CV_Assert(!trainingImgDescriptors.empty());
-
-    std::vector<IMatch> matches;
-    getIndexLikelihoods(queryImgDescriptor, trainingDefaults,
-            trainingInvertedMap, matches);
-
-    double averageLogLikelihood = -DBL_MAX + matches.front().likelihood + 1;
-    for (size_t i = 0; i < matches.size(); i++) {
-        averageLogLikelihood =
-            logsumexp(matches[i].likelihood, averageLogLikelihood);
-    }
-
-    return averageLogLikelihood - std::log((double)trainingDefaults.size());
-
-}
-
-void FabMap2::addToIndex(const Mat& queryImgDescriptor,
-        std::vector<double>& defaults,
-        std::map<int, std::vector<int> >& invertedMap) {
-    defaults.push_back(0);
-    for (int q = 0; q < clTree.cols; q++) {
-        if (queryImgDescriptor.at<float>(0,q) > 0) {
-            defaults.back() += d1[q];
-            invertedMap[q].push_back((int)defaults.size()-1);
-        }
-    }
-}
-
-void FabMap2::getIndexLikelihoods(const Mat& queryImgDescriptor,
-        std::vector<double>& defaults,
-        std::map<int, std::vector<int> >& invertedMap,
-        std::vector<IMatch>& matches) {
-
-    std::vector<int>::iterator LwithI, child;
-
-    std::vector<double> likelihoods = defaults;
-
-    for (int q = 0; q < clTree.cols; q++) {
-        if (queryImgDescriptor.at<float>(0,q) > 0) {
-            for (LwithI = invertedMap[q].begin();
-                LwithI != invertedMap[q].end(); LwithI++) {
-
-                if (queryImgDescriptor.at<float>(0,pq(q)) > 0) {
-                    likelihoods[*LwithI] += d4[q];
-                } else {
-                    likelihoods[*LwithI] += d3[q];
-                }
-            }
-            for (child = children[q].begin(); child != children[q].end();
-                child++) {
-
-                if (queryImgDescriptor.at<float>(0,*child) == 0) {
-                    for (LwithI = invertedMap[*child].begin();
-                        LwithI != invertedMap[*child].end(); LwithI++) {
-
-                        likelihoods[*LwithI] += d2[*child];
-                    }
-                }
-            }
-        }
-    }
-
-    for (size_t i = 0; i < likelihoods.size(); i++) {
-        matches.push_back(IMatch(0,(int)i,likelihoods[i],0));
-    }
-}
-
-}
-
-}
diff --git a/modules/contrib/src/polyfit.cpp b/modules/contrib/src/polyfit.cpp
deleted file mode 100644 (file)
index 10785c7..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-// This original code was written by
-//  Onkar Raut
-//  Graduate Student,
-//  University of North Carolina at Charlotte
-
-#include "precomp.hpp"
-
-typedef double polyfit_type;
-
-void cv::polyfit(const Mat& src_x, const Mat& src_y, Mat& dst, int order)
-{
-    const int wdepth = DataType<polyfit_type>::depth;
-    int npoints = src_x.checkVector(1);
-    int nypoints = src_y.checkVector(1);
-
-    CV_Assert(npoints == nypoints && npoints >= order+1);
-
-    Mat srcX = Mat_<polyfit_type>(src_x), srcY = Mat_<polyfit_type>(src_y);
-
-    Mat X = Mat::zeros(order + 1, npoints, wdepth);
-    polyfit_type* pSrcX = (polyfit_type*)srcX.data;
-    polyfit_type* pXData = (polyfit_type*)X.data;
-    int stepX = (int)(X.step/X.elemSize1());
-    for (int y = 0; y < order + 1; ++y)
-    {
-        for (int x = 0; x < npoints; ++x)
-        {
-            if (y == 0)
-                pXData[x] = 1;
-            else if (y == 1)
-                pXData[x + stepX] = pSrcX[x];
-            else pXData[x + y*stepX] = pSrcX[x]* pXData[x + (y-1)*stepX];
-        }
-    }
-
-    Mat A, b, w;
-    mulTransposed(X, A, false);
-    b = X*srcY;
-    solve(A, b, w, DECOMP_SVD);
-    w.convertTo(dst, std::max(std::max(src_x.depth(), src_y.depth()), CV_32F));
-}
diff --git a/modules/contrib/src/precomp.hpp b/modules/contrib/src/precomp.hpp
deleted file mode 100644 (file)
index 09ffd08..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                          License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_PRECOMP_H__
-#define __OPENCV_PRECOMP_H__
-
-#include "opencv2/contrib.hpp"
-#include "opencv2/features2d.hpp"
-#include "opencv2/objdetect.hpp"
-#include "opencv2/imgproc.hpp"
-#include "opencv2/core/utility.hpp"
-
-#include "opencv2/core/private.hpp"
-
-namespace cv
-{
-
-// special function to get pointer to constant valarray elements, since
-// simple &arr[0] does not compile on VS2005/VS2008.
-template<typename T> inline const T* get_data(const std::valarray<T>& arr)
-{ return &((std::valarray<T>&)arr)[0]; }
-
-}
-
-#endif
diff --git a/modules/contrib/src/rgbdodometry.cpp b/modules/contrib/src/rgbdodometry.cpp
deleted file mode 100644 (file)
index a4e64f9..0000000
+++ /dev/null
@@ -1,635 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#define SHOW_DEBUG_IMAGES 0
-
-#include "opencv2/core.hpp"
-#include "opencv2/calib3d.hpp"
-
-#if SHOW_DEBUG_IMAGES
-#  include "opencv2/highgui.hpp"
-#endif
-
-#include <iostream>
-#include <limits>
-
-#if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 3
-#  ifdef ANDROID
-     template <typename Scalar> Scalar log2(Scalar v) { return std::log(v)/std::log(Scalar(2)); }
-#  endif
-#  if defined __GNUC__ && defined __APPLE__
-#    pragma GCC diagnostic ignored "-Wshadow"
-#  endif
-#  include <unsupported/Eigen/MatrixFunctions>
-#  include <Eigen/Dense>
-#endif
-
-using namespace cv;
-
-inline static
-void computeC_RigidBodyMotion( double* C, double dIdx, double dIdy, const Point3f& p3d, double fx, double fy )
-{
-    double invz  = 1. / p3d.z,
-           v0 = dIdx * fx * invz,
-           v1 = dIdy * fy * invz,
-           v2 = -(v0 * p3d.x + v1 * p3d.y) * invz;
-
-    C[0] = -p3d.z * v1 + p3d.y * v2;
-    C[1] =  p3d.z * v0 - p3d.x * v2;
-    C[2] = -p3d.y * v0 + p3d.x * v1;
-    C[3] = v0;
-    C[4] = v1;
-    C[5] = v2;
-}
-
-inline static
-void computeC_Rotation( double* C, double dIdx, double dIdy, const Point3f& p3d, double fx, double fy )
-{
-    double invz  = 1. / p3d.z,
-           v0 = dIdx * fx * invz,
-           v1 = dIdy * fy * invz,
-           v2 = -(v0 * p3d.x + v1 * p3d.y) * invz;
-
-    C[0] = -p3d.z * v1 + p3d.y * v2;
-    C[1] =  p3d.z * v0 - p3d.x * v2;
-    C[2] = -p3d.y * v0 + p3d.x * v1;
-}
-
-inline static
-void computeC_Translation( double* C, double dIdx, double dIdy, const Point3f& p3d, double fx, double fy )
-{
-    double invz  = 1. / p3d.z,
-           v0 = dIdx * fx * invz,
-           v1 = dIdy * fy * invz,
-           v2 = -(v0 * p3d.x + v1 * p3d.y) * invz;
-
-    C[0] = v0;
-    C[1] = v1;
-    C[2] = v2;
-}
-
-inline static
-void computeProjectiveMatrix( const Mat& ksi, Mat& Rt )
-{
-    CV_Assert( ksi.size() == Size(1,6) && ksi.type() == CV_64FC1 );
-
-#if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 3 && (!defined _MSC_VER || !defined _M_X64 || _MSC_VER > 1500)
-    const double* ksi_ptr = reinterpret_cast<const double*>(ksi.ptr(0));
-    Eigen::Matrix<double,4,4> twist, g;
-    twist << 0.,          -ksi_ptr[2], ksi_ptr[1],  ksi_ptr[3],
-             ksi_ptr[2],  0.,          -ksi_ptr[0], ksi_ptr[4],
-             -ksi_ptr[1], ksi_ptr[0],  0,           ksi_ptr[5],
-             0.,          0.,          0.,          0.;
-    g = twist.exp();
-
-
-    eigen2cv(g, Rt);
-#else
-    // for infinitesimal transformation
-    Rt = Mat::eye(4, 4, CV_64FC1);
-
-    Mat R = Rt(Rect(0,0,3,3));
-    Mat rvec = ksi.rowRange(0,3);
-
-    Rodrigues( rvec, R );
-
-    Rt.at<double>(0,3) = ksi.at<double>(3);
-    Rt.at<double>(1,3) = ksi.at<double>(4);
-    Rt.at<double>(2,3) = ksi.at<double>(5);
-#endif
-}
-
-static
-void cvtDepth2Cloud( const Mat& depth, Mat& cloud, const Mat& cameraMatrix )
-{
-    CV_Assert( cameraMatrix.type() == CV_64FC1 );
-    const double inv_fx = 1.f/cameraMatrix.at<double>(0,0);
-    const double inv_fy = 1.f/cameraMatrix.at<double>(1,1);
-    const double ox = cameraMatrix.at<double>(0,2);
-    const double oy = cameraMatrix.at<double>(1,2);
-    cloud.create( depth.size(), CV_32FC3 );
-    for( int y = 0; y < cloud.rows; y++ )
-    {
-        Point3f* cloud_ptr = reinterpret_cast<Point3f*>(cloud.ptr(y));
-        const float* depth_prt = reinterpret_cast<const float*>(depth.ptr(y));
-        for( int x = 0; x < cloud.cols; x++ )
-        {
-            float z = depth_prt[x];
-            cloud_ptr[x].x = (float)((x - ox) * z * inv_fx);
-            cloud_ptr[x].y = (float)((y - oy) * z * inv_fy);
-            cloud_ptr[x].z = z;
-        }
-    }
-}
-
-#if SHOW_DEBUG_IMAGES
-template<class ImageElemType>
-static void warpImage( const Mat& image, const Mat& depth,
-                       const Mat& Rt, const Mat& cameraMatrix, const Mat& distCoeff,
-                       Mat& warpedImage )
-{
-    const Rect rect = Rect(0, 0, image.cols, image.rows);
-
-    std::vector<Point2f> points2d;
-    Mat cloud, transformedCloud;
-
-    cvtDepth2Cloud( depth, cloud, cameraMatrix );
-    perspectiveTransform( cloud, transformedCloud, Rt );
-    projectPoints( transformedCloud.reshape(3,1), Mat::eye(3,3,CV_64FC1), Mat::zeros(3,1,CV_64FC1), cameraMatrix, distCoeff, points2d );
-
-    Mat pointsPositions( points2d );
-    pointsPositions = pointsPositions.reshape( 2, image.rows );
-
-    warpedImage.create( image.size(), image.type() );
-    warpedImage = Scalar::all(0);
-
-    Mat zBuffer( image.size(), CV_32FC1, FLT_MAX );
-    for( int y = 0; y < image.rows; y++ )
-    {
-        for( int x = 0; x < image.cols; x++ )
-        {
-            const Point3f p3d = transformedCloud.at<Point3f>(y,x);
-            const Point p2d = pointsPositions.at<Point2f>(y,x);
-            if( !cvIsNaN(cloud.at<Point3f>(y,x).z) && cloud.at<Point3f>(y,x).z > 0 &&
-                rect.contains(p2d) && zBuffer.at<float>(p2d) > p3d.z )
-            {
-                warpedImage.at<ImageElemType>(p2d) = image.at<ImageElemType>(y,x);
-                zBuffer.at<float>(p2d) = p3d.z;
-            }
-        }
-    }
-}
-#endif
-
-static inline
-void set2shorts( int& dst, int short_v1, int short_v2 )
-{
-    unsigned short* ptr = reinterpret_cast<unsigned short*>(&dst);
-    ptr[0] = static_cast<unsigned short>(short_v1);
-    ptr[1] = static_cast<unsigned short>(short_v2);
-}
-
-static inline
-void get2shorts( int src, int& short_v1, int& short_v2 )
-{
-    typedef union { int vint32; unsigned short vuint16[2]; } s32tou16;
-    const unsigned short* ptr = (reinterpret_cast<s32tou16*>(&src))->vuint16;
-    short_v1 = ptr[0];
-    short_v2 = ptr[1];
-}
-
-static
-int computeCorresp( const Mat& K, const Mat& K_inv, const Mat& Rt,
-                    const Mat& depth0, const Mat& depth1, const Mat& texturedMask1, float maxDepthDiff,
-                    Mat& corresps )
-{
-    CV_Assert( K.type() == CV_64FC1 );
-    CV_Assert( K_inv.type() == CV_64FC1 );
-    CV_Assert( Rt.type() == CV_64FC1 );
-
-    corresps.create( depth1.size(), CV_32SC1 );
-
-    Mat R = Rt(Rect(0,0,3,3)).clone();
-
-    Mat KRK_inv = K * R * K_inv;
-    const double * KRK_inv_ptr = reinterpret_cast<const double *>(KRK_inv.ptr());
-
-    Mat Kt = Rt(Rect(3,0,1,3)).clone();
-    Kt = K * Kt;
-    const double * Kt_ptr = reinterpret_cast<const double *>(Kt.ptr());
-
-    Rect r(0, 0, depth1.cols, depth1.rows);
-
-    corresps = Scalar(-1);
-    int correspCount = 0;
-    for( int v1 = 0; v1 < depth1.rows; v1++ )
-    {
-        for( int u1 = 0; u1 < depth1.cols; u1++ )
-        {
-            float d1 = depth1.at<float>(v1,u1);
-            if( !cvIsNaN(d1) && texturedMask1.at<uchar>(v1,u1) )
-            {
-                float transformed_d1 = (float)(d1 * (KRK_inv_ptr[6] * u1 + KRK_inv_ptr[7] * v1 + KRK_inv_ptr[8]) + Kt_ptr[2]);
-                int u0 = cvRound((d1 * (KRK_inv_ptr[0] * u1 + KRK_inv_ptr[1] * v1 + KRK_inv_ptr[2]) + Kt_ptr[0]) / transformed_d1);
-                int v0 = cvRound((d1 * (KRK_inv_ptr[3] * u1 + KRK_inv_ptr[4] * v1 + KRK_inv_ptr[5]) + Kt_ptr[1]) / transformed_d1);
-
-                if( r.contains(Point(u0,v0)) )
-                {
-                    float d0 = depth0.at<float>(v0,u0);
-                    if( !cvIsNaN(d0) && std::abs(transformed_d1 - d0) <= maxDepthDiff )
-                    {
-                        int c = corresps.at<int>(v0,u0);
-                        if( c != -1 )
-                        {
-                            int exist_u1, exist_v1;
-                            get2shorts( c, exist_u1, exist_v1);
-
-                            float exist_d1 = (float)(depth1.at<float>(exist_v1,exist_u1) * (KRK_inv_ptr[6] * exist_u1 + KRK_inv_ptr[7] * exist_v1 + KRK_inv_ptr[8]) + Kt_ptr[2]);
-
-                            if( transformed_d1 > exist_d1 )
-                                continue;
-                        }
-                        else
-                            correspCount++;
-
-                        set2shorts( corresps.at<int>(v0,u0), u1, v1 );
-                    }
-                }
-            }
-        }
-    }
-
-    return correspCount;
-}
-
-static inline
-void preprocessDepth( Mat depth0, Mat depth1,
-                      const Mat& validMask0, const Mat& validMask1,
-                      float minDepth, float maxDepth )
-{
-    CV_DbgAssert( depth0.size() == depth1.size() );
-
-    for( int y = 0; y < depth0.rows; y++ )
-    {
-        for( int x = 0; x < depth0.cols; x++ )
-        {
-            float& d0 = depth0.at<float>(y,x);
-            if( !cvIsNaN(d0) && (d0 > maxDepth || d0 < minDepth || d0 <= 0 || (!validMask0.empty() && !validMask0.at<uchar>(y,x))) )
-                d0 = std::numeric_limits<float>::quiet_NaN();
-
-            float& d1 = depth1.at<float>(y,x);
-            if( !cvIsNaN(d1) && (d1 > maxDepth || d1 < minDepth || d1 <= 0 || (!validMask1.empty() && !validMask1.at<uchar>(y,x))) )
-                d1 = std::numeric_limits<float>::quiet_NaN();
-        }
-    }
-}
-
-static
-void buildPyramids( const Mat& image0, const Mat& image1,
-                    const Mat& depth0, const Mat& depth1,
-                    const Mat& cameraMatrix, int sobelSize, double sobelScale,
-                    const std::vector<float>& minGradMagnitudes,
-                    std::vector<Mat>& pyramidImage0, std::vector<Mat>& pyramidDepth0,
-                    std::vector<Mat>& pyramidImage1, std::vector<Mat>& pyramidDepth1,
-                    std::vector<Mat>& pyramid_dI_dx1, std::vector<Mat>& pyramid_dI_dy1,
-                    std::vector<Mat>& pyramidTexturedMask1, std::vector<Mat>& pyramidCameraMatrix )
-{
-    const int pyramidMaxLevel = (int)minGradMagnitudes.size() - 1;
-
-    buildPyramid( image0, pyramidImage0, pyramidMaxLevel );
-    buildPyramid( image1, pyramidImage1, pyramidMaxLevel );
-
-    pyramid_dI_dx1.resize( pyramidImage1.size() );
-    pyramid_dI_dy1.resize( pyramidImage1.size() );
-    pyramidTexturedMask1.resize( pyramidImage1.size() );
-
-    pyramidCameraMatrix.reserve( pyramidImage1.size() );
-
-    Mat cameraMatrix_dbl;
-    cameraMatrix.convertTo( cameraMatrix_dbl, CV_64FC1 );
-
-    for( size_t i = 0; i < pyramidImage1.size(); i++ )
-    {
-        Sobel( pyramidImage1[i], pyramid_dI_dx1[i], CV_16S, 1, 0, sobelSize );
-        Sobel( pyramidImage1[i], pyramid_dI_dy1[i], CV_16S, 0, 1, sobelSize );
-
-        const Mat& dx = pyramid_dI_dx1[i];
-        const Mat& dy = pyramid_dI_dy1[i];
-
-        Mat texturedMask( dx.size(), CV_8UC1, Scalar(0) );
-        const float minScalesGradMagnitude2 = (float)((minGradMagnitudes[i] * minGradMagnitudes[i]) / (sobelScale * sobelScale));
-        for( int y = 0; y < dx.rows; y++ )
-        {
-            for( int x = 0; x < dx.cols; x++ )
-            {
-                float m2 = (float)(dx.at<short>(y,x)*dx.at<short>(y,x) + dy.at<short>(y,x)*dy.at<short>(y,x));
-                if( m2 >= minScalesGradMagnitude2 )
-                    texturedMask.at<uchar>(y,x) = 255;
-            }
-        }
-        pyramidTexturedMask1[i] = texturedMask;
-        Mat levelCameraMatrix = i == 0 ? cameraMatrix_dbl : 0.5f * pyramidCameraMatrix[i-1];
-        levelCameraMatrix.at<double>(2,2) = 1.;
-        pyramidCameraMatrix.push_back( levelCameraMatrix );
-    }
-
-    buildPyramid( depth0, pyramidDepth0, pyramidMaxLevel );
-    buildPyramid( depth1, pyramidDepth1, pyramidMaxLevel );
-}
-
-static
-bool solveSystem( const Mat& C, const Mat& dI_dt, double detThreshold, Mat& ksi )
-{
-#if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 3
-    Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> eC, eCt, edI_dt;
-    cv2eigen(C, eC);
-    cv2eigen(dI_dt, edI_dt);
-    eCt = eC.transpose();
-
-    Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> A, B, eksi;
-
-    A = eCt * eC;
-    double det = A.determinant();
-    if( fabs (det) < detThreshold || cvIsNaN(det) || cvIsInf(det) )
-        return false;
-
-    B = -eCt * edI_dt;
-
-    eksi = A.ldlt().solve(B);
-    eigen2cv( eksi, ksi );
-
-#else
-    Mat A = C.t() * C;
-
-    double det = cv::determinant(A);
-
-    if( fabs (det) < detThreshold || cvIsNaN(det) || cvIsInf(det) )
-        return false;
-
-    Mat B = -C.t() * dI_dt;
-    cv::solve( A, B, ksi, DECOMP_CHOLESKY );
-#endif
-
-    return true;
-}
-
-typedef void (*ComputeCFuncPtr)( double* C, double dIdx, double dIdy, const Point3f& p3d, double fx, double fy );
-
-static
-bool computeKsi( int transformType,
-                 const Mat& image0, const Mat&  cloud0,
-                 const Mat& image1, const Mat& dI_dx1, const Mat& dI_dy1,
-                 const Mat& corresps, int correspsCount,
-                 double fx, double fy, double sobelScale, double determinantThreshold,
-                 Mat& ksi )
-{
-    int Cwidth = -1;
-    ComputeCFuncPtr computeCFuncPtr = 0;
-    if( transformType == RIGID_BODY_MOTION )
-    {
-        Cwidth = 6;
-        computeCFuncPtr = computeC_RigidBodyMotion;
-    }
-    else if( transformType == ROTATION )
-    {
-        Cwidth = 3;
-        computeCFuncPtr = computeC_Rotation;
-    }
-    else if( transformType == TRANSLATION )
-    {
-        Cwidth = 3;
-        computeCFuncPtr = computeC_Translation;
-    }
-    else
-        CV_Error(Error::StsBadFlag, "Unsupported value of transformation type flag.");
-
-    Mat C( correspsCount, Cwidth, CV_64FC1 );
-    Mat dI_dt( correspsCount, 1, CV_64FC1 );
-
-    double sigma = 0;
-    int pointCount = 0;
-    for( int v0 = 0; v0 < corresps.rows; v0++ )
-    {
-        for( int u0 = 0; u0 < corresps.cols; u0++ )
-        {
-            if( corresps.at<int>(v0,u0) != -1 )
-            {
-                int u1, v1;
-                get2shorts( corresps.at<int>(v0,u0), u1, v1 );
-                double diff = static_cast<double>(image1.at<uchar>(v1,u1)) -
-                              static_cast<double>(image0.at<uchar>(v0,u0));
-                sigma += diff * diff;
-                pointCount++;
-            }
-        }
-    }
-    sigma = std::sqrt(sigma/pointCount);
-
-    pointCount = 0;
-    for( int v0 = 0; v0 < corresps.rows; v0++ )
-    {
-        for( int u0 = 0; u0 < corresps.cols; u0++ )
-        {
-            if( corresps.at<int>(v0,u0) != -1 )
-            {
-                int u1, v1;
-                get2shorts( corresps.at<int>(v0,u0), u1, v1 );
-
-                double diff = static_cast<double>(image1.at<uchar>(v1,u1)) -
-                              static_cast<double>(image0.at<uchar>(v0,u0));
-                double w = sigma + std::abs(diff);
-                w = w > DBL_EPSILON ? 1./w : 1.;
-
-                (*computeCFuncPtr)( (double*)C.ptr(pointCount),
-                                     w * sobelScale * dI_dx1.at<short int>(v1,u1),
-                                     w * sobelScale * dI_dy1.at<short int>(v1,u1),
-                                     cloud0.at<Point3f>(v0,u0), fx, fy);
-
-                dI_dt.at<double>(pointCount) = w * diff;
-                pointCount++;
-            }
-        }
-    }
-
-    Mat sln;
-    bool solutionExist = solveSystem( C, dI_dt, determinantThreshold, sln );
-
-    if( solutionExist )
-    {
-        ksi.create(6,1,CV_64FC1);
-        ksi = Scalar(0);
-
-        Mat subksi;
-        if( transformType == RIGID_BODY_MOTION )
-        {
-            subksi = ksi;
-        }
-        else if( transformType == ROTATION )
-        {
-            subksi = ksi.rowRange(0,3);
-        }
-        else if( transformType == TRANSLATION )
-        {
-            subksi = ksi.rowRange(3,6);
-        }
-
-        sln.copyTo( subksi );
-    }
-
-    return solutionExist;
-}
-
-bool cv::RGBDOdometry( cv::Mat& Rt, const Mat& initRt,
-                       const cv::Mat& image0, const cv::Mat& _depth0, const cv::Mat& validMask0,
-                       const cv::Mat& image1, const cv::Mat& _depth1, const cv::Mat& validMask1,
-                       const cv::Mat& cameraMatrix, float minDepth, float maxDepth, float maxDepthDiff,
-                       const std::vector<int>& iterCounts, const std::vector<float>& minGradientMagnitudes,
-                       int transformType )
-{
-    const int sobelSize = 3;
-    const double sobelScale = 1./8;
-
-    Mat depth0 = _depth0.clone(),
-        depth1 = _depth1.clone();
-
-    // check RGB-D input data
-    CV_Assert( !image0.empty() );
-    CV_Assert( image0.type() == CV_8UC1 );
-    CV_Assert( depth0.type() == CV_32FC1 && depth0.size() == image0.size() );
-
-    CV_Assert( image1.size() == image0.size() );
-    CV_Assert( image1.type() == CV_8UC1 );
-    CV_Assert( depth1.type() == CV_32FC1 && depth1.size() == image0.size() );
-
-    // check masks
-    CV_Assert( validMask0.empty() || (validMask0.type() == CV_8UC1 && validMask0.size() == image0.size()) );
-    CV_Assert( validMask1.empty() || (validMask1.type() == CV_8UC1 && validMask1.size() == image0.size()) );
-
-    // check camera params
-    CV_Assert( cameraMatrix.type() == CV_32FC1 && cameraMatrix.size() == Size(3,3) );
-
-    // other checks
-    CV_Assert( iterCounts.empty() || minGradientMagnitudes.empty() ||
-               minGradientMagnitudes.size() == iterCounts.size() );
-    CV_Assert( initRt.empty() || (initRt.type()==CV_64FC1 && initRt.size()==Size(4,4) ) );
-
-    std::vector<int> defaultIterCounts;
-    std::vector<float> defaultMinGradMagnitudes;
-    std::vector<int> const* iterCountsPtr = &iterCounts;
-    std::vector<float> const* minGradientMagnitudesPtr = &minGradientMagnitudes;
-
-    if( iterCounts.empty() || minGradientMagnitudes.empty() )
-    {
-        defaultIterCounts.resize(4);
-        defaultIterCounts[0] = 7;
-        defaultIterCounts[1] = 7;
-        defaultIterCounts[2] = 7;
-        defaultIterCounts[3] = 10;
-
-        defaultMinGradMagnitudes.resize(4);
-        defaultMinGradMagnitudes[0] = 12;
-        defaultMinGradMagnitudes[1] = 5;
-        defaultMinGradMagnitudes[2] = 3;
-        defaultMinGradMagnitudes[3] = 1;
-
-        iterCountsPtr = &defaultIterCounts;
-        minGradientMagnitudesPtr = &defaultMinGradMagnitudes;
-    }
-
-    preprocessDepth( depth0, depth1, validMask0, validMask1, minDepth, maxDepth );
-
-    std::vector<Mat> pyramidImage0, pyramidDepth0,
-                pyramidImage1, pyramidDepth1, pyramid_dI_dx1, pyramid_dI_dy1, pyramidTexturedMask1,
-                pyramidCameraMatrix;
-    buildPyramids( image0, image1, depth0, depth1, cameraMatrix, sobelSize, sobelScale, *minGradientMagnitudesPtr,
-                   pyramidImage0, pyramidDepth0, pyramidImage1, pyramidDepth1,
-                   pyramid_dI_dx1, pyramid_dI_dy1, pyramidTexturedMask1, pyramidCameraMatrix );
-
-    Mat resultRt = initRt.empty() ? Mat::eye(4,4,CV_64FC1) : initRt.clone();
-    Mat currRt, ksi;
-    for( int level = (int)iterCountsPtr->size() - 1; level >= 0; level-- )
-    {
-        const Mat& levelCameraMatrix = pyramidCameraMatrix[level];
-
-        const Mat& levelImage0 = pyramidImage0[level];
-        const Mat& levelDepth0 = pyramidDepth0[level];
-        Mat levelCloud0;
-        cvtDepth2Cloud( pyramidDepth0[level], levelCloud0, levelCameraMatrix );
-
-        const Mat& levelImage1 = pyramidImage1[level];
-        const Mat& levelDepth1 = pyramidDepth1[level];
-        const Mat& level_dI_dx1 = pyramid_dI_dx1[level];
-        const Mat& level_dI_dy1 = pyramid_dI_dy1[level];
-
-        CV_Assert( level_dI_dx1.type() == CV_16S );
-        CV_Assert( level_dI_dy1.type() == CV_16S );
-
-        const double fx = levelCameraMatrix.at<double>(0,0);
-        const double fy = levelCameraMatrix.at<double>(1,1);
-        const double determinantThreshold = 1e-6;
-
-        Mat corresps( levelImage0.size(), levelImage0.type() );
-
-        // Run transformation search on current level iteratively.
-        for( int iter = 0; iter < (*iterCountsPtr)[level]; iter ++ )
-        {
-            int correspsCount = computeCorresp( levelCameraMatrix, levelCameraMatrix.inv(), resultRt.inv(DECOMP_SVD),
-                                                levelDepth0, levelDepth1, pyramidTexturedMask1[level], maxDepthDiff,
-                                                corresps );
-
-            if( correspsCount == 0 )
-                break;
-
-            bool solutionExist = computeKsi( transformType,
-                                             levelImage0, levelCloud0,
-                                             levelImage1, level_dI_dx1, level_dI_dy1,
-                                             corresps, correspsCount,
-                                             fx, fy, sobelScale, determinantThreshold,
-                                             ksi );
-
-            if( !solutionExist )
-                break;
-
-            computeProjectiveMatrix( ksi, currRt );
-
-            resultRt = currRt * resultRt;
-
-#if SHOW_DEBUG_IMAGES
-            std::cout << "currRt " << currRt << std::endl;
-            Mat warpedImage0;
-            const Mat distCoeff(1,5,CV_32FC1,Scalar(0));
-            warpImage<uchar>( levelImage0, levelDepth0, resultRt, levelCameraMatrix, distCoeff, warpedImage0 );
-
-            imshow( "im0", levelImage0 );
-            imshow( "wim0", warpedImage0 );
-            imshow( "im1", levelImage1 );
-            waitKey();
-#endif
-        }
-    }
-
-    Rt = resultRt;
-
-    return !Rt.empty();
-}
diff --git a/modules/contrib/src/selfsimilarity.cpp b/modules/contrib/src/selfsimilarity.cpp
deleted file mode 100644 (file)
index ecca87c..0000000
+++ /dev/null
@@ -1,259 +0,0 @@
-// This is based on Rainer Lienhart contribution. Below is the original copyright:
-//
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                University of Augsburg License Agreement
-//                For Open Source MultiMedia Computing (MMC) Library
-//
-// Copyright (C) 2007, University of Augsburg, Germany, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of University of Augsburg, Germany may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the University of Augsburg, Germany or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-//   Author:    Rainer Lienhart
-//              email: Rainer.Lienhart@informatik.uni-augsburg.de
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-
-// Please cite the following two papers:
-// 1. Shechtman, E., Irani, M.:
-//             Matching local self-similarities across images and videos.
-//             CVPR, (2007)
-// 2. Eva Horster, Thomas Greif, Rainer Lienhart, Malcolm Slaney.
-//             Comparing Local Feature Descriptors in pLSA-Based Image Models.
-//             30th Annual Symposium of the German Association for
-//      Pattern Recognition (DAGM) 2008, Munich, Germany, June 2008.
-
-#include "precomp.hpp"
-
-namespace cv
-{
-
-SelfSimDescriptor::SelfSimDescriptor()
-{
-    smallSize = DEFAULT_SMALL_SIZE;
-    largeSize = DEFAULT_LARGE_SIZE;
-    numberOfAngles = DEFAULT_NUM_ANGLES;
-    startDistanceBucket = DEFAULT_START_DISTANCE_BUCKET;
-    numberOfDistanceBuckets = DEFAULT_NUM_DISTANCE_BUCKETS;
-}
-
-SelfSimDescriptor::SelfSimDescriptor(int _ssize, int _lsize,
-                                     int _startDistanceBucket,
-                                     int _numberOfDistanceBuckets, int _numberOfAngles)
-{
-    smallSize = _ssize;
-    largeSize = _lsize;
-    startDistanceBucket = _startDistanceBucket;
-    numberOfDistanceBuckets = _numberOfDistanceBuckets;
-    numberOfAngles = _numberOfAngles;
-}
-
-SelfSimDescriptor::SelfSimDescriptor(const SelfSimDescriptor& ss)
-{
-    smallSize = ss.smallSize;
-    largeSize = ss.largeSize;
-    startDistanceBucket = ss.startDistanceBucket;
-    numberOfDistanceBuckets = ss.numberOfDistanceBuckets;
-    numberOfAngles = ss.numberOfAngles;
-}
-
-SelfSimDescriptor::~SelfSimDescriptor()
-{
-}
-
-SelfSimDescriptor& SelfSimDescriptor::operator = (const SelfSimDescriptor& ss)
-{
-    if( this != &ss )
-    {
-        smallSize = ss.smallSize;
-        largeSize = ss.largeSize;
-        startDistanceBucket = ss.startDistanceBucket;
-        numberOfDistanceBuckets = ss.numberOfDistanceBuckets;
-        numberOfAngles = ss.numberOfAngles;
-    }
-    return *this;
-}
-
-size_t SelfSimDescriptor::getDescriptorSize() const
-{
-    return numberOfAngles*(numberOfDistanceBuckets - startDistanceBucket);
-}
-
-Size SelfSimDescriptor::getGridSize( Size imgSize, Size winStride ) const
-{
-    winStride.width = std::max(winStride.width, 1);
-    winStride.height = std::max(winStride.height, 1);
-    int border = largeSize/2 + smallSize/2;
-    return Size(std::max(imgSize.width - border*2 + winStride.width - 1, 0)/winStride.width,
-                std::max(imgSize.height - border*2 + winStride.height - 1, 0)/winStride.height);
-}
-
-// TODO: optimized with SSE2
-void SelfSimDescriptor::SSD(const Mat& img, Point pt, Mat& ssd) const
-{
-    int x, y, dx, dy, r0 = largeSize/2, r1 = smallSize/2;
-    int step = (int)img.step;
-    for( y = -r0; y <= r0; y++ )
-    {
-        float* sptr = ssd.ptr<float>(y+r0) + r0;
-        for( x = -r0; x <= r0; x++ )
-        {
-            int sum = 0;
-            const uchar* src0 = img.ptr<uchar>(y + pt.y - r1) + x + pt.x;
-            const uchar* src1 = img.ptr<uchar>(pt.y - r1) + pt.x;
-            for( dy = -r1; dy <= r1; dy++, src0 += step, src1 += step )
-                for( dx = -r1; dx <= r1; dx++ )
-                {
-                    int t = src0[dx] - src1[dx];
-                    sum += t*t;
-                }
-            sptr[x] = (float)sum;
-        }
-    }
-}
-
-
-void SelfSimDescriptor::compute(const Mat& img, std::vector<float>& descriptors, Size winStride,
-                                const std::vector<Point>& locations) const
-{
-    CV_Assert( img.depth() == CV_8U );
-
-    winStride.width = std::max(winStride.width, 1);
-    winStride.height = std::max(winStride.height, 1);
-    Size gridSize = getGridSize(img.size(), winStride);
-    int i, nwindows = locations.empty() ? gridSize.width*gridSize.height : (int)locations.size();
-    int border = largeSize/2 + smallSize/2;
-    int fsize = (int)getDescriptorSize();
-    std::vector<float> tempFeature(fsize+1);
-    descriptors.resize(fsize*nwindows + 1);
-    Mat ssd(largeSize, largeSize, CV_32F), mappingMask;
-    computeLogPolarMapping(mappingMask);
-
-#if 0 //def _OPENMP
-    int nthreads = cvGetNumThreads();
-    #pragma omp parallel for num_threads(nthreads)
-#endif
-    for( i = 0; i < nwindows; i++ )
-    {
-        Point pt;
-        float* feature0 = &descriptors[fsize*i];
-        float* feature = &tempFeature[0];
-        int x, y, j;
-
-        if( !locations.empty() )
-        {
-            pt = locations[i];
-            if( pt.x < border || pt.x >= img.cols - border ||
-                pt.y < border || pt.y >= img.rows - border )
-            {
-                for( j = 0; j < fsize; j++ )
-                    feature0[j] = 0.f;
-                continue;
-            }
-        }
-        else
-            pt = Point((i % gridSize.width)*winStride.width + border,
-                       (i / gridSize.width)*winStride.height + border);
-
-        SSD(img, pt, ssd);
-
-        // Determine in the local neighborhood the largest difference and use for normalization
-        float var_noise = 1000.f;
-        for( y = -1; y <= 1 ; y++ )
-            for( x = -1 ; x <= 1 ; x++ )
-                var_noise = std::max(var_noise, ssd.at<float>(largeSize/2+y, largeSize/2+x));
-
-        for( j = 0; j <= fsize; j++ )
-            feature[j] = FLT_MAX;
-
-        // Derive feature vector before exp(-x) computation
-        // Idea: for all  x,a >= 0, a=const.   we have:
-        //       max [ exp( -x / a) ] = exp ( -min(x) / a )
-        // Thus, determine min(ssd) and store in feature[...]
-        for( y = 0; y < ssd.rows; y++ )
-        {
-            const schar *mappingMaskPtr = mappingMask.ptr<schar>(y);
-            const float *ssdPtr = ssd.ptr<float>(y);
-            for( x = 0 ; x < ssd.cols; x++ )
-            {
-                int index = mappingMaskPtr[x];
-                feature[index] = std::min(feature[index], ssdPtr[x]);
-            }
-        }
-
-        var_noise = -1.f/var_noise;
-        for( j = 0; j < fsize; j++ )
-            feature0[j] = feature[j]*var_noise;
-        Mat _f(1, fsize, CV_32F, feature0);
-        cv::exp(_f, _f);
-    }
-}
-
-void SelfSimDescriptor::computeLogPolarMapping(Mat& mappingMask) const
-{
-    mappingMask.create(largeSize, largeSize, CV_8S);
-
-    // What we want is
-    //          log_m (radius) = numberOfDistanceBuckets
-    // <==> log_10 (radius) / log_10 (m) = numberOfDistanceBuckets
-    // <==> log_10 (radius) / numberOfDistanceBuckets = log_10 (m)
-    // <==> m = 10 ^ log_10(m) = 10 ^ [log_10 (radius) / numberOfDistanceBuckets]
-    //
-    int radius = largeSize/2, angleBucketSize = 360 / numberOfAngles;
-    int fsize = (int)getDescriptorSize();
-    double inv_log10m = (double)numberOfDistanceBuckets/log10((double)radius);
-
-    for (int y=-radius ; y<=radius ; y++)
-    {
-        schar* mrow = mappingMask.ptr<schar>(y+radius);
-        for (int x=-radius ; x<=radius ; x++)
-        {
-            int index = fsize;
-            float dist = (float)std::sqrt((float)x*x + (float)y*y);
-            int distNo = dist > 0 ? cvRound(log10(dist)*inv_log10m) : 0;
-            if( startDistanceBucket <= distNo && distNo < numberOfDistanceBuckets )
-            {
-                float angle = std::atan2( (float)y, (float)x ) / (float)CV_PI * 180.0f;
-                if (angle < 0) angle += 360.0f;
-                int angleInt = (cvRound(angle) + angleBucketSize/2) % 360;
-                int angleIndex = angleInt / angleBucketSize;
-                index = (distNo-startDistanceBucket)*numberOfAngles + angleIndex;
-            }
-            mrow[x + radius] = saturate_cast<schar>(index);
-        }
-    }
-}
-
-}
diff --git a/modules/contrib/src/spinimages.cpp b/modules/contrib/src/spinimages.cpp
deleted file mode 100644 (file)
index 9b0235e..0000000
+++ /dev/null
@@ -1,1212 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include <algorithm>
-#include <cmath>
-#include <functional>
-#include <fstream>
-#include <limits>
-#include <set>
-
-using namespace cv;
-
-/********************************* local utility *********************************/
-
-namespace
-{
-    const static Scalar colors[] =
-    {
-        Scalar(255,   0,   0),
-        Scalar(  0, 255,   0),
-        Scalar(  0,   0, 255),
-        Scalar(255, 255,   0),
-        Scalar(255,   0, 255),
-        Scalar(  0, 255, 255),
-        Scalar(255, 127, 127),
-        Scalar(127, 127, 255),
-        Scalar(127, 255, 127),
-        Scalar(255, 255, 127),
-        Scalar(127, 255, 255),
-        Scalar(255, 127, 255),
-        Scalar(127,   0,   0),
-        Scalar(  0, 127,   0),
-        Scalar(  0,   0, 127),
-        Scalar(127, 127,   0),
-        Scalar(127,   0, 127),
-        Scalar(  0, 127, 127)
-    };
-    size_t colors_mum = sizeof(colors)/sizeof(colors[0]);
-
-template<class FwIt, class T> inline void _iota(FwIt first, FwIt last, T value)
-{
-    while(first != last) *first++ = value++;
-}
-
-void computeNormals( const Octree& Octree, const std::vector<Point3f>& centers, std::vector<Point3f>& normals,
-                    std::vector<uchar>& mask, float normalRadius, int minNeighbors = 20)
-{
-    size_t normals_size = centers.size();
-    normals.resize(normals_size);
-
-    if (mask.size() != normals_size)
-    {
-        size_t m = mask.size();
-        mask.resize(normals_size);
-        if (normals_size > m)
-            for(; m < normals_size; ++m)
-                mask[m] = 1;
-    }
-
-    std::vector<Point3f> buffer;
-    buffer.reserve(128);
-    SVD svd;
-
-    const static Point3f zero(0.f, 0.f, 0.f);
-
-    for(size_t n = 0; n < normals_size; ++n)
-    {
-        if (mask[n] == 0)
-            continue;
-
-        const Point3f& center = centers[n];
-        Octree.getPointsWithinSphere(center, normalRadius, buffer);
-
-        int buf_size = (int)buffer.size();
-        if (buf_size < minNeighbors)
-        {
-            normals[n] = Mesh3D::allzero;
-            mask[n] = 0;
-            continue;
-        }
-
-        //find the mean point for normalization
-        Point3f mean(Mesh3D::allzero);
-        for(int i = 0; i < buf_size; ++i)
-            mean += buffer[i];
-
-        mean.x /= buf_size;
-        mean.y /= buf_size;
-        mean.z /= buf_size;
-
-        double pxpx = 0;
-        double pypy = 0;
-        double pzpz = 0;
-
-        double pxpy = 0;
-        double pxpz = 0;
-        double pypz = 0;
-
-        for(int i = 0; i < buf_size; ++i)
-        {
-            const Point3f& p = buffer[i];
-
-            pxpx += (p.x - mean.x) * (p.x - mean.x);
-            pypy += (p.y - mean.y) * (p.y - mean.y);
-            pzpz += (p.z - mean.z) * (p.z - mean.z);
-
-            pxpy += (p.x - mean.x) * (p.y - mean.y);
-            pxpz += (p.x - mean.x) * (p.z - mean.z);
-            pypz += (p.y - mean.y) * (p.z - mean.z);
-        }
-
-        //create and populate matrix with normalized nbrs
-        double M_data[] = { pxpx, pxpy, pxpz, /**/ pxpy, pypy, pypz, /**/ pxpz, pypz, pzpz };
-        Mat M(3, 3, CV_64F, M_data);
-
-        svd(M, SVD::MODIFY_A);
-
-        /*normals[n] = Point3f(  (float)((double*)svd.vt.data)[6],
-                                 (float)((double*)svd.vt.data)[7],
-                                 (float)((double*)svd.vt.data)[8]  );*/
-        normals[n] = reinterpret_cast<Point3d*>(svd.vt.data)[2];
-        mask[n] = 1;
-    }
-}
-
-void initRotationMat(const Point3f& n, float out[9])
-{
-    double pitch = atan2(n.x, n.z);
-    double pmat[] = { cos(pitch), 0, -sin(pitch) ,
-                        0      , 1,      0      ,
-                     sin(pitch), 0,  cos(pitch) };
-
-    double roll = atan2((double)n.y, n.x * pmat[3*2+0] + n.z * pmat[3*2+2]);
-
-    double rmat[] = { 1,     0,         0,
-                     0, cos(roll), -sin(roll) ,
-                     0, sin(roll),  cos(roll) };
-
-    for(int i = 0; i < 3; ++i)
-        for(int j = 0; j < 3; ++j)
-            out[3*i+j] = (float)(rmat[3*i+0]*pmat[3*0+j] +
-                rmat[3*i+1]*pmat[3*1+j] + rmat[3*i+2]*pmat[3*2+j]);
-}
-
-void transform(const Point3f& in, float matrix[9], Point3f& out)
-{
-    out.x = in.x * matrix[3*0+0] + in.y * matrix[3*0+1] + in.z * matrix[3*0+2];
-    out.y = in.x * matrix[3*1+0] + in.y * matrix[3*1+1] + in.z * matrix[3*1+2];
-    out.z = in.x * matrix[3*2+0] + in.y * matrix[3*2+1] + in.z * matrix[3*2+2];
-}
-
-#if CV_SSE2
-void convertTransformMatrix(const float* matrix, float* sseMatrix)
-{
-    sseMatrix[0] = matrix[0]; sseMatrix[1] = matrix[3]; sseMatrix[2] = matrix[6]; sseMatrix[3] = 0;
-    sseMatrix[4] = matrix[1]; sseMatrix[5] = matrix[4]; sseMatrix[6] = matrix[7]; sseMatrix[7] = 0;
-    sseMatrix[8] = matrix[2]; sseMatrix[9] = matrix[5]; sseMatrix[10] = matrix[8]; sseMatrix[11] = 0;
-}
-
-inline __m128 transformSSE(const __m128* matrix, const __m128& in)
-{
-    CV_DbgAssert(((size_t)matrix & 15) == 0);
-    __m128 a0 = _mm_mul_ps(_mm_load_ps((float*)(matrix+0)), _mm_shuffle_ps(in,in,_MM_SHUFFLE(0,0,0,0)));
-    __m128 a1 = _mm_mul_ps(_mm_load_ps((float*)(matrix+1)), _mm_shuffle_ps(in,in,_MM_SHUFFLE(1,1,1,1)));
-    __m128 a2 = _mm_mul_ps(_mm_load_ps((float*)(matrix+2)), _mm_shuffle_ps(in,in,_MM_SHUFFLE(2,2,2,2)));
-
-    return _mm_add_ps(_mm_add_ps(a0,a1),a2);
-}
-
-inline __m128i _mm_mullo_epi32_emul(const __m128i& a, __m128i& b)
-{
-    __m128i pack = _mm_packs_epi32(a, a);
-    return _mm_unpacklo_epi16(_mm_mullo_epi16(pack, b), _mm_mulhi_epi16(pack, b));
-}
-
-#endif
-
-void computeSpinImages( const Octree& Octree, const std::vector<Point3f>& points, const std::vector<Point3f>& normals,
-                       std::vector<uchar>& mask, Mat& spinImages, int imageWidth, float binSize)
-{
-    float pixelsPerMeter = 1.f / binSize;
-    float support = imageWidth * binSize;
-
-    CV_Assert(normals.size() == points.size());
-    CV_Assert(mask.size() == points.size());
-
-    size_t points_size = points.size();
-    mask.resize(points_size);
-
-    int height = imageWidth;
-    int width  = imageWidth;
-
-    spinImages.create( (int)points_size, width*height, CV_32F );
-
-    int nthreads = getNumThreads();
-    int i;
-
-    std::vector< std::vector<Point3f> > pointsInSpherePool(nthreads);
-    for(i = 0; i < nthreads; i++)
-        pointsInSpherePool[i].reserve(2048);
-
-    float halfSuppport = support / 2;
-    float searchRad = support * std::sqrt(5.f) / 2;  //  std::sqrt(sup*sup + (sup/2) * (sup/2) )
-
-#ifdef _OPENMP
-    #pragma omp parallel for num_threads(nthreads)
-#endif
-    for(i = 0; i < (int)points_size; ++i)
-    {
-        if (mask[i] == 0)
-            continue;
-
-        int t = getThreadNum();
-        std::vector<Point3f>& pointsInSphere = pointsInSpherePool[t];
-
-        const Point3f& center = points[i];
-        Octree.getPointsWithinSphere(center, searchRad, pointsInSphere);
-
-        size_t inSphere_size = pointsInSphere.size();
-        if (inSphere_size == 0)
-        {
-            mask[i] = 0;
-            continue;
-        }
-
-        const Point3f& normal = normals[i];
-
-        float rotmat[9];
-        initRotationMat(normal, rotmat);
-        Point3f new_center;
-        transform(center, rotmat, new_center);
-
-        Mat spinImage = spinImages.row(i).reshape(1, height);
-        float* spinImageData = (float*)spinImage.data;
-        int step = width;
-        spinImage = Scalar(0.);
-
-        float alpha, beta;
-        size_t j = 0;
-#if CV_SSE2
-        if (inSphere_size > 4 && checkHardwareSupport(CV_CPU_SSE2))
-        {
-            __m128 rotmatSSE[3];
-            convertTransformMatrix(rotmat, (float*)rotmatSSE);
-
-            __m128 center_x4 = _mm_set1_ps(new_center.x);
-            __m128 center_y4 = _mm_set1_ps(new_center.y);
-            __m128 center_z4 = _mm_set1_ps(new_center.z + halfSuppport);
-            __m128 ppm4 = _mm_set1_ps(pixelsPerMeter);
-            __m128i height4m1 = _mm_set1_epi32(spinImage.rows-1);
-            __m128i width4m1 = _mm_set1_epi32(spinImage.cols-1);
-            CV_Assert( spinImage.step <= 0xffff );
-            __m128i step4 = _mm_set1_epi16((short)step);
-            __m128i zero4 = _mm_setzero_si128();
-            __m128i one4i = _mm_set1_epi32(1);
-            __m128 zero4f = _mm_setzero_ps();
-            __m128 one4f = _mm_set1_ps(1.f);
-            //__m128 two4f = _mm_set1_ps(2.f);
-            int CV_DECL_ALIGNED(16) o[4];
-
-            for (; j <= inSphere_size - 5; j += 4)
-            {
-                __m128 pt0 = transformSSE(rotmatSSE, _mm_loadu_ps((float*)&pointsInSphere[j+0])); // x0 y0 z0 .
-                __m128 pt1 = transformSSE(rotmatSSE, _mm_loadu_ps((float*)&pointsInSphere[j+1])); // x1 y1 z1 .
-                __m128 pt2 = transformSSE(rotmatSSE, _mm_loadu_ps((float*)&pointsInSphere[j+2])); // x2 y2 z2 .
-                __m128 pt3 = transformSSE(rotmatSSE, _mm_loadu_ps((float*)&pointsInSphere[j+3])); // x3 y3 z3 .
-
-                __m128 z0 = _mm_unpackhi_ps(pt0, pt1); // z0 z1 . .
-                __m128 z1 = _mm_unpackhi_ps(pt2, pt3); // z2 z3 . .
-                __m128 beta4 = _mm_sub_ps(center_z4, _mm_movelh_ps(z0, z1)); // b0 b1 b2 b3
-
-                __m128 xy0 = _mm_unpacklo_ps(pt0, pt1); // x0 x1 y0 y1
-                __m128 xy1 = _mm_unpacklo_ps(pt2, pt3); // x2 x3 y2 y3
-                __m128 x4 = _mm_movelh_ps(xy0, xy1); // x0 x1 x2 x3
-                __m128 y4 = _mm_movehl_ps(xy1, xy0); // y0 y1 y2 y3
-
-                x4 = _mm_sub_ps(x4, center_x4);
-                y4 = _mm_sub_ps(y4, center_y4);
-                __m128 alpha4 = _mm_sqrt_ps(_mm_add_ps(_mm_mul_ps(x4,x4),_mm_mul_ps(y4,y4)));
-
-                __m128 n1f4 = _mm_mul_ps( beta4, ppm4);  /* beta4 float */
-                __m128 n2f4 = _mm_mul_ps(alpha4, ppm4); /* alpha4 float */
-
-                /* floor */
-                __m128i n1 = _mm_sub_epi32(_mm_cvttps_epi32( _mm_add_ps( n1f4, one4f ) ), one4i);
-                __m128i n2 = _mm_sub_epi32(_mm_cvttps_epi32( _mm_add_ps( n2f4, one4f ) ), one4i);
-
-                __m128 f1 = _mm_sub_ps( n1f4, _mm_cvtepi32_ps(n1) );  /* { beta4  }  */
-                __m128 f2 = _mm_sub_ps( n2f4, _mm_cvtepi32_ps(n2) );  /* { alpha4 }  */
-
-                __m128 f1f2 = _mm_mul_ps(f1, f2);  // f1 * f2
-                __m128 omf1omf2 = _mm_add_ps(_mm_sub_ps(_mm_sub_ps(one4f, f2), f1), f1f2); // (1-f1) * (1-f2)
-
-                __m128i _mask = _mm_and_si128(
-                    _mm_andnot_si128(_mm_cmpgt_epi32(zero4, n1), _mm_cmpgt_epi32(height4m1, n1)),
-                    _mm_andnot_si128(_mm_cmpgt_epi32(zero4, n2), _mm_cmpgt_epi32(width4m1, n2)));
-
-                __m128 maskf = _mm_cmpneq_ps(_mm_cvtepi32_ps(_mask), zero4f);
-
-                __m128 v00 = _mm_and_ps(        omf1omf2       , maskf); // a00 b00 c00 d00
-                __m128 v01 = _mm_and_ps( _mm_sub_ps( f2, f1f2 ), maskf); // a01 b01 c01 d01
-                __m128 v10 = _mm_and_ps( _mm_sub_ps( f1, f1f2 ), maskf); // a10 b10 c10 d10
-                __m128 v11 = _mm_and_ps(          f1f2         , maskf); // a11 b11 c11 d11
-
-                __m128i ofs4 = _mm_and_si128(_mm_add_epi32(_mm_mullo_epi32_emul(n1, step4), n2), _mask);
-                _mm_store_si128((__m128i*)o, ofs4);
-
-                __m128 t0 = _mm_unpacklo_ps(v00, v01); // a00 a01 b00 b01
-                __m128 t1 = _mm_unpacklo_ps(v10, v11); // a10 a11 b10 b11
-                __m128 u0 = _mm_movelh_ps(t0, t1); // a00 a01 a10 a11
-                __m128 u1 = _mm_movehl_ps(t1, t0); // b00 b01 b10 b11
-
-                __m128 x0 = _mm_loadl_pi(u0, (__m64*)(spinImageData+o[0])); // x00 x01
-                x0 = _mm_loadh_pi(x0, (__m64*)(spinImageData+o[0]+step));   // x00 x01 x10 x11
-                x0 = _mm_add_ps(x0, u0);
-                _mm_storel_pi((__m64*)(spinImageData+o[0]), x0);
-                _mm_storeh_pi((__m64*)(spinImageData+o[0]+step), x0);
-
-                x0 = _mm_loadl_pi(x0, (__m64*)(spinImageData+o[1]));        // y00 y01
-                x0 = _mm_loadh_pi(x0, (__m64*)(spinImageData+o[1]+step));   // y00 y01 y10 y11
-                x0 = _mm_add_ps(x0, u1);
-                _mm_storel_pi((__m64*)(spinImageData+o[1]), x0);
-                _mm_storeh_pi((__m64*)(spinImageData+o[1]+step), x0);
-
-                t0 = _mm_unpackhi_ps(v00, v01); // c00 c01 d00 d01
-                t1 = _mm_unpackhi_ps(v10, v11); // c10 c11 d10 d11
-                u0 = _mm_movelh_ps(t0, t1); // c00 c01 c10 c11
-                u1 = _mm_movehl_ps(t1, t0); // d00 d01 d10 d11
-
-                x0 = _mm_loadl_pi(x0, (__m64*)(spinImageData+o[2]));        // z00 z01
-                x0 = _mm_loadh_pi(x0, (__m64*)(spinImageData+o[2]+step));   // z00 z01 z10 z11
-                x0 = _mm_add_ps(x0, u0);
-                _mm_storel_pi((__m64*)(spinImageData+o[2]), x0);
-                _mm_storeh_pi((__m64*)(spinImageData+o[2]+step), x0);
-
-                x0 = _mm_loadl_pi(x0, (__m64*)(spinImageData+o[3]));        // w00 w01
-                x0 = _mm_loadh_pi(x0, (__m64*)(spinImageData+o[3]+step));   // w00 w01 w10 w11
-                x0 = _mm_add_ps(x0, u1);
-                _mm_storel_pi((__m64*)(spinImageData+o[3]), x0);
-                _mm_storeh_pi((__m64*)(spinImageData+o[3]+step), x0);
-            }
-        }
-#endif
-        for (; j < inSphere_size; ++j)
-        {
-            Point3f pt;
-            transform(pointsInSphere[j], rotmat, pt);
-
-            beta = halfSuppport - (pt.z - new_center.z);
-            if (beta >= support || beta < 0)
-                continue;
-
-            alpha = std::sqrt( (new_center.x - pt.x) * (new_center.x - pt.x) +
-                          (new_center.y - pt.y) * (new_center.y - pt.y) );
-
-            float n1f = beta  * pixelsPerMeter;
-            float n2f = alpha * pixelsPerMeter;
-
-            int n1 = cvFloor(n1f);
-            int n2 = cvFloor(n2f);
-
-            float f1 = n1f - n1;
-            float f2 = n2f - n2;
-
-            if  ((unsigned)n1 >= (unsigned)(spinImage.rows-1) ||
-                 (unsigned)n2 >= (unsigned)(spinImage.cols-1))
-                continue;
-
-            float *cellptr = spinImageData + step * n1 + n2;
-            float f1f2 = f1*f2;
-            cellptr[0] += 1 - f1 - f2 + f1f2;
-            cellptr[1] += f2 - f1f2;
-            cellptr[step] += f1 - f1f2;
-            cellptr[step+1] += f1f2;
-        }
-        mask[i] = 1;
-    }
-}
-
-}
-
-/********************************* Mesh3D *********************************/
-
-const Point3f cv::Mesh3D::allzero(0.f, 0.f, 0.f);
-
-cv::Mesh3D::Mesh3D() { resolution = -1; }
-cv::Mesh3D::Mesh3D(const std::vector<Point3f>& _vtx)
-{
-    resolution = -1;
-    vtx.resize(_vtx.size());
-    std::copy(_vtx.begin(), _vtx.end(), vtx.begin());
-}
-cv::Mesh3D::~Mesh3D() {}
-
-void cv::Mesh3D::buildOctree() { if (octree.getNodes().empty()) octree.buildTree(vtx); }
-void cv::Mesh3D::clearOctree(){ octree = Octree(); }
-
-float cv::Mesh3D::estimateResolution(float /*tryRatio*/)
-{
-#if 0
-    const int neighbors = 3;
-    const int minReasonable = 10;
-
-    int tryNum = static_cast<int>(tryRatio * vtx.size());
-    tryNum = std::min(std::max(tryNum, minReasonable), (int)vtx.size());
-
-    CvMat desc = cvMat((int)vtx.size(), 3, CV_32F, &vtx[0]);
-    CvFeatureTree* tr = cvCreateKDTree(&desc);
-
-    std::vector<double> dist(tryNum * neighbors);
-    std::vector<int>    inds(tryNum * neighbors);
-    std::vector<Point3f> query;
-
-    RNG& rng = theRNG();
-    for(int i = 0; i < tryNum; ++i)
-        query.push_back(vtx[rng.next() % vtx.size()]);
-
-    CvMat cvinds  = cvMat( (int)tryNum, neighbors, CV_32S,  &inds[0] );
-    CvMat cvdist  = cvMat( (int)tryNum, neighbors, CV_64F,  &dist[0] );
-    CvMat cvquery = cvMat( (int)tryNum,         3, CV_32F, &query[0] );
-    cvFindFeatures(tr, &cvquery, &cvinds, &cvdist, neighbors, 50);
-    cvReleaseFeatureTree(tr);
-
-    const int invalid_dist = -2;
-    for(int i = 0; i < tryNum; ++i)
-        if (inds[i] == -1)
-            dist[i] = invalid_dist;
-
-    dist.resize(remove(dist.begin(), dist.end(), invalid_dist) - dist.begin());
-
-    sort(dist, std::less<double>());
-
-    return resolution = (float)dist[ dist.size() / 2 ];
-#else
-    CV_Error(Error::StsNotImplemented, "");
-    return 1.f;
-#endif
-}
-
-
-void cv::Mesh3D::computeNormals(float normalRadius, int minNeighbors)
-{
-    buildOctree();
-    std::vector<uchar> mask;
-    ::computeNormals(octree, vtx, normals, mask, normalRadius, minNeighbors);
-}
-
-void cv::Mesh3D::computeNormals(const std::vector<int>& subset, float normalRadius, int minNeighbors)
-{
-    buildOctree();
-    std::vector<uchar> mask(vtx.size(), 0);
-    for(size_t i = 0; i < subset.size(); ++i)
-        mask[subset[i]] = 1;
-    ::computeNormals(octree, vtx, normals, mask, normalRadius, minNeighbors);
-}
-
-void cv::Mesh3D::writeAsVrml(const String& file, const std::vector<Scalar>& _colors) const
-{
-    std::ofstream ofs(file.c_str());
-
-    ofs << "#VRML V2.0 utf8" << std::endl;
-    ofs << "Shape" << std::endl << "{" << std::endl;
-    ofs << "geometry PointSet" << std::endl << "{" << std::endl;
-    ofs << "coord Coordinate" << std::endl << "{" << std::endl;
-    ofs << "point[" << std::endl;
-
-    for(size_t i = 0; i < vtx.size(); ++i)
-        ofs << vtx[i].x << " " << vtx[i].y << " " << vtx[i].z << std::endl;
-
-    ofs << "]" << std::endl; //point[
-    ofs << "}" << std::endl; //Coordinate{
-
-    if (vtx.size() == _colors.size())
-    {
-        ofs << "color Color" << std::endl << "{" << std::endl;
-        ofs << "color[" << std::endl;
-
-        for(size_t i = 0; i < _colors.size(); ++i)
-            ofs << (float)_colors[i][2] << " " << (float)_colors[i][1] << " " << (float)_colors[i][0] << std::endl;
-
-        ofs << "]" << std::endl; //color[
-        ofs << "}" << std::endl; //color Color{
-    }
-
-    ofs << "}" << std::endl; //PointSet{
-    ofs << "}" << std::endl; //Shape{
-}
-
-
-/********************************* SpinImageModel *********************************/
-
-
-bool cv::SpinImageModel::spinCorrelation(const Mat& spin1, const Mat& spin2, float lambda, float& result)
-{
-    struct Math { static double atanh(double x) { return 0.5 * std::log( (1 + x) / (1 - x) ); } };
-
-    const float* s1 = spin1.ptr<float>();
-    const float* s2 = spin2.ptr<float>();
-
-    int spin_sz = spin1.cols * spin1.rows;
-    double sum1 = 0.0, sum2 = 0.0, sum12 = 0.0, sum11 = 0.0, sum22 = 0.0;
-
-    int N = 0;
-    int i = 0;
-#if CV_SSE2//____________TEMPORARY_DISABLED_____________
-    float CV_DECL_ALIGNED(16) su1[4], su2[4], su11[4], su22[4], su12[4], n[4];
-
-    __m128 zerof4 = _mm_setzero_ps();
-    __m128 onef4  = _mm_set1_ps(1.f);
-    __m128 Nf4 = zerof4;
-    __m128 sum1f4  = zerof4;
-    __m128 sum2f4  = zerof4;
-    __m128 sum11f4 = zerof4;
-    __m128 sum22f4 = zerof4;
-    __m128 sum12f4 = zerof4;
-    for(; i < spin_sz - 5; i += 4)
-    {
-        __m128 v1f4 = _mm_loadu_ps(s1 + i);
-        __m128 v2f4 = _mm_loadu_ps(s2 + i);
-
-        __m128 mskf4 = _mm_and_ps(_mm_cmpneq_ps(v1f4, zerof4), _mm_cmpneq_ps(v2f4, zerof4));
-        if( !_mm_movemask_ps(mskf4) )
-            continue;
-
-        Nf4 = _mm_add_ps(Nf4, _mm_and_ps(onef4, mskf4));
-
-        v1f4 = _mm_and_ps(v1f4, mskf4);
-        v2f4 = _mm_and_ps(v2f4, mskf4);
-
-        sum1f4 = _mm_add_ps(sum1f4, v1f4);
-        sum2f4 = _mm_add_ps(sum2f4, v2f4);
-        sum11f4 = _mm_add_ps(sum11f4, _mm_mul_ps(v1f4, v1f4));
-        sum22f4 = _mm_add_ps(sum22f4, _mm_mul_ps(v2f4, v2f4));
-        sum12f4 = _mm_add_ps(sum12f4, _mm_mul_ps(v1f4, v2f4));
-    }
-    _mm_store_ps( su1,  sum1f4 );
-    _mm_store_ps( su2,  sum2f4 );
-    _mm_store_ps(su11, sum11f4 );
-    _mm_store_ps(su22, sum22f4 );
-    _mm_store_ps(su12, sum12f4 );
-    _mm_store_ps(n, Nf4 );
-
-    N = static_cast<int>(n[0] + n[1] + n[2] + n[3]);
-    sum1  =  su1[0] +  su1[1] +  su1[2] +  su1[3];
-    sum2  =  su2[0] +  su2[1] +  su2[2] +  su2[3];
-    sum11 = su11[0] + su11[1] + su11[2] + su11[3];
-    sum22 = su22[0] + su22[1] + su22[2] + su22[3];
-    sum12 = su12[0] + su12[1] + su12[2] + su12[3];
-#endif
-
-    for(; i < spin_sz; ++i)
-    {
-        float v1 = s1[i];
-        float v2 = s2[i];
-
-        if( !v1 || !v2 )
-            continue;
-        N++;
-
-        sum1  += v1;
-        sum2  += v2;
-        sum11 += v1 * v1;
-        sum22 += v2 * v2;
-        sum12 += v1 * v2;
-    }
-    if( N < 4 )
-        return false;
-
-    double sum1sum1 = sum1 * sum1;
-    double sum2sum2 = sum2 * sum2;
-
-    double Nsum12 = N * sum12;
-    double Nsum11 = N * sum11;
-    double Nsum22 = N * sum22;
-
-    if (Nsum11 == sum1sum1 || Nsum22 == sum2sum2)
-        return false;
-
-    double corr = (Nsum12 - sum1 * sum2) / std::sqrt( (Nsum11 - sum1sum1) * (Nsum22 - sum2sum2) );
-    double atanh = Math::atanh(corr);
-    result = (float)( atanh * atanh - lambda * ( 1.0 / (N - 3) ) );
-    return true;
-}
-
-inline Point2f cv::SpinImageModel::calcSpinMapCoo(const Point3f& p, const Point3f& v, const Point3f& n)
-{
-    /*Point3f PmV(p.x - v.x, p.y - v.y, p.z - v.z);
-    float normalNorm = (float)norm(n);
-    float beta = PmV.dot(n) / normalNorm;
-    float pmcNorm = (float)norm(PmV);
-    float alpha = std::sqrt( pmcNorm * pmcNorm - beta * beta);
-    return Point2f(alpha, beta);*/
-
-    float pmv_x = p.x - v.x, pmv_y = p.y - v.y, pmv_z = p.z - v.z;
-
-    float beta = (pmv_x * n.x + pmv_y + n.y + pmv_z * n.z) / std::sqrt(n.x * n.x + n.y * n.y + n.z * n.z);
-    float alpha = std::sqrt( pmv_x * pmv_x + pmv_y * pmv_y + pmv_z * pmv_z - beta * beta);
-    return Point2f(alpha, beta);
-}
-
-inline float cv::SpinImageModel::geometricConsistency(const Point3f& pointScene1, const Point3f& normalScene1,
-                                                      const Point3f& pointModel1, const Point3f& normalModel1,
-                                                      const Point3f& pointScene2, const Point3f& normalScene2,
-                                                      const Point3f& pointModel2, const Point3f& normalModel2)
-{
-    Point2f Sm2_to_m1, Ss2_to_s1;
-    Point2f Sm1_to_m2, Ss1_to_s2;
-
-    double n_Sm2_to_m1 = norm(Sm2_to_m1 = calcSpinMapCoo(pointModel2, pointModel1, normalModel1));
-    double n_Ss2_to_s1 = norm(Ss2_to_s1 = calcSpinMapCoo(pointScene2, pointScene1, normalScene1));
-
-    double gc21 = 2 * norm(Sm2_to_m1 - Ss2_to_s1) / (n_Sm2_to_m1 + n_Ss2_to_s1 ) ;
-
-    double n_Sm1_to_m2 = norm(Sm1_to_m2 = calcSpinMapCoo(pointModel1, pointModel2, normalModel2));
-    double n_Ss1_to_s2 = norm(Ss1_to_s2 = calcSpinMapCoo(pointScene1, pointScene2, normalScene2));
-
-    double gc12 = 2 * norm(Sm1_to_m2 - Ss1_to_s2) / (n_Sm1_to_m2 + n_Ss1_to_s2 ) ;
-
-    return (float)std::max(gc12, gc21);
-}
-
-inline float cv::SpinImageModel::groupingCreteria(const Point3f& pointScene1, const Point3f& normalScene1,
-                                                  const Point3f& pointModel1, const Point3f& normalModel1,
-                                                  const Point3f& pointScene2, const Point3f& normalScene2,
-                                                  const Point3f& pointModel2, const Point3f& normalModel2,
-                                                  float gamma)
-{
-    Point2f Sm2_to_m1, Ss2_to_s1;
-    Point2f Sm1_to_m2, Ss1_to_s2;
-
-    float gamma05_inv =  0.5f/gamma;
-
-    double n_Sm2_to_m1 = norm(Sm2_to_m1 = calcSpinMapCoo(pointModel2, pointModel1, normalModel1));
-    double n_Ss2_to_s1 = norm(Ss2_to_s1 = calcSpinMapCoo(pointScene2, pointScene1, normalScene1));
-
-    double gc21 = 2 * norm(Sm2_to_m1 - Ss2_to_s1) / (n_Sm2_to_m1 + n_Ss2_to_s1 );
-    double wgc21 = gc21 / (1 - std::exp( -(n_Sm2_to_m1 + n_Ss2_to_s1) * gamma05_inv ) );
-
-    double n_Sm1_to_m2 = norm(Sm1_to_m2 = calcSpinMapCoo(pointModel1, pointModel2, normalModel2));
-    double n_Ss1_to_s2 = norm(Ss1_to_s2 = calcSpinMapCoo(pointScene1, pointScene2, normalScene2));
-
-    double gc12 = 2 * norm(Sm1_to_m2 - Ss1_to_s2) / (n_Sm1_to_m2 + n_Ss1_to_s2 );
-    double wgc12 = gc12 / (1 - std::exp( -(n_Sm1_to_m2 + n_Ss1_to_s2) * gamma05_inv ) );
-
-    return (float)std::max(wgc12, wgc21);
-}
-
-
-cv::SpinImageModel::SpinImageModel(const Mesh3D& _mesh) : mesh(_mesh)
-{
-     if (mesh.vtx.empty())
-         throw Mesh3D::EmptyMeshException();
-    defaultParams();
-}
-
-cv::SpinImageModel::SpinImageModel() { defaultParams(); }
-cv::SpinImageModel::~SpinImageModel() {}
-
-void cv::SpinImageModel::defaultParams()
-{
-    normalRadius = 0.f;
-    minNeighbors = 20;
-
-    binSize    = 0.f; /* autodetect according to mesh resolution */
-    imageWidth = 32;
-
-    lambda = 0.f; /* autodetect according to medan non zero images bin */
-    gamma  = 0.f; /* autodetect according to mesh resolution */
-
-    T_GeometriccConsistency = 0.25f;
-    T_GroupingCorespondances = 0.25f;
-}
-
-Mat cv::SpinImageModel::packRandomScaledSpins(bool separateScale, size_t xCount, size_t yCount) const
-{
-    int spinNum = (int)getSpinCount();
-    int num = std::min(spinNum, (int)(xCount * yCount));
-
-    if (num == 0)
-        return Mat();
-
-    RNG& rng = theRNG();
-
-    std::vector<Mat> spins;
-    for(int i = 0; i < num; ++i)
-        spins.push_back(getSpinImage( rng.next() % spinNum ).reshape(1, imageWidth));
-
-    if (separateScale)
-        for(int i = 0; i < num; ++i)
-        {
-            double max;
-            Mat spin8u;
-            minMaxLoc(spins[i], 0, &max);
-            spins[i].convertTo(spin8u, CV_8U, -255.0/max, 255.0);
-            spins[i] = spin8u;
-        }
-    else
-    {
-        double totalMax = 0;
-        for(int i = 0; i < num; ++i)
-        {
-            double m;
-            minMaxLoc(spins[i], 0, &m);
-            totalMax = std::max(m, totalMax);
-        }
-
-        for(int i = 0; i < num; ++i)
-        {
-            Mat spin8u;
-            spins[i].convertTo(spin8u, CV_8U, -255.0/totalMax, 255.0);
-            spins[i] = spin8u;
-        }
-    }
-
-    int sz = spins.front().cols;
-
-    Mat result((int)(yCount * sz + (yCount - 1)), (int)(xCount * sz + (xCount - 1)), CV_8UC3);
-    result = colors[(static_cast<int64>(getTickCount()/getTickFrequency())/1000) % colors_mum];
-
-    int pos = 0;
-    for(int y = 0; y < (int)yCount; ++y)
-        for(int x = 0; x < (int)xCount; ++x)
-            if (pos < num)
-            {
-                int starty = (y + 0) * sz + y;
-                int endy   = (y + 1) * sz + y;
-
-                int startx = (x + 0) * sz + x;
-                int endx   = (x + 1) * sz + x;
-
-                Mat color;
-                cvtColor(spins[pos++], color, COLOR_GRAY2BGR);
-                Mat roi = result(Range(starty, endy), Range(startx, endx));
-                color.copyTo(roi);
-            }
-    return result;
-}
-
-void cv::SpinImageModel::selectRandomSubset(float ratio)
-{
-    ratio = std::min(std::max(ratio, 0.f), 1.f);
-
-    size_t vtxSize = mesh.vtx.size();
-    size_t setSize  = static_cast<size_t>(vtxSize * ratio);
-
-    if (setSize == 0)
-    {
-        subset.clear();
-    }
-    else if (setSize == vtxSize)
-    {
-        subset.resize(vtxSize);
-        _iota(subset.begin(), subset.end(), 0);
-    }
-    else
-    {
-        RNG& rnd = theRNG();
-
-        std::vector<size_t> left(vtxSize);
-        _iota(left.begin(), left.end(), (size_t)0);
-
-        subset.resize(setSize);
-        for(size_t i = 0; i < setSize; ++i)
-        {
-            int pos = rnd.next() % (int)left.size();
-            subset[i] = (int)left[pos];
-
-            left[pos] = left.back();
-            left.resize(left.size() - 1);
-        }
-        std::sort(subset.begin(), subset.end());
-    }
-}
-
-void cv::SpinImageModel::setSubset(const std::vector<int>& ss)
-{
-    subset = ss;
-}
-
-void cv::SpinImageModel::repackSpinImages(const std::vector<uchar>& mask, Mat& _spinImages, bool reAlloc) const
-{
-    if (reAlloc)
-    {
-        size_t spinCount = mask.size() - std::count(mask.begin(), mask.end(), (uchar)0);
-        Mat newImgs((int)spinCount, _spinImages.cols, _spinImages.type());
-
-        int pos = 0;
-        for(size_t t = 0; t < mask.size(); ++t)
-            if (mask[t])
-            {
-                Mat row = newImgs.row(pos++);
-                _spinImages.row((int)t).copyTo(row);
-            }
-        _spinImages = newImgs;
-    }
-    else
-    {
-        int last = (int)mask.size();
-
-        int dest = (int)(std::find(mask.begin(), mask.end(), (uchar)0) - mask.begin());
-        if (dest == last)
-            return;
-
-        int first = dest + 1;
-        for (; first != last; ++first)
-            if (mask[first] != 0)
-            {
-                Mat row = _spinImages.row(dest);
-                _spinImages.row(first).copyTo(row);
-                ++dest;
-            }
-        _spinImages = _spinImages.rowRange(0, dest);
-    }
-}
-
-void cv::SpinImageModel::compute()
-{
-    /* estimate binSize */
-    if (binSize == 0.f)
-    {
-         if (mesh.resolution == -1.f)
-            mesh.estimateResolution();
-        binSize = mesh.resolution;
-    }
-    /* estimate normalRadius */
-    normalRadius = normalRadius != 0.f ? normalRadius : binSize * imageWidth / 2;
-
-    mesh.buildOctree();
-    if (subset.empty())
-    {
-        mesh.computeNormals(normalRadius, minNeighbors);
-        subset.resize(mesh.vtx.size());
-        _iota(subset.begin(), subset.end(), 0);
-    }
-    else
-        mesh.computeNormals(subset, normalRadius, minNeighbors);
-
-    std::vector<uchar> mask(mesh.vtx.size(), 0);
-    for(size_t i = 0; i < subset.size(); ++i)
-        if (mesh.normals[subset[i]] == Mesh3D::allzero)
-            subset[i] = -1;
-        else
-            mask[subset[i]] = 1;
-    subset.resize( std::remove(subset.begin(), subset.end(), -1) - subset.begin() );
-
-    std::vector<Point3f> vtx;
-    std::vector<Point3f> normals;
-    for(size_t i = 0; i < mask.size(); ++i)
-        if(mask[i])
-        {
-            vtx.push_back(mesh.vtx[i]);
-            normals.push_back(mesh.normals[i]);
-        }
-
-    std::vector<uchar> spinMask(vtx.size(), 1);
-    computeSpinImages( mesh.octree, vtx, normals, spinMask, spinImages, imageWidth, binSize);
-    repackSpinImages(spinMask, spinImages);
-
-    size_t mask_pos = 0;
-    for(size_t i = 0; i < mask.size(); ++i)
-        if(mask[i])
-            if (spinMask[mask_pos++] == 0)
-                subset.resize( std::remove(subset.begin(), subset.end(), (int)i) - subset.begin() );
-}
-
-void cv::SpinImageModel::matchSpinToModel(const Mat& spin, std::vector<int>& indeces, std::vector<float>& corrCoeffs, bool useExtremeOutliers) const
-{
-    const SpinImageModel& model = *this;
-
-    indeces.clear();
-    corrCoeffs.clear();
-
-    std::vector<float> corrs(model.spinImages.rows);
-    std::vector<uchar>  masks(model.spinImages.rows);
-    std::vector<float> cleanCorrs;
-    cleanCorrs.reserve(model.spinImages.rows);
-
-    for(int i = 0; i < model.spinImages.rows; ++i)
-    {
-        masks[i] = spinCorrelation(spin, model.spinImages.row(i), model.lambda, corrs[i]);
-        if (masks[i])
-            cleanCorrs.push_back(corrs[i]);
-    }
-
-    /* Filtering by measure histogram */
-    size_t total = cleanCorrs.size();
-    if(total < 5)
-        return;
-
-    std::sort(cleanCorrs.begin(), cleanCorrs.end());
-
-    float lower_fourth = cleanCorrs[(1 * total) / 4 - 1];
-    float upper_fourth = cleanCorrs[(3 * total) / 4 - 0];
-    float fourth_spread = upper_fourth - lower_fourth;
-
-    //extreme or moderate?
-    float coef = useExtremeOutliers ? 3.0f : 1.5f;
-
-    float histThresHi = upper_fourth + coef * fourth_spread;
-    //float histThresLo = lower_fourth - coef * fourth_spread;
-
-    for(size_t i = 0; i < corrs.size(); ++i)
-        if (masks[i])
-            if (/* corrs[i] < histThresLo || */ corrs[i] > histThresHi)
-            {
-                indeces.push_back((int)i);
-                corrCoeffs.push_back(corrs[i]);
-            }
-}
-
-namespace
-{
-
-struct Match
-{
-    int sceneInd;
-    int modelInd;
-    float measure;
-
-    Match(){}
-    Match(int sceneIndex, int modelIndex, float coeff) : sceneInd(sceneIndex), modelInd(modelIndex), measure(coeff) {}
-    operator float() const { return measure; }
-};
-
-typedef std::set<size_t> group_t;
-typedef group_t::iterator iter;
-typedef group_t::const_iterator citer;
-
-struct WgcHelper
-{
-    const group_t& grp;
-    const Mat& mat;
-    WgcHelper(const group_t& group, const Mat& groupingMat) : grp(group), mat(groupingMat){}
-    float operator()(size_t leftInd) const { return Wgc(leftInd, grp); }
-
-    /* Wgc( correspondence_C, group_{C1..Cn} ) = max_i=1..n_( Wgc(C, Ci) ) */
-    float Wgc(const size_t corespInd, const group_t& group) const
-    {
-        const float* wgcLine = mat.ptr<float>((int)corespInd);
-        float maximum = std::numeric_limits<float>::min();
-
-        for(citer pos = group.begin(); pos != group.end(); ++pos)
-            maximum = std::max(wgcLine[*pos], maximum);
-
-        return maximum;
-    }
-private:
-    WgcHelper& operator=(const WgcHelper& helper);
-};
-
-}
-
- void cv::SpinImageModel::match(const SpinImageModel& scene, std::vector< std::vector<Vec2i> >& result)
-{
-    if (mesh.vtx.empty())
-        throw Mesh3D::EmptyMeshException();
-
-    result.clear();
-
-    SpinImageModel& model = *this;
-    const float infinity = std::numeric_limits<float>::infinity();
-    const float float_max = std::numeric_limits<float>::max();
-
-    /* estimate gamma */
-    if (model.gamma == 0.f)
-    {
-        if (model.mesh.resolution == -1.f)
-            model.mesh.estimateResolution();
-        model.gamma = 4 * model.mesh.resolution;
-    }
-
-    /* estimate lambda */
-    if (model.lambda == 0.f)
-    {
-        std::vector<int> nonzero(model.spinImages.rows);
-        for(int i = 0; i < model.spinImages.rows; ++i)
-            nonzero[i] = countNonZero(model.spinImages.row(i));
-        std::sort(nonzero.begin(), nonzero.end());
-        model.lambda = static_cast<float>( nonzero[ nonzero.size()/2 ] ) / 2;
-    }
-
-    TickMeter corr_timer;
-    corr_timer.start();
-    std::vector<Match> allMatches;
-    for(int i = 0; i < scene.spinImages.rows; ++i)
-    {
-        std::vector<int> indeces;
-        std::vector<float> coeffs;
-        matchSpinToModel(scene.spinImages.row(i), indeces, coeffs);
-        for(size_t t = 0; t < indeces.size(); ++t)
-            allMatches.push_back(Match(i, indeces[t], coeffs[t]));
-    }
-    corr_timer.stop();
-
-    if(allMatches.empty())
-        return;
-
-    /* filtering by similarity measure */
-    const float fraction = 0.5f;
-    float maxMeasure = max_element(allMatches.begin(), allMatches.end(), std::less<float>())->measure;
-    allMatches.erase(
-        remove_if(allMatches.begin(), allMatches.end(), bind2nd(std::less<float>(), maxMeasure * fraction)),
-        allMatches.end());
-
-    int matchesSize = (int)allMatches.size();
-    if(matchesSize == 0)
-        return;
-
-    /* filtering by geometric consistency */
-    for(int i = 0; i < matchesSize; ++i)
-    {
-        int consistNum = 1;
-        float gc = float_max;
-
-        for(int j = 0; j < matchesSize; ++j)
-            if (i != j)
-            {
-                const Match& mi = allMatches[i];
-                const Match& mj = allMatches[j];
-
-                if (mi.sceneInd == mj.sceneInd || mi.modelInd == mj.modelInd)
-                    gc = float_max;
-                else
-                {
-                    const Point3f& pointSceneI  = scene.getSpinVertex(mi.sceneInd);
-                    const Point3f& normalSceneI = scene.getSpinNormal(mi.sceneInd);
-
-                    const Point3f& pointModelI  = model.getSpinVertex(mi.modelInd);
-                    const Point3f& normalModelI = model.getSpinNormal(mi.modelInd);
-
-                    const Point3f& pointSceneJ  = scene.getSpinVertex(mj.sceneInd);
-                    const Point3f& normalSceneJ = scene.getSpinNormal(mj.sceneInd);
-
-                    const Point3f& pointModelJ  = model.getSpinVertex(mj.modelInd);
-                    const Point3f& normalModelJ = model.getSpinNormal(mj.modelInd);
-
-                    gc = geometricConsistency(pointSceneI, normalSceneI, pointModelI, normalModelI,
-                                              pointSceneJ, normalSceneJ, pointModelJ, normalModelJ);
-                }
-
-                if (gc < model.T_GeometriccConsistency)
-                    ++consistNum;
-            }
-
-
-        if (consistNum < matchesSize / 4) /* failed consistensy test */
-            allMatches[i].measure = infinity;
-    }
-    allMatches.erase(
-      std::remove_if(allMatches.begin(), allMatches.end(), std::bind2nd(std::equal_to<float>(), infinity)),
-      allMatches.end());
-
-
-    matchesSize = (int)allMatches.size();
-    if(matchesSize == 0)
-        return;
-
-    Mat groupingMat((int)matchesSize, (int)matchesSize, CV_32F);
-    groupingMat = Scalar(0);
-
-    /* grouping */
-    for(int j = 0; j < matchesSize; ++j)
-        for(int i = j + 1; i < matchesSize; ++i)
-        {
-            const Match& mi = allMatches[i];
-            const Match& mj = allMatches[j];
-
-            if (mi.sceneInd == mj.sceneInd || mi.modelInd == mj.modelInd)
-            {
-                groupingMat.ptr<float>(i)[j] = float_max;
-                groupingMat.ptr<float>(j)[i] = float_max;
-                continue;
-            }
-
-            const Point3f& pointSceneI  = scene.getSpinVertex(mi.sceneInd);
-            const Point3f& normalSceneI = scene.getSpinNormal(mi.sceneInd);
-
-            const Point3f& pointModelI  = model.getSpinVertex(mi.modelInd);
-            const Point3f& normalModelI = model.getSpinNormal(mi.modelInd);
-
-            const Point3f& pointSceneJ  = scene.getSpinVertex(mj.sceneInd);
-            const Point3f& normalSceneJ = scene.getSpinNormal(mj.sceneInd);
-
-            const Point3f& pointModelJ  = model.getSpinVertex(mj.modelInd);
-            const Point3f& normalModelJ = model.getSpinNormal(mj.modelInd);
-
-            float wgc = groupingCreteria(pointSceneI, normalSceneI, pointModelI, normalModelI,
-                                         pointSceneJ, normalSceneJ, pointModelJ, normalModelJ,
-                                         model.gamma);
-
-            groupingMat.ptr<float>(i)[j] = wgc;
-            groupingMat.ptr<float>(j)[i] = wgc;
-        }
-
-    group_t allMatchesInds;
-    for(int i = 0; i < matchesSize; ++i)
-        allMatchesInds.insert(i);
-
-    std::vector<float> buf(matchesSize);
-    float *buf_beg = &buf[0];
-    std::vector<group_t> groups;
-
-    for(int g = 0; g < matchesSize; ++g)
-    {
-        group_t left = allMatchesInds;
-        group_t group;
-
-        left.erase(g);
-        group.insert(g);
-
-        for(;;)
-        {
-            size_t left_size = left.size();
-            if (left_size == 0)
-                break;
-
-            std::transform(left.begin(), left.end(), buf_beg,  WgcHelper(group, groupingMat));
-            size_t minInd = std::min_element(buf_beg, buf_beg + left_size) - buf_beg;
-
-            if (buf[minInd] < model.T_GroupingCorespondances) /* can add corespondance to group */
-            {
-                iter pos = left.begin();
-                advance(pos, minInd);
-
-                group.insert(*pos);
-                left.erase(pos);
-            }
-            else
-                break;
-        }
-
-        if (group.size() >= 4)
-            groups.push_back(group);
-    }
-
-    /* converting the data to final result */
-    for(size_t i = 0; i < groups.size(); ++i)
-    {
-        const group_t& group = groups[i];
-
-        std::vector< Vec2i > outgrp;
-        for(citer pos = group.begin(); pos != group.end(); ++pos)
-        {
-            const Match& m = allMatches[*pos];
-            outgrp.push_back(Vec2i(subset[m.modelInd], scene.subset[m.sceneInd]));
-        }
-        result.push_back(outgrp);
-    }
-}
-
-cv::TickMeter::TickMeter() { reset(); }
-int64 cv::TickMeter::getTimeTicks() const { return sumTime; }
-double cv::TickMeter::getTimeSec()   const { return (double)getTimeTicks()/getTickFrequency(); }
-double cv::TickMeter::getTimeMilli() const { return getTimeSec()*1e3; }
-double cv::TickMeter::getTimeMicro() const { return getTimeMilli()*1e3; }
-int64 cv::TickMeter::getCounter() const { return counter; }
-void  cv::TickMeter::reset() {startTime = 0; sumTime = 0; counter = 0; }
-
-void cv::TickMeter::start(){ startTime = getTickCount(); }
-void cv::TickMeter::stop()
-{
-    int64 time = getTickCount();
-    if ( startTime == 0 )
-        return;
-
-    ++counter;
-
-    sumTime += ( time - startTime );
-    startTime = 0;
-}
-
-//std::ostream& cv::operator<<(std::ostream& out, const TickMeter& tm){ return out << tm.getTimeSec() << "sec"; }
diff --git a/modules/contrib/src/stereovar.cpp b/modules/contrib/src/stereovar.cpp
deleted file mode 100644 (file)
index b2141b1..0000000
+++ /dev/null
@@ -1,411 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
- This is a modification of the variational stereo correspondence algorithm, described in:
- S. Kosov, T. Thormaehlen, H.-P. Seidel "Accurate Real-Time Disparity Estimation with Variational Methods"
- Proceedings of the 5th International Symposium on Visual Computing, Vegas, USA
-
- This code is written by Sergey G. Kosov for "Visir PX" application as part of Project X (www.project-10.de)
- */
-
-#include "precomp.hpp"
-#include <limits.h>
-
-namespace cv
-{
-StereoVar::StereoVar() : levels(3), pyrScale(0.5), nIt(5), minDisp(0), maxDisp(16), poly_n(3), poly_sigma(0), fi(25.0f), lambda(0.03f), penalization(PENALIZATION_TICHONOV), cycle(CYCLE_V), flags(USE_SMART_ID | USE_AUTO_PARAMS)
-{
-}
-
-StereoVar::StereoVar(int _levels, double _pyrScale, int _nIt, int _minDisp, int _maxDisp, int _poly_n, double _poly_sigma, float _fi, float _lambda, int _penalization, int _cycle, int _flags) : levels(_levels), pyrScale(_pyrScale), nIt(_nIt), minDisp(_minDisp), maxDisp(_maxDisp), poly_n(_poly_n), poly_sigma(_poly_sigma), fi(_fi), lambda(_lambda), penalization(_penalization), cycle(_cycle), flags(_flags)
-{ // No Parameters check, since they are all public
-}
-
-StereoVar::~StereoVar()
-{
-}
-
-static Mat diffX(Mat &src)
-{
-    int cols = src.cols - 1;
-    Mat dst(src.size(), src.type());
-    for(int y = 0; y < src.rows; y++){
-        const float* pSrc = src.ptr<float>(y);
-        float* pDst = dst.ptr<float>(y);
-        int x = 0;
-#if CV_SSE2
-        for (x = 0; x <= cols - 8; x += 8) {
-            __m128 a0 = _mm_loadu_ps(pSrc + x);
-            __m128 b0 = _mm_loadu_ps(pSrc + x + 1);
-            __m128 a1 = _mm_loadu_ps(pSrc + x + 4);
-            __m128 b1 = _mm_loadu_ps(pSrc + x + 5);
-            b0 = _mm_sub_ps(b0, a0);
-            b1 = _mm_sub_ps(b1, a1);
-            _mm_storeu_ps(pDst + x, b0);
-            _mm_storeu_ps(pDst + x + 4, b1);
-        }
-#endif
-        for( ; x < cols; x++) pDst[x] = pSrc[x+1] - pSrc[x];
-        pDst[cols] = 0.f;
-    }
-    return dst;
-}
-
-static Mat getGradient(Mat &src)
-{
-    register int x, y;
-    Mat dst(src.size(), src.type());
-    dst.setTo(0);
-    for (y = 0; y < src.rows - 1; y++) {
-        float *pSrc = src.ptr<float>(y);
-        float *pSrcF = src.ptr<float>(y + 1);
-        float *pDst = dst.ptr<float>(y);
-        for (x = 0; x < src.cols - 1; x++)
-            pDst[x] = fabs(pSrc[x + 1] - pSrc[x]) + fabs(pSrcF[x] - pSrc[x]);
-    }
-    return dst;
-}
-
-static Mat getG_c(Mat &src, float l)
-{
-    Mat dst(src.size(), src.type());
-    for (register int y = 0; y < src.rows; y++) {
-        float *pSrc = src.ptr<float>(y);
-        float *pDst = dst.ptr<float>(y);
-        for (register int x = 0; x < src.cols; x++)
-            pDst[x] = 0.5f*l / sqrtf(l*l + pSrc[x]*pSrc[x]);
-    }
-    return dst;
-}
-
-static Mat getG_p(Mat &src, float l)
-{
-    Mat dst(src.size(), src.type());
-    for (register int y = 0; y < src.rows; y++) {
-        float *pSrc = src.ptr<float>(y);
-        float *pDst = dst.ptr<float>(y);
-        for (register int x = 0; x < src.cols; x++)
-            pDst[x] = 0.5f*l*l / (l*l + pSrc[x]*pSrc[x]);
-    }
-    return dst;
-}
-
-void StereoVar::VariationalSolver(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level)
-{
-    register int n, x, y;
-    float gl = 1, gr = 1, gu = 1, gd = 1, gc = 4;
-    Mat g_c, g_p;
-    Mat U;
-    u.copyTo(U);
-
-    int     N = nIt;
-    float   l = lambda;
-    float   Fi = fi;
-
-
-    if (flags & USE_SMART_ID) {
-        double scale = std::pow(pyrScale, (double) level) * (1 + pyrScale);
-        N = (int) (N / scale);
-    }
-
-    double scale = std::pow(pyrScale, (double) level);
-    Fi /= (float) scale;
-    l *= (float) scale;
-
-    int width   = u.cols - 1;
-    int height  = u.rows - 1;
-    for (n = 0; n < N; n++) {
-        if (penalization != PENALIZATION_TICHONOV) {
-            Mat gradient = getGradient(U);
-            switch (penalization) {
-                case PENALIZATION_CHARBONNIER:  g_c = getG_c(gradient, l); break;
-                case PENALIZATION_PERONA_MALIK: g_p = getG_p(gradient, l); break;
-            }
-            gradient.release();
-        }
-        for (y = 1 ; y < height; y++) {
-            float *pU   = U.ptr<float>(y);
-            float *pUu  = U.ptr<float>(y + 1);
-            float *pUd  = U.ptr<float>(y - 1);
-            float *pu   = u.ptr<float>(y);
-            float *pI1  = I1.ptr<float>(y);
-            float *pI2  = I2.ptr<float>(y);
-            float *pI2x = I2x.ptr<float>(y);
-            float *pG_c = NULL, *pG_cu = NULL, *pG_cd = NULL;
-            float *pG_p = NULL, *pG_pu = NULL, *pG_pd = NULL;
-            switch (penalization) {
-                case PENALIZATION_CHARBONNIER:
-                    pG_c    = g_c.ptr<float>(y);
-                    pG_cu   = g_c.ptr<float>(y + 1);
-                    pG_cd   = g_c.ptr<float>(y - 1);
-                    break;
-                case PENALIZATION_PERONA_MALIK:
-                    pG_p    = g_p.ptr<float>(y);
-                    pG_pu   = g_p.ptr<float>(y + 1);
-                    pG_pd   = g_p.ptr<float>(y - 1);
-                    break;
-            }
-            for (x = 1; x < width; x++) {
-                switch (penalization) {
-                    case PENALIZATION_CHARBONNIER:
-                        gc = pG_c[x];
-                        gl = gc + pG_c[x - 1];
-                        gr = gc + pG_c[x + 1];
-                        gu = gc + pG_cu[x];
-                        gd = gc + pG_cd[x];
-                        gc = gl + gr + gu + gd;
-                        break;
-                    case PENALIZATION_PERONA_MALIK:
-                        gc = pG_p[x];
-                        gl = gc + pG_p[x - 1];
-                        gr = gc + pG_p[x + 1];
-                        gu = gc + pG_pu[x];
-                        gd = gc + pG_pd[x];
-                        gc = gl + gr + gu + gd;
-                        break;
-                }
-
-                float _fi = Fi;
-                if (maxDisp > minDisp) {
-                    if (pU[x] > maxDisp * scale) {_fi *= 1000; pU[x] = static_cast<float>(maxDisp * scale);}
-                    if (pU[x] < minDisp * scale) {_fi *= 1000; pU[x] = static_cast<float>(minDisp * scale);}
-                }
-
-                int A = static_cast<int>(pU[x]);
-                int neg = 0; if (pU[x] <= 0) neg = -1;
-
-                if (x + A > width)
-                    pu[x] = pU[width - A];
-                else if (x + A + neg < 0)
-                    pu[x] = pU[- A + 2];
-                else {
-                    pu[x] = A + (pI2x[x + A + neg] * (pI1[x] - pI2[x + A])
-                              + _fi * (gr * pU[x + 1] + gl * pU[x - 1] + gu * pUu[x] + gd * pUd[x] - gc * A))
-                              / (pI2x[x + A + neg] * pI2x[x + A + neg] + gc * _fi) ;
-                }
-            }// x
-            pu[0] = pu[1];
-            pu[width] = pu[width - 1];
-        }// y
-        for (x = 0; x <= width; x++) {
-            u.at<float>(0, x) = u.at<float>(1, x);
-            u.at<float>(height, x) = u.at<float>(height - 1, x);
-        }
-        u.copyTo(U);
-        if (!g_c.empty()) g_c.release();
-        if (!g_p.empty()) g_p.release();
-    }//n
-}
-
-void StereoVar::VCycle_MyFAS(Mat &I1, Mat &I2, Mat &I2x, Mat &_u, int level)
-{
-    Size imgSize = _u.size();
-    Size frmSize = Size((int) (imgSize.width * pyrScale + 0.5), (int) (imgSize.height * pyrScale + 0.5));
-    Mat I1_h, I2_h, I2x_h, u_h, U, U_h;
-
-    //PRE relaxation
-    VariationalSolver(I1, I2, I2x, _u, level);
-
-    if (level >= levels - 1) return;
-    level ++;
-
-    //scaling DOWN
-    resize(I1, I1_h, frmSize, 0, 0, INTER_AREA);
-    resize(I2, I2_h, frmSize, 0, 0, INTER_AREA);
-    resize(_u, u_h, frmSize, 0, 0, INTER_AREA);
-    u_h.convertTo(u_h, u_h.type(), pyrScale);
-    I2x_h = diffX(I2_h);
-
-    //Next level
-    U_h = u_h.clone();
-    VCycle_MyFAS(I1_h, I2_h, I2x_h, U_h, level);
-
-    subtract(U_h, u_h, U_h);
-    U_h.convertTo(U_h, U_h.type(), 1.0 / pyrScale);
-
-    //scaling UP
-    resize(U_h, U, imgSize);
-
-    //correcting the solution
-    add(_u, U, _u);
-
-    //POST relaxation
-    VariationalSolver(I1, I2, I2x, _u, level - 1);
-
-    if (flags & USE_MEDIAN_FILTERING) medianBlur(_u, _u, 3);
-
-    I1_h.release();
-    I2_h.release();
-    I2x_h.release();
-    u_h.release();
-    U.release();
-    U_h.release();
-}
-
-void StereoVar::FMG(Mat &I1, Mat &I2, Mat &I2x, Mat &u, int level)
-{
-    double  scale = std::pow(pyrScale, (double) level);
-    Size  frmSize = Size((int) (u.cols * scale + 0.5), (int) (u.rows * scale + 0.5));
-    Mat I1_h, I2_h, I2x_h, u_h;
-
-    //scaling DOWN
-    resize(I1, I1_h, frmSize, 0, 0, INTER_AREA);
-    resize(I2, I2_h, frmSize, 0, 0, INTER_AREA);
-    resize(u, u_h, frmSize, 0, 0, INTER_AREA);
-    u_h.convertTo(u_h, u_h.type(), scale);
-    I2x_h = diffX(I2_h);
-
-    switch (cycle) {
-        case CYCLE_O:
-            VariationalSolver(I1_h, I2_h, I2x_h, u_h, level);
-            break;
-        case CYCLE_V:
-            VCycle_MyFAS(I1_h, I2_h, I2x_h, u_h, level);
-            break;
-    }
-
-    u_h.convertTo(u_h, u_h.type(), 1.0 / scale);
-
-    //scaling UP
-    resize(u_h, u, u.size(), 0, 0, INTER_CUBIC);
-
-    I1_h.release();
-    I2_h.release();
-    I2x_h.release();
-    u_h.release();
-
-    level--;
-    if ((flags & USE_AUTO_PARAMS) && (level < levels / 3)) {
-        penalization = PENALIZATION_PERONA_MALIK;
-        fi *= 100;
-        flags -= USE_AUTO_PARAMS;
-        autoParams();
-    }
-    if (flags & USE_MEDIAN_FILTERING) medianBlur(u, u, 3);
-    if (level >= 0) FMG(I1, I2, I2x, u, level);
-}
-
-void StereoVar::autoParams()
-{
-    int maxD = MAX(labs(maxDisp), labs(minDisp));
-
-    if (!maxD) pyrScale = 0.85;
-    else if (maxD < 8) pyrScale = 0.5;
-    else if (maxD < 64) pyrScale = 0.5 + static_cast<double>(maxD - 8) * 0.00625;
-    else pyrScale = 0.85;
-
-    if (maxD) {
-        levels = 0;
-        while ( std::pow(pyrScale, levels) * maxD > 1.5) levels ++;
-        levels++;
-    }
-
-    switch(penalization) {
-        case PENALIZATION_TICHONOV: cycle = CYCLE_V; break;
-        case PENALIZATION_CHARBONNIER: cycle = CYCLE_O; break;
-        case PENALIZATION_PERONA_MALIK: cycle = CYCLE_O; break;
-    }
-}
-
-void StereoVar::operator ()( const Mat& left, const Mat& right, Mat& disp )
-{
-    CV_Assert(left.size() == right.size() && left.type() == right.type());
-    Size imgSize = left.size();
-    int MaxD = MAX(labs(minDisp), labs(maxDisp));
-    int SignD = 1; if (MIN(minDisp, maxDisp) < 0) SignD = -1;
-    if (minDisp >= maxDisp) {MaxD = 256; SignD = 1;}
-
-    Mat u;
-    if ((flags & USE_INITIAL_DISPARITY) && (!disp.empty())) {
-        CV_Assert(disp.size() == left.size() && disp.type() == CV_8UC1);
-        disp.convertTo(u, CV_32FC1, static_cast<double>(SignD * MaxD) / 256);
-    } else {
-        u.create(imgSize, CV_32FC1);
-        u.setTo(0);
-    }
-
-    // Preprocessing
-    Mat leftgray, rightgray;
-    if (left.type() != CV_8UC1) {
-        cvtColor(left, leftgray, COLOR_BGR2GRAY);
-        cvtColor(right, rightgray, COLOR_BGR2GRAY);
-    } else {
-        left.copyTo(leftgray);
-        right.copyTo(rightgray);
-    }
-    if (flags & USE_EQUALIZE_HIST) {
-        equalizeHist(leftgray, leftgray);
-        equalizeHist(rightgray, rightgray);
-    }
-    if (poly_sigma > 0.0001) {
-        GaussianBlur(leftgray, leftgray, Size(poly_n, poly_n), poly_sigma);
-        GaussianBlur(rightgray, rightgray, Size(poly_n, poly_n), poly_sigma);
-    }
-
-    if (flags & USE_AUTO_PARAMS) {
-        penalization = PENALIZATION_TICHONOV;
-        autoParams();
-    }
-
-    Mat I1, I2;
-    leftgray.convertTo(I1, CV_32FC1);
-    rightgray.convertTo(I2, CV_32FC1);
-    leftgray.release();
-    rightgray.release();
-
-    Mat I2x = diffX(I2);
-
-    FMG(I1, I2, I2x, u, levels - 1);
-
-    I1.release();
-    I2.release();
-    I2x.release();
-
-
-    disp.create( left.size(), CV_8UC1 );
-    u = abs(u);
-    u.convertTo(disp, disp.type(), 256 / MaxD, 0);
-
-    u.release();
-}
-} // namespace
diff --git a/modules/contrib/test/test_main.cpp b/modules/contrib/test/test_main.cpp
deleted file mode 100644 (file)
index 6b24993..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "test_precomp.hpp"
-
-CV_TEST_MAIN("cv")
diff --git a/modules/contrib/test/test_precomp.hpp b/modules/contrib/test/test_precomp.hpp
deleted file mode 100644 (file)
index 992ff28..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifdef __GNUC__
-#  pragma GCC diagnostic ignored "-Wmissing-declarations"
-#  if defined __clang__ || defined __APPLE__
-#    pragma GCC diagnostic ignored "-Wmissing-prototypes"
-#    pragma GCC diagnostic ignored "-Wextra"
-#  endif
-#endif
-
-#ifndef __OPENCV_TEST_PRECOMP_HPP__
-#define __OPENCV_TEST_PRECOMP_HPP__
-
-#include "opencv2/ts.hpp"
-#include "opencv2/contrib.hpp"
-#include <iostream>
-
-#endif
diff --git a/modules/legacy/CMakeLists.txt b/modules/legacy/CMakeLists.txt
deleted file mode 100644 (file)
index 348de72..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ocv_define_module(legacy opencv_calib3d opencv_video opencv_ml OPTIONAL opencv_highgui)
diff --git a/modules/legacy/doc/common_interfaces_of_descriptor_extractors.rst b/modules/legacy/doc/common_interfaces_of_descriptor_extractors.rst
deleted file mode 100644 (file)
index 2b59a4e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-Common Interfaces of Descriptor Extractors
-==========================================
-
-.. highlight:: cpp
-
-Extractors of keypoint descriptors in OpenCV have wrappers with a common interface that enables you to easily switch
-between different algorithms solving the same problem. This section is devoted to computing descriptors
-represented as vectors in a multidimensional space. All objects that implement the ``vector``
-descriptor extractors inherit the
-:ocv:class:`DescriptorExtractor` interface.
-
-
-
-CalonderDescriptorExtractor
----------------------------
-.. ocv:class:: CalonderDescriptorExtractor : public DescriptorExtractor
-
-Wrapping class for computing descriptors by using the
-:ocv:class:`RTreeClassifier` class. ::
-
-    template<typename T>
-    class CalonderDescriptorExtractor : public DescriptorExtractor
-    {
-    public:
-        CalonderDescriptorExtractor( const String& classifierFile );
-
-        virtual void read( const FileNode &fn );
-        virtual void write( FileStorage &fs ) const;
-        virtual int descriptorSize() const;
-        virtual int descriptorType() const;
-        virtual int defaultNorm() const;
-    protected:
-        ...
-    }
diff --git a/modules/legacy/doc/common_interfaces_of_generic_descriptor_matchers.rst b/modules/legacy/doc/common_interfaces_of_generic_descriptor_matchers.rst
deleted file mode 100644 (file)
index e959bbf..0000000
+++ /dev/null
@@ -1,363 +0,0 @@
-Common Interfaces of Generic Descriptor Matchers
-================================================
-
-.. highlight:: cpp
-
-OneWayDescriptorBase
---------------------
-.. ocv:class:: OneWayDescriptorBase
-
-Class encapsulates functionality for training/loading a set of one way descriptors
-and finding the nearest closest descriptor to an input feature. ::
-
-    class CV_EXPORTS OneWayDescriptorBase
-    {
-    public:
-
-        // creates an instance of OneWayDescriptor from a set of training files
-        // - patch_size: size of the input (large) patch
-        // - pose_count: the number of poses to generate for each descriptor
-        // - train_path: path to training files
-        // - pca_config: the name of the file that contains PCA for small patches (2 times smaller
-        // than patch_size each dimension
-        // - pca_hr_config: the name of the file that contains PCA for large patches (of patch_size size)
-        // - pca_desc_config: the name of the file that contains descriptors of PCA components
-        OneWayDescriptorBase(CvSize patch_size, int pose_count, const char* train_path = 0, const char* pca_config = 0,
-                            const char* pca_hr_config = 0, const char* pca_desc_config = 0, int pyr_levels = 1,
-                            int pca_dim_high = 100, int pca_dim_low = 100);
-
-        OneWayDescriptorBase(CvSize patch_size, int pose_count, const String &pca_filename, const String &train_path = String(), const String &images_list = String(),
-                            float _scale_min = 0.7f, float _scale_max=1.5f, float _scale_step=1.2f, int pyr_levels = 1,
-                            int pca_dim_high = 100, int pca_dim_low = 100);
-
-
-        virtual ~OneWayDescriptorBase();
-        void clear ();
-
-
-        // Allocate: allocates memory for a given number of descriptors
-        void Allocate(int train_feature_count);
-
-        // AllocatePCADescriptors: allocates memory for pca descriptors
-        void AllocatePCADescriptors();
-
-        // returns patch size
-        CvSize GetPatchSize() const {return m_patch_size;};
-        // returns the number of poses for each descriptor
-        int GetPoseCount() const {return m_pose_count;};
-
-        // returns the number of pyramid levels
-        int GetPyrLevels() const {return m_pyr_levels;};
-
-        // returns the number of descriptors
-        int GetDescriptorCount() const {return m_train_feature_count;};
-
-        // CreateDescriptorsFromImage: creates descriptors for each of the input features
-        // - src: input image
-        // - features: input features
-        // - pyr_levels: the number of pyramid levels
-        void CreateDescriptorsFromImage(IplImage* src, const vector<KeyPoint>& features);
-
-        // CreatePCADescriptors: generates descriptors for PCA components, needed for fast generation of feature descriptors
-        void CreatePCADescriptors();
-
-        // returns a feature descriptor by feature index
-        const OneWayDescriptor* GetDescriptor(int desc_idx) const {return &m_descriptors[desc_idx];};
-
-        // FindDescriptor: finds the closest descriptor
-        // - patch: input image patch
-        // - desc_idx: output index of the closest descriptor to the input patch
-        // - pose_idx: output index of the closest pose of the closest descriptor to the input patch
-        // - distance: distance from the input patch to the closest feature pose
-        // - _scales: scales of the input patch for each descriptor
-        // - scale_ranges: input scales variation (float[2])
-        void FindDescriptor(IplImage* patch, int& desc_idx, int& pose_idx, float& distance, float* _scale = 0, float* scale_ranges = 0) const;
-
-        // - patch: input image patch
-        // - n: number of the closest indexes
-        // - desc_idxs: output indexes of the closest descriptor to the input patch (n)
-        // - pose_idx: output indexes of the closest pose of the closest descriptor to the input patch (n)
-        // - distances: distance from the input patch to the closest feature pose (n)
-        // - _scales: scales of the input patch
-        // - scale_ranges: input scales variation (float[2])
-        void FindDescriptor(IplImage* patch, int n, vector<int>& desc_idxs, vector<int>& pose_idxs,
-                            vector<float>& distances, vector<float>& _scales, float* scale_ranges = 0) const;
-
-        // FindDescriptor: finds the closest descriptor
-        // - src: input image
-        // - pt: center of the feature
-        // - desc_idx: output index of the closest descriptor to the input patch
-        // - pose_idx: output index of the closest pose of the closest descriptor to the input patch
-        // - distance: distance from the input patch to the closest feature pose
-        void FindDescriptor(IplImage* src, cv::Point2f pt, int& desc_idx, int& pose_idx, float& distance) const;
-
-        // InitializePoses: generates random poses
-        void InitializePoses();
-
-        // InitializeTransformsFromPoses: generates 2x3 affine matrices from poses (initializes m_transforms)
-        void InitializeTransformsFromPoses();
-
-        // InitializePoseTransforms: subsequently calls InitializePoses and InitializeTransformsFromPoses
-        void InitializePoseTransforms();
-
-        // InitializeDescriptor: initializes a descriptor
-        // - desc_idx: descriptor index
-        // - train_image: image patch (ROI is supported)
-        // - feature_label: feature textual label
-        void InitializeDescriptor(int desc_idx, IplImage* train_image, const char* feature_label);
-
-        void InitializeDescriptor(int desc_idx, IplImage* train_image, const KeyPoint& keypoint, const char* feature_label);
-
-        // InitializeDescriptors: load features from an image and create descriptors for each of them
-        void InitializeDescriptors(IplImage* train_image, const vector<KeyPoint>& features,
-                                  const char* feature_label = "", int desc_start_idx = 0);
-
-        // Write: writes this object to a file storage
-        // - fs: output filestorage
-        void Write (FileStorage &fs) const;
-
-        // Read: reads OneWayDescriptorBase object from a file node
-        // - fn: input file node
-        void Read (const FileNode &fn);
-
-        // LoadPCADescriptors: loads PCA descriptors from a file
-        // - filename: input filename
-        int LoadPCADescriptors(const char* filename);
-
-        // LoadPCADescriptors: loads PCA descriptors from a file node
-        // - fn: input file node
-        int LoadPCADescriptors(const FileNode &fn);
-
-        // SavePCADescriptors: saves PCA descriptors to a file
-        // - filename: output filename
-        void SavePCADescriptors(const char* filename);
-
-        // SavePCADescriptors: saves PCA descriptors to a file storage
-        // - fs: output file storage
-        void SavePCADescriptors(CvFileStorage* fs) const;
-
-        // GeneratePCA: calculate and save PCA components and descriptors
-        // - img_path: path to training PCA images directory
-        // - images_list: filename with filenames of training PCA images
-        void GeneratePCA(const char* img_path, const char* images_list, int pose_count=500);
-
-        // SetPCAHigh: sets the high resolution pca matrices (copied to internal structures)
-        void SetPCAHigh(CvMat* avg, CvMat* eigenvectors);
-
-        // SetPCALow: sets the low resolution pca matrices (copied to internal structures)
-        void SetPCALow(CvMat* avg, CvMat* eigenvectors);
-
-        int GetLowPCA(CvMat** avg, CvMat** eigenvectors)
-        {
-            *avg = m_pca_avg;
-            *eigenvectors = m_pca_eigenvectors;
-            return m_pca_dim_low;
-        };
-
-        int GetPCADimLow() const {return m_pca_dim_low;};
-        int GetPCADimHigh() const {return m_pca_dim_high;};
-
-        void ConvertDescriptorsArrayToTree(); // Converting pca_descriptors array to KD tree
-
-        // GetPCAFilename: get default PCA filename
-        static String GetPCAFilename () { return "pca.yml"; }
-
-        virtual bool empty() const { return m_train_feature_count <= 0 ? true : false; }
-
-    protected:
-        ...
-    };
-
-OneWayDescriptorMatcher
------------------------
-.. ocv:class:: OneWayDescriptorMatcher : public GenericDescriptorMatcher
-
-Wrapping class for computing, matching, and classifying descriptors using the
-:ocv:class:`OneWayDescriptorBase` class. ::
-
-    class OneWayDescriptorMatcher : public GenericDescriptorMatcher
-    {
-    public:
-        class Params
-        {
-        public:
-            static const int POSE_COUNT = 500;
-            static const int PATCH_WIDTH = 24;
-            static const int PATCH_HEIGHT = 24;
-            static float GET_MIN_SCALE() { return 0.7f; }
-            static float GET_MAX_SCALE() { return 1.5f; }
-            static float GET_STEP_SCALE() { return 1.2f; }
-
-            Params( int poseCount = POSE_COUNT,
-                    Size patchSize = Size(PATCH_WIDTH, PATCH_HEIGHT),
-                    String pcaFilename = String(),
-                    String trainPath = String(), String trainImagesList = String(),
-                    float minScale = GET_MIN_SCALE(), float maxScale = GET_MAX_SCALE(),
-                    float stepScale = GET_STEP_SCALE() );
-
-            int poseCount;
-            Size patchSize;
-            String pcaFilename;
-            String trainPath;
-            String trainImagesList;
-
-            float minScale, maxScale, stepScale;
-        };
-
-        OneWayDescriptorMatcher( const Params& params=Params() );
-        virtual ~OneWayDescriptorMatcher();
-
-        void initialize( const Params& params, const Ptr<OneWayDescriptorBase>& base=Ptr<OneWayDescriptorBase>() );
-
-        // Clears keypoints stored in collection and OneWayDescriptorBase
-        virtual void clear();
-
-        virtual void train();
-
-        virtual bool isMaskSupported();
-
-        virtual void read( const FileNode &fn );
-        virtual void write( FileStorage& fs ) const;
-
-        virtual Ptr<GenericDescriptorMatcher> clone( bool emptyTrainData=false ) const;
-    protected:
-        ...
-    };
-
-FernClassifier
---------------
-.. ocv:class:: FernClassifier
-
-::
-
-    class CV_EXPORTS FernClassifier
-    {
-    public:
-        FernClassifier();
-        FernClassifier(const FileNode& node);
-        FernClassifier(const vector<vector<Point2f> >& points,
-                      const vector<Mat>& refimgs,
-                      const vector<vector<int> >& labels=vector<vector<int> >(),
-                      int _nclasses=0, int _patchSize=PATCH_SIZE,
-                      int _signatureSize=DEFAULT_SIGNATURE_SIZE,
-                      int _nstructs=DEFAULT_STRUCTS,
-                      int _structSize=DEFAULT_STRUCT_SIZE,
-                      int _nviews=DEFAULT_VIEWS,
-                      int _compressionMethod=COMPRESSION_NONE,
-                      const PatchGenerator& patchGenerator=PatchGenerator());
-        virtual ~FernClassifier();
-        virtual void read(const FileNode& n);
-        virtual void write(FileStorage& fs, const String& name=String()) const;
-        virtual void trainFromSingleView(const Mat& image,
-                                        const vector<KeyPoint>& keypoints,
-                                        int _patchSize=PATCH_SIZE,
-                                        int _signatureSize=DEFAULT_SIGNATURE_SIZE,
-                                        int _nstructs=DEFAULT_STRUCTS,
-                                        int _structSize=DEFAULT_STRUCT_SIZE,
-                                        int _nviews=DEFAULT_VIEWS,
-                                        int _compressionMethod=COMPRESSION_NONE,
-                                        const PatchGenerator& patchGenerator=PatchGenerator());
-        virtual void train(const vector<vector<Point2f> >& points,
-                          const vector<Mat>& refimgs,
-                          const vector<vector<int> >& labels=vector<vector<int> >(),
-                          int _nclasses=0, int _patchSize=PATCH_SIZE,
-                          int _signatureSize=DEFAULT_SIGNATURE_SIZE,
-                          int _nstructs=DEFAULT_STRUCTS,
-                          int _structSize=DEFAULT_STRUCT_SIZE,
-                          int _nviews=DEFAULT_VIEWS,
-                          int _compressionMethod=COMPRESSION_NONE,
-                          const PatchGenerator& patchGenerator=PatchGenerator());
-        virtual int operator()(const Mat& img, Point2f kpt, vector<float>& signature) const;
-        virtual int operator()(const Mat& patch, vector<float>& signature) const;
-        virtual void clear();
-        virtual bool empty() const;
-        void setVerbose(bool verbose);
-
-        int getClassCount() const;
-        int getStructCount() const;
-        int getStructSize() const;
-        int getSignatureSize() const;
-        int getCompressionMethod() const;
-        Size getPatchSize() const;
-
-        struct Feature
-        {
-            uchar x1, y1, x2, y2;
-            Feature() : x1(0), y1(0), x2(0), y2(0) {}
-            Feature(int _x1, int _y1, int _x2, int _y2)
-            : x1((uchar)_x1), y1((uchar)_y1), x2((uchar)_x2), y2((uchar)_y2)
-            {}
-            template<typename _Tp> bool operator ()(const Mat_<_Tp>& patch) const
-            { return patch(y1,x1) > patch(y2, x2); }
-        };
-
-        enum
-        {
-            PATCH_SIZE = 31,
-            DEFAULT_STRUCTS = 50,
-            DEFAULT_STRUCT_SIZE = 9,
-            DEFAULT_VIEWS = 5000,
-            DEFAULT_SIGNATURE_SIZE = 176,
-            COMPRESSION_NONE = 0,
-            COMPRESSION_RANDOM_PROJ = 1,
-            COMPRESSION_PCA = 2,
-            DEFAULT_COMPRESSION_METHOD = COMPRESSION_NONE
-        };
-
-    protected:
-        ...
-    };
-
-FernDescriptorMatcher
----------------------
-.. ocv:class:: FernDescriptorMatcher : public GenericDescriptorMatcher
-
-Wrapping class for computing, matching, and classifying descriptors using the
-:ocv:class:`FernClassifier` class. ::
-
-    class FernDescriptorMatcher : public GenericDescriptorMatcher
-    {
-    public:
-        class Params
-        {
-        public:
-            Params( int nclasses=0,
-                    int patchSize=FernClassifier::PATCH_SIZE,
-                    int signatureSize=FernClassifier::DEFAULT_SIGNATURE_SIZE,
-                    int nstructs=FernClassifier::DEFAULT_STRUCTS,
-                    int structSize=FernClassifier::DEFAULT_STRUCT_SIZE,
-                    int nviews=FernClassifier::DEFAULT_VIEWS,
-                    int compressionMethod=FernClassifier::COMPRESSION_NONE,
-                    const PatchGenerator& patchGenerator=PatchGenerator() );
-
-            Params( const String& filename );
-
-            int nclasses;
-            int patchSize;
-            int signatureSize;
-            int nstructs;
-            int structSize;
-            int nviews;
-            int compressionMethod;
-            PatchGenerator patchGenerator;
-
-            String filename;
-        };
-
-        FernDescriptorMatcher( const Params& params=Params() );
-        virtual ~FernDescriptorMatcher();
-
-        virtual void clear();
-
-        virtual void train();
-
-        virtual bool isMaskSupported();
-
-        virtual void read( const FileNode &fn );
-        virtual void write( FileStorage& fs ) const;
-
-        virtual Ptr<GenericDescriptorMatcher> clone( bool emptyTrainData=false ) const;
-
-    protected:
-            ...
-    };
diff --git a/modules/legacy/doc/expectation_maximization.rst b/modules/legacy/doc/expectation_maximization.rst
deleted file mode 100644 (file)
index 6a5418f..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-Expectation Maximization
-========================
-
-This section describes obsolete ``C`` interface of EM algorithm. Details of the algorithm and its ``C++`` interface can be found in the other section :ref:`ML_Expectation Maximization`.
-
-.. highlight:: cpp
-
-.. note::
-
-   * An example on using the Expectation Maximalization algorithm can be found at opencv_source_code/samples/cpp/em.cpp
-
-   * (Python) An example using Expectation Maximalization for Gaussian Mixing can be found at opencv_source_code/samples/python2/gaussian_mix.py
-
-
-CvEMParams
-----------
-.. ocv:struct:: CvEMParams
-
-Parameters of the EM algorithm. All parameters are public. You can initialize them by a constructor and then override some of them directly if you want.
-
-CvEMParams::CvEMParams
-----------------------
-The constructors
-
-.. ocv:function:: CvEMParams::CvEMParams()
-
-.. ocv:function:: CvEMParams::CvEMParams( int nclusters, int cov_mat_type=EM::COV_MAT_DIAGONAL, int start_step=EM::START_AUTO_STEP, CvTermCriteria term_crit=cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 100, FLT_EPSILON), const CvMat* probs=0, const CvMat* weights=0, const CvMat* means=0, const CvMat** covs=0 )
-
-    :param nclusters: The number of mixture components in the Gaussian mixture model. Some of EM implementation could determine the optimal number of mixtures within a specified value range, but that is not the case in ML yet.
-
-    :param cov_mat_type: Constraint on covariance matrices which defines type of matrices. Possible values are:
-
-        * **CvEM::COV_MAT_SPHERICAL** A scaled identity matrix :math:`\mu_k * I`. There is the only parameter :math:`\mu_k` to be estimated for each matrix. The option may be used in special cases, when the constraint is relevant, or as a first step in the optimization (for example in case when the data is preprocessed with PCA). The results of such preliminary estimation may be passed again to the optimization procedure, this time with ``cov_mat_type=CvEM::COV_MAT_DIAGONAL``.
-
-        * **CvEM::COV_MAT_DIAGONAL** A diagonal matrix with positive diagonal elements. The number of free parameters is ``d`` for each matrix. This is most commonly used option yielding good estimation results.
-
-        * **CvEM::COV_MAT_GENERIC** A symmetric positively defined matrix. The number of free parameters in each matrix is about :math:`d^2/2`. It is not recommended to use this option, unless there is pretty accurate initial estimation of the parameters and/or a huge number of training samples.
-
-    :param start_step: The start step of the EM algorithm:
-
-        * **CvEM::START_E_STEP** Start with Expectation step. You need to provide means :math:`a_k` of mixture components to use this option. Optionally you can pass weights :math:`\pi_k` and covariance matrices :math:`S_k` of mixture components.
-        * **CvEM::START_M_STEP** Start with Maximization step. You need to provide initial probabilities :math:`p_{i,k}` to use this option.
-        * **CvEM::START_AUTO_STEP** Start with Expectation step. You need not provide any parameters because they will be estimated by the kmeans algorithm.
-
-    :param term_crit: The termination criteria of the EM algorithm. The EM algorithm can be terminated by the number of iterations ``term_crit.max_iter`` (number of M-steps) or when relative change of likelihood logarithm is less than ``term_crit.epsilon``.
-
-    :param probs: Initial probabilities :math:`p_{i,k}` of sample :math:`i` to belong to mixture component :math:`k`. It is a floating-point matrix of :math:`nsamples \times nclusters` size. It is used and must be not NULL only when ``start_step=CvEM::START_M_STEP``.
-
-    :param weights: Initial weights :math:`\pi_k` of mixture components. It is a floating-point vector with :math:`nclusters` elements. It is used (if not NULL) only when ``start_step=CvEM::START_E_STEP``.
-
-    :param means: Initial means :math:`a_k` of mixture components. It is a floating-point matrix of :math:`nclusters \times dims` size. It is used used and must be not NULL only when ``start_step=CvEM::START_E_STEP``.
-
-    :param covs: Initial covariance matrices :math:`S_k` of mixture components. Each of covariance matrices is a valid square floating-point matrix of :math:`dims \times dims` size. It is used (if not NULL) only when ``start_step=CvEM::START_E_STEP``.
-
-The default constructor represents a rough rule-of-the-thumb:
-
-::
-
-    CvEMParams() : nclusters(10), cov_mat_type(1/*CvEM::COV_MAT_DIAGONAL*/),
-        start_step(0/*CvEM::START_AUTO_STEP*/), probs(0), weights(0), means(0), covs(0)
-    {
-        term_crit=cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 100, FLT_EPSILON );
-    }
-
-
-With another constructor it is possible to override a variety of parameters from a single number of mixtures (the only essential problem-dependent parameter) to initial values for the mixture parameters.
-
-
-CvEM
-----
-.. ocv:class:: CvEM : public CvStatModel
-
-    The class implements the EM algorithm as described in the beginning of the section :ref:`ML_Expectation Maximization`.
-
-
-CvEM::train
------------
-Estimates the Gaussian mixture parameters from a sample set.
-
-.. ocv:function:: bool CvEM::train( const Mat& samples, const Mat& sampleIdx=Mat(), CvEMParams params=CvEMParams(), Mat* labels=0 )
-
-.. ocv:function:: bool CvEM::train( const CvMat* samples, const CvMat* sampleIdx=0, CvEMParams params=CvEMParams(), CvMat* labels=0 )
-
-    :param samples: Samples from which the Gaussian mixture model will be estimated.
-
-    :param sampleIdx: Mask of samples to use. All samples are used by default.
-
-    :param params: Parameters of the EM algorithm.
-
-    :param labels: The optional output "class label" for each sample: :math:`\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N` (indices of the most probable mixture component for each sample).
-
-Unlike many of the ML models, EM is an unsupervised learning algorithm and it does not take responses (class labels or function values) as input. Instead, it computes the
-*Maximum Likelihood Estimate* of the Gaussian mixture parameters from an input sample set, stores all the parameters inside the structure:
-:math:`p_{i,k}` in ``probs``,
-:math:`a_k` in ``means`` ,
-:math:`S_k` in ``covs[k]``,
-:math:`\pi_k` in ``weights`` , and optionally computes the output "class label" for each sample:
-:math:`\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N` (indices of the most probable mixture component for each sample).
-
-The trained model can be used further for prediction, just like any other classifier. The trained model is similar to the
-:ocv:class:`CvNormalBayesClassifier`.
-
-For an example of clustering random samples of the multi-Gaussian distribution using EM, see ``em.cpp`` sample in the OpenCV distribution.
-
-
-CvEM::predict
--------------
-Returns a mixture component index of a sample.
-
-.. ocv:function:: float CvEM::predict( const Mat& sample, Mat* probs=0 ) const
-
-.. ocv:function:: float CvEM::predict( const CvMat* sample, CvMat* probs ) const
-
-    :param sample: A sample for classification.
-
-    :param probs: If it is not null then the method will write posterior probabilities of each component given the sample data to this parameter.
-
-
-CvEM::getNClusters
-------------------
-Returns the number of mixture components :math:`M` in the Gaussian mixture model.
-
-.. ocv:function:: int CvEM::getNClusters() const
-
-.. ocv:function:: int CvEM::get_nclusters() const
-
-
-CvEM::getMeans
-------------------
-Returns mixture means :math:`a_k`.
-
-.. ocv:function:: Mat CvEM::getMeans() const
-
-.. ocv:function:: const CvMat* CvEM::get_means() const
-
-
-CvEM::getCovs
--------------
-Returns mixture covariance matrices :math:`S_k`.
-
-.. ocv:function:: void CvEM::getCovs(std::vector<cv::Mat>& covs) const
-
-.. ocv:function:: const CvMat** CvEM::get_covs() const
-
-
-CvEM::getWeights
-----------------
-Returns mixture weights :math:`\pi_k`.
-
-.. ocv:function:: Mat CvEM::getWeights() const
-
-.. ocv:function:: const CvMat* CvEM::get_weights() const
-
-
-CvEM::getProbs
---------------
-Returns vectors of probabilities for each training sample.
-
-.. ocv:function:: Mat CvEM::getProbs() const
-
-.. ocv:function:: const CvMat* CvEM::get_probs() const
-
-For each training sample :math:`i` (that have been passed to the constructor or to :ocv:func:`CvEM::train`) returns probabilities :math:`p_{i,k}` to belong to a mixture component :math:`k`.
-
-
-CvEM::getLikelihood
--------------------
-Returns logarithm of likelihood.
-
-.. ocv:function:: double CvEM::getLikelihood() const
-
-.. ocv:function:: double CvEM::get_log_likelihood() const
-
-
-CvEM::write
------------
-Writes the trained Gaussian mixture model to the file storage.
-
-.. ocv:function:: void CvEM::write( CvFileStorage* fs, const char* name ) const
-
-    :param fs: A file storage where the model will be written.
-    :param name: A name of the file node where the model data will be written.
-
-
-CvEM::read
------------------
-Reads the trained Gaussian mixture model from the file storage.
-
-.. ocv:function:: void CvEM::read( CvFileStorage* fs, CvFileNode* node )
-
-    :param fs: A file storage with the trained model.
-
-    :param node: The parent map. If it is NULL, the function searches a node with parameters in all the top-level nodes (streams), starting with the first one.
diff --git a/modules/legacy/doc/feature_detection_and_description.rst b/modules/legacy/doc/feature_detection_and_description.rst
deleted file mode 100644 (file)
index 3dc1ae5..0000000
+++ /dev/null
@@ -1,434 +0,0 @@
-Feature Detection and Description
-=================================
-
-.. highlight:: cpp
-
-RandomizedTree
---------------
-.. ocv:class:: RandomizedTree
-
-Class containing a base structure for ``RTreeClassifier``. ::
-
-    class CV_EXPORTS RandomizedTree
-    {
-    public:
-            friend class RTreeClassifier;
-
-            RandomizedTree();
-            ~RandomizedTree();
-
-            void train(std::vector<BaseKeypoint> const& base_set,
-                     RNG &rng, int depth, int views,
-                     size_t reduced_num_dim, int num_quant_bits);
-            void train(std::vector<BaseKeypoint> const& base_set,
-                     RNG &rng, PatchGenerator &make_patch, int depth,
-                     int views, size_t reduced_num_dim, int num_quant_bits);
-
-            // next two functions are EXPERIMENTAL
-            //(do not use unless you know exactly what you do)
-            static void quantizeVector(float *vec, int dim, int N, float bnds[2],
-                     int clamp_mode=0);
-            static void quantizeVector(float *src, int dim, int N, float bnds[2],
-                     uchar *dst);
-
-            // patch_data must be a 32x32 array (no row padding)
-            float* getPosterior(uchar* patch_data);
-            const float* getPosterior(uchar* patch_data) const;
-            uchar* getPosterior2(uchar* patch_data);
-
-            void read(const char* file_name, int num_quant_bits);
-            void read(std::istream &is, int num_quant_bits);
-            void write(const char* file_name) const;
-            void write(std::ostream &os) const;
-
-            int classes() { return classes_; }
-            int depth() { return depth_; }
-
-            void discardFloatPosteriors() { freePosteriors(1); }
-
-            inline void applyQuantization(int num_quant_bits)
-                     { makePosteriors2(num_quant_bits); }
-
-    private:
-            int classes_;
-            int depth_;
-            int num_leaves_;
-            std::vector<RTreeNode> nodes_;
-            float **posteriors_;        // 16-byte aligned posteriors
-            uchar **posteriors2_;     // 16-byte aligned posteriors
-            std::vector<int> leaf_counts_;
-
-            void createNodes(int num_nodes, RNG &rng);
-            void allocPosteriorsAligned(int num_leaves, int num_classes);
-            void freePosteriors(int which);
-                     // which: 1=posteriors_, 2=posteriors2_, 3=both
-            void init(int classes, int depth, RNG &rng);
-            void addExample(int class_id, uchar* patch_data);
-            void finalize(size_t reduced_num_dim, int num_quant_bits);
-            int getIndex(uchar* patch_data) const;
-            inline float* getPosteriorByIndex(int index);
-            inline uchar* getPosteriorByIndex2(int index);
-            inline const float* getPosteriorByIndex(int index) const;
-            void convertPosteriorsToChar();
-            void makePosteriors2(int num_quant_bits);
-            void compressLeaves(size_t reduced_num_dim);
-            void estimateQuantPercForPosteriors(float perc[2]);
-    };
-
-.. note::
-
-   * : PYTHON : An example using Randomized Tree training for letter recognition can be found at opencv_source_code/samples/python2/letter_recog.py
-
-RandomizedTree::train
--------------------------
-Trains a randomized tree using an input set of keypoints.
-
-.. ocv:function:: void RandomizedTree::train( vector<BaseKeypoint> const& base_set, RNG & rng, int depth, int views, size_t reduced_num_dim, int num_quant_bits )
-
-.. ocv:function:: void RandomizedTree::train( vector<BaseKeypoint> const& base_set, RNG & rng, PatchGenerator & make_patch, int depth, int views, size_t reduced_num_dim, int num_quant_bits )
-
-    :param base_set: Vector of the ``BaseKeypoint`` type. It contains image keypoints used for training.
-
-    :param rng: Random-number generator used for training.
-
-    :param make_patch: Patch generator used for training.
-
-    :param depth: Maximum tree depth.
-
-    :param views: Number of random views of each keypoint neighborhood to generate.
-
-    :param reduced_num_dim: Number of dimensions used in the compressed signature.
-
-    :param num_quant_bits: Number of bits used for quantization.
-
-.. note::
-
-   * : An example on training a Random Tree Classifier for letter recognition can be found at opencv_source_code\samples\cpp\letter_recog.cpp
-
-RandomizedTree::read
-------------------------
-Reads a pre-saved randomized tree from a file or stream.
-
-.. ocv:function:: RandomizedTree::read(const char* file_name, int num_quant_bits)
-
-.. ocv:function:: RandomizedTree::read(std::istream &is, int num_quant_bits)
-
-    :param file_name: Name of the file that contains randomized tree data.
-
-    :param is: Input stream associated with the file that contains randomized tree data.
-
-    :param num_quant_bits: Number of bits used for quantization.
-
-
-
-RandomizedTree::write
--------------------------
-Writes the current randomized tree to a file or stream.
-
-.. ocv:function:: void RandomizedTree::write(const char* file_name) const
-
-.. ocv:function:: void RandomizedTree::write(std::ostream &os) const
-
-    :param file_name: Name of the file where randomized tree data is stored.
-
-    :param os: Output stream associated with the file where randomized tree data is stored.
-
-
-
-RandomizedTree::applyQuantization
--------------------------------------
-.. ocv:function:: void RandomizedTree::applyQuantization(int num_quant_bits)
-
-    Applies quantization to the current randomized tree.
-
-    :param num_quant_bits: Number of bits used for quantization.
-
-
-RTreeNode
----------
-.. ocv:struct:: RTreeNode
-
-Class containing a base structure for ``RandomizedTree``. ::
-
-    struct RTreeNode
-    {
-            short offset1, offset2;
-
-            RTreeNode() {}
-
-            RTreeNode(uchar x1, uchar y1, uchar x2, uchar y2)
-                    : offset1(y1*PATCH_SIZE + x1),
-                    offset2(y2*PATCH_SIZE + x2)
-            {}
-
-            //! Left child on 0, right child on 1
-            inline bool operator() (uchar* patch_data) const
-            {
-                    return patch_data[offset1] > patch_data[offset2];
-            }
-    };
-
-
-
-RTreeClassifier
----------------
-.. ocv:class:: RTreeClassifier
-
-Class containing ``RTreeClassifier``. It represents the Calonder descriptor originally introduced by Michael Calonder. ::
-
-    class CV_EXPORTS RTreeClassifier
-    {
-    public:
-            static const int DEFAULT_TREES = 48;
-            static const size_t DEFAULT_NUM_QUANT_BITS = 4;
-
-            RTreeClassifier();
-
-            void train(std::vector<BaseKeypoint> const& base_set,
-                    RNG &rng,
-                    int num_trees = RTreeClassifier::DEFAULT_TREES,
-                    int depth = DEFAULT_DEPTH,
-                    int views = DEFAULT_VIEWS,
-                    size_t reduced_num_dim = DEFAULT_REDUCED_NUM_DIM,
-                    int num_quant_bits = DEFAULT_NUM_QUANT_BITS,
-                             bool print_status = true);
-            void train(std::vector<BaseKeypoint> const& base_set,
-                    RNG &rng,
-                    PatchGenerator &make_patch,
-                    int num_trees = RTreeClassifier::DEFAULT_TREES,
-                    int depth = DEFAULT_DEPTH,
-                    int views = DEFAULT_VIEWS,
-                    size_t reduced_num_dim = DEFAULT_REDUCED_NUM_DIM,
-                    int num_quant_bits = DEFAULT_NUM_QUANT_BITS,
-                     bool print_status = true);
-
-            // sig must point to a memory block of at least
-            //classes()*sizeof(float|uchar) bytes
-            void getSignature(IplImage *patch, uchar *sig);
-            void getSignature(IplImage *patch, float *sig);
-            void getSparseSignature(IplImage *patch, float *sig,
-                     float thresh);
-
-            static int countNonZeroElements(float *vec, int n, double tol=1e-10);
-            static inline void safeSignatureAlloc(uchar **sig, int num_sig=1,
-                            int sig_len=176);
-            static inline uchar* safeSignatureAlloc(int num_sig=1,
-                             int sig_len=176);
-
-            inline int classes() { return classes_; }
-            inline int original_num_classes()
-                     { return original_num_classes_; }
-
-            void setQuantization(int num_quant_bits);
-            void discardFloatPosteriors();
-
-            void read(const char* file_name);
-            void read(std::istream &is);
-            void write(const char* file_name) const;
-            void write(std::ostream &os) const;
-
-            std::vector<RandomizedTree> trees_;
-
-    private:
-            int classes_;
-            int num_quant_bits_;
-            uchar **posteriors_;
-            ushort *ptemp_;
-            int original_num_classes_;
-            bool keep_floats_;
-    };
-
-
-
-RTreeClassifier::train
---------------------------
-Trains a randomized tree classifier using an input set of keypoints.
-
-.. ocv:function:: void RTreeClassifier::train( vector<BaseKeypoint> const& base_set, RNG & rng, int num_trees=RTreeClassifier::DEFAULT_TREES, int depth=RandomizedTree::DEFAULT_DEPTH, int views=RandomizedTree::DEFAULT_VIEWS, size_t reduced_num_dim=RandomizedTree::DEFAULT_REDUCED_NUM_DIM, int num_quant_bits=DEFAULT_NUM_QUANT_BITS )
-
-.. ocv:function:: void RTreeClassifier::train( vector<BaseKeypoint> const& base_set, RNG & rng, PatchGenerator & make_patch, int num_trees=RTreeClassifier::DEFAULT_TREES, int depth=RandomizedTree::DEFAULT_DEPTH, int views=RandomizedTree::DEFAULT_VIEWS, size_t reduced_num_dim=RandomizedTree::DEFAULT_REDUCED_NUM_DIM, int num_quant_bits=DEFAULT_NUM_QUANT_BITS )
-
-    :param base_set: Vector of the ``BaseKeypoint``  type. It contains image keypoints used for training.
-
-    :param rng: Random-number generator used for training.
-
-    :param make_patch: Patch generator used for training.
-
-    :param num_trees: Number of randomized trees used in ``RTreeClassificator`` .
-
-    :param depth: Maximum tree depth.
-
-    :param views: Number of random views of each keypoint neighborhood to generate.
-
-    :param reduced_num_dim: Number of dimensions used in the compressed signature.
-
-    :param num_quant_bits: Number of bits used for quantization.
-
-
-RTreeClassifier::getSignature
----------------------------------
-Returns a signature for an image patch.
-
-.. ocv:function:: void RTreeClassifier::getSignature(IplImage *patch, uchar *sig)
-
-.. ocv:function:: void RTreeClassifier::getSignature(IplImage *patch, float *sig)
-
-    :param patch: Image patch to calculate the signature for.
-    :param sig: Output signature (array dimension is ``reduced_num_dim)`` .
-
-
-
-RTreeClassifier::getSparseSignature
----------------------------------------
-Returns a sparse signature for an image patch
-
-.. ocv:function:: void RTreeClassifier::getSparseSignature(IplImage *patch, float *sig, float thresh)
-
-    :param patch: Image patch to calculate the signature for.
-
-    :param sig: Output signature (array dimension is ``reduced_num_dim)`` .
-
-    :param thresh: Threshold used for compressing the signature.
-
-    Returns a signature for an image patch similarly to ``getSignature``  but uses a threshold for removing all signature elements below the threshold so that the signature is compressed.
-
-
-RTreeClassifier::countNonZeroElements
------------------------------------------
-Returns the number of non-zero elements in an input array.
-
-.. ocv:function:: static int RTreeClassifier::countNonZeroElements(float *vec, int n, double tol=1e-10)
-
-    :param vec: Input vector containing float elements.
-
-    :param n: Input vector size.
-
-    :param tol: Threshold used for counting elements. All elements less than ``tol``  are considered as zero elements.
-
-
-
-RTreeClassifier::read
--------------------------
-Reads a pre-saved ``RTreeClassifier`` from a file or stream.
-
-.. ocv:function:: void RTreeClassifier::read(const char* file_name)
-
-.. ocv:function:: void RTreeClassifier::read( std::istream & is )
-
-    :param file_name: Name of the file that contains randomized tree data.
-
-    :param is: Input stream associated with the file that contains randomized tree data.
-
-
-
-RTreeClassifier::write
---------------------------
-Writes the current ``RTreeClassifier`` to a file or stream.
-
-.. ocv:function:: void RTreeClassifier::write(const char* file_name) const
-
-.. ocv:function:: void RTreeClassifier::write(std::ostream &os) const
-
-    :param file_name: Name of the file where randomized tree data is stored.
-
-    :param os: Output stream associated with the file where randomized tree data is stored.
-
-
-
-RTreeClassifier::setQuantization
-------------------------------------
-Applies quantization to the current randomized tree.
-
-.. ocv:function:: void RTreeClassifier::setQuantization(int num_quant_bits)
-
-    :param num_quant_bits: Number of bits used for quantization.
-
-The example below demonstrates the usage of ``RTreeClassifier`` for matching the features. The features are extracted from the test and train images with SURF. Output is
-:math:`best\_corr` and
-:math:`best\_corr\_idx` arrays that keep the best probabilities and corresponding features indices for every train feature. ::
-
-    CvMemStorage* storage = cvCreateMemStorage(0);
-    CvSeq *objectKeypoints = 0, *objectDescriptors = 0;
-    CvSeq *imageKeypoints = 0, *imageDescriptors = 0;
-    CvSURFParams params = cvSURFParams(500, 1);
-    cvExtractSURF( test_image, 0, &imageKeypoints, &imageDescriptors,
-                     storage, params );
-    cvExtractSURF( train_image, 0, &objectKeypoints, &objectDescriptors,
-                     storage, params );
-
-    RTreeClassifier detector;
-    int patch_width = PATCH_SIZE;
-    iint patch_height = PATCH_SIZE;
-    vector<BaseKeypoint> base_set;
-    int i=0;
-    CvSURFPoint* point;
-    for (i=0;i<(n_points > 0 ? n_points : objectKeypoints->total);i++)
-    {
-            point=(CvSURFPoint*)cvGetSeqElem(objectKeypoints,i);
-            base_set.push_back(
-                    BaseKeypoint(point->pt.x,point->pt.y,train_image));
-    }
-
-            //Detector training
-     RNG rng( cvGetTickCount() );
-    PatchGenerator gen(0,255,2,false,0.7,1.3,-CV_PI/3,CV_PI/3,
-                            -CV_PI/3,CV_PI/3);
-
-    printf("RTree Classifier training...n");
-    detector.train(base_set,rng,gen,24,DEFAULT_DEPTH,2000,
-            (int)base_set.size(), detector.DEFAULT_NUM_QUANT_BITS);
-    printf("Donen");
-
-    float* signature = new float[detector.original_num_classes()];
-    float* best_corr;
-    int* best_corr_idx;
-    if (imageKeypoints->total > 0)
-    {
-            best_corr = new float[imageKeypoints->total];
-            best_corr_idx = new int[imageKeypoints->total];
-    }
-
-    for(i=0; i < imageKeypoints->total; i++)
-    {
-            point=(CvSURFPoint*)cvGetSeqElem(imageKeypoints,i);
-            int part_idx = -1;
-            float prob = 0.0f;
-
-            CvRect roi = cvRect((int)(point->pt.x) - patch_width/2,
-                    (int)(point->pt.y) - patch_height/2,
-                     patch_width, patch_height);
-            cvSetImageROI(test_image, roi);
-            roi = cvGetImageROI(test_image);
-            if(roi.width != patch_width || roi.height != patch_height)
-            {
-                    best_corr_idx[i] = part_idx;
-                    best_corr[i] = prob;
-            }
-            else
-            {
-                    cvSetImageROI(test_image, roi);
-                    IplImage* roi_image =
-                             cvCreateImage(cvSize(roi.width, roi.height),
-                             test_image->depth, test_image->nChannels);
-                    cvCopy(test_image,roi_image);
-
-                    detector.getSignature(roi_image, signature);
-                    for (int j = 0; j< detector.original_num_classes();j++)
-                    {
-                            if (prob < signature[j])
-                            {
-                                    part_idx = j;
-                                    prob = signature[j];
-                            }
-                    }
-
-                    best_corr_idx[i] = part_idx;
-                    best_corr[i] = prob;
-
-                    if (roi_image)
-                            cvReleaseImage(&roi_image);
-            }
-            cvResetImageROI(test_image);
-    }
-
-..
diff --git a/modules/legacy/doc/histograms.rst b/modules/legacy/doc/histograms.rst
deleted file mode 100644 (file)
index fba348c..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-Histograms
-==========
-
-.. highlight:: cpp
-
-
-
-CalcPGH
--------
-Calculates a pair-wise geometrical histogram for a contour.
-
-.. ocv:cfunction:: void cvCalcPGH( const CvSeq* contour, CvHistogram* hist )
-
-    :param contour: Input contour. Currently, only integer point coordinates are allowed.
-
-    :param hist: Calculated histogram. It must be two-dimensional.
-
-The function calculates a 2D pair-wise geometrical histogram (PGH), described in [Iivarinen97]_ for the contour. The algorithm considers every pair of contour
-edges. The angle between the edges and the minimum/maximum distances
-are determined for every pair. To do this, each of the edges in turn
-is taken as the base, while the function loops through all the other
-edges. When the base edge and any other edge are considered, the minimum
-and maximum distances from the points on the non-base edge and line of
-the base edge are selected. The angle between the edges defines the row
-of the histogram in which all the bins that correspond to the distance
-between the calculated minimum and maximum distances are incremented
-(that is, the histogram is transposed relatively to the definition in the original paper). The histogram can be used for contour matching.
-
-
-.. [Iivarinen97] Jukka Iivarinen, Markus Peura, Jaakko Srel, and Ari Visa. *Comparison of Combined Shape Descriptors for Irregular Objects*, 8th British Machine Vision Conference, BMVC'97. http://www.cis.hut.fi/research/IA/paper/publications/bmvc97/bmvc97.html
-
-
-QueryHistValue*D
-----------------
-Queries the value of the histogram bin.
-
-.. ocv:cfunction:: float cvQueryHistValue_1D(CvHistogram hist, int idx0)
-.. ocv:cfunction:: float cvQueryHistValue_2D(CvHistogram hist, int idx0, int idx1)
-.. ocv:cfunction:: float cvQueryHistValue_3D(CvHistogram hist, int idx0, int idx1, int idx2)
-.. ocv:cfunction:: float cvQueryHistValue_nD(CvHistogram hist, const int* idx)
-
-    :param hist: Histogram.
-
-    :param idx0: 0-th index.
-
-    :param idx1: 1-st index.
-
-    :param idx2: 2-nd index.
-
-    :param idx: Array of indices.
-
-The macros return the value of the specified bin of the 1D, 2D, 3D, or N-D histogram. In case of a sparse histogram, the function returns 0. If the bin is not present in the histogram, no new bin is created.
-
-GetHistValue\_?D
-----------------
-Returns a pointer to the histogram bin.
-
-.. ocv:cfunction:: float cvGetHistValue_1D(CvHistogram hist, int idx0)
-
-.. ocv:cfunction:: float cvGetHistValue_2D(CvHistogram hist, int idx0, int idx1)
-
-.. ocv:cfunction:: float cvGetHistValue_3D(CvHistogram hist, int idx0, int idx1, int idx2)
-
-.. ocv:cfunction:: float cvGetHistValue_nD(CvHistogram hist, int idx)
-
-    :param hist: Histogram.
-
-    :param idx0: 0-th index.
-
-    :param idx1: 1-st index.
-
-    :param idx2: 2-nd index.
-
-    :param idx: Array of indices.
-
-::
-
-    #define cvGetHistValue_1D( hist, idx0 )
-        ((float*)(cvPtr1D( (hist)->bins, (idx0), 0 ))
-    #define cvGetHistValue_2D( hist, idx0, idx1 )
-        ((float*)(cvPtr2D( (hist)->bins, (idx0), (idx1), 0 )))
-    #define cvGetHistValue_3D( hist, idx0, idx1, idx2 )
-        ((float*)(cvPtr3D( (hist)->bins, (idx0), (idx1), (idx2), 0 )))
-    #define cvGetHistValue_nD( hist, idx )
-        ((float*)(cvPtrND( (hist)->bins, (idx), 0 )))
-
-..
-
-The macros ``GetHistValue`` return a pointer to the specified bin of the 1D, 2D, 3D, or N-D histogram. In case of a sparse histogram, the function creates a new bin and sets it to 0, unless it exists already.
diff --git a/modules/legacy/doc/legacy.rst b/modules/legacy/doc/legacy.rst
deleted file mode 100644 (file)
index d2eac06..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-********************************
-legacy. Deprecated stuff
-********************************
-
-.. highlight:: cpp
-
-.. toctree::
-    :maxdepth: 2
-
-    motion_analysis
-    expectation_maximization
-    histograms
-    planar_subdivisions
-    feature_detection_and_description
-    common_interfaces_of_descriptor_extractors
-    common_interfaces_of_generic_descriptor_matchers
diff --git a/modules/legacy/doc/motion_analysis.rst b/modules/legacy/doc/motion_analysis.rst
deleted file mode 100644 (file)
index 8c046bf..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-Motion Analysis
-===============
-
-.. highlight:: cpp
-
-
-CalcOpticalFlowBM
------------------
-Calculates the optical flow for two images by using the block matching method.
-
-.. ocv:cfunction:: void cvCalcOpticalFlowBM( const CvArr* prev, const CvArr* curr, CvSize block_size, CvSize shift_size, CvSize max_range, int use_previous, CvArr* velx, CvArr* vely )
-
-        :param prev: First image, 8-bit, single-channel
-
-        :param curr: Second image, 8-bit, single-channel
-
-        :param block_size: Size of basic blocks that are compared
-
-        :param shift_size: Block coordinate increments
-
-        :param max_range: Size of the scanned neighborhood in pixels around the block
-
-        :param use_previous: Flag that specifies whether to use the input velocity as initial approximations or not.
-
-        :param velx: Horizontal component of the optical flow of
-
-            .. math::
-
-                \left \lfloor   \frac{\texttt{prev->width} - \texttt{block\_size.width}}{\texttt{shift\_size.width}}   \right \rfloor \times \left \lfloor   \frac{\texttt{prev->height} - \texttt{block\_size.height}}{\texttt{shift\_size.height}}   \right \rfloor
-
-            size, 32-bit floating-point, single-channel
-
-        :param vely: Vertical component of the optical flow of the same size  ``velx`` , 32-bit floating-point, single-channel
-
-
-The function calculates the optical flow for overlapped blocks ``block_size.width x block_size.height`` pixels each, thus the velocity fields are smaller than the original images. For every block in  ``prev``
-the functions tries to find a similar block in ``curr`` in some neighborhood of the original block or shifted by ``(velx(x0,y0), vely(x0,y0))`` block as has been calculated by previous function call (if ``use_previous=1``)
-
-
-CalcOpticalFlowHS
------------------
-Calculates the optical flow for two images using Horn-Schunck algorithm.
-
-.. ocv:cfunction:: void cvCalcOpticalFlowHS(const CvArr* prev, const CvArr* curr, int use_previous, CvArr* velx, CvArr* vely, double lambda, CvTermCriteria criteria)
-
-    :param prev: First image, 8-bit, single-channel
-
-    :param curr: Second image, 8-bit, single-channel
-
-    :param use_previous: Flag that specifies whether to use the input velocity as initial approximations or not.
-
-    :param velx: Horizontal component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
-
-    :param vely: Vertical component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
-
-    :param lambda: Smoothness weight. The larger it is, the smoother optical flow map you get.
-
-    :param criteria: Criteria of termination of velocity computing
-
-The function computes the flow for every pixel of the first input image using the Horn and Schunck algorithm [Horn81]_. The function is obsolete. To track sparse features, use :ocv:func:`calcOpticalFlowPyrLK`. To track all the pixels, use :ocv:func:`calcOpticalFlowFarneback`.
-
-
-CalcOpticalFlowLK
------------------
-
-Calculates the optical flow for two images using Lucas-Kanade algorithm.
-
-.. ocv:cfunction:: void cvCalcOpticalFlowLK( const CvArr* prev, const CvArr* curr, CvSize win_size, CvArr* velx, CvArr* vely )
-
-    :param prev: First image, 8-bit, single-channel
-
-    :param curr: Second image, 8-bit, single-channel
-
-    :param win_size: Size of the averaging window used for grouping pixels
-
-    :param velx: Horizontal component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
-
-    :param vely: Vertical component of the optical flow of the same size as input images, 32-bit floating-point, single-channel
-
-The function computes the flow for every pixel of the first input image using the Lucas and Kanade algorithm [Lucas81]_. The function is obsolete. To track sparse features, use :ocv:func:`calcOpticalFlowPyrLK`. To track all the pixels, use :ocv:func:`calcOpticalFlowFarneback`.
diff --git a/modules/legacy/doc/pics/quadedge.png b/modules/legacy/doc/pics/quadedge.png
deleted file mode 100644 (file)
index 2fc6c2b..0000000
Binary files a/modules/legacy/doc/pics/quadedge.png and /dev/null differ
diff --git a/modules/legacy/doc/pics/subdiv.png b/modules/legacy/doc/pics/subdiv.png
deleted file mode 100644 (file)
index 21026e5..0000000
Binary files a/modules/legacy/doc/pics/subdiv.png and /dev/null differ
diff --git a/modules/legacy/doc/planar_subdivisions.rst b/modules/legacy/doc/planar_subdivisions.rst
deleted file mode 100644 (file)
index f4ce8cb..0000000
+++ /dev/null
@@ -1,314 +0,0 @@
-Planar Subdivisions (C API)
-============================
-
-.. highlight:: c
-
-CvSubdiv2D
-----------
-
-.. ocv:struct:: CvSubdiv2D
-
-Planar subdivision.
-
-::
-
-    #define CV_SUBDIV2D_FIELDS()    \
-        CV_GRAPH_FIELDS()           \
-        int  quad_edges;            \
-        int  is_geometry_valid;     \
-        CvSubdiv2DEdge recent_edge; \
-        CvPoint2D32f  topleft;      \
-        CvPoint2D32f  bottomright;
-
-    typedef struct CvSubdiv2D
-    {
-        CV_SUBDIV2D_FIELDS()
-    }
-    CvSubdiv2D;
-
-..
-
-Planar subdivision is the subdivision of a plane into a set of
-non-overlapped regions (facets) that cover the whole plane. The above
-structure describes a subdivision built on a 2D point set, where the points
-are linked together and form a planar graph, which, together with a few
-edges connecting the exterior subdivision points (namely, convex hull points)
-with infinity, subdivides a plane into facets by its edges.
-
-For every subdivision, there is a dual subdivision in which facets and
-points (subdivision vertices) swap their roles. This means that a facet is
-treated as a vertex (called a virtual point below) of the dual subdivision and
-the original subdivision vertices become facets. In the figure below, the
-original subdivision is marked with solid lines and dual subdivision -
-with dotted lines.
-
-.. image:: pics/subdiv.png
-
-OpenCV subdivides a plane into triangles using the Delaunay's
-algorithm. Subdivision is built iteratively starting from a dummy
-triangle that includes all the subdivision points for sure. In this
-case, the dual subdivision is a Voronoi diagram of the input 2D point set. The
-subdivisions can be used for the 3D piece-wise transformation of a plane,
-morphing, fast location of points on the plane, building special graphs
-(such as NNG,RNG), and so forth.
-
-CvQuadEdge2D
-------------
-
-.. ocv:struct:: CvQuadEdge2D
-
-Quad-edge of a planar subdivision.
-
-::
-
-    /* one of edges within quad-edge, lower 2 bits is index (0..3)
-       and upper bits are quad-edge pointer */
-    typedef long CvSubdiv2DEdge;
-
-    /* quad-edge structure fields */
-    #define CV_QUADEDGE2D_FIELDS()     \
-        int flags;                     \
-        struct CvSubdiv2DPoint* pt[4]; \
-        CvSubdiv2DEdge  next[4];
-
-    typedef struct CvQuadEdge2D
-    {
-        CV_QUADEDGE2D_FIELDS()
-    }
-    CvQuadEdge2D;
-
-..
-
-Quad-edge is a basic element of a subdivision containing four edges (e, eRot, reversed e, and reversed eRot):
-
-.. image:: pics/quadedge.png
-
-CvSubdiv2DPoint
----------------
-
-.. ocv:struct:: CvSubdiv2DPoint
-
-Point of an original or dual subdivision.
-
-::
-
-    #define CV_SUBDIV2D_POINT_FIELDS()\
-        int            flags;      \
-        CvSubdiv2DEdge first;      \
-        CvPoint2D32f   pt;         \
-        int id;
-
-    #define CV_SUBDIV2D_VIRTUAL_POINT_FLAG (1 << 30)
-
-    typedef struct CvSubdiv2DPoint
-    {
-        CV_SUBDIV2D_POINT_FIELDS()
-    }
-    CvSubdiv2DPoint;
-
-..
-
-* id
-    This integer can be used to index auxiliary data associated with each vertex of the planar subdivision.
-
-CalcSubdivVoronoi2D
--------------------
-Calculates the coordinates of the Voronoi diagram cells.
-
-.. ocv:cfunction:: void cvCalcSubdivVoronoi2D(  CvSubdiv2D* subdiv )
-
-    :param subdiv: Delaunay subdivision, in which all the points are already added.
-
-The function calculates the coordinates
-of virtual points. All virtual points corresponding to a vertex of the
-original subdivision form (when connected together) a boundary of the Voronoi
-cell at that point.
-
-ClearSubdivVoronoi2D
---------------------
-Removes all virtual points.
-
-.. ocv:cfunction:: void cvClearSubdivVoronoi2D( CvSubdiv2D* subdiv )
-
-    :param subdiv: Delaunay subdivision.
-
-The function removes all of the virtual points. It
-is called internally in
-:ocv:cfunc:`CalcSubdivVoronoi2D`
-if the subdivision
-was modified after the previous call to the function.
-
-CreateSubdivDelaunay2D
-----------------------
-Creates an empty Delaunay triangulation.
-
-.. ocv:cfunction:: CvSubdiv2D* cvCreateSubdivDelaunay2D(  CvRect rect, CvMemStorage* storage )
-
-    :param rect: Rectangle that includes all of the 2D points that are to be added to the subdivision.
-
-    :param storage: Container for the subdivision.
-
-The function creates an empty Delaunay
-subdivision where 2D points can be added using the function
-:ocv:cfunc:`SubdivDelaunay2DInsert`
-. All of the points to be added must be within
-the specified rectangle, otherwise a runtime error is raised.
-
-Note that the triangulation is a single large triangle that covers the given rectangle.  Hence the three vertices of this triangle are outside the rectangle
-``rect``
-.
-
-FindNearestPoint2D
-------------------
-Finds the subdivision vertex closest to the given point.
-
-.. ocv:cfunction:: CvSubdiv2DPoint* cvFindNearestPoint2D(  CvSubdiv2D* subdiv, CvPoint2D32f pt )
-
-    :param subdiv: Delaunay or another subdivision.
-
-    :param pt: Input point.
-
-The function is another function that
-locates the input point within the subdivision. It finds the subdivision vertex that
-is the closest to the input point. It is not necessarily one of vertices
-of the facet containing the input point, though the facet (located using
-:ocv:cfunc:`Subdiv2DLocate`
-) is used as a starting
-point. The function returns a pointer to the found subdivision vertex.
-
-Subdiv2DEdgeDst
----------------
-Returns the edge destination.
-
-.. ocv:cfunction:: CvSubdiv2DPoint* cvSubdiv2DEdgeDst(  CvSubdiv2DEdge edge )
-
-    :param edge: Subdivision edge (not a quad-edge).
-
-The function returns the edge destination. The
-returned pointer may be NULL if the edge is from a dual subdivision and
-the virtual point coordinates are not calculated yet. The virtual points
-can be calculated using the function
-:ocv:cfunc:`CalcSubdivVoronoi2D`.
-
-Subdiv2DGetEdge
----------------
-Returns one of the edges related to the given edge.
-
-.. ocv:cfunction:: CvSubdiv2DEdge  cvSubdiv2DGetEdge( CvSubdiv2DEdge edge, CvNextEdgeType type )
-
-    :param edge: Subdivision edge (not a quad-edge).
-
-    :param type: Parameter specifying which of the related edges to return. The following values are possible:
-
-        * **CV_NEXT_AROUND_ORG** next around the edge origin ( ``eOnext``  on the picture below if  ``e``  is the input edge)
-
-        * **CV_NEXT_AROUND_DST** next around the edge vertex ( ``eDnext`` )
-
-        * **CV_PREV_AROUND_ORG** previous around the edge origin (reversed  ``eRnext`` )
-
-        * **CV_PREV_AROUND_DST** previous around the edge destination (reversed  ``eLnext`` )
-
-        * **CV_NEXT_AROUND_LEFT** next around the left facet ( ``eLnext`` )
-
-        * **CV_NEXT_AROUND_RIGHT** next around the right facet ( ``eRnext`` )
-
-        * **CV_PREV_AROUND_LEFT** previous around the left facet (reversed  ``eOnext`` )
-
-        * **CV_PREV_AROUND_RIGHT** previous around the right facet (reversed  ``eDnext`` )
-
-.. image:: pics/quadedge.png
-
-The function returns one of the edges related to the input edge.
-
-Subdiv2DNextEdge
-----------------
-Returns next edge around the edge origin.
-
-.. ocv:cfunction:: CvSubdiv2DEdge  cvSubdiv2DNextEdge( CvSubdiv2DEdge edge )
-
-    :param edge: Subdivision edge (not a quad-edge).
-
-The function returns the next edge around the edge origin:
-``eOnext``
-on the picture above if
-``e``
-is the input edge).
-
-Subdiv2DLocate
---------------
-Returns the location of a point within a Delaunay triangulation.
-
-.. ocv:cfunction:: CvSubdiv2DPointLocation  cvSubdiv2DLocate(  CvSubdiv2D* subdiv, CvPoint2D32f pt, CvSubdiv2DEdge* edge, CvSubdiv2DPoint** vertex=NULL )
-
-    :param subdiv: Delaunay or another subdivision.
-
-    :param pt: Point to locate.
-
-    :param edge: Output edge that the point belongs to or is located to the right of it.
-
-    :param vertex: Optional output vertex double pointer the input point coincides with.
-
-The function locates the input point within the subdivision. There are five cases:
-
-*
-    The point falls into some facet. The function returns
-    ``CV_PTLOC_INSIDE``
-    and
-    ``*edge``
-    will contain one of edges of the facet.
-
-*
-    The point falls onto the edge. The function returns
-    ``CV_PTLOC_ON_EDGE``
-    and
-    ``*edge``
-    will contain this edge.
-
-*
-    The point coincides with one of the subdivision vertices. The function returns
-    ``CV_PTLOC_VERTEX``
-    and
-    ``*vertex``
-    will contain a pointer to the vertex.
-
-*
-    The point is outside the subdivision reference rectangle. The function returns
-    ``CV_PTLOC_OUTSIDE_RECT``
-    and no pointers are filled.
-
-*
-    One of input arguments is invalid. A runtime error is raised or, if silent or "parent" error processing mode is selected,
-    ``CV_PTLOC_ERROR``
-    is returnd.
-
-Subdiv2DRotateEdge
-------------------
-Returns another edge of the same quad-edge.
-
-.. ocv:cfunction:: CvSubdiv2DEdge  cvSubdiv2DRotateEdge(  CvSubdiv2DEdge edge, int rotate )
-
-    :param edge: Subdivision edge (not a quad-edge).
-
-    :param rotate: Parameter specifying which of the edges of the same quad-edge as the input one to return. The following values are possible:
-
-            * **0** the input edge ( ``e``  on the picture below if  ``e``  is the input edge)
-
-            * **1** the rotated edge ( ``eRot`` )
-
-            * **2** the reversed edge (reversed  ``e``  (in green))
-
-            * **3** the reversed rotated edge (reversed  ``eRot``  (in green))
-
-The function returns one of the edges of the same quad-edge as the input edge.
-
-SubdivDelaunay2DInsert
-----------------------
-Inserts a single point into a Delaunay triangulation.
-
-.. ocv:cfunction:: CvSubdiv2DPoint*  cvSubdivDelaunay2DInsert(  CvSubdiv2D* subdiv, CvPoint2D32f pt)
-
-    :param subdiv: Delaunay subdivision created by the function  :ocv:cfunc:`CreateSubdivDelaunay2D`.
-
-    :param pt: Inserted point.
-
-The function inserts a single point into a subdivision and modifies the subdivision topology appropriately. If a point with the same coordinates exists already, no new point is added. The function returns a pointer to the allocated point. No virtual point coordinates are calculated at this stage.
diff --git a/modules/legacy/include/opencv2/legacy.hpp b/modules/legacy/include/opencv2/legacy.hpp
deleted file mode 100644 (file)
index e85bfd2..0000000
+++ /dev/null
@@ -1,3506 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_LEGACY_HPP__
-#define __OPENCV_LEGACY_HPP__
-
-#include "opencv2/imgproc/imgproc_c.h"
-#include "opencv2/calib3d/calib3d_c.h"
-#include "opencv2/ml.hpp"
-
-#ifdef __cplusplus
-#include "opencv2/features2d.hpp"
-extern "C" {
-#endif
-
-CVAPI(CvSeq*) cvSegmentImage( const CvArr* srcarr, CvArr* dstarr,
-                                    double canny_threshold,
-                                    double ffill_threshold,
-                                    CvMemStorage* storage );
-
-/****************************************************************************************\
-*                                  Eigen objects                                         *
-\****************************************************************************************/
-
-typedef int (CV_CDECL * CvCallback)(int index, void* buffer, void* user_data);
-typedef union
-{
-    CvCallback callback;
-    void* data;
-}
-CvInput;
-
-#define CV_EIGOBJ_NO_CALLBACK     0
-#define CV_EIGOBJ_INPUT_CALLBACK  1
-#define CV_EIGOBJ_OUTPUT_CALLBACK 2
-#define CV_EIGOBJ_BOTH_CALLBACK   3
-
-/* Calculates covariation matrix of a set of arrays */
-CVAPI(void)  cvCalcCovarMatrixEx( int nObjects, void* input, int ioFlags,
-                                  int ioBufSize, uchar* buffer, void* userData,
-                                  IplImage* avg, float* covarMatrix );
-
-/* Calculates eigen values and vectors of covariation matrix of a set of
-   arrays */
-CVAPI(void)  cvCalcEigenObjects( int nObjects, void* input, void* output,
-                                 int ioFlags, int ioBufSize, void* userData,
-                                 CvTermCriteria* calcLimit, IplImage* avg,
-                                 float* eigVals );
-
-/* Calculates dot product (obj - avg) * eigObj (i.e. projects image to eigen vector) */
-CVAPI(double)  cvCalcDecompCoeff( IplImage* obj, IplImage* eigObj, IplImage* avg );
-
-/* Projects image to eigen space (finds all decomposion coefficients */
-CVAPI(void)  cvEigenDecomposite( IplImage* obj, int nEigObjs, void* eigInput,
-                                 int ioFlags, void* userData, IplImage* avg,
-                                 float* coeffs );
-
-/* Projects original objects used to calculate eigen space basis to that space */
-CVAPI(void)  cvEigenProjection( void* eigInput, int nEigObjs, int ioFlags,
-                                void* userData, float* coeffs, IplImage* avg,
-                                IplImage* proj );
-
-/****************************************************************************************\
-*                                       1D/2D HMM                                        *
-\****************************************************************************************/
-
-typedef struct CvImgObsInfo
-{
-    int obs_x;
-    int obs_y;
-    int obs_size;
-    float* obs;//consequtive observations
-
-    int* state;/* arr of pairs superstate/state to which observation belong */
-    int* mix;  /* number of mixture to which observation belong */
-
-} CvImgObsInfo;/*struct for 1 image*/
-
-typedef CvImgObsInfo Cv1DObsInfo;
-
-typedef struct CvEHMMState
-{
-    int num_mix;        /*number of mixtures in this state*/
-    float* mu;          /*mean vectors corresponding to each mixture*/
-    float* inv_var;     /* square root of inversed variances corresp. to each mixture*/
-    float* log_var_val; /* sum of 0.5 (LN2PI + ln(variance[i]) ) for i=1,n */
-    float* weight;      /*array of mixture weights. Summ of all weights in state is 1. */
-
-} CvEHMMState;
-
-typedef struct CvEHMM
-{
-    int level; /* 0 - lowest(i.e its states are real states), ..... */
-    int num_states; /* number of HMM states */
-    float*  transP;/*transition probab. matrices for states */
-    float** obsProb; /* if level == 0 - array of brob matrices corresponding to hmm
-                        if level == 1 - martix of matrices */
-    union
-    {
-        CvEHMMState* state; /* if level == 0 points to real states array,
-                               if not - points to embedded hmms */
-        struct CvEHMM* ehmm; /* pointer to an embedded model or NULL, if it is a leaf */
-    } u;
-
-} CvEHMM;
-
-/*CVAPI(int)  icvCreate1DHMM( CvEHMM** this_hmm,
-                                   int state_number, int* num_mix, int obs_size );
-
-CVAPI(int)  icvRelease1DHMM( CvEHMM** phmm );
-
-CVAPI(int)  icvUniform1DSegm( Cv1DObsInfo* obs_info, CvEHMM* hmm );
-
-CVAPI(int)  icvInit1DMixSegm( Cv1DObsInfo** obs_info_array, int num_img, CvEHMM* hmm);
-
-CVAPI(int)  icvEstimate1DHMMStateParams( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm);
-
-CVAPI(int)  icvEstimate1DObsProb( CvImgObsInfo* obs_info, CvEHMM* hmm );
-
-CVAPI(int)  icvEstimate1DTransProb( Cv1DObsInfo** obs_info_array,
-                                           int num_seq,
-                                           CvEHMM* hmm );
-
-CVAPI(float)  icvViterbi( Cv1DObsInfo* obs_info, CvEHMM* hmm);
-
-CVAPI(int)  icv1DMixSegmL2( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm );*/
-
-/*********************************** Embedded HMMs *************************************/
-
-/* Creates 2D HMM */
-CVAPI(CvEHMM*)  cvCreate2DHMM( int* stateNumber, int* numMix, int obsSize );
-
-/* Releases HMM */
-CVAPI(void)  cvRelease2DHMM( CvEHMM** hmm );
-
-#define CV_COUNT_OBS(roi, win, delta, numObs )                                       \
-{                                                                                    \
-   (numObs)->width  =((roi)->width  -(win)->width  +(delta)->width)/(delta)->width;  \
-   (numObs)->height =((roi)->height -(win)->height +(delta)->height)/(delta)->height;\
-}
-
-/* Creates storage for observation vectors */
-CVAPI(CvImgObsInfo*)  cvCreateObsInfo( CvSize numObs, int obsSize );
-
-/* Releases storage for observation vectors */
-CVAPI(void)  cvReleaseObsInfo( CvImgObsInfo** obs_info );
-
-
-/* The function takes an image on input and and returns the sequnce of observations
-   to be used with an embedded HMM; Each observation is top-left block of DCT
-   coefficient matrix */
-CVAPI(void)  cvImgToObs_DCT( const CvArr* arr, float* obs, CvSize dctSize,
-                             CvSize obsSize, CvSize delta );
-
-
-/* Uniformly segments all observation vectors extracted from image */
-CVAPI(void)  cvUniformImgSegm( CvImgObsInfo* obs_info, CvEHMM* ehmm );
-
-/* Does mixture segmentation of the states of embedded HMM */
-CVAPI(void)  cvInitMixSegm( CvImgObsInfo** obs_info_array,
-                            int num_img, CvEHMM* hmm );
-
-/* Function calculates means, variances, weights of every Gaussian mixture
-   of every low-level state of embedded HMM */
-CVAPI(void)  cvEstimateHMMStateParams( CvImgObsInfo** obs_info_array,
-                                       int num_img, CvEHMM* hmm );
-
-/* Function computes transition probability matrices of embedded HMM
-   given observations segmentation */
-CVAPI(void)  cvEstimateTransProb( CvImgObsInfo** obs_info_array,
-                                  int num_img, CvEHMM* hmm );
-
-/* Function computes probabilities of appearing observations at any state
-   (i.e. computes P(obs|state) for every pair(obs,state)) */
-CVAPI(void)  cvEstimateObsProb( CvImgObsInfo* obs_info,
-                                CvEHMM* hmm );
-
-/* Runs Viterbi algorithm for embedded HMM */
-CVAPI(float)  cvEViterbi( CvImgObsInfo* obs_info, CvEHMM* hmm );
-
-
-/* Function clusters observation vectors from several images
-   given observations segmentation.
-   Euclidean distance used for clustering vectors.
-   Centers of clusters are given means of every mixture */
-CVAPI(void)  cvMixSegmL2( CvImgObsInfo** obs_info_array,
-                          int num_img, CvEHMM* hmm );
-
-/****************************************************************************************\
-*               A few functions from old stereo gesture recognition demosions            *
-\****************************************************************************************/
-
-/* Creates hand mask image given several points on the hand */
-CVAPI(void)  cvCreateHandMask( CvSeq* hand_points,
-                                   IplImage *img_mask, CvRect *roi);
-
-/* Finds hand region in range image data */
-CVAPI(void)  cvFindHandRegion (CvPoint3D32f* points, int count,
-                                CvSeq* indexs,
-                                float* line, CvSize2D32f size, int flag,
-                                CvPoint3D32f* center,
-                                CvMemStorage* storage, CvSeq **numbers);
-
-/* Finds hand region in range image data (advanced version) */
-CVAPI(void)  cvFindHandRegionA( CvPoint3D32f* points, int count,
-                                CvSeq* indexs,
-                                float* line, CvSize2D32f size, int jc,
-                                CvPoint3D32f* center,
-                                CvMemStorage* storage, CvSeq **numbers);
-
-/* Calculates the cooficients of the homography matrix */
-CVAPI(void)  cvCalcImageHomography( float* line, CvPoint3D32f* center,
-                                    float* intrinsic, float* homography );
-
-/****************************************************************************************\
-*                           More operations on sequences                                 *
-\****************************************************************************************/
-
-/*****************************************************************************************/
-
-#define CV_CURRENT_INT( reader ) (*((int *)(reader).ptr))
-#define CV_PREV_INT( reader ) (*((int *)(reader).prev_elem))
-
-#define  CV_GRAPH_WEIGHTED_VERTEX_FIELDS() CV_GRAPH_VERTEX_FIELDS()\
-    float weight;
-
-#define  CV_GRAPH_WEIGHTED_EDGE_FIELDS() CV_GRAPH_EDGE_FIELDS()
-
-typedef struct CvGraphWeightedVtx
-{
-    CV_GRAPH_WEIGHTED_VERTEX_FIELDS()
-} CvGraphWeightedVtx;
-
-typedef struct CvGraphWeightedEdge
-{
-    CV_GRAPH_WEIGHTED_EDGE_FIELDS()
-} CvGraphWeightedEdge;
-
-typedef enum CvGraphWeightType
-{
-    CV_NOT_WEIGHTED,
-    CV_WEIGHTED_VTX,
-    CV_WEIGHTED_EDGE,
-    CV_WEIGHTED_ALL
-} CvGraphWeightType;
-
-
-/* Calculates histogram of a contour */
-CVAPI(void)  cvCalcPGH( const CvSeq* contour, CvHistogram* hist );
-
-#define CV_DOMINANT_IPAN 1
-
-/* Finds high-curvature points of the contour */
-CVAPI(CvSeq*) cvFindDominantPoints( CvSeq* contour, CvMemStorage* storage,
-                                   int method CV_DEFAULT(CV_DOMINANT_IPAN),
-                                   double parameter1 CV_DEFAULT(0),
-                                   double parameter2 CV_DEFAULT(0),
-                                   double parameter3 CV_DEFAULT(0),
-                                   double parameter4 CV_DEFAULT(0));
-
-/*****************************************************************************************/
-
-
-/*******************************Stereo correspondence*************************************/
-
-typedef struct CvCliqueFinder
-{
-    CvGraph* graph;
-    int**    adj_matr;
-    int N; //graph size
-
-    // stacks, counters etc/
-    int k; //stack size
-    int* current_comp;
-    int** All;
-
-    int* ne;
-    int* ce;
-    int* fixp; //node with minimal disconnections
-    int* nod;
-    int* s; //for selected candidate
-    int status;
-    int best_score;
-    int weighted;
-    int weighted_edges;
-    float best_weight;
-    float* edge_weights;
-    float* vertex_weights;
-    float* cur_weight;
-    float* cand_weight;
-
-} CvCliqueFinder;
-
-#define CLIQUE_TIME_OFF 2
-#define CLIQUE_FOUND 1
-#define CLIQUE_END   0
-
-/*CVAPI(void) cvStartFindCliques( CvGraph* graph, CvCliqueFinder* finder, int reverse,
-                                   int weighted CV_DEFAULT(0),  int weighted_edges CV_DEFAULT(0));
-CVAPI(int) cvFindNextMaximalClique( CvCliqueFinder* finder, int* clock_rest CV_DEFAULT(0) );
-CVAPI(void) cvEndFindCliques( CvCliqueFinder* finder );
-
-CVAPI(void) cvBronKerbosch( CvGraph* graph );*/
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//
-//    Name:    cvSubgraphWeight
-//    Purpose: finds weight of subgraph in a graph
-//    Context:
-//    Parameters:
-//      graph - input graph.
-//      subgraph - sequence of pairwise different ints.  These are indices of vertices of subgraph.
-//      weight_type - describes the way we measure weight.
-//            one of the following:
-//            CV_NOT_WEIGHTED - weight of a clique is simply its size
-//            CV_WEIGHTED_VTX - weight of a clique is the sum of weights of its vertices
-//            CV_WEIGHTED_EDGE - the same but edges
-//            CV_WEIGHTED_ALL - the same but both edges and vertices
-//      weight_vtx - optional vector of floats, with size = graph->total.
-//            If weight_type is either CV_WEIGHTED_VTX or CV_WEIGHTED_ALL
-//            weights of vertices must be provided.  If weight_vtx not zero
-//            these weights considered to be here, otherwise function assumes
-//            that vertices of graph are inherited from CvGraphWeightedVtx.
-//      weight_edge - optional matrix of floats, of width and height = graph->total.
-//            If weight_type is either CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL
-//            weights of edges ought to be supplied.  If weight_edge is not zero
-//            function finds them here, otherwise function expects
-//            edges of graph to be inherited from CvGraphWeightedEdge.
-//            If this parameter is not zero structure of the graph is determined from matrix
-//            rather than from CvGraphEdge's.  In particular, elements corresponding to
-//            absent edges should be zero.
-//    Returns:
-//      weight of subgraph.
-//    Notes:
-//F*/
-/*CVAPI(float) cvSubgraphWeight( CvGraph *graph, CvSeq *subgraph,
-                                  CvGraphWeightType weight_type CV_DEFAULT(CV_NOT_WEIGHTED),
-                                  CvVect32f weight_vtx CV_DEFAULT(0),
-                                  CvMatr32f weight_edge CV_DEFAULT(0) );*/
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//
-//    Name:    cvFindCliqueEx
-//    Purpose: tries to find clique with maximum possible weight in a graph
-//    Context:
-//    Parameters:
-//      graph - input graph.
-//      storage - memory storage to be used by the result.
-//      is_complementary - optional flag showing whether function should seek for clique
-//            in complementary graph.
-//      weight_type - describes our notion about weight.
-//            one of the following:
-//            CV_NOT_WEIGHTED - weight of a clique is simply its size
-//            CV_WEIGHTED_VTX - weight of a clique is the sum of weights of its vertices
-//            CV_WEIGHTED_EDGE - the same but edges
-//            CV_WEIGHTED_ALL - the same but both edges and vertices
-//      weight_vtx - optional vector of floats, with size = graph->total.
-//            If weight_type is either CV_WEIGHTED_VTX or CV_WEIGHTED_ALL
-//            weights of vertices must be provided.  If weight_vtx not zero
-//            these weights considered to be here, otherwise function assumes
-//            that vertices of graph are inherited from CvGraphWeightedVtx.
-//      weight_edge - optional matrix of floats, of width and height = graph->total.
-//            If weight_type is either CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL
-//            weights of edges ought to be supplied.  If weight_edge is not zero
-//            function finds them here, otherwise function expects
-//            edges of graph to be inherited from CvGraphWeightedEdge.
-//            Note that in case of CV_WEIGHTED_EDGE or CV_WEIGHTED_ALL
-//            nonzero is_complementary implies nonzero weight_edge.
-//      start_clique - optional sequence of pairwise different ints.  They are indices of
-//            vertices that shall be present in the output clique.
-//      subgraph_of_ban - optional sequence of (maybe equal) ints.  They are indices of
-//            vertices that shall not be present in the output clique.
-//      clique_weight_ptr - optional output parameter.  Weight of found clique stored here.
-//      num_generations - optional number of generations in evolutionary part of algorithm,
-//            zero forces to return first found clique.
-//      quality - optional parameter determining degree of required quality/speed tradeoff.
-//            Must be in the range from 0 to 9.
-//            0 is fast and dirty, 9 is slow but hopefully yields good clique.
-//    Returns:
-//      sequence of pairwise different ints.
-//      These are indices of vertices that form found clique.
-//    Notes:
-//      in cases of CV_WEIGHTED_EDGE and CV_WEIGHTED_ALL weights should be nonnegative.
-//      start_clique has a priority over subgraph_of_ban.
-//F*/
-/*CVAPI(CvSeq*) cvFindCliqueEx( CvGraph *graph, CvMemStorage *storage,
-                                 int is_complementary CV_DEFAULT(0),
-                                 CvGraphWeightType weight_type CV_DEFAULT(CV_NOT_WEIGHTED),
-                                 CvVect32f weight_vtx CV_DEFAULT(0),
-                                 CvMatr32f weight_edge CV_DEFAULT(0),
-                                 CvSeq *start_clique CV_DEFAULT(0),
-                                 CvSeq *subgraph_of_ban CV_DEFAULT(0),
-                                 float *clique_weight_ptr CV_DEFAULT(0),
-                                 int num_generations CV_DEFAULT(3),
-                                 int quality CV_DEFAULT(2) );*/
-
-
-#define CV_UNDEF_SC_PARAM         12345 //default value of parameters
-
-#define CV_IDP_BIRCHFIELD_PARAM1  25
-#define CV_IDP_BIRCHFIELD_PARAM2  5
-#define CV_IDP_BIRCHFIELD_PARAM3  12
-#define CV_IDP_BIRCHFIELD_PARAM4  15
-#define CV_IDP_BIRCHFIELD_PARAM5  25
-
-
-#define  CV_DISPARITY_BIRCHFIELD  0
-
-
-/*F///////////////////////////////////////////////////////////////////////////
-//
-//    Name:    cvFindStereoCorrespondence
-//    Purpose: find stereo correspondence on stereo-pair
-//    Context:
-//    Parameters:
-//      leftImage - left image of stereo-pair (format 8uC1).
-//      rightImage - right image of stereo-pair (format 8uC1).
-//   mode - mode of correspondence retrieval (now CV_DISPARITY_BIRCHFIELD only)
-//      dispImage - destination disparity image
-//      maxDisparity - maximal disparity
-//      param1, param2, param3, param4, param5 - parameters of algorithm
-//    Returns:
-//    Notes:
-//      Images must be rectified.
-//      All images must have format 8uC1.
-//F*/
-CVAPI(void)
-cvFindStereoCorrespondence(
-                   const  CvArr* leftImage, const  CvArr* rightImage,
-                   int     mode,
-                   CvArr*  dispImage,
-                   int     maxDisparity,
-                   double  param1 CV_DEFAULT(CV_UNDEF_SC_PARAM),
-                   double  param2 CV_DEFAULT(CV_UNDEF_SC_PARAM),
-                   double  param3 CV_DEFAULT(CV_UNDEF_SC_PARAM),
-                   double  param4 CV_DEFAULT(CV_UNDEF_SC_PARAM),
-                   double  param5 CV_DEFAULT(CV_UNDEF_SC_PARAM) );
-
-/*****************************************************************************************/
-/************ Epiline functions *******************/
-
-
-
-typedef struct CvStereoLineCoeff
-{
-    double Xcoef;
-    double XcoefA;
-    double XcoefB;
-    double XcoefAB;
-
-    double Ycoef;
-    double YcoefA;
-    double YcoefB;
-    double YcoefAB;
-
-    double Zcoef;
-    double ZcoefA;
-    double ZcoefB;
-    double ZcoefAB;
-}CvStereoLineCoeff;
-
-
-typedef struct CvCamera
-{
-    float   imgSize[2]; /* size of the camera view, used during calibration */
-    float   matrix[9]; /* intinsic camera parameters:  [ fx 0 cx; 0 fy cy; 0 0 1 ] */
-    float   distortion[4]; /* distortion coefficients - two coefficients for radial distortion
-                              and another two for tangential: [ k1 k2 p1 p2 ] */
-    float   rotMatr[9];
-    float   transVect[3]; /* rotation matrix and transition vector relatively
-                             to some reference point in the space. */
-} CvCamera;
-
-typedef struct CvStereoCamera
-{
-    CvCamera* camera[2]; /* two individual camera parameters */
-    float fundMatr[9]; /* fundamental matrix */
-
-    /* New part for stereo */
-    CvPoint3D32f epipole[2];
-    CvPoint2D32f quad[2][4]; /* coordinates of destination quadrangle after
-                                epipolar geometry rectification */
-    double coeffs[2][3][3];/* coefficients for transformation */
-    CvPoint2D32f border[2][4];
-    CvSize warpSize;
-    CvStereoLineCoeff* lineCoeffs;
-    int needSwapCameras;/* flag set to 1 if need to swap cameras for good reconstruction */
-    float rotMatrix[9];
-    float transVector[3];
-} CvStereoCamera;
-
-
-typedef struct CvContourOrientation
-{
-    float egvals[2];
-    float egvects[4];
-
-    float max, min; // minimum and maximum projections
-    int imax, imin;
-} CvContourOrientation;
-
-#define CV_CAMERA_TO_WARP 1
-#define CV_WARP_TO_CAMERA 2
-
-CVAPI(int) icvConvertWarpCoordinates(double coeffs[3][3],
-                                CvPoint2D32f* cameraPoint,
-                                CvPoint2D32f* warpPoint,
-                                int direction);
-
-CVAPI(int) icvGetSymPoint3D(  CvPoint3D64f pointCorner,
-                            CvPoint3D64f point1,
-                            CvPoint3D64f point2,
-                            CvPoint3D64f *pointSym2);
-
-CVAPI(void) icvGetPieceLength3D(CvPoint3D64f point1,CvPoint3D64f point2,double* dist);
-
-CVAPI(int) icvCompute3DPoint(    double alpha,double betta,
-                            CvStereoLineCoeff* coeffs,
-                            CvPoint3D64f* point);
-
-CVAPI(int) icvCreateConvertMatrVect( double*     rotMatr1,
-                                double*     transVect1,
-                                double*     rotMatr2,
-                                double*     transVect2,
-                                double*     convRotMatr,
-                                double*     convTransVect);
-
-CVAPI(int) icvConvertPointSystem(CvPoint3D64f  M2,
-                            CvPoint3D64f* M1,
-                            double*     rotMatr,
-                            double*     transVect
-                            );
-
-CVAPI(int) icvComputeCoeffForStereo(  CvStereoCamera* stereoCamera);
-
-CVAPI(int) icvGetCrossPieceVector(CvPoint2D32f p1_start,CvPoint2D32f p1_end,CvPoint2D32f v2_start,CvPoint2D32f v2_end,CvPoint2D32f *cross);
-CVAPI(int) icvGetCrossLineDirect(CvPoint2D32f p1,CvPoint2D32f p2,float a,float b,float c,CvPoint2D32f* cross);
-CVAPI(float) icvDefinePointPosition(CvPoint2D32f point1,CvPoint2D32f point2,CvPoint2D32f point);
-CVAPI(int) icvStereoCalibration( int numImages,
-                            int* nums,
-                            CvSize imageSize,
-                            CvPoint2D32f* imagePoints1,
-                            CvPoint2D32f* imagePoints2,
-                            CvPoint3D32f* objectPoints,
-                            CvStereoCamera* stereoparams
-                           );
-
-
-CVAPI(int) icvComputeRestStereoParams(CvStereoCamera *stereoparams);
-
-CVAPI(void) cvComputePerspectiveMap( const double coeffs[3][3], CvArr* rectMapX, CvArr* rectMapY );
-
-CVAPI(int) icvComCoeffForLine(   CvPoint2D64f point1,
-                            CvPoint2D64f point2,
-                            CvPoint2D64f point3,
-                            CvPoint2D64f point4,
-                            double*    camMatr1,
-                            double*    rotMatr1,
-                            double*    transVect1,
-                            double*    camMatr2,
-                            double*    rotMatr2,
-                            double*    transVect2,
-                            CvStereoLineCoeff*    coeffs,
-                            int* needSwapCameras);
-
-CVAPI(int) icvGetDirectionForPoint(  CvPoint2D64f point,
-                                double* camMatr,
-                                CvPoint3D64f* direct);
-
-CVAPI(int) icvGetCrossLines(CvPoint3D64f point11,CvPoint3D64f point12,
-                       CvPoint3D64f point21,CvPoint3D64f point22,
-                       CvPoint3D64f* midPoint);
-
-CVAPI(int) icvComputeStereoLineCoeffs(   CvPoint3D64f pointA,
-                                    CvPoint3D64f pointB,
-                                    CvPoint3D64f pointCam1,
-                                    double gamma,
-                                    CvStereoLineCoeff*    coeffs);
-
-/*CVAPI(int) icvComputeFundMatrEpipoles ( double* camMatr1,
-                                    double*     rotMatr1,
-                                    double*     transVect1,
-                                    double*     camMatr2,
-                                    double*     rotMatr2,
-                                    double*     transVect2,
-                                    CvPoint2D64f* epipole1,
-                                    CvPoint2D64f* epipole2,
-                                    double*     fundMatr);*/
-
-CVAPI(int) icvGetAngleLine( CvPoint2D64f startPoint, CvSize imageSize,CvPoint2D64f *point1,CvPoint2D64f *point2);
-
-CVAPI(void) icvGetCoefForPiece(   CvPoint2D64f p_start,CvPoint2D64f p_end,
-                        double *a,double *b,double *c,
-                        int* result);
-
-/*CVAPI(void) icvGetCommonArea( CvSize imageSize,
-                    CvPoint2D64f epipole1,CvPoint2D64f epipole2,
-                    double* fundMatr,
-                    double* coeff11,double* coeff12,
-                    double* coeff21,double* coeff22,
-                    int* result);*/
-
-CVAPI(void) icvComputeeInfiniteProject1(double*    rotMatr,
-                                     double*    camMatr1,
-                                     double*    camMatr2,
-                                     CvPoint2D32f point1,
-                                     CvPoint2D32f *point2);
-
-CVAPI(void) icvComputeeInfiniteProject2(double*    rotMatr,
-                                     double*    camMatr1,
-                                     double*    camMatr2,
-                                     CvPoint2D32f* point1,
-                                     CvPoint2D32f point2);
-
-CVAPI(void) icvGetCrossDirectDirect(  double* direct1,double* direct2,
-                            CvPoint2D64f *cross,int* result);
-
-CVAPI(void) icvGetCrossPieceDirect(   CvPoint2D64f p_start,CvPoint2D64f p_end,
-                            double a,double b,double c,
-                            CvPoint2D64f *cross,int* result);
-
-CVAPI(void) icvGetCrossPiecePiece( CvPoint2D64f p1_start,CvPoint2D64f p1_end,
-                            CvPoint2D64f p2_start,CvPoint2D64f p2_end,
-                            CvPoint2D64f* cross,
-                            int* result);
-
-CVAPI(void) icvGetPieceLength(CvPoint2D64f point1,CvPoint2D64f point2,double* dist);
-
-CVAPI(void) icvGetCrossRectDirect(    CvSize imageSize,
-                            double a,double b,double c,
-                            CvPoint2D64f *start,CvPoint2D64f *end,
-                            int* result);
-
-CVAPI(void) icvProjectPointToImage(   CvPoint3D64f point,
-                            double* camMatr,double* rotMatr,double* transVect,
-                            CvPoint2D64f* projPoint);
-
-CVAPI(void) icvGetQuadsTransform( CvSize        imageSize,
-                        double*     camMatr1,
-                        double*     rotMatr1,
-                        double*     transVect1,
-                        double*     camMatr2,
-                        double*     rotMatr2,
-                        double*     transVect2,
-                        CvSize*       warpSize,
-                        double quad1[4][2],
-                        double quad2[4][2],
-                        double*     fundMatr,
-                        CvPoint3D64f* epipole1,
-                        CvPoint3D64f* epipole2
-                        );
-
-CVAPI(void) icvGetQuadsTransformStruct(  CvStereoCamera* stereoCamera);
-
-CVAPI(void) icvComputeStereoParamsForCameras(CvStereoCamera* stereoCamera);
-
-CVAPI(void) icvGetCutPiece(   double* areaLineCoef1,double* areaLineCoef2,
-                    CvPoint2D64f epipole,
-                    CvSize imageSize,
-                    CvPoint2D64f* point11,CvPoint2D64f* point12,
-                    CvPoint2D64f* point21,CvPoint2D64f* point22,
-                    int* result);
-
-CVAPI(void) icvGetMiddleAnglePoint(   CvPoint2D64f basePoint,
-                            CvPoint2D64f point1,CvPoint2D64f point2,
-                            CvPoint2D64f* midPoint);
-
-CVAPI(void) icvGetNormalDirect(double* direct,CvPoint2D64f point,double* normDirect);
-
-CVAPI(double) icvGetVect(CvPoint2D64f basePoint,CvPoint2D64f point1,CvPoint2D64f point2);
-
-CVAPI(void) icvProjectPointToDirect(  CvPoint2D64f point,double* lineCoeff,
-                            CvPoint2D64f* projectPoint);
-
-CVAPI(void) icvGetDistanceFromPointToDirect( CvPoint2D64f point,double* lineCoef,double*dist);
-
-CVAPI(IplImage*) icvCreateIsometricImage( IplImage* src, IplImage* dst,
-                              int desired_depth, int desired_num_channels );
-
-CVAPI(void) cvDeInterlace( const CvArr* frame, CvArr* fieldEven, CvArr* fieldOdd );
-
-/*CVAPI(int) icvSelectBestRt(           int           numImages,
-                                    int*          numPoints,
-                                    CvSize        imageSize,
-                                    CvPoint2D32f* imagePoints1,
-                                    CvPoint2D32f* imagePoints2,
-                                    CvPoint3D32f* objectPoints,
-
-                                    CvMatr32f     cameraMatrix1,
-                                    CvVect32f     distortion1,
-                                    CvMatr32f     rotMatrs1,
-                                    CvVect32f     transVects1,
-
-                                    CvMatr32f     cameraMatrix2,
-                                    CvVect32f     distortion2,
-                                    CvMatr32f     rotMatrs2,
-                                    CvVect32f     transVects2,
-
-                                    CvMatr32f     bestRotMatr,
-                                    CvVect32f     bestTransVect
-                                    );*/
-
-
-/****************************************************************************************\
-*                                     Contour Tree                                       *
-\****************************************************************************************/
-
-/* Contour tree header */
-typedef struct CvContourTree
-{
-    CV_SEQUENCE_FIELDS()
-    CvPoint p1;            /* the first point of the binary tree root segment */
-    CvPoint p2;            /* the last point of the binary tree root segment */
-} CvContourTree;
-
-/* Builds hierarhical representation of a contour */
-CVAPI(CvContourTree*)  cvCreateContourTree( const CvSeq* contour,
-                                            CvMemStorage* storage,
-                                            double threshold );
-
-/* Reconstruct (completelly or partially) contour a from contour tree */
-CVAPI(CvSeq*)  cvContourFromContourTree( const CvContourTree* tree,
-                                         CvMemStorage* storage,
-                                         CvTermCriteria criteria );
-
-/* Compares two contour trees */
-enum { CV_CONTOUR_TREES_MATCH_I1 = 1 };
-
-CVAPI(double)  cvMatchContourTrees( const CvContourTree* tree1,
-                                    const CvContourTree* tree2,
-                                    int method, double threshold );
-
-/****************************************************************************************\
-*                                   Contour Morphing                                     *
-\****************************************************************************************/
-
-/* finds correspondence between two contours */
-CvSeq* cvCalcContoursCorrespondence( const CvSeq* contour1,
-                                     const CvSeq* contour2,
-                                     CvMemStorage* storage);
-
-/* morphs contours using the pre-calculated correspondence:
-   alpha=0 ~ contour1, alpha=1 ~ contour2 */
-CvSeq* cvMorphContours( const CvSeq* contour1, const CvSeq* contour2,
-                        CvSeq* corr, double alpha,
-                        CvMemStorage* storage );
-
-
-/****************************************************************************************\
-*                                   Active Contours                                      *
-\****************************************************************************************/
-
-#define  CV_VALUE  1
-#define  CV_ARRAY  2
-/* Updates active contour in order to minimize its cummulative
-   (internal and external) energy. */
-CVAPI(void)  cvSnakeImage( const IplImage* image, CvPoint* points,
-                           int  length, float* alpha,
-                           float* beta, float* gamma,
-                           int coeff_usage, CvSize  win,
-                           CvTermCriteria criteria, int calc_gradient CV_DEFAULT(1));
-
-/****************************************************************************************\
-*                                    Texture Descriptors                                 *
-\****************************************************************************************/
-
-#define CV_GLCM_OPTIMIZATION_NONE                   -2
-#define CV_GLCM_OPTIMIZATION_LUT                    -1
-#define CV_GLCM_OPTIMIZATION_HISTOGRAM              0
-
-#define CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST    10
-#define CV_GLCMDESC_OPTIMIZATION_ALLOWTRIPLENEST    11
-#define CV_GLCMDESC_OPTIMIZATION_HISTOGRAM          4
-
-#define CV_GLCMDESC_ENTROPY                         0
-#define CV_GLCMDESC_ENERGY                          1
-#define CV_GLCMDESC_HOMOGENITY                      2
-#define CV_GLCMDESC_CONTRAST                        3
-#define CV_GLCMDESC_CLUSTERTENDENCY                 4
-#define CV_GLCMDESC_CLUSTERSHADE                    5
-#define CV_GLCMDESC_CORRELATION                     6
-#define CV_GLCMDESC_CORRELATIONINFO1                7
-#define CV_GLCMDESC_CORRELATIONINFO2                8
-#define CV_GLCMDESC_MAXIMUMPROBABILITY              9
-
-#define CV_GLCM_ALL                                 0
-#define CV_GLCM_GLCM                                1
-#define CV_GLCM_DESC                                2
-
-typedef struct CvGLCM CvGLCM;
-
-CVAPI(CvGLCM*) cvCreateGLCM( const IplImage* srcImage,
-                                int stepMagnitude,
-                                const int* stepDirections CV_DEFAULT(0),
-                                int numStepDirections CV_DEFAULT(0),
-                                int optimizationType CV_DEFAULT(CV_GLCM_OPTIMIZATION_NONE));
-
-CVAPI(void) cvReleaseGLCM( CvGLCM** GLCM, int flag CV_DEFAULT(CV_GLCM_ALL));
-
-CVAPI(void) cvCreateGLCMDescriptors( CvGLCM* destGLCM,
-                                        int descriptorOptimizationType
-                                        CV_DEFAULT(CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST));
-
-CVAPI(double) cvGetGLCMDescriptor( CvGLCM* GLCM, int step, int descriptor );
-
-CVAPI(void) cvGetGLCMDescriptorStatistics( CvGLCM* GLCM, int descriptor,
-                                              double* average, double* standardDeviation );
-
-CVAPI(IplImage*) cvCreateGLCMImage( CvGLCM* GLCM, int step );
-
-/****************************************************************************************\
-*                                  Face eyes&mouth tracking                              *
-\****************************************************************************************/
-
-
-typedef struct CvFaceTracker CvFaceTracker;
-
-#define CV_NUM_FACE_ELEMENTS    3
-enum CV_FACE_ELEMENTS
-{
-    CV_FACE_MOUTH = 0,
-    CV_FACE_LEFT_EYE = 1,
-    CV_FACE_RIGHT_EYE = 2
-};
-
-CVAPI(CvFaceTracker*) cvInitFaceTracker(CvFaceTracker* pFaceTracking, const IplImage* imgGray,
-                                                CvRect* pRects, int nRects);
-CVAPI(int) cvTrackFace( CvFaceTracker* pFaceTracker, IplImage* imgGray,
-                              CvRect* pRects, int nRects,
-                              CvPoint* ptRotate, double* dbAngleRotate);
-CVAPI(void) cvReleaseFaceTracker(CvFaceTracker** ppFaceTracker);
-
-
-typedef struct CvFace
-{
-    CvRect MouthRect;
-    CvRect LeftEyeRect;
-    CvRect RightEyeRect;
-} CvFaceData;
-
-CvSeq * cvFindFace(IplImage * Image,CvMemStorage* storage);
-CvSeq * cvPostBoostingFindFace(IplImage * Image,CvMemStorage* storage);
-
-
-/****************************************************************************************\
-*                                         3D Tracker                                     *
-\****************************************************************************************/
-
-typedef unsigned char CvBool;
-
-typedef struct Cv3dTracker2dTrackedObject
-{
-    int id;
-    CvPoint2D32f p; // pgruebele: So we do not loose precision, this needs to be float
-} Cv3dTracker2dTrackedObject;
-
-CV_INLINE Cv3dTracker2dTrackedObject cv3dTracker2dTrackedObject(int id, CvPoint2D32f p)
-{
-    Cv3dTracker2dTrackedObject r;
-    r.id = id;
-    r.p = p;
-    return r;
-}
-
-typedef struct Cv3dTrackerTrackedObject
-{
-    int id;
-    CvPoint3D32f p;             // location of the tracked object
-} Cv3dTrackerTrackedObject;
-
-CV_INLINE Cv3dTrackerTrackedObject cv3dTrackerTrackedObject(int id, CvPoint3D32f p)
-{
-    Cv3dTrackerTrackedObject r;
-    r.id = id;
-    r.p = p;
-    return r;
-}
-
-typedef struct Cv3dTrackerCameraInfo
-{
-    CvBool valid;
-    float mat[4][4];              /* maps camera coordinates to world coordinates */
-    CvPoint2D32f principal_point; /* copied from intrinsics so this structure */
-                                  /* has all the info we need */
-} Cv3dTrackerCameraInfo;
-
-typedef struct Cv3dTrackerCameraIntrinsics
-{
-    CvPoint2D32f principal_point;
-    float focal_length[2];
-    float distortion[4];
-} Cv3dTrackerCameraIntrinsics;
-
-CVAPI(CvBool) cv3dTrackerCalibrateCameras(int num_cameras,
-                     const Cv3dTrackerCameraIntrinsics camera_intrinsics[], /* size is num_cameras */
-                     CvSize etalon_size,
-                     float square_size,
-                     IplImage *samples[],                                   /* size is num_cameras */
-                     Cv3dTrackerCameraInfo camera_info[]);                  /* size is num_cameras */
-
-CVAPI(int)  cv3dTrackerLocateObjects(int num_cameras, int num_objects,
-                   const Cv3dTrackerCameraInfo camera_info[],        /* size is num_cameras */
-                   const Cv3dTracker2dTrackedObject tracking_info[], /* size is num_objects*num_cameras */
-                   Cv3dTrackerTrackedObject tracked_objects[]);      /* size is num_objects */
-/****************************************************************************************
- tracking_info is a rectangular array; one row per camera, num_objects elements per row.
- The id field of any unused slots must be -1. Ids need not be ordered or consecutive. On
- completion, the return value is the number of objects located; i.e., the number of objects
- visible by more than one camera. The id field of any unused slots in tracked objects is
- set to -1.
-****************************************************************************************/
-
-
-/****************************************************************************************\
-*                           Skeletons and Linear-Contour Models                          *
-\****************************************************************************************/
-
-typedef enum CvLeeParameters
-{
-    CV_LEE_INT = 0,
-    CV_LEE_FLOAT = 1,
-    CV_LEE_DOUBLE = 2,
-    CV_LEE_AUTO = -1,
-    CV_LEE_ERODE = 0,
-    CV_LEE_ZOOM = 1,
-    CV_LEE_NON = 2
-} CvLeeParameters;
-
-#define CV_NEXT_VORONOISITE2D( SITE ) ((SITE)->edge[0]->site[((SITE)->edge[0]->site[0] == (SITE))])
-#define CV_PREV_VORONOISITE2D( SITE ) ((SITE)->edge[1]->site[((SITE)->edge[1]->site[0] == (SITE))])
-#define CV_FIRST_VORONOIEDGE2D( SITE ) ((SITE)->edge[0])
-#define CV_LAST_VORONOIEDGE2D( SITE ) ((SITE)->edge[1])
-#define CV_NEXT_VORONOIEDGE2D( EDGE, SITE ) ((EDGE)->next[(EDGE)->site[0] != (SITE)])
-#define CV_PREV_VORONOIEDGE2D( EDGE, SITE ) ((EDGE)->next[2 + ((EDGE)->site[0] != (SITE))])
-#define CV_VORONOIEDGE2D_BEGINNODE( EDGE, SITE ) ((EDGE)->node[((EDGE)->site[0] != (SITE))])
-#define CV_VORONOIEDGE2D_ENDNODE( EDGE, SITE ) ((EDGE)->node[((EDGE)->site[0] == (SITE))])
-#define CV_TWIN_VORONOISITE2D( SITE, EDGE ) ( (EDGE)->site[((EDGE)->site[0] == (SITE))])
-
-#define CV_VORONOISITE2D_FIELDS()    \
-    struct CvVoronoiNode2D *node[2]; \
-    struct CvVoronoiEdge2D *edge[2];
-
-typedef struct CvVoronoiSite2D
-{
-    CV_VORONOISITE2D_FIELDS()
-    struct CvVoronoiSite2D *next[2];
-} CvVoronoiSite2D;
-
-#define CV_VORONOIEDGE2D_FIELDS()    \
-    struct CvVoronoiNode2D *node[2]; \
-    struct CvVoronoiSite2D *site[2]; \
-    struct CvVoronoiEdge2D *next[4];
-
-typedef struct CvVoronoiEdge2D
-{
-    CV_VORONOIEDGE2D_FIELDS()
-} CvVoronoiEdge2D;
-
-#define CV_VORONOINODE2D_FIELDS()       \
-    CV_SET_ELEM_FIELDS(CvVoronoiNode2D) \
-    CvPoint2D32f pt;                    \
-    float radius;
-
-typedef struct CvVoronoiNode2D
-{
-    CV_VORONOINODE2D_FIELDS()
-} CvVoronoiNode2D;
-
-#define CV_VORONOIDIAGRAM2D_FIELDS() \
-    CV_GRAPH_FIELDS()                \
-    CvSet *sites;
-
-typedef struct CvVoronoiDiagram2D
-{
-    CV_VORONOIDIAGRAM2D_FIELDS()
-} CvVoronoiDiagram2D;
-
-/* Computes Voronoi Diagram for given polygons with holes */
-CVAPI(int)  cvVoronoiDiagramFromContour(CvSeq* ContourSeq,
-                                           CvVoronoiDiagram2D** VoronoiDiagram,
-                                           CvMemStorage* VoronoiStorage,
-                                           CvLeeParameters contour_type CV_DEFAULT(CV_LEE_INT),
-                                           int contour_orientation CV_DEFAULT(-1),
-                                           int attempt_number CV_DEFAULT(10));
-
-/* Computes Voronoi Diagram for domains in given image */
-CVAPI(int)  cvVoronoiDiagramFromImage(IplImage* pImage,
-                                         CvSeq** ContourSeq,
-                                         CvVoronoiDiagram2D** VoronoiDiagram,
-                                         CvMemStorage* VoronoiStorage,
-                                         CvLeeParameters regularization_method CV_DEFAULT(CV_LEE_NON),
-                                         float approx_precision CV_DEFAULT(CV_LEE_AUTO));
-
-/* Deallocates the storage */
-CVAPI(void) cvReleaseVoronoiStorage(CvVoronoiDiagram2D* VoronoiDiagram,
-                                          CvMemStorage** pVoronoiStorage);
-
-/*********************** Linear-Contour Model ****************************/
-
-struct CvLCMEdge;
-struct CvLCMNode;
-
-typedef struct CvLCMEdge
-{
-    CV_GRAPH_EDGE_FIELDS()
-    CvSeq* chain;
-    float width;
-    int index1;
-    int index2;
-} CvLCMEdge;
-
-typedef struct CvLCMNode
-{
-    CV_GRAPH_VERTEX_FIELDS()
-    CvContour* contour;
-} CvLCMNode;
-
-
-/* Computes hybrid model from Voronoi Diagram */
-CVAPI(CvGraph*) cvLinearContorModelFromVoronoiDiagram(CvVoronoiDiagram2D* VoronoiDiagram,
-                                                         float maxWidth);
-
-/* Releases hybrid model storage */
-CVAPI(int) cvReleaseLinearContorModelStorage(CvGraph** Graph);
-
-
-/* two stereo-related functions */
-
-CVAPI(void) cvInitPerspectiveTransform( CvSize size, const CvPoint2D32f vertex[4], double matrix[3][3],
-                                              CvArr* rectMap );
-
-/*CVAPI(void) cvInitStereoRectification( CvStereoCamera* params,
-                                             CvArr* rectMap1, CvArr* rectMap2,
-                                             int do_undistortion );*/
-
-/*************************** View Morphing Functions ************************/
-
-typedef struct CvMatrix3
-{
-    float m[3][3];
-} CvMatrix3;
-
-/* The order of the function corresponds to the order they should appear in
-   the view morphing pipeline */
-
-/* Finds ending points of scanlines on left and right images of stereo-pair */
-CVAPI(void)  cvMakeScanlines( const CvMatrix3* matrix, CvSize  img_size,
-                              int*  scanlines1, int*  scanlines2,
-                              int*  lengths1, int*  lengths2,
-                              int*  line_count );
-
-/* Grab pixel values from scanlines and stores them sequentially
-   (some sort of perspective image transform) */
-CVAPI(void)  cvPreWarpImage( int       line_count,
-                             IplImage* img,
-                             uchar*    dst,
-                             int*      dst_nums,
-                             int*      scanlines);
-
-/* Approximate each grabbed scanline by a sequence of runs
-   (lossy run-length compression) */
-CVAPI(void)  cvFindRuns( int    line_count,
-                         uchar* prewarp1,
-                         uchar* prewarp2,
-                         int*   line_lengths1,
-                         int*   line_lengths2,
-                         int*   runs1,
-                         int*   runs2,
-                         int*   num_runs1,
-                         int*   num_runs2);
-
-/* Compares two sets of compressed scanlines */
-CVAPI(void)  cvDynamicCorrespondMulti( int  line_count,
-                                       int* first,
-                                       int* first_runs,
-                                       int* second,
-                                       int* second_runs,
-                                       int* first_corr,
-                                       int* second_corr);
-
-/* Finds scanline ending coordinates for some intermediate "virtual" camera position */
-CVAPI(void)  cvMakeAlphaScanlines( int*  scanlines1,
-                                   int*  scanlines2,
-                                   int*  scanlinesA,
-                                   int*  lengths,
-                                   int   line_count,
-                                   float alpha);
-
-/* Blends data of the left and right image scanlines to get
-   pixel values of "virtual" image scanlines */
-CVAPI(void)  cvMorphEpilinesMulti( int    line_count,
-                                   uchar* first_pix,
-                                   int*   first_num,
-                                   uchar* second_pix,
-                                   int*   second_num,
-                                   uchar* dst_pix,
-                                   int*   dst_num,
-                                   float  alpha,
-                                   int*   first,
-                                   int*   first_runs,
-                                   int*   second,
-                                   int*   second_runs,
-                                   int*   first_corr,
-                                   int*   second_corr);
-
-/* Does reverse warping of the morphing result to make
-   it fill the destination image rectangle */
-CVAPI(void)  cvPostWarpImage( int       line_count,
-                              uchar*    src,
-                              int*      src_nums,
-                              IplImage* img,
-                              int*      scanlines);
-
-/* Deletes Moire (missed pixels that appear due to discretization) */
-CVAPI(void)  cvDeleteMoire( IplImage*  img );
-
-
-typedef struct CvConDensation
-{
-    int MP;
-    int DP;
-    float* DynamMatr;       /* Matrix of the linear Dynamics system  */
-    float* State;           /* Vector of State                       */
-    int SamplesNum;         /* Number of the Samples                 */
-    float** flSamples;      /* arr of the Sample Vectors             */
-    float** flNewSamples;   /* temporary array of the Sample Vectors */
-    float* flConfidence;    /* Confidence for each Sample            */
-    float* flCumulative;    /* Cumulative confidence                 */
-    float* Temp;            /* Temporary vector                      */
-    float* RandomSample;    /* RandomVector to update sample set     */
-    struct CvRandState* RandS; /* Array of structures to generate random vectors */
-} CvConDensation;
-
-/* Creates ConDensation filter state */
-CVAPI(CvConDensation*)  cvCreateConDensation( int dynam_params,
-                                             int measure_params,
-                                             int sample_count );
-
-/* Releases ConDensation filter state */
-CVAPI(void)  cvReleaseConDensation( CvConDensation** condens );
-
-/* Updates ConDensation filter by time (predict future state of the system) */
-CVAPI(void)  cvConDensUpdateByTime( CvConDensation* condens);
-
-/* Initializes ConDensation filter samples  */
-CVAPI(void)  cvConDensInitSampleSet( CvConDensation* condens, CvMat* lower_bound, CvMat* upper_bound );
-
-CV_INLINE int iplWidth( const IplImage* img )
-{
-    return !img ? 0 : !img->roi ? img->width : img->roi->width;
-}
-
-CV_INLINE int iplHeight( const IplImage* img )
-{
-    return !img ? 0 : !img->roi ? img->height : img->roi->height;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#ifdef __cplusplus
-
-/****************************************************************************************\
-*                                   Calibration engine                                   *
-\****************************************************************************************/
-
-typedef enum CvCalibEtalonType
-{
-    CV_CALIB_ETALON_USER = -1,
-    CV_CALIB_ETALON_CHESSBOARD = 0,
-    CV_CALIB_ETALON_CHECKERBOARD = CV_CALIB_ETALON_CHESSBOARD
-}
-CvCalibEtalonType;
-
-class CV_EXPORTS CvCalibFilter
-{
-public:
-    /* Constructor & destructor */
-    CvCalibFilter();
-    virtual ~CvCalibFilter();
-
-    /* Sets etalon type - one for all cameras.
-       etalonParams is used in case of pre-defined etalons (such as chessboard).
-       Number of elements in etalonParams is determined by etalonType.
-       E.g., if etalon type is CV_ETALON_TYPE_CHESSBOARD then:
-         etalonParams[0] is number of squares per one side of etalon
-         etalonParams[1] is number of squares per another side of etalon
-         etalonParams[2] is linear size of squares in the board in arbitrary units.
-       pointCount & points are used in case of
-       CV_CALIB_ETALON_USER (user-defined) etalon. */
-    virtual bool
-        SetEtalon( CvCalibEtalonType etalonType, double* etalonParams,
-                   int pointCount = 0, CvPoint2D32f* points = 0 );
-
-    /* Retrieves etalon parameters/or and points */
-    virtual CvCalibEtalonType
-        GetEtalon( int* paramCount = 0, const double** etalonParams = 0,
-                   int* pointCount = 0, const CvPoint2D32f** etalonPoints = 0 ) const;
-
-    /* Sets number of cameras calibrated simultaneously. It is equal to 1 initially */
-    virtual void SetCameraCount( int cameraCount );
-
-    /* Retrieves number of cameras */
-    int GetCameraCount() const { return cameraCount; }
-
-    /* Starts cameras calibration */
-    virtual bool SetFrames( int totalFrames );
-
-    /* Stops cameras calibration */
-    virtual void Stop( bool calibrate = false );
-
-    /* Retrieves number of cameras */
-    bool IsCalibrated() const { return isCalibrated; }
-
-    /* Feeds another serie of snapshots (one per each camera) to filter.
-       Etalon points on these images are found automatically.
-       If the function can't locate points, it returns false */
-    virtual bool FindEtalon( IplImage** imgs );
-
-    /* The same but takes matrices */
-    virtual bool FindEtalon( CvMat** imgs );
-
-    /* Lower-level function for feeding filter with already found etalon points.
-       Array of point arrays for each camera is passed. */
-    virtual bool Push( const CvPoint2D32f** points = 0 );
-
-    /* Returns total number of accepted frames and, optionally,
-       total number of frames to collect */
-    virtual int GetFrameCount( int* framesTotal = 0 ) const;
-
-    /* Retrieves camera parameters for specified camera.
-       If camera is not calibrated the function returns 0 */
-    virtual const CvCamera* GetCameraParams( int idx = 0 ) const;
-
-    virtual const CvStereoCamera* GetStereoParams() const;
-
-    /* Sets camera parameters for all cameras */
-    virtual bool SetCameraParams( CvCamera* params );
-
-    /* Saves all camera parameters to file */
-    virtual bool SaveCameraParams( const char* filename );
-
-    /* Loads all camera parameters from file */
-    virtual bool LoadCameraParams( const char* filename );
-
-    /* Undistorts images using camera parameters. Some of src pointers can be NULL. */
-    virtual bool Undistort( IplImage** src, IplImage** dst );
-
-    /* Undistorts images using camera parameters. Some of src pointers can be NULL. */
-    virtual bool Undistort( CvMat** src, CvMat** dst );
-
-    /* Returns array of etalon points detected/partally detected
-       on the latest frame for idx-th camera */
-    virtual bool GetLatestPoints( int idx, CvPoint2D32f** pts,
-                                                  int* count, bool* found );
-
-    /* Draw the latest detected/partially detected etalon */
-    virtual void DrawPoints( IplImage** dst );
-
-    /* Draw the latest detected/partially detected etalon */
-    virtual void DrawPoints( CvMat** dst );
-
-    virtual bool Rectify( IplImage** srcarr, IplImage** dstarr );
-    virtual bool Rectify( CvMat** srcarr, CvMat** dstarr );
-
-protected:
-
-    enum { MAX_CAMERAS = 3 };
-
-    /* etalon data */
-    CvCalibEtalonType  etalonType;
-    int     etalonParamCount;
-    double* etalonParams;
-    int     etalonPointCount;
-    CvPoint2D32f* etalonPoints;
-    CvSize  imgSize;
-    CvMat*  grayImg;
-    CvMat*  tempImg;
-    CvMemStorage* storage;
-
-    /* camera data */
-    int     cameraCount;
-    CvCamera cameraParams[MAX_CAMERAS];
-    CvStereoCamera stereo;
-    CvPoint2D32f* points[MAX_CAMERAS];
-    CvMat*  undistMap[MAX_CAMERAS][2];
-    CvMat*  undistImg;
-    int     latestCounts[MAX_CAMERAS];
-    CvPoint2D32f* latestPoints[MAX_CAMERAS];
-    CvMat*  rectMap[MAX_CAMERAS][2];
-
-    /* Added by Valery */
-    //CvStereoCamera stereoParams;
-
-    int     maxPoints;
-    int     framesTotal;
-    int     framesAccepted;
-    bool    isCalibrated;
-};
-
-#include <iosfwd>
-#include <limits>
-
-class CV_EXPORTS CvImage
-{
-public:
-    CvImage() : image(0), refcount(0) {}
-    CvImage( CvSize _size, int _depth, int _channels )
-    {
-        image = cvCreateImage( _size, _depth, _channels );
-        refcount = image ? new int(1) : 0;
-    }
-
-    CvImage( IplImage* img ) : image(img)
-    {
-        refcount = image ? new int(1) : 0;
-    }
-
-    CvImage( const CvImage& img ) : image(img.image), refcount(img.refcount)
-    {
-        if( refcount ) ++(*refcount);
-    }
-
-    CvImage( const char* filename, const char* imgname=0, int color=-1 ) : image(0), refcount(0)
-    { load( filename, imgname, color ); }
-
-    CvImage( CvFileStorage* fs, const char* mapname, const char* imgname ) : image(0), refcount(0)
-    { read( fs, mapname, imgname ); }
-
-    CvImage( CvFileStorage* fs, const char* seqname, int idx ) : image(0), refcount(0)
-    { read( fs, seqname, idx ); }
-
-    ~CvImage()
-    {
-        if( refcount && !(--*refcount) )
-        {
-            cvReleaseImage( &image );
-            delete refcount;
-        }
-    }
-
-    CvImage clone() { return CvImage(image ? cvCloneImage(image) : 0); }
-
-    void create( CvSize _size, int _depth, int _channels )
-    {
-        if( !image || !refcount ||
-           image->width != _size.width || image->height != _size.height ||
-           image->depth != _depth || image->nChannels != _channels )
-            attach( cvCreateImage( _size, _depth, _channels ));
-    }
-
-    void release() { detach(); }
-    void clear() { detach(); }
-
-    void attach( IplImage* img, bool use_refcount=true )
-    {
-        if( refcount && --*refcount == 0 )
-        {
-            cvReleaseImage( &image );
-            delete refcount;
-        }
-        image = img;
-        refcount = use_refcount && image ? new int(1) : 0;
-    }
-
-    void detach()
-    {
-        if( refcount && --*refcount == 0 )
-        {
-            cvReleaseImage( &image );
-            delete refcount;
-        }
-        image = 0;
-        refcount = 0;
-    }
-
-    bool load( const char* filename, const char* imgname=0, int color=-1 );
-    bool read( CvFileStorage* fs, const char* mapname, const char* imgname );
-    bool read( CvFileStorage* fs, const char* seqname, int idx );
-    void save( const char* filename, const char* imgname, const int* params=0 );
-    void write( CvFileStorage* fs, const char* imgname );
-
-    void show( const char* window_name );
-    bool is_valid() { return image != 0; }
-
-    int width() const { return image ? image->width : 0; }
-    int height() const { return image ? image->height : 0; }
-
-    CvSize size() const { return image ? cvSize(image->width, image->height) : cvSize(0,0); }
-
-    CvSize roi_size() const
-    {
-        return !image ? cvSize(0,0) :
-        !image->roi ? cvSize(image->width,image->height) :
-        cvSize(image->roi->width, image->roi->height);
-    }
-
-    CvRect roi() const
-    {
-        return !image ? cvRect(0,0,0,0) :
-        !image->roi ? cvRect(0,0,image->width,image->height) :
-        cvRect(image->roi->xOffset,image->roi->yOffset,
-               image->roi->width,image->roi->height);
-    }
-
-    int coi() const { return !image || !image->roi ? 0 : image->roi->coi; }
-
-    void set_roi(CvRect _roi) { cvSetImageROI(image,_roi); }
-    void reset_roi() { cvResetImageROI(image); }
-    void set_coi(int _coi) { cvSetImageCOI(image,_coi); }
-    int depth() const { return image ? image->depth : 0; }
-    int channels() const { return image ? image->nChannels : 0; }
-    int pix_size() const { return image ? ((image->depth & 255)>>3)*image->nChannels : 0; }
-
-    uchar* data() { return image ? (uchar*)image->imageData : 0; }
-    const uchar* data() const { return image ? (const uchar*)image->imageData : 0; }
-    int step() const { return image ? image->widthStep : 0; }
-    int origin() const { return image ? image->origin : 0; }
-
-    uchar* roi_row(int y)
-    {
-        assert(0<=y);
-        assert(!image ?
-               1 : image->roi ?
-               y<image->roi->height : y<image->height);
-
-        return !image ? 0 :
-        !image->roi ?
-        (uchar*)(image->imageData + y*image->widthStep) :
-        (uchar*)(image->imageData + (y+image->roi->yOffset)*image->widthStep +
-                 image->roi->xOffset*((image->depth & 255)>>3)*image->nChannels);
-    }
-
-    const uchar* roi_row(int y) const
-    {
-        assert(0<=y);
-        assert(!image ?
-               1 : image->roi ?
-               y<image->roi->height : y<image->height);
-
-        return !image ? 0 :
-        !image->roi ?
-        (const uchar*)(image->imageData + y*image->widthStep) :
-        (const uchar*)(image->imageData + (y+image->roi->yOffset)*image->widthStep +
-                       image->roi->xOffset*((image->depth & 255)>>3)*image->nChannels);
-    }
-
-    operator const IplImage* () const { return image; }
-    operator IplImage* () { return image; }
-
-    CvImage& operator = (const CvImage& img)
-    {
-        if( img.refcount )
-            ++*img.refcount;
-        if( refcount && !(--*refcount) )
-            cvReleaseImage( &image );
-        image=img.image;
-        refcount=img.refcount;
-        return *this;
-    }
-
-protected:
-    IplImage* image;
-    int* refcount;
-};
-
-
-class CV_EXPORTS CvMatrix
-{
-public:
-    CvMatrix() : matrix(0) {}
-    CvMatrix( int _rows, int _cols, int _type )
-    { matrix = cvCreateMat( _rows, _cols, _type ); }
-
-    CvMatrix( int _rows, int _cols, int _type, CvMat* hdr,
-             void* _data=0, int _step=CV_AUTOSTEP )
-    { matrix = cvInitMatHeader( hdr, _rows, _cols, _type, _data, _step ); }
-
-    CvMatrix( int rows, int cols, int type, CvMemStorage* storage, bool alloc_data=true );
-
-    CvMatrix( int _rows, int _cols, int _type, void* _data, int _step=CV_AUTOSTEP )
-    { matrix = cvCreateMatHeader( _rows, _cols, _type );
-        cvSetData( matrix, _data, _step ); }
-
-    CvMatrix( CvMat* m )
-    { matrix = m; }
-
-    CvMatrix( const CvMatrix& m )
-    {
-        matrix = m.matrix;
-        addref();
-    }
-
-    CvMatrix( const char* filename, const char* matname=0, int color=-1 ) : matrix(0)
-    {  load( filename, matname, color ); }
-
-    CvMatrix( CvFileStorage* fs, const char* mapname, const char* matname ) : matrix(0)
-    {  read( fs, mapname, matname ); }
-
-    CvMatrix( CvFileStorage* fs, const char* seqname, int idx ) : matrix(0)
-    {  read( fs, seqname, idx ); }
-
-    ~CvMatrix()
-    {
-        release();
-    }
-
-    CvMatrix clone() { return CvMatrix(matrix ? cvCloneMat(matrix) : 0); }
-
-    void set( CvMat* m, bool add_ref )
-    {
-        release();
-        matrix = m;
-        if( add_ref )
-            addref();
-    }
-
-    void create( int _rows, int _cols, int _type )
-    {
-        if( !matrix || !matrix->refcount ||
-           matrix->rows != _rows || matrix->cols != _cols ||
-           CV_MAT_TYPE(matrix->type) != _type )
-            set( cvCreateMat( _rows, _cols, _type ), false );
-    }
-
-    void addref() const
-    {
-        if( matrix )
-        {
-            if( matrix->hdr_refcount )
-                ++matrix->hdr_refcount;
-            else if( matrix->refcount )
-                ++*matrix->refcount;
-        }
-    }
-
-    void release()
-    {
-        if( matrix )
-        {
-            if( matrix->hdr_refcount )
-            {
-                if( --matrix->hdr_refcount == 0 )
-                    cvReleaseMat( &matrix );
-            }
-            else if( matrix->refcount )
-            {
-                if( --*matrix->refcount == 0 )
-                    cvFree( &matrix->refcount );
-            }
-            matrix = 0;
-        }
-    }
-
-    void clear()
-    {
-        release();
-    }
-
-    bool load( const char* filename, const char* matname=0, int color=-1 );
-    bool read( CvFileStorage* fs, const char* mapname, const char* matname );
-    bool read( CvFileStorage* fs, const char* seqname, int idx );
-    void save( const char* filename, const char* matname, const int* params=0 );
-    void write( CvFileStorage* fs, const char* matname );
-
-    void show( const char* window_name );
-
-    bool is_valid() { return matrix != 0; }
-
-    int rows() const { return matrix ? matrix->rows : 0; }
-    int cols() const { return matrix ? matrix->cols : 0; }
-
-    CvSize size() const
-    {
-        return !matrix ? cvSize(0,0) : cvSize(matrix->rows,matrix->cols);
-    }
-
-    int type() const { return matrix ? CV_MAT_TYPE(matrix->type) : 0; }
-    int depth() const { return matrix ? CV_MAT_DEPTH(matrix->type) : 0; }
-    int channels() const { return matrix ? CV_MAT_CN(matrix->type) : 0; }
-    int pix_size() const { return matrix ? CV_ELEM_SIZE(matrix->type) : 0; }
-
-    uchar* data() { return matrix ? matrix->data.ptr : 0; }
-    const uchar* data() const { return matrix ? matrix->data.ptr : 0; }
-    int step() const { return matrix ? matrix->step : 0; }
-
-    void set_data( void* _data, int _step=CV_AUTOSTEP )
-    { cvSetData( matrix, _data, _step ); }
-
-    uchar* row(int i) { return !matrix ? 0 : matrix->data.ptr + i*matrix->step; }
-    const uchar* row(int i) const
-    { return !matrix ? 0 : matrix->data.ptr + i*matrix->step; }
-
-    operator const CvMat* () const { return matrix; }
-    operator CvMat* () { return matrix; }
-
-    CvMatrix& operator = (const CvMatrix& _m)
-    {
-        _m.addref();
-        release();
-        matrix = _m.matrix;
-        return *this;
-    }
-
-protected:
-    CvMat* matrix;
-};
-
-/****************************************************************************************\
- *                                       CamShiftTracker                                  *
- \****************************************************************************************/
-
-class CV_EXPORTS CvCamShiftTracker
-{
-public:
-
-    CvCamShiftTracker();
-    virtual ~CvCamShiftTracker();
-
-    /**** Characteristics of the object that are calculated by track_object method *****/
-    float   get_orientation() const // orientation of the object in degrees
-    { return m_box.angle; }
-    float   get_length() const // the larger linear size of the object
-    { return m_box.size.height; }
-    float   get_width() const // the smaller linear size of the object
-    { return m_box.size.width; }
-    CvPoint2D32f get_center() const // center of the object
-    { return m_box.center; }
-    CvRect get_window() const // bounding rectangle for the object
-    { return m_comp.rect; }
-
-    /*********************** Tracking parameters ************************/
-    int     get_threshold() const // thresholding value that applied to back project
-    { return m_threshold; }
-
-    int     get_hist_dims( int* dims = 0 ) const // returns number of histogram dimensions and sets
-    { return m_hist ? cvGetDims( m_hist->bins, dims ) : 0; }
-
-    int     get_min_ch_val( int channel ) const // get the minimum allowed value of the specified channel
-    { return m_min_ch_val[channel]; }
-
-    int     get_max_ch_val( int channel ) const // get the maximum allowed value of the specified channel
-    { return m_max_ch_val[channel]; }
-
-    // set initial object rectangle (must be called before initial calculation of the histogram)
-    bool    set_window( CvRect window)
-    { m_comp.rect = window; return true; }
-
-    bool    set_threshold( int threshold ) // threshold applied to the histogram bins
-    { m_threshold = threshold; return true; }
-
-    bool    set_hist_bin_range( int dim, int min_val, int max_val );
-
-    bool    set_hist_dims( int c_dims, int* dims );// set the histogram parameters
-
-    bool    set_min_ch_val( int channel, int val ) // set the minimum allowed value of the specified channel
-    { m_min_ch_val[channel] = val; return true; }
-    bool    set_max_ch_val( int channel, int val ) // set the maximum allowed value of the specified channel
-    { m_max_ch_val[channel] = val; return true; }
-
-    /************************ The processing methods *********************************/
-    // update object position
-    virtual bool  track_object( const IplImage* cur_frame );
-
-    // update object histogram
-    virtual bool  update_histogram( const IplImage* cur_frame );
-
-    // reset histogram
-    virtual void  reset_histogram();
-
-    /************************ Retrieving internal data *******************************/
-    // get back project image
-    virtual IplImage* get_back_project()
-    { return m_back_project; }
-
-    float query( int* bin ) const
-    { return m_hist ? (float)cvGetRealND(m_hist->bins, bin) : 0.f; }
-
-protected:
-
-    // internal method for color conversion: fills m_color_planes group
-    virtual void color_transform( const IplImage* img );
-
-    CvHistogram* m_hist;
-
-    CvBox2D    m_box;
-    CvConnectedComp m_comp;
-
-    float      m_hist_ranges_data[CV_MAX_DIM][2];
-    float*     m_hist_ranges[CV_MAX_DIM];
-
-    int        m_min_ch_val[CV_MAX_DIM];
-    int        m_max_ch_val[CV_MAX_DIM];
-    int        m_threshold;
-
-    IplImage*  m_color_planes[CV_MAX_DIM];
-    IplImage*  m_back_project;
-    IplImage*  m_temp;
-    IplImage*  m_mask;
-};
-
-/****************************************************************************************\
-*                              Expectation - Maximization                                *
-\****************************************************************************************/
-struct CV_EXPORTS_W_MAP CvEMParams
-{
-    CvEMParams();
-    CvEMParams( int nclusters, int cov_mat_type=cv::EM::COV_MAT_DIAGONAL,
-                int start_step=cv::EM::START_AUTO_STEP,
-                CvTermCriteria term_crit=cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 100, FLT_EPSILON),
-                const CvMat* probs=0, const CvMat* weights=0, const CvMat* means=0, const CvMat** covs=0 );
-
-    CV_PROP_RW int nclusters;
-    CV_PROP_RW int cov_mat_type;
-    CV_PROP_RW int start_step;
-    const CvMat* probs;
-    const CvMat* weights;
-    const CvMat* means;
-    const CvMat** covs;
-    CV_PROP_RW CvTermCriteria term_crit;
-};
-
-
-class CV_EXPORTS_W CvEM : public CvStatModel
-{
-public:
-    // Type of covariation matrices
-    enum { COV_MAT_SPHERICAL=cv::EM::COV_MAT_SPHERICAL,
-           COV_MAT_DIAGONAL =cv::EM::COV_MAT_DIAGONAL,
-           COV_MAT_GENERIC  =cv::EM::COV_MAT_GENERIC };
-
-    // The initial step
-    enum { START_E_STEP=cv::EM::START_E_STEP,
-           START_M_STEP=cv::EM::START_M_STEP,
-           START_AUTO_STEP=cv::EM::START_AUTO_STEP };
-
-    CV_WRAP CvEM();
-    CvEM( const CvMat* samples, const CvMat* sampleIdx=0,
-          CvEMParams params=CvEMParams(), CvMat* labels=0 );
-
-    virtual ~CvEM();
-
-    virtual bool train( const CvMat* samples, const CvMat* sampleIdx=0,
-                        CvEMParams params=CvEMParams(), CvMat* labels=0 );
-
-    virtual float predict( const CvMat* sample, CV_OUT CvMat* probs ) const;
-
-    CV_WRAP CvEM( const cv::Mat& samples, const cv::Mat& sampleIdx=cv::Mat(),
-                  CvEMParams params=CvEMParams() );
-
-    CV_WRAP virtual bool train( const cv::Mat& samples,
-                                const cv::Mat& sampleIdx=cv::Mat(),
-                                CvEMParams params=CvEMParams(),
-                                CV_OUT cv::Mat* labels=0 );
-
-    CV_WRAP virtual float predict( const cv::Mat& sample, CV_OUT cv::Mat* probs=0 ) const;
-    CV_WRAP virtual double calcLikelihood( const cv::Mat &sample ) const;
-
-    CV_WRAP int getNClusters() const;
-    CV_WRAP cv::Mat getMeans() const;
-    CV_WRAP void getCovs(CV_OUT std::vector<cv::Mat>& covs) const;
-    CV_WRAP cv::Mat getWeights() const;
-    CV_WRAP cv::Mat getProbs() const;
-
-    CV_WRAP inline double getLikelihood() const { return emObj.isTrained() ? logLikelihood : DBL_MAX; }
-
-    CV_WRAP virtual void clear();
-
-    int get_nclusters() const;
-    const CvMat* get_means() const;
-    const CvMat** get_covs() const;
-    const CvMat* get_weights() const;
-    const CvMat* get_probs() const;
-
-    inline double get_log_likelihood() const { return getLikelihood(); }
-
-    virtual void read( CvFileStorage* fs, CvFileNode* node );
-    virtual void write( CvFileStorage* fs, const char* name ) const;
-
-protected:
-    void set_mat_hdrs();
-
-    cv::EM emObj;
-    cv::Mat probs;
-    double logLikelihood;
-
-    CvMat meansHdr;
-    std::vector<CvMat> covsHdrs;
-    std::vector<CvMat*> covsPtrs;
-    CvMat weightsHdr;
-    CvMat probsHdr;
-};
-
-namespace cv
-{
-
-typedef CvEMParams EMParams;
-typedef CvEM ExpectationMaximization;
-
-/*!
- The Patch Generator class
- */
-class CV_EXPORTS PatchGenerator
-{
-public:
-    PatchGenerator();
-    PatchGenerator(double _backgroundMin, double _backgroundMax,
-                   double _noiseRange, bool _randomBlur=true,
-                   double _lambdaMin=0.6, double _lambdaMax=1.5,
-                   double _thetaMin=-CV_PI, double _thetaMax=CV_PI,
-                   double _phiMin=-CV_PI, double _phiMax=CV_PI );
-    void operator()(const Mat& image, Point2f pt, Mat& patch, Size patchSize, RNG& rng) const;
-    void operator()(const Mat& image, const Mat& transform, Mat& patch,
-                    Size patchSize, RNG& rng) const;
-    void warpWholeImage(const Mat& image, Mat& matT, Mat& buf,
-                        CV_OUT Mat& warped, int border, RNG& rng) const;
-    void generateRandomTransform(Point2f srcCenter, Point2f dstCenter,
-                                 CV_OUT Mat& transform, RNG& rng,
-                                 bool inverse=false) const;
-    void setAffineParam(double lambda, double theta, double phi);
-
-    double backgroundMin, backgroundMax;
-    double noiseRange;
-    bool randomBlur;
-    double lambdaMin, lambdaMax;
-    double thetaMin, thetaMax;
-    double phiMin, phiMax;
-};
-
-
-class CV_EXPORTS LDetector
-{
-public:
-    LDetector();
-    LDetector(int _radius, int _threshold, int _nOctaves,
-              int _nViews, double _baseFeatureSize, double _clusteringDistance);
-    void operator()(const Mat& image,
-                    CV_OUT std::vector<KeyPoint>& keypoints,
-                    int maxCount=0, bool scaleCoords=true) const;
-    void operator()(const std::vector<Mat>& pyr,
-                    CV_OUT std::vector<KeyPoint>& keypoints,
-                    int maxCount=0, bool scaleCoords=true) const;
-    void getMostStable2D(const Mat& image, CV_OUT std::vector<KeyPoint>& keypoints,
-                         int maxCount, const PatchGenerator& patchGenerator) const;
-    void setVerbose(bool verbose);
-
-    void read(const FileNode& node);
-    void write(FileStorage& fs, const String& name=String()) const;
-
-    int radius;
-    int threshold;
-    int nOctaves;
-    int nViews;
-    bool verbose;
-
-    double baseFeatureSize;
-    double clusteringDistance;
-};
-
-typedef LDetector YAPE;
-
-class CV_EXPORTS FernClassifier
-{
-public:
-    FernClassifier();
-    FernClassifier(const FileNode& node);
-    FernClassifier(const std::vector<std::vector<Point2f> >& points,
-                   const std::vector<Mat>& refimgs,
-                   const std::vector<std::vector<int> >& labels=std::vector<std::vector<int> >(),
-                   int _nclasses=0, int _patchSize=PATCH_SIZE,
-                   int _signatureSize=DEFAULT_SIGNATURE_SIZE,
-                   int _nstructs=DEFAULT_STRUCTS,
-                   int _structSize=DEFAULT_STRUCT_SIZE,
-                   int _nviews=DEFAULT_VIEWS,
-                   int _compressionMethod=COMPRESSION_NONE,
-                   const PatchGenerator& patchGenerator=PatchGenerator());
-    virtual ~FernClassifier();
-    virtual void read(const FileNode& n);
-    virtual void write(FileStorage& fs, const String& name=String()) const;
-    virtual void trainFromSingleView(const Mat& image,
-                                     const std::vector<KeyPoint>& keypoints,
-                                     int _patchSize=PATCH_SIZE,
-                                     int _signatureSize=DEFAULT_SIGNATURE_SIZE,
-                                     int _nstructs=DEFAULT_STRUCTS,
-                                     int _structSize=DEFAULT_STRUCT_SIZE,
-                                     int _nviews=DEFAULT_VIEWS,
-                                     int _compressionMethod=COMPRESSION_NONE,
-                                     const PatchGenerator& patchGenerator=PatchGenerator());
-    virtual void train(const std::vector<std::vector<Point2f> >& points,
-                       const std::vector<Mat>& refimgs,
-                       const std::vector<std::vector<int> >& labels=std::vector<std::vector<int> >(),
-                       int _nclasses=0, int _patchSize=PATCH_SIZE,
-                       int _signatureSize=DEFAULT_SIGNATURE_SIZE,
-                       int _nstructs=DEFAULT_STRUCTS,
-                       int _structSize=DEFAULT_STRUCT_SIZE,
-                       int _nviews=DEFAULT_VIEWS,
-                       int _compressionMethod=COMPRESSION_NONE,
-                       const PatchGenerator& patchGenerator=PatchGenerator());
-    virtual int operator()(const Mat& img, Point2f kpt, std::vector<float>& signature) const;
-    virtual int operator()(const Mat& patch, std::vector<float>& signature) const;
-    virtual void clear();
-    virtual bool empty() const;
-    void setVerbose(bool verbose);
-
-    int getClassCount() const;
-    int getStructCount() const;
-    int getStructSize() const;
-    int getSignatureSize() const;
-    int getCompressionMethod() const;
-    Size getPatchSize() const;
-
-    struct Feature
-    {
-        uchar x1, y1, x2, y2;
-        Feature() : x1(0), y1(0), x2(0), y2(0) {}
-        Feature(int _x1, int _y1, int _x2, int _y2)
-        : x1((uchar)_x1), y1((uchar)_y1), x2((uchar)_x2), y2((uchar)_y2)
-        {}
-        template<typename _Tp> bool operator ()(const Mat_<_Tp>& patch) const
-        { return patch(y1,x1) > patch(y2, x2); }
-    };
-
-    enum
-    {
-        PATCH_SIZE = 31,
-        DEFAULT_STRUCTS = 50,
-        DEFAULT_STRUCT_SIZE = 9,
-        DEFAULT_VIEWS = 5000,
-        DEFAULT_SIGNATURE_SIZE = 176,
-        COMPRESSION_NONE = 0,
-        COMPRESSION_RANDOM_PROJ = 1,
-        COMPRESSION_PCA = 2,
-        DEFAULT_COMPRESSION_METHOD = COMPRESSION_NONE
-    };
-
-protected:
-    virtual void prepare(int _nclasses, int _patchSize, int _signatureSize,
-                         int _nstructs, int _structSize,
-                         int _nviews, int _compressionMethod);
-    virtual void finalize(RNG& rng);
-    virtual int getLeaf(int fidx, const Mat& patch) const;
-
-    bool verbose;
-    int nstructs;
-    int structSize;
-    int nclasses;
-    int signatureSize;
-    int compressionMethod;
-    int leavesPerStruct;
-    Size patchSize;
-    std::vector<Feature> features;
-    std::vector<int> classCounters;
-    std::vector<float> posteriors;
-};
-
-
-/****************************************************************************************\
- *                                 Calonder Classifier                                    *
- \****************************************************************************************/
-
-struct RTreeNode;
-
-struct CV_EXPORTS BaseKeypoint
-{
-    int x;
-    int y;
-    IplImage* image;
-
-    BaseKeypoint()
-    : x(0), y(0), image(NULL)
-    {}
-
-    BaseKeypoint(int _x, int _y, IplImage* _image)
-    : x(_x), y(_y), image(_image)
-    {}
-};
-
-class CV_EXPORTS RandomizedTree
-{
-public:
-    friend class RTreeClassifier;
-
-    static const uchar PATCH_SIZE = 32;
-    static const int DEFAULT_DEPTH = 9;
-    static const int DEFAULT_VIEWS = 5000;
-    static const size_t DEFAULT_REDUCED_NUM_DIM = 176;
-    static float GET_LOWER_QUANT_PERC() { return .03f; }
-    static float GET_UPPER_QUANT_PERC() { return .92f; }
-
-    RandomizedTree();
-    ~RandomizedTree();
-
-    void train(std::vector<BaseKeypoint> const& base_set, RNG &rng,
-               int depth, int views, size_t reduced_num_dim, int num_quant_bits);
-    void train(std::vector<BaseKeypoint> const& base_set, RNG &rng,
-               PatchGenerator &make_patch, int depth, int views, size_t reduced_num_dim,
-               int num_quant_bits);
-
-    // following two funcs are EXPERIMENTAL (do not use unless you know exactly what you do)
-    static void quantizeVector(float *vec, int dim, int N, float bnds[2], int clamp_mode=0);
-    static void quantizeVector(float *src, int dim, int N, float bnds[2], uchar *dst);
-
-    // patch_data must be a 32x32 array (no row padding)
-    float* getPosterior(uchar* patch_data);
-    const float* getPosterior(uchar* patch_data) const;
-    uchar* getPosterior2(uchar* patch_data);
-    const uchar* getPosterior2(uchar* patch_data) const;
-
-    void read(const char* file_name, int num_quant_bits);
-    void read(std::istream &is, int num_quant_bits);
-    void write(const char* file_name) const;
-    void write(std::ostream &os) const;
-
-    int classes() { return classes_; }
-    int depth() { return depth_; }
-
-    //void setKeepFloatPosteriors(bool b) { keep_float_posteriors_ = b; }
-    void discardFloatPosteriors() { freePosteriors(1); }
-
-    inline void applyQuantization(int num_quant_bits) { makePosteriors2(num_quant_bits); }
-
-    // debug
-    void savePosteriors(String url, bool append=false);
-    void savePosteriors2(String url, bool append=false);
-
-private:
-    int classes_;
-    int depth_;
-    int num_leaves_;
-    std::vector<RTreeNode> nodes_;
-    float **posteriors_;        // 16-bytes aligned posteriors
-    uchar **posteriors2_;     // 16-bytes aligned posteriors
-    std::vector<int> leaf_counts_;
-
-    void createNodes(int num_nodes, RNG &rng);
-    void allocPosteriorsAligned(int num_leaves, int num_classes);
-    void freePosteriors(int which);    // which: 1=posteriors_, 2=posteriors2_, 3=both
-    void init(int classes, int depth, RNG &rng);
-    void addExample(int class_id, uchar* patch_data);
-    void finalize(size_t reduced_num_dim, int num_quant_bits);
-    int getIndex(uchar* patch_data) const;
-    inline float* getPosteriorByIndex(int index);
-    inline const float* getPosteriorByIndex(int index) const;
-    inline uchar* getPosteriorByIndex2(int index);
-    inline const uchar* getPosteriorByIndex2(int index) const;
-    //void makeRandomMeasMatrix(float *cs_phi, PHI_DISTR_TYPE dt, size_t reduced_num_dim);
-    void convertPosteriorsToChar();
-    void makePosteriors2(int num_quant_bits);
-    void compressLeaves(size_t reduced_num_dim);
-    void estimateQuantPercForPosteriors(float perc[2]);
-};
-
-
-inline uchar* getData(IplImage* image)
-{
-    return reinterpret_cast<uchar*>(image->imageData);
-}
-
-inline float* RandomizedTree::getPosteriorByIndex(int index)
-{
-    return const_cast<float*>(const_cast<const RandomizedTree*>(this)->getPosteriorByIndex(index));
-}
-
-inline const float* RandomizedTree::getPosteriorByIndex(int index) const
-{
-    return posteriors_[index];
-}
-
-inline uchar* RandomizedTree::getPosteriorByIndex2(int index)
-{
-    return const_cast<uchar*>(const_cast<const RandomizedTree*>(this)->getPosteriorByIndex2(index));
-}
-
-inline const uchar* RandomizedTree::getPosteriorByIndex2(int index) const
-{
-    return posteriors2_[index];
-}
-
-struct CV_EXPORTS RTreeNode
-{
-    short offset1, offset2;
-
-    RTreeNode() {}
-    RTreeNode(uchar x1, uchar y1, uchar x2, uchar y2)
-    : offset1(y1*RandomizedTree::PATCH_SIZE + x1),
-    offset2(y2*RandomizedTree::PATCH_SIZE + x2)
-    {}
-
-    //! Left child on 0, right child on 1
-    inline bool operator() (uchar* patch_data) const
-    {
-        return patch_data[offset1] > patch_data[offset2];
-    }
-};
-
-class CV_EXPORTS RTreeClassifier
-{
-public:
-    static const int DEFAULT_TREES = 48;
-    static const size_t DEFAULT_NUM_QUANT_BITS = 4;
-
-    RTreeClassifier();
-    void train(std::vector<BaseKeypoint> const& base_set,
-               RNG &rng,
-               int num_trees = RTreeClassifier::DEFAULT_TREES,
-               int depth = RandomizedTree::DEFAULT_DEPTH,
-               int views = RandomizedTree::DEFAULT_VIEWS,
-               size_t reduced_num_dim = RandomizedTree::DEFAULT_REDUCED_NUM_DIM,
-               int num_quant_bits = DEFAULT_NUM_QUANT_BITS);
-    void train(std::vector<BaseKeypoint> const& base_set,
-               RNG &rng,
-               PatchGenerator &make_patch,
-               int num_trees = RTreeClassifier::DEFAULT_TREES,
-               int depth = RandomizedTree::DEFAULT_DEPTH,
-               int views = RandomizedTree::DEFAULT_VIEWS,
-               size_t reduced_num_dim = RandomizedTree::DEFAULT_REDUCED_NUM_DIM,
-               int num_quant_bits = DEFAULT_NUM_QUANT_BITS);
-
-    // sig must point to a memory block of at least classes()*sizeof(float|uchar) bytes
-    void getSignature(IplImage *patch, uchar *sig) const;
-    void getSignature(IplImage *patch, float *sig) const;
-    void getSparseSignature(IplImage *patch, float *sig, float thresh) const;
-    // TODO: deprecated in favor of getSignature overload, remove
-    void getFloatSignature(IplImage *patch, float *sig) const { getSignature(patch, sig); }
-
-    static int countNonZeroElements(float *vec, int n, double tol=1e-10);
-    static inline void safeSignatureAlloc(uchar **sig, int num_sig=1, int sig_len=176);
-    static inline uchar* safeSignatureAlloc(int num_sig=1, int sig_len=176);
-
-    inline int classes() const { return classes_; }
-    inline int original_num_classes() const { return original_num_classes_; }
-
-    void setQuantization(int num_quant_bits);
-    void discardFloatPosteriors();
-
-    void read(const char* file_name);
-    void read(std::istream &is);
-    void write(const char* file_name) const;
-    void write(std::ostream &os) const;
-
-    // experimental and debug
-    void saveAllFloatPosteriors(String file_url);
-    void saveAllBytePosteriors(String file_url);
-    void setFloatPosteriorsFromTextfile_176(String url);
-    float countZeroElements();
-
-    std::vector<RandomizedTree> trees_;
-
-private:
-    int classes_;
-    int num_quant_bits_;
-    mutable uchar **posteriors_;
-    mutable unsigned short *ptemp_;
-    int original_num_classes_;
-    bool keep_floats_;
-};
-
-/****************************************************************************************\
-*                                     One-Way Descriptor                                 *
-\****************************************************************************************/
-
-// CvAffinePose: defines a parameterized affine transformation of an image patch.
-// An image patch is rotated on angle phi (in degrees), then scaled lambda1 times
-// along horizontal and lambda2 times along vertical direction, and then rotated again
-// on angle (theta - phi).
-class CV_EXPORTS CvAffinePose
-{
-public:
-    float phi;
-    float theta;
-    float lambda1;
-    float lambda2;
-};
-
-class CV_EXPORTS OneWayDescriptor
-{
-public:
-    OneWayDescriptor();
-    ~OneWayDescriptor();
-
-    // allocates memory for given descriptor parameters
-    void Allocate(int pose_count, CvSize size, int nChannels);
-
-    // GenerateSamples: generates affine transformed patches with averaging them over small transformation variations.
-    // If external poses and transforms were specified, uses them instead of generating random ones
-    // - pose_count: the number of poses to be generated
-    // - frontal: the input patch (can be a roi in a larger image)
-    // - norm: if nonzero, normalizes the output patch so that the sum of pixel intensities is 1
-    void GenerateSamples(int pose_count, IplImage* frontal, int norm = 0);
-
-    // GenerateSamplesFast: generates affine transformed patches with averaging them over small transformation variations.
-    // Uses precalculated transformed pca components.
-    // - frontal: the input patch (can be a roi in a larger image)
-    // - pca_hr_avg: pca average vector
-    // - pca_hr_eigenvectors: pca eigenvectors
-    // - pca_descriptors: an array of precomputed descriptors of pca components containing their affine transformations
-    //   pca_descriptors[0] corresponds to the average, pca_descriptors[1]-pca_descriptors[pca_dim] correspond to eigenvectors
-    void GenerateSamplesFast(IplImage* frontal, CvMat* pca_hr_avg,
-                             CvMat* pca_hr_eigenvectors, OneWayDescriptor* pca_descriptors);
-
-    // sets the poses and corresponding transforms
-    void SetTransforms(CvAffinePose* poses, CvMat** transforms);
-
-    // Initialize: builds a descriptor.
-    // - pose_count: the number of poses to build. If poses were set externally, uses them rather than generating random ones
-    // - frontal: input patch. Can be a roi in a larger image
-    // - feature_name: the feature name to be associated with the descriptor
-    // - norm: if 1, the affine transformed patches are normalized so that their sum is 1
-    void Initialize(int pose_count, IplImage* frontal, const char* feature_name = 0, int norm = 0);
-
-    // InitializeFast: builds a descriptor using precomputed descriptors of pca components
-    // - pose_count: the number of poses to build
-    // - frontal: input patch. Can be a roi in a larger image
-    // - feature_name: the feature name to be associated with the descriptor
-    // - pca_hr_avg: average vector for PCA
-    // - pca_hr_eigenvectors: PCA eigenvectors (one vector per row)
-    // - pca_descriptors: precomputed descriptors of PCA components, the first descriptor for the average vector
-    // followed by the descriptors for eigenvectors
-    void InitializeFast(int pose_count, IplImage* frontal, const char* feature_name,
-                        CvMat* pca_hr_avg, CvMat* pca_hr_eigenvectors, OneWayDescriptor* pca_descriptors);
-
-    // ProjectPCASample: unwarps an image patch into a vector and projects it into PCA space
-    // - patch: input image patch
-    // - avg: PCA average vector
-    // - eigenvectors: PCA eigenvectors, one per row
-    // - pca_coeffs: output PCA coefficients
-    void ProjectPCASample(IplImage* patch, CvMat* avg, CvMat* eigenvectors, CvMat* pca_coeffs) const;
-
-    // InitializePCACoeffs: projects all warped patches into PCA space
-    // - avg: PCA average vector
-    // - eigenvectors: PCA eigenvectors, one per row
-    void InitializePCACoeffs(CvMat* avg, CvMat* eigenvectors);
-
-    // EstimatePose: finds the closest match between an input patch and a set of patches with different poses
-    // - patch: input image patch
-    // - pose_idx: the output index of the closest pose
-    // - distance: the distance to the closest pose (L2 distance)
-    void EstimatePose(IplImage* patch, int& pose_idx, float& distance) const;
-
-    // EstimatePosePCA: finds the closest match between an input patch and a set of patches with different poses.
-    // The distance between patches is computed in PCA space
-    // - patch: input image patch
-    // - pose_idx: the output index of the closest pose
-    // - distance: distance to the closest pose (L2 distance in PCA space)
-    // - avg: PCA average vector. If 0, matching without PCA is used
-    // - eigenvectors: PCA eigenvectors, one per row
-    void EstimatePosePCA(CvArr* patch, int& pose_idx, float& distance, CvMat* avg, CvMat* eigenvalues) const;
-
-    // GetPatchSize: returns the size of each image patch after warping (2 times smaller than the input patch)
-    CvSize GetPatchSize() const
-    {
-        return m_patch_size;
-    }
-
-    // GetInputPatchSize: returns the required size of the patch that the descriptor is built from
-    // (2 time larger than the patch after warping)
-    CvSize GetInputPatchSize() const
-    {
-        return cvSize(m_patch_size.width*2, m_patch_size.height*2);
-    }
-
-    // GetPatch: returns a patch corresponding to specified pose index
-    // - index: pose index
-    // - return value: the patch corresponding to specified pose index
-    IplImage* GetPatch(int index);
-
-    // GetPose: returns a pose corresponding to specified pose index
-    // - index: pose index
-    // - return value: the pose corresponding to specified pose index
-    CvAffinePose GetPose(int index) const;
-
-    // Save: saves all patches with different poses to a specified path
-    void Save(const char* path);
-
-    // ReadByName: reads a descriptor from a file storage
-    // - fs: file storage
-    // - parent: parent node
-    // - name: node name
-    // - return value: 1 if succeeded, 0 otherwise
-    int ReadByName(CvFileStorage* fs, CvFileNode* parent, const char* name);
-
-    // ReadByName: reads a descriptor from a file node
-    // - parent: parent node
-    // - name: node name
-    // - return value: 1 if succeeded, 0 otherwise
-    int ReadByName(const FileNode &parent, const char* name);
-
-    // Write: writes a descriptor into a file storage
-    // - fs: file storage
-    // - name: node name
-    void Write(CvFileStorage* fs, const char* name);
-
-    // GetFeatureName: returns a name corresponding to a feature
-    const char* GetFeatureName() const;
-
-    // GetCenter: returns the center of the feature
-    CvPoint GetCenter() const;
-
-    void SetPCADimHigh(int pca_dim_high) {m_pca_dim_high = pca_dim_high;};
-    void SetPCADimLow(int pca_dim_low) {m_pca_dim_low = pca_dim_low;};
-
-    int GetPCADimLow() const;
-    int GetPCADimHigh() const;
-
-    CvMat** GetPCACoeffs() const {return m_pca_coeffs;}
-
-protected:
-    int m_pose_count; // the number of poses
-    CvSize m_patch_size; // size of each image
-    IplImage** m_samples; // an array of length m_pose_count containing the patch in different poses
-    IplImage* m_input_patch;
-    IplImage* m_train_patch;
-    CvMat** m_pca_coeffs; // an array of length m_pose_count containing pca decomposition of the patch in different poses
-    CvAffinePose* m_affine_poses; // an array of poses
-    CvMat** m_transforms; // an array of affine transforms corresponding to poses
-
-    String m_feature_name; // the name of the feature associated with the descriptor
-    CvPoint m_center; // the coordinates of the feature (the center of the input image ROI)
-
-    int m_pca_dim_high; // the number of descriptor pca components to use for generating affine poses
-    int m_pca_dim_low; // the number of pca components to use for comparison
-};
-
-
-// OneWayDescriptorBase: encapsulates functionality for training/loading a set of one way descriptors
-// and finding the nearest closest descriptor to an input feature
-class CV_EXPORTS OneWayDescriptorBase
-{
-public:
-
-    // creates an instance of OneWayDescriptor from a set of training files
-    // - patch_size: size of the input (large) patch
-    // - pose_count: the number of poses to generate for each descriptor
-    // - train_path: path to training files
-    // - pca_config: the name of the file that contains PCA for small patches (2 times smaller
-    // than patch_size each dimension
-    // - pca_hr_config: the name of the file that contains PCA for large patches (of patch_size size)
-    // - pca_desc_config: the name of the file that contains descriptors of PCA components
-    OneWayDescriptorBase(CvSize patch_size, int pose_count, const char* train_path = 0, const char* pca_config = 0,
-                         const char* pca_hr_config = 0, const char* pca_desc_config = 0, int pyr_levels = 1,
-                         int pca_dim_high = 100, int pca_dim_low = 100);
-
-    OneWayDescriptorBase(CvSize patch_size, int pose_count, const String &pca_filename, const String &train_path = String(), const String &images_list = String(),
-                         float _scale_min = 0.7f, float _scale_max=1.5f, float _scale_step=1.2f, int pyr_levels = 1,
-                         int pca_dim_high = 100, int pca_dim_low = 100);
-
-
-    virtual ~OneWayDescriptorBase();
-    void clear ();
-
-
-    // Allocate: allocates memory for a given number of descriptors
-    void Allocate(int train_feature_count);
-
-    // AllocatePCADescriptors: allocates memory for pca descriptors
-    void AllocatePCADescriptors();
-
-    // returns patch size
-    CvSize GetPatchSize() const {return m_patch_size;};
-    // returns the number of poses for each descriptor
-    int GetPoseCount() const {return m_pose_count;};
-
-    // returns the number of pyramid levels
-    int GetPyrLevels() const {return m_pyr_levels;};
-
-    // returns the number of descriptors
-    int GetDescriptorCount() const {return m_train_feature_count;};
-
-    // CreateDescriptorsFromImage: creates descriptors for each of the input features
-    // - src: input image
-    // - features: input features
-    // - pyr_levels: the number of pyramid levels
-    void CreateDescriptorsFromImage(IplImage* src, const std::vector<KeyPoint>& features);
-
-    // CreatePCADescriptors: generates descriptors for PCA components, needed for fast generation of feature descriptors
-    void CreatePCADescriptors();
-
-    // returns a feature descriptor by feature index
-    const OneWayDescriptor* GetDescriptor(int desc_idx) const {return &m_descriptors[desc_idx];};
-
-    // FindDescriptor: finds the closest descriptor
-    // - patch: input image patch
-    // - desc_idx: output index of the closest descriptor to the input patch
-    // - pose_idx: output index of the closest pose of the closest descriptor to the input patch
-    // - distance: distance from the input patch to the closest feature pose
-    // - _scales: scales of the input patch for each descriptor
-    // - scale_ranges: input scales variation (float[2])
-    void FindDescriptor(IplImage* patch, int& desc_idx, int& pose_idx, float& distance, float* _scale = 0, float* scale_ranges = 0) const;
-
-    // - patch: input image patch
-    // - n: number of the closest indexes
-    // - desc_idxs: output indexes of the closest descriptor to the input patch (n)
-    // - pose_idx: output indexes of the closest pose of the closest descriptor to the input patch (n)
-    // - distances: distance from the input patch to the closest feature pose (n)
-    // - _scales: scales of the input patch
-    // - scale_ranges: input scales variation (float[2])
-    void FindDescriptor(IplImage* patch, int n, std::vector<int>& desc_idxs, std::vector<int>& pose_idxs,
-                        std::vector<float>& distances, std::vector<float>& _scales, float* scale_ranges = 0) const;
-
-    // FindDescriptor: finds the closest descriptor
-    // - src: input image
-    // - pt: center of the feature
-    // - desc_idx: output index of the closest descriptor to the input patch
-    // - pose_idx: output index of the closest pose of the closest descriptor to the input patch
-    // - distance: distance from the input patch to the closest feature pose
-    void FindDescriptor(IplImage* src, cv::Point2f pt, int& desc_idx, int& pose_idx, float& distance) const;
-
-    // InitializePoses: generates random poses
-    void InitializePoses();
-
-    // InitializeTransformsFromPoses: generates 2x3 affine matrices from poses (initializes m_transforms)
-    void InitializeTransformsFromPoses();
-
-    // InitializePoseTransforms: subsequently calls InitializePoses and InitializeTransformsFromPoses
-    void InitializePoseTransforms();
-
-    // InitializeDescriptor: initializes a descriptor
-    // - desc_idx: descriptor index
-    // - train_image: image patch (ROI is supported)
-    // - feature_label: feature textual label
-    void InitializeDescriptor(int desc_idx, IplImage* train_image, const char* feature_label);
-
-    void InitializeDescriptor(int desc_idx, IplImage* train_image, const KeyPoint& keypoint, const char* feature_label);
-
-    // InitializeDescriptors: load features from an image and create descriptors for each of them
-    void InitializeDescriptors(IplImage* train_image, const std::vector<KeyPoint>& features,
-                               const char* feature_label = "", int desc_start_idx = 0);
-
-    // Write: writes this object to a file storage
-    // - fs: output filestorage
-    void Write (FileStorage &fs) const;
-
-    // Read: reads OneWayDescriptorBase object from a file node
-    // - fn: input file node
-    void Read (const FileNode &fn);
-
-    // LoadPCADescriptors: loads PCA descriptors from a file
-    // - filename: input filename
-    int LoadPCADescriptors(const char* filename);
-
-    // LoadPCADescriptors: loads PCA descriptors from a file node
-    // - fn: input file node
-    int LoadPCADescriptors(const FileNode &fn);
-
-    // SavePCADescriptors: saves PCA descriptors to a file
-    // - filename: output filename
-    void SavePCADescriptors(const char* filename);
-
-    // SavePCADescriptors: saves PCA descriptors to a file storage
-    // - fs: output file storage
-    void SavePCADescriptors(CvFileStorage* fs) const;
-
-    // GeneratePCA: calculate and save PCA components and descriptors
-    // - img_path: path to training PCA images directory
-    // - images_list: filename with filenames of training PCA images
-    void GeneratePCA(const char* img_path, const char* images_list, int pose_count=500);
-
-    // SetPCAHigh: sets the high resolution pca matrices (copied to internal structures)
-    void SetPCAHigh(CvMat* avg, CvMat* eigenvectors);
-
-    // SetPCALow: sets the low resolution pca matrices (copied to internal structures)
-    void SetPCALow(CvMat* avg, CvMat* eigenvectors);
-
-    int GetLowPCA(CvMat** avg, CvMat** eigenvectors)
-    {
-        *avg = m_pca_avg;
-        *eigenvectors = m_pca_eigenvectors;
-        return m_pca_dim_low;
-    };
-
-    int GetPCADimLow() const {return m_pca_dim_low;};
-    int GetPCADimHigh() const {return m_pca_dim_high;};
-
-    void ConvertDescriptorsArrayToTree(); // Converting pca_descriptors array to KD tree
-
-    // GetPCAFilename: get default PCA filename
-    static String GetPCAFilename () { return "pca.yml"; }
-
-    virtual bool empty() const { return m_train_feature_count <= 0 ? true : false; }
-
-protected:
-    CvSize m_patch_size; // patch size
-    int m_pose_count; // the number of poses for each descriptor
-    int m_train_feature_count; // the number of the training features
-    OneWayDescriptor* m_descriptors; // array of train feature descriptors
-    CvMat* m_pca_avg; // PCA average Vector for small patches
-    CvMat* m_pca_eigenvectors; // PCA eigenvectors for small patches
-    CvMat* m_pca_hr_avg; // PCA average Vector for large patches
-    CvMat* m_pca_hr_eigenvectors; // PCA eigenvectors for large patches
-    OneWayDescriptor* m_pca_descriptors; // an array of PCA descriptors
-
-    cv::flann::Index* m_pca_descriptors_tree;
-    CvMat* m_pca_descriptors_matrix;
-
-    CvAffinePose* m_poses; // array of poses
-    CvMat** m_transforms; // array of affine transformations corresponding to poses
-
-    int m_pca_dim_high;
-    int m_pca_dim_low;
-
-    int m_pyr_levels;
-    float scale_min;
-    float scale_max;
-    float scale_step;
-
-    // SavePCAall: saves PCA components and descriptors to a file storage
-    // - fs: output file storage
-    void SavePCAall (FileStorage &fs) const;
-
-    // LoadPCAall: loads PCA components and descriptors from a file node
-    // - fn: input file node
-    void LoadPCAall (const FileNode &fn);
-};
-
-class CV_EXPORTS OneWayDescriptorObject : public OneWayDescriptorBase
-{
-public:
-    // creates an instance of OneWayDescriptorObject from a set of training files
-    // - patch_size: size of the input (large) patch
-    // - pose_count: the number of poses to generate for each descriptor
-    // - train_path: path to training files
-    // - pca_config: the name of the file that contains PCA for small patches (2 times smaller
-    // than patch_size each dimension
-    // - pca_hr_config: the name of the file that contains PCA for large patches (of patch_size size)
-    // - pca_desc_config: the name of the file that contains descriptors of PCA components
-    OneWayDescriptorObject(CvSize patch_size, int pose_count, const char* train_path, const char* pca_config,
-                           const char* pca_hr_config = 0, const char* pca_desc_config = 0, int pyr_levels = 1);
-
-    OneWayDescriptorObject(CvSize patch_size, int pose_count, const String &pca_filename,
-                           const String &train_path = String (), const String &images_list = String (),
-                           float _scale_min = 0.7f, float _scale_max=1.5f, float _scale_step=1.2f, int pyr_levels = 1);
-
-
-    virtual ~OneWayDescriptorObject();
-
-    // Allocate: allocates memory for a given number of features
-    // - train_feature_count: the total number of features
-    // - object_feature_count: the number of features extracted from the object
-    void Allocate(int train_feature_count, int object_feature_count);
-
-
-    void SetLabeledFeatures(const std::vector<KeyPoint>& features) {m_train_features = features;};
-    std::vector<KeyPoint>& GetLabeledFeatures() {return m_train_features;};
-    const std::vector<KeyPoint>& GetLabeledFeatures() const {return m_train_features;};
-    std::vector<KeyPoint> _GetLabeledFeatures() const;
-
-    // IsDescriptorObject: returns 1 if descriptor with specified index is positive, otherwise 0
-    int IsDescriptorObject(int desc_idx) const;
-
-    // MatchPointToPart: returns the part number of a feature if it matches one of the object parts, otherwise -1
-    int MatchPointToPart(CvPoint pt) const;
-
-    // GetDescriptorPart: returns the part number of the feature corresponding to a specified descriptor
-    // - desc_idx: descriptor index
-    int GetDescriptorPart(int desc_idx) const;
-
-
-    void InitializeObjectDescriptors(IplImage* train_image, const std::vector<KeyPoint>& features,
-                                     const char* feature_label, int desc_start_idx = 0, float scale = 1.0f,
-                                     int is_background = 0);
-
-    // GetObjectFeatureCount: returns the number of object features
-    int GetObjectFeatureCount() const {return m_object_feature_count;};
-
-protected:
-    int* m_part_id; // contains part id for each of object descriptors
-    std::vector<KeyPoint> m_train_features; // train features
-    int m_object_feature_count; // the number of the positive features
-
-};
-
-
-/*
- *  OneWayDescriptorMatcher
- */
-class OneWayDescriptorMatcher;
-typedef OneWayDescriptorMatcher OneWayDescriptorMatch;
-
-class CV_EXPORTS OneWayDescriptorMatcher : public GenericDescriptorMatcher
-{
-public:
-    class CV_EXPORTS Params
-    {
-    public:
-        static const int POSE_COUNT = 500;
-        static const int PATCH_WIDTH = 24;
-        static const int PATCH_HEIGHT = 24;
-        static float GET_MIN_SCALE() { return 0.7f; }
-        static float GET_MAX_SCALE() { return 1.5f; }
-        static float GET_STEP_SCALE() { return 1.2f; }
-
-        Params( int poseCount = POSE_COUNT,
-               Size patchSize = Size(PATCH_WIDTH, PATCH_HEIGHT),
-               String pcaFilename = String(),
-               String trainPath = String(), String trainImagesList = String(),
-               float minScale = GET_MIN_SCALE(), float maxScale = GET_MAX_SCALE(),
-               float stepScale = GET_STEP_SCALE() );
-
-        int poseCount;
-        Size patchSize;
-        String pcaFilename;
-        String trainPath;
-        String trainImagesList;
-
-        float minScale, maxScale, stepScale;
-    };
-
-    OneWayDescriptorMatcher( const Params& params=Params() );
-    virtual ~OneWayDescriptorMatcher();
-
-    void initialize( const Params& params, const Ptr<OneWayDescriptorBase>& base=Ptr<OneWayDescriptorBase>() );
-
-    // Clears keypoints storing in collection and OneWayDescriptorBase
-    virtual void clear();
-
-    virtual void train();
-
-    virtual bool isMaskSupported();
-
-    virtual void read( const FileNode &fn );
-    virtual void write( FileStorage& fs ) const;
-
-    virtual bool empty() const;
-
-    virtual Ptr<GenericDescriptorMatcher> clone( bool emptyTrainData=false ) const;
-
-protected:
-    // Matches a set of keypoints from a single image of the training set. A rectangle with a center in a keypoint
-    // and size (patch_width/2*scale, patch_height/2*scale) is cropped from the source image for each
-    // keypoint. scale is iterated from DescriptorOneWayParams::min_scale to DescriptorOneWayParams::max_scale.
-    // The minimum distance to each training patch with all its affine poses is found over all scales.
-    // The class ID of a match is returned for each keypoint. The distance is calculated over PCA components
-    // loaded with DescriptorOneWay::Initialize, kd tree is used for finding minimum distances.
-    virtual void knnMatchImpl( InputArray queryImage, std::vector<KeyPoint>& queryKeypoints,
-                              std::vector<std::vector<DMatch> >& matches, int k,
-                              InputArrayOfArrays masks, bool compactResult );
-    virtual void radiusMatchImpl( InputArray queryImage, std::vector<KeyPoint>& queryKeypoints,
-                                 std::vector<std::vector<DMatch> >& matches, float maxDistance,
-                                 InputArrayOfArrays masks, bool compactResult );
-
-    Ptr<OneWayDescriptorBase> base;
-    Params params;
-    int prevTrainCount;
-};
-
-/*
- *  FernDescriptorMatcher
- */
-class FernDescriptorMatcher;
-typedef FernDescriptorMatcher FernDescriptorMatch;
-
-class CV_EXPORTS FernDescriptorMatcher : public GenericDescriptorMatcher
-{
-public:
-    class CV_EXPORTS Params
-    {
-    public:
-        Params( int nclasses=0,
-               int patchSize=FernClassifier::PATCH_SIZE,
-               int signatureSize=FernClassifier::DEFAULT_SIGNATURE_SIZE,
-               int nstructs=FernClassifier::DEFAULT_STRUCTS,
-               int structSize=FernClassifier::DEFAULT_STRUCT_SIZE,
-               int nviews=FernClassifier::DEFAULT_VIEWS,
-               int compressionMethod=FernClassifier::COMPRESSION_NONE,
-               const PatchGenerator& patchGenerator=PatchGenerator() );
-
-        Params( const String& filename );
-
-        int nclasses;
-        int patchSize;
-        int signatureSize;
-        int nstructs;
-        int structSize;
-        int nviews;
-        int compressionMethod;
-        PatchGenerator patchGenerator;
-
-        String filename;
-    };
-
-    FernDescriptorMatcher( const Params& params=Params() );
-    virtual ~FernDescriptorMatcher();
-
-    virtual void clear();
-
-    virtual void train();
-
-    virtual bool isMaskSupported();
-
-    virtual void read( const FileNode &fn );
-    virtual void write( FileStorage& fs ) const;
-    virtual bool empty() const;
-
-    virtual Ptr<GenericDescriptorMatcher> clone( bool emptyTrainData=false ) const;
-
-protected:
-    virtual void knnMatchImpl( InputArray queryImage, std::vector<KeyPoint>& queryKeypoints,
-                              std::vector<std::vector<DMatch> >& matches, int k,
-                              InputArrayOfArrays masks, bool compactResult );
-    virtual void radiusMatchImpl( InputArray queryImage, std::vector<KeyPoint>& queryKeypoints,
-                                 std::vector<std::vector<DMatch> >& matches, float maxDistance,
-                                 InputArrayOfArrays masks, bool compactResult );
-
-    void trainFernClassifier();
-    void calcBestProbAndMatchIdx( const Mat& image, const Point2f& pt,
-                                 float& bestProb, int& bestMatchIdx, std::vector<float>& signature );
-    Ptr<FernClassifier> classifier;
-    Params params;
-    int prevTrainCount;
-};
-
-
-/*
- * CalonderDescriptorExtractor
- */
-template<typename T>
-class CV_EXPORTS CalonderDescriptorExtractor : public DescriptorExtractor
-{
-public:
-    CalonderDescriptorExtractor( const String& classifierFile );
-
-    virtual void read( const FileNode &fn );
-    virtual void write( FileStorage &fs ) const;
-
-    virtual int descriptorSize() const { return classifier_.classes(); }
-    virtual int descriptorType() const { return DataType<T>::type; }
-    virtual int defaultNorm() const { return NORM_L1; }
-
-    virtual bool empty() const;
-
-protected:
-    virtual void computeImpl( InputArray image, std::vector<KeyPoint>& keypoints, OutputArray descriptors ) const;
-
-    RTreeClassifier classifier_;
-    static const int BORDER_SIZE = 16;
-};
-
-template<typename T>
-CalonderDescriptorExtractor<T>::CalonderDescriptorExtractor(const String& classifier_file)
-{
-    classifier_.read( classifier_file.c_str() );
-}
-
-template<typename T>
-void CalonderDescriptorExtractor<T>::computeImpl( InputArray _image,
-                                                 std::vector<KeyPoint>& keypoints,
-                                                 OutputArray _descriptors) const
-{
-    Mat image = _image.getMat(), descriptors;
-    // Cannot compute descriptors for keypoints on the image border.
-    KeyPointsFilter::runByImageBorder(keypoints, image.size(), BORDER_SIZE);
-
-    /// @todo Check 16-byte aligned
-    _descriptors.create((int)keypoints.size(), classifier_.classes(), cv::DataType<T>::type);
-     descriptors = _descriptors.getMat();
-
-    int patchSize = RandomizedTree::PATCH_SIZE;
-    int offset = patchSize / 2;
-    for (size_t i = 0; i < keypoints.size(); ++i)
-    {
-        cv::Point2f pt = keypoints[i].pt;
-        IplImage ipl = image( Rect((int)(pt.x - offset), (int)(pt.y - offset), patchSize, patchSize) );
-        classifier_.getSignature( &ipl, descriptors.ptr<T>((int)i));
-    }
-}
-
-template<typename T>
-void CalonderDescriptorExtractor<T>::read( const FileNode& )
-{}
-
-template<typename T>
-void CalonderDescriptorExtractor<T>::write( FileStorage& ) const
-{}
-
-template<typename T>
-bool CalonderDescriptorExtractor<T>::empty() const
-{
-    return classifier_.trees_.empty();
-}
-
-
-////////////////////// Brute Force Matcher //////////////////////////
-
-template<class Distance>
-class CV_EXPORTS BruteForceMatcher : public BFMatcher
-{
-public:
-    BruteForceMatcher( Distance d = Distance() ) : BFMatcher(Distance::normType, false) {(void)d;}
-    virtual ~BruteForceMatcher() {}
-};
-
-
-/****************************************************************************************\
-*                                Planar Object Detection                                 *
-\****************************************************************************************/
-
-class CV_EXPORTS PlanarObjectDetector
-{
-public:
-    PlanarObjectDetector();
-    PlanarObjectDetector(const FileNode& node);
-    PlanarObjectDetector(const std::vector<Mat>& pyr, int _npoints=300,
-                         int _patchSize=FernClassifier::PATCH_SIZE,
-                         int _nstructs=FernClassifier::DEFAULT_STRUCTS,
-                         int _structSize=FernClassifier::DEFAULT_STRUCT_SIZE,
-                         int _nviews=FernClassifier::DEFAULT_VIEWS,
-                         const LDetector& detector=LDetector(),
-                         const PatchGenerator& patchGenerator=PatchGenerator());
-    virtual ~PlanarObjectDetector();
-    virtual void train(const std::vector<Mat>& pyr, int _npoints=300,
-                       int _patchSize=FernClassifier::PATCH_SIZE,
-                       int _nstructs=FernClassifier::DEFAULT_STRUCTS,
-                       int _structSize=FernClassifier::DEFAULT_STRUCT_SIZE,
-                       int _nviews=FernClassifier::DEFAULT_VIEWS,
-                       const LDetector& detector=LDetector(),
-                       const PatchGenerator& patchGenerator=PatchGenerator());
-    virtual void train(const std::vector<Mat>& pyr, const std::vector<KeyPoint>& keypoints,
-                       int _patchSize=FernClassifier::PATCH_SIZE,
-                       int _nstructs=FernClassifier::DEFAULT_STRUCTS,
-                       int _structSize=FernClassifier::DEFAULT_STRUCT_SIZE,
-                       int _nviews=FernClassifier::DEFAULT_VIEWS,
-                       const LDetector& detector=LDetector(),
-                       const PatchGenerator& patchGenerator=PatchGenerator());
-    Rect getModelROI() const;
-    std::vector<KeyPoint> getModelPoints() const;
-    const LDetector& getDetector() const;
-    const FernClassifier& getClassifier() const;
-    void setVerbose(bool verbose);
-
-    void read(const FileNode& node);
-    void write(FileStorage& fs, const String& name=String()) const;
-    bool operator()(const Mat& image, CV_OUT Mat& H, CV_OUT std::vector<Point2f>& corners) const;
-    bool operator()(const std::vector<Mat>& pyr, const std::vector<KeyPoint>& keypoints,
-                    CV_OUT Mat& H, CV_OUT std::vector<Point2f>& corners,
-                    CV_OUT std::vector<int>* pairs=0) const;
-
-protected:
-    bool verbose;
-    Rect modelROI;
-    std::vector<KeyPoint> modelPoints;
-    LDetector ldetector;
-    FernClassifier fernClassifier;
-};
-
-}
-
-// 2009-01-12, Xavier Delacour <xavier.delacour@gmail.com>
-
-struct lsh_hash {
-    int h1, h2;
-};
-
-struct CvLSHOperations
-{
-    virtual ~CvLSHOperations() {}
-
-    virtual int vector_add(const void* data) = 0;
-    virtual void vector_remove(int i) = 0;
-    virtual const void* vector_lookup(int i) = 0;
-    virtual void vector_reserve(int n) = 0;
-    virtual unsigned int vector_count() = 0;
-
-    virtual void hash_insert(lsh_hash h, int l, int i) = 0;
-    virtual void hash_remove(lsh_hash h, int l, int i) = 0;
-    virtual int hash_lookup(lsh_hash h, int l, int* ret_i, int ret_i_max) = 0;
-};
-
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Splits color or grayscale image into multiple connected components
- of nearly the same color/brightness using modification of Burt algorithm.
- comp with contain a pointer to sequence (CvSeq)
- of connected components (CvConnectedComp) */
-CVAPI(void) cvPyrSegmentation( IplImage* src, IplImage* dst,
-                              CvMemStorage* storage, CvSeq** comp,
-                              int level, double threshold1,
-                              double threshold2 );
-
-/****************************************************************************************\
-*                              Planar subdivisions                                       *
-\****************************************************************************************/
-
-typedef size_t CvSubdiv2DEdge;
-
-#define CV_QUADEDGE2D_FIELDS()     \
-    int flags;                     \
-    struct CvSubdiv2DPoint* pt[4]; \
-    CvSubdiv2DEdge  next[4];
-
-#define CV_SUBDIV2D_POINT_FIELDS()\
-    int            flags;      \
-    CvSubdiv2DEdge first;      \
-    CvPoint2D32f   pt;         \
-    int id;
-
-#define CV_SUBDIV2D_VIRTUAL_POINT_FLAG (1 << 30)
-
-typedef struct CvQuadEdge2D
-{
-    CV_QUADEDGE2D_FIELDS()
-}
-CvQuadEdge2D;
-
-typedef struct CvSubdiv2DPoint
-{
-    CV_SUBDIV2D_POINT_FIELDS()
-}
-CvSubdiv2DPoint;
-
-#define CV_SUBDIV2D_FIELDS()    \
-    CV_GRAPH_FIELDS()           \
-    int  quad_edges;            \
-    int  is_geometry_valid;     \
-    CvSubdiv2DEdge recent_edge; \
-    CvPoint2D32f  topleft;      \
-    CvPoint2D32f  bottomright;
-
-typedef struct CvSubdiv2D
-{
-    CV_SUBDIV2D_FIELDS()
-}
-CvSubdiv2D;
-
-typedef enum CvSubdiv2DPointLocation
-{
-    CV_PTLOC_ERROR = -2,
-    CV_PTLOC_OUTSIDE_RECT = -1,
-    CV_PTLOC_INSIDE = 0,
-    CV_PTLOC_VERTEX = 1,
-    CV_PTLOC_ON_EDGE = 2
-}
-CvSubdiv2DPointLocation;
-
-typedef enum CvNextEdgeType
-{
-    CV_NEXT_AROUND_ORG   = 0x00,
-    CV_NEXT_AROUND_DST   = 0x22,
-    CV_PREV_AROUND_ORG   = 0x11,
-    CV_PREV_AROUND_DST   = 0x33,
-    CV_NEXT_AROUND_LEFT  = 0x13,
-    CV_NEXT_AROUND_RIGHT = 0x31,
-    CV_PREV_AROUND_LEFT  = 0x20,
-    CV_PREV_AROUND_RIGHT = 0x02
-}
-CvNextEdgeType;
-
-/* get the next edge with the same origin point (counterwise) */
-#define  CV_SUBDIV2D_NEXT_EDGE( edge )  (((CvQuadEdge2D*)((edge) & ~3))->next[(edge)&3])
-
-
-/* Initializes Delaunay triangulation */
-CVAPI(void)  cvInitSubdivDelaunay2D( CvSubdiv2D* subdiv, CvRect rect );
-
-/* Creates new subdivision */
-CVAPI(CvSubdiv2D*)  cvCreateSubdiv2D( int subdiv_type, int header_size,
-                                     int vtx_size, int quadedge_size,
-                                     CvMemStorage* storage );
-
-/************************* high-level subdivision functions ***************************/
-
-/* Simplified Delaunay diagram creation */
-CV_INLINE  CvSubdiv2D* cvCreateSubdivDelaunay2D( CvRect rect, CvMemStorage* storage )
-{
-    CvSubdiv2D* subdiv = cvCreateSubdiv2D( CV_SEQ_KIND_SUBDIV2D, sizeof(*subdiv),
-                                          sizeof(CvSubdiv2DPoint), sizeof(CvQuadEdge2D), storage );
-
-    cvInitSubdivDelaunay2D( subdiv, rect );
-    return subdiv;
-}
-
-
-/* Inserts new point to the Delaunay triangulation */
-CVAPI(CvSubdiv2DPoint*)  cvSubdivDelaunay2DInsert( CvSubdiv2D* subdiv, CvPoint2D32f pt);
-
-/* Locates a point within the Delaunay triangulation (finds the edge
- the point is left to or belongs to, or the triangulation point the given
- point coinsides with */
-CVAPI(CvSubdiv2DPointLocation)  cvSubdiv2DLocate(
-                                                 CvSubdiv2D* subdiv, CvPoint2D32f pt,
-                                                 CvSubdiv2DEdge* edge,
-                                                 CvSubdiv2DPoint** vertex CV_DEFAULT(NULL) );
-
-/* Calculates Voronoi tesselation (i.e. coordinates of Voronoi points) */
-CVAPI(void)  cvCalcSubdivVoronoi2D( CvSubdiv2D* subdiv );
-
-
-/* Removes all Voronoi points from the tesselation */
-CVAPI(void)  cvClearSubdivVoronoi2D( CvSubdiv2D* subdiv );
-
-
-/* Finds the nearest to the given point vertex in subdivision. */
-CVAPI(CvSubdiv2DPoint*) cvFindNearestPoint2D( CvSubdiv2D* subdiv, CvPoint2D32f pt );
-
-
-/************ Basic quad-edge navigation and operations ************/
-
-CV_INLINE  CvSubdiv2DEdge  cvSubdiv2DNextEdge( CvSubdiv2DEdge edge )
-{
-    return  CV_SUBDIV2D_NEXT_EDGE(edge);
-}
-
-
-CV_INLINE  CvSubdiv2DEdge  cvSubdiv2DRotateEdge( CvSubdiv2DEdge edge, int rotate )
-{
-    return  (edge & ~3) + ((edge + rotate) & 3);
-}
-
-CV_INLINE  CvSubdiv2DEdge  cvSubdiv2DSymEdge( CvSubdiv2DEdge edge )
-{
-    return edge ^ 2;
-}
-
-CV_INLINE  CvSubdiv2DEdge  cvSubdiv2DGetEdge( CvSubdiv2DEdge edge, CvNextEdgeType type )
-{
-    CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
-    edge = e->next[(edge + (int)type) & 3];
-    return  (edge & ~3) + ((edge + ((int)type >> 4)) & 3);
-}
-
-
-CV_INLINE  CvSubdiv2DPoint*  cvSubdiv2DEdgeOrg( CvSubdiv2DEdge edge )
-{
-    CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
-    return (CvSubdiv2DPoint*)e->pt[edge & 3];
-}
-
-
-CV_INLINE  CvSubdiv2DPoint*  cvSubdiv2DEdgeDst( CvSubdiv2DEdge edge )
-{
-    CvQuadEdge2D* e = (CvQuadEdge2D*)(edge & ~3);
-    return (CvSubdiv2DPoint*)e->pt[(edge + 2) & 3];
-}
-
-/****************************************************************************************\
-*                           Additional operations on Subdivisions                        *
-\****************************************************************************************/
-
-// paints voronoi diagram: just demo function
-CVAPI(void)  icvDrawMosaic( CvSubdiv2D* subdiv, IplImage* src, IplImage* dst );
-
-// checks planar subdivision for correctness. It is not an absolute check,
-// but it verifies some relations between quad-edges
-CVAPI(int)   icvSubdiv2DCheck( CvSubdiv2D* subdiv );
-
-// returns squared distance between two 2D points with floating-point coordinates.
-CV_INLINE double icvSqDist2D32f( CvPoint2D32f pt1, CvPoint2D32f pt2 )
-{
-    double dx = pt1.x - pt2.x;
-    double dy = pt1.y - pt2.y;
-
-    return dx*dx + dy*dy;
-}
-
-
-
-
-CV_INLINE  double  cvTriangleArea( CvPoint2D32f a, CvPoint2D32f b, CvPoint2D32f c )
-{
-    return ((double)b.x - a.x) * ((double)c.y - a.y) - ((double)b.y - a.y) * ((double)c.x - a.x);
-}
-
-
-/* Constructs kd-tree from set of feature descriptors */
-CVAPI(struct CvFeatureTree*) cvCreateKDTree(CvMat* desc);
-
-/* Constructs spill-tree from set of feature descriptors */
-CVAPI(struct CvFeatureTree*) cvCreateSpillTree( const CvMat* raw_data,
-                                               const int naive CV_DEFAULT(50),
-                                               const double rho CV_DEFAULT(.7),
-                                               const double tau CV_DEFAULT(.1) );
-
-/* Release feature tree */
-CVAPI(void) cvReleaseFeatureTree(struct CvFeatureTree* tr);
-
-/* Searches feature tree for k nearest neighbors of given reference points,
- searching (in case of kd-tree/bbf) at most emax leaves. */
-CVAPI(void) cvFindFeatures(struct CvFeatureTree* tr, const CvMat* query_points,
-                           CvMat* indices, CvMat* dist, int k, int emax CV_DEFAULT(20));
-
-/* Search feature tree for all points that are inlier to given rect region.
- Only implemented for kd trees */
-CVAPI(int) cvFindFeaturesBoxed(struct CvFeatureTree* tr,
-                               CvMat* bounds_min, CvMat* bounds_max,
-                               CvMat* out_indices);
-
-
-/* Construct a Locality Sensitive Hash (LSH) table, for indexing d-dimensional vectors of
- given type. Vectors will be hashed L times with k-dimensional p-stable (p=2) functions. */
-CVAPI(struct CvLSH*) cvCreateLSH(struct CvLSHOperations* ops, int d,
-                                 int L CV_DEFAULT(10), int k CV_DEFAULT(10),
-                                 int type CV_DEFAULT(CV_64FC1), double r CV_DEFAULT(4),
-                                 int64 seed CV_DEFAULT(-1));
-
-/* Construct in-memory LSH table, with n bins. */
-CVAPI(struct CvLSH*) cvCreateMemoryLSH(int d, int n, int L CV_DEFAULT(10), int k CV_DEFAULT(10),
-                                       int type CV_DEFAULT(CV_64FC1), double r CV_DEFAULT(4),
-                                       int64 seed CV_DEFAULT(-1));
-
-/* Free the given LSH structure. */
-CVAPI(void) cvReleaseLSH(struct CvLSH** lsh);
-
-/* Return the number of vectors in the LSH. */
-CVAPI(unsigned int) LSHSize(struct CvLSH* lsh);
-
-/* Add vectors to the LSH structure, optionally returning indices. */
-CVAPI(void) cvLSHAdd(struct CvLSH* lsh, const CvMat* data, CvMat* indices CV_DEFAULT(0));
-
-/* Remove vectors from LSH, as addressed by given indices. */
-CVAPI(void) cvLSHRemove(struct CvLSH* lsh, const CvMat* indices);
-
-/* Query the LSH n times for at most k nearest points; data is n x d,
- indices and dist are n x k. At most emax stored points will be accessed. */
-CVAPI(void) cvLSHQuery(struct CvLSH* lsh, const CvMat* query_points,
-                       CvMat* indices, CvMat* dist, int k, int emax);
-
-/* Kolmogorov-Zabin stereo-correspondence algorithm (a.k.a. KZ1) */
-#define CV_STEREO_GC_OCCLUDED  SHRT_MAX
-
-typedef struct CvStereoGCState
-{
-    int Ithreshold;
-    int interactionRadius;
-    float K, lambda, lambda1, lambda2;
-    int occlusionCost;
-    int minDisparity;
-    int numberOfDisparities;
-    int maxIters;
-
-    CvMat* left;
-    CvMat* right;
-    CvMat* dispLeft;
-    CvMat* dispRight;
-    CvMat* ptrLeft;
-    CvMat* ptrRight;
-    CvMat* vtxBuf;
-    CvMat* edgeBuf;
-} CvStereoGCState;
-
-CVAPI(CvStereoGCState*) cvCreateStereoGCState( int numberOfDisparities, int maxIters );
-CVAPI(void) cvReleaseStereoGCState( CvStereoGCState** state );
-
-CVAPI(void) cvFindStereoCorrespondenceGC( const CvArr* left, const CvArr* right,
-                                         CvArr* disparityLeft, CvArr* disparityRight,
-                                         CvStereoGCState* state,
-                                         int useDisparityGuess CV_DEFAULT(0) );
-
-/* Calculates optical flow for 2 images using classical Lucas & Kanade algorithm */
-CVAPI(void)  cvCalcOpticalFlowLK( const CvArr* prev, const CvArr* curr,
-                                 CvSize win_size, CvArr* velx, CvArr* vely );
-
-/* Calculates optical flow for 2 images using block matching algorithm */
-CVAPI(void)  cvCalcOpticalFlowBM( const CvArr* prev, const CvArr* curr,
-                                 CvSize block_size, CvSize shift_size,
-                                 CvSize max_range, int use_previous,
-                                 CvArr* velx, CvArr* vely );
-
-/* Calculates Optical flow for 2 images using Horn & Schunck algorithm */
-CVAPI(void)  cvCalcOpticalFlowHS( const CvArr* prev, const CvArr* curr,
-                                 int use_previous, CvArr* velx, CvArr* vely,
-                                 double lambda, CvTermCriteria criteria );
-
-
-/****************************************************************************************\
-*                           Background/foreground segmentation                           *
-\****************************************************************************************/
-
-/* We discriminate between foreground and background pixels
- * by building and maintaining a model of the background.
- * Any pixel which does not fit this model is then deemed
- * to be foreground.
- *
- * At present we support two core background models,
- * one of which has two variations:
- *
- *  o CV_BG_MODEL_FGD: latest and greatest algorithm, described in
- *
- *      Foreground Object Detection from Videos Containing Complex Background.
- *      Liyuan Li, Weimin Huang, Irene Y.H. Gu, and Qi Tian.
- *      ACM MM2003 9p
- *
- *  o CV_BG_MODEL_FGD_SIMPLE:
- *       A code comment describes this as a simplified version of the above,
- *       but the code is in fact currently identical
- *
- *  o CV_BG_MODEL_MOG: "Mixture of Gaussians", older algorithm, described in
- *
- *       Moving target classification and tracking from real-time video.
- *       A Lipton, H Fujijoshi, R Patil
- *       Proceedings IEEE Workshop on Application of Computer Vision pp 8-14 1998
- *
- *       Learning patterns of activity using real-time tracking
- *       C Stauffer and W Grimson  August 2000
- *       IEEE Transactions on Pattern Analysis and Machine Intelligence 22(8):747-757
- */
-
-
-#define CV_BG_MODEL_FGD                0
-#define CV_BG_MODEL_MOG                1                       /* "Mixture of Gaussians".      */
-#define CV_BG_MODEL_FGD_SIMPLE 2
-
-struct CvBGStatModel;
-
-typedef void (CV_CDECL * CvReleaseBGStatModel)( struct CvBGStatModel** bg_model );
-typedef int (CV_CDECL * CvUpdateBGStatModel)( IplImage* curr_frame, struct CvBGStatModel* bg_model,
-                                             double learningRate );
-
-#define CV_BG_STAT_MODEL_FIELDS()                                               \
-int             type; /*type of BG model*/                                      \
-CvReleaseBGStatModel release;                                                   \
-CvUpdateBGStatModel update;                                                     \
-IplImage*       background;   /*8UC3 reference background image*/               \
-IplImage*       foreground;   /*8UC1 foreground image*/                         \
-IplImage**      layers;       /*8UC3 reference background image, can be null */ \
-int             layer_count;  /* can be zero */                                 \
-CvMemStorage*   storage;      /*storage for foreground_regions*/                \
-CvSeq*          foreground_regions /*foreground object contours*/
-
-typedef struct CvBGStatModel
-{
-    CV_BG_STAT_MODEL_FIELDS();
-} CvBGStatModel;
-
-//
-
-// Releases memory used by BGStatModel
-CVAPI(void) cvReleaseBGStatModel( CvBGStatModel** bg_model );
-
-// Updates statistical model and returns number of found foreground regions
-CVAPI(int) cvUpdateBGStatModel( IplImage* current_frame, CvBGStatModel*  bg_model,
-                               double learningRate CV_DEFAULT(-1));
-
-// Performs FG post-processing using segmentation
-// (all pixels of a region will be classified as foreground if majority of pixels of the region are FG).
-// parameters:
-//      segments - pointer to result of segmentation (for example MeanShiftSegmentation)
-//      bg_model - pointer to CvBGStatModel structure
-CVAPI(void) cvRefineForegroundMaskBySegm( CvSeq* segments, CvBGStatModel*  bg_model );
-
-/* Common use change detection function */
-CVAPI(int)  cvChangeDetection( IplImage*  prev_frame,
-                              IplImage*  curr_frame,
-                              IplImage*  change_mask );
-
-/*
- Interface of ACM MM2003 algorithm
- */
-
-/* Default parameters of foreground detection algorithm: */
-#define  CV_BGFG_FGD_LC              128
-#define  CV_BGFG_FGD_N1C             15
-#define  CV_BGFG_FGD_N2C             25
-
-#define  CV_BGFG_FGD_LCC             64
-#define  CV_BGFG_FGD_N1CC            25
-#define  CV_BGFG_FGD_N2CC            40
-
-/* Background reference image update parameter: */
-#define  CV_BGFG_FGD_ALPHA_1         0.1f
-
-/* stat model update parameter
- * 0.002f ~ 1K frame(~45sec), 0.005 ~ 18sec (if 25fps and absolutely static BG)
- */
-#define  CV_BGFG_FGD_ALPHA_2         0.005f
-
-/* start value for alpha parameter (to fast initiate statistic model) */
-#define  CV_BGFG_FGD_ALPHA_3         0.1f
-
-#define  CV_BGFG_FGD_DELTA           2
-
-#define  CV_BGFG_FGD_T               0.9f
-
-#define  CV_BGFG_FGD_MINAREA         15.f
-
-#define  CV_BGFG_FGD_BG_UPDATE_TRESH 0.5f
-
-/* See the above-referenced Li/Huang/Gu/Tian paper
- * for a full description of these background-model
- * tuning parameters.
- *
- * Nomenclature:  'c'  == "color", a three-component red/green/blue vector.
- *                         We use histograms of these to model the range of
- *                         colors we've seen at a given background pixel.
- *
- *                'cc' == "color co-occurrence", a six-component vector giving
- *                         RGB color for both this frame and preceding frame.
- *                             We use histograms of these to model the range of
- *                         color CHANGES we've seen at a given background pixel.
- */
-typedef struct CvFGDStatModelParams
-{
-    int    Lc;                 /* Quantized levels per 'color' component. Power of two, typically 32, 64 or 128.                               */
-    int    N1c;                        /* Number of color vectors used to model normal background color variation at a given pixel.                    */
-    int    N2c;                        /* Number of color vectors retained at given pixel.  Must be > N1c, typically ~ 5/3 of N1c.                     */
-    /* Used to allow the first N1c vectors to adapt over time to changing background.                          */
-
-    int    Lcc;                        /* Quantized levels per 'color co-occurrence' component.  Power of two, typically 16, 32 or 64.                 */
-    int    N1cc;               /* Number of color co-occurrence vectors used to model normal background color variation at a given pixel.      */
-    int    N2cc;               /* Number of color co-occurrence vectors retained at given pixel.  Must be > N1cc, typically ~ 5/3 of N1cc.     */
-    /* Used to allow the first N1cc vectors to adapt over time to changing background.                         */
-
-    int    is_obj_without_holes;/* If TRUE we ignore holes within foreground blobs. Defaults to TRUE.                                          */
-    int    perform_morphing;   /* Number of erode-dilate-erode foreground-blob cleanup iterations.                                             */
-    /* These erase one-pixel junk blobs and merge almost-touching blobs. Default value is 1.                   */
-
-    float  alpha1;             /* How quickly we forget old background pixel values seen.  Typically set to 0.1                                */
-    float  alpha2;             /* "Controls speed of feature learning". Depends on T. Typical value circa 0.005.                               */
-    float  alpha3;             /* Alternate to alpha2, used (e.g.) for quicker initial convergence. Typical value 0.1.                         */
-
-    float  delta;              /* Affects color and color co-occurrence quantization, typically set to 2.                                      */
-    float  T;                  /* "A percentage value which determines when new features can be recognized as new background." (Typically 0.9).*/
-    float  minArea;            /* Discard foreground blobs whose bounding box is smaller than this threshold.                                  */
-} CvFGDStatModelParams;
-
-typedef struct CvBGPixelCStatTable
-{
-    float          Pv, Pvb;
-    uchar          v[3];
-} CvBGPixelCStatTable;
-
-typedef struct CvBGPixelCCStatTable
-{
-    float          Pv, Pvb;
-    uchar          v[6];
-} CvBGPixelCCStatTable;
-
-typedef struct CvBGPixelStat
-{
-    float                 Pbc;
-    float                 Pbcc;
-    CvBGPixelCStatTable*  ctable;
-    CvBGPixelCCStatTable* cctable;
-    uchar                 is_trained_st_model;
-    uchar                 is_trained_dyn_model;
-} CvBGPixelStat;
-
-
-typedef struct CvFGDStatModel
-{
-    CV_BG_STAT_MODEL_FIELDS();
-    CvBGPixelStat*         pixel_stat;
-    IplImage*              Ftd;
-    IplImage*              Fbd;
-    IplImage*              prev_frame;
-    CvFGDStatModelParams   params;
-} CvFGDStatModel;
-
-/* Creates FGD model */
-CVAPI(CvBGStatModel*) cvCreateFGDStatModel( IplImage* first_frame,
-                                           CvFGDStatModelParams* parameters CV_DEFAULT(NULL));
-
-/*
- Interface of Gaussian mixture algorithm
-
- "An improved adaptive background mixture model for real-time tracking with shadow detection"
- P. KadewTraKuPong and R. Bowden,
- Proc. 2nd European Workshp on Advanced Video-Based Surveillance Systems, 2001."
- http://personal.ee.surrey.ac.uk/Personal/R.Bowden/publications/avbs01/avbs01.pdf
- */
-
-/* Note:  "MOG" == "Mixture Of Gaussians": */
-
-#define CV_BGFG_MOG_MAX_NGAUSSIANS 500
-
-/* default parameters of gaussian background detection algorithm */
-#define CV_BGFG_MOG_BACKGROUND_THRESHOLD     0.7     /* threshold sum of weights for background test */
-#define CV_BGFG_MOG_STD_THRESHOLD            2.5     /* lambda=2.5 is 99% */
-#define CV_BGFG_MOG_WINDOW_SIZE              200     /* Learning rate; alpha = 1/CV_GBG_WINDOW_SIZE */
-#define CV_BGFG_MOG_NGAUSSIANS               5       /* = K = number of Gaussians in mixture */
-#define CV_BGFG_MOG_WEIGHT_INIT              0.05
-#define CV_BGFG_MOG_SIGMA_INIT               30
-#define CV_BGFG_MOG_MINAREA                  15.f
-
-
-#define CV_BGFG_MOG_NCOLORS                  3
-
-typedef struct CvGaussBGStatModelParams
-{
-    int     win_size;               /* = 1/alpha */
-    int     n_gauss;
-    double  bg_threshold, std_threshold, minArea;
-    double  weight_init, variance_init;
-}CvGaussBGStatModelParams;
-
-typedef struct CvGaussBGValues
-{
-    int         match_sum;
-    double      weight;
-    double      variance[CV_BGFG_MOG_NCOLORS];
-    double      mean[CV_BGFG_MOG_NCOLORS];
-} CvGaussBGValues;
-
-typedef struct CvGaussBGPoint
-{
-    CvGaussBGValues* g_values;
-} CvGaussBGPoint;
-
-
-typedef struct CvGaussBGModel
-{
-    CV_BG_STAT_MODEL_FIELDS();
-    CvGaussBGStatModelParams   params;
-    CvGaussBGPoint*            g_point;
-    int                        countFrames;
-    void*                      mog;
-} CvGaussBGModel;
-
-
-/* Creates Gaussian mixture background model */
-CVAPI(CvBGStatModel*) cvCreateGaussianBGModel( IplImage* first_frame,
-                                              CvGaussBGStatModelParams* parameters CV_DEFAULT(NULL));
-
-
-typedef struct CvBGCodeBookElem
-{
-    struct CvBGCodeBookElem* next;
-    int tLastUpdate;
-    int stale;
-    uchar boxMin[3];
-    uchar boxMax[3];
-    uchar learnMin[3];
-    uchar learnMax[3];
-} CvBGCodeBookElem;
-
-typedef struct CvBGCodeBookModel
-{
-    CvSize size;
-    int t;
-    uchar cbBounds[3];
-    uchar modMin[3];
-    uchar modMax[3];
-    CvBGCodeBookElem** cbmap;
-    CvMemStorage* storage;
-    CvBGCodeBookElem* freeList;
-} CvBGCodeBookModel;
-
-CVAPI(CvBGCodeBookModel*) cvCreateBGCodeBookModel( void );
-CVAPI(void) cvReleaseBGCodeBookModel( CvBGCodeBookModel** model );
-
-CVAPI(void) cvBGCodeBookUpdate( CvBGCodeBookModel* model, const CvArr* image,
-                               CvRect roi CV_DEFAULT(cvRect(0,0,0,0)),
-                               const CvArr* mask CV_DEFAULT(0) );
-
-CVAPI(int) cvBGCodeBookDiff( const CvBGCodeBookModel* model, const CvArr* image,
-                            CvArr* fgmask, CvRect roi CV_DEFAULT(cvRect(0,0,0,0)) );
-
-CVAPI(void) cvBGCodeBookClearStale( CvBGCodeBookModel* model, int staleThresh,
-                                   CvRect roi CV_DEFAULT(cvRect(0,0,0,0)),
-                                   const CvArr* mask CV_DEFAULT(0) );
-
-CVAPI(CvSeq*) cvSegmentFGMask( CvArr *fgmask, int poly1Hull0 CV_DEFAULT(1),
-                              float perimScale CV_DEFAULT(4.f),
-                              CvMemStorage* storage CV_DEFAULT(0),
-                              CvPoint offset CV_DEFAULT(cvPoint(0,0)));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-/* End of file. */
diff --git a/modules/legacy/include/opencv2/legacy/blobtrack.hpp b/modules/legacy/include/opencv2/legacy/blobtrack.hpp
deleted file mode 100644 (file)
index 496b8be..0000000
+++ /dev/null
@@ -1,948 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-
-#ifndef __OPENCV_VIDEOSURVEILLANCE_H__
-#define __OPENCV_VIDEOSURVEILLANCE_H__
-
-/* Turn off the functionality until cvaux/src/Makefile.am gets updated: */
-//#if _MSC_VER >= 1200
-
-#include "opencv2/core/core_c.h"
-#include <stdio.h>
-
-#if (defined _MSC_VER && _MSC_VER >= 1200) || defined __BORLANDC__
-#define cv_stricmp stricmp
-#define cv_strnicmp strnicmp
-#if defined WINCE
-#define strdup _strdup
-#define stricmp _stricmp
-#endif
-#elif defined __GNUC__ || defined __sun
-#define cv_stricmp strcasecmp
-#define cv_strnicmp strncasecmp
-#else
-#error Do not know how to make case-insensitive string comparison on this platform
-#endif
-
-//struct DefParam;
-struct CvDefParam
-{
-    struct CvDefParam*    next;
-    char*               pName;
-    char*               pComment;
-    double*             pDouble;
-    double              Double;
-    float*              pFloat;
-    float               Float;
-    int*                pInt;
-    int                 Int;
-    char**              pStr;
-    char*               Str;
-};
-
-class CV_EXPORTS CvVSModule
-{
-private: /* Internal data: */
-    CvDefParam*   m_pParamList;
-    char*       m_pModuleTypeName;
-    char*       m_pModuleName;
-    char*       m_pNickName;
-protected:
-    int         m_Wnd;
-public: /* Constructor and destructor: */
-    CvVSModule();
-    virtual ~CvVSModule();
-private: /* Internal functions: */
-    void    FreeParam(CvDefParam** pp);
-    CvDefParam* NewParam(const char* name);
-    CvDefParam* GetParamPtr(int index);
-    CvDefParam* GetParamPtr(const char* name);
-protected: /* INTERNAL INTERFACE */
-    int  IsParam(const char* name);
-    void AddParam(const char* name, double* pAddr);
-    void AddParam(const char* name, float* pAddr);
-    void AddParam(const char* name, int* pAddr);
-    void AddParam(const char* name, const char** pAddr);
-    void AddParam(const char* name);
-    void CommentParam(const char* name, const char* pComment);
-    void SetTypeName(const char* name);
-    void SetModuleName(const char* name);
-    void DelParam(const char* name);
-
-public: /* EXTERNAL INTERFACE */
-    const char* GetParamName(int index);
-    const char* GetParamComment(const char* name);
-    double GetParam(const char* name);
-    const char* GetParamStr(const char* name);
-    void   SetParam(const char* name, double val);
-    void   SetParamStr(const char* name, const char* str);
-    void TransferParamsFromChild(CvVSModule* pM, const char* prefix = NULL);
-    void TransferParamsToChild(CvVSModule* pM, char* prefix = NULL);
-    virtual void ParamUpdate();
-    const char*   GetTypeName();
-    int     IsModuleTypeName(const char* name);
-    char*   GetModuleName();
-    int     IsModuleName(const char* name);
-    void SetNickName(const char* pStr);
-    const char* GetNickName();
-    virtual void SaveState(CvFileStorage*);
-    virtual void LoadState(CvFileStorage*, CvFileNode*);
-
-    virtual void Release() = 0;
-};/* CvVMModule */
-
-CV_EXPORTS void cvWriteStruct(CvFileStorage* fs, const char* name, void* addr, const char* desc, int num=1);
-CV_EXPORTS void cvReadStructByName(CvFileStorage* fs, CvFileNode* node, const char* name, void* addr, const char* desc);
-
-/* FOREGROUND DETECTOR INTERFACE */
-class CV_EXPORTS CvFGDetector : public CvVSModule
-{
-public:
-    CvFGDetector();
-    virtual IplImage* GetMask() = 0;
-    /* Process current image: */
-    virtual void    Process(IplImage* pImg) = 0;
-    /* Release foreground detector: */
-    virtual void    Release() = 0;
-};
-
-CV_EXPORTS void cvReleaseFGDetector(CvFGDetector** ppT );
-CV_EXPORTS CvFGDetector* cvCreateFGDetectorBase(int type, void *param);
-
-
-/* BLOB STRUCTURE*/
-struct CvBlob
-{
-    float   x,y; /* blob position   */
-    float   w,h; /* blob sizes      */
-    int     ID;  /* blob ID         */
-};
-
-inline CvBlob cvBlob(float x,float y, float w, float h)
-{
-    CvBlob B = {x,y,w,h,0};
-    return B;
-}
-#define CV_BLOB_MINW 5
-#define CV_BLOB_MINH 5
-#define CV_BLOB_ID(pB) (((CvBlob*)(pB))->ID)
-#define CV_BLOB_CENTER(pB) cvPoint2D32f(((CvBlob*)(pB))->x,((CvBlob*)(pB))->y)
-#define CV_BLOB_X(pB) (((CvBlob*)(pB))->x)
-#define CV_BLOB_Y(pB) (((CvBlob*)(pB))->y)
-#define CV_BLOB_WX(pB) (((CvBlob*)(pB))->w)
-#define CV_BLOB_WY(pB) (((CvBlob*)(pB))->h)
-#define CV_BLOB_RX(pB) (0.5f*CV_BLOB_WX(pB))
-#define CV_BLOB_RY(pB) (0.5f*CV_BLOB_WY(pB))
-#define CV_BLOB_RECT(pB) cvRect(cvRound(((CvBlob*)(pB))->x-CV_BLOB_RX(pB)),cvRound(((CvBlob*)(pB))->y-CV_BLOB_RY(pB)),cvRound(CV_BLOB_WX(pB)),cvRound(CV_BLOB_WY(pB)))
-/* END BLOB STRUCTURE*/
-
-
-/* simple BLOBLIST */
-class CV_EXPORTS CvBlobSeq
-{
-public:
-    CvBlobSeq(int BlobSize = sizeof(CvBlob))
-    {
-        m_pMem = cvCreateMemStorage();
-        m_pSeq = cvCreateSeq(0,sizeof(CvSeq),BlobSize,m_pMem);
-        strcpy(m_pElemFormat,"ffffi");
-    }
-    virtual ~CvBlobSeq()
-    {
-        cvReleaseMemStorage(&m_pMem);
-    };
-    virtual CvBlob* GetBlob(int BlobIndex)
-    {
-        return (CvBlob*)cvGetSeqElem(m_pSeq,BlobIndex);
-    };
-    virtual CvBlob* GetBlobByID(int BlobID)
-    {
-        int i;
-        for(i=0; i<m_pSeq->total; ++i)
-            if(BlobID == CV_BLOB_ID(GetBlob(i)))
-                return GetBlob(i);
-        return NULL;
-    };
-    virtual void DelBlob(int BlobIndex)
-    {
-        cvSeqRemove(m_pSeq,BlobIndex);
-    };
-    virtual void DelBlobByID(int BlobID)
-    {
-        int i;
-        for(i=0; i<m_pSeq->total; ++i)
-        {
-            if(BlobID == CV_BLOB_ID(GetBlob(i)))
-            {
-                DelBlob(i);
-                return;
-            }
-        }
-    };
-    virtual void Clear()
-    {
-        cvClearSeq(m_pSeq);
-    };
-    virtual void AddBlob(CvBlob* pB)
-    {
-        cvSeqPush(m_pSeq,pB);
-    };
-    virtual int GetBlobNum()
-    {
-        return m_pSeq->total;
-    };
-    virtual void Write(CvFileStorage* fs, const char* name)
-    {
-        const char*  attr[] = {"dt",m_pElemFormat,NULL};
-        if(fs)
-        {
-            cvWrite(fs,name,m_pSeq,cvAttrList(attr,NULL));
-        }
-    }
-    virtual void Load(CvFileStorage* fs, CvFileNode* node)
-    {
-        if(fs==NULL) return;
-        CvSeq* pSeq = (CvSeq*)cvRead(fs, node);
-        if(pSeq)
-        {
-            int i;
-            cvClearSeq(m_pSeq);
-            for(i=0;i<pSeq->total;++i)
-            {
-                void* pB = cvGetSeqElem( pSeq, i );
-                cvSeqPush( m_pSeq, pB );
-            }
-        }
-    }
-    void AddFormat(const char* str){strcat(m_pElemFormat,str);}
-protected:
-    CvMemStorage*   m_pMem;
-    CvSeq*          m_pSeq;
-    char            m_pElemFormat[1024];
-};
-/* simple BLOBLIST */
-
-
-/* simple TRACKLIST */
-struct CvBlobTrack
-{
-    int         TrackID;
-    int         StartFrame;
-    CvBlobSeq*  pBlobSeq;
-};
-
-class CV_EXPORTS CvBlobTrackSeq
-{
-public:
-    CvBlobTrackSeq(int TrackSize = sizeof(CvBlobTrack));
-    virtual ~CvBlobTrackSeq();
-    virtual CvBlobTrack* GetBlobTrack(int TrackIndex);
-    virtual CvBlobTrack* GetBlobTrackByID(int TrackID);
-    virtual void DelBlobTrack(int TrackIndex);
-    virtual void DelBlobTrackByID(int TrackID);
-    virtual void Clear();
-    virtual void AddBlobTrack(int TrackID, int StartFrame = 0);
-    virtual int GetBlobTrackNum();
-protected:
-    CvMemStorage*   m_pMem;
-    CvSeq*          m_pSeq;
-};
-
-/* simple TRACKLIST */
-
-
-/* BLOB DETECTOR INTERFACE */
-class CV_EXPORTS CvBlobDetector: public CvVSModule
-{
-public:
-    CvBlobDetector(){SetTypeName("BlobDetector");};
-    /* Try to detect new blob entrance based on foreground mask. */
-    /* pFGMask - image of foreground mask */
-    /* pNewBlob - pointer to CvBlob structure which will be filled if new blob entrance detected */
-    /* pOldBlobList - pointer to blob list which already exist on image */
-    virtual int DetectNewBlob(IplImage* pImg, IplImage* pImgFG, CvBlobSeq* pNewBlobList, CvBlobSeq* pOldBlobList) = 0;
-    /* release blob detector */
-    virtual void Release()=0;
-};
-
-/* Release any blob detector: */
-CV_EXPORTS void cvReleaseBlobDetector(CvBlobDetector** ppBD);
-
-/* Declarations of constructors of implemented modules: */
-CV_EXPORTS CvBlobDetector* cvCreateBlobDetectorSimple();
-CV_EXPORTS CvBlobDetector* cvCreateBlobDetectorCC();
-
-struct CV_EXPORTS CvDetectedBlob : public CvBlob
-{
-    float response;
-};
-
-CV_INLINE CvDetectedBlob cvDetectedBlob( float x, float y, float w, float h, int ID = 0, float response = 0.0F )
-{
-    CvDetectedBlob b;
-    b.x = x; b.y = y; b.w = w; b.h = h; b.ID = ID; b.response = response;
-    return b;
-}
-
-
-class CV_EXPORTS CvObjectDetector
-{
-public:
-    CvObjectDetector( const char* /*detector_file_name*/ = 0 );
-    ~CvObjectDetector();
-
-    /*
-     * Release the current detector and load new detector from file
-     * (if detector_file_name is not 0)
-     * Return true on success:
-     */
-    bool Load( const char* /*detector_file_name*/ = 0 );
-
-    /* Return min detector window size: */
-    CvSize GetMinWindowSize() const;
-
-    /* Return max border: */
-    int GetMaxBorderSize() const;
-
-    /*
-     * Detect the object on the image and push the detected
-     * blobs into <detected_blob_seq> which must be the sequence of <CvDetectedBlob>s
-     */
-    void Detect( const CvArr* /*img*/, /* out */ CvBlobSeq* /*detected_blob_seq*/ = 0 );
-
-protected:
-    class CvObjectDetectorImpl* impl;
-};
-
-
-CV_INLINE CvRect cvRectIntersection( const CvRect r1, const CvRect r2 )
-{
-    CvRect r = cvRect( MAX(r1.x, r2.x), MAX(r1.y, r2.y), 0, 0 );
-
-    r.width  = MIN(r1.x + r1.width, r2.x + r2.width) - r.x;
-    r.height = MIN(r1.y + r1.height, r2.y + r2.height) - r.y;
-
-    return r;
-}
-
-
-/*
- * CvImageDrawer
- *
- * Draw on an image the specified ROIs from the source image and
- * given blobs as ellipses or rectangles:
- */
-
-struct CvDrawShape
-{
-    enum {RECT, ELLIPSE} shape;
-    CvScalar color;
-};
-
-/*extern const CvDrawShape icv_shape[] =
-{
-    { CvDrawShape::ELLIPSE, CV_RGB(255,0,0) },
-    { CvDrawShape::ELLIPSE, CV_RGB(0,255,0) },
-    { CvDrawShape::ELLIPSE, CV_RGB(0,0,255) },
-    { CvDrawShape::ELLIPSE, CV_RGB(255,255,0) },
-    { CvDrawShape::ELLIPSE, CV_RGB(0,255,255) },
-    { CvDrawShape::ELLIPSE, CV_RGB(255,0,255) }
-};*/
-
-class CV_EXPORTS CvImageDrawer
-{
-public:
-    CvImageDrawer() : m_image(0) {}
-    ~CvImageDrawer() { cvReleaseImage( &m_image ); }
-    void SetShapes( const CvDrawShape* shapes, int num );
-    /* <blob_seq> must be the sequence of <CvDetectedBlob>s */
-    IplImage* Draw( const CvArr* src, CvBlobSeq* blob_seq = 0, const CvSeq* roi_seq = 0 );
-    IplImage* GetImage() { return m_image; }
-protected:
-    //static const int MAX_SHAPES = sizeof(icv_shape) / sizeof(icv_shape[0]);;
-
-    IplImage* m_image;
-    CvDrawShape m_shape[16];
-};
-
-
-
-/* Trajectory generation module: */
-class CV_EXPORTS CvBlobTrackGen: public CvVSModule
-{
-public:
-    CvBlobTrackGen(){SetTypeName("BlobTrackGen");};
-    virtual void    SetFileName(char* pFileName) = 0;
-    virtual void    AddBlob(CvBlob* pBlob) = 0;
-    virtual void    Process(IplImage* pImg = NULL, IplImage* pFG = NULL) = 0;
-    virtual void    Release() = 0;
-};
-
-inline void cvReleaseBlobTrackGen(CvBlobTrackGen** pBTGen)
-{
-    if(*pBTGen)(*pBTGen)->Release();
-    *pBTGen = 0;
-}
-
-/* Declarations of constructors of implemented modules: */
-CV_EXPORTS CvBlobTrackGen* cvCreateModuleBlobTrackGen1();
-CV_EXPORTS CvBlobTrackGen* cvCreateModuleBlobTrackGenYML();
-
-
-
-/* BLOB TRACKER INTERFACE */
-class CV_EXPORTS CvBlobTracker: public CvVSModule
-{
-public:
-    CvBlobTracker();
-
-    /* Add new blob to track it and assign to this blob personal ID */
-    /* pBlob - pointer to structure with blob parameters (ID is ignored)*/
-    /* pImg - current image */
-    /* pImgFG - current foreground mask */
-    /* Return pointer to new added blob: */
-    virtual CvBlob* AddBlob(CvBlob* pBlob, IplImage* pImg, IplImage* pImgFG = NULL ) = 0;
-
-    /* Return number of currently tracked blobs: */
-    virtual int     GetBlobNum() = 0;
-
-    /* Return pointer to specified by index blob: */
-    virtual CvBlob* GetBlob(int BlobIndex) = 0;
-
-    /* Delete blob by its index: */
-    virtual void    DelBlob(int BlobIndex) = 0;
-
-    /* Process current image and track all existed blobs: */
-    virtual void    Process(IplImage* pImg, IplImage* pImgFG = NULL) = 0;
-
-    /* Release blob tracker: */
-    virtual void    Release() = 0;
-
-
-    /* Process one blob (for multi hypothesis tracing): */
-    virtual void ProcessBlob(int BlobIndex, CvBlob* pBlob, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL);
-
-    /* Get confidence/wieght/probability (0-1) for blob: */
-    virtual double  GetConfidence(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL);
-
-    virtual double GetConfidenceList(CvBlobSeq* pBlobList, IplImage* pImg, IplImage* pImgFG = NULL);
-
-    virtual void UpdateBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL);
-
-    /* Update all blob models: */
-    virtual void Update(IplImage* pImg, IplImage* pImgFG = NULL);
-
-    /* Return pointer to blob by its unique ID: */
-    virtual int     GetBlobIndexByID(int BlobID);
-
-    /* Return pointer to blob by its unique ID: */
-    virtual CvBlob* GetBlobByID(int BlobID);
-
-    /* Delete blob by its ID: */
-    virtual void    DelBlobByID(int BlobID);
-
-    /* Set new parameters for specified (by index) blob: */
-    virtual void    SetBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/);
-
-    /* Set new parameters for specified (by ID) blob: */
-    virtual void    SetBlobByID(int BlobID, CvBlob* pBlob);
-
-    /*  ===============  MULTI HYPOTHESIS INTERFACE ==================  */
-
-    /* Return number of position hyposetis of currently tracked blob: */
-    virtual int     GetBlobHypNum(int /*BlobIdx*/);
-
-    /* Return pointer to specified blob hypothesis by index blob: */
-    virtual CvBlob* GetBlobHyp(int BlobIndex, int /*hypothesis*/);
-
-    /* Set new parameters for specified (by index) blob hyp
-     * (can be called several times for each hyp ):
-     */
-    virtual void    SetBlobHyp(int /*BlobIndex*/, CvBlob* /*pBlob*/);
-};
-
-CV_EXPORTS void cvReleaseBlobTracker(CvBlobTracker**ppT );
-/* BLOB TRACKER INTERFACE */
-
-/*BLOB TRACKER ONE INTERFACE */
-class CV_EXPORTS CvBlobTrackerOne : public CvVSModule
-{
-public:
-    virtual void Init(CvBlob* pBlobInit, IplImage* pImg, IplImage* pImgFG = NULL) = 0;
-    virtual CvBlob* Process(CvBlob* pBlobPrev, IplImage* pImg, IplImage* pImgFG = NULL) = 0;
-    virtual void Release() =  0;
-
-    /* Non-required methods: */
-    virtual void SkipProcess(CvBlob* /*pBlobPrev*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL){};
-    virtual void Update(CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL){};
-    virtual void SetCollision(int /*CollisionFlag*/){}; /* call in case of blob collision situation*/
-    virtual double GetConfidence(CvBlob* /*pBlob*/, IplImage* /*pImg*/,
-                                 IplImage* /*pImgFG*/ = NULL, IplImage* /*pImgUnusedReg*/ = NULL)
-    {
-        return 1;
-    };
-};
-inline void cvReleaseBlobTrackerOne(CvBlobTrackerOne **ppT )
-{
-    ppT[0]->Release();
-    ppT[0] = 0;
-}
-CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerList(CvBlobTrackerOne* (*create)());
-/*BLOB TRACKER ONE INTERFACE */
-
-/* Declarations of constructors of implemented modules: */
-
-/* Some declarations for specific MeanShift tracker: */
-#define PROFILE_EPANECHNIKOV    0
-#define PROFILE_DOG             1
-struct CvBlobTrackerParamMS
-{
-    int     noOfSigBits;
-    int     appearance_profile;
-    int     meanshift_profile;
-    float   sigma;
-};
-
-CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS1(CvBlobTrackerParamMS* param);
-CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS2(CvBlobTrackerParamMS* param);
-CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS1ByList();
-
-/* Some declarations for specific Likelihood tracker: */
-struct CvBlobTrackerParamLH
-{
-    int     HistType; /* see Prob.h */
-    int     ScaleAfter;
-};
-
-/* Without scale optimization: */
-CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerLHR(CvBlobTrackerParamLH* /*param*/ = NULL);
-
-/* With scale optimization: */
-CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerLHRS(CvBlobTrackerParamLH* /*param*/ = NULL);
-
-/* Simple blob tracker based on connected component tracking: */
-CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerCC();
-
-/* Connected component tracking and mean-shift particle filter collion-resolver: */
-CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerCCMSPF();
-
-/* Blob tracker that integrates meanshift and connected components: */
-CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSFG();
-CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSFGS();
-
-/* Meanshift without connected-components */
-CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMS();
-
-/* Particle filtering via Bhattacharya coefficient, which        */
-/* is roughly the dot-product of two probability densities.      */
-/* See: Real-Time Tracking of Non-Rigid Objects using Mean Shift */
-/*      Comanicius, Ramesh, Meer, 2000, 8p                       */
-/*      http://citeseer.ist.psu.edu/321441.html                  */
-CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerMSPF();
-
-/* =========== tracker integrators trackers =============*/
-
-/* Integrator based on Particle Filtering method: */
-//CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIPF();
-
-/* Rule based integrator: */
-//CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIRB();
-
-/* Integrator based on data fusion using particle filtering: */
-//CV_EXPORTS CvBlobTracker* cvCreateBlobTrackerIPFDF();
-
-
-
-
-/* Trajectory postprocessing module: */
-class CV_EXPORTS CvBlobTrackPostProc: public CvVSModule
-{
-public:
-    CvBlobTrackPostProc(){SetTypeName("BlobTrackPostProc");};
-    virtual void    AddBlob(CvBlob* pBlob) = 0;
-    virtual void    Process() = 0;
-    virtual int     GetBlobNum() = 0;
-    virtual CvBlob* GetBlob(int index) = 0;
-    virtual void    Release() = 0;
-
-    /* Additional functionality: */
-    virtual CvBlob* GetBlobByID(int BlobID)
-    {
-        int i;
-        for(i=GetBlobNum();i>0;i--)
-        {
-            CvBlob* pB=GetBlob(i-1);
-            if(pB->ID==BlobID) return pB;
-        }
-        return NULL;
-    };
-};
-
-inline void cvReleaseBlobTrackPostProc(CvBlobTrackPostProc** pBTPP)
-{
-    if(pBTPP == NULL) return;
-    if(*pBTPP)(*pBTPP)->Release();
-    *pBTPP = 0;
-}
-
-/* Trajectory generation module: */
-class CV_EXPORTS CvBlobTrackPostProcOne: public CvVSModule
-{
-public:
-    CvBlobTrackPostProcOne(){SetTypeName("BlobTrackPostOne");};
-    virtual CvBlob* Process(CvBlob* pBlob) = 0;
-    virtual void    Release() = 0;
-};
-
-/* Create blob tracking post processing module based on simle module: */
-CV_EXPORTS CvBlobTrackPostProc* cvCreateBlobTrackPostProcList(CvBlobTrackPostProcOne* (*create)());
-
-
-/* Declarations of constructors of implemented modules: */
-CV_EXPORTS CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcKalman();
-CV_EXPORTS CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcTimeAverRect();
-CV_EXPORTS CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcTimeAverExp();
-
-
-/* PREDICTORS */
-/* blob PREDICTOR */
-class CvBlobTrackPredictor: public CvVSModule
-{
-public:
-    CvBlobTrackPredictor(){SetTypeName("BlobTrackPredictor");};
-    virtual CvBlob* Predict() = 0;
-    virtual void    Update(CvBlob* pBlob) = 0;
-    virtual void    Release() = 0;
-};
-CV_EXPORTS CvBlobTrackPredictor* cvCreateModuleBlobTrackPredictKalman();
-
-
-
-/* Trajectory analyser module: */
-class CV_EXPORTS CvBlobTrackAnalysis: public CvVSModule
-{
-public:
-    CvBlobTrackAnalysis(){SetTypeName("BlobTrackAnalysis");};
-    virtual void    AddBlob(CvBlob* pBlob) = 0;
-    virtual void    Process(IplImage* pImg, IplImage* pFG) = 0;
-    virtual float   GetState(int BlobID) = 0;
-    /* return 0 if trajectory is normal
-       return >0 if trajectory abnormal */
-    virtual const char*   GetStateDesc(int /*BlobID*/){return NULL;};
-    virtual void    SetFileName(char* /*DataBaseName*/){};
-    virtual void    Release() = 0;
-};
-
-
-inline void cvReleaseBlobTrackAnalysis(CvBlobTrackAnalysis** pBTPP)
-{
-    if(pBTPP == NULL) return;
-    if(*pBTPP)(*pBTPP)->Release();
-    *pBTPP = 0;
-}
-
-/* Feature-vector generation module: */
-class CV_EXPORTS CvBlobTrackFVGen : public CvVSModule
-{
-public:
-    CvBlobTrackFVGen(){SetTypeName("BlobTrackFVGen");};
-    virtual void    AddBlob(CvBlob* pBlob) = 0;
-    virtual void    Process(IplImage* pImg, IplImage* pFG) = 0;
-    virtual void    Release() = 0;
-    virtual int     GetFVSize() = 0;
-    virtual int     GetFVNum() = 0;
-    virtual float*  GetFV(int index, int* pFVID) = 0; /* Returns pointer to FV, if return 0 then FV not created */
-    virtual float*  GetFVVar(){return NULL;}; /* Returns pointer to array of variation of values of FV, if returns 0 then FVVar does not exist. */
-    virtual float*  GetFVMin() = 0; /* Returns pointer to array of minimal values of FV, if returns 0 then FVrange does not exist */
-    virtual float*  GetFVMax() = 0; /* Returns pointer to array of maximal values of FV, if returns 0 then FVrange does not exist */
-};
-
-
-/* Trajectory Analyser module: */
-class CV_EXPORTS CvBlobTrackAnalysisOne
-{
-public:
-    virtual ~CvBlobTrackAnalysisOne() {};
-    virtual int     Process(CvBlob* pBlob, IplImage* pImg, IplImage* pFG) = 0;
-    /* return 0 if trajectory is normal
-       return >0 if trajectory abnormal */
-    virtual void    Release() = 0;
-};
-
-/* Create blob tracking post processing module based on simle module: */
-CV_EXPORTS CvBlobTrackAnalysis* cvCreateBlobTrackAnalysisList(CvBlobTrackAnalysisOne* (*create)());
-
-/* Declarations of constructors of implemented modules: */
-
-/* Based on histogram analysis of 2D FV (x,y): */
-CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistP();
-
-/* Based on histogram analysis of 4D FV (x,y,vx,vy): */
-CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistPV();
-
-/* Based on histogram analysis of 5D FV (x,y,vx,vy,state): */
-CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistPVS();
-
-/* Based on histogram analysis of 4D FV (startpos,stoppos): */
-CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistSS();
-
-
-
-/* Based on SVM classifier analysis of 2D FV (x,y): */
-//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMP();
-
-/* Based on SVM classifier analysis of 4D FV (x,y,vx,vy): */
-//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMPV();
-
-/* Based on SVM classifier analysis of 5D FV (x,y,vx,vy,state): */
-//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMPVS();
-
-/* Based on SVM classifier analysis of 4D FV (startpos,stoppos): */
-//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMSS();
-
-/* Track analysis based on distance between tracks: */
-CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisTrackDist();
-
-/* Analyzer based on reation Road and height map: */
-//CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysis3DRoadMap();
-
-/* Analyzer that makes OR decision using set of analyzers: */
-CV_EXPORTS CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisIOR();
-
-/* Estimator of human height: */
-class CV_EXPORTS CvBlobTrackAnalysisHeight: public CvBlobTrackAnalysis
-{
-public:
-    virtual double  GetHeight(CvBlob* pB) = 0;
-};
-//CV_EXPORTS CvBlobTrackAnalysisHeight* cvCreateModuleBlobTrackAnalysisHeightScale();
-
-
-
-/* AUTO BLOB TRACKER INTERFACE -- pipeline of 3 modules: */
-class CV_EXPORTS CvBlobTrackerAuto: public CvVSModule
-{
-public:
-    CvBlobTrackerAuto(){SetTypeName("BlobTrackerAuto");};
-    virtual void        Process(IplImage* pImg, IplImage* pMask = NULL) = 0;
-    virtual CvBlob*     GetBlob(int index) = 0;
-    virtual CvBlob*     GetBlobByID(int ID) = 0;
-    virtual int         GetBlobNum() = 0;
-    virtual IplImage*   GetFGMask(){return NULL;};
-    virtual float       GetState(int BlobID) = 0;
-    virtual const char*       GetStateDesc(int BlobID) = 0;
-    /* return 0 if trajectory is normal;
-     * return >0 if trajectory abnormal. */
-    virtual void    Release() = 0;
-};
-inline void cvReleaseBlobTrackerAuto(CvBlobTrackerAuto** ppT)
-{
-    ppT[0]->Release();
-    ppT[0] = 0;
-}
-/* END AUTO BLOB TRACKER INTERFACE */
-
-
-/* Constructor functions and data for specific BlobTRackerAuto modules: */
-
-/* Parameters of blobtracker auto ver1: */
-struct CvBlobTrackerAutoParam1
-{
-    int                     FGTrainFrames; /* Number of frames needed for FG (foreground) detector to train.        */
-
-    CvFGDetector*           pFG;           /* FGDetector module. If this field is NULL the Process FG mask is used. */
-
-    CvBlobDetector*         pBD;           /* Selected blob detector module.                                       */
-                                           /* If this field is NULL default blobdetector module will be created.    */
-
-    CvBlobTracker*          pBT;           /* Selected blob tracking module.                                       */
-                                           /* If this field is NULL default blobtracker module will be created.     */
-
-    CvBlobTrackGen*         pBTGen;        /* Selected blob trajectory generator.                                  */
-                                           /* If this field is NULL no generator is used.                           */
-
-    CvBlobTrackPostProc*    pBTPP;         /* Selected blob trajectory postprocessing module.                      */
-                                           /* If this field is NULL no postprocessing is done.                      */
-
-    int                     UsePPData;
-
-    CvBlobTrackAnalysis*    pBTA;          /* Selected blob trajectory analysis module.                             */
-                                           /* If this field is NULL no track analysis is done.                      */
-};
-
-/* Create blob tracker auto ver1: */
-CV_EXPORTS CvBlobTrackerAuto* cvCreateBlobTrackerAuto1(CvBlobTrackerAutoParam1* param = NULL);
-
-/* Simple loader for many auto trackers by its type : */
-inline CvBlobTrackerAuto* cvCreateBlobTrackerAuto(int type, void* param)
-{
-    if(type == 0) return cvCreateBlobTrackerAuto1((CvBlobTrackerAutoParam1*)param);
-    return 0;
-}
-
-
-
-struct CvTracksTimePos
-{
-    int len1,len2;
-    int beg1,beg2;
-    int end1,end2;
-    int comLen; //common length for two tracks
-    int shift1,shift2;
-};
-
-/*CV_EXPORTS int cvCompareTracks( CvBlobTrackSeq *groundTruth,
-                   CvBlobTrackSeq *result,
-                   FILE *file);*/
-
-
-/* Constructor functions:  */
-
-CV_EXPORTS void cvCreateTracks_One(CvBlobTrackSeq *TS);
-CV_EXPORTS void cvCreateTracks_Same(CvBlobTrackSeq *TS1, CvBlobTrackSeq *TS2);
-CV_EXPORTS void cvCreateTracks_AreaErr(CvBlobTrackSeq *TS1, CvBlobTrackSeq *TS2, int addW, int addH);
-
-
-/* HIST API */
-class CV_EXPORTS CvProb
-{
-public:
-    virtual ~CvProb() {};
-
-    /* Calculate probability value: */
-    virtual double Value(int* /*comp*/, int /*x*/ = 0, int /*y*/ = 0){return -1;};
-
-    /* Update histograpp Pnew = (1-W)*Pold + W*Padd*/
-    /* W weight of new added prob */
-    /* comps - matrix of new fetature vectors used to update prob */
-    virtual void AddFeature(float W, int* comps, int x =0, int y = 0) = 0;
-    virtual void Scale(float factor = 0, int x = -1, int y = -1) = 0;
-    virtual void Release() = 0;
-};
-inline void cvReleaseProb(CvProb** ppProb){ppProb[0]->Release();ppProb[0]=NULL;}
-/* HIST API */
-
-/* Some Prob: */
-CV_EXPORTS CvProb* cvCreateProbS(int dim, CvSize size, int sample_num);
-CV_EXPORTS CvProb* cvCreateProbMG(int dim, CvSize size, int sample_num);
-CV_EXPORTS CvProb* cvCreateProbMG2(int dim, CvSize size, int sample_num);
-CV_EXPORTS CvProb* cvCreateProbHist(int dim, CvSize size);
-
-#define CV_BT_HIST_TYPE_S     0
-#define CV_BT_HIST_TYPE_MG    1
-#define CV_BT_HIST_TYPE_MG2   2
-#define CV_BT_HIST_TYPE_H     3
-inline CvProb* cvCreateProb(int type, int dim, CvSize size = cvSize(1,1), void* /*param*/ = NULL)
-{
-    if(type == CV_BT_HIST_TYPE_S) return cvCreateProbS(dim, size, -1);
-    if(type == CV_BT_HIST_TYPE_MG) return cvCreateProbMG(dim, size, -1);
-    if(type == CV_BT_HIST_TYPE_MG2) return cvCreateProbMG2(dim, size, -1);
-    if(type == CV_BT_HIST_TYPE_H) return cvCreateProbHist(dim, size);
-    return NULL;
-}
-
-
-
-/* Noise type definitions: */
-#define CV_NOISE_NONE               0
-#define CV_NOISE_GAUSSIAN           1
-#define CV_NOISE_UNIFORM            2
-#define CV_NOISE_SPECKLE            3
-#define CV_NOISE_SALT_AND_PEPPER    4
-
-/* Add some noise to image: */
-/* pImg - (input) image without noise */
-/* pImg - (output) image with noise */
-/* noise_type - type of added noise */
-/*  CV_NOISE_GAUSSIAN - pImg += n , n - is gaussian noise with Ampl standart deviation */
-/*  CV_NOISE_UNIFORM - pImg += n , n - is uniform noise with Ampl standart deviation */
-/*  CV_NOISE_SPECKLE - pImg += n*pImg , n - is gaussian noise with Ampl standart deviation */
-/*  CV_NOISE_SALT_AND_PAPPER - pImg = pImg with blacked and whited pixels,
-            Ampl is density of brocken pixels (0-there are not broken pixels, 1 - all pixels are broken)*/
-/* Ampl - "amplitude" of noise */
-//CV_EXPORTS void cvAddNoise(IplImage* pImg, int noise_type, double Ampl, CvRNG* rnd_state = NULL);
-
-/*================== GENERATOR OF TEST VIDEO SEQUENCE ===================== */
-typedef void CvTestSeq;
-
-/* pConfigfile - Name of file (yml or xml) with description of test sequence */
-/* videos - array of names of test videos described in "pConfigfile" file */
-/* numvideos - size of "videos" array */
-CV_EXPORTS CvTestSeq* cvCreateTestSeq(char* pConfigfile, char** videos, int numvideo, float Scale = 1, int noise_type = CV_NOISE_NONE, double noise_ampl = 0);
-CV_EXPORTS void cvReleaseTestSeq(CvTestSeq** ppTestSeq);
-
-/* Generate next frame from test video seq and return pointer to it: */
-CV_EXPORTS IplImage* cvTestSeqQueryFrame(CvTestSeq* pTestSeq);
-
-/* Return pointer to current foreground mask: */
-CV_EXPORTS IplImage* cvTestSeqGetFGMask(CvTestSeq* pTestSeq);
-
-/* Return pointer to current image: */
-CV_EXPORTS IplImage* cvTestSeqGetImage(CvTestSeq* pTestSeq);
-
-/* Return frame size of result test video: */
-CV_EXPORTS CvSize cvTestSeqGetImageSize(CvTestSeq* pTestSeq);
-
-/* Return number of frames result test video: */
-CV_EXPORTS int cvTestSeqFrameNum(CvTestSeq* pTestSeq);
-
-/* Return number of existing objects.
- * This is general number of any objects.
- * For example number of trajectories may be equal or less than returned value:
- */
-CV_EXPORTS int cvTestSeqGetObjectNum(CvTestSeq* pTestSeq);
-
-/* Return 0 if there is not position for current defined on current frame */
-/* Return 1 if there is object position and pPos was filled */
-CV_EXPORTS int cvTestSeqGetObjectPos(CvTestSeq* pTestSeq, int ObjIndex, CvPoint2D32f* pPos);
-CV_EXPORTS int cvTestSeqGetObjectSize(CvTestSeq* pTestSeq, int ObjIndex, CvPoint2D32f* pSize);
-
-/* Add noise to final image: */
-CV_EXPORTS void cvTestSeqAddNoise(CvTestSeq* pTestSeq, int noise_type = CV_NOISE_NONE, double noise_ampl = 0);
-
-/* Add Intensity variation: */
-CV_EXPORTS void cvTestSeqAddIntensityVariation(CvTestSeq* pTestSeq, float DI_per_frame, float MinI, float MaxI);
-CV_EXPORTS void cvTestSeqSetFrame(CvTestSeq* pTestSeq, int n);
-
-#endif
-
-/* End of file. */
diff --git a/modules/legacy/include/opencv2/legacy/compat.hpp b/modules/legacy/include/opencv2/legacy/compat.hpp
deleted file mode 100644 (file)
index 5840d74..0000000
+++ /dev/null
@@ -1,735 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright( C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-//(including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort(including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_COMPAT_HPP__
-#define __OPENCV_COMPAT_HPP__
-
-#include "opencv2/core/core_c.h"
-#include "opencv2/imgproc/types_c.h"
-
-#include <math.h>
-#include <string.h>
-
-#define CV_NOOP(...)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef int CvMatType;
-typedef int CvDisMaskType;
-typedef CvMat CvMatArray;
-
-typedef int CvThreshType;
-typedef int CvAdaptiveThreshMethod;
-typedef int CvCompareMethod;
-typedef int CvFontFace;
-typedef int CvPolyApproxMethod;
-typedef int CvContoursMatchMethod;
-typedef int CvContourTreesMatchMethod;
-typedef int CvCoeffType;
-typedef int CvRodriguesType;
-typedef int CvElementShape;
-typedef int CvMorphOp;
-typedef int CvTemplMatchMethod;
-
-typedef CvPoint2D64f CvPoint2D64d;
-typedef CvPoint3D64f CvPoint3D64d;
-
-enum
-{
-    CV_MAT32F      = CV_32FC1,
-    CV_MAT3x1_32F  = CV_32FC1,
-    CV_MAT4x1_32F  = CV_32FC1,
-    CV_MAT3x3_32F  = CV_32FC1,
-    CV_MAT4x4_32F  = CV_32FC1,
-
-    CV_MAT64D      = CV_64FC1,
-    CV_MAT3x1_64D  = CV_64FC1,
-    CV_MAT4x1_64D  = CV_64FC1,
-    CV_MAT3x3_64D  = CV_64FC1,
-    CV_MAT4x4_64D  = CV_64FC1
-};
-
-enum
-{
-    IPL_GAUSSIAN_5x5 = 7
-};
-
-typedef CvBox2D  CvBox2D32f;
-
-/* allocation/deallocation macros */
-#define cvCreateImageData   cvCreateData
-#define cvReleaseImageData  cvReleaseData
-#define cvSetImageData      cvSetData
-#define cvGetImageRawData   cvGetRawData
-
-#define cvmAlloc            cvCreateData
-#define cvmFree             cvReleaseData
-#define cvmAllocArray       cvCreateData
-#define cvmFreeArray        cvReleaseData
-
-#define cvIntegralImage     cvIntegral
-#define cvMatchContours     cvMatchShapes
-
-CV_EXPORTS CvMat cvMatArray( int rows, int cols, int type,
-                            int count, void* data CV_DEFAULT(0));
-
-#define cvUpdateMHIByTime  cvUpdateMotionHistory
-
-#define cvAccMask cvAcc
-#define cvSquareAccMask cvSquareAcc
-#define cvMultiplyAccMask cvMultiplyAcc
-#define cvRunningAvgMask(imgY, imgU, mask, alpha) cvRunningAvg(imgY, imgU, alpha, mask)
-
-#define cvSetHistThresh  cvSetHistBinRanges
-#define cvCalcHistMask(img, mask, hist, doNotClear) cvCalcHist(img, hist, doNotClear, mask)
-
-CV_EXPORTS double cvMean( const CvArr* image, const CvArr* mask CV_DEFAULT(0));
-CV_EXPORTS double cvSumPixels( const CvArr* image );
-CV_EXPORTS void  cvMean_StdDev( const CvArr* image, double* mean, double* sdv,
-                                const CvArr* mask CV_DEFAULT(0));
-
-CV_EXPORTS void cvmPerspectiveProject( const CvMat* mat, const CvArr* src, CvArr* dst );
-CV_EXPORTS void cvFillImage( CvArr* mat, double color );
-
-#define cvCvtPixToPlane cvSplit
-#define cvCvtPlaneToPix cvMerge
-
-typedef struct CvRandState
-{
-    CvRNG     state;    /* RNG state (the current seed and carry)*/
-    int       disttype; /* distribution type */
-    CvScalar  param[2]; /* parameters of RNG */
-} CvRandState;
-
-/* Changes RNG range while preserving RNG state */
-CV_EXPORTS void  cvRandSetRange( CvRandState* state, double param1,
-                                 double param2, int index CV_DEFAULT(-1));
-
-CV_EXPORTS void  cvRandInit( CvRandState* state, double param1,
-                             double param2, int seed,
-                             int disttype CV_DEFAULT(CV_RAND_UNI));
-
-/* Fills array with random numbers */
-CV_EXPORTS void cvRand( CvRandState* state, CvArr* arr );
-
-#define cvRandNext( _state ) cvRandInt( &(_state)->state )
-
-CV_EXPORTS void cvbRand( CvRandState* state, float* dst, int len );
-
-CV_EXPORTS void  cvbCartToPolar( const float* y, const float* x,
-                                 float* magnitude, float* angle, int len );
-CV_EXPORTS void  cvbFastArctan( const float* y, const float* x, float* angle, int len );
-CV_EXPORTS void  cvbSqrt( const float* x, float* y, int len );
-CV_EXPORTS void  cvbInvSqrt( const float* x, float* y, int len );
-CV_EXPORTS void  cvbReciprocal( const float* x, float* y, int len );
-CV_EXPORTS void  cvbFastExp( const float* x, double* y, int len );
-CV_EXPORTS void  cvbFastLog( const double* x, float* y, int len );
-
-CV_EXPORTS CvRect  cvContourBoundingRect( void* point_set, int update CV_DEFAULT(0));
-
-CV_EXPORTS double cvPseudoInverse( const CvArr* src, CvArr* dst );
-#define cvPseudoInv cvPseudoInverse
-
-#define cvContourMoments( contour, moments ) cvMoments( contour, moments, 0 )
-
-#define cvGetPtrAt              cvPtr2D
-#define cvGetAt                 cvGet2D
-#define cvSetAt(arr,val,y,x)    cvSet2D((arr),(y),(x),(val))
-
-#define cvMeanMask  cvMean
-#define cvMean_StdDevMask(img,mask,mean,sdv) cvMean_StdDev(img,mean,sdv,mask)
-
-#define cvNormMask(imgA,imgB,mask,normType) cvNorm(imgA,imgB,normType,mask)
-
-#define cvMinMaxLocMask(img, mask, min_val, max_val, min_loc, max_loc) \
-        cvMinMaxLoc(img, min_val, max_val, min_loc, max_loc, mask)
-
-#define cvRemoveMemoryManager  CV_NOOP
-#define cvSetMemoryManager     CV_NOOP
-
-#define cvmSetZero( mat )               cvSetZero( mat )
-#define cvmSetIdentity( mat )           cvSetIdentity( mat )
-#define cvmAdd( src1, src2, dst )       cvAdd( src1, src2, dst, 0 )
-#define cvmSub( src1, src2, dst )       cvSub( src1, src2, dst, 0 )
-#define cvmCopy( src, dst )             cvCopy( src, dst, 0 )
-#define cvmMul( src1, src2, dst )       cvMatMulAdd( src1, src2, 0, dst )
-#define cvmTranspose( src, dst )        cvT( src, dst )
-#define cvmInvert( src, dst )           cvInv( src, dst )
-#define cvmMahalanobis(vec1, vec2, mat) cvMahalanobis( vec1, vec2, mat )
-#define cvmDotProduct( vec1, vec2 )     cvDotProduct( vec1, vec2 )
-#define cvmCrossProduct(vec1, vec2,dst) cvCrossProduct( vec1, vec2, dst )
-#define cvmTrace( mat )                 (cvTrace( mat )).val[0]
-#define cvmMulTransposed( src, dst, order ) cvMulTransposed( src, dst, order )
-#define cvmEigenVV( mat, evec, eval, eps)   cvEigenVV( mat, evec, eval, eps )
-#define cvmDet( mat )                   cvDet( mat )
-#define cvmScale( src, dst, scale )     cvScale( src, dst, scale )
-
-#define cvCopyImage( src, dst )         cvCopy( src, dst, 0 )
-#define cvReleaseMatHeader              cvReleaseMat
-
-/* Calculates exact convex hull of 2d point set */
-CV_EXPORTS void cvConvexHull( CvPoint* points, int num_points,
-                             CvRect* bound_rect,
-                             int orientation, int* hull, int* hullsize );
-
-
-CV_EXPORTS void cvMinAreaRect( CvPoint* points, int n,
-                              int left, int bottom,
-                              int right, int top,
-                              CvPoint2D32f* anchor,
-                              CvPoint2D32f* vect1,
-                              CvPoint2D32f* vect2 );
-
-typedef int CvDisType;
-typedef int CvChainApproxMethod;
-typedef int CvContourRetrievalMode;
-
-CV_EXPORTS  void  cvFitLine3D( CvPoint3D32f* points, int count, int dist,
-                    void *param, float reps, float aeps, float* line );
-
-/* Fits a line into set of 2d points in a robust way (M-estimator technique) */
-CV_EXPORTS  void  cvFitLine2D( CvPoint2D32f* points, int count, int dist,
-                    void *param, float reps, float aeps, float* line );
-
-CV_EXPORTS  void  cvFitEllipse( const CvPoint2D32f* points, int count, CvBox2D* box );
-
-/* Projects 2d points to one of standard coordinate planes
-   (i.e. removes one of coordinates) */
-CV_EXPORTS  void  cvProject3D( CvPoint3D32f* points3D, int count,
-                              CvPoint2D32f* points2D,
-                              int xIndx CV_DEFAULT(0),
-                              int yIndx CV_DEFAULT(1));
-
-/* Retrieves value of the particular bin
-   of x-dimensional (x=1,2,3,...) histogram */
-#define cvQueryHistValue_1D( hist, idx0 ) \
-    ((float)cvGetReal1D( (hist)->bins, (idx0)))
-#define cvQueryHistValue_2D( hist, idx0, idx1 ) \
-    ((float)cvGetReal2D( (hist)->bins, (idx0), (idx1)))
-#define cvQueryHistValue_3D( hist, idx0, idx1, idx2 ) \
-    ((float)cvGetReal3D( (hist)->bins, (idx0), (idx1), (idx2)))
-#define cvQueryHistValue_nD( hist, idx ) \
-    ((float)cvGetRealND( (hist)->bins, (idx)))
-
-/* Returns pointer to the particular bin of x-dimesional histogram.
-   For sparse histogram the bin is created if it didn't exist before */
-#define cvGetHistValue_1D( hist, idx0 ) \
-    ((float*)cvPtr1D( (hist)->bins, (idx0), 0))
-#define cvGetHistValue_2D( hist, idx0, idx1 ) \
-    ((float*)cvPtr2D( (hist)->bins, (idx0), (idx1), 0))
-#define cvGetHistValue_3D( hist, idx0, idx1, idx2 ) \
-    ((float*)cvPtr3D( (hist)->bins, (idx0), (idx1), (idx2), 0))
-#define cvGetHistValue_nD( hist, idx ) \
-    ((float*)cvPtrND( (hist)->bins, (idx), 0))
-
-
-#define CV_IS_SET_ELEM_EXISTS CV_IS_SET_ELEM
-
-
-CV_EXPORTS  int  cvHoughLines( CvArr* image, double rho,
-                              double theta, int threshold,
-                              float* lines, int linesNumber );
-
-CV_EXPORTS  int  cvHoughLinesP( CvArr* image, double rho,
-                               double theta, int threshold,
-                               int lineLength, int lineGap,
-                               int* lines, int linesNumber );
-
-
-CV_EXPORTS  int  cvHoughLinesSDiv( CvArr* image, double rho, int srn,
-                                  double theta, int stn, int threshold,
-                                  float* lines, int linesNumber );
-
-CV_EXPORTS  float  cvCalcEMD( const float* signature1, int size1,
-                             const float* signature2, int size2,
-                             int dims, int dist_type CV_DEFAULT(CV_DIST_L2),
-                             CvDistanceFunction dist_func CV_DEFAULT(0),
-                             float* lower_bound CV_DEFAULT(0),
-                             void* user_param CV_DEFAULT(0));
-
-CV_EXPORTS  void  cvKMeans( int num_clusters, float** samples,
-                           int num_samples, int vec_size,
-                           CvTermCriteria termcrit, int* cluster_idx );
-
-CV_EXPORTS void  cvStartScanGraph( CvGraph* graph, CvGraphScanner* scanner,
-                                  CvGraphVtx* vtx CV_DEFAULT(NULL),
-                                  int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS));
-
-CV_EXPORTS  void  cvEndScanGraph( CvGraphScanner* scanner );
-
-
-/* old drawing functions */
-CV_EXPORTS void  cvLineAA( CvArr* img, CvPoint pt1, CvPoint pt2,
-                            double color, int scale CV_DEFAULT(0));
-
-CV_EXPORTS void  cvCircleAA( CvArr* img, CvPoint center, int radius,
-                            double color, int scale CV_DEFAULT(0) );
-
-CV_EXPORTS void  cvEllipseAA( CvArr* img, CvPoint center, CvSize axes,
-                              double angle, double start_angle,
-                              double end_angle, double color,
-                              int scale CV_DEFAULT(0) );
-
-CV_EXPORTS void  cvPolyLineAA( CvArr* img, CvPoint** pts, int* npts, int contours,
-                              int is_closed, double color, int scale CV_DEFAULT(0) );
-
-/****************************************************************************************\
-*                                   Pixel Access Macros                                  *
-\****************************************************************************************/
-
-typedef struct _CvPixelPosition8u
-{
-    uchar*  currline;      /* pointer to the start of the current pixel line   */
-    uchar*  topline;       /* pointer to the start of the top pixel line       */
-    uchar*  bottomline;    /* pointer to the start of the first line           */
-                                    /* which is below the image                         */
-    int     x;                      /* current x coordinate ( in pixels )               */
-    int     width;                  /* width of the image  ( in pixels )                */
-    int     height;                 /* height of the image  ( in pixels )               */
-    int     step;                   /* distance between lines ( in elements of single   */
-                                    /* plane )                                          */
-    int     step_arr[3];            /* array: ( 0, -step, step ). It is used for        */
-                                    /* vertical moving                                  */
-} CvPixelPosition8u;
-
-/* this structure differs from the above only in data type */
-typedef struct _CvPixelPosition8s
-{
-    schar*  currline;
-    schar*  topline;
-    schar*  bottomline;
-    int     x;
-    int     width;
-    int     height;
-    int     step;
-    int     step_arr[3];
-} CvPixelPosition8s;
-
-/* this structure differs from the CvPixelPosition8u only in data type */
-typedef struct _CvPixelPosition32f
-{
-    float*  currline;
-    float*  topline;
-    float*  bottomline;
-    int     x;
-    int     width;
-    int     height;
-    int     step;
-    int     step_arr[3];
-} CvPixelPosition32f;
-
-
-/* Initialize one of the CvPixelPosition structures.   */
-/*  pos    - initialized structure                     */
-/*  origin - pointer to the left-top corner of the ROI */
-/*  step   - width of the whole image in bytes         */
-/*  roi    - width & height of the ROI                 */
-/*  x, y   - initial position                          */
-#define CV_INIT_PIXEL_POS(pos, origin, _step, roi, _x, _y, orientation)    \
-    (                                                                        \
-    (pos).step = (_step)/sizeof((pos).currline[0]) * (orientation ? -1 : 1), \
-    (pos).width = (roi).width,                                               \
-    (pos).height = (roi).height,                                             \
-    (pos).bottomline = (origin) + (pos).step*(pos).height,                   \
-    (pos).topline = (origin) - (pos).step,                                   \
-    (pos).step_arr[0] = 0,                                                   \
-    (pos).step_arr[1] = -(pos).step,                                         \
-    (pos).step_arr[2] = (pos).step,                                          \
-    (pos).x = (_x),                                                          \
-    (pos).currline = (origin) + (pos).step*(_y) )
-
-
-/* Move to specified point ( absolute shift ) */
-/*  pos    - position structure               */
-/*  x, y   - coordinates of the new position  */
-/*  cs     - number of the image channels     */
-#define CV_MOVE_TO( pos, _x, _y, cs )                                                   \
-((pos).currline = (_y) >= 0 && (_y) < (pos).height ? (pos).topline + ((_y)+1)*(pos).step : 0, \
- (pos).x = (_x) >= 0 && (_x) < (pos).width ? (_x) : 0, (pos).currline + (_x) * (cs) )
-
-/* Get current coordinates                    */
-/*  pos    - position structure               */
-/*  x, y   - coordinates of the new position  */
-/*  cs     - number of the image channels     */
-#define CV_GET_CURRENT( pos, cs )  ((pos).currline + (pos).x * (cs))
-
-/* Move by one pixel relatively to current position */
-/*  pos    - position structure                     */
-/*  cs     - number of the image channels           */
-
-/* left */
-#define CV_MOVE_LEFT( pos, cs ) \
- ( --(pos).x >= 0 ? (pos).currline + (pos).x*(cs) : 0 )
-
-/* right */
-#define CV_MOVE_RIGHT( pos, cs ) \
- ( ++(pos).x < (pos).width ? (pos).currline + (pos).x*(cs) : 0 )
-
-/* up */
-#define CV_MOVE_UP( pos, cs ) \
- (((pos).currline -= (pos).step) != (pos).topline ? (pos).currline + (pos).x*(cs) : 0 )
-
-/* down */
-#define CV_MOVE_DOWN( pos, cs ) \
- (((pos).currline += (pos).step) != (pos).bottomline ? (pos).currline + (pos).x*(cs) : 0 )
-
-/* left up */
-#define CV_MOVE_LU( pos, cs ) ( CV_MOVE_LEFT(pos, cs), CV_MOVE_UP(pos, cs))
-
-/* right up */
-#define CV_MOVE_RU( pos, cs ) ( CV_MOVE_RIGHT(pos, cs), CV_MOVE_UP(pos, cs))
-
-/* left down */
-#define CV_MOVE_LD( pos, cs ) ( CV_MOVE_LEFT(pos, cs), CV_MOVE_DOWN(pos, cs))
-
-/* right down */
-#define CV_MOVE_RD( pos, cs ) ( CV_MOVE_RIGHT(pos, cs), CV_MOVE_DOWN(pos, cs))
-
-
-
-/* Move by one pixel relatively to current position with wrapping when the position     */
-/* achieves image boundary                                                              */
-/*  pos    - position structure                                                         */
-/*  cs     - number of the image channels                                               */
-
-/* left */
-#define CV_MOVE_LEFT_WRAP( pos, cs ) \
- ((pos).currline + ( --(pos).x >= 0 ? (pos).x : ((pos).x = (pos).width-1))*(cs))
-
-/* right */
-#define CV_MOVE_RIGHT_WRAP( pos, cs ) \
- ((pos).currline + ( ++(pos).x < (pos).width ? (pos).x : ((pos).x = 0))*(cs) )
-
-/* up */
-#define CV_MOVE_UP_WRAP( pos, cs ) \
-    ((((pos).currline -= (pos).step) != (pos).topline ? \
-    (pos).currline : ((pos).currline = (pos).bottomline - (pos).step)) + (pos).x*(cs) )
-
-/* down */
-#define CV_MOVE_DOWN_WRAP( pos, cs ) \
-    ((((pos).currline += (pos).step) != (pos).bottomline ? \
-    (pos).currline : ((pos).currline = (pos).topline + (pos).step)) + (pos).x*(cs) )
-
-/* left up */
-#define CV_MOVE_LU_WRAP( pos, cs ) ( CV_MOVE_LEFT_WRAP(pos, cs), CV_MOVE_UP_WRAP(pos, cs))
-/* right up */
-#define CV_MOVE_RU_WRAP( pos, cs ) ( CV_MOVE_RIGHT_WRAP(pos, cs), CV_MOVE_UP_WRAP(pos, cs))
-/* left down */
-#define CV_MOVE_LD_WRAP( pos, cs ) ( CV_MOVE_LEFT_WRAP(pos, cs), CV_MOVE_DOWN_WRAP(pos, cs))
-/* right down */
-#define CV_MOVE_RD_WRAP( pos, cs ) ( CV_MOVE_RIGHT_WRAP(pos, cs), CV_MOVE_DOWN_WRAP(pos, cs))
-
-/* Numeric constants which used for moving in arbitrary direction  */
-enum
-{
-    CV_SHIFT_NONE = 2,
-    CV_SHIFT_LEFT = 1,
-    CV_SHIFT_RIGHT = 3,
-    CV_SHIFT_UP = 6,
-    CV_SHIFT_DOWN = 10,
-    CV_SHIFT_LU = 5,
-    CV_SHIFT_RU = 7,
-    CV_SHIFT_LD = 9,
-    CV_SHIFT_RD = 11
-};
-
-/* Move by one pixel in specified direction                                     */
-/*  pos    - position structure                                                 */
-/*  shift  - direction ( it's value must be one of the CV_SHIFT_Ö constants ) */
-/*  cs     - number of the image channels                                       */
-#define CV_MOVE_PARAM( pos, shift, cs )                                             \
-    ( (pos).currline += (pos).step_arr[(shift)>>2], (pos).x += ((shift)&3)-2,       \
-    ((pos).currline != (pos).topline && (pos).currline != (pos).bottomline &&       \
-    (pos).x >= 0 && (pos).x < (pos).width) ? (pos).currline + (pos).x*(cs) : 0 )
-
-/* Move by one pixel in specified direction with wrapping when the               */
-/* position achieves image boundary                                              */
-/*  pos    - position structure                                                  */
-/*  shift  - direction ( it's value must be one of the CV_SHIFT_Ö constants )  */
-/*  cs     - number of the image channels                                        */
-#define CV_MOVE_PARAM_WRAP( pos, shift, cs )                                        \
-    ( (pos).currline += (pos).step_arr[(shift)>>2],                                 \
-    (pos).currline = ((pos).currline == (pos).topline ?                             \
-    (pos).bottomline - (pos).step :                                                 \
-    (pos).currline == (pos).bottomline ?                                            \
-    (pos).topline + (pos).step : (pos).currline),                                   \
-                                                                                    \
-    (pos).x += ((shift)&3)-2,                                                       \
-    (pos).x = ((pos).x < 0 ? (pos).width-1 : (pos).x >= (pos).width ? 0 : (pos).x), \
-                                                                                    \
-    (pos).currline + (pos).x*(cs) )
-
-
-typedef float*   CvVect32f;
-typedef float*   CvMatr32f;
-typedef double*  CvVect64d;
-typedef double*  CvMatr64d;
-
-CV_EXPORTS void cvUnDistortOnce( const CvArr* src, CvArr* dst,
-                                const float* intrinsic_matrix,
-                                const float* distortion_coeffs,
-                                int interpolate );
-
-/* the two functions below have quite hackerish implementations, use with care
-   (or, which is better, switch to cvUndistortInitMap and cvRemap instead */
-CV_EXPORTS void cvUnDistortInit( const CvArr* src,
-                                CvArr* undistortion_map,
-                                const float* A, const float* k,
-                                int interpolate );
-
-CV_EXPORTS void  cvUnDistort( const CvArr* src, CvArr* dst,
-                             const CvArr* undistortion_map,
-                             int interpolate );
-
-/* Find fundamental matrix */
-CV_EXPORTS void  cvFindFundamentalMatrix( int* points1, int* points2,
-    int numpoints, int method, float* matrix );
-
-
-CV_EXPORTS int cvFindChessBoardCornerGuesses( const void* arr, void* thresharr,
-                               CvMemStorage* storage,
-                               CvSize pattern_size, CvPoint2D32f * corners,
-                               int *corner_count );
-
-/* Calibrates camera using multiple views of calibration pattern */
-CV_EXPORTS void cvCalibrateCamera( int image_count, int* _point_counts,
-    CvSize image_size, CvPoint2D32f* _image_points, CvPoint3D32f* _object_points,
-    float* _distortion_coeffs, float* _camera_matrix, float* _translation_vectors,
-    float* _rotation_matrices, int flags );
-
-
-CV_EXPORTS void cvCalibrateCamera_64d( int image_count, int* _point_counts,
-    CvSize image_size, CvPoint2D64f* _image_points, CvPoint3D64f* _object_points,
-    double* _distortion_coeffs, double* _camera_matrix, double* _translation_vectors,
-    double* _rotation_matrices, int flags );
-
-
-/* Find 3d position of object given intrinsic camera parameters,
-   3d model of the object and projection of the object into view plane */
-CV_EXPORTS void cvFindExtrinsicCameraParams( int point_count,
-    CvSize image_size, CvPoint2D32f* _image_points,
-    CvPoint3D32f* _object_points, float* focal_length,
-    CvPoint2D32f principal_point, float* _distortion_coeffs,
-    float* _rotation_vector, float* _translation_vector );
-
-/* Variant of the previous function that takes double-precision parameters */
-CV_EXPORTS void cvFindExtrinsicCameraParams_64d( int point_count,
-    CvSize image_size, CvPoint2D64f* _image_points,
-    CvPoint3D64f* _object_points, double* focal_length,
-    CvPoint2D64f principal_point, double* _distortion_coeffs,
-    double* _rotation_vector, double* _translation_vector );
-
-/* Rodrigues transform */
-enum
-{
-    CV_RODRIGUES_M2V = 0,
-    CV_RODRIGUES_V2M = 1
-};
-
-/* Converts rotation_matrix matrix to rotation_matrix vector or vice versa */
-CV_EXPORTS void  cvRodrigues( CvMat* rotation_matrix, CvMat* rotation_vector,
-                              CvMat* jacobian, int conv_type );
-
-/* Does reprojection of 3d object points to the view plane */
-CV_EXPORTS void  cvProjectPoints( int point_count, CvPoint3D64f* _object_points,
-    double* _rotation_vector, double*  _translation_vector,
-    double* focal_length, CvPoint2D64f principal_point,
-    double* _distortion, CvPoint2D64f* _image_points,
-    double* _deriv_points_rotation_matrix,
-    double* _deriv_points_translation_vect,
-    double* _deriv_points_focal,
-    double* _deriv_points_principal_point,
-    double* _deriv_points_distortion_coeffs );
-
-
-/* Simpler version of the previous function */
-CV_EXPORTS void  cvProjectPointsSimple( int point_count, CvPoint3D64f* _object_points,
-    double* _rotation_matrix, double*  _translation_vector,
-    double* _camera_matrix, double* _distortion, CvPoint2D64f* _image_points );
-
-
-#define cvMake2DPoints cvConvertPointsHomogeneous
-#define cvMake3DPoints cvConvertPointsHomogeneous
-
-#define cvWarpPerspectiveQMatrix cvGetPerspectiveTransform
-
-#define cvConvertPointsHomogenious cvConvertPointsHomogeneous
-
-
-//////////////////////////////////// feature extractors: obsolete API //////////////////////////////////
-
-typedef struct CvSURFPoint
-{
-    CvPoint2D32f pt;
-
-    int          laplacian;
-    int          size;
-    float        dir;
-    float        hessian;
-
-} CvSURFPoint;
-
-CV_INLINE CvSURFPoint cvSURFPoint( CvPoint2D32f pt, int laplacian,
-                                  int size, float dir CV_DEFAULT(0),
-                                  float hessian CV_DEFAULT(0))
-{
-    CvSURFPoint kp;
-
-    kp.pt        = pt;
-    kp.laplacian = laplacian;
-    kp.size      = size;
-    kp.dir       = dir;
-    kp.hessian   = hessian;
-
-    return kp;
-}
-
-typedef struct CvSURFParams
-{
-    int    extended;
-    int    upright;
-    double hessianThreshold;
-
-    int    nOctaves;
-    int    nOctaveLayers;
-
-} CvSURFParams;
-
-CVAPI(CvSURFParams) cvSURFParams( double hessianThreshold, int extended CV_DEFAULT(0) );
-
-// If useProvidedKeyPts!=0, keypoints are not detected, but descriptors are computed
-//  at the locations provided in keypoints (a CvSeq of CvSURFPoint).
-CVAPI(void) cvExtractSURF( const CvArr* img, const CvArr* mask,
-                          CvSeq** keypoints, CvSeq** descriptors,
-                          CvMemStorage* storage, CvSURFParams params,
-                             int useProvidedKeyPts CV_DEFAULT(0)  );
-
-/*!
- Maximal Stable Regions Parameters
- */
-typedef struct CvMSERParams
-{
-    //! delta, in the code, it compares (size_{i}-size_{i-delta})/size_{i-delta}
-    int delta;
-    //! prune the area which bigger than maxArea
-    int maxArea;
-    //! prune the area which smaller than minArea
-    int minArea;
-    //! prune the area have simliar size to its children
-    float maxVariation;
-    //! trace back to cut off mser with diversity < min_diversity
-    float minDiversity;
-
-    /////// the next few params for MSER of color image
-
-    //! for color image, the evolution steps
-    int maxEvolution;
-    //! the area threshold to cause re-initialize
-    double areaThreshold;
-    //! ignore too small margin
-    double minMargin;
-    //! the aperture size for edge blur
-    int edgeBlurSize;
-} CvMSERParams;
-
-CVAPI(CvMSERParams) cvMSERParams( int delta CV_DEFAULT(5), int min_area CV_DEFAULT(60),
-                                 int max_area CV_DEFAULT(14400), float max_variation CV_DEFAULT(.25f),
-                                 float min_diversity CV_DEFAULT(.2f), int max_evolution CV_DEFAULT(200),
-                                 double area_threshold CV_DEFAULT(1.01),
-                                 double min_margin CV_DEFAULT(.003),
-                                 int edge_blur_size CV_DEFAULT(5) );
-
-// Extracts the contours of Maximally Stable Extremal Regions
-CVAPI(void) cvExtractMSER( CvArr* _img, CvArr* _mask, CvSeq** contours, CvMemStorage* storage, CvMSERParams params );
-
-
-typedef struct CvStarKeypoint
-{
-    CvPoint pt;
-    int size;
-    float response;
-} CvStarKeypoint;
-
-CV_INLINE CvStarKeypoint cvStarKeypoint(CvPoint pt, int size, float response)
-{
-    CvStarKeypoint kpt;
-    kpt.pt = pt;
-    kpt.size = size;
-    kpt.response = response;
-    return kpt;
-}
-
-typedef struct CvStarDetectorParams
-{
-    int maxSize;
-    int responseThreshold;
-    int lineThresholdProjected;
-    int lineThresholdBinarized;
-    int suppressNonmaxSize;
-} CvStarDetectorParams;
-
-CV_INLINE CvStarDetectorParams cvStarDetectorParams(
-                                                    int maxSize CV_DEFAULT(45),
-                                                    int responseThreshold CV_DEFAULT(30),
-                                                    int lineThresholdProjected CV_DEFAULT(10),
-                                                    int lineThresholdBinarized CV_DEFAULT(8),
-                                                    int suppressNonmaxSize CV_DEFAULT(5))
-{
-    CvStarDetectorParams params;
-    params.maxSize = maxSize;
-    params.responseThreshold = responseThreshold;
-    params.lineThresholdProjected = lineThresholdProjected;
-    params.lineThresholdBinarized = lineThresholdBinarized;
-    params.suppressNonmaxSize = suppressNonmaxSize;
-
-    return params;
-}
-
-CVAPI(CvSeq*) cvGetStarKeypoints( const CvArr* img, CvMemStorage* storage,
-                                 CvStarDetectorParams params CV_DEFAULT(cvStarDetectorParams()));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/modules/legacy/include/opencv2/legacy/legacy.hpp b/modules/legacy/include/opencv2/legacy/legacy.hpp
deleted file mode 100644 (file)
index adea8da..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                          License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifdef __OPENCV_BUILD
-#error this is a compatibility header which should not be used inside the OpenCV library
-#endif
-
-#include "opencv2/legacy.hpp"
diff --git a/modules/legacy/include/opencv2/legacy/streams.hpp b/modules/legacy/include/opencv2/legacy/streams.hpp
deleted file mode 100644 (file)
index e164bf4..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_CVSTREAMS_H__
-#define __OPENCV_CVSTREAMS_H__
-
-#ifdef WIN32
-#include <streams.h>  /* !!! IF YOU'VE GOT AN ERROR HERE, PLEASE READ BELOW !!! */
-/***************** How to get Visual Studio understand streams.h ****************\
-
-You need DirectShow SDK that is now a part of Platform SDK
-(Windows Server 2003 SP1 SDK or later),
-and DirectX SDK (2006 April or later).
-
-1. Download the Platform SDK from
-   http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
-   and DirectX SDK from msdn.microsoft.com/directx/
-   (They are huge, but you can download it by parts).
-   If it doesn't work for you, consider HighGUI that can capture video via VFW or MIL
-
-2. Install Platform SDK together with DirectShow SDK.
-   Install DirectX (with or without sample code).
-
-3. Build baseclasses.
-   See <PlatformSDKInstallFolder>\samples\multimedia\directshow\readme.txt.
-
-4. Copy the built libraries (called strmbase.lib and strmbasd.lib
-   in Release and Debug versions, respectively) to
-   <PlatformSDKInstallFolder>\lib.
-
-5. In Developer Studio add the following paths:
-      <DirectXSDKInstallFolder>\include
-      <PlatformSDKInstallFolder>\include
-      <PlatformSDKInstallFolder>\samples\multimedia\directshow\baseclasses
-    to the includes' search path
-    (at Tools->Options->Directories->Include files in case of Visual Studio 6.0,
-     at Tools->Options->Projects and Solutions->VC++ Directories->Include files in case
-     of Visual Studio 2005)
-   Add
-      <DirectXSDKInstallFolder>\lib
-      <PlatformSDKInstallFolder>\lib
-   to the libraries' search path (in the same dialog, ...->"Library files" page)
-
-   NOTE: PUT THE ADDED LINES ON THE VERY TOP OF THE LISTS, OTHERWISE YOU MAY STILL GET
-   COMPILER OR LINKER ERRORS. This is necessary, because Visual Studio
-   may include older versions of the same headers and libraries.
-
-6. Now you can build OpenCV DirectShow filters.
-
-\***********************************************************************************/
-
-#endif
-
-#endif
diff --git a/modules/legacy/src/3dtracker.cpp b/modules/legacy/src/3dtracker.cpp
deleted file mode 100644 (file)
index a55a9f8..0000000
+++ /dev/null
@@ -1,582 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2002, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistributions of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistributions in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "opencv2/calib3d/calib3d_c.h"
-
-#include <stdio.h>
-#include <map>
-#include <algorithm>
-
-#define ARRAY_SIZEOF(a) (sizeof(a)/sizeof((a)[0]))
-
-static void FillObjectPoints(CvPoint3D32f *obj_points, CvSize etalon_size, float square_size);
-static void DrawEtalon(IplImage *img, CvPoint2D32f *corners,
-                       int corner_count, CvSize etalon_size, int draw_ordered);
-static void MultMatrix(float rm[4][4], const float m1[4][4], const float m2[4][4]);
-static void MultVectorMatrix(float rv[4], const float v[4], const float m[4][4]);
-static CvPoint3D32f ImageCStoWorldCS(const Cv3dTrackerCameraInfo &camera_info, CvPoint2D32f p);
-static bool intersection(CvPoint3D32f o1, CvPoint3D32f p1,
-                         CvPoint3D32f o2, CvPoint3D32f p2,
-                         CvPoint3D32f &r1, CvPoint3D32f &r2);
-
-/////////////////////////////////
-// cv3dTrackerCalibrateCameras //
-/////////////////////////////////
-CV_IMPL CvBool cv3dTrackerCalibrateCameras(int num_cameras,
-                   const Cv3dTrackerCameraIntrinsics camera_intrinsics[], // size is num_cameras
-                   CvSize etalon_size,
-                   float square_size,
-                   IplImage *samples[],                                   // size is num_cameras
-                   Cv3dTrackerCameraInfo camera_info[])                   // size is num_cameras
-{
-    CV_FUNCNAME("cv3dTrackerCalibrateCameras");
-    const int num_points = etalon_size.width * etalon_size.height;
-    int cameras_done = 0;        // the number of cameras whose positions have been determined
-    CvPoint3D32f *object_points = NULL; // real-world coordinates of checkerboard points
-    CvPoint2D32f *points = NULL; // 2d coordinates of checkerboard points as seen by a camera
-    IplImage *gray_img = NULL;   // temporary image for color conversion
-    IplImage *tmp_img = NULL;    // temporary image used by FindChessboardCornerGuesses
-    int c, i, j;
-
-    if (etalon_size.width < 3 || etalon_size.height < 3)
-        CV_ERROR(CV_StsBadArg, "Chess board size is invalid");
-
-    for (c = 0; c < num_cameras; c++)
-    {
-        // CV_CHECK_IMAGE is not available in the cvaux library
-        // so perform the checks inline.
-
-        //CV_CALL(CV_CHECK_IMAGE(samples[c]));
-
-        if( samples[c] == NULL )
-            CV_ERROR( CV_HeaderIsNull, "Null image" );
-
-        if( samples[c]->dataOrder != IPL_DATA_ORDER_PIXEL && samples[c]->nChannels > 1 )
-            CV_ERROR( CV_BadOrder, "Unsupported image format" );
-
-        if( samples[c]->maskROI != 0 || samples[c]->tileInfo != 0 )
-            CV_ERROR( CV_StsBadArg, "Unsupported image format" );
-
-        if( samples[c]->imageData == 0 )
-            CV_ERROR( CV_BadDataPtr, "Null image data" );
-
-        if( samples[c]->roi &&
-            ((samples[c]->roi->xOffset | samples[c]->roi->yOffset
-              | samples[c]->roi->width | samples[c]->roi->height) < 0 ||
-             samples[c]->roi->xOffset + samples[c]->roi->width > samples[c]->width ||
-             samples[c]->roi->yOffset + samples[c]->roi->height > samples[c]->height ||
-             (unsigned) (samples[c]->roi->coi) > (unsigned) (samples[c]->nChannels)))
-            CV_ERROR( CV_BadROISize, "Invalid ROI" );
-
-        // End of CV_CHECK_IMAGE inline expansion
-
-        if (samples[c]->depth != IPL_DEPTH_8U)
-            CV_ERROR(CV_BadDepth, "Channel depth of source image must be 8");
-
-        if (samples[c]->nChannels != 3 && samples[c]->nChannels != 1)
-            CV_ERROR(CV_BadNumChannels, "Source image must have 1 or 3 channels");
-    }
-
-    CV_CALL(object_points = (CvPoint3D32f *)cvAlloc(num_points * sizeof(CvPoint3D32f)));
-    CV_CALL(points = (CvPoint2D32f *)cvAlloc(num_points * sizeof(CvPoint2D32f)));
-
-    // fill in the real-world coordinates of the checkerboard points
-    FillObjectPoints(object_points, etalon_size, square_size);
-
-    for (c = 0; c < num_cameras; c++)
-    {
-        CvSize image_size = cvSize(samples[c]->width, samples[c]->height);
-        IplImage *img;
-
-        // The input samples are not required to all have the same size or color
-        // format. If they have different sizes, the temporary images are
-        // reallocated as necessary.
-        if (samples[c]->nChannels == 3)
-        {
-            // convert to gray
-            if (gray_img == NULL || gray_img->width != samples[c]->width ||
-                gray_img->height != samples[c]->height )
-            {
-                if (gray_img != NULL)
-                    cvReleaseImage(&gray_img);
-                CV_CALL(gray_img = cvCreateImage(image_size, IPL_DEPTH_8U, 1));
-            }
-
-            CV_CALL(cvCvtColor(samples[c], gray_img, CV_BGR2GRAY));
-
-            img = gray_img;
-        }
-        else
-        {
-            // no color conversion required
-            img = samples[c];
-        }
-
-        if (tmp_img == NULL || tmp_img->width != samples[c]->width ||
-            tmp_img->height != samples[c]->height )
-        {
-            if (tmp_img != NULL)
-                cvReleaseImage(&tmp_img);
-            CV_CALL(tmp_img = cvCreateImage(image_size, IPL_DEPTH_8U, 1));
-        }
-
-        int count = num_points;
-        bool found = cvFindChessBoardCornerGuesses(img, tmp_img, 0,
-                                                   etalon_size, points, &count) != 0;
-        if (count == 0)
-            continue;
-
-        // If found is true, it means all the points were found (count = num_points).
-        // If found is false but count is non-zero, it means that not all points were found.
-
-        cvFindCornerSubPix(img, points, count, cvSize(5,5), cvSize(-1,-1),
-                    cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS, 10, 0.01f));
-
-        // If the image origin is BL (bottom-left), fix the y coordinates
-        // so they are relative to the true top of the image.
-        if (samples[c]->origin == IPL_ORIGIN_BL)
-        {
-            for (i = 0; i < count; i++)
-                points[i].y = samples[c]->height - 1 - points[i].y;
-        }
-
-        if (found)
-        {
-            // Make sure x coordinates are increasing and y coordinates are decreasing.
-            // (The y coordinate of point (0,0) should be the greatest, because the point
-            // on the checkerboard that is the origin is nearest the bottom of the image.)
-            // This is done after adjusting the y coordinates according to the image origin.
-            if (points[0].x > points[1].x)
-            {
-                // reverse points in each row
-                for (j = 0; j < etalon_size.height; j++)
-                {
-                    CvPoint2D32f *row = &points[j*etalon_size.width];
-                    for (i = 0; i < etalon_size.width/2; i++)
-                        std::swap(row[i], row[etalon_size.width-i-1]);
-                }
-            }
-
-            if (points[0].y < points[etalon_size.width].y)
-            {
-                // reverse points in each column
-                for (i = 0; i < etalon_size.width; i++)
-                {
-                    for (j = 0; j < etalon_size.height/2; j++)
-                        std::swap(points[i+j*etalon_size.width],
-                                  points[i+(etalon_size.height-j-1)*etalon_size.width]);
-                }
-            }
-        }
-
-        DrawEtalon(samples[c], points, count, etalon_size, found);
-
-        if (!found)
-            continue;
-
-        float rotVect[3];
-        float rotMatr[9];
-        float transVect[3];
-
-        cvFindExtrinsicCameraParams(count,
-                                    image_size,
-                                    points,
-                                    object_points,
-                                    const_cast<float *>(camera_intrinsics[c].focal_length),
-                                    camera_intrinsics[c].principal_point,
-                                    const_cast<float *>(camera_intrinsics[c].distortion),
-                                    rotVect,
-                                    transVect);
-
-        // Check result against an arbitrary limit to eliminate impossible values.
-        // (If the chess board were truly that far away, the camera wouldn't be able to
-        // see the squares.)
-        if (transVect[0] > 1000*square_size
-            || transVect[1] > 1000*square_size
-            || transVect[2] > 1000*square_size)
-        {
-            // ignore impossible results
-            continue;
-        }
-
-        CvMat rotMatrDescr = cvMat(3, 3, CV_32FC1, rotMatr);
-        CvMat rotVectDescr = cvMat(3, 1, CV_32FC1, rotVect);
-
-        /* Calc rotation matrix by Rodrigues Transform */
-        cvRodrigues2( &rotVectDescr, &rotMatrDescr );
-
-        //combine the two transformations into one matrix
-        //order is important! rotations are not commutative
-        float tmat[4][4] = { { 1.f, 0.f, 0.f, 0.f },
-                             { 0.f, 1.f, 0.f, 0.f },
-                             { 0.f, 0.f, 1.f, 0.f },
-                             { transVect[0], transVect[1], transVect[2], 1.f } };
-
-        float rmat[4][4] = { { rotMatr[0], rotMatr[1], rotMatr[2], 0.f },
-                             { rotMatr[3], rotMatr[4], rotMatr[5], 0.f },
-                             { rotMatr[6], rotMatr[7], rotMatr[8], 0.f },
-                             { 0.f, 0.f, 0.f, 1.f } };
-
-
-        MultMatrix(camera_info[c].mat, tmat, rmat);
-
-        // change the transformation of the cameras to put them in the world coordinate
-        // system we want to work with.
-
-        // Start with an identity matrix; then fill in the values to accomplish
-        // the desired transformation.
-        float smat[4][4] = { { 1.f, 0.f, 0.f, 0.f },
-                             { 0.f, 1.f, 0.f, 0.f },
-                             { 0.f, 0.f, 1.f, 0.f },
-                             { 0.f, 0.f, 0.f, 1.f } };
-
-        // First, reflect through the origin by inverting all three axes.
-        smat[0][0] = -1.f;
-        smat[1][1] = -1.f;
-        smat[2][2] = -1.f;
-        MultMatrix(tmat, camera_info[c].mat, smat);
-
-        // Scale x and y coordinates by the focal length (allowing for non-square pixels
-        // and/or non-symmetrical lenses).
-        smat[0][0] = 1.0f / camera_intrinsics[c].focal_length[0];
-        smat[1][1] = 1.0f / camera_intrinsics[c].focal_length[1];
-        smat[2][2] = 1.0f;
-        MultMatrix(camera_info[c].mat, smat, tmat);
-
-        camera_info[c].principal_point = camera_intrinsics[c].principal_point;
-        camera_info[c].valid = true;
-
-        cameras_done++;
-    }
-
-exit:
-    cvReleaseImage(&gray_img);
-    cvReleaseImage(&tmp_img);
-    cvFree(&object_points);
-    cvFree(&points);
-
-    return cameras_done == num_cameras;
-}
-
-// fill in the real-world coordinates of the checkerboard points
-static void FillObjectPoints(CvPoint3D32f *obj_points, CvSize etalon_size, float square_size)
-{
-    int x, y, i;
-
-    for (y = 0, i = 0; y < etalon_size.height; y++)
-    {
-        for (x = 0; x < etalon_size.width; x++, i++)
-        {
-            obj_points[i].x = square_size * x;
-            obj_points[i].y = square_size * y;
-            obj_points[i].z = 0;
-        }
-    }
-}
-
-
-// Mark the points found on the input image
-// The marks are drawn multi-colored if all the points were found.
-static void DrawEtalon(IplImage *img, CvPoint2D32f *corners,
-                       int corner_count, CvSize etalon_size, int draw_ordered)
-{
-    const int r = 4;
-    int i;
-    int x, y;
-    CvPoint prev_pt;
-    static const CvScalar rgb_colors[] =
-    {
-        CvScalar(0,0,255),
-        CvScalar(0,128,255),
-        CvScalar(0,200,200),
-        CvScalar(0,255,0),
-        CvScalar(200,200,0),
-        CvScalar(255,0,0),
-        CvScalar(255,0,255)
-    };
-    static const CvScalar gray_colors[] = {
-        CvScalar(80), CvScalar(120), CvScalar(160), CvScalar(200), CvScalar(100), CvScalar(140), CvScalar(180)
-    };
-    const CvScalar* colors = img->nChannels == 3 ? rgb_colors : gray_colors;
-
-    CvScalar color = colors[0];
-    for (y = 0, i = 0; y < etalon_size.height; y++)
-    {
-        if (draw_ordered)
-            color = colors[y % ARRAY_SIZEOF(rgb_colors)];
-
-        for (x = 0; x < etalon_size.width && i < corner_count; x++, i++)
-        {
-            CvPoint pt;
-            pt.x = cvRound(corners[i].x);
-            pt.y = cvRound(corners[i].y);
-            if (img->origin == IPL_ORIGIN_BL)
-                pt.y = img->height - 1 - pt.y;
-
-            if (draw_ordered)
-            {
-                if (i != 0)
-                   cvLine(img, prev_pt, pt, color, 1, CV_AA);
-                prev_pt = pt;
-            }
-
-            cvLine( img, cvPoint(pt.x - r, pt.y - r),
-                    cvPoint(pt.x + r, pt.y + r), color, 1, CV_AA );
-            cvLine( img, cvPoint(pt.x - r, pt.y + r),
-                    cvPoint(pt.x + r, pt.y - r), color, 1, CV_AA );
-            cvCircle( img, pt, r+1, color, 1, CV_AA );
-        }
-    }
-}
-
-// Find the midpoint of the line segment between two points.
-static CvPoint3D32f midpoint(const CvPoint3D32f &p1, const CvPoint3D32f &p2)
-{
-    return cvPoint3D32f((p1.x+p2.x)/2, (p1.y+p2.y)/2, (p1.z+p2.z)/2);
-}
-
-static void operator +=(CvPoint3D32f &p1, const CvPoint3D32f &p2)
-{
-    p1.x += p2.x;
-    p1.y += p2.y;
-    p1.z += p2.z;
-}
-
-static CvPoint3D32f operator /(const CvPoint3D32f &p, int d)
-{
-    return cvPoint3D32f(p.x/d, p.y/d, p.z/d);
-}
-
-static const Cv3dTracker2dTrackedObject *find(const Cv3dTracker2dTrackedObject v[], int num_objects, int id)
-{
-    for (int i = 0; i < num_objects; i++)
-    {
-        if (v[i].id == id)
-            return &v[i];
-    }
-    return NULL;
-}
-
-#define CAMERA_POS(c) (cvPoint3D32f((c).mat[3][0], (c).mat[3][1], (c).mat[3][2]))
-
-//////////////////////////////
-// cv3dTrackerLocateObjects //
-//////////////////////////////
-CV_IMPL int  cv3dTrackerLocateObjects(int num_cameras, int num_objects,
-                 const Cv3dTrackerCameraInfo camera_info[],      // size is num_cameras
-                 const Cv3dTracker2dTrackedObject tracking_info[], // size is num_objects*num_cameras
-                 Cv3dTrackerTrackedObject tracked_objects[])     // size is num_objects
-{
-    /*CV_FUNCNAME("cv3dTrackerLocateObjects");*/
-    int found_objects = 0;
-
-    // count how many cameras could see each object
-    std::map<int, int> count;
-    for (int c = 0; c < num_cameras; c++)
-    {
-        if (!camera_info[c].valid)
-            continue;
-
-        for (int i = 0; i < num_objects; i++)
-        {
-            const Cv3dTracker2dTrackedObject *o = &tracking_info[c*num_objects+i];
-            if (o->id != -1)
-                count[o->id]++;
-        }
-    }
-
-    // process each object that was seen by at least two cameras
-    for (std::map<int, int>::iterator i = count.begin(); i != count.end(); i++)
-    {
-        if (i->second < 2)
-            continue; // ignore object seen by only one camera
-        int id = i->first;
-
-        // find an approximation of the objects location for each pair of cameras that
-        // could see this object, and average them
-        CvPoint3D32f total = cvPoint3D32f(0, 0, 0);
-        int weight = 0;
-
-        for (int c1 = 0; c1 < num_cameras-1; c1++)
-        {
-            if (!camera_info[c1].valid)
-                continue;
-
-            const Cv3dTracker2dTrackedObject *o1 = find(&tracking_info[c1*num_objects],
-                                                        num_objects, id);
-            if (o1 == NULL)
-                continue; // this camera didn't see this object
-
-            CvPoint3D32f p1a = CAMERA_POS(camera_info[c1]);
-            CvPoint3D32f p1b = ImageCStoWorldCS(camera_info[c1], o1->p);
-
-            for (int c2 = c1 + 1; c2 < num_cameras; c2++)
-            {
-                if (!camera_info[c2].valid)
-                    continue;
-
-                const Cv3dTracker2dTrackedObject *o2 = find(&tracking_info[c2*num_objects],
-                                                            num_objects, id);
-                if (o2 == NULL)
-                    continue; // this camera didn't see this object
-
-                CvPoint3D32f p2a = CAMERA_POS(camera_info[c2]);
-                CvPoint3D32f p2b = ImageCStoWorldCS(camera_info[c2], o2->p);
-
-                // these variables are initialized simply to avoid erroneous error messages
-                // from the compiler
-                CvPoint3D32f r1 = cvPoint3D32f(0, 0, 0);
-                CvPoint3D32f r2 = cvPoint3D32f(0, 0, 0);
-
-                // find the intersection of the two lines (or the points of closest
-                // approach, if they don't intersect)
-                if (!intersection(p1a, p1b, p2a, p2b, r1, r2))
-                    continue;
-
-                total += midpoint(r1, r2);
-                weight++;
-            }
-        }
-
-        CvPoint3D32f center = total/weight;
-        tracked_objects[found_objects++] = cv3dTrackerTrackedObject(id, center);
-    }
-
-    return found_objects;
-}
-
-#define EPS 1e-9
-
-// Compute the determinant of the 3x3 matrix represented by 3 row vectors.
-static inline double det(CvPoint3D32f v1, CvPoint3D32f v2, CvPoint3D32f v3)
-{
-    return v1.x*v2.y*v3.z + v1.z*v2.x*v3.y + v1.y*v2.z*v3.x
-           - v1.z*v2.y*v3.x - v1.x*v2.z*v3.y - v1.y*v2.x*v3.z;
-}
-
-static CvPoint3D32f operator +(CvPoint3D32f a, CvPoint3D32f b)
-{
-    return cvPoint3D32f(a.x + b.x, a.y + b.y, a.z + b.z);
-}
-
-static CvPoint3D32f operator -(CvPoint3D32f a, CvPoint3D32f b)
-{
-    return cvPoint3D32f(a.x - b.x, a.y - b.y, a.z - b.z);
-}
-
-static CvPoint3D32f operator *(CvPoint3D32f v, double f)
-{
-    return cvPoint3D32f(f*v.x, f*v.y, f*v.z);
-}
-
-
-// Find the intersection of two lines, or if they don't intersect,
-// the points of closest approach.
-// The lines are defined by (o1,p1) and (o2, p2).
-// If they intersect, r1 and r2 will be the same.
-// Returns false on error.
-static bool intersection(CvPoint3D32f o1, CvPoint3D32f p1,
-                         CvPoint3D32f o2, CvPoint3D32f p2,
-                         CvPoint3D32f &r1, CvPoint3D32f &r2)
-{
-    CvPoint3D32f x = o2 - o1;
-    CvPoint3D32f d1 = p1 - o1;
-    CvPoint3D32f d2 = p2 - o2;
-
-    CvPoint3D32f cross = cvPoint3D32f(d1.y*d2.z - d1.z*d2.y,
-                                      d1.z*d2.x - d1.x*d2.z,
-                                      d1.x*d2.y - d1.y*d2.x);
-    double den = cross.x*cross.x + cross.y*cross.y + cross.z*cross.z;
-
-    if (den < EPS)
-        return false;
-
-    double t1 = det(x, d2, cross) / den;
-    double t2 = det(x, d1, cross) / den;
-
-    r1 = o1 + d1 * t1;
-    r2 = o2 + d2 * t2;
-
-    return true;
-}
-
-// Convert from image to camera space by transforming point p in
-// the image plane by the camera matrix.
-static CvPoint3D32f ImageCStoWorldCS(const Cv3dTrackerCameraInfo &camera_info, CvPoint2D32f p)
-{
-    float tp[4];
-    tp[0] = (float)p.x - camera_info.principal_point.x;
-    tp[1] = (float)p.y - camera_info.principal_point.y;
-    tp[2] = 1.f;
-    tp[3] = 1.f;
-
-    float tr[4];
-    //multiply tp by mat to get tr
-    MultVectorMatrix(tr, tp, camera_info.mat);
-
-    return cvPoint3D32f(tr[0]/tr[3], tr[1]/tr[3], tr[2]/tr[3]);
-}
-
-// Multiply affine transformation m1 by the affine transformation m2 and
-// return the result in rm.
-static void MultMatrix(float rm[4][4], const float m1[4][4], const float m2[4][4])
-{
-    for (int i=0; i<=3; i++)
-        for (int j=0; j<=3; j++)
-        {
-            rm[i][j]= 0.0;
-            for (int k=0; k <= 3; k++)
-                rm[i][j] += m1[i][k]*m2[k][j];
-        }
-}
-
-// Multiply the vector v by the affine transformation matrix m and return the
-// result in rv.
-void MultVectorMatrix(float rv[4], const float v[4], const float m[4][4])
-{
-    for (int i=0; i<=3; i++)
-    {
-        rv[i] = 0.f;
-        for (int j=0;j<=3;j++)
-            rv[i] += v[j] * m[j][i];
-    }
-}
diff --git a/modules/legacy/src/_facedetection.h b/modules/legacy/src/_facedetection.h
deleted file mode 100644 (file)
index 32f1a98..0000000
+++ /dev/null
@@ -1,412 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-///////////////////////////////////////////////
-//// Created by Khudyakov V.A. bober@gorodok.net
-// FaceDetection.h: interface for the FaceDetection class.
-//
-//////////////////////////////////////////////////////////////////////
-
-#ifndef _CVFACEDETECTION_H_
-#define _CVFACEDETECTION_H_
-
-#define MAX_LAYERS 64
-
-class FaceFeature
-{
-public:
-    FaceFeature(double dWeight,void * lpContour,bool bIsFeature);
-    FaceFeature();
-    virtual ~FaceFeature();
-    inline bool isFaceFeature();
-    inline void * GetContour();
-    inline double GetWeight();
-    inline void SetContour(void * lpContour);
-    inline void SetWeight(double dWeight);
-    inline void SetFeature(bool bIsFeature);
-private:
-    double m_dWeight;
-    void * m_lpContour;
-    bool m_bIsFaceFeature;
-};//class FaceFeature
-
-inline void FaceFeature::SetFeature(bool bIsFeature)
-{
-    m_bIsFaceFeature = bIsFeature;
-}
-
-inline bool FaceFeature::isFaceFeature()
-{
-    return m_bIsFaceFeature;
-}//inline bool FaceFeature::isFaceFeature()
-
-inline void * FaceFeature::GetContour()
-{
-    return m_lpContour;
-}//inline void * FaceFeature::GetContour()
-
-inline double FaceFeature::GetWeight()
-{
-    return m_dWeight;
-}//inline long FaceFeature::GetWeight()
-
-inline void FaceFeature::SetContour(void * lpContour)
-{
-    m_lpContour = lpContour;
-}//inline void FaceFeature::SetContour(void * lpContour)
-
-inline void FaceFeature::SetWeight(double  dWeight)
-{
-    m_dWeight = dWeight;
-}//inline void FaceFeature::SetWeight(double * dWeight)
-
-
-
-class FaceTemplate
-{
-public:
-    FaceTemplate(long lFeatureCount) {m_lFeaturesCount = lFeatureCount;  m_lpFeaturesList = new FaceFeature[lFeatureCount];};
-    virtual ~FaceTemplate();
-
-    inline long GetCount();
-    inline FaceFeature * GetFeatures();
-
-protected:
-    FaceFeature * m_lpFeaturesList;
-private:
-    long m_lFeaturesCount;
-};//class FaceTemplate
-
-
-inline long FaceTemplate::GetCount()
-{
-    return m_lFeaturesCount;
-}//inline long FaceTemplate::GetCount()
-
-
-inline FaceFeature * FaceTemplate::GetFeatures()
-{
-    return m_lpFeaturesList;
-}//inline FaceFeature * FaceTemplate::GetFeatures()
-
-////////////
-//class RFaceTemplate
-///////////
-
-class MouthFaceTemplate:public FaceTemplate
-{
-public:
-    inline MouthFaceTemplate(long lNumber,CvRect rect,double dEyeWidth,double dEyeHeight,double dDistanceBetweenEye,double dDistanceEyeAboveMouth);
-    ~MouthFaceTemplate();
-};//class MouthFaceTemplate:public FaceTemplate
-
-
-inline MouthFaceTemplate::MouthFaceTemplate(long lNumber,CvRect rect,double dEyeWidth,double dEyeHeight,
-                             double dDistanceBetweenEye,double dDistanceEyeAboveMouth):FaceTemplate(lNumber)
-{
-
-    CvRect MouthRect = rect;
-
-
-    CvRect LeftEyeRect = cvRect(cvRound(rect.x - (dEyeWidth + dDistanceBetweenEye/(double)2 - (double)rect.width/(double)2)),
-                                cvRound(rect.y - dDistanceEyeAboveMouth - dEyeHeight),
-                                cvRound(dEyeWidth),
-                                cvRound(dEyeHeight) );
-
-    CvRect RightEyeRect = cvRect(cvRound(rect.x + (double)rect.width/(double)2 + dDistanceBetweenEye/(double)2),
-                                 cvRound(rect.y - dDistanceEyeAboveMouth - dEyeHeight),
-                                 cvRound(dEyeWidth),
-                                 cvRound(dEyeHeight) );
-
-//  CvRect NoseRect = cvRect(cvRound(rect.x + (double)rect.width/(double)4),
-//                           cvRound(rect.y - (double)rect.width/(double)2 - (double)rect.height/(double)4),
-//                           cvRound((double)rect.width/(double)2),
-//                           cvRound((double)rect.width/(double)2) );
-/*
-    CvRect CheenRect = cvRect(rect.x,rect.y + 3*rect.height/2,rect.width,rect.height);
-
-*/
-
-    CvRect * lpMouthRect = new CvRect();
-    *lpMouthRect = MouthRect;
-    m_lpFeaturesList[0].SetContour(lpMouthRect);
-    m_lpFeaturesList[0].SetWeight(1);
-    m_lpFeaturesList[0].SetFeature(false);
-
-
-    CvRect * lpLeftEyeRect = new CvRect();
-    *lpLeftEyeRect = LeftEyeRect;
-    m_lpFeaturesList[1].SetContour(lpLeftEyeRect);
-    m_lpFeaturesList[1].SetWeight(1);
-    m_lpFeaturesList[1].SetFeature(true);
-
-    CvRect * lpRightEyeRect = new CvRect();
-    *lpRightEyeRect = RightEyeRect;
-    m_lpFeaturesList[2].SetContour(lpRightEyeRect);
-    m_lpFeaturesList[2].SetWeight(1);
-    m_lpFeaturesList[2].SetFeature(true);
-
-
-//  CvRect * lpNoseRect = new CvRect();
-//  *lpNoseRect = NoseRect;
-//  m_lpFeaturesList[3].SetContour(lpNoseRect);
-//  m_lpFeaturesList[3].SetWeight(0);
-//  m_lpFeaturesList[3].SetFeature(true);
-
-/*  CvRect * lpCheenRect = new CvRect();
-    *lpCheenRect = CheenRect;
-    m_lpFeaturesList[4].SetContour(lpCheenRect);
-    m_lpFeaturesList[4].SetWeight(1);
-    m_lpFeaturesList[4].SetFeature(false);
-
-*/
-
-}//constructor MouthFaceTemplate(long lNumFeatures,CvRect rect,double dEyeWidth,double dEyeHeight,double dDistanceBetweenEye,double dDistanceEyeAboveMouth);
-
-
-typedef struct CvContourRect
-{
-    int     iNumber;
-    int     iType;
-    int     iFlags;
-    CvSeq   *seqContour;
-    int     iContourLength;
-    CvRect  r;
-    CvPoint pCenter;
-    int     iColor;
-} CvContourRect;
-
-class Face
-{
-public:
-    Face(FaceTemplate * lpFaceTemplate);
-    virtual ~Face();
-
-    inline bool isFeature(void * lpElem);
-
-    virtual void Show(IplImage * /*Image*/){};
-    virtual void ShowIdeal(IplImage* /*Image*/){};
-
-    virtual void CreateFace(void * lpData) = 0;
-    virtual bool CheckElem(void * lpCandidat,void * lpIdeal) = 0;
-    virtual double GetWeight() = 0;
-protected:
-    FaceFeature * m_lpIdealFace;//ideal face definition
-    long m_lFaceFeaturesNumber; //total number of diferent face features
-    long * m_lplFaceFeaturesCount;//number of each features fouded for this face
-    FaceFeature ** m_lppFoundedFaceFeatures;//founded features of curen face
-    double m_dWeight;
-};
-
-inline bool Face::isFeature(void * lpElem)
-{
-    for (int i = 0;i < m_lFaceFeaturesNumber;i ++)
-    {
-        void * lpIdeal = m_lpIdealFace[i].GetContour();
-
-        if ( CheckElem( lpElem,lpIdeal) )
-        {
-            if (m_lplFaceFeaturesCount[i] < 3*MAX_LAYERS)
-            {
-                double dWeight = m_lpIdealFace[i].GetWeight();
-                bool bIsFeature = m_lpIdealFace[i].isFaceFeature();
-
-
-                if (bIsFeature)
-                {
-                    m_lppFoundedFaceFeatures[i][m_lplFaceFeaturesCount[i]].SetWeight(dWeight);
-                    m_lppFoundedFaceFeatures[i][m_lplFaceFeaturesCount[i]].SetContour(lpElem);
-                    m_lppFoundedFaceFeatures[i][m_lplFaceFeaturesCount[i]].SetFeature(bIsFeature);
-                    m_lplFaceFeaturesCount[i] ++;
-                }
-
-                m_dWeight += dWeight;
-
-                if (bIsFeature)
-                    return true;
-            }
-        }
-
-    }
-
-    return false;
-}//inline bool RFace::isFeature(void * lpElem);
-
-
-struct FaceData
-{
-    CvRect LeftEyeRect;
-    CvRect RightEyeRect;
-    CvRect MouthRect;
-    double Error;
-};//struct FaceData
-
-class RFace:public Face
-{
-public:
-    RFace(FaceTemplate * lpFaceTemplate);
-    virtual ~RFace();
-    virtual bool CheckElem(void * lpCandidat,void * lpIdeal);
-    virtual void  CreateFace(void * lpData);
-    virtual void Show(IplImage* Image);
-    virtual void ShowIdeal(IplImage* Image);
-    virtual double GetWeight();
-private:
-    bool isPointInRect(CvPoint p,CvRect rect);
-    bool m_bIsGenerated;
-    void ResizeRect(CvRect Rect,CvRect * lpRect,long lDir,long lD);
-    void CalculateError(FaceData * lpFaceData);
-};
-
-
-class FaceDetectionListElem
-{
-public:
-    FaceDetectionListElem();
-    FaceDetectionListElem(Face * pFace,FaceDetectionListElem * pHead);
-    virtual ~FaceDetectionListElem();
-    FaceDetectionListElem * m_pNext;
-    FaceDetectionListElem * m_pPrev;
-    Face * m_pFace;
-};//class FaceDetectionListElem
-
-class FaceDetectionList
-{
-public:
-    FaceDetectionList();
-    int AddElem(Face * pFace);
-    virtual ~FaceDetectionList();
-    Face* GetData();
-        long m_FacesCount;
-private:
-    FaceDetectionListElem * m_pHead;
-    FaceDetectionListElem * m_pCurElem;
-};//class FaceDetectionList
-
-
-class FaceDetection
-{
-public:
-    void FindFace(IplImage* img);
-    void CreateResults(CvSeq * lpSeq);
-    FaceDetection();
-    virtual ~FaceDetection();
-    void SetBoosting(bool bBoosting) {m_bBoosting = bBoosting;}
-    bool isPostBoosting() {return m_bBoosting;}
-protected:
-
-    IplImage* m_imgGray;
-    IplImage* m_imgThresh;
-    int m_iNumLayers;
-    CvMemStorage* m_mstgContours;
-    CvSeq* m_seqContours[MAX_LAYERS];
-    CvMemStorage* m_mstgRects;
-    CvSeq* m_seqRects;
-
-    bool m_bBoosting;
-    FaceDetectionList * m_pFaceList;
-
-protected:
-    void ResetImage();
-    void FindContours(IplImage* imgGray);
-    void AddContours2Rect(CvSeq*  seq, int color, int iLayer);
-    void ThresholdingParam(IplImage* imgGray, int iNumLayers, int& iMinLevel, int& iMaxLevel, int& iStep);
-    void FindCandidats();
-    void PostBoostingFindCandidats(IplImage * FaceImage);
-};
-
-inline void ReallocImage(IplImage** ppImage, CvSize sz, long lChNum)
-{
-    IplImage* pImage;
-    if( ppImage == NULL )
-        return;
-    pImage = *ppImage;
-    if( pImage != NULL )
-    {
-        if (pImage->width != sz.width || pImage->height != sz.height || pImage->nChannels != lChNum)
-            cvReleaseImage( &pImage );
-    }
-    if( pImage == NULL )
-        pImage = cvCreateImage( sz, IPL_DEPTH_8U, lChNum);
-    *ppImage = pImage;
-}
-
-////////////
-//class RFaceTemplate
-///////////
-
-class BoostingFaceTemplate:public FaceTemplate
-{
-public:
-    inline BoostingFaceTemplate(long lNumber,CvRect rect);
-    ~BoostingFaceTemplate() {};
-};//class RFaceTemplate:public FaceTemplate
-
-
-inline BoostingFaceTemplate::BoostingFaceTemplate(long lNumber,CvRect rect):FaceTemplate(lNumber)
-{
-    long EyeWidth = rect.width/5;
-    long EyeHeight = EyeWidth;
-
-    CvRect LeftEyeRect = cvRect(rect.x + EyeWidth,rect.y + rect.height/2 - EyeHeight,EyeWidth,EyeHeight);
-    CvRect RightEyeRect = cvRect(rect.x + 3*EyeWidth,rect.y + rect.height/2 - EyeHeight,EyeWidth,EyeHeight);
-    CvRect MouthRect = cvRect(rect.x + 3*EyeWidth/2,rect.y + 3*rect.height/4 - EyeHeight/2,2*EyeWidth,EyeHeight);
-
-    CvRect * lpMouthRect = new CvRect();
-    *lpMouthRect = MouthRect;
-    m_lpFeaturesList[0].SetContour(lpMouthRect);
-    m_lpFeaturesList[0].SetWeight(1);
-    m_lpFeaturesList[0].SetFeature(true);
-
-    CvRect * lpLeftEyeRect = new CvRect();
-    *lpLeftEyeRect = LeftEyeRect;
-    m_lpFeaturesList[1].SetContour(lpLeftEyeRect);
-    m_lpFeaturesList[1].SetWeight(1);
-    m_lpFeaturesList[1].SetFeature(true);
-
-    CvRect * lpRightEyeRect = new CvRect();
-    *lpRightEyeRect = RightEyeRect;
-    m_lpFeaturesList[2].SetContour(lpRightEyeRect);
-    m_lpFeaturesList[2].SetWeight(1);
-    m_lpFeaturesList[2].SetFeature(true);
-
-}//inline BoostingFaceTemplate::BoostingFaceTemplate(long lNumber,CvRect rect):FaceTemplate(lNumber)
-
-#endif // !defined(AFX_FACEDETECTION_H__55865033_D8E5_4DD5_8925_34C2285BB1BE__INCLUDED_)
diff --git a/modules/legacy/src/_featuretree.h b/modules/legacy/src/_featuretree.h
deleted file mode 100644 (file)
index 76a7b4f..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2009, Xavier Delacour, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-// 2009-01-09, Xavier Delacour <xavier.delacour@gmail.com>
-
-#ifndef __opencv_featuretree_h__
-#define __opencv_featuretree_h__
-
-struct CvFeatureTree {
-  CvFeatureTree(const CvFeatureTree& x);
-  CvFeatureTree& operator= (const CvFeatureTree& rhs);
-
-  CvFeatureTree() {}
-  virtual ~CvFeatureTree() {}
-  virtual void FindFeatures(const CvMat* d, int k, int emax, CvMat* results, CvMat* dist) = 0;
-  virtual int FindOrthoRange(CvMat* /*bounds_min*/, CvMat* /*bounds_max*/,CvMat* /*results*/) {
-    return 0;
-  }
-};
-
-#endif // __cv_featuretree_h__
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/modules/legacy/src/_kdtree.hpp b/modules/legacy/src/_kdtree.hpp
deleted file mode 100644 (file)
index 48925ee..0000000
+++ /dev/null
@@ -1,464 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2008, Xavier Delacour, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-// 2008-05-13, Xavier Delacour <xavier.delacour@gmail.com>
-
-#ifndef __cv_kdtree_h__
-#define __cv_kdtree_h__
-
-#include "precomp.hpp"
-
-#include <vector>
-#include <algorithm>
-#include <limits>
-#include <iostream>
-#include "assert.h"
-#include "math.h"
-
-// J.S. Beis and D.G. Lowe. Shape indexing using approximate nearest-neighbor search
-// in highdimensional spaces. In Proc. IEEE Conf. Comp. Vision Patt. Recog.,
-// pages 1000--1006, 1997. http://citeseer.ist.psu.edu/beis97shape.html
-#undef __deref
-#undef __valuetype
-
-template < class __valuetype, class __deref >
-class CvKDTree {
-public:
-  typedef __deref deref_type;
-  typedef typename __deref::scalar_type scalar_type;
-  typedef typename __deref::accum_type accum_type;
-
-private:
-  struct node {
-    int dim;      // split dimension; >=0 for nodes, -1 for leaves
-    __valuetype value;    // if leaf, value of leaf
-    int left, right;    // node indices of left and right branches
-    scalar_type boundary; // left if deref(value,dim)<=boundary, otherwise right
-  };
-  typedef std::vector < node > node_array;
-
-  __deref deref;    // requires operator() (__valuetype lhs,int dim)
-
-  node_array nodes;   // node storage
-  int point_dim;    // dimension of points (the k in kd-tree)
-  int root_node;    // index of root node, -1 if empty tree
-
-  // for given set of point indices, compute dimension of highest variance
-  template < class __instype, class __valuector >
-  int dimension_of_highest_variance(__instype * first, __instype * last,
-            __valuector ctor) {
-    assert(last - first > 0);
-
-    accum_type maxvar = -std::numeric_limits < accum_type >::max();
-    int maxj = -1;
-    for (int j = 0; j < point_dim; ++j) {
-      accum_type mean = 0;
-      for (__instype * k = first; k < last; ++k)
-  mean += deref(ctor(*k), j);
-      mean /= last - first;
-      accum_type var = 0;
-      for (__instype * k = first; k < last; ++k) {
-  accum_type diff = accum_type(deref(ctor(*k), j)) - mean;
-  var += diff * diff;
-      }
-      var /= last - first;
-
-      assert(maxj != -1 || var >= maxvar);
-
-      if (var >= maxvar) {
-  maxvar = var;
-  maxj = j;
-      }
-    }
-
-    return maxj;
-  }
-
-  // given point indices and dimension, find index of median; (almost) modifies [first,last)
-  // such that points_in[first,median]<=point[median], points_in(median,last)>point[median].
-  // implemented as partial quicksort; expected linear perf.
-  template < class __instype, class __valuector >
-  __instype * median_partition(__instype * first, __instype * last,
-             int dim, __valuector ctor) {
-    assert(last - first > 0);
-    __instype *k = first + (last - first) / 2;
-    median_partition(first, last, k, dim, ctor);
-    return k;
-  }
-
-  template < class __instype, class __valuector >
-  struct median_pr {
-    const __instype & pivot;
-    int dim;
-    __deref deref;
-    __valuector ctor;
-    median_pr(const __instype & _pivot, int _dim, __deref _deref, __valuector _ctor)
-      : pivot(_pivot), dim(_dim), deref(_deref), ctor(_ctor) {
-    }
-    bool operator() (const __instype & lhs) const {
-      return deref(ctor(lhs), dim) <= deref(ctor(pivot), dim);
-    }
-  private:
-    median_pr& operator=(const median_pr&);
-  };
-
-  template < class __instype, class __valuector >
-  void median_partition(__instype * first, __instype * last,
-      __instype * k, int dim, __valuector ctor) {
-    int pivot = (int)((last - first) / 2);
-
-    std::swap(first[pivot], last[-1]);
-    __instype *middle = std::partition(first, last - 1,
-               median_pr < __instype, __valuector >
-               (last[-1], dim, deref, ctor));
-    std::swap(*middle, last[-1]);
-
-    if (middle < k)
-      median_partition(middle + 1, last, k, dim, ctor);
-    else if (middle > k)
-      median_partition(first, middle, k, dim, ctor);
-  }
-
-  // insert given points into the tree; return created node
-  template < class __instype, class __valuector >
-  int insert(__instype * first, __instype * last, __valuector ctor) {
-    if (first == last)
-      return -1;
-    else {
-
-      int dim = dimension_of_highest_variance(first, last, ctor);
-      __instype *median = median_partition(first, last, dim, ctor);
-
-      __instype *split = median;
-      for (; split != last && deref(ctor(*split), dim) ==
-       deref(ctor(*median), dim); ++split) {}
-
-      if (split == last) { // leaf
-  int nexti = -1;
-  for (--split; split >= first; --split) {
-    int i = (int)nodes.size();
-    node & n = *nodes.insert(nodes.end(), node());
-    n.dim = -1;
-    n.value = ctor(*split);
-    n.left = -1;
-    n.right = nexti;
-    nexti = i;
-  }
-
-  return nexti;
-      } else { // node
-  int i = (int)nodes.size();
-  // note that recursive insert may invalidate this ref
-  node & n = *nodes.insert(nodes.end(), node());
-
-  n.dim = dim;
-  n.boundary = deref(ctor(*median), dim);
-
-  int left = insert(first, split, ctor);
-  nodes[i].left = left;
-  int right = insert(split, last, ctor);
-  nodes[i].right = right;
-
-  return i;
-      }
-    }
-  }
-
-  // run to leaf; linear search for p;
-  // if found, remove paths to empty leaves on unwind
-  bool remove(int *i, const __valuetype & p) {
-    if (*i == -1)
-      return false;
-    node & n = nodes[*i];
-    bool r;
-
-    if (n.dim >= 0) { // node
-      if (deref(p, n.dim) <= n.boundary) // left
-  r = remove(&n.left, p);
-      else // right
-  r = remove(&n.right, p);
-
-      // if terminal, remove this node
-      if (n.left == -1 && n.right == -1)
-  *i = -1;
-
-      return r;
-    } else { // leaf
-      if (n.value == p) {
-  *i = n.right;
-  return true;
-      } else
-  return remove(&n.right, p);
-    }
-  }
-
-public:
-  struct identity_ctor {
-    const __valuetype & operator() (const __valuetype & rhs) const {
-      return rhs;
-    }
-  };
-
-  // initialize an empty tree
-  CvKDTree(__deref _deref = __deref())
-    : deref(_deref), root_node(-1) {
-  }
-  // given points, initialize a balanced tree
-  CvKDTree(__valuetype * first, __valuetype * last, int _point_dim,
-     __deref _deref = __deref())
-    : deref(_deref) {
-    set_data(first, last, _point_dim, identity_ctor());
-  }
-  // given points, initialize a balanced tree
-  template < class __instype, class __valuector >
-  CvKDTree(__instype * first, __instype * last, int _point_dim,
-     __valuector ctor, __deref _deref = __deref())
-    : deref(_deref) {
-    set_data(first, last, _point_dim, ctor);
-  }
-
-  void set_deref(__deref _deref) {
-    deref = _deref;
-  }
-
-  void set_data(__valuetype * first, __valuetype * last, int _point_dim) {
-    set_data(first, last, _point_dim, identity_ctor());
-  }
-  template < class __instype, class __valuector >
-  void set_data(__instype * first, __instype * last, int _point_dim,
-    __valuector ctor) {
-    point_dim = _point_dim;
-    nodes.clear();
-    nodes.reserve(last - first);
-    root_node = insert(first, last, ctor);
-  }
-
-  int dims() const {
-    return point_dim;
-  }
-
-  // remove the given point
-  bool remove(const __valuetype & p) {
-    return remove(&root_node, p);
-  }
-
-  void print() const {
-    print(root_node);
-  }
-  void print(int i, int indent = 0) const {
-    if (i == -1)
-      return;
-    for (int j = 0; j < indent; ++j)
-      std::cout << " ";
-    const node & n = nodes[i];
-    if (n.dim >= 0) {
-      std::cout << "node " << i << ", left " << nodes[i].left << ", right " <<
-  nodes[i].right << ", dim " << nodes[i].dim << ", boundary " <<
-  nodes[i].boundary << std::endl;
-      print(n.left, indent + 3);
-      print(n.right, indent + 3);
-    } else
-      std::cout << "leaf " << i << ", value = " << nodes[i].value << std::endl;
-  }
-
-  ////////////////////////////////////////////////////////////////////////////////////////
-  // bbf search
-public:
-  struct bbf_nn {   // info on found neighbors (approx k nearest)
-    const __valuetype *p; // nearest neighbor
-    accum_type dist;    // distance from d to query point
-    bbf_nn(const __valuetype & _p, accum_type _dist)
-      : p(&_p), dist(_dist) {
-    }
-    bool operator<(const bbf_nn & rhs) const {
-      return dist < rhs.dist;
-    }
-  };
-  typedef std::vector < bbf_nn > bbf_nn_pqueue;
-private:
-  struct bbf_node {   // info on branches not taken
-    int node;     // corresponding node
-    accum_type dist;    // minimum distance from bounds to query point
-    bbf_node(int _node, accum_type _dist)
-      : node(_node), dist(_dist) {
-    }
-    bool operator<(const bbf_node & rhs) const {
-      return dist > rhs.dist;
-    }
-  };
-  typedef std::vector < bbf_node > bbf_pqueue;
-  mutable bbf_pqueue tmp_pq;
-
-  // called for branches not taken, as bbf walks to leaf;
-  // construct bbf_node given minimum distance to bounds of alternate branch
-  void pq_alternate(int alt_n, bbf_pqueue & pq, scalar_type dist) const {
-    if (alt_n == -1)
-      return;
-
-    // add bbf_node for alternate branch in priority queue
-    pq.push_back(bbf_node(alt_n, dist));
-    std::push_heap(pq.begin(), pq.end());
-  }
-
-  // called by bbf to walk to leaf;
-  // takes one step down the tree towards query point d
-  template < class __desctype >
-  int bbf_branch(int i, const __desctype * d, bbf_pqueue & pq) const {
-    const node & n = nodes[i];
-    // push bbf_node with bounds of alternate branch, then branch
-    if (d[n.dim] <= n.boundary) { // left
-      pq_alternate(n.right, pq, n.boundary - d[n.dim]);
-      return n.left;
-    } else {      // right
-      pq_alternate(n.left, pq, d[n.dim] - n.boundary);
-      return n.right;
-    }
-  }
-
-  // compute euclidean distance between two points
-  template < class __desctype >
-  accum_type distance(const __desctype * d, const __valuetype & p) const {
-    accum_type dist = 0;
-    for (int j = 0; j < point_dim; ++j) {
-      accum_type diff = accum_type(d[j]) - accum_type(deref(p, j));
-      dist += diff * diff;
-    } return (accum_type) sqrt(dist);
-  }
-
-  // called per candidate nearest neighbor; constructs new bbf_nn for
-  // candidate and adds it to priority queue of all candidates; if
-  // queue len exceeds k, drops the point furthest from query point d.
-  template < class __desctype >
-  void bbf_new_nn(bbf_nn_pqueue & nn_pq, int k,
-      const __desctype * d, const __valuetype & p) const {
-    bbf_nn nn(p, distance(d, p));
-    if ((int) nn_pq.size() < k) {
-      nn_pq.push_back(nn);
-      std::push_heap(nn_pq.begin(), nn_pq.end());
-    } else if (nn_pq[0].dist > nn.dist) {
-      std::pop_heap(nn_pq.begin(), nn_pq.end());
-      nn_pq.end()[-1] = nn;
-      std::push_heap(nn_pq.begin(), nn_pq.end());
-    }
-    assert(nn_pq.size() < 2 || nn_pq[0].dist >= nn_pq[1].dist);
-  }
-
-public:
-  // finds (with high probability) the k nearest neighbors of d,
-  // searching at most emax leaves/bins.
-  // ret_nn_pq is an array containing the (at most) k nearest neighbors
-  // (see bbf_nn structure def above).
-  template < class __desctype >
-  int find_nn_bbf(const __desctype * d, int k, int emax, bbf_nn_pqueue & ret_nn_pq) const
-  {
-    assert(k > 0);
-    ret_nn_pq.clear();
-
-    if (root_node == -1)
-      return 0;
-
-    // add root_node to bbf_node priority queue;
-    // iterate while queue non-empty and emax>0
-    tmp_pq.clear();
-    tmp_pq.push_back(bbf_node(root_node, 0));
-    while (tmp_pq.size() && emax > 0)
-    {
-
-      // from node nearest query point d, run to leaf
-      std::pop_heap(tmp_pq.begin(), tmp_pq.end());
-      bbf_node bbf(tmp_pq.end()[-1]);
-      tmp_pq.erase(tmp_pq.end() - 1);
-
-      int i;
-      for (i = bbf.node; i != -1 && nodes[i].dim >= 0; i = bbf_branch(i, d, tmp_pq)) {}
-
-      if (i != -1)
-      {
-
-        // add points in leaf/bin to ret_nn_pq
-        do {
-          bbf_new_nn(ret_nn_pq, k, d, nodes[i].value);
-        } while (-1 != (i = nodes[i].right));
-
-        --emax;
-      }
-    }
-
-    tmp_pq.clear();
-    return (int)ret_nn_pq.size();
-  }
-
-  ////////////////////////////////////////////////////////////////////////////////////////
-  // orthogonal range search
-private:
-  void find_ortho_range(int i, scalar_type * bounds_min,
-      scalar_type * bounds_max,
-      std::vector < __valuetype > &inbounds) const {
-    if (i == -1)
-      return;
-    const node & n = nodes[i];
-    if (n.dim >= 0) { // node
-      if (bounds_min[n.dim] <= n.boundary)
-  find_ortho_range(n.left, bounds_min, bounds_max, inbounds);
-      if (bounds_max[n.dim] > n.boundary)
-  find_ortho_range(n.right, bounds_min, bounds_max, inbounds);
-    } else { // leaf
-      do {
-  inbounds.push_back(nodes[i].value);
-      } while (-1 != (i = nodes[i].right));
-    }
-  }
-public:
-  // return all points that lie within the given bounds; inbounds is cleared
-  int find_ortho_range(scalar_type * bounds_min,
-           scalar_type * bounds_max,
-           std::vector < __valuetype > &inbounds) const {
-    inbounds.clear();
-    find_ortho_range(root_node, bounds_min, bounds_max, inbounds);
-    return (int)inbounds.size();
-  }
-};
-
-#endif // __cv_kdtree_h__
-
-// Local Variables:
-// mode:C++
-// End:
diff --git a/modules/legacy/src/_matrix.h b/modules/legacy/src/_matrix.h
deleted file mode 100644 (file)
index b992dc3..0000000
+++ /dev/null
@@ -1,405 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef _CV_MATRIX_H_
-#define _CV_MATRIX_H_
-
-#define icvCopyVector( src, dst, len ) memcpy( (dst), (src), (len)*sizeof((dst)[0]))
-#define icvSetZero( dst, len ) memset( (dst), 0, (len)*sizeof((dst)[0]))
-
-#define icvCopyVector_32f( src, len, dst ) memcpy((dst),(src),(len)*sizeof(float))
-#define icvSetZero_32f( dst, cols, rows ) memset((dst),0,(rows)*(cols)*sizeof(float))
-#define icvCopyVector_64d( src, len, dst ) memcpy((dst),(src),(len)*sizeof(double))
-#define icvSetZero_64d( dst, cols, rows ) memset((dst),0,(rows)*(cols)*sizeof(double))
-#define icvCopyMatrix_32f( src, w, h, dst ) memcpy((dst),(src),(w)*(h)*sizeof(float))
-#define icvCopyMatrix_64d( src, w, h, dst ) memcpy((dst),(src),(w)*(h)*sizeof(double))
-
-#define icvCreateVector_32f( len )  (float*)cvAlloc( (len)*sizeof(float))
-#define icvCreateVector_64d( len )  (double*)cvAlloc( (len)*sizeof(double))
-#define icvCreateMatrix_32f( w, h )  (float*)cvAlloc( (w)*(h)*sizeof(float))
-#define icvCreateMatrix_64d( w, h )  (double*)cvAlloc( (w)*(h)*sizeof(double))
-
-#define icvDeleteVector( vec )  cvFree( &(vec) )
-#define icvDeleteMatrix icvDeleteVector
-
-#define icvAddMatrix_32f( src1, src2, dst, w, h ) \
-    icvAddVector_32f( (src1), (src2), (dst), (w)*(h))
-
-#define icvSubMatrix_32f( src1, src2, dst, w, h ) \
-    icvSubVector_32f( (src1), (src2), (dst), (w)*(h))
-
-#define icvNormVector_32f( src, len )  \
-    sqrt(icvDotProduct_32f( src, src, len ))
-
-#define icvNormVector_64d( src, len )  \
-    sqrt(icvDotProduct_64d( src, src, len ))
-
-
-#define icvDeleteMatrix icvDeleteVector
-
-#define icvCheckVector_64f( ptr, len )
-#define icvCheckVector_32f( ptr, len )
-
-CV_INLINE double icvSum_32f( const float* src, int len )
-{
-    double s = 0;
-    for( int i = 0; i < len; i++ ) s += src[i];
-
-    icvCheckVector_64f( &s, 1 );
-
-    return s;
-}
-
-CV_INLINE double icvDotProduct_32f( const float* src1, const float* src2, int len )
-{
-    double s = 0;
-    for( int i = 0; i < len; i++ ) s += src1[i]*src2[i];
-
-    icvCheckVector_64f( &s, 1 );
-
-    return s;
-}
-
-
-CV_INLINE double icvDotProduct_64f( const double* src1, const double* src2, int len )
-{
-    double s = 0;
-    for( int i = 0; i < len; i++ ) s += src1[i]*src2[i];
-
-    icvCheckVector_64f( &s, 1 );
-
-    return s;
-}
-
-
-CV_INLINE void icvMulVectors_32f( const float* src1, const float* src2,
-                                  float* dst, int len )
-{
-    int i;
-    for( i = 0; i < len; i++ )
-        dst[i] = src1[i] * src2[i];
-
-    icvCheckVector_32f( dst, len );
-}
-
-CV_INLINE void icvMulVectors_64d( const double* src1, const double* src2,
-                                  double* dst, int len )
-{
-    int i;
-    for( i = 0; i < len; i++ )
-        dst[i] = src1[i] * src2[i];
-
-    icvCheckVector_64f( dst, len );
-}
-
-
-CV_INLINE void icvAddVector_32f( const float* src1, const float* src2,
-                                  float* dst, int len )
-{
-    int i;
-    for( i = 0; i < len; i++ )
-        dst[i] = src1[i] + src2[i];
-
-    icvCheckVector_32f( dst, len );
-}
-
-CV_INLINE void icvAddVector_64d( const double* src1, const double* src2,
-                                  double* dst, int len )
-{
-    int i;
-    for( i = 0; i < len; i++ )
-        dst[i] = src1[i] + src2[i];
-
-    icvCheckVector_64f( dst, len );
-}
-
-
-CV_INLINE void icvSubVector_32f( const float* src1, const float* src2,
-                                  float* dst, int len )
-{
-    int i;
-    for( i = 0; i < len; i++ )
-        dst[i] = src1[i] - src2[i];
-
-    icvCheckVector_32f( dst, len );
-}
-
-CV_INLINE void icvSubVector_64d( const double* src1, const double* src2,
-                                  double* dst, int len )
-{
-    int i;
-    for( i = 0; i < len; i++ )
-        dst[i] = src1[i] - src2[i];
-
-    icvCheckVector_64f( dst, len );
-}
-
-
-#define icvAddMatrix_64d( src1, src2, dst, w, h ) \
-    icvAddVector_64d( (src1), (src2), (dst), (w)*(h))
-
-#define icvSubMatrix_64d( src1, src2, dst, w, h ) \
-    icvSubVector_64d( (src1), (src2), (dst), (w)*(h))
-
-
-CV_INLINE void icvSetIdentity_32f( float* dst, int w, int h )
-{
-    int i, len = MIN( w, h );
-    icvSetZero_32f( dst, w, h );
-    for( i = 0; len--; i += w+1 )
-        dst[i] = 1.f;
-}
-
-
-CV_INLINE void icvSetIdentity_64d( double* dst, int w, int h )
-{
-    int i, len = MIN( w, h );
-    icvSetZero_64d( dst, w, h );
-    for( i = 0; len--; i += w+1 )
-        dst[i] = 1.;
-}
-
-
-CV_INLINE void icvTrace_32f( const float* src, int w, int h, float* trace )
-{
-    int i, len = MIN( w, h );
-    double sum = 0;
-    for( i = 0; len--; i += w+1 )
-        sum += src[i];
-    *trace = (float)sum;
-
-    icvCheckVector_64f( &sum, 1 );
-}
-
-
-CV_INLINE void icvTrace_64d( const double* src, int w, int h, double* trace )
-{
-    int i, len = MIN( w, h );
-    double sum = 0;
-    for( i = 0; len--; i += w+1 )
-        sum += src[i];
-    *trace = sum;
-
-    icvCheckVector_64f( &sum, 1 );
-}
-
-
-CV_INLINE void icvScaleVector_32f( const float* src, float* dst,
-                                   int len, double scale )
-{
-    int i;
-    for( i = 0; i < len; i++ )
-        dst[i] = (float)(src[i]*scale);
-
-    icvCheckVector_32f( dst, len );
-}
-
-
-CV_INLINE void icvScaleVector_64d( const double* src, double* dst,
-                                   int len, double scale )
-{
-    int i;
-    for( i = 0; i < len; i++ )
-        dst[i] = src[i]*scale;
-
-    icvCheckVector_64f( dst, len );
-}
-
-
-CV_INLINE void icvTransposeMatrix_32f( const float* src, int w, int h, float* dst )
-{
-    int i, j;
-
-    for( i = 0; i < w; i++ )
-        for( j = 0; j < h; j++ )
-            *dst++ = src[j*w + i];
-
-    icvCheckVector_32f( dst, w*h );
-}
-
-CV_INLINE void icvTransposeMatrix_64d( const double* src, int w, int h, double* dst )
-{
-    int i, j;
-
-    for( i = 0; i < w; i++ )
-        for( j = 0; j < h; j++ )
-            *dst++ = src[j*w + i];
-
-    icvCheckVector_64f( dst, w*h );
-}
-
-CV_INLINE void icvDetMatrix3x3_64d( const double* mat, double* det )
-{
-    #define m(y,x) mat[(y)*3 + (x)]
-
-    *det = m(0,0)*(m(1,1)*m(2,2) - m(1,2)*m(2,1)) -
-           m(0,1)*(m(1,0)*m(2,2) - m(1,2)*m(2,0)) +
-           m(0,2)*(m(1,0)*m(2,1) - m(1,1)*m(2,0));
-
-    #undef m
-
-    icvCheckVector_64f( det, 1 );
-}
-
-
-CV_INLINE void icvMulMatrix_32f( const float* src1, int w1, int h1,
-                                 const float* src2, int w2, int h2,
-                                 float* dst )
-{
-    int i, j, k;
-
-    if( w1 != h2 )
-    {
-        assert(0);
-        return;
-    }
-
-    for( i = 0; i < h1; i++, src1 += w1, dst += w2 )
-        for( j = 0; j < w2; j++ )
-        {
-            double s = 0;
-            for( k = 0; k < w1; k++ )
-                s += src1[k]*src2[j + k*w2];
-            dst[j] = (float)s;
-        }
-
-    icvCheckVector_32f( dst, h1*w2 );
-}
-
-
-CV_INLINE void icvMulMatrix_64d( const double* src1, int w1, int h1,
-                                 const double* src2, int w2, int h2,
-                                 double* dst )
-{
-    int i, j, k;
-
-    if( w1 != h2 )
-    {
-        assert(0);
-        return;
-    }
-
-    for( i = 0; i < h1; i++, src1 += w1, dst += w2 )
-        for( j = 0; j < w2; j++ )
-        {
-            double s = 0;
-            for( k = 0; k < w1; k++ )
-                s += src1[k]*src2[j + k*w2];
-            dst[j] = s;
-        }
-
-    icvCheckVector_64f( dst, h1*w2 );
-}
-
-
-#define icvTransformVector_32f( matr, src, dst, w, h ) \
-    icvMulMatrix_32f( matr, w, h, src, 1, w, dst )
-
-#define icvTransformVector_64d( matr, src, dst, w, h ) \
-    icvMulMatrix_64d( matr, w, h, src, 1, w, dst )
-
-
-#define icvScaleMatrix_32f( src, dst, w, h, scale ) \
-    icvScaleVector_32f( (src), (dst), (w)*(h), (scale) )
-
-#define icvScaleMatrix_64d( src, dst, w, h, scale ) \
-    icvScaleVector_64d( (src), (dst), (w)*(h), (scale) )
-
-#define icvDotProduct_64d icvDotProduct_64f
-
-
-CV_INLINE void icvInvertMatrix_64d( double* A, int n, double* invA )
-{
-    CvMat Am = cvMat( n, n, CV_64F, A );
-    CvMat invAm = cvMat( n, n, CV_64F, invA );
-
-    cvInvert( &Am, &invAm, CV_SVD );
-}
-
-CV_INLINE void icvMulTransMatrixR_64d( double* src, int width, int height, double* dst )
-{
-    CvMat srcMat = cvMat( height, width, CV_64F, src );
-    CvMat dstMat = cvMat( width, width, CV_64F, dst );
-
-    cvMulTransposed( &srcMat, &dstMat, 1 );
-}
-
-CV_INLINE void icvMulTransMatrixL_64d( double* src, int width, int height, double* dst )
-{
-    CvMat srcMat = cvMat( height, width, CV_64F, src );
-    CvMat dstMat = cvMat( height, height, CV_64F, dst );
-
-    cvMulTransposed( &srcMat, &dstMat, 0 );
-}
-
-CV_INLINE void icvMulTransMatrixR_32f( float* src, int width, int height, float* dst )
-{
-    CvMat srcMat = cvMat( height, width, CV_32F, src );
-    CvMat dstMat = cvMat( width, width, CV_32F, dst );
-
-    cvMulTransposed( &srcMat, &dstMat, 1 );
-}
-
-CV_INLINE void icvMulTransMatrixL_32f( float* src, int width, int height, float* dst )
-{
-    CvMat srcMat = cvMat( height, width, CV_32F, src );
-    CvMat dstMat = cvMat( height, height, CV_32F, dst );
-
-    cvMulTransposed( &srcMat, &dstMat, 0 );
-}
-
-CV_INLINE void icvCvt_32f_64d( const float* src, double* dst, int len )
-{
-    int i;
-    for( i = 0; i < len; i++ )
-        dst[i] = src[i];
-}
-
-CV_INLINE void icvCvt_64d_32f( const double* src, float* dst, int len )
-{
-    int i;
-    for( i = 0; i < len; i++ )
-        dst[i] = (float)src[i];
-}
-
-#endif/*_CV_MATRIX_H_*/
-
-/* End of file. */
diff --git a/modules/legacy/src/_vectrack.h b/modules/legacy/src/_vectrack.h
deleted file mode 100644 (file)
index 9c90cc7..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-
-#ifndef __CVVECTRACK_H__
-#define __CVVECTRACK_H__
-
-#include <string.h>
-#include <math.h>
-#include <time.h>
-#include <stdio.h>
-
-#undef max
-#undef min
-
-#define max(a,b) ((a)<(b) ? (b) : (a))
-#define min(a,b) ((a)>(b) ? (a) : (b))
-
-inline int pow2(int v)
-{
-        return (v*v);
-}
-
-inline int operator == (const CvRect& r1, const CvRect& r2)
-{
-        return (r1.x == r2.x) && (r1.y == r2.y) &&
-                        (r1.width == r2.width) && (r1.height == r2.height);
-}
-
-inline int operator != (const CvRect& r1, const CvRect& r2)
-{
-        return !(r1 == r2);
-}
-
-inline
-int CmpPoints(const CvPoint& p1, const CvPoint& p2, int err)
-{
-        /* Simakov: modify __max to max */
-        return (max(abs(p1.x - p2.x), abs(p1.y - p2.y)) < err);
-}
-
-inline
-int PointInRect(const CvPoint& p, const CvRect& r)
-{
-        return ((p.x > r.x) && (p.x < (r.x + r.width)) &&
-                        (p.y > r.y) && (p.y < (r.y + r.height)));
-}
-
-inline
-int RectInRect(const CvRect& r1, const CvRect& r2)
-{
-        CvPoint plt(r1.x, r1.y);
-        CvPoint prb(r1.x + r1.width, r1.y + r1.height);
-        return (PointInRect(plt, r2) && PointInRect(prb, r2));
-}
-
-inline
-CvRect Increase(const CvRect& r, int decr)
-{
-        CvRect rect;
-        rect.x = r.x * decr;
-        rect.y = r.y * decr;
-        rect.width = r.width * decr;
-        rect.height = r.height * decr;
-        return rect;
-}
-
-inline
-CvPoint Increase(const CvPoint& p, int decr)
-{
-        CvPoint point;
-        point.x = p.x * decr;
-        point.y = p.y * decr;
-        return point;
-}
-
-inline
-void Move(CvRect& r, int dx, int dy)
-{
-        r.x += dx;
-        r.y += dy;
-}
-
-inline
-void Move(CvPoint& p, int dx, int dy)
-{
-        p.x += dx;
-        p.y += dy;
-}
-
-inline
-void Extend(CvRect& r, int d)
-{
-        r.x -= d;
-        r.y -= d;
-        r.width += 2*d;
-        r.height += 2*d;
-}
-
-inline
-CvPoint Center(const CvRect& r)
-{
-        CvPoint p;
-        p.x = r.x + r.width / 2;
-        p.y = r.y + r.height / 2;
-        return p;
-}
-
-inline void ReallocImage(IplImage** ppImage, CvSize sz, long lChNum)
-{
-    IplImage* pImage;
-    if( ppImage == NULL )
-                return;
-    pImage = *ppImage;
-    if( pImage != NULL )
-    {
-        if (pImage->width != sz.width || pImage->height != sz.height || pImage->nChannels != lChNum)
-            cvReleaseImage( &pImage );
-    }
-    if( pImage == NULL )
-        pImage = cvCreateImage( sz, IPL_DEPTH_8U, lChNum);
-    *ppImage = pImage;
-}
-
-#endif //__VECTRACK_H__
diff --git a/modules/legacy/src/_vm.h b/modules/legacy/src/_vm.h
deleted file mode 100644 (file)
index 7964cd3..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef _CV_VM_H_
-#define _CV_VM_H_
-
-/*----------------------- Internal ViewMorphing Functions ------------------------------*/
-
-/*======================================================================================*/
-
-typedef struct CvMatrix4
-{
-    float m[4][4];
-}
-CvMatrix4;
-
-
-/* Scanline section. Find coordinates by fundamental matrix */
-
-/* Epsilon and real zero */
-#define EPSILON             1.e-4
-//#define REAL_ZERO(x)        ( (x) < EPSILON && (x) > -EPSILON)
-#define REAL_ZERO(x) ( (x) < 1e-8 && (x) > -1e-8)
-
-#define SIGN(x)                                ( (x)<0 ? -1:((x)>0?1:0 ) )
-
-CvStatus  icvMakeScanlinesLengths( int*        scanlines,
-                                    int         numlines,
-                                    int*        lens);
-
-/*=============================== PreWarp section ======================================*/
-
-CvStatus  icvFindRunsInOneImage(
-                                int     numLines,       /* number of scanlines         */
-                                uchar*  prewarp,        /* prewarp image                       */
-                                int*    line_lens,      /* line lengths in pixels      */
-                                int*    runs,           /* result runs                         */
-                                int*    num_runs);
-
-/*================================ Morphing section ====================================*/
-
-CvStatus  icvMorphEpilines8uC3(    uchar*  first_pix, /* raster epiline from the first image       */
-                                    uchar*  second_pix, /* raster epiline from the second image      */
-                                    uchar*  dst_pix,    /* raster epiline from the destination image */
-                                                        /* (it's an output parameter)                */
-                                    float   alpha,      /* relative position of camera               */
-                                    int*    first,      /* first sequence of runs                    */
-                                    int     first_runs, /* it's length                               */
-                                    int*    second,     /* second sequence of runs                   */
-                                    int     second_runs,
-                                    int*    first_corr, /* correspond information for the 1st seq    */
-                                    int*    second_corr,
-                                    int     dst_len);   /* correspond information for the 2nd seq    */
-
-/*========================== Dynamic correspond section ================================*/
-
-CvStatus  icvDynamicCorrespond(   int*  first,         /* first sequence of runs           */
-                                                         /* s0|w0|s1|w1|...|s(n-1)|w(n-1)|sn */
-                                    int   first_runs,    /* number of runs                   */
-                                    int*  second,        /* second sequence of runs          */
-                                    int   second_runs,
-                                    int*  first_corr,    /* s0'|e0'|s1'|e1'|...              */
-                                    int*  second_corr );
-
-/*============================= PostWarp Functions =====================================*/
-
-CvStatus  icvFetchLine8uC3R(
-                                uchar*   src,  int   src_step,
-                                uchar*   dst,  int*  dst_num,
-                                CvSize  src_size,
-                                CvPoint start,
-                                CvPoint end );
-
-CvStatus  icvDrawLine8uC3R(
-                                uchar*   src,  int  src_num,
-                                uchar*   dst,  int  dst_step,
-                                CvSize  dst_size,
-                                CvPoint start,
-                                CvPoint end );
-
-
-/*============================== Fundamental Matrix Functions ==========================*/
-CvStatus  icvPoint7(  int*        points1,
-                        int*        points2,
-                        double*     F,
-                        int*        amount
-                        );
-
-CvStatus  icvCubic(      double a2, double a1,
-                            double a0, double* squares );
-
-double icvDet( double* M );
-double   icvMinor( double* M, int x, int y );
-
-int
-icvGaussMxN( double *A, double *B, int M, int N, double **solutions );
-
-CvStatus
-icvGetCoef( double *f1, double *f2, double *a2, double *a1, double *a0 );
-
-/*================================= Scanlines Functions ================================*/
-
-CvStatus  icvGetCoefficient(  CvMatrix3*     matrix,
-                                CvSize         imgSize,
-                                int*            scanlines_1,
-                                int*            scanlines_2,
-                                int*            numlines);
-
-CvStatus  icvGetCoefficientDefault(   CvMatrix3*     matrix,
-                                        CvSize         imgSize,
-                                        int*            scanlines_1,
-                                        int*            scanlines_2,
-                                        int*            numlines);
-
-CvStatus  icvGetCoefficientStereo(    CvMatrix3*     matrix,
-                                        CvSize         imgSize,
-                                        float*          l_epipole,
-                                        float*          r_epipole,
-                                        int*            scanlines_1,
-                                        int*            scanlines_2,
-                                        int*            numlines
-                                    );
-
-CvStatus  icvGetCoefficientOrto(  CvMatrix3*     matrix,
-                                    CvSize         imgSize,
-                                    int*            scanlines_1,
-                                    int*            scanlines_2,
-                                    int*            numlines);
-
-
-CvStatus  icvGetCrossEpilineFrame(    CvSize     imgSize,
-                                        float*      epiline,
-                                        int*        x1,
-                                        int*        y1,
-                                        int*        x2,
-                                        int*        y2
-                                    );
-
-CvStatus  icvBuildScanlineLeftStereo(
-                                        CvSize         imgSize,
-                                        CvMatrix3*     matrix,
-                                        float*          l_epipole,
-                                        float*          l_angle,
-                                        float           l_radius,
-                                        int*            scanlines_1,
-                                        int*            scanlines_2,
-                                        int*            numlines);
-
-CvStatus  icvBuildScanlineRightStereo(
-                                        CvSize         imgSize,
-                                        CvMatrix3*     matrix,
-                                        float*          r_epipole,
-                                        float*          r_angle,
-                                        float           r_radius,
-                                        int*            scanlines_1,
-                                        int*            scanlines_2,
-                                        int*            numlines);
-
-CvStatus  icvGetStartEnd1(
-                                    CvMatrix3*     matrix,
-                                    CvSize         imgSize,
-                                    float*          l_start_end,
-                                    float*          r_start_end );
-
-CvStatus  icvGetStartEnd2(
-                                    CvMatrix3*     matrix,
-                                    CvSize         imgSize,
-                                    float*          l_start_end,
-                                    float*          r_start_end );
-
-CvStatus  icvGetStartEnd3(
-                                    CvMatrix3*     matrix,
-                                    CvSize         imgSize,
-                                    float*          l_start_end,
-                                    float*          r_start_end );
-
-CvStatus  icvGetStartEnd4(
-                                    CvMatrix3*     matrix,
-                                    CvSize         imgSize,
-                                    float*          l_start_end,
-                                    float*          r_start_end );
-
-CvStatus  icvBuildScanlineLeft(
-                                    CvMatrix3*     matrix,
-                                    CvSize         imgSize,
-                                    int*            scanlines_1,
-                                    int*            scanlines_2,
-                                    float*          l_start_end,
-                                    int*            numlines
-                                    );
-
-CvStatus  icvBuildScanlineRight(
-                                    CvMatrix3*     matrix,
-                                    CvSize         imgSize,
-                                    int*            scanlines_1,
-                                    int*            scanlines_2,
-                                    float*          r_start_end,
-                                    int*            numlines
-                                    );
-
-
-/*=================================== LMedS Functions ==================================*/
-CvStatus  icvLMedS7(
-                        int*            points1,
-                        int*            points2,
-                        CvMatrix3*     matrix);
-
-
-CvStatus  icvLMedS(   int*    points1,
-                        int*    points2,
-                        int     numPoints,
-                        CvMatrix3* fundamentalMatrix );
-
-
-/*
-CvStatus  icvFindFundamentalMatrix(
-                                    int*            points1,
-                                    int*            points2,
-                                    int             numpoints,
-                                    int             method,
-                                    CvMatrix3*      matrix);
-*/
-void   icvChoose7(     int*    ml,     int* mr,
-                        int     num,   int* ml7,
-                        int*   mr7 );
-
-double icvMedian(      int* ml, int* mr,
-                    int num, double* F );
-
-int icvBoltingPoints( int* ml,     int* mr,
-                        int num,        double* F,
-                        double Mj,      int* *new_ml,
-                        int* *new_mr,   int* new_num);
-
-CvStatus  icvPoints8( int* ml, int* mr,
-                        int num, double* F );
-
-CvStatus  icvRank2Constraint( double* F );
-
-CvStatus  icvSort( double* array, int length );
-
-double icvAnalyticPoints8(     double* A,
-                                            int num, double* F );
-
-int icvSingularValueDecomposition(     int             M,
-                                        int            N,
-                                        double*        A,
-                                        double*        W,
-                                        int            get_U,
-                                        double*        U,
-                                        int            get_V,
-                                        double*        V
-                                                 );
-
-
-/*======================================================================================*/
-#endif/*_CV_VM_H_*/
diff --git a/modules/legacy/src/auxutils.cpp b/modules/legacy/src/auxutils.cpp
deleted file mode 100644 (file)
index 3e0ec42..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-/* End of file. */
diff --git a/modules/legacy/src/bgfg_acmmm2003.cpp b/modules/legacy/src/bgfg_acmmm2003.cpp
deleted file mode 100644 (file)
index bf4b451..0000000
+++ /dev/null
@@ -1,741 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-
-// This file implements the foreground/background pixel
-// discrimination algorithm described in
-//
-//     Foreground Object Detection from Videos Containing Complex Background
-//     Li, Huan, Gu, Tian 2003 9p
-//     http://muq.org/~cynbe/bib/foreground-object-detection-from-videos-containing-complex-background.pdf
-
-
-#include "precomp.hpp"
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-//#include <algorithm>
-
-static double* _cv_max_element( double* start, double* end )
-{
-    double* p = start++;
-
-    for( ; start != end;  ++start) {
-
-        if (*p < *start)   p = start;
-    }
-
-    return p;
-}
-
-static void CV_CDECL icvReleaseFGDStatModel( CvFGDStatModel** model );
-static int CV_CDECL icvUpdateFGDStatModel( IplImage* curr_frame,
-                                           CvFGDStatModel*  model,
-                                           double );
-
-// Function cvCreateFGDStatModel initializes foreground detection process
-// parameters:
-//      first_frame - frame from video sequence
-//      parameters  - (optional) if NULL default parameters of the algorithm will be used
-//      p_model     - pointer to CvFGDStatModel structure
-CV_IMPL CvBGStatModel*
-cvCreateFGDStatModel( IplImage* first_frame, CvFGDStatModelParams* parameters )
-{
-    CvFGDStatModel* p_model = 0;
-
-    CV_FUNCNAME( "cvCreateFGDStatModel" );
-
-    __BEGIN__;
-
-    int i, j, k, pixel_count, buf_size;
-    CvFGDStatModelParams params;
-
-    if( !CV_IS_IMAGE(first_frame) )
-        CV_ERROR( CV_StsBadArg, "Invalid or NULL first_frame parameter" );
-
-    if (first_frame->nChannels != 3)
-        CV_ERROR( CV_StsBadArg, "first_frame must have 3 color channels" );
-
-    // Initialize parameters:
-    if( parameters == NULL )
-    {
-        params.Lc      = CV_BGFG_FGD_LC;
-        params.N1c     = CV_BGFG_FGD_N1C;
-        params.N2c     = CV_BGFG_FGD_N2C;
-
-        params.Lcc     = CV_BGFG_FGD_LCC;
-        params.N1cc    = CV_BGFG_FGD_N1CC;
-        params.N2cc    = CV_BGFG_FGD_N2CC;
-
-        params.delta   = CV_BGFG_FGD_DELTA;
-
-        params.alpha1  = CV_BGFG_FGD_ALPHA_1;
-        params.alpha2  = CV_BGFG_FGD_ALPHA_2;
-        params.alpha3  = CV_BGFG_FGD_ALPHA_3;
-
-        params.T       = CV_BGFG_FGD_T;
-        params.minArea = CV_BGFG_FGD_MINAREA;
-
-        params.is_obj_without_holes = 1;
-        params.perform_morphing     = 1;
-    }
-    else
-    {
-        params = *parameters;
-    }
-
-    CV_CALL( p_model = (CvFGDStatModel*)cvAlloc( sizeof(*p_model) ));
-    memset( p_model, 0, sizeof(*p_model) );
-    p_model->type = CV_BG_MODEL_FGD;
-    p_model->release = (CvReleaseBGStatModel)icvReleaseFGDStatModel;
-    p_model->update = (CvUpdateBGStatModel)icvUpdateFGDStatModel;;
-    p_model->params = params;
-
-    // Initialize storage pools:
-    pixel_count = first_frame->width * first_frame->height;
-
-    buf_size = pixel_count*sizeof(p_model->pixel_stat[0]);
-    CV_CALL( p_model->pixel_stat = (CvBGPixelStat*)cvAlloc(buf_size) );
-    memset( p_model->pixel_stat, 0, buf_size );
-
-    buf_size = pixel_count*params.N2c*sizeof(p_model->pixel_stat[0].ctable[0]);
-    CV_CALL( p_model->pixel_stat[0].ctable = (CvBGPixelCStatTable*)cvAlloc(buf_size) );
-    memset( p_model->pixel_stat[0].ctable, 0, buf_size );
-
-    buf_size = pixel_count*params.N2cc*sizeof(p_model->pixel_stat[0].cctable[0]);
-    CV_CALL( p_model->pixel_stat[0].cctable = (CvBGPixelCCStatTable*)cvAlloc(buf_size) );
-    memset( p_model->pixel_stat[0].cctable, 0, buf_size );
-
-    for(     i = 0, k = 0; i < first_frame->height; i++ ) {
-        for( j = 0;        j < first_frame->width;  j++, k++ )
-        {
-            p_model->pixel_stat[k].ctable = p_model->pixel_stat[0].ctable + k*params.N2c;
-            p_model->pixel_stat[k].cctable = p_model->pixel_stat[0].cctable + k*params.N2cc;
-        }
-    }
-
-    // Init temporary images:
-    CV_CALL( p_model->Ftd = cvCreateImage(cvSize(first_frame->width, first_frame->height), IPL_DEPTH_8U, 1));
-    CV_CALL( p_model->Fbd = cvCreateImage(cvSize(first_frame->width, first_frame->height), IPL_DEPTH_8U, 1));
-    CV_CALL( p_model->foreground = cvCreateImage(cvSize(first_frame->width, first_frame->height), IPL_DEPTH_8U, 1));
-
-    CV_CALL( p_model->background = cvCloneImage(first_frame));
-    CV_CALL( p_model->prev_frame = cvCloneImage(first_frame));
-    CV_CALL( p_model->storage = cvCreateMemStorage());
-
-    __END__;
-
-    if( cvGetErrStatus() < 0 )
-    {
-        CvBGStatModel* base_ptr = (CvBGStatModel*)p_model;
-
-        if( p_model && p_model->release )
-            p_model->release( &base_ptr );
-        else
-            cvFree( &p_model );
-        p_model = 0;
-    }
-
-    return (CvBGStatModel*)p_model;
-}
-
-
-static void CV_CDECL
-icvReleaseFGDStatModel( CvFGDStatModel** _model )
-{
-    CV_FUNCNAME( "icvReleaseFGDStatModel" );
-
-    __BEGIN__;
-
-    if( !_model )
-        CV_ERROR( CV_StsNullPtr, "" );
-
-    if( *_model )
-    {
-        CvFGDStatModel* model = *_model;
-        if( model->pixel_stat )
-        {
-            cvFree( &model->pixel_stat[0].ctable );
-            cvFree( &model->pixel_stat[0].cctable );
-            cvFree( &model->pixel_stat );
-        }
-
-        cvReleaseImage( &model->Ftd );
-        cvReleaseImage( &model->Fbd );
-        cvReleaseImage( &model->foreground );
-        cvReleaseImage( &model->background );
-        cvReleaseImage( &model->prev_frame );
-        cvReleaseMemStorage(&model->storage);
-
-        cvFree( _model );
-    }
-
-    __END__;
-}
-
-//  Function cvChangeDetection performs change detection for Foreground detection algorithm
-// parameters:
-//      prev_frame -
-//      curr_frame -
-//      change_mask -
-CV_IMPL int
-cvChangeDetection( IplImage*  prev_frame,
-                   IplImage*  curr_frame,
-                   IplImage*  change_mask )
-{
-    int i, j, b, x, y, thres;
-    const int PIXELRANGE=256;
-
-    if( !prev_frame
-    ||  !curr_frame
-    ||  !change_mask
-    ||   prev_frame->nChannels  != 3
-    ||   curr_frame->nChannels  != 3
-    ||   change_mask->nChannels != 1
-    ||   prev_frame->depth  != IPL_DEPTH_8U
-    ||   curr_frame->depth  != IPL_DEPTH_8U
-    ||   change_mask->depth != IPL_DEPTH_8U
-    ||   prev_frame->width  != curr_frame->width
-    ||   prev_frame->height != curr_frame->height
-    ||   prev_frame->width  != change_mask->width
-    ||   prev_frame->height != change_mask->height
-    ){
-        return 0;
-    }
-
-    cvZero ( change_mask );
-
-    // All operations per colour
-    for (b=0 ; b<prev_frame->nChannels ; b++) {
-
-        // Create histogram:
-
-        long HISTOGRAM[PIXELRANGE];
-        for (i=0 ; i<PIXELRANGE; i++) HISTOGRAM[i]=0;
-
-        for (y=0 ; y<curr_frame->height ; y++)
-        {
-            uchar* rowStart1 = (uchar*)curr_frame->imageData + y * curr_frame->widthStep + b;
-            uchar* rowStart2 = (uchar*)prev_frame->imageData + y * prev_frame->widthStep + b;
-            for (x=0 ; x<curr_frame->width ; x++, rowStart1+=curr_frame->nChannels, rowStart2+=prev_frame->nChannels) {
-                int diff = abs( int(*rowStart1) - int(*rowStart2) );
-                HISTOGRAM[diff]++;
-            }
-        }
-
-        double relativeVariance[PIXELRANGE];
-        for (i=0 ; i<PIXELRANGE; i++) relativeVariance[i]=0;
-
-        for (thres=PIXELRANGE-2; thres>=0 ; thres--)
-        {
-            //            fprintf(stderr, "Iter %d\n", thres);
-            double sum=0;
-            double sqsum=0;
-            int count=0;
-            //            fprintf(stderr, "Iter %d entering loop\n", thres);
-            for (j=thres ; j<PIXELRANGE ; j++) {
-                sum   += double(j)*double(HISTOGRAM[j]);
-                sqsum += double(j*j)*double(HISTOGRAM[j]);
-                count += HISTOGRAM[j];
-            }
-            count = count == 0 ? 1 : count;
-            //            fprintf(stderr, "Iter %d finishing loop\n", thres);
-            double my = sum / count;
-            double sigma = sqrt( sqsum/count - my*my);
-            //            fprintf(stderr, "Iter %d sum=%g sqsum=%g count=%d sigma = %g\n", thres, sum, sqsum, count, sigma);
-            //            fprintf(stderr, "Writing to %x\n", &(relativeVariance[thres]));
-            relativeVariance[thres] = sigma;
-            //            fprintf(stderr, "Iter %d finished\n", thres);
-        }
-
-        // Find maximum:
-        uchar bestThres = 0;
-
-        double* pBestThres = _cv_max_element(relativeVariance, relativeVariance+PIXELRANGE);
-        bestThres = (uchar)(*pBestThres); if (bestThres <10) bestThres=10;
-
-        for (y=0 ; y<prev_frame->height ; y++)
-        {
-            uchar* rowStart1 = (uchar*)(curr_frame->imageData) + y * curr_frame->widthStep + b;
-            uchar* rowStart2 = (uchar*)(prev_frame->imageData) + y * prev_frame->widthStep + b;
-            uchar* rowStart3 = (uchar*)(change_mask->imageData) + y * change_mask->widthStep;
-            for (x = 0; x < curr_frame->width; x++, rowStart1+=curr_frame->nChannels,
-                rowStart2+=prev_frame->nChannels, rowStart3+=change_mask->nChannels) {
-                // OR between different color channels
-                int diff = abs( int(*rowStart1) - int(*rowStart2) );
-                if ( diff > bestThres)
-                    *rowStart3 |=255;
-            }
-        }
-    }
-
-    return 1;
-}
-
-
-#define MIN_PV 1E-10
-
-
-#define V_C(k,l) ctable[k].v[l]
-#define PV_C(k) ctable[k].Pv
-#define PVB_C(k) ctable[k].Pvb
-#define V_CC(k,l) cctable[k].v[l]
-#define PV_CC(k) cctable[k].Pv
-#define PVB_CC(k) cctable[k].Pvb
-
-
-// Function cvUpdateFGDStatModel updates statistical model and returns number of foreground regions
-// parameters:
-//      curr_frame  - current frame from video sequence
-//      p_model     - pointer to CvFGDStatModel structure
-static int CV_CDECL
-icvUpdateFGDStatModel( IplImage* curr_frame, CvFGDStatModel*  model, double )
-{
-    int            mask_step = model->Ftd->widthStep;
-    CvSeq         *first_seq = NULL, *prev_seq = NULL, *seq = NULL;
-    IplImage*      prev_frame = model->prev_frame;
-    int            region_count = 0;
-    int            FG_pixels_count = 0;
-    int            deltaC  = cvRound(model->params.delta * 256 / model->params.Lc);
-    int            deltaCC = cvRound(model->params.delta * 256 / model->params.Lcc);
-    int            i, j, k, l;
-
-    //clear storages
-    cvClearMemStorage(model->storage);
-    cvZero(model->foreground);
-
-    // From foreground pixel candidates using image differencing
-    // with adaptive thresholding.  The algorithm is from:
-    //
-    //    Thresholding for Change Detection
-    //    Paul L. Rosin 1998 6p
-    //    http://www.cis.temple.edu/~latecki/Courses/CIS750-03/Papers/thresh-iccv.pdf
-    //
-    cvChangeDetection( prev_frame, curr_frame, model->Ftd );
-    cvChangeDetection( model->background, curr_frame, model->Fbd );
-
-    for( i = 0; i < model->Ftd->height; i++ )
-    {
-        for( j = 0; j < model->Ftd->width; j++ )
-        {
-            if( ((uchar*)model->Fbd->imageData)[i*mask_step+j] || ((uchar*)model->Ftd->imageData)[i*mask_step+j] )
-            {
-            float Pb  = 0;
-                float Pv  = 0;
-                float Pvb = 0;
-
-                CvBGPixelStat* stat = model->pixel_stat + i * model->Ftd->width + j;
-
-                CvBGPixelCStatTable*   ctable = stat->ctable;
-                CvBGPixelCCStatTable* cctable = stat->cctable;
-
-                uchar* curr_data = (uchar*)(curr_frame->imageData) + i*curr_frame->widthStep + j*3;
-                uchar* prev_data = (uchar*)(prev_frame->imageData) + i*prev_frame->widthStep + j*3;
-
-                int val = 0;
-
-                // Is it a motion pixel?
-                if( ((uchar*)model->Ftd->imageData)[i*mask_step+j] )
-                {
-            if( !stat->is_trained_dyn_model ) {
-
-                        val = 1;
-
-            } else {
-
-                        // Compare with stored CCt vectors:
-                        for( k = 0;  PV_CC(k) > model->params.alpha2 && k < model->params.N1cc;  k++ )
-                        {
-                            if ( abs( V_CC(k,0) - prev_data[0]) <=  deltaCC &&
-                                 abs( V_CC(k,1) - prev_data[1]) <=  deltaCC &&
-                                 abs( V_CC(k,2) - prev_data[2]) <=  deltaCC &&
-                                 abs( V_CC(k,3) - curr_data[0]) <=  deltaCC &&
-                                 abs( V_CC(k,4) - curr_data[1]) <=  deltaCC &&
-                                 abs( V_CC(k,5) - curr_data[2]) <=  deltaCC)
-                            {
-                                Pv += PV_CC(k);
-                                Pvb += PVB_CC(k);
-                            }
-                        }
-                        Pb = stat->Pbcc;
-                        if( 2 * Pvb * Pb <= Pv ) val = 1;
-                    }
-                }
-                else if( stat->is_trained_st_model )
-                {
-                    // Compare with stored Ct vectors:
-                    for( k = 0;  PV_C(k) > model->params.alpha2 && k < model->params.N1c;  k++ )
-                    {
-                        if ( abs( V_C(k,0) - curr_data[0]) <=  deltaC &&
-                             abs( V_C(k,1) - curr_data[1]) <=  deltaC &&
-                             abs( V_C(k,2) - curr_data[2]) <=  deltaC )
-                        {
-                            Pv += PV_C(k);
-                            Pvb += PVB_C(k);
-                        }
-                    }
-                    Pb = stat->Pbc;
-                    if( 2 * Pvb * Pb <= Pv ) val = 1;
-                }
-
-                // Update foreground:
-                ((uchar*)model->foreground->imageData)[i*mask_step+j] = (uchar)(val*255);
-                FG_pixels_count += val;
-
-            }          // end if( change detection...
-        }              // for j...
-    }                  // for i...
-    //end BG/FG classification
-
-    // Foreground segmentation.
-    // Smooth foreground map:
-    if( model->params.perform_morphing ){
-        cvMorphologyEx( model->foreground, model->foreground, 0, 0, CV_MOP_OPEN,  model->params.perform_morphing );
-        cvMorphologyEx( model->foreground, model->foreground, 0, 0, CV_MOP_CLOSE, model->params.perform_morphing );
-    }
-
-
-    if( model->params.minArea > 0 || model->params.is_obj_without_holes ){
-
-        // Discard under-size foreground regions:
-    //
-        cvFindContours( model->foreground, model->storage, &first_seq, sizeof(CvContour), CV_RETR_LIST );
-        for( seq = first_seq; seq; seq = seq->h_next )
-        {
-            CvContour* cnt = (CvContour*)seq;
-            if( cnt->rect.width * cnt->rect.height < model->params.minArea ||
-                (model->params.is_obj_without_holes && CV_IS_SEQ_HOLE(seq)) )
-            {
-                // Delete under-size contour:
-                prev_seq = seq->h_prev;
-                if( prev_seq )
-                {
-                    prev_seq->h_next = seq->h_next;
-                    if( seq->h_next ) seq->h_next->h_prev = prev_seq;
-                }
-                else
-                {
-                    first_seq = seq->h_next;
-                    if( seq->h_next ) seq->h_next->h_prev = NULL;
-                }
-            }
-            else
-            {
-                region_count++;
-            }
-        }
-        model->foreground_regions = first_seq;
-        cvZero(model->foreground);
-        cvDrawContours(model->foreground, first_seq, CV_RGB(0, 0, 255), CV_RGB(0, 0, 255), 10, -1);
-
-    } else {
-
-        model->foreground_regions = NULL;
-    }
-
-    // Check ALL BG update condition:
-    if( ((float)FG_pixels_count/(model->Ftd->width*model->Ftd->height)) > CV_BGFG_FGD_BG_UPDATE_TRESH )
-    {
-         for( i = 0; i < model->Ftd->height; i++ )
-             for( j = 0; j < model->Ftd->width; j++ )
-             {
-                 CvBGPixelStat* stat = model->pixel_stat + i * model->Ftd->width + j;
-                 stat->is_trained_st_model = stat->is_trained_dyn_model = 1;
-             }
-    }
-
-
-    // Update background model:
-    for( i = 0; i < model->Ftd->height; i++ )
-    {
-        for( j = 0; j < model->Ftd->width; j++ )
-        {
-            CvBGPixelStat* stat = model->pixel_stat + i * model->Ftd->width + j;
-            CvBGPixelCStatTable* ctable = stat->ctable;
-            CvBGPixelCCStatTable* cctable = stat->cctable;
-
-            uchar *curr_data = (uchar*)(curr_frame->imageData)+i*curr_frame->widthStep+j*3;
-            uchar *prev_data = (uchar*)(prev_frame->imageData)+i*prev_frame->widthStep+j*3;
-
-            if( ((uchar*)model->Ftd->imageData)[i*mask_step+j] || !stat->is_trained_dyn_model )
-            {
-                float alpha = stat->is_trained_dyn_model ? model->params.alpha2 : model->params.alpha3;
-                float diff = 0;
-                int dist, min_dist = 2147483647, indx = -1;
-
-                //update Pb
-                stat->Pbcc *= (1.f-alpha);
-                if( !((uchar*)model->foreground->imageData)[i*mask_step+j] )
-                {
-                    stat->Pbcc += alpha;
-                }
-
-                // Find best Vi match:
-                for(k = 0; PV_CC(k) && k < model->params.N2cc; k++ )
-                {
-                    // Exponential decay of memory
-                    PV_CC(k)  *= (1-alpha);
-                    PVB_CC(k) *= (1-alpha);
-                    if( PV_CC(k) < MIN_PV )
-                    {
-                        PV_CC(k) = 0;
-                        PVB_CC(k) = 0;
-                        continue;
-                    }
-
-                    dist = 0;
-                    for( l = 0; l < 3; l++ )
-                    {
-                        int val = abs( V_CC(k,l) - prev_data[l] );
-                        if( val > deltaCC ) break;
-                        dist += val;
-                        val = abs( V_CC(k,l+3) - curr_data[l] );
-                        if( val > deltaCC) break;
-                        dist += val;
-                    }
-                    if( l == 3 && dist < min_dist )
-                    {
-                        min_dist = dist;
-                        indx = k;
-                    }
-                }
-
-
-                if( indx < 0 )
-                {   // Replace N2th elem in the table by new feature:
-                    indx = model->params.N2cc - 1;
-                    PV_CC(indx) = alpha;
-                    PVB_CC(indx) = alpha;
-                    //udate Vt
-                    for( l = 0; l < 3; l++ )
-                    {
-                        V_CC(indx,l) = prev_data[l];
-                        V_CC(indx,l+3) = curr_data[l];
-                    }
-                }
-                else
-                {   // Update:
-                    PV_CC(indx) += alpha;
-                    if( !((uchar*)model->foreground->imageData)[i*mask_step+j] )
-                    {
-                        PVB_CC(indx) += alpha;
-                    }
-                }
-
-                //re-sort CCt table by Pv
-                for( k = 0; k < indx; k++ )
-                {
-                    if( PV_CC(k) <= PV_CC(indx) )
-                    {
-                        //shift elements
-                        CvBGPixelCCStatTable tmp1, tmp2 = cctable[indx];
-                        for( l = k; l <= indx; l++ )
-                        {
-                            tmp1 = cctable[l];
-                            cctable[l] = tmp2;
-                            tmp2 = tmp1;
-                        }
-                        break;
-                    }
-                }
-
-
-                float sum1=0, sum2=0;
-                //check "once-off" changes
-                for(k = 0; PV_CC(k) && k < model->params.N1cc; k++ )
-                {
-                    sum1 += PV_CC(k);
-                    sum2 += PVB_CC(k);
-                }
-                if( sum1 > model->params.T ) stat->is_trained_dyn_model = 1;
-
-                diff = sum1 - stat->Pbcc * sum2;
-                // Update stat table:
-                if( diff >  model->params.T )
-                {
-                    //printf("once off change at motion mode\n");
-                    //new BG features are discovered
-                    for( k = 0; PV_CC(k) && k < model->params.N1cc; k++ )
-                    {
-                        PVB_CC(k) =
-                            (PV_CC(k)-stat->Pbcc*PVB_CC(k))/(1-stat->Pbcc);
-                    }
-                    assert(stat->Pbcc<=1 && stat->Pbcc>=0);
-                }
-            }
-
-            // Handle "stationary" pixel:
-            if( !((uchar*)model->Ftd->imageData)[i*mask_step+j] )
-            {
-                float alpha = stat->is_trained_st_model ? model->params.alpha2 : model->params.alpha3;
-                float diff = 0;
-                int dist, min_dist = 2147483647, indx = -1;
-
-                //update Pb
-                stat->Pbc *= (1.f-alpha);
-                if( !((uchar*)model->foreground->imageData)[i*mask_step+j] )
-                {
-                    stat->Pbc += alpha;
-                }
-
-                //find best Vi match
-                for( k = 0; k < model->params.N2c; k++ )
-                {
-                    // Exponential decay of memory
-                    PV_C(k) *= (1-alpha);
-                    PVB_C(k) *= (1-alpha);
-                    if( PV_C(k) < MIN_PV )
-                    {
-                        PV_C(k) = 0;
-                        PVB_C(k) = 0;
-                        continue;
-                    }
-
-                    dist = 0;
-                    for( l = 0; l < 3; l++ )
-                    {
-                        int val = abs( V_C(k,l) - curr_data[l] );
-                        if( val > deltaC ) break;
-                        dist += val;
-                    }
-                    if( l == 3 && dist < min_dist )
-                    {
-                        min_dist = dist;
-                        indx = k;
-                    }
-                }
-
-                if( indx < 0 )
-                {//N2th elem in the table is replaced by a new features
-                    indx = model->params.N2c - 1;
-                    PV_C(indx) = alpha;
-                    PVB_C(indx) = alpha;
-                    //udate Vt
-                    for( l = 0; l < 3; l++ )
-                    {
-                        V_C(indx,l) = curr_data[l];
-                    }
-                } else
-                {//update
-                    PV_C(indx) += alpha;
-                    if( !((uchar*)model->foreground->imageData)[i*mask_step+j] )
-                    {
-                        PVB_C(indx) += alpha;
-                    }
-                }
-
-                //re-sort Ct table by Pv
-                for( k = 0; k < indx; k++ )
-                {
-                    if( PV_C(k) <= PV_C(indx) )
-                    {
-                        //shift elements
-                        CvBGPixelCStatTable tmp1, tmp2 = ctable[indx];
-                        for( l = k; l <= indx; l++ )
-                        {
-                            tmp1 = ctable[l];
-                            ctable[l] = tmp2;
-                            tmp2 = tmp1;
-                        }
-                        break;
-                    }
-                }
-
-                // Check "once-off" changes:
-                float sum1=0, sum2=0;
-                for( k = 0; PV_C(k) && k < model->params.N1c; k++ )
-                {
-                    sum1 += PV_C(k);
-                    sum2 += PVB_C(k);
-                }
-                diff = sum1 - stat->Pbc * sum2;
-                if( sum1 > model->params.T ) stat->is_trained_st_model = 1;
-
-                // Update stat table:
-                if( diff >  model->params.T )
-                {
-                    //printf("once off change at stat mode\n");
-                    //new BG features are discovered
-                    for( k = 0; PV_C(k) && k < model->params.N1c; k++ )
-                    {
-                        PVB_C(k) = (PV_C(k)-stat->Pbc*PVB_C(k))/(1-stat->Pbc);
-                    }
-                    stat->Pbc = 1 - stat->Pbc;
-                }
-            }          // if !(change detection) at pixel (i,j)
-
-            // Update the reference BG image:
-            if( !((uchar*)model->foreground->imageData)[i*mask_step+j])
-            {
-                uchar* ptr = ((uchar*)model->background->imageData) + i*model->background->widthStep+j*3;
-
-                if( !((uchar*)model->Ftd->imageData)[i*mask_step+j] &&
-                    !((uchar*)model->Fbd->imageData)[i*mask_step+j] )
-                {
-                    // Apply IIR filter:
-                    for( l = 0; l < 3; l++ )
-                    {
-                        int a = cvRound(ptr[l]*(1 - model->params.alpha1) + model->params.alpha1*curr_data[l]);
-                        ptr[l] = (uchar)a;
-                        //((uchar*)model->background->imageData)[i*model->background->widthStep+j*3+l]*=(1 - model->params.alpha1);
-                        //((uchar*)model->background->imageData)[i*model->background->widthStep+j*3+l] += model->params.alpha1*curr_data[l];
-                    }
-                }
-                else
-                {
-                    // Background change detected:
-                    for( l = 0; l < 3; l++ )
-                    {
-                        //((uchar*)model->background->imageData)[i*model->background->widthStep+j*3+l] = curr_data[l];
-                        ptr[l] = curr_data[l];
-                    }
-                }
-            }
-        }              // j
-    }                  // i
-
-    // Keep previous frame:
-    cvCopy( curr_frame, model->prev_frame );
-
-    return region_count;
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/bgfg_codebook.cpp b/modules/legacy/src/bgfg_codebook.cpp
deleted file mode 100644 (file)
index 2a53b29..0000000
+++ /dev/null
@@ -1,361 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-CvBGCodeBookModel* cvCreateBGCodeBookModel()
-{
-    CvBGCodeBookModel* model = (CvBGCodeBookModel*)cvAlloc( sizeof(*model) );
-    memset( model, 0, sizeof(*model) );
-    model->cbBounds[0] = model->cbBounds[1] = model->cbBounds[2] = 10;
-    model->modMin[0] = 3;
-    model->modMax[0] = 10;
-    model->modMin[1] = model->modMin[2] = 1;
-    model->modMax[1] = model->modMax[2] = 1;
-    model->storage = cvCreateMemStorage();
-
-    return model;
-}
-
-void cvReleaseBGCodeBookModel( CvBGCodeBookModel** model )
-{
-    if( model && *model )
-    {
-        cvReleaseMemStorage( &(*model)->storage );
-        memset( *model, 0, sizeof(**model) );
-        cvFree( model );
-    }
-}
-
-static uchar satTab8u[768];
-#undef SAT_8U
-#define SAT_8U(x) satTab8u[(x) + 255]
-
-static void icvInitSatTab()
-{
-    static int initialized = 0;
-    if( !initialized )
-    {
-        for( int i = 0; i < 768; i++ )
-        {
-            int v = i - 255;
-            satTab8u[i] = (uchar)(v < 0 ? 0 : v > 255 ? 255 : v);
-        }
-        initialized = 1;
-    }
-}
-
-
-void cvBGCodeBookUpdate( CvBGCodeBookModel* model, const CvArr* _image,
-                         CvRect roi, const CvArr* _mask )
-{
-    CV_FUNCNAME( "cvBGCodeBookUpdate" );
-
-    __BEGIN__;
-
-    CvMat stub, *image = cvGetMat( _image, &stub );
-    CvMat mstub, *mask = _mask ? cvGetMat( _mask, &mstub ) : 0;
-    int i, x, y, T;
-    int nblocks;
-    uchar cb0, cb1, cb2;
-    CvBGCodeBookElem* freeList;
-
-    CV_ASSERT( model && CV_MAT_TYPE(image->type) == CV_8UC3 &&
-        (!mask || (CV_IS_MASK_ARR(mask) && CV_ARE_SIZES_EQ(image, mask))) );
-
-    if( roi.x == 0 && roi.y == 0 && roi.width == 0 && roi.height == 0 )
-    {
-        roi.width = image->cols;
-        roi.height = image->rows;
-    }
-    else
-        CV_ASSERT( (unsigned)roi.x < (unsigned)image->cols &&
-                   (unsigned)roi.y < (unsigned)image->rows &&
-                   roi.width >= 0 && roi.height >= 0 &&
-                   roi.x + roi.width <= image->cols &&
-                   roi.y + roi.height <= image->rows );
-
-    if( image->cols != model->size.width || image->rows != model->size.height )
-    {
-        cvClearMemStorage( model->storage );
-        model->freeList = 0;
-        cvFree( &model->cbmap );
-        int bufSz = image->cols*image->rows*sizeof(model->cbmap[0]);
-        model->cbmap = (CvBGCodeBookElem**)cvAlloc(bufSz);
-        memset( model->cbmap, 0, bufSz );
-        model->size = cvSize(image->cols, image->rows);
-    }
-
-    icvInitSatTab();
-
-    cb0 = model->cbBounds[0];
-    cb1 = model->cbBounds[1];
-    cb2 = model->cbBounds[2];
-
-    T = ++model->t;
-    freeList = model->freeList;
-    nblocks = (int)((model->storage->block_size - sizeof(CvMemBlock))/sizeof(*freeList));
-    nblocks = MIN( nblocks, 1024 );
-    CV_ASSERT( nblocks > 0 );
-
-    for( y = 0; y < roi.height; y++ )
-    {
-        const uchar* p = image->data.ptr + image->step*(y + roi.y) + roi.x*3;
-        const uchar* m = mask ? mask->data.ptr + mask->step*(y + roi.y) + roi.x : 0;
-        CvBGCodeBookElem** cb = model->cbmap + image->cols*(y + roi.y) + roi.x;
-
-        for( x = 0; x < roi.width; x++, p += 3, cb++ )
-        {
-            CvBGCodeBookElem *e, *found = 0;
-            uchar p0, p1, p2, l0, l1, l2, h0, h1, h2;
-            int negRun;
-
-            if( m && m[x] == 0 )
-                continue;
-
-            p0 = p[0]; p1 = p[1]; p2 = p[2];
-            l0 = SAT_8U(p0 - cb0); l1 = SAT_8U(p1 - cb1); l2 = SAT_8U(p2 - cb2);
-            h0 = SAT_8U(p0 + cb0); h1 = SAT_8U(p1 + cb1); h2 = SAT_8U(p2 + cb2);
-
-            for( e = *cb; e != 0; e = e->next )
-            {
-                if( e->learnMin[0] <= p0 && p0 <= e->learnMax[0] &&
-                    e->learnMin[1] <= p1 && p1 <= e->learnMax[1] &&
-                    e->learnMin[2] <= p2 && p2 <= e->learnMax[2] )
-                {
-                    e->tLastUpdate = T;
-                    e->boxMin[0] = MIN(e->boxMin[0], p0);
-                    e->boxMax[0] = MAX(e->boxMax[0], p0);
-                    e->boxMin[1] = MIN(e->boxMin[1], p1);
-                    e->boxMax[1] = MAX(e->boxMax[1], p1);
-                    e->boxMin[2] = MIN(e->boxMin[2], p2);
-                    e->boxMax[2] = MAX(e->boxMax[2], p2);
-
-                    // no need to use SAT_8U for updated learnMin[i] & learnMax[i] here,
-                    // as the bounding li & hi are already within 0..255.
-                    if( e->learnMin[0] > l0 ) e->learnMin[0]--;
-                    if( e->learnMax[0] < h0 ) e->learnMax[0]++;
-                    if( e->learnMin[1] > l1 ) e->learnMin[1]--;
-                    if( e->learnMax[1] < h1 ) e->learnMax[1]++;
-                    if( e->learnMin[2] > l2 ) e->learnMin[2]--;
-                    if( e->learnMax[2] < h2 ) e->learnMax[2]++;
-
-                    found = e;
-                    break;
-                }
-                negRun = T - e->tLastUpdate;
-                e->stale = MAX( e->stale, negRun );
-            }
-
-            for( ; e != 0; e = e->next )
-            {
-                negRun = T - e->tLastUpdate;
-                e->stale = MAX( e->stale, negRun );
-            }
-
-            if( !found )
-            {
-                if( !freeList )
-                {
-                    freeList = (CvBGCodeBookElem*)cvMemStorageAlloc(model->storage,
-                        nblocks*sizeof(*freeList));
-                    for( i = 0; i < nblocks-1; i++ )
-                        freeList[i].next = &freeList[i+1];
-                    freeList[nblocks-1].next = 0;
-                }
-                e = freeList;
-                freeList = freeList->next;
-
-                e->learnMin[0] = l0; e->learnMax[0] = h0;
-                e->learnMin[1] = l1; e->learnMax[1] = h1;
-                e->learnMin[2] = l2; e->learnMax[2] = h2;
-                e->boxMin[0] = e->boxMax[0] = p0;
-                e->boxMin[1] = e->boxMax[1] = p1;
-                e->boxMin[2] = e->boxMax[2] = p2;
-                e->tLastUpdate = T;
-                e->stale = 0;
-                e->next = *cb;
-                *cb = e;
-            }
-        }
-    }
-
-    model->freeList = freeList;
-
-    __END__;
-}
-
-
-int cvBGCodeBookDiff( const CvBGCodeBookModel* model, const CvArr* _image,
-                      CvArr* _fgmask, CvRect roi )
-{
-    int maskCount = -1;
-
-    CV_FUNCNAME( "cvBGCodeBookDiff" );
-
-    __BEGIN__;
-
-    CvMat stub, *image = cvGetMat( _image, &stub );
-    CvMat mstub, *mask = cvGetMat( _fgmask, &mstub );
-    int x, y;
-    uchar m0, m1, m2, M0, M1, M2;
-
-    CV_ASSERT( model && CV_MAT_TYPE(image->type) == CV_8UC3 &&
-        image->cols == model->size.width && image->rows == model->size.height &&
-        CV_IS_MASK_ARR(mask) && CV_ARE_SIZES_EQ(image, mask) );
-
-    if( roi.x == 0 && roi.y == 0 && roi.width == 0 && roi.height == 0 )
-    {
-        roi.width = image->cols;
-        roi.height = image->rows;
-    }
-    else
-        CV_ASSERT( (unsigned)roi.x < (unsigned)image->cols &&
-                   (unsigned)roi.y < (unsigned)image->rows &&
-                   roi.width >= 0 && roi.height >= 0 &&
-                   roi.x + roi.width <= image->cols &&
-                   roi.y + roi.height <= image->rows );
-
-    m0 = model->modMin[0]; M0 = model->modMax[0];
-    m1 = model->modMin[1]; M1 = model->modMax[1];
-    m2 = model->modMin[2]; M2 = model->modMax[2];
-
-    maskCount = roi.height*roi.width;
-    for( y = 0; y < roi.height; y++ )
-    {
-        const uchar* p = image->data.ptr + image->step*(y + roi.y) + roi.x*3;
-        uchar* m = mask->data.ptr + mask->step*(y + roi.y) + roi.x;
-        CvBGCodeBookElem** cb = model->cbmap + image->cols*(y + roi.y) + roi.x;
-
-        for( x = 0; x < roi.width; x++, p += 3, cb++ )
-        {
-            CvBGCodeBookElem *e;
-            uchar p0 = p[0], p1 = p[1], p2 = p[2];
-            int l0 = p0 + m0, l1 = p1 + m1, l2 = p2 + m2;
-            int h0 = p0 - M0, h1 = p1 - M1, h2 = p2 - M2;
-            m[x] = (uchar)255;
-
-            for( e = *cb; e != 0; e = e->next )
-            {
-                if( e->boxMin[0] <= l0 && h0 <= e->boxMax[0] &&
-                    e->boxMin[1] <= l1 && h1 <= e->boxMax[1] &&
-                    e->boxMin[2] <= l2 && h2 <= e->boxMax[2] )
-                {
-                    m[x] = 0;
-                    maskCount--;
-                    break;
-                }
-            }
-        }
-    }
-
-    __END__;
-
-    return maskCount;
-}
-
-void cvBGCodeBookClearStale( CvBGCodeBookModel* model, int staleThresh,
-                             CvRect roi, const CvArr* _mask )
-{
-    CV_FUNCNAME( "cvBGCodeBookClearStale" );
-
-    __BEGIN__;
-
-    CvMat mstub, *mask = _mask ? cvGetMat( _mask, &mstub ) : 0;
-    int x, y, T;
-    CvBGCodeBookElem* freeList;
-
-    CV_ASSERT( model && (!mask || (CV_IS_MASK_ARR(mask) &&
-        mask->cols == model->size.width && mask->rows == model->size.height)) );
-
-    if( roi.x == 0 && roi.y == 0 && roi.width == 0 && roi.height == 0 )
-    {
-        roi.width = model->size.width;
-        roi.height = model->size.height;
-    }
-    else
-        CV_ASSERT( (unsigned)roi.x < (unsigned)mask->cols &&
-                   (unsigned)roi.y < (unsigned)mask->rows &&
-                   roi.width >= 0 && roi.height >= 0 &&
-                   roi.x + roi.width <= mask->cols &&
-                   roi.y + roi.height <= mask->rows );
-
-    icvInitSatTab();
-    freeList = model->freeList;
-    T = model->t;
-
-    for( y = 0; y < roi.height; y++ )
-    {
-        const uchar* m = mask ? mask->data.ptr + mask->step*(y + roi.y) + roi.x : 0;
-        CvBGCodeBookElem** cb = model->cbmap + model->size.width*(y + roi.y) + roi.x;
-
-        for( x = 0; x < roi.width; x++, cb++ )
-        {
-            CvBGCodeBookElem *e, first, *prev = &first;
-
-            if( m && m[x] == 0 )
-                continue;
-
-            for( first.next = e = *cb; e != 0; e = prev->next )
-            {
-                if( e->stale > staleThresh )
-                {
-                    prev->next = e->next;
-                    e->next = freeList;
-                    freeList = e;
-                }
-                else
-                {
-                    e->stale = 0;
-                    e->tLastUpdate = T;
-                    prev = e;
-                }
-            }
-
-            *cb = first.next;
-        }
-    }
-
-    model->freeList = freeList;
-
-    __END__;
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/bgfg_common.cpp b/modules/legacy/src/bgfg_common.cpp
deleted file mode 100644 (file)
index 2bcea55..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-void cvReleaseBGStatModel( CvBGStatModel** bg_model )
-{
-    if( bg_model && *bg_model && (*bg_model)->release )
-        (*bg_model)->release( bg_model );
-}
-
-int cvUpdateBGStatModel( IplImage* current_frame,
-                        CvBGStatModel*  bg_model,
-                        double learningRate )
-{
-    return bg_model && bg_model->update ? bg_model->update( current_frame, bg_model, learningRate ) : 0;
-}
-
-
-//  Function cvRefineForegroundMaskBySegm preforms FG post-processing based on segmentation
-//    (all pixels of the segment will be classified as FG if majority of pixels of the region are FG).
-// parameters:
-//      segments - pointer to result of segmentation (for example MeanShiftSegmentation)
-//      bg_model - pointer to CvBGStatModel structure
-CV_IMPL void cvRefineForegroundMaskBySegm( CvSeq* segments, CvBGStatModel*  bg_model )
-{
-    IplImage* tmp_image = cvCreateImage(cvSize(bg_model->foreground->width,bg_model->foreground->height),
-                            IPL_DEPTH_8U, 1);
-    for( ; segments; segments = ((CvSeq*)segments)->h_next )
-    {
-        CvSeq seq = *segments;
-        seq.v_next = seq.h_next = NULL;
-        cvZero(tmp_image);
-        cvDrawContours( tmp_image, &seq, CV_RGB(0, 0, 255), CV_RGB(0, 0, 255), 10, -1);
-        int num1 = cvCountNonZero(tmp_image);
-        cvAnd(tmp_image, bg_model->foreground, tmp_image);
-        int num2 = cvCountNonZero(tmp_image);
-        if( num2 > num1*0.5 )
-            cvDrawContours( bg_model->foreground, &seq, CV_RGB(0, 0, 255), CV_RGB(0, 0, 255), 10, -1);
-        else
-            cvDrawContours( bg_model->foreground, &seq, CV_RGB(0, 0, 0), CV_RGB(0, 0, 0), 10, -1);
-    }
-    cvReleaseImage(&tmp_image);
-}
-
-
-
-CV_IMPL CvSeq*
-cvSegmentFGMask( CvArr* _mask, int poly1Hull0, float perimScale,
-                 CvMemStorage* storage, CvPoint offset )
-{
-    CvMat mstub, *mask = cvGetMat( _mask, &mstub );
-    CvMemStorage* tempStorage = storage ? storage : cvCreateMemStorage();
-    CvSeq *contours, *c;
-    int nContours = 0;
-    CvContourScanner scanner;
-
-    // clean up raw mask
-    cvMorphologyEx( mask, mask, 0, 0, CV_MOP_OPEN, 1 );
-    cvMorphologyEx( mask, mask, 0, 0, CV_MOP_CLOSE, 1 );
-
-    // find contours around only bigger regions
-    scanner = cvStartFindContours( mask, tempStorage,
-        sizeof(CvContour), CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, offset );
-
-    while( (c = cvFindNextContour( scanner )) != 0 )
-    {
-        double len = cvContourPerimeter( c );
-        double q = (mask->rows + mask->cols)/perimScale; // calculate perimeter len threshold
-        if( len < q ) //Get rid of blob if it's perimeter is too small
-            cvSubstituteContour( scanner, 0 );
-        else //Smooth it's edges if it's large enough
-        {
-            CvSeq* newC;
-            if( poly1Hull0 ) //Polygonal approximation of the segmentation
-                newC = cvApproxPoly( c, sizeof(CvContour), tempStorage, CV_POLY_APPROX_DP, 2, 0 );
-            else //Convex Hull of the segmentation
-                newC = cvConvexHull2( c, tempStorage, CV_CLOCKWISE, 1 );
-            cvSubstituteContour( scanner, newC );
-            nContours++;
-        }
-    }
-    contours = cvEndFindContours( &scanner );
-
-    // paint the found regions back into the image
-    cvZero( mask );
-    for( c=contours; c != 0; c = c->h_next )
-        cvDrawContours( mask, c, cvScalarAll(255), cvScalarAll(0), -1, CV_FILLED, 8,
-            cvPoint(-offset.x,-offset.y));
-
-    if( tempStorage != storage )
-    {
-        cvReleaseMemStorage( &tempStorage );
-        contours = 0;
-    }
-
-    return contours;
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/bgfg_estimation.cpp b/modules/legacy/src/bgfg_estimation.cpp
deleted file mode 100644 (file)
index d40411b..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-// Function cvCreateBGStatModel creates and returns initialized BG model.
-// Parameters:
-//      first_frame   - frame from video sequence
-//      model_type ñ type of BG model (CV_BG_MODEL_MOG, CV_BG_MODEL_FGD,Ö)
-//      parameters  - (optional) if NULL the default parameters of the algorithm will be used
-static CvBGStatModel* cvCreateBGStatModel( IplImage* first_frame, int model_type, void* params )
-{
-    CvBGStatModel* bg_model = NULL;
-
-    if( model_type == CV_BG_MODEL_FGD || model_type == CV_BG_MODEL_FGD_SIMPLE )
-        bg_model = cvCreateFGDStatModel( first_frame, (CvFGDStatModelParams*)params );
-    else if( model_type == CV_BG_MODEL_MOG )
-        bg_model = cvCreateGaussianBGModel( first_frame, (CvGaussBGStatModelParams*)params );
-
-    return bg_model;
-}
-
-/* FOREGROUND DETECTOR INTERFACE */
-class CvFGDetectorBase : public CvFGDetector
-{
-protected:
-    CvBGStatModel*  m_pFG;
-    int             m_FGType;
-    void*           m_pFGParam; /* Foreground parameters. */
-    CvFGDStatModelParams        m_ParamFGD;
-    CvGaussBGStatModelParams    m_ParamMOG;
-    const char*                       m_SaveName;
-    const char*                       m_LoadName;
-public:
-    virtual void SaveState(CvFileStorage* )
-    {
-        if( m_FGType == CV_BG_MODEL_FGD || m_FGType == CV_BG_MODEL_FGD_SIMPLE )
-        {
-            if( m_SaveName ) /* File name is not empty */
-            {
-                //cvSaveStatModel(m_SaveName, (CvFGDStatModel*)m_pFG);
-            }
-        }
-    };
-    virtual void LoadState(CvFileStorage* , CvFileNode* )
-    {
-        if( m_FGType == CV_BG_MODEL_FGD || m_FGType == CV_BG_MODEL_FGD_SIMPLE )
-        {
-            if( m_LoadName ) /* File name is not empty */
-            {
-                //cvRestoreStatModel(m_LoadName, (CvFGDStatModel*)m_pFG);
-            }
-        }
-    };
-    CvFGDetectorBase(int type, void* param)
-    {
-        m_pFG = NULL;
-        m_FGType = type;
-        m_pFGParam = param;
-        if( m_FGType == CV_BG_MODEL_FGD || m_FGType == CV_BG_MODEL_FGD_SIMPLE )
-        {
-            if(m_pFGParam)
-            {
-              m_ParamFGD = *(CvFGDStatModelParams*)m_pFGParam;
-            }
-            else
-            {
-                m_ParamFGD.Lc = CV_BGFG_FGD_LC;
-                m_ParamFGD.N1c = CV_BGFG_FGD_N1C;
-                m_ParamFGD.N2c = CV_BGFG_FGD_N2C;
-                m_ParamFGD.Lcc = CV_BGFG_FGD_LCC;
-                m_ParamFGD.N1cc = CV_BGFG_FGD_N1CC;
-                m_ParamFGD.N2cc = CV_BGFG_FGD_N2CC;
-                m_ParamFGD.delta = CV_BGFG_FGD_DELTA;
-                m_ParamFGD.alpha1 = CV_BGFG_FGD_ALPHA_1;
-                m_ParamFGD.alpha2 = CV_BGFG_FGD_ALPHA_2;
-                m_ParamFGD.alpha3 = CV_BGFG_FGD_ALPHA_3;
-                m_ParamFGD.T = CV_BGFG_FGD_T;
-                m_ParamFGD.minArea = CV_BGFG_FGD_MINAREA;
-                m_ParamFGD.is_obj_without_holes = 1;
-                m_ParamFGD.perform_morphing = 1;
-            }
-            AddParam("LC",&m_ParamFGD.Lc);
-            AddParam("alpha1",&m_ParamFGD.alpha1);
-            AddParam("alpha2",&m_ParamFGD.alpha2);
-            AddParam("alpha3",&m_ParamFGD.alpha3);
-            AddParam("N1c",&m_ParamFGD.N1c);
-            AddParam("N2c",&m_ParamFGD.N2c);
-            AddParam("N1cc",&m_ParamFGD.N1cc);
-            AddParam("N2cc",&m_ParamFGD.N2cc);
-            m_SaveName = 0;
-            m_LoadName = 0;
-            AddParam("SaveName",&m_SaveName);
-            AddParam("LoadName",&m_LoadName);
-            AddParam("ObjWithoutHoles",&m_ParamFGD.is_obj_without_holes);
-            AddParam("Morphology",&m_ParamFGD.perform_morphing);
-
-        SetModuleName("FGD");
-        }
-        else if( m_FGType == CV_BG_MODEL_MOG )                 // "MOG" == "Mixture Of Gaussians"
-        {
-            if(m_pFGParam)
-            {
-                m_ParamMOG = *(CvGaussBGStatModelParams*)m_pFGParam;
-            }
-            else
-            {                              // These constants are all from cvaux/include/cvaux.h
-                m_ParamMOG.win_size      = CV_BGFG_MOG_WINDOW_SIZE;
-                m_ParamMOG.bg_threshold  = CV_BGFG_MOG_BACKGROUND_THRESHOLD;
-
-                m_ParamMOG.std_threshold = CV_BGFG_MOG_STD_THRESHOLD;
-                m_ParamMOG.weight_init   = CV_BGFG_MOG_WEIGHT_INIT;
-
-                m_ParamMOG.variance_init = CV_BGFG_MOG_SIGMA_INIT*CV_BGFG_MOG_SIGMA_INIT;
-                m_ParamMOG.minArea       = CV_BGFG_MOG_MINAREA;
-                m_ParamMOG.n_gauss       = CV_BGFG_MOG_NGAUSSIANS;
-            }
-            AddParam("NG",&m_ParamMOG.n_gauss);
-
-            SetModuleName("MOG");
-        }
-
-    };
-    ~CvFGDetectorBase()
-    {
-        if(m_pFG)cvReleaseBGStatModel( &m_pFG );
-    }
-    void ParamUpdate()
-    {
-        if(m_pFG)cvReleaseBGStatModel( &m_pFG );
-    }
-
-    inline IplImage* GetMask()
-    {
-        return m_pFG?m_pFG->foreground:NULL;
-    };
-
-    /* Process current image: */
-    virtual void    Process(IplImage* pImg)
-    {
-        if(m_pFG == NULL)
-        {
-            void* param = m_pFGParam;
-            if( m_FGType == CV_BG_MODEL_FGD || m_FGType == CV_BG_MODEL_FGD_SIMPLE )
-            {
-                param = &m_ParamFGD;
-            }
-            else if( m_FGType == CV_BG_MODEL_MOG )
-            {
-                param = &m_ParamMOG;
-            }
-            m_pFG = cvCreateBGStatModel(
-                pImg,
-                m_FGType,
-                param);
-            LoadState(0, 0);
-        }
-        else
-        {
-            cvUpdateBGStatModel( pImg, m_pFG );
-        }
-    };
-
-    /* Release foreground detector: */
-    virtual void    Release()
-    {
-        SaveState(0);
-        if(m_pFG)cvReleaseBGStatModel( &m_pFG );
-    };
-};
-
-CvFGDetector* cvCreateFGDetectorBase(int type, void *param)
-{
-    return (CvFGDetector*) new CvFGDetectorBase(type, param);
-}
diff --git a/modules/legacy/src/bgfg_gaussmix.cpp b/modules/legacy/src/bgfg_gaussmix.cpp
deleted file mode 100644 (file)
index 415e63a..0000000
+++ /dev/null
@@ -1,1328 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-/////////////////////////////////////// MOG model //////////////////////////////////////////
-
-static void CV_CDECL
-icvReleaseGaussianBGModel( CvGaussBGModel** bg_model )
-{
-    if( !bg_model )
-        CV_Error( CV_StsNullPtr, "" );
-
-    if( *bg_model )
-    {
-        delete (cv::Ptr<cv::BackgroundSubtractor>*)((*bg_model)->mog);
-        cvReleaseImage( &(*bg_model)->background );
-        cvReleaseImage( &(*bg_model)->foreground );
-        memset( *bg_model, 0, sizeof(**bg_model) );
-        delete *bg_model;
-        *bg_model = 0;
-    }
-}
-
-
-static int CV_CDECL
-icvUpdateGaussianBGModel( IplImage* curr_frame, CvGaussBGModel*  bg_model, double learningRate )
-{
-    cv::Mat image = cv::cvarrToMat(curr_frame), mask = cv::cvarrToMat(bg_model->foreground);
-
-    cv::Ptr<cv::BackgroundSubtractor>* mog = (cv::Ptr<cv::BackgroundSubtractor>*)(bg_model->mog);
-    CV_Assert(mog != 0);
-
-    (*mog)->apply(image, mask, learningRate);
-    bg_model->countFrames++;
-
-    return 0;
-}
-
-CV_IMPL CvBGStatModel*
-cvCreateGaussianBGModel( IplImage* first_frame, CvGaussBGStatModelParams* parameters )
-{
-    CvGaussBGStatModelParams params;
-
-    CV_Assert( CV_IS_IMAGE(first_frame) );
-
-    //init parameters
-    if( parameters == NULL )
-    {                        // These constants are defined in cvaux/include/cvaux.h
-        params.win_size      = CV_BGFG_MOG_WINDOW_SIZE;
-        params.bg_threshold  = CV_BGFG_MOG_BACKGROUND_THRESHOLD;
-
-        params.std_threshold = CV_BGFG_MOG_STD_THRESHOLD;
-        params.weight_init   = CV_BGFG_MOG_WEIGHT_INIT;
-
-        params.variance_init = CV_BGFG_MOG_SIGMA_INIT*CV_BGFG_MOG_SIGMA_INIT;
-        params.minArea       = CV_BGFG_MOG_MINAREA;
-        params.n_gauss       = CV_BGFG_MOG_NGAUSSIANS;
-    }
-    else
-        params = *parameters;
-
-    CvGaussBGModel* bg_model = new CvGaussBGModel;
-    memset( bg_model, 0, sizeof(*bg_model) );
-    bg_model->type = CV_BG_MODEL_MOG;
-    bg_model->release = (CvReleaseBGStatModel)icvReleaseGaussianBGModel;
-    bg_model->update = (CvUpdateBGStatModel)icvUpdateGaussianBGModel;
-
-    bg_model->params = params;
-
-    cv::Ptr<cv::BackgroundSubtractor> mog = cv::createBackgroundSubtractorMOG(params.win_size, params.n_gauss,
-                                                                              params.bg_threshold);
-    cv::Ptr<cv::BackgroundSubtractor>* pmog = new cv::Ptr<cv::BackgroundSubtractor>;
-    *pmog = mog;
-    bg_model->mog = pmog;
-
-    CvSize sz = cvGetSize(first_frame);
-    bg_model->background = cvCreateImage(sz, IPL_DEPTH_8U, first_frame->nChannels);
-    bg_model->foreground = cvCreateImage(sz, IPL_DEPTH_8U, 1);
-
-    bg_model->countFrames = 0;
-
-    icvUpdateGaussianBGModel( first_frame, bg_model, 1 );
-
-    return (CvBGStatModel*)bg_model;
-}
-
-
-//////////////////////////////////////////// MOG2 //////////////////////////////////////////////
-
-/*M///////////////////////////////////////////////////////////////////////////////////////
- //
- //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
- //
- //  By downloading, copying, installing or using the software you agree to this license.
- //  If you do not agree to this license, do not download, install,
- //  copy or use the software.
- //
- //
- //                        Intel License Agreement
- //
- // Copyright (C) 2000, Intel Corporation, all rights reserved.
- // Third party copyrights are property of their respective owners.
- //
- // Redistribution and use in source and binary forms, with or without modification,
- // are permitted provided that the following conditions are met:
- //
- //   * Redistribution's of source code must retain the above copyright notice,
- //     this list of conditions and the following disclaimer.
- //
- //   * Redistribution's in binary form must reproduce the above copyright notice,
- //     this list of conditions and the following disclaimer in the documentation
- //     and/or other materials provided with the distribution.
- //
- //   * The name of Intel Corporation may not be used to endorse or promote products
- //     derived from this software without specific prior written permission.
- //
- // This software is provided by the copyright holders and contributors "as is" and
- // any express or implied warranties, including, but not limited to, the implied
- // warranties of merchantability and fitness for a particular purpose are disclaimed.
- // In no event shall the Intel Corporation or contributors be liable for any direct,
- // indirect, incidental, special, exemplary, or consequential damages
- // (including, but not limited to, procurement of substitute goods or services;
- // loss of use, data, or profits; or business interruption) however caused
- // and on any theory of liability, whether in contract, strict liability,
- // or tort (including negligence or otherwise) arising in any way out of
- // the use of this software, even if advised of the possibility of such damage.
- //
- //M*/
-
-/*//Implementation of the Gaussian mixture model background subtraction from:
- //
- //"Improved adaptive Gausian mixture model for background subtraction"
- //Z.Zivkovic
- //International Conference Pattern Recognition, UK, August, 2004
- //http://www.zoranz.net/Publications/zivkovic2004ICPR.pdf
- //The code is very fast and performs also shadow detection.
- //Number of Gausssian components is adapted per pixel.
- //
- // and
- //
- //"Efficient Adaptive Density Estimapion per Image Pixel for the Task of Background Subtraction"
- //Z.Zivkovic, F. van der Heijden
- //Pattern Recognition Letters, vol. 27, no. 7, pages 773-780, 2006.
- //
- //The algorithm similar to the standard Stauffer&Grimson algorithm with
- //additional selection of the number of the Gaussian components based on:
- //
- //"Recursive unsupervised learning of finite mixture models "
- //Z.Zivkovic, F.van der Heijden
- //IEEE Trans. on Pattern Analysis and Machine Intelligence, vol.26, no.5, pages 651-656, 2004
- //http://www.zoranz.net/Publications/zivkovic2004PAMI.pdf
- //
- //
- //Example usage with as cpp class
- // BackgroundSubtractorMOG2 bg_model;
- //For each new image the model is updates using:
- // bg_model(img, fgmask);
- //
- //Example usage as part of the CvBGStatModel:
- // CvBGStatModel* bg_model = cvCreateGaussianBGModel2( first_frame );
- //
- // //update for each frame
- // cvUpdateBGStatModel( tmp_frame, bg_model );//segmentation result is in bg_model->foreground
- //
- // //release at the program termination
- // cvReleaseBGStatModel( &bg_model );
- //
- //Author: Z.Zivkovic, www.zoranz.net
- //Date: 7-April-2011, Version:1.0
- ///////////*/
-
-#include "precomp.hpp"
-
-
-/*
- Interface of Gaussian mixture algorithm from:
-
- "Improved adaptive Gausian mixture model for background subtraction"
- Z.Zivkovic
- International Conference Pattern Recognition, UK, August, 2004
- http://www.zoranz.net/Publications/zivkovic2004ICPR.pdf
-
- Advantages:
- -fast - number of Gausssian components is constantly adapted per pixel.
- -performs also shadow detection (see bgfg_segm_test.cpp example)
-
- */
-
-
-#define CV_BG_MODEL_MOG2            3                 /* "Mixture of Gaussians 2".  */
-
-
-/* default parameters of gaussian background detection algorithm */
-#define CV_BGFG_MOG2_STD_THRESHOLD            4.0f     /* lambda=2.5 is 99% */
-#define CV_BGFG_MOG2_WINDOW_SIZE              500      /* Learning rate; alpha = 1/CV_GBG_WINDOW_SIZE */
-#define CV_BGFG_MOG2_BACKGROUND_THRESHOLD     0.9f     /* threshold sum of weights for background test */
-#define CV_BGFG_MOG2_STD_THRESHOLD_GENERATE   3.0f     /* lambda=2.5 is 99% */
-#define CV_BGFG_MOG2_NGAUSSIANS               5        /* = K = number of Gaussians in mixture */
-#define CV_BGFG_MOG2_VAR_INIT                 15.0f    /* initial variance for new components*/
-#define CV_BGFG_MOG2_VAR_MIN                    4.0f
-#define CV_BGFG_MOG2_VAR_MAX                      5*CV_BGFG_MOG2_VAR_INIT
-#define CV_BGFG_MOG2_MINAREA                  15.0f    /* for postfiltering */
-
-/* additional parameters */
-#define CV_BGFG_MOG2_CT                               0.05f     /* complexity reduction prior constant 0 - no reduction of number of components*/
-#define CV_BGFG_MOG2_SHADOW_VALUE             127       /* value to use in the segmentation mask for shadows, sot 0 not to do shadow detection*/
-#define CV_BGFG_MOG2_SHADOW_TAU               0.5f      /* Tau - shadow threshold, see the paper for explanation*/
-
-typedef struct CvGaussBGStatModel2Params
-{
-    //image info
-    int nWidth;
-    int nHeight;
-    int nND;//number of data dimensions (image channels)
-
-    bool bPostFiltering;//defult 1 - do postfiltering - will make shadow detection results also give value 255
-    double  minArea; // for postfiltering
-
-    bool bInit;//default 1, faster updates at start
-
-    /////////////////////////
-    //very important parameters - things you will change
-    ////////////////////////
-    float fAlphaT;
-    //alpha - speed of update - if the time interval you want to average over is T
-    //set alpha=1/T. It is also usefull at start to make T slowly increase
-    //from 1 until the desired T
-    float fTb;
-    //Tb - threshold on the squared Mahalan. dist. to decide if it is well described
-    //by the background model or not. Related to Cthr from the paper.
-    //This does not influence the update of the background. A typical value could be 4 sigma
-    //and that is Tb=4*4=16;
-
-    /////////////////////////
-    //less important parameters - things you might change but be carefull
-    ////////////////////////
-    float fTg;
-    //Tg - threshold on the squared Mahalan. dist. to decide
-    //when a sample is close to the existing components. If it is not close
-    //to any a new component will be generated. I use 3 sigma => Tg=3*3=9.
-    //Smaller Tg leads to more generated components and higher Tg might make
-    //lead to small number of components but they can grow too large
-    float fTB;//1-cf from the paper
-    //TB - threshold when the component becomes significant enough to be included into
-    //the background model. It is the TB=1-cf from the paper. So I use cf=0.1 => TB=0.
-    //For alpha=0.001 it means that the mode should exist for approximately 105 frames before
-    //it is considered foreground
-    float fVarInit;
-    float fVarMax;
-    float fVarMin;
-    //initial standard deviation  for the newly generated components.
-    //It will will influence the speed of adaptation. A good guess should be made.
-    //A simple way is to estimate the typical standard deviation from the images.
-    //I used here 10 as a reasonable value
-    float fCT;//CT - complexity reduction prior
-    //this is related to the number of samples needed to accept that a component
-    //actually exists. We use CT=0.05 of all the samples. By setting CT=0 you get
-    //the standard Stauffer&Grimson algorithm (maybe not exact but very similar)
-
-    //even less important parameters
-    int nM;//max number of modes - const - 4 is usually enough
-
-    //shadow detection parameters
-    bool bShadowDetection;//default 1 - do shadow detection
-    unsigned char nShadowDetection;//do shadow detection - insert this value as the detection result
-    float fTau;
-    // Tau - shadow threshold. The shadow is detected if the pixel is darker
-    //version of the background. Tau is a threshold on how much darker the shadow can be.
-    //Tau= 0.5 means that if pixel is more than 2 times darker then it is not shadow
-    //See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
-} CvGaussBGStatModel2Params;
-
-#define CV_BGFG_MOG2_NDMAX 3
-
-typedef struct CvPBGMMGaussian
-{
-    float weight;
-    float mean[CV_BGFG_MOG2_NDMAX];
-    float variance;
-}CvPBGMMGaussian;
-
-typedef struct CvGaussBGStatModel2Data
-{
-    CvPBGMMGaussian* rGMM; //array for the mixture of Gaussians
-    unsigned char* rnUsedModes;//number of Gaussian components per pixel (maximum 255)
-} CvGaussBGStatModel2Data;
-
-
-/*
- //only foreground image is updated
- //no filtering included
- typedef struct CvGaussBGModel2
- {
- CV_BG_STAT_MODEL_FIELDS();
- CvGaussBGStatModel2Params params;
- CvGaussBGStatModel2Data   data;
- int                       countFrames;
- } CvGaussBGModel2;
-
- CVAPI(CvBGStatModel*) cvCreateGaussianBGModel2( IplImage* first_frame,
- CvGaussBGStatModel2Params* params CV_DEFAULT(NULL) );
- */
-
-//shadow detection performed per pixel
-// should work for rgb data, could be usefull for gray scale and depth data as well
-//  See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
-CV_INLINE int _icvRemoveShadowGMM(float* data, int nD,
-                                  unsigned char nModes,
-                                  CvPBGMMGaussian* pGMM,
-                                  float m_fTb,
-                                  float m_fTB,
-                                  float m_fTau)
-{
-    float tWeight = 0;
-    float numerator, denominator;
-    // check all the components  marked as background:
-    for (int iModes=0;iModes<nModes;iModes++)
-    {
-
-        CvPBGMMGaussian g=pGMM[iModes];
-
-        numerator = 0.0f;
-        denominator = 0.0f;
-        for (int iD=0;iD<nD;iD++)
-        {
-            numerator   += data[iD]  * g.mean[iD];
-            denominator += g.mean[iD]* g.mean[iD];
-        }
-
-        // no division by zero allowed
-        if (denominator == 0)
-        {
-            return 0;
-        };
-        float a = numerator / denominator;
-
-        // if tau < a < 1 then also check the color distortion
-        if ((a <= 1) && (a >= m_fTau))
-        {
-
-            float dist2a=0.0f;
-
-            for (int iD=0;iD<nD;iD++)
-            {
-                float dD= a*g.mean[iD] - data[iD];
-                dist2a += (dD*dD);
-            }
-
-            if (dist2a<m_fTb*g.variance*a*a)
-            {
-                return 2;
-            }
-        };
-
-        tWeight += g.weight;
-        if (tWeight > m_fTB)
-        {
-            return 0;
-        };
-    };
-    return 0;
-}
-
-//update GMM - the base update function performed per pixel
-//
-//"Efficient Adaptive Density Estimapion per Image Pixel for the Task of Background Subtraction"
-//Z.Zivkovic, F. van der Heijden
-//Pattern Recognition Letters, vol. 27, no. 7, pages 773-780, 2006.
-//
-//The algorithm similar to the standard Stauffer&Grimson algorithm with
-//additional selection of the number of the Gaussian components based on:
-//
-//"Recursive unsupervised learning of finite mixture models "
-//Z.Zivkovic, F.van der Heijden
-//IEEE Trans. on Pattern Analysis and Machine Intelligence, vol.26, no.5, pages 651-656, 2004
-//http://www.zoranz.net/Publications/zivkovic2004PAMI.pdf
-
-#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
-#endif
-
-CV_INLINE int _icvUpdateGMM(float* data, int nD,
-                            unsigned char* pModesUsed,
-                            CvPBGMMGaussian* pGMM,
-                            int m_nM,
-                            float m_fAlphaT,
-                            float m_fTb,
-                            float m_fTB,
-                            float m_fTg,
-                            float m_fVarInit,
-                            float m_fVarMax,
-                            float m_fVarMin,
-                            float m_fPrune)
-{
-    //calculate distances to the modes (+ sort)
-    //here we need to go in descending order!!!
-    bool bBackground=0;//return value -> true - the pixel classified as background
-
-    //internal:
-    bool bFitsPDF=0;//if it remains zero a new GMM mode will be added
-    float m_fOneMinAlpha=1-m_fAlphaT;
-    unsigned char nModes=*pModesUsed;//current number of modes in GMM
-    float totalWeight=0.0f;
-
-    //////
-    //go through all modes
-    int iMode=0;
-    CvPBGMMGaussian* pGauss=pGMM;
-    for (;iMode<nModes;iMode++,pGauss++)
-    {
-        float weight = pGauss->weight;//need only weight if fit is found
-        weight=m_fOneMinAlpha*weight+m_fPrune;
-
-        ////
-        //fit not found yet
-        if (!bFitsPDF)
-        {
-            //check if it belongs to some of the remaining modes
-            float var=pGauss->variance;
-
-            //calculate difference and distance
-            float dist2=0.0f;
-#if (CV_BGFG_MOG2_NDMAX==1)
-            float dData=pGauss->mean[0]-data[0];
-            dist2=dData*dData;
-#else
-            float dData[CV_BGFG_MOG2_NDMAX];
-
-            for (int iD=0;iD<nD;iD++)
-            {
-                dData[iD]=pGauss->mean[iD]-data[iD];
-                dist2+=dData[iD]*dData[iD];
-            }
-#endif
-            //background? - m_fTb - usually larger than m_fTg
-            if ((totalWeight<m_fTB)&&(dist2<m_fTb*var))
-                bBackground=1;
-
-            //check fit
-            if (dist2<m_fTg*var)
-            {
-                /////
-                //belongs to the mode - bFitsPDF becomes 1
-                bFitsPDF=1;
-
-                //update distribution
-
-                //update weight
-                weight+=m_fAlphaT;
-
-                float k = m_fAlphaT/weight;
-
-                //update mean
-#if (CV_BGFG_MOG2_NDMAX==1)
-                pGauss->mean[0]-=k*dData;
-#else
-                for (int iD=0;iD<nD;iD++)
-                {
-                    pGauss->mean[iD]-=k*dData[iD];
-                }
-#endif
-
-                //update variance
-                float varnew = var + k*(dist2-var);
-                //limit the variance
-                pGauss->variance = MIN(m_fVarMax,MAX(varnew,m_fVarMin));
-
-                //sort
-                //all other weights are at the same place and
-                //only the matched (iModes) is higher -> just find the new place for it
-                for (int iLocal = iMode;iLocal>0;iLocal--)
-                {
-                    //check one up
-                    if (weight < (pGMM[iLocal-1].weight))
-                    {
-                        break;
-                    }
-                    else
-                    {
-                        //swap one up
-                        CvPBGMMGaussian temp = pGMM[iLocal];
-                        pGMM[iLocal] = pGMM[iLocal-1];
-                        pGMM[iLocal-1] = temp;
-                        pGauss--;
-                    }
-                }
-                //belongs to the mode - bFitsPDF becomes 1
-                /////
-            }
-        }//!bFitsPDF)
-
-        //check prune
-        if (weight<-m_fPrune)
-        {
-            weight=0.0;
-            nModes--;
-        }
-
-        pGauss->weight=weight;//update weight by the calculated value
-        totalWeight+=weight;
-    }
-    //go through all modes
-    //////
-
-    //renormalize weights
-    for (iMode = 0; iMode < nModes; iMode++)
-    {
-        pGMM[iMode].weight = pGMM[iMode].weight/totalWeight;
-    }
-
-    //make new mode if needed and exit
-    if (!bFitsPDF)
-    {
-        if (nModes==m_nM)
-        {
-            //replace the weakest
-            pGauss=pGMM+m_nM-1;
-        }
-        else
-        {
-            //add a new one
-            pGauss=pGMM+nModes;
-            nModes++;
-        }
-
-        if (nModes==1)
-        {
-            pGauss->weight=1;
-        }
-        else
-        {
-            pGauss->weight=m_fAlphaT;
-
-            //renormalize all weights
-            for (iMode = 0; iMode < nModes-1; iMode++)
-            {
-                pGMM[iMode].weight *=m_fOneMinAlpha;
-            }
-        }
-
-        //init
-        memcpy(pGauss->mean,data,nD*sizeof(float));
-        pGauss->variance=m_fVarInit;
-
-        //sort
-        //find the new place for it
-        for (int iLocal = nModes-1;iLocal>0;iLocal--)
-        {
-            //check one up
-            if (m_fAlphaT < (pGMM[iLocal-1].weight))
-            {
-                break;
-            }
-            else
-            {
-                //swap one up
-                CvPBGMMGaussian temp = pGMM[iLocal];
-                pGMM[iLocal] = pGMM[iLocal-1];
-                pGMM[iLocal-1] = temp;
-            }
-        }
-    }
-
-    //set the number of modes
-    *pModesUsed=nModes;
-
-    return bBackground;
-}
-
-#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
-# pragma GCC diagnostic pop
-#endif
-
-// a bit more efficient implementation for common case of 3 channel (rgb) images
-CV_INLINE int _icvUpdateGMM_C3(float r,float g, float b,
-                               unsigned char* pModesUsed,
-                               CvPBGMMGaussian* pGMM,
-                               int m_nM,
-                               float m_fAlphaT,
-                               float m_fTb,
-                               float m_fTB,
-                               float m_fTg,
-                               float m_fVarInit,
-                               float m_fVarMax,
-                               float m_fVarMin,
-                               float m_fPrune)
-{
-    //calculate distances to the modes (+ sort)
-    //here we need to go in descending order!!!
-    bool bBackground=0;//return value -> true - the pixel classified as background
-
-    //internal:
-    bool bFitsPDF=0;//if it remains zero a new GMM mode will be added
-    float m_fOneMinAlpha=1-m_fAlphaT;
-    unsigned char nModes=*pModesUsed;//current number of modes in GMM
-    float totalWeight=0.0f;
-
-    //////
-    //go through all modes
-    int iMode=0;
-    CvPBGMMGaussian* pGauss=pGMM;
-    for (;iMode<nModes;iMode++,pGauss++)
-    {
-        float weight = pGauss->weight;//need only weight if fit is found
-        weight=m_fOneMinAlpha*weight+m_fPrune;
-
-        ////
-        //fit not found yet
-        if (!bFitsPDF)
-        {
-            //check if it belongs to some of the remaining modes
-            float var=pGauss->variance;
-
-            //calculate difference and distance
-            float muR = pGauss->mean[0];
-            float muG = pGauss->mean[1];
-            float muB = pGauss->mean[2];
-
-            float dR=muR - r;
-            float dG=muG - g;
-            float dB=muB - b;
-
-            float dist2=(dR*dR+dG*dG+dB*dB);
-
-            //background? - m_fTb - usually larger than m_fTg
-            if ((totalWeight<m_fTB)&&(dist2<m_fTb*var))
-                bBackground=1;
-
-            //check fit
-            if (dist2<m_fTg*var)
-            {
-                /////
-                //belongs to the mode - bFitsPDF becomes 1
-                bFitsPDF=1;
-
-                //update distribution
-
-                //update weight
-                weight+=m_fAlphaT;
-
-                float k = m_fAlphaT/weight;
-
-                //update mean
-                pGauss->mean[0] = muR - k*(dR);
-                pGauss->mean[1] = muG - k*(dG);
-                pGauss->mean[2] = muB - k*(dB);
-
-                //update variance
-                float varnew = var + k*(dist2-var);
-                //limit the variance
-                pGauss->variance = MIN(m_fVarMax,MAX(varnew,m_fVarMin));
-
-                //sort
-                //all other weights are at the same place and
-                //only the matched (iModes) is higher -> just find the new place for it
-                for (int iLocal = iMode;iLocal>0;iLocal--)
-                {
-                    //check one up
-                    if (weight < (pGMM[iLocal-1].weight))
-                    {
-                        break;
-                    }
-                    else
-                    {
-                        //swap one up
-                        CvPBGMMGaussian temp = pGMM[iLocal];
-                        pGMM[iLocal] = pGMM[iLocal-1];
-                        pGMM[iLocal-1] = temp;
-                        pGauss--;
-                    }
-                }
-                //belongs to the mode - bFitsPDF becomes 1
-                /////
-            }
-
-        }//!bFitsPDF)
-
-        //check prunning
-        if (weight<-m_fPrune)
-        {
-            weight=0.0;
-            nModes--;
-        }
-
-        pGauss->weight=weight;
-        totalWeight+=weight;
-    }
-    //go through all modes
-    //////
-
-    //renormalize weights
-    for (iMode = 0; iMode < nModes; iMode++)
-    {
-        pGMM[iMode].weight = pGMM[iMode].weight/totalWeight;
-    }
-
-    //make new mode if needed and exit
-    if (!bFitsPDF)
-    {
-        if (nModes==m_nM)
-        {
-            //replace the weakest
-            pGauss=pGMM+m_nM-1;
-        }
-        else
-        {
-            //add a new one
-            pGauss=pGMM+nModes;
-            nModes++;
-        }
-
-        if (nModes==1)
-        {
-            pGauss->weight=1;
-        }
-        else
-        {
-            pGauss->weight=m_fAlphaT;
-
-            //renormalize all weights
-            for (iMode = 0; iMode < nModes-1; iMode++)
-            {
-                pGMM[iMode].weight *=m_fOneMinAlpha;
-            }
-        }
-
-        //init
-        pGauss->mean[0]=r;
-        pGauss->mean[1]=g;
-        pGauss->mean[2]=b;
-
-        pGauss->variance=m_fVarInit;
-
-        //sort
-        //find the new place for it
-        for (int iLocal = nModes-1;iLocal>0;iLocal--)
-        {
-            //check one up
-            if (m_fAlphaT < (pGMM[iLocal-1].weight))
-            {
-                break;
-            }
-            else
-            {
-                //swap one up
-                CvPBGMMGaussian temp = pGMM[iLocal];
-                pGMM[iLocal] = pGMM[iLocal-1];
-                pGMM[iLocal-1] = temp;
-            }
-        }
-    }
-
-    //set the number of modes
-    *pModesUsed=nModes;
-
-    return bBackground;
-}
-
-//the main function to update the background model
-static void icvUpdatePixelBackgroundGMM2( const CvArr* srcarr, CvArr* dstarr ,
-                                  CvPBGMMGaussian *pGMM,
-                                  unsigned char *pUsedModes,
-                                  //CvGaussBGStatModel2Params* pGMMPar,
-                                  int nM,
-                                  float fTb,
-                                  float fTB,
-                                  float fTg,
-                                  float fVarInit,
-                                  float fVarMax,
-                                  float fVarMin,
-                                  float fCT,
-                                  float fTau,
-                                  bool bShadowDetection,
-                                  unsigned char  nShadowDetection,
-                                  float alpha)
-{
-    CvMat sstub, *src = cvGetMat(srcarr, &sstub);
-    CvMat dstub, *dst = cvGetMat(dstarr, &dstub);
-    CvSize size = cvGetMatSize(src);
-    int nD=CV_MAT_CN(src->type);
-
-    //reshape if possible
-    if( CV_IS_MAT_CONT(src->type & dst->type) )
-    {
-        size.width *= size.height;
-        size.height = 1;
-    }
-
-    int x, y;
-    float data[CV_BGFG_MOG2_NDMAX];
-    float prune=-alpha*fCT;
-
-    //general nD
-
-    if (nD!=3)
-    {
-        switch (CV_MAT_DEPTH(src->type))
-        {
-            case CV_8U:
-                for( y = 0; y < size.height; y++ )
-                {
-                    uchar* sptr = src->data.ptr + src->step*y;
-                    uchar* pDataOutput = dst->data.ptr + dst->step*y;
-                    for( x = 0; x < size.width; x++,
-                        pGMM+=nM,pUsedModes++,pDataOutput++,sptr+=nD)
-                    {
-                        //convert data
-                        for (int iD=0;iD<nD;iD++) data[iD]=float(sptr[iD]);
-                        //update GMM model
-                        int result = _icvUpdateGMM(data,nD,pUsedModes,pGMM,nM,alpha, fTb, fTB, fTg, fVarInit, fVarMax, fVarMin,prune);
-                        //detect shadows in the foreground
-                        if (bShadowDetection)
-                            if (result==0) result= _icvRemoveShadowGMM(data,nD,(*pUsedModes),pGMM,fTb,fTB,fTau);
-                        //generate output
-                        (* pDataOutput)= (result==1) ? 0 : (result==2) ? (nShadowDetection) : 255;
-                    }
-                }
-                break;
-            case CV_16S:
-                for( y = 0; y < size.height; y++ )
-                {
-                    short* sptr = src->data.s + src->step*y;
-                    uchar* pDataOutput = dst->data.ptr + dst->step*y;
-                    for( x = 0; x < size.width; x++,
-                        pGMM+=nM,pUsedModes++,pDataOutput++,sptr+=nD)
-                    {
-                        //convert data
-                        for (int iD=0;iD<nD;iD++) data[iD]=float(sptr[iD]);
-                        //update GMM model
-                        int result = _icvUpdateGMM(data,nD,pUsedModes,pGMM,nM,alpha, fTb, fTB, fTg, fVarInit, fVarMax, fVarMin,prune);
-                        //detect shadows in the foreground
-                        if (bShadowDetection)
-                            if (result==0) result= _icvRemoveShadowGMM(data,nD,(*pUsedModes),pGMM,fTb,fTB,fTau);
-                        //generate output
-                        (* pDataOutput)= (result==1) ? 0 : (result==2) ? (nShadowDetection) : 255;
-                    }
-                }
-                break;
-            case CV_16U:
-                for( y = 0; y < size.height; y++ )
-                {
-                    unsigned short* sptr = (unsigned short*) (src->data.s + src->step*y);
-                    uchar* pDataOutput = dst->data.ptr + dst->step*y;
-                    for( x = 0; x < size.width; x++,
-                        pGMM+=nM,pUsedModes++,pDataOutput++,sptr+=nD)
-                    {
-                        //convert data
-                        for (int iD=0;iD<nD;iD++) data[iD]=float(sptr[iD]);
-                        //update GMM model
-                        int result = _icvUpdateGMM(data,nD,pUsedModes,pGMM,nM,alpha, fTb, fTB, fTg, fVarInit, fVarMax, fVarMin,prune);
-                        //detect shadows in the foreground
-                        if (bShadowDetection)
-                            if (result==0) result= _icvRemoveShadowGMM(data,nD,(*pUsedModes),pGMM,fTb,fTB,fTau);
-                        //generate output
-                        (* pDataOutput)= (result==1) ? 0 : (result==2) ? (nShadowDetection) : 255;
-                    }
-                }
-                break;
-            case CV_32S:
-                for( y = 0; y < size.height; y++ )
-                {
-                    int* sptr = src->data.i + src->step*y;
-                    uchar* pDataOutput = dst->data.ptr + dst->step*y;
-                    for( x = 0; x < size.width; x++,
-                        pGMM+=nM,pUsedModes++,pDataOutput++,sptr+=nD)
-                    {
-                        //convert data
-                        for (int iD=0;iD<nD;iD++) data[iD]=float(sptr[iD]);
-                        //update GMM model
-                        int result = _icvUpdateGMM(data,nD,pUsedModes,pGMM,nM,alpha, fTb, fTB, fTg, fVarInit, fVarMax, fVarMin,prune);
-                        //detect shadows in the foreground
-                        if (bShadowDetection)
-                            if (result==0) result= _icvRemoveShadowGMM(data,nD,(*pUsedModes),pGMM,fTb,fTB,fTau);
-                        //generate output
-                        (* pDataOutput)= (result==1) ? 0 : (result==2) ? (nShadowDetection) : 255;
-                    }
-                }
-                break;
-            case CV_32F:
-                for( y = 0; y < size.height; y++ )
-                {
-                    float* sptr = src->data.fl + src->step*y;
-                    uchar* pDataOutput = dst->data.ptr + dst->step*y;
-                    for( x = 0; x < size.width; x++,
-                        pGMM+=nM,pUsedModes++,pDataOutput++,sptr+=nD)
-                    {
-                        //update GMM model
-                        int result = _icvUpdateGMM(sptr,nD,pUsedModes,pGMM,nM,alpha, fTb, fTB, fTg, fVarInit, fVarMax, fVarMin,prune);
-                        //detect shadows in the foreground
-                        if (bShadowDetection)
-                            if (result==0) result= _icvRemoveShadowGMM(data,nD,(*pUsedModes),pGMM,fTb,fTB,fTau);
-                        //generate output
-                        (* pDataOutput)= (result==1) ? 0 : (result==2) ? (nShadowDetection) : 255;
-                    }
-                }
-                break;
-            case CV_64F:
-                for( y = 0; y < size.height; y++ )
-                {
-                    double* sptr = src->data.db + src->step*y;
-                    uchar* pDataOutput = dst->data.ptr + dst->step*y;
-                    for( x = 0; x < size.width; x++,
-                        pGMM+=nM,pUsedModes++,pDataOutput++,sptr+=nD)
-                    {
-                        //convert data
-                        for (int iD=0;iD<nD;iD++) data[iD]=float(sptr[iD]);
-                        //update GMM model
-                        int result = _icvUpdateGMM(data,nD,pUsedModes,pGMM,nM,alpha, fTb, fTB, fTg, fVarInit, fVarMax, fVarMin,prune);
-                        //detect shadows in the foreground
-                        if (bShadowDetection)
-                            if (result==0) result= _icvRemoveShadowGMM(data,nD,(*pUsedModes),pGMM,fTb,fTB,fTau);
-                        //generate output
-                        (* pDataOutput)= (result==1) ? 0 : (result==2) ? (nShadowDetection) : 255;
-                    }
-                }
-                break;
-        }
-    }else ///if (nD==3) - a bit faster
-    {
-        switch (CV_MAT_DEPTH(src->type))
-        {
-            case CV_8U:
-                for( y = 0; y < size.height; y++ )
-                {
-                    uchar* sptr = src->data.ptr + src->step*y;
-                    uchar* pDataOutput = dst->data.ptr + dst->step*y;
-                    for( x = 0; x < size.width; x++,
-                        pGMM+=nM,pUsedModes++,pDataOutput++,sptr+=nD)
-                    {
-                        //convert data
-                        data[0]=float(sptr[0]),data[1]=float(sptr[1]),data[2]=float(sptr[2]);
-                        //update GMM model
-                        int result = _icvUpdateGMM_C3(data[0],data[1],data[2],pUsedModes,pGMM,nM,alpha, fTb, fTB, fTg, fVarInit, fVarMax, fVarMin,prune);
-                        //detect shadows in the foreground
-                        if (bShadowDetection)
-                            if (result==0) result= _icvRemoveShadowGMM(data,nD,(*pUsedModes),pGMM,fTb,fTB,fTau);
-                        //generate output
-                        (* pDataOutput)= (result==1) ? 0 : (result==2) ? (nShadowDetection) : 255;
-                    }
-                }
-                break;
-            case CV_16S:
-                for( y = 0; y < size.height; y++ )
-                {
-                    short* sptr = src->data.s + src->step*y;
-                    uchar* pDataOutput = dst->data.ptr + dst->step*y;
-                    for( x = 0; x < size.width; x++,
-                        pGMM+=nM,pUsedModes++,pDataOutput++,sptr+=nD)
-                    {
-                        //convert data
-                        data[0]=float(sptr[0]),data[1]=float(sptr[1]),data[2]=float(sptr[2]);
-                        //update GMM model
-                        int result = _icvUpdateGMM_C3(data[0],data[1],data[2],pUsedModes,pGMM,nM,alpha, fTb, fTB, fTg, fVarInit, fVarMax, fVarMin,prune);
-                        //detect shadows in the foreground
-                        if (bShadowDetection)
-                            if (result==0) result= _icvRemoveShadowGMM(data,nD,(*pUsedModes),pGMM,fTb,fTB,fTau);
-                        //generate output
-                        (* pDataOutput)= (result==1) ? 0 : (result==2) ? (nShadowDetection) : 255;
-                    }
-                }
-                break;
-            case CV_16U:
-                for( y = 0; y < size.height; y++ )
-                {
-                    unsigned short* sptr = (unsigned short*) src->data.s + src->step*y;
-                    uchar* pDataOutput = dst->data.ptr + dst->step*y;
-                    for( x = 0; x < size.width; x++,
-                        pGMM+=nM,pUsedModes++,pDataOutput++,sptr+=nD)
-                    {
-                        //convert data
-                        data[0]=float(sptr[0]),data[1]=float(sptr[1]),data[2]=float(sptr[2]);
-                        //update GMM model
-                        int result = _icvUpdateGMM_C3(data[0],data[1],data[2],pUsedModes,pGMM,nM,alpha, fTb, fTB, fTg, fVarInit, fVarMax, fVarMin,prune);
-                        //detect shadows in the foreground
-                        if (bShadowDetection)
-                            if (result==0) result= _icvRemoveShadowGMM(data,nD,(*pUsedModes),pGMM,fTb,fTB,fTau);
-                        //generate output
-                        (* pDataOutput)= (result==1) ? 0 : (result==2) ? (nShadowDetection) : 255;
-                    }
-                }
-                break;
-            case CV_32S:
-                for( y = 0; y < size.height; y++ )
-                {
-                    int* sptr = src->data.i + src->step*y;
-                    uchar* pDataOutput = dst->data.ptr + dst->step*y;
-                    for( x = 0; x < size.width; x++,
-                        pGMM+=nM,pUsedModes++,pDataOutput++,sptr+=nD)
-                    {
-                        //convert data
-                        data[0]=float(sptr[0]),data[1]=float(sptr[1]),data[2]=float(sptr[2]);
-                        //update GMM model
-                        int result = _icvUpdateGMM_C3(data[0],data[1],data[2],pUsedModes,pGMM,nM,alpha, fTb, fTB, fTg, fVarInit, fVarMax, fVarMin,prune);
-                        //detect shadows in the foreground
-                        if (bShadowDetection)
-                            if (result==0) result= _icvRemoveShadowGMM(data,nD,(*pUsedModes),pGMM,fTb,fTB,fTau);
-                        //generate output
-                        (* pDataOutput)= (result==1) ? 0 : (result==2) ? (nShadowDetection) : 255;
-                    }
-                }
-                break;
-            case CV_32F:
-                for( y = 0; y < size.height; y++ )
-                {
-                    float* sptr = src->data.fl + src->step*y;
-                    uchar* pDataOutput = dst->data.ptr + dst->step*y;
-                    for( x = 0; x < size.width; x++,
-                        pGMM+=nM,pUsedModes++,pDataOutput++,sptr+=nD)
-                    {
-                        //update GMM model
-                        int result = _icvUpdateGMM_C3(sptr[0],sptr[1],sptr[2],pUsedModes,pGMM,nM,alpha, fTb, fTB, fTg, fVarInit, fVarMax, fVarMin,prune);
-                        //detect shadows in the foreground
-                        if (bShadowDetection)
-                            if (result==0) result= _icvRemoveShadowGMM(data,nD,(*pUsedModes),pGMM,fTb,fTB,fTau);
-                        //generate output
-                        (* pDataOutput)= (result==1) ? 0 : (result==2) ? (nShadowDetection) : 255;
-                    }
-                }
-                break;
-            case CV_64F:
-                for( y = 0; y < size.height; y++ )
-                {
-                    double* sptr = src->data.db + src->step*y;
-                    uchar* pDataOutput = dst->data.ptr + dst->step*y;
-                    for( x = 0; x < size.width; x++,
-                        pGMM+=nM,pUsedModes++,pDataOutput++,sptr+=nD)
-                    {
-                        //convert data
-                        data[0]=float(sptr[0]),data[1]=float(sptr[1]),data[2]=float(sptr[2]);
-                        //update GMM model
-                        int result = _icvUpdateGMM_C3(data[0],data[1],data[2],pUsedModes,pGMM,nM,alpha, fTb, fTB, fTg, fVarInit, fVarMax, fVarMin,prune);
-                        //detect shadows in the foreground
-                        if (bShadowDetection)
-                            if (result==0) result= _icvRemoveShadowGMM(data,nD,(*pUsedModes),pGMM,fTb,fTB,fTau);
-                        //generate output
-                        (* pDataOutput)= (result==1) ? 0 : (result==2) ? (nShadowDetection) : 255;
-                    }
-                }
-                break;
-        }
-    }//a bit faster for nD=3;
-}
-
-
-//only foreground image is updated
-//no filtering included
-typedef struct CvGaussBGModel2
-{
-    CV_BG_STAT_MODEL_FIELDS();
-    CvGaussBGStatModel2Params params;
-    CvGaussBGStatModel2Data   data;
-    int                       countFrames;
-} CvGaussBGModel2;
-
-CVAPI(CvBGStatModel*) cvCreateGaussianBGModel2( IplImage* first_frame,
-                                               CvGaussBGStatModel2Params* params CV_DEFAULT(NULL) );
-
-//////////////////////////////////////////////
-//implementation as part of the CvBGStatModel
-static void CV_CDECL icvReleaseGaussianBGModel2( CvGaussBGModel2** bg_model );
-static int CV_CDECL icvUpdateGaussianBGModel2( IplImage* curr_frame, CvGaussBGModel2*  bg_model );
-
-
-CV_IMPL CvBGStatModel*
-cvCreateGaussianBGModel2( IplImage* first_frame, CvGaussBGStatModel2Params* parameters )
-{
-    CvGaussBGModel2* bg_model = 0;
-    int w,h;
-
-    CV_FUNCNAME( "cvCreateGaussianBGModel2" );
-
-    __BEGIN__;
-
-    CvGaussBGStatModel2Params params;
-
-    if( !CV_IS_IMAGE(first_frame) )
-        CV_ERROR( CV_StsBadArg, "Invalid or NULL first_frame parameter" );
-
-    if( first_frame->nChannels>CV_BGFG_MOG2_NDMAX )
-        CV_ERROR( CV_StsBadArg, "Maxumum number of channels in the image is excedded (change CV_BGFG_MOG2_MAXBANDS constant)!" );
-
-
-    CV_CALL( bg_model = (CvGaussBGModel2*)cvAlloc( sizeof(*bg_model) ));
-    memset( bg_model, 0, sizeof(*bg_model) );
-    bg_model->type    = CV_BG_MODEL_MOG2;
-    bg_model->release = (CvReleaseBGStatModel) icvReleaseGaussianBGModel2;
-    bg_model->update  = (CvUpdateBGStatModel)  icvUpdateGaussianBGModel2;
-
-    //init parameters
-    if( parameters == NULL )
-    {
-        memset(&params, 0, sizeof(params));
-
-        // These constants are defined in cvaux/include/cvaux.h
-        params.bShadowDetection = 1;
-        params.bPostFiltering=0;
-        params.minArea=CV_BGFG_MOG2_MINAREA;
-
-        //set parameters
-        // K - max number of Gaussians per pixel
-        params.nM = CV_BGFG_MOG2_NGAUSSIANS;//4;
-        // Tb - the threshold - n var
-        //pGMM->fTb = 4*4;
-        params.fTb = CV_BGFG_MOG2_STD_THRESHOLD*CV_BGFG_MOG2_STD_THRESHOLD;
-        // Tbf - the threshold
-        //pGMM->fTB = 0.9f;//1-cf from the paper
-        params.fTB = CV_BGFG_MOG2_BACKGROUND_THRESHOLD;
-        // Tgenerate - the threshold
-        params.fTg = CV_BGFG_MOG2_STD_THRESHOLD_GENERATE*CV_BGFG_MOG2_STD_THRESHOLD_GENERATE;//update the mode or generate new
-        //pGMM->fSigma= 11.0f;//sigma for the new mode
-        params.fVarInit = CV_BGFG_MOG2_VAR_INIT;
-        params.fVarMax = CV_BGFG_MOG2_VAR_MAX;
-        params.fVarMin = CV_BGFG_MOG2_VAR_MIN;
-        // alpha - the learning factor
-        params.fAlphaT = 1.0f/CV_BGFG_MOG2_WINDOW_SIZE;//0.003f;
-        // complexity reduction prior constant
-        params.fCT = CV_BGFG_MOG2_CT;//0.05f;
-
-        //shadow
-        // Shadow detection
-        params.nShadowDetection = (unsigned char)CV_BGFG_MOG2_SHADOW_VALUE;//value 0 to turn off
-        params.fTau = CV_BGFG_MOG2_SHADOW_TAU;//0.5f;// Tau - shadow threshold
-    }
-    else
-    {
-        params = *parameters;
-    }
-
-    bg_model->params = params;
-
-    //image data
-    w = first_frame->width;
-    h = first_frame->height;
-
-    bg_model->params.nWidth = w;
-    bg_model->params.nHeight = h;
-
-    bg_model->params.nND = first_frame->nChannels;
-
-
-    //allocate GMM data
-
-    //GMM for each pixel
-    bg_model->data.rGMM = (CvPBGMMGaussian*) malloc(w*h * params.nM * sizeof(CvPBGMMGaussian));
-    //used modes per pixel
-    bg_model->data.rnUsedModes = (unsigned char* ) malloc(w*h);
-    memset(bg_model->data.rnUsedModes,0,w*h);//no modes used
-
-    //prepare storages
-    CV_CALL( bg_model->background = cvCreateImage(cvSize(w,h), IPL_DEPTH_8U, first_frame->nChannels));
-    CV_CALL( bg_model->foreground = cvCreateImage(cvSize(w,h), IPL_DEPTH_8U, 1));
-
-    //for eventual filtering
-    CV_CALL( bg_model->storage = cvCreateMemStorage());
-
-    bg_model->countFrames = 0;
-
-    __END__;
-
-    if( cvGetErrStatus() < 0 )
-    {
-        CvBGStatModel* base_ptr = (CvBGStatModel*)bg_model;
-
-        if( bg_model && bg_model->release )
-            bg_model->release( &base_ptr );
-        else
-            cvFree( &bg_model );
-        bg_model = 0;
-    }
-
-    return (CvBGStatModel*)bg_model;
-}
-
-
-static void CV_CDECL
-icvReleaseGaussianBGModel2( CvGaussBGModel2** _bg_model )
-{
-    CV_FUNCNAME( "icvReleaseGaussianBGModel2" );
-
-    __BEGIN__;
-
-    if( !_bg_model )
-        CV_ERROR( CV_StsNullPtr, "" );
-
-    if( *_bg_model )
-    {
-        CvGaussBGModel2* bg_model = *_bg_model;
-
-        free (bg_model->data.rGMM);
-        free (bg_model->data.rnUsedModes);
-
-        cvReleaseImage( &bg_model->background );
-        cvReleaseImage( &bg_model->foreground );
-        cvReleaseMemStorage(&bg_model->storage);
-        memset( bg_model, 0, sizeof(*bg_model) );
-        cvFree( _bg_model );
-    }
-
-    __END__;
-}
-
-
-static int CV_CDECL
-icvUpdateGaussianBGModel2( IplImage* curr_frame, CvGaussBGModel2*  bg_model )
-{
-    //checks
-    if ((curr_frame->height!=bg_model->params.nHeight)||(curr_frame->width!=bg_model->params.nWidth)||(curr_frame->nChannels!=bg_model->params.nND))
-        CV_Error( CV_StsBadSize, "the image not the same size as the reserved GMM background model");
-
-    float alpha=bg_model->params.fAlphaT;
-    bg_model->countFrames++;
-
-    //faster initial updates - increase value of alpha
-    if (bg_model->params.bInit){
-        float alphaInit=(1.0f/(2*bg_model->countFrames+1));
-        if (alphaInit>alpha)
-        {
-            alpha = alphaInit;
-        }
-        else
-        {
-            bg_model->params.bInit = 0;
-        }
-    }
-
-    //update background
-    //icvUpdatePixelBackgroundGMM2( curr_frame, bg_model->foreground, bg_model->data.rGMM,bg_model->data.rnUsedModes,&(bg_model->params),alpha);
-    icvUpdatePixelBackgroundGMM2( curr_frame, bg_model->foreground, bg_model->data.rGMM,bg_model->data.rnUsedModes,
-                                 bg_model->params.nM,
-                                 bg_model->params.fTb,
-                                 bg_model->params.fTB,
-                                 bg_model->params.fTg,
-                                 bg_model->params.fVarInit,
-                                 bg_model->params.fVarMax,
-                                 bg_model->params.fVarMin,
-                                 bg_model->params.fCT,
-                                 bg_model->params.fTau,
-                                 bg_model->params.bShadowDetection,
-                                 bg_model->params.nShadowDetection,
-                                 alpha);
-
-    //foreground filtering
-    if (bg_model->params.bPostFiltering==1)
-    {
-        int region_count = 0;
-        CvSeq *first_seq = NULL, *prev_seq = NULL, *seq = NULL;
-
-
-        //filter small regions
-        cvClearMemStorage(bg_model->storage);
-
-        cvMorphologyEx( bg_model->foreground, bg_model->foreground, 0, 0, CV_MOP_OPEN, 1 );
-        cvMorphologyEx( bg_model->foreground, bg_model->foreground, 0, 0, CV_MOP_CLOSE, 1 );
-
-        cvFindContours( bg_model->foreground, bg_model->storage, &first_seq, sizeof(CvContour), CV_RETR_LIST );
-        for( seq = first_seq; seq; seq = seq->h_next )
-        {
-            CvContour* cnt = (CvContour*)seq;
-            if( cnt->rect.width * cnt->rect.height < bg_model->params.minArea )
-            {
-                //delete small contour
-                prev_seq = seq->h_prev;
-                if( prev_seq )
-                {
-                    prev_seq->h_next = seq->h_next;
-                    if( seq->h_next ) seq->h_next->h_prev = prev_seq;
-                }
-                else
-                {
-                    first_seq = seq->h_next;
-                    if( seq->h_next ) seq->h_next->h_prev = NULL;
-                }
-            }
-            else
-            {
-                region_count++;
-            }
-        }
-        bg_model->foreground_regions = first_seq;
-        cvZero(bg_model->foreground);
-        cvDrawContours(bg_model->foreground, first_seq, CV_RGB(0, 0, 255), CV_RGB(0, 0, 255), 10, -1);
-
-        return region_count;
-    }
-
-    return 1;
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/blobtrack.cpp b/modules/legacy/src/blobtrack.cpp
deleted file mode 100644 (file)
index 00e4905..0000000
+++ /dev/null
@@ -1,639 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The names of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-//////////////////////////// CvVSModule /////////////////////////////
-
-CvVSModule::CvVSModule()
-{
-    m_pNickName = NULL;
-    m_pParamList = NULL;
-    m_pModuleTypeName = NULL;
-    m_pModuleName = NULL;
-    m_Wnd = 0;
-    AddParam("DebugWnd",&m_Wnd);
-}
-
-CvVSModule::~CvVSModule()
-{
-    CvDefParam* p = m_pParamList;
-    for(;p;)
-    {
-        CvDefParam* pf = p;
-        p=p->next;
-        FreeParam(&pf);
-    }
-    m_pParamList=NULL;
-    if(m_pModuleTypeName)free(m_pModuleTypeName);
-    if(m_pModuleName)free(m_pModuleName);
-}
-
-void    CvVSModule::FreeParam(CvDefParam** pp)
-{
-    CvDefParam* p = pp[0];
-    if(p->Str)free(p->Str);
-    if(p->pName)free(p->pName);
-    if(p->pComment)free(p->pComment);
-    cvFree(pp);
-}
-
-CvDefParam* CvVSModule::NewParam(const char* name)
-{
-    CvDefParam* pNew = (CvDefParam*)cvAlloc(sizeof(CvDefParam));
-    memset(pNew,0,sizeof(CvDefParam));
-    pNew->pName = strdup(name);
-    if(m_pParamList==NULL)
-    {
-        m_pParamList = pNew;
-    }
-    else
-    {
-        CvDefParam* p = m_pParamList;
-        for(;p->next;p=p->next) ;
-        p->next = pNew;
-    }
-    return pNew;
-}
-
-CvDefParam* CvVSModule::GetParamPtr(int index)
-{
-    CvDefParam* p = m_pParamList;
-    for(;index>0 && p;index--,p=p->next) ;
-    return p;
-}
-
-CvDefParam* CvVSModule::GetParamPtr(const char* name)
-{
-    CvDefParam* p = m_pParamList;
-    for(;p;p=p->next)
-    {
-        if(cv_stricmp(p->pName,name)==0) break;
-    }
-    return p;
-}
-
-int  CvVSModule::IsParam(const char* name)
-{
-    return GetParamPtr(name)?1:0;
-}
-
-void CvVSModule::AddParam(const char* name, double* pAddr)
-{
-    NewParam(name)->pDouble = pAddr;
-}
-
-void CvVSModule::AddParam(const char* name, float* pAddr)
-{
-    NewParam(name)->pFloat=pAddr;
-}
-
-void CvVSModule::AddParam(const char* name, int* pAddr)
-{
-    NewParam(name)->pInt=pAddr;
-}
-
-void CvVSModule::AddParam(const char* name, const char** pAddr)
-{
-    CvDefParam* pP = NewParam(name);
-    const char* p = pAddr?pAddr[0]:NULL;
-    pP->pStr = pAddr?(char**)pAddr:&(pP->Str);
-    if(p)
-    {
-        pP->Str = strdup(p);
-        pP->pStr[0] = pP->Str;
-    }
-}
-
-void CvVSModule::AddParam(const char* name)
-{
-    CvDefParam* p = NewParam(name);
-    p->pDouble = &p->Double;
-}
-
-void CvVSModule::CommentParam(const char* name, const char* pComment)
-{
-    CvDefParam* p = GetParamPtr(name);
-    if(p)p->pComment = pComment ? strdup(pComment) : 0;
-}
-
-void CvVSModule::SetTypeName(const char* name){m_pModuleTypeName = strdup(name);}
-
-void CvVSModule::SetModuleName(const char* name){m_pModuleName = strdup(name);}
-
-void CvVSModule::DelParam(const char* name)
-{
-    CvDefParam* p = m_pParamList;
-    CvDefParam* pPrev = NULL;
-    for(;p;p=p->next)
-    {
-        if(cv_stricmp(p->pName,name)==0) break;
-        pPrev = p;
-    }
-    if(p)
-    {
-        if(pPrev)
-        {
-            pPrev->next = p->next;
-        }
-        else
-        {
-            m_pParamList = p->next;
-        }
-        FreeParam(&p);
-    }
-}/* DelParam */
-
-
-const char* CvVSModule::GetParamName(int index)
-{
-    CvDefParam* p = GetParamPtr(index);
-    return p?p->pName:NULL;
-}
-const char* CvVSModule::GetParamComment(const char* name)
-{
-    CvDefParam* p = GetParamPtr(name);
-    if(p && p->pComment) return p->pComment;
-    return NULL;
-}
-double CvVSModule::GetParam(const char* name)
-{
-    CvDefParam* p = GetParamPtr(name);
-    if(p)
-    {
-        if(p->pDouble) return p->pDouble[0];
-        if(p->pFloat) return p->pFloat[0];
-        if(p->pInt) return p->pInt[0];
-    }
-    return 0;
-}
-
-const char* CvVSModule::GetParamStr(const char* name)
-{
-    CvDefParam* p = GetParamPtr(name);
-    return p?p->Str:NULL;
-}
-void   CvVSModule::SetParam(const char* name, double val)
-{
-    CvDefParam* p = m_pParamList;
-    for(;p;p=p->next)
-    {
-        if(cv_stricmp(p->pName,name) != 0) continue;
-        if(p->pDouble)p->pDouble[0] = val;
-        if(p->pFloat)p->pFloat[0] = (float)val;
-        if(p->pInt)p->pInt[0] = cvRound(val);
-    }
-}
-void   CvVSModule::SetParamStr(const char* name, const char* str)
-{
-    CvDefParam* p = m_pParamList;
-    for(; p; p=p->next)
-    {
-        if(cv_stricmp(p->pName,name) != 0) continue;
-        if(p->pStr)
-        {
-            if(p->Str)free(p->Str);
-            p->Str = NULL;
-            if(str)p->Str = strdup(str);
-            p->pStr[0] = p->Str;
-        }
-    }
-    /* Convert to double and set: */
-    if(str) SetParam(name,atof(str));
-}
-
-void CvVSModule::TransferParamsFromChild(CvVSModule* pM, const char* prefix)
-{
-    char    tmp[1024];
-    const char*   FN = NULL;
-    int i;
-    for(i=0;;++i)
-    {
-        const char* N = pM->GetParamName(i);
-        if(N == NULL) break;
-        FN = N;
-        if(prefix)
-        {
-            strcpy(tmp,prefix);
-            strcat(tmp,"_");
-            FN = strcat(tmp,N);
-        }
-
-        if(!IsParam(FN))
-        {
-            if(pM->GetParamStr(N))
-            {
-                AddParam(FN,(const char**)NULL);
-            }
-            else
-            {
-                AddParam(FN);
-            }
-        }
-        if(pM->GetParamStr(N))
-        {
-            const char* val = pM->GetParamStr(N);
-            SetParamStr(FN,val);
-        }
-        else
-        {
-            double val = pM->GetParam(N);
-            SetParam(FN,val);
-        }
-        CommentParam(FN, pM->GetParamComment(N));
-    }/* transfer next param */
-}/* Transfer params */
-
-void CvVSModule::TransferParamsToChild(CvVSModule* pM, char* prefix)
-{
-    char    tmp[1024];
-    int i;
-    for(i=0;;++i)
-    {
-        const char* N = pM->GetParamName(i);
-        if(N == NULL) break;
-        if(prefix)
-        {
-            strcpy(tmp,prefix);
-            strcat(tmp,"_");
-            strcat(tmp,N);
-        }
-        else
-        {
-            strcpy(tmp,N);
-        }
-
-        if(IsParam(tmp))
-        {
-            if(GetParamStr(tmp))
-                pM->SetParamStr(N,GetParamStr(tmp));
-            else
-                pM->SetParam(N,GetParam(tmp));
-        }
-    }/* Transfer next parameter */
-    pM->ParamUpdate();
-}/* Transfer params */
-
-void CvVSModule::ParamUpdate(){}
-
-const char*   CvVSModule::GetTypeName()
-{
-    return m_pModuleTypeName;
-}
-
-int     CvVSModule::IsModuleTypeName(const char* name)
-{
-    return m_pModuleTypeName?(cv_stricmp(m_pModuleTypeName,name)==0):0;
-}
-
-char*   CvVSModule::GetModuleName()
-{
-    return m_pModuleName;
-}
-
-int     CvVSModule::IsModuleName(const char* name)
-{
-    return m_pModuleName?(cv_stricmp(m_pModuleName,name)==0):0;
-}
-
-void CvVSModule::SetNickName(const char* pStr)
-{
-    if(m_pNickName)
-        free(m_pNickName);
-
-    m_pNickName = NULL;
-
-    if(pStr)
-        m_pNickName = strdup(pStr);
-}
-
-const char* CvVSModule::GetNickName()
-{
-    return m_pNickName ? m_pNickName : "unknown";
-}
-
-void CvVSModule::SaveState(CvFileStorage*)
-{
-}
-
-void CvVSModule::LoadState(CvFileStorage*, CvFileNode*)
-{
-}
-
-/////////////////////////////////////////////////////////////////////
-
-void cvWriteStruct(CvFileStorage* fs, const char* name, void* addr, const char* desc, int num)
-{
-    cvStartWriteStruct(fs,name,CV_NODE_SEQ|CV_NODE_FLOW);
-    cvWriteRawData(fs,addr,num,desc);
-    cvEndWriteStruct(fs);
-}
-
-void cvReadStructByName(CvFileStorage* fs, CvFileNode* node, const char* name, void* addr, const char* desc)
-{
-    CvFileNode* pSeqNode = cvGetFileNodeByName(fs, node, name);
-    if(pSeqNode==NULL)
-    {
-        printf("WARNING!!! Can't read structure %s\n",name);
-    }
-    else
-    {
-        if(CV_NODE_IS_SEQ(pSeqNode->tag))
-        {
-            cvReadRawData( fs, pSeqNode, addr, desc );
-        }
-        else
-        {
-            printf("WARNING!!! Structure %s is not sequence and can not be read\n",name);
-        }
-    }
-}
-
-////////////////////////////// CvFGDetector ///////////////////////////////////////////
-
-CvFGDetector::CvFGDetector()
-{
-    SetTypeName("FGDetector");
-}
-
-void cvReleaseFGDetector(CvFGDetector** ppT )
-{
-    ppT[0]->Release();
-    ppT[0] = 0;
-}
-
-///////////////////////////// CvBlobSeq ///////////////////////////////////////////////
-
-CvBlobTrackSeq::CvBlobTrackSeq(int TrackSize)
-{
-    m_pMem = cvCreateMemStorage();
-    m_pSeq = cvCreateSeq(0,sizeof(CvSeq),TrackSize,m_pMem);
-}
-
-CvBlobTrackSeq::~CvBlobTrackSeq()
-{
-    Clear();
-    cvReleaseMemStorage(&m_pMem);
-}
-
-CvBlobTrack* CvBlobTrackSeq::GetBlobTrack(int TrackIndex)
-{
-    return (CvBlobTrack*)cvGetSeqElem(m_pSeq,TrackIndex);
-}
-
-CvBlobTrack* CvBlobTrackSeq::GetBlobTrackByID(int TrackID)
-{
-    int i;
-    for(i=0; i<m_pSeq->total; ++i)
-    {
-        CvBlobTrack* pP = GetBlobTrack(i);
-        if(pP && pP->TrackID == TrackID)
-            return pP;
-    }
-    return NULL;
-}
-
-void CvBlobTrackSeq::DelBlobTrack(int TrackIndex)
-{
-    CvBlobTrack* pP = GetBlobTrack(TrackIndex);
-    if(pP && pP->pBlobSeq) delete pP->pBlobSeq;
-    cvSeqRemove(m_pSeq,TrackIndex);
-}
-
-void CvBlobTrackSeq::DelBlobTrackByID(int TrackID)
-{
-    int i;
-    for(i=0; i<m_pSeq->total; ++i)
-    {
-        CvBlobTrack* pP = GetBlobTrack(i);
-        if(TrackID == pP->TrackID)
-        {
-            DelBlobTrack(i);
-            return;
-        }
-    }
-}
-
-void CvBlobTrackSeq::Clear()
-{
-    int i;
-    for(i=GetBlobTrackNum();i>0;i--)
-    {
-        DelBlobTrack(i-1);
-    }
-    cvClearSeq(m_pSeq);
-}
-
-void CvBlobTrackSeq::AddBlobTrack(int TrackID, int StartFrame)
-{
-    CvBlobTrack N;
-    N.TrackID = TrackID;
-    N.StartFrame = StartFrame;
-    N.pBlobSeq = new CvBlobSeq;
-    cvSeqPush(m_pSeq,&N);
-}
-
-int CvBlobTrackSeq::GetBlobTrackNum()
-{
-    return m_pSeq->total;
-}
-
-void cvReleaseBlobDetector(CvBlobDetector** ppBD)
-{
-    ppBD[0]->Release();
-    ppBD[0] = NULL;
-}
-
-
-///////////////////////////////////// CvObjectDetector /////////////////////////////////
-
-CvObjectDetector::CvObjectDetector( const char* /*detector_file_name*/ )
-{
-}
-
-CvObjectDetector::~CvObjectDetector()
-{
-}
-
-/*
- * Release the current detector and load new detector from file
- * (if detector_file_name is not 0)
- * Return true on success:
- */
-bool CvObjectDetector::Load( const char* /*detector_file_name*/ )
-{
-    return false;
-}
-
-/* Return min detector window size: */
-CvSize CvObjectDetector::GetMinWindowSize() const
-{
-    return cvSize(0,0);
-}
-
-/* Return max border: */
-int CvObjectDetector::GetMaxBorderSize() const
-{
-    return 0;
-}
-
-/*
- * Detect the object on the image and push the detected
- * blobs into <detected_blob_seq> which must be the sequence of <CvDetectedBlob>s
- */
-void CvObjectDetector::Detect( const CvArr* /*img*/,
-                               /* out */ CvBlobSeq* /*detected_blob_seq*/ )
-{
-}
-
-//////////////////////////////// CvBlobTracker //////////////////////////////////////
-
-CvBlobTracker::CvBlobTracker(){SetTypeName("BlobTracker");}
-
-/* Process one blob (for multi hypothesis tracing): */
-void CvBlobTracker::ProcessBlob(int BlobIndex, CvBlob* pBlob, IplImage* /*pImg*/, IplImage* /*pImgFG*/)
-{
-    CvBlob* pB;
-    int ID = 0;
-    assert(pBlob);
-    //pBlob->ID;
-    pB = GetBlob(BlobIndex);
-    if(pB)
-        pBlob[0] = pB[0];
-    pBlob->ID = ID;
-}
-
-/* Get confidence/wieght/probability (0-1) for blob: */
-double  CvBlobTracker::GetConfidence(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/)
-{
-    return 1;
-}
-
-double CvBlobTracker::GetConfidenceList(CvBlobSeq* pBlobList, IplImage* pImg, IplImage* pImgFG)
-{
-    int     b,bN = pBlobList->GetBlobNum();
-    double  W = 1;
-    for(b=0;b<bN;++b)
-    {
-        CvBlob* pB = pBlobList->GetBlob(b);
-        int     BI = GetBlobIndexByID(pB->ID);
-        W *= GetConfidence(BI,pB,pImg,pImgFG);
-    }
-    return W;
-}
-
-void CvBlobTracker::UpdateBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* /*pImgFG*/)
-{
-}
-
-/* Update all blob models: */
-void CvBlobTracker::Update(IplImage* pImg, IplImage* pImgFG)
-{
-    int i;
-    for(i=GetBlobNum();i>0;i--)
-    {
-        CvBlob* pB=GetBlob(i-1);
-        UpdateBlob(i-1, pB, pImg, pImgFG);
-    }
-}
-
-/* Return pointer to blob by its unique ID: */
-int     CvBlobTracker::GetBlobIndexByID(int BlobID)
-{
-    int i;
-    for(i=GetBlobNum();i>0;i--)
-    {
-        CvBlob* pB=GetBlob(i-1);
-        if(CV_BLOB_ID(pB) == BlobID) return i-1;
-    }
-    return -1;
-}
-
-/* Return pointer to blob by its unique ID: */
-CvBlob* CvBlobTracker::GetBlobByID(int BlobID)
-{
-    return GetBlob(GetBlobIndexByID(BlobID));
-}
-
-/* Delete blob by its ID: */
-void    CvBlobTracker::DelBlobByID(int BlobID)
-{
-    DelBlob(GetBlobIndexByID(BlobID));
-}
-
-/* Set new parameters for specified (by index) blob: */
-void    CvBlobTracker::SetBlob(int /*BlobIndex*/, CvBlob* /*pBlob*/)
-{
-}
-
-/* Set new parameters for specified (by ID) blob: */
-void    CvBlobTracker::SetBlobByID(int BlobID, CvBlob* pBlob)
-{
-    SetBlob(GetBlobIndexByID(BlobID),pBlob);
-}
-
-/*  ===============  MULTI HYPOTHESIS INTERFACE ==================  */
-
-/* Return number of position hyposetis of currently tracked blob: */
-int     CvBlobTracker::GetBlobHypNum(int /*BlobIdx*/)
-{
-    return 1;
-}
-
-/* Return pointer to specified blob hypothesis by index blob: */
-CvBlob* CvBlobTracker::GetBlobHyp(int BlobIndex, int /*hypothesis*/)
-{
-    return GetBlob(BlobIndex);
-}
-
-/* Set new parameters for specified (by index) blob hyp
- * (can be called several times for each hyp ):
- */
-void    CvBlobTracker::SetBlobHyp(int /*BlobIndex*/, CvBlob* /*pBlob*/)
-{
-}
-
-void cvReleaseBlobTracker(CvBlobTracker**ppT )
-{
-    ppT[0]->Release();
-    ppT[0] = 0;
-}
diff --git a/modules/legacy/src/blobtrackanalysis.cpp b/modules/legacy/src/blobtrackanalysis.cpp
deleted file mode 100644 (file)
index 6416ae6..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-/*======================= FILTER LIST SHELL =====================*/
-typedef struct DefTrackAnalyser
-{
-    CvBlob                  blob;
-    CvBlobTrackAnalysisOne* pFilter;
-    int                     m_LastFrame;
-    int                     state;
-} DefTrackAnalyser;
-
-class CvBlobTrackAnalysisList : public CvBlobTrackAnalysis
-{
-protected:
-    CvBlobTrackAnalysisOne* (*m_CreateAnalysis)();
-    CvBlobSeq               m_TrackAnalyserList;
-    int                     m_Frame;
-public:
-    CvBlobTrackAnalysisList(CvBlobTrackAnalysisOne* (*create)()):m_TrackAnalyserList(sizeof(DefTrackAnalyser))
-    {
-        m_Frame = 0;
-        m_CreateAnalysis = create;
-        SetModuleName("List");
-    }
-    ~CvBlobTrackAnalysisList()
-    {
-        int i;
-        for(i=m_TrackAnalyserList.GetBlobNum(); i>0; --i)
-        {
-            DefTrackAnalyser* pF = (DefTrackAnalyser*)m_TrackAnalyserList.GetBlob(i-1);
-            pF->pFilter->Release();
-        }
-    };
-    virtual void    AddBlob(CvBlob* pBlob)
-    {
-        DefTrackAnalyser* pF = (DefTrackAnalyser*)m_TrackAnalyserList.GetBlobByID(CV_BLOB_ID(pBlob));
-        if(pF == NULL)
-        {   /* Create new filter: */
-            DefTrackAnalyser F;
-            F.state = 0;
-            F.blob = pBlob[0];
-            F.m_LastFrame = m_Frame;
-            F.pFilter = m_CreateAnalysis();
-            m_TrackAnalyserList.AddBlob((CvBlob*)&F);
-            pF = (DefTrackAnalyser*)m_TrackAnalyserList.GetBlobByID(CV_BLOB_ID(pBlob));
-        }
-
-        assert(pF);
-        pF->blob = pBlob[0];
-        pF->m_LastFrame = m_Frame;
-    };
-    virtual void    Process(IplImage* pImg, IplImage* pFG)
-    {
-        int i;
-        for(i=m_TrackAnalyserList.GetBlobNum(); i>0; --i)
-        {
-            DefTrackAnalyser* pF = (DefTrackAnalyser*)m_TrackAnalyserList.GetBlob(i-1);
-            if(pF->m_LastFrame == m_Frame)
-            {   /* Process: */
-                int ID = CV_BLOB_ID(pF);
-                pF->state = pF->pFilter->Process(&(pF->blob), pImg, pFG);
-                CV_BLOB_ID(pF) = ID;
-            }
-            else
-            {   /* Delete blob filter: */
-                pF->pFilter->Release();
-                m_TrackAnalyserList.DelBlob(i-1);
-            }
-        } /* Next blob. */
-        m_Frame++;
-    };
-    float GetState(int BlobID)
-    {
-        DefTrackAnalyser* pF = (DefTrackAnalyser*)m_TrackAnalyserList.GetBlobByID(BlobID);
-        return pF?pF->state:0.f;
-    };
-    void    Release(){delete this;};
-
-}; /* CvBlobTrackAnalysisList */
-
-CvBlobTrackAnalysis* cvCreateBlobTrackAnalysisList(CvBlobTrackAnalysisOne* (*create)())
-{
-    return (CvBlobTrackAnalysis*) new CvBlobTrackAnalysisList(create);
-}
-
-/* ======================== Analyser modules ============================= */
diff --git a/modules/legacy/src/blobtrackanalysishist.cpp b/modules/legacy/src/blobtrackanalysishist.cpp
deleted file mode 100644 (file)
index c75c954..0000000
+++ /dev/null
@@ -1,1517 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#define MAX_FV_SIZE 5
-#define BLOB_NUM    5
-
-typedef struct DefBlobFVN
-{
-    CvBlob  blob;
-    CvBlob  BlobSeq[BLOB_NUM];
-    int     state;
-    int     LastFrame;
-    int     FrameNum;
-} DefBlobFVN;
-
-class CvBlobTrackFVGenN: public CvBlobTrackFVGen
-{
-private:
-    CvBlobSeq       m_BlobList;
-    CvMemStorage*   m_pMem;
-    CvSeq*          m_pFVSeq;
-    float           m_FVMax[MAX_FV_SIZE];
-    float           m_FVMin[MAX_FV_SIZE];
-    float           m_FVVar[MAX_FV_SIZE];
-    int             m_Dim;
-    CvBlob          m_BlobSeq[BLOB_NUM];
-    int             m_Frame;
-    int             m_State;
-    int             m_LastFrame;
-    int             m_ClearFlag;
-    void Clear()
-    {
-        if(m_pMem)
-        {
-            cvClearMemStorage(m_pMem);
-            m_pFVSeq = cvCreateSeq(0,sizeof(CvSeq),sizeof(float)*(m_Dim+1), m_pMem);
-            m_ClearFlag = 1;
-        }
-    }
-public:
-    CvBlobTrackFVGenN(int dim = 2 ):m_BlobList(sizeof(DefBlobFVN))
-    {
-        int i;
-        assert(dim <= MAX_FV_SIZE);
-        m_Dim = dim;
-        for(i=0; i<m_Dim; ++i)
-        {
-            m_FVVar[i] = 0.01f;
-            m_FVMax[i] = 1;
-            m_FVMin[i] = 0;
-        }
-        m_Frame = 0;
-        m_State = 0;
-        m_pMem = cvCreateMemStorage();
-        m_pFVSeq = NULL;
-        Clear();
-
-        switch(dim) {
-        case 2: SetModuleName("P"); break;
-        case 4: SetModuleName("PV"); break;
-        case 5: SetModuleName("PVS"); break;
-        }
-    };
-
-    ~CvBlobTrackFVGenN()
-    {
-        if(m_pMem)cvReleaseMemStorage(&m_pMem);
-    };
-
-    void AddBlob(CvBlob* pBlob)
-    {
-        float       FV[MAX_FV_SIZE+1];
-        DefBlobFVN* pFVBlob = (DefBlobFVN*)m_BlobList.GetBlobByID(CV_BLOB_ID(pBlob));
-
-        if(!m_ClearFlag) Clear();
-
-        if(pFVBlob==NULL)
-        {
-            DefBlobFVN BlobNew;
-            BlobNew.blob = pBlob[0];
-            BlobNew.LastFrame = m_Frame;
-            BlobNew.state = 0;;
-            BlobNew.FrameNum = 0;
-            m_BlobList.AddBlob((CvBlob*)&BlobNew);
-            pFVBlob = (DefBlobFVN*)m_BlobList.GetBlobByID(CV_BLOB_ID(pBlob));
-        } /* Add new record if necessary. */
-
-        pFVBlob->blob = pBlob[0];
-
-        /* Shift: */
-        for(int i=(BLOB_NUM-1); i>0; --i)
-        {
-            pFVBlob->BlobSeq[i] = pFVBlob->BlobSeq[i-1];
-        }
-
-        pFVBlob->BlobSeq[0] = pBlob[0];
-
-        if(m_Dim>0)
-        {   /* Calculate FV position: */
-            FV[0] = CV_BLOB_X(pBlob);
-            FV[1] = CV_BLOB_Y(pBlob);
-        }
-
-        if(m_Dim<=2)
-        {   /* Add new FV if position is enough: */
-            *(int*)(FV+m_Dim) = CV_BLOB_ID(pBlob);
-            cvSeqPush( m_pFVSeq, FV );
-        }
-        else if(pFVBlob->FrameNum > BLOB_NUM)
-        {   /* Calculate velocity for more complex FV: */
-            float       AverVx = 0;
-            float       AverVy = 0;
-            {   /* Average velocity: */
-                CvBlob* pBlobSeq = pFVBlob->BlobSeq;
-                for(int i=1;i<BLOB_NUM;++i)
-                {
-                    AverVx += CV_BLOB_X(pBlobSeq+i-1)-CV_BLOB_X(pBlobSeq+i);
-                    AverVy += CV_BLOB_Y(pBlobSeq+i-1)-CV_BLOB_Y(pBlobSeq+i);
-                }
-                AverVx /= BLOB_NUM-1;
-                AverVy /= BLOB_NUM-1;
-
-                FV[2] = AverVx;
-                FV[3] = AverVy;
-            }
-
-            if(m_Dim>4)
-            {   /* State duration: */
-                float T = (CV_BLOB_WX(pBlob)+CV_BLOB_WY(pBlob))*0.01f;
-
-                if( fabs(AverVx) < T && fabs(AverVy) < T)
-                    pFVBlob->state++;
-                else
-                    pFVBlob->state=0;
-                FV[4] = (float)pFVBlob->state;
-            } /* State duration. */
-
-            /* Add new FV: */
-            *(int*)(FV+m_Dim) = CV_BLOB_ID(pBlob);
-            cvSeqPush( m_pFVSeq, FV );
-
-        } /* If velocity is calculated. */
-
-        pFVBlob->FrameNum++;
-        pFVBlob->LastFrame = m_Frame;
-    };  /* AddBlob */
-
-    void Process(IplImage* pImg, IplImage* /*pFG*/)
-    {
-        int i;
-        if(!m_ClearFlag) Clear();
-        for(i=m_BlobList.GetBlobNum(); i>0; --i)
-        {   /* Delete unused blob: */
-            DefBlobFVN* pFVBlob = (DefBlobFVN*)m_BlobList.GetBlob(i-1);
-            if(pFVBlob->LastFrame < m_Frame)
-            {
-                m_BlobList.DelBlob(i-1);
-            }
-        } /* Check next blob in list. */
-
-        m_FVMin[0] = 0;
-        m_FVMin[1] = 0;
-        m_FVMax[0] = (float)(pImg->width-1);
-        m_FVMax[1] = (float)(pImg->height-1);
-        m_FVVar[0] = m_FVMax[0]*0.01f;
-        m_FVVar[1] = m_FVMax[1]*0.01f;
-        m_FVVar[2] = (float)(pImg->width-1)/1440.0f;
-        m_FVMax[2] = (float)(pImg->width-1)*0.02f;
-        m_FVMin[2] = -m_FVMax[2];
-        m_FVVar[3] = (float)(pImg->width-1)/1440.0f;
-        m_FVMax[3] = (float)(pImg->height-1)*0.02f;
-        m_FVMin[3] = -m_FVMax[3];
-        m_FVMax[4] = 25*32.0f; /* max state is 32 sec */
-        m_FVMin[4] = 0;
-        m_FVVar[4] = 10;
-
-        m_Frame++;
-        m_ClearFlag = 0;
-    };
-    virtual void    Release(){delete this;};
-    virtual int     GetFVSize(){return m_Dim;};
-    virtual int     GetFVNum()
-    {
-        return m_pFVSeq->total;
-    };
-
-    virtual float*  GetFV(int index, int* pFVID)
-    {
-        float* pFV = (float*)cvGetSeqElem( m_pFVSeq, index );
-        if(pFVID)pFVID[0] = *(int*)(pFV+m_Dim);
-        return pFV;
-    };
-    virtual float*  GetFVMin(){return m_FVMin;}; /* returned pointer to array of minimal values of FV, if return 0 then FVrange is not exist */
-    virtual float*  GetFVMax(){return m_FVMax;}; /* returned pointer to array of maximal values of FV, if return 0 then FVrange is not exist */
-    virtual float*  GetFVVar(){return m_FVVar;}; /* returned pointer to array of maximal values of FV, if return 0 then FVrange is not exist */
-};/* CvBlobTrackFVGenN */
-
-inline CvBlobTrackFVGen* cvCreateFVGenP(){return (CvBlobTrackFVGen*)new CvBlobTrackFVGenN(2);}
-inline CvBlobTrackFVGen* cvCreateFVGenPV(){return (CvBlobTrackFVGen*)new CvBlobTrackFVGenN(4);}
-inline CvBlobTrackFVGen* cvCreateFVGenPVS(){return (CvBlobTrackFVGen*)new CvBlobTrackFVGenN(5);}
-#undef MAX_FV_SIZE
-
-#define MAX_FV_SIZE 4
-class CvBlobTrackFVGenSS: public CvBlobTrackFVGen
-{
-private:
-    CvBlobSeq       m_BlobList;
-    CvMemStorage*   m_pMem;
-    CvSeq*          m_pFVSeq;
-    float           m_FVMax[MAX_FV_SIZE];
-    float           m_FVMin[MAX_FV_SIZE];
-    float           m_FVVar[MAX_FV_SIZE];
-    int             m_Dim;
-    CvBlob          m_BlobSeq[BLOB_NUM];
-    int             m_Frame;
-    int             m_State;
-    int             m_LastFrame;
-    int             m_ClearFlag;
-    void Clear()
-    {
-        cvClearMemStorage(m_pMem);
-        m_pFVSeq = cvCreateSeq(0,sizeof(CvSeq),sizeof(float)*(m_Dim+1), m_pMem);
-        m_ClearFlag = 1;
-    }
-public:
-    CvBlobTrackFVGenSS(int dim = 2 ):m_BlobList(sizeof(DefBlobFVN))
-    {
-        int i;
-        assert(dim <= MAX_FV_SIZE);
-        m_Dim = dim;
-        for(i=0;i<m_Dim;++i)
-        {
-            m_FVVar[i] = 0.01f;
-            m_FVMax[i] = 1;
-            m_FVMin[i] = 0;
-        }
-        m_Frame = 0;
-        m_State = 0;
-        m_pMem = cvCreateMemStorage();
-        m_pFVSeq = NULL;
-
-        SetModuleName("SS");
-    };
-    ~CvBlobTrackFVGenSS()
-    {
-        if(m_pMem)cvReleaseMemStorage(&m_pMem);
-    };
-
-    void AddBlob(CvBlob* pBlob)
-    {
-        //float       FV[MAX_FV_SIZE+1];
-        DefBlobFVN* pFVBlob = (DefBlobFVN*)m_BlobList.GetBlobByID(CV_BLOB_ID(pBlob));
-
-        if(!m_ClearFlag) Clear();
-
-        if(pFVBlob==NULL)
-        {
-            DefBlobFVN BlobNew;
-            BlobNew.blob = pBlob[0];
-            BlobNew.LastFrame = m_Frame;
-            BlobNew.state = 0;;
-            BlobNew.FrameNum = 0;
-            m_BlobList.AddBlob((CvBlob*)&BlobNew);
-            pFVBlob = (DefBlobFVN*)m_BlobList.GetBlobByID(CV_BLOB_ID(pBlob));
-        } /* Add new record if necessary. */
-
-        /* Shift: */
-        for(int i=(BLOB_NUM-1); i>0; --i)
-        {
-            pFVBlob->BlobSeq[i] = pFVBlob->BlobSeq[i-1];
-        }
-
-        pFVBlob->BlobSeq[0] = pBlob[0];
-
-        if(pFVBlob->FrameNum > BLOB_NUM)
-        {   /* Average velocity: */
-            CvBlob* pBlobSeq = pFVBlob->BlobSeq;
-            float   T = (CV_BLOB_WX(pBlob)+CV_BLOB_WY(pBlob))*0.01f;
-            float   AverVx = 0;
-            float   AverVy = 0;
-            for(int i=1; i<BLOB_NUM; ++i)
-            {
-                AverVx += CV_BLOB_X(pBlobSeq+i-1)-CV_BLOB_X(pBlobSeq+i);
-                AverVy += CV_BLOB_Y(pBlobSeq+i-1)-CV_BLOB_Y(pBlobSeq+i);
-            }
-            AverVx /= BLOB_NUM-1;
-            AverVy /= BLOB_NUM-1;
-
-            if( fabs(AverVx) < T && fabs(AverVy) < T)
-                pFVBlob->state++;
-            else
-                pFVBlob->state=0;
-        }
-
-        if(pFVBlob->state == 5)
-        {   /* Object is stopped:  */
-            float   FV[MAX_FV_SIZE];
-            FV[0] = pFVBlob->blob.x;
-            FV[1] = pFVBlob->blob.y;
-            FV[2] = pFVBlob->BlobSeq[0].x;
-            FV[3] = pFVBlob->BlobSeq[0].y;
-            *(int*)(FV+m_Dim) = CV_BLOB_ID(pBlob);
-            cvSeqPush( m_pFVSeq, FV );
-        } /* Object is stopped. */
-
-        pFVBlob->FrameNum++;
-        pFVBlob->LastFrame = m_Frame;
-    };  /* AddBlob */
-    void Process(IplImage* pImg, IplImage* /*pFG*/)
-    {
-        int i;
-
-        if(!m_ClearFlag) Clear();
-
-        for(i=m_BlobList.GetBlobNum();i>0;--i)
-        {   /* Delete unused blob: */
-            DefBlobFVN* pFVBlob = (DefBlobFVN*)m_BlobList.GetBlob(i-1);
-            if(pFVBlob->LastFrame < m_Frame)
-            {
-                float   FV[MAX_FV_SIZE+1];
-                FV[0] = pFVBlob->blob.x;
-                FV[1] = pFVBlob->blob.y;
-                FV[2] = pFVBlob->BlobSeq[0].x;
-                FV[3] = pFVBlob->BlobSeq[0].y;
-                *(int*)(FV+m_Dim) = CV_BLOB_ID(pFVBlob);
-                cvSeqPush( m_pFVSeq, FV );
-                m_BlobList.DelBlob(i-1);
-            }
-        } /* Check next blob in list. */
-
-        /* Set max min range: */
-        m_FVMin[0] = 0;
-        m_FVMin[1] = 0;
-        m_FVMin[2] = 0;
-        m_FVMin[3] = 0;
-        m_FVMax[0] = (float)(pImg->width-1);
-        m_FVMax[1] = (float)(pImg->height-1);
-        m_FVMax[2] = (float)(pImg->width-1);
-        m_FVMax[3] = (float)(pImg->height-1);
-        m_FVVar[0] = m_FVMax[0]*0.01f;
-        m_FVVar[1] = m_FVMax[1]*0.01f;
-        m_FVVar[2] = m_FVMax[2]*0.01f;
-        m_FVVar[3] = m_FVMax[3]*0.01f;
-
-        m_Frame++;
-        m_ClearFlag = 0;
-    };
-    virtual void    Release(){delete this;};
-    virtual int     GetFVSize(){return m_Dim;};
-    virtual int     GetFVNum()
-    {
-        return m_pFVSeq->total;
-    };
-
-    virtual float*  GetFV(int index, int* pFVID)
-    {
-        float* pFV = (float*)cvGetSeqElem( m_pFVSeq, index );
-        if(pFVID)pFVID[0] = *(int*)(pFV+m_Dim);
-        return pFV;
-    };
-
-    virtual float*  GetFVMin(){return m_FVMin;}; /* returned pointer to array of minimal values of FV, if return 0 then FVrange is not exist */
-    virtual float*  GetFVMax(){return m_FVMax;}; /* returned pointer to array of maximal values of FV, if return 0 then FVrange is not exist */
-    virtual float*  GetFVVar(){return m_FVVar;}; /* returned pointer to array of maximal values of FV, if return 0 then FVrange is not exist */
-};/* CvBlobTrackFVGenSS */
-
-inline CvBlobTrackFVGen* cvCreateFVGenSS(){return (CvBlobTrackFVGen*)new CvBlobTrackFVGenSS;}
-
-/*======================= TRAJECTORY ANALYZER MODULES =====================*/
-/* Trajectory Analyser module */
-#define SPARSE  0
-#define ND      1
-#define BYSIZE  -1
-class DefMat
-{
-private:
-    CvSparseMatIterator m_SparseIterator;
-    CvSparseNode*       m_pSparseNode;
-    int*                m_IDXs;
-    int                 m_Dim;
-
-public:
-    CvSparseMat*        m_pSparse;
-    CvMatND*            m_pND;
-    int                 m_Volume;
-    int                 m_Max;
-    DefMat(int dim = 0, int* sizes = NULL, int type = SPARSE)
-    {
-        /* Create sparse or ND matrix but not both: */
-        m_pSparseNode = NULL;
-        m_pSparse = NULL;
-        m_pND = NULL;
-        m_Volume = 0;
-        m_Max = 0;
-        m_IDXs = NULL;
-        m_Dim = 0;
-        if(dim>0 && sizes != 0)
-            Realloc(dim, sizes, type);
-    }
-    ~DefMat()
-    {
-        if(m_pSparse)cvReleaseSparseMat(&m_pSparse);
-        if(m_pND)cvReleaseMatND(&m_pND);
-        if(m_IDXs) cvFree(&m_IDXs);
-    }
-
-    void Realloc(int dim, int* sizes, int type = SPARSE)
-    {
-        if(m_pSparse)cvReleaseSparseMat(&m_pSparse);
-        if(m_pND)cvReleaseMatND(&m_pND);
-
-        if(type == BYSIZE )
-        {
-            int size = 0;
-            int i;
-            for(size=1,i=0;i<dim;++i)
-            {
-                size *= sizes[i];
-            }
-            size *= sizeof(int);
-            if(size > (2<<20))
-            { /* if size > 1M */
-                type = SPARSE;
-            }
-            else
-            {
-                type = ND;
-            }
-        } /* Define matrix type. */
-
-        if(type == SPARSE)
-        {
-            m_pSparse = cvCreateSparseMat( dim, sizes, CV_32SC1 );
-            m_Dim = dim;
-        }
-        if(type == ND )
-        {
-            m_pND = cvCreateMatND( dim, sizes, CV_32SC1 );
-            cvZero(m_pND);
-            m_IDXs = (int*)cvAlloc(sizeof(int)*dim);
-            m_Dim = dim;
-        }
-        m_Volume = 0;
-        m_Max = 0;
-    }
-    void Save(const char* File)
-    {
-        if(m_pSparse)cvSave(File, m_pSparse );
-        if(m_pND)cvSave(File, m_pND );
-    }
-    void Save(CvFileStorage* fs, const char* name)
-    {
-        if(m_pSparse)
-        {
-            cvWrite(fs, name, m_pSparse );
-        }
-        else if(m_pND)
-        {
-            cvWrite(fs, name, m_pND );
-        }
-    }
-    void Load(const char* File)
-    {
-        CvFileStorage* fs = cvOpenFileStorage( File, NULL, CV_STORAGE_READ );
-        if(fs)
-        {
-            void* ptr;
-            if(m_pSparse) cvReleaseSparseMat(&m_pSparse);
-            if(m_pND) cvReleaseMatND(&m_pND);
-            m_Volume = 0;
-            m_Max = 0;
-            ptr = cvLoad(File);
-            if(ptr && CV_IS_MATND_HDR(ptr)) m_pND = (CvMatND*)ptr;
-            if(ptr && CV_IS_SPARSE_MAT_HDR(ptr)) m_pSparse = (CvSparseMat*)ptr;
-            cvReleaseFileStorage(&fs);
-        }
-        AfterLoad();
-    } /* Load. */
-
-    void Load(CvFileStorage* fs, CvFileNode* node, const char* name)
-    {
-        CvFileNode* n = cvGetFileNodeByName(fs,node,name);
-        void* ptr = n?cvRead(fs,n):NULL;
-        if(ptr)
-        {
-            if(m_pSparse) cvReleaseSparseMat(&m_pSparse);
-            if(m_pND) cvReleaseMatND(&m_pND);
-            m_Volume = 0;
-            m_Max = 0;
-            if(CV_IS_MATND_HDR(ptr)) m_pND = (CvMatND*)ptr;
-            if(CV_IS_SPARSE_MAT_HDR(ptr)) m_pSparse = (CvSparseMat*)ptr;
-        }
-        else
-        {
-            printf("WARNING!!! Can't load %s matrix\n",name);
-        }
-        AfterLoad();
-    } /* Load. */
-
-    void AfterLoad()
-    {
-        m_Volume = 0;
-        m_Max = 0;
-        if(m_pSparse)
-        {   /* Calculate Volume of loaded hist: */
-            CvSparseMatIterator mat_iterator;
-            CvSparseNode* node = cvInitSparseMatIterator( m_pSparse, &mat_iterator );
-
-            for( ; node != 0; node = cvGetNextSparseNode( &mat_iterator ))
-            {
-                int val = *(int*)CV_NODE_VAL( m_pSparse, node ); /* get value of the element
-                                                                (assume that the type is CV_32SC1) */
-                m_Volume += val;
-                if(m_Max < val)m_Max = val;
-            }
-        } /* Calculate Volume of loaded hist. */
-
-        if(m_pND)
-        {   /* Calculate Volume of loaded hist: */
-            CvMat   mat;
-            double  max_val;
-            double  vol;
-            cvGetMat( m_pND, &mat, NULL, 1 );
-
-            vol = cvSum(&mat).val[0];
-            m_Volume = cvRound(vol);
-            cvMinMaxLoc( &mat, NULL, &max_val);
-            m_Max = cvRound(max_val);
-            /* MUST BE WRITTEN LATER */
-        } /* Calculate Volume of loaded hist. */
-    } /* AfterLoad. */
-
-    int* GetPtr(int* indx)
-    {
-        if(m_pSparse) return (int*)cvPtrND( m_pSparse, indx, NULL, 1, NULL);
-        if(m_pND) return  (int*)cvPtrND( m_pND, indx, NULL, 1, NULL);
-        return NULL;
-    } /* GetPtr. */
-
-    int GetVal(int* indx)
-    {
-        int* p = GetPtr(indx);
-        if(p)return p[0];
-        return -1;
-    } /* GetVal. */
-
-    int Add(int* indx, int val)
-    {
-        int  NewVal;
-        int* pVal = GetPtr(indx);
-        if(pVal == NULL) return -1;
-        pVal[0] += val;
-        NewVal = pVal[0];
-        m_Volume += val;
-        if(m_Max < NewVal)m_Max = NewVal;
-        return NewVal;
-    } /* Add. */
-
-    void Add(DefMat* pMatAdd)
-    {
-        int*    pIDXS = NULL;
-        int     Val = 0;
-        for(Val = pMatAdd->GetNext(&pIDXS, 1 );pIDXS;Val=pMatAdd->GetNext(&pIDXS, 0 ))
-        {
-            Add(pIDXS,Val);
-        }
-    } /* Add. */
-
-    int SetMax(int* indx, int val)
-    {
-        int  NewVal;
-        int* pVal = GetPtr(indx);
-        if(pVal == NULL) return -1;
-        if(val > pVal[0])
-        {
-            m_Volume += val-pVal[0];
-            pVal[0] = val;
-        }
-        NewVal = pVal[0];
-        if(m_Max < NewVal)m_Max = NewVal;
-        return NewVal;
-    } /* Add. */
-
-    int GetNext(int** pIDXS, int init = 0)
-    {
-        int     Val = 0;
-        pIDXS[0] = NULL;
-        if(m_pSparse)
-        {
-            m_pSparseNode = (init || m_pSparseNode==NULL)?
-                    cvInitSparseMatIterator( m_pSparse, &m_SparseIterator ):
-                        cvGetNextSparseNode( &m_SparseIterator );
-
-                    if(m_pSparseNode)
-                    {
-                        int* pVal = (int*)CV_NODE_VAL( m_pSparse, m_pSparseNode );
-                        if(pVal)Val = pVal[0];
-                        pIDXS[0] = CV_NODE_IDX( m_pSparse, m_pSparseNode );
-                    }
-        }/* Sparse matrix. */
-
-        if(m_pND)
-        {
-            int i;
-            if(init)
-            {
-                for(i=0;i<m_Dim;++i)
-                {
-                    m_IDXs[i] = cvGetDimSize( m_pND, i )-1;
-                }
-                pIDXS[0] = m_IDXs;
-                Val = GetVal(m_IDXs);
-            }
-            else
-            {
-                for(i=0;i<m_Dim;++i)
-                {
-                    if((m_IDXs[i]--)>0)
-                        break;
-                    m_IDXs[i] = cvGetDimSize( m_pND, i )-1;
-                }
-                if(i==m_Dim)
-                {
-                    pIDXS[0] = NULL;
-                }
-                else
-                {
-                    pIDXS[0] = m_IDXs;
-                    Val = GetVal(m_IDXs);
-                }
-
-            } /* Get next ND. */
-
-        } /* Sparse matrix. */
-
-        return Val;
-
-    }; /* GetNext. */
-};
-
-#define FV_NUM 10
-#define FV_SIZE 10
-typedef struct DefTrackFG
-{
-    CvBlob                  blob;
-    //    CvBlobTrackFVGen*       pFVGen;
-    int                     LastFrame;
-    float                   state;
-    DefMat*                 pHist;
-} DefTrackFG;
-class CvBlobTrackAnalysisHist : public CvBlobTrackAnalysis
-{
-    /*---------------- Internal functions: --------------------*/
-private:
-    int                 m_BinNumParam;
-    int                 m_SmoothRadius;
-    const char*         m_SmoothKernel;
-    float               m_AbnormalThreshold;
-    int                 m_TrackNum;
-    int                 m_Frame;
-    int                 m_BinNum;
-    char                m_DataFileName[1024];
-    int                 m_Dim;
-    int*                m_Sizes;
-    DefMat              m_HistMat;
-    int                 m_HistVolumeSaved;
-    int*                m_pFVi;
-    int*                m_pFViVar;
-    int*                m_pFViVarRes;
-    CvBlobSeq           m_TrackFGList;
-    //CvBlobTrackFVGen*   (*m_CreateFVGen)();
-    CvBlobTrackFVGen*   m_pFVGen;
-    void SaveHist()
-    {
-        if(m_DataFileName[0])
-        {
-            m_HistMat.Save(m_DataFileName);
-            m_HistVolumeSaved = m_HistMat.m_Volume;
-        }
-    };
-    void LoadHist()
-    {
-        if(m_DataFileName[0])m_HistMat.Load(m_DataFileName);
-        m_HistVolumeSaved = m_HistMat.m_Volume;
-    }
-    void AllocData()
-    {   /* AllocData: */
-        m_pFVi = (int*)cvAlloc(sizeof(int)*m_Dim);
-        m_pFViVar = (int*)cvAlloc(sizeof(int)*m_Dim);
-        m_pFViVarRes = (int*)cvAlloc(sizeof(int)*m_Dim);
-        m_Sizes = (int*)cvAlloc(sizeof(int)*m_Dim);
-
-        {   /* Create init sparse matrix: */
-            int     i;
-            for(i=0;i<m_Dim;++i)m_Sizes[i] = m_BinNum;
-            m_HistMat.Realloc(m_Dim,m_Sizes,SPARSE);
-            m_HistVolumeSaved = 0;
-        } /* Create init sparse matrix. */
-    } /* AllocData. */
-
-    void FreeData()
-    {   /* FreeData. */
-        int i;
-        for(i=m_TrackFGList.GetBlobNum();i>0;--i)
-        {
-            //DefTrackFG* pF = (DefTrackFG*)m_TrackFGList.GetBlob(i-1);
-            //            pF->pFVGen->Release();
-            m_TrackFGList.DelBlob(i-1);
-        }
-        cvFree(&m_pFVi);
-        cvFree(&m_pFViVar);
-        cvFree(&m_pFViVarRes);
-        cvFree(&m_Sizes);
-    } /* FreeData. */
-
-    virtual void ParamUpdate()
-    {
-        if(m_BinNum != m_BinNumParam)
-        {
-            FreeData();
-            m_BinNum = m_BinNumParam;
-            AllocData();
-        }
-    }
-public:
-    CvBlobTrackAnalysisHist(CvBlobTrackFVGen*   (*createFVGen)()):m_TrackFGList(sizeof(DefTrackFG))
-    {
-        m_pFVGen = createFVGen();
-        m_Dim = m_pFVGen->GetFVSize();
-        m_Frame = 0;
-        m_pFVi = 0;
-        m_TrackNum = 0;
-        m_BinNum = 32;
-        m_DataFileName[0] = 0;
-
-        m_AbnormalThreshold = 0.02f;
-        AddParam("AbnormalThreshold",&m_AbnormalThreshold);
-        CommentParam("AbnormalThreshold","If trajectory histogram value is lesst then <AbnormalThreshold*DataBaseTrackNum> then trajectory is abnormal");
-
-        m_SmoothRadius = 1;
-        AddParam("SmoothRadius",&m_SmoothRadius);
-        CommentParam("AbnormalThreshold","Radius (in bins) for histogram smoothing");
-
-        m_SmoothKernel = "L";
-        AddParam("SmoothKernel",&m_SmoothKernel);
-        CommentParam("SmoothKernel","L - Linear, G - Gaussian");
-
-
-        m_BinNumParam = m_BinNum;
-        AddParam("BinNum",&m_BinNumParam);
-        CommentParam("BinNum","Number of bin for each dimention of feature vector");
-
-        AllocData();
-        SetModuleName("Hist");
-
-    } /* Constructor. */
-
-    ~CvBlobTrackAnalysisHist()
-    {
-        SaveHist();
-        FreeData();
-        m_pFVGen->Release();
-    } /* Destructor. */
-
-    /*----------------- Interface: --------------------*/
-    virtual void    AddBlob(CvBlob* pBlob)
-    {
-        DefTrackFG* pF = (DefTrackFG*)m_TrackFGList.GetBlobByID(CV_BLOB_ID(pBlob));
-        if(pF == NULL)
-        { /* create new filter */
-            DefTrackFG F;
-            F.state = 0;
-            F.blob = pBlob[0];
-            F.LastFrame = m_Frame;
-            //            F.pFVGen = m_CreateFVGen();
-            F.pHist = new DefMat(m_Dim,m_Sizes,SPARSE);
-            m_TrackFGList.AddBlob((CvBlob*)&F);
-            pF = (DefTrackFG*)m_TrackFGList.GetBlobByID(CV_BLOB_ID(pBlob));
-        }
-
-        assert(pF);
-        pF->blob = pBlob[0];
-        pF->LastFrame = m_Frame;
-        m_pFVGen->AddBlob(pBlob);
-    };
-    virtual void Process(IplImage* pImg, IplImage* pFG)
-    {
-        m_pFVGen->Process(pImg, pFG);
-        int SK = m_SmoothKernel[0];
-
-        for(int i=0; i<m_pFVGen->GetFVNum(); ++i)
-        {
-            int         BlobID = 0;
-            float*      pFV = m_pFVGen->GetFV(i,&BlobID);
-            float*      pFVMax = m_pFVGen->GetFVMax();
-            float*      pFVMin = m_pFVGen->GetFVMin();
-            DefTrackFG* pF = (DefTrackFG*)m_TrackFGList.GetBlobByID(BlobID);
-            int         HistVal = 1;
-
-            if(pFV==NULL) break;
-
-            pF->LastFrame = m_Frame;
-
-            {   /* Binarize FV: */
-                int         j;
-            for(j=0; j<m_Dim; ++j)
-            {
-                int     index;
-                float   f0 = pFVMin?pFVMin[j]:0;
-                float   f1 = pFVMax?pFVMax[j]:1;
-                assert(f1>f0);
-                index = cvRound((m_BinNum-1)*(pFV[j]-f0)/(f1-f0));
-                if(index<0)index=0;
-                if(index>=m_BinNum)index=m_BinNum-1;
-                m_pFVi[j] = index;
-            }
-            }
-
-            HistVal = m_HistMat.GetVal(m_pFVi);/* get bin value*/
-            pF->state = 0;
-            {   /* Calculate state: */
-                float   T = m_HistMat.m_Max*m_AbnormalThreshold; /* calc threshold */
-
-                if(m_TrackNum>0) T = 256.0f * m_TrackNum*m_AbnormalThreshold;
-                if(T>0)
-                {
-                    pF->state = (T - HistVal)/(T*0.2f) + 0.5f;
-                }
-                if(pF->state<0)pF->state=0;
-                if(pF->state>1)pF->state=1;
-            }
-
-            {   /* If it is a new FV then add it to trajectory histogram: */
-                int flag = 1;
-                int r = m_SmoothRadius;
-
-                //                    printf("BLob %3d NEW FV [", CV_BLOB_ID(pF));
-                //                    for(i=0;i<m_Dim;++i) printf("%d,", m_pFVi[i]);
-                //                    printf("]");
-
-                for(int k=0; k<m_Dim; ++k)
-                {
-                    m_pFViVar[k]=-r;
-                }
-
-                while(flag)
-                {
-                    float   dist = 0;
-                    int     HistAdd = 0;
-                    int     good = 1;
-                    for(int k=0; k<m_Dim; ++k)
-                    {
-                        m_pFViVarRes[k] = m_pFVi[k]+m_pFViVar[k];
-                        if(m_pFViVarRes[k]<0) good= 0;
-                        if(m_pFViVarRes[k]>=m_BinNum) good= 0;
-                        dist += m_pFViVar[k]*m_pFViVar[k];
-                    }/* Calculate next dimension. */
-
-                    if(SK=='G' || SK=='g')
-                    {
-                        double dist2 = dist/(r*r);
-                        HistAdd = cvRound(256*exp(-dist2)); /* Hist Add for (dist=1) = 25.6*/
-                    }
-                    else if(SK=='L' || SK=='l')
-                    {
-                        dist = (float)(sqrt(dist)/(r+1));
-                        HistAdd = cvRound(256*(1-dist));
-                    }
-                    else
-                    {
-                        HistAdd = 255; /* Flat smoothing. */
-                    }
-
-                    if(good && HistAdd>0)
-                    {   /* Update histogram: */
-                        assert(pF->pHist);
-                        pF->pHist->SetMax(m_pFViVarRes, HistAdd);
-                    }   /* Update histogram. */
-
-                    int idx = 0;
-                    for( ; idx<m_Dim; ++idx)
-                    {   /* Next config: */
-                        if((m_pFViVar[idx]++) < r)
-                            break;
-                        m_pFViVar[idx] = -r;
-                    }   /* Increase next dimension variable. */
-                    if(idx==m_Dim)break;
-                }   /* Next variation. */
-            } /* If new FV. */
-        } /* Next FV. */
-
-        {   /* Check all blobs on list: */
-            int i;
-            for(i=m_TrackFGList.GetBlobNum(); i>0; --i)
-            {   /* Add histogram and delete blob from list: */
-                DefTrackFG* pF = (DefTrackFG*)m_TrackFGList.GetBlob(i-1);
-                if(pF->LastFrame+3 < m_Frame && pF->pHist)
-                {
-                    m_HistMat.Add(pF->pHist);
-                    delete pF->pHist;
-                    m_TrackNum++;
-                    m_TrackFGList.DelBlob(i-1);
-                }
-            }/* next blob */
-        }
-
-        m_Frame++;
-
-        if(m_Wnd)
-        {   /* Debug output: */
-            int*        idxs = NULL;
-            int         Val = 0;
-            IplImage*   pI = cvCloneImage(pImg);
-
-            cvZero(pI);
-
-            for(Val = m_HistMat.GetNext(&idxs,1); idxs; Val=m_HistMat.GetNext(&idxs,0))
-            {   /* Draw all elements: */
-                if(!idxs) break;
-                if(Val == 0) continue;
-
-                float vf = (float)Val/(m_HistMat.m_Max?m_HistMat.m_Max:1);
-                int x = cvRound((float)(pI->width-1)*(float)idxs[0] / (float)m_BinNum);
-                int y = cvRound((float)(pI->height-1)*(float)idxs[1] / (float)m_BinNum);
-
-                cvCircle(pI, cvPoint(x,y), cvRound(vf*pI->height/(m_BinNum*2)),CV_RGB(255,0,0),CV_FILLED);
-                if(m_Dim > 3)
-                {
-                    int dx = -2*(idxs[2]-m_BinNum/2);
-                    int dy = -2*(idxs[3]-m_BinNum/2);
-                    cvLine(pI,cvPoint(x,y),cvPoint(x+dx,y+dy),CV_RGB(0,cvRound(vf*255),1));
-                }
-                if( m_Dim==4 &&
-                        m_pFVGen->GetFVMax()[0]==m_pFVGen->GetFVMax()[2] &&
-                        m_pFVGen->GetFVMax()[1]==m_pFVGen->GetFVMax()[3])
-                {
-                    int x1 = cvRound((float)(pI->width-1)*(float)idxs[2] / (float)m_BinNum);
-                    int y1 = cvRound((float)(pI->height-1)*(float)idxs[3] / (float)m_BinNum);
-                    cvCircle(pI, cvPoint(x1,y1), cvRound(vf*pI->height/(m_BinNum*2)),CV_RGB(0,0,255),CV_FILLED);
-                }
-            } /* Draw all elements. */
-
-            for(int i=m_TrackFGList.GetBlobNum();i>0;--i)
-            {
-                DefTrackFG* pF = (DefTrackFG*)m_TrackFGList.GetBlob(i-1);
-                DefMat* pHist = pF?pF->pHist:NULL;
-
-                if(pHist==NULL) continue;
-
-                for(Val = pHist->GetNext(&idxs,1);idxs;Val=pHist->GetNext(&idxs,0))
-                {   /* Draw all elements: */
-                    float   vf;
-                int     x,y;
-
-                if(!idxs) break;
-                if(Val == 0) continue;
-
-                vf = (float)Val/(pHist->m_Max?pHist->m_Max:1);
-                x = cvRound((float)(pI->width-1)*(float)idxs[0] / (float)m_BinNum);
-                y = cvRound((float)(pI->height-1)*(float)idxs[1] / (float)m_BinNum);
-
-                cvCircle(pI, cvPoint(x,y), cvRound(2*vf),CV_RGB(0,0,cvRound(255*vf)),CV_FILLED);
-                if(m_Dim > 3)
-                {
-                    int dx = -2*(idxs[2]-m_BinNum/2);
-                    int dy = -2*(idxs[3]-m_BinNum/2);
-                    cvLine(pI,cvPoint(x,y),cvPoint(x+dx,y+dy),CV_RGB(0,0,255));
-                }
-                if( m_Dim==4 &&
-                        m_pFVGen->GetFVMax()[0]==m_pFVGen->GetFVMax()[2] &&
-                        m_pFVGen->GetFVMax()[1]==m_pFVGen->GetFVMax()[3])
-                { /* if SS feature vector */
-                    int x1 = cvRound((float)(pI->width-1)*(float)idxs[2] / (float)m_BinNum);
-                    int y1 = cvRound((float)(pI->height-1)*(float)idxs[3] / (float)m_BinNum);
-                    cvCircle(pI, cvPoint(x1,y1), cvRound(vf*pI->height/(m_BinNum*2)),CV_RGB(0,0,255),CV_FILLED);
-                }
-                } /* Draw all elements. */
-            } /* Next track. */
-
-            //cvNamedWindow("Hist",0);
-            //cvShowImage("Hist", pI);
-            cvReleaseImage(&pI);
-        }
-    };
-
-    float GetState(int BlobID)
-    {
-        DefTrackFG* pF = (DefTrackFG*)m_TrackFGList.GetBlobByID(BlobID);
-        return pF?pF->state:0.0f;
-    };
-
-    /* Return 0 if trajectory is normal;
-       rreturn >0 if trajectory abnormal. */
-    virtual const char*   GetStateDesc(int BlobID)
-    {
-        if(GetState(BlobID)>0.5) return "abnormal";
-        return NULL;
-    }
-
-    virtual void    SetFileName(char* DataBaseName)
-    {
-        if(m_HistMat.m_Volume!=m_HistVolumeSaved)SaveHist();
-        m_DataFileName[0] = m_DataFileName[1000] = 0;
-
-        if(DataBaseName)
-        {
-            strncpy(m_DataFileName,DataBaseName,1000);
-            strcat(m_DataFileName, ".yml");
-        }
-        LoadHist();
-    };
-
-    virtual void SaveState(CvFileStorage* fs)
-    {
-        int b, bN = m_TrackFGList.GetBlobNum();
-        cvWriteInt(fs,"BlobNum",bN);
-        cvStartWriteStruct(fs,"BlobList",CV_NODE_SEQ);
-
-        for(b=0; b<bN; ++b)
-        {
-            DefTrackFG* pF = (DefTrackFG*)m_TrackFGList.GetBlob(b);
-            cvStartWriteStruct(fs,NULL,CV_NODE_MAP);
-            cvWriteStruct(fs,"Blob", &(pF->blob), "ffffi");
-            cvWriteInt(fs,"LastFrame",pF->LastFrame);
-            cvWriteReal(fs,"State",pF->state);
-            pF->pHist->Save(fs, "Hist");
-            cvEndWriteStruct(fs);
-        }
-        cvEndWriteStruct(fs);
-        m_HistMat.Save(fs, "Hist");
-    };
-
-    virtual void LoadState(CvFileStorage* fs, CvFileNode* node)
-    {
-        CvFileNode* pBLN = cvGetFileNodeByName(fs,node,"BlobList");
-
-        if(pBLN && CV_NODE_IS_SEQ(pBLN->tag))
-        {
-            int b, bN = pBLN->data.seq->total;
-            for(b=0; b<bN; ++b)
-            {
-                DefTrackFG* pF = NULL;
-                CvBlob      Blob;
-                CvFileNode* pBN = (CvFileNode*)cvGetSeqElem(pBLN->data.seq,b);
-
-                assert(pBN);
-                cvReadStructByName(fs, pBN, "Blob", &Blob, "ffffi");
-                AddBlob(&Blob);
-                pF = (DefTrackFG*)m_TrackFGList.GetBlobByID(Blob.ID);
-                if(pF==NULL) continue;
-                assert(pF);
-                pF->state = (float)cvReadIntByName(fs,pBN,"State",cvRound(pF->state));
-                assert(pF->pHist);
-                pF->pHist->Load(fs,pBN,"Hist");
-            }
-        }
-
-        m_HistMat.Load(fs, node, "Hist");
-    }; /* LoadState */
-
-
-    virtual void    Release(){ delete this; };
-
-};
-
-
-
-CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistP()
-{return (CvBlobTrackAnalysis*) new CvBlobTrackAnalysisHist(cvCreateFVGenP);}
-
-CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistPV()
-{return (CvBlobTrackAnalysis*) new CvBlobTrackAnalysisHist(cvCreateFVGenPV);}
-
-CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistPVS()
-{return (CvBlobTrackAnalysis*) new CvBlobTrackAnalysisHist(cvCreateFVGenPVS);}
-
-CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisHistSS()
-{return (CvBlobTrackAnalysis*) new CvBlobTrackAnalysisHist(cvCreateFVGenSS);}
-
-typedef struct DefTrackSVM
-{
-    CvBlob                  blob;
-    //    CvBlobTrackFVGen*       pFVGen;
-    int                     LastFrame;
-    float                   state;
-    CvBlob                  BlobLast;
-    CvSeq*                  pFVSeq;
-    CvMemStorage*           pMem;
-} DefTrackSVM;
-
-class CvBlobTrackAnalysisSVM : public CvBlobTrackAnalysis
-{
-    /*---------------- Internal functions: --------------------*/
-private:
-    CvMemStorage*       m_pMem;
-    int                 m_TrackNum;
-    int                 m_Frame;
-    char                m_DataFileName[1024];
-    int                 m_Dim;
-    float*              m_pFV;
-    //CvStatModel*        m_pStatModel;
-    void*               m_pStatModel;
-    CvBlobSeq           m_Tracks;
-    CvMat*              m_pTrainData;
-    int                 m_LastTrainDataSize;
-    //    CvBlobTrackFVGen*   (*m_CreateFVGen)();
-    CvBlobTrackFVGen*   m_pFVGen;
-    float               m_NU;
-    float               m_RBFWidth;
-    IplImage*           m_pStatImg; /* for debug purpose */
-    CvSize              m_ImgSize;
-    void RetrainStatModel()
-    {
-        ///////// !!!!! TODO !!!!! Repair /////////////
-#if 0
-        float               nu = 0;
-        CvSVMModelParams    SVMParams = {0};
-        CvStatModel*        pM = NULL;
-
-
-        memset(&SVMParams,0,sizeof(SVMParams));
-        SVMParams.svm_type = CV_SVM_ONE_CLASS;
-        SVMParams.kernel_type = CV_SVM_RBF;
-        SVMParams.gamma = 2.0/(m_RBFWidth*m_RBFWidth);
-        SVMParams.nu = m_NU;
-        SVMParams.degree = 3;
-        SVMParams.criteria = cvTermCriteria(CV_TERMCRIT_EPS, 100, 1e-3 );
-        SVMParams.C = 1;
-        SVMParams.p = 0.1;
-
-
-        if(m_pTrainData == NULL) return;
-        {
-            int64       TickCount = cvGetTickCount();
-            printf("Frame: %d\n           Retrain SVM\nData Size = %d\n",m_Frame, m_pTrainData->rows);
-            pM = cvTrainSVM( m_pTrainData,CV_ROW_SAMPLE, NULL, (CvStatModelParams*)&SVMParams, NULL, NULL);
-            TickCount = cvGetTickCount() - TickCount ;
-            printf("SV Count = %d\n",((CvSVMModel*)pM)->sv_total);
-            printf("Processing Time = %.1f(ms)\n",TickCount/(1000*cvGetTickFrequency()));
-
-        }
-        if(pM==NULL) return;
-        if(m_pStatModel) cvReleaseStatModel(&m_pStatModel);
-        m_pStatModel = pM;
-
-        if(m_pTrainData && m_Wnd)
-        {
-            float       MaxVal = 0;
-            IplImage*   pW = cvCreateImage(m_ImgSize,IPL_DEPTH_32F,1);
-            IplImage*   pI = cvCreateImage(m_ImgSize,IPL_DEPTH_8U,1);
-            float*      pFVVar = m_pFVGen->GetFVVar();
-            int     i;
-            cvZero(pW);
-
-            for(i=0; i<m_pTrainData->rows; ++i)
-            {   /* Draw all elements: */
-                float*          pFV = (float*)(m_pTrainData->data.ptr + m_pTrainData->step*i);
-                int             x = cvRound(pFV[0]*pFVVar[0]);
-                int             y = cvRound(pFV[1]*pFVVar[1]);
-                float           r;
-
-                if(x<0)x=0;
-                if(x>=pW->width)x=pW->width-1;
-                if(y<0)y=0;
-                if(y>=pW->height)y=pW->height-1;
-
-                r = ((float*)(pW->imageData + y*pW->widthStep))[x];
-                r++;
-                ((float*)(pW->imageData + y*pW->widthStep))[x] = r;
-
-                if(r>MaxVal)MaxVal=r;
-            } /* Next point. */
-
-            if(MaxVal>0)cvConvertScale(pW,pI,255/MaxVal,0);
-            cvNamedWindow("SVMData",0);
-            cvShowImage("SVMData",pI);
-            cvSaveImage("SVMData.bmp",pI);
-            cvReleaseImage(&pW);
-            cvReleaseImage(&pI);
-        } /* Prepare for debug. */
-
-        if(m_pStatModel && m_Wnd && m_Dim == 2)
-        {
-            float*      pFVVar = m_pFVGen->GetFVVar();
-            int x,y;
-            if(m_pStatImg==NULL)
-            {
-                m_pStatImg = cvCreateImage(m_ImgSize,IPL_DEPTH_8U,1);
-            }
-            cvZero(m_pStatImg);
-
-            for(y=0; y<m_pStatImg->height; y+=1) for(x=0; x<m_pStatImg->width; x+=1)
-            {   /* Draw all elements: */
-                float           res;
-            uchar*  pData = (uchar*)m_pStatImg->imageData + x + y*m_pStatImg->widthStep;
-            CvMat           FVmat;
-            float           xy[2] = {x/pFVVar[0],y/pFVVar[1]};
-            cvInitMatHeader( &FVmat, 1, 2, CV_32F, xy );
-            res = cvStatModelPredict( m_pStatModel, &FVmat, NULL );
-            pData[0]=((res>0.5)?255:0);
-            } /* Next point. */
-
-            cvNamedWindow("SVMMask",0);
-            cvShowImage("SVMMask",m_pStatImg);
-            cvSaveImage("SVMMask.bmp",m_pStatImg);
-        } /* Prepare for debug. */
-#endif
-    };
-    void SaveStatModel()
-    {
-        if(m_DataFileName[0])
-        {
-            if(m_pTrainData)cvSave(m_DataFileName, m_pTrainData);
-        }
-    };
-    void LoadStatModel()
-    {
-        if(m_DataFileName[0])
-        {
-            CvMat* pTrainData = (CvMat*)cvLoad(m_DataFileName);
-            if(CV_IS_MAT(pTrainData) && pTrainData->width == m_Dim)
-            {
-                if(m_pTrainData) cvReleaseMat(&m_pTrainData);
-                m_pTrainData = pTrainData;
-                RetrainStatModel();
-            }
-        }
-    }
-public:
-    CvBlobTrackAnalysisSVM(CvBlobTrackFVGen*   (*createFVGen)()):m_Tracks(sizeof(DefTrackSVM))
-    {
-        m_pFVGen = createFVGen();
-        m_Dim = m_pFVGen->GetFVSize();
-        m_pFV = (float*)cvAlloc(sizeof(float)*m_Dim);
-        m_Frame = 0;
-        m_TrackNum = 0;
-        m_pTrainData = NULL;
-        m_pStatModel = NULL;
-        m_DataFileName[0] = 0;
-        m_pStatImg = NULL;
-        m_LastTrainDataSize = 0;
-
-        m_NU = 0.2f;
-        AddParam("Nu",&m_NU);
-        CommentParam("Nu","Parameters that tunes SVM border elastic");
-
-        m_RBFWidth = 1;
-        AddParam("RBFWidth",&m_RBFWidth);
-        CommentParam("RBFWidth","Parameters that tunes RBF kernel function width.");
-
-        SetModuleName("SVM");
-
-    } /* Constructor. */
-
-    ~CvBlobTrackAnalysisSVM()
-    {
-        int i;
-        SaveStatModel();
-        for(i=m_Tracks.GetBlobNum();i>0;--i)
-        {
-            DefTrackSVM* pF = (DefTrackSVM*)m_Tracks.GetBlob(i-1);
-            if(pF->pMem) cvReleaseMemStorage(&pF->pMem);
-            //pF->pFVGen->Release();
-        }
-        if(m_pStatImg)cvReleaseImage(&m_pStatImg);
-        cvFree(&m_pFV);
-    } /* Destructor. */
-
-    /*----------------- Interface: --------------------*/
-    virtual void    AddBlob(CvBlob* pBlob)
-    {
-        DefTrackSVM* pF = (DefTrackSVM*)m_Tracks.GetBlobByID(CV_BLOB_ID(pBlob));
-
-        m_pFVGen->AddBlob(pBlob);
-
-        if(pF == NULL)
-        {   /* Create new record: */
-            DefTrackSVM F;
-            F.state = 0;
-            F.blob = pBlob[0];
-            F.LastFrame = m_Frame;
-            //F.pFVGen = m_CreateFVGen();
-            F.pMem = cvCreateMemStorage();
-            F.pFVSeq = cvCreateSeq(0,sizeof(CvSeq),sizeof(float)*m_Dim,F.pMem);
-
-            F.BlobLast.x = -1;
-            F.BlobLast.y = -1;
-            F.BlobLast.w = -1;
-            F.BlobLast.h = -1;
-            m_Tracks.AddBlob((CvBlob*)&F);
-            pF = (DefTrackSVM*)m_Tracks.GetBlobByID(CV_BLOB_ID(pBlob));
-        }
-
-        assert(pF);
-        pF->blob = pBlob[0];
-        pF->LastFrame = m_Frame;
-    };
-
-    virtual void Process(IplImage* pImg, IplImage* pFG)
-    {
-        int     i;
-        float*  pFVVar = m_pFVGen->GetFVVar();
-
-        m_pFVGen->Process(pImg, pFG);
-        m_ImgSize = cvSize(pImg->width,pImg->height);
-
-        for(i=m_pFVGen->GetFVNum(); i>0; --i)
-        {
-            int             BlobID = 0;
-            float*          pFV = m_pFVGen->GetFV(i,&BlobID);
-            DefTrackSVM*    pF = (DefTrackSVM*)m_Tracks.GetBlobByID(BlobID);
-
-            if(pF && pFV)
-            {   /* Process: */
-                float   dx,dy;
-            CvMat   FVmat;
-
-            pF->state = 0;
-
-            if(m_pStatModel)
-            {
-                int j;
-                for(j=0; j<m_Dim; ++j)
-                {
-                    m_pFV[j] = pFV[j]/pFVVar[j];
-                }
-
-                cvInitMatHeader( &FVmat, 1, m_Dim, CV_32F, m_pFV );
-                //pF->state = cvStatModelPredict( m_pStatModel, &FVmat, NULL )<0.5;
-                pF->state = 1.f;
-            }
-
-            dx = (pF->blob.x - pF->BlobLast.x);
-            dy = (pF->blob.y - pF->BlobLast.y);
-
-            if(pF->BlobLast.x<0 || (dx*dx+dy*dy) >= 2*2)
-            {   /* Add feature vector to train data base: */
-                pF->BlobLast = pF->blob;
-                cvSeqPush(pF->pFVSeq,pFV);
-            }
-            } /* Process one blob. */
-        } /* Next FV. */
-
-        for(i=m_Tracks.GetBlobNum(); i>0; --i)
-        {   /* Check each blob record: */
-            DefTrackSVM* pF = (DefTrackSVM*)m_Tracks.GetBlob(i-1);
-
-            if(pF->LastFrame+3 < m_Frame )
-            {   /* Retrain stat model and delete blob filter: */
-                int                 mult = 1+m_Dim;
-                int                 old_height = m_pTrainData?m_pTrainData->height:0;
-                int                 height = old_height + pF->pFVSeq->total*mult;
-                CvMat*              pTrainData = cvCreateMat(height, m_Dim, CV_32F);
-                int                 j;
-                if(m_pTrainData && pTrainData)
-                {   /* Create new train data matrix: */
-                    int h = pTrainData->height;
-                    pTrainData->height = MIN(pTrainData->height, m_pTrainData->height);
-                    cvCopy(m_pTrainData,pTrainData);
-                    pTrainData->height = h;
-                }
-
-                for(j=0; j<pF->pFVSeq->total; ++j)
-                {   /* Copy new data to train data: */
-                    float*  pFVvar = m_pFVGen->GetFVVar();
-                    float*  pFV = (float*)cvGetSeqElem(pF->pFVSeq,j);
-                    int     k;
-
-                    for(k=0; k<mult; ++k)
-                    {
-                        int t;
-                        float*  pTD = (float*)CV_MAT_ELEM_PTR( pTrainData[0], old_height+j*mult+k, 0);
-                        memcpy(pTD,pFV,sizeof(float)*m_Dim);
-
-                        if(pFVvar)for(t=0;t<m_Dim;++t)
-                        {   /* Scale FV: */
-                            pTD[t] /= pFVvar[t];
-                        }
-
-                        if(k>0)
-                        {   /* Variate: */
-                            for(t=0; t<m_Dim; ++t)
-                            {
-                                pTD[t] += m_RBFWidth*0.5f*(1-2.0f*rand()/(float)RAND_MAX);
-                            }
-                        }
-                    }
-                } /* Next new datum. */
-
-                if(m_pTrainData) cvReleaseMat(&m_pTrainData);
-                m_pTrainData = pTrainData;
-
-                /* delete track record */
-                cvReleaseMemStorage(&pF->pMem);
-                m_TrackNum++;
-                m_Tracks.DelBlob(i-1);
-
-            } /* End delete. */
-        } /* Next track. */
-
-        /* Retrain data each 1 minute if new data exist: */
-        if(m_Frame%(25*60) == 0 && m_pTrainData && m_pTrainData->rows > m_LastTrainDataSize)
-        {
-            RetrainStatModel();
-        }
-
-        m_Frame++;
-
-        if(m_Wnd && m_Dim==2)
-        {   /* Debug output: */
-            int         x,y;
-            IplImage*   pI = cvCloneImage(pImg);
-
-            if(m_pStatModel && m_pStatImg)
-
-                for(y=0; y<pI->height; y+=2)
-                {
-                    uchar*  pStatData = (uchar*)m_pStatImg->imageData + y*m_pStatImg->widthStep;
-                    uchar*  pData = (uchar*)pI->imageData + y*pI->widthStep;
-
-                    for(x=0;x<pI->width;x+=2)
-                    {   /* Draw all elements: */
-                        int d = pStatData[x];
-                        d = (d<<8) | (d^0xff);
-                        *(ushort*)(pData + x*3) = (ushort)d;
-                    }
-                } /* Next line. */
-
-            //cvNamedWindow("SVMMap",0);
-            //cvShowImage("SVMMap", pI);
-            cvReleaseImage(&pI);
-        } /* Debug output. */
-    };
-    float GetState(int BlobID)
-    {
-        DefTrackSVM* pF = (DefTrackSVM*)m_Tracks.GetBlobByID(BlobID);
-        return pF?pF->state:0.0f;
-    };
-
-    /* Return 0 if trajectory is normal;
-       return >0 if trajectory abnormal. */
-    virtual const char*   GetStateDesc(int BlobID)
-    {
-        if(GetState(BlobID)>0.5) return "abnormal";
-        return NULL;
-    }
-
-    virtual void    SetFileName(char* DataBaseName)
-    {
-        if(m_pTrainData)SaveStatModel();
-        m_DataFileName[0] = m_DataFileName[1000] = 0;
-        if(DataBaseName)
-        {
-            strncpy(m_DataFileName,DataBaseName,1000);
-            strcat(m_DataFileName, ".yml");
-        }
-        LoadStatModel();
-    };
-
-
-    virtual void    Release(){ delete this; };
-
-}; /* CvBlobTrackAnalysisSVM. */
-
-#if 0
-CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMP()
-{return (CvBlobTrackAnalysis*) new CvBlobTrackAnalysisSVM(cvCreateFVGenP);}
-
-CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMPV()
-{return (CvBlobTrackAnalysis*) new CvBlobTrackAnalysisSVM(cvCreateFVGenPV);}
-
-CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMPVS()
-{return (CvBlobTrackAnalysis*) new CvBlobTrackAnalysisSVM(cvCreateFVGenPVS);}
-
-CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisSVMSS()
-{return (CvBlobTrackAnalysis*) new CvBlobTrackAnalysisSVM(cvCreateFVGenSS);}
-#endif
diff --git a/modules/legacy/src/blobtrackanalysisior.cpp b/modules/legacy/src/blobtrackanalysisior.cpp
deleted file mode 100644 (file)
index c5b2222..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-/*======================= FILTER LIST SHELL =====================*/
-#define MAX_ANS 16
-#define MAX_DESC 1024
-class CvBlobTrackAnalysisIOR : public CvBlobTrackAnalysis
-{
-protected:
-    struct  DefAn
-    {
-        const char*                   pName;
-        CvBlobTrackAnalysis*    pAn;
-    } m_Ans[MAX_ANS];
-    int m_AnNum;
-    char m_Desc[MAX_DESC];
-
-public:
-    CvBlobTrackAnalysisIOR()
-    {
-        m_AnNum = 0;
-        SetModuleName("IOR");
-    }
-
-    ~CvBlobTrackAnalysisIOR()
-    {
-    };
-
-    virtual void    AddBlob(CvBlob* pBlob)
-    {
-        int i;
-        for(i=0; i<m_AnNum; ++i)
-        {
-            m_Ans[i].pAn->AddBlob(pBlob);
-        } /* Next analyzer. */
-    };
-
-    virtual void    Process(IplImage* pImg, IplImage* pFG)
-    {
-        int i;
-#ifdef _OPENMP
-#pragma omp parallel for
-#endif
-        for(i=0; i<m_AnNum; ++i)
-        {
-            m_Ans[i].pAn->Process(pImg, pFG);
-        } /* Next analyzer. */
-    };
-
-    float GetState(int BlobID)
-    {
-        int state = 0;
-        int i;
-        for(i=0; i<m_AnNum; ++i)
-        {
-            state |= (m_Ans[i].pAn->GetState(BlobID) > 0.5);
-        } /* Next analyzer. */
-
-        return (float)state;
-    };
-
-    virtual const char*   GetStateDesc(int BlobID)
-    {
-        int     rest = MAX_DESC-1;
-        int     i;
-        m_Desc[0] = 0;
-
-        for(i=0; i<m_AnNum; ++i)
-        {
-            const char* str = m_Ans[i].pAn->GetStateDesc(BlobID);
-
-            if(str && strlen(m_Ans[i].pName) + strlen(str)+4 < (size_t)rest)
-            {
-                strcat(m_Desc,m_Ans[i].pName);
-                strcat(m_Desc,": ");
-                strcat(m_Desc,str);
-                strcat(m_Desc,"\n");
-                rest = MAX_DESC - (int)strlen(m_Desc) - 1;
-            }
-        } /* Next analyzer. */
-
-        if(m_Desc[0]!=0)return m_Desc;
-
-        return NULL;
-    };
-
-    virtual void SetFileName(char* /*DataBaseName*/)
-    {
-    };
-
-    int AddAnalyzer(CvBlobTrackAnalysis* pA, const char* pName)
-    {
-        if(m_AnNum<MAX_ANS)
-        {
-            //int i;
-            m_Ans[m_AnNum].pName = pName;
-            m_Ans[m_AnNum].pAn = pA;
-            TransferParamsFromChild(m_Ans[m_AnNum].pAn, pName);
-            m_AnNum++;
-            return 1;
-        }
-        else
-        {
-            printf("Can not add track analyzer %s! (not more that %d analyzers)\n",pName,MAX_ANS);
-            return 0;
-        }
-    }
-    void    Release()
-    {
-        int i;
-        for(i=0; i<m_AnNum; ++i)
-        {
-            m_Ans[i].pAn->Release();
-        } /* Next analyzer. */
-
-        delete this;
-    };
-}; /* CvBlobTrackAnalysisIOR. */
-
-CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisIOR()
-{
-    CvBlobTrackAnalysisIOR* pIOR = new CvBlobTrackAnalysisIOR();
-    CvBlobTrackAnalysis* pA = NULL;
-
-    pA = cvCreateModuleBlobTrackAnalysisHistPVS();
-    pIOR->AddAnalyzer(pA, "HIST");
-
-    //pA = (CvBlobTrackAnalysis*)cvCreateModuleBlobTrackAnalysisHeightScale();
-    //pIOR->AddAnalyzer(pA, "SCALE");
-
-    return (CvBlobTrackAnalysis*)pIOR;
-}/* cvCreateCvBlobTrackAnalysisIOR */
-/* ======================== Analyser modules ============================= */
diff --git a/modules/legacy/src/blobtrackanalysistrackdist.cpp b/modules/legacy/src/blobtrackanalysistrackdist.cpp
deleted file mode 100644 (file)
index 2adba7e..0000000
+++ /dev/null
@@ -1,580 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-typedef struct DefTrackPoint
-{
-    float x,y,r,vx,vy,v;
-} DefTrackPoint;
-
-class DefTrackRec
-{
-private:
-    int     ID;
-public:
-    DefTrackRec(int id = 0,int BlobSize = sizeof(DefTrackPoint))
-    {
-        ID = id;
-        m_pMem = cvCreateMemStorage();
-        m_pSeq = cvCreateSeq(0,sizeof(CvSeq),BlobSize,m_pMem);
-    }
-    ~DefTrackRec()
-    {
-        cvReleaseMemStorage(&m_pMem);
-    };
-    inline DefTrackPoint* GetPoint(int PointIndex)
-    {
-        return (DefTrackPoint*)cvGetSeqElem(m_pSeq,PointIndex);
-    };
-    inline void DelPoint(int PointIndex)
-    {
-        cvSeqRemove(m_pSeq,PointIndex);
-    };
-    inline void Clear()
-    {
-        cvClearSeq(m_pSeq);
-    };
-    inline void AddPoint(float x, float y, float r)
-    {
-        DefTrackPoint   p = {x,y,r,0,0,0};
-        int             Num = GetPointNum();
-
-        if(Num > 0)
-        {
-            DefTrackPoint* pPrev = GetPoint(Num-1);
-            float   Alpha = 0.8f;
-            float  dx = x-pPrev->x;
-            float  dy = y-pPrev->y;
-            p.vx = Alpha*dx+(1-Alpha)*pPrev->vx;
-            p.vy = Alpha*dy+(1-Alpha)*pPrev->vy;
-            p.v  = Alpha*dx+(1-Alpha)*pPrev->v;
-        }
-        AddPoint(&p);
-    }
-
-    inline void AddPoint(DefTrackPoint* pB)
-    {   /* Add point and recalculate last velocities: */
-        int     wnd=3;
-        int     Num;
-        int     i;
-        cvSeqPush(m_pSeq,pB);
-
-        Num = GetPointNum();
-
-        for(i=MAX(0,Num-wnd-1); i<Num; ++i)
-        {   /* Next updating point: */
-            DefTrackPoint*  p = GetPoint(i);
-            int             j0 = i - wnd;
-            int             j1 = i + wnd;
-
-            if(j0<0) j0 = 0;
-            if(j1>=Num)j1=Num-1;
-
-            if(j1>j0)
-            {
-                float           dt = (float)(j1-j0);
-                DefTrackPoint*  p0 = GetPoint(j0);
-                DefTrackPoint*  p1 = GetPoint(j1);
-                p->vx = (p1->x - p0->x) / dt;
-                p->vy = (p1->y - p0->y) / dt;
-                p->v = (float)sqrt(p->vx*p->vx+p->vy*p->vy);
-            }
-        } /* Next updating point. */
-
-#if 0
-        if(0)
-        {   /* Debug: */
-            int i;
-            printf("Blob %d: ",ID);
-
-            for(i=0; i<GetPointNum(); ++i)
-            {
-                DefTrackPoint*  p = GetPoint(i);
-                printf(",(%.2f,%.2f,%f.2)",p->vx,p->vy,p->v);
-            }
-            printf("\n");
-        }
-#endif
-    };
-    inline int GetPointNum()
-    {
-        return m_pSeq->total;
-    };
-private:
-    CvMemStorage*   m_pMem;
-    CvSeq*          m_pSeq;
-};
-
-/* Fill array pIdxPairs by pair of index of correspondent blobs. */
-/* Return number of pairs.                                       */
-/* pIdxPairs must have size not less that 2*(pSeqNum+pSeqTNum)   */
-/* pTmp is pointer to memory which size is pSeqNum*pSeqTNum*16   */
-typedef struct DefMatch
-{
-    int     Idx;  /* Previous best blob index.          */
-    int     IdxT; /* Previous best template blob index. */
-    double  D;    /* Blob to blob distance sum.         */
-} DefMatch;
-
-static int cvTrackMatch(DefTrackRec* pSeq, int MaxLen, DefTrackRec* pSeqT, int* pIdxPairs, void* pTmp)
-{
-    int         NumPair = 0;
-    DefMatch*   pMT = (DefMatch*)pTmp;
-    int         Num = pSeq->GetPointNum();
-    int         NumT = pSeqT->GetPointNum();
-    int         i,it;
-    int         i0=0; /* Last point in the track sequence. */
-
-    if(MaxLen > 0 && Num > MaxLen)
-    {   /* Set new point seq len and new last point in this seq: */
-        Num = MaxLen;
-        i0 = pSeq->GetPointNum() - Num;
-    }
-
-    for(i=0; i<Num; ++i)
-    {   /* For each point row: */
-        for(it=0; it<NumT; ++it)
-        {   /* For each point template column: */
-            DefTrackPoint*  pB = pSeq->GetPoint(i+i0);
-            DefTrackPoint*  pBT = pSeqT->GetPoint(it);
-            DefMatch*       pMT_cur = pMT + i*NumT + it;
-            double          dx = pB->x-pBT->x;
-            double          dy = pB->y-pBT->y;
-            double          D = dx*dx+dy*dy;
-            int             DI[3][2] = {{-1,-1},{-1,0},{0,-1}};
-            int             iDI;
-
-            pMT_cur->D = D;
-            pMT_cur->Idx = -1;
-            pMT_cur->IdxT = 0;
-
-            if(i==0) continue;
-
-            for(iDI=0; iDI<3; ++iDI)
-            {
-                int         i_prev = i+DI[iDI][0];
-                int         it_prev = it+DI[iDI][1];
-
-                if(i_prev >= 0 && it_prev>=0)
-                {
-                    double D_cur = D+pMT[NumT*i_prev+it_prev].D;
-
-                    if(pMT_cur->D > D_cur || (pMT_cur->Idx<0) )
-                    {   /* Set new best local way: */
-                        pMT_cur->D = D_cur;
-                        pMT_cur->Idx = i_prev;
-                        pMT_cur->IdxT = it_prev;
-                    }
-                }
-            } /* Check next direction. */
-        } /* Fill next colum from table. */
-    } /* Fill next row. */
-
-    {   /* Back tracking. */
-        /* Find best end in template: */
-        int         it_best = 0;
-        DefMatch*   pMT_best = pMT + (Num-1)*NumT;
-        i = Num-1; /* set current i to last position */
-
-        for(it=1; it<NumT; ++it)
-        {
-            DefMatch* pMT_new = pMT + it + i*NumT;
-
-            if(pMT_best->D > pMT_new->D)
-            {
-                pMT_best->D = pMT_new->D;
-                it_best = it;
-            }
-        } /* Find best end template point. */
-
-        /* Back tracking whole sequence: */
-        for(it = it_best;i>=0 && it>=0;)
-        {
-            DefMatch* pMT_new = pMT + it + i*NumT;
-            pIdxPairs[2*NumPair] = i+i0;
-            pIdxPairs[2*NumPair+1] = it;
-            NumPair++;
-
-            it = pMT_new->IdxT;
-            i = pMT_new->Idx;
-        }
-    } /* End back tracing. */
-
-    return NumPair;
-} /* cvTrackMatch. */
-
-typedef struct DefTrackForDist
-{
-    CvBlob                  blob;
-    DefTrackRec*            pTrack;
-    int                     LastFrame;
-    float                   state;
-    /* for debug */
-    int                     close;
-} DefTrackForDist;
-
-class CvBlobTrackAnalysisTrackDist : public CvBlobTrackAnalysis
-{
-    /*---------------- Internal functions: --------------------*/
-private:
-    const char*               m_pDebugAVIName; /* For debugging. */
-  //CvVideoWriter*      m_pDebugAVI;     /* For debugging. */
-    IplImage*           m_pDebugImg;     /* For debugging. */
-
-    char                m_DataFileName[1024];
-    CvBlobSeq           m_Tracks;
-    CvBlobSeq           m_TrackDataBase;
-    int                 m_Frame;
-    void*               m_pTempData;
-    int                 m_TempDataSize;
-    int                 m_TraceLen;
-    float               m_AbnormalThreshold;
-    float               m_PosThreshold;
-    float               m_VelThreshold;
-    inline void* ReallocTempData(int Size)
-    {
-        if(Size <= m_TempDataSize && m_pTempData) return m_pTempData;
-        cvFree(&m_pTempData);
-        m_TempDataSize = 0;
-        m_pTempData = cvAlloc(Size);
-        if(m_pTempData) m_TempDataSize = Size;
-        return m_pTempData;
-    } /* ReallocTempData. */
-
-public:
-    CvBlobTrackAnalysisTrackDist():m_Tracks(sizeof(DefTrackForDist)),m_TrackDataBase(sizeof(DefTrackForDist))
-    {
-        m_pDebugImg = 0;
-        //m_pDebugAVI = 0;
-        m_Frame = 0;
-        m_pTempData = NULL;
-        m_TempDataSize = 0;
-
-        m_pDebugAVIName = NULL;
-        AddParam("DebugAVI",&m_pDebugAVIName);
-        CommentParam("DebugAVI","Name of AVI file to save images from debug window");
-
-        m_TraceLen = 50;
-        AddParam("TraceLen",&m_TraceLen);
-        CommentParam("TraceLen","Length (in frames) of trajectory part that is used for comparison");
-
-        m_AbnormalThreshold = 0.02f;
-        AddParam("AbnormalThreshold",&m_AbnormalThreshold);
-        CommentParam("AbnormalThreshold","If trajectory is equal with less then <AbnormalThreshold*DataBaseTrackNum> tracks then trajectory is abnormal");
-
-        m_PosThreshold = 1.25;
-        AddParam("PosThreshold",&m_PosThreshold);
-        CommentParam("PosThreshold","Minimal allowd distance in blob width that is allowed");
-
-        m_VelThreshold = 0.5;
-        AddParam("VelThreshold",&m_VelThreshold);
-        CommentParam("VelThreshold","Minimal allowed relative difference between blob speed");
-
-        SetModuleName("TrackDist");
-
-    } /* Constructor. */
-
-    ~CvBlobTrackAnalysisTrackDist()
-    {
-        int i;
-        for(i=m_Tracks.GetBlobNum(); i>0; --i)
-        {
-            DefTrackForDist* pF = (DefTrackForDist*)m_Tracks.GetBlob(i-1);
-            delete pF->pTrack;
-        }
-        if(m_pDebugImg) cvReleaseImage(&m_pDebugImg);
-        //if(m_pDebugAVI) cvReleaseVideoWriter(&m_pDebugAVI);
-    } /* Destructor. */
-
-    /*----------------- Interface: --------------------*/
-    virtual void    AddBlob(CvBlob* pBlob)
-    {
-        DefTrackForDist* pF = (DefTrackForDist*)m_Tracks.GetBlobByID(CV_BLOB_ID(pBlob));
-
-        if(pF == NULL)
-        {   /* Create new TRack record: */
-            DefTrackForDist F;
-            F.state = 0;
-            F.blob = pBlob[0];
-            F.LastFrame = m_Frame;
-            F.pTrack = new DefTrackRec(CV_BLOB_ID(pBlob));
-            m_Tracks.AddBlob((CvBlob*)&F);
-            pF = (DefTrackForDist*)m_Tracks.GetBlobByID(CV_BLOB_ID(pBlob));
-        }
-
-        assert(pF);
-        assert(pF->pTrack);
-        pF->pTrack->AddPoint(pBlob->x,pBlob->y,pBlob->w*0.5f);
-        pF->blob = pBlob[0];
-        pF->LastFrame = m_Frame;
-    };
-
-    virtual void Process(IplImage* pImg, IplImage* /*pFG*/)
-    {
-        double          MinTv = pImg->width/1440.0; /* minimal threshold for speed difference */
-        double          MinTv2 = MinTv*MinTv;
-
-        for(int i=m_Tracks.GetBlobNum(); i>0; --i)
-        {
-            DefTrackForDist* pF = (DefTrackForDist*)m_Tracks.GetBlob(i-1);
-            pF->state = 0;
-
-            if(pF->LastFrame == m_Frame || pF->LastFrame+1 == m_Frame)
-            {   /* Process one blob trajectory: */
-                int NumEq = 0;
-                int it;
-
-                for(it=m_TrackDataBase.GetBlobNum(); it>0; --it)
-                {   /* Check template: */
-                    DefTrackForDist*   pFT = (DefTrackForDist*)m_TrackDataBase.GetBlob(it-1);
-                    int         Num = pF->pTrack->GetPointNum();
-                    int         NumT = pFT->pTrack->GetPointNum();
-                    int*        pPairIdx = (int*)ReallocTempData(sizeof(int)*2*(Num+NumT)+sizeof(DefMatch)*Num*NumT);
-                    void*       pTmpData = pPairIdx+2*(Num+NumT);
-                    int         PairNum = 0;
-                    int         k;
-                    int         Equal = 1;
-                    int         UseVel = 0;
-                    int         UsePos = 0;
-
-                    if(i==it) continue;
-
-                    /* Match track: */
-                    PairNum = cvTrackMatch( pF->pTrack, m_TraceLen, pFT->pTrack, pPairIdx, pTmpData );
-                    Equal = MAX(1,cvRound(PairNum*0.1));
-
-                    UseVel = 3*pF->pTrack->GetPointNum() > m_TraceLen;
-                    UsePos = 10*pF->pTrack->GetPointNum() > m_TraceLen;
-
-                    {   /* Check continues: */
-                        float   D;
-                        int     DI = pPairIdx[0*2+0]-pPairIdx[(PairNum-1)*2+0];
-                        int     DIt = pPairIdx[0*2+1]-pPairIdx[(PairNum-1)*2+1];
-                        if(UseVel && DI != 0)
-                        {
-                            D = (float)(DI-DIt)/(float)DI;
-                            if(fabs(D)>m_VelThreshold)Equal=0;
-                            if(fabs(D)>m_VelThreshold*0.5)Equal/=2;
-                        }
-                    }   /* Check continues. */
-
-                    for(k=0; Equal>0 && k<PairNum; ++k)
-                    {   /* Compare with threshold: */
-                        int             j = pPairIdx[k*2+0];
-                        int             jt = pPairIdx[k*2+1];
-                        DefTrackPoint*  pB = pF->pTrack->GetPoint(j);
-                        DefTrackPoint*  pBT = pFT->pTrack->GetPoint(jt);
-                        double          dx = pB->x-pBT->x;
-                        double          dy = pB->y-pBT->y;
-                        double          dvx = pB->vx - pBT->vx;
-                        double          dvy = pB->vy - pBT->vy;
-                      //double          dv = pB->v - pBT->v;
-                        double          D = dx*dx+dy*dy;
-                        double          Td = pBT->r*m_PosThreshold;
-                        double          dv2 = dvx*dvx+dvy*dvy;
-                        double          Tv2 = (pBT->vx*pBT->vx+pBT->vy*pBT->vy)*m_VelThreshold*m_VelThreshold;
-                        double          Tvm = pBT->v*m_VelThreshold;
-
-
-                        if(Tv2 < MinTv2) Tv2 = MinTv2;
-                        if(Tvm < MinTv) Tvm = MinTv;
-
-                        /* Check trajectory position: */
-                        if(UsePos && D > Td*Td)
-                        {
-                            Equal--;
-                        }
-                        else
-                        /* Check trajectory velocity. */
-                        /* Don't consider trajectory tail because its unstable for velocity computation. */
-                        if(UseVel && j>5 && jt>5 && dv2 > Tv2 )
-                        {
-                            Equal--;
-                        }
-                    } /* Compare with threshold. */
-
-                    if(Equal>0)
-                    {
-                        NumEq++;
-                        pFT->close++;
-                    }
-                } /* Next template. */
-
-                {   /* Calculate state: */
-                    float   T = m_TrackDataBase.GetBlobNum() * m_AbnormalThreshold; /* calc threshold */
-
-                    if(T>0)
-                    {
-                        pF->state = (T - NumEq)/(T*0.2f) + 0.5f;
-                    }
-                    if(pF->state<0)pF->state=0;
-                    if(pF->state>1)pF->state=1;
-
-                    /*if(0)if(pF->state>0)
-                    {// if abnormal blob
-                        printf("Abnormal blob(%d) %d < %f, state=%f\n",CV_BLOB_ID(pF),NumEq,T, pF->state);
-                    }*/
-                }   /* Calculate state. */
-            }   /*  Process one blob trajectory. */
-            else
-            {   /* Move track to tracks data base: */
-                m_TrackDataBase.AddBlob((CvBlob*)pF);
-                m_Tracks.DelBlob(i-1);
-            }
-        } /* Next blob. */
-
-
-        if(m_Wnd)
-        {   /* Debug output: */
-
-            if(m_pDebugImg==NULL)
-                m_pDebugImg = cvCloneImage(pImg);
-            else
-                cvCopy(pImg, m_pDebugImg);
-
-            for(int i=m_TrackDataBase.GetBlobNum(); i>0; --i)
-            {   /* Draw all elements in track data base:  */
-                int         j;
-                DefTrackForDist*   pF = (DefTrackForDist*)m_TrackDataBase.GetBlob(i-1);
-                CvScalar    color = CV_RGB(0,0,0);
-                if(!pF->close) continue;
-                if(pF->close)
-                {
-                    color = CV_RGB(0,0,255);
-                }
-                else
-                {
-                    color = CV_RGB(0,0,128);
-                }
-
-                for(j=pF->pTrack->GetPointNum(); j>0; j--)
-                {
-                    DefTrackPoint* pB = pF->pTrack->GetPoint(j-1);
-                    int r = 0;//MAX(cvRound(pB->r),1);
-                    cvCircle(m_pDebugImg, cvPoint(cvRound(pB->x),cvRound(pB->y)), r, color);
-                }
-                pF->close = 0;
-            }   /* Draw all elements in track data base. */
-
-            for(int i=m_Tracks.GetBlobNum(); i>0; --i)
-            {   /* Draw all elements for all trajectories: */
-                DefTrackForDist*    pF = (DefTrackForDist*)m_Tracks.GetBlob(i-1);
-                int                 j;
-                int                 c = cvRound(pF->state*255);
-                CvScalar            color = CV_RGB(c,255-c,0);
-                CvPoint             p = cvPointFrom32f(CV_BLOB_CENTER(pF));
-                int                 x = cvRound(CV_BLOB_RX(pF)), y = cvRound(CV_BLOB_RY(pF));
-                CvSize              s = cvSize(MAX(1,x), MAX(1,y));
-
-                cvEllipse( m_pDebugImg,
-                    p,
-                    s,
-                    0, 0, 360,
-                    CV_RGB(c,255-c,0), cvRound(1+(0*c)/255) );
-
-                for(j=pF->pTrack->GetPointNum(); j>0; j--)
-                {
-                    DefTrackPoint* pB = pF->pTrack->GetPoint(j-1);
-                    if(pF->pTrack->GetPointNum()-j > m_TraceLen) break;
-                    cvCircle(m_pDebugImg, cvPoint(cvRound(pB->x),cvRound(pB->y)), 0, color);
-                }
-                pF->close = 0;
-
-            }   /* Draw all elements for all trajectories. */
-
-            //cvNamedWindow("Tracks",0);
-            //cvShowImage("Tracks", m_pDebugImg);
-        } /* Debug output. */
-
-#if 0
-        if(m_pDebugImg && m_pDebugAVIName)
-        {
-            if(m_pDebugAVI==NULL)
-            {   /* Create avi file for writing: */
-                m_pDebugAVI = cvCreateVideoWriter(
-                    m_pDebugAVIName,
-                    CV_FOURCC('x','v','i','d'),
-                    25,
-                    cvSize(m_pDebugImg->width,m_pDebugImg->height));
-
-                if(m_pDebugAVI == NULL)
-                {
-                    printf("WARNING!!! Can not create AVI file %s for writing\n",m_pDebugAVIName);
-                }
-            }   /* Create avi file for writing. */
-
-            if(m_pDebugAVI)cvWriteFrame( m_pDebugAVI, m_pDebugImg );
-        }   /* Write debug window to AVI file. */
-#endif
-        m_Frame++;
-    };
-    float GetState(int BlobID)
-    {
-        DefTrackForDist* pF = (DefTrackForDist*)m_Tracks.GetBlobByID(BlobID);
-        return pF?pF->state:0.0f;
-    };
-
-    /* Return 0 if trajectory is normal;
-       return >0 if trajectory abnormal. */
-    virtual const char*   GetStateDesc(int BlobID)
-    {
-        if(GetState(BlobID)>0.5) return "abnormal";
-        return NULL;
-    }
-
-    virtual void    SetFileName(char* DataBaseName)
-    {
-        m_DataFileName[0] = m_DataFileName[1000] = 0;
-        if(DataBaseName)
-        {
-            strncpy(m_DataFileName,DataBaseName,1000);
-            strcat(m_DataFileName, ".yml");
-        }
-    };
-
-    virtual void    Release(){ delete this; };
-};
-
-
-
-CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisTrackDist()
-{return (CvBlobTrackAnalysis*) new CvBlobTrackAnalysisTrackDist;}
diff --git a/modules/legacy/src/blobtrackgen1.cpp b/modules/legacy/src/blobtrackgen1.cpp
deleted file mode 100644 (file)
index af9c3b3..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-typedef struct DefBlobTrack
-{
-    CvBlob      blob;
-    CvBlobSeq*  pSeq;
-    int         FrameBegin;
-    int         FrameLast;
-    int         Saved; /* flag */
-} DefBlobTrack;
-
-
-static void SaveTrack(DefBlobTrack* pTrack, char* pFileName, int norm = 0)
-{   /* Save blob track: */
-    int         j;
-    FILE*       out = NULL;
-    CvBlobSeq*  pS = pTrack->pSeq;
-    CvBlob*     pB0 = pS?pS->GetBlob(0):NULL;
-
-    if(pFileName == NULL) return;
-    if(pTrack == NULL) return;
-
-    out = fopen(pFileName,"at");
-    if(out == NULL)
-    {
-        printf("Warning! Cannot open %s file for track output\n", pFileName);
-        return;
-    }
-
-    fprintf(out,"%d",pTrack->FrameBegin);
-
-    if(pS) for(j=0; j<pS->GetBlobNum(); ++j)
-    {
-        CvBlob* pB = pS->GetBlob(j);
-
-        fprintf(out,", %.1f, %.1f", CV_BLOB_X(pB),CV_BLOB_Y(pB));
-
-        if(CV_BLOB_WX(pB0)>0)
-            fprintf(out,", %.2f",CV_BLOB_WX(pB)/(norm?CV_BLOB_WX(pB0):1));
-
-        if(CV_BLOB_WY(pB0)>0)
-            fprintf(out,", %.2f",CV_BLOB_WY(pB)/(norm?CV_BLOB_WY(pB0):1));
-    }
-    fprintf(out,"\n");
-    fclose(out);
-    pTrack->Saved = 1;
-}   /* Save blob track. */
-
-class CvBlobTrackGen1:public CvBlobTrackGen
-{
-
-public:
-    CvBlobTrackGen1(int BlobSizeNorm = 0):m_TrackList(sizeof(DefBlobTrack))
-    {
-        m_BlobSizeNorm = BlobSizeNorm;
-        m_Frame = 0;
-        m_pFileName = NULL;
-
-        SetModuleName("Gen1");
-    }
-
-    ~CvBlobTrackGen1()
-    {
-        int i;
-        for(i=m_TrackList.GetBlobNum();i>0;--i)
-        {
-            DefBlobTrack* pTrack = (DefBlobTrack*)m_TrackList.GetBlob(i-1);
-            if(!pTrack->Saved)
-            {   /* Save track: */
-                SaveTrack(pTrack, m_pFileName, m_BlobSizeNorm);
-            }   /* Save track. */
-
-            /* Delete sequence: */
-            delete pTrack->pSeq;
-
-            pTrack->pSeq = NULL;
-
-        }   /* Check next track. */
-    }   /*  Destructor. */
-
-    void    SetFileName(char* pFileName){m_pFileName = pFileName;}
-
-    void    AddBlob(CvBlob* pBlob)
-    {
-        DefBlobTrack* pTrack = (DefBlobTrack*)m_TrackList.GetBlobByID(CV_BLOB_ID(pBlob));
-
-        if(pTrack==NULL)
-        {   /* Add new track: */
-            DefBlobTrack    Track;
-            Track.blob = pBlob[0];
-            Track.FrameBegin = m_Frame;
-            Track.pSeq = new CvBlobSeq;
-            Track.Saved = 0;
-            m_TrackList.AddBlob((CvBlob*)&Track);
-            pTrack = (DefBlobTrack*)m_TrackList.GetBlobByID(CV_BLOB_ID(pBlob));
-        }   /* Add new track. */
-
-        assert(pTrack);
-        pTrack->FrameLast = m_Frame;
-        assert(pTrack->pSeq);
-        pTrack->pSeq->AddBlob(pBlob);
-    }
-
-    void    Process(IplImage* /*pImg*/ = NULL, IplImage* /*pFG*/ = NULL)
-    {
-        int i;
-
-        for(i=m_TrackList.GetBlobNum(); i>0; --i)
-        {
-            DefBlobTrack* pTrack = (DefBlobTrack*)m_TrackList.GetBlob(i-1);
-
-            if(pTrack->FrameLast < m_Frame && !pTrack->Saved)
-            {   /* Save track: */
-                SaveTrack(pTrack, m_pFileName, m_BlobSizeNorm);
-                if(pTrack->Saved)
-                {   /* delete sequence */
-                    delete pTrack->pSeq;
-                    pTrack->pSeq = NULL;
-                    m_TrackList.DelBlob(i-1);
-                }
-            }   /* Save track. */
-        }   /*  Check next track. */
-        m_Frame++;
-    }
-
-    void Release()
-    {
-        delete this;
-    }
-
-protected:
-    int         m_Frame;
-    char*       m_pFileName;
-    CvBlobSeq   m_TrackList;
-    int         m_BlobSizeNorm;
-};  /* class CvBlobTrackGen1 */
-
-
-CvBlobTrackGen* cvCreateModuleBlobTrackGen1()
-{
-    return (CvBlobTrackGen*) new CvBlobTrackGen1(0);
-}
diff --git a/modules/legacy/src/blobtrackgenyml.cpp b/modules/legacy/src/blobtrackgenyml.cpp
deleted file mode 100644 (file)
index c33d16d..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-typedef struct DefBlobTrack
-{
-    CvBlob      blob;
-    CvBlobSeq*  pSeq;
-    int         FrameBegin;
-    int         FrameLast;
-    int         Saved; /* flag */
-} DefBlobTrack;
-
-class CvBlobTrackGenYML:public CvBlobTrackGen
-{
-protected:
-    int         m_Frame;
-    char*       m_pFileName;
-    CvBlobSeq   m_TrackList;
-    CvSize      m_Size;
-
-    void SaveAll()
-    {
-        int     ObjNum = m_TrackList.GetBlobNum();
-        int     i;
-        char    video_name[1024+1];
-        char*   struct_name = NULL;
-        CvFileStorage* storage = cvOpenFileStorage(m_pFileName,NULL,CV_STORAGE_WRITE_TEXT);
-
-        if(storage==NULL)
-        {
-            printf("WARNING!!! Cannot open %s file for trajectory output.", m_pFileName);
-        }
-
-        for(i=0; i<1024 && m_pFileName[i]!='.' && m_pFileName[i]!=0; ++i) video_name[i]=m_pFileName[i];
-        video_name[i] = 0;
-
-        for(;i>0; i--)
-        {
-            if(video_name[i-1] == '\\') break;
-            if(video_name[i-1] == '/') break;
-            if(video_name[i-1] == ':') break;
-        }
-        struct_name = video_name + i;
-
-        cvStartWriteStruct(storage, struct_name, CV_NODE_SEQ);
-
-        for(i=0; i<ObjNum; ++i)
-        {
-            char            obj_name[1024];
-            DefBlobTrack*   pTrack = (DefBlobTrack*)m_TrackList.GetBlob(i);
-            if(pTrack==NULL) continue;
-            sprintf(obj_name,"%s_obj%d",struct_name,i);
-            cvStartWriteStruct(storage, NULL, CV_NODE_MAP);
-            cvWriteInt(storage, "FrameBegin", pTrack->FrameBegin);
-            cvWriteString(storage, "VideoObj", obj_name);
-            cvEndWriteStruct( storage );
-            pTrack->Saved = 1;
-        }
-        cvEndWriteStruct( storage );
-
-        for(i=0;i<ObjNum;++i)
-        {
-            char            obj_name[1024];
-            DefBlobTrack*   pTrack = (DefBlobTrack*)m_TrackList.GetBlob(i);
-            CvBlobSeq*      pSeq = pTrack->pSeq;
-            sprintf(obj_name,"%s_obj%d",struct_name,i);
-            cvStartWriteStruct(storage, obj_name, CV_NODE_MAP);
-
-            {   /* Write position: */
-                int             j;
-                CvPoint2D32f    p;
-                cvStartWriteStruct(storage, "Pos", CV_NODE_SEQ|CV_NODE_FLOW);
-                for(j=0;j<pSeq->GetBlobNum();++j)
-                {
-                    CvBlob* pB = pSeq->GetBlob(j);
-                    p.x = pB->x/(m_Size.width-1);
-                    p.y = pB->y/(m_Size.height-1);
-                    cvWriteRawData(storage, &p, 1 ,"ff");
-                }
-                cvEndWriteStruct( storage );
-            }
-
-            {   /* Write size: */
-                int             j;
-                CvPoint2D32f    p;
-                cvStartWriteStruct(storage, "Size", CV_NODE_SEQ|CV_NODE_FLOW);
-
-                for(j=0; j<pSeq->GetBlobNum(); ++j)
-                {
-                    CvBlob* pB = pSeq->GetBlob(j);
-                    p.x = pB->w/(m_Size.width-1);
-                    p.y = pB->h/(m_Size.height-1);
-                    cvWriteRawData(storage, &p, 1 ,"ff");
-                }
-                cvEndWriteStruct( storage );
-            }
-            cvEndWriteStruct( storage );
-        }
-        cvReleaseFileStorage(&storage);
-
-    }   /* Save All */
-
-public:
-    CvBlobTrackGenYML():m_TrackList(sizeof(DefBlobTrack))
-    {
-        m_Frame = 0;
-        m_pFileName = NULL;
-        m_Size = cvSize(2,2);
-
-        SetModuleName("YML");
-    }
-
-    ~CvBlobTrackGenYML()
-    {
-        int i;
-        SaveAll();
-
-        for(i=m_TrackList.GetBlobNum(); i>0; --i)
-        {
-            DefBlobTrack* pTrack = (DefBlobTrack*)m_TrackList.GetBlob(i-1);
-            /* Delete sequence: */
-            delete pTrack->pSeq;
-            pTrack->pSeq = NULL;
-        }   /* Check next track. */
-
-    }   /* Destructor. */
-
-    void    SetFileName(char* pFileName){m_pFileName = pFileName;}
-    void    AddBlob(CvBlob* pBlob)
-    {
-        DefBlobTrack* pTrack = (DefBlobTrack*)m_TrackList.GetBlobByID(CV_BLOB_ID(pBlob));
-
-        if(pTrack==NULL)
-        {   /* Add new track: */
-            DefBlobTrack    Track;
-            Track.blob = pBlob[0];
-            Track.FrameBegin = m_Frame;
-            Track.pSeq = new CvBlobSeq;
-            Track.Saved = 0;
-            m_TrackList.AddBlob((CvBlob*)&Track);
-            pTrack = (DefBlobTrack*)m_TrackList.GetBlobByID(CV_BLOB_ID(pBlob));
-        }   /* Add new track. */
-
-        assert(pTrack);
-        pTrack->FrameLast = m_Frame;
-        assert(pTrack->pSeq);
-        pTrack->pSeq->AddBlob(pBlob);
-    }
-    void    Process(IplImage* pImg = NULL, IplImage* /*pFG*/ = NULL)
-    {
-        int i;
-        m_Size = cvSize(pImg->width,pImg->height);
-
-        for(i=m_TrackList.GetBlobNum(); i>0; --i)
-        {
-            DefBlobTrack* pTrack = (DefBlobTrack*)m_TrackList.GetBlob(i-1);
-
-            if(pTrack->FrameLast < m_Frame && !pTrack->Saved)
-            {   /* Save track: */
-                SaveAll();
-            }   /* Save track. */
-
-        }   /* Check next track. */
-
-        m_Frame++;
-    }
-
-    void Release()
-    {
-        delete this;
-    }
-};  /* class CvBlobTrackGenYML */
-
-
-CvBlobTrackGen* cvCreateModuleBlobTrackGenYML()
-{
-    return (CvBlobTrackGen*) new CvBlobTrackGenYML;
-}
diff --git a/modules/legacy/src/blobtrackingauto.cpp b/modules/legacy/src/blobtrackingauto.cpp
deleted file mode 100644 (file)
index 1fd6953..0000000
+++ /dev/null
@@ -1,481 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
-This file contain simple implementation of BlobTrackerAuto virtual interface
-This module just connected other low level 3 modules
-(foreground estimator + BlobDetector + BlobTracker)
-and some simple code to detect "lost tracking"
-The track is lost when integral of foreground mask image by blob area has low value
-*/
-#include "precomp.hpp"
-#include <time.h>
-
-/* list of Blob Detection modules */
-CvBlobDetector* cvCreateBlobDetectorSimple();
-
-/* Get frequency for each module time working estimation: */
-static double FREQ = 1000*cvGetTickFrequency();
-
-#if 1
-#define COUNTNUM 100
-#define TIME_BEGIN() \
-{\
-    static double   _TimeSum = 0;\
-    static int      _Count = 0;\
-    static int      _CountBlob = 0;\
-    int64           _TickCount = cvGetTickCount();\
-
-#define TIME_END(_name_,_BlobNum_)    \
-    _Count++;\
-    _CountBlob+=_BlobNum_;\
-    _TimeSum += (cvGetTickCount()-_TickCount)/FREQ;\
-    if(m_TimesFile)if(_Count%COUNTNUM==0)\
-    { \
-        FILE* out = fopen(m_TimesFile,"at");\
-        if(out)\
-        {\
-            fprintf(out,"ForFrame Frame: %d %s %f on %f blobs\n",_Count,_name_, _TimeSum/COUNTNUM,((float)_CountBlob)/COUNTNUM);\
-            if(_CountBlob>0)fprintf(out,"ForBlob  Frame: %d %s - %f\n",_Count,_name_, _TimeSum/_CountBlob);\
-            fclose(out);\
-        }\
-        _TimeSum = 0;\
-        _CountBlob = 0;\
-    }\
-}
-#else
-#define TIME_BEGIN()
-#define TIME_END(_name_)
-#endif
-
-/* Special extended blob structure for auto blob tracking: */
-typedef struct CvBlobTrackAuto
-{
-    CvBlob  blob;
-    int     BadFrames;
-} CvBlobTrackAuto;
-
-class CvBlobTrackerAuto1: public CvBlobTrackerAuto
-{
-public:
-    CvBlobTrackerAuto1(CvBlobTrackerAutoParam1* param);
-    ~CvBlobTrackerAuto1();
-    CvBlob* GetBlob(int index){return m_BlobList.GetBlob(index);}
-    CvBlob* GetBlobByID(int ID){return m_BlobList.GetBlobByID(ID);}
-    int     GetBlobNum(){return m_BlobList.GetBlobNum();}
-    virtual IplImage* GetFGMask(){return m_pFGMask;}
-    float   GetState(int BlobID){return m_pBTA?m_pBTA->GetState(BlobID):0;}
-    const char*   GetStateDesc(int BlobID){return m_pBTA?m_pBTA->GetStateDesc(BlobID):NULL;}
-    /* Return 0 if trajectory is normal;
-       return >0 if trajectory abnormal. */
-    void Process(IplImage* pImg, IplImage* pMask = NULL);
-    void Release(){delete this;}
-
-private:
-    IplImage*               m_pFGMask;
-    int                     m_FGTrainFrames;
-    CvFGDetector*           m_pFG; /* Pointer to foreground mask detector module. */
-    CvBlobTracker*          m_pBT; /* Pointer to Blob tracker module. */
-    int                     m_BTDel;
-    int                     m_BTReal;
-    CvBlobDetector*         m_pBD; /* Pointer to Blob detector module. */
-    int                     m_BDDel;
-    CvBlobTrackGen*         m_pBTGen;
-    CvBlobTrackPostProc*    m_pBTPostProc;
-    int                     m_UsePPData;
-    CvBlobTrackAnalysis*    m_pBTA; /* Blob trajectory analyser. */
-    CvBlobSeq               m_BlobList;
-    int                     m_FrameCount;
-    int                     m_NextBlobID;
-    const char*                   m_TimesFile;
-
-public:
-    virtual void SaveState(CvFileStorage* fs)
-    {
-        cvWriteInt(fs,"FrameCount",m_FrameCount);
-        cvWriteInt(fs,"NextBlobID",m_NextBlobID);
-        m_BlobList.Write(fs,"BlobList");
-    };
-
-    virtual void LoadState(CvFileStorage* fs, CvFileNode* node)
-    {
-        CvFileNode* BlobListNode = cvGetFileNodeByName(fs,node,"BlobList");
-        m_FrameCount = cvReadIntByName(fs,node, "FrameCount", m_FrameCount);
-        m_NextBlobID = cvReadIntByName(fs,node, "NextBlobID", m_NextBlobID);
-        if(BlobListNode)
-        {
-            m_BlobList.Load(fs,BlobListNode);
-        }
-    };
-};
-
-/* Auto Blob tracker creater (sole interface function for this file) */
-CvBlobTrackerAuto* cvCreateBlobTrackerAuto1(CvBlobTrackerAutoParam1* param)
-{
-    return (CvBlobTrackerAuto*)new CvBlobTrackerAuto1(param);
-}
-
-/* Constructor of auto blob tracker: */
-CvBlobTrackerAuto1::CvBlobTrackerAuto1(CvBlobTrackerAutoParam1* param):m_BlobList(sizeof(CvBlobTrackAuto))
-{
-    m_BlobList.AddFormat("i");
-    m_TimesFile = NULL;
-    AddParam("TimesFile",&m_TimesFile);
-
-    m_NextBlobID = 0;
-    m_pFGMask = NULL;
-    m_FrameCount = 0;
-
-    m_FGTrainFrames = param?param->FGTrainFrames:0;
-    m_pFG = param?param->pFG:0;
-
-    m_BDDel = 0;
-    m_pBD = param?param->pBD:NULL;
-    m_BTDel = 0;
-    m_pBT = param?param->pBT:NULL;;
-    m_BTReal = m_pBT?m_pBT->IsModuleName("BlobTrackerReal"):0;
-
-    m_pBTGen = param?param->pBTGen:NULL;
-
-    m_pBTA = param?param->pBTA:NULL;
-
-    m_pBTPostProc = param?param->pBTPP:NULL;
-    m_UsePPData = param?param->UsePPData:0;
-
-    /* Create default submodules: */
-    if(m_pBD==NULL)
-    {
-        m_pBD = cvCreateBlobDetectorSimple();
-        m_BDDel = 1;
-    }
-
-    if(m_pBT==NULL)
-    {
-        m_pBT = cvCreateBlobTrackerMS();
-        m_BTDel = 1;
-    }
-
-    SetModuleName("Auto1");
-
-} /* CvBlobTrackerAuto1::CvBlobTrackerAuto1 */
-
-/* Destructor for auto blob tracker: */
-CvBlobTrackerAuto1::~CvBlobTrackerAuto1()
-{
-    if(m_BDDel)m_pBD->Release();
-    if(m_BTDel)m_pBT->Release();
-}
-
-void CvBlobTrackerAuto1::Process(IplImage* pImg, IplImage* pMask)
-{
-    int         CurBlobNum = 0;
-    IplImage*   pFG = pMask;
-
-    /* Bump frame counter: */
-    m_FrameCount++;
-
-    if(m_TimesFile)
-    {
-        static int64  TickCount = cvGetTickCount();
-        static double TimeSum = 0;
-        static int Count = 0;
-        Count++;
-
-        if(Count%100==0)
-        {
-#ifndef WINCE
-            time_t ltime;
-            time( &ltime );
-            char* stime = ctime( &ltime );
-#else
-            /* WINCE does not have above POSIX functions (time,ctime) */
-            const char* stime = " wince ";
-#endif
-            FILE* out = fopen(m_TimesFile,"at");
-            double Time;
-            TickCount = cvGetTickCount()-TickCount;
-            Time = TickCount/FREQ;
-            TimeSum += Time;
-            if(out){fprintf(out,"- %sFrame: %d ALL_TIME - %f\n",stime,Count,TimeSum/1000);fclose(out);}
-
-            TimeSum = 0;
-            TickCount = cvGetTickCount();
-        }
-    }
-
-    /* Update BG model: */
-    TIME_BEGIN()
-
-    if(m_pFG)
-    {   /* If FG detector is needed: */
-        m_pFG->Process(pImg);
-        pFG = m_pFG->GetMask();
-    }   /* If FG detector is needed. */
-
-    TIME_END("FGDetector",-1)
-
-    m_pFGMask = pFG; /* For external use. */
-
-    /*if(m_pFG && m_pFG->GetParam("DebugWnd") == 1)
-    {// debug foreground result
-        IplImage *pFG = m_pFG->GetMask();
-        if(pFG)
-        {
-            cvNamedWindow("FG",0);
-            cvShowImage("FG", pFG);
-        }
-    }*/
-
-    /* Track blobs: */
-    TIME_BEGIN()
-    if(m_pBT)
-    {
-        m_pBT->Process(pImg, pFG);
-
-        for(int i=m_BlobList.GetBlobNum(); i>0; --i)
-        {   /* Update data of tracked blob list: */
-            CvBlob* pB = m_BlobList.GetBlob(i-1);
-            int     BlobID = CV_BLOB_ID(pB);
-            int     idx = m_pBT->GetBlobIndexByID(BlobID);
-            m_pBT->ProcessBlob(idx, pB, pImg, pFG);
-            pB->ID = BlobID;
-        }
-        CurBlobNum = m_pBT->GetBlobNum();
-    }
-    TIME_END("BlobTracker",CurBlobNum)
-
-    /* This part should be removed: */
-    if(m_BTReal && m_pBT)
-    {   /* Update blob list (detect new blob for real blob tracker): */
-        for(int i=m_pBT->GetBlobNum(); i>0; --i)
-        {   /* Update data of tracked blob list: */
-            CvBlob* pB = m_pBT->GetBlob(i-1);
-            if(pB && m_BlobList.GetBlobByID(CV_BLOB_ID(pB)) == NULL )
-            {
-                CvBlobTrackAuto     NewB;
-                NewB.blob = pB[0];
-                NewB.BadFrames = 0;
-                m_BlobList.AddBlob((CvBlob*)&NewB);
-            }
-        }   /* Next blob. */
-
-        /* Delete blobs: */
-        for(int i=m_BlobList.GetBlobNum(); i>0; --i)
-        {   /* Update tracked-blob list: */
-            CvBlob* pB = m_BlobList.GetBlob(i-1);
-            if(pB && m_pBT->GetBlobByID(CV_BLOB_ID(pB)) == NULL )
-            {
-                m_BlobList.DelBlob(i-1);
-            }
-        }   /* Next blob. */
-    }   /* Update bloblist. */
-
-
-    TIME_BEGIN()
-    if(m_pBTPostProc)
-    {   /* Post-processing module: */
-        for(int i=m_BlobList.GetBlobNum(); i>0; --i)
-        {   /* Update tracked-blob list: */
-            CvBlob* pB = m_BlobList.GetBlob(i-1);
-            m_pBTPostProc->AddBlob(pB);
-        }
-        m_pBTPostProc->Process();
-
-        for(int i=m_BlobList.GetBlobNum(); i>0; --i)
-        {   /* Update tracked-blob list: */
-            CvBlob* pB = m_BlobList.GetBlob(i-1);
-            int     BlobID = CV_BLOB_ID(pB);
-            CvBlob* pBN = m_pBTPostProc->GetBlobByID(BlobID);
-
-            if(pBN && m_UsePPData && pBN->w >= CV_BLOB_MINW && pBN->h >= CV_BLOB_MINH)
-            {   /* Set new data for tracker: */
-                m_pBT->SetBlobByID(BlobID, pBN );
-            }
-
-            if(pBN)
-            {   /* Update blob list with results from postprocessing: */
-                pB[0] = pBN[0];
-            }
-        }
-    }   /* Post-processing module. */
-
-    TIME_END("PostProcessing",CurBlobNum)
-
-    /* Blob deleter (experimental and simple): */
-    TIME_BEGIN()
-    if(pFG)
-    {   /* Blob deleter: */
-        int i;
-        if(!m_BTReal)for(i=m_BlobList.GetBlobNum();i>0;--i)
-        {   /* Check all blobs on list: */
-            CvBlobTrackAuto* pB = (CvBlobTrackAuto*)(m_BlobList.GetBlob(i-1));
-            int     Good = 0;
-            int     w=pFG->width;
-            int     h=pFG->height;
-            CvRect  r = CV_BLOB_RECT(pB);
-            CvMat   mat;
-            double  aver = 0;
-            double  area = CV_BLOB_WX(pB)*CV_BLOB_WY(pB);
-            if(r.x < 0){r.width += r.x;r.x = 0;}
-            if(r.y < 0){r.height += r.y;r.y = 0;}
-            if(r.x+r.width>=w){r.width = w-r.x-1;}
-            if(r.y+r.height>=h){r.height = h-r.y-1;}
-
-            if(r.width > 4 && r.height > 4 && r.x < w && r.y < h &&
-                r.x >=0 && r.y >=0 &&
-                r.x+r.width < w && r.y+r.height < h && area > 0)
-            {
-                aver = cvSum(cvGetSubRect(pFG,&mat,r)).val[0] / area;
-                /* if mask in blob area exists then its blob OK*/
-                if(aver > 0.1*255)Good = 1;
-            }
-            else
-            {
-                pB->BadFrames+=2;
-            }
-
-            if(Good)
-            {
-                pB->BadFrames = 0;
-            }
-            else
-            {
-                pB->BadFrames++;
-            }
-        }   /* Next blob: */
-
-        /* Check error count: */
-        for(i=0; i<m_BlobList.GetBlobNum(); ++i)
-        {
-            CvBlobTrackAuto* pB = (CvBlobTrackAuto*)m_BlobList.GetBlob(i);
-
-            if(pB->BadFrames>3)
-            {   /* Delete such objects */
-                /* from tracker...     */
-                m_pBT->DelBlobByID(CV_BLOB_ID(pB));
-
-                /* ... and from local list: */
-                m_BlobList.DelBlob(i);
-                i--;
-            }
-        }   /* Check error count for next blob. */
-    }   /*  Blob deleter. */
-
-    TIME_END("BlobDeleter",m_BlobList.GetBlobNum())
-
-    /* Update blobs: */
-    TIME_BEGIN()
-    if(m_pBT)
-        m_pBT->Update(pImg, pFG);
-    TIME_END("BlobTrackerUpdate",CurBlobNum)
-
-    /* Detect new blob: */
-    TIME_BEGIN()
-    if(!m_BTReal && m_pBD && pFG && (m_FrameCount > m_FGTrainFrames) )
-    {   /* Detect new blob: */
-        static CvBlobSeq    NewBlobList;
-        CvBlobTrackAuto     NewB;
-
-        NewBlobList.Clear();
-
-        if(m_pBD->DetectNewBlob(pImg, pFG, &NewBlobList, &m_BlobList))
-        {   /* Add new blob to tracker and blob list: */
-            int i;
-            IplImage* pmask = pFG;
-
-            /*if(0)if(NewBlobList.GetBlobNum()>0 && pFG )
-            {// erode FG mask (only for FG_0 and MS1||MS2)
-                pmask = cvCloneImage(pFG);
-                cvErode(pFG,pmask,NULL,2);
-            }*/
-
-            for(i=0; i<NewBlobList.GetBlobNum(); ++i)
-            {
-                CvBlob* pBN = NewBlobList.GetBlob(i);
-
-                if(pBN && pBN->w >= CV_BLOB_MINW && pBN->h >= CV_BLOB_MINH)
-                {
-                    pBN->ID = m_NextBlobID;
-
-                    CvBlob* pB = m_pBT->AddBlob(pBN, pImg, pmask );
-                    if(pB)
-                    {
-                        NewB.blob = pB[0];
-                        NewB.BadFrames = 0;
-                        m_BlobList.AddBlob((CvBlob*)&NewB);
-                        m_NextBlobID++;
-                    }
-                }
-            }   /* Add next blob from list of detected blob. */
-
-            if(pmask != pFG) cvReleaseImage(&pmask);
-
-        }   /* Create and add new blobs and trackers. */
-
-    }   /*  Detect new blob. */
-
-    TIME_END("BlobDetector",-1)
-
-    TIME_BEGIN()
-    if(m_pBTGen)
-    {   /* Run track generator: */
-        for(int i=m_BlobList.GetBlobNum(); i>0; --i)
-        {   /* Update data of tracked blob list: */
-            CvBlob* pB = m_BlobList.GetBlob(i-1);
-            m_pBTGen->AddBlob(pB);
-        }
-        m_pBTGen->Process(pImg, pFG);
-    }   /* Run track generator: */
-    TIME_END("TrajectoryGeneration",-1)
-
-    TIME_BEGIN()
-    if(m_pBTA)
-    {   /* Trajectory analysis module: */
-        int i;
-        for(i=m_BlobList.GetBlobNum(); i>0; i--)
-            m_pBTA->AddBlob(m_BlobList.GetBlob(i-1));
-
-        m_pBTA->Process(pImg, pFG);
-
-    }   /* Trajectory analysis module. */
-
-    TIME_END("TrackAnalysis",m_BlobList.GetBlobNum())
-
-} /* CvBlobTrackerAuto1::Process */
diff --git a/modules/legacy/src/blobtrackingcc.cpp b/modules/legacy/src/blobtrackingcc.cpp
deleted file mode 100644 (file)
index 1a72c7e..0000000
+++ /dev/null
@@ -1,553 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-static float CalcAverageMask(CvBlob* pBlob, IplImage* pImgFG )
-{   /* Calculate sum of mask: */
-    double  Area, Aver = 0;
-    CvRect  r;
-    CvMat   mat;
-
-    if(pImgFG==NULL) return 0;
-
-    r.x = cvRound(pBlob->x - pBlob->w*0.5);
-    r.y = cvRound(pBlob->y - pBlob->h*0.5);
-    r.width = cvRound(pBlob->w);
-    r.height = cvRound(pBlob->h);
-    Area = r.width*r.height;
-    if(r.x<0){r.width += r.x;r.x = 0;}
-    if(r.y<0){r.height += r.y;r.y = 0;}
-    if((r.x+r.width)>=pImgFG->width){r.width=pImgFG->width-r.x-1;}
-    if((r.y+r.height)>=pImgFG->height){r.height=pImgFG->height-r.y-1;}
-
-    if(r.width>0 && r.height>0)
-    {
-        double Sum = cvSum(cvGetSubRect(pImgFG,&mat,r)).val[0]/255.0;
-        assert(Area>0);
-        Aver = Sum/Area;
-    }
-    return (float)Aver;
-}   /* Calculate sum of mask. */
-
-
-/*============== BLOB TRACKERCC CLASS DECLARATION =============== */
-typedef struct DefBlobTracker
-{
-    CvBlob                      blob;
-    CvBlobTrackPredictor*       pPredictor;
-    CvBlob                      BlobPredict;
-    int                         Collision;
-    CvBlobSeq*                  pBlobHyp;
-    float                       AverFG;
-} DefBlobTracker;
-
-void cvFindBlobsByCCClasters(IplImage* pFG, CvBlobSeq* pBlobs, CvMemStorage* storage);
-
-class CvBlobTrackerCC : public CvBlobTracker
-{
-private:
-    float           m_AlphaSize;
-    float           m_AlphaPos;
-    float           m_Alpha;
-    int             m_Collision;
-    int             m_ConfidenceType;
-    const char*           m_ConfidenceTypeStr;
-    CvBlobSeq       m_BlobList;
-    CvBlobSeq       m_BlobListNew;
-//  int             m_LastID;
-    CvMemStorage*   m_pMem;
-    int             m_ClearHyp;
-    IplImage*       m_pImg;
-    IplImage*       m_pImgFG;
-public:
-    CvBlobTrackerCC():m_BlobList(sizeof(DefBlobTracker))
-    {
-//      m_LastID = 0;
-        m_ClearHyp = 0;
-        m_pMem = cvCreateMemStorage();
-        m_Collision = 1; /* if 1 then collistion will be detected and processed */
-        AddParam("Collision",&m_Collision);
-        CommentParam("Collision", "If 1 then collision cases are processed in special way");
-
-        m_AlphaSize = 0.02f;
-        AddParam("AlphaSize",&m_AlphaSize);
-        CommentParam("AlphaSize", "Size update speed (0..1)");
-
-        m_AlphaPos = 1.0f;
-        AddParam("AlphaPos",&m_AlphaPos);
-        CommentParam("AlphaPos", "Position update speed (0..1)");
-
-        m_Alpha = 0.001f;
-        AddParam("Alpha", &m_Alpha);
-        CommentParam("Alpha","Coefficient for model histogram updating (0 - hist is not updated)");
-
-        m_ConfidenceType=0;
-        m_ConfidenceTypeStr = "NearestBlob";
-        AddParam("ConfidenceType", &m_ConfidenceTypeStr);
-        CommentParam("ConfidenceType","Type of calculated Confidence (NearestBlob, AverFG, BC)");
-
-        SetModuleName("CC");
-    }
-
-    ~CvBlobTrackerCC()
-    {
-        if(m_pMem)cvReleaseMemStorage(&m_pMem);
-    }
-
-    /* Blob functions: */
-    virtual int     GetBlobNum() {return m_BlobList.GetBlobNum();}
-    virtual CvBlob* GetBlob(int BlobIndex){return m_BlobList.GetBlob(BlobIndex);}
-    virtual void    SetBlob(int BlobIndex, CvBlob* pBlob)
-    {
-        CvBlob* pB = m_BlobList.GetBlob(BlobIndex);
-        if(pB) pB[0] = pBlob[0];
-    }
-
-    virtual CvBlob* GetBlobByID(int BlobID){return m_BlobList.GetBlobByID(BlobID);}
-    virtual void    DelBlob(int BlobIndex)
-    {
-        DefBlobTracker* pBT = (DefBlobTracker*)m_BlobList.GetBlob(BlobIndex);
-        if(pBT==NULL) return;
-        if(pBT->pPredictor)
-        {
-            pBT->pPredictor->Release();
-        }
-        else
-        {
-            printf("WARNING!!! Invalid Predictor in CC tracker");
-        }
-        delete pBT->pBlobHyp;
-        m_BlobList.DelBlob(BlobIndex);
-    }
-#if 0
-    virtual void    DelBlobByID(int BlobID)
-    {
-        DefBlobTracker* pBT = (DefBlobTracker*)m_BlobList.GetBlobByID(BlobID);
-        pBT->pPredictor->Release();
-        delete pBT->pBlobHyp;
-        m_BlobList.DelBlobByID(BlobID);
-    };
-#endif
-    virtual void    Release(){delete this;}
-
-    /* Add new blob to track it and assign to this blob personal ID */
-    /* pBlob - pinter to structure with blob parameters (ID is ignored)*/
-    /* pImg - current image */
-    /* pImgFG - current foreground mask */
-    /* return pointer to new added blob */
-    virtual CvBlob* AddBlob(CvBlob* pB, IplImage* /*pImg*/, IplImage* pImgFG = NULL )
-    {
-        assert(pImgFG); /* This tracker uses only foreground mask. */
-        DefBlobTracker NewB;
-        NewB.blob = pB[0];
-//        CV_BLOB_ID(&NewB) = m_LastID;
-        NewB.pBlobHyp = new CvBlobSeq;
-        NewB.pPredictor = cvCreateModuleBlobTrackPredictKalman(); /* Module for position prediction. */
-        NewB.pPredictor->Update(pB);
-        NewB.AverFG = pImgFG?CalcAverageMask(pB,pImgFG):0;
-        m_BlobList.AddBlob((CvBlob*)&NewB);
-        return m_BlobList.GetBlob(m_BlobList.GetBlobNum()-1);
-    }
-
-    virtual void    Process(IplImage* pImg, IplImage* pImgFG = NULL)
-    {
-        CvSeq*      cnts;
-        CvSeq*      cnt;
-        int i;
-
-        m_pImg = pImg;
-        m_pImgFG = pImgFG;
-
-        if(m_BlobList.GetBlobNum() <= 0 ) return;
-
-        /* Clear bloblist for new blobs: */
-        m_BlobListNew.Clear();
-
-        assert(m_pMem);
-        cvClearMemStorage(m_pMem);
-        assert(pImgFG);
-
-
-        /* Find CC: */
-#if 0
-        {   // By contour clustering:
-            cvFindBlobsByCCClasters(pImgFG, &m_BlobListNew, m_pMem);
-        }
-#else
-        {   /* One contour - one blob: */
-            IplImage* pBin = cvCloneImage(pImgFG);
-            assert(pBin);
-            cvThreshold(pBin,pBin,128,255,CV_THRESH_BINARY);
-            cvFindContours(pBin, m_pMem, &cnts, sizeof(CvContour), CV_RETR_EXTERNAL);
-
-            /* Process each contour: */
-            for(cnt = cnts; cnt; cnt=cnt->h_next)
-            {
-                CvBlob  NewBlob;
-
-                /* Image moments: */
-                double      M00,X,Y,XX,YY;
-                CvMoments   m;
-                CvRect      r = ((CvContour*)cnt)->rect;
-                CvMat       mat;
-                if(r.height < 3 || r.width < 3) continue;
-                cvMoments( cvGetSubRect(pImgFG,&mat,r), &m, 0 );
-                M00 = cvGetSpatialMoment( &m, 0, 0 );
-                if(M00 <= 0 ) continue;
-                X = cvGetSpatialMoment( &m, 1, 0 )/M00;
-                Y = cvGetSpatialMoment( &m, 0, 1 )/M00;
-                XX = (cvGetSpatialMoment( &m, 2, 0 )/M00) - X*X;
-                YY = (cvGetSpatialMoment( &m, 0, 2 )/M00) - Y*Y;
-                NewBlob = cvBlob(r.x+(float)X,r.y+(float)Y,(float)(4*sqrt(XX)),(float)(4*sqrt(YY)));
-                m_BlobListNew.AddBlob(&NewBlob);
-            }   /* Next contour. */
-
-            cvReleaseImage(&pBin);
-        }
-#endif
-        for(i=m_BlobList.GetBlobNum(); i>0; --i)
-        {   /* Predict new blob position: */
-            CvBlob*         pB=NULL;
-            DefBlobTracker* pBT = (DefBlobTracker*)m_BlobList.GetBlob(i-1);
-
-            /* Update predictor by previous value of blob: */
-            pBT->pPredictor->Update(&(pBT->blob));
-
-            /* Predict current position: */
-            pB = pBT->pPredictor->Predict();
-
-            if(pB)
-            {
-                pBT->BlobPredict = pB[0];
-            }
-            else
-            {
-                pBT->BlobPredict = pBT->blob;
-            }
-        }   /* Predict new blob position. */
-
-        if(m_Collision)
-        for(i=m_BlobList.GetBlobNum(); i>0; --i)
-        {   /* Predict collision. */
-            int             Collision = 0;
-            int             j;
-            DefBlobTracker* pF = (DefBlobTracker*)m_BlobList.GetBlob(i-1);
-
-            for(j=m_BlobList.GetBlobNum(); j>0; --j)
-            {   /* Predict collision: */
-                CvBlob* pB1;
-                CvBlob* pB2;
-                DefBlobTracker* pF2 = (DefBlobTracker*)m_BlobList.GetBlob(j-1);
-                if(i==j) continue;
-                pB1 = &pF->BlobPredict;
-                pB2 = &pF2->BlobPredict;
-
-                if( fabs(pB1->x-pB2->x)<0.6*(pB1->w+pB2->w) &&
-                    fabs(pB1->y-pB2->y)<0.6*(pB1->h+pB2->h) ) Collision = 1;
-
-                pB1 = &pF->blob;
-                pB2 = &pF2->blob;
-
-                if( fabs(pB1->x-pB2->x)<0.6*(pB1->w+pB2->w) &&
-                    fabs(pB1->y-pB2->y)<0.6*(pB1->h+pB2->h) ) Collision = 1;
-
-                if(Collision) break;
-
-            }   /* Check next blob to cross current. */
-
-            pF->Collision = Collision;
-
-        }   /* Predict collision. */
-
-        for(i=m_BlobList.GetBlobNum(); i>0; --i)
-        {   /* Find a neighbour on current frame
-             * for each blob from previous frame:
-             */
-            CvBlob*         pBl = m_BlobList.GetBlob(i-1);
-            DefBlobTracker* pBT = (DefBlobTracker*)pBl;
-            //int             BlobID = CV_BLOB_ID(pB);
-            //CvBlob*         pBBest = NULL;
-            //double          DistBest = -1;
-            //int j;
-
-            if(pBT->pBlobHyp->GetBlobNum()>0)
-            {   /* Track all hypotheses: */
-                int h,hN = pBT->pBlobHyp->GetBlobNum();
-                for(h=0; h<hN; ++h)
-                {
-                    int         j, jN = m_BlobListNew.GetBlobNum();
-                    CvBlob*     pB = pBT->pBlobHyp->GetBlob(h);
-                    int         BlobID = CV_BLOB_ID(pB);
-                    CvBlob*     pBBest = NULL;
-                    double      DistBest = -1;
-                    for(j=0; j<jN; j++)
-                    {   /* Find best CC: */
-                        double  Dist = -1;
-                        CvBlob* pBNew = m_BlobListNew.GetBlob(j);
-                        double  dx = fabs(CV_BLOB_X(pB)-CV_BLOB_X(pBNew));
-                        double  dy = fabs(CV_BLOB_Y(pB)-CV_BLOB_Y(pBNew));
-                        if(dx > 2*CV_BLOB_WX(pB) || dy > 2*CV_BLOB_WY(pB)) continue;
-
-                        Dist = sqrt(dx*dx+dy*dy);
-                        if(Dist < DistBest || pBBest == NULL)
-                        {
-                            DistBest = Dist;
-                            pBBest = pBNew;
-                        }
-                    }   /* Find best CC. */
-
-                    if(pBBest)
-                    {
-                        pB[0] = pBBest[0];
-                        CV_BLOB_ID(pB) = BlobID;
-                    }
-                    else
-                    {   /* Delete this hypothesis. */
-                        pBT->pBlobHyp->DelBlob(h);
-                        h--;
-                        hN--;
-                    }
-                }   /* Next hypothysis. */
-            }   /*  Track all hypotheses. */
-        }   /*  Track next blob. */
-
-        m_ClearHyp = 1;
-
-    } /* Process. */
-
-    virtual void ProcessBlob(int BlobIndex, CvBlob* pBlob, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL)
-    {
-        int             ID = pBlob->ID;
-        CvBlob*         pB = m_BlobList.GetBlob(BlobIndex);
-        DefBlobTracker* pBT = (DefBlobTracker*)pB;
-        //CvBlob*         pBBest = NULL;
-        //double          DistBest = -1;
-        int             BlobID;
-
-        if(pB==NULL) return;
-
-        BlobID = pB->ID;
-
-        if(m_Collision && pBT->Collision)
-        {   /* Tracking in collision: */
-            pB[0]=pBT->BlobPredict;
-            CV_BLOB_ID(pB)=BlobID;
-        }   /* Tracking in collision. */
-        else
-        {   /* Non-collision tracking: */
-            CvBlob* pBBest = GetNearestBlob(pB);
-            if(pBBest)
-            {
-                float   w = pBlob->w*(1-m_AlphaSize)+m_AlphaSize*pBBest->w;
-                float   h = pBlob->h*(1-m_AlphaSize)+m_AlphaSize*pBBest->h;
-                float   x = pBlob->x*(1-m_AlphaPos)+m_AlphaPos*pBBest->x;
-                float   y = pBlob->y*(1-m_AlphaPos)+m_AlphaPos*pBBest->y;
-                pB->w = w;
-                pB->h = h;
-                pB->x = x;
-                pB->y = y;
-                CV_BLOB_ID(pB) = BlobID;
-            }
-        }   /* Non-collision tracking. */
-
-        pBlob[0] = pB[0];
-        pBlob->ID = ID;
-    }
-
-    virtual double  GetConfidence(int BlobIndex, CvBlob* pBlob, IplImage* /*pImg*/, IplImage* pImgFG = NULL)
-    {
-        /* Define coefficients in exp by exp(-XT*K)=VT: */
-        static double _KS = -log(0.1)/pow(0.5,2); /* XT = 1, VT = 0.1 - when size is Larger in 2 times Confidence is smoller in 10 times */
-        static double _KP = -log(0.1)/pow(m_pImg->width*0.02,2); /* XT = 0.02*ImgWidth, VT = 0.1*/
-        DefBlobTracker* pBT = (DefBlobTracker*)m_BlobList.GetBlob(BlobIndex);
-        float   dx,dy,dw,dh;
-        float   dp2,ds2;
-        double  W = 1;
-        CvBlob* pBC = GetNearestBlob(pBlob);
-        if(pBC == NULL ) return 0;
-
-        dx = pBC->x-pBlob->x;
-        dy = pBC->y-pBlob->y;
-        dw = (pBC->w-pBlob->w)/pBC->w;
-        dh = (pBC->h-pBlob->h)/pBC->h;
-
-        dp2 = dx*dx+dy*dy;
-        ds2 = dw*dw+dh*dh;
-
-        if(!pBT->Collision)
-        {   /* Confidence for size by nearest blob: */
-            W*=exp(-_KS*ds2);
-        }
-
-        if(m_ConfidenceType==0 && !pBT->Collision)
-        {   /* Confidence by nearest blob: */
-            W*=exp(-_KP*dp2);
-        }
-
-        if(m_ConfidenceType==1 && pBT->AverFG>0)
-        {   /* Calculate sum of mask: */
-            float   Aver = CalcAverageMask(pBlob, pImgFG );
-            if(Aver < pBT->AverFG)
-            {
-                float diff = 1+0.9f*(Aver-pBT->AverFG)/pBT->AverFG;
-                if(diff < 0.1f) diff = 0.1f;
-                W *= diff;
-            }
-        }   /* Calculate sum of mask. */
-
-        if(m_ConfidenceType==2)
-        {   /* Calculate BCoeff: */
-            float   S = 0.2f;
-            float   Aver = CalcAverageMask(pBlob, pImgFG );
-            double B = sqrt(Aver*pBT->AverFG)+sqrt((1-Aver)*(1-pBT->AverFG));
-
-            W *= exp((B-1)/(2*S));
-        }   /* Calculate sum of mask. */
-
-        return W;
-    }
-
-    virtual void UpdateBlob(int BlobIndex, CvBlob* /*pBlob*/, IplImage* /*pImg*/, IplImage* pImgFG = NULL)
-    {
-        DefBlobTracker* pBT = (DefBlobTracker*)m_BlobList.GetBlob(BlobIndex);
-
-        if(pImgFG==NULL || pBT==NULL) return;
-
-        if(!pBT->Collision)
-        {
-        //pBT->AverFG = pBT->AverFG * (1-m_Alpha) + m_Alpha * CalcAverageMask(pBlob,pImgFG);
-        }
-    }
-
-    virtual void ParamUpdate()
-    {
-        const char*   pCT[3] = {"NearestBlob","AverFG","BC"};
-        int     i;
-
-        CvBlobTracker::ParamUpdate();
-
-        for(i=0; i<3; ++i)
-        {
-            if(cv_stricmp(m_ConfidenceTypeStr,pCT[i])==0)
-            {
-                m_ConfidenceType = i;
-            }
-        }
-        SetParamStr("ConfidenceType",pCT[m_ConfidenceType]);
-    }
-
-    /* ===============  MULTI HYPOTHESIS INTERFACE ================== */
-    /* Return number of position hypotheses of currently tracked blob: */
-    virtual int     GetBlobHypNum(int BlobIdx)
-    {
-        DefBlobTracker* pBT = (DefBlobTracker*)m_BlobList.GetBlob(BlobIdx);
-        assert(pBT->pBlobHyp);
-        return pBT->pBlobHyp->GetBlobNum();
-    }  /* CvBlobtrackerList::GetBlobHypNum() */
-
-    /* Return pointer to specified blob hypothesis by index blob: */
-    virtual CvBlob* GetBlobHyp(int BlobIndex, int hypothesis)
-    {
-        DefBlobTracker* pBT = (DefBlobTracker*)m_BlobList.GetBlob(BlobIndex);
-        assert(pBT->pBlobHyp);
-        return pBT->pBlobHyp->GetBlob(hypothesis);
-    }  /* CvBlobtrackerList::GetBlobHyp() */
-
-    /* Set new parameters for specified (by index) blob hypothesis
-     * (can be called several times for each hypothesis):
-     */
-    virtual void    SetBlobHyp(int BlobIndex, CvBlob* pBlob)
-    {
-        if(m_ClearHyp)
-        {   /* Clear all hypotheses: */
-            int b, bN = m_BlobList.GetBlobNum();
-            for(b=0; b<bN; ++b)
-            {
-                DefBlobTracker* pBT = (DefBlobTracker*)m_BlobList.GetBlob(b);
-                assert(pBT->pBlobHyp);
-                pBT->pBlobHyp->Clear();
-            }
-            m_ClearHyp = 0;
-        }
-        {   /* Add hypothesis: */
-            DefBlobTracker* pBT = (DefBlobTracker*)m_BlobList.GetBlob(BlobIndex);
-            assert(pBT->pBlobHyp);
-            pBT->pBlobHyp->AddBlob(pBlob);
-        }
-    }
-
-private:
-    CvBlob* GetNearestBlob(CvBlob* pB)
-    {
-        //DefBlobTracker* pBT = (DefBlobTracker*)pB;
-        CvBlob*         pBBest = NULL;
-        double          DistBest = -1;
-
-        if(pB==NULL) return NULL;
-
-        for(int j=m_BlobListNew.GetBlobNum(); j>0; --j)
-        {   /* Find best CC: */
-            double  Dist = -1;
-            CvBlob* pBNew = m_BlobListNew.GetBlob(j-1);
-            double  dx = fabs(CV_BLOB_X(pB)-CV_BLOB_X(pBNew));
-            double  dy = fabs(CV_BLOB_Y(pB)-CV_BLOB_Y(pBNew));
-            if(dx > 2*CV_BLOB_WX(pB) || dy > 2*CV_BLOB_WY(pB)) continue;
-
-            Dist = sqrt(dx*dx+dy*dy);
-            if(Dist < DistBest || pBBest == NULL)
-            {
-                DistBest = Dist;
-                pBBest = pBNew;
-            }
-
-        }   /* Find best CC. */
-
-        return pBBest;
-
-    } /* GetNearestBlob */
-
-};
-
-CvBlobTracker* cvCreateBlobTrackerCC()
-{
-    return (CvBlobTracker*) new CvBlobTrackerCC;
-}
-/*============== BLOB TRACKERCC CLASS DECLARATION =============== */
diff --git a/modules/legacy/src/blobtrackingccwithcr.cpp b/modules/legacy/src/blobtrackingccwithcr.cpp
deleted file mode 100644 (file)
index e8bd4de..0000000
+++ /dev/null
@@ -1,491 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-/* Blob (foreground-pixel connected-component) tracking with collision resolution.
- *
- * For entrypoints into the literature see:
- *
- *  A Tutorial on Particle Filters for Online Nonlinear/Non-Gaussian Bayesian Tracking
- *  Arulampalam &t al, 2001, 15p
- *  http://www-clmc.usc.edu/publications/A/arulampalam-TSP2002.pdf
- *
- *  Particle Filters for Positioning, Navigation, and Tracking
- *  Gustafsson et al, 2002 12p
- *  http://www.control.isy.liu.se/~fredrik/reports/01SPpf4pos.pdf
- *
- *  Particle Filtering in High Clutter Environments
- *  Korhonen et al, 2005 4p
- *  http://www.cs.uku.fi/finsig05/papers/paper26_FINSIG05.pdf
- *
- *   Appearance Models for Occlusion Handling
- *   Andrew Senior &t al, 8p 2001
- *   http://www.research.ibm.com/peoplevision/PETS2001.pdf
- *
- */
-
-/*============== BLOB TRACKERCC CLASS DECLARATION =============== */
-typedef struct DefBlobTrackerCR
-{
-    CvBlob                      blob;
-    CvBlobTrackPredictor*       pPredictor;
-    CvBlob                      BlobPredict;
-    CvBlob                      BlobPrev;
-    int                         Collision;
-    CvBlobSeq*                  pBlobHyp;
-    CvBlobTrackerOne*           pResolver;
-} DefBlobTrackerCR;
-
-void cvFindBlobsByCCClasters(IplImage* pFG, CvBlobSeq* pBlobs, CvMemStorage* storage);
-
-class CvBlobTrackerCCCR : public CvBlobTracker
-{
-private:
-    float           m_AlphaSize;
-    int             m_Collision;
-    CvBlobSeq       m_BlobList;
-    CvBlobSeq       m_BlobListNew;
-    CvMemStorage*   m_pMem;
-    CvBlobTrackerOne* (*m_CreateCR)();
-    char            m_ModuleName[1024];
-
-
-public:
-    CvBlobTrackerCCCR(CvBlobTrackerOne* (*CreateCR)(), const char* CRName):m_BlobList(sizeof(DefBlobTrackerCR))
-    {
-        m_CreateCR = CreateCR;
-        m_pMem = cvCreateMemStorage();
-
-        m_Collision = 1; /* if 1 then collistion will be detected and processed */
-
-        m_AlphaSize = 0.05f;
-        AddParam("AlphaSize",&m_AlphaSize);
-        CommentParam("AlphaSize", "Size update speed (0..1)");
-
-        strcpy(m_ModuleName, "CCCR");
-        if(CRName)strcat(m_ModuleName,CRName);
-        SetModuleName(m_ModuleName);
-
-        {
-            CvBlobTrackerOne* pM = m_CreateCR();
-            TransferParamsFromChild(pM,NULL);
-            pM->Release();
-        }
-        SetParam("SizeVar",0);
-    }
-
-    ~CvBlobTrackerCCCR()
-    {
-        if(m_pMem)cvReleaseMemStorage(&m_pMem);
-    }
-
-    /* Blob functions: */
-    virtual int     GetBlobNum() {return m_BlobList.GetBlobNum();}
-    virtual CvBlob* GetBlob(int BlobIndex){return m_BlobList.GetBlob(BlobIndex);}
-    virtual void    SetBlob(int BlobIndex, CvBlob* pBlob)
-    {
-        CvBlob* pB = m_BlobList.GetBlob(BlobIndex);
-        if(pB) pB[0] = pBlob[0];
-    }
-
-    virtual CvBlob* GetBlobByID(int BlobID){return m_BlobList.GetBlobByID(BlobID);}
-    virtual void    DelBlob(int BlobIndex)
-    {
-        DefBlobTrackerCR* pBT = (DefBlobTrackerCR*)m_BlobList.GetBlob(BlobIndex);
-        if(pBT->pResolver)pBT->pResolver->Release();
-        if(pBT->pPredictor)pBT->pPredictor->Release();
-        delete pBT->pBlobHyp;
-        m_BlobList.DelBlob(BlobIndex);
-    }
-
-    virtual void    DelBlobByID(int BlobID)
-    {
-        DefBlobTrackerCR* pBT = (DefBlobTrackerCR*)m_BlobList.GetBlobByID(BlobID);
-        if(pBT->pResolver)pBT->pResolver->Release();
-        if(pBT->pPredictor)pBT->pPredictor->Release();
-        delete pBT->pBlobHyp;
-        m_BlobList.DelBlobByID(BlobID);
-    }
-
-    virtual void    Release(){delete this;}
-
-    /* Add new blob to track it and assign to this blob personal ID */
-    /* pBlob - pinter to structure with blob parameters (ID is ignored)*/
-    /* pImg - current image */
-    /* pImgFG - current foreground mask */
-    /* Return pointer to new added blob: */
-    virtual CvBlob* AddBlob(CvBlob* pB, IplImage* pImg, IplImage* pImgFG = NULL )
-    {
-        DefBlobTrackerCR NewB;
-        NewB.blob = pB[0];
-        NewB.pBlobHyp = new CvBlobSeq;
-        NewB.pPredictor = cvCreateModuleBlobTrackPredictKalman(); /* module for predict position */
-        NewB.pPredictor->SetParam("DataNoisePos",0.001);
-        NewB.pPredictor->ParamUpdate();
-        NewB.pResolver = NULL;
-        if(m_CreateCR)
-        {
-            NewB.pResolver = m_CreateCR();
-            TransferParamsToChild(NewB.pResolver,NULL);
-            NewB.pResolver->Init(pB, pImg, pImgFG);
-        }
-        m_BlobList.AddBlob((CvBlob*)&NewB);
-        return m_BlobList.GetBlob(m_BlobList.GetBlobNum()-1);
-    }
-
-    virtual void    Process(IplImage* pImg, IplImage* pImgFG = NULL)
-    {
-        CvSeq*      cnts;
-        CvSeq*      cnt;
-        //CvMat*      pMC = NULL;
-
-        if(m_BlobList.GetBlobNum() <= 0 ) return;
-
-        /* Clear blob list for new blobs: */
-        m_BlobListNew.Clear();
-
-        assert(m_pMem);
-        cvClearMemStorage(m_pMem);
-        assert(pImgFG);
-
-        {   /* One contour - one blob: */
-            IplImage* pBin = cvCloneImage(pImgFG);
-            assert(pBin);
-            cvThreshold(pBin,pBin,128,255,CV_THRESH_BINARY);
-            cvFindContours(pBin, m_pMem, &cnts, sizeof(CvContour), CV_RETR_EXTERNAL);
-
-            /* Process each contour: */
-            for(cnt = cnts; cnt; cnt=cnt->h_next)
-            {
-                CvBlob  NewBlob;
-
-                /* Image moments: */
-                double      M00,X,Y,XX,YY;
-                CvMoments   m;
-                CvRect      r = ((CvContour*)cnt)->rect;
-                CvMat       mat;
-                if(r.height < 3 || r.width < 3) continue;
-                cvMoments( cvGetSubRect(pImgFG,&mat,r), &m, 0 );
-                M00 = cvGetSpatialMoment( &m, 0, 0 );
-                if(M00 <= 0 ) continue;
-                X = cvGetSpatialMoment( &m, 1, 0 )/M00;
-                Y = cvGetSpatialMoment( &m, 0, 1 )/M00;
-                XX = (cvGetSpatialMoment( &m, 2, 0 )/M00) - X*X;
-                YY = (cvGetSpatialMoment( &m, 0, 2 )/M00) - Y*Y;
-                NewBlob = cvBlob(r.x+(float)X,r.y+(float)Y,(float)(4*sqrt(XX)),(float)(4*sqrt(YY)));
-                m_BlobListNew.AddBlob(&NewBlob);
-
-            }   /* Next contour. */
-
-            cvReleaseImage(&pBin);
-        }
-
-        for(int i=m_BlobList.GetBlobNum(); i>0; --i)
-        {   /* Predict new blob position. */
-            CvBlob*             pB = NULL;
-            DefBlobTrackerCR*   pBT = (DefBlobTrackerCR*)m_BlobList.GetBlob(i-1);
-
-            /* Update predictor. */
-            pBT->pPredictor->Update(&(pBT->blob));
-            pB = pBT->pPredictor->Predict();
-            if(pB)
-            {
-                pBT->BlobPredict = pB[0];
-            }
-            pBT->BlobPrev = pBT->blob;
-        }   /* Predict new blob position. */
-
-
-        if(m_BlobList.GetBlobNum()>0 && m_BlobListNew.GetBlobNum()>0)
-        {   /* Resolve new blob to old: */
-            int NOld = m_BlobList.GetBlobNum();
-            int NNew = m_BlobListNew.GetBlobNum();
-
-            for(int i=0; i<NOld; i++)
-            {   /* Set 0 collision and clear all hyp: */
-                DefBlobTrackerCR* pF = (DefBlobTrackerCR*)m_BlobList.GetBlob(i);
-                pF->Collision = 0;
-                pF->pBlobHyp->Clear();
-            }   /* Set 0 collision. */
-
-            /* Create correspondence records: */
-            for(int j=0; j<NNew; ++j)
-            {
-                CvBlob*             pB1 = m_BlobListNew.GetBlob(j);
-                DefBlobTrackerCR*   pFLast = NULL;
-
-                for(int i=0; i<NOld; i++)
-                {   /* Check intersection: */
-                    int Intersection = 0;
-                    DefBlobTrackerCR* pF = (DefBlobTrackerCR*)m_BlobList.GetBlob(i);
-                    CvBlob* pB2 = &(pF->BlobPredict);
-
-                    if( fabs(pB1->x-pB2->x)<0.5*(pB1->w+pB2->w) &&
-                        fabs(pB1->y-pB2->y)<0.5*(pB1->h+pB2->h) ) Intersection = 1;
-
-                    if(Intersection)
-                    {
-                        if(pFLast)
-                        {
-                            pF->Collision = pFLast->Collision = 1;
-                        }
-                        pFLast = pF;
-                        pF->pBlobHyp->AddBlob(pB1);
-                    }
-                }   /* Check intersection. */
-            }   /*  Check next new blob. */
-        }   /*  Resolve new blob to old. */
-
-        for(int i=m_BlobList.GetBlobNum(); i>0; --i)
-        {   /* Track each blob. */
-            CvBlob*             pB = m_BlobList.GetBlob(i-1);
-            DefBlobTrackerCR*   pBT = (DefBlobTrackerCR*)pB;
-            int                 BlobID = CV_BLOB_ID(pB);
-          //CvBlob*             pBBest = NULL;
-          //double              DistBest = -1;
-
-            if(pBT->pResolver)
-            {
-                pBT->pResolver->SetCollision(pBT->Collision);
-            }
-
-            if(pBT->Collision)
-            {   /* Tracking in collision: */
-                if(pBT->pResolver)
-                {
-                    pB[0] = pBT->pResolver->Process(&(pBT->BlobPredict),pImg, pImgFG)[0];
-                }
-            }   /* Tracking in collision. */
-            else
-            {   /* Non-collision tracking: */
-                CvBlob  NewCC = pBT->BlobPredict;
-                if(pBT->pBlobHyp->GetBlobNum()==1)
-                {   /* One blob to one CC: */
-                    NewCC = pBT->pBlobHyp->GetBlob(0)[0];
-                }
-                else
-                {   /* One blob several CC: */
-                    CvBlob* pBBest = NULL;
-                    double  DistBest = -1;
-                    double  CMax = 0;
-                    for(int j=pBT->pBlobHyp->GetBlobNum();j>0;--j)
-                    {   /* Find best CC: */
-                        CvBlob* pBNew = pBT->pBlobHyp->GetBlob(j-1);
-                        if(pBT->pResolver)
-                        {     /* Choose CC by confidence: */
-//                            double  dx = fabs(CV_BLOB_X(pB)-CV_BLOB_X(pBNew));
-//                            double  dy = fabs(CV_BLOB_Y(pB)-CV_BLOB_Y(pBNew));
-                            double  C = pBT->pResolver->GetConfidence(pBNew,pImg, pImgFG);
-                            if(C > CMax || pBBest == NULL)
-                            {
-                                CMax = C;
-                                pBBest = pBNew;
-                            }
-                        }
-                        else
-                        {    /* Choose CC by distance: */
-                            double  dx = fabs(CV_BLOB_X(pB)-CV_BLOB_X(pBNew));
-                            double  dy = fabs(CV_BLOB_Y(pB)-CV_BLOB_Y(pBNew));
-                            double  Dist = sqrt(dx*dx+dy*dy);
-                            if(Dist < DistBest || pBBest == NULL)
-                            {
-                                DistBest = Dist;
-                                pBBest = pBNew;
-                            }
-                        }
-                    }   /* Find best CC. */
-                    if(pBBest)
-                        NewCC = pBBest[0];
-                }   /* One blob several CC. */
-                pB->x = NewCC.x;
-                pB->y = NewCC.y;
-                pB->w = (m_AlphaSize)*NewCC.w+(1-m_AlphaSize)*pB->w;
-                pB->h = (m_AlphaSize)*NewCC.h+(1-m_AlphaSize)*pB->h;
-                pBT->pResolver->SkipProcess(&(pBT->BlobPredict),pImg, pImgFG);
-            }   /* Non-collision tracking. */
-
-            pBT->pResolver->Update(pB, pImg, pImgFG);
-
-            CV_BLOB_ID(pB)=BlobID;
-
-        }   /* Track next blob. */
-
-        if(m_Wnd)
-        {
-            IplImage* pI = cvCloneImage(pImg);
-            for(int i=m_BlobListNew.GetBlobNum(); i>0; --i)
-            {   /* Draw each new CC: */
-                CvBlob* pB = m_BlobListNew.GetBlob(i-1);
-                CvPoint p = cvPointFrom32f(CV_BLOB_CENTER(pB));
-                int x = cvRound(CV_BLOB_RX(pB)), y = cvRound(CV_BLOB_RY(pB));
-                CvSize  s = cvSize(MAX(1,x), MAX(1,y));
-                //int c = 255;
-                cvEllipse( pI,
-                    p,
-                    s,
-                    0, 0, 360,
-                    CV_RGB(255,255,0), 1 );
-            }
-
-            for(int i=m_BlobList.GetBlobNum(); i>0; --i)
-            {   /* Draw each new CC: */
-                DefBlobTrackerCR* pF = (DefBlobTrackerCR*)m_BlobList.GetBlob(i-1);
-                CvBlob* pB = &(pF->BlobPredict);
-                CvPoint p = cvPointFrom32f(CV_BLOB_CENTER(pB));
-                int x = cvRound(CV_BLOB_RX(pB)), y = cvRound(CV_BLOB_RY(pB));
-                CvSize  s = cvSize(MAX(1,x), MAX(1,y));
-                cvEllipse( pI,
-                    p,
-                    s,
-                    0, 0, 360,
-                    CV_RGB(0,0,255), 1 );
-
-                pB = &(pF->blob);
-                p = cvPointFrom32f(CV_BLOB_CENTER(pB));
-                x = cvRound(CV_BLOB_RX(pB)); y = cvRound(CV_BLOB_RY(pB));
-                s = cvSize(MAX(1,x), MAX(1,y));
-                cvEllipse( pI,
-                    p,
-                    s,
-                    0, 0, 360,
-                    CV_RGB(0,255,0), 1 );
-            }
-
-            //cvNamedWindow("CCwithCR",0);
-            //cvShowImage("CCwithCR",pI);
-            cvReleaseImage(&pI);
-        }
-
-    } /* Process. */
-
-    virtual void SaveState(CvFileStorage* fs)
-    {
-        int     b,bN = m_BlobList.GetBlobNum();
-        cvWriteInt(fs,"BlobNum",m_BlobList.GetBlobNum());
-        cvStartWriteStruct(fs,"BlobList",CV_NODE_SEQ);
-
-        for(b=0; b<bN; ++b)
-        {
-            DefBlobTrackerCR* pF = (DefBlobTrackerCR*)m_BlobList.GetBlob(b);
-            cvStartWriteStruct(fs,NULL,CV_NODE_MAP);
-            cvWriteInt(fs,"ID",CV_BLOB_ID(pF));
-            cvStartWriteStruct(fs,"Blob",CV_NODE_SEQ|CV_NODE_FLOW);
-            cvWriteRawData(fs,&(pF->blob),1,"ffffi");
-            cvEndWriteStruct(fs);
-            cvStartWriteStruct(fs,"BlobPredict",CV_NODE_SEQ|CV_NODE_FLOW);
-            cvWriteRawData(fs,&(pF->BlobPredict),1,"ffffi");
-            cvEndWriteStruct(fs);
-            cvStartWriteStruct(fs,"BlobPrev",CV_NODE_SEQ|CV_NODE_FLOW);
-            cvWriteRawData(fs,&(pF->BlobPrev),1,"ffffi");
-            cvEndWriteStruct(fs);
-            pF->pBlobHyp->Write(fs,"BlobHyp");
-            cvWriteInt(fs,"Collision",pF->Collision);
-
-            cvStartWriteStruct(fs,"Predictor",CV_NODE_MAP);
-            pF->pPredictor->SaveState(fs);
-            cvEndWriteStruct(fs);
-
-            cvStartWriteStruct(fs,"Resolver",CV_NODE_MAP);
-            pF->pResolver->SaveState(fs);
-            cvEndWriteStruct(fs);
-            cvEndWriteStruct(fs);
-        }
-
-        cvEndWriteStruct(fs);
-
-    }   /* SaveState. */
-
-    virtual void LoadState(CvFileStorage* fs, CvFileNode* node)
-    {
-        int         b,bN = cvReadIntByName(fs,node,"BlobNum",0);
-        CvFileNode* pBlobListNode = cvGetFileNodeByName(fs,node,"BlobList");
-        if(!CV_NODE_IS_SEQ(pBlobListNode->tag)) return;
-        bN = pBlobListNode->data.seq->total;
-
-        for(b=0; b<bN; ++b)
-        {
-            DefBlobTrackerCR*   pF = NULL;
-            CvBlob              Blob;
-            CvFileNode*         pSeqNode = NULL;
-            CvFileNode*         pBlobNode = (CvFileNode*)cvGetSeqElem(pBlobListNode->data.seq,b);
-            assert(pBlobNode);
-
-            Blob.ID = cvReadIntByName(fs,pBlobNode,"ID",0);
-
-            pSeqNode = cvGetFileNodeByName(fs, pBlobNode, "Blob");
-            if(CV_NODE_IS_SEQ(pSeqNode->tag))
-                cvReadRawData( fs, pSeqNode, &Blob, "ffffi" );
-
-            AddBlob(&Blob,NULL,NULL);
-            pF = (DefBlobTrackerCR*)m_BlobList.GetBlobByID(Blob.ID);
-
-            pSeqNode = cvGetFileNodeByName(fs, pBlobNode, "BlobPredict");
-            if(CV_NODE_IS_SEQ(pSeqNode->tag))
-                cvReadRawData( fs, pSeqNode, &pF->BlobPredict, "ffffi" );
-
-            pSeqNode = cvGetFileNodeByName(fs, pBlobNode, "BlobPrev");
-            if(CV_NODE_IS_SEQ(pSeqNode->tag))
-                cvReadRawData( fs, pSeqNode, &pF->BlobPrev, "ffffi" );
-
-            pSeqNode = cvGetFileNodeByName(fs, pBlobNode, "BlobHyp");
-            if(pSeqNode)
-                pF->pBlobHyp->Load(fs,pSeqNode);
-            pF->Collision = cvReadIntByName(fs, pBlobNode,"Collision",pF->Collision);
-
-            pSeqNode = cvGetFileNodeByName(fs, pBlobNode, "Predictor");
-            if(pSeqNode)
-                pF->pPredictor->LoadState(fs,pSeqNode);
-
-            pSeqNode = cvGetFileNodeByName(fs, pBlobNode, "Resolver");
-            if(pSeqNode)
-                pF->pResolver->LoadState(fs,pSeqNode);
-        }   /* Read next blob. */
-    }   /*  CCwithCR LoadState */
-
-    //void SetCollision(int Collision){m_Collision = Collision;}
-};
-
-CvBlobTrackerOne* cvCreateBlobTrackerOneMSPF();
-CvBlobTracker* cvCreateBlobTrackerCCMSPF()
-{
-    return (CvBlobTracker*) new CvBlobTrackerCCCR(cvCreateBlobTrackerOneMSPF,"MSPF");
-}
-/*============== BLOB TRACKERCC CLASS DECLARATION =============== */
diff --git a/modules/legacy/src/blobtrackinglist.cpp b/modules/legacy/src/blobtrackinglist.cpp
deleted file mode 100644 (file)
index cbf0071..0000000
+++ /dev/null
@@ -1,548 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#define  PIX_HIST_BIN_NUM_1  3 //number of bins for classification (not used now)
-#define  PIX_HIST_BIN_NUM_2  5 //number of bins for statistic collection
-#define  PIX_HIST_ALPHA      0.01f //alpha-coefficient for running avarage procedure
-#define  PIX_HIST_DELTA      2 //maximal difference between descriptors(RGB)
-#define  PIX_HIST_COL_QUANTS 64 //quantization level in rgb-space
-#define  PIX_HIST_DELTA_IN_PIX_VAL  (PIX_HIST_DELTA * 256 / PIX_HIST_COL_QUANTS) //allowed difference in rgb-space
-
-// Structures for background statistics estimation:
-typedef struct CvPixHistBin{
-    float          bin_val;
-    uchar          cols[3];
-} CvPixHistBin;
-
-typedef struct CvPixHist{
-    CvPixHistBin   bins[PIX_HIST_BIN_NUM_2];
-} CvPixHist;
-
-// Class for background statistics estimation:
-class CvBGEstimPixHist
-{
-private:
-    CvPixHist*  m_PixHists;
-    int         m_width;
-    int         m_height;
-
-    // Function for update color histogram for one pixel:
-    void update_hist_elem(int x, int y, uchar* cols )
-    {
-        // Find closest bin:
-        int    dist = 0, min_dist = 2147483647, indx = -1;
-        for( int k = 0; k < PIX_HIST_BIN_NUM_2; k++ ){
-
-            uchar* hist_cols = m_PixHists[y*m_width+x].bins[k].cols;
-
-            m_PixHists[y*m_width+x].bins[k].bin_val *= (1-PIX_HIST_ALPHA);
-
-            int  l;
-            for( l = 0; l < 3; l++ ){
-                int val = abs( hist_cols[l] - cols[l] );
-                if( val > PIX_HIST_DELTA_IN_PIX_VAL ) break;
-                dist += val;
-            }
-
-            if( l == 3 && dist < min_dist ){
-                min_dist = dist;
-                indx = k;
-            }
-        }
-        if( indx < 0 ){   // N2th elem in the table is replaced by a new feature.
-            indx = PIX_HIST_BIN_NUM_2 - 1;
-            m_PixHists[y*m_width+x].bins[indx].bin_val = PIX_HIST_ALPHA;
-            for(int l = 0; l < 3; l++ ){
-                m_PixHists[y*m_width+x].bins[indx].cols[l] = cols[l];
-            }
-        }
-        else {
-            //add vote!
-            m_PixHists[y*m_width+x].bins[indx].bin_val += PIX_HIST_ALPHA;
-        }
-        // Re-sort bins by BIN_VAL:
-        {
-            int k;
-            for(k = 0; k < indx; k++ ){
-                if( m_PixHists[y*m_width+x].bins[k].bin_val <= m_PixHists[y*m_width+x].bins[indx].bin_val ){
-                    CvPixHistBin tmp1, tmp2 = m_PixHists[y*m_width+x].bins[indx];
-                    // Shift elements:
-                    for(int l = k; l <= indx; l++ ){
-                        tmp1 = m_PixHists[y*m_width+x].bins[l];
-                        m_PixHists[y*m_width+x].bins[l] = tmp2;
-                        tmp2 = tmp1;
-                    }
-                    break;
-                }
-            }
-        }
-    }   // void update_hist(...)
-
-    // Function for calculation difference between histograms:
-    float get_hist_diff(int x1, int y1, int x2, int y2)
-    {
-        float  dist = 0;
-        for( int i = 0; i < 3; i++ ){
-            dist += labs(m_PixHists[y1*m_width+x1].bins[0].cols[i] -
-                                m_PixHists[y2*m_width+x2].bins[0].cols[i]);
-        }
-        return dist;
-    }
-
-
-public:
-    IplImage*   bg_image;
-
-    CvBGEstimPixHist(CvSize img_size)
-    {
-        m_PixHists = (CvPixHist*)cvAlloc(img_size.width*img_size.height*sizeof(CvPixHist));
-        memset( m_PixHists, 0, img_size.width*img_size.height*sizeof(CvPixHist) );
-        m_width = img_size.width;
-        m_height = img_size.height;
-
-        bg_image = cvCreateImage(img_size, IPL_DEPTH_8U, 3 );
-    }   /* Constructor. */
-
-    ~CvBGEstimPixHist()
-    {
-        cvReleaseImage(&bg_image);
-        cvFree(&m_PixHists);
-    }   /* Destructor. */
-
-    // Function to update histograms and bg_image:
-    void update_hists( IplImage* pImg )
-    {
-        for( int i = 0; i < pImg->height; i++ ){
-            for( int j = 0; j < pImg->width; j++ ){
-                update_hist_elem( j, i, ((uchar*)(pImg->imageData))+i*pImg->widthStep+3*j );
-                ((uchar*)(bg_image->imageData))[i*bg_image->widthStep+3*j] = m_PixHists[i*m_width+j].bins[0].cols[0];
-                ((uchar*)(bg_image->imageData))[i*bg_image->widthStep+3*j+1] = m_PixHists[i*m_width+j].bins[0].cols[1];
-                ((uchar*)(bg_image->imageData))[i*bg_image->widthStep+3*j+2] = m_PixHists[i*m_width+j].bins[0].cols[2];
-            }
-        }
-        // cvNamedWindow("RoadMap2",0);
-        // cvShowImage("RoadMap2", bg_image);
-    }
-};  /* CvBGEstimPixHist */
-
-
-
-/*======================= TRACKER LIST SHELL =====================*/
-typedef struct DefBlobTrackerL
-{
-    CvBlob                  blob;
-    CvBlobTrackerOne*       pTracker;
-    int                     Frame;
-    int                     Collision;
-    CvBlobTrackPredictor*   pPredictor;
-    CvBlob                  BlobPredict;
-    CvBlobSeq*              pBlobHyp;
-} DefBlobTrackerL;
-
-class CvBlobTrackerList : public CvBlobTracker
-{
-private:
-    CvBlobTrackerOne*       (*m_Create)();
-    CvBlobSeq               m_BlobTrackerList;
-//    int                     m_LastID;
-    int                     m_Collision;
-    int                     m_ClearHyp;
-    float                   m_BGImageUsing;
-    CvBGEstimPixHist*       m_pBGImage;
-    IplImage*               m_pImgFG;
-    IplImage*               m_pImgReg; /* mask for multiblob confidence calculation */
-
-public:
-    CvBlobTrackerList(CvBlobTrackerOne* (*create)()):m_BlobTrackerList(sizeof(DefBlobTrackerL))
-    {
-        //int i;
-        CvBlobTrackerOne* pM = create();
-//        m_LastID = 0;
-        m_Create = create;
-        m_ClearHyp = 0;
-        m_pImgFG = 0;
-        m_pImgReg = NULL;
-
-        TransferParamsFromChild(pM,NULL);
-
-        pM->Release();
-
-        m_Collision = 1; /* if 1 then collistion will be detected and processed */
-        AddParam("Collision",&m_Collision);
-        CommentParam("Collision", "if 1 then collision cases are processed in special way");
-
-        m_pBGImage = NULL;
-        m_BGImageUsing = 50;
-        AddParam("BGImageUsing", &m_BGImageUsing);
-        CommentParam("BGImageUsing","Weight of using BG image in update hist model (0 - BG dies not use 1 - use)");
-
-        SetModuleName("List");
-    }
-
-    ~CvBlobTrackerList()
-    {
-        int i;
-        if(m_pBGImage) delete m_pBGImage;
-        if(m_pImgFG) cvReleaseImage(&m_pImgFG);
-        if(m_pImgReg) cvReleaseImage(&m_pImgReg);
-        for(i=m_BlobTrackerList.GetBlobNum();i>0;--i)
-        {
-            m_BlobTrackerList.DelBlob(i-1);
-        }
-    }
-
-    CvBlob* AddBlob(CvBlob* pBlob, IplImage* pImg, IplImage* pImgFG )
-    {   /* Create new tracker: */
-        DefBlobTrackerL F;
-        F.blob = pBlob[0];
-//        F.blob.ID = m_LastID++;
-        F.pTracker = m_Create();
-        F.pPredictor = cvCreateModuleBlobTrackPredictKalman();
-        F.pBlobHyp = new CvBlobSeq;
-        F.Frame = 0;
-        TransferParamsToChild(F.pTracker,NULL);
-
-        F.pTracker->Init(pBlob,pImg, pImgFG);
-        m_BlobTrackerList.AddBlob((CvBlob*)&F);
-        return m_BlobTrackerList.GetBlob(m_BlobTrackerList.GetBlobNum()-1);
-    }
-
-    void DelBlob(int BlobIndex)
-    {
-        DefBlobTrackerL* pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(BlobIndex);
-        if(pF == NULL) return;
-        pF->pTracker->Release();
-        pF->pPredictor->Release();
-        delete pF->pBlobHyp;
-        m_BlobTrackerList.DelBlob(BlobIndex);
-    }
-
-    void DelBlobByID(int BlobID)
-    {
-        DefBlobTrackerL* pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlobByID(BlobID);
-        if(pF == NULL) return;
-        pF->pTracker->Release();
-        pF->pPredictor->Release();
-        delete pF->pBlobHyp;
-        m_BlobTrackerList.DelBlobByID(BlobID);
-    }
-
-    virtual void Process(IplImage* pImg, IplImage* pImgFG = NULL)
-    {
-        int i;
-        if(pImgFG)
-        {
-            if(m_pImgFG) cvCopy(pImgFG,m_pImgFG);
-            else         m_pImgFG = cvCloneImage(pImgFG);
-        }
-
-        if(m_pBGImage==NULL && m_BGImageUsing>0)
-        {
-            m_pBGImage = new CvBGEstimPixHist(cvSize(pImg->width,pImg->height));
-        }
-
-        if(m_Collision)
-        for(i=m_BlobTrackerList.GetBlobNum(); i>0; --i)
-        {   /* Update predictor: */
-            DefBlobTrackerL* pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(i-1);
-            pF->pPredictor->Update((CvBlob*)pF);
-        }   /* Update predictor. */
-
-        if(m_pBGImage && m_pImgFG)
-        {   /* Weighting mask mask: */
-            int x,y,yN=pImg->height,xN=pImg->width;
-            IplImage* pImgBG = NULL;
-            m_pBGImage->update_hists(pImg);
-            pImgBG = m_pBGImage->bg_image;
-
-            for(y=0; y<yN; ++y)
-            {
-                unsigned char* pI = (unsigned char*)pImg->imageData + y*pImg->widthStep;
-                unsigned char* pBG = (unsigned char*)pImgBG->imageData + y*pImgBG->widthStep;
-                unsigned char* pFG = (unsigned char*)m_pImgFG->imageData +y*m_pImgFG->widthStep;
-
-                for(x=0; x<xN; ++x)
-                {
-                    if(pFG[x])
-                    {
-                        int D1 = (int)(pI[3*x+0])-(int)(pBG[3*x+0]);
-                        int D2 = (int)(pI[3*x+1])-(int)(pBG[3*x+1]);
-                        int D3 = (int)(pI[3*x+2])-(int)(pBG[3*x+2]);
-                        int DD = D1*D1+D2*D2+D3*D3;
-                        double  D = sqrt((float)DD);
-                        double  DW = 25;
-                        double  W = 1/(exp(-4*(D-m_BGImageUsing)/DW)+1);
-                        pFG[x] = (uchar)cvRound(W*255);
-                    }
-                }   /* Next mask pixel. */
-            }   /*  Next mask line. */
-            /*if(m_Wnd)
-            {
-                cvNamedWindow("BlobList_FGWeight",0);
-                cvShowImage("BlobList_FGWeight",m_pImgFG);
-            }*/
-        }   /* Weighting mask mask. */
-
-        for(i=m_BlobTrackerList.GetBlobNum(); i>0; --i)
-        {   /* Predict position. */
-            DefBlobTrackerL* pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(i-1);
-            CvBlob*         pB = pF->pPredictor->Predict();
-            if(pB)
-            {
-                pF->BlobPredict = pB[0];
-                pF->BlobPredict.w = pF->blob.w;
-                pF->BlobPredict.h = pF->blob.h;
-            }
-        }   /* Predict position. */
-
-        if(m_Collision)
-        for(i=m_BlobTrackerList.GetBlobNum(); i>0; --i)
-        {   /* Predict collision. */
-            int             Collision = 0;
-            int             j;
-            DefBlobTrackerL* pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(i-1);
-
-            for(j=m_BlobTrackerList.GetBlobNum(); j>0; --j)
-            {   /* Predict collision. */
-                CvBlob* pB1;
-                CvBlob* pB2;
-                DefBlobTrackerL* pF2 = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(j-1);
-                if(i==j) continue;
-                pB1 = &pF->BlobPredict;
-                pB2 = &pF2->BlobPredict;
-                if( fabs(pB1->x-pB2->x)<0.5*(pB1->w+pB2->w) &&
-                    fabs(pB1->y-pB2->y)<0.5*(pB1->h+pB2->h) ) Collision = 1;
-                pB1 = &pF->blob;
-                pB2 = &pF2->blob;
-                if( fabs(pB1->x-pB2->x)<0.5*(pB1->w+pB2->w) &&
-                    fabs(pB1->y-pB2->y)<0.5*(pB1->h+pB2->h) ) Collision = 1;
-                if(Collision) break;
-            }   /* Check next blob to cross current. */
-
-            pF->Collision = Collision;
-            pF->pTracker->SetCollision(Collision);
-
-        }   /* Predict collision. */
-
-        for(i=m_BlobTrackerList.GetBlobNum(); i>0; --i)
-        {   /* Track each blob. */
-            DefBlobTrackerL*    pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(i-1);
-            if(pF->pBlobHyp->GetBlobNum()>0)
-            {   /* Track all hypothesis. */
-                int h,hN = pF->pBlobHyp->GetBlobNum();
-                for(h=0;h<hN;++h)
-                {
-                    CvBlob*     pB = pF->pBlobHyp->GetBlob(h);
-                    CvBlob*     pNewBlob = pF->pTracker->Process(pB,pImg,m_pImgFG);
-                    int         BlobID = CV_BLOB_ID(pB);
-                    if(pNewBlob)
-                    {
-                        pB[0] = pNewBlob[0];
-                        pB->w = MAX(CV_BLOB_MINW,pNewBlob->w);
-                        pB->h = MAX(CV_BLOB_MINH,pNewBlob->h);
-                        CV_BLOB_ID(pB) = BlobID;
-                    }
-                }   /* Next hypothesis. */
-
-            }   /* Track all hypotheses. */
-
-            pF->Frame++;
-
-        }   /* Next blob. */
-
-#if 0
-        for(i=m_BlobTrackerList.GetBlobNum(); i>0; --i)
-        {   /* Update predictor: */
-            DefBlobTrackerL* pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(i-1);
-            if((m_Collision && !pF->Collision) || !m_Collision)
-            {
-                pF->pPredictor->Update((CvBlob*)pF);
-            }
-            else
-            {   /* pravilnyp putem idete tovarischy!!! */
-                pF->pPredictor->Update(&(pF->BlobPredict));
-            }
-        }   /* Update predictor. */
-#endif
-        m_ClearHyp = 1;
-    }
-
-
-    /* Process on blob (for multi hypothesis tracing) */
-    virtual void ProcessBlob(int BlobIndex, CvBlob* pBlob, IplImage* pImg, IplImage* /*pImgFG*/ = NULL)
-    {
-        int                 ID = pBlob->ID;
-        DefBlobTrackerL*    pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(BlobIndex);
-        CvBlob*             pNewBlob = pF->pTracker->Process(pBlob?pBlob:&(pF->blob),pImg,m_pImgFG);
-        if(pNewBlob)
-        {
-            pF->blob = pNewBlob[0];
-            pF->blob.w = MAX(CV_BLOB_MINW,pNewBlob->w);
-            pF->blob.h = MAX(CV_BLOB_MINH,pNewBlob->h);
-            pBlob[0] = pF->blob;
-        }
-        pBlob->ID = ID;
-    }
-
-    virtual double  GetConfidence(int BlobIndex, CvBlob* pBlob, IplImage* pImg, IplImage* pImgFG = NULL)
-    {
-        DefBlobTrackerL* pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(BlobIndex);
-        if(pF==NULL) return 0;
-        if(pF->pTracker==NULL) return 0;
-        return pF->pTracker->GetConfidence(pBlob?pBlob:(&pF->blob), pImg, pImgFG, NULL);
-    }
-
-    virtual double GetConfidenceList(CvBlobSeq* pBlobList, IplImage* pImg, IplImage* pImgFG = NULL)
-    {
-        double  W = 1;
-        int     b,bN = pBlobList->GetBlobNum();
-
-        if(m_pImgReg == NULL)
-        {
-            m_pImgReg = cvCreateImage(cvSize(pImg->width,pImg->height),IPL_DEPTH_8U,1);
-        }
-        assert(pImg);
-
-        cvSet(m_pImgReg,cvScalar(255));
-
-        for(b=0; b<bN; ++b)
-        {
-            CvBlob* pB = pBlobList->GetBlob(b);
-            DefBlobTrackerL* pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlobByID(pB->ID);
-            if(pF==NULL || pF->pTracker==NULL) continue;
-            W *= pF->pTracker->GetConfidence(pB, pImg, pImgFG, m_pImgReg );
-            cvEllipse(
-                m_pImgReg,
-                cvPoint(cvRound(pB->x*256),cvRound(pB->y*256)), cvSize(cvRound(pB->w*128),cvRound(pB->h*128)),
-                0, 0, 360,
-                cvScalar(0), CV_FILLED, 8, 8 );
-//            cvNamedWindow("REG",0);
-//            cvShowImage("REG",m_pImgReg);
-//            cvWaitKey(0);
-        }
-        return W;
-    }
-
-    virtual void UpdateBlob(int BlobIndex, CvBlob* pBlob, IplImage* pImg, IplImage* /*pImgFG*/ = NULL)
-    {
-        DefBlobTrackerL*    pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(BlobIndex);
-        if(pF)
-        {
-            pF->pTracker->Update(pBlob?pBlob:&(pF->blob),pImg,m_pImgFG);
-        }
-    }
-
-    int     GetBlobNum(){return m_BlobTrackerList.GetBlobNum();}
-    CvBlob* GetBlob(int index){return m_BlobTrackerList.GetBlob(index);}
-
-    void  SetBlob(int BlobIndex, CvBlob* pBlob)
-    {
-        CvBlob* pB = m_BlobTrackerList.GetBlob(BlobIndex);
-        if(pB)
-        {
-            pB[0] = pBlob[0];
-            pB->w = MAX(CV_BLOB_MINW, pBlob->w);
-            pB->h = MAX(CV_BLOB_MINH, pBlob->h);
-        }
-    }
-
-    void    Release(){delete this;}
-
-    /* Additional functionality: */
-    CvBlob* GetBlobByID(int BlobID){return m_BlobTrackerList.GetBlobByID(BlobID);}
-
-    /*  ===============  MULTI HYPOTHESIS INTERFACE ==================  */
-    /* Return number of position hypotheses of currently tracked blob: */
-    virtual int     GetBlobHypNum(int BlobIdx)
-    {
-        DefBlobTrackerL* pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(BlobIdx);
-        assert(pF->pBlobHyp);
-        return pF->pBlobHyp->GetBlobNum();
-    }  /* CvBlobtrackerList::GetBlobHypNum() */
-
-    /* Return pointer to specified blob hypothesis by index blob: */
-    virtual CvBlob* GetBlobHyp(int BlobIndex, int hypothesis)
-    {
-        DefBlobTrackerL* pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(BlobIndex);
-        assert(pF->pBlobHyp);
-        return pF->pBlobHyp->GetBlob(hypothesis);
-    }  /* CvBlobtrackerList::GetBlobHyp() */
-
-    /* Set new parameters for specified (by index) blob hyp (can be called several times for each hyp )*/
-    virtual void    SetBlobHyp(int BlobIndex, CvBlob* pBlob)
-    {
-        if(m_ClearHyp)
-        {   /* Clear all hypotheses: */
-            int b, bN = m_BlobTrackerList.GetBlobNum();
-            for(b=0; b<bN; ++b)
-            {
-                DefBlobTrackerL* pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(b);
-                assert(pF->pBlobHyp);
-                pF->pBlobHyp->Clear();
-            }
-            m_ClearHyp = 0;
-        }
-        {   /* Add hypothesis: */
-            DefBlobTrackerL* pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(BlobIndex);
-            assert(pF->pBlobHyp);
-            pF->pBlobHyp->AddBlob(pBlob);
-        }
-    }  /* CvBlobtrackerList::SetBlobHyp */
-
-private:
-public:
-    void ParamUpdate()
-    {
-        int i;
-        for(i=m_BlobTrackerList.GetBlobNum(); i>0; --i)
-        {
-            DefBlobTrackerL* pF = (DefBlobTrackerL*)m_BlobTrackerList.GetBlob(i-1);
-            TransferParamsToChild(pF->pTracker);
-            pF->pTracker->ParamUpdate();
-        }
-    }
-};  /* CvBlobTrackerList */
-
-CvBlobTracker* cvCreateBlobTrackerList(CvBlobTrackerOne* (*create)())
-{
-    return (CvBlobTracker*) new CvBlobTrackerList(create);
-}
diff --git a/modules/legacy/src/blobtrackingmsfg.cpp b/modules/legacy/src/blobtrackingmsfg.cpp
deleted file mode 100644 (file)
index a26ce02..0000000
+++ /dev/null
@@ -1,1181 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#ifdef _OPENMP
-#include "omp.h"
-#endif
-
-// Uncomment to trade flexibility for speed
-//#define CONST_HIST_SIZE
-
-// Uncomment to get some performance stats in stderr
-//#define REPORT_TICKS
-
-#ifdef CONST_HIST_SIZE
-#define m_BinBit 5
-#define m_ByteShift 3
-#endif
-
-typedef float DefHistType;
-#define DefHistTypeMat CV_32F
-#define HIST_INDEX(_pData) (((_pData)[0]>>m_ByteShift) + (((_pData)[1]>>(m_ByteShift))<<m_BinBit)+((pImgData[2]>>m_ByteShift)<<(m_BinBit*2)))
-
-class DefHist
-{
-public:
-    CvMat*          m_pHist;
-    DefHistType     m_HistVolume;
-    DefHist(int BinNum=0)
-    {
-        m_pHist = NULL;
-        m_HistVolume = 0;
-        Resize(BinNum);
-    }
-
-    ~DefHist()
-    {
-        if(m_pHist)cvReleaseMat(&m_pHist);
-    }
-
-    void Resize(int BinNum)
-    {
-        if(m_pHist)cvReleaseMat(&m_pHist);
-        if(BinNum>0)
-        {
-            m_pHist = cvCreateMat(1, BinNum, DefHistTypeMat);
-            cvZero(m_pHist);
-        }
-        m_HistVolume = 0;
-    }
-
-    void Update(DefHist* pH, float W)
-    {   /* Update histogram: */
-        double  Vol, WM, WC;
-        Vol = 0.5*(m_HistVolume + pH->m_HistVolume);
-        WM = Vol*(1-W)/m_HistVolume;
-        WC = Vol*(W)/pH->m_HistVolume;
-        cvAddWeighted(m_pHist, WM, pH->m_pHist,WC,0,m_pHist);
-        m_HistVolume = (float)cvSum(m_pHist).val[0];
-    }   /* Update histogram: */
-};
-
-class CvBlobTrackerOneMSFG:public CvBlobTrackerOne
-{
-protected:
-    int             m_BinNumTotal; /* protected only for parralel MSPF */
-    CvSize          m_ObjSize;
-
-    void ReAllocKernel(int  w, int h)
-    {
-        int     x,y;
-        float   x0 = 0.5f*(w-1);
-        float   y0 = 0.5f*(h-1);
-        assert(w>0);
-        assert(h>0);
-        m_ObjSize = cvSize(w,h);
-
-        if(m_KernelHist) cvReleaseMat(&m_KernelHist);
-        if(m_KernelMeanShift) cvReleaseMat(&m_KernelMeanShift);
-        m_KernelHist = cvCreateMat(h, w, DefHistTypeMat);
-        m_KernelMeanShift = cvCreateMat(h, w, DefHistTypeMat);
-
-        for(y=0; y<h; ++y) for(x=0; x<w; ++x)
-        {
-            double r2 = ((x-x0)*(x-x0)/(x0*x0)+(y-y0)*(y-y0)/(y0*y0));
-//            double r2 = ((x-x0)*(x-x0)+(y-y0)*(y-y0))/((y0*y0)+(x0*x0));
-            CV_MAT_ELEM(m_KernelHist[0],DefHistType, y, x) = (DefHistType)GetKernelHist(r2);
-            CV_MAT_ELEM(m_KernelMeanShift[0],DefHistType, y, x) = (DefHistType)GetKernelMeanShift(r2);
-        }
-    }
-
-private:
-    /* Parameters: */
-    int             m_IterNum;
-    float           m_FGWeight;
-    float           m_Alpha;
-    CvMat*          m_KernelHist;
-    CvMat*          m_KernelMeanShift;
-#ifndef CONST_HIST_SIZE
-    int             m_BinBit;
-    int             m_ByteShift;
-#endif
-    int             m_BinNum;
-    int             m_Dim;
-    /*
-    CvMat*          m_HistModel;
-    float           m_HistModelVolume;
-    CvMat*          m_HistCandidate;
-    float           m_HistCandidateVolume;
-    CvMat*          m_HistTemp;
-    */
-    DefHist         m_HistModel;
-    DefHist         m_HistCandidate;
-    DefHist         m_HistTemp;
-
-    CvBlob          m_Blob;
-    int             m_Collision;
-
-    void ReAllocHist(int Dim, int BinBit)
-    {
-#ifndef CONST_HIST_SIZE
-        m_BinBit = BinBit;
-        m_ByteShift = 8-BinBit;
-#endif
-        m_Dim = Dim;
-        m_BinNum = (1<<BinBit);
-        m_BinNumTotal = cvRound(pow((double)m_BinNum,(double)m_Dim));
-        /*
-        if(m_HistModel) cvReleaseMat(&m_HistModel);
-        if(m_HistCandidate) cvReleaseMat(&m_HistCandidate);
-        if(m_HistTemp) cvReleaseMat(&m_HistTemp);
-        m_HistCandidate = cvCreateMat(1, m_BinNumTotal, DefHistTypeMat);
-        m_HistModel = cvCreateMat(1, m_BinNumTotal, DefHistTypeMat);
-        m_HistTemp = cvCreateMat(1, m_BinNumTotal, DefHistTypeMat);
-        cvZero(m_HistCandidate);
-        cvZero(m_HistModel);
-        m_HistModelVolume = 0.0f;
-        m_HistCandidateVolume = 0.0f;
-        */
-        m_HistCandidate.Resize(m_BinNumTotal);
-        m_HistModel.Resize(m_BinNumTotal);
-        m_HistTemp.Resize(m_BinNumTotal);
-    }
-
-    double GetKernelHist(double r2)
-    {
-        return (r2 < 1) ? 1 -  r2 : 0;
-    }
-
-    double GetKernelMeanShift(double r2)
-    {
-        return (r2<1) ? 1 : 0;
-    }
-
-//    void CollectHist(IplImage* pImg, IplImage* pMask, CvPoint Center, CvMat* pHist, DefHistType* pHistVolume)
-//    void CollectHist(IplImage* pImg, IplImage* pMask, CvPoint Center, DefHist* pHist)
-
-    void CollectHist(IplImage* pImg, IplImage* pMask, CvBlob* pBlob, DefHist* pHist)
-    {
-        int UsePrecalculatedKernel = 0;
-        int BW = cvRound(pBlob->w);
-        int BH = cvRound(pBlob->h);
-        DefHistType Volume = 0;
-        int         x0 = cvRound(pBlob->x - BW*0.5);
-        int         y0 = cvRound(pBlob->y - BH*0.5);
-        int         x,y;
-
-        UsePrecalculatedKernel = (BW == m_ObjSize.width && BH == m_ObjSize.height ) ;
-
-        //cvZero(pHist);
-        cvSet(pHist->m_pHist,cvScalar(1.0/m_BinNumTotal)); /* no zero bins, all bins have very small value*/
-        Volume = 1;
-
-        assert(BW < pImg->width);
-        assert(BH < pImg->height);
-        if((x0+BW)>=pImg->width) BW=pImg->width-x0-1;
-        if((y0+BH)>=pImg->height) BH=pImg->height-y0-1;
-        if(x0<0){ x0=0;}
-        if(y0<0){ y0=0;}
-
-        if(m_Dim == 3)
-        {
-            for(y=0; y<BH; ++y)
-            {
-                unsigned char* pImgData = &CV_IMAGE_ELEM(pImg,unsigned char,y+y0,x0*3);
-                unsigned char* pMaskData = pMask?(&CV_IMAGE_ELEM(pMask,unsigned char,y+y0,x0)):NULL;
-                DefHistType* pKernelData = NULL;
-
-                if(UsePrecalculatedKernel)
-                {
-                    pKernelData = ((DefHistType*)CV_MAT_ELEM_PTR_FAST(m_KernelHist[0],y,0,sizeof(DefHistType)));
-                }
-
-                for(x=0; x<BW; ++x, pImgData+=3)
-                {
-                    DefHistType K;
-                    int index = HIST_INDEX(pImgData);
-                    assert(index >= 0 && index < pHist->m_pHist->cols);
-
-                    if(UsePrecalculatedKernel)
-                    {
-                        K = pKernelData[x];
-                    }
-                    else
-                    {
-                        float dx = (x+x0-pBlob->x)/(pBlob->w*0.5f);
-                        float dy = (y+y0-pBlob->y)/(pBlob->h*0.5f);
-                        double r2 = dx*dx+dy*dy;
-                        K = (float)GetKernelHist(r2);
-                    }
-
-                    if(pMaskData)
-                    {
-                        K *= pMaskData[x]*0.003921568627450980392156862745098f;
-                    }
-                    Volume += K;
-                    ((DefHistType*)(pHist->m_pHist->data.ptr))[index] += K;
-
-                }   /* Next column. */
-            }   /*  Next row. */
-        }   /* if m_Dim == 3. */
-
-        pHist->m_HistVolume = Volume;
-
-    }  /* CollectHist */
-
-    double calcBhattacharyya(DefHist* pHM = NULL, DefHist* pHC = NULL, DefHist* pHT = NULL)
-    {
-        if(pHM==NULL) pHM = &m_HistModel;
-        if(pHC==NULL) pHC = &m_HistCandidate;
-        if(pHT==NULL) pHT = &m_HistTemp;
-        if(pHC->m_HistVolume*pHM->m_HistVolume > 0)
-        {
-#if 0
-            // Use CV functions:
-            cvMul(pHM->m_pHist,pHC->m_pHist,pHT->m_pHist);
-            cvPow(pHT->m_pHist,pHT->m_pHist,0.5);
-            return cvSum(pHT->m_pHist).val[0] / sqrt(pHC->m_HistVolume*pHM->m_HistVolume);
-#else
-            // Do computations manually and let autovectorizer do the job:
-            DefHistType* hm=(DefHistType *)(pHM->m_pHist->data.ptr);
-            DefHistType* hc=(DefHistType *)(pHC->m_pHist->data.ptr);
-            //ht=(DefHistType *)(pHT->m_pHist->data.ptr);
-            int size = pHM->m_pHist->width*pHM->m_pHist->height;
-            double sum = 0.;
-            for(int i = 0; i < size; i++ )
-            {
-                sum += sqrt(hm[i]*hc[i]);
-            }
-            return sum / sqrt(pHC->m_HistVolume*pHM->m_HistVolume);
-#endif
-        }
-        return 0;
-    }   /* calcBhattacharyyaCoefficient. */
-
-protected:
-    // double GetBhattacharyya(IplImage* pImg, IplImage* pImgFG, float x, float y, DefHist* pHist=NULL)
-    double GetBhattacharyya(IplImage* pImg, IplImage* pImgFG, CvBlob* pBlob, DefHist* pHist=NULL, int /*thread_number*/ = 0)
-    {
-        if(pHist==NULL)pHist = &m_HistTemp;
-        CollectHist(pImg, pImgFG, pBlob, pHist);
-        return calcBhattacharyya(&m_HistModel, pHist, pHist);
-    }
-
-    void UpdateModelHist(IplImage* pImg, IplImage* pImgFG, CvBlob* pBlob)
-    {
-        if(m_Alpha>0 && !m_Collision)
-        {   /* Update histogram: */
-            CollectHist(pImg, pImgFG, pBlob, &m_HistCandidate);
-            m_HistModel.Update(&m_HistCandidate, m_Alpha);
-        }   /* Update histogram. */
-
-    }   /* UpdateModelHist */
-
-public:
-    CvBlobTrackerOneMSFG()
-    {
-
-        /* Add several parameters for external use: */
-        m_FGWeight = 2;
-        AddParam("FGWeight", &m_FGWeight);
-        CommentParam("FGWeight","Weight of FG mask using (0 - mask will not be used for tracking)");
-
-        m_Alpha = 0.01f;
-        AddParam("Alpha", &m_Alpha);
-        CommentParam("Alpha","Coefficient for model histogram updating (0 - hist is not upated)");
-
-        m_IterNum = 10;
-        AddParam("IterNum", &m_IterNum);
-        CommentParam("IterNum","Maximal number of iteration in meanshift operation");
-
-        /* Initialize internal data: */
-        m_Collision = 0;
-//        m_BinBit=0;
-        m_Dim = 0;
-        /*
-        m_HistModel = NULL;
-        m_HistCandidate = NULL;
-        m_HistTemp = NULL;
-        */
-        m_KernelHist = NULL;
-        m_KernelMeanShift = NULL;
-        ReAllocHist(3,5);   /* 3D hist, each dim has 2^5 bins*/
-
-        SetModuleName("MSFG");
-    }
-
-    ~CvBlobTrackerOneMSFG()
-    {
-        /*
-        if(m_HistModel) cvReleaseMat(&m_HistModel);
-        if(m_HistCandidate) cvReleaseMat(&m_HistCandidate);
-        if(m_HistTemp) cvReleaseMat(&m_HistTemp);
-        */
-        if(m_KernelHist) cvReleaseMat(&m_KernelHist);
-        if(m_KernelMeanShift) cvReleaseMat(&m_KernelMeanShift);
-    }
-
-    /* Interface: */
-    virtual void Init(CvBlob* pBlobInit, IplImage* pImg, IplImage* pImgFG = NULL)
-    {
-        int w = cvRound(CV_BLOB_WX(pBlobInit));
-        int h = cvRound(CV_BLOB_WY(pBlobInit));
-        if(w<CV_BLOB_MINW)w=CV_BLOB_MINW;
-        if(h<CV_BLOB_MINH)h=CV_BLOB_MINH;
-        if(pImg)
-        {
-            if(w>pImg->width)w=pImg->width;
-            if(h>pImg->height)h=pImg->height;
-        }
-        ReAllocKernel(w,h);
-        if(pImg)
-            CollectHist(pImg, pImgFG, pBlobInit, &m_HistModel);
-        m_Blob = pBlobInit[0];
-    }
-
-    virtual CvBlob* Process(CvBlob* pBlobPrev, IplImage* pImg, IplImage* pImgFG = NULL)
-    {
-        int     iter;
-
-        if(pBlobPrev)
-        {
-            m_Blob = pBlobPrev[0];
-        }
-
-        {   /* Check blob size and realloc kernels if it is necessary: */
-            int w = cvRound(m_Blob.w);
-            int h = cvRound(m_Blob.h);
-            if( w != m_ObjSize.width || h!=m_ObjSize.height)
-            {
-                ReAllocKernel(w,h);
-                /* after this ( w != m_ObjSize.width || h!=m_ObjSize.height) shoiuld be false */
-            }
-        }   /* Check blob size and realloc kernels if it is necessary: */
-
-
-        for(iter=0; iter<m_IterNum; ++iter)
-        {
-            float   newx=0,newy=0,sum=0;
-            //int     x,y;
-            double  B0;
-
-            //CvPoint Center = cvPoint(cvRound(m_Blob.x),cvRound(m_Blob.y));
-            CollectHist(pImg, NULL, &m_Blob, &m_HistCandidate);
-            B0 = calcBhattacharyya();
-
-            if(m_Wnd)if(CV_BLOB_ID(pBlobPrev)==0 && iter == 0)
-            {   /* Debug: */
-                IplImage*   pW = cvCloneImage(pImgFG);
-                IplImage*   pWFG = cvCloneImage(pImgFG);
-                int         x,y;
-
-                cvZero(pW);
-                cvZero(pWFG);
-
-                assert(m_ObjSize.width < pImg->width);
-                assert(m_ObjSize.height < pImg->height);
-
-                /* Calculate shift vector: */
-                for(y=0; y<pImg->height; ++y)
-                {
-                    unsigned char* pImgData = &CV_IMAGE_ELEM(pImg,unsigned char,y,0);
-                    unsigned char* pMaskData = pImgFG?(&CV_IMAGE_ELEM(pImgFG,unsigned char,y,0)):NULL;
-
-                    for(x=0; x<pImg->width; ++x, pImgData+=3)
-                    {
-                        int         xk = cvRound(x-(m_Blob.x-m_Blob.w*0.5));
-                        int         yk = cvRound(y-(m_Blob.y-m_Blob.h*0.5));
-                        double      HM = 0;
-                        double      HC = 0;
-                        double      K;
-                        int index = HIST_INDEX(pImgData);
-                        assert(index >= 0 && index < m_BinNumTotal);
-
-                        if(fabs(x-m_Blob.x)>m_Blob.w*0.6) continue;
-                        if(fabs(y-m_Blob.y)>m_Blob.h*0.6) continue;
-
-                        if(xk < 0 || xk >= m_KernelMeanShift->cols) continue;
-                        if(yk < 0 || yk >= m_KernelMeanShift->rows) continue;
-
-                        if(m_HistModel.m_HistVolume>0)
-                            HM = ((DefHistType*)m_HistModel.m_pHist->data.ptr)[index]/m_HistModel.m_HistVolume;
-
-                        if(m_HistCandidate.m_HistVolume>0)
-                            HC = ((DefHistType*)m_HistCandidate.m_pHist->data.ptr)[index]/m_HistCandidate.m_HistVolume;
-
-                        K = *(DefHistType*)CV_MAT_ELEM_PTR_FAST(m_KernelMeanShift[0],yk,xk,sizeof(DefHistType));
-
-                        if(HC>0)
-                        {
-                            double  V = sqrt(HM / HC);
-                            int     Vi = cvRound(V * 64);
-                            if(Vi < 0) Vi = 0;
-                            if(Vi > 255) Vi = 255;
-                            CV_IMAGE_ELEM(pW,uchar,y,x) = (uchar)Vi;
-
-                            V += m_FGWeight*(pMaskData?(pMaskData[x]/255.0f):0);
-                            V*=K;
-                            Vi = cvRound(V * 64);
-                            if(Vi < 0) Vi = 0;
-                            if(Vi > 255) Vi = 255;
-                            CV_IMAGE_ELEM(pWFG,uchar,y,x) = (uchar)Vi;
-                        }
-
-                    }   /* Next column. */
-                }   /*  Next row. */
-
-                //cvNamedWindow("MSFG_W",0);
-                //cvShowImage("MSFG_W",pW);
-                //cvNamedWindow("MSFG_WFG",0);
-                //cvShowImage("MSFG_WFG",pWFG);
-                //cvNamedWindow("MSFG_FG",0);
-                //cvShowImage("MSFG_FG",pImgFG);
-
-                //cvSaveImage("MSFG_W.bmp",pW);
-                //cvSaveImage("MSFG_WFG.bmp",pWFG);
-                //cvSaveImage("MSFG_FG.bmp",pImgFG);
-
-            }   /* Debug. */
-
-
-            /* Calculate new position by meanshift: */
-
-            /* Calculate new position: */
-            if(m_Dim == 3)
-            {
-                int         x0 = cvRound(m_Blob.x - m_ObjSize.width*0.5);
-                int         y0 = cvRound(m_Blob.y - m_ObjSize.height*0.5);
-                int         x,y;
-
-                assert(m_ObjSize.width < pImg->width);
-                assert(m_ObjSize.height < pImg->height);
-
-                /* Crop blob bounds: */
-                if((x0+m_ObjSize.width)>=pImg->width) x0=pImg->width-m_ObjSize.width-1;
-                if((y0+m_ObjSize.height)>=pImg->height) y0=pImg->height-m_ObjSize.height-1;
-                if(x0<0){ x0=0;}
-                if(y0<0){ y0=0;}
-
-                /* Calculate shift vector: */
-                for(y=0; y<m_ObjSize.height; ++y)
-                {
-                    unsigned char* pImgData = &CV_IMAGE_ELEM(pImg,unsigned char,y+y0,x0*3);
-                    unsigned char* pMaskData = pImgFG?(&CV_IMAGE_ELEM(pImgFG,unsigned char,y+y0,x0)):NULL;
-                    DefHistType* pKernelData = (DefHistType*)CV_MAT_ELEM_PTR_FAST(m_KernelMeanShift[0],y,0,sizeof(DefHistType));
-
-                    for(x=0; x<m_ObjSize.width; ++x, pImgData+=3)
-                    {
-                        DefHistType K = pKernelData[x];
-                        double      HM = 0;
-                        double      HC = 0;
-                        int index = HIST_INDEX(pImgData);
-                        assert(index >= 0 && index < m_BinNumTotal);
-
-                        if(m_HistModel.m_HistVolume>0)
-                            HM = ((DefHistType*)m_HistModel.m_pHist->data.ptr)[index]/m_HistModel.m_HistVolume;
-
-                        if(m_HistCandidate.m_HistVolume>0)
-                            HC = ((DefHistType*)m_HistCandidate.m_pHist->data.ptr)[index]/m_HistCandidate.m_HistVolume;
-
-                        if(HC>0)
-                        {
-                            double V = sqrt(HM / HC);
-                            if(!m_Collision && m_FGWeight>0 && pMaskData)
-                            {
-                                V += m_FGWeight*(pMaskData[x]/255.0f);
-                            }
-                            K *= (float)MIN(V,100000.);
-                        }
-
-                        sum += K;
-                        newx += K*x;
-                        newy += K*y;
-                    }   /* Next column. */
-                }   /*  Next row. */
-
-                if(sum > 0)
-                {
-                    newx /= sum;
-                    newy /= sum;
-                }
-                newx += x0;
-                newy += y0;
-
-            }   /* if m_Dim == 3. */
-
-            /* Calculate new position by meanshift: */
-
-            for(;;)
-            {   /* Iterate using bahattcharrya coefficient: */
-                double  B1;
-                CvBlob  B = m_Blob;
-//                CvPoint NewCenter = cvPoint(cvRound(newx),cvRound(newy));
-                B.x = newx;
-                B.y = newy;
-                CollectHist(pImg, NULL, &B, &m_HistCandidate);
-                B1 = calcBhattacharyya();
-                if(B1 > B0) break;
-                newx = 0.5f*(newx+m_Blob.x);
-                newy = 0.5f*(newy+m_Blob.y);
-                if(fabs(newx-m_Blob.x)<0.1 && fabs(newy-m_Blob.y)<0.1) break;
-            }   /* Iterate using bahattcharrya coefficient. */
-
-            if(fabs(newx-m_Blob.x)<0.5 && fabs(newy-m_Blob.y)<0.5) break;
-            m_Blob.x = newx;
-            m_Blob.y = newy;
-        }   /* Next iteration. */
-
-        while(!m_Collision && m_FGWeight>0)
-        {   /* Update size if no collision. */
-            float       Alpha = 0.04f;
-            CvBlob      NewBlob;
-            double      M00,X,Y,XX,YY;
-            CvMoments   m;
-            CvRect      r;
-            CvMat       mat;
-
-            r.width = cvRound(m_Blob.w*1.5+0.5);
-            r.height = cvRound(m_Blob.h*1.5+0.5);
-            r.x = cvRound(m_Blob.x - 0.5*r.width);
-            r.y = cvRound(m_Blob.y - 0.5*r.height);
-            if(r.x < 0) break;
-            if(r.y < 0) break;
-            if(r.x+r.width >= pImgFG->width) break;
-            if(r.y+r.height >= pImgFG->height) break;
-            if(r.height < 5 || r.width < 5) break;
-
-            cvMoments( cvGetSubRect(pImgFG,&mat,r), &m, 0 );
-            M00 = cvGetSpatialMoment( &m, 0, 0 );
-            if(M00 <= 0 ) break;
-            X = cvGetSpatialMoment( &m, 1, 0 )/M00;
-            Y = cvGetSpatialMoment( &m, 0, 1 )/M00;
-            XX = (cvGetSpatialMoment( &m, 2, 0 )/M00) - X*X;
-            YY = (cvGetSpatialMoment( &m, 0, 2 )/M00) - Y*Y;
-            NewBlob = cvBlob(r.x+(float)X,r.y+(float)Y,(float)(4*sqrt(XX)),(float)(4*sqrt(YY)));
-
-            NewBlob.w = Alpha*NewBlob.w+m_Blob.w*(1-Alpha);
-            NewBlob.h = Alpha*NewBlob.h+m_Blob.h*(1-Alpha);
-
-            m_Blob.w = MAX(NewBlob.w,5);
-            m_Blob.h = MAX(NewBlob.h,5);
-            break;
-
-        }   /* Update size if no collision. */
-
-        return &m_Blob;
-
-    }  /* CvBlobTrackerOneMSFG::Process */
-
-    virtual double GetConfidence(CvBlob* pBlob, IplImage* pImg, IplImage* /*pImgFG*/ = NULL, IplImage* pImgUnusedReg = NULL)
-    {
-        double  S = 0.2;
-        double  B = GetBhattacharyya(pImg, pImgUnusedReg, pBlob, &m_HistTemp);
-        return exp((B-1)/(2*S));
-
-    }  /*CvBlobTrackerOneMSFG::*/
-
-    virtual void Update(CvBlob* pBlob, IplImage* pImg, IplImage* pImgFG = NULL)
-    {   /* Update histogram: */
-        UpdateModelHist(pImg, pImgFG, pBlob?pBlob:&m_Blob);
-    }   /*CvBlobTrackerOneMSFG::*/
-
-    virtual void Release(){delete this;}
-    virtual void SetCollision(int CollisionFlag)
-    {
-        m_Collision = CollisionFlag;
-    }
-    virtual void SaveState(CvFileStorage* fs)
-    {
-        cvWriteStruct(fs, "Blob", &m_Blob, "ffffi");
-        cvWriteInt(fs,"Collision", m_Collision);
-        cvWriteInt(fs,"HistVolume", cvRound(m_HistModel.m_HistVolume));
-        cvWrite(fs,"Hist", m_HistModel.m_pHist);
-    }
-    virtual void LoadState(CvFileStorage* fs, CvFileNode* node)
-    {
-        CvMat* pM;
-        cvReadStructByName(fs, node, "Blob",&m_Blob, "ffffi");
-        m_Collision = cvReadIntByName(fs,node,"Collision",m_Collision);
-        pM = (CvMat*)cvRead(fs,cvGetFileNodeByName(fs,node,"Hist"));
-        if(pM)
-        {
-            m_HistModel.m_pHist = pM;
-            m_HistModel.m_HistVolume = (float)cvSum(pM).val[0];
-        }
-    }
-
-};  /*CvBlobTrackerOneMSFG*/
-
-#if 0
-void CvBlobTrackerOneMSFG::CollectHist(IplImage* pImg, IplImage* pMask, CvBlob* pBlob, DefHist* pHist)
-{
-    int UsePrecalculatedKernel = 0;
-    int BW = cvRound(pBlob->w);
-    int BH = cvRound(pBlob->h);
-    DefHistType Volume = 0;
-    int         x0 = cvRound(pBlob->x - BW*0.5);
-    int         y0 = cvRound(pBlob->y - BH*0.5);
-    int         x,y;
-
-    UsePrecalculatedKernel = (BW == m_ObjSize.width && BH == m_ObjSize.height ) ;
-
-    //cvZero(pHist);
-    cvSet(pHist->m_pHist,cvScalar(1.0/m_BinNumTotal)); /* no zero bins, all bins have very small value*/
-    Volume = 1;
-
-    assert(BW < pImg->width);
-    assert(BH < pImg->height);
-    if((x0+BW)>=pImg->width) BW=pImg->width-x0-1;
-    if((y0+BH)>=pImg->height) BH=pImg->height-y0-1;
-    if(x0<0){ x0=0;}
-    if(y0<0){ y0=0;}
-
-    if(m_Dim == 3)
-    {
-        for(y=0; y<BH; ++y)
-        {
-            unsigned char* pImgData = &CV_IMAGE_ELEM(pImg,unsigned char,y+y0,x0*3);
-            unsigned char* pMaskData = pMask?(&CV_IMAGE_ELEM(pMask,unsigned char,y+y0,x0)):NULL;
-            DefHistType* pKernelData = NULL;
-
-            if(UsePrecalculatedKernel)
-            {
-                pKernelData = ((DefHistType*)CV_MAT_ELEM_PTR_FAST(m_KernelHist[0],y,0,sizeof(DefHistType)));
-            }
-
-            for(x=0; x<BW; ++x, pImgData+=3)
-            {
-                DefHistType K;
-                int index = HIST_INDEX(pImgData);
-                assert(index >= 0 && index < pHist->m_pHist->cols);
-
-                if(UsePrecalculatedKernel)
-                {
-                    K = pKernelData[x];
-                }
-                else
-                {
-                    float dx = (x+x0-pBlob->x)/(pBlob->w*0.5);
-                    float dy = (y+y0-pBlob->y)/(pBlob->h*0.5);
-                    double r2 = dx*dx+dy*dy;
-                    K = GetKernelHist(r2);
-                }
-
-                if(pMaskData)
-                {
-                    K *= pMaskData[x]*0.003921568627450980392156862745098;
-                }
-                Volume += K;
-                ((DefHistType*)(pHist->m_pHist->data.ptr))[index] += K;
-
-            }   /* Next column. */
-        }   /*  Next row. */
-    }   /*  if m_Dim == 3. */
-
-    pHist->m_HistVolume = Volume;
-
-};  /* CollectHist */
-#endif
-
-static CvBlobTrackerOne* cvCreateBlobTrackerOneMSFG()
-{
-    return (CvBlobTrackerOne*) new CvBlobTrackerOneMSFG;
-}
-
-CvBlobTracker* cvCreateBlobTrackerMSFG()
-{
-    return cvCreateBlobTrackerList(cvCreateBlobTrackerOneMSFG);
-}
-
-/* Create specific tracker without FG
- * usin - just simple mean-shift tracker: */
-class CvBlobTrackerOneMS:public CvBlobTrackerOneMSFG
-{
-public:
-    CvBlobTrackerOneMS()
-    {
-        SetParam("FGWeight",0);
-        DelParam("FGWeight");
-        SetModuleName("MS");
-    };
-};
-
-static CvBlobTrackerOne* cvCreateBlobTrackerOneMS()
-{
-    return (CvBlobTrackerOne*) new CvBlobTrackerOneMS;
-}
-
-CvBlobTracker* cvCreateBlobTrackerMS()
-{
-    return cvCreateBlobTrackerList(cvCreateBlobTrackerOneMS);
-}
-
-typedef struct DefParticle
-{
-    CvBlob  blob;
-    float   Vx,Vy;
-    double  W;
-} DefParticle;
-
-class CvBlobTrackerOneMSPF:public CvBlobTrackerOneMS
-{
-private:
-    /* parameters */
-    int             m_ParticleNum;
-    float           m_UseVel;
-    float           m_SizeVar;
-    float           m_PosVar;
-
-    CvSize          m_ImgSize;
-    CvBlob          m_Blob;
-    DefParticle*    m_pParticlesPredicted;
-    DefParticle*    m_pParticlesResampled;
-    CvRNG           m_RNG;
-#ifdef _OPENMP
-    int             m_ThreadNum;
-    DefHist*        m_HistForParalel;
-#endif
-
-public:
-    virtual void SaveState(CvFileStorage* fs)
-    {
-        CvBlobTrackerOneMS::SaveState(fs);
-        cvWriteInt(fs,"ParticleNum",m_ParticleNum);
-        cvWriteStruct(fs,"ParticlesPredicted",m_pParticlesPredicted,"ffffiffd",m_ParticleNum);
-        cvWriteStruct(fs,"ParticlesResampled",m_pParticlesResampled,"ffffiffd",m_ParticleNum);
-    }
-
-    virtual void LoadState(CvFileStorage* fs, CvFileNode* node)
-    {
-        //CvMat* pM;
-        CvBlobTrackerOneMS::LoadState(fs,node);
-        m_ParticleNum = cvReadIntByName(fs,node,"ParticleNum",m_ParticleNum);
-        if(m_ParticleNum>0)
-        {
-            Realloc();
-            printf("sizeof(DefParticle) is %d\n", (int)sizeof(DefParticle));
-            cvReadStructByName(fs,node,"ParticlesPredicted",m_pParticlesPredicted,"ffffiffd");
-            cvReadStructByName(fs,node,"ParticlesResampled",m_pParticlesResampled,"ffffiffd");
-        }
-    }
-    CvBlobTrackerOneMSPF()
-    {
-        m_pParticlesPredicted = NULL;
-        m_pParticlesResampled = NULL;
-        m_ParticleNum = 200;
-
-        AddParam("ParticleNum",&m_ParticleNum);
-        CommentParam("ParticleNum","Number of particles");
-        Realloc();
-
-        m_UseVel = 0;
-        AddParam("UseVel",&m_UseVel);
-        CommentParam("UseVel","Percent of particles which use velocity feature");
-
-        m_SizeVar = 0.05f;
-        AddParam("SizeVar",&m_SizeVar);
-        CommentParam("SizeVar","Size variation (in object size)");
-
-        m_PosVar = 0.2f;
-        AddParam("PosVar",&m_PosVar);
-        CommentParam("PosVar","Position variation (in object size)");
-
-        m_RNG = cvRNG(0);
-
-        SetModuleName("MSPF");
-
-#ifdef _OPENMP
-        {
-            m_ThreadNum = omp_get_num_procs();
-            m_HistForParalel = new DefHist[m_ThreadNum];
-        }
-#endif
-    }
-
-    ~CvBlobTrackerOneMSPF()
-    {
-        if(m_pParticlesResampled)cvFree(&m_pParticlesResampled);
-        if(m_pParticlesPredicted)cvFree(&m_pParticlesPredicted);
-#ifdef _OPENMP
-        if(m_HistForParalel) delete[] m_HistForParalel;
-#endif
-    }
-
-private:
-    void Realloc()
-    {
-        if(m_pParticlesResampled)cvFree(&m_pParticlesResampled);
-        if(m_pParticlesPredicted)cvFree(&m_pParticlesPredicted);
-        m_pParticlesPredicted = (DefParticle*)cvAlloc(sizeof(DefParticle)*m_ParticleNum);
-        m_pParticlesResampled = (DefParticle*)cvAlloc(sizeof(DefParticle)*m_ParticleNum);
-    }  /* Realloc*/
-
-    void DrawDebug(IplImage* pImg, IplImage* /*pImgFG*/)
-    {
-        int k;
-        for(k=0; k<2; ++k)
-        {
-            DefParticle*    pBP = k?m_pParticlesResampled:m_pParticlesPredicted;
-            //const char*   name = k?"MSPF resampled particle":"MSPF Predicted particle";
-            IplImage*       pI = cvCloneImage(pImg);
-            int             h,hN = m_ParticleNum;
-            CvBlob          C = cvBlob(0,0,0,0);
-            double          WS = 0;
-            for(h=0; h<hN; ++h)
-            {
-                CvBlob  B = pBP[h].blob;
-                int     CW = cvRound(255*pBP[h].W);
-                CvBlob* pB = &B;
-                int x = cvRound(CV_BLOB_RX(pB)), y = cvRound(CV_BLOB_RY(pB));
-                CvSize  s = cvSize(MAX(1,x), MAX(1,y));
-                double  W = pBP[h].W;
-                C.x += pB->x;
-                C.y += pB->y;
-                C.w += pB->w;
-                C.h += pB->h;
-                WS+=W;
-
-                s = cvSize(1,1);
-                cvEllipse( pI,
-                    cvPointFrom32f(CV_BLOB_CENTER(pB)),
-                    s,
-                    0, 0, 360,
-                    CV_RGB(CW,0,0), 1 );
-
-            }   /* Next hypothesis. */
-
-            C.x /= hN;
-            C.y /= hN;
-            C.w /= hN;
-            C.h /= hN;
-
-            cvEllipse( pI,
-                cvPointFrom32f(CV_BLOB_CENTER(&C)),
-                cvSize(cvRound(C.w*0.5),cvRound(C.h*0.5)),
-                0, 0, 360,
-                CV_RGB(0,0,255), 1 );
-
-            cvEllipse( pI,
-                cvPointFrom32f(CV_BLOB_CENTER(&m_Blob)),
-                cvSize(cvRound(m_Blob.w*0.5),cvRound(m_Blob.h*0.5)),
-                0, 0, 360,
-                CV_RGB(0,255,0), 1 );
-
-            //cvNamedWindow(name,0);
-            //cvShowImage(name,pI);
-            cvReleaseImage(&pI);
-        } /*  */
-
-        //printf("Blob %d, point (%.1f,%.1f) size (%.1f,%.1f)\n",m_Blob.ID,m_Blob.x,m_Blob.y,m_Blob.w,m_Blob.h);
-    } /* ::DrawDebug */
-
-private:
-    void Prediction()
-    {
-        int p;
-        for(p=0; p<m_ParticleNum; ++p)
-        {   /* "Prediction" of particle: */
-            //double  t;
-            float   r[5];
-            CvMat   rm = cvMat(1,5,CV_32F,r);
-            cvRandArr(&m_RNG,&rm,CV_RAND_NORMAL,cvScalar(0),cvScalar(1));
-
-            m_pParticlesPredicted[p] = m_pParticlesResampled[p];
-
-            if(cvRandReal(&m_RNG)<0.5)
-            {   /* Half of particles will predict based on external blob: */
-                m_pParticlesPredicted[p].blob = m_Blob;
-            }
-
-            if(cvRandReal(&m_RNG)<m_UseVel)
-            {   /* Predict moving particle by usual way by using speed: */
-                m_pParticlesPredicted[p].blob.x += m_pParticlesPredicted[p].Vx;
-                m_pParticlesPredicted[p].blob.y += m_pParticlesPredicted[p].Vy;
-            }
-            else
-            {   /* Stop several particles: */
-                m_pParticlesPredicted[p].Vx = 0;
-                m_pParticlesPredicted[p].Vy = 0;
-            }
-
-            {   /* Update position: */
-                float S = (m_Blob.w + m_Blob.h)*0.5f;
-                m_pParticlesPredicted[p].blob.x += m_PosVar*S*r[0];
-                m_pParticlesPredicted[p].blob.y += m_PosVar*S*r[1];
-
-                /* Update velocity: */
-                m_pParticlesPredicted[p].Vx += (float)(m_PosVar*S*0.1*r[3]);
-                m_pParticlesPredicted[p].Vy += (float)(m_PosVar*S*0.1*r[4]);
-            }
-
-            /* Update size: */
-            m_pParticlesPredicted[p].blob.w *= (1+m_SizeVar*r[2]);
-            m_pParticlesPredicted[p].blob.h *= (1+m_SizeVar*r[2]);
-
-            /* Truncate size of particle: */
-            if(m_pParticlesPredicted[p].blob.w > m_ImgSize.width*0.5f)
-            {
-                m_pParticlesPredicted[p].blob.w = m_ImgSize.width*0.5f;
-            }
-
-            if(m_pParticlesPredicted[p].blob.h > m_ImgSize.height*0.5f)
-            {
-                m_pParticlesPredicted[p].blob.h = m_ImgSize.height*0.5f;
-            }
-
-            if(m_pParticlesPredicted[p].blob.w < 1 )
-            {
-                m_pParticlesPredicted[p].blob.w = 1;
-            }
-
-            if(m_pParticlesPredicted[p].blob.h < 1)
-            {
-                m_pParticlesPredicted[p].blob.h = 1;
-            }
-        }   /* "Prediction" of particle. */
-    }   /* Prediction */
-
-    void UpdateWeightsMS(IplImage* pImg, IplImage* /*pImgFG*/)
-    {
-        int p;
-#ifdef _OPENMP
-        if( m_HistForParalel[0].m_pHist==NULL || m_HistForParalel[0].m_pHist->cols != m_BinNumTotal)
-        {
-            int t;
-            for(t=0; t<m_ThreadNum; ++t)
-                m_HistForParalel[t].Resize(m_BinNumTotal);
-        }
-#endif
-
-#ifdef _OPENMP
-#pragma omp parallel for num_threads(m_ThreadNum) schedule(runtime)
-#endif
-        for(p=0;p<m_ParticleNum;++p)
-        {   /* Calculate weights for particles: */
-            double  S = 0.2;
-            double  B = 0;
-#ifdef _OPENMP
-            assert(omp_get_thread_num()<m_ThreadNum);
-#endif
-
-            B = GetBhattacharyya(
-                pImg, NULL,
-                &(m_pParticlesPredicted[p].blob)
-#ifdef _OPENMP
-                ,&(m_HistForParalel[omp_get_thread_num()])
-#endif
-                );
-            m_pParticlesPredicted[p].W *= exp((B-1)/(2*S));
-
-        }   /* Calculate weights for particles. */
-    }
-
-    void UpdateWeightsCC(IplImage* /*pImg*/, IplImage* /*pImgFG*/)
-    {
-        int p;
-#ifdef _OPENMP
-#pragma omp parallel for
-#endif
-        for(p=0; p<m_ParticleNum; ++p)
-        {   /* Calculate weights for particles: */
-            double W = 1;
-            m_pParticlesPredicted[p].W *= W;
-        }   /* Calculate weights for particles. */
-    }
-
-    void Resample()
-    {   /* Resample particle: */
-        int         p;
-        double      Sum = 0;
-
-        for(p=0; p<m_ParticleNum; ++p)
-        {
-            Sum += m_pParticlesPredicted[p].W;
-        }
-
-        for(p=0; p<m_ParticleNum; ++p)
-        {
-            double  T = Sum * cvRandReal(&m_RNG);   /* Set current random threshold for cululative weight. */
-            int     p2;
-            double  Sum2 = 0;
-
-            for(p2=0; p2<m_ParticleNum; ++p2)
-            {
-                Sum2 += m_pParticlesPredicted[p2].W;
-                if(Sum2 >= T)break;
-            }
-
-            if(p2>=m_ParticleNum)p2=m_ParticleNum-1;
-            m_pParticlesResampled[p] = m_pParticlesPredicted[p2];
-            m_pParticlesResampled[p].W = 1;
-
-        }   /* Find next particle. */
-    }   /*  Resample particle. */
-
-
-public:
-    virtual void Init(CvBlob* pBlobInit, IplImage* pImg, IplImage* pImgFG = NULL)
-    {
-        int i;
-        CvBlobTrackerOneMSFG::Init(pBlobInit, pImg, pImgFG);
-        DefParticle PP;
-        PP.W = 1;
-        PP.Vx = 0;
-        PP.Vy = 0;
-        PP.blob = pBlobInit[0];
-        for(i=0;i<m_ParticleNum;++i)
-        {
-            m_pParticlesPredicted[i] = PP;
-            m_pParticlesResampled[i] = PP;
-        }
-        m_Blob = pBlobInit[0];
-
-    }   /* CvBlobTrackerOneMSPF::Init*/
-
-    virtual CvBlob* Process(CvBlob* pBlobPrev, IplImage* pImg, IplImage* pImgFG = NULL)
-    {
-        int p;
-
-        m_ImgSize.width = pImg->width;
-        m_ImgSize.height = pImg->height;
-
-
-        m_Blob = pBlobPrev[0];
-
-        {   /* Check blob size and realloc kernels if it is necessary: */
-            int w = cvRound(m_Blob.w);
-            int h = cvRound(m_Blob.h);
-            if( w != m_ObjSize.width || h!=m_ObjSize.height)
-            {
-                ReAllocKernel(w,h);
-                /* After this ( w != m_ObjSize.width || h!=m_ObjSize.height) should be false. */
-            }
-        }   /* Check blob size and realloc kernels if it is necessary. */
-
-        Prediction();
-
-#ifdef REPORT_TICKS
-        int64 ticks = cvGetTickCount();
-#endif
-
-        UpdateWeightsMS(pImg, pImgFG);
-
-#ifdef REPORT_TICKS
-        ticks = cvGetTickCount() - ticks;
-        fprintf(stderr, "PF UpdateWeights, %d ticks\n",  (int)ticks);
-        ticks = cvGetTickCount();
-#endif
-
-        Resample();
-
-#ifdef REPORT_TICKS
-        ticks = cvGetTickCount() - ticks;
-        fprintf(stderr, "PF Resampling, %d ticks\n",  (int)ticks);
-#endif
-
-        {   /* Find average result: */
-            float   x = 0;
-            float   y = 0;
-            float   w = 0;
-            float   h = 0;
-            float   Sum = 0;
-
-            DefParticle* pP = m_pParticlesResampled;
-
-            for(p=0; p<m_ParticleNum; ++p)
-            {
-                float W = (float)pP[p].W;
-                x += W*pP[p].blob.x;
-                y += W*pP[p].blob.y;
-                w += W*pP[p].blob.w;
-                h += W*pP[p].blob.h;
-                Sum += W;
-            }
-
-            if(Sum>0)
-            {
-                m_Blob.x = x / Sum;
-                m_Blob.y = y / Sum;
-                m_Blob.w = w / Sum;
-                m_Blob.h = h / Sum;
-            }
-        }   /* Find average result. */
-
-        if(m_Wnd)
-        {
-            DrawDebug(pImg, pImgFG);
-        }
-
-        return &m_Blob;
-
-    }   /* CvBlobTrackerOneMSPF::Process */
-
-    virtual void SkipProcess(CvBlob* pBlob, IplImage* /*pImg*/, IplImage* /*pImgFG*/ = NULL)
-    {
-        int p;
-        for(p=0; p<m_ParticleNum; ++p)
-        {
-            m_pParticlesResampled[p].blob = pBlob[0];
-            m_pParticlesResampled[p].Vx = 0;
-            m_pParticlesResampled[p].Vy = 0;
-            m_pParticlesResampled[p].W = 1;
-        }
-    }
-
-    virtual void Release(){delete this;}
-    virtual void ParamUpdate()
-    {
-        Realloc();
-    }
-
-};  /* CvBlobTrackerOneMSPF */
-
-CvBlobTrackerOne* cvCreateBlobTrackerOneMSPF();
-CvBlobTrackerOne* cvCreateBlobTrackerOneMSPF()
-{
-    return (CvBlobTrackerOne*) new CvBlobTrackerOneMSPF;
-}
-
-CvBlobTracker* cvCreateBlobTrackerMSPF()
-{
-    return cvCreateBlobTrackerList(cvCreateBlobTrackerOneMSPF);
-}
diff --git a/modules/legacy/src/blobtrackingmsfgs.cpp b/modules/legacy/src/blobtrackingmsfgs.cpp
deleted file mode 100644 (file)
index afe3384..0000000
+++ /dev/null
@@ -1,456 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#define SCALE_BASE 1.1
-#define SCALE_RANGE 2
-#define SCALE_NUM (2*SCALE_RANGE+1)
-typedef float DefHistType;
-#define DefHistTypeMat CV_32F
-#define HIST_INDEX(_pData) (((_pData)[0]>>m_ByteShift) + (((_pData)[1]>>(m_ByteShift))<<m_BinBit)+((pImgData[2]>>m_ByteShift)<<(m_BinBit*2)))
-
-static void calcKernelEpanechnikov(CvMat* pK)
-{    /* Allocate kernel for histogramm creation: */
-    int     x,y;
-    int     w = pK->width;
-    int     h = pK->height;
-    float   x0 = 0.5f*(w-1);
-    float   y0 = 0.5f*(h-1);
-
-    for(y=0; y<h; ++y) for(x=0; x<w; ++x)
-    {
-//                float   r2 = ((x-x0)*(x-x0)/(x0*x0)+(y-y0)*(y-y0)/(y0*y0));
-        float   r2 = ((x-x0)*(x-x0)+(y-y0)*(y-y0))/((x0*x0)+(y0*y0));
-        CV_MAT_ELEM(pK[0],DefHistType, y, x) = (DefHistType)((r2<1)?(1-r2):0);
-    }
-}   /* Allocate kernel for histogram creation. */
-
-class CvBlobTrackerOneMSFGS:public CvBlobTrackerOne
-{
-private:
-    /* Parameters: */
-    float           m_FGWeight;
-    float           m_Alpha;
-    CvSize          m_ObjSize;
-    CvMat*          m_KernelHistModel;
-    CvMat*          m_KernelHistCandidate;
-    CvSize          m_KernelMeanShiftSize;
-    CvMat*          m_KernelMeanShiftK[SCALE_NUM];
-    CvMat*          m_KernelMeanShiftG[SCALE_NUM];
-    CvMat*          m_Weights;
-    int             m_BinBit;
-    int             m_ByteShift;
-    int             m_BinNum;
-    int             m_Dim;
-    int             m_BinNumTotal;
-    CvMat*          m_HistModel;
-    float           m_HistModelVolume;
-    CvMat*          m_HistCandidate;
-    float           m_HistCandidateVolume;
-    CvMat*          m_HistTemp;
-    CvBlob          m_Blob;
-
-    void ReAllocHist(int Dim, int BinBit)
-    {
-        m_BinBit = BinBit;
-        m_ByteShift = 8-BinBit;
-        m_Dim = Dim;
-        m_BinNum = (1<<BinBit);
-        m_BinNumTotal = cvRound(pow((double)m_BinNum,(double)m_Dim));
-        if(m_HistModel) cvReleaseMat(&m_HistModel);
-        if(m_HistCandidate) cvReleaseMat(&m_HistCandidate);
-        if(m_HistTemp) cvReleaseMat(&m_HistTemp);
-        m_HistCandidate = cvCreateMat(1, m_BinNumTotal, DefHistTypeMat);
-        m_HistModel = cvCreateMat(1, m_BinNumTotal, DefHistTypeMat);
-        m_HistTemp = cvCreateMat(1, m_BinNumTotal, DefHistTypeMat);
-        cvZero(m_HistCandidate);
-        cvZero(m_HistModel);
-        m_HistModelVolume = 0.0f;
-        m_HistCandidateVolume = 0.0f;
-    }
-
-    void ReAllocKernel(int  w, int h, float sigma=0.4)
-    {
-        double  ScaleToObj = sigma*1.39;
-        int     kernel_width = cvRound(w/ScaleToObj);
-        int     kernel_height = cvRound(h/ScaleToObj);
-        int     x,y,s;
-        assert(w>0);
-        assert(h>0);
-        m_ObjSize = cvSize(w,h);
-        m_KernelMeanShiftSize = cvSize(kernel_width,kernel_height);
-
-
-        /* Create kernels for histogram calculation: */
-        if(m_KernelHistModel) cvReleaseMat(&m_KernelHistModel);
-        m_KernelHistModel = cvCreateMat(h, w, DefHistTypeMat);
-        calcKernelEpanechnikov(m_KernelHistModel);
-        if(m_KernelHistCandidate) cvReleaseMat(&m_KernelHistCandidate);
-        m_KernelHistCandidate = cvCreateMat(kernel_height, kernel_width, DefHistTypeMat);
-        calcKernelEpanechnikov(m_KernelHistCandidate);
-
-        if(m_Weights) cvReleaseMat(&m_Weights);
-        m_Weights = cvCreateMat(kernel_height, kernel_width, CV_32F);
-
-        for(s=-SCALE_RANGE; s<=SCALE_RANGE; ++s)
-        {   /* Allocate kernel for meanshifts in space and scale: */
-            int     si = s+SCALE_RANGE;
-            double  cur_sigma = sigma * pow(SCALE_BASE,s);
-            double  cur_sigma2 = cur_sigma*cur_sigma;
-            double  x0 = 0.5*(kernel_width-1);
-            double  y0 = 0.5*(kernel_height-1);
-            if(m_KernelMeanShiftK[si]) cvReleaseMat(&m_KernelMeanShiftK[si]);
-            if(m_KernelMeanShiftG[si]) cvReleaseMat(&m_KernelMeanShiftG[si]);
-            m_KernelMeanShiftK[si] = cvCreateMat(kernel_height, kernel_width, DefHistTypeMat);
-            m_KernelMeanShiftG[si] = cvCreateMat(kernel_height, kernel_width, DefHistTypeMat);
-
-            for(y=0; y<kernel_height; ++y)
-            {
-                DefHistType* pK = (DefHistType*)CV_MAT_ELEM_PTR_FAST( m_KernelMeanShiftK[si][0], y, 0, sizeof(DefHistType) );
-                DefHistType* pG = (DefHistType*)CV_MAT_ELEM_PTR_FAST( m_KernelMeanShiftG[si][0], y, 0, sizeof(DefHistType) );
-
-                for(x=0; x<kernel_width; ++x)
-                {
-                    double r2 = ((x-x0)*(x-x0)/(x0*x0)+(y-y0)*(y-y0)/(y0*y0));
-                    double sigma12 = cur_sigma2 / 2.56;
-                    double sigma22 = cur_sigma2 * 2.56;
-                    pK[x] = (DefHistType)(Gaussian2D(r2, sigma12)/sigma12 - Gaussian2D(r2, sigma22)/sigma22);
-                    pG[x] = (DefHistType)(Gaussian2D(r2, cur_sigma2/1.6) - Gaussian2D(r2, cur_sigma2*1.6));
-                }
-            }   /* Next line. */
-        }
-    }   /* ReallocKernel */
-
-    inline double Gaussian2D(double x, double sigma2)
-    {
-        return (exp(-x/(2*sigma2)) / (2*3.1415926535897932384626433832795*sigma2) );
-    }
-
-    void calcHist(IplImage* pImg, IplImage* pMask, CvPoint Center, CvMat* pKernel, CvMat* pHist, DefHistType* pHistVolume)
-    {
-        int         w = pKernel->width;
-        int         h = pKernel->height;
-        DefHistType Volume = 0;
-        int         x0 = Center.x - w/2;
-        int         y0 = Center.y - h/2;
-        int         x,y;
-
-        //cvZero(pHist);
-        cvSet(pHist,cvScalar(1.0/m_BinNumTotal)); /* no zero bins, all bins have very small value*/
-        Volume = 1;
-
-        if(m_Dim == 3)
-        {
-            for(y=0; y<h; ++y)
-            {
-                unsigned char* pImgData = NULL;
-                unsigned char* pMaskData = NULL;
-                DefHistType* pKernelData = NULL;
-                if((y0+y)>=pImg->height) continue;
-                if((y0+y)<0)continue;
-                pImgData = &CV_IMAGE_ELEM(pImg,unsigned char,y+y0,x0*3);
-                pMaskData = pMask?(&CV_IMAGE_ELEM(pMask,unsigned char,y+y0,x0)):NULL;
-                pKernelData = (DefHistType*)CV_MAT_ELEM_PTR_FAST(pKernel[0],y,0,sizeof(DefHistType));
-
-                for(x=0; x<w; ++x, pImgData+=3)
-                {
-                    if((x0+x)>=pImg->width) continue;
-                    if((x0+x)<0)continue;
-
-                    if(pMaskData==NULL || pMaskData[x]>128)
-                    {
-                        DefHistType K = pKernelData[x];
-                        int index = HIST_INDEX(pImgData);
-                        assert(index >= 0 && index < pHist->cols);
-                        Volume += K;
-                        ((DefHistType*)(pHist->data.ptr))[index] += K;
-
-                    }   /* Only masked pixels. */
-                }   /*  Next column. */
-            }   /*  Next row. */
-        }   /* if m_Dim == 3. */
-
-        if(pHistVolume)pHistVolume[0] = Volume;
-
-    } /* calcHist */
-
-    double calcBhattacharyya()
-    {
-        cvMul(m_HistCandidate,m_HistModel,m_HistTemp);
-        cvPow(m_HistTemp,m_HistTemp,0.5);
-        return cvSum(m_HistTemp).val[0] / sqrt(m_HistCandidateVolume*m_HistModelVolume);
-    }   /* calcBhattacharyyaCoefficient */
-
-    void calcWeights(IplImage* pImg, IplImage* pImgFG, CvPoint Center)
-    {
-        cvZero(m_Weights);
-
-        /* Calculate new position: */
-        if(m_Dim == 3)
-        {
-            int         x0 = Center.x - m_KernelMeanShiftSize.width/2;
-            int         y0 = Center.y - m_KernelMeanShiftSize.height/2;
-            int         x,y;
-
-            assert(m_Weights->width == m_KernelMeanShiftSize.width);
-            assert(m_Weights->height == m_KernelMeanShiftSize.height);
-
-            /* Calcualte shift vector: */
-            for(y=0; y<m_KernelMeanShiftSize.height; ++y)
-            {
-                unsigned char* pImgData = NULL;
-                unsigned char* pMaskData = NULL;
-                float* pWData = NULL;
-
-                if(y+y0 < 0 || y+y0 >= pImg->height) continue;
-
-                pImgData = &CV_IMAGE_ELEM(pImg,unsigned char,y+y0,x0*3);
-                pMaskData = pImgFG?(&CV_IMAGE_ELEM(pImgFG,unsigned char,y+y0,x0)):NULL;
-                pWData = (float*)CV_MAT_ELEM_PTR_FAST(m_Weights[0],y,0,sizeof(float));
-
-                for(x=0; x<m_KernelMeanShiftSize.width; ++x, pImgData+=3)
-                {
-                    double      V  = 0;
-                    double      HM = 0;
-                    double      HC = 0;
-                    int         index;
-                    if(x+x0 < 0 || x+x0 >= pImg->width) continue;
-
-                    index = HIST_INDEX(pImgData);
-                    assert(index >= 0 && index < m_BinNumTotal);
-
-                    if(m_HistModelVolume>0)
-                        HM = ((DefHistType*)m_HistModel->data.ptr)[index]/m_HistModelVolume;
-
-                    if(m_HistCandidateVolume>0)
-                        HC = ((DefHistType*)m_HistCandidate->data.ptr)[index]/m_HistCandidateVolume;
-
-                    V = (HC>0)?sqrt(HM / HC):0;
-                    V += m_FGWeight*(pMaskData?((pMaskData[x]/255.0f)):0);
-                    pWData[x] = (float)MIN(V,100000);
-
-                }   /* Next column. */
-            }   /*  Next row. */
-        }   /*  if m_Dim == 3. */
-    }   /*  calcWeights */
-
-public:
-    CvBlobTrackerOneMSFGS()
-    {
-        int i;
-        m_FGWeight = 0;
-        m_Alpha = 0.0;
-
-        /* Add several parameters for external use: */
-        AddParam("FGWeight", &m_FGWeight);
-        CommentParam("FGWeight","Weight of FG mask using (0 - mask will not be used for tracking)");
-        AddParam("Alpha", &m_Alpha);
-        CommentParam("Alpha","Coefficient for model histogramm updating (0 - hist is not upated)");
-
-        m_BinBit=0;
-        m_Dim = 0;
-        m_HistModel = NULL;
-        m_HistCandidate = NULL;
-        m_HistTemp = NULL;
-        m_KernelHistModel = NULL;
-        m_KernelHistCandidate = NULL;
-        m_Weights = NULL;
-
-        for(i=0; i<SCALE_NUM; ++i)
-        {
-            m_KernelMeanShiftK[i] = NULL;
-            m_KernelMeanShiftG[i] = NULL;
-        }
-        ReAllocHist(3,5);   /* 3D hist, each dimension has 2^5 bins. */
-
-        SetModuleName("MSFGS");
-    }
-
-    ~CvBlobTrackerOneMSFGS()
-    {
-        int i;
-        if(m_HistModel) cvReleaseMat(&m_HistModel);
-        if(m_HistCandidate) cvReleaseMat(&m_HistCandidate);
-        if(m_HistTemp) cvReleaseMat(&m_HistTemp);
-        if(m_KernelHistModel) cvReleaseMat(&m_KernelHistModel);
-
-        for(i=0; i<SCALE_NUM; ++i)
-        {
-            if(m_KernelMeanShiftK[i]) cvReleaseMat(&m_KernelMeanShiftK[i]);
-            if(m_KernelMeanShiftG[i]) cvReleaseMat(&m_KernelMeanShiftG[i]);
-        }
-    }
-
-    /* Interface: */
-    virtual void Init(CvBlob* pBlobInit, IplImage* pImg, IplImage* pImgFG = NULL)
-    {
-        int w = cvRound(CV_BLOB_WX(pBlobInit));
-        int h = cvRound(CV_BLOB_WY(pBlobInit));
-        if(w<3)w=3;
-        if(h<3)h=3;
-        if(w>pImg->width)w=pImg->width;
-        if(h>pImg->height)h=pImg->height;
-        ReAllocKernel(w,h);
-        calcHist(pImg, pImgFG, cvPointFrom32f(CV_BLOB_CENTER(pBlobInit)), m_KernelHistModel, m_HistModel, &m_HistModelVolume);
-        m_Blob = pBlobInit[0];
-    };
-
-    virtual CvBlob* Process(CvBlob* pBlobPrev, IplImage* pImg, IplImage* pImgFG = NULL)
-    {
-        int     iter;
-
-        if(pBlobPrev)
-        {
-            m_Blob = pBlobPrev[0];
-        }
-
-        for(iter=0; iter<10; ++iter)
-        {
-//            float   newx=0,newy=0,sum=0;
-            float   dx=0,dy=0,sum=0;
-            int     x,y,si;
-
-            CvPoint Center = cvPoint(cvRound(m_Blob.x),cvRound(m_Blob.y));
-            CvSize  Size   = cvSize(cvRound(m_Blob.w),cvRound(m_Blob.h));
-
-            if(m_ObjSize.width != Size.width || m_ObjSize.height != Size.height)
-            {   /* Reallocate kernels: */
-                ReAllocKernel(Size.width,Size.height);
-            }   /* Reallocate kernels. */
-
-            /* Mean shift in coordinate space: */
-            calcHist(pImg, NULL, Center, m_KernelHistCandidate, m_HistCandidate, &m_HistCandidateVolume);
-            calcWeights(pImg, pImgFG, Center);
-
-            for(si=1; si<(SCALE_NUM-1); ++si)
-            {
-                CvMat*  pKernel = m_KernelMeanShiftK[si];
-                float   sdx = 0, sdy=0, ssum=0;
-                int     s = si-SCALE_RANGE;
-                float   factor = (1.0f-( float(s)/float(SCALE_RANGE) )*( float(s)/float(SCALE_RANGE) ));
-
-                for(y=0; y<m_KernelMeanShiftSize.height; ++y)
-                for(x=0; x<m_KernelMeanShiftSize.width;  ++x)
-                {
-                    float W = *(float*)CV_MAT_ELEM_PTR_FAST(m_Weights[0],y,x,sizeof(float));
-                    float K = *(float*)CV_MAT_ELEM_PTR_FAST(pKernel[0],y,x,sizeof(float));
-                    float KW = K*W;
-                    ssum += (float)fabs(KW);
-                    sdx += KW*(x-m_KernelMeanShiftSize.width*0.5f);
-                    sdy += KW*(y-m_KernelMeanShiftSize.height*0.5f);
-                }   /* Next pixel. */
-
-                dx += sdx * factor;
-                dy += sdy * factor;
-                sum  += ssum * factor;
-
-            }   /* Next scale. */
-
-            if(sum > 0)
-            {
-                dx /= sum;
-                dy /= sum;
-            }
-
-            m_Blob.x += dx;
-            m_Blob.y += dy;
-
-            {   /* Mean shift in scale space: */
-                float   news = 0;
-                float   sum1 = 0;
-                float   scale;
-
-                Center = cvPoint(cvRound(m_Blob.x),cvRound(m_Blob.y));
-                calcHist(pImg, NULL, Center, m_KernelHistCandidate, m_HistCandidate, &m_HistCandidateVolume);
-                calcWeights(pImg, pImgFG, Center);
-                //cvSet(m_Weights,cvScalar(1));
-
-                for(si=0; si<SCALE_NUM; si++)
-                {
-                    double  W = cvDotProduct(m_Weights, m_KernelMeanShiftG[si]);;
-                    int     s = si-SCALE_RANGE;
-                    sum1 += (float)fabs(W);
-                    news += (float)(s*W);
-                }
-
-                if(sum1>0)
-                {
-                    news /= sum1;
-                }
-
-                scale = (float)pow((double)SCALE_BASE,(double)news);
-                m_Blob.w *= scale;
-                m_Blob.h *= scale;
-            }   /* Mean shift in scale space. */
-
-            /* Check fo finish: */
-            if(fabs(dx)<0.1 && fabs(dy)<0.1) break;
-
-        }   /* Next iteration. */
-
-        if(m_Alpha>0)
-        {   /* Update histogram: */
-            double  Vol, WM, WC;
-            CvPoint Center = cvPoint(cvRound(m_Blob.x),cvRound(m_Blob.y));
-            calcHist(pImg, pImgFG, Center, m_KernelHistModel, m_HistCandidate, &m_HistCandidateVolume);
-            Vol = 0.5*(m_HistModelVolume + m_HistCandidateVolume);
-            WM = Vol*(1-m_Alpha)/m_HistModelVolume;
-            WC = Vol*(m_Alpha)/m_HistCandidateVolume;
-            cvAddWeighted(m_HistModel, WM, m_HistCandidate,WC,0,m_HistModel);
-            m_HistModelVolume = (float)cvSum(m_HistModel).val[0];
-        }   /* Update histogram. */
-
-        return &m_Blob;
-
-    }  /* Process */
-
-    virtual void Release(){delete this;}
-}; /*CvBlobTrackerOneMSFGS*/
-
-static CvBlobTrackerOne* cvCreateBlobTrackerOneMSFGS()
-{
-    return (CvBlobTrackerOne*) new CvBlobTrackerOneMSFGS;
-}
-
-CvBlobTracker* cvCreateBlobTrackerMSFGS()
-{
-    return cvCreateBlobTrackerList(cvCreateBlobTrackerOneMSFGS);
-}
diff --git a/modules/legacy/src/blobtrackpostprockalman.cpp b/modules/legacy/src/blobtrackpostprockalman.cpp
deleted file mode 100644 (file)
index 378e1e7..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "opencv2/video/tracking_c.h"
-
-/*======================= KALMAN FILTER =========================*/
-/* State vector is (x,y,w,h,dx,dy,dw,dh). */
-/* Measurement is (x,y,w,h). */
-
-/* Dynamic matrix A: */
-const float A8[] = { 1, 0, 0, 0, 1, 0, 0, 0,
-                     0, 1, 0, 0, 0, 1, 0, 0,
-                     0, 0, 1, 0, 0, 0, 1, 0,
-                     0, 0, 0, 1, 0, 0, 0, 1,
-                     0, 0, 0, 0, 1, 0, 0, 0,
-                     0, 0, 0, 0, 0, 1, 0, 0,
-                     0, 0, 0, 0, 0, 0, 1, 0,
-                     0, 0, 0, 0, 0, 0, 0, 1};
-
-/* Measurement matrix H: */
-const float H8[] = { 1, 0, 0, 0, 0, 0, 0, 0,
-                     0, 1, 0, 0, 0, 0, 0, 0,
-                     0, 0, 1, 0, 0, 0, 0, 0,
-                     0, 0, 0, 1, 0, 0, 0, 0};
-
-/* Matrices for zero size velocity: */
-/* Dinamic matrix A: */
-const float A6[] = { 1, 0, 0, 0, 1, 0,
-                     0, 1, 0, 0, 0, 1,
-                     0, 0, 1, 0, 0, 0,
-                     0, 0, 0, 1, 0, 0,
-                     0, 0, 0, 0, 1, 0,
-                     0, 0, 0, 0, 0, 1};
-
-/* Measurement matrix H: */
-const float H6[] = { 1, 0, 0, 0, 0, 0,
-                     0, 1, 0, 0, 0, 0,
-                     0, 0, 1, 0, 0, 0,
-                     0, 0, 0, 1, 0, 0};
-
-#define STATE_NUM 6
-#define A A6
-#define H H6
-
-class CvBlobTrackPostProcKalman:public CvBlobTrackPostProcOne
-{
-
-private:
-    CvBlob      m_Blob;
-    CvKalman*   m_pKalman;
-    int         m_Frame;
-    float       m_ModelNoise;
-    float       m_DataNoisePos;
-    float       m_DataNoiseSize;
-
-public:
-    CvBlobTrackPostProcKalman();
-   ~CvBlobTrackPostProcKalman();
-    CvBlob* Process(CvBlob* pBlob);
-    void Release();
-    virtual void ParamUpdate();
-}; /* class CvBlobTrackPostProcKalman */
-
-
-CvBlobTrackPostProcKalman::CvBlobTrackPostProcKalman()
-{
-    m_ModelNoise = 1e-6f;
-    m_DataNoisePos = 1e-6f;
-    m_DataNoiseSize = 1e-1f;
-
-    #if STATE_NUM>6
-        m_DataNoiseSize *= (float)pow(20.,2.);
-    #else
-        m_DataNoiseSize /= (float)pow(20.,2.);
-    #endif
-
-    AddParam("ModelNoise",&m_ModelNoise);
-    AddParam("DataNoisePos",&m_DataNoisePos);
-    AddParam("DataNoiseSize",&m_DataNoiseSize);
-
-    m_Frame = 0;
-    m_pKalman = cvCreateKalman(STATE_NUM,4);
-    memcpy( m_pKalman->transition_matrix->data.fl, A, sizeof(A));
-    memcpy( m_pKalman->measurement_matrix->data.fl, H, sizeof(H));
-
-    cvSetIdentity( m_pKalman->process_noise_cov, cvRealScalar(m_ModelNoise) );
-    cvSetIdentity( m_pKalman->measurement_noise_cov, cvRealScalar(m_DataNoisePos) );
-    CV_MAT_ELEM(*m_pKalman->measurement_noise_cov, float, 2,2) = m_DataNoiseSize;
-    CV_MAT_ELEM(*m_pKalman->measurement_noise_cov, float, 3,3) = m_DataNoiseSize;
-    cvSetIdentity( m_pKalman->error_cov_post, cvRealScalar(1));
-    cvZero(m_pKalman->state_post);
-    cvZero(m_pKalman->state_pre);
-
-    SetModuleName("Kalman");
-}
-
-CvBlobTrackPostProcKalman::~CvBlobTrackPostProcKalman()
-{
-    cvReleaseKalman(&m_pKalman);
-}
-
-void CvBlobTrackPostProcKalman::ParamUpdate()
-{
-    cvSetIdentity( m_pKalman->process_noise_cov, cvRealScalar(m_ModelNoise) );
-    cvSetIdentity( m_pKalman->measurement_noise_cov, cvRealScalar(m_DataNoisePos) );
-    CV_MAT_ELEM(*m_pKalman->measurement_noise_cov, float, 2,2) = m_DataNoiseSize;
-    CV_MAT_ELEM(*m_pKalman->measurement_noise_cov, float, 3,3) = m_DataNoiseSize;
-}
-
-CvBlob* CvBlobTrackPostProcKalman::Process(CvBlob* pBlob)
-{
-    CvBlob* pBlobRes = &m_Blob;
-    float   Z[4];
-    CvMat   Zmat = cvMat(4,1,CV_32F,Z);
-    m_Blob = pBlob[0];
-
-    if(m_Frame < 2)
-    {   /* First call: */
-        m_pKalman->state_post->data.fl[0+4] = CV_BLOB_X(pBlob)-m_pKalman->state_post->data.fl[0];
-        m_pKalman->state_post->data.fl[1+4] = CV_BLOB_Y(pBlob)-m_pKalman->state_post->data.fl[1];
-        if(m_pKalman->DP>6)
-        {
-            m_pKalman->state_post->data.fl[2+4] = CV_BLOB_WX(pBlob)-m_pKalman->state_post->data.fl[2];
-            m_pKalman->state_post->data.fl[3+4] = CV_BLOB_WY(pBlob)-m_pKalman->state_post->data.fl[3];
-        }
-        m_pKalman->state_post->data.fl[0] = CV_BLOB_X(pBlob);
-        m_pKalman->state_post->data.fl[1] = CV_BLOB_Y(pBlob);
-        m_pKalman->state_post->data.fl[2] = CV_BLOB_WX(pBlob);
-        m_pKalman->state_post->data.fl[3] = CV_BLOB_WY(pBlob);
-    }
-    else
-    {   /* Nonfirst call: */
-        cvKalmanPredict(m_pKalman,0);
-        Z[0] = CV_BLOB_X(pBlob);
-        Z[1] = CV_BLOB_Y(pBlob);
-        Z[2] = CV_BLOB_WX(pBlob);
-        Z[3] = CV_BLOB_WY(pBlob);
-        cvKalmanCorrect(m_pKalman,&Zmat);
-        cvMatMulAdd(m_pKalman->measurement_matrix, m_pKalman->state_post, NULL, &Zmat);
-        CV_BLOB_X(pBlobRes) = Z[0];
-        CV_BLOB_Y(pBlobRes) = Z[1];
-//        CV_BLOB_WX(pBlobRes) = Z[2];
-//        CV_BLOB_WY(pBlobRes) = Z[3];
-    }
-    m_Frame++;
-    return pBlobRes;
-}
-
-void CvBlobTrackPostProcKalman::Release()
-{
-    delete this;
-}
-
-static CvBlobTrackPostProcOne* cvCreateModuleBlobTrackPostProcKalmanOne()
-{
-    return (CvBlobTrackPostProcOne*) new CvBlobTrackPostProcKalman;
-}
-
-CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcKalman()
-{
-    return cvCreateBlobTrackPostProcList(cvCreateModuleBlobTrackPostProcKalmanOne);
-}
-/*======================= KALMAN FILTER =========================*/
-
-
-
-/*======================= KALMAN PREDICTOR =========================*/
-class CvBlobTrackPredictKalman:public CvBlobTrackPredictor
-{
-
-private:
-    CvBlob      m_BlobPredict;
-    CvKalman*   m_pKalman;
-    int         m_Frame;
-    float       m_ModelNoise;
-    float       m_DataNoisePos;
-    float       m_DataNoiseSize;
-
-public:
-    CvBlobTrackPredictKalman();
-    ~CvBlobTrackPredictKalman();
-    CvBlob* Predict();
-    void Update(CvBlob* pBlob);
-    virtual void ParamUpdate();
-    void Release()
-    {
-        delete this;
-    }
-};  /* class CvBlobTrackPredictKalman */
-
-
-void CvBlobTrackPredictKalman::ParamUpdate()
-{
-    cvSetIdentity( m_pKalman->process_noise_cov, cvRealScalar(m_ModelNoise) );
-    cvSetIdentity( m_pKalman->measurement_noise_cov, cvRealScalar(m_DataNoisePos) );
-    CV_MAT_ELEM(*m_pKalman->measurement_noise_cov, float, 2,2) = m_DataNoiseSize;
-    CV_MAT_ELEM(*m_pKalman->measurement_noise_cov, float, 3,3) = m_DataNoiseSize;
-}
-
-CvBlobTrackPredictKalman::CvBlobTrackPredictKalman()
-{
-    m_ModelNoise = 1e-6f;
-    m_DataNoisePos = 1e-6f;
-    m_DataNoiseSize = 1e-1f;
-
-    #if STATE_NUM>6
-        m_DataNoiseSize *= (float)pow(20.,2.);
-    #else
-        m_DataNoiseSize /= (float)pow(20.,2.);
-    #endif
-
-    AddParam("ModelNoise",&m_ModelNoise);
-    AddParam("DataNoisePos",&m_DataNoisePos);
-    AddParam("DataNoiseSize",&m_DataNoiseSize);
-
-    m_Frame = 0;
-    m_pKalman = cvCreateKalman(STATE_NUM,4);
-    memcpy( m_pKalman->transition_matrix->data.fl, A, sizeof(A));
-    memcpy( m_pKalman->measurement_matrix->data.fl, H, sizeof(H));
-
-    cvSetIdentity( m_pKalman->process_noise_cov, cvRealScalar(m_ModelNoise) );
-    cvSetIdentity( m_pKalman->measurement_noise_cov, cvRealScalar(m_DataNoisePos) );
-    CV_MAT_ELEM(*m_pKalman->measurement_noise_cov, float, 2,2) = m_DataNoiseSize;
-    CV_MAT_ELEM(*m_pKalman->measurement_noise_cov, float, 3,3) = m_DataNoiseSize;
-    cvSetIdentity( m_pKalman->error_cov_post, cvRealScalar(1));
-    cvZero(m_pKalman->state_post);
-    cvZero(m_pKalman->state_pre);
-
-    SetModuleName("Kalman");
-}
-
-CvBlobTrackPredictKalman::~CvBlobTrackPredictKalman()
-{
-    cvReleaseKalman(&m_pKalman);
-}
-
-CvBlob* CvBlobTrackPredictKalman::Predict()
-{
-    if(m_Frame >= 2)
-    {
-        cvKalmanPredict(m_pKalman,0);
-        m_BlobPredict.x = m_pKalman->state_pre->data.fl[0];
-        m_BlobPredict.y = m_pKalman->state_pre->data.fl[1];
-        m_BlobPredict.w = m_pKalman->state_pre->data.fl[2];
-        m_BlobPredict.h = m_pKalman->state_pre->data.fl[3];
-    }
-    return &m_BlobPredict;
-}
-
-void CvBlobTrackPredictKalman::Update(CvBlob* pBlob)
-{
-    float   Z[4];
-    CvMat   Zmat = cvMat(4,1,CV_32F,Z);
-    m_BlobPredict = pBlob[0];
-
-    if(m_Frame < 2)
-    {   /* First call: */
-        m_pKalman->state_post->data.fl[0+4] = CV_BLOB_X(pBlob)-m_pKalman->state_post->data.fl[0];
-        m_pKalman->state_post->data.fl[1+4] = CV_BLOB_Y(pBlob)-m_pKalman->state_post->data.fl[1];
-        if(m_pKalman->DP>6)
-        {
-            m_pKalman->state_post->data.fl[2+4] = CV_BLOB_WX(pBlob)-m_pKalman->state_post->data.fl[2];
-            m_pKalman->state_post->data.fl[3+4] = CV_BLOB_WY(pBlob)-m_pKalman->state_post->data.fl[3];
-        }
-        m_pKalman->state_post->data.fl[0] = CV_BLOB_X(pBlob);
-        m_pKalman->state_post->data.fl[1] = CV_BLOB_Y(pBlob);
-        m_pKalman->state_post->data.fl[2] = CV_BLOB_WX(pBlob);
-        m_pKalman->state_post->data.fl[3] = CV_BLOB_WY(pBlob);
-    }
-    else
-    {   /* Nonfirst call: */
-        Z[0] = CV_BLOB_X(pBlob);
-        Z[1] = CV_BLOB_Y(pBlob);
-        Z[2] = CV_BLOB_WX(pBlob);
-        Z[3] = CV_BLOB_WY(pBlob);
-        cvKalmanCorrect(m_pKalman,&Zmat);
-    }
-
-    cvKalmanPredict(m_pKalman,0);
-
-    m_Frame++;
-
-}   /* Update. */
-
-CvBlobTrackPredictor* cvCreateModuleBlobTrackPredictKalman()
-{
-    return (CvBlobTrackPredictor*) new CvBlobTrackPredictKalman;
-}
-/*======================= KALMAN PREDICTOR =========================*/
diff --git a/modules/legacy/src/blobtrackpostproclinear.cpp b/modules/legacy/src/blobtrackpostproclinear.cpp
deleted file mode 100644 (file)
index 2192cf0..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-/*======================= TIME AVERAGING FILTER =========================*/
-#define TIME_WND 5
-class CvBlobTrackPostProcTimeAver:public CvBlobTrackPostProcOne
-{
-
-protected:
-    CvBlob      m_Blob;
-    CvBlob      m_pBlobs[TIME_WND];
-    float       m_Weights[TIME_WND];
-    int         m_Frame;
-
-public:
-    CvBlobTrackPostProcTimeAver( int KernelType = 0)
-    {
-        int i;
-        m_Frame = 0;
-        for(i=0;i<TIME_WND;++i)
-        {
-            m_Weights[i] = 1;
-            if(KernelType == 1)
-            {
-                m_Weights[i] = (float)exp((-2.3*i)/(TIME_WND-1)); /* last weight is 0.1 of first weight */
-            }
-        }
-
-        SetModuleName("TimeAver");
-    };
-
-   ~CvBlobTrackPostProcTimeAver(){};
-
-    CvBlob* Process(CvBlob* pBlob)
-    {
-        float   WSum = 0;
-        int     i;
-        int idx = m_Frame % TIME_WND;
-        int size = MIN((m_Frame+1), TIME_WND);
-        m_pBlobs[idx] = pBlob[0];
-        m_Blob.x = m_Blob.y = m_Blob.w = m_Blob.h = 0;
-
-        for(i=0; i<size; ++i)
-        {
-            float   W = m_Weights[i];
-            int     index  = (m_Frame - i + TIME_WND) % TIME_WND;
-            m_Blob.x += W*m_pBlobs[index].x;
-            m_Blob.y += W*m_pBlobs[index].y;
-            m_Blob.w += W*m_pBlobs[index].w;
-            m_Blob.h += W*m_pBlobs[index].h;
-            WSum += W;
-        }
-        assert(WSum>0);
-
-        m_Blob.x /= WSum;
-        m_Blob.y /= WSum;
-        m_Blob.w /= WSum;
-        m_Blob.h /= WSum;
-
-        m_Frame++;
-        return &m_Blob;
-    };
-
-    void Release()
-    {
-        delete this;
-    }
-};  /* class CvBlobTrackPostProcTimeAver */
-
-static CvBlobTrackPostProcOne* cvCreateModuleBlobTrackPostProcTimeAverRectOne()
-{
-    return (CvBlobTrackPostProcOne*) new CvBlobTrackPostProcTimeAver(0);
-}
-
-static CvBlobTrackPostProcOne* cvCreateModuleBlobTrackPostProcTimeAverExpOne()
-{
-    return (CvBlobTrackPostProcOne*) new CvBlobTrackPostProcTimeAver(1);
-}
-
-CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcTimeAverRect()
-{
-    return cvCreateBlobTrackPostProcList(cvCreateModuleBlobTrackPostProcTimeAverRectOne);
-}
-
-CvBlobTrackPostProc* cvCreateModuleBlobTrackPostProcTimeAverExp()
-{
-    return cvCreateBlobTrackPostProcList(cvCreateModuleBlobTrackPostProcTimeAverExpOne);
-}
-/*======================= KALMAN FILTER =========================*/
diff --git a/modules/legacy/src/blobtrackpostproclist.cpp b/modules/legacy/src/blobtrackpostproclist.cpp
deleted file mode 100644 (file)
index ed03d8e..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-/*======================= FILTER LIST SHELL =====================*/
-typedef struct DefBlobFilter
-{
-    CvBlob                  blob;
-    CvBlobTrackPostProcOne* pFilter;
-    int                     m_LastFrame;
-} DefBlobFilter;
-
-class CvBlobTrackPostProcList : public CvBlobTrackPostProc
-{
-protected:
-    CvBlobTrackPostProcOne* (*m_CreatePostProc)();
-    CvBlobSeq               m_BlobFilterList;
-    int                     m_Frame;
-
-public:
-    CvBlobTrackPostProcList(CvBlobTrackPostProcOne* (*create)()):m_BlobFilterList(sizeof(DefBlobFilter))
-    {
-        m_Frame = 0;
-        m_CreatePostProc = create;
-        CvBlobTrackPostProcOne* pM = create();
-        TransferParamsFromChild(pM,NULL);
-        pM->Release();
-        SetModuleName("List");
-    }
-
-   ~CvBlobTrackPostProcList()
-    {
-        int i;
-        for(i=m_BlobFilterList.GetBlobNum();i>0;--i)
-        {
-            DefBlobFilter* pF = (DefBlobFilter*)m_BlobFilterList.GetBlob(i-1);
-            pF->pFilter->Release();
-        }
-    }
-
-    virtual void    AddBlob(CvBlob* pBlob)
-    {
-        DefBlobFilter* pF = (DefBlobFilter*)m_BlobFilterList.GetBlobByID(CV_BLOB_ID(pBlob));
-        if(pF == NULL)
-        {   /* Create new filter: */
-            DefBlobFilter F;
-            F.blob = pBlob[0];
-            F.m_LastFrame = m_Frame;
-            F.pFilter = m_CreatePostProc();
-            TransferParamsToChild(F.pFilter,NULL);
-            m_BlobFilterList.AddBlob((CvBlob*)&F);
-            pF = (DefBlobFilter*)m_BlobFilterList.GetBlobByID(CV_BLOB_ID(pBlob));
-        }
-
-        assert(pF);
-        pF->blob = pBlob[0];
-        pF->m_LastFrame = m_Frame;
-    }
-
-    virtual void    Process()
-    {
-        int i;
-        for(i=m_BlobFilterList.GetBlobNum(); i>0; --i)
-        {
-            DefBlobFilter* pF = (DefBlobFilter*)m_BlobFilterList.GetBlob(i-1);
-
-            if(pF->m_LastFrame == m_Frame)
-            {   /* Process: */
-                int ID = CV_BLOB_ID(pF);
-                pF->blob = *(pF->pFilter->Process(&(pF->blob)));
-                CV_BLOB_ID(pF) = ID;
-            }
-            else
-            {   /* Delete blob filter: */
-                pF->pFilter->Release();
-                m_BlobFilterList.DelBlob(i-1);
-            }
-        }   /* Next blob. */
-        m_Frame++;
-    }
-
-    int     GetBlobNum(){return m_BlobFilterList.GetBlobNum();}
-    CvBlob* GetBlob(int index){return m_BlobFilterList.GetBlob(index);}
-    void    Release(){delete this;}
-
-    /* Additional functionality: */
-    CvBlob* GetBlobByID(int BlobID){return m_BlobFilterList.GetBlobByID(BlobID);}
-
-};  /* CvBlobTrackPostProcList */
-
-CvBlobTrackPostProc* cvCreateBlobTrackPostProcList(CvBlobTrackPostProcOne* (*create)())
-{
-    return (CvBlobTrackPostProc*) new CvBlobTrackPostProcList(create);
-}
-/*======================= FILTER LIST SHELL =====================*/
diff --git a/modules/legacy/src/calcimagehomography.cpp b/modules/legacy/src/calcimagehomography.cpp
deleted file mode 100644 (file)
index 928e056..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-/****************************************************************************************\
-
-   calculate image homography
-
-\****************************************************************************************/
-
-CV_IMPL void
-cvCalcImageHomography( float* line, CvPoint3D32f* _center,
-                       float* _intrinsic, float* _homography )
-{
-    double norm_xy, norm_xz, xy_sina, xy_cosa, xz_sina, xz_cosa, nx1, plane_dist;
-    float _ry[3], _rz[3], _r_trans[9];
-    CvMat rx = cvMat( 1, 3, CV_32F, line );
-    CvMat ry = cvMat( 1, 3, CV_32F, _ry );
-    CvMat rz = cvMat( 1, 3, CV_32F, _rz );
-    CvMat r_trans = cvMat( 3, 3, CV_32F, _r_trans );
-    CvMat center = cvMat( 3, 1, CV_32F, _center );
-
-    float _sub[9];
-    CvMat sub = cvMat( 3, 3, CV_32F, _sub );
-    float _t_trans[3];
-    CvMat t_trans = cvMat( 3, 1, CV_32F, _t_trans );
-
-    CvMat intrinsic = cvMat( 3, 3, CV_32F, _intrinsic );
-    CvMat homography = cvMat( 3, 3, CV_32F, _homography );
-
-    if( !line || !_center || !_intrinsic || !_homography )
-        CV_Error( CV_StsNullPtr, "" );
-
-    norm_xy = cvSqrt( line[0] * line[0] + line[1] * line[1] );
-    xy_cosa = line[0] / norm_xy;
-    xy_sina = line[1] / norm_xy;
-
-    norm_xz = cvSqrt( line[0] * line[0] + line[2] * line[2] );
-    xz_cosa = line[0] / norm_xz;
-    xz_sina = line[2] / norm_xz;
-
-    nx1 = -xz_sina;
-
-    _rz[0] = (float)(xy_cosa * nx1);
-    _rz[1] = (float)(xy_sina * nx1);
-    _rz[2] = (float)xz_cosa;
-    cvScale( &rz, &rz, 1./cvNorm(&rz,0,CV_L2) );
-
-    /*  new axe  y  */
-    cvCrossProduct( &rz, &rx, &ry );
-    cvScale( &ry, &ry, 1./cvNorm( &ry, 0, CV_L2 ) );
-
-    /*  transpone rotation matrix    */
-    memcpy( &_r_trans[0], line, 3*sizeof(float));
-    memcpy( &_r_trans[3], _ry, 3*sizeof(float));
-    memcpy( &_r_trans[6], _rz, 3*sizeof(float));
-
-    /*  calculate center distanse from arm plane  */
-    plane_dist = cvDotProduct( &center, &rz );
-
-    /* calculate (I - r_trans)*center */
-    cvSetIdentity( &sub );
-    cvSub( &sub, &r_trans, &sub );
-    cvMatMul( &sub, &center, &t_trans );
-
-    cvMatMul( &t_trans, &rz, &sub );
-    cvScaleAdd( &sub, cvRealScalar(1./plane_dist), &r_trans, &sub ); /* ? */
-
-    cvMatMul( &intrinsic, &sub, &r_trans );
-    cvInvert( &intrinsic, &sub, CV_SVD );
-    cvMatMul( &r_trans, &sub, &homography );
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/calibfilter.cpp b/modules/legacy/src/calibfilter.cpp
deleted file mode 100644 (file)
index 9bcf035..0000000
+++ /dev/null
@@ -1,915 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include <stdio.h>
-
-#undef quad
-
-CvCalibFilter::CvCalibFilter()
-{
-    /* etalon data */
-    etalonType = CV_CALIB_ETALON_USER;
-    etalonParamCount = 0;
-    etalonParams = 0;
-    etalonPointCount = 0;
-    etalonPoints = 0;
-
-    /* camera data */
-    cameraCount = 1;
-
-    memset( points, 0, sizeof(points));
-    memset( undistMap, 0, sizeof(undistMap));
-    undistImg = 0;
-    memset( latestCounts, 0, sizeof(latestCounts));
-    memset( latestPoints, 0, sizeof(latestPoints));
-    memset( &stereo, 0, sizeof(stereo) );
-    maxPoints = 0;
-    framesTotal = 15;
-    framesAccepted = 0;
-    isCalibrated = false;
-
-    imgSize = cvSize(0,0);
-    grayImg = 0;
-    tempImg = 0;
-    storage = 0;
-
-    memset( rectMap, 0, sizeof(rectMap));
-}
-
-
-CvCalibFilter::~CvCalibFilter()
-{
-    SetCameraCount(0);
-    cvFree( &etalonParams );
-    cvFree( &etalonPoints );
-    cvReleaseMat( &grayImg );
-    cvReleaseMat( &tempImg );
-    cvReleaseMat( &undistImg );
-    cvReleaseMemStorage( &storage );
-}
-
-
-bool CvCalibFilter::SetEtalon( CvCalibEtalonType type, double* params,
-                               int pointCount, CvPoint2D32f* _points )
-{
-    int i, arrSize;
-
-    Stop();
-
-    if (latestPoints != NULL)
-    {
-        for( i = 0; i < MAX_CAMERAS; i++ )
-            cvFree( latestPoints + i );
-    }
-
-    if( type == CV_CALIB_ETALON_USER || type != etalonType )
-    {
-        if (etalonParams != NULL)
-        {
-            cvFree( &etalonParams );
-        }
-    }
-
-    etalonType = type;
-
-    switch( etalonType )
-    {
-    case CV_CALIB_ETALON_CHESSBOARD:
-        etalonParamCount = 3;
-        if( !params || cvRound(params[0]) != params[0] || params[0] < 3 ||
-            cvRound(params[1]) != params[1] || params[1] < 3 || params[2] <= 0 )
-        {
-            assert(0);
-            return false;
-        }
-
-        pointCount = cvRound((params[0] - 1)*(params[1] - 1));
-        break;
-
-    case CV_CALIB_ETALON_USER:
-        etalonParamCount = 0;
-
-        if( !_points || pointCount < 4 )
-        {
-            assert(0);
-            return false;
-        }
-        break;
-
-    default:
-        assert(0);
-        return false;
-    }
-
-    if( etalonParamCount > 0 )
-    {
-        arrSize = etalonParamCount * sizeof(etalonParams[0]);
-        etalonParams = (double*)cvAlloc( arrSize );
-    }
-
-    arrSize = pointCount * sizeof(etalonPoints[0]);
-
-    if( etalonPointCount != pointCount )
-    {
-        if (etalonPoints != NULL)
-        {
-            cvFree( &etalonPoints );
-        }
-        etalonPointCount = pointCount;
-        etalonPoints = (CvPoint2D32f*)cvAlloc( arrSize );
-    }
-
-    switch( etalonType )
-    {
-    case CV_CALIB_ETALON_CHESSBOARD:
-        {
-            int etalonWidth = cvRound( params[0] ) - 1;
-            int etalonHeight = cvRound( params[1] ) - 1;
-            int x, y, k = 0;
-
-            etalonParams[0] = etalonWidth;
-            etalonParams[1] = etalonHeight;
-            etalonParams[2] = params[2];
-
-            for( y = 0; y < etalonHeight; y++ )
-                for( x = 0; x < etalonWidth; x++ )
-                {
-                    etalonPoints[k++] = cvPoint2D32f( (etalonWidth - 1 - x)*params[2],
-                                                      y*params[2] );
-                }
-        }
-        break;
-
-    case CV_CALIB_ETALON_USER:
-        if (params != NULL)
-        {
-            memcpy( etalonParams, params, arrSize );
-        }
-        if (_points != NULL)
-        {
-            memcpy( etalonPoints, _points, arrSize );
-        }
-        break;
-
-    default:
-        assert(0);
-        return false;
-    }
-
-    return true;
-}
-
-
-CvCalibEtalonType
-CvCalibFilter::GetEtalon( int* paramCount, const double** params,
-                          int* pointCount, const CvPoint2D32f** _points ) const
-{
-    if( paramCount )
-        *paramCount = etalonParamCount;
-
-    if( params )
-        *params = etalonParams;
-
-    if( pointCount )
-        *pointCount = etalonPointCount;
-
-    if( _points )
-        *_points = etalonPoints;
-
-    return etalonType;
-}
-
-
-void CvCalibFilter::SetCameraCount( int count )
-{
-    Stop();
-
-    if( count != cameraCount )
-    {
-        for( int i = 0; i < cameraCount; i++ )
-        {
-            cvFree( points + i );
-            cvFree( latestPoints + i );
-            cvReleaseMat( &undistMap[i][0] );
-            cvReleaseMat( &undistMap[i][1] );
-            cvReleaseMat( &rectMap[i][0] );
-            cvReleaseMat( &rectMap[i][1] );
-        }
-
-        memset( latestCounts, 0, sizeof(latestCounts) );
-        maxPoints = 0;
-        cameraCount = count;
-    }
-}
-
-
-bool CvCalibFilter::SetFrames( int frames )
-{
-    if( frames < 5 )
-    {
-        assert(0);
-        return false;
-    }
-
-    framesTotal = frames;
-    return true;
-}
-
-
-void CvCalibFilter::Stop( bool calibrate )
-{
-    int i, j;
-    isCalibrated = false;
-
-    // deallocate undistortion maps
-    for( i = 0; i < cameraCount; i++ )
-    {
-        cvReleaseMat( &undistMap[i][0] );
-        cvReleaseMat( &undistMap[i][1] );
-        cvReleaseMat( &rectMap[i][0] );
-        cvReleaseMat( &rectMap[i][1] );
-    }
-
-    if( calibrate && framesAccepted > 0 )
-    {
-        int n = framesAccepted;
-        CvPoint3D32f* buffer =
-            (CvPoint3D32f*)cvAlloc( n * etalonPointCount * sizeof(buffer[0]));
-        CvMat mat;
-        float* rotMatr = (float*)cvAlloc( n * 9 * sizeof(rotMatr[0]));
-        float* transVect = (float*)cvAlloc( n * 3 * sizeof(transVect[0]));
-        int* counts = (int*)cvAlloc( n * sizeof(counts[0]));
-
-        cvInitMatHeader( &mat, 1, sizeof(CvCamera)/sizeof(float), CV_32FC1, 0 );
-        memset( cameraParams, 0, cameraCount * sizeof(cameraParams[0]));
-
-        for( i = 0; i < framesAccepted; i++ )
-        {
-            counts[i] = etalonPointCount;
-            for( j = 0; j < etalonPointCount; j++ )
-                buffer[i * etalonPointCount + j] = cvPoint3D32f( etalonPoints[j].x,
-                                                                 etalonPoints[j].y, 0 );
-        }
-
-        for( i = 0; i < cameraCount; i++ )
-        {
-            cvCalibrateCamera( framesAccepted, counts,
-                               imgSize, points[i], buffer,
-                               cameraParams[i].distortion,
-                               cameraParams[i].matrix,
-                               transVect, rotMatr, 0 );
-
-            cameraParams[i].imgSize[0] = (float)imgSize.width;
-            cameraParams[i].imgSize[1] = (float)imgSize.height;
-
-//            cameraParams[i].focalLength[0] = cameraParams[i].matrix[0];
-//            cameraParams[i].focalLength[1] = cameraParams[i].matrix[4];
-
-//            cameraParams[i].principalPoint[0] = cameraParams[i].matrix[2];
-//            cameraParams[i].principalPoint[1] = cameraParams[i].matrix[5];
-
-            memcpy( cameraParams[i].rotMatr, rotMatr, 9 * sizeof(rotMatr[0]));
-            memcpy( cameraParams[i].transVect, transVect, 3 * sizeof(transVect[0]));
-
-            mat.data.ptr = (uchar*)(cameraParams + i);
-
-            /* check resultant camera parameters: if there are some INF's or NAN's,
-               stop and reset results */
-            if( !cvCheckArr( &mat, CV_CHECK_RANGE | CV_CHECK_QUIET, -10000, 10000 ))
-                break;
-        }
-
-
-
-        isCalibrated = i == cameraCount;
-
-        {/* calibrate stereo cameras */
-            if( cameraCount == 2 )
-            {
-                stereo.camera[0] = &cameraParams[0];
-                stereo.camera[1] = &cameraParams[1];
-
-                icvStereoCalibration( framesAccepted, counts,
-                                   imgSize,
-                                   points[0],points[1],
-                                   buffer,
-                                   &stereo);
-            }
-
-        }
-
-        cvFree( &buffer );
-        cvFree( &counts );
-        cvFree( &rotMatr );
-        cvFree( &transVect );
-    }
-
-    framesAccepted = 0;
-}
-
-
-bool CvCalibFilter::FindEtalon( IplImage** imgs )
-{
-    return FindEtalon( (CvMat**)imgs );
-}
-
-
-bool CvCalibFilter::FindEtalon( CvMat** mats )
-{
-    bool result = true;
-
-    if( !mats || etalonPointCount == 0 )
-    {
-        assert(0);
-        result = false;
-    }
-
-    if( result )
-    {
-        int i, tempPointCount0 = etalonPointCount*2;
-
-        for( i = 0; i < cameraCount; i++ )
-        {
-            if( !latestPoints[i] )
-                latestPoints[i] = (CvPoint2D32f*)
-                    cvAlloc( tempPointCount0*2*sizeof(latestPoints[0]));
-        }
-
-        for( i = 0; i < cameraCount; i++ )
-        {
-            CvSize size;
-            int tempPointCount = tempPointCount0;
-            bool found = false;
-
-            if( !CV_IS_MAT(mats[i]) && !CV_IS_IMAGE(mats[i]))
-            {
-                assert(0);
-                break;
-            }
-
-            size = cvGetSize(mats[i]);
-
-            if( size.width != imgSize.width || size.height != imgSize.height )
-            {
-                imgSize = size;
-            }
-
-            if( !grayImg || grayImg->width != imgSize.width ||
-                grayImg->height != imgSize.height )
-            {
-                cvReleaseMat( &grayImg );
-                cvReleaseMat( &tempImg );
-                grayImg = cvCreateMat( imgSize.height, imgSize.width, CV_8UC1 );
-                tempImg = cvCreateMat( imgSize.height, imgSize.width, CV_8UC1 );
-            }
-
-            if( !storage )
-                storage = cvCreateMemStorage();
-
-            switch( etalonType )
-            {
-            case CV_CALIB_ETALON_CHESSBOARD:
-                if( CV_MAT_CN(cvGetElemType(mats[i])) == 1 )
-                    cvCopy( mats[i], grayImg );
-                else
-                    cvCvtColor( mats[i], grayImg, CV_BGR2GRAY );
-                found = cvFindChessBoardCornerGuesses( grayImg, tempImg, storage,
-                                                       cvSize( cvRound(etalonParams[0]),
-                                                       cvRound(etalonParams[1])),
-                                                       latestPoints[i], &tempPointCount ) != 0;
-                if( found )
-                    cvFindCornerSubPix( grayImg, latestPoints[i], tempPointCount,
-                                        cvSize(5,5), cvSize(-1,-1),
-                                        cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,10,0.1));
-                break;
-            default:
-                assert(0);
-                result = false;
-                break;
-            }
-
-            latestCounts[i] = found ? tempPointCount : -tempPointCount;
-            result = result && found;
-        }
-    }
-
-    if( storage )
-        cvClearMemStorage( storage );
-
-    return result;
-}
-
-
-bool CvCalibFilter::Push( const CvPoint2D32f** pts )
-{
-    bool result = true;
-    int i, newMaxPoints = etalonPointCount*(MAX(framesAccepted,framesTotal) + 1);
-
-    isCalibrated = false;
-
-    if( !pts )
-    {
-        for( i = 0; i < cameraCount; i++ )
-            if( latestCounts[i] <= 0 )
-                return false;
-        pts = (const CvPoint2D32f**)latestPoints;
-    }
-
-    for( i = 0; i < cameraCount; i++ )
-    {
-        if( !pts[i] )
-        {
-            assert(0);
-            break;
-        }
-
-        if( maxPoints < newMaxPoints )
-        {
-            CvPoint2D32f* prev = points[i];
-            cvFree( points + i );
-            points[i] = (CvPoint2D32f*)cvAlloc( newMaxPoints * sizeof(prev[0]));
-            memcpy( points[i], prev, maxPoints * sizeof(prev[0]));
-        }
-
-        memcpy( points[i] + framesAccepted*etalonPointCount, pts[i],
-                etalonPointCount*sizeof(points[0][0]));
-    }
-
-    if( maxPoints < newMaxPoints )
-        maxPoints = newMaxPoints;
-
-    result = i == cameraCount;
-
-    if( ++framesAccepted >= framesTotal )
-        Stop( true );
-    return result;
-}
-
-
-bool CvCalibFilter::GetLatestPoints( int idx, CvPoint2D32f** pts,
-                                     int* count, bool* found )
-{
-    int n;
-
-    if( (unsigned)idx >= (unsigned)cameraCount ||
-        !pts || !count || !found )
-    {
-        assert(0);
-        return false;
-    }
-
-    n = latestCounts[idx];
-
-    *found = n > 0;
-    *count = abs(n);
-    *pts = latestPoints[idx];
-
-    return true;
-}
-
-
-void CvCalibFilter::DrawPoints( IplImage** dst )
-{
-    DrawPoints( (CvMat**)dst );
-}
-
-
-void CvCalibFilter::DrawPoints( CvMat** dstarr )
-{
-    int i, j;
-
-    if( !dstarr )
-    {
-        assert(0);
-        return;
-    }
-
-    if( latestCounts )
-    {
-        for( i = 0; i < cameraCount; i++ )
-        {
-            if( dstarr[i] && latestCounts[i] )
-            {
-                CvMat dst_stub, *dst;
-                int count = 0;
-                bool found = false;
-                CvPoint2D32f* pts = 0;
-
-                GetLatestPoints( i, &pts, &count, &found );
-
-                dst = cvGetMat( dstarr[i], &dst_stub );
-
-                static const CvScalar line_colors[] =
-                {
-                    CvScalar(0,0,255),
-                    CvScalar(0,128,255),
-                    CvScalar(0,200,200),
-                    CvScalar(0,255,0),
-                    CvScalar(200,200,0),
-                    CvScalar(255,0,0),
-                    CvScalar(255,0,255)
-                };
-
-                const int colorCount = sizeof(line_colors)/sizeof(line_colors[0]);
-                const int r = 4;
-                CvScalar color = line_colors[0];
-                CvPoint prev_pt;
-
-                for( j = 0; j < count; j++ )
-                {
-                    CvPoint pt;
-                    pt.x = cvRound(pts[j].x);
-                    pt.y = cvRound(pts[j].y);
-
-                    if( found )
-                    {
-                        if( etalonType == CV_CALIB_ETALON_CHESSBOARD )
-                            color = line_colors[(j/cvRound(etalonParams[0]))%colorCount];
-                        else
-                            color = CV_RGB(0,255,0);
-
-                        if( j != 0 )
-                            cvLine( dst, prev_pt, pt, color, 1, CV_AA );
-                    }
-
-                    cvLine( dst, cvPoint( pt.x - r, pt.y - r ),
-                            cvPoint( pt.x + r, pt.y + r ), color, 1, CV_AA );
-
-                    cvLine( dst, cvPoint( pt.x - r, pt.y + r),
-                            cvPoint( pt.x + r, pt.y - r), color, 1, CV_AA );
-
-                    cvCircle( dst, pt, r+1, color, 1, CV_AA );
-
-                    prev_pt = pt;
-                }
-            }
-        }
-    }
-}
-
-
-/* Get total number of frames and already accepted pair of frames */
-int CvCalibFilter::GetFrameCount( int* total ) const
-{
-    if( total )
-        *total = framesTotal;
-
-    return framesAccepted;
-}
-
-
-/* Get camera parameters for specified camera. If camera is not calibrated
-   the function returns 0 */
-const CvCamera* CvCalibFilter::GetCameraParams( int idx ) const
-{
-    if( (unsigned)idx >= (unsigned)cameraCount )
-    {
-        assert(0);
-        return 0;
-    }
-
-    return isCalibrated ? cameraParams + idx : 0;
-}
-
-
-/* Get camera parameters for specified camera. If camera is not calibrated
-   the function returns 0 */
-const CvStereoCamera* CvCalibFilter::GetStereoParams() const
-{
-    if( !(isCalibrated && cameraCount == 2) )
-    {
-        assert(0);
-        return 0;
-    }
-
-    return &stereo;
-}
-
-
-/* Sets camera parameters for all cameras */
-bool CvCalibFilter::SetCameraParams( CvCamera* params )
-{
-    CvMat mat;
-    int arrSize;
-
-    Stop();
-
-    if( !params )
-    {
-        assert(0);
-        return false;
-    }
-
-    arrSize = cameraCount * sizeof(params[0]);
-
-    cvInitMatHeader( &mat, 1, cameraCount * (arrSize/sizeof(float)),
-                     CV_32FC1, params );
-    cvCheckArr( &mat, CV_CHECK_RANGE, -10000, 10000 );
-
-    memcpy( cameraParams, params, arrSize );
-    isCalibrated = true;
-
-    return true;
-}
-
-
-bool CvCalibFilter::SaveCameraParams( const char* filename )
-{
-    if( isCalibrated )
-    {
-        int i, j;
-
-        FILE* f = fopen( filename, "w" );
-
-        if( !f ) return false;
-
-        fprintf( f, "%d\n\n", cameraCount );
-
-        for( i = 0; i < cameraCount; i++ )
-        {
-            for( j = 0; j < (int)(sizeof(cameraParams[i])/sizeof(float)); j++ )
-            {
-                fprintf( f, "%15.10f ", ((float*)(cameraParams + i))[j] );
-            }
-            fprintf( f, "\n\n" );
-        }
-
-        /* Save stereo params */
-
-        /* Save quad */
-        for( i = 0; i < 2; i++ )
-        {
-            for( j = 0; j < 4; j++ )
-            {
-                fprintf(f, "%15.10f ", stereo.quad[i][j].x );
-                fprintf(f, "%15.10f ", stereo.quad[i][j].y );
-            }
-            fprintf(f, "\n");
-        }
-
-        /* Save coeffs */
-        for( i = 0; i < 2; i++ )
-        {
-            for( j = 0; j < 9; j++ )
-            {
-                fprintf(f, "%15.10lf ", stereo.coeffs[i][j/3][j%3] );
-            }
-            fprintf(f, "\n");
-        }
-
-
-        fclose(f);
-        return true;
-    }
-
-    return true;
-}
-
-
-bool CvCalibFilter::LoadCameraParams( const char* filename )
-{
-    int i, j;
-    int d = 0;
-    FILE* f = fopen( filename, "r" );
-
-    isCalibrated = false;
-
-    if( !f ) return false;
-
-    if( fscanf( f, "%d", &d ) != 1 || d <= 0 || d > 10 )
-        return false;
-
-    SetCameraCount( d );
-
-    for( i = 0; i < cameraCount; i++ )
-    {
-        for( j = 0; j < (int)(sizeof(cameraParams[i])/sizeof(float)); j++ )
-        {
-            int values_read = fscanf( f, "%f", &((float*)(cameraParams + i))[j] );
-            CV_Assert(values_read == 1);
-        }
-    }
-
-
-    /* Load stereo params */
-
-    /* load quad */
-    for( i = 0; i < 2; i++ )
-    {
-        for( j = 0; j < 4; j++ )
-        {
-            int values_read = fscanf(f, "%f ", &(stereo.quad[i][j].x) );
-            CV_Assert(values_read == 1);
-            values_read = fscanf(f, "%f ", &(stereo.quad[i][j].y) );
-            CV_Assert(values_read == 1);
-        }
-    }
-
-    /* Load coeffs */
-    for( i = 0; i < 2; i++ )
-    {
-        for( j = 0; j < 9; j++ )
-        {
-            int values_read = fscanf(f, "%lf ", &(stereo.coeffs[i][j/3][j%3]) );
-            CV_Assert(values_read == 1);
-        }
-    }
-
-
-
-
-    fclose(f);
-
-    stereo.warpSize = cvSize( cvRound(cameraParams[0].imgSize[0]), cvRound(cameraParams[0].imgSize[1]));
-
-    isCalibrated = true;
-
-    return true;
-}
-
-
-bool CvCalibFilter::Rectify( IplImage** srcarr, IplImage** dstarr )
-{
-    return Rectify( (CvMat**)srcarr, (CvMat**)dstarr );
-}
-
-bool CvCalibFilter::Rectify( CvMat** srcarr, CvMat** dstarr )
-{
-    int i;
-
-    if( !srcarr || !dstarr )
-    {
-        assert(0);
-        return false;
-    }
-
-    if( isCalibrated && cameraCount == 2 )
-    {
-        for( i = 0; i < cameraCount; i++ )
-        {
-            if( srcarr[i] && dstarr[i] )
-            {
-                IplImage src_stub, *src;
-                IplImage dst_stub, *dst;
-
-                src = cvGetImage( srcarr[i], &src_stub );
-                dst = cvGetImage( dstarr[i], &dst_stub );
-
-                if( src->imageData == dst->imageData )
-                {
-                    if( !undistImg ||
-                        undistImg->width != src->width ||
-                        undistImg->height != src->height ||
-                        CV_MAT_CN(undistImg->type) != src->nChannels )
-                    {
-                        cvReleaseMat( &undistImg );
-                        undistImg = cvCreateMat( src->height, src->width,
-                                                 CV_8U + (src->nChannels-1)*8 );
-                    }
-                    cvCopy( src, undistImg );
-                    src = cvGetImage( undistImg, &src_stub );
-                }
-
-                cvZero( dst );
-
-                if( !rectMap[i][0] || rectMap[i][0]->width != src->width ||
-                    rectMap[i][0]->height != src->height )
-                {
-                    cvReleaseMat( &rectMap[i][0] );
-                    cvReleaseMat( &rectMap[i][1] );
-                    rectMap[i][0] = cvCreateMat(stereo.warpSize.height,stereo.warpSize.width,CV_32FC1);
-                    rectMap[i][1] = cvCreateMat(stereo.warpSize.height,stereo.warpSize.width,CV_32FC1);
-                    cvComputePerspectiveMap(stereo.coeffs[i], rectMap[i][0], rectMap[i][1]);
-                }
-                cvRemap( src, dst, rectMap[i][0], rectMap[i][1] );
-            }
-        }
-    }
-    else
-    {
-        for( i = 0; i < cameraCount; i++ )
-        {
-            if( srcarr[i] != dstarr[i] )
-                cvCopy( srcarr[i], dstarr[i] );
-        }
-    }
-
-    return true;
-}
-
-bool CvCalibFilter::Undistort( IplImage** srcarr, IplImage** dstarr )
-{
-    return Undistort( (CvMat**)srcarr, (CvMat**)dstarr );
-}
-
-
-bool CvCalibFilter::Undistort( CvMat** srcarr, CvMat** dstarr )
-{
-    int i;
-
-    if( !srcarr || !dstarr )
-    {
-        assert(0);
-        return false;
-    }
-
-    if( isCalibrated )
-    {
-        for( i = 0; i < cameraCount; i++ )
-        {
-            if( srcarr[i] && dstarr[i] )
-            {
-                CvMat src_stub, *src;
-                CvMat dst_stub, *dst;
-
-                src = cvGetMat( srcarr[i], &src_stub );
-                dst = cvGetMat( dstarr[i], &dst_stub );
-
-                if( src->data.ptr == dst->data.ptr )
-                {
-                    if( !undistImg || undistImg->width != src->width ||
-                        undistImg->height != src->height ||
-                        CV_ARE_TYPES_EQ( undistImg, src ))
-                    {
-                        cvReleaseMat( &undistImg );
-                        undistImg = cvCreateMat( src->height, src->width, src->type );
-                    }
-
-                    cvCopy( src, undistImg );
-                    src = undistImg;
-                }
-
-            #if 1
-                {
-                CvMat A = cvMat( 3, 3, CV_32FC1, cameraParams[i].matrix );
-                CvMat k = cvMat( 1, 4, CV_32FC1, cameraParams[i].distortion );
-
-                if( !undistMap[i][0] || undistMap[i][0]->width != src->width ||
-                     undistMap[i][0]->height != src->height )
-                {
-                    cvReleaseMat( &undistMap[i][0] );
-                    cvReleaseMat( &undistMap[i][1] );
-                    undistMap[i][0] = cvCreateMat( src->height, src->width, CV_32FC1 );
-                    undistMap[i][1] = cvCreateMat( src->height, src->width, CV_32FC1 );
-                    cvInitUndistortMap( &A, &k, undistMap[i][0], undistMap[i][1] );
-                }
-
-                cvRemap( src, dst, undistMap[i][0], undistMap[i][1] );
-            #else
-                cvUndistort2( src, dst, &A, &k );
-            #endif
-                }
-            }
-        }
-    }
-    else
-    {
-        for( i = 0; i < cameraCount; i++ )
-        {
-            if( srcarr[i] != dstarr[i] )
-                cvCopy( srcarr[i], dstarr[i] );
-        }
-    }
-
-
-    return true;
-}
diff --git a/modules/legacy/src/calonder.cpp b/modules/legacy/src/calonder.cpp
deleted file mode 100644 (file)
index c5a8a6e..0000000
+++ /dev/null
@@ -1,998 +0,0 @@
-//*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-#include <cstdio>
-#include <iostream>
-#include <fstream>
-
-class CSMatrixGenerator {
-public:
-   typedef enum { PDT_GAUSS=1, PDT_BERNOULLI, PDT_DBFRIENDLY } PHI_DISTR_TYPE;
-   ~CSMatrixGenerator();
-   static float* getCSMatrix(int m, int n, PHI_DISTR_TYPE dt);     // do NOT free returned pointer
-
-
-private:
-   static float *cs_phi_;    // matrix for compressive sensing
-   static int cs_phi_m_, cs_phi_n_;
-};
-
-float* CSMatrixGenerator::getCSMatrix(int m, int n, PHI_DISTR_TYPE dt)
-{
-   assert(m <= n);
-
-   if (cs_phi_m_!=m || cs_phi_n_!=n || cs_phi_==NULL) {
-      if (cs_phi_) delete [] cs_phi_;
-      cs_phi_ = new float[m*n];
-   }
-
-   #if 0 // debug - load the random matrix from a file (for reproducability of results)
-      //assert(m == 176);
-      //assert(n == 500);
-      //const char *phi = "/u/calonder/temp/dim_red/kpca_phi.txt";
-      const char *phi = "/u/calonder/temp/dim_red/debug_phi.txt";
-      std::ifstream ifs(phi);
-      for (size_t i=0; i<m*n; ++i) {
-         if (!ifs.good()) {
-            printf("[ERROR] RandomizedTree::makeRandomMeasMatrix: problem reading '%s'\n", phi);
-            exit(0);
-         }
-         ifs >> cs_phi[i];
-      }
-      ifs.close();
-
-      static bool warned=false;
-      if (!warned) {
-         printf("[NOTE] RT: reading %ix%i PHI matrix from '%s'...\n", m, n, phi);
-         warned=true;
-      }
-
-      return;
-   #endif
-
-   float *cs_phi = cs_phi_;
-
-   if (m == n) {
-      // special case - set to 0 for safety
-      memset(cs_phi, 0, m*n*sizeof(float));
-      printf("[WARNING] %s:%i: square CS matrix (-> no reduction)\n", __FILE__, __LINE__);
-   }
-   else {
-       cv::RNG rng(23);
-
-      // par is distr param, cf 'Favorable JL Distributions' (Baraniuk et al, 2006)
-      if (dt == PDT_GAUSS) {
-         float par = (float)(1./m);
-         for (int i=0; i<m*n; ++i)
-            *cs_phi++ = (float)rng.gaussian(par);
-      }
-      else if (dt == PDT_BERNOULLI) {
-         float par = (float)(1./sqrt((float)m));
-         for (int i=0; i<m*n; ++i)
-            *cs_phi++ = (rng(2)==0 ? par : -par);
-      }
-      else if (dt == PDT_DBFRIENDLY) {
-         float par = (float)sqrt(3./m);
-         for (int i=0; i<m*n; ++i) {
-            int r = rng(6);
-            *cs_phi++ = (r==0 ? par : (r==1 ? -par : 0.f));
-         }
-      }
-      else
-         throw("PHI_DISTR_TYPE not implemented.");
-   }
-
-   return cs_phi_;
-}
-
-CSMatrixGenerator::~CSMatrixGenerator()
-{
-   if (cs_phi_) delete [] cs_phi_;
-   cs_phi_ = NULL;
-}
-
-float *CSMatrixGenerator::cs_phi_   = NULL;
-int    CSMatrixGenerator::cs_phi_m_ = 0;
-int    CSMatrixGenerator::cs_phi_n_ = 0;
-
-
-inline void addVec(int size, const float* src1, const float* src2, float* dst)
-{
-  while(--size >= 0) {
-    *dst = *src1 + *src2;
-    ++dst; ++src1; ++src2;
-  }
-}
-
-
-// sum up 50 byte vectors of length 176
-// assume 4 bits max for input vector values
-// final shift is 2 bits right
-// temp buffer should be twice as long as signature
-// sig and buffer need not be initialized
-inline void sum_50t_176c(uchar **pp, uchar *sig, unsigned short *temp)
-{
-#if CV_SSE2
-  __m128i acc, *acc1, *acc2, *acc3, *acc4, tzero;
-  __m128i *ssig, *ttemp;
-
-  ssig = (__m128i *)sig;
-  ttemp = (__m128i *)temp;
-
-  // empty ttemp[]
-  tzero = _mm_set_epi32(0, 0, 0, 0);
-  for (int i=0; i<22; i++)
-    ttemp[i] = tzero;
-
-  for (int j=0; j<48; j+=16)
-    {
-      // empty ssig[]
-      for (int i=0; i<11; i++)
-    ssig[i] = tzero;
-
-      for (int i=j; i<j+16; i+=4) // 4 columns at a time, to 16
-    {
-      acc1 = (__m128i *)pp[i];
-      acc2 = (__m128i *)pp[i+1];
-      acc3 = (__m128i *)pp[i+2];
-      acc4 = (__m128i *)pp[i+3];
-
-      // add next four columns
-      acc = _mm_adds_epu8(acc1[0],acc2[0]);
-      acc = _mm_adds_epu8(acc,acc3[0]);
-      acc = _mm_adds_epu8(acc,acc4[1]);
-      ssig[0] = _mm_adds_epu8(acc,ssig[0]);
-      // add four columns
-      acc = _mm_adds_epu8(acc1[1],acc2[1]);
-      acc = _mm_adds_epu8(acc,acc3[1]);
-      acc = _mm_adds_epu8(acc,acc4[1]);
-      ssig[1] = _mm_adds_epu8(acc,ssig[1]);
-      // add four columns
-      acc = _mm_adds_epu8(acc1[2],acc2[2]);
-      acc = _mm_adds_epu8(acc,acc3[2]);
-      acc = _mm_adds_epu8(acc,acc4[2]);
-      ssig[2] = _mm_adds_epu8(acc,ssig[2]);
-      // add four columns
-      acc = _mm_adds_epu8(acc1[3],acc2[3]);
-      acc = _mm_adds_epu8(acc,acc3[3]);
-      acc = _mm_adds_epu8(acc,acc4[3]);
-      ssig[3] = _mm_adds_epu8(acc,ssig[3]);
-      // add four columns
-      acc = _mm_adds_epu8(acc1[4],acc2[4]);
-      acc = _mm_adds_epu8(acc,acc3[4]);
-      acc = _mm_adds_epu8(acc,acc4[4]);
-      ssig[4] = _mm_adds_epu8(acc,ssig[4]);
-      // add four columns
-      acc = _mm_adds_epu8(acc1[5],acc2[5]);
-      acc = _mm_adds_epu8(acc,acc3[5]);
-      acc = _mm_adds_epu8(acc,acc4[5]);
-      ssig[5] = _mm_adds_epu8(acc,ssig[5]);
-      // add four columns
-      acc = _mm_adds_epu8(acc1[6],acc2[6]);
-      acc = _mm_adds_epu8(acc,acc3[6]);
-      acc = _mm_adds_epu8(acc,acc4[6]);
-      ssig[6] = _mm_adds_epu8(acc,ssig[6]);
-      // add four columns
-      acc = _mm_adds_epu8(acc1[7],acc2[7]);
-      acc = _mm_adds_epu8(acc,acc3[7]);
-      acc = _mm_adds_epu8(acc,acc4[7]);
-      ssig[7] = _mm_adds_epu8(acc,ssig[7]);
-      // add four columns
-      acc = _mm_adds_epu8(acc1[8],acc2[8]);
-      acc = _mm_adds_epu8(acc,acc3[8]);
-      acc = _mm_adds_epu8(acc,acc4[8]);
-      ssig[8] = _mm_adds_epu8(acc,ssig[8]);
-      // add four columns
-      acc = _mm_adds_epu8(acc1[9],acc2[9]);
-      acc = _mm_adds_epu8(acc,acc3[9]);
-      acc = _mm_adds_epu8(acc,acc4[9]);
-      ssig[9] = _mm_adds_epu8(acc,ssig[9]);
-      // add four columns
-      acc = _mm_adds_epu8(acc1[10],acc2[10]);
-      acc = _mm_adds_epu8(acc,acc3[10]);
-      acc = _mm_adds_epu8(acc,acc4[10]);
-      ssig[10] = _mm_adds_epu8(acc,ssig[10]);
-    }
-
-      // unpack to ttemp buffer and add
-      ttemp[0] = _mm_add_epi16(_mm_unpacklo_epi8(ssig[0],tzero),ttemp[0]);
-      ttemp[1] = _mm_add_epi16(_mm_unpackhi_epi8(ssig[0],tzero),ttemp[1]);
-      ttemp[2] = _mm_add_epi16(_mm_unpacklo_epi8(ssig[1],tzero),ttemp[2]);
-      ttemp[3] = _mm_add_epi16(_mm_unpackhi_epi8(ssig[1],tzero),ttemp[3]);
-      ttemp[4] = _mm_add_epi16(_mm_unpacklo_epi8(ssig[2],tzero),ttemp[4]);
-      ttemp[5] = _mm_add_epi16(_mm_unpackhi_epi8(ssig[2],tzero),ttemp[5]);
-      ttemp[6] = _mm_add_epi16(_mm_unpacklo_epi8(ssig[3],tzero),ttemp[6]);
-      ttemp[7] = _mm_add_epi16(_mm_unpackhi_epi8(ssig[3],tzero),ttemp[7]);
-      ttemp[8] = _mm_add_epi16(_mm_unpacklo_epi8(ssig[4],tzero),ttemp[8]);
-      ttemp[9] = _mm_add_epi16(_mm_unpackhi_epi8(ssig[4],tzero),ttemp[9]);
-      ttemp[10] = _mm_add_epi16(_mm_unpacklo_epi8(ssig[5],tzero),ttemp[10]);
-      ttemp[11] = _mm_add_epi16(_mm_unpackhi_epi8(ssig[5],tzero),ttemp[11]);
-      ttemp[12] = _mm_add_epi16(_mm_unpacklo_epi8(ssig[6],tzero),ttemp[12]);
-      ttemp[13] = _mm_add_epi16(_mm_unpackhi_epi8(ssig[6],tzero),ttemp[13]);
-      ttemp[14] = _mm_add_epi16(_mm_unpacklo_epi8(ssig[7],tzero),ttemp[14]);
-      ttemp[15] = _mm_add_epi16(_mm_unpackhi_epi8(ssig[7],tzero),ttemp[15]);
-      ttemp[16] = _mm_add_epi16(_mm_unpacklo_epi8(ssig[8],tzero),ttemp[16]);
-      ttemp[17] = _mm_add_epi16(_mm_unpackhi_epi8(ssig[8],tzero),ttemp[17]);
-      ttemp[18] = _mm_add_epi16(_mm_unpacklo_epi8(ssig[9],tzero),ttemp[18]);
-      ttemp[19] = _mm_add_epi16(_mm_unpackhi_epi8(ssig[9],tzero),ttemp[19]);
-      ttemp[20] = _mm_add_epi16(_mm_unpacklo_epi8(ssig[10],tzero),ttemp[20]);
-      ttemp[21] = _mm_add_epi16(_mm_unpackhi_epi8(ssig[10],tzero),ttemp[21]);
-    }
-
-  // create ssignature from 16-bit result
-  ssig[0] =_mm_packus_epi16(_mm_srai_epi16(ttemp[0],2),_mm_srai_epi16(ttemp[1],2));
-  ssig[1] =_mm_packus_epi16(_mm_srai_epi16(ttemp[2],2),_mm_srai_epi16(ttemp[3],2));
-  ssig[2] =_mm_packus_epi16(_mm_srai_epi16(ttemp[4],2),_mm_srai_epi16(ttemp[5],2));
-  ssig[3] =_mm_packus_epi16(_mm_srai_epi16(ttemp[6],2),_mm_srai_epi16(ttemp[7],2));
-  ssig[4] =_mm_packus_epi16(_mm_srai_epi16(ttemp[8],2),_mm_srai_epi16(ttemp[9],2));
-  ssig[5] =_mm_packus_epi16(_mm_srai_epi16(ttemp[10],2),_mm_srai_epi16(ttemp[11],2));
-  ssig[6] =_mm_packus_epi16(_mm_srai_epi16(ttemp[12],2),_mm_srai_epi16(ttemp[13],2));
-  ssig[7] =_mm_packus_epi16(_mm_srai_epi16(ttemp[14],2),_mm_srai_epi16(ttemp[15],2));
-  ssig[8] =_mm_packus_epi16(_mm_srai_epi16(ttemp[16],2),_mm_srai_epi16(ttemp[17],2));
-  ssig[9] =_mm_packus_epi16(_mm_srai_epi16(ttemp[18],2),_mm_srai_epi16(ttemp[19],2));
-  ssig[10] =_mm_packus_epi16(_mm_srai_epi16(ttemp[20],2),_mm_srai_epi16(ttemp[21],2));
-#else
-  (void)pp;
-  (void)sig;
-  (void)temp;
-  CV_Error( CV_StsNotImplemented, "Not supported without SSE2" );
-#endif
-}
-
-namespace cv
-{
-RandomizedTree::RandomizedTree()
-  : posteriors_(NULL), posteriors2_(NULL)
-{
-}
-
-RandomizedTree::~RandomizedTree()
-{
-   freePosteriors(3);
-}
-
-void RandomizedTree::createNodes(int num_nodes, RNG &rng)
-{
-  nodes_.reserve(num_nodes);
-  for (int i = 0; i < num_nodes; ++i) {
-    nodes_.push_back( RTreeNode((uchar)rng(RandomizedTree::PATCH_SIZE),
-                                (uchar)rng(RandomizedTree::PATCH_SIZE),
-                                (uchar)rng(RandomizedTree::PATCH_SIZE),
-                                (uchar)rng(RandomizedTree::PATCH_SIZE)) );
-  }
-}
-
-int RandomizedTree::getIndex(uchar* patch_data) const
-{
-  int index = 0;
-  for (int d = 0; d < depth_; ++d) {
-    int child_offset = nodes_[index](patch_data);
-    index = 2*index + 1 + child_offset;
-  }
-  return (int)(index - nodes_.size());
-}
-
-void RandomizedTree::train(std::vector<BaseKeypoint> const& base_set,
-                           RNG &rng, int _depth, int views, size_t reduced_num_dim,
-                           int num_quant_bits)
-{
-  PatchGenerator make_patch;
-  train(base_set, rng, make_patch, _depth, views, reduced_num_dim, num_quant_bits);
-}
-
-void RandomizedTree::train(std::vector<BaseKeypoint> const& base_set,
-                           RNG &rng, PatchGenerator &make_patch,
-                           int _depth, int views, size_t reduced_num_dim,
-                           int num_quant_bits)
-{
-  init((int)base_set.size(), _depth, rng);
-
-  Mat patch;
-
-  // Estimate posterior probabilities using random affine views
-  std::vector<BaseKeypoint>::const_iterator keypt_it;
-  int class_id = 0;
-  Size patchSize(PATCH_SIZE, PATCH_SIZE);
-  for (keypt_it = base_set.begin(); keypt_it != base_set.end(); ++keypt_it, ++class_id) {
-    for (int i = 0; i < views; ++i) {
-      make_patch( cv::cvarrToMat(keypt_it->image), Point(keypt_it->x, keypt_it->y ), patch, patchSize, rng );
-      IplImage iplPatch = patch;
-      addExample(class_id, getData(&iplPatch));
-    }
-  }
-
-  finalize(reduced_num_dim, num_quant_bits);
-}
-
-void RandomizedTree::allocPosteriorsAligned(int num_leaves, int num_classes)
-{
-  freePosteriors(3);
-
-  posteriors_ = new float*[num_leaves]; //(float**) malloc(num_leaves*sizeof(float*));
-  for (int i=0; i<num_leaves; ++i) {
-    posteriors_[i] = (float*)cvAlloc(num_classes*sizeof(posteriors_[i][0]));
-    memset(posteriors_[i], 0, num_classes*sizeof(float));
-  }
-
-  posteriors2_ = new uchar*[num_leaves];
-  for (int i=0; i<num_leaves; ++i) {
-    posteriors2_[i] = (uchar*)cvAlloc(num_classes*sizeof(posteriors2_[i][0]));
-    memset(posteriors2_[i], 0, num_classes*sizeof(uchar));
-  }
-
-  classes_ = num_classes;
-}
-
-void RandomizedTree::freePosteriors(int which)
-{
-   if (posteriors_ && (which&1)) {
-      for (int i=0; i<num_leaves_; ++i)
-         if (posteriors_[i])
-            cvFree( &posteriors_[i] );
-      delete [] posteriors_;
-      posteriors_ = NULL;
-   }
-
-   if (posteriors2_ && (which&2)) {
-      for (int i=0; i<num_leaves_; ++i)
-         cvFree( &posteriors2_[i] );
-      delete [] posteriors2_;
-      posteriors2_ = NULL;
-   }
-
-   classes_ = -1;
-}
-
-void RandomizedTree::init(int num_classes, int _depth, RNG &rng)
-{
-  depth_ = _depth;
-  num_leaves_ = 1 << _depth;       // 2**d
-  int num_nodes = num_leaves_ - 1; // 2**d - 1
-
-  // Initialize probabilities and counts to 0
-  allocPosteriorsAligned(num_leaves_, num_classes);      // will set classes_ correctly
-  for (int i = 0; i < num_leaves_; ++i)
-    memset((void*)posteriors_[i], 0, num_classes*sizeof(float));
-  leaf_counts_.resize(num_leaves_);
-
-  for (int i = 0; i < num_leaves_; ++i)
-    memset((void*)posteriors2_[i], 0, num_classes*sizeof(uchar));
-
-  createNodes(num_nodes, rng);
-}
-
-void RandomizedTree::addExample(int class_id, uchar* patch_data)
-{
-  int index = getIndex(patch_data);
-  float* posterior = getPosteriorByIndex(index);
-  ++leaf_counts_[index];
-  ++posterior[class_id];
-}
-
-// returns the p% percentile of data (length n vector)
-static float percentile(float *data, int n, float p)
-{
-   assert(n>0);
-   assert(p>=0 && p<=1);
-   std::vector<float> vec(data, data+n);
-   std::sort(vec.begin(), vec.end());
-   int ix = (int)(p*(n-1));
-   return vec[ix];
-}
-
-void RandomizedTree::finalize(size_t reduced_num_dim, int num_quant_bits)
-{
-   // Normalize by number of patches to reach each leaf
-   for (int index = 0; index < num_leaves_; ++index) {
-      float* posterior = posteriors_[index];
-      assert(posterior != NULL);
-      int count = leaf_counts_[index];
-      if (count != 0) {
-         float normalizer = 1.0f / count;
-         for (int c = 0; c < classes_; ++c) {
-            *posterior *= normalizer;
-            ++posterior;
-         }
-      }
-   }
-   leaf_counts_.clear();
-
-   // apply compressive sensing
-   if ((int)reduced_num_dim != classes_)
-      compressLeaves(reduced_num_dim);
-   else {
-      static bool notified = false;
-      if (!notified)
-         printf("\n[OK] NO compression to leaves applied, dim=%i\n", (int)reduced_num_dim);
-      notified = true;
-   }
-
-   // convert float-posteriors to char-posteriors (quantization step)
-   makePosteriors2(num_quant_bits);
-}
-
-void RandomizedTree::compressLeaves(size_t reduced_num_dim)
-{
-   static bool warned = false;
-   if (!warned) {
-      printf("\n[OK] compressing leaves with phi %i x %i\n", (int)reduced_num_dim, (int)classes_);
-      warned = true;
-   }
-
-   static bool warned2 = false;
-   if ((int)reduced_num_dim == classes_) {
-     if (!warned2)
-       printf("[WARNING] RandomizedTree::compressLeaves:  not compressing because reduced_dim == classes()\n");
-     warned2 = true;
-     return;
-   }
-
-   // DO NOT FREE RETURNED POINTER
-   float *cs_phi = CSMatrixGenerator::getCSMatrix((int)reduced_num_dim, classes_, CSMatrixGenerator::PDT_BERNOULLI);
-
-   float *cs_posteriors = new float[num_leaves_ * reduced_num_dim];         // temp, num_leaves_ x reduced_num_dim
-   for (int i=0; i<num_leaves_; ++i) {
-      float *post = getPosteriorByIndex(i);
-      float *prod = &cs_posteriors[i*reduced_num_dim];
-      Mat A( (int)reduced_num_dim, classes_, CV_32FC1, cs_phi );
-      Mat X( classes_, 1, CV_32FC1, post );
-      Mat Y( (int)reduced_num_dim, 1, CV_32FC1, prod );
-      Y = A*X;
-   }
-
-   // copy new posteriors
-   freePosteriors(3);
-   allocPosteriorsAligned(num_leaves_, (int)reduced_num_dim);
-   for (int i=0; i<num_leaves_; ++i)
-      memcpy(posteriors_[i], &cs_posteriors[i*reduced_num_dim], reduced_num_dim*sizeof(float));
-   classes_ = (int)reduced_num_dim;
-
-   delete [] cs_posteriors;
-}
-
-void RandomizedTree::makePosteriors2(int num_quant_bits)
-{
-   int N = (1<<num_quant_bits) - 1;
-
-   float perc[2];
-   estimateQuantPercForPosteriors(perc);
-
-   assert(posteriors_ != NULL);
-   for (int i=0; i<num_leaves_; ++i)
-      quantizeVector(posteriors_[i], classes_, N, perc, posteriors2_[i]);
-
-   // printf("makePosteriors2 quantization bounds: %.3e, %.3e (num_leaves=%i, N=%i)\n",
-   //        perc[0], perc[1], num_leaves_, N);
-}
-
-void RandomizedTree::estimateQuantPercForPosteriors(float perc[2])
-{
-   // _estimate_ percentiles for this tree
-   // TODO: do this more accurately
-   assert(posteriors_ != NULL);
-   perc[0] = perc[1] = .0f;
-   for (int i=0; i<num_leaves_; i++) {
-      perc[0] += percentile(posteriors_[i], classes_, GET_LOWER_QUANT_PERC());
-      perc[1] += percentile(posteriors_[i], classes_, GET_UPPER_QUANT_PERC());
-   }
-   perc[0] /= num_leaves_;
-   perc[1] /= num_leaves_;
-}
-
-
-float* RandomizedTree::getPosterior(uchar* patch_data)
-{
-  return const_cast<float*>(const_cast<const RandomizedTree*>(this)->getPosterior(patch_data));
-}
-
-const float* RandomizedTree::getPosterior(uchar* patch_data) const
-{
-  return getPosteriorByIndex( getIndex(patch_data) );
-}
-
-uchar* RandomizedTree::getPosterior2(uchar* patch_data)
-{
-  return const_cast<uchar*>(const_cast<const RandomizedTree*>(this)->getPosterior2(patch_data));
-}
-
-const uchar* RandomizedTree::getPosterior2(uchar* patch_data) const
-{
-  return getPosteriorByIndex2( getIndex(patch_data) );
-}
-
-void RandomizedTree::quantizeVector(float *vec, int dim, int N, float bnds[2], int clamp_mode)
-{
-   float map_bnd[2] = {0.f,(float)N};          // bounds of quantized target interval we're mapping to
-   for (int k=0; k<dim; ++k, ++vec) {
-      *vec = float(int((*vec - bnds[0])/(bnds[1] - bnds[0])*(map_bnd[1] - map_bnd[0]) + map_bnd[0]));
-      // 0: clamp both, lower and upper values
-      if (clamp_mode == 0)      *vec = (*vec<map_bnd[0]) ? map_bnd[0] : ((*vec>map_bnd[1]) ? map_bnd[1] : *vec);
-      // 1: clamp lower values only
-      else if (clamp_mode == 1) *vec = (*vec<map_bnd[0]) ? map_bnd[0] : *vec;
-      // 2: clamp upper values only
-      else if (clamp_mode == 2) *vec = (*vec>map_bnd[1]) ? map_bnd[1] : *vec;
-      // 4: no clamping
-      else if (clamp_mode == 4) ; // yep, nothing
-      else {
-         printf("clamp_mode == %i is not valid (%s:%i).\n", clamp_mode, __FILE__, __LINE__);
-         exit(1);
-      }
-   }
-
-}
-
-void RandomizedTree::quantizeVector(float *vec, int dim, int N, float bnds[2], uchar *dst)
-{
-   int map_bnd[2] = {0, N};          // bounds of quantized target interval we're mapping to
-   int tmp;
-   for (int k=0; k<dim; ++k) {
-      tmp = int((*vec - bnds[0])/(bnds[1] - bnds[0])*(map_bnd[1] - map_bnd[0]) + map_bnd[0]);
-      *dst = (uchar)((tmp<0) ? 0 : ((tmp>N) ? N : tmp));
-      ++vec;
-      ++dst;
-   }
-}
-
-
-void RandomizedTree::read(const char* file_name, int num_quant_bits)
-{
-  std::ifstream file(file_name, std::ifstream::binary);
-  read(file, num_quant_bits);
-  file.close();
-}
-
-void RandomizedTree::read(std::istream &is, int num_quant_bits)
-{
-  is.read((char*)(&classes_), sizeof(classes_));
-  is.read((char*)(&depth_), sizeof(depth_));
-
-  num_leaves_ = 1 << depth_;
-  int num_nodes = num_leaves_ - 1;
-
-  nodes_.resize(num_nodes);
-  is.read((char*)(&nodes_[0]), num_nodes * sizeof(nodes_[0]));
-
-  //posteriors_.resize(classes_ * num_leaves_);
-  //freePosteriors(3);
-  //printf("[DEBUG] reading: %i leaves, %i classes\n", num_leaves_, classes_);
-  allocPosteriorsAligned(num_leaves_, classes_);
-  for (int i=0; i<num_leaves_; i++)
-    is.read((char*)posteriors_[i], classes_ * sizeof(*posteriors_[0]));
-
-  // make char-posteriors from float-posteriors
-  makePosteriors2(num_quant_bits);
-}
-
-void RandomizedTree::write(const char* file_name) const
-{
-  std::ofstream file(file_name, std::ofstream::binary);
-  write(file);
-  file.close();
-}
-
-void RandomizedTree::write(std::ostream &os) const
-{
-  if (!posteriors_) {
-    printf("WARNING: Cannot write float posteriors (posteriors_ = NULL).\n");
-    return;
-  }
-
-  os.write((char*)(&classes_), sizeof(classes_));
-  os.write((char*)(&depth_), sizeof(depth_));
-
-  os.write((char*)(&nodes_[0]), (int)(nodes_.size() * sizeof(nodes_[0])));
-  for (int i=0; i<num_leaves_; i++) {
-    os.write((char*)posteriors_[i], classes_ * sizeof(*posteriors_[0]));
-  }
-}
-
-
-void RandomizedTree::savePosteriors(String url, bool append)
-{
-   std::ofstream file(url.c_str(), (append?std::ios::app:std::ios::out));
-   for (int i=0; i<num_leaves_; i++) {
-      float *post = posteriors_[i];
-      char buf[20];
-      for (int j=0; j<classes_; j++) {
-         sprintf(buf, "%.10e", *post++);
-         file << buf << ((j<classes_-1) ? " " : "");
-      }
-      file << std::endl;
-   }
-   file.close();
-}
-
-void RandomizedTree::savePosteriors2(String url, bool append)
-{
-   std::ofstream file(url.c_str(), (append?std::ios::app:std::ios::out));
-   for (int i=0; i<num_leaves_; i++) {
-      uchar *post = posteriors2_[i];
-      for (int j=0; j<classes_; j++)
-         file << int(*post++) << (j<classes_-1?" ":"");
-      file << std::endl;
-   }
-   file.close();
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-RTreeClassifier::RTreeClassifier()
-  : classes_(0)
-{
-  posteriors_ = NULL;
-}
-
-void RTreeClassifier::train(std::vector<BaseKeypoint> const& base_set,
-                            RNG &rng, int num_trees, int depth,
-                            int views, size_t reduced_num_dim,
-                            int num_quant_bits)
-{
-  PatchGenerator make_patch;
-  train(base_set, rng, make_patch, num_trees, depth, views, reduced_num_dim, num_quant_bits);
-}
-
-// Single-threaded version of train(), with progress output
-void RTreeClassifier::train(std::vector<BaseKeypoint> const& base_set,
-                            RNG &rng, PatchGenerator &make_patch, int num_trees,
-                            int depth, int views, size_t reduced_num_dim,
-                            int num_quant_bits)
-{
-  if (reduced_num_dim > base_set.size()) {
-    printf("INVALID PARAMS in RTreeClassifier::train: reduced_num_dim{%i} > base_set.size(){%i}\n",
-           (int)reduced_num_dim, (int)base_set.size());
-    return;
-  }
-
-  num_quant_bits_ = num_quant_bits;
-  classes_ = (int)reduced_num_dim; // base_set.size();
-  original_num_classes_ = (int)base_set.size();
-  trees_.resize(num_trees);
-
-  printf("[OK] Training trees: base size=%i, reduced size=%i\n", (int)base_set.size(), (int)reduced_num_dim);
-
-  int count = 1;
-  printf("[OK] Trained 0 / %i trees", num_trees);  fflush(stdout);
-  for( int ti = 0; ti < num_trees; ti++ ) {
-    trees_[ti].train(base_set, rng, make_patch, depth, views, reduced_num_dim, num_quant_bits_);
-    printf("\r[OK] Trained %i / %i trees", count++, num_trees);
-    fflush(stdout);
-  }
-
-  printf("\n");
-  countZeroElements();
-  printf("\n\n");
-}
-
-void RTreeClassifier::getSignature(IplImage* patch, float *sig) const
-{
-  // Need pointer to 32x32 patch data
-  uchar buffer[RandomizedTree::PATCH_SIZE * RandomizedTree::PATCH_SIZE];
-  uchar* patch_data;
-  if (patch->widthStep != RandomizedTree::PATCH_SIZE) {
-    //printf("[INFO] patch is padded, data will be copied (%i/%i).\n",
-    //       patch->widthStep, RandomizedTree::PATCH_SIZE);
-    uchar* data = getData(patch);
-    patch_data = buffer;
-    for (int i = 0; i < RandomizedTree::PATCH_SIZE; ++i) {
-      memcpy((void*)patch_data, (void*)data, RandomizedTree::PATCH_SIZE);
-      data += patch->widthStep;
-      patch_data += RandomizedTree::PATCH_SIZE;
-    }
-    patch_data = buffer;
-  }
-  else {
-    patch_data = getData(patch);
-  }
-
-  memset((void*)sig, 0, classes_ * sizeof(float));
-  std::vector<RandomizedTree>::const_iterator tree_it;
-
-  // get posteriors
-  float **posteriors = new float*[trees_.size()];  // TODO: move alloc outside this func
-  float **pp = posteriors;
-  for (tree_it = trees_.begin(); tree_it != trees_.end(); ++tree_it, pp++) {
-    *pp = const_cast<float*>(tree_it->getPosterior(patch_data));
-    assert(*pp != NULL);
-  }
-
-  // sum them up
-  pp = posteriors;
-  for (tree_it = trees_.begin(); tree_it != trees_.end(); ++tree_it, pp++)
-    addVec(classes_, sig, *pp, sig);
-
-  delete [] posteriors;
-  posteriors = NULL;
-
-  // full quantization (experimental)
-  #if 0
-    int n_max = 1<<8 - 1;
-    int sum_max = (1<<4 - 1)*trees_.size();
-    int shift = 0;
-    while ((sum_max>>shift) > n_max) shift++;
-
-    for (int i = 0; i < classes_; ++i) {
-      sig[i] = int(sig[i] + .5) >> shift;
-      if (sig[i]>n_max) sig[i] = n_max;
-    }
-
-    static bool warned = false;
-    if (!warned) {
-      printf("[WARNING] Using full quantization (RTreeClassifier::getSignature)! shift=%i\n", shift);
-      warned = true;
-    }
-  #else
-    // TODO: get rid of this multiply (-> number of trees is known at train
-    // time, exploit it in RandomizedTree::finalize())
-    float normalizer = 1.0f / trees_.size();
-    for (int i = 0; i < classes_; ++i)
-      sig[i] *= normalizer;
-  #endif
-}
-
-void RTreeClassifier::getSignature(IplImage* patch, uchar *sig) const
-{
-  // Need pointer to 32x32 patch data
-  uchar buffer[RandomizedTree::PATCH_SIZE * RandomizedTree::PATCH_SIZE];
-  uchar* patch_data;
-  if (patch->widthStep != RandomizedTree::PATCH_SIZE) {
-    //printf("[INFO] patch is padded, data will be copied (%i/%i).\n",
-    //       patch->widthStep, RandomizedTree::PATCH_SIZE);
-    uchar* data = getData(patch);
-    patch_data = buffer;
-    for (int i = 0; i < RandomizedTree::PATCH_SIZE; ++i) {
-      memcpy((void*)patch_data, (void*)data, RandomizedTree::PATCH_SIZE);
-      data += patch->widthStep;
-      patch_data += RandomizedTree::PATCH_SIZE;
-    }
-    patch_data = buffer;
-  } else {
-    patch_data = getData(patch);
-  }
-
-  std::vector<RandomizedTree>::const_iterator tree_it;
-
-  // get posteriors
-  if (posteriors_ == NULL)
-    {
-      posteriors_ = (uchar**)cvAlloc( trees_.size()*sizeof(posteriors_[0]) );
-      ptemp_ = (unsigned short*)cvAlloc( classes_*sizeof(ptemp_[0]) );
-    }
-  /// @todo What is going on in the next 4 lines?
-  uchar **pp = posteriors_;
-  for (tree_it = trees_.begin(); tree_it != trees_.end(); ++tree_it, pp++)
-    *pp = const_cast<uchar*>(tree_it->getPosterior2(patch_data));
-  pp = posteriors_;
-
-#if 1
-     // SSE2 optimized code
-     sum_50t_176c(pp, sig, ptemp_);    // sum them up
-#else
-     static bool warned = false;
-
-     memset((void*)sig, 0, classes_ * sizeof(sig[0]));
-     unsigned short *sig16 = new unsigned short[classes_];           // TODO: make member, no alloc here
-     memset((void*)sig16, 0, classes_ * sizeof(sig16[0]));
-     for (tree_it = trees_.begin(); tree_it != trees_.end(); ++tree_it, pp++)
-       addVec(classes_, sig16, *pp, sig16);
-
-     // squeeze signatures into an uchar
-     const bool full_shifting = true;
-     int shift;
-     if (full_shifting) {
-        float num_add_bits_f = log((float)trees_.size())/log(2.f);     // # additional bits required due to summation
-        int num_add_bits = int(num_add_bits_f);
-        if (num_add_bits_f != float(num_add_bits)) ++num_add_bits;
-        shift = num_quant_bits_ + num_add_bits - 8*sizeof(uchar);
-//shift = num_quant_bits_ + num_add_bits - 2;
-//shift = 6;
-        if (shift>0)
-          for (int i = 0; i < classes_; ++i)
-            sig[i] = (sig16[i] >> shift);      // &3 cut off all but lowest 2 bits, 3(dec) = 11(bin)
-
-        if (!warned)
-           printf("[OK] RTC: quantizing by FULL RIGHT SHIFT, shift = %i\n", shift);
-     }
-     else {
-        printf("[ERROR] RTC: not implemented!\n");
-        exit(0);
-     }
-
-     if (!warned)
-        printf("[WARNING] RTC: unoptimized signature computation\n");
-     warned = true;
-#endif
-}
-
-
-void RTreeClassifier::getSparseSignature(IplImage *patch, float *sig, float thresh) const
-{
-   getFloatSignature(patch, sig);
-   for (int i=0; i<classes_; ++i, sig++)
-      if (*sig < thresh) *sig = 0.f;
-}
-
-int RTreeClassifier::countNonZeroElements(float *vec, int n, double tol)
-{
-   int res = 0;
-   while (n-- > 0)
-      res += (fabs(*vec++) > tol);
-   return res;
-}
-
-void RTreeClassifier::read(const char* file_name)
-{
-  std::ifstream file(file_name, std::ifstream::binary);
-  if( file.is_open() )
-  {
-      read(file);
-      file.close();
-  }
-}
-
-void RTreeClassifier::read(std::istream &is)
-{
-  int num_trees = 0;
-  is.read((char*)(&num_trees), sizeof(num_trees));
-  is.read((char*)(&classes_), sizeof(classes_));
-  is.read((char*)(&original_num_classes_), sizeof(original_num_classes_));
-  is.read((char*)(&num_quant_bits_), sizeof(num_quant_bits_));
-
-  if (num_quant_bits_<1 || num_quant_bits_>8) {
-    printf("[WARNING] RTC: suspicious value num_quant_bits_=%i found; setting to %i.\n",
-           num_quant_bits_, (int)DEFAULT_NUM_QUANT_BITS);
-    num_quant_bits_ = DEFAULT_NUM_QUANT_BITS;
-  }
-
-  trees_.resize(num_trees);
-  std::vector<RandomizedTree>::iterator tree_it;
-
-  for (tree_it = trees_.begin(); tree_it != trees_.end(); ++tree_it) {
-    tree_it->read(is, num_quant_bits_);
-  }
-
-  printf("[OK] Loaded RTC, quantization=%i bits\n", num_quant_bits_);
-
-  countZeroElements();
-}
-
-void RTreeClassifier::write(const char* file_name) const
-{
-  std::ofstream file(file_name, std::ofstream::binary);
-  write(file);
-  file.close();
-}
-
-void RTreeClassifier::write(std::ostream &os) const
-{
-  int num_trees = (int)trees_.size();
-  os.write((char*)(&num_trees), sizeof(num_trees));
-  os.write((char*)(&classes_), sizeof(classes_));
-  os.write((char*)(&original_num_classes_), sizeof(original_num_classes_));
-  os.write((char*)(&num_quant_bits_), sizeof(num_quant_bits_));
-printf("RTreeClassifier::write: num_quant_bits_=%i\n", num_quant_bits_);
-
-  std::vector<RandomizedTree>::const_iterator tree_it;
-  for (tree_it = trees_.begin(); tree_it != trees_.end(); ++tree_it)
-    tree_it->write(os);
-}
-
-void RTreeClassifier::saveAllFloatPosteriors(String url)
-{
-  printf("[DEBUG] writing all float posteriors to %s...\n", url.c_str());
-  for (int i=0; i<(int)trees_.size(); ++i)
-    trees_[i].savePosteriors(url, (i==0 ? false : true));
-  printf("[DEBUG] done\n");
-}
-
-void RTreeClassifier::saveAllBytePosteriors(String url)
-{
-  printf("[DEBUG] writing all byte posteriors to %s...\n", url.c_str());
-  for (int i=0; i<(int)trees_.size(); ++i)
-    trees_[i].savePosteriors2(url, (i==0 ? false : true));
-  printf("[DEBUG] done\n");
-}
-
-
-void RTreeClassifier::setFloatPosteriorsFromTextfile_176(String url)
-{
-   std::ifstream ifs(url.c_str());
-
-   for (int i=0; i<(int)trees_.size(); ++i) {
-      int num_classes = trees_[i].classes_;
-      assert(num_classes == 176);     // TODO: remove this limitation (arose due to SSE2 optimizations)
-      for (int k=0; k<trees_[i].num_leaves_; ++k) {
-         float *post = trees_[i].getPosteriorByIndex(k);
-         for (int j=0; j<num_classes; ++j, ++post)
-            ifs >> *post;
-         assert(ifs.good());
-      }
-   }
-   classes_ = 176;
-
-   //setQuantization(num_quant_bits_);
-
-   ifs.close();
-   printf("[EXPERIMENTAL] read entire tree from '%s'\n", url.c_str());
-}
-
-
-float RTreeClassifier::countZeroElements()
-{
-   size_t flt_zeros = 0;
-   size_t ui8_zeros = 0;
-   size_t num_elem = trees_[0].classes();
-   for (int i=0; i<(int)trees_.size(); ++i)
-      for (int k=0; k<(int)trees_[i].num_leaves_; ++k) {
-         float *p = trees_[i].getPosteriorByIndex(k);
-         uchar *p2 = trees_[i].getPosteriorByIndex2(k);
-         assert(p); assert(p2);
-         for (int j=0; j<(int)num_elem; ++j, ++p, ++p2) {
-            if (*p == 0.f) flt_zeros++;
-            if (*p2 == 0) ui8_zeros++;
-         }
-      }
-   num_elem = trees_.size()*trees_[0].num_leaves_*num_elem;
-   float flt_perc = 100.f*flt_zeros/num_elem;
-   float ui8_perc = 100.f*ui8_zeros/num_elem;
-   printf("[OK] RTC: overall %i/%i (%.3f%%) zeros in float leaves\n", (int)flt_zeros, (int)num_elem, flt_perc);
-   printf("          overall %i/%i (%.3f%%) zeros in uint8 leaves\n", (int)ui8_zeros, (int)num_elem, ui8_perc);
-
-   return flt_perc;
-}
-
-void RTreeClassifier::setQuantization(int num_quant_bits)
-{
-   for (int i=0; i<(int)trees_.size(); ++i)
-      trees_[i].applyQuantization(num_quant_bits);
-
-   printf("[OK] signature quantization is now %i bits (before: %i)\n", num_quant_bits, num_quant_bits_);
-   num_quant_bits_ = num_quant_bits;
-}
-
-void RTreeClassifier::discardFloatPosteriors()
-{
-   for (int i=0; i<(int)trees_.size(); ++i)
-      trees_[i].discardFloatPosteriors();
-   printf("[OK] RTC: discarded float posteriors of all trees\n");
-}
-
-}
diff --git a/modules/legacy/src/camshift.cpp b/modules/legacy/src/camshift.cpp
deleted file mode 100644 (file)
index b3cd997..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-#include "opencv2/video/tracking_c.h"
-
-CvCamShiftTracker::CvCamShiftTracker()
-{
-    int i;
-
-    memset( &m_box, 0, sizeof(m_box));
-    memset( &m_comp, 0, sizeof(m_comp));
-    memset( m_color_planes, 0, sizeof(m_color_planes));
-    m_threshold = 0;
-
-    for( i = 0; i < CV_MAX_DIM; i++ )
-    {
-        m_min_ch_val[i] = 0;
-        m_max_ch_val[i] = 255;
-        m_hist_ranges[i] = m_hist_ranges_data[i];
-        m_hist_ranges[i][0] = 0.f;
-        m_hist_ranges[i][1] = 256.f;
-    }
-
-    m_hist = 0;
-    m_back_project = 0;
-    m_temp = 0;
-    m_mask = 0;
-}
-
-
-CvCamShiftTracker::~CvCamShiftTracker()
-{
-    int i;
-
-    cvReleaseHist( &m_hist );
-    for( i = 0; i < CV_MAX_DIM; i++ )
-        cvReleaseImage( &m_color_planes[i] );
-    cvReleaseImage( &m_back_project );
-    cvReleaseImage( &m_temp );
-    cvReleaseImage( &m_mask );
-}
-
-
-void
-CvCamShiftTracker::color_transform( const IplImage* image )
-{
-    CvSize size = cvGetSize(image);
-    uchar* color_data = 0, *mask = 0;
-    uchar* planes[CV_MAX_DIM];
-    int x, color_step = 0, plane_step = 0, mask_step;
-    int dims[CV_MAX_DIM];
-    int i, n = get_hist_dims(dims);
-
-    assert( image->nChannels == 3 && m_hist != 0 );
-
-    if( !m_temp || !m_mask || !m_color_planes[0] || !m_color_planes[n-1] || !m_back_project ||
-        m_temp->width != size.width || m_temp->height != size.height ||
-        m_temp->nChannels != 3 )
-    {
-        cvReleaseImage( &m_temp );
-        m_temp = cvCreateImage( size, IPL_DEPTH_8U, 3 );
-        cvReleaseImage( &m_mask );
-        m_mask = cvCreateImage( size, IPL_DEPTH_8U, 1 );
-        cvReleaseImage( &m_back_project );
-        m_back_project = cvCreateImage( size, IPL_DEPTH_8U, 1 );
-        for( i = 0; i < CV_MAX_DIM; i++ )
-        {
-            cvReleaseImage( &m_color_planes[i] );
-            if( i < n )
-                m_color_planes[i] = cvCreateImage( size, IPL_DEPTH_8U, 1 );
-        }
-    }
-
-    cvCvtColor( image, m_temp, CV_BGR2HSV );
-    cvGetRawData( m_temp, &color_data, &color_step, &size );
-    cvGetRawData( m_mask, &mask, &mask_step, &size );
-
-    for( i = 0; i < n; i++ )
-        cvGetRawData( m_color_planes[i], &planes[i], &plane_step, &size );
-
-    for( ; size.height--; color_data += color_step, mask += mask_step )
-    {
-        for( x = 0; x < size.width; x++ )
-        {
-            int val0 = color_data[x*3];
-            int val1 = color_data[x*3+1];
-            int val2 = color_data[x*3+2];
-            if( m_min_ch_val[0] <= val0 && val0 <= m_max_ch_val[0] &&
-                m_min_ch_val[1] <= val1 && val1 <= m_max_ch_val[1] &&
-                m_min_ch_val[2] <= val2 && val2 <= m_max_ch_val[2] )
-            {
-                // hue is written to the 0-th plane, saturation - to the 1-st one,
-                // so 1d histogram will automagically correspond to hue-based tracking,
-                // 2d histogram - to saturation-based tracking.
-                planes[0][x] = (uchar)val0;
-                if( n > 1 )
-                    planes[1][x] = (uchar)val1;
-                if( n > 2 )
-                    planes[2][x] = (uchar)val2;
-
-                mask[x] = (uchar)255;
-            }
-            else
-            {
-                planes[0][x] = 0;
-                if( n > 1 )
-                    planes[1][x] = 0;
-                if( n > 2 )
-                    planes[2][x] = 0;
-                mask[x] = 0;
-            }
-        }
-        for( i = 0; i < n; i++ )
-            planes[i] += plane_step;
-    }
-}
-
-
-bool
-CvCamShiftTracker::update_histogram( const IplImage* cur_frame )
-{
-    float max_val = 0;
-    int i, dims;
-
-    if( m_comp.rect.width == 0 || m_comp.rect.height == 0 ||
-        m_hist == 0 )
-    {
-        assert(0);
-        return false;
-    }
-
-    color_transform(cur_frame);
-
-    dims = cvGetDims( m_hist->bins );
-    for( i = 0; i < dims; i++ )
-        cvSetImageROI( m_color_planes[i], m_comp.rect );
-    cvSetImageROI( m_mask, m_comp.rect );
-
-    cvSetHistBinRanges( m_hist, m_hist_ranges, 1 );
-    cvCalcHist( m_color_planes, m_hist, 0, m_mask );
-
-    for( i = 0; i < dims; i++ )
-        cvSetImageROI( m_color_planes[i], m_comp.rect );
-
-    for( i = 0; i < dims; i++ )
-        cvResetImageROI( m_color_planes[i] );
-    cvResetImageROI( m_mask );
-
-    cvGetMinMaxHistValue( m_hist, 0, &max_val );
-    cvScale( m_hist->bins, m_hist->bins, max_val ? 255. / max_val : 0. );
-
-    return max_val != 0;
-}
-
-
-void
-CvCamShiftTracker::reset_histogram()
-{
-    if( m_hist )
-        cvClearHist( m_hist );
-}
-
-
-bool
-CvCamShiftTracker::track_object( const IplImage* cur_frame )
-{
-    CvRect rect;
-    CvSize bp_size;
-
-    union
-    {
-        void** arr;
-        IplImage** img;
-    } u;
-
-    if( m_comp.rect.width == 0 || m_comp.rect.height == 0 ||
-        m_hist == 0 )
-    {
-        return false;
-    }
-
-    color_transform( cur_frame );
-    u.img = m_color_planes;
-    cvCalcArrBackProject( u.arr, m_back_project, m_hist );
-    cvAnd( m_back_project, m_mask, m_back_project );
-
-    rect = m_comp.rect;
-    bp_size = cvGetSize( m_back_project );
-    if( rect.x < 0 )
-        rect.x = 0;
-    if( rect.x + rect.width > bp_size.width )
-        rect.width = bp_size.width - rect.x;
-    if( rect.y < 0 )
-        rect.y = 0;
-    if( rect.y + rect.height > bp_size.height )
-        rect.height = bp_size.height - rect.y;
-
-    cvCamShift( m_back_project, rect,
-                cvTermCriteria( CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 10, 1 ),
-                &m_comp, &m_box );
-
-    if( m_comp.rect.width == 0 || m_comp.rect.height == 0 )
-        m_comp.rect = rect; // do not allow tracker to loose the object
-
-    return m_comp.rect.width != 0 && m_comp.rect.height != 0;
-}
-
-
-bool
-CvCamShiftTracker::set_hist_dims( int c_dims, int *dims )
-{
-    if( (unsigned)(c_dims-1) >= (unsigned)CV_MAX_DIM || dims == 0 )
-        return false;
-
-    if( m_hist )
-    {
-        int dims2[CV_MAX_DIM];
-        int c_dims2 = cvGetDims( m_hist->bins, dims2 );
-
-        if( c_dims2 == c_dims && memcmp( dims, dims2, c_dims*sizeof(dims[0])) == 0 )
-            return true;
-
-        cvReleaseHist( &m_hist );
-    }
-
-    m_hist = cvCreateHist( c_dims, dims, CV_HIST_ARRAY, 0, 0 );
-
-    return true;
-}
-
-
-bool
-CvCamShiftTracker::set_hist_bin_range( int channel, int min_val, int max_val )
-{
-    if( (unsigned)channel >= (unsigned)CV_MAX_DIM ||
-        min_val >= max_val || min_val < 0 || max_val > 256 )
-    {
-        assert(0);
-        return false;
-    }
-
-    m_hist_ranges[channel][0] = (float)min_val;
-    m_hist_ranges[channel][1] = (float)max_val;
-
-    return true;
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/clique.cpp b/modules/legacy/src/clique.cpp
deleted file mode 100644 (file)
index 90111b1..0000000
+++ /dev/null
@@ -1,708 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#if 0
-
-#include <float.h>
-#include <limits.h>
-#include <stdio.h>
-
-
-#include "_cvutils.h"
-#include "_cvwrap.h"
-
-/*typedef struct CvCliqueFinder
-{
-    CvGraph* graph;
-    int**    adj_matr;
-    int N; //graph size
-
-    // stacks, counters etc/
-    int k; //stack size
-    int* current_comp;
-    int** All;
-
-    int* ne;
-    int* ce;
-    int* fixp; //node with minimal disconnections
-    int* nod;
-    int* s; //for selected candidate
-    int status;
-    int best_score;
-
-} CvCliqueFinder;
-*/
-
-#define GO 1
-#define BACK 2
-#define PEREBOR 3
-#define NEXT PEREBOR
-#define END 4
-
-
-#define  CV_GET_ADJ_VTX( vertex, edge ) \
-(                                       \
-    assert(edge->vtx[0]==vertex||edge->vtx[1] == vertex ), \
-    (edge->vtx[0] == vertex)?edge->vtx[1]:edge->vtx[0]     \
-)
-
-
-#define NUMBER( v ) ((v)->flags >> 1 )
-
-void _MarkNodes( CvGraph* graph )
-{
-    //set number of vertices to their flags
-    for( int i = 0; i < graph->total; i++ )
-    {
-        CvGraphVtx* ver = cvGetGraphVtx( graph, i );
-        if( ver )
-        {
-            ver->flags = i<<1;
-        }
-    }
-}
-
-void _FillAdjMatrix( CvGraph* graph, int** connected, int reverse )
-{
-    //assume all vertices are marked
-    for( int i = 0; i < graph->total; i++ )
-    {
-        for( int j = 0; j < graph->total; j++ )
-        {
-            connected[i][j] = 0|reverse;
-        }
-        //memset( connected[i], 0, sizeof(int)*graph->total );
-        CvGraphVtx* ver = cvGetGraphVtx( graph, i );
-        if( ver )
-        {
-            connected[i][i] = 1;
-            for( CvGraphEdge* e = ver->first; e ; e = CV_NEXT_GRAPH_EDGE( e, ver ) )
-            {
-               CvGraphVtx* v = CV_GET_ADJ_VTX( ver, e );
-               connected[i][NUMBER(v)] = 1^reverse;
-            }
-        }
-    }
-}
-
-
-void cvStartFindCliques( CvGraph* graph, CvCliqueFinder* finder, int reverse, int weighted, int weighted_edges )
-{
-    int i;
-
-    if (weighted)
-    {
-        finder->weighted = 1;
-        finder->best_weight = 0;
-        finder->vertex_weights = (float*)malloc( sizeof(float)*(graph->total+1));
-        finder->cur_weight = (float*)malloc( sizeof(float)*(graph->total+1));
-        finder->cand_weight = (float*)malloc( sizeof(float)*(graph->total+1));
-
-        finder->cur_weight[0] = 0;
-        finder->cand_weight[0] = 0;
-        for( i = 0 ; i < graph->total; i++ )
-        {
-            CvGraphWeightedVtx* ver = (CvGraphWeightedVtx*)cvGetGraphVtx( graph, i );
-            assert(ver);
-            assert(ver->weight>=0);
-            finder->vertex_weights[i] = ver->weight;
-            finder->cand_weight[0] += ver->weight;
-        }
-    }
-    else finder->weighted = 0;
-
-    if (weighted_edges)
-    {
-        finder->weighted_edges = 1;
-        //finder->best_weight = 0;
-        finder->edge_weights = (float*)malloc( sizeof(float)*(graph->total)*(graph->total));
-        //finder->cur_weight = (float*)malloc( sizeof(float)*(graph->total+1));
-        //finder->cand_weight = (float*)malloc( sizeof(float)*(graph->total+1));
-
-        //finder->cur_weight[0] = 0;
-        //finder->cand_weight[0] = 0;
-        memset( finder->edge_weights, 0, sizeof(float)*(graph->total)*(graph->total) );
-        for( i = 0 ; i < graph->total; i++ )
-        {
-            CvGraphVtx* ver1 = cvGetGraphVtx( graph, i );
-            if(!ver1) continue;
-            for( int j = i ; j < graph->total; j++ )
-            {
-                CvGraphVtx* ver2 = cvGetGraphVtx( graph, j );
-                if(!ver2) continue;
-                CvGraphEdge* edge = cvFindGraphEdgeByPtr( graph, ver1, ver2 );
-                if( edge )
-                {
-                    assert( ((CvGraphWeightedEdge*)edge)->weight >= 0 );
-                    finder->edge_weights[ i * graph->total + j ] =
-                    finder->edge_weights[ j * graph->total + i ] = ((CvGraphWeightedEdge*)edge)->weight;
-                }
-            }
-        }
-    }
-    else finder->weighted_edges = 0;
-
-
-    //int* Compsub; //current component (vertex stack)
-    finder->k = 0; //counter of steps
-    int N = finder->N = graph->total;
-    finder->current_comp = new int[N];
-    finder->All = new int*[N];
-    for( i = 0 ; i < finder->N; i++ )
-    {
-        finder->All[i] = new int[N];
-    }
-
-    finder->ne = new int[N+1];
-    finder->ce = new int[N+1];
-    finder->fixp = new int[N+1]; //node with minimal disconnections
-    finder->nod = new int[N+1];
-    finder->s = new int[N+1]; //for selected candidate
-
-    //form adj matrix
-    finder->adj_matr = new int*[N]; //assume filled with 0
-    for( i = 0 ; i < N; i++ )
-    {
-        finder->adj_matr[i] = new int[N];
-    }
-
-    //set number to vertices
-    _MarkNodes( graph );
-    _FillAdjMatrix( graph, finder->adj_matr, reverse );
-
-    //init all arrays
-    int k = finder->k = 0; //stack size
-    memset( finder->All[k], 0, sizeof(int) * N );
-    for( i = 0; i < N; i++ )  finder->All[k][i] = i;
-    finder->ne[0] = 0;
-    finder->ce[0] = N;
-
-    finder->status = GO;
-    finder->best_score = 0;
-
-}
-
-void cvEndFindCliques( CvCliqueFinder* finder )
-{
-    int i;
-
-    //int* Compsub; //current component (vertex stack)
-    delete finder->current_comp;
-    for( i = 0 ; i < finder->N; i++ )
-    {
-        delete finder->All[i];
-    }
-    delete finder->All;
-
-    delete finder->ne;
-    delete finder->ce;
-    delete finder->fixp; //node with minimal disconnections
-    delete finder->nod;
-    delete finder->s; //for selected candidate
-
-    //delete adj matrix
-    for( i = 0 ; i < finder->N; i++ )
-    {
-        delete finder->adj_matr[i];
-    }
-    delete finder->adj_matr;
-
-    if(finder->weighted)
-    {
-        free(finder->vertex_weights);
-        free(finder->cur_weight);
-        free(finder->cand_weight);
-    }
-    if(finder->weighted_edges)
-    {
-        free(finder->edge_weights);
-    }
-}
-
-int cvFindNextMaximalClique( CvCliqueFinder* finder )
-{
-    int**  connected = finder->adj_matr;
-//    int N = finder->N; //graph size
-
-    // stacks, counters etc/
-    int k = finder->k; //stack size
-    int* Compsub = finder->current_comp;
-    int** All = finder->All;
-
-    int* ne = finder->ne;
-    int* ce = finder->ce;
-    int* fixp = finder->fixp; //node with minimal disconnections
-    int* nod = finder->nod;
-    int* s = finder->s; //for selected candidate
-
-    //START
-    while( k >= 0)
-    {
-        int* old = All[k];
-        switch(finder->status)
-        {
-        case GO://Forward step
-        /* we have all sets and will choose fixed point */
-            {
-                //check potential size of clique
-                if( (!finder->weighted) && (k + ce[k] - ne[k] < finder->best_score) )
-                {
-                    finder->status  = BACK;
-                    break;
-                }
-                //check potential weight
-                if( finder->weighted && !finder->weighted_edges &&
-                    finder->cur_weight[k] + finder->cand_weight[k] < finder->best_weight )
-                {
-                    finder->status  = BACK;
-                    break;
-                }
-
-                int minnod = ce[k];
-                nod[k] = 0;
-
-                //for every vertex of All determine counter value and choose minimum
-                for( int i = 0; i < ce[k] && minnod != 0; i++)
-                {
-                    int p = old[i]; //current point
-                    int count = 0;  //counter
-                    int pos = 0;
-
-                    /* Count disconnections with candidates */
-                    for (int j = ne[k]; j < ce[k] && (count < minnod); j++)
-                    {
-                        if ( !connected[p][old[j]] )
-                        {
-                            count++;
-                            /* Save position of potential candidate */
-                            pos = j;
-                        }
-                    }
-
-                    /* Test new minimum */
-                    if (count < minnod)
-                    {
-                        fixp[k] = p;     //set current point as fixed
-                        minnod = count;  //new value for minnod
-                        if (i < ne[k])      //if current fixed point belongs to 'not'
-                        {
-                            s[k] = pos;     //s - selected candidate
-                        }
-                        else
-                        {
-                            s[k] = i;        //selected candidate is fixed point itself
-                            /* preincr */
-                            nod[k] = 1;      //nod is aux variable, 1 means fixp == s
-                        }
-                    }
-                }//for
-
-                nod[k] = minnod + nod[k];
-                finder->status = NEXT;//go to backtrackcycle
-            }
-            break;
-        case NEXT:
-            //here we will look for candidate to translate into not
-            //s[k] now contains index of chosen candidate
-            {
-                int* new_ = All[k+1];
-                if( nod[k] != 0 )
-                {
-                    //swap selected and first candidate
-                    int i, p = old[s[k]];
-                    old[s[k]] = old[ne[k]];
-                    int sel = old[ne[k]] = p;
-
-                    int newne = 0;
-                    //fill new set 'not'
-                    for ( i = 0; i < ne[k]; i++)
-                    {
-                        if (connected[sel][old[i]])
-                        {
-                            new_[newne] = old[i];
-                            newne++;
-
-                        }
-                    }
-                    //fill new set 'candidate'
-                    int newce = newne;
-                    i++;//skip selected candidate
-
-                    float candweight = 0;
-
-                    for (; i < ce[k]; i++)
-                    {
-                        if (connected[sel][old[i]])
-                        {
-                            new_[newce] = old[i];
-
-                            if( finder->weighted )
-                                candweight += finder->vertex_weights[old[i]];
-
-                            newce++;
-                        }
-                    }
-
-                    nod[k]--;
-
-                    //add selected to stack
-                    Compsub[k] = sel;
-
-                    k++;
-                    assert( k <= finder->N );
-                    if( finder->weighted )
-                    {
-                        //update weights of current clique and candidates
-                        finder->cur_weight[k] = finder->cur_weight[k-1] + finder->vertex_weights[sel];
-                        finder->cand_weight[k] = candweight;
-                    }
-                    if( finder->weighted_edges )
-                    {
-                        //update total weight by edge weights
-                        float added = 0;
-                        for( int ind = 0; ind < k-1; ind++ )
-                        {
-                            added += finder->edge_weights[ Compsub[ind] * finder->N + sel ];
-                        }
-                        finder->cur_weight[k] += added;
-                    }
-
-                    //check if 'not' and 'cand' are both empty
-                    if( newce == 0 )
-                    {
-                        finder->best_score = MAX(finder->best_score, k );
-
-                        if( finder->weighted )
-                            finder->best_weight = MAX( finder->best_weight, finder->cur_weight[k] );
-                        /*FILE* file  = fopen("cliques.txt", "a" );
-
-                        for (int t=0; t<k; t++)
-                        {
-                          fprintf(file, "%d ", Compsub[t]);
-                        }
-                        fprintf(file, "\n");
-
-                        fclose(file);
-                        */
-
-                        //output new clique//************************
-                        finder->status = BACK;
-                        finder->k = k;
-
-                        return CLIQUE_FOUND;
-
-                    }
-                    else //check nonempty set of candidates
-                    if( newne < newce )
-                    {
-                        //go further
-                        ne[k] = newne;
-                        ce[k] = newce;
-                        finder->status  = GO;
-                        break;
-                    }
-
-                }
-                else
-                    finder->status  = BACK;
-
-            }
-            break;
-
-        case BACK:
-            {
-                //decrease stack
-                k--;
-                old = All[k];
-                if( k < 0 ) break;
-
-                //add to not
-                ne[k]++;
-
-                if( nod[k] > 0 )
-                {
-                    //select next candidate
-                    for( s[k] = ne[k]; s[k] < ce[k]; s[k]++ )
-                    {
-                        if( !connected[fixp[k]][old[s[k]]])
-                            break;
-                    }
-                    assert( s[k] < ce[k] );
-                    finder->status = NEXT;
-                }
-                else
-                    finder->status = BACK;
-
-            }
-            break;
-        case END: assert(0);
-
-        }
-    }//end while
-
-    finder->status = END;
-    return CLIQUE_END;
-}
-
-
-
-
-void cvBronKerbosch( CvGraph* graph )
-{
-    int* Compsub; //current component (vertex stack)
-    int k = 0; //counter of steps
-    int N = graph->total;
-    int i;
-    Compsub = new int[N];
-    int** All = new int*[N];
-    for( i = 0 ; i < N; i++ )
-    {
-        All[i] = new int[N];
-    }
-
-    int* ne = new int[N];
-    int* ce = new int[N];
-    int* fixp = new int[N]; //node with minimal disconnections
-    int* nod = new int[N];
-    int* s = new int[N]; //for selected candidate
-
-    //form adj matrix
-    int** connected = new int*[N]; //assume filled with 0
-    for( i = 0 ; i < N; i++ )
-    {
-        connected[i] = new int[N];
-    }
-
-
-
-    //set number to vertices
-    _MarkNodes( graph );
-    _FillAdjMatrix( graph, connected, 0 );
-
-    //init all arrays
-    k = 0; //stack size
-    memset( All[k], 0, sizeof(int) * N );
-    for( i = 0; i < N; i++ )  All[k][i] = i;
-    ne[0] = 0;
-    ce[0] = N;
-
-    int status = GO;
-    int best_score = 0;
-
-    //START
-    while( k >= 0)
-    {
-        int* old = All[k];
-        switch(status)
-        {
-        case GO://Forward step
-        /* we have all sets and will choose fixed point */
-            {
-
-                if( k + ce[k] - ne[k] < best_score )
-                {
-                    status  = BACK;
-                    break;
-                }
-
-                int minnod = ce[k];
-                nod[k] = 0;
-
-                //for every vertex of All determine counter value and choose minimum
-                for( int i = 0; i < ce[k] && minnod != 0; i++)
-                {
-                    int p = old[i]; //current point
-                    int count = 0;  //counter
-                    int pos = 0;
-
-                    /* Count disconnections with candidates */
-                    for (int j = ne[k]; j < ce[k] && (count < minnod); j++)
-                    {
-                        if ( !connected[p][old[j]] )
-                        {
-                            count++;
-                            /* Save position of potential candidate */
-                            pos = j;
-                        }
-                    }
-
-                    /* Test new minimum */
-                    if (count < minnod)
-                    {
-                        fixp[k] = p;     //set current point as fixed
-                        minnod = count;  //new value for minnod
-                        if (i < ne[k])      //if current fixed point belongs to 'not'
-                        {
-                            s[k] = pos;     //s - selected candidate
-                        }
-                        else
-                        {
-                            s[k] = i;        //selected candidate is fixed point itself
-                            /* preincr */
-                            nod[k] = 1;      //nod is aux variable, 1 means fixp == s
-                        }
-                    }
-                }//for
-
-                nod[k] = minnod + nod[k];
-                status = NEXT;//go to backtrackcycle
-            }
-            break;
-        case NEXT:
-            //here we will look for candidate to translate into not
-            //s[k] now contains index of chosen candidate
-            {
-                int* new_ = All[k+1];
-                if( nod[k] != 0 )
-                {
-                    //swap selected and first candidate
-                    int p = old[s[k]];
-                    old[s[k]] = old[ne[k]];
-                    int sel = old[ne[k]] = p;
-
-                    int newne = 0;
-                    //fill new set 'not'
-                    for ( i = 0; i < ne[k]; i++)
-                    {
-                        if (connected[sel][old[i]])
-                        {
-                            new_[newne] = old[i];
-                            newne++;
-
-                        }
-                    }
-                    //fill new set 'candidate'
-                    int newce = newne;
-                    i++;//skip selected candidate
-                    for (; i < ce[k]; i++)
-                    {
-                        if (connected[sel][old[i]])
-                        {
-                            new_[newce] = old[i];
-                            newce++;
-                        }
-                    }
-
-                    nod[k]--;
-
-                    //add selected to stack
-                    Compsub[k] = sel;
-                    k++;
-
-                    //check if 'not' and 'cand' are both empty
-                    if( newce == 0 )
-                    {
-                        best_score = MAX(best_score, k );
-
-                        FILE* file  = fopen("cliques.txt", "a" );
-
-                        for (int t=0; t<k; t++)
-                        {
-                          fprintf(file, "%d ", Compsub[t]);
-                        }
-                        fprintf(file, "\n");
-
-                        fclose(file);
-
-                        /*for( int t = 0; t < k; t++ )
-                        {
-                            printf("%d ", Compsub[t] );
-                        }
-                        printf("\n"); */
-
-                        //printf("found %d\n", k);
-
-                        //output new clique//************************
-                        status = BACK;
-                    }
-                    else //check nonempty set of candidates
-                    if( newne < newce )
-                    {
-                        //go further
-                        ne[k] = newne;
-                        ce[k] = newce;
-                        status  = GO;
-                        break;
-                    }
-
-                }
-                else
-                    status  = BACK;
-
-            }
-            break;
-
-        case BACK:
-            {
-                //decrease stack
-                k--;
-                old = All[k];
-                if( k < 0 ) break;
-
-                //add to not
-                ne[k]++;
-
-                if( nod[k] > 0 )
-                {
-                    //select next candidate
-                    for( s[k] = ne[k]; s[k] < ce[k]; s[k]++ )
-                    {
-                        if( !connected[fixp[k]][old[s[k]]])
-                            break;
-                    }
-                    assert( s[k] < ce[k] );
-                    status = NEXT;
-                }
-                else
-                    status = BACK;
-
-            }
-            break;
-
-
-        }
-    }//end while
-
-}//end cvBronKerbosch
-
-#endif
diff --git a/modules/legacy/src/compat.cpp b/modules/legacy/src/compat.cpp
deleted file mode 100644 (file)
index 52e05b9..0000000
+++ /dev/null
@@ -1,685 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2010, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "opencv2/calib3d/calib3d_c.h"
-
-CvMat cvMatArray( int rows, int cols, int type,
-                  int count, void* data)
-{
-    return cvMat( rows*count, cols, type, data );
-}
-
-
-double cvMean( const CvArr* image, const CvArr* mask )
-{
-    CvScalar mean = cvAvg( image, mask );
-    return mean.val[0];
-}
-
-
-double  cvSumPixels( const CvArr* image )
-{
-    CvScalar scalar = cvSum( image );
-    return scalar.val[0];
-}
-
-void  cvMean_StdDev( const CvArr* image, double* mean, double* sdv, const CvArr* mask)
-{
-    CvScalar _mean, _sdv;
-    cvAvgSdv( image, &_mean, &_sdv, mask );
-
-    if( mean )
-        *mean = _mean.val[0];
-
-    if( sdv )
-        *sdv = _sdv.val[0];
-}
-
-
-void cvmPerspectiveProject( const CvMat* mat, const CvArr* src, CvArr* dst )
-{
-    CvMat tsrc, tdst;
-
-    cvReshape( src, &tsrc, 3, 0 );
-    cvReshape( dst, &tdst, 3, 0 );
-
-    cvPerspectiveTransform( &tsrc, &tdst, mat );
-}
-
-
-void cvFillImage( CvArr* mat, double color )
-{
-    cvSet( mat, cvColorToScalar(color, cvGetElemType(mat)), 0 );
-}
-
-
-/* Changes RNG range while preserving RNG state */
-void  cvRandSetRange( CvRandState* state, double param1, double param2, int index)
-{
-    if( !state )
-    {
-        cvError( CV_StsNullPtr, "cvRandSetRange", "Null pointer to RNG state", "cvcompat.h", 0 );
-        return;
-    }
-
-    if( (unsigned)(index + 1) > 4 )
-    {
-        cvError( CV_StsOutOfRange, "cvRandSetRange", "index is not in -1..3", "cvcompat.h", 0 );
-        return;
-    }
-
-    if( index < 0 )
-    {
-        state->param[0].val[0] = state->param[0].val[1] =
-        state->param[0].val[2] = state->param[0].val[3] = param1;
-        state->param[1].val[0] = state->param[1].val[1] =
-        state->param[1].val[2] = state->param[1].val[3] = param2;
-    }
-    else
-    {
-        state->param[0].val[index] = param1;
-        state->param[1].val[index] = param2;
-    }
-}
-
-
-void  cvRandInit( CvRandState* state, double param1, double param2,
-                  int seed, int disttype)
-{
-    if( !state )
-    {
-        cvError( CV_StsNullPtr, "cvRandInit", "Null pointer to RNG state", "cvcompat.h", 0 );
-        return;
-    }
-
-    if( disttype != CV_RAND_UNI && disttype != CV_RAND_NORMAL )
-    {
-        cvError( CV_StsBadFlag, "cvRandInit", "Unknown distribution type", "cvcompat.h", 0 );
-        return;
-    }
-
-    state->state = (uint64)(seed ? seed : -1);
-    state->disttype = disttype;
-    cvRandSetRange( state, param1, param2, -1 );
-}
-
-
-/* Fills array with random numbers */
-void cvRand( CvRandState* state, CvArr* arr )
-{
-    if( !state )
-    {
-        cvError( CV_StsNullPtr, "cvRand", "Null pointer to RNG state", "cvcompat.h", 0 );
-        return;
-    }
-    cvRandArr( &state->state, arr, state->disttype, state->param[0], state->param[1] );
-}
-
-void cvbRand( CvRandState* state, float* dst, int len )
-{
-    CvMat mat = cvMat( 1, len, CV_32F, (void*)dst );
-    cvRand( state, &mat );
-}
-
-
-void  cvbCartToPolar( const float* y, const float* x, float* magnitude, float* angle, int len )
-{
-    CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
-    CvMat my = mx;
-    CvMat mm = mx;
-    CvMat ma = mx;
-
-    my.data.fl = (float*)y;
-    mm.data.fl = (float*)magnitude;
-    ma.data.fl = (float*)angle;
-
-    cvCartToPolar( &mx, &my, &mm, angle ? &ma : NULL, 1 );
-}
-
-
-void  cvbFastArctan( const float* y, const float* x, float* angle, int len )
-{
-    CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
-    CvMat my = mx;
-    CvMat ma = mx;
-
-    my.data.fl = (float*)y;
-    ma.data.fl = (float*)angle;
-
-    cvCartToPolar( &mx, &my, NULL, &ma, 1 );
-}
-
-
- void  cvbSqrt( const float* x, float* y, int len )
-{
-    CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
-    CvMat my = mx;
-    my.data.fl = (float*)y;
-
-    cvPow( &mx, &my, 0.5 );
-}
-
-
- void  cvbInvSqrt( const float* x, float* y, int len )
-{
-    CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
-    CvMat my = mx;
-    my.data.fl = (float*)y;
-
-    cvPow( &mx, &my, -0.5 );
-}
-
-
- void  cvbReciprocal( const float* x, float* y, int len )
-{
-    CvMat mx = cvMat( 1, len, CV_32F, (void*)x );
-    CvMat my = mx;
-    my.data.fl = (float*)y;
-
-    cvPow( &mx, &my, -1 );
-}
-
-
- void  cvbFastExp( const float* x, double* y, int len )
-{
-    int i;
-    for( i = 0; i < len; i++ )
-        y[i] = exp((double)x[i]);
-}
-
-
- void  cvbFastLog( const double* x, float* y, int len )
-{
-    int i;
-    for( i = 0; i < len; i++ )
-        y[i] = (float)log(x[i]);
-}
-
-
-CvRect  cvContourBoundingRect( void* point_set, int update)
-{
-    return cvBoundingRect( point_set, update );
-}
-
-
-double cvPseudoInverse( const CvArr* src, CvArr* dst )
-{
-    return cvInvert( src, dst, CV_SVD );
-}
-
-
-/* Calculates exact convex hull of 2d point set */
-void cvConvexHull( CvPoint* points, int num_points, CvRect*,
-                   int orientation, int* hull, int* hullsize )
-{
-    CvMat points1 = cvMat( 1, num_points, CV_32SC2, points );
-    CvMat hull1 = cvMat( 1, num_points, CV_32SC1, hull );
-
-    cvConvexHull2( &points1, &hull1, orientation, 0 );
-    *hullsize = hull1.cols;
-}
-
-void cvMinAreaRect( CvPoint* points, int n, int, int, int, int,
-                    CvPoint2D32f* anchor, CvPoint2D32f* vect1, CvPoint2D32f* vect2 )
-{
-    CvMat mat = cvMat( 1, n, CV_32SC2, points );
-    CvBox2D box = cvMinAreaRect2( &mat, 0 );
-    CvPoint2D32f pt[4];
-
-    cvBoxPoints( box, pt );
-    *anchor = pt[0];
-    vect1->x = pt[1].x - pt[0].x;
-    vect1->y = pt[1].y - pt[0].y;
-    vect2->x = pt[3].x - pt[0].x;
-    vect2->y = pt[3].y - pt[0].y;
-}
-
-void  cvFitLine3D( CvPoint3D32f* points, int count, int dist,
-                   void *param, float reps, float aeps, float* line )
-{
-    CvMat mat = cvMat( 1, count, CV_32FC3, points );
-    float _param = param != NULL ? *(float*)param : 0.f;
-    assert( dist != CV_DIST_USER );
-    cvFitLine( &mat, dist, _param, reps, aeps, line );
-}
-
-/* Fits a line into set of 2d points in a robust way (M-estimator technique) */
-void  cvFitLine2D( CvPoint2D32f* points, int count, int dist,
-                   void *param, float reps, float aeps, float* line )
-{
-    CvMat mat = cvMat( 1, count, CV_32FC2, points );
-    float _param = param != NULL ? *(float*)param : 0.f;
-    assert( dist != CV_DIST_USER );
-    cvFitLine( &mat, dist, _param, reps, aeps, line );
-}
-
-
-void cvFitEllipse( const CvPoint2D32f* points, int count, CvBox2D* box )
-{
-    CvMat mat = cvMat( 1, count, CV_32FC2, (void*)points );
-    *box = cvFitEllipse2( &mat );
-}
-
-/* Projects 2d points to one of standard coordinate planes
-   (i.e. removes one of coordinates) */
-void  cvProject3D( CvPoint3D32f* points3D, int count,
-                   CvPoint2D32f* points2D, int xIndx, int yIndx)
-{
-    CvMat src = cvMat( 1, count, CV_32FC3, points3D );
-    CvMat dst = cvMat( 1, count, CV_32FC2, points2D );
-    float m[6] = {0,0,0,0,0,0};
-    CvMat M = cvMat( 2, 3, CV_32F, m );
-
-    assert( (unsigned)xIndx < 3 && (unsigned)yIndx < 3 );
-    m[xIndx] = m[yIndx+3] = 1.f;
-
-    cvTransform( &src, &dst, &M, NULL );
-}
-
-
-int  cvHoughLines( CvArr* image, double rho,
-                   double theta, int threshold,
-                   float* lines, int linesNumber )
-{
-    CvMat linesMat = cvMat( 1, linesNumber, CV_32FC2, lines );
-    cvHoughLines2( image, &linesMat, CV_HOUGH_STANDARD,
-                   rho, theta, threshold, 0, 0 );
-
-    return linesMat.cols;
-}
-
-
-int  cvHoughLinesP( CvArr* image, double rho,
-                    double theta, int threshold,
-                    int lineLength, int lineGap,
-                    int* lines, int linesNumber )
-{
-    CvMat linesMat = cvMat( 1, linesNumber, CV_32SC4, lines );
-    cvHoughLines2( image, &linesMat, CV_HOUGH_PROBABILISTIC,
-                   rho, theta, threshold, lineLength, lineGap );
-
-    return linesMat.cols;
-}
-
-
-int  cvHoughLinesSDiv( CvArr* image, double rho, int srn,
-                       double theta, int stn, int threshold,
-                       float* lines, int linesNumber )
-{
-    CvMat linesMat = cvMat( 1, linesNumber, CV_32FC2, lines );
-    cvHoughLines2( image, &linesMat, CV_HOUGH_MULTI_SCALE,
-                   rho, theta, threshold, srn, stn );
-
-    return linesMat.cols;
-}
-
-
-float  cvCalcEMD( const float* signature1, int size1, const float* signature2, int size2,
-                  int dims, int dist_type, CvDistanceFunction dist_func,
-                  float* lower_bound, void* user_param)
-{
-    CvMat sign1 = cvMat( size1, dims + 1, CV_32FC1, (void*)signature1 );
-    CvMat sign2 = cvMat( size2, dims + 1, CV_32FC1, (void*)signature2 );
-
-    return cvCalcEMD2( &sign1, &sign2, dist_type, dist_func, 0, 0, lower_bound, user_param );
-}
-
-
-void  cvKMeans( int num_clusters, float** samples,
-                int num_samples, int vec_size,
-                CvTermCriteria termcrit, int* cluster_idx )
-{
-    CvMat* samples_mat = cvCreateMat( num_samples, vec_size, CV_32FC1 );
-    CvMat cluster_idx_mat = cvMat( num_samples, 1, CV_32SC1, cluster_idx );
-    int i;
-    for( i = 0; i < num_samples; i++ )
-        memcpy( samples_mat->data.fl + i*vec_size, samples[i], vec_size*sizeof(float));
-    cvKMeans2( samples_mat, num_clusters, &cluster_idx_mat, termcrit, 1, 0, 0, 0, 0 );
-    cvReleaseMat( &samples_mat );
-}
-
-
-void  cvStartScanGraph( CvGraph* graph, CvGraphScanner* scanner,
-                        CvGraphVtx* vtx, int mask)
-{
-    CvGraphScanner* temp_scanner;
-
-    if( !scanner )
-        cvError( CV_StsNullPtr, "cvStartScanGraph", "Null scanner pointer", "cvcompat.h", 0 );
-
-    temp_scanner = cvCreateGraphScanner( graph, vtx, mask );
-    *scanner = *temp_scanner;
-    cvFree( &temp_scanner );
-}
-
-
-void  cvEndScanGraph( CvGraphScanner* scanner )
-{
-    if( !scanner )
-        cvError( CV_StsNullPtr, "cvEndScanGraph", "Null scanner pointer", "cvcompat.h", 0 );
-
-    if( scanner->stack )
-    {
-        CvGraphScanner* temp_scanner = (CvGraphScanner*)cvAlloc( sizeof(*temp_scanner) );
-        *temp_scanner = *scanner;
-        cvReleaseGraphScanner( &temp_scanner );
-        memset( scanner, 0, sizeof(*scanner) );
-    }
-}
-
-
-/* old drawing functions */
-void  cvLineAA( CvArr* img, CvPoint pt1, CvPoint pt2, double color, int scale)
-{
-    cvLine( img, pt1, pt2, cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale );
-}
-
-void  cvCircleAA( CvArr* img, CvPoint center, int radius, double color, int scale)
-{
-    cvCircle( img, center, radius, cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale );
-}
-
-void  cvEllipseAA( CvArr* img, CvPoint center, CvSize axes,
-                   double angle, double start_angle,
-                   double end_angle, double color,
-                   int scale)
-{
-    cvEllipse( img, center, axes, angle, start_angle, end_angle,
-               cvColorToScalar(color, cvGetElemType(img)), 1, CV_AA, scale );
-}
-
-void  cvPolyLineAA( CvArr* img, CvPoint** pts, int* npts, int contours,
-                    int is_closed, double color, int scale )
-{
-    cvPolyLine( img, pts, npts, contours, is_closed,
-                cvColorToScalar(color, cvGetElemType(img)),
-                1, CV_AA, scale );
-}
-
-
-void cvUnDistortOnce( const CvArr* src, CvArr* dst,
-                      const float* intrinsic_matrix,
-                      const float* distortion_coeffs,
-                      int )
-{
-    CvMat _a = cvMat( 3, 3, CV_32F, (void*)intrinsic_matrix );
-    CvMat _k = cvMat( 4, 1, CV_32F, (void*)distortion_coeffs );
-    cvUndistort2( src, dst, &_a, &_k, 0 );
-}
-
-
-/* the two functions below have quite hackerish implementations, use with care
-   (or, which is better, switch to cvUndistortInitMap and cvRemap instead */
-void cvUnDistortInit( const CvArr*,
-                      CvArr* undistortion_map,
-                      const float* A, const float* k,
-                      int)
-{
-    union { uchar* ptr; float* fl; } data;
-    CvSize sz;
-    cvGetRawData( undistortion_map, &data.ptr, 0, &sz );
-    assert( sz.width >= 8 );
-    /* just save the intrinsic parameters to the map */
-    data.fl[0] = A[0]; data.fl[1] = A[4];
-    data.fl[2] = A[2]; data.fl[3] = A[5];
-    data.fl[4] = k[0]; data.fl[5] = k[1];
-    data.fl[6] = k[2]; data.fl[7] = k[3];
-}
-
-void  cvUnDistort( const CvArr* src, CvArr* dst,
-                   const CvArr* undistortion_map, int )
-{
-    union { uchar* ptr; float* fl; } data;
-    float a[] = {0,0,0,0,0,0,0,0,1};
-    CvSize sz;
-    cvGetRawData( undistortion_map, &data.ptr, 0, &sz );
-    assert( sz.width >= 8 );
-    a[0] = data.fl[0]; a[4] = data.fl[1];
-    a[2] = data.fl[2]; a[5] = data.fl[3];
-    cvUnDistortOnce( src, dst, a, data.fl + 4, 1 );
-}
-
-
-/* Find fundamental matrix */
-void  cvFindFundamentalMatrix( int* points1, int* points2, int numpoints, int, float* matrix )
-{
-    CvMat* pointsMat1;
-    CvMat* pointsMat2;
-    CvMat fundMatr = cvMat(3,3,CV_32F,matrix);
-    int i, curr = 0;
-
-    pointsMat1 = cvCreateMat(3,numpoints,CV_64F);
-    pointsMat2 = cvCreateMat(3,numpoints,CV_64F);
-
-    for( i = 0; i < numpoints; i++ )
-    {
-        cvmSet(pointsMat1,0,i,points1[curr]);//x
-        cvmSet(pointsMat1,1,i,points1[curr+1]);//y
-        cvmSet(pointsMat1,2,i,1.0);
-
-        cvmSet(pointsMat2,0,i,points2[curr]);//x
-        cvmSet(pointsMat2,1,i,points2[curr+1]);//y
-        cvmSet(pointsMat2,2,i,1.0);
-        curr += 2;
-    }
-
-    cvFindFundamentalMat(pointsMat1,pointsMat2,&fundMatr,CV_FM_RANSAC,1,0.99,0);
-
-    cvReleaseMat(&pointsMat1);
-    cvReleaseMat(&pointsMat2);
-}
-
-
-int cvFindChessBoardCornerGuesses( const void* arr, void*,
-                                   CvMemStorage*, CvSize pattern_size,
-                                   CvPoint2D32f* corners, int* corner_count )
-{
-    return cvFindChessboardCorners( arr, pattern_size, corners,
-                                    corner_count, CV_CALIB_CB_ADAPTIVE_THRESH );
-}
-
-
-/* Calibrates camera using multiple views of calibration pattern */
-void cvCalibrateCamera( int image_count, int* _point_counts,
-    CvSize image_size, CvPoint2D32f* _image_points, CvPoint3D32f* _object_points,
-    float* _distortion_coeffs, float* _camera_matrix, float* _translation_vectors,
-    float* _rotation_matrices, int flags )
-{
-    int i, total = 0;
-    CvMat point_counts = cvMat( image_count, 1, CV_32SC1, _point_counts );
-    CvMat image_points, object_points;
-    CvMat dist_coeffs = cvMat( 4, 1, CV_32FC1, _distortion_coeffs );
-    CvMat camera_matrix = cvMat( 3, 3, CV_32FC1, _camera_matrix );
-    CvMat rotation_matrices = cvMat( image_count, 9, CV_32FC1, _rotation_matrices );
-    CvMat translation_vectors = cvMat( image_count, 3, CV_32FC1, _translation_vectors );
-
-    for( i = 0; i < image_count; i++ )
-        total += _point_counts[i];
-
-    image_points = cvMat( total, 1, CV_32FC2, _image_points );
-    object_points = cvMat( total, 1, CV_32FC3, _object_points );
-
-    cvCalibrateCamera2( &object_points, &image_points, &point_counts, image_size,
-        &camera_matrix, &dist_coeffs, &rotation_matrices, &translation_vectors,
-        flags );
-}
-
-
-void cvCalibrateCamera_64d( int image_count, int* _point_counts,
-    CvSize image_size, CvPoint2D64f* _image_points, CvPoint3D64f* _object_points,
-    double* _distortion_coeffs, double* _camera_matrix, double* _translation_vectors,
-    double* _rotation_matrices, int flags )
-{
-    int i, total = 0;
-    CvMat point_counts = cvMat( image_count, 1, CV_32SC1, _point_counts );
-    CvMat image_points, object_points;
-    CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion_coeffs );
-    CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, _camera_matrix );
-    CvMat rotation_matrices = cvMat( image_count, 9, CV_64FC1, _rotation_matrices );
-    CvMat translation_vectors = cvMat( image_count, 3, CV_64FC1, _translation_vectors );
-
-    for( i = 0; i < image_count; i++ )
-        total += _point_counts[i];
-
-    image_points = cvMat( total, 1, CV_64FC2, _image_points );
-    object_points = cvMat( total, 1, CV_64FC3, _object_points );
-
-    cvCalibrateCamera2( &object_points, &image_points, &point_counts, image_size,
-        &camera_matrix, &dist_coeffs, &rotation_matrices, &translation_vectors,
-        flags );
-}
-
-
-
-/* Find 3d position of object given intrinsic camera parameters,
-   3d model of the object and projection of the object into view plane */
-void cvFindExtrinsicCameraParams( int point_count,
-    CvSize, CvPoint2D32f* _image_points,
-    CvPoint3D32f* _object_points, float* focal_length,
-    CvPoint2D32f principal_point, float* _distortion_coeffs,
-    float* _rotation_vector, float* _translation_vector )
-{
-    CvMat image_points = cvMat( point_count, 1, CV_32FC2, _image_points );
-    CvMat object_points = cvMat( point_count, 1, CV_32FC3, _object_points );
-    CvMat dist_coeffs = cvMat( 4, 1, CV_32FC1, _distortion_coeffs );
-    float a[9];
-    CvMat camera_matrix = cvMat( 3, 3, CV_32FC1, a );
-    CvMat rotation_vector = cvMat( 1, 1, CV_32FC3, _rotation_vector );
-    CvMat translation_vector = cvMat( 1, 1, CV_32FC3, _translation_vector );
-
-    a[0] = focal_length[0]; a[4] = focal_length[1];
-    a[2] = principal_point.x; a[5] = principal_point.y;
-    a[1] = a[3] = a[6] = a[7] = 0.f;
-    a[8] = 1.f;
-
-    cvFindExtrinsicCameraParams2( &object_points, &image_points, &camera_matrix,
-        &dist_coeffs, &rotation_vector, &translation_vector, 0 );
-}
-
-
-/* Variant of the previous function that takes double-precision parameters */
-void cvFindExtrinsicCameraParams_64d( int point_count,
-    CvSize, CvPoint2D64f* _image_points,
-    CvPoint3D64f* _object_points, double* focal_length,
-    CvPoint2D64f principal_point, double* _distortion_coeffs,
-    double* _rotation_vector, double* _translation_vector )
-{
-    CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points );
-    CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points );
-    CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion_coeffs );
-    double a[9];
-    CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, a );
-    CvMat rotation_vector = cvMat( 1, 1, CV_64FC3, _rotation_vector );
-    CvMat translation_vector = cvMat( 1, 1, CV_64FC3, _translation_vector );
-
-    a[0] = focal_length[0]; a[4] = focal_length[1];
-    a[2] = principal_point.x; a[5] = principal_point.y;
-    a[1] = a[3] = a[6] = a[7] = 0.;
-    a[8] = 1.;
-
-    cvFindExtrinsicCameraParams2( &object_points, &image_points, &camera_matrix,
-        &dist_coeffs, &rotation_vector, &translation_vector, 0 );
-}
-
-/* Converts rotation_matrix matrix to rotation_matrix vector or vice versa */
-void  cvRodrigues( CvMat* rotation_matrix, CvMat* rotation_vector,
-                   CvMat* jacobian, int conv_type )
-{
-    if( conv_type == CV_RODRIGUES_V2M )
-        cvRodrigues2( rotation_vector, rotation_matrix, jacobian );
-    else
-        cvRodrigues2( rotation_matrix, rotation_vector, jacobian );
-}
-
-
-/* Does reprojection of 3d object points to the view plane */
-void  cvProjectPoints( int point_count, CvPoint3D64f* _object_points,
-    double* _rotation_vector, double*  _translation_vector,
-    double* focal_length, CvPoint2D64f principal_point,
-    double* _distortion, CvPoint2D64f* _image_points,
-    double* _deriv_points_rotation_matrix,
-    double* _deriv_points_translation_vect,
-    double* _deriv_points_focal,
-    double* _deriv_points_principal_point,
-    double* _deriv_points_distortion_coeffs )
-{
-    CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points );
-    CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points );
-    CvMat rotation_vector = cvMat( 3, 1, CV_64FC1, _rotation_vector );
-    CvMat translation_vector = cvMat( 3, 1, CV_64FC1, _translation_vector );
-    double a[9];
-    CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, a );
-    CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion );
-    CvMat dpdr = cvMat( 2*point_count, 3, CV_64FC1, _deriv_points_rotation_matrix );
-    CvMat dpdt = cvMat( 2*point_count, 3, CV_64FC1, _deriv_points_translation_vect );
-    CvMat dpdf = cvMat( 2*point_count, 2, CV_64FC1, _deriv_points_focal );
-    CvMat dpdc = cvMat( 2*point_count, 2, CV_64FC1, _deriv_points_principal_point );
-    CvMat dpdk = cvMat( 2*point_count, 4, CV_64FC1, _deriv_points_distortion_coeffs );
-
-    a[0] = focal_length[0]; a[4] = focal_length[1];
-    a[2] = principal_point.x; a[5] = principal_point.y;
-    a[1] = a[3] = a[6] = a[7] = 0.;
-    a[8] = 1.;
-
-    cvProjectPoints2( &object_points, &rotation_vector, &translation_vector,
-                      &camera_matrix, &dist_coeffs, &image_points,
-                      &dpdr, &dpdt, &dpdf, &dpdc, &dpdk, 0 );
-}
-
-
-/* Simpler version of the previous function */
-void  cvProjectPointsSimple( int point_count, CvPoint3D64f* _object_points,
-    double* _rotation_matrix, double*  _translation_vector,
-    double* _camera_matrix, double* _distortion, CvPoint2D64f* _image_points )
-{
-    CvMat object_points = cvMat( point_count, 1, CV_64FC3, _object_points );
-    CvMat image_points = cvMat( point_count, 1, CV_64FC2, _image_points );
-    CvMat rotation_matrix = cvMat( 3, 3, CV_64FC1, _rotation_matrix );
-    CvMat translation_vector = cvMat( 3, 1, CV_64FC1, _translation_vector );
-    CvMat camera_matrix = cvMat( 3, 3, CV_64FC1, _camera_matrix );
-    CvMat dist_coeffs = cvMat( 4, 1, CV_64FC1, _distortion );
-
-    cvProjectPoints2( &object_points, &rotation_matrix, &translation_vector,
-                      &camera_matrix, &dist_coeffs, &image_points,
-                      0, 0, 0, 0, 0, 0 );
-}
diff --git a/modules/legacy/src/condens.cpp b/modules/legacy/src/condens.cpp
deleted file mode 100644 (file)
index af0af97..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name:    cvCreateConDensation
-//    Purpose: Creating CvConDensation structure and allocating memory for it
-//    Context:
-//    Parameters:
-//      Kalman     - double pointer to CvConDensation structure
-//      DP         - dimension of the dynamical vector
-//      MP         - dimension of the measurement vector
-//      SamplesNum - number of samples in sample set used in algorithm
-//    Returns:
-//    Notes:
-//
-//F*/
-
-CV_IMPL CvConDensation* cvCreateConDensation( int DP, int MP, int SamplesNum )
-{
-    int i;
-    CvConDensation *CD = 0;
-
-    if( DP < 0 || MP < 0 || SamplesNum < 0 )
-        CV_Error( CV_StsOutOfRange, "" );
-
-    /* allocating memory for the structure */
-    CD = (CvConDensation *) cvAlloc( sizeof( CvConDensation ));
-    /* setting structure params */
-    CD->SamplesNum = SamplesNum;
-    CD->DP = DP;
-    CD->MP = MP;
-    /* allocating memory for structure fields */
-    CD->flSamples = (float **) cvAlloc( sizeof( float * ) * SamplesNum );
-    CD->flNewSamples = (float **) cvAlloc( sizeof( float * ) * SamplesNum );
-    CD->flSamples[0] = (float *) cvAlloc( sizeof( float ) * SamplesNum * DP );
-    CD->flNewSamples[0] = (float *) cvAlloc( sizeof( float ) * SamplesNum * DP );
-
-    /* setting pointers in pointer's arrays */
-    for( i = 1; i < SamplesNum; i++ )
-    {
-        CD->flSamples[i] = CD->flSamples[i - 1] + DP;
-        CD->flNewSamples[i] = CD->flNewSamples[i - 1] + DP;
-    }
-
-    CD->State = (float *) cvAlloc( sizeof( float ) * DP );
-    CD->DynamMatr = (float *) cvAlloc( sizeof( float ) * DP * DP );
-    CD->flConfidence = (float *) cvAlloc( sizeof( float ) * SamplesNum );
-    CD->flCumulative = (float *) cvAlloc( sizeof( float ) * SamplesNum );
-
-    CD->RandS = (CvRandState *) cvAlloc( sizeof( CvRandState ) * DP );
-    CD->Temp = (float *) cvAlloc( sizeof( float ) * DP );
-    CD->RandomSample = (float *) cvAlloc( sizeof( float ) * DP );
-
-    /* Returning created structure */
-
-    return CD;
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name:    cvReleaseConDensation
-//    Purpose: Releases CvConDensation structure and frees memory allocated for it
-//    Context:
-//    Parameters:
-//      Kalman     - double pointer to CvConDensation structure
-//      DP         - dimension of the dynamical vector
-//      MP         - dimension of the measurement vector
-//      SamplesNum - number of samples in sample set used in algorithm
-//    Returns:
-//    Notes:
-//
-//F*/
-CV_IMPL void
-cvReleaseConDensation( CvConDensation ** ConDensation )
-{
-    CvConDensation *CD = *ConDensation;
-
-    if( !ConDensation )
-        CV_Error( CV_StsNullPtr, "" );
-
-    if( !CD )
-        return;
-
-    /* freeing the memory */
-    cvFree( &CD->State );
-    cvFree( &CD->DynamMatr);
-    cvFree( &CD->flConfidence );
-    cvFree( &CD->flCumulative );
-    cvFree( &CD->flSamples[0] );
-    cvFree( &CD->flNewSamples[0] );
-    cvFree( &CD->flSamples );
-    cvFree( &CD->flNewSamples );
-    cvFree( &CD->Temp );
-    cvFree( &CD->RandS );
-    cvFree( &CD->RandomSample );
-    /* release structure */
-    cvFree( ConDensation );
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name:    cvConDensUpdateByTime
-//    Purpose: Performing Time Update routine for ConDensation algorithm
-//    Context:
-//    Parameters:
-//      Kalman     - pointer to CvConDensation structure
-//    Returns:
-//    Notes:
-//
-//F*/
-CV_IMPL void
-cvConDensUpdateByTime( CvConDensation * ConDens )
-{
-    int i, j;
-    float Sum = 0;
-
-    if( !ConDens )
-        CV_Error( CV_StsNullPtr, "" );
-
-    /* Sets Temp to Zero */
-    icvSetZero_32f( ConDens->Temp, ConDens->DP, 1 );
-
-    /* Calculating the Mean */
-    for( i = 0; i < ConDens->SamplesNum; i++ )
-    {
-        icvScaleVector_32f( ConDens->flSamples[i], ConDens->State, ConDens->DP,
-                             ConDens->flConfidence[i] );
-        icvAddVector_32f( ConDens->Temp, ConDens->State, ConDens->Temp, ConDens->DP );
-        Sum += ConDens->flConfidence[i];
-        ConDens->flCumulative[i] = Sum;
-    }
-
-    /* Taking the new vector from transformation of mean by dynamics matrix */
-
-    icvScaleVector_32f( ConDens->Temp, ConDens->Temp, ConDens->DP, 1.f / Sum );
-    icvTransformVector_32f( ConDens->DynamMatr, ConDens->Temp, ConDens->State, ConDens->DP,
-                             ConDens->DP );
-    Sum = Sum / ConDens->SamplesNum;
-
-    /* Updating the set of random samples */
-    for( i = 0; i < ConDens->SamplesNum; i++ )
-    {
-        j = 0;
-        while( (ConDens->flCumulative[j] <= (float) i * Sum)&&(j<ConDens->SamplesNum-1))
-        {
-            j++;
-        }
-        icvCopyVector_32f( ConDens->flSamples[j], ConDens->DP, ConDens->flNewSamples[i] );
-    }
-
-    /* Adding the random-generated vector to every vector in sample set */
-    for( i = 0; i < ConDens->SamplesNum; i++ )
-    {
-        for( j = 0; j < ConDens->DP; j++ )
-        {
-            cvbRand( ConDens->RandS + j, ConDens->RandomSample + j, 1 );
-        }
-
-        icvTransformVector_32f( ConDens->DynamMatr, ConDens->flNewSamples[i],
-                                 ConDens->flSamples[i], ConDens->DP, ConDens->DP );
-        icvAddVector_32f( ConDens->flSamples[i], ConDens->RandomSample, ConDens->flSamples[i],
-                           ConDens->DP );
-    }
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name:    cvConDensInitSamplSet
-//    Purpose: Performing Time Update routine for ConDensation algorithm
-//    Context:
-//    Parameters:
-//    conDens     - pointer to CvConDensation structure
-//    lowerBound  - vector of lower bounds used to random update of sample set
-//    lowerBound  - vector of upper bounds used to random update of sample set
-//    Returns:
-//    Notes:
-//
-//F*/
-
-CV_IMPL void
-cvConDensInitSampleSet( CvConDensation * conDens, CvMat * lowerBound, CvMat * upperBound )
-{
-    int i, j;
-    float *LBound;
-    float *UBound;
-    float Prob = 1.f / conDens->SamplesNum;
-
-    if( !conDens || !lowerBound || !upperBound )
-        CV_Error( CV_StsNullPtr, "" );
-
-    if( CV_MAT_TYPE(lowerBound->type) != CV_32FC1 ||
-        !CV_ARE_TYPES_EQ(lowerBound,upperBound) )
-        CV_Error( CV_StsBadArg, "source  has not appropriate format" );
-
-    if( (lowerBound->cols != 1) || (upperBound->cols != 1) )
-        CV_Error( CV_StsBadArg, "source  has not appropriate size" );
-
-    if( (lowerBound->rows != conDens->DP) || (upperBound->rows != conDens->DP) )
-        CV_Error( CV_StsBadArg, "source  has not appropriate size" );
-
-    LBound = lowerBound->data.fl;
-    UBound = upperBound->data.fl;
-    /* Initializing the structures to create initial Sample set */
-    for( i = 0; i < conDens->DP; i++ )
-    {
-        cvRandInit( &(conDens->RandS[i]),
-                    LBound[i],
-                    UBound[i],
-                    i );
-    }
-    /* Generating the samples */
-    for( j = 0; j < conDens->SamplesNum; j++ )
-    {
-        for( i = 0; i < conDens->DP; i++ )
-        {
-            cvbRand( conDens->RandS + i, conDens->flSamples[j] + i, 1 );
-        }
-        conDens->flConfidence[j] = Prob;
-    }
-    /* Reinitializes the structures to update samples randomly */
-    for( i = 0; i < conDens->DP; i++ )
-    {
-        cvRandInit( &(conDens->RandS[i]),
-                    (LBound[i] - UBound[i]) / 5,
-                    (UBound[i] - LBound[i]) / 5,
-                    i);
-    }
-}
diff --git a/modules/legacy/src/contourtree.cpp b/modules/legacy/src/contourtree.cpp
deleted file mode 100644 (file)
index 8115b60..0000000
+++ /dev/null
@@ -1,970 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-#define _CV_BINTREE_LIST()                                          \
-struct _CvTrianAttr* prev_v;   /* pointer to the parent  element on the previous level of the tree  */    \
-struct _CvTrianAttr* next_v1;   /* pointer to the child  element on the next level of the tree  */        \
-struct _CvTrianAttr* next_v2;   /* pointer to the child  element on the next level of the tree  */
-
-typedef struct _CvTrianAttr
-{
-    CvPoint pt;    /* Coordinates x and y of the vertex  which don't lie on the base line LMIAT  */
-    char sign;             /*  sign of the triangle   */
-    double area;       /*   area of the triangle    */
-    double r1;   /*  The ratio of the height of triangle to the base of the triangle  */
-    double r2;  /*   The ratio of the projection of the left side of the triangle on the base to the base */
-    _CV_BINTREE_LIST()    /* structure double list   */
-}
-_CvTrianAttr;
-
-#define CV_MATCH_CHECK( status, cvFun )                                    \
-  {                                                                        \
-    status = cvFun;                                                        \
-    if( status != CV_OK )                                                  \
-     goto M_END;                                                           \
-  }
-
-static CvStatus
-icvCalcTriAttr( const CvSeq * contour, CvPoint t2, CvPoint t1, int n1,
-                CvPoint t3, int n3, double *s, double *s_c,
-                double *h, double *a, double *b );
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvCreateContourTree
-//    Purpose:
-//    Create binary tree representation for the contour
-//    Context:
-//    Parameters:
-//      contour - pointer to input contour object.
-//      storage - pointer to the current storage block
-//      tree   -  output pointer to the binary tree representation
-//      threshold - threshold for the binary tree building
-//
-//F*/
-static CvStatus
-icvCreateContourTree( const CvSeq * contour, CvMemStorage * storage,
-                      CvContourTree ** tree, double threshold )
-{
-    CvPoint *pt_p;              /*  pointer to previos points   */
-    CvPoint *pt_n;              /*  pointer to next points      */
-    CvPoint *pt1, *pt2;         /*  pointer to current points   */
-
-    CvPoint t, tp1, tp2, tp3, tn1, tn2, tn3;
-    int lpt, flag, i, j, i_tree, j_1, j_3, i_buf;
-    double s, sp1, sp2, sn1, sn2, s_c, sp1_c, sp2_c, sn1_c, sn2_c, h, hp1, hp2, hn1, hn2,
-        a, ap1, ap2, an1, an2, b, bp1, bp2, bn1, bn2;
-    double a_s_c, a_sp1_c;
-
-    _CvTrianAttr **ptr_p, **ptr_n, **ptr1, **ptr2;      /*  pointers to pointers of triangles  */
-    _CvTrianAttr *cur_adr;
-
-    int *num_p, *num_n, *num1, *num2;   /*   numbers of input contour points   */
-    int nm, nmp1, nmp2, nmp3, nmn1, nmn2, nmn3;
-    int seq_flags = 1, i_end, prev_null, prev2_null;
-    double koef = 1.5;
-    double eps = 1.e-7;
-    double e;
-    CvStatus status;
-    int hearder_size;
-    _CvTrianAttr tree_one, tree_two, *tree_end, *tree_root;
-
-    CvSeqWriter writer;
-
-    assert( contour != NULL && contour->total >= 4 );
-    status = CV_OK;
-
-    if( contour == NULL )
-        return CV_NULLPTR_ERR;
-    if( contour->total < 4 )
-        return CV_BADSIZE_ERR;
-
-    if( !CV_IS_SEQ_POINT_SET( contour ))
-        return CV_BADFLAG_ERR;
-
-
-/*   Convert Sequence to array    */
-    lpt = contour->total;
-    pt_p = pt_n = NULL;
-    num_p = num_n = NULL;
-    ptr_p = ptr_n = ptr1 = ptr2 = NULL;
-    tree_end = NULL;
-
-    pt_p = (CvPoint *) cvAlloc( lpt * sizeof( CvPoint ));
-    pt_n = (CvPoint *) cvAlloc( lpt * sizeof( CvPoint ));
-
-    num_p = (int *) cvAlloc( lpt * sizeof( int ));
-    num_n = (int *) cvAlloc( lpt * sizeof( int ));
-
-    hearder_size = sizeof( CvContourTree );
-    seq_flags = CV_SEQ_POLYGON_TREE;
-    cvStartWriteSeq( seq_flags, hearder_size, sizeof( _CvTrianAttr ), storage, &writer );
-
-    ptr_p = (_CvTrianAttr **) cvAlloc( lpt * sizeof( _CvTrianAttr * ));
-    ptr_n = (_CvTrianAttr **) cvAlloc( lpt * sizeof( _CvTrianAttr * ));
-
-    memset( ptr_p, 0, lpt * sizeof( _CvTrianAttr * ));
-    memset( ptr_n, 0, lpt * sizeof( _CvTrianAttr * ));
-
-    if( pt_p == NULL || pt_n == NULL )
-        return CV_OUTOFMEM_ERR;
-    if( ptr_p == NULL || ptr_n == NULL )
-        return CV_OUTOFMEM_ERR;
-
-/*     write fild for the binary tree root   */
-/*  start_writer = writer;   */
-
-    tree_one.pt.x = tree_one.pt.y = 0;
-    tree_one.sign = 0;
-    tree_one.area = 0;
-    tree_one.r1 = tree_one.r2 = 0;
-    tree_one.next_v1 = tree_one.next_v2 = tree_one.prev_v = NULL;
-
-    CV_WRITE_SEQ_ELEM( tree_one, writer );
-    tree_root = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
-
-    if( cvCvtSeqToArray( contour, (char *) pt_p ) == (char *) contour )
-        return CV_BADPOINT_ERR;
-
-    for( i = 0; i < lpt; i++ )
-        num_p[i] = i;
-
-    i = lpt;
-    flag = 0;
-    i_tree = 0;
-    e = 20.;                    /*  initial threshold value   */
-    ptr1 = ptr_p;
-    ptr2 = ptr_n;
-    pt1 = pt_p;
-    pt2 = pt_n;
-    num1 = num_p;
-    num2 = num_n;
-/*  binary tree constraction    */
-    while( i > 4 )
-    {
-        if( flag == 0 )
-        {
-            ptr1 = ptr_p;
-            ptr2 = ptr_n;
-            pt1 = pt_p;
-            pt2 = pt_n;
-            num1 = num_p;
-            num2 = num_n;
-            flag = 1;
-        }
-        else
-        {
-            ptr1 = ptr_n;
-            ptr2 = ptr_p;
-            pt1 = pt_n;
-            pt2 = pt_p;
-            num1 = num_n;
-            num2 = num_p;
-            flag = 0;
-        }
-        t = pt1[0];
-        nm = num1[0];
-        tp1 = pt1[i - 1];
-        nmp1 = num1[i - 1];
-        tp2 = pt1[i - 2];
-        nmp2 = num1[i - 2];
-        tp3 = pt1[i - 3];
-        nmp3 = num1[i - 3];
-        tn1 = pt1[1];
-        nmn1 = num1[1];
-        tn2 = pt1[2];
-        nmn2 = num1[2];
-
-        i_buf = 0;
-        i_end = -1;
-        CV_MATCH_CHECK( status,
-                        icvCalcTriAttr( contour, t, tp1, nmp1, tn1, nmn1, &s, &s_c, &h, &a,
-                                        &b ));
-        CV_MATCH_CHECK( status,
-                        icvCalcTriAttr( contour, tp1, tp2, nmp2, t, nm, &sp1, &sp1_c, &hp1,
-                                        &ap1, &bp1 ));
-        CV_MATCH_CHECK( status,
-                        icvCalcTriAttr( contour, tp2, tp3, nmp3, tp1, nmp1, &sp2, &sp2_c, &hp2,
-                                        &ap2, &bp2 ));
-        CV_MATCH_CHECK( status,
-                        icvCalcTriAttr( contour, tn1, t, nm, tn2, nmn2, &sn1, &sn1_c, &hn1,
-                                        &an1, &bn1 ));
-
-
-        j_3 = 3;
-        prev_null = prev2_null = 0;
-        for( j = 0; j < i; j++ )
-        {
-            tn3 = pt1[j_3];
-            nmn3 = num1[j_3];
-            if( j == 0 )
-                j_1 = i - 1;
-            else
-                j_1 = j - 1;
-
-            CV_MATCH_CHECK( status, icvCalcTriAttr( contour, tn2, tn1, nmn1, tn3, nmn3,
-                                                    &sn2, &sn2_c, &hn2, &an2, &bn2 ));
-
-            if( (s_c < sp1_c && s_c < sp2_c && s_c <= sn1_c && s_c <= sn2_c && s_c < e) ||
-                (((s_c == sp1_c && s_c <= sp2_c) || (s_c == sp2_c && s_c <= sp1_c)) &&
-                s_c <= sn1_c && s_c <= sn2_c && s_c < e && j > 1 && prev2_null == 0) ||
-                (s_c < eps && j > 0 && prev_null == 0) )
-            {
-                prev_null = prev2_null = 1;
-                if( s_c < threshold )
-                {
-                    if( ptr1[j_1] == NULL && ptr1[j] == NULL )
-                    {
-                        if( i_buf > 0 )
-                            ptr2[i_buf - 1] = NULL;
-                        else
-                            i_end = 0;
-                    }
-                    else
-                    {
-/*   form next vertex  */
-                        tree_one.pt = t;
-                        tree_one.sign = (char) (CV_SIGN( s ));
-                        tree_one.r1 = h / a;
-                        tree_one.r2 = b / a;
-                        tree_one.area = fabs( s );
-                        tree_one.next_v1 = ptr1[j_1];
-                        tree_one.next_v2 = ptr1[j];
-
-                        CV_WRITE_SEQ_ELEM( tree_one, writer );
-                        cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
-
-                        if( ptr1[j_1] != NULL )
-                            ptr1[j_1]->prev_v = cur_adr;
-                        if( ptr1[j] != NULL )
-                            ptr1[j]->prev_v = cur_adr;
-
-                        if( i_buf > 0 )
-                            ptr2[i_buf - 1] = cur_adr;
-                        else
-                        {
-                            tree_end = (_CvTrianAttr *) writer.ptr;
-                            i_end = 1;
-                        }
-                        i_tree++;
-                    }
-                }
-                else
-/*   form next vertex    */
-                {
-                    tree_one.pt = t;
-                    tree_one.sign = (char) (CV_SIGN( s ));
-                    tree_one.area = fabs( s );
-                    tree_one.r1 = h / a;
-                    tree_one.r2 = b / a;
-                    tree_one.next_v1 = ptr1[j_1];
-                    tree_one.next_v2 = ptr1[j];
-
-                    CV_WRITE_SEQ_ELEM( tree_one, writer );
-                    cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
-
-                    if( ptr1[j_1] != NULL )
-                        ptr1[j_1]->prev_v = cur_adr;
-                    if( ptr1[j] != NULL )
-                        ptr1[j]->prev_v = cur_adr;
-
-                    if( i_buf > 0 )
-                        ptr2[i_buf - 1] = cur_adr;
-                    else
-                    {
-                        tree_end = cur_adr;
-                        i_end = 1;
-                    }
-                    i_tree++;
-                }
-            }
-            else
-/*   the current triangle is'not LMIAT    */
-            {
-                prev_null = 0;
-                switch (prev2_null)
-                {
-                case 0:
-                    break;
-                case 1:
-                    {
-                        prev2_null = 2;
-                        break;
-                    }
-                case 2:
-                    {
-                        prev2_null = 0;
-                        break;
-                    }
-                }
-                if( j != i - 1 || i_end == -1 )
-                    ptr2[i_buf] = ptr1[j];
-                else if( i_end == 0 )
-                    ptr2[i_buf] = NULL;
-                else
-                    ptr2[i_buf] = tree_end;
-                pt2[i_buf] = t;
-                num2[i_buf] = num1[j];
-                i_buf++;
-            }
-/*    go to next vertex    */
-            tp3 = tp2;
-            tp2 = tp1;
-            tp1 = t;
-            t = tn1;
-            tn1 = tn2;
-            tn2 = tn3;
-            nmp3 = nmp2;
-            nmp2 = nmp1;
-            nmp1 = nm;
-            nm = nmn1;
-            nmn1 = nmn2;
-            nmn2 = nmn3;
-
-            sp2 = sp1;
-            sp1 = s;
-            s = sn1;
-            sn1 = sn2;
-            sp2_c = sp1_c;
-            sp1_c = s_c;
-            s_c = sn1_c;
-            sn1_c = sn2_c;
-
-            ap2 = ap1;
-            ap1 = a;
-            a = an1;
-            an1 = an2;
-            bp2 = bp1;
-            bp1 = b;
-            b = bn1;
-            bn1 = bn2;
-            hp2 = hp1;
-            hp1 = h;
-            h = hn1;
-            hn1 = hn2;
-            j_3++;
-            if( j_3 >= i )
-                j_3 = 0;
-        }
-
-        i = i_buf;
-        e = e * koef;
-    }
-
-/*  constract tree root  */
-    if( i != 4 )
-        return CV_BADFACTOR_ERR;
-
-    t = pt2[0];
-    tn1 = pt2[1];
-    tn2 = pt2[2];
-    tp1 = pt2[3];
-    nm = num2[0];
-    nmn1 = num2[1];
-    nmn2 = num2[2];
-    nmp1 = num2[3];
-/*   first pair of the triangles   */
-    CV_MATCH_CHECK( status,
-                    icvCalcTriAttr( contour, t, tp1, nmp1, tn1, nmn1, &s, &s_c, &h, &a, &b ));
-    CV_MATCH_CHECK( status,
-                    icvCalcTriAttr( contour, tn2, tn1, nmn1, tp1, nmp1, &sn2, &sn2_c, &hn2,
-                                    &an2, &bn2 ));
-/*   second pair of the triangles   */
-    CV_MATCH_CHECK( status,
-                    icvCalcTriAttr( contour, tn1, t, nm, tn2, nmn2, &sn1, &sn1_c, &hn1, &an1,
-                                    &bn1 ));
-    CV_MATCH_CHECK( status,
-                    icvCalcTriAttr( contour, tp1, tn2, nmn2, t, nm, &sp1, &sp1_c, &hp1, &ap1,
-                                    &bp1 ));
-
-    a_s_c = fabs( s_c - sn2_c );
-    a_sp1_c = fabs( sp1_c - sn1_c );
-
-    if( a_s_c > a_sp1_c )
-/*   form child vertexs for the root     */
-    {
-        tree_one.pt = t;
-        tree_one.sign = (char) (CV_SIGN( s ));
-        tree_one.area = fabs( s );
-        tree_one.r1 = h / a;
-        tree_one.r2 = b / a;
-        tree_one.next_v1 = ptr2[3];
-        tree_one.next_v2 = ptr2[0];
-
-        tree_two.pt = tn2;
-        tree_two.sign = (char) (CV_SIGN( sn2 ));
-        tree_two.area = fabs( sn2 );
-        tree_two.r1 = hn2 / an2;
-        tree_two.r2 = bn2 / an2;
-        tree_two.next_v1 = ptr2[1];
-        tree_two.next_v2 = ptr2[2];
-
-        CV_WRITE_SEQ_ELEM( tree_one, writer );
-        cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
-
-        if( s_c > sn2_c )
-        {
-            if( ptr2[3] != NULL )
-                ptr2[3]->prev_v = cur_adr;
-            if( ptr2[0] != NULL )
-                ptr2[0]->prev_v = cur_adr;
-            ptr1[0] = cur_adr;
-
-            i_tree++;
-
-            CV_WRITE_SEQ_ELEM( tree_two, writer );
-            cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
-
-            if( ptr2[1] != NULL )
-                ptr2[1]->prev_v = cur_adr;
-            if( ptr2[2] != NULL )
-                ptr2[2]->prev_v = cur_adr;
-            ptr1[1] = cur_adr;
-
-            i_tree++;
-
-            pt1[0] = tp1;
-            pt1[1] = tn1;
-        }
-        else
-        {
-            CV_WRITE_SEQ_ELEM( tree_two, writer );
-            cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
-
-            if( ptr2[1] != NULL )
-                ptr2[1]->prev_v = cur_adr;
-            if( ptr2[2] != NULL )
-                ptr2[2]->prev_v = cur_adr;
-            ptr1[0] = cur_adr;
-
-            i_tree++;
-
-            CV_WRITE_SEQ_ELEM( tree_one, writer );
-            cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
-
-            if( ptr2[3] != NULL )
-                ptr2[3]->prev_v = cur_adr;
-            if( ptr2[0] != NULL )
-                ptr2[0]->prev_v = cur_adr;
-            ptr1[1] = cur_adr;
-
-            i_tree++;
-
-            pt1[0] = tn1;
-            pt1[1] = tp1;
-        }
-    }
-    else
-    {
-        tree_one.pt = tp1;
-        tree_one.sign = (char) (CV_SIGN( sp1 ));
-        tree_one.area = fabs( sp1 );
-        tree_one.r1 = hp1 / ap1;
-        tree_one.r2 = bp1 / ap1;
-        tree_one.next_v1 = ptr2[2];
-        tree_one.next_v2 = ptr2[3];
-
-        tree_two.pt = tn1;
-        tree_two.sign = (char) (CV_SIGN( sn1 ));
-        tree_two.area = fabs( sn1 );
-        tree_two.r1 = hn1 / an1;
-        tree_two.r2 = bn1 / an1;
-        tree_two.next_v1 = ptr2[0];
-        tree_two.next_v2 = ptr2[1];
-
-        CV_WRITE_SEQ_ELEM( tree_one, writer );
-        cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
-
-        if( sp1_c > sn1_c )
-        {
-            if( ptr2[2] != NULL )
-                ptr2[2]->prev_v = cur_adr;
-            if( ptr2[3] != NULL )
-                ptr2[3]->prev_v = cur_adr;
-            ptr1[0] = cur_adr;
-
-            i_tree++;
-
-            CV_WRITE_SEQ_ELEM( tree_two, writer );
-            cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
-
-            if( ptr2[0] != NULL )
-                ptr2[0]->prev_v = cur_adr;
-            if( ptr2[1] != NULL )
-                ptr2[1]->prev_v = cur_adr;
-            ptr1[1] = cur_adr;
-
-            i_tree++;
-
-            pt1[0] = tn2;
-            pt1[1] = t;
-        }
-        else
-        {
-            CV_WRITE_SEQ_ELEM( tree_two, writer );
-            cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
-
-            if( ptr2[0] != NULL )
-                ptr2[0]->prev_v = cur_adr;
-            if( ptr2[1] != NULL )
-                ptr2[1]->prev_v = cur_adr;
-            ptr1[0] = cur_adr;
-
-            i_tree++;
-
-            CV_WRITE_SEQ_ELEM( tree_one, writer );
-            cur_adr = (_CvTrianAttr *) (writer.ptr - writer.seq->elem_size);
-
-            if( ptr2[2] != NULL )
-                ptr2[2]->prev_v = cur_adr;
-            if( ptr2[3] != NULL )
-                ptr2[3]->prev_v = cur_adr;
-            ptr1[1] = cur_adr;
-
-            i_tree++;
-
-            pt1[0] = t;
-            pt1[1] = tn2;
-
-        }
-    }
-
-/*    form root   */
-    s = cvContourArea( contour );
-
-    tree_root->pt = pt1[1];
-    tree_root->sign = 0;
-    tree_root->area = fabs( s );
-    tree_root->r1 = 0;
-    tree_root->r2 = 0;
-    tree_root->next_v1 = ptr1[0];
-    tree_root->next_v2 = ptr1[1];
-    tree_root->prev_v = NULL;
-
-    ptr1[0]->prev_v = (_CvTrianAttr *) tree_root;
-    ptr1[1]->prev_v = (_CvTrianAttr *) tree_root;
-
-/*     write binary tree root   */
-/*    CV_WRITE_SEQ_ELEM (tree_one, start_writer);   */
-    i_tree++;
-/*  create Sequence hearder     */
-    *tree = (CvContourTree*)cvEndWriteSeq( &writer );
-/*   write points for the main segment into sequence header   */
-    (*tree)->p1 = pt1[0];
-
-  M_END:
-
-    cvFree( &ptr_n );
-    cvFree( &ptr_p );
-    cvFree( &num_n );
-    cvFree( &num_p );
-    cvFree( &pt_n );
-    cvFree( &pt_p );
-
-    return status;
-}
-
-/****************************************************************************************\
-
- triangle attributes calculations
-
-\****************************************************************************************/
-static CvStatus
-icvCalcTriAttr( const CvSeq * contour, CvPoint t2, CvPoint t1, int n1,
-                CvPoint t3, int n3, double *s, double *s_c,
-                double *h, double *a, double *b )
-{
-    double x13, y13, x12, y12, l_base, nx, ny, qq;
-    double eps = 1.e-5;
-
-    x13 = t3.x - t1.x;
-    y13 = t3.y - t1.y;
-    x12 = t2.x - t1.x;
-    y12 = t2.y - t1.y;
-    qq = x13 * x13 + y13 * y13;
-    l_base = cvSqrt( (float) (qq) );
-    if( l_base > eps )
-    {
-        nx = y13 / l_base;
-        ny = -x13 / l_base;
-
-        *h = nx * x12 + ny * y12;
-
-        *s = (*h) * l_base / 2.;
-
-        *b = nx * y12 - ny * x12;
-
-        *a = l_base;
-/*   calculate interceptive area   */
-        *s_c = cvContourArea( contour, cvSlice(n1, n3+1));
-    }
-    else
-    {
-        *h = 0;
-        *s = 0;
-        *s_c = 0;
-        *b = 0;
-        *a = 0;
-    }
-
-    return CV_OK;
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: cvCreateContourTree
-//    Purpose:
-//    Create binary tree representation for the contour
-//    Context:
-//    Parameters:
-//      contour - pointer to input contour object.
-//      storage - pointer to the current storage block
-//      tree   -  output pointer to the binary tree representation
-//      threshold - threshold for the binary tree building
-//
-//F*/
-CV_IMPL CvContourTree*
-cvCreateContourTree( const CvSeq* contour, CvMemStorage* storage, double threshold )
-{
-    CvContourTree* tree = 0;
-
-    IPPI_CALL( icvCreateContourTree( contour, storage, &tree, threshold ));
-
-    return tree;
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvContourFromContourTree
-//    Purpose:
-//    reconstracts contour from binary tree representation
-//    Context:
-//    Parameters:
-//      tree   -  pointer to the input binary tree representation
-//      storage - pointer to the current storage block
-//      contour - pointer to output contour object.
-//      criteria - criteria for the definition threshold value
-//                 for the contour reconstracting (level or precision)
-//F*/
-CV_IMPL CvSeq*
-cvContourFromContourTree( const CvContourTree*  tree,
-                          CvMemStorage*  storage,
-                          CvTermCriteria  criteria )
-{
-    CvSeq* contour = 0;
-    cv::AutoBuffer<_CvTrianAttr*> ptr_buf;     /*  pointer to the pointer's buffer  */
-    cv::AutoBuffer<int> level_buf;
-    int i_buf;
-
-    int lpt;
-    double area_all;
-    double threshold;
-    int cur_level;
-    int level;
-    int seq_flags;
-    char log_iter, log_eps;
-    int out_hearder_size;
-    _CvTrianAttr *tree_one = 0, tree_root;  /*  current vertex  */
-
-    CvSeqReader reader;
-    CvSeqWriter writer;
-
-    if( !tree )
-        CV_Error( CV_StsNullPtr, "" );
-
-    if( !CV_IS_SEQ_POLYGON_TREE( tree ))
-        CV_Error( CV_StsBadArg, "" );
-
-    criteria = cvCheckTermCriteria( criteria, 0., 100 );
-
-    lpt = tree->total;
-    i_buf = 0;
-    cur_level = 0;
-    log_iter = (char) (criteria.type == CV_TERMCRIT_ITER ||
-                       (criteria.type == CV_TERMCRIT_ITER + CV_TERMCRIT_EPS));
-    log_eps = (char) (criteria.type == CV_TERMCRIT_EPS ||
-                      (criteria.type == CV_TERMCRIT_ITER + CV_TERMCRIT_EPS));
-
-    cvStartReadSeq( (CvSeq *) tree, &reader, 0 );
-
-    out_hearder_size = sizeof( CvContour );
-
-    seq_flags = CV_SEQ_POLYGON;
-    cvStartWriteSeq( seq_flags, out_hearder_size, sizeof( CvPoint ), storage, &writer );
-
-    ptr_buf.allocate(lpt);
-    if( log_iter )
-        level_buf.allocate(lpt);
-
-    memset( ptr_buf, 0, lpt * sizeof( _CvTrianAttr * ));
-
-/*     write the first tree root's point as a start point of the result contour  */
-    CV_WRITE_SEQ_ELEM( tree->p1, writer );
-/*     write the second tree root"s point into buffer    */
-
-/*     read the root of the tree   */
-    CV_READ_SEQ_ELEM( tree_root, reader );
-
-    tree_one = &tree_root;
-    area_all = tree_one->area;
-
-    if( log_eps )
-        threshold = criteria.epsilon * area_all;
-    else
-        threshold = 10 * area_all;
-
-    if( log_iter )
-        level = criteria.max_iter;
-    else
-        level = -1;
-
-/*  contour from binary tree constraction    */
-    while( i_buf >= 0 )
-    {
-        if( tree_one != NULL && (cur_level <= level || tree_one->area >= threshold) )
-/*   go to left sub tree for the vertex and save pointer to the right vertex   */
-/*   into the buffer     */
-        {
-            ptr_buf[i_buf] = tree_one;
-            if( log_iter )
-            {
-                level_buf[i_buf] = cur_level;
-                cur_level++;
-            }
-            i_buf++;
-            tree_one = tree_one->next_v1;
-        }
-        else
-        {
-            i_buf--;
-            if( i_buf >= 0 )
-            {
-                CvPoint pt = ptr_buf[i_buf]->pt;
-                CV_WRITE_SEQ_ELEM( pt, writer );
-                tree_one = ptr_buf[i_buf]->next_v2;
-                if( log_iter )
-                {
-                    cur_level = level_buf[i_buf] + 1;
-                }
-            }
-        }
-    }
-
-    contour = cvEndWriteSeq( &writer );
-    cvBoundingRect( contour, 1 );
-
-    return contour;
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvMatchContourTrees
-//    Purpose:
-//      Calculates matching of the two contour trees
-//    Context:
-//    Parameters:
-//      tree1 - pointer to the first input contour tree object.
-//      tree2 - pointer to the second input contour tree object.
-//      method - method for the matching calculation
-//      (now CV_CONTOUR_TREES_MATCH_I1 only  )
-//      threshold - threshold for the contour trees matching
-//      result - output calculated measure
-//F*/
-CV_IMPL  double
-cvMatchContourTrees( const CvContourTree* tree1, const CvContourTree* tree2,
-                     int method, double threshold )
-{
-    cv::AutoBuffer<_CvTrianAttr*> buf;
-    _CvTrianAttr **ptr_p1 = 0, **ptr_p2 = 0;    /*pointers to the pointer's buffer */
-    _CvTrianAttr **ptr_n1 = 0, **ptr_n2 = 0;    /*pointers to the pointer's buffer */
-    _CvTrianAttr **ptr11, **ptr12, **ptr21, **ptr22;
-
-    int lpt1, lpt2, lpt, flag, flag_n, i, j, ibuf, ibuf1;
-    double match_v, d12, area1, area2, r11, r12, r21, r22, w1, w2;
-    double eps = 1.e-5;
-    char s1, s2;
-    _CvTrianAttr tree_1, tree_2;        /*current vertex 1 and 2 tree */
-    CvSeqReader reader1, reader2;
-
-    if( !tree1 || !tree2 )
-        CV_Error( CV_StsNullPtr, "" );
-
-    if( method != CV_CONTOUR_TREES_MATCH_I1 )
-        CV_Error( CV_StsBadArg, "Unknown/unsupported comparison method" );
-
-    if( !CV_IS_SEQ_POLYGON_TREE( tree1 ))
-        CV_Error( CV_StsBadArg, "The first argument is not a valid contour tree" );
-
-    if( !CV_IS_SEQ_POLYGON_TREE( tree2 ))
-        CV_Error( CV_StsBadArg, "The second argument is not a valid contour tree" );
-
-    lpt1 = tree1->total;
-    lpt2 = tree2->total;
-    lpt = lpt1 > lpt2 ? lpt1 : lpt2;
-
-    ptr_p1 = ptr_n1 = ptr_p2 = ptr_n2 = NULL;
-    buf.allocate(lpt*4);
-    ptr_p1 = buf;
-    ptr_p2 = ptr_p1 + lpt;
-    ptr_n1 = ptr_p2 + lpt;
-    ptr_n2 = ptr_n1 + lpt;
-
-    cvStartReadSeq( (CvSeq *) tree1, &reader1, 0 );
-    cvStartReadSeq( (CvSeq *) tree2, &reader2, 0 );
-
-/*read the root of the first and second tree*/
-    CV_READ_SEQ_ELEM( tree_1, reader1 );
-    CV_READ_SEQ_ELEM( tree_2, reader2 );
-
-/*write to buffer pointers to root's childs vertexs*/
-    ptr_p1[0] = tree_1.next_v1;
-    ptr_p1[1] = tree_1.next_v2;
-    ptr_p2[0] = tree_2.next_v1;
-    ptr_p2[1] = tree_2.next_v2;
-    i = 2;
-    match_v = 0.;
-    area1 = tree_1.area;
-    area2 = tree_2.area;
-
-    if( area1 < eps || area2 < eps || lpt < 4 )
-        CV_Error( CV_StsBadSize, "" );
-
-    r11 = r12 = r21 = r22 = w1 = w2 = d12 = 0;
-    flag = 0;
-    s1 = s2 = 0;
-    do
-    {
-        if( flag == 0 )
-        {
-            ptr11 = ptr_p1;
-            ptr12 = ptr_n1;
-            ptr21 = ptr_p2;
-            ptr22 = ptr_n2;
-            flag = 1;
-        }
-        else
-        {
-            ptr11 = ptr_n1;
-            ptr12 = ptr_p1;
-            ptr21 = ptr_n2;
-            ptr22 = ptr_p2;
-            flag = 0;
-        }
-        ibuf = 0;
-        for( j = 0; j < i; j++ )
-        {
-            flag_n = 0;
-            if( ptr11[j] != NULL )
-            {
-                r11 = ptr11[j]->r1;
-                r12 = ptr11[j]->r2;
-                flag_n = 1;
-                w1 = ptr11[j]->area / area1;
-                s1 = ptr11[j]->sign;
-            }
-            else
-            {
-                r11 = r21 = 0;
-            }
-            if( ptr21[j] != NULL )
-            {
-                r21 = ptr21[j]->r1;
-                r22 = ptr21[j]->r2;
-                flag_n = 1;
-                w2 = ptr21[j]->area / area2;
-                s2 = ptr21[j]->sign;
-            }
-            else
-            {
-                r21 = r22 = 0;
-            }
-            if( flag_n != 0 )
-/* calculate node distance */
-            {
-                switch (method)
-                {
-                case 1:
-                    {
-                        double t0, t1;
-                        if( s1 != s2 )
-                        {
-                            t0 = fabs( r11 * w1 + r21 * w2 );
-                            t1 = fabs( r12 * w1 + r22 * w2 );
-                        }
-                        else
-                        {
-                            t0 = fabs( r11 * w1 - r21 * w2 );
-                            t1 = fabs( r12 * w1 - r22 * w2 );
-                        }
-                        d12 = t0 + t1;
-                        break;
-                    }
-                }
-                match_v += d12;
-                ibuf1 = ibuf + 1;
-/*write to buffer the pointer to child vertexes*/
-                if( ptr11[j] != NULL )
-                {
-                    ptr12[ibuf] = ptr11[j]->next_v1;
-                    ptr12[ibuf1] = ptr11[j]->next_v2;
-                }
-                else
-                {
-                    ptr12[ibuf] = NULL;
-                    ptr12[ibuf1] = NULL;
-                }
-                if( ptr21[j] != NULL )
-                {
-                    ptr22[ibuf] = ptr21[j]->next_v1;
-                    ptr22[ibuf1] = ptr21[j]->next_v2;
-                }
-                else
-                {
-                    ptr22[ibuf] = NULL;
-                    ptr22[ibuf1] = NULL;
-                }
-                ibuf += 2;
-            }
-        }
-        i = ibuf;
-    }
-    while( i > 0 && match_v < threshold );
-
-    return match_v;
-}
diff --git a/modules/legacy/src/correspond.cpp b/modules/legacy/src/correspond.cpp
deleted file mode 100644 (file)
index b1c630e..0000000
+++ /dev/null
@@ -1,398 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-#include "_vm.h"
-#include <stdlib.h>
-#include <assert.h>
-
-
-/*======================================================================================*/
-
-CvStatus
-icvDynamicCorrespond( int *first,       /* first sequence of runs */
-                      /* s0|w0|s1|w1|...|s(n-1)|w(n-1)|sn */
-                      int first_runs,   /* number of runs */
-                      int *second,      /* second sequence of runs */
-                      int second_runs, int *first_corr, /* s0'|e0'|s1'|e1'|... */
-                      int *second_corr )
-{
-
-    float Pd, Fi, S;
-    float Occlusion;
-    float *costTable;
-    uchar *matchEdges;
-    int prev;
-    int curr;
-    int baseIndex;
-    int i, j;
-    int i_1, j_1;
-    int n;
-    int l_beg, r_beg, l_end, r_end, l_len, r_len;
-    int first_curr;
-    int second_curr;
-    int l_color, r_color;
-    int len_color;
-    float cost, cost1;
-    float min1, min2, min3;
-    float cmin;
-    uchar cpath;
-    int row_size;
-
-    /* Test arguments for errors */
-
-    if( (first == 0) ||
-        (first_runs < 1) ||
-        (second == 0) || (second_runs < 1) || (first_corr == 0) || (second_corr == 0) )
-
-        return CV_BADFACTOR_ERR;
-
-
-    Pd = 0.95f;
-    Fi = (float) CV_PI;
-    S = 1;
-
-    Occlusion = (float) log( Pd * Fi / ((1 - Pd) * sqrt( fabs( (CV_PI * 2) * (1. / S) ))));
-
-    costTable = (float *)cvAlloc( (first_runs + 1) * (second_runs + 1) * sizeof( float ));
-
-    if( costTable == 0 )
-        return CV_OUTOFMEM_ERR;
-
-    matchEdges = (uchar *)cvAlloc( (first_runs + 1) * (second_runs + 1) * sizeof( uchar ));
-
-    if( matchEdges == 0 )
-    {
-        cvFree( &costTable );
-        return CV_OUTOFMEM_ERR;
-    }
-
-    row_size = first_runs + 1;
-
-    /* ============= Fill costTable ============= */
-
-    costTable[0] = 0.0f;
-
-    /* Fill upper line in the cost Table */
-
-    prev = first[0];
-    curr = 2;
-
-    for( n = 0; n < first_runs; n++ )
-    {
-
-        l_end = first[curr];
-        curr += 2;
-        costTable[n + 1] = costTable[n] + Occlusion * (l_end - prev);
-        prev = l_end;
-
-    }                           /* for */
-
-    /* Fill lefter line in the cost Table */
-
-    prev = second[0];
-    curr = 2;
-    baseIndex = 0;
-
-    for( n = 0; n < second_runs; n++ )
-    {
-
-        l_end = second[curr];
-        curr += 2;
-        costTable[baseIndex + row_size] = costTable[baseIndex] + Occlusion * (l_end - prev);
-        baseIndex += row_size;
-        prev = l_end;
-
-    }                           /* for */
-
-    /* Count costs in the all rest cells */
-
-    first_curr = 0;
-    second_curr = 0;
-
-    for( i = 1; i <= first_runs; i++ )
-    {
-        for( j = 1; j <= second_runs; j++ )
-        {
-
-            first_curr = (i - 1) * 2;
-            second_curr = (j - 1) * 2;
-
-            l_beg = first[first_curr];
-            first_curr++;
-            l_color = first[first_curr];
-            first_curr++;
-            l_end = first[first_curr];
-            l_len = l_end - l_beg + 1;
-
-            r_beg = second[second_curr];
-            second_curr++;
-            r_color = second[second_curr];
-            second_curr++;
-            r_end = second[second_curr];
-            r_len = r_end - r_beg + 1;
-
-            i_1 = i - 1;
-            j_1 = j - 1;
-
-            if( r_len == l_len )
-            {
-                cost = 0;
-            }
-            else
-            {
-
-                if( r_len > l_len )
-                {
-                    cost = (float) (r_len * r_len - l_len * l_len) * (1 / (r_len * l_len));
-                }
-                else
-                {
-                    cost = (float) (l_len * l_len - r_len * r_len) * (1 / (r_len * l_len));
-                }
-            }                   /* if */
-
-            len_color = r_color - l_color;
-
-            cost1 = (float) ((len_color * len_color) >> 2);
-
-            min2 = costTable[i_1 + j * row_size] + Occlusion * l_len;
-
-            min3 = costTable[i + j_1 * row_size] + Occlusion * r_len;
-
-            min1 = costTable[i_1 + j_1 * row_size] + cost + (float) cost1;
-
-            if( min1 < min2 )
-            {
-
-                if( min1 < min3 )
-                {
-                    cmin = min1;
-                    cpath = 1;
-                }
-                else
-                {
-                    cmin = min3;
-                    cpath = 3;
-                }               /* if */
-
-            }
-            else
-            {
-
-                if( min2 < min3 )
-                {
-                    cmin = min2;
-                    cpath = 2;
-                }
-                else
-                {
-                    cmin = min3;
-                    cpath = 3;
-                }               /* if */
-
-            }                   /* if */
-
-            costTable[i + j * row_size] = cmin;
-            matchEdges[i + j * row_size] = cpath;
-        }                       /* for */
-    }                           /* for */
-
-    /* =========== Reconstruct the Path =========== */
-
-    i = first_runs;
-    j = second_runs;
-
-    first_curr = i * 2 - 2;
-    second_curr = j * 2 - 2;
-
-
-    while( i > 0 && j > 0 )
-    {
-
-        /* Connect begins */
-        switch (matchEdges[i + j * row_size])
-        {
-
-        case 1:                /* to diagonal */
-
-            first_corr[first_curr] = second[second_curr];
-            first_corr[first_curr + 1] = second[second_curr + 2];
-            second_corr[second_curr] = first[first_curr];
-            second_corr[second_curr + 1] = first[first_curr + 2];
-
-            first_curr -= 2;
-            second_curr -= 2;
-            i--;
-            j--;
-
-            break;
-
-        case 2:                /* to left */
-
-            first_corr[first_curr] = second[second_curr + 2];
-            first_corr[first_curr + 1] = second[second_curr + 2];
-
-            first_curr -= 2;
-            i--;
-
-            break;
-
-        case 3:                /* to up */
-
-            second_corr[second_curr] = first[first_curr + 2];
-            second_corr[second_curr + 1] = first[first_curr + 2];
-
-            second_curr -= 2;
-            j--;
-
-            break;
-        }                       /* switch */
-    }                           /* while */
-
-    /* construct rest of horisontal path if its need */
-    while( i > 0 )
-    {
-
-        first_corr[first_curr] = second[second_curr + 2];       /* connect to begin */
-        first_corr[first_curr + 1] = second[second_curr + 2];   /* connect to begin */
-
-        first_curr -= 2;
-        i--;
-
-    }                           /* while */
-
-    /* construct rest of vertical path if its need */
-    while( j > 0 )
-    {
-
-        second_corr[second_curr] = first[first_curr + 2];
-        second_corr[second_curr + 1] = first[first_curr + 2];
-
-        second_curr -= 2;
-        j--;
-
-    }                           /* while */
-
-    cvFree( &costTable );
-    cvFree( &matchEdges );
-
-    return CV_NO_ERR;
-}                               /* icvDynamicCorrespond */
-
-
-/*======================================================================================*/
-
-static CvStatus
-icvDynamicCorrespondMulti( int lines,   /* number of scanlines */
-                           int *first,  /* s0|w0|s1|w1|...s(n-1)|w(n-1)|sn */
-                           int *first_runs,     /* numbers of runs */
-                           int *second, int *second_runs, int *first_corr,      /* s0'|e0'|s1'|e1'|... */
-                           int *second_corr )
-{
-    CvStatus error;
-
-    int currFirst;
-    int currSecond;
-    int currFirstCorr;
-    int currSecondCorr;
-    int n;
-
-    /* Test errors */
-
-    if( (lines < 1) ||
-        (first == 0) ||
-        (first_runs == 0) ||
-        (second == 0) || (second_runs == 0) || (first_corr == 0) || (second_corr == 0) )
-        return CV_BADFACTOR_ERR;
-
-    currFirst = 0;
-    currSecond = 0;
-    currFirstCorr = 0;
-    currSecondCorr = 0;
-
-    for( n = 0; n < lines; n++ )
-    {
-
-        error = icvDynamicCorrespond( &(first[currFirst]),
-                                      first_runs[n],
-                                      &(second[currSecond]),
-                                      second_runs[n],
-                                      &(first_corr[currFirstCorr]),
-                                      &(second_corr[currSecondCorr]) );
-
-        if( error != CV_NO_ERR )
-            return error;
-
-        currFirst += first_runs[n] * 2 + 1;
-        currSecond += second_runs[n] * 2 + 1;
-        currFirstCorr += first_runs[n] * 2;
-        currSecondCorr += second_runs[n] * 2;
-
-    }
-
-    return CV_NO_ERR;
-
-}                               /* icvDynamicCorrespondMulti */
-
-
-/*======================================================================================*/
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: cvDynamicCorrespondMulti
-//    Purpose: The functions
-//    Context:
-//    Parameters:
-//
-//    Notes:
-//F*/
-CV_IMPL void
-cvDynamicCorrespondMulti( int lines,    /* number of scanlines */
-                          int *first,   /* s0|w0|s1|w1|...s(n-1)|w(n-1)|sn */
-                          int *first_runs,      /* numbers of runs */
-                          int *second, int *second_runs, int *first_corr,       /* s0'|e0'|s1'|e1'|... */
-                          int *second_corr )
-{
-    IPPI_CALL( icvDynamicCorrespondMulti( lines,        /* number of scanlines */
-                                          first,        /* s0|w0|s1|w1|...s(n-1)|w(n-1)|sn */
-                                          first_runs,   /* numbers of runs */
-                                          second, second_runs, first_corr,      /* s0'|e0'|s1'|e1'|... */
-                                          second_corr ));
-}
diff --git a/modules/legacy/src/corrimages.cpp b/modules/legacy/src/corrimages.cpp
deleted file mode 100644 (file)
index 019fb01..0000000
+++ /dev/null
@@ -1,1146 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#if 0
-#include <stdio.h>
-
-/* Valery Mosyagin */
-
-/* ===== Function for find corresponding between images ===== */
-
-/* Create feature points on image and return number of them. Array points fills by found points */
-static int icvCreateFeaturePoints(IplImage *image, CvMat *points, CvMat *status)
-{
-    int foundFeaturePoints = 0;
-    IplImage *grayImage = 0;
-    IplImage *eigImage = 0;
-    IplImage *tmpImage = 0;
-    CvPoint2D32f *cornerPoints = 0;
-
-    CV_FUNCNAME( "icvFeatureCreatePoints" );
-    __BEGIN__;
-
-    /* Test for errors */
-    if( image == 0 || points == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    /* Test image size */
-    int w,h;
-    w = image->width;
-    h = image->height;
-
-    if( w <= 0 || h <= 0)
-    {
-        CV_ERROR( CV_StsOutOfRange, "Size of image must be > 0" );
-    }
-
-    /* Test for matrices */
-    if( !CV_IS_MAT(points) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameter points must be a matrix" );
-    }
-
-    int needNumPoints;
-    needNumPoints = points->cols;
-    if( needNumPoints <= 0 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of need points must be > 0" );
-    }
-
-    if( points->rows != 2 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of point coordinates must be == 2" );
-    }
-
-    if( status != 0 )
-    {
-        /* If status matrix exist test it for correct */
-        if( !CV_IS_MASK_ARR(status) )
-        {
-            CV_ERROR( CV_StsUnsupportedFormat, "Statuses must be a mask arrays" );
-        }
-
-        if( status->cols != needNumPoints )
-        {
-            CV_ERROR( CV_StsUnmatchedSizes, "Size of points and statuses must be the same" );
-        }
-
-        if( status->rows !=1 )
-        {
-            CV_ERROR( CV_StsUnsupportedFormat, "Number of rows of status must be 1" );
-        }
-    }
-
-    /* Create temporary images */
-    CV_CALL( grayImage = cvCreateImage(cvSize(w,h), 8,1) );
-    CV_CALL( eigImage   = cvCreateImage(cvSize(w,h),32,1) );
-    CV_CALL( tmpImage   = cvCreateImage(cvSize(w,h),32,1) );
-
-    /* Create points */
-    CV_CALL( cornerPoints = (CvPoint2D32f*)cvAlloc( sizeof(CvPoint2D32f) * needNumPoints) );
-
-    int foundNum;
-    double quality;
-    double minDist;
-
-    cvCvtColor(image,grayImage, CV_BGR2GRAY);
-
-    foundNum = needNumPoints;
-    quality = 0.01;
-    minDist = 5;
-    cvGoodFeaturesToTrack(grayImage, eigImage, tmpImage, cornerPoints, &foundNum, quality, minDist);
-
-    /* Copy found points to result */
-    int i;
-    for( i = 0; i < foundNum; i++ )
-    {
-        cvmSet(points,0,i,cornerPoints[i].x);
-        cvmSet(points,1,i,cornerPoints[i].y);
-    }
-
-    /* Set status if need */
-    if( status )
-    {
-        for( i = 0; i < foundNum; i++ )
-        {
-            status->data.ptr[i] = 1;
-        }
-
-        for( i = foundNum; i < needNumPoints; i++ )
-        {
-            status->data.ptr[i] = 0;
-        }
-    }
-
-    foundFeaturePoints = foundNum;
-
-    __END__;
-
-    /* Free allocated memory */
-    cvReleaseImage(&grayImage);
-    cvReleaseImage(&eigImage);
-    cvReleaseImage(&tmpImage);
-    cvFree(&cornerPoints);
-
-    return foundFeaturePoints;
-}
-
-/*-------------------------------------------------------------------------------------*/
-
-/* For given points1 (with pntStatus) on image1 finds corresponding points2 on image2 and set pntStatus2 for them */
-/* Returns number of corresponding points */
-static int icvFindCorrForGivenPoints( IplImage *image1,/* Image 1 */
-                                IplImage *image2,/* Image 2 */
-                                CvMat *points1,
-                                CvMat *pntStatus1,
-                                CvMat *points2,
-                                CvMat *pntStatus2,
-                                int useFilter,/*Use fundamental matrix to filter points */
-                                double threshold)/* Threshold for good points in filter */
-{
-    int resNumCorrPoints = 0;
-    CvPoint2D32f* cornerPoints1 = 0;
-    CvPoint2D32f* cornerPoints2 = 0;
-    char*  status = 0;
-    float* errors = 0;
-    CvMat* tmpPoints1 = 0;
-    CvMat* tmpPoints2 = 0;
-    CvMat* pStatus = 0;
-    IplImage *grayImage1 = 0;
-    IplImage *grayImage2 = 0;
-    IplImage *pyrImage1 = 0;
-    IplImage *pyrImage2 = 0;
-
-    CV_FUNCNAME( "icvFindCorrForGivenPoints" );
-    __BEGIN__;
-
-    /* Test input data for errors */
-
-    /* Test for null pointers */
-    if( image1     == 0 || image2     == 0 ||
-        points1    == 0 || points2    == 0 ||
-        pntStatus1 == 0 || pntStatus2 == 0)
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    /* Test image size */
-    int w,h;
-    w = image1->width;
-    h = image1->height;
-
-    if( w <= 0 || h <= 0)
-    {
-        CV_ERROR( CV_StsOutOfRange, "Size of image1 must be > 0" );
-    }
-
-    if( image2->width != w || image2->height != h )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of images must be the same" );
-    }
-
-    /* Test for matrices */
-    if( !CV_IS_MAT(points1)    || !CV_IS_MAT(points2) ||
-        !CV_IS_MAT(pntStatus1) || !CV_IS_MAT(pntStatus2) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters (points and status) must be a matrices" );
-    }
-
-    /* Test type of status matrices */
-    if( !CV_IS_MASK_ARR(pntStatus1) || !CV_IS_MASK_ARR(pntStatus2) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Statuses must be a mask arrays" );
-    }
-
-    /* Test number of points */
-    int numPoints;
-    numPoints = points1->cols;
-
-    if( numPoints <= 0 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points1 must be > 0" );
-    }
-
-    if( points2->cols != numPoints || pntStatus1->cols != numPoints || pntStatus2->cols != numPoints )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of points and statuses must be the same" );
-    }
-
-    if( points1->rows != 2 || points2->rows != 2 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points coordinates must be 2" );
-    }
-
-    if( pntStatus1->rows != 1 || pntStatus2->rows != 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Status must be a matrix 1xN" );
-    }
-    /* ----- End test ----- */
-
-
-    /* Compute number of visible points on image1 */
-    int numVisPoints;
-    numVisPoints = cvCountNonZero(pntStatus1);
-
-    if( numVisPoints > 0 )
-    {
-        /* Create temporary images */
-        /* We must use iplImage againts hughgui images */
-
-/*
-        CvvImage grayImage1;
-        CvvImage grayImage2;
-        CvvImage pyrImage1;
-        CvvImage pyrImage2;
-*/
-
-        /* Create Ipl images */
-        CV_CALL( grayImage1 = cvCreateImage(cvSize(w,h),8,1) );
-        CV_CALL( grayImage2 = cvCreateImage(cvSize(w,h),8,1) );
-        CV_CALL( pyrImage1  = cvCreateImage(cvSize(w,h),8,1) );
-        CV_CALL( pyrImage2  = cvCreateImage(cvSize(w,h),8,1) );
-
-        CV_CALL( cornerPoints1 = (CvPoint2D32f*)cvAlloc( sizeof(CvPoint2D32f)*numVisPoints) );
-        CV_CALL( cornerPoints2 = (CvPoint2D32f*)cvAlloc( sizeof(CvPoint2D32f)*numVisPoints) );
-        CV_CALL( status = (char*)cvAlloc( sizeof(char)*numVisPoints) );
-        CV_CALL( errors = (float*)cvAlloc( 2 * sizeof(float)*numVisPoints) );
-
-        int i;
-        for( i = 0; i < numVisPoints; i++ )
-        {
-            status[i] = 1;
-        }
-
-        /* !!! Need test creation errors */
-        /*
-        if( !grayImage1.Create(w,h,8)) EXIT;
-        if( !grayImage2.Create(w,h,8)) EXIT;
-        if( !pyrImage1. Create(w,h,8)) EXIT;
-        if( !pyrImage2. Create(w,h,8)) EXIT;
-        */
-
-        cvCvtColor(image1,grayImage1,CV_BGR2GRAY);
-        cvCvtColor(image2,grayImage2,CV_BGR2GRAY);
-
-        /*
-        grayImage1.CopyOf(image1,0);
-        grayImage2.CopyOf(image2,0);
-        */
-
-        /* Copy points good points from input data */
-        uchar *stat1 = pntStatus1->data.ptr;
-        uchar *stat2 = pntStatus2->data.ptr;
-
-        int curr = 0;
-        for( i = 0; i < numPoints; i++ )
-        {
-            if( stat1[i] )
-            {
-                cornerPoints1[curr].x = (float)cvmGet(points1,0,i);
-                cornerPoints1[curr].y = (float)cvmGet(points1,1,i);
-                curr++;
-            }
-        }
-
-        /* Define number of levels of pyramid */
-        cvCalcOpticalFlowPyrLK( grayImage1, grayImage2,
-                                pyrImage1, pyrImage2,
-                                cornerPoints1, cornerPoints2,
-                                numVisPoints, cvSize(10,10), 3,
-                                status, errors,
-                                cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,20,0.03),
-                                0/*CV_LKFLOW_PYR_A_READY*/ );
-
-
-        memset(stat2,0,sizeof(uchar)*numPoints);
-
-        int currVis = 0;
-        int totalCorns = 0;
-
-        /* Copy new points and set status */
-        /* stat1 may not be the same as stat2 */
-        for( i = 0; i < numPoints; i++ )
-        {
-            if( stat1[i] )
-            {
-                if( status[currVis] && errors[currVis] < 1000 )
-                {
-                    stat2[i] = 1;
-                    cvmSet(points2,0,i,cornerPoints2[currVis].x);
-                    cvmSet(points2,1,i,cornerPoints2[currVis].y);
-                    totalCorns++;
-                }
-                currVis++;
-            }
-        }
-
-        resNumCorrPoints = totalCorns;
-
-        /* Filter points using RANSAC */
-        if( useFilter )
-        {
-            resNumCorrPoints = 0;
-            /* Use RANSAC filter for found points */
-            if( totalCorns > 7 )
-            {
-                /* Create array with good points only */
-                CV_CALL( tmpPoints1 = cvCreateMat(2,totalCorns,CV_64F) );
-                CV_CALL( tmpPoints2 = cvCreateMat(2,totalCorns,CV_64F) );
-
-                /* Copy just good points */
-                int currPoint = 0;
-                for( i = 0; i < numPoints; i++ )
-                {
-                    if( stat2[i] )
-                    {
-                        cvmSet(tmpPoints1,0,currPoint,cvmGet(points1,0,i));
-                        cvmSet(tmpPoints1,1,currPoint,cvmGet(points1,1,i));
-
-                        cvmSet(tmpPoints2,0,currPoint,cvmGet(points2,0,i));
-                        cvmSet(tmpPoints2,1,currPoint,cvmGet(points2,1,i));
-
-                        currPoint++;
-                    }
-                }
-
-                /* Compute fundamental matrix */
-                CvMat fundMatr;
-                double fundMatr_dat[9];
-                fundMatr = cvMat(3,3,CV_64F,fundMatr_dat);
-
-                CV_CALL( pStatus = cvCreateMat(1,totalCorns,CV_32F) );
-
-                int num = cvFindFundamentalMat(tmpPoints1,tmpPoints2,&fundMatr,CV_FM_RANSAC,threshold,0.99,pStatus);
-                if( num > 0 )
-                {
-                    int curr = 0;
-                    /* Set final status for points2 */
-                    for( i = 0; i < numPoints; i++ )
-                    {
-                        if( stat2[i] )
-                        {
-                            if( cvmGet(pStatus,0,curr) == 0 )
-                            {
-                                stat2[i] = 0;
-                            }
-                            curr++;
-                        }
-                    }
-                    resNumCorrPoints = curr;
-                }
-            }
-        }
-    }
-
-    __END__;
-
-    /* Free allocated memory */
-    cvFree(&cornerPoints1);
-    cvFree(&cornerPoints2);
-    cvFree(&status);
-    cvFree(&errors);
-    cvFree(&tmpPoints1);
-    cvFree(&tmpPoints2);
-    cvReleaseMat( &pStatus );
-    cvReleaseImage( &grayImage1 );
-    cvReleaseImage( &grayImage2 );
-    cvReleaseImage( &pyrImage1 );
-    cvReleaseImage( &pyrImage2 );
-
-    return resNumCorrPoints;
-}
-
-/*-------------------------------------------------------------------------------------*/
-static int icvGrowPointsAndStatus(CvMat **oldPoints,CvMat **oldStatus,CvMat *addPoints,CvMat *addStatus,int addCreateNum)
-{
-    /* Add to existing points and status arrays new points or just grow */
-    CvMat *newOldPoint  = 0;
-    CvMat *newOldStatus = 0;
-    int newTotalNumber = 0;
-
-    CV_FUNCNAME( "icvGrowPointsAndStatus" );
-    __BEGIN__;
-
-    /* Test for errors */
-    if( oldPoints == 0 || oldStatus == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( *oldPoints == 0 || *oldStatus == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(*oldPoints))
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "oldPoints must be a pointer to a matrix" );
-    }
-
-    if( !CV_IS_MASK_ARR(*oldStatus))
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "oldStatus must be a pointer to a mask array" );
-    }
-
-    int oldNum;
-    oldNum = (*oldPoints)->cols;
-    if( oldNum < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of old points must be > 0" );
-    }
-
-    /* Define if need number of add points */
-    int addNum;
-    addNum = 0;
-    if( addPoints != 0 && addStatus != 0 )
-    {/* We have aditional points */
-        if( CV_IS_MAT(addPoints) && CV_IS_MASK_ARR(addStatus) )
-        {
-            addNum = addPoints->cols;
-            if( addStatus->cols != addNum )
-            {
-                CV_ERROR( CV_StsOutOfRange, "Number of add points and statuses must be the same" );
-            }
-        }
-    }
-
-    /*  */
-
-    int numCoord;
-    numCoord = (*oldPoints)->rows;
-    newTotalNumber = oldNum + addNum + addCreateNum;
-
-    if( newTotalNumber )
-    {
-        /* Free allocated memory */
-        newOldPoint  = cvCreateMat(numCoord,newTotalNumber,CV_64F);
-        newOldStatus = cvCreateMat(1,newTotalNumber,CV_8S);
-
-        /* Copy old values to  */
-        int i;
-
-        /* Clear all values */
-        cvZero(newOldPoint);
-        cvZero(newOldStatus);
-
-        for( i = 0; i < oldNum; i++ )
-        {
-            int currCoord;
-            for( currCoord = 0; currCoord < numCoord; currCoord++ )
-            {
-                cvmSet(newOldPoint,currCoord,i,cvmGet(*oldPoints,currCoord,i));
-            }
-            newOldStatus->data.ptr[i] = (*oldStatus)->data.ptr[i];
-        }
-
-        /* Copy additional points and statuses */
-        if( addNum )
-        {
-            for( i = 0; i < addNum; i++ )
-            {
-                int currCoord;
-                for( currCoord = 0; currCoord < numCoord; currCoord++ )
-                {
-                    cvmSet(newOldPoint,currCoord,i+oldNum,cvmGet(addPoints,currCoord,i));
-                }
-                newOldStatus->data.ptr[i+oldNum] = addStatus->data.ptr[i];
-                //cvmSet(newOldStatus,0,i,cvmGet(addStatus,0,i));
-            }
-        }
-
-        /* Delete previous data */
-        cvReleaseMat(oldPoints);
-        cvReleaseMat(oldStatus);
-
-        /* copy pointers */
-        *oldPoints  = newOldPoint;
-        *oldStatus = newOldStatus;
-
-    }
-    __END__;
-
-    return newTotalNumber;
-}
-
-/*-------------------------------------------------------------------------------------*/
-static int icvRemoveDoublePoins(   CvMat *oldPoints,/* Points on prev image */
-                            CvMat *newPoints,/* New points */
-                            CvMat *oldStatus,/* Status for old points */
-                            CvMat *newStatus,
-                            CvMat *origStatus,
-                            float threshold)/* Status for new points */
-{
-
-    CvMemStorage* storage = 0;
-    CvSubdiv2D* subdiv = 0;
-    CvSeq* seq = 0;
-
-    int originalPoints = 0;
-
-    CV_FUNCNAME( "icvRemoveDoublePoins" );
-    __BEGIN__;
-
-    /* Test input data */
-    if( oldPoints == 0 || newPoints == 0 ||
-        oldStatus == 0 || newStatus == 0 || origStatus == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(oldPoints) || !CV_IS_MAT(newPoints) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters points must be a matrices" );
-    }
-
-    if( !CV_IS_MASK_ARR(oldStatus) || !CV_IS_MASK_ARR(newStatus) || !CV_IS_MASK_ARR(origStatus) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters statuses must be a mask array" );
-    }
-
-    int oldNumPoints;
-    oldNumPoints = oldPoints->cols;
-    if( oldNumPoints < 0 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of oldPoints must be >= 0" );
-    }
-
-    if( oldStatus->cols != oldNumPoints )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of old Points and old Statuses must be the same" );
-    }
-
-    int newNumPoints;
-    newNumPoints = newPoints->cols;
-    if( newNumPoints < 0 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of newPoints must be >= 0" );
-    }
-
-    if( newStatus->cols != newNumPoints )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of new Points and new Statuses must be the same" );
-    }
-
-    if( origStatus->cols != newNumPoints )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of new Points and new original Status must be the same" );
-    }
-
-    if( oldPoints->rows != 2)
-    {
-        CV_ERROR( CV_StsOutOfRange, "OldPoints must have 2 coordinates >= 0" );
-    }
-
-    if( newPoints->rows != 2)
-    {
-        CV_ERROR( CV_StsOutOfRange, "NewPoints must have 2 coordinates >= 0" );
-    }
-
-    if( oldStatus->rows != 1 || newStatus->rows != 1 || origStatus->rows != 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Statuses must have 1 row" );
-    }
-
-    /* we have points on image and wants add new points */
-    /* use subdivision for find nearest points */
-
-    /* Define maximum and minimum X and Y */
-    float minX,minY;
-    float maxX,maxY;
-
-    minX = minY = FLT_MAX;
-    maxX = maxY = FLT_MIN;
-
-    int i;
-
-    for( i = 0; i < oldNumPoints; i++ )
-    {
-        if( oldStatus->data.ptr[i] )
-        {
-            float x = (float)cvmGet(oldPoints,0,i);
-            float y = (float)cvmGet(oldPoints,1,i);
-
-            if( x < minX )
-                minX = x;
-
-            if( x > maxX )
-                maxX = x;
-
-            if( y < minY )
-                minY = y;
-
-            if( y > maxY )
-                maxY = y;
-        }
-    }
-
-    for( i = 0; i < newNumPoints; i++ )
-    {
-        if( newStatus->data.ptr[i] )
-        {
-            float x = (float)cvmGet(newPoints,0,i);
-            float y = (float)cvmGet(newPoints,1,i);
-
-            if( x < minX )
-                minX = x;
-
-            if( x > maxX )
-                maxX = x;
-
-            if( y < minY )
-                minY = y;
-
-            if( y > maxY )
-                maxY = y;
-        }
-    }
-
-
-    /* Creare subdivision for old image */
-    storage = cvCreateMemStorage(0);
-//    subdiv = cvCreateSubdivDelaunay2D( cvRect( 0, 0, size.width, size.height ), storage );
-    subdiv = cvCreateSubdivDelaunay2D( cvRect( cvRound(minX)-5, cvRound(minY)-5, cvRound(maxX-minX)+10, cvRound(maxY-minY)+10 ), storage );
-    seq = cvCreateSeq( 0, sizeof(*seq), sizeof(CvPoint2D32f), storage );
-
-    /* Insert each point from first image */
-    for( i = 0; i < oldNumPoints; i++ )
-    {
-        /* Add just exist points */
-        if( oldStatus->data.ptr[i] )
-        {
-            CvPoint2D32f pt;
-            pt.x = (float)cvmGet(oldPoints,0,i);
-            pt.y = (float)cvmGet(oldPoints,1,i);
-
-            cvSubdivDelaunay2DInsert( subdiv, pt );
-        }
-    }
-
-
-    /* Find nearest points */
-    /* for each new point */
-    int flag;
-    for( i = 0; i < newNumPoints; i++ )
-    {
-        flag = 0;
-        /* Test just exist points */
-        if( newStatus->data.ptr[i] )
-        {
-            flag = 1;
-            /* Let this is a good point */
-            //originalPoints++;
-
-            CvPoint2D32f pt;
-
-            pt.x = (float)cvmGet(newPoints,0,i);
-            pt.y = (float)cvmGet(newPoints,1,i);
-
-            CvSubdiv2DPoint* point = cvFindNearestPoint2D( subdiv, pt );
-
-            if( point )
-            {
-                /* Test distance of found nearest point */
-                double minDistance = icvSqDist2D32f( pt, point->pt );
-
-                if( minDistance < threshold*threshold )
-                {
-                    /* Point is double. Turn it off */
-                    /* Set status */
-                    //newStatus->data.ptr[i] = 0;
-
-                    /* No this is a double point */
-                    //originalPoints--;
-                    flag = 0;
-                }
-            }
-        }
-        originalPoints += flag;
-        origStatus->data .ptr[i] = (uchar)flag;
-    }
-
-    __END__;
-
-    cvReleaseMemStorage( &storage );
-
-
-    return originalPoints;
-
-
-}
-
-void icvComputeProjectMatrix(CvMat* objPoints,CvMat* projPoints,CvMat* projMatr);
-
-/*-------------------------------------------------------------------------------------*/
-static void icvComputeProjectMatrixStatus(CvMat *objPoints4D,CvMat *points2,CvMat *status, CvMat *projMatr)
-{
-    /* Compute number of good points */
-    int num = cvCountNonZero(status);
-
-    /* Create arrays */
-    CvMat *objPoints = 0;
-    objPoints = cvCreateMat(4,num,CV_64F);
-
-    CvMat *points2D = 0;
-    points2D = cvCreateMat(2,num,CV_64F);
-
-    int currVis = 0;
-    int i;
-#if 1
-    FILE *file;
-    file = fopen("d:\\test\\projStatus.txt","w");
-#endif
-    int totalNum = objPoints4D->cols;
-    for( i = 0; i < totalNum; i++ )
-    {
-        fprintf(file,"%d (%d) ",i,status->data.ptr[i]);
-        if( status->data.ptr[i] )
-        {
-
-#if 1
-            double X,Y,Z,W;
-            double x,y;
-            X = cvmGet(objPoints4D,0,i);
-            Y = cvmGet(objPoints4D,1,i);
-            Z = cvmGet(objPoints4D,2,i);
-            W = cvmGet(objPoints4D,3,i);
-
-            x = cvmGet(points2,0,i);
-            y = cvmGet(points2,1,i);
-            fprintf(file,"%d (%lf %lf %lf %lf) - (%lf %lf)",i,X,Y,Z,W,x,y );
-#endif
-            cvmSet(objPoints,0,currVis,cvmGet(objPoints4D,0,i));
-            cvmSet(objPoints,1,currVis,cvmGet(objPoints4D,1,i));
-            cvmSet(objPoints,2,currVis,cvmGet(objPoints4D,2,i));
-            cvmSet(objPoints,3,currVis,cvmGet(objPoints4D,3,i));
-
-            cvmSet(points2D,0,currVis,cvmGet(points2,0,i));
-            cvmSet(points2D,1,currVis,cvmGet(points2,1,i));
-
-            currVis++;
-        }
-
-        fprintf(file,"\n");
-    }
-
-#if 1
-    fclose(file);
-#endif
-
-    icvComputeProjectMatrix(objPoints,points2D,projMatr);
-
-    /* Free allocated memory */
-    cvReleaseMat(&objPoints);
-    cvReleaseMat(&points2D);
-}
-
-
-
-/*-------------------------------------------------------------------------------------*/
-/* For given N images
- we have corresponding points on N images
- computed projection matrices
- reconstructed 4D points
-
-  we must to compute
-
-
-*/
-static void icvAddNewImageToPrevious____(
-                                    IplImage *newImage,//Image to add
-                                    IplImage *oldImage,//Previous image
-                                    CvMat *oldPoints,// previous 2D points on prev image (some points may be not visible)
-                                    CvMat *oldPntStatus,//Status for each point on prev image
-                                    CvMat *objPoints4D,//prev 4D points
-                                    CvMat *newPoints,  //Points on new image corr for prev
-                                    CvMat *newPntStatus,// New point status for new image
-                                    CvMat *newFPoints2D1,//new feature points on prev image
-                                    CvMat *newFPoints2D2,//new feature points on new image
-                                    CvMat *newFPointsStatus,
-                                    CvMat *newProjMatr,
-                                    int useFilter,
-                                    double threshold)//New projection matrix
-{
-    CvMat *points2 = 0;
-    CvMat *status = 0;
-    CvMat *newFPointsStatusTmp = 0;
-
-    //CV_FUNCNAME( "icvAddNewImageToPrevious____" );
-    __BEGIN__;
-
-    /* First found correspondence points for images */
-
-    /* Test input params */
-
-    int numPoints;
-    numPoints = oldPoints->cols;
-
-    /* Allocate memory */
-
-    points2 = cvCreateMat(2,numPoints,CV_64F);
-    status = cvCreateMat(1,numPoints,CV_8S);
-    newFPointsStatusTmp = cvCreateMat(1, newFPoints2D1->cols,CV_8S);
-
-    int corrNum;
-    corrNum = icvFindCorrForGivenPoints(    oldImage,/* Image 1 */
-                                            newImage,/* Image 2 */
-                                            oldPoints,
-                                            oldPntStatus,
-                                            points2,
-                                            status,
-                                            useFilter,/*Use fundamental matrix to filter points */
-                                            threshold);/* Threshold for good points in filter */
-
-    cvCopy(status,newPntStatus);
-    cvCopy(points2,newPoints);
-
-    CvMat projMatr;
-    double projMatr_dat[12];
-    projMatr = cvMat(3,4,CV_64F,projMatr_dat);
-
-    if( corrNum >= 6 )
-    {/* We can compute projection matrix */
-//        icvComputeProjectMatrix(objPoints4D,points2,&projMatr);
-        icvComputeProjectMatrixStatus(objPoints4D,points2,status,&projMatr);
-        cvCopy(&projMatr,newProjMatr);
-
-        /* Create new points and find correspondence */
-        icvCreateFeaturePoints(newImage, newFPoints2D2,newFPointsStatus);
-
-        /* Good if we test new points before find corr points */
-
-        /* Find correspondence for new found points */
-        icvFindCorrForGivenPoints( newImage,/* Image 1 */
-                                   oldImage,/* Image 2 */
-                                   newFPoints2D2,
-                                   newFPointsStatus,//prev status
-                                   newFPoints2D1,
-                                   newFPointsStatusTmp,//new status
-                                   useFilter,/*Use fundamental matrix to filter points */
-                                   threshold);/* Threshold for good points in filter */
-
-        /* We generated new points on image test for exist points */
-
-        /* Remove all new double points */
-
-        /* Find point of old image */
-        icvRemoveDoublePoins( oldPoints,/* Points on prev image */
-                              newFPoints2D1,/* New points */
-                              oldPntStatus,/* Status for old points */
-                              newFPointsStatusTmp,
-                              newFPointsStatusTmp,//orig status
-                              20);/* Status for new points */
-
-        /* Find double points on new image */
-        icvRemoveDoublePoins( newPoints,/* Points on prev image */
-                              newFPoints2D2,/* New points */
-                              newPntStatus,/* Status for old points */
-                              newFPointsStatusTmp,
-                              newFPointsStatusTmp,//orig status
-                              20);/* Status for new points */
-
-
-
-        /* Add all new good points to result */
-
-
-        /* Copy new status to old */
-        cvCopy(newFPointsStatusTmp,newFPointsStatus);
-
-
-    }
-
-
-
-    __END__;
-
-    /* Free allocated memory */
-
-    return;
-}
-/*-------------------------------------------------------------------------------------*/
-//int icvDelete//
-//CreateGood
-
-/*-------------------------------------------------------------------------------------*/
-static int icvDeleteSparsInPoints(  int numImages,
-                             CvMat **points,
-                             CvMat **status,
-                             CvMat *wasStatus)/* status of previous configuration */
-{
-    /* Delete points which no exist on any of images */
-    /* numImages - number of images */
-    /* points - arrays of points for each image. Changing */
-    /* status - arrays of status for each image. Changing */
-    /* Function returns number of common points */
-
-    int comNumber = 0;
-    CV_FUNCNAME( "icvDeleteSparsInPoints" );
-    __BEGIN__;
-
-    /* Test for errors */
-    if( numImages < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of images must be more than 0" );
-    }
-
-    if( points == 0 || status == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-    int numPoints;
-
-    numPoints = points[0]->cols;
-    ////////// TESTS //////////
-
-    int numCoord;
-    numCoord = points[0]->rows;// !!! may be number of coordinates is not correct !!!
-
-    int i;
-    int currExistPoint;
-    currExistPoint = 0;
-
-    if( wasStatus )
-    {
-        cvZero(wasStatus);
-    }
-
-    int currImage;
-    for( i = 0; i < numPoints; i++ )
-    {
-        int flag = 0;
-        for( currImage = 0; currImage < numImages; currImage++ )
-        {
-            flag |= status[currImage]->data.ptr[i];
-        }
-
-        if( flag )
-        {
-            /* Current point exists */
-            /* Copy points and status */
-            if( currExistPoint != i )/* Copy just if different */
-            {
-                for( currImage = 0; currImage < numImages; currImage++ )
-                {
-                    /* Copy points */
-                    for( int currCoord = 0; currCoord < numCoord; currCoord++ )
-                    {
-                        cvmSet(points[currImage],currCoord,currExistPoint, cvmGet(points[currImage],currCoord,i) );
-                    }
-
-                    /* Copy status */
-                    status[currImage]->data.ptr[currExistPoint] = status[currImage]->data.ptr[i];
-                }
-            }
-            if( wasStatus )
-            {
-                wasStatus->data.ptr[i] = 1;
-            }
-
-            currExistPoint++;
-
-        }
-    }
-
-    /* Rest of final status of points must be set to 0  */
-    for( i = currExistPoint; i < numPoints; i++ )
-    {
-        for( currImage = 0; currImage < numImages; currImage++ )
-        {
-            status[currImage]->data.ptr[i] = 0;
-        }
-    }
-
-    comNumber = currExistPoint;
-
-    __END__;
-    return comNumber;
-}
-
-
-/*-------------------------------------------------------------------------------------*/
-void icvGrowPointsArray(CvMat **points)
-{
-
-
-}
-
-/*-------------------------------------------------------------------------------------*/
-void icvAddNewArrayPoints()
-{
-
-}
-
-/*-------------------------------------------------------------------------------------*/
-#endif
-
-//////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////
-
-/* Add image to existing images and corr points */
-#if 0
-/* Returns: 1 if new image was added good */
-/*          0 image was not added. Not enought corr points */
-int AddImageToStruct(  IplImage *newImage,//Image to add
-                        IplImage *oldImage,//Previous image
-                        CvMat *oldPoints,// previous 2D points on prev image (some points may be not visible)
-                        CvMat *oldPntStatus,//Status for each point on prev image
-                        CvMat *objPoints4D,//prev 4D points
-                        CvMat *newPntStatus,// New point status for new image
-                        CvMat *newPoints,//New corresponding points on new image
-                        CvMat *newPoints2D1,//new points on prev image
-                        CvMat *newPoints2D2,//new points on new image
-                        CvMat *newProjMatr);//New projection matrix
-{
-
-    /* Add new image. Create new corr points */
-    /* Track exist points from oldImage to newImage */
-    /* Create new vector status */
-    CvMat *status;
-    int numPoints = oldPoints->cols;
-    status = cvCreateMat(1,numPoints,CV_64F);
-    /* Copy status */
-    cvConvert(pntStatus,status);
-
-    int corrNum = FindCorrForGivenPoints(oldImage,newImage,oldPoints,newPoints,status);
-
-    /* Status has new status of points */
-
-    CvMat projMatr;
-    double projMatr_dat[12];
-    projMatr = cvMat(3,4,CV_64F,projMatr_dat);
-
-    /* If number of corr points is 6 or more can compute projection matrix */
-    if( corrNum >= 6)
-    {
-        /* Compute projection matrix for new image using corresponding points */
-        icvComputeProjectMatrix(objPoints4D,newPoints,&projMatr);
-
-        CvMat *tmpPoints;
-        /* Create new points and find correspondence */
-        int num = FindFeaturePoints(newImage, &tmpPoints);
-        if( num > 0 )
-        {
-            CvMat *newPoints;
-            newPoints = cvCreateMat(2,num,CV_64F);
-            CvMat *status;
-            status = cvCreateMat(1,num,CV_64F);
-            /* Set status for all points */
-            int i;
-            for( i = 0; i < num; i++ )
-            {
-                cvmSet(status,0,i,1.0);
-            }
-
-            int corrNum2 = FindCorrForGivenPoints(oldImage,newImage,tmpPoints,newPoints,status);
-
-            /* !!! Filter points using projection matrices or not ??? */
-
-            /* !!! Need to filter nearest points */
-
-            /* Add new found points to exist points and optimize again */
-            CvMat *new2DPoints;
-            CvMat *newStatus;
-
-            /* add new status to old status */
-
-
-
-
-
-        }
-        else
-        {
-            /* No new points were found */
-        }
-    }
-    else
-    {
-        /* We can't compute projection matrix for new image */
-        return 0;
-    }
-
-}
-#endif
diff --git a/modules/legacy/src/createhandmask.cpp b/modules/legacy/src/createhandmask.cpp
deleted file mode 100644 (file)
index 7936718..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-#define CV_MAX2( a, b ) ((a)>(b) ? (a) : (b))
-#define CV_MIN2( a, b ) ((a)<(b) ? (a) : (b))
-
-/****************************************************************************************\
-
-   create hand mask
-
-\****************************************************************************************/
-
-static CvStatus icvCreateHandMask8uC1R(CvSeq * numbers,
-                                       uchar * image_mask, int step,
-                                       CvSize size, CvRect * roi )
-{
-
-    CvSeqReader reader;
-    CvPoint pt;
-    int k_point;
-    int i_min, i_max, j_min, j_max;
-
-    if( numbers == NULL )
-        return CV_NULLPTR_ERR;
-
-    if( !CV_IS_SEQ_POINT_SET( numbers ))
-        return CV_BADFLAG_ERR;
-
-    i_max = j_max = 0;
-    i_min = size.height;
-    j_min = size.width;
-
-    cvStartReadSeq( numbers, &reader, 0 );
-
-    k_point = numbers->total;
-    assert( k_point > 0 );
-    if( k_point <= 0 )
-        return CV_BADSIZE_ERR;
-
-    memset( image_mask, 0, step * size.height );
-
-    while( k_point-- > 0 )
-    {
-        CV_READ_SEQ_ELEM( pt, reader );
-
-        i_min = CV_MIN2( i_min, pt.y );
-        i_max = CV_MAX2( i_max, pt.y );
-        j_min = CV_MIN2( j_min, pt.x );
-        j_max = CV_MAX2( j_max, pt.x );
-
-        *(image_mask + pt.y * step + pt.x) = 255;
-    }
-
-    roi->x = j_min;
-    roi->y = i_min;
-    roi->width = j_max - j_min + 1;
-    roi->height = i_max - i_min + 1;
-
-    return CV_OK;
-
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name:     cvCreateHandMask
-//    Purpose:  creates hand mask image
-//    Context:
-//    Parameters:
-//      numbers - pointer to the input sequence of the point's indexes inside
-//                hand region
-//      img_mask - pointer to the result mask image
-//      roi      - result hand mask ROI
-//
-//    Notes:
-//F*/
-CV_IMPL void
-cvCreateHandMask( CvSeq * numbers, IplImage * img_mask, CvRect * roi )
-{
-    uchar *img_mask_data = 0;
-    int img_mask_step = 0;
-    CvSize img_mask_size;
-
-    CV_FUNCNAME( "cvCreateHandMask" );
-
-    __BEGIN__;
-
-    if( img_mask->depth != IPL_DEPTH_8U )
-        CV_ERROR( CV_BadDepth, "Unsupported format" );
-
-    if( img_mask->nChannels != 1 )
-        CV_ERROR( CV_BadNumChannels, "output image have wrong number of channels" );
-
-    cvGetImageRawData( img_mask, &img_mask_data, &img_mask_step, &img_mask_size );
-
-    IPPI_CALL( icvCreateHandMask8uC1R( numbers, img_mask_data,
-                                        img_mask_step, img_mask_size, roi ));
-
-    __END__;
-}
diff --git a/modules/legacy/src/decomppoly.cpp b/modules/legacy/src/decomppoly.cpp
deleted file mode 100644 (file)
index 0cb1055..0000000
+++ /dev/null
@@ -1,628 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#if 0
-
-#include <malloc.h>
-//#include "decomppoly.h"
-
-#define ZERO_CLOSE 0.00001f
-#define ONE_CLOSE  0.99999f
-
-#define CHECK_COLLINEARITY(vec1_x,vec1_y,vec2_x,vec2_y) \
-    if( vec1_x == 0 ) {                                 \
-        if( vec1_y * vec2_y > 0 ) {                     \
-            return 0;                                   \
-        }                                               \
-    }                                                   \
-    else {                                              \
-        if( vec1_x * vec2_x > 0 ) {                     \
-            return 0;                                   \
-        }                                               \
-    }
-
-// determines if edge number one lies in counterclockwise
-//  earlier than edge number two
-inline int  icvIsFirstEdgeClosier( int x0,
-                                   int y0,
-                                   int x0_end,
-                                   int y0_end,
-                                   int x1_end,
-                                   int y1_end,
-                                   int x2_end,
-                                   int y2_end )
-{
-    int mult, mult1, mult2;
-    int vec0_x, vec0_y;
-    int vec1_x, vec1_y;
-    int vec2_x, vec2_y;
-
-    vec0_x = x0_end - x0;
-    vec0_y = y0_end - y0;
-    vec1_x = x1_end - x0;
-    vec1_y = y1_end - y0;
-    vec2_x = x2_end - x0;
-    vec2_y = y2_end - y0;
-
-    mult1 = vec1_x * vec0_y - vec0_x * vec1_y;
-    mult2 = vec2_x * vec0_y - vec0_x * vec2_y;
-
-    if( mult1 == 0 ) {
-        CHECK_COLLINEARITY( vec0_x, vec0_y, vec1_x, vec1_y );
-    }
-    if( mult2 == 0 ) {
-        CHECK_COLLINEARITY( vec0_x, vec0_y, vec2_x, vec2_y );
-    }
-    if( mult1 > 0 && mult2 < 0 ) {
-        return 1;
-    }
-    if( mult1 < 0 && mult2 > 0 ) {
-        return -1;
-    }
-
-    mult = vec1_x * vec2_y - vec2_x * vec1_y;
-    if( mult == 0 ) {
-        CHECK_COLLINEARITY( vec1_x, vec1_y, vec2_x, vec2_y );
-    }
-
-    if( mult1 > 0 )
-    {
-        if( mult > 0 ) {
-            return -1;
-        }
-        else {
-            return 1;
-        }
-    } // if( mult1 > 0 )
-    else
-    {
-        if( mult1 != 0 ) {
-            if( mult > 0 ) {
-                return 1;
-            }
-            else {
-                return -1;
-            }
-        } // if( mult1 != 0 )
-        else {
-            if( mult2 > 0 ) {
-                return -1;
-            }
-            else {
-                return 1;
-            }
-        } // if( mult1 != 0 ) else
-
-    } // if( mult1 > 0 ) else
-
-} // icvIsFirstEdgeClosier
-
-bool icvEarCutTriangulation( CvPoint* contour,
-                               int num,
-                               int* outEdges,
-                               int* numEdges )
-{
-    int i;
-    int notFoundFlag = 0;
-    int begIndex = -1;
-    int isInternal;
-    int currentNum = num;
-    int index1, index2, index3;
-    int ix0, iy0, ix1, iy1, ix2, iy2;
-    int x1, y1, x2, y2, x3, y3;
-    int dx1, dy1, dx2, dy2;
-    int* pointExist = ( int* )0;
-    int det, det1, det2;
-    float t1, t2;
-
-    (*numEdges) = 0;
-
-    if( num <= 2 ) {
-        return false;
-    }
-
-    pointExist = ( int* )malloc( num * sizeof( int ) );
-
-    for( i = 0; i < num; i ++ ) {
-        pointExist[i] = 1;
-    }
-
-    for( i = 0; i < num; i ++ ) {
-        outEdges[ (*numEdges) * 2 ] = i;
-        if( i != num - 1 ) {
-            outEdges[ (*numEdges) * 2 + 1 ] = i + 1;
-        }
-        else {
-            outEdges[ (*numEdges) * 2 + 1 ] = 0;
-        }
-        (*numEdges) ++;
-    } // for( i = 0; i < num; i ++ )
-
-    // initializing data before while cycle
-    index1 = 0;
-    index2 = 1;
-    index3 = 2;
-    x1 = contour[ index1 ].x;
-    y1 = contour[ index1 ].y;
-    x2 = contour[ index2 ].x;
-    y2 = contour[ index2 ].y;
-    x3 = contour[ index3 ].x;
-    y3 = contour[ index3 ].y;
-
-    while( currentNum > 3 )
-    {
-        dx1 = x2 - x1;
-        dy1 = y2 - y1;
-        dx2 = x3 - x2;
-        dy2 = y3 - y2;
-        if( dx1 * dy2 - dx2 * dy1 < 0 ) // convex condition
-        {
-            // checking for noncrossing edge
-            ix1 = x3 - x1;
-            iy1 = y3 - y1;
-            isInternal = 1;
-            for( i = 0; i < num; i ++ )
-            {
-                if( i != num - 1 ) {
-                    ix2 = contour[ i + 1 ].x - contour[ i ].x;
-                    iy2 = contour[ i + 1 ].y - contour[ i ].y;
-                }
-                else {
-                    ix2 = contour[ 0 ].x - contour[ i ].x;
-                    iy2 = contour[ 0 ].y - contour[ i ].y;
-                }
-                ix0 = contour[ i ].x - x1;
-                iy0 = contour[ i ].y - y1;
-
-                det  = ix2 * iy1 - ix1 * iy2;
-                det1 = ix2 * iy0 - ix0 * iy2;
-                if( det != 0.0f )
-                {
-                    t1 = ( ( float )( det1 ) ) / det;
-                    if( t1 > ZERO_CLOSE && t1 < ONE_CLOSE )
-                    {
-                        det2 = ix1 * iy0 - ix0 * iy1;
-                        t2 = ( ( float )( det2 ) ) / det;
-                        if( t2 > ZERO_CLOSE && t2 < ONE_CLOSE ) {
-                            isInternal = 0;
-                        }
-
-                    } // if( t1 > ZERO_CLOSE && t1 < ONE_CLOSE )
-
-                } // if( det != 0.0f )
-
-            } // for( i = 0; i < (*numEdges); i ++ )
-
-            if( isInternal )
-            {
-                // this edge is internal
-                notFoundFlag = 0;
-                outEdges[ (*numEdges) * 2     ] = index1;
-                outEdges[ (*numEdges) * 2 + 1 ] = index3;
-                (*numEdges) ++;
-                pointExist[ index2 ] = 0;
-                index2 = index3;
-                x2 = x3;
-                y2 = y3;
-                currentNum --;
-                if( currentNum >= 3 ) {
-                    do {
-                        index3 ++;
-                        if( index3 == num ) {
-                            index3 = 0;
-                        }
-                    } while( !pointExist[ index3 ] );
-                    x3 = contour[ index3 ].x;
-                    y3 = contour[ index3 ].y;
-                } // if( currentNum >= 3 )
-
-            } // if( isInternal )
-            else {
-                // this edge intersects some other initial edges
-                if( !notFoundFlag ) {
-                    notFoundFlag = 1;
-                    begIndex = index1;
-                }
-                index1 = index2;
-                x1 = x2;
-                y1 = y2;
-                index2 = index3;
-                x2 = x3;
-                y2 = y3;
-                do {
-                    index3 ++;
-                    if( index3 == num ) {
-                        index3 = 0;
-                    }
-                    if( index3 == begIndex ) {
-                        if( pointExist ) {
-                            free( pointExist );
-                        }
-                        return false;
-                    }
-                } while( !pointExist[ index3 ] );
-                x3 = contour[ index3 ].x;
-                y3 = contour[ index3 ].y;
-            } // if( isInternal ) else
-
-        } // if( dx1 * dy2 - dx2 * dy1 < 0 )
-        else
-        {
-            if( !notFoundFlag ) {
-                notFoundFlag = 1;
-                begIndex = index1;
-            }
-            index1 = index2;
-            x1 = x2;
-            y1 = y2;
-            index2 = index3;
-            x2 = x3;
-            y2 = y3;
-            do {
-                index3 ++;
-                if( index3 == num ) {
-                    index3 = 0;
-                }
-                if( index3 == begIndex ) {
-                    if( pointExist ) {
-                        free( pointExist );
-                    }
-                    return false;
-                }
-            } while( !pointExist[ index3 ] );
-            x3 = contour[ index3 ].x;
-            y3 = contour[ index3 ].y;
-        } // if( dx1 * dy2 - dx2 * dy1 < 0 ) else
-
-    } // while( currentNum > 3 )
-
-    if( pointExist ) {
-        free( pointExist );
-    }
-
-    return true;
-
-} // icvEarCutTriangulation
-
-inline bool icvFindTwoNeighbourEdges( CvPoint* contour,
-                                      int* edges,
-                                      int numEdges,
-                                      int vtxIdx,
-                                      int mainEdgeIdx,
-                                      int* leftEdgeIdx,
-                                      int* rightEdgeIdx )
-{
-    int i;
-    int compRes;
-    int vec0_x, vec0_y;
-    int x0, y0, x0_end, y0_end;
-    int x1_left = 0, y1_left = 0, x1_right = 0, y1_right = 0, x2, y2;
-
-    (*leftEdgeIdx)  = -1;
-    (*rightEdgeIdx) = -1;
-
-    if( edges[ mainEdgeIdx * 2 ] == vtxIdx ) {
-        x0 = contour[ vtxIdx ].x;
-        y0 = contour[ vtxIdx ].y;
-        x0_end = contour[ edges[ mainEdgeIdx * 2 + 1 ] ].x;
-        y0_end = contour[ edges[ mainEdgeIdx * 2 + 1 ] ].y;
-        vec0_x = x0_end - x0;
-        vec0_y = y0_end - y0;
-    }
-    else {
-        //x0 = contour[ edges[ mainEdgeIdx * 2 ] ].x;
-        //y0 = contour[ edges[ mainEdgeIdx * 2 ] ].y;
-        //x0_end = contour[ vtxIdx ].x;
-        //y0_end = contour[ vtxIdx ].y;
-        x0 = contour[ vtxIdx ].x;
-        y0 = contour[ vtxIdx ].y;
-        x0_end = contour[ edges[ mainEdgeIdx * 2 ] ].x;
-        y0_end = contour[ edges[ mainEdgeIdx * 2 ] ].y;
-        vec0_x = x0_end - x0;
-        vec0_y = y0_end - y0;
-    }
-
-    for( i = 0; i < numEdges; i ++ )
-    {
-        if( ( i != mainEdgeIdx ) &&
-            ( edges[ i * 2 ] == vtxIdx || edges[ i * 2 + 1 ] == vtxIdx ) )
-        {
-            if( (*leftEdgeIdx) == -1 )
-            {
-                (*leftEdgeIdx) = (*rightEdgeIdx) = i;
-                if( edges[ i * 2 ] == vtxIdx ) {
-                    x1_left = x1_right = contour[ edges[ i * 2 + 1 ] ].x;
-                    y1_left = y1_right = contour[ edges[ i * 2 + 1 ] ].y;
-                }
-                else {
-                    x1_left = x1_right = contour[ edges[ i * 2 ] ].x;
-                    y1_left = y1_right = contour[ edges[ i * 2 ] ].y;
-                }
-
-            } // if( (*leftEdgeIdx) == -1 )
-            else
-            {
-                if( edges[ i * 2 ] == vtxIdx ) {
-                    x2 = contour[ edges[ i * 2 + 1 ] ].x;
-                    y2 = contour[ edges[ i * 2 + 1 ] ].y;
-                }
-                else {
-                    x2 = contour[ edges[ i * 2 ] ].x;
-                    y2 = contour[ edges[ i * 2 ] ].y;
-                }
-
-                compRes = icvIsFirstEdgeClosier( x0,
-                    y0, x0_end, y0_end, x1_left, y1_left, x2, y2 );
-                if( compRes == 0 ) {
-                    return false;
-                }
-                if( compRes == -1 ) {
-                    (*leftEdgeIdx) = i;
-                    x1_left = x2;
-                    y1_left = y2;
-                } // if( compRes == -1 )
-                else {
-                    compRes = icvIsFirstEdgeClosier( x0,
-                        y0, x0_end, y0_end, x1_right, y1_right, x2, y2 );
-                    if( compRes == 0 ) {
-                        return false;
-                    }
-                    if( compRes == 1 ) {
-                        (*rightEdgeIdx) = i;
-                        x1_right = x2;
-                        y1_right = y2;
-                    }
-
-                } // if( compRes == -1 ) else
-
-            } // if( (*leftEdgeIdx) == -1 ) else
-
-        } // if( ( i != mainEdgesIdx ) && ...
-
-    } // for( i = 0; i < numEdges; i ++ )
-
-    return true;
-
-} // icvFindTwoNeighbourEdges
-
-bool icvFindReferences( CvPoint* contour,
-                        int num,
-                        int* outEdges,
-                        int* refer,
-                        int* numEdges )
-{
-    int i;
-    int currPntIdx;
-    int leftEdgeIdx, rightEdgeIdx;
-
-    if( icvEarCutTriangulation( contour, num, outEdges, numEdges ) )
-    {
-        for( i = 0; i < (*numEdges); i ++ )
-        {
-            refer[ i * 4     ] = -1;
-            refer[ i * 4 + 1 ] = -1;
-            refer[ i * 4 + 2 ] = -1;
-            refer[ i * 4 + 3 ] = -1;
-        } // for( i = 0; i < (*numEdges); i ++ )
-
-        for( i = 0; i < (*numEdges); i ++ )
-        {
-            currPntIdx = outEdges[ i * 2 ];
-            if( !icvFindTwoNeighbourEdges( contour,
-                outEdges, (*numEdges), currPntIdx,
-                i, &leftEdgeIdx, &rightEdgeIdx ) )
-            {
-                return false;
-            } // if( !icvFindTwoNeighbourEdges( contour, ...
-            else
-            {
-                if( outEdges[ leftEdgeIdx * 2 ] == currPntIdx ) {
-                    if( refer[ i * 4     ] == -1 ) {
-                        refer[ i * 4     ] = ( leftEdgeIdx << 2 );
-                    }
-                }
-                else {
-                    if( refer[ i * 4     ] == -1 ) {
-                        refer[ i * 4     ] = ( leftEdgeIdx << 2 ) | 2;
-                    }
-                }
-                if( outEdges[ rightEdgeIdx * 2 ] == currPntIdx ) {
-                    if( refer[ i * 4 + 1 ] == -1 ) {
-                        refer[ i * 4 + 1 ] = ( rightEdgeIdx << 2 ) | 3;
-                    }
-                }
-                else {
-                    if( refer[ i * 4 + 1 ] == -1 ) {
-                        refer[ i * 4 + 1 ] = ( rightEdgeIdx << 2 ) | 1;
-                    }
-                }
-
-            } // if( !icvFindTwoNeighbourEdges( contour, ... ) else
-
-            currPntIdx = outEdges[ i * 2 + 1 ];
-            if( i == 18 ) {
-                i = i;
-            }
-            if( !icvFindTwoNeighbourEdges( contour,
-                outEdges, (*numEdges), currPntIdx,
-                i, &leftEdgeIdx, &rightEdgeIdx ) )
-            {
-                return false;
-            } // if( !icvFindTwoNeighbourEdges( contour, ...
-            else
-            {
-                if( outEdges[ leftEdgeIdx * 2 ] == currPntIdx ) {
-                    if( refer[ i * 4 + 3 ] == -1 ) {
-                        refer[ i * 4 + 3 ] = ( leftEdgeIdx << 2 );
-                    }
-                }
-                else {
-                    if( refer[ i * 4 + 3 ] == -1 ) {
-                        refer[ i * 4 + 3 ] = ( leftEdgeIdx << 2 ) | 2;
-                    }
-                }
-                if( outEdges[ rightEdgeIdx * 2 ] == currPntIdx ) {
-                    if( refer[ i * 4 + 2 ] == -1 ) {
-                        refer[ i * 4 + 2 ] = ( rightEdgeIdx << 2 ) | 3;
-                    }
-                }
-                else {
-                    if( refer[ i * 4 + 2 ] == -1 ) {
-                        refer[ i * 4 + 2 ] = ( rightEdgeIdx << 2 ) | 1;
-                    }
-                }
-
-            } // if( !icvFindTwoNeighbourEdges( contour, ... ) else
-
-        } // for( i = 0; i < (*numEdges); i ++ )
-
-    } // if( icvEarCutTriangulation( contour, num, outEdges, numEdges ) )
-    else {
-        return false;
-    } // if( icvEarCutTriangulation( contour, num, outEdges, ... ) else
-
-    return true;
-
-} // icvFindReferences
-
-void cvDecompPoly( CvContour* cont,
-                      CvSubdiv2D** subdiv,
-                      CvMemStorage* storage )
-{
-    int*    memory;
-    CvPoint*    contour;
-    int*        outEdges;
-    int*        refer;
-    CvSubdiv2DPoint**   pntsPtrs;
-    CvQuadEdge2D**      edgesPtrs;
-    int numVtx;
-    int numEdges;
-    int i;
-    CvSeqReader reader;
-    CvPoint2D32f pnt;
-    CvQuadEdge2D* quadEdge;
-
-    numVtx = cont -> total;
-    if( numVtx < 3 ) {
-        return;
-    }
-
-    *subdiv = ( CvSubdiv2D* )0;
-
-    memory = ( int* )malloc( sizeof( int ) * ( numVtx * 2
-        + numVtx * numVtx * 2 * 5 )
-        + sizeof( CvQuadEdge2D* ) * ( numVtx * numVtx )
-        + sizeof( CvSubdiv2DPoint* ) * ( numVtx * 2 ) );
-    contour     = ( CvPoint* )memory;
-    outEdges    = ( int* )( contour + numVtx );
-    refer       = outEdges + numVtx * numVtx * 2;
-    edgesPtrs   = ( CvQuadEdge2D** )( refer + numVtx * numVtx * 4 );
-    pntsPtrs    = ( CvSubdiv2DPoint** )( edgesPtrs + numVtx * numVtx );
-
-    cvStartReadSeq( ( CvSeq* )cont, &reader, 0 );
-    for( i = 0; i < numVtx; i ++ )
-    {
-        CV_READ_SEQ_ELEM( (contour[ i ]), reader );
-    } // for( i = 0; i < numVtx; i ++ )
-
-    if( !icvFindReferences( contour, numVtx, outEdges, refer, &numEdges ) )
-    {
-        free( memory );
-        return;
-    } // if( !icvFindReferences( contour, numVtx, outEdges, refer, ...
-
-    *subdiv = cvCreateSubdiv2D( CV_SEQ_KIND_SUBDIV2D,
-                                sizeof( CvSubdiv2D ),
-                                sizeof( CvSubdiv2DPoint ),
-                                sizeof( CvQuadEdge2D ),
-                                storage );
-
-    for( i = 0; i < numVtx; i ++ )
-    {
-        pnt.x = ( float )contour[ i ].x;
-        pnt.y = ( float )contour[ i ].y;
-        pntsPtrs[ i ] = cvSubdiv2DAddPoint( *subdiv, pnt, 0 );
-    } // for( i = 0; i < numVtx; i ++ )
-
-    for( i = 0; i < numEdges; i ++ )
-    {
-        edgesPtrs[ i ] = ( CvQuadEdge2D* )
-            ( cvSubdiv2DMakeEdge( *subdiv ) & 0xfffffffc );
-    } // for( i = 0; i < numEdges; i ++ )
-
-    for( i = 0; i < numEdges; i ++ )
-    {
-        quadEdge = edgesPtrs[ i ];
-        quadEdge -> next[ 0 ] =
-            ( ( CvSubdiv2DEdge )edgesPtrs[ refer[ i * 4     ] >> 2 ] )
-            | ( refer[ i * 4     ] & 3 );
-        quadEdge -> next[ 1 ] =
-            ( ( CvSubdiv2DEdge )edgesPtrs[ refer[ i * 4 + 1 ] >> 2 ] )
-            | ( refer[ i * 4 + 1 ] & 3 );
-        quadEdge -> next[ 2 ] =
-            ( ( CvSubdiv2DEdge )edgesPtrs[ refer[ i * 4 + 2 ] >> 2 ] )
-            | ( refer[ i * 4 + 2 ] & 3 );
-        quadEdge -> next[ 3 ] =
-            ( ( CvSubdiv2DEdge )edgesPtrs[ refer[ i * 4 + 3 ] >> 2 ] )
-            | ( refer[ i * 4 + 3 ] & 3 );
-        quadEdge -> pt[ 0 ] = pntsPtrs[ outEdges[ i * 2     ] ];
-        quadEdge -> pt[ 1 ] = ( CvSubdiv2DPoint* )0;
-        quadEdge -> pt[ 2 ] = pntsPtrs[ outEdges[ i * 2 + 1 ] ];
-        quadEdge -> pt[ 3 ] = ( CvSubdiv2DPoint* )0;
-    } // for( i = 0; i < numEdges; i ++ )
-
-    (*subdiv) -> topleft.x = ( float )cont -> rect.x;
-    (*subdiv) -> topleft.y = ( float )cont -> rect.y;
-    (*subdiv) -> bottomright.x =
-        ( float )( cont -> rect.x + cont -> rect.width );
-    (*subdiv) -> bottomright.y =
-        ( float )( cont -> rect.y + cont -> rect.height );
-
-    free( memory );
-    return;
-
-} // cvDecompPoly
-
-#endif
-
-// End of file decomppoly.cpp
diff --git a/modules/legacy/src/dominants.cpp b/modules/legacy/src/dominants.cpp
deleted file mode 100644 (file)
index e307768..0000000
+++ /dev/null
@@ -1,402 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-typedef struct _PointInfo
-{
-    CvPoint pt;
-    int left_neigh;
-    int right_neigh;
-
-}
-icvPointInfo;
-
-
-static CvStatus
-icvFindDominantPointsIPAN( CvSeq * contour,
-                           CvMemStorage * storage,
-                           CvSeq ** corners, int dmin2, int dmax2, int dneigh2, float amax )
-{
-    CvStatus status = CV_OK;
-
-    /* variables */
-    int n = contour->total;
-
-    float *sharpness;
-    float *distance;
-    icvPointInfo *ptInf;
-
-    int i, j, k;
-
-    CvSeqWriter writer;
-
-    float mincos = (float) cos( 3.14159265359 * amax / 180 );
-
-    /* check bad arguments */
-    if( contour == NULL )
-        return CV_NULLPTR_ERR;
-    if( storage == NULL )
-        return CV_NULLPTR_ERR;
-    if( corners == NULL )
-        return CV_NULLPTR_ERR;
-    if( dmin2 < 0 )
-        return CV_BADSIZE_ERR;
-    if( dmax2 < dmin2 )
-        return CV_BADSIZE_ERR;
-    if( (dneigh2 > dmax2) || (dneigh2 < 0) )
-        return CV_BADSIZE_ERR;
-    if( (amax < 0) || (amax > 180) )
-        return CV_BADSIZE_ERR;
-
-    sharpness = (float *) cvAlloc( n * sizeof( float ));
-    distance = (float *) cvAlloc( n * sizeof( float ));
-
-    ptInf = (icvPointInfo *) cvAlloc( n * sizeof( icvPointInfo ));
-
-/*****************************************************************************************/
-/*                                 First pass                                            */
-/*****************************************************************************************/
-
-    if( CV_IS_SEQ_CHAIN_CONTOUR( contour ))
-    {
-        CvChainPtReader reader;
-
-        cvStartReadChainPoints( (CvChain *) contour, &reader );
-
-        for( i = 0; i < n; i++ )
-        {
-            CV_READ_CHAIN_POINT( ptInf[i].pt, reader );
-        }
-    }
-    else if( CV_IS_SEQ_POINT_SET( contour ))
-    {
-        CvSeqReader reader;
-
-        cvStartReadSeq( contour, &reader, 0 );
-
-        for( i = 0; i < n; i++ )
-        {
-            CV_READ_SEQ_ELEM( ptInf[i].pt, reader );
-        }
-    }
-    else
-    {
-        return CV_BADFLAG_ERR;
-    }
-
-    for( i = 0; i < n; i++ )
-    {
-        /* find nearest suitable points
-           which satisfy distance constraint >dmin */
-        int left_near = 0;
-        int right_near = 0;
-        int left_far, right_far;
-
-        float dist_l = 0;
-        float dist_r = 0;
-
-        int i_plus = 0;
-        int i_minus = 0;
-
-        float max_cos_alpha;
-
-        /* find  right minimum */
-        while( dist_r < dmin2 )
-        {
-            float dx, dy;
-            int ind;
-
-            if( i_plus >= n )
-                goto error;
-
-            right_near = i_plus;
-
-            if( dist_r < dneigh2 )
-                ptInf[i].right_neigh = i_plus;
-
-            i_plus++;
-
-            ind = (i + i_plus) % n;
-            dx = (float) (ptInf[i].pt.x - ptInf[ind].pt.x);
-            dy = (float) (ptInf[i].pt.y - ptInf[ind].pt.y);
-            dist_r = dx * dx + dy * dy;
-        }
-        /* find right maximum */
-        while( dist_r <= dmax2 )
-        {
-            float dx, dy;
-            int ind;
-
-            if( i_plus >= n )
-                goto error;
-
-            distance[(i + i_plus) % n] = cvSqrt( dist_r );
-
-            if( dist_r < dneigh2 )
-                ptInf[i].right_neigh = i_plus;
-
-            i_plus++;
-
-            right_far = i_plus;
-
-            ind = (i + i_plus) % n;
-
-            dx = (float) (ptInf[i].pt.x - ptInf[ind].pt.x);
-            dy = (float) (ptInf[i].pt.y - ptInf[ind].pt.y);
-            dist_r = dx * dx + dy * dy;
-        }
-        right_far = i_plus;
-
-        /* left minimum */
-        while( dist_l < dmin2 )
-        {
-            float dx, dy;
-            int ind;
-
-            if( i_minus <= -n )
-                goto error;
-
-            left_near = i_minus;
-
-            if( dist_l < dneigh2 )
-                ptInf[i].left_neigh = i_minus;
-
-            i_minus--;
-
-            ind = i + i_minus;
-            ind = (ind < 0) ? (n + ind) : ind;
-
-            dx = (float) (ptInf[i].pt.x - ptInf[ind].pt.x);
-            dy = (float) (ptInf[i].pt.y - ptInf[ind].pt.y);
-            dist_l = dx * dx + dy * dy;
-        }
-
-        /* find left maximum */
-        while( dist_l <= dmax2 )
-        {
-            float dx, dy;
-            int ind;
-
-            if( i_minus <= -n )
-                goto error;
-
-            ind = i + i_minus;
-            ind = (ind < 0) ? (n + ind) : ind;
-
-            distance[ind] = cvSqrt( dist_l );
-
-            if( dist_l < dneigh2 )
-                ptInf[i].left_neigh = i_minus;
-
-            i_minus--;
-
-            left_far = i_minus;
-
-            ind = i + i_minus;
-            ind = (ind < 0) ? (n + ind) : ind;
-
-            dx = (float) (ptInf[i].pt.x - ptInf[ind].pt.x);
-            dy = (float) (ptInf[i].pt.y - ptInf[ind].pt.y);
-            dist_l = dx * dx + dy * dy;
-        }
-        left_far = i_minus;
-
-        if( (i_plus - i_minus) > n + 2 )
-            goto error;
-
-        max_cos_alpha = -1;
-        for( j = left_far + 1; j < left_near; j++ )
-        {
-            float dx, dy;
-            float a, a2;
-            int leftind = i + j;
-
-            leftind = (leftind < 0) ? (n + leftind) : leftind;
-
-            a = distance[leftind];
-            a2 = a * a;
-
-            for( k = right_near + 1; k < right_far; k++ )
-            {
-                int ind = (i + k) % n;
-                float c2, cosalpha;
-                float b = distance[ind];
-                float b2 = b * b;
-
-                /* compute cosinus */
-                dx = (float) (ptInf[leftind].pt.x - ptInf[ind].pt.x);
-                dy = (float) (ptInf[leftind].pt.y - ptInf[ind].pt.y);
-
-                c2 = dx * dx + dy * dy;
-                cosalpha = (a2 + b2 - c2) / (2 * a * b);
-
-                max_cos_alpha = MAX( max_cos_alpha, cosalpha );
-
-                if( max_cos_alpha < mincos )
-                    max_cos_alpha = -1;
-
-                sharpness[i] = max_cos_alpha;
-            }
-        }
-    }
-/*****************************************************************************************/
-/*                                 Second pass                                           */
-/*****************************************************************************************/
-
-    cvStartWriteSeq( (contour->flags & ~CV_SEQ_ELTYPE_MASK) | CV_SEQ_ELTYPE_INDEX,
-                     sizeof( CvSeq ), sizeof( int ), storage, &writer );
-
-    /* second pass - nonmaxima suppression */
-    /* neighborhood of point < dneigh2 */
-    for( i = 0; i < n; i++ )
-    {
-        int suppressed = 0;
-        if( sharpness[i] == -1 )
-            continue;
-
-        for( j = 1; (j <= ptInf[i].right_neigh) && (suppressed == 0); j++ )
-        {
-            if( sharpness[i] < sharpness[(i + j) % n] )
-                suppressed = 1;
-        }
-
-        for( j = -1; (j >= ptInf[i].left_neigh) && (suppressed == 0); j-- )
-        {
-            int ind = i + j;
-
-            ind = (ind < 0) ? (n + ind) : ind;
-            if( sharpness[i] < sharpness[ind] )
-                suppressed = 1;
-        }
-
-        if( !suppressed )
-            CV_WRITE_SEQ_ELEM( i, writer );
-    }
-
-    *corners = cvEndWriteSeq( &writer );
-
-    cvFree( &sharpness );
-    cvFree( &distance );
-    cvFree( &ptInf );
-
-    return status;
-
-  error:
-    /* dmax is so big (more than contour diameter)
-       that algorithm could become infinite cycle */
-    cvFree( &sharpness );
-    cvFree( &distance );
-    cvFree( &ptInf );
-
-    return CV_BADRANGE_ERR;
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvFindDominantPoints
-//    Purpose:
-//      Applies some algorithm to find dominant points ( corners ) of contour
-//
-//    Context:
-//    Parameters:
-//      contours - pointer to input contour object.
-//      out_numbers - array of dominant points indices
-//      count - length of out_numbers array on input
-//              and numbers of founded dominant points on output
-//
-//      method - only CV_DOMINANT_IPAN now
-//      parameters - array of parameters
-//                   for IPAN algorithm
-//                   [0] - minimal distance
-//                   [1] - maximal distance
-//                   [2] - neighborhood distance (must be not greater than dmaximal distance)
-//                   [3] - maximal possible angle of curvature
-//    Returns:
-//      CV_OK or error code
-//    Notes:
-//      User must allocate out_numbers array. If it is small - function fills array
-//      with part of points and returns  error
-//F*/
-CV_IMPL CvSeq*
-cvFindDominantPoints( CvSeq * contour, CvMemStorage * storage, int method,
-                      double parameter1, double parameter2, double parameter3, double parameter4 )
-{
-    CvSeq* corners = 0;
-
-    if( !contour )
-        CV_Error( CV_StsNullPtr, "" );
-
-    if( !storage )
-        storage = contour->storage;
-
-    if( !storage )
-        CV_Error( CV_StsNullPtr, "" );
-
-    switch (method)
-    {
-    case CV_DOMINANT_IPAN:
-        {
-            int dmin = cvRound(parameter1);
-            int dmax = cvRound(parameter2);
-            int dneigh = cvRound(parameter3);
-            int amax = cvRound(parameter4);
-
-            if( amax == 0 )
-                amax = 150;
-            if( dmin == 0 )
-                dmin = 7;
-            if( dmax == 0 )
-                dmax = dmin + 2;
-            if( dneigh == 0 )
-                dneigh = dmin;
-
-            IPPI_CALL( icvFindDominantPointsIPAN( contour, storage, &corners,
-                                                  dmin*dmin, dmax*dmax, dneigh*dneigh, (float)amax ));
-        }
-        break;
-    default:
-        CV_Error( CV_StsBadArg, "" );
-    }
-
-    return corners;
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/dpstereo.cpp b/modules/legacy/src/dpstereo.cpp
deleted file mode 100644 (file)
index 7b7ebd6..0000000
+++ /dev/null
@@ -1,553 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-/****************************************************************************************\
-    The code below is some modification of Stan Birchfield's algorithm described in:
-
-    Depth Discontinuities by Pixel-to-Pixel Stereo
-    Stan Birchfield and Carlo Tomasi
-    International Journal of Computer Vision,
-    35(3): 269-293, December 1999.
-
-    This implementation uses different cost function that results in
-    O(pixPerRow*maxDisparity) complexity of dynamic programming stage versus
-    O(pixPerRow*log(pixPerRow)*maxDisparity) in the above paper.
-\****************************************************************************************/
-
-/****************************************************************************************\
-*       Find stereo correspondence by dynamic programming algorithm                      *
-\****************************************************************************************/
-#define ICV_DP_STEP_LEFT  0
-#define ICV_DP_STEP_UP    1
-#define ICV_DP_STEP_DIAG  2
-
-#define ICV_BIRCH_DIFF_LUM 5
-
-#define ICV_MAX_DP_SUM_VAL (INT_MAX/4)
-
-typedef struct _CvDPCell
-{
-    uchar  step; //local-optimal step
-    int    sum;  //current sum
-}_CvDPCell;
-
-typedef struct _CvRightImData
-{
-    uchar min_val, max_val;
-} _CvRightImData;
-
-#define CV_IMAX3(a,b,c) (std::max(std::max((a), (b)), (c)))
-#define CV_IMIN3(a,b,c) (std::min(std::min((a), (b)), (c)))
-
-static void icvFindStereoCorrespondenceByBirchfieldDP( uchar* src1, uchar* src2,
-                                                uchar* disparities,
-                                                CvSize size, int widthStep,
-                                                int    maxDisparity,
-                                                float  _param1, float _param2,
-                                                float  _param3, float _param4,
-                                                float  _param5 )
-{
-    int     x, y, i, j;
-    int     d, s;
-    int     dispH =  maxDisparity + 3;
-    uchar  *dispdata;
-    int     imgW = size.width;
-    int     imgH = size.height;
-    uchar   val, prevval, prev, curr;
-    int     min_val;
-    uchar*  dest = disparities;
-    int param1 = cvRound(_param1);
-    int param2 = cvRound(_param2);
-    int param3 = cvRound(_param3);
-    int param4 = cvRound(_param4);
-    int param5 = cvRound(_param5);
-
-    #define CELL(d,x)   cells[(d)+(x)*dispH]
-
-    uchar*              dsi = (uchar*)cvAlloc(sizeof(uchar)*imgW*dispH);
-    uchar*              edges = (uchar*)cvAlloc(sizeof(uchar)*imgW*imgH);
-    _CvDPCell*          cells = (_CvDPCell*)cvAlloc(sizeof(_CvDPCell)*imgW*MAX(dispH,(imgH+1)/2));
-    _CvRightImData*     rData = (_CvRightImData*)cvAlloc(sizeof(_CvRightImData)*imgW);
-    int*                reliabilities = (int*)cells;
-
-    for( y = 0; y < imgH; y++ )
-    {
-        uchar* srcdata1 = src1 + widthStep * y;
-        uchar* srcdata2 = src2 + widthStep * y;
-
-        //init rData
-        prevval = prev = srcdata2[0];
-        for( j = 1; j < imgW; j++ )
-        {
-            curr = srcdata2[j];
-            val = (uchar)((curr + prev)>>1);
-            rData[j-1].max_val = (uchar)CV_IMAX3( val, prevval, prev );
-            rData[j-1].min_val = (uchar)CV_IMIN3( val, prevval, prev );
-            prevval = val;
-            prev = curr;
-        }
-        rData[j-1] = rData[j-2];//last elem
-
-        // fill dissimularity space image
-        for( i = 1; i <= maxDisparity + 1; i++ )
-        {
-            dsi += imgW;
-            rData--;
-            for( j = i - 1; j < imgW - 1; j++ )
-            {
-                int t;
-                if( (t = srcdata1[j] - rData[j+1].max_val) >= 0 )
-                {
-                    dsi[j] = (uchar)t;
-                }
-                else if( (t = rData[j+1].min_val - srcdata1[j]) >= 0 )
-                {
-                    dsi[j] = (uchar)t;
-                }
-                else
-                {
-                    dsi[j] = 0;
-                }
-            }
-        }
-        dsi -= (maxDisparity+1)*imgW;
-        rData += maxDisparity+1;
-
-        //intensity gradients image construction
-        //left row
-        edges[y*imgW] = edges[y*imgW+1] = edges[y*imgW+2] = 2;
-        edges[y*imgW+imgW-1] = edges[y*imgW+imgW-2] = edges[y*imgW+imgW-3] = 1;
-        for( j = 3; j < imgW-4; j++ )
-        {
-            edges[y*imgW+j] = 0;
-
-            if( ( CV_IMAX3( srcdata1[j-3], srcdata1[j-2], srcdata1[j-1] ) -
-                  CV_IMIN3( srcdata1[j-3], srcdata1[j-2], srcdata1[j-1] ) ) >= ICV_BIRCH_DIFF_LUM )
-            {
-                edges[y*imgW+j] |= 1;
-            }
-            if( ( CV_IMAX3( srcdata2[j+3], srcdata2[j+2], srcdata2[j+1] ) -
-                  CV_IMIN3( srcdata2[j+3], srcdata2[j+2], srcdata2[j+1] ) ) >= ICV_BIRCH_DIFF_LUM )
-            {
-                edges[y*imgW+j] |= 2;
-            }
-        }
-
-        //find correspondence using dynamical programming
-        //init DP table
-        for( x = 0; x < imgW; x++ )
-        {
-            CELL(0,x).sum = CELL(dispH-1,x).sum = ICV_MAX_DP_SUM_VAL;
-            CELL(0,x).step = CELL(dispH-1,x).step = ICV_DP_STEP_LEFT;
-        }
-        for( d = 2; d < dispH; d++ )
-        {
-            CELL(d,d-2).sum = ICV_MAX_DP_SUM_VAL;
-            CELL(d,d-2).step = ICV_DP_STEP_UP;
-        }
-        CELL(1,0).sum  = 0;
-        CELL(1,0).step = ICV_DP_STEP_LEFT;
-
-        for( x = 1; x < imgW; x++ )
-        {
-            int dp = MIN( x + 1, maxDisparity + 1);
-            uchar* _edges = edges + y*imgW + x;
-            int e0 = _edges[0] & 1;
-            _CvDPCell* _cell = cells + x*dispH;
-
-            do
-            {
-                int _s = dsi[dp*imgW+x];
-                int sum[3];
-
-                //check left step
-                sum[0] = _cell[dp-dispH].sum - param2;
-
-                //check up step
-                if( _cell[dp+1].step != ICV_DP_STEP_DIAG && e0 )
-                {
-                    sum[1] = _cell[dp+1].sum + param1;
-
-                    if( _cell[dp-1-dispH].step != ICV_DP_STEP_UP && (_edges[1-dp] & 2) )
-                    {
-                        int t;
-
-                        sum[2] = _cell[dp-1-dispH].sum + param1;
-
-                        t = sum[1] < sum[0];
-
-                        //choose local-optimal pass
-                        if( sum[t] <= sum[2] )
-                        {
-                            _cell[dp].step = (uchar)t;
-                            _cell[dp].sum = sum[t] + _s;
-                        }
-                        else
-                        {
-                            _cell[dp].step = ICV_DP_STEP_DIAG;
-                            _cell[dp].sum = sum[2] + _s;
-                        }
-                    }
-                    else
-                    {
-                        if( sum[0] <= sum[1] )
-                        {
-                            _cell[dp].step = ICV_DP_STEP_LEFT;
-                            _cell[dp].sum = sum[0] + _s;
-                        }
-                        else
-                        {
-                            _cell[dp].step = ICV_DP_STEP_UP;
-                            _cell[dp].sum = sum[1] + _s;
-                        }
-                    }
-                }
-                else if( _cell[dp-1-dispH].step != ICV_DP_STEP_UP && (_edges[1-dp] & 2) )
-                {
-                    sum[2] = _cell[dp-1-dispH].sum + param1;
-                    if( sum[0] <= sum[2] )
-                    {
-                        _cell[dp].step = ICV_DP_STEP_LEFT;
-                        _cell[dp].sum = sum[0] + _s;
-                    }
-                    else
-                    {
-                        _cell[dp].step = ICV_DP_STEP_DIAG;
-                        _cell[dp].sum = sum[2] + _s;
-                    }
-                }
-                else
-                {
-                    _cell[dp].step = ICV_DP_STEP_LEFT;
-                    _cell[dp].sum = sum[0] + _s;
-                }
-            }
-            while( --dp );
-        }// for x
-
-        //extract optimal way and fill disparity image
-        dispdata = dest + widthStep * y;
-
-        //find min_val
-        min_val = ICV_MAX_DP_SUM_VAL;
-        for( i = 1; i <= maxDisparity + 1; i++ )
-        {
-            if( min_val > CELL(i,imgW-1).sum )
-            {
-                d = i;
-                min_val = CELL(i,imgW-1).sum;
-            }
-        }
-
-        //track optimal pass
-        for( x = imgW - 1; x > 0; x-- )
-        {
-            dispdata[x] = (uchar)(d - 1);
-            while( CELL(d,x).step == ICV_DP_STEP_UP ) d++;
-            if ( CELL(d,x).step == ICV_DP_STEP_DIAG )
-            {
-                s = x;
-                while( CELL(d,x).step == ICV_DP_STEP_DIAG )
-                {
-                    d--;
-                    x--;
-                }
-                for( i = x; i < s; i++ )
-                {
-                    dispdata[i] = (uchar)(d-1);
-                }
-            }
-        }//for x
-    }// for y
-
-    //Postprocessing the Disparity Map
-
-    //remove obvious errors in the disparity map
-    for( x = 0; x < imgW; x++ )
-    {
-        for( y = 1; y < imgH - 1; y++ )
-        {
-            if( dest[(y-1)*widthStep+x] == dest[(y+1)*widthStep+x] )
-            {
-                dest[y*widthStep+x] = dest[(y-1)*widthStep+x];
-            }
-        }
-    }
-
-    //compute intensity Y-gradients
-    for( x = 0; x < imgW; x++ )
-    {
-        for( y = 1; y < imgH - 1; y++ )
-        {
-            if( ( CV_IMAX3( src1[(y-1)*widthStep+x], src1[y*widthStep+x],
-                        src1[(y+1)*widthStep+x] ) -
-                  CV_IMIN3( src1[(y-1)*widthStep+x], src1[y*widthStep+x],
-                        src1[(y+1)*widthStep+x] ) ) >= ICV_BIRCH_DIFF_LUM )
-            {
-                edges[y*imgW+x] |= 4;
-                edges[(y+1)*imgW+x] |= 4;
-                edges[(y-1)*imgW+x] |= 4;
-                y++;
-            }
-        }
-    }
-
-    //remove along any particular row, every gradient
-    //for which two adjacent columns do not agree.
-    for( y = 0; y < imgH; y++ )
-    {
-        prev = edges[y*imgW];
-        for( x = 1; x < imgW - 1; x++ )
-        {
-            curr = edges[y*imgW+x];
-            if( (curr & 4) &&
-                ( !( prev & 4 ) ||
-                  !( edges[y*imgW+x+1] & 4 ) ) )
-            {
-                edges[y*imgW+x] -= 4;
-            }
-            prev = curr;
-        }
-    }
-
-    // define reliability
-    for( x = 0; x < imgW; x++ )
-    {
-        for( y = 1; y < imgH; y++ )
-        {
-            i = y - 1;
-            for( ; y < imgH && dest[y*widthStep+x] == dest[(y-1)*widthStep+x]; y++ )
-                ;
-            s = y - i;
-            for( ; i < y; i++ )
-            {
-                reliabilities[i*imgW+x] = s;
-            }
-        }
-    }
-
-    //Y - propagate reliable regions
-    for( x = 0; x < imgW; x++ )
-    {
-        for( y = 0; y < imgH; y++ )
-        {
-            d = dest[y*widthStep+x];
-            if( reliabilities[y*imgW+x] >= param4 && !(edges[y*imgW+x] & 4) &&
-                d > 0 )//highly || moderately
-            {
-                disparities[y*widthStep+x] = (uchar)d;
-                //up propagation
-                for( i = y - 1; i >= 0; i-- )
-                {
-                    if(  ( edges[i*imgW+x] & 4 ) ||
-                         ( dest[i*widthStep+x] < d &&
-                           reliabilities[i*imgW+x] >= param3 ) ||
-                         ( reliabilities[y*imgW+x] < param5 &&
-                           dest[i*widthStep+x] - 1 == d ) ) break;
-
-                    disparities[i*widthStep+x] = (uchar)d;
-                }
-
-                //down propagation
-                for( i = y + 1; i < imgH; i++ )
-                {
-                    if(  ( edges[i*imgW+x] & 4 ) ||
-                         ( dest[i*widthStep+x] < d &&
-                           reliabilities[i*imgW+x] >= param3 ) ||
-                         ( reliabilities[y*imgW+x] < param5 &&
-                           dest[i*widthStep+x] - 1 == d ) ) break;
-
-                    disparities[i*widthStep+x] = (uchar)d;
-                }
-                y = i - 1;
-            }
-            else
-            {
-                disparities[y*widthStep+x] = (uchar)d;
-            }
-        }
-    }
-
-    // define reliability along X
-    for( y = 0; y < imgH; y++ )
-    {
-        for( x = 1; x < imgW; x++ )
-        {
-            i = x - 1;
-            for( ; x < imgW && dest[y*widthStep+x] == dest[y*widthStep+x-1]; x++ ) {}
-            s = x - i;
-            for( ; i < x; i++ )
-            {
-                reliabilities[y*imgW+i] = s;
-            }
-        }
-    }
-
-    //X - propagate reliable regions
-    for( y = 0; y < imgH; y++ )
-    {
-        for( x = 0; x < imgW; x++ )
-        {
-            d = dest[y*widthStep+x];
-            if( reliabilities[y*imgW+x] >= param4 && !(edges[y*imgW+x] & 1) &&
-                d > 0 )//highly || moderately
-            {
-                disparities[y*widthStep+x] = (uchar)d;
-                //up propagation
-                for( i = x - 1; i >= 0; i-- )
-                {
-                    if(  (edges[y*imgW+i] & 1) ||
-                         ( dest[y*widthStep+i] < d &&
-                           reliabilities[y*imgW+i] >= param3 ) ||
-                         ( reliabilities[y*imgW+x] < param5 &&
-                           dest[y*widthStep+i] - 1 == d ) ) break;
-
-                    disparities[y*widthStep+i] = (uchar)d;
-                }
-
-                //down propagation
-                for( i = x + 1; i < imgW; i++ )
-                {
-                    if(  (edges[y*imgW+i] & 1) ||
-                         ( dest[y*widthStep+i] < d &&
-                           reliabilities[y*imgW+i] >= param3 ) ||
-                         ( reliabilities[y*imgW+x] < param5 &&
-                           dest[y*widthStep+i] - 1 == d ) ) break;
-
-                    disparities[y*widthStep+i] = (uchar)d;
-                }
-                x = i - 1;
-            }
-            else
-            {
-                disparities[y*widthStep+x] = (uchar)d;
-            }
-        }
-    }
-
-    //release resources
-    cvFree( &dsi );
-    cvFree( &edges );
-    cvFree( &cells );
-    cvFree( &rData );
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////
-//
-//    Name:    cvFindStereoCorrespondence
-//    Purpose: find stereo correspondence on stereo-pair
-//    Context:
-//    Parameters:
-//      leftImage - left image of stereo-pair (format 8uC1).
-//      rightImage - right image of stereo-pair (format 8uC1).
-//      mode -mode of correspondance retrieval (now CV_RETR_DP_BIRCHFIELD only)
-//      dispImage - destination disparity image
-//      maxDisparity - maximal disparity
-//      param1, param2, param3, param4, param5 - parameters of algorithm
-//    Returns:
-//    Notes:
-//      Images must be rectified.
-//      All images must have format 8uC1.
-//F*/
-CV_IMPL void
-cvFindStereoCorrespondence(
-                   const  CvArr* leftImage, const  CvArr* rightImage,
-                   int     mode,
-                   CvArr*  depthImage,
-                   int     maxDisparity,
-                   double  param1, double  param2, double  param3,
-                   double  param4, double  param5  )
-{
-    CV_FUNCNAME( "cvFindStereoCorrespondence" );
-
-    __BEGIN__;
-
-    CvMat  *src1, *src2;
-    CvMat  *dst;
-    CvMat  src1_stub, src2_stub, dst_stub;
-    int    coi;
-
-    CV_CALL( src1 = cvGetMat( leftImage, &src1_stub, &coi ));
-    if( coi ) CV_ERROR( CV_BadCOI, "COI is not supported by the function" );
-    CV_CALL( src2 = cvGetMat( rightImage, &src2_stub, &coi ));
-    if( coi ) CV_ERROR( CV_BadCOI, "COI is not supported by the function" );
-    CV_CALL( dst = cvGetMat( depthImage, &dst_stub, &coi ));
-    if( coi ) CV_ERROR( CV_BadCOI, "COI is not supported by the function" );
-
-    // check args
-    if( CV_MAT_TYPE( src1->type ) != CV_8UC1 ||
-        CV_MAT_TYPE( src2->type ) != CV_8UC1 ||
-        CV_MAT_TYPE( dst->type ) != CV_8UC1) CV_ERROR(CV_StsUnsupportedFormat,
-                        "All images must be single-channel and have 8u" );
-
-    if( !CV_ARE_SIZES_EQ( src1, src2 ) || !CV_ARE_SIZES_EQ( src1, dst ) )
-            CV_ERROR( CV_StsUnmatchedSizes, "" );
-
-    if( maxDisparity <= 0 || maxDisparity >= src1->width || maxDisparity > 255 )
-        CV_ERROR(CV_StsOutOfRange,
-                 "parameter /maxDisparity/ is out of range");
-
-    if( mode == CV_DISPARITY_BIRCHFIELD )
-    {
-        if( param1 == CV_UNDEF_SC_PARAM ) param1 = CV_IDP_BIRCHFIELD_PARAM1;
-        if( param2 == CV_UNDEF_SC_PARAM ) param2 = CV_IDP_BIRCHFIELD_PARAM2;
-        if( param3 == CV_UNDEF_SC_PARAM ) param3 = CV_IDP_BIRCHFIELD_PARAM3;
-        if( param4 == CV_UNDEF_SC_PARAM ) param4 = CV_IDP_BIRCHFIELD_PARAM4;
-        if( param5 == CV_UNDEF_SC_PARAM ) param5 = CV_IDP_BIRCHFIELD_PARAM5;
-
-        CV_CALL( icvFindStereoCorrespondenceByBirchfieldDP( src1->data.ptr,
-            src2->data.ptr, dst->data.ptr,
-            cvGetMatSize( src1 ), src1->step,
-            maxDisparity, (float)param1, (float)param2, (float)param3,
-            (float)param4, (float)param5 ) );
-    }
-    else
-    {
-        CV_ERROR( CV_StsBadArg, "Unsupported mode of function" );
-    }
-
-    __END__;
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/eigenobjects.cpp b/modules/legacy/src/eigenobjects.cpp
deleted file mode 100644 (file)
index 4c8b973..0000000
+++ /dev/null
@@ -1,1810 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-static CvStatus
-icvJacobiEigens_32f(float *A, float *V, float *E, int n, float eps)
-{
-    int i, j, k, ind;
-    float *AA = A, *VV = V;
-    double Amax, anorm = 0, ax;
-
-    if( A == NULL || V == NULL || E == NULL )
-        return CV_NULLPTR_ERR;
-    if( n <= 0 )
-        return CV_BADSIZE_ERR;
-    if( eps < 1.0e-7f )
-        eps = 1.0e-7f;
-
-    /*-------- Prepare --------*/
-    for( i = 0; i < n; i++, VV += n, AA += n )
-    {
-        for( j = 0; j < i; j++ )
-        {
-            double Am = AA[j];
-
-            anorm += Am * Am;
-        }
-        for( j = 0; j < n; j++ )
-            VV[j] = 0.f;
-        VV[i] = 1.f;
-    }
-
-    anorm = sqrt( anorm + anorm );
-    ax = anorm * eps / n;
-    Amax = anorm;
-
-    while( Amax > ax )
-    {
-        Amax /= n;
-        do                      /* while (ind) */
-        {
-            int p, q;
-            float *V1 = V, *A1 = A;
-
-            ind = 0;
-            for( p = 0; p < n - 1; p++, A1 += n, V1 += n )
-            {
-                float *A2 = A + n * (p + 1), *V2 = V + n * (p + 1);
-
-                for( q = p + 1; q < n; q++, A2 += n, V2 += n )
-                {
-                    double x, y, c, s, c2, s2, a;
-                    float *A3, Apq = A1[q], App, Aqq, Aip, Aiq, Vpi, Vqi;
-
-                    if( fabs( Apq ) < Amax )
-                        continue;
-
-                    ind = 1;
-
-                    /*---- Calculation of rotation angle's sine & cosine ----*/
-                    App = A1[p];
-                    Aqq = A2[q];
-                    y = 5.0e-1 * (App - Aqq);
-                    x = -Apq / sqrt( (double)Apq * Apq + (double)y * y );
-                    if( y < 0.0 )
-                        x = -x;
-                    s = x / sqrt( 2.0 * (1.0 + sqrt( 1.0 - (double)x * x )));
-                    s2 = s * s;
-                    c = sqrt( 1.0 - s2 );
-                    c2 = c * c;
-                    a = 2.0 * Apq * c * s;
-
-                    /*---- Apq annulation ----*/
-                    A3 = A;
-                    for( i = 0; i < p; i++, A3 += n )
-                    {
-                        Aip = A3[p];
-                        Aiq = A3[q];
-                        Vpi = V1[i];
-                        Vqi = V2[i];
-                        A3[p] = (float) (Aip * c - Aiq * s);
-                        A3[q] = (float) (Aiq * c + Aip * s);
-                        V1[i] = (float) (Vpi * c - Vqi * s);
-                        V2[i] = (float) (Vqi * c + Vpi * s);
-                    }
-                    for( ; i < q; i++, A3 += n )
-                    {
-                        Aip = A1[i];
-                        Aiq = A3[q];
-                        Vpi = V1[i];
-                        Vqi = V2[i];
-                        A1[i] = (float) (Aip * c - Aiq * s);
-                        A3[q] = (float) (Aiq * c + Aip * s);
-                        V1[i] = (float) (Vpi * c - Vqi * s);
-                        V2[i] = (float) (Vqi * c + Vpi * s);
-                    }
-                    for( ; i < n; i++ )
-                    {
-                        Aip = A1[i];
-                        Aiq = A2[i];
-                        Vpi = V1[i];
-                        Vqi = V2[i];
-                        A1[i] = (float) (Aip * c - Aiq * s);
-                        A2[i] = (float) (Aiq * c + Aip * s);
-                        V1[i] = (float) (Vpi * c - Vqi * s);
-                        V2[i] = (float) (Vqi * c + Vpi * s);
-                    }
-                    A1[p] = (float) (App * c2 + Aqq * s2 - a);
-                    A2[q] = (float) (App * s2 + Aqq * c2 + a);
-                    A1[q] = A2[p] = 0.0f;
-                }               /*q */
-            }                   /*p */
-        }
-        while( ind );
-        Amax /= n;
-    }                           /* while ( Amax > ax ) */
-
-    for( i = 0, k = 0; i < n; i++, k += n + 1 )
-        E[i] = A[k];
-    /*printf(" M = %d\n", M); */
-
-    /* -------- ordering -------- */
-    for( i = 0; i < n; i++ )
-    {
-        int m = i;
-        float Em = (float) fabs( E[i] );
-
-        for( j = i + 1; j < n; j++ )
-        {
-            float Ej = (float) fabs( E[j] );
-
-            m = (Em < Ej) ? j : m;
-            Em = (Em < Ej) ? Ej : Em;
-        }
-        if( m != i )
-        {
-            int l;
-            float b = E[i];
-
-            E[i] = E[m];
-            E[m] = b;
-            for( j = 0, k = i * n, l = m * n; j < n; j++, k++, l++ )
-            {
-                b = V[k];
-                V[k] = V[l];
-                V[l] = b;
-            }
-        }
-    }
-
-    return CV_NO_ERR;
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvCalcCovarMatrixEx_8u32fR
-//    Purpose: The function calculates a covariance matrix for a group of input objects
-//             (images, vectors, etc.). ROI supported.
-//    Context:
-//    Parameters:  nObjects    - number of source objects
-//                 objects     - array of pointers to ROIs of the source objects
-//                 imgStep     - full width of each source object row in bytes
-//                 avg         - pointer to averaged object
-//                 avgStep     - full width of averaged object row in bytes
-//                 size        - ROI size of each source and averaged objects
-//                 covarMatrix - covariance matrix (output parameter; must be allocated
-//                               before call)
-//
-//    Returns: CV_NO_ERR or error code
-//
-//    Notes:
-//F*/
-static CvStatus  CV_STDCALL
-icvCalcCovarMatrixEx_8u32fR( int nObjects, void *input, int objStep1,
-                             int ioFlags, int ioBufSize, uchar* buffer,
-                             void *userData, float *avg, int avgStep,
-                             CvSize size, float *covarMatrix )
-{
-    int objStep = objStep1;
-
-    /* ---- TEST OF PARAMETERS ---- */
-
-    if( nObjects < 2 )
-        return CV_BADFACTOR_ERR;
-    if( ioFlags < 0 || ioFlags > 3 )
-        return CV_BADFACTOR_ERR;
-    if( ioFlags && ioBufSize < 1024 )
-        return CV_BADFACTOR_ERR;
-    if( ioFlags && buffer == NULL )
-        return CV_NULLPTR_ERR;
-    if( input == NULL || avg == NULL || covarMatrix == NULL )
-        return CV_NULLPTR_ERR;
-    if( size.width > objStep || 4 * size.width > avgStep || size.height < 1 )
-        return CV_BADSIZE_ERR;
-
-    avgStep /= 4;
-
-    if( ioFlags & CV_EIGOBJ_INPUT_CALLBACK )    /* ==== USE INPUT CALLBACK ==== */
-    {
-        int nio, ngr, igr, n = size.width * size.height, mm = 0;
-        CvCallback read_callback = ((CvInput *) & input)->callback;
-        uchar *buffer2;
-
-        objStep = n;
-        nio = ioBufSize / n;    /* number of objects in buffer */
-        ngr = nObjects / nio;   /* number of io groups */
-        if( nObjects % nio )
-            mm = 1;
-        ngr += mm;
-
-        buffer2 = (uchar *)cvAlloc( sizeof( uchar ) * n );
-        if( buffer2 == NULL )
-            return CV_OUTOFMEM_ERR;
-
-        for( igr = 0; igr < ngr; igr++ )
-        {
-            int k, l;
-            int io, jo, imin = igr * nio, imax = imin + nio;
-            uchar *bu1 = buffer, *bu2;
-
-            if( imax > nObjects )
-                imax = nObjects;
-
-            /* read igr group */
-            for( io = imin; io < imax; io++, bu1 += n )
-            {
-                CvStatus r;
-
-                r = (CvStatus)read_callback( io, (void *) bu1, userData );
-                if( r )
-                    return r;
-            }
-
-            /* diagonal square calc */
-            bu1 = buffer;
-            for( io = imin; io < imax; io++, bu1 += n )
-            {
-                bu2 = bu1;
-                for( jo = io; jo < imax; jo++, bu2 += n )
-                {
-                    float w = 0.f;
-                    float *fu = avg;
-                    int ij = 0;
-
-                    for( k = 0; k < size.height; k++, fu += avgStep )
-                        for( l = 0; l < size.width; l++, ij++ )
-                        {
-                            float f = fu[l], u1 = bu1[ij], u2 = bu2[ij];
-
-                            w += (u1 - f) * (u2 - f);
-                        }
-                    covarMatrix[io * nObjects + jo] = covarMatrix[jo * nObjects + io] = w;
-                }
-            }
-
-            /* non-diagonal elements calc */
-            for( jo = imax; jo < nObjects; jo++ )
-            {
-                CvStatus r;
-
-                bu1 = buffer;
-                bu2 = buffer2;
-
-                /* read jo object */
-                r = (CvStatus)read_callback( jo, (void *) bu2, userData );
-                if( r )
-                    return r;
-
-                for( io = imin; io < imax; io++, bu1 += n )
-                {
-                    float w = 0.f;
-                    float *fu = avg;
-                    int ij = 0;
-
-                    for( k = 0; k < size.height; k++, fu += avgStep )
-                    {
-                        for( l = 0; l < size.width - 3; l += 4, ij += 4 )
-                        {
-                            float f = fu[l];
-                            uchar u1 = bu1[ij];
-                            uchar u2 = bu2[ij];
-
-                            w += (u1 - f) * (u2 - f);
-                            f = fu[l + 1];
-                            u1 = bu1[ij + 1];
-                            u2 = bu2[ij + 1];
-                            w += (u1 - f) * (u2 - f);
-                            f = fu[l + 2];
-                            u1 = bu1[ij + 2];
-                            u2 = bu2[ij + 2];
-                            w += (u1 - f) * (u2 - f);
-                            f = fu[l + 3];
-                            u1 = bu1[ij + 3];
-                            u2 = bu2[ij + 3];
-                            w += (u1 - f) * (u2 - f);
-                        }
-                        for( ; l < size.width; l++, ij++ )
-                        {
-                            float f = fu[l], u1 = bu1[ij], u2 = bu2[ij];
-
-                            w += (u1 - f) * (u2 - f);
-                        }
-                    }
-                    covarMatrix[io * nObjects + jo] = covarMatrix[jo * nObjects + io] = w;
-                }
-            }
-        }                       /* igr */
-
-        cvFree( &buffer2 );
-    }                           /* if() */
-
-    else
-        /* ==== NOT USE INPUT CALLBACK ==== */
-    {
-        int i, j;
-        uchar **objects = (uchar **) (((CvInput *) & input)->data);
-
-        for( i = 0; i < nObjects; i++ )
-        {
-            uchar *bu = objects[i];
-
-            for( j = i; j < nObjects; j++ )
-            {
-                int k, l;
-                float w = 0.f;
-                float *a = avg;
-                uchar *bu1 = bu;
-                uchar *bu2 = objects[j];
-
-                for( k = 0; k < size.height;
-                     k++, bu1 += objStep, bu2 += objStep, a += avgStep )
-                {
-                    for( l = 0; l < size.width - 3; l += 4 )
-                    {
-                        float f = a[l];
-                        uchar u1 = bu1[l];
-                        uchar u2 = bu2[l];
-
-                        w += (u1 - f) * (u2 - f);
-                        f = a[l + 1];
-                        u1 = bu1[l + 1];
-                        u2 = bu2[l + 1];
-                        w += (u1 - f) * (u2 - f);
-                        f = a[l + 2];
-                        u1 = bu1[l + 2];
-                        u2 = bu2[l + 2];
-                        w += (u1 - f) * (u2 - f);
-                        f = a[l + 3];
-                        u1 = bu1[l + 3];
-                        u2 = bu2[l + 3];
-                        w += (u1 - f) * (u2 - f);
-                    }
-                    for( ; l < size.width; l++ )
-                    {
-                        float f = a[l];
-                        uchar u1 = bu1[l];
-                        uchar u2 = bu2[l];
-
-                        w += (u1 - f) * (u2 - f);
-                    }
-                }
-
-                covarMatrix[i * nObjects + j] = covarMatrix[j * nObjects + i] = w;
-            }
-        }
-    }                           /* else */
-
-    return CV_NO_ERR;
-}
-
-/*======================== end of icvCalcCovarMatrixEx_8u32fR ===========================*/
-
-
-static int
-icvDefaultBufferSize( void )
-{
-    return 10 * 1024 * 1024;
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvCalcEigenObjects_8u32fR
-//    Purpose: The function calculates an orthonormal eigen basis and a mean (averaged)
-//             object for a group of input objects (images, vectors, etc.). ROI supported.
-//    Context:
-//    Parameters: nObjects  - number of source objects
-//                input     - pointer either to array of pointers to input objects
-//                            or to read callback function (depending on ioFlags)
-//                imgStep   - full width of each source object row in bytes
-//                output    - pointer either to array of pointers to output eigen objects
-//                            or to write callback function (depending on ioFlags)
-//                eigStep   - full width of each eigenobject row in bytes
-//                size      - ROI size of each source object
-//                ioFlags   - input/output flags (see Notes)
-//                ioBufSize - input/output buffer size
-//                userData  - pointer to the structure which contains all necessary
-//                            data for the callback functions
-//                calcLimit - determines the calculation finish conditions
-//                avg       - pointer to averaged object (has the same size as ROI)
-//                avgStep   - full width of averaged object row in bytes
-//                eigVals   - pointer to corresponding eigenvalues (array of <nObjects>
-//                            elements in descending order)
-//
-//    Returns: CV_NO_ERR or error code
-//
-//    Notes: 1. input/output data (that is, input objects and eigen ones) may either
-//              be allocated in the RAM or be read from/written to the HDD (or any
-//              other device) by read/write callback functions. It depends on the
-//              value of ioFlags paramater, which may be the following:
-//                  CV_EIGOBJ_NO_CALLBACK, or 0;
-//                  CV_EIGOBJ_INPUT_CALLBACK;
-//                  CV_EIGOBJ_OUTPUT_CALLBACK;
-//                  CV_EIGOBJ_BOTH_CALLBACK, or
-//                            CV_EIGOBJ_INPUT_CALLBACK | CV_EIGOBJ_OUTPUT_CALLBACK.
-//              The callback functions as well as the user data structure must be
-//              developed by the user.
-//
-//           2. If ioBufSize = 0, or it's too large, the function dermines buffer size
-//              itself.
-//
-//           3. Depending on calcLimit parameter, calculations are finished either if
-//              eigenfaces number comes up to certain value or the relation of the
-//              current eigenvalue and the largest one comes down to certain value
-//              (or any of the above conditions takes place). The calcLimit->type value
-//              must be CV_TERMCRIT_NUMB, CV_TERMCRIT_EPS or
-//              CV_TERMCRIT_NUMB | CV_TERMCRIT_EPS. The function returns the real
-//              values calcLimit->max_iter and calcLimit->epsilon.
-//
-//           4. eigVals may be equal to NULL (if you don't need eigen values in further).
-//
-//F*/
-static CvStatus CV_STDCALL
-icvCalcEigenObjects_8u32fR( int nObjects, void* input, int objStep,
-                            void* output, int eigStep, CvSize size,
-                            int  ioFlags, int ioBufSize, void* userData,
-                            CvTermCriteria* calcLimit, float* avg,
-                            int    avgStep, float  *eigVals )
-{
-    int i, j, n, iev = 0, m1 = nObjects - 1, objStep1 = objStep, eigStep1 = eigStep / 4;
-    CvSize objSize, eigSize, avgSize;
-    float *c = 0;
-    float *ev = 0;
-    float *bf = 0;
-    uchar *buf = 0;
-    void *buffer = 0;
-    float m = 1.0f / (float) nObjects;
-    CvStatus r;
-
-    if( m1 > calcLimit->max_iter && calcLimit->type != CV_TERMCRIT_EPS )
-        m1 = calcLimit->max_iter;
-
-    /* ---- TEST OF PARAMETERS ---- */
-
-    if( nObjects < 2 )
-        return CV_BADFACTOR_ERR;
-    if( ioFlags < 0 || ioFlags > 3 )
-        return CV_BADFACTOR_ERR;
-    if( input == NULL || output == NULL || avg == NULL )
-        return CV_NULLPTR_ERR;
-    if( size.width > objStep || 4 * size.width > eigStep ||
-        4 * size.width > avgStep || size.height < 1 )
-        return CV_BADSIZE_ERR;
-    if( !(ioFlags & CV_EIGOBJ_INPUT_CALLBACK) )
-        for( i = 0; i < nObjects; i++ )
-            if( ((uchar **) input)[i] == NULL )
-                return CV_NULLPTR_ERR;
-    if( !(ioFlags & CV_EIGOBJ_OUTPUT_CALLBACK) )
-        for( i = 0; i < m1; i++ )
-            if( ((float **) output)[i] == NULL )
-                return CV_NULLPTR_ERR;
-
-    avgStep /= 4;
-    eigStep /= 4;
-
-    if( objStep == size.width && eigStep == size.width && avgStep == size.width )
-    {
-        size.width *= size.height;
-        size.height = 1;
-        objStep = objStep1 = eigStep = eigStep1 = avgStep = size.width;
-    }
-    objSize = eigSize = avgSize = size;
-
-    if( ioFlags & CV_EIGOBJ_INPUT_CALLBACK )
-    {
-        objSize.width *= objSize.height;
-        objSize.height = 1;
-        objStep = objSize.width;
-        objStep1 = size.width;
-    }
-
-    if( ioFlags & CV_EIGOBJ_OUTPUT_CALLBACK )
-    {
-        eigSize.width *= eigSize.height;
-        eigSize.height = 1;
-        eigStep = eigSize.width;
-        eigStep1 = size.width;
-    }
-
-    n = objSize.height * objSize.width * (ioFlags & CV_EIGOBJ_INPUT_CALLBACK) +
-        2 * eigSize.height * eigSize.width * (ioFlags & CV_EIGOBJ_OUTPUT_CALLBACK);
-
-    /* Buffer size determination */
-    if( ioFlags )
-    {
-        ioBufSize = MIN( icvDefaultBufferSize(), n );
-    }
-
-    /* memory allocation (if necesseay) */
-
-    if( ioFlags & CV_EIGOBJ_INPUT_CALLBACK )
-    {
-        buf = (uchar *) cvAlloc( sizeof( uchar ) * objSize.width );
-        if( buf == NULL )
-            return CV_OUTOFMEM_ERR;
-    }
-
-    if( ioFlags )
-    {
-        buffer = (void *) cvAlloc( ioBufSize );
-        if( buffer == NULL )
-        {
-            if( buf )
-                cvFree( &buf );
-            return CV_OUTOFMEM_ERR;
-        }
-    }
-
-    /* Calculation of averaged object */
-    bf = avg;
-    for( i = 0; i < avgSize.height; i++, bf += avgStep )
-        for( j = 0; j < avgSize.width; j++ )
-            bf[j] = 0.f;
-
-    for( i = 0; i < nObjects; i++ )
-    {
-        int k, l;
-        uchar *bu = (ioFlags & CV_EIGOBJ_INPUT_CALLBACK) ? buf : ((uchar **) input)[i];
-
-        if( ioFlags & CV_EIGOBJ_INPUT_CALLBACK )
-        {
-            CvCallback read_callback = ((CvInput *) & input)->callback;
-
-            r = (CvStatus)read_callback( i, (void *) buf, userData );
-            if( r )
-            {
-                if( buffer )
-                    cvFree( &buffer );
-                if( buf )
-                    cvFree( &buf );
-                return r;
-            }
-        }
-
-        bf = avg;
-        for( k = 0; k < avgSize.height; k++, bf += avgStep, bu += objStep1 )
-            for( l = 0; l < avgSize.width; l++ )
-                bf[l] += bu[l];
-    }
-
-    bf = avg;
-    for( i = 0; i < avgSize.height; i++, bf += avgStep )
-        for( j = 0; j < avgSize.width; j++ )
-            bf[j] *= m;
-
-    /* Calculation of covariance matrix */
-    c = (float *) cvAlloc( sizeof( float ) * nObjects * nObjects );
-
-    if( c == NULL )
-    {
-        if( buffer )
-            cvFree( &buffer );
-        if( buf )
-            cvFree( &buf );
-        return CV_OUTOFMEM_ERR;
-    }
-
-    r = icvCalcCovarMatrixEx_8u32fR( nObjects, input, objStep1, ioFlags, ioBufSize,
-                                      (uchar *) buffer, userData, avg, 4 * avgStep, size, c );
-    if( r )
-    {
-        cvFree( &c );
-        if( buffer )
-            cvFree( &buffer );
-        if( buf )
-            cvFree( &buf );
-        return r;
-    }
-
-    /* Calculation of eigenvalues & eigenvectors */
-    ev = (float *) cvAlloc( sizeof( float ) * nObjects * nObjects );
-
-    if( ev == NULL )
-    {
-        cvFree( &c );
-        if( buffer )
-            cvFree( &buffer );
-        if( buf )
-            cvFree( &buf );
-        return CV_OUTOFMEM_ERR;
-    }
-
-    if( eigVals == NULL )
-    {
-        eigVals = (float *) cvAlloc( sizeof( float ) * nObjects );
-
-        if( eigVals == NULL )
-        {
-            cvFree( &c );
-            cvFree( &ev );
-            if( buffer )
-                cvFree( &buffer );
-            if( buf )
-                cvFree( &buf );
-            return CV_OUTOFMEM_ERR;
-        }
-        iev = 1;
-    }
-
-    r = icvJacobiEigens_32f( c, ev, eigVals, nObjects, 0.0f );
-    cvFree( &c );
-    if( r )
-    {
-        cvFree( &ev );
-        if( buffer )
-            cvFree( &buffer );
-        if( buf )
-            cvFree( &buf );
-        if( iev )
-            cvFree( &eigVals );
-        return r;
-    }
-
-    /* Eigen objects number determination */
-    if( calcLimit->type != CV_TERMCRIT_NUMBER )
-    {
-        for( i = 0; i < m1; i++ )
-            if( fabs( eigVals[i] / eigVals[0] ) < calcLimit->epsilon )
-                break;
-        m1 = calcLimit->max_iter = i;
-    }
-    else
-        m1 = calcLimit->max_iter;
-    calcLimit->epsilon = (float) fabs( eigVals[m1 - 1] / eigVals[0] );
-
-    for( i = 0; i < m1; i++ )
-        eigVals[i] = (float) (1.0 / sqrt( (double)eigVals[i] ));
-
-    /* ----------------- Calculation of eigenobjects ----------------------- */
-    if( ioFlags & CV_EIGOBJ_OUTPUT_CALLBACK )
-    {
-        int nio, ngr, igr;
-
-        nio = ioBufSize / (4 * eigSize.width);  /* number of eigen objects in buffer */
-        ngr = m1 / nio;         /* number of io groups */
-        if( nObjects % nio )
-            ngr += 1;
-
-        for( igr = 0; igr < ngr; igr++ )
-        {
-            int io, ie, imin = igr * nio, imax = imin + nio;
-
-            if( imax > m1 )
-                imax = m1;
-
-            for(int k = 0; k < eigSize.width * (imax - imin); k++ )
-                ((float *) buffer)[k] = 0.f;
-
-            for( io = 0; io < nObjects; io++ )
-            {
-                uchar *bu = ioFlags & CV_EIGOBJ_INPUT_CALLBACK ? buf : ((uchar **) input)[io];
-
-                if( ioFlags & CV_EIGOBJ_INPUT_CALLBACK )
-                {
-                    CvCallback read_callback = ((CvInput *) & input)->callback;
-
-                    r = (CvStatus)read_callback( io, (void *) buf, userData );
-                    if( r )
-                    {
-                        cvFree( &ev );
-                        if( iev )
-                            cvFree( &eigVals );
-                        if( buffer )
-                            cvFree( &buffer );
-                        if( buf )
-                            cvFree( &buf );
-                        return r;
-                    }
-                }
-
-                for( ie = imin; ie < imax; ie++ )
-                {
-                    int k, l;
-                    uchar *bv = bu;
-                    float e = ev[ie * nObjects + io] * eigVals[ie];
-                    float *be = ((float *) buffer) + ((ie - imin) * eigStep);
-
-                    bf = avg;
-                    for( k = 0; k < size.height; k++, bv += objStep1,
-                         bf += avgStep, be += eigStep1 )
-                    {
-                        for( l = 0; l < size.width - 3; l += 4 )
-                        {
-                            float f = bf[l];
-                            uchar v = bv[l];
-
-                            be[l] += e * (v - f);
-                            f = bf[l + 1];
-                            v = bv[l + 1];
-                            be[l + 1] += e * (v - f);
-                            f = bf[l + 2];
-                            v = bv[l + 2];
-                            be[l + 2] += e * (v - f);
-                            f = bf[l + 3];
-                            v = bv[l + 3];
-                            be[l + 3] += e * (v - f);
-                        }
-                        for( ; l < size.width; l++ )
-                            be[l] += e * (bv[l] - bf[l]);
-                    }
-                }
-            }                   /* io */
-
-            for( ie = imin; ie < imax; ie++ )   /* calculated eigen objects writting */
-            {
-                CvCallback write_callback = ((CvInput *) & output)->callback;
-                float *be = ((float *) buffer) + ((ie - imin) * eigStep);
-
-                r = (CvStatus)write_callback( ie, (void *) be, userData );
-                if( r )
-                {
-                    cvFree( &ev );
-                    if( iev )
-                        cvFree( &eigVals );
-                    if( buffer )
-                        cvFree( &buffer );
-                    if( buf )
-                        cvFree( &buf );
-                    return r;
-                }
-            }
-        }                       /* igr */
-    }
-
-    else
-    {
-        int k, p, l;
-
-        for( i = 0; i < m1; i++ )       /* e.o. annulation */
-        {
-            float *be = ((float **) output)[i];
-
-            for( p = 0; p < eigSize.height; p++, be += eigStep )
-                for( l = 0; l < eigSize.width; l++ )
-                    be[l] = 0.0f;
-        }
-
-        for( k = 0; k < nObjects; k++ )
-        {
-            uchar *bv = (ioFlags & CV_EIGOBJ_INPUT_CALLBACK) ? buf : ((uchar **) input)[k];
-
-            if( ioFlags & CV_EIGOBJ_INPUT_CALLBACK )
-            {
-                CvCallback read_callback = ((CvInput *) & input)->callback;
-
-                r = (CvStatus)read_callback( k, (void *) buf, userData );
-                if( r )
-                {
-                    cvFree( &ev );
-                    if( iev )
-                        cvFree( &eigVals );
-                    if( buffer )
-                        cvFree( &buffer );
-                    if( buf )
-                        cvFree( &buf );
-                    return r;
-                }
-            }
-
-            for( i = 0; i < m1; i++ )
-            {
-                float v = eigVals[i] * ev[i * nObjects + k];
-                float *be = ((float **) output)[i];
-                uchar *bu = bv;
-
-                bf = avg;
-
-                for( p = 0; p < size.height; p++, bu += objStep1,
-                     bf += avgStep, be += eigStep1 )
-                {
-                    for( l = 0; l < size.width - 3; l += 4 )
-                    {
-                        float f = bf[l];
-                        uchar u = bu[l];
-
-                        be[l] += v * (u - f);
-                        f = bf[l + 1];
-                        u = bu[l + 1];
-                        be[l + 1] += v * (u - f);
-                        f = bf[l + 2];
-                        u = bu[l + 2];
-                        be[l + 2] += v * (u - f);
-                        f = bf[l + 3];
-                        u = bu[l + 3];
-                        be[l + 3] += v * (u - f);
-                    }
-                    for( ; l < size.width; l++ )
-                        be[l] += v * (bu[l] - bf[l]);
-                }
-            }                   /* i */
-        }                       /* k */
-    }                           /* else */
-
-    cvFree( &ev );
-    if( iev )
-        cvFree( &eigVals );
-    else
-        for( i = 0; i < m1; i++ )
-            eigVals[i] = 1.f / (eigVals[i] * eigVals[i]);
-    if( buffer )
-        cvFree( &buffer );
-    if( buf )
-        cvFree( &buf );
-    return CV_NO_ERR;
-}
-
-/* --- End of icvCalcEigenObjects_8u32fR --- */
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvCalcDecompCoeff_8u32fR
-//    Purpose: The function calculates one decomposition coefficient of input object
-//             using previously calculated eigen object and the mean (averaged) object
-//    Context:
-//    Parameters:  obj     - input object
-//                 objStep - its step (in bytes)
-//                 eigObj  - pointer to eigen object
-//                 eigStep - its step (in bytes)
-//                 avg     - pointer to averaged object
-//                 avgStep - its step (in bytes)
-//                 size    - ROI size of each source object
-//
-//    Returns: decomposition coefficient value or large negative value (if error)
-//
-//    Notes:
-//F*/
-static float CV_STDCALL
-icvCalcDecompCoeff_8u32fR( uchar* obj, int objStep,
-                           float *eigObj, int eigStep,
-                           float *avg, int avgStep, CvSize size )
-{
-    int i, k;
-    float w = 0.0f;
-
-    if( size.width > objStep || 4 * size.width > eigStep
-        || 4 * size.width > avgStep || size.height < 1 )
-        return -1.0e30f;
-    if( obj == NULL || eigObj == NULL || avg == NULL )
-        return -1.0e30f;
-
-    eigStep /= 4;
-    avgStep /= 4;
-
-    if( size.width == objStep && size.width == eigStep && size.width == avgStep )
-    {
-        size.width *= size.height;
-        size.height = 1;
-        objStep = eigStep = avgStep = size.width;
-    }
-
-    for( i = 0; i < size.height; i++, obj += objStep, eigObj += eigStep, avg += avgStep )
-    {
-        for( k = 0; k < size.width - 4; k += 4 )
-        {
-            float o = (float) obj[k];
-            float e = eigObj[k];
-            float a = avg[k];
-
-            w += e * (o - a);
-            o = (float) obj[k + 1];
-            e = eigObj[k + 1];
-            a = avg[k + 1];
-            w += e * (o - a);
-            o = (float) obj[k + 2];
-            e = eigObj[k + 2];
-            a = avg[k + 2];
-            w += e * (o - a);
-            o = (float) obj[k + 3];
-            e = eigObj[k + 3];
-            a = avg[k + 3];
-            w += e * (o - a);
-        }
-        for( ; k < size.width; k++ )
-            w += eigObj[k] * ((float) obj[k] - avg[k]);
-    }
-
-    return w;
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Names: icvEigenDecomposite_8u32fR
-//    Purpose: The function calculates all decomposition coefficients for input object
-//             using previously calculated eigen objects basis and the mean (averaged)
-//             object
-//    Context:
-//    Parameters:  obj         - input object
-//                 objStep     - its step (in bytes)
-//                 nEigObjs    - number of eigen objects
-//                 eigInput    - pointer either to array of pointers to eigen objects
-//                               or to read callback function (depending on ioFlags)
-//                 eigStep     - eigen objects step (in bytes)
-//                 ioFlags     - input/output flags
-//                 iserData    - pointer to the structure which contains all necessary
-//                               data for the callback function
-//                 avg         - pointer to averaged object
-//                 avgStep     - its step (in bytes)
-//                 size        - ROI size of each source object
-//                 coeffs      - calculated coefficients (output data)
-//
-//    Returns: icv status
-//
-//    Notes:   see notes for icvCalcEigenObjects_8u32fR function
-//F*/
-static CvStatus CV_STDCALL
-icvEigenDecomposite_8u32fR( uchar * obj, int objStep, int nEigObjs,
-                            void *eigInput, int eigStep, int ioFlags,
-                            void *userData, float *avg, int avgStep,
-                            CvSize size, float *coeffs )
-{
-    int i;
-
-    if( nEigObjs < 2 )
-        return CV_BADFACTOR_ERR;
-    if( ioFlags < 0 || ioFlags > 1 )
-        return CV_BADFACTOR_ERR;
-    if( size.width > objStep || 4 * size.width > eigStep ||
-        4 * size.width > avgStep || size.height < 1 )
-        return CV_BADSIZE_ERR;
-    if( obj == NULL || eigInput == NULL || coeffs == NULL || avg == NULL )
-        return CV_NULLPTR_ERR;
-    if( !ioFlags )
-        for( i = 0; i < nEigObjs; i++ )
-            if( ((uchar **) eigInput)[i] == NULL )
-                return CV_NULLPTR_ERR;
-
-    if( ioFlags )               /* callback */
-
-    {
-        float *buffer;
-        CvCallback read_callback = ((CvInput *) & eigInput)->callback;
-
-        eigStep = 4 * size.width;
-
-        /* memory allocation */
-        buffer = (float *) cvAlloc( sizeof( float ) * size.width * size.height );
-
-        if( buffer == NULL )
-            return CV_OUTOFMEM_ERR;
-
-        for( i = 0; i < nEigObjs; i++ )
-        {
-            float w;
-            CvStatus r = (CvStatus)read_callback( i, (void *) buffer, userData );
-
-            if( r )
-            {
-                cvFree( &buffer );
-                return r;
-            }
-            w = icvCalcDecompCoeff_8u32fR( obj, objStep, buffer,
-                                            eigStep, avg, avgStep, size );
-            if( w < -1.0e29f )
-            {
-                cvFree( &buffer );
-                return CV_NOTDEFINED_ERR;
-            }
-            coeffs[i] = w;
-        }
-        cvFree( &buffer );
-    }
-
-    else
-        /* no callback */
-        for( i = 0; i < nEigObjs; i++ )
-        {
-            float w = icvCalcDecompCoeff_8u32fR( obj, objStep, ((float **) eigInput)[i],
-                                                  eigStep, avg, avgStep, size );
-
-            if( w < -1.0e29f )
-                return CV_NOTDEFINED_ERR;
-            coeffs[i] = w;
-        }
-
-    return CV_NO_ERR;
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Names: icvEigenProjection_8u32fR
-//    Purpose: The function calculates object projection to the eigen sub-space (restores
-//             an object) using previously calculated eigen objects basis, mean (averaged)
-//             object and decomposition coefficients of the restored object
-//    Context:
-//    Parameters:  nEigObjs - Number of eigen objects
-//                 eigens   - Array of pointers to eigen objects
-//                 eigStep  - Eigen objects step (in bytes)
-//                 coeffs   - Previously calculated decomposition coefficients
-//                 avg      - Pointer to averaged object
-//                 avgStep  - Its step (in bytes)
-//                 rest     - Pointer to restored object
-//                 restStep - Its step (in bytes)
-//                 size     - ROI size of each object
-//
-//    Returns: CV status
-//
-//    Notes:
-//F*/
-static CvStatus CV_STDCALL
-icvEigenProjection_8u32fR( int nEigObjs, void *eigInput, int eigStep,
-                           int ioFlags, void *userData, float *coeffs,
-                           float *avg, int avgStep, uchar * rest,
-                           int restStep, CvSize size )
-{
-    int i, j, k;
-    float *buf;
-    float *buffer = NULL;
-    float *b;
-    CvCallback read_callback = ((CvInput *) & eigInput)->callback;
-
-    if( size.width > avgStep || 4 * size.width > eigStep || size.height < 1 )
-        return CV_BADSIZE_ERR;
-    if( rest == NULL || eigInput == NULL || avg == NULL || coeffs == NULL )
-        return CV_NULLPTR_ERR;
-    if( ioFlags < 0 || ioFlags > 1 )
-        return CV_BADFACTOR_ERR;
-    if( !ioFlags )
-        for( i = 0; i < nEigObjs; i++ )
-            if( ((uchar **) eigInput)[i] == NULL )
-                return CV_NULLPTR_ERR;
-    eigStep /= 4;
-    avgStep /= 4;
-
-    if( size.width == restStep && size.width == eigStep && size.width == avgStep )
-    {
-        size.width *= size.height;
-        size.height = 1;
-        restStep = eigStep = avgStep = size.width;
-    }
-
-    buf = (float *) cvAlloc( sizeof( float ) * size.width * size.height );
-
-    if( buf == NULL )
-        return CV_OUTOFMEM_ERR;
-    b = buf;
-    for( i = 0; i < size.height; i++, avg += avgStep, b += size.width )
-        for( j = 0; j < size.width; j++ )
-            b[j] = avg[j];
-
-    if( ioFlags )
-    {
-        buffer = (float *) cvAlloc( sizeof( float ) * size.width * size.height );
-
-        if( buffer == NULL )
-        {
-            cvFree( &buf );
-            return CV_OUTOFMEM_ERR;
-        }
-        eigStep = size.width;
-    }
-
-    for( k = 0; k < nEigObjs; k++ )
-    {
-        float *e = ioFlags ? buffer : ((float **) eigInput)[k];
-        float c = coeffs[k];
-
-        if( ioFlags )           /* read eigen object */
-        {
-            CvStatus r = (CvStatus)read_callback( k, (void *) buffer, userData );
-
-            if( r )
-            {
-                cvFree( &buf );
-                cvFree( &buffer );
-                return r;
-            }
-        }
-
-        b = buf;
-        for( i = 0; i < size.height; i++, e += eigStep, b += size.width )
-        {
-            for( j = 0; j < size.width - 3; j += 4 )
-            {
-                float b0 = c * e[j];
-                float b1 = c * e[j + 1];
-                float b2 = c * e[j + 2];
-                float b3 = c * e[j + 3];
-
-                b[j] += b0;
-                b[j + 1] += b1;
-                b[j + 2] += b2;
-                b[j + 3] += b3;
-            }
-            for( ; j < size.width; j++ )
-                b[j] += c * e[j];
-        }
-    }
-
-    b = buf;
-    for( i = 0; i < size.height; i++, avg += avgStep, b += size.width, rest += restStep )
-        for( j = 0; j < size.width; j++ )
-        {
-            int w = cvRound( b[j] );
-
-            w = !(w & ~255) ? w : w < 0 ? 0 : 255;
-            rest[j] = (uchar) w;
-        }
-
-    cvFree( &buf );
-    if( ioFlags )
-        cvFree( &buffer );
-    return CV_NO_ERR;
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: cvCalcCovarMatrixEx
-//    Purpose: The function calculates a covariance matrix for a group of input objects
-//             (images, vectors, etc.).
-//    Context:
-//    Parameters:  nObjects    - number of source objects
-//                 input       - pointer either to array of input objects
-//                               or to read callback function (depending on ioFlags)
-//                 ioFlags     - input/output flags (see Notes to
-//                               cvCalcEigenObjects function)
-//                 ioBufSize   - input/output buffer size
-//                 userData    - pointer to the structure which contains all necessary
-//                               data for the callback functions
-//                 avg         - averaged object
-//                 covarMatrix - covariance matrix (output parameter; must be allocated
-//                               before call)
-//
-//    Notes:  See Notes to cvCalcEigenObjects function
-//F*/
-
-CV_IMPL void
-cvCalcCovarMatrixEx( int  nObjects, void*  input, int  ioFlags,
-                     int  ioBufSize, uchar*  buffer, void*  userData,
-                     IplImage* avg, float*  covarMatrix )
-{
-    float *avg_data;
-    int avg_step = 0;
-    CvSize avg_size;
-    int i;
-
-    CV_FUNCNAME( "cvCalcCovarMatrixEx" );
-
-    __BEGIN__;
-
-    cvGetImageRawData( avg, (uchar **) & avg_data, &avg_step, &avg_size );
-    if( avg->depth != IPL_DEPTH_32F )
-        CV_ERROR( CV_BadDepth, "Unsupported format" );
-    if( avg->nChannels != 1 )
-        CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-
-    if( ioFlags == CV_EIGOBJ_NO_CALLBACK )
-    {
-        IplImage **images = (IplImage **) (((CvInput *) & input)->data);
-        uchar **objects = (uchar **) cvAlloc( sizeof( uchar * ) * nObjects );
-        int img_step = 0, old_step = 0;
-        CvSize img_size = avg_size, old_size = avg_size;
-
-        if( objects == NULL )
-            CV_ERROR( CV_StsBadArg, "Insufficient memory" );
-
-        for( i = 0; i < nObjects; i++ )
-        {
-            IplImage *img = images[i];
-            uchar *img_data;
-
-            cvGetImageRawData( img, &img_data, &img_step, &img_size );
-            if( img->depth != IPL_DEPTH_8U )
-                CV_ERROR( CV_BadDepth, "Unsupported format" );
-            if( img_size != avg_size || img_size != old_size )
-                CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
-            if( img->nChannels != 1 )
-                CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-            if( i > 0 && img_step != old_step )
-                CV_ERROR( CV_StsBadArg, "Different steps of objects" );
-
-            old_step = img_step;
-            old_size = img_size;
-            objects[i] = img_data;
-        }
-
-        CV_CALL( icvCalcCovarMatrixEx_8u32fR( nObjects,
-                                              (void*) objects,
-                                              img_step,
-                                              CV_EIGOBJ_NO_CALLBACK,
-                                              0,
-                                              NULL,
-                                              NULL,
-                                              avg_data,
-                                              avg_step,
-                                              avg_size,
-                                              covarMatrix ));
-        cvFree( &objects );
-    }
-
-    else
-
-    {
-        CV_CALL( icvCalcCovarMatrixEx_8u32fR( nObjects,
-                                              input,
-                                              avg_step / 4,
-                                              ioFlags,
-                                              ioBufSize,
-                                              buffer,
-                                              userData,
-                                              avg_data,
-                                              avg_step,
-                                              avg_size,
-                                              covarMatrix ));
-    }
-
-    __END__;
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: cvCalcEigenObjects
-//    Purpose: The function calculates an orthonormal eigen basis and a mean (averaged)
-//             object for a group of input objects (images, vectors, etc.).
-//    Context:
-//    Parameters: nObjects  - number of source objects
-//                input     - pointer either to array of input objects
-//                            or to read callback function (depending on ioFlags)
-//                output    - pointer either to output eigen objects
-//                            or to write callback function (depending on ioFlags)
-//                ioFlags   - input/output flags (see Notes)
-//                ioBufSize - input/output buffer size
-//                userData  - pointer to the structure which contains all necessary
-//                            data for the callback functions
-//                calcLimit - determines the calculation finish conditions
-//                avg       - averaged object (has the same size as ROI)
-//                eigVals   - pointer to corresponding eigen values (array of <nObjects>
-//                            elements in descending order)
-//
-//    Notes: 1. input/output data (that is, input objects and eigen ones) may either
-//              be allocated in the RAM or be read from/written to the HDD (or any
-//              other device) by read/write callback functions. It depends on the
-//              value of ioFlags paramater, which may be the following:
-//                  CV_EIGOBJ_NO_CALLBACK, or 0;
-//                  CV_EIGOBJ_INPUT_CALLBACK;
-//                  CV_EIGOBJ_OUTPUT_CALLBACK;
-//                  CV_EIGOBJ_BOTH_CALLBACK, or
-//                            CV_EIGOBJ_INPUT_CALLBACK | CV_EIGOBJ_OUTPUT_CALLBACK.
-//              The callback functions as well as the user data structure must be
-//              developed by the user.
-//
-//           2. If ioBufSize = 0, or it's too large, the function dermines buffer size
-//              itself.
-//
-//           3. Depending on calcLimit parameter, calculations are finished either if
-//              eigenfaces number comes up to certain value or the relation of the
-//              current eigenvalue and the largest one comes down to certain value
-//              (or any of the above conditions takes place). The calcLimit->type value
-//              must be CV_TERMCRIT_NUMB, CV_TERMCRIT_EPS or
-//              CV_TERMCRIT_NUMB | CV_TERMCRIT_EPS. The function returns the real
-//              values calcLimit->max_iter and calcLimit->epsilon.
-//
-//           4. eigVals may be equal to NULL (if you don't need eigen values in further).
-//
-//F*/
-CV_IMPL void
-cvCalcEigenObjects( int       nObjects,
-                    void*     input,
-                    void*     output,
-                    int       ioFlags,
-                    int       ioBufSize,
-                    void*     userData,
-                    CvTermCriteria* calcLimit,
-                    IplImage* avg,
-                    float*    eigVals )
-{
-    float *avg_data;
-    int avg_step = 0;
-    CvSize avg_size;
-    int i;
-    int nEigens = nObjects - 1;
-
-    CV_FUNCNAME( "cvCalcEigenObjects" );
-
-    __BEGIN__;
-
-    cvGetImageRawData( avg, (uchar **) & avg_data, &avg_step, &avg_size );
-    if( avg->depth != IPL_DEPTH_32F )
-        CV_ERROR( CV_BadDepth, "Unsupported format" );
-    if( avg->nChannels != 1 )
-        CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-
-    if( nEigens > calcLimit->max_iter && calcLimit->type != CV_TERMCRIT_EPS )
-        nEigens = calcLimit->max_iter;
-
-    switch (ioFlags)
-    {
-    case CV_EIGOBJ_NO_CALLBACK:
-        {
-            IplImage **objects = (IplImage **) (((CvInput *) & input)->data);
-            IplImage **eigens = (IplImage **) (((CvInput *) & output)->data);
-            uchar **objs = (uchar **) cvAlloc( sizeof( uchar * ) * nObjects );
-            float **eigs = (float **) cvAlloc( sizeof( float * ) * nEigens );
-            int obj_step = 0, old_step = 0;
-            int eig_step = 0, oldeig_step = 0;
-            CvSize obj_size = avg_size, old_size = avg_size,
-
-                eig_size = avg_size, oldeig_size = avg_size;
-
-            if( objects == NULL || eigens == NULL )
-                CV_ERROR( CV_StsBadArg, "Insufficient memory" );
-
-            for( i = 0; i < nObjects; i++ )
-            {
-                IplImage *img = objects[i];
-                uchar *obj_data;
-
-                cvGetImageRawData( img, &obj_data, &obj_step, &obj_size );
-                if( img->depth != IPL_DEPTH_8U )
-                    CV_ERROR( CV_BadDepth, "Unsupported format" );
-                if( obj_size != avg_size || obj_size != old_size )
-                    CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
-                if( img->nChannels != 1 )
-                    CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-                if( i > 0 && obj_step != old_step )
-                    CV_ERROR( CV_StsBadArg, "Different steps of objects" );
-
-                old_step = obj_step;
-                old_size = obj_size;
-                objs[i] = obj_data;
-            }
-            for( i = 0; i < nEigens; i++ )
-            {
-                IplImage *eig = eigens[i];
-                float *eig_data;
-
-                cvGetImageRawData( eig, (uchar **) & eig_data, &eig_step, &eig_size );
-                if( eig->depth != IPL_DEPTH_32F )
-                    CV_ERROR( CV_BadDepth, "Unsupported format" );
-                if( eig_size != avg_size || eig_size != oldeig_size )
-                    CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
-                if( eig->nChannels != 1 )
-                    CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-                if( i > 0 && eig_step != oldeig_step )
-                    CV_ERROR( CV_StsBadArg, "Different steps of objects" );
-
-                oldeig_step = eig_step;
-                oldeig_size = eig_size;
-                eigs[i] = eig_data;
-            }
-            CV_CALL( icvCalcEigenObjects_8u32fR( nObjects, (void*) objs, obj_step,
-                                                 (void*) eigs, eig_step, obj_size,
-                                                 ioFlags, ioBufSize, userData,
-                                                 calcLimit, avg_data, avg_step, eigVals ));
-            cvFree( &objs );
-            cvFree( &eigs );
-            break;
-        }
-
-    case CV_EIGOBJ_OUTPUT_CALLBACK:
-        {
-            IplImage **objects = (IplImage **) (((CvInput *) & input)->data);
-            uchar **objs = (uchar **) cvAlloc( sizeof( uchar * ) * nObjects );
-            int obj_step = 0, old_step = 0;
-            CvSize obj_size = avg_size, old_size = avg_size;
-
-            if( objects == NULL )
-                CV_ERROR( CV_StsBadArg, "Insufficient memory" );
-
-            for( i = 0; i < nObjects; i++ )
-            {
-                IplImage *img = objects[i];
-                uchar *obj_data;
-
-                cvGetImageRawData( img, &obj_data, &obj_step, &obj_size );
-                if( img->depth != IPL_DEPTH_8U )
-                    CV_ERROR( CV_BadDepth, "Unsupported format" );
-                if( obj_size != avg_size || obj_size != old_size )
-                    CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
-                if( img->nChannels != 1 )
-                    CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-                if( i > 0 && obj_step != old_step )
-                    CV_ERROR( CV_StsBadArg, "Different steps of objects" );
-
-                old_step = obj_step;
-                old_size = obj_size;
-                objs[i] = obj_data;
-            }
-            CV_CALL( icvCalcEigenObjects_8u32fR( nObjects,
-                                                 (void*) objs,
-                                                 obj_step,
-                                                 output,
-                                                 avg_step,
-                                                 obj_size,
-                                                 ioFlags,
-                                                 ioBufSize,
-                                                 userData,
-                                                 calcLimit,
-                                                 avg_data,
-                                                 avg_step,
-                                                 eigVals   ));
-            cvFree( &objs );
-            break;
-        }
-
-    case CV_EIGOBJ_INPUT_CALLBACK:
-        {
-            IplImage **eigens = (IplImage **) (((CvInput *) & output)->data);
-            float **eigs = (float**) cvAlloc( sizeof( float* ) * nEigens );
-            int eig_step = 0, oldeig_step = 0;
-            CvSize eig_size = avg_size, oldeig_size = avg_size;
-
-            if( eigens == NULL )
-                CV_ERROR( CV_StsBadArg, "Insufficient memory" );
-
-            for( i = 0; i < nEigens; i++ )
-            {
-                IplImage *eig = eigens[i];
-                float *eig_data;
-
-                cvGetImageRawData( eig, (uchar **) & eig_data, &eig_step, &eig_size );
-                if( eig->depth != IPL_DEPTH_32F )
-                    CV_ERROR( CV_BadDepth, "Unsupported format" );
-                if( eig_size != avg_size || eig_size != oldeig_size )
-                    CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
-                if( eig->nChannels != 1 )
-                    CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-                if( i > 0 && eig_step != oldeig_step )
-                    CV_ERROR( CV_StsBadArg, "Different steps of objects" );
-
-                oldeig_step = eig_step;
-                oldeig_size = eig_size;
-                eigs[i] = eig_data;
-            }
-            CV_CALL( icvCalcEigenObjects_8u32fR( nObjects,
-                                                 input,
-                                                 avg_step / 4,
-                                                 (void*) eigs,
-                                                 eig_step,
-                                                 eig_size,
-                                                 ioFlags,
-                                                 ioBufSize,
-                                                 userData,
-                                                 calcLimit,
-                                                 avg_data,
-                                                 avg_step,
-                                                 eigVals   ));
-            cvFree( &eigs );
-            break;
-        }
-    case CV_EIGOBJ_INPUT_CALLBACK | CV_EIGOBJ_OUTPUT_CALLBACK:
-
-        CV_CALL( icvCalcEigenObjects_8u32fR( nObjects,
-                                             input,
-                                             avg_step / 4,
-                                             output,
-                                             avg_step,
-                                             avg_size,
-                                             ioFlags,
-                                             ioBufSize,
-                                             userData,
-                                             calcLimit,
-                                             avg_data,
-                                             avg_step,
-                                             eigVals   ));
-        break;
-
-    default:
-        CV_ERROR( CV_StsBadArg, "Unsupported i/o flag" );
-    }
-
-    __END__;
-}
-
-/*--------------------------------------------------------------------------------------*/
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: cvCalcDecompCoeff
-//    Purpose: The function calculates one decomposition coefficient of input object
-//             using previously calculated eigen object and the mean (averaged) object
-//    Context:
-//    Parameters:  obj     - input object
-//                 eigObj  - eigen object
-//                 avg     - averaged object
-//
-//    Returns: decomposition coefficient value or large negative value (if error)
-//
-//    Notes:
-//F*/
-
-CV_IMPL double
-cvCalcDecompCoeff( IplImage * obj, IplImage * eigObj, IplImage * avg )
-{
-    double coeff = DBL_MAX;
-
-    uchar *obj_data;
-    float *eig_data;
-    float *avg_data;
-    int obj_step = 0, eig_step = 0, avg_step = 0;
-    CvSize obj_size, eig_size, avg_size;
-
-    CV_FUNCNAME( "cvCalcDecompCoeff" );
-
-    __BEGIN__;
-
-    cvGetImageRawData( obj, &obj_data, &obj_step, &obj_size );
-    if( obj->depth != IPL_DEPTH_8U )
-        CV_ERROR( CV_BadDepth, "Unsupported format" );
-    if( obj->nChannels != 1 )
-        CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-
-    cvGetImageRawData( eigObj, (uchar **) & eig_data, &eig_step, &eig_size );
-    if( eigObj->depth != IPL_DEPTH_32F )
-        CV_ERROR( CV_BadDepth, "Unsupported format" );
-    if( eigObj->nChannels != 1 )
-        CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-
-    cvGetImageRawData( avg, (uchar **) & avg_data, &avg_step, &avg_size );
-    if( avg->depth != IPL_DEPTH_32F )
-        CV_ERROR( CV_BadDepth, "Unsupported format" );
-    if( avg->nChannels != 1 )
-        CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-
-    if( obj_size != eig_size || obj_size != avg_size )
-        CV_ERROR( CV_StsBadArg, "different sizes of images" );
-
-    coeff = icvCalcDecompCoeff_8u32fR( obj_data, obj_step,
-                                       eig_data, eig_step,
-                                       avg_data, avg_step, obj_size );
-
-    __END__;
-
-    return coeff;
-}
-
-/*--------------------------------------------------------------------------------------*/
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Names: cvEigenDecomposite
-//    Purpose: The function calculates all decomposition coefficients for input object
-//             using previously calculated eigen objects basis and the mean (averaged)
-//             object
-//
-//    Parameters:  obj         - input object
-//                 nEigObjs    - number of eigen objects
-//                 eigInput    - pointer either to array of pointers to eigen objects
-//                               or to read callback function (depending on ioFlags)
-//                 ioFlags     - input/output flags
-//                 userData    - pointer to the structure which contains all necessary
-//                               data for the callback function
-//                 avg         - averaged object
-//                 coeffs      - calculated coefficients (output data)
-//
-//    Notes:   see notes for cvCalcEigenObjects function
-//F*/
-
-CV_IMPL void
-cvEigenDecomposite( IplImage* obj,
-                    int       nEigObjs,
-                    void*     eigInput,
-                    int       ioFlags,
-                    void*     userData,
-                    IplImage* avg,
-                    float*    coeffs )
-{
-    float *avg_data;
-    uchar *obj_data;
-    int avg_step = 0, obj_step = 0;
-    CvSize avg_size, obj_size;
-    int i;
-
-    CV_FUNCNAME( "cvEigenDecomposite" );
-
-    __BEGIN__;
-
-    cvGetImageRawData( avg, (uchar **) & avg_data, &avg_step, &avg_size );
-    if( avg->depth != IPL_DEPTH_32F )
-        CV_ERROR( CV_BadDepth, "Unsupported format" );
-    if( avg->nChannels != 1 )
-        CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-
-    cvGetImageRawData( obj, &obj_data, &obj_step, &obj_size );
-    if( obj->depth != IPL_DEPTH_8U )
-        CV_ERROR( CV_BadDepth, "Unsupported format" );
-    if( obj->nChannels != 1 )
-        CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-
-    if( obj_size != avg_size )
-        CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
-
-    if( ioFlags == CV_EIGOBJ_NO_CALLBACK )
-    {
-        IplImage **eigens = (IplImage **) (((CvInput *) & eigInput)->data);
-        float **eigs = (float **) cvAlloc( sizeof( float * ) * nEigObjs );
-        int eig_step = 0, old_step = 0;
-        CvSize eig_size = avg_size, old_size = avg_size;
-
-        if( eigs == NULL )
-            CV_ERROR( CV_StsBadArg, "Insufficient memory" );
-
-        for( i = 0; i < nEigObjs; i++ )
-        {
-            IplImage *eig = eigens[i];
-            float *eig_data;
-
-            cvGetImageRawData( eig, (uchar **) & eig_data, &eig_step, &eig_size );
-            if( eig->depth != IPL_DEPTH_32F )
-                CV_ERROR( CV_BadDepth, "Unsupported format" );
-            if( eig_size != avg_size || eig_size != old_size )
-                CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
-            if( eig->nChannels != 1 )
-                CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-            if( i > 0 && eig_step != old_step )
-                CV_ERROR( CV_StsBadArg, "Different steps of objects" );
-
-            old_step = eig_step;
-            old_size = eig_size;
-            eigs[i] = eig_data;
-        }
-
-        CV_CALL( icvEigenDecomposite_8u32fR( obj_data,
-                                             obj_step,
-                                             nEigObjs,
-                                             (void*) eigs,
-                                             eig_step,
-                                             ioFlags,
-                                             userData,
-                                             avg_data,
-                                             avg_step,
-                                             obj_size,
-                                             coeffs   ));
-        cvFree( &eigs );
-    }
-
-    else
-
-    {
-        CV_CALL( icvEigenDecomposite_8u32fR( obj_data,
-                                             obj_step,
-                                             nEigObjs,
-                                             eigInput,
-                                             avg_step,
-                                             ioFlags,
-                                             userData,
-                                             avg_data,
-                                             avg_step,
-                                             obj_size,
-                                             coeffs   ));
-    }
-
-    __END__;
-}
-
-/*--------------------------------------------------------------------------------------*/
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: cvEigenProjection
-//    Purpose: The function calculates object projection to the eigen sub-space (restores
-//             an object) using previously calculated eigen objects basis, mean (averaged)
-//             object and decomposition coefficients of the restored object
-//    Context:
-//    Parameters:  nEigObjs    - number of eigen objects
-//                 eigInput    - pointer either to array of pointers to eigen objects
-//                               or to read callback function (depending on ioFlags)
-//                 ioFlags     - input/output flags
-//                 userData    - pointer to the structure which contains all necessary
-//                               data for the callback function
-//                 coeffs      - array of decomposition coefficients
-//                 avg         - averaged object
-//                 proj        - object projection (output data)
-//
-//    Notes:   see notes for cvCalcEigenObjects function
-//F*/
-
-CV_IMPL void
-cvEigenProjection( void*     eigInput,
-                   int       nEigObjs,
-                   int       ioFlags,
-                   void*     userData,
-                   float*    coeffs,
-                   IplImage* avg,
-                   IplImage* proj )
-{
-    float *avg_data;
-    uchar *proj_data;
-    int avg_step = 0, proj_step = 0;
-    CvSize avg_size, proj_size;
-    int i;
-
-    CV_FUNCNAME( "cvEigenProjection" );
-
-    __BEGIN__;
-
-    cvGetImageRawData( avg, (uchar **) & avg_data, &avg_step, &avg_size );
-    if( avg->depth != IPL_DEPTH_32F )
-        CV_ERROR( CV_BadDepth, "Unsupported format" );
-    if( avg->nChannels != 1 )
-        CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-
-    cvGetImageRawData( proj, &proj_data, &proj_step, &proj_size );
-    if( proj->depth != IPL_DEPTH_8U )
-        CV_ERROR( CV_BadDepth, "Unsupported format" );
-    if( proj->nChannels != 1 )
-        CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-
-    if( proj_size != avg_size )
-        CV_ERROR( CV_StsBadArg, "Different sizes of projects" );
-
-    if( ioFlags == CV_EIGOBJ_NO_CALLBACK )
-    {
-        IplImage **eigens = (IplImage**) (((CvInput *) & eigInput)->data);
-        float **eigs = (float**) cvAlloc( sizeof( float * ) * nEigObjs );
-        int eig_step = 0, old_step = 0;
-        CvSize eig_size = avg_size, old_size = avg_size;
-
-        if( eigs == NULL )
-            CV_ERROR( CV_StsBadArg, "Insufficient memory" );
-
-        for( i = 0; i < nEigObjs; i++ )
-        {
-            IplImage *eig = eigens[i];
-            float *eig_data;
-
-            cvGetImageRawData( eig, (uchar **) & eig_data, &eig_step, &eig_size );
-            if( eig->depth != IPL_DEPTH_32F )
-                CV_ERROR( CV_BadDepth, "Unsupported format" );
-            if( eig_size != avg_size || eig_size != old_size )
-                CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
-            if( eig->nChannels != 1 )
-                CV_ERROR( CV_BadNumChannels, "Unsupported format" );
-            if( i > 0 && eig_step != old_step )
-                CV_ERROR( CV_StsBadArg, "Different steps of objects" );
-
-            old_step = eig_step;
-            old_size = eig_size;
-            eigs[i] = eig_data;
-        }
-
-        CV_CALL( icvEigenProjection_8u32fR( nEigObjs,
-                                            (void*) eigs,
-                                            eig_step,
-                                            ioFlags,
-                                            userData,
-                                            coeffs,
-                                            avg_data,
-                                            avg_step,
-                                            proj_data,
-                                            proj_step,
-                                            avg_size   ));
-        cvFree( &eigs );
-    }
-
-    else
-
-    {
-        CV_CALL( icvEigenProjection_8u32fR( nEigObjs,
-                                            eigInput,
-                                            avg_step,
-                                            ioFlags,
-                                            userData,
-                                            coeffs,
-                                            avg_data,
-                                            avg_step,
-                                            proj_data,
-                                            proj_step,
-                                            avg_size   ));
-    }
-
-    __END__;
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/em.cpp b/modules/legacy/src/em.cpp
deleted file mode 100644 (file)
index b6ff6c8..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright( C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-//(including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort(including negligence or otherwise) arising in any way out of
-// the use of this software, even ifadvised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-using namespace cv;
-
-CvEMParams::CvEMParams() : nclusters(10), cov_mat_type(CvEM::COV_MAT_DIAGONAL),
-    start_step(CvEM::START_AUTO_STEP), probs(0), weights(0), means(0), covs(0)
-{
-    term_crit=cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 100, FLT_EPSILON );
-}
-
-CvEMParams::CvEMParams( int _nclusters, int _cov_mat_type, int _start_step,
-                        CvTermCriteria _term_crit, const CvMat* _probs,
-                        const CvMat* _weights, const CvMat* _means, const CvMat** _covs ) :
-                        nclusters(_nclusters), cov_mat_type(_cov_mat_type), start_step(_start_step),
-                        probs(_probs), weights(_weights), means(_means), covs(_covs), term_crit(_term_crit)
-{}
-
-CvEM::CvEM() : logLikelihood(DBL_MAX)
-{
-}
-
-CvEM::CvEM( const CvMat* samples, const CvMat* sample_idx,
-            CvEMParams params, CvMat* labels ) : logLikelihood(DBL_MAX)
-{
-    train(samples, sample_idx, params, labels);
-}
-
-CvEM::~CvEM()
-{
-    clear();
-}
-
-void CvEM::clear()
-{
-    emObj.clear();
-}
-
-void CvEM::read( CvFileStorage* fs, CvFileNode* node )
-{
-    FileNode fn(fs, node);
-    emObj.read(fn);
-    set_mat_hdrs();
-}
-
-void CvEM::write( CvFileStorage* _fs, const char* name ) const
-{
-    FileStorage fs(_fs, false);
-    if(name)
-        fs << name << "{";
-    emObj.write(fs);
-    if(name)
-        fs << "}";
-}
-
-double CvEM::calcLikelihood( const Mat &input_sample ) const
-{
-    return emObj.predict(input_sample)[0];
-}
-
-float
-CvEM::predict( const CvMat* _sample, CvMat* _probs ) const
-{
-    Mat prbs0 = cvarrToMat(_probs), prbs = prbs0, sample = cvarrToMat(_sample);
-    int cls = static_cast<int>(emObj.predict(sample, _probs ? _OutputArray(prbs) :
-                                             (OutputArray)cv::noArray())[1]);
-    if(_probs)
-    {
-        if( prbs.data != prbs0.data )
-        {
-            CV_Assert( prbs.size == prbs0.size );
-            prbs.convertTo(prbs0, prbs0.type());
-        }
-    }
-    return (float)cls;
-}
-
-void CvEM::set_mat_hdrs()
-{
-    if(emObj.isTrained())
-    {
-        meansHdr = emObj.get<Mat>("means");
-        int K = emObj.get<int>("nclusters");
-        covsHdrs.resize(K);
-        covsPtrs.resize(K);
-        const std::vector<Mat>& covs = emObj.get<std::vector<Mat> >("covs");
-        for(size_t i = 0; i < covsHdrs.size(); i++)
-        {
-            covsHdrs[i] = covs[i];
-            covsPtrs[i] = &covsHdrs[i];
-        }
-        weightsHdr = emObj.get<Mat>("weights");
-        probsHdr = probs;
-    }
-}
-
-static
-void init_params(const CvEMParams& src,
-                 Mat& prbs, Mat& weights,
-                 Mat& means, std::vector<Mat>& covsHdrs)
-{
-    prbs = cv::cvarrToMat(src.probs);
-    weights = cv::cvarrToMat(src.weights);
-    means = cv::cvarrToMat(src.means);
-
-    if(src.covs)
-    {
-        covsHdrs.resize(src.nclusters);
-        for(size_t i = 0; i < covsHdrs.size(); i++)
-            covsHdrs[i] = cv::cvarrToMat(src.covs[i]);
-    }
-}
-
-bool CvEM::train( const CvMat* _samples, const CvMat* _sample_idx,
-                  CvEMParams _params, CvMat* _labels )
-{
-    CV_Assert(_sample_idx == 0);
-    Mat samples = cvarrToMat(_samples), labels0, labels;
-    if( _labels )
-        labels0 = labels = cvarrToMat(_labels);
-
-    bool isOk = train(samples, Mat(), _params, _labels ? &labels : 0);
-    CV_Assert( labels0.data == labels.data );
-
-    return isOk;
-}
-
-int CvEM::get_nclusters() const
-{
-    return emObj.get<int>("nclusters");
-}
-
-const CvMat* CvEM::get_means() const
-{
-    return emObj.isTrained() ? &meansHdr : 0;
-}
-
-const CvMat** CvEM::get_covs() const
-{
-    return emObj.isTrained() ? (const CvMat**)&covsPtrs[0] : 0;
-}
-
-const CvMat* CvEM::get_weights() const
-{
-    return emObj.isTrained() ? &weightsHdr : 0;
-}
-
-const CvMat* CvEM::get_probs() const
-{
-    return emObj.isTrained() ? &probsHdr : 0;
-}
-
-using namespace cv;
-
-CvEM::CvEM( const Mat& samples, const Mat& sample_idx, CvEMParams params )
-{
-    train(samples, sample_idx, params, 0);
-}
-
-bool CvEM::train( const Mat& _samples, const Mat& _sample_idx,
-                 CvEMParams _params, Mat* _labels )
-{
-    CV_Assert(_sample_idx.empty());
-    Mat prbs, weights, means, logLikelihoods;
-    std::vector<Mat> covshdrs;
-    init_params(_params, prbs, weights, means, covshdrs);
-
-    emObj = EM(_params.nclusters, _params.cov_mat_type, _params.term_crit);
-    bool isOk = false;
-    if( _params.start_step == EM::START_AUTO_STEP )
-        isOk = emObj.train(_samples,
-                           logLikelihoods, _labels ? _OutputArray(*_labels) :
-                           (OutputArray)cv::noArray(), probs);
-    else if( _params.start_step == EM::START_E_STEP )
-        isOk = emObj.trainE(_samples, means, covshdrs, weights,
-                            logLikelihoods, _labels ? _OutputArray(*_labels) :
-                            (OutputArray)cv::noArray(), probs);
-    else if( _params.start_step == EM::START_M_STEP )
-        isOk = emObj.trainM(_samples, prbs,
-                            logLikelihoods, _labels ? _OutputArray(*_labels) :
-                            (OutputArray)cv::noArray(), probs);
-    else
-        CV_Error(CV_StsBadArg, "Bad start type of EM algorithm");
-
-    if(isOk)
-    {
-        logLikelihood = sum(logLikelihoods).val[0];
-        set_mat_hdrs();
-    }
-
-    return isOk;
-}
-
-float
-CvEM::predict( const Mat& _sample, Mat* _probs ) const
-{
-    return static_cast<float>(emObj.predict(_sample, _probs ?
-                                            _OutputArray(*_probs) :
-                                            (OutputArray)cv::noArray())[1]);
-}
-
-int CvEM::getNClusters() const
-{
-    return emObj.get<int>("nclusters");
-}
-
-Mat CvEM::getMeans() const
-{
-    return emObj.get<Mat>("means");
-}
-
-void CvEM::getCovs(std::vector<Mat>& _covs) const
-{
-    _covs = emObj.get<std::vector<Mat> >("covs");
-}
-
-Mat CvEM::getWeights() const
-{
-    return emObj.get<Mat>("weights");
-}
-
-Mat CvEM::getProbs() const
-{
-    return probs;
-}
-
-
-/* End of file. */
diff --git a/modules/legacy/src/enmin.cpp b/modules/legacy/src/enmin.cpp
deleted file mode 100644 (file)
index 890d367..0000000
+++ /dev/null
@@ -1,1381 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#if 0
-
-//#include "windows.h"
-
-//#define ALPHA_EXPANSION
-
-#ifndef ALPHA_EXPANSION
-    #define ALPHA_BETA_EXCHANGE
-#endif
-
-#define MAX_LABEL 20
-
-#define CV_MODULE(xxx) \
-    ( (xxx) < 0 ? -(xxx) : (xxx) )
-
-#define CV_MAX3(xxx1,xxx2,xxx3) \
-    ( (xxx1) > (xxx2) && (xxx1) > (xxx3) ? (xxx1) : \
-        (xxx2) > (xxx3) ? (xxx2) : (xxx3) )
-
-#define CV_MIN2(xxx1,xxx2) \
-    ( (xxx1) < (xxx2) ? (xxx1) : (xxx2) )
-
-#define getSizeForGraph(xxxType) \
-    ( sizeof(xxxType) < 8 ? 8 : sizeof(xxxType) + 4 - sizeof(xxxType) % 4 )
-
-#define INT_INFINITY 1000000000
-#define MAX_DIFFERENCE 10
-
-
-// struct Vertex is used for storing vertices of graph
-//      coord       - coordinate corresponding pixel on the real image line
-struct Vertex
-{
-    CvGraphVtx vtx;
-    int coord;
-};
-
-// struct Edge is used for storing edges of graph
-//      weight      - weight of the edge ( maximum flow via the edge )
-//      flow        - current flow via the edge
-//      srcVtx      - coordinate of source vertex on the real image line
-//      destVtx     - coordinate of destination vertex on the real image line
-struct Edge
-{
-    CV_GRAPH_EDGE_FIELDS()
-    int weight;
-    int flow;
-    int srcVtx;
-    int destVtx;
-};
-
-// function vFunc is energy function which determines the difference
-//   between two labels ( alpha and beta )
-//      alpha       - label number one
-//      beta        - label number two
-inline int vFunc( int alpha, int beta )
-{
-    if( alpha == beta )
-        return 0;
-    else
-        return /*1*//*5*/10;
-}
-
-// function dFunc is energy function which determines energy of interaction
-//   between pixel ( having coordinate xCoord ) and label
-//          leftLine        - line of left image
-//          rightLine       - line of right image
-//          xCoord          - coordinate of pixel on the left image
-//          label           - label corresponding to the pixel
-//          width           - width of the image line in pixels
-inline int dFunc( unsigned char* leftLine,
-                  unsigned char* rightLine,
-                  int xCoord,
-                  int label,
-                  int width)
-{
-    assert( xCoord >= 0 && xCoord < width );
-    int r, g, b;
-    int yCoord = xCoord + label;
-
-    if( yCoord >= width )
-        yCoord = width;
-    if( yCoord < 0 )
-        yCoord = 0;
-
-    r = leftLine[ 3 * xCoord     ] - rightLine[ 3 * yCoord     ];
-    g = leftLine[ 3 * xCoord + 1 ] - rightLine[ 3 * yCoord + 1 ];
-    b = leftLine[ 3 * xCoord + 2 ] - rightLine[ 3 * yCoord + 2 ];
-
-    r = CV_MODULE( r );
-    g = CV_MODULE( g );
-    b = CV_MODULE( b );
-
-    return CV_MAX3( r, g, b );
-}
-
-// function allocTempMem allocates all temporary memory needed for work
-//   of some function
-//      memPtr          - pointer to pointer to the large block of memory
-//      verticesPtr     - pointer to pointer to block of memory for
-//                        temporary storing vertices
-//      width           - width of line in pixels
-void allocTempMem( int** memPtr,
-                   int** verticesPtr,
-                   int width )
-{
-    int* tempPtr = ( int* ) malloc( ( width + 2 ) * 7 * sizeof( int ) );
-    *verticesPtr = tempPtr;
-    *memPtr = *verticesPtr + width + 2;
-}
-
-// function freeTempMem frees all allocated by allocTempMem function memory
-//      memPtr          - pointer to pointer to the large block of memory
-//      verticesPtr     - pointer to pointer to block of memory for
-//                        temporary storing vertices
-void freeTempMem( int** memPtr,
-                  int** verticesPtr )
-{
-    free( ( void* )( *verticesPtr ) );
-    *verticesPtr = NULL;
-    *memPtr = NULL;
-}
-
-// function makeGraph creates initial graph to find maximum flow in it
-//      graphPtr        - pointer to pointer to CvGraph structure to be filled
-//      leftLine        - pointer to the left image line
-//      rightLine       - pointer to the right image line
-//      alpha           - label number one for doing exchange
-//      beta            - label number two for doing exchange
-//      corr            - pointer to array of correspondences ( each element
-//                        of array includes disparity of pixel on right image
-//                        for pixel each on left image ). This pointer direct
-//                        to correspondence ofr one line only
-//      width           - width of image lines in pixels
-//      storage         - pointer to CvMemStorage structure which contains
-//                        memory storage
-void makeGraph( CvGraph** graphPtr,
-                unsigned char* leftLine,
-                unsigned char* rightLine,
-                int alpha,
-                int beta,
-                int* corr,
-                int width,
-                CvMemStorage* storage )
-{
-    int i;
-
-    if( *graphPtr )  {
-        cvClearGraph( *graphPtr );
-    }
-    /*else {*/
-        *graphPtr = cvCreateGraph( CV_SEQ_KIND_GRAPH | CV_GRAPH_FLAG_ORIENTED,
-                                   sizeof( CvGraph ),
-                                   getSizeForGraph( Vertex ),
-                                   getSizeForGraph( Edge ),
-                                   storage );
-    /*}*/
-
-    CvGraph* graph = *graphPtr;
-
-    #ifdef ALPHA_BETA_EXCHANGE
-
-    CvGraphVtx* newVtxPtr;
-    for( i = 0; i < width; i ++ )
-    {
-        if( corr[i] == alpha || corr[i] == beta ) {
-            cvGraphAddVtx( graph, NULL, &newVtxPtr );
-            ( ( Vertex* )newVtxPtr ) -> coord = i;
-        }
-    } /* for( i = 0; i < width; i ++ ) */
-    cvGraphAddVtx( graph, NULL, &newVtxPtr );
-    if( newVtxPtr )
-        ( ( Vertex* )newVtxPtr ) -> coord = -2; /* adding alpha vertex */
-    cvGraphAddVtx( graph, NULL, &newVtxPtr );
-    if( newVtxPtr )
-        ( ( Vertex* )newVtxPtr ) -> coord = -1; /* adding beta vertex */
-
-    int alphaVtx = graph -> total - 2;
-    int betaVtx = graph -> total - 1;
-    CvGraphEdge* newEdgePtr;
-    CvGraphVtx* vtxPtr;
-    if( graph -> total > 2 )
-    {
-        for( i = 0; i < alphaVtx; i ++ )
-        {
-            vtxPtr = cvGetGraphVtx( graph, i );
-
-            /* adding edge oriented from alpha vertex to current vertex */
-            cvGraphAddEdge( graph, alphaVtx, i, NULL, &newEdgePtr );
-            ( ( Edge* )newEdgePtr ) -> weight = dFunc( leftLine,
-                rightLine,
-                ( ( Vertex* )vtxPtr ) -> coord,
-                alpha,
-                width );
-            ( ( Edge* )newEdgePtr ) -> flow = 0;
-            if( i != 0 ) {
-                CvGraphVtx* tempVtxPtr = cvGetGraphVtx( graph, i - 1 );
-                /* if vertices are neighbours */
-                if( ( ( Vertex* )tempVtxPtr ) -> coord + 1 ==
-                    ( ( Vertex* )vtxPtr ) -> coord )
-                {
-                    ( ( Edge* )newEdgePtr ) -> weight +=
-                        vFunc( corr[ ( ( Vertex* )tempVtxPtr ) -> coord ],
-                               alpha );
-                    /* adding neighbour edge oriented from current vertex
-                       to the previous one */
-                    CvGraphEdge* tempEdgePtr;
-                    cvGraphAddEdge( graph, i, i - 1, NULL, &tempEdgePtr );
-                    ( ( Edge* )tempEdgePtr ) -> weight = vFunc( alpha, beta );
-                    ( ( Edge* )tempEdgePtr ) -> flow = 0;
-                    ( ( Edge* )tempEdgePtr ) -> srcVtx =
-                        ( ( Vertex* )vtxPtr ) -> coord;
-                    ( ( Edge* )tempEdgePtr ) -> destVtx =
-                        ( ( Vertex* )tempVtxPtr ) -> coord;
-                }
-            } /* if( i != 0 ) */
-            if( i != alphaVtx - 1 ) {
-                CvGraphVtx* tempVtxPtr = cvGetGraphVtx( graph, i + 1 );
-                /* if vertices are neighbours */
-                if( ( ( Vertex* )tempVtxPtr ) -> coord - 1 ==
-                    ( ( Vertex* )vtxPtr ) -> coord )
-                {
-                    ( ( Edge* )newEdgePtr ) -> weight +=
-                        vFunc( corr[ ( ( Vertex* )tempVtxPtr ) -> coord ],
-                               alpha );
-                    /* adding neighbour edge oriented from current vertex
-                       to the next one */
-                    CvGraphEdge* tempEdgePtr;
-                    cvGraphAddEdge( graph, i, i + 1, NULL, &tempEdgePtr );
-                    ( ( Edge* )tempEdgePtr ) -> weight = vFunc( alpha, beta );
-                    ( ( Edge* )tempEdgePtr ) -> flow = 0;
-                    ( ( Edge* )tempEdgePtr ) -> srcVtx =
-                        ( ( Vertex* )vtxPtr ) -> coord;
-                    ( ( Edge* )tempEdgePtr ) -> destVtx =
-                        ( ( Vertex* )tempVtxPtr ) -> coord;
-                }
-            } /* if( i != alphaVtx - 1 ) */
-            ( ( Edge* )newEdgePtr ) -> flow = 0;
-            ( ( Edge* )newEdgePtr ) -> srcVtx = -1; /* source vertex is alpha
-                                                       vertex */
-            ( ( Edge* )newEdgePtr ) -> destVtx = ( ( Vertex* )vtxPtr ) -> coord;
-
-            /* adding edge oriented from current vertex to beta vertex */
-            cvGraphAddEdge( graph, i, betaVtx, NULL, &newEdgePtr );
-            ( ( Edge* )newEdgePtr ) -> weight = dFunc( leftLine,
-                rightLine,
-                ( ( Vertex* )vtxPtr ) -> coord,
-                beta,
-                width );
-            ( ( Edge* )newEdgePtr ) -> flow = 0;
-            if( i != 0 ) {
-                CvGraphVtx* tempVtxPtr = cvGetGraphVtx( graph, i - 1 );
-                /* if vertices are neighbours */
-                if( ( ( Vertex* )tempVtxPtr ) -> coord + 1 ==
-                    ( ( Vertex* )vtxPtr ) -> coord )
-                {
-                    ( ( Edge* )newEdgePtr ) -> weight +=
-                        vFunc( corr[ ( ( Vertex* )tempVtxPtr ) -> coord ],
-                               beta );
-                }
-            } /* if( i != 0 ) */
-            if( i != alphaVtx - 1 ) {
-                CvGraphVtx* tempVtxPtr = cvGetGraphVtx( graph, i + 1 );
-                /* if vertices are neighbours */
-                if( ( ( Vertex* )tempVtxPtr ) -> coord - 1 ==
-                    ( ( Vertex* )vtxPtr ) -> coord )
-                {
-                    ( ( Edge* )newEdgePtr ) -> weight +=
-                        vFunc( corr[ ( ( Vertex* )tempVtxPtr ) -> coord ],
-                               beta );
-                }
-            } /* if( i != alphaVtx - 1 ) */
-            ( ( Edge* )newEdgePtr ) -> flow = 0;
-            ( ( Edge* )newEdgePtr ) -> srcVtx =
-                ( ( Vertex* )vtxPtr ) -> coord;
-            ( ( Edge* )newEdgePtr ) -> destVtx = -2; /* destination vertex is
-                                                        beta vertex */
-
-        } /* for( i = 0; i < graph -> total - 2; i ++ ) */
-
-    } /* if( graph -> total > 2 ) */
-
-    #endif /* #ifdef ALPHA_BETA_EXCHANGE */
-
-    #ifdef ALPHA_EXPANSION
-    #endif /* #ifdef ALPHA_EXPANSION */
-
-} /* makeGraph */
-
-// function makeHelpGraph creates help graph using initial graph
-//      graph           - pointer to initial graph ( represented by CvGraph
-//                        structure )
-//      hlpGraphPtr     - pointer to pointer to new help graph
-//      storage         - pointer to CvStorage structure
-//      mem             - pointer to memory allocated by allocTempMem function
-//      vertices        - pointer to memory allocated by allocTempMem function
-//      verticesCountPtr- pointer to value containing number of vertices
-//                        in vertices array
-//      width           - width of image line in pixels
-int makeHelpGraph( CvGraph* graph,
-                   CvGraph** hlpGraphPtr,
-                   CvMemStorage* storage,
-                   int* mem,
-                   int* vertices,
-                   int* verticesCountPtr,
-                   int width )
-{
-    int u, v;
-    int* order = mem;
-    int* lengthArr = order + width + 2;
-    int s = graph -> total - 2; /* source vertex */
-    int t = graph -> total - 1; /* terminate vertex */
-    int orderFirst;
-    int orderCount;
-    int &verticesCount = *verticesCountPtr;
-    CvGraph* hlpGraph;
-
-    if( *hlpGraphPtr )  {
-        cvClearGraph( *hlpGraphPtr );
-    }
-    else {
-        *hlpGraphPtr = cvCreateGraph( CV_SEQ_KIND_GRAPH |
-                                          CV_GRAPH_FLAG_ORIENTED,
-                                      sizeof( CvGraph ),
-                                      getSizeForGraph( Vertex ),
-                                      getSizeForGraph( Edge ),
-                                      storage );
-    }
-
-    hlpGraph = *hlpGraphPtr;
-
-    /* initialization */
-    for( u = 0; u < graph -> total; u ++ )
-    {
-        lengthArr[ u ] = INT_INFINITY;
-        cvGraphAddVtx( hlpGraph, NULL, NULL );
-    } /* for( u = 0; u < graph -> total - 1; u ++ ) */
-
-    orderFirst = 0;
-    orderCount = 0;
-    verticesCount = 0;
-    lengthArr[ s ] = 0;
-
-    /* add vertex s to order */
-    order[ orderCount ] = s;
-    orderCount ++;
-
-    while( orderCount != orderFirst )
-    {
-        /* getting u from order */
-        u = order[ orderFirst ];
-        orderFirst ++;
-
-        /* adding u to vertex array */
-        vertices[ verticesCount ] = u;
-        verticesCount ++;
-
-        int ofs;
-        CvGraphVtx* graphVtx = cvGetGraphVtx( graph, u );
-
-        /* processing all vertices outgoing from vertex u */
-        CvGraphEdge* graphEdge = graphVtx -> first;
-        while( graphEdge )
-        {
-            int tempVtxIdx = cvGraphVtxIdx( graph, graphEdge -> vtx[1] );
-            ofs = tempVtxIdx == u;
-            if( !ofs )
-            {
-                v = tempVtxIdx;
-
-                CvGraphEdge* tempGraphEdge = cvFindGraphEdge( graph, u, v );
-                if( ( lengthArr[ u ] < lengthArr[ v ] )
-                    && ( lengthArr[ v ] <= lengthArr[ t ] )
-                    && ( ( ( Edge* )tempGraphEdge ) -> flow <
-                        ( ( Edge* )tempGraphEdge ) -> weight ) )
-                {
-                    if( lengthArr[ v ] == INT_INFINITY )
-                    {
-                        /* adding vertex v to order */
-                        order[ orderCount ] = v;
-                        orderCount ++;
-
-                        lengthArr[ v ] = lengthArr[ u ] + 1;
-                        CvGraphEdge* tempGraphEdge2;
-
-                        cvGraphAddEdge( hlpGraph, u, v, NULL, &tempGraphEdge2 );
-                        ( ( Edge* )tempGraphEdge2 ) -> flow = 0;
-
-                        ( ( Edge* )tempGraphEdge2 ) -> weight =
-                            ( ( Edge* )tempGraphEdge ) -> weight -
-                            ( ( Edge* )tempGraphEdge ) -> flow;
-
-                    } /* if( length[ v ] == INT_INFINITY ) */
-
-                } /* if( ( lengthArr[ u ] < lengthArr[ v ] ) ... */
-
-            } /* if( !ofs ) */
-
-            graphEdge = graphEdge -> next[ ofs ];
-
-        } /* while( graphEdge ) */
-
-        /* processing all vertices incoming to vertex u */
-        graphEdge = graphVtx -> first;
-        while( graphEdge )
-        {
-            int tempVtxIdx = cvGraphVtxIdx( graph, graphEdge -> vtx[1] );
-            ofs = tempVtxIdx == u;
-            if( ofs )
-            {
-                tempVtxIdx = cvGraphVtxIdx( graph, graphEdge -> vtx[0] );
-                v = tempVtxIdx;
-
-                CvGraphEdge* tempGraphEdge = cvFindGraphEdge( graph, v, u );
-                if( ( lengthArr[ u ] < lengthArr[ v ] )
-                    && ( lengthArr[ v ] <= lengthArr[ t ] )
-                    && ( ( ( Edge* )tempGraphEdge ) -> flow > 0 ) )
-                {
-                    if( lengthArr[ v ] == INT_INFINITY )
-                    {
-                        /* adding vertex v to order */
-                        order[ orderCount ] = v;
-                        orderCount ++;
-
-                        lengthArr[ v ] = lengthArr[ u ] + 1;
-                        CvGraphEdge* tempGraphEdge3 = cvFindGraphEdge( hlpGraph, u, v );
-
-                        if( tempGraphEdge3 == NULL ||
-                            ( ( Edge* )tempGraphEdge3 ) -> weight == 0 )
-                        {
-                            CvGraphEdge* tempGraphEdge2;
-                            cvGraphAddEdge( hlpGraph, u, v, NULL,
-                                &tempGraphEdge2 );
-                            ( ( Edge* )tempGraphEdge2 ) -> flow = 0;
-                            ( ( Edge* )tempGraphEdge2 ) -> weight = 0;
-                        } /* if( tempGraphEdge3 == NULL || ... */
-
-                        ( ( Edge* )tempGraphEdge3 ) -> weight +=
-                            ( ( Edge* )tempGraphEdge ) -> flow;
-
-                    } /* if( length[ v ] == INT_INFINITY ) */
-
-                } /* if( ( lengthArr[ u ] < lengthArr[ v ] ) ... */
-
-            } /* if( ofs ) */
-
-            graphEdge = graphEdge -> next[ ofs ];
-
-        } /* while( graphEdge ) */
-
-    } /* while( orderCount != orderFirst ) */
-
-    int i;
-    for( i = 0; i < hlpGraph -> total - 2; i ++ )
-    {
-        CvGraphVtx* hlpGraphVtxTemp = cvGetGraphVtx( hlpGraph, i );
-        if( hlpGraphVtxTemp ) {
-            if( !hlpGraphVtxTemp -> first ) {
-                cvGraphRemoveVtxByPtr( hlpGraph, hlpGraphVtxTemp );
-            }
-        }
-    } /* for( i = 0; i < hlpGraph -> total - 2; i ++ ) */
-
-    return lengthArr[ t ];
-
-} /* makeHelpGraph */
-
-// function makePseudoMaxFlow increases flow in graph by using hlpGraph
-//      graph           - pointer to initial graph
-//      hlpGraph        - pointer to help graph
-//      vertices        - pointer to vertices array
-//      verticesCount   - number of vertices in vertices array
-//      mem             - pointer to memory allocated by allocTempMem function
-//      width           - width of image line in pixels
-void makePseudoMaxFlow( CvGraph* graph,
-                        CvGraph* hlpGraph,
-                        int* vertices,
-                        int verticesCount,
-                        int* mem,
-                        int width )
-{
-    int stekCount;
-    int orderFirst;
-    int orderCount;
-    int i;
-    int v, u;
-    int* stek = mem;
-    int* order = stek + width + 2;
-    int* incomFlow = order + width + 2;
-    int* outgoFlow = incomFlow + width + 2;
-    int* flow = outgoFlow + width + 2;
-    int* cargo = flow+ width + 2;
-    int s = graph -> total - 2; /* source vertex */
-    int t = graph -> total - 1; /* terminate vertex */
-    int realVerticesCount = verticesCount;
-
-    stekCount = 0;
-
-    for( i = 0; i < verticesCount; i ++ )
-    {
-        v = vertices[ i ];
-
-        incomFlow[ v ] = outgoFlow[ v ] = 0;
-
-        if( v == s ) {
-            incomFlow[ v ] = INT_INFINITY;
-        } /* if( v == s ) */
-        else {
-            CvGraphVtx* hlpGraphVtx = cvGetGraphVtx( hlpGraph, v );
-            CvGraphEdge* hlpGraphEdge = hlpGraphVtx -> first;
-            int ofs;
-
-            while( hlpGraphEdge )
-            {
-                int vtxIdx = cvGraphVtxIdx( hlpGraph,
-                    hlpGraphEdge -> vtx[1] );
-                ofs = vtxIdx == v;
-
-                if( ofs )
-                {
-                    incomFlow[ v ] += ( ( Edge* )hlpGraphEdge ) -> weight;
-                } /* if( ofs ) */
-
-                hlpGraphEdge = hlpGraphEdge -> next[ ofs ];
-            } /* while( hlpGraphEdge ) */
-
-        } /* if( v == s ) else */
-
-        if( v == t ) {
-            outgoFlow[ v ] = INT_INFINITY;
-        } /* if( v == t ) */
-        else {
-            CvGraphVtx* hlpGraphVtx = cvGetGraphVtx( hlpGraph, v );
-            CvGraphEdge* hlpGraphEdge = hlpGraphVtx -> first;
-            int ofs;
-
-            while( hlpGraphEdge )
-            {
-                int vtxIdx = cvGraphVtxIdx( hlpGraph,
-                    hlpGraphEdge -> vtx[1] );
-                ofs = vtxIdx == v;
-
-                if( !ofs )
-                {
-                    outgoFlow[ v ] += ( ( Edge* )hlpGraphEdge ) -> weight;
-                } /* if( ofs ) */
-
-                hlpGraphEdge = hlpGraphEdge -> next[ ofs ];
-            } /* while( hlpGraphEdge ) */
-
-        } /* if( v == t ) else */
-
-        flow[ v ] = CV_MIN2( incomFlow[ v ], outgoFlow[ v ] );
-
-        if( !flow[ v ] ) {
-            stek[ stekCount ] = v;
-            stekCount ++;
-        } /* if( !flow[ v ] ) */
-
-    } /* for( i = 0; i < verticesCount; i ++ ) */
-
-    for( i = 0; i < verticesCount; i ++ )
-    {
-        v = vertices[ i ];
-        cargo[ v ] = 0;
-    } /* for( i = 0; i < verticesCount; i ++ ) */
-
-    while( realVerticesCount > 2 )
-    {
-        /* deleting all vertices included in stek */
-        while( stekCount )
-        {
-            v = stek[ stekCount - 1 ];
-            stekCount --;
-
-            /* deleting edges incoming to v and outgoing from v */
-            int ofs;
-            CvGraphVtx* hlpGraphVtx = cvGetGraphVtx( hlpGraph, v );
-            CvGraphEdge* hlpGraphEdge;
-            if( hlpGraphVtx ) {
-                hlpGraphEdge = hlpGraphVtx -> first;
-            }
-            else {
-                hlpGraphEdge = NULL;
-            }
-            while( hlpGraphEdge )
-            {
-                CvGraphVtx* hlpGraphVtx2 = hlpGraphEdge -> vtx[ 1 ];
-                int hlpGraphVtxIdx2 = cvGraphVtxIdx( hlpGraph,
-                    hlpGraphVtx2 );
-                ofs = hlpGraphVtxIdx2 == v;
-
-                if( ofs )
-                {
-                    /* hlpGraphEdge is incoming edge */
-                    CvGraphVtx* hlpGraphVtx3 = hlpGraphEdge -> vtx[0];
-                    u = cvGraphVtxIdx( hlpGraph,
-                                       hlpGraphVtx3 );
-                    outgoFlow[ u ] -= ( ( Edge* )hlpGraphEdge ) -> weight
-                        - ( ( Edge* )hlpGraphEdge ) -> flow;
-                    cvGraphRemoveEdgeByPtr( hlpGraph,
-                                            hlpGraphVtx3,
-                                            hlpGraphVtx2 );
-                    if( flow[ u ] != 0 ) {
-                        flow[ u ] = CV_MIN2( incomFlow[u], outgoFlow[u] );
-                        if( flow[ u ] == 0 ) {
-                            stek[ stekCount ] = u;
-                            stekCount ++;
-                        }
-                    }
-                } /* if( ofs ) */
-                else
-                {
-                    /* hlpGraphEdge is outgoing edge */
-                    CvGraphVtx* hlpGraphVtx3 = hlpGraphEdge -> vtx[1];
-                    int u = cvGraphVtxIdx( hlpGraph,
-                                              hlpGraphVtx3 );
-                    incomFlow[ u ] -= ( ( Edge* )hlpGraphEdge ) -> weight
-                        - ( ( Edge* )hlpGraphEdge ) -> flow;
-                    cvGraphRemoveEdgeByPtr( hlpGraph,
-                                            hlpGraphVtx2,
-                                            hlpGraphVtx3 );
-                    if( flow[ u ] != 0 ) {
-                        flow[ u ] = CV_MIN2( incomFlow[u], outgoFlow[u] );
-                        if( flow[ u ] == 0 ) {
-                            stek[ stekCount ] = u;
-                            stekCount ++;
-                        }
-                    }
-                } /* if( ofs ) else */
-
-                hlpGraphEdge = hlpGraphEdge -> next[ ofs ];
-
-            } /* while( hlpGraphEdge ) */
-
-            /* deleting vertex v */
-            cvGraphRemoveVtx( hlpGraph, v );
-            realVerticesCount --;
-
-        } /* while( stekCount ) */
-
-        if( realVerticesCount > 2 ) /* the flow is not max still */
-        {
-            int p = INT_INFINITY;
-            int r = -1;
-            CvGraphVtx* graphVtx;
-
-            if( realVerticesCount == 3 ) {
-                r = r;
-            }
-            for( i = 0; i < hlpGraph -> total - 2; i ++ )
-            {
-                graphVtx = cvGetGraphVtx( hlpGraph, i );
-                if( graphVtx ) {
-                    v = cvGraphVtxIdx( hlpGraph, graphVtx );
-                    if( flow[ v ] < p ) {
-                        r = v;
-                        p = flow[ v ];
-                    }
-                }
-
-            } /* for( i = 0; i < hlpGraph -> total - 2; i ++ ) */
-
-            /* building of size p flow from r to t */
-            orderCount = orderFirst = 0;
-            order[ orderCount ] = r;
-            orderCount ++;
-
-            v = order[ orderFirst ];
-            orderFirst ++;
-
-            cargo[ r ] = p;
-            do /* while( v != t ) */
-            {
-                incomFlow[ v ] -= cargo[ v ];
-                outgoFlow[ v ] -= cargo[ v ];
-                flow[ v ] -= cargo[ v ];
-
-                if( flow[ v ] == 0 ) {
-                    stek[ stekCount ] = v;
-                    stekCount ++;
-                }
-
-                if( v == t ) {
-                    cargo[ v ] = p;
-                }
-                else
-                {
-                    int ofs;
-                    CvGraphVtx* hlpGraphVtx2;
-                    CvGraphVtx* hlpGraphVtx = cvGetGraphVtx( hlpGraph, v );
-                    CvGraphEdge* hlpGraphEdge = hlpGraphVtx -> first;
-                    CvGraphEdge* hlpGraphEdge2 = NULL;
-
-                    while( hlpGraphEdge && cargo[ v ] > 0 )
-                    {
-                        hlpGraphVtx2 = hlpGraphEdge -> vtx[ 1 ];
-                        u = cvGraphVtxIdx( hlpGraph, hlpGraphVtx2 );
-                        ofs = u == v;
-
-                        if( !ofs )
-                        {
-                            if( cargo[ u ] == 0 ) {
-                                order[ orderCount ] = u;
-                                orderCount ++;
-                            }
-                            int delta = ( ( Edge* )hlpGraphEdge ) -> weight
-                                - ( ( Edge* )hlpGraphEdge ) -> flow;
-                            delta = CV_MIN2( cargo[ v ], delta );
-                            ( ( Edge* )hlpGraphEdge ) -> flow += delta;
-                            cargo[ v ] -= delta;
-                            cargo[ u ] += delta;
-                            if( ( ( Edge* )hlpGraphEdge ) -> weight ==
-                                ( ( Edge* )hlpGraphEdge ) -> flow )
-                            {
-                                /* deleting hlpGraphEdge */
-                                hlpGraphEdge2 = hlpGraphEdge -> next[ ofs ];
-                                CvGraphEdge* graphEdge =
-                                    cvFindGraphEdge( graph, v, u );
-                                ( ( Edge* )graphEdge ) -> flow +=
-                                    ( ( Edge* )hlpGraphEdge ) -> flow;
-                                cvGraphRemoveEdgeByPtr( hlpGraph,
-                                    hlpGraphEdge -> vtx[0],
-                                    hlpGraphEdge -> vtx[1] );
-                            }
-                        } /* if( !ofs ) */
-
-                        if( hlpGraphEdge2 ) {
-                            hlpGraphEdge = hlpGraphEdge2;
-                            hlpGraphEdge2 = NULL;
-                        }
-                        else {
-                            hlpGraphEdge = hlpGraphEdge -> next[ ofs ];
-                        }
-                    } /* while( hlpGraphEdge && cargo[ v ] > 0 ) */
-
-                } /* if( v == t ) else */
-
-                v = order[ orderFirst ];
-                orderFirst ++;
-
-            } while( v != t ); /* do */
-
-            /* building of size p flow from s to r */
-            orderCount = orderFirst = 0;
-            order[ orderCount ] = r;
-            orderCount ++;
-
-            v = order[ orderFirst ];
-            orderFirst ++;
-
-            cargo[ r ] = p;
-            do /* while( v != s ) */
-            {
-                if( v != r )
-                {
-                    incomFlow[ v ] -= cargo[ v ];
-                    outgoFlow[ v ] -= cargo[ v ];
-                    flow[ v ] -= cargo[ v ];
-                    if( flow[ v ] == 0 ) {
-                        stek[ stekCount ] = v;
-                        stekCount ++;
-                    }
-                } /* if( v != r ) */
-
-                if( v == s ) {
-                    cargo[ v ] = 0;
-                } /* if( v == s ) */
-                else
-                {
-                    int ofs;
-
-                    CvGraphVtx* hlpGraphVtx = cvGetGraphVtx( hlpGraph, v );
-                    CvGraphEdge* hlpGraphEdge = hlpGraphVtx -> first;
-                    CvGraphEdge* hlpGraphEdge2 = NULL;
-                    while( hlpGraphEdge && cargo[ v ] > 0 )
-                    {
-                        u = cvGraphVtxIdx( hlpGraph,
-                                hlpGraphEdge -> vtx[ 1 ] );
-                        ofs = u == v;
-
-                        if( ofs )
-                        {
-                            u = cvGraphVtxIdx( hlpGraph,
-                                    hlpGraphEdge -> vtx[ 0 ] );
-
-                            if( cargo[ u ] == 0 ) {
-                                order[ orderCount ] = u;
-                                orderCount ++;
-                            }
-
-                            int delta = ( ( Edge* )hlpGraphEdge ) -> weight
-                                - ( ( Edge* )hlpGraphEdge ) -> flow;
-
-                            delta = CV_MIN2( cargo[ v ], delta );
-
-                            (( ( Edge* )hlpGraphEdge ) -> flow) += delta;
-
-                            cargo[ v ] -= delta;
-                            cargo[ u ] += delta;
-
-                            if( ( ( Edge* )hlpGraphEdge ) -> weight ==
-                                ( ( Edge* )hlpGraphEdge ) -> flow )
-                            {
-                                hlpGraphEdge2 = hlpGraphEdge -> next[ ofs ];
-                                CvGraphEdge* graphEdge =
-                                    cvFindGraphEdge( graph, u, v );
-                                ( ( Edge* )graphEdge ) -> flow +=
-                                    ( ( Edge* )hlpGraphEdge ) -> flow;
-                                cvGraphRemoveEdgeByPtr( hlpGraph,
-                                    hlpGraphEdge -> vtx[0],
-                                    hlpGraphEdge -> vtx[1] );
-                            }
-                        } /* if( ofs ) */
-
-                        if( hlpGraphEdge2 ) {
-                            hlpGraphEdge = hlpGraphEdge2;
-                            hlpGraphEdge2 = NULL;
-                        }
-                        else {
-                            hlpGraphEdge = hlpGraphEdge -> next[ ofs ];
-                        }
-                    } /* while( hlpGraphEdge && cargo[ v ] > 0 ) */
-
-                } /* if( v == s ) else */
-
-                v = order[ orderFirst ]; //added
-                orderFirst ++; //added
-
-            } while( v != s ); /* do */
-
-        } /* if( hlpGraph -> total > 2 ) */
-
-    } /* while( hlpGraph -> total > 2 ) */
-
-} /* makePseudoMaxFlow */
-
-
-// function oneStep produces one alpha-beta exchange for one line of images
-//      leftLine        - pointer to the left image line
-//      rightLine       - pointer to the right image line
-//      alpha           - label number one
-//      beta            - label number two
-//      corr            - pointer to correspondence array for this line
-//      width           - width of image line in pixels
-//      mem             - pointer to memory allocated by allocTempMem function
-//      vertices        - pointer to vertices array allocated by allocTempMem
-//                        function
-//      storage         - pointer to CvMemStorage structure
-bool oneStep( unsigned char* leftLine,
-              unsigned char* rightLine,
-              int alpha,
-              int beta,
-              int* corr,
-              int width,
-              int* mem,
-              int* vertices,
-              CvMemStorage* storage )
-{
-    CvGraph* graph = NULL;
-    CvGraph* hlpGraph = NULL;
-    CvMemStoragePos storagePos;
-    int i;
-    bool change = false;
-    cvSaveMemStoragePos( storage, &storagePos );
-
-    int verticesCount;
-
-    makeGraph( &graph, leftLine, rightLine, alpha, beta, corr, width, storage );
-
-    int s = graph -> total - 2; /* source vertex - alpha vertex */
-    //int t = graph -> total - 1; /* terminate vertex - beta vertex */
-
-    int length = makeHelpGraph( graph,
-                                &hlpGraph,
-                                storage,
-                                mem,
-                                vertices,
-                                &verticesCount,
-                                width );
-    while( length != INT_INFINITY )
-    {
-        change = true;
-        makePseudoMaxFlow( graph,
-                           hlpGraph,
-                           vertices,
-                           verticesCount,
-                           mem,
-                           width );
-        cvClearGraph( hlpGraph );
-        length = makeHelpGraph( graph,
-                                &hlpGraph,
-                                storage,
-                                mem,
-                                vertices,
-                                &verticesCount,
-                                width );
-    } /* while( length != INT_INFINITY ) */
-
-    int coord;
-    CvGraphVtx* graphVtx;
-    for( i = 0; i < s; i ++ )
-    {
-        CvGraphEdge* graphEdge = cvFindGraphEdge( graph, s, i );
-
-        if( ( ( Edge* )graphEdge ) -> weight ==
-            ( ( Edge* )graphEdge ) -> flow )
-        { /* this vertex must have alpha label */
-            graphVtx = cvGetGraphVtx( graph, i );
-            coord = ( ( Vertex* )graphVtx )-> coord;
-            if( corr[ coord ] != alpha ) {
-                corr[ coord ] = alpha; //added
-                change = true;
-            }
-            else {
-                corr[ coord ] = alpha;
-            }
-        } /* if( ( ( Edge* )graphEdge ) -> weight == ... */
-        else
-        { /* this vertex must have beta label */
-            graphVtx = cvGetGraphVtx( graph, i );
-            coord = ( ( Vertex* )graphVtx )-> coord;
-            if( corr[ coord ] != beta ) {
-                corr[ coord ] = beta; //added
-                change = true;
-            }
-            else {
-                corr[ coord ] = beta;
-            }
-        } /* if( ( ( Edge* )graphEdge ) -> weight == ... else */
-
-    } /* for( i = 0; i < s; i ++ ) */
-
-    cvClearGraph( hlpGraph );
-    cvClearGraph( graph );
-
-    cvRestoreMemStoragePos( storage, &storagePos );
-
-    return change;
-
-} /* oneStep */
-
-// function initCorr fills correspondence array with initial values
-//      corr                - pointer to correspondence array for this line
-//      width               -  width of image line in pixels
-//      maxPixelDifference  - maximum value of difference between the same
-//                            point painted on two images
-void initCorr( int* corr, int width, int maxPixelDifference )
-{
-    int i;
-    int pixelDifferenceRange = maxPixelDifference * 2 + 1;
-
-    for( i = 0; i < width; i ++ )
-    {
-        corr[ i ] = i % pixelDifferenceRange - maxPixelDifference;
-    }
-} /* initCorr */
-
-// function oneLineCorr fully computes one line of images
-//      leftLine                - pointer to the left image line
-//      rightLine               - pointer to the right image line
-//      corr                    - pointer to the correspondence array for one
-//                                line
-//      mem                     - pointer to memory allocated by allocTempMem
-//                                function
-//      vertices                - pointer to memory allocated by allocTempMem
-//                                function
-//      width                   - width of image line in pixels
-//      maxPixelDifference      - maximum value of pixel differences in pixels
-//      storage                 - pointer to CvMemStorage struct which
-//                                contains memory storage
-void oneLineCorr( unsigned char* leftLine,
-                  unsigned char* rightLine,
-                  int* corr,
-                  int* mem,
-                  int* vertices,
-                  int width,
-                  int maxPixelDifference,
-                  CvMemStorage* storage )
-{
-    int result = 1;
-    int count = 0;
-    int i, j;
-
-    initCorr( corr, width, maxPixelDifference );
-    while( result )
-    {
-        result = 0;
-
-        for( i = - maxPixelDifference; i < maxPixelDifference; i ++ )
-        for( j = i + 1; j <= maxPixelDifference; j ++ )
-        {
-            result += (int)oneStep( leftLine,
-                               rightLine,
-                               i,
-                               j,
-                               corr,
-                               width,
-                               mem,
-                               vertices,
-                               storage );
-        } /* for( j = i + 1; j < width; j ++ ) */
-
-        count ++;
-        if( count > /*0*//*1*/2 ) {
-            break;
-        }
-
-    } /* while( result ) */
-
-} /* oneLineCorr */
-
-// function allLinesCorr computes all lines on the images
-//      leftImage           - pointer to the left image
-//      leftLineStep        - size of line on the left image in bytes
-//      rightImage          - pointer to the right image
-//      rightLineStep       - size of line on the right image in bytes
-//      width               - width of line in pixels
-//      height              - height of image in pixels
-//      corr                - pointer to correspondence array for all lines
-//      maxPixelDifference  - maximum value of difference between the same
-//                            point painted on two images
-//      storage             - pointer to CvMemStorage which contains memory
-//                            storage
-void allLinesCorr( unsigned char* leftImage,
-                   int leftLineStep,
-                   unsigned char* rightImage,
-                   int rightLineStep,
-                   int width,
-                   int height,
-                   int* corr,
-                   int maxPixelDifference,
-                   CvMemStorage* storage )
-{
-    int i;
-    unsigned char* leftLine = leftImage;
-    unsigned char* rightLine = rightImage;
-    int* mem;
-    int* vertices;
-
-    allocTempMem( &mem,
-                  &vertices,
-                  width );
-
-    for( i = 0; i < height; i ++ )
-    {
-        oneLineCorr( leftLine,
-                     rightLine,
-                     corr + i * width,
-                     mem,
-                     vertices,
-                     width,
-                     maxPixelDifference,
-                     storage );
-        leftLine += leftLineStep;
-        rightLine += rightLineStep;
-    } /* for( i = 0; i < height; i ++ ) */
-
-    freeTempMem( &mem,
-                 &vertices );
-
-} /* allLinesCorr */
-
-// This function produces morphing of two images into one image, which includes morphed
-// image or depth map
-//      _leftImage              - pointer to left image
-//      _leftLineStep           - size of line on left image in bytes
-//      _rightImage             - pointer to right image
-//      _rightLineStep          - size of line on right image in bytes
-//      _resultImage            - pointer to result morphed image
-//      _resultLineStep         - size of line on result image in bytes
-//      _corrArray              - pointer to array with correspondences
-//      _numCorrArray           - pointer to array with numbers correspondeces on each line
-//      width                   - width of images
-//      height                  - height of images
-//      alpha                   - position of virtual camera ( 0 corresponds to left image, 1 - to right one )
-//      imageNeed               - defines your wishes. if you want to see normal morphed image you have to set
-//                                this parameter to morphNormalImage ( this is default value ), else if you want
-//                                to see depth map you have to set this parameter to morphDepthMap and set the
-//                                next parameter ( maxPixelDifference ) to real value
-//      maxPixelDifference      - maximum value of pixel difference on two images
-void CCvGraphCutMorpher::Morph( unsigned char* _leftImage,
-            int _leftLineStep,
-            unsigned char* _rightImage,
-            int _rightLineStep,
-            unsigned char* _resultImage,
-            int _resultLineStep,
-            int* _corrArray,
-            int width,
-            int height,
-            float alpha,
-            morphImageType imageNeed,
-            int maxDifference
-          )
-{
-    unsigned char* leftArray    = _leftImage;
-    unsigned char* middleArray  = _resultImage;
-    unsigned char* rightArray   = _rightImage;
-    int leftLineSize            = _leftLineStep;
-    int middleLineSize          = _resultLineStep;
-    int rightLineSize           = _rightLineStep;
-
-    int lineNumber;
-    unsigned char* leftTemp;
-    unsigned char* middleTemp;
-    unsigned char* rightTemp;
-    int leftPixel;
-    int prevLeftPixel;
-    int middlePixel;
-    int prevMiddlePixel;
-    int rightPixel;
-    int prevRightPixel;
-    int leftPixel3;
-    int middlePixel3;
-    int rightPixel3;
-    int i;
-    int j;
-    int tempIndex;
-    int* result;
-    int number;
-    float alpha1        = 1.0f - alpha;
-
-    for( lineNumber = 0; lineNumber < height; lineNumber ++ )
-    {
-        leftTemp    = leftArray + leftLineSize * lineNumber;
-        middleTemp  = middleArray + middleLineSize * lineNumber;
-        rightTemp   = rightArray + rightLineSize * lineNumber;
-        memset( ( void* )middleTemp, 0, middleLineSize );
-
-        result = _corrArray + width * lineNumber;
-        number = width;
-
-        prevLeftPixel   = 0;
-        prevRightPixel  = prevLeftPixel + result[ 0 ];
-        if( prevRightPixel >= width ) {
-            prevRightPixel = width - 1;
-        }
-        else if ( prevRightPixel < 0 ) {
-            prevRightPixel = 0;
-        }
-        prevMiddlePixel =
-            (int)( prevLeftPixel * alpha1 + prevRightPixel * alpha );
-        for( i = 0; i < number - 1; i ++ )
-        {
-            leftPixel       = i;
-            rightPixel      = i + result[ i ];
-            if( rightPixel >= width ) {
-                rightPixel = width - 1;
-            }
-            else if( rightPixel < 0 ) {
-                rightPixel = 0;
-            }
-            middlePixel     =
-                (int)( leftPixel * alpha1 + rightPixel * alpha );
-            leftPixel3      = leftPixel * 3;
-            middlePixel3    = middlePixel * 3;
-            rightPixel3     = rightPixel * 3;
-
-            if( imageNeed == morphDepthMap ) {
-                int t   = leftPixel - rightPixel + maxDifference;
-                t       = t < 0 ? -t : t;
-                t       = t * 255 / maxDifference / 2;
-                middleTemp[ middlePixel3 ]      = ( unsigned char )t;
-                middleTemp[ middlePixel3 + 1 ]  = ( unsigned char )t;
-                middleTemp[ middlePixel3 + 2 ]  = ( unsigned char )t;
-            } // if( imageNeed == morphDepthMap )
-            else
-            {
-                middleTemp[ middlePixel3 ] =
-                    (unsigned char)( leftTemp[ leftPixel3 ] * alpha1
-                    + rightTemp[ rightPixel3 ] * alpha );
-                middleTemp[ middlePixel3 + 1 ] =
-                    (unsigned char)( leftTemp[ leftPixel3 + 1 ] * alpha1
-                    + rightTemp[ rightPixel3 + 1 ] * alpha );
-                middleTemp[ middlePixel3 + 2 ] =
-                    (unsigned char)( leftTemp[ leftPixel3 + 2 ] * alpha1
-                    + rightTemp[ rightPixel3 + 2 ] * alpha );
-
-                if( middlePixel - prevMiddlePixel > 1 ) // occlusion
-                {
-                    if( leftPixel - prevLeftPixel > 1 )
-                    {
-                        int LenSrc  = leftPixel - prevLeftPixel - 2;
-                        int LenDest = middlePixel - prevMiddlePixel - 1;
-                        for( j = prevMiddlePixel + 1; j < middlePixel; j ++ )
-                        {
-                            tempIndex   = prevLeftPixel + 1 + LenSrc *
-                                ( j - prevMiddlePixel - 1 ) / LenDest;
-                            middleTemp[ j * 3 ]     =
-                                leftTemp[ tempIndex * 3 ];
-                            middleTemp[ j * 3 + 1 ] =
-                                leftTemp[ tempIndex * 3 + 1 ];
-                            middleTemp[ j * 3 + 2 ] =
-                                leftTemp[ tempIndex * 3 + 2 ];
-                        }
-                    } // if( leftPixel - prevLeftPixel > 1 )
-                    else
-                    {
-                        int LenSrc  = rightPixel - prevRightPixel - 2;
-                        int LenDest = middlePixel - prevMiddlePixel - 1;
-                        for( j = prevMiddlePixel + 1; j < middlePixel; j ++ )
-                        {
-                            tempIndex   = prevRightPixel + 1 + LenSrc *
-                                ( j - prevMiddlePixel - 1 ) / LenDest;
-                            middleTemp[ j * 3 ]     =
-                                rightTemp[ tempIndex * 3 ];
-                            middleTemp[ j * 3 + 1 ] =
-                                rightTemp[ tempIndex * 3 + 1 ];
-                            middleTemp[ j * 3 + 2 ] =
-                                rightTemp[ tempIndex * 3 + 2 ];
-                        }
-                    } // if( leftPixel - prevLeftPixel > 1 ) else
-
-                } // if( middlePixel - prevMiddlePixel > 1 )
-
-            } // if( imageNeed == morphDepthMap ) else
-
-            if( middlePixel > prevMiddlePixel ) {
-                if( leftPixel > prevLeftPixel )
-                    prevLeftPixel   = leftPixel;
-                if( rightPixel > prevRightPixel )
-                    prevRightPixel  = rightPixel;
-                prevMiddlePixel = middlePixel;
-            }
-        } // for( i = number - 1; i >= 0; i -- )
-
-    } // for( lineNumber = 0; lineNumber < LeftImage -> m_Raster -> GetHeight() )
-
-} // Morph
-
-bool  CCvGraphCutMorpher::OnCalculateStereo()
-{
-    CvSize imageSizeLeft = GetImageSize( m_left_img ),
-           imageSizeRight = GetImageSize( m_right_img );
-
-    if( ( imageSizeLeft.width != imageSizeRight.width )
-        || ( imageSizeLeft.height != imageSizeRight.height ) )
-    {
-        return false;
-    }
-
-    if( m_corr ) {
-        free( m_corr );
-        m_corr = NULL;
-    }
-    m_corr = ( int* ) malloc( m_left_img -> width
-        * m_left_img -> height
-        * sizeof( int ) );
-
-    if( !m_storage ) {
-        m_storage = cvCreateMemStorage( 0 );
-        m_isStorageAllocated = true;
-    }
-    // Find correspondence for full image and store it to corr array
-    allLinesCorr( ( unsigned char* )m_left_img -> imageData,
-                  m_left_img -> widthStep,
-                  ( unsigned char* )m_right_img -> imageData,
-                  m_right_img -> widthStep,
-                  m_left_img -> width,
-                  m_left_img -> height,
-                  m_corr,
-                  m_maxPixelDifference,
-                  m_storage );
-
-    m_isStereoReady = true;
-
-    return true;
-}
-
-bool  CCvGraphCutMorpher::OnCalculateVirtualImage()
-{
-    // Output image to ResultImage window
-    Morph( ( unsigned char* )m_left_img -> imageData,
-           m_left_img ->widthStep,
-           ( unsigned char* )m_right_img -> imageData,
-           m_right_img -> widthStep,
-           ( unsigned char* )m_virtual_img -> imageData,
-           m_virtual_img -> widthStep,
-           m_corr,
-           m_left_img -> width,
-           m_left_img -> height,
-           m_pan );
-
-    m_isVirtualImageReady = true;
-
-    return true;
-}
-
-bool  CCvGraphCutMorpher::OnCalculateDisparity()
-{
-    Morph( ( unsigned char* )m_left_img -> imageData,
-           m_left_img ->widthStep,
-           ( unsigned char* )m_right_img -> imageData,
-           m_right_img -> widthStep,
-           ( unsigned char* )m_disparity_img -> imageData,
-           m_disparity_img -> widthStep,
-           m_corr,
-           m_left_img -> width,
-           m_left_img -> height,
-           m_pan,
-           morphDepthMap,
-           m_maxPixelDifference );
-
-    return true;
-}
-
-bool  CCvGraphCutMorpher::OnCalculateDisparityImage()
-{
-    Morph( ( unsigned char* )m_left_img -> imageData,
-           m_left_img ->widthStep,
-           ( unsigned char* )m_right_img -> imageData,
-           m_right_img -> widthStep,
-           ( unsigned char* )m_disparity_img -> imageData,
-           m_disparity_img -> widthStep,
-           m_corr,
-           m_left_img -> width,
-           m_left_img -> height,
-           m_pan,
-           morphDepthMap,
-           m_maxPixelDifference );
-
-    return true;
-}
-
-CCvGraphCutMorpher::CCvGraphCutMorpher()
-{
-    m_maxPixelDifference = MAX_DIFFERENCE;
-    m_corr = 0;
-    m_isStereoReady = false;
-    m_isVirtualImageReady = false;
-    m_isDisparityReady = false;
-    m_storage = NULL;
-    m_isStorageAllocated = false;
-}
-
-#endif
-
-/* End of file */
diff --git a/modules/legacy/src/enteringblobdetection.cpp b/modules/legacy/src/enteringblobdetection.cpp
deleted file mode 100644 (file)
index a488e08..0000000
+++ /dev/null
@@ -1,1062 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
-This file implements the virtual interface defined as "CvBlobDetector".
-This implementation based on a simple algorithm:
-A new blob is detected when several successive frames contains connected components
-which have uniform motion not at an unreasonably high speed.
-Separation from border and already tracked blobs are also considered.
-
-For an entrypoint into the literature see:
-
-     Appearance Models for Occlusion Handling
-     Andrew Senior &t al, 8p 2001
-     http://www.research.ibm.com/peoplevision/PETS2001.pdf
-
-*/
-
-//#define USE_OBJECT_DETECTOR
-
-#include "precomp.hpp"
-
-static int CompareContour(const void* a, const void* b, void* )
-{
-    float           dx,dy;
-    float           h,w,ht,wt;
-    CvPoint2D32f    pa,pb;
-    CvRect          ra,rb;
-    CvSeq*          pCA = *(CvSeq**)a;
-    CvSeq*          pCB = *(CvSeq**)b;
-    ra = ((CvContour*)pCA)->rect;
-    rb = ((CvContour*)pCB)->rect;
-    pa.x = ra.x + ra.width*0.5f;
-    pa.y = ra.y + ra.height*0.5f;
-    pb.x = rb.x + rb.width*0.5f;
-    pb.y = rb.y + rb.height*0.5f;
-    w = (ra.width+rb.width)*0.5f;
-    h = (ra.height+rb.height)*0.5f;
-
-    dx = (float)(fabs(pa.x - pb.x)-w);
-    dy = (float)(fabs(pa.y - pb.y)-h);
-
-    //wt = MAX(ra.width,rb.width)*0.1f;
-    wt = 0;
-    ht = MAX(ra.height,rb.height)*0.3f;
-    return (dx < wt && dy < ht);
-}
-
-static void cvFindBlobsByCCClasters(IplImage* pFG, CvBlobSeq* pBlobs, CvMemStorage* storage)
-{   /* Create contours: */
-    IplImage*       pIB = NULL;
-    CvSeq*          cnt = NULL;
-    CvSeq*          cnt_list = cvCreateSeq(0,sizeof(CvSeq),sizeof(CvSeq*), storage );
-    CvSeq*          clasters = NULL;
-    int             claster_cur, claster_num;
-
-    pIB = cvCloneImage(pFG);
-    cvThreshold(pIB,pIB,128,255,CV_THRESH_BINARY);
-    cvFindContours(pIB,storage, &cnt, sizeof(CvContour), CV_RETR_EXTERNAL);
-    cvReleaseImage(&pIB);
-
-    /* Create cnt_list.      */
-    /* Process each contour: */
-    for(; cnt; cnt=cnt->h_next)
-    {
-        cvSeqPush( cnt_list, &cnt);
-    }
-
-    claster_num = cvSeqPartition( cnt_list, storage, &clasters, CompareContour, NULL );
-
-    for(claster_cur=0; claster_cur<claster_num; ++claster_cur)
-    {
-        int         cnt_cur;
-        CvBlob      NewBlob;
-        double      M00,X,Y,XX,YY; /* image moments */
-        CvMoments   m;
-        CvRect      rect_res = cvRect(-1,-1,-1,-1);
-        CvMat       mat;
-
-        for(cnt_cur=0; cnt_cur<clasters->total; ++cnt_cur)
-        {
-            CvRect  rect;
-            CvSeq*  cont;
-            int k = *(int*)cvGetSeqElem( clasters, cnt_cur );
-            if(k!=claster_cur) continue;
-            cont = *(CvSeq**)cvGetSeqElem( cnt_list, cnt_cur );
-            rect = ((CvContour*)cont)->rect;
-
-            if(rect_res.height<0)
-            {
-                rect_res = rect;
-            }
-            else
-            {   /* Unite rects: */
-                int x0,x1,y0,y1;
-                x0 = MIN(rect_res.x,rect.x);
-                y0 = MIN(rect_res.y,rect.y);
-                x1 = MAX(rect_res.x+rect_res.width,rect.x+rect.width);
-                y1 = MAX(rect_res.y+rect_res.height,rect.y+rect.height);
-                rect_res.x = x0;
-                rect_res.y = y0;
-                rect_res.width = x1-x0;
-                rect_res.height = y1-y0;
-            }
-        }
-
-        if(rect_res.height < 1 || rect_res.width < 1)
-        {
-            X = 0;
-            Y = 0;
-            XX = 0;
-            YY = 0;
-        }
-        else
-        {
-            cvMoments( cvGetSubRect(pFG,&mat,rect_res), &m, 0 );
-            M00 = cvGetSpatialMoment( &m, 0, 0 );
-            if(M00 <= 0 ) continue;
-            X = cvGetSpatialMoment( &m, 1, 0 )/M00;
-            Y = cvGetSpatialMoment( &m, 0, 1 )/M00;
-            XX = (cvGetSpatialMoment( &m, 2, 0 )/M00) - X*X;
-            YY = (cvGetSpatialMoment( &m, 0, 2 )/M00) - Y*Y;
-        }
-        NewBlob = cvBlob(rect_res.x+(float)X,rect_res.y+(float)Y,(float)(4*sqrt(XX)),(float)(4*sqrt(YY)));
-        pBlobs->AddBlob(&NewBlob);
-
-    }   /* Next cluster. */
-
-    #if 0
-    {   // Debug info:
-        IplImage* pI = cvCreateImage(cvSize(pFG->width,pFG->height),IPL_DEPTH_8U,3);
-        cvZero(pI);
-        for(claster_cur=0; claster_cur<claster_num; ++claster_cur)
-        {
-            int         cnt_cur;
-            CvScalar    color = CV_RGB(rand()%256,rand()%256,rand()%256);
-
-            for(cnt_cur=0; cnt_cur<clasters->total; ++cnt_cur)
-            {
-                CvSeq*  cnt;
-                int k = *(int*)cvGetSeqElem( clasters, cnt_cur );
-                if(k!=claster_cur) continue;
-                cnt = *(CvSeq**)cvGetSeqElem( cnt_list, cnt_cur );
-                cvDrawContours( pI, cnt, color, color, 0, 1, 8);
-            }
-
-            CvBlob* pB = pBlobs->GetBlob(claster_cur);
-            int x = cvRound(CV_BLOB_RX(pB)), y = cvRound(CV_BLOB_RY(pB));
-            cvEllipse( pI,
-                cvPointFrom32f(CV_BLOB_CENTER(pB)),
-                cvSize(MAX(1,x), MAX(1,y)),
-                0, 0, 360,
-                color, 1 );
-        }
-
-        cvNamedWindow( "Clusters", 0);
-        cvShowImage( "Clusters",pI );
-
-        cvReleaseImage(&pI);
-
-    }   /* Debug info. */
-    #endif
-
-}   /* cvFindBlobsByCCClasters */
-
-/* Simple blob detector.  */
-/* Number of successive frame to analyse: */
-#define EBD_FRAME_NUM   5
-class CvBlobDetectorSimple:public CvBlobDetector
-{
-public:
-    CvBlobDetectorSimple();
-   ~CvBlobDetectorSimple();
-    int DetectNewBlob(IplImage* pImg, IplImage* pFGMask, CvBlobSeq* pNewBlobList, CvBlobSeq* pOldBlobList);
-    void Release(){delete this;}
-
-protected:
-    IplImage*       m_pMaskBlobNew;
-    IplImage*       m_pMaskBlobExist;
-    /* Lists of connected components detected on previous frames: */
-    CvBlobSeq*      m_pBlobLists[EBD_FRAME_NUM];
-};
-
-/* Blob detector creator (sole interface function for this file) */
-CvBlobDetector* cvCreateBlobDetectorSimple(){return new CvBlobDetectorSimple;}
-
-/* Constructor of BlobDetector: */
-CvBlobDetectorSimple::CvBlobDetectorSimple()
-{
-    int i = 0;
-    m_pMaskBlobNew = NULL;
-    m_pMaskBlobExist = NULL;
-    for(i=0;i<EBD_FRAME_NUM;++i)m_pBlobLists[i] = NULL;
-
-    SetModuleName("Simple");
-}
-
-/* Destructor of BlobDetector: */
-CvBlobDetectorSimple::~CvBlobDetectorSimple()
-{
-    int i;
-    if(m_pMaskBlobExist) cvReleaseImage(&m_pMaskBlobExist);
-    if(m_pMaskBlobNew) cvReleaseImage(&m_pMaskBlobNew);
-    for(i=0; i<EBD_FRAME_NUM; ++i) delete m_pBlobLists[i];
-}   /* cvReleaseBlobDetector */
-
-/* cvDetectNewBlobs
- * return 1 and fill blob pNewBlob by blob parameters
- * if new blob is detected:
- */
-int CvBlobDetectorSimple::DetectNewBlob(IplImage* /*pImg*/, IplImage* pFGMask, CvBlobSeq* pNewBlobList, CvBlobSeq* pOldBlobList)
-{
-    int         result = 0;
-    CvSize      S = cvSize(pFGMask->width,pFGMask->height);
-    if(m_pMaskBlobNew == NULL ) m_pMaskBlobNew = cvCreateImage(S,IPL_DEPTH_8U,1);
-    if(m_pMaskBlobExist == NULL ) m_pMaskBlobExist = cvCreateImage(S,IPL_DEPTH_8U,1);
-
-    /* Shift blob list: */
-    {
-        int     i;
-        if(m_pBlobLists[0]) delete m_pBlobLists[0];
-        for(i=1;i<EBD_FRAME_NUM;++i)m_pBlobLists[i-1]=m_pBlobLists[i];
-        m_pBlobLists[EBD_FRAME_NUM-1] = new CvBlobSeq;
-    }   /* Shift blob list. */
-
-    /* Create exist blob mask: */
-    cvCopy(pFGMask, m_pMaskBlobNew);
-
-    /* Create contours and add new blobs to blob list: */
-    {   /* Create blobs: */
-        CvBlobSeq       Blobs;
-        CvMemStorage*   storage = cvCreateMemStorage();
-
-#if 1
-        {   /* Glue contours: */
-            cvFindBlobsByCCClasters(m_pMaskBlobNew, &Blobs, storage );
-        }   /* Glue contours. */
-#else
-        {   /**/
-            IplImage*       pIB = cvCloneImage(m_pMaskBlobNew);
-            CvSeq*          cnts = NULL;
-            CvSeq*          cnt = NULL;
-            cvThreshold(pIB,pIB,128,255,CV_THRESH_BINARY);
-            cvFindContours(pIB,storage, &cnts, sizeof(CvContour), CV_RETR_EXTERNAL);
-
-            /* Process each contour: */
-            for(cnt = cnts; cnt; cnt=cnt->h_next)
-            {
-                CvBlob  NewBlob;
-
-                /* Image moments: */
-                double      M00,X,Y,XX,YY;
-                CvMoments   m;
-                CvRect      r = ((CvContour*)cnt)->rect;
-                CvMat       mat;
-
-                if(r.height < S.height*0.02 || r.width < S.width*0.02) continue;
-
-                cvMoments( cvGetSubRect(m_pMaskBlobNew,&mat,r), &m, 0 );
-                M00 = cvGetSpatialMoment( &m, 0, 0 );
-
-                if(M00 <= 0 ) continue;
-
-                X  = cvGetSpatialMoment( &m, 1, 0 )/M00;
-                Y  = cvGetSpatialMoment( &m, 0, 1 )/M00;
-
-                XX = (cvGetSpatialMoment( &m, 2, 0 )/M00) - X*X;
-                YY = (cvGetSpatialMoment( &m, 0, 2 )/M00) - Y*Y;
-
-                NewBlob = cvBlob(r.x+(float)X,r.y+(float)Y,(float)(4*sqrt(XX)),(float)(4*sqrt(YY)));
-
-                Blobs.AddBlob(&NewBlob);
-
-            }   /* Next contour. */
-
-            cvReleaseImage(&pIB);
-
-        }   /* One contour - one blob. */
-#endif
-
-        {   /* Delete small and intersected blobs: */
-            int i;
-            for(i=Blobs.GetBlobNum(); i>0; i--)
-            {
-                CvBlob* pB = Blobs.GetBlob(i-1);
-
-                if(pB->h < S.height*0.02 || pB->w < S.width*0.02)
-                {
-                    Blobs.DelBlob(i-1);
-                    continue;
-                }
-                if(pOldBlobList)
-                {
-                    int j;
-                    for(j=pOldBlobList->GetBlobNum(); j>0; j--)
-                    {
-                        CvBlob* pBOld = pOldBlobList->GetBlob(j-1);
-                        if((fabs(pBOld->x-pB->x) < (CV_BLOB_RX(pBOld)+CV_BLOB_RX(pB))) &&
-                           (fabs(pBOld->y-pB->y) < (CV_BLOB_RY(pBOld)+CV_BLOB_RY(pB))))
-                        {   /* Intersection is present, so delete blob from list: */
-                            Blobs.DelBlob(i-1);
-                            break;
-                        }
-                    }   /* Check next old blob. */
-                }   /*  if pOldBlobList */
-            }   /* Check next blob. */
-        }   /*  Delete small and intersected blobs. */
-
-        {   /* Bubble-sort blobs by size: */
-            int N = Blobs.GetBlobNum();
-            int i,j;
-            for(i=1; i<N; ++i)
-            {
-                for(j=i; j>0; --j)
-                {
-                    CvBlob  temp;
-                    float   AreaP, AreaN;
-                    CvBlob* pP = Blobs.GetBlob(j-1);
-                    CvBlob* pN = Blobs.GetBlob(j);
-                    AreaP = CV_BLOB_WX(pP)*CV_BLOB_WY(pP);
-                    AreaN = CV_BLOB_WX(pN)*CV_BLOB_WY(pN);
-                    if(AreaN < AreaP)break;
-                    temp = pN[0];
-                    pN[0] = pP[0];
-                    pP[0] = temp;
-                }
-            }
-
-            /* Copy only first 10 blobs: */
-            for(i=0; i<MIN(N,10); ++i)
-            {
-                m_pBlobLists[EBD_FRAME_NUM-1]->AddBlob(Blobs.GetBlob(i));
-            }
-
-        }   /* Sort blobs by size. */
-
-        cvReleaseMemStorage(&storage);
-
-    }   /* Create blobs. */
-
-    /* Analyze blob list to find best blob trajectory: */
-    {
-        int     Count = 0;
-        int     pBLIndex[EBD_FRAME_NUM];
-        int     pBL_BEST[EBD_FRAME_NUM];
-        int     i;
-        int     finish = 0;
-        double  BestError = -1;
-        int     Good = 1;
-
-        for(i=0; i<EBD_FRAME_NUM; ++i)
-        {
-            pBLIndex[i] = 0;
-            pBL_BEST[i] = 0;
-        }
-
-        /* Check configuration exist: */
-        for(i=0; Good && (i<EBD_FRAME_NUM); ++i)
-            if(m_pBlobLists[i] == NULL || m_pBlobLists[i]->GetBlobNum() == 0)
-                Good = 0;
-
-        if(Good)
-        do{ /* For each configuration: */
-            CvBlob* pBL[EBD_FRAME_NUM];
-            int     good = 1;
-            double  Error = 0;
-            CvBlob* pBNew = m_pBlobLists[EBD_FRAME_NUM-1]->GetBlob(pBLIndex[EBD_FRAME_NUM-1]);
-
-            for(i=0; i<EBD_FRAME_NUM; ++i)  pBL[i] = m_pBlobLists[i]->GetBlob(pBLIndex[i]);
-
-            Count++;
-
-            /* Check intersection last blob with existed: */
-            if(good && pOldBlobList)
-            {   /* Check intersection last blob with existed: */
-                int     k;
-                for(k=pOldBlobList->GetBlobNum(); k>0; --k)
-                {
-                    CvBlob* pBOld = pOldBlobList->GetBlob(k-1);
-                    if((fabs(pBOld->x-pBNew->x) < (CV_BLOB_RX(pBOld)+CV_BLOB_RX(pBNew))) &&
-                       (fabs(pBOld->y-pBNew->y) < (CV_BLOB_RY(pBOld)+CV_BLOB_RY(pBNew))))
-                        good = 0;
-                }
-            }   /* Check intersection last blob with existed. */
-
-            /* Check distance to image border: */
-            if(good)
-            {   /* Check distance to image border: */
-                CvBlob*  pB = pBNew;
-                float    dx = MIN(pB->x,S.width-pB->x)/CV_BLOB_RX(pB);
-                float    dy = MIN(pB->y,S.height-pB->y)/CV_BLOB_RY(pB);
-
-                if(dx < 1.1 || dy < 1.1) good = 0;
-            }   /* Check distance to image border. */
-
-            /* Check uniform motion: */
-            if(good)
-            {
-                int     N = EBD_FRAME_NUM;
-                float   sum[2] = {0,0};
-                float   jsum[2] = {0,0};
-                float   a[2],b[2]; /* estimated parameters of moving x(t) = a*t+b*/
-
-                int j;
-                for(j=0; j<N; ++j)
-                {
-                    float   x = pBL[j]->x;
-                    float   y = pBL[j]->y;
-                    sum[0] += x;
-                    jsum[0] += j*x;
-                    sum[1] += y;
-                    jsum[1] += j*y;
-                }
-
-                a[0] = 6*((1-N)*sum[0]+2*jsum[0])/(N*(N*N-1));
-                b[0] = -2*((1-2*N)*sum[0]+3*jsum[0])/(N*(N+1));
-                a[1] = 6*((1-N)*sum[1]+2*jsum[1])/(N*(N*N-1));
-                b[1] = -2*((1-2*N)*sum[1]+3*jsum[1])/(N*(N+1));
-
-                for(j=0; j<N; ++j)
-                {
-                    Error +=
-                        pow(a[0]*j+b[0]-pBL[j]->x,2)+
-                        pow(a[1]*j+b[1]-pBL[j]->y,2);
-                }
-
-                Error = sqrt(Error/N);
-
-                if( Error > S.width*0.01 ||
-                    fabs(a[0])>S.width*0.1 ||
-                    fabs(a[1])>S.height*0.1)
-                    good = 0;
-
-            }   /* Check configuration. */
-
-
-            /* New best trajectory: */
-            if(good && (BestError == -1 || BestError > Error))
-            {
-                for(i=0; i<EBD_FRAME_NUM; ++i)
-                {
-                    pBL_BEST[i] = pBLIndex[i];
-                }
-                BestError = Error;
-            }   /* New best trajectory. */
-
-            /* Set next configuration: */
-            for(i=0; i<EBD_FRAME_NUM; ++i)
-            {
-                pBLIndex[i]++;
-                if(pBLIndex[i] != m_pBlobLists[i]->GetBlobNum()) break;
-                pBLIndex[i]=0;
-            }   /* Next time shift. */
-
-            if(i==EBD_FRAME_NUM)finish=1;
-
-        } while(!finish);   /* Check next time configuration of connected components. */
-
-        #if 0
-        {/**/
-            printf("BlobDetector configurations = %d [",Count);
-            int i;
-            for(i=0; i<EBD_FRAME_NUM; ++i)
-            {
-                printf("%d,",m_pBlobLists[i]?m_pBlobLists[i]->GetBlobNum():0);
-            }
-            printf("]\n");
-
-        }
-        #endif
-
-        if(BestError != -1)
-        {   /* Write new blob to output and delete from blob list: */
-            CvBlob* pNewBlob = m_pBlobLists[EBD_FRAME_NUM-1]->GetBlob(pBL_BEST[EBD_FRAME_NUM-1]);
-            pNewBlobList->AddBlob(pNewBlob);
-
-            for(i=0; i<EBD_FRAME_NUM; ++i)
-            {   /* Remove blob from each list: */
-                m_pBlobLists[i]->DelBlob(pBL_BEST[i]);
-            }   /* Remove blob from each list. */
-
-            result = 1;
-
-        }   /* Write new blob to output and delete from blob list. */
-    }   /*  Analyze blob list to find best blob trajectory. */
-
-    return result;
-
-}   /* cvDetectNewBlob */
-
-
-
-
-/* Simple blob detector2.  */
-/* Number of successive frames to analyse: */
-#define SEQ_SIZE_MAX    30
-#define SEQ_NUM         1000
-typedef struct
-{
-    int     size;
-    CvBlob* pBlobs[SEQ_SIZE_MAX];
-} DefSeq;
-
-class CvBlobDetectorCC:public CvBlobDetector
-{
-public:
-    CvBlobDetectorCC();
-   ~CvBlobDetectorCC();
-    int DetectNewBlob(IplImage* pImg, IplImage* pFGMask, CvBlobSeq* pNewBlobList, CvBlobSeq* pOldBlobList);
-    void Release(){delete this;}
-
-    virtual void ParamUpdate()
-    {
-        if(SEQ_SIZE<1)SEQ_SIZE=1;
-        if(SEQ_SIZE>SEQ_SIZE_MAX)SEQ_SIZE=SEQ_SIZE_MAX;
-
-#ifdef USE_OBJECT_DETECTOR
-        if( m_param_split_detector_file_name )
-        {
-            m_split_detector = new CvObjectDetector();
-            if( !m_split_detector->Load( m_param_split_detector_file_name ) )
-            {
-                delete m_split_detector;
-                m_split_detector = 0;
-            }
-            else
-            {
-                m_min_window_size = m_split_detector->GetMinWindowSize();
-                m_max_border = m_split_detector->GetMaxBorderSize();
-            }
-        }
-#endif
-    }
-
-private:
-    /* Lists of connected components detected on previous frames: */
-    CvBlobSeq*      m_pBlobLists[SEQ_SIZE_MAX];
-    DefSeq          m_TrackSeq[SEQ_NUM];
-    int             m_TrackNum;
-    float           m_HMin;
-    float           m_WMin;
-    float           m_MinDistToBorder;
-    int             m_Clastering;
-    int             SEQ_SIZE;
-
-    /* If not 0 then the detector is loaded from the specified file
-     * and it is applied for splitting blobs which actually correspond
-     * to groups of objects:
-     */
-    char*           m_param_split_detector_file_name;
-    float           m_param_roi_scale;
-    int             m_param_only_roi;
-
-    CvObjectDetector* m_split_detector;
-    CvSize          m_min_window_size;
-    int             m_max_border;
-
-    CvBlobSeq       m_detected_blob_seq;
-    CvSeq*          m_roi_seq;
-
-    CvBlobSeq       m_debug_blob_seq;
-};
-
-/* Blob detector creator (sole interface function for this file): */
-CvBlobDetector* cvCreateBlobDetectorCC(){return new CvBlobDetectorCC;}
-
-/* Constructor for BlobDetector: */
-CvBlobDetectorCC::CvBlobDetectorCC() :
-    m_split_detector(0),
-    m_detected_blob_seq(sizeof(CvDetectedBlob)),
-    m_roi_seq(0),
-    m_debug_blob_seq(sizeof(CvDetectedBlob))
-{
-    /*CvDrawShape shapes[] =
-    {
-        { CvDrawShape::RECT,    {{255,255,255}} },
-        { CvDrawShape::RECT,    {{0,0,255}} },
-        { CvDrawShape::ELLIPSE, {{0,255,0}} }
-    };
-    int num_shapes = sizeof(shapes) / sizeof(shapes[0]);*/
-
-    int i = 0;
-    SEQ_SIZE = 10;
-    AddParam("Latency",&SEQ_SIZE);
-    for(i=0;i<SEQ_SIZE_MAX;++i)m_pBlobLists[i] = NULL;
-    for(i=0;i<SEQ_NUM;++i)m_TrackSeq[i].size = 0;
-    m_TrackNum = 0;
-
-    m_HMin = 0.02f;
-    m_WMin = 0.01f;
-    AddParam("HMin",&m_HMin);
-    AddParam("WMin",&m_WMin);
-    m_MinDistToBorder = 1.1f;
-    AddParam("MinDistToBorder",&m_MinDistToBorder);
-    CommentParam("MinDistToBorder","Minimal allowed distance from blob center to image border in blob sizes");
-
-    m_Clastering=1;
-    AddParam("Clastering",&m_Clastering);
-    CommentParam("Clastering","Minimal allowed distance from blob center to image border in blob sizes");
-
-    m_param_split_detector_file_name = 0;
-#ifdef USE_OBJECT_DETECTOR
-    AddParam("Detector", &m_param_split_detector_file_name);
-    CommentParam("Detector", "Detector file name");
-#endif
-
-    m_param_roi_scale = 1.5F;
-    AddParam("ROIScale", &m_param_roi_scale);
-    CommentParam("ROIScale", "Determines the size of search window around a blob");
-
-    m_param_only_roi = 1;
-    AddParam("OnlyROI", &m_param_only_roi);
-    CommentParam("OnlyROI", "Shows the whole debug image (0) or only ROIs where the detector was applied (1)");
-
-    m_min_window_size = cvSize(0,0);
-    m_max_border = 0;
-    m_roi_seq = cvCreateSeq( 0, sizeof(*m_roi_seq), sizeof(CvRect), cvCreateMemStorage() );
-
-    SetModuleName("CC");
-}
-
-/* Destructor for BlobDetector: */
-CvBlobDetectorCC::~CvBlobDetectorCC()
-{
-    int i;
-    for(i=0; i<SEQ_SIZE_MAX; ++i)
-    {
-        if(m_pBlobLists[i])
-            delete m_pBlobLists[i];
-    }
-
-    if( m_roi_seq )
-    {
-        cvReleaseMemStorage( &m_roi_seq->storage );
-        m_roi_seq = 0;
-    }
-    //cvDestroyWindow( "EnteringBlobDetectionDebug" );
-}   /* cvReleaseBlobDetector */
-
-
-/* cvDetectNewBlobs
- * Return 1 and fill blob pNewBlob  with
- * blob parameters if new blob is detected:
- */
-int CvBlobDetectorCC::DetectNewBlob(IplImage* /*pImg*/, IplImage* pFGMask, CvBlobSeq* pNewBlobList, CvBlobSeq* pOldBlobList)
-{
-    int         result = 0;
-    CvSize      S = cvSize(pFGMask->width,pFGMask->height);
-
-    /* Shift blob list: */
-    {
-        int     i;
-        if(m_pBlobLists[SEQ_SIZE-1]) delete m_pBlobLists[SEQ_SIZE-1];
-
-        for(i=SEQ_SIZE-1; i>0; --i)  m_pBlobLists[i] = m_pBlobLists[i-1];
-
-        m_pBlobLists[0] = new CvBlobSeq;
-
-    }   /* Shift blob list. */
-
-    /* Create contours and add new blobs to blob list: */
-    {   /* Create blobs: */
-        CvBlobSeq       Blobs;
-        CvMemStorage*   storage = cvCreateMemStorage();
-
-        if(m_Clastering)
-        {   /* Glue contours: */
-            cvFindBlobsByCCClasters(pFGMask, &Blobs, storage );
-        }   /* Glue contours. */
-        else
-        { /**/
-            IplImage*       pIB = cvCloneImage(pFGMask);
-            CvSeq*          cnts = NULL;
-            CvSeq*          cnt = NULL;
-            cvThreshold(pIB,pIB,128,255,CV_THRESH_BINARY);
-            cvFindContours(pIB,storage, &cnts, sizeof(CvContour), CV_RETR_EXTERNAL);
-
-            /* Process each contour: */
-            for(cnt = cnts; cnt; cnt=cnt->h_next)
-            {
-                CvBlob  NewBlob;
-                /* Image moments: */
-                double      M00,X,Y,XX,YY;
-                CvMoments   m;
-                CvRect      r = ((CvContour*)cnt)->rect;
-                CvMat       mat;
-                if(r.height < S.height*m_HMin || r.width < S.width*m_WMin) continue;
-                cvMoments( cvGetSubRect(pFGMask,&mat,r), &m, 0 );
-                M00 = cvGetSpatialMoment( &m, 0, 0 );
-                if(M00 <= 0 ) continue;
-                X = cvGetSpatialMoment( &m, 1, 0 )/M00;
-                Y = cvGetSpatialMoment( &m, 0, 1 )/M00;
-                XX = (cvGetSpatialMoment( &m, 2, 0 )/M00) - X*X;
-                YY = (cvGetSpatialMoment( &m, 0, 2 )/M00) - Y*Y;
-                NewBlob = cvBlob(r.x+(float)X,r.y+(float)Y,(float)(4*sqrt(XX)),(float)(4*sqrt(YY)));
-                Blobs.AddBlob(&NewBlob);
-
-            }   /* Next contour. */
-
-            cvReleaseImage(&pIB);
-
-        }   /* One contour - one blob. */
-
-        {   /* Delete small and intersected blobs: */
-            int i;
-            for(i=Blobs.GetBlobNum(); i>0; i--)
-            {
-                CvBlob* pB = Blobs.GetBlob(i-1);
-
-                if(pB->h < S.height*m_HMin || pB->w < S.width*m_WMin)
-                {
-                    Blobs.DelBlob(i-1);
-                    continue;
-                }
-
-                if(pOldBlobList)
-                {
-                    int j;
-                    for(j=pOldBlobList->GetBlobNum(); j>0; j--)
-                    {
-                        CvBlob* pBOld = pOldBlobList->GetBlob(j-1);
-                        if((fabs(pBOld->x-pB->x) < (CV_BLOB_RX(pBOld)+CV_BLOB_RX(pB))) &&
-                           (fabs(pBOld->y-pB->y) < (CV_BLOB_RY(pBOld)+CV_BLOB_RY(pB))))
-                        {   /* Intersection detected, delete blob from list: */
-                            Blobs.DelBlob(i-1);
-                            break;
-                        }
-                    }   /* Check next old blob. */
-                }   /*  if pOldBlobList. */
-            }   /*  Check next blob. */
-        }   /*  Delete small and intersected blobs. */
-
-        {   /* Bubble-sort blobs by size: */
-            int N = Blobs.GetBlobNum();
-            int i,j;
-            for(i=1; i<N; ++i)
-            {
-                for(j=i; j>0; --j)
-                {
-                    CvBlob  temp;
-                    float   AreaP, AreaN;
-                    CvBlob* pP = Blobs.GetBlob(j-1);
-                    CvBlob* pN = Blobs.GetBlob(j);
-                    AreaP = CV_BLOB_WX(pP)*CV_BLOB_WY(pP);
-                    AreaN = CV_BLOB_WX(pN)*CV_BLOB_WY(pN);
-                    if(AreaN < AreaP)break;
-                    temp = pN[0];
-                    pN[0] = pP[0];
-                    pP[0] = temp;
-                }
-            }
-
-            /* Copy only first 10 blobs: */
-            for(i=0; i<MIN(N,10); ++i)
-            {
-                m_pBlobLists[0]->AddBlob(Blobs.GetBlob(i));
-            }
-
-        }   /* Sort blobs by size. */
-
-        cvReleaseMemStorage(&storage);
-
-    }   /* Create blobs. */
-
-    {   /* Shift each track: */
-        int j;
-        for(j=0; j<m_TrackNum; ++j)
-        {
-            int     i;
-            DefSeq* pTrack = m_TrackSeq+j;
-
-            for(i=SEQ_SIZE-1; i>0; --i)
-                pTrack->pBlobs[i] = pTrack->pBlobs[i-1];
-
-            pTrack->pBlobs[0] = NULL;
-            if(pTrack->size == SEQ_SIZE)pTrack->size--;
-        }
-    }   /* Shift each track. */
-
-    /* Analyze blob list to find best blob trajectory: */
-    {
-        double      BestError = -1;
-        int         BestTrack = -1;;
-        CvBlobSeq*  pNewBlobs = m_pBlobLists[0];
-        int         i;
-        int         NewTrackNum = 0;
-        for(i=pNewBlobs->GetBlobNum(); i>0; --i)
-        {
-            CvBlob* pBNew = pNewBlobs->GetBlob(i-1);
-            int     j;
-            int     AsignedTrack = 0;
-            for(j=0; j<m_TrackNum; ++j)
-            {
-                double  dx,dy;
-                DefSeq* pTrack = m_TrackSeq+j;
-                CvBlob* pLastBlob = pTrack->size>0?pTrack->pBlobs[1]:NULL;
-                if(pLastBlob == NULL) continue;
-                dx = fabs(CV_BLOB_X(pLastBlob)-CV_BLOB_X(pBNew));
-                dy = fabs(CV_BLOB_Y(pLastBlob)-CV_BLOB_Y(pBNew));
-                if(dx > 2*CV_BLOB_WX(pLastBlob) || dy > 2*CV_BLOB_WY(pLastBlob)) continue;
-                AsignedTrack++;
-
-                if(pTrack->pBlobs[0]==NULL)
-                {   /* Fill existed track: */
-                    pTrack->pBlobs[0] = pBNew;
-                    pTrack->size++;
-                }
-                else if((m_TrackNum+NewTrackNum)<SEQ_NUM)
-                {   /* Duplicate existed track: */
-                    m_TrackSeq[m_TrackNum+NewTrackNum] = pTrack[0];
-                    m_TrackSeq[m_TrackNum+NewTrackNum].pBlobs[0] = pBNew;
-                    NewTrackNum++;
-                }
-            }   /* Next track. */
-
-            if(AsignedTrack==0 && (m_TrackNum+NewTrackNum)<SEQ_NUM )
-            {   /* Initialize new track: */
-                m_TrackSeq[m_TrackNum+NewTrackNum].size = 1;
-                m_TrackSeq[m_TrackNum+NewTrackNum].pBlobs[0] = pBNew;
-                NewTrackNum++;
-            }
-        }   /* Next new blob. */
-
-        m_TrackNum += NewTrackNum;
-
-        /* Check each track: */
-        for(i=0; i<m_TrackNum; ++i)
-        {
-            int     Good = 1;
-            DefSeq* pTrack = m_TrackSeq+i;
-            CvBlob* pBNew = pTrack->pBlobs[0];
-            if(pTrack->size != SEQ_SIZE) continue;
-            if(pBNew == NULL ) continue;
-
-            /* Check intersection last blob with existed: */
-            if(Good && pOldBlobList)
-            {
-                int k;
-                for(k=pOldBlobList->GetBlobNum(); k>0; --k)
-                {
-                    CvBlob* pBOld = pOldBlobList->GetBlob(k-1);
-                    if((fabs(pBOld->x-pBNew->x) < (CV_BLOB_RX(pBOld)+CV_BLOB_RX(pBNew))) &&
-                       (fabs(pBOld->y-pBNew->y) < (CV_BLOB_RY(pBOld)+CV_BLOB_RY(pBNew))))
-                        Good = 0;
-                }
-            }   /* Check intersection last blob with existed. */
-
-            /* Check distance to image border: */
-            if(Good)
-            {   /* Check distance to image border: */
-                float    dx = MIN(pBNew->x,S.width-pBNew->x)/CV_BLOB_RX(pBNew);
-                float    dy = MIN(pBNew->y,S.height-pBNew->y)/CV_BLOB_RY(pBNew);
-                if(dx < m_MinDistToBorder || dy < m_MinDistToBorder) Good = 0;
-            }   /* Check distance to image border. */
-
-            /* Check uniform motion: */
-            if(Good)
-            {   /* Check uniform motion: */
-                double      Error = 0;
-                int         N = pTrack->size;
-                CvBlob**    pBL = pTrack->pBlobs;
-                float       sum[2] = {0,0};
-                float       jsum[2] = {0,0};
-                float       a[2],b[2]; /* estimated parameters of moving x(t) = a*t+b*/
-                int         j;
-
-                for(j=0; j<N; ++j)
-                {
-                    float   x = pBL[j]->x;
-                    float   y = pBL[j]->y;
-                    sum[0] += x;
-                    jsum[0] += j*x;
-                    sum[1] += y;
-                    jsum[1] += j*y;
-                }
-
-                a[0] = 6*((1-N)*sum[0]+2*jsum[0])/(N*(N*N-1));
-                b[0] = -2*((1-2*N)*sum[0]+3*jsum[0])/(N*(N+1));
-                a[1] = 6*((1-N)*sum[1]+2*jsum[1])/(N*(N*N-1));
-                b[1] = -2*((1-2*N)*sum[1]+3*jsum[1])/(N*(N+1));
-
-                for(j=0; j<N; ++j)
-                {
-                    Error +=
-                        pow(a[0]*j+b[0]-pBL[j]->x,2)+
-                        pow(a[1]*j+b[1]-pBL[j]->y,2);
-                }
-
-                Error = sqrt(Error/N);
-
-                if( Error > S.width*0.01 ||
-                    fabs(a[0])>S.width*0.1 ||
-                    fabs(a[1])>S.height*0.1)
-                    Good = 0;
-
-                /* New best trajectory: */
-                if(Good && (BestError == -1 || BestError > Error))
-                {   /* New best trajectory: */
-                    BestTrack = i;
-                    BestError = Error;
-                }   /* New best trajectory. */
-            }   /*  Check uniform motion. */
-        }   /*  Next track. */
-
-        #if 0
-        {   /**/
-            printf("BlobDetector configurations = %d [",m_TrackNum);
-            int i;
-            for(i=0; i<SEQ_SIZE; ++i)
-            {
-                printf("%d,",m_pBlobLists[i]?m_pBlobLists[i]->GetBlobNum():0);
-            }
-            printf("]\n");
-        }
-        #endif
-
-        if(BestTrack >= 0)
-        {   /* Put new blob to output and delete from blob list: */
-            assert(m_TrackSeq[BestTrack].size == SEQ_SIZE);
-            assert(m_TrackSeq[BestTrack].pBlobs[0]);
-            pNewBlobList->AddBlob(m_TrackSeq[BestTrack].pBlobs[0]);
-            m_TrackSeq[BestTrack].pBlobs[0] = NULL;
-            m_TrackSeq[BestTrack].size--;
-            result = 1;
-        }   /* Put new blob to output and mark in blob list to delete. */
-    }   /*  Analyze blod list to find best blob trajectory. */
-
-    {   /* Delete bad tracks: */
-        int i;
-        for(i=m_TrackNum-1; i>=0; --i)
-        {   /* Delete bad tracks: */
-            if(m_TrackSeq[i].pBlobs[0]) continue;
-            if(m_TrackNum>0)
-                m_TrackSeq[i] = m_TrackSeq[--m_TrackNum];
-        }   /* Delete bad tracks: */
-    }
-
-#ifdef USE_OBJECT_DETECTOR
-    if( m_split_detector && pNewBlobList->GetBlobNum() > 0 )
-    {
-        int num_new_blobs = pNewBlobList->GetBlobNum();
-        int i = 0;
-
-        if( m_roi_seq ) cvClearSeq( m_roi_seq );
-        m_debug_blob_seq.Clear();
-        for( i = 0; i < num_new_blobs; ++i )
-        {
-            CvBlob* b = pNewBlobList->GetBlob(i);
-            CvMat roi_stub;
-            CvMat* roi_mat = 0;
-            CvMat* scaled_roi_mat = 0;
-
-            CvDetectedBlob d_b = cvDetectedBlob( CV_BLOB_X(b), CV_BLOB_Y(b), CV_BLOB_WX(b), CV_BLOB_WY(b), 0 );
-            m_debug_blob_seq.AddBlob(&d_b);
-
-            float scale = m_param_roi_scale * m_min_window_size.height / CV_BLOB_WY(b);
-
-            float b_width =   MAX(CV_BLOB_WX(b), m_min_window_size.width / scale)
-                            + (m_param_roi_scale - 1.0F) * (m_min_window_size.width / scale)
-                            + 2.0F * m_max_border / scale;
-            float b_height = CV_BLOB_WY(b) * m_param_roi_scale + 2.0F * m_max_border / scale;
-
-            CvRect roi = cvRectIntersection( cvRect( cvFloor(CV_BLOB_X(b) - 0.5F*b_width),
-                                                     cvFloor(CV_BLOB_Y(b) - 0.5F*b_height),
-                                                     cvCeil(b_width), cvCeil(b_height) ),
-                                             cvRect( 0, 0, pImg->width, pImg->height ) );
-            if( roi.width <= 0 || roi.height <= 0 )
-                continue;
-
-            if( m_roi_seq ) cvSeqPush( m_roi_seq, &roi );
-
-            roi_mat = cvGetSubRect( pImg, &roi_stub, roi );
-            scaled_roi_mat = cvCreateMat( cvCeil(scale*roi.height), cvCeil(scale*roi.width), CV_8UC3 );
-            cvResize( roi_mat, scaled_roi_mat );
-
-            m_detected_blob_seq.Clear();
-            m_split_detector->Detect( scaled_roi_mat, &m_detected_blob_seq );
-            cvReleaseMat( &scaled_roi_mat );
-
-            for( int k = 0; k < m_detected_blob_seq.GetBlobNum(); ++k )
-            {
-                CvDetectedBlob* b = (CvDetectedBlob*) m_detected_blob_seq.GetBlob(k);
-
-                /* scale and shift each detected blob back to the original image coordinates */
-                CV_BLOB_X(b) = CV_BLOB_X(b) / scale + roi.x;
-                CV_BLOB_Y(b) = CV_BLOB_Y(b) / scale + roi.y;
-                CV_BLOB_WX(b) /= scale;
-                CV_BLOB_WY(b) /= scale;
-
-                CvDetectedBlob d_b = cvDetectedBlob( CV_BLOB_X(b), CV_BLOB_Y(b), CV_BLOB_WX(b), CV_BLOB_WY(b), 1,
-                        b->response );
-                m_debug_blob_seq.AddBlob(&d_b);
-            }
-
-            if( m_detected_blob_seq.GetBlobNum() > 1 )
-            {
-                /*
-                 * Split blob.
-                 * The original blob is replaced by the first detected blob,
-                 * remaining detected blobs are added to the end of the sequence:
-                 */
-                CvBlob* first_b = m_detected_blob_seq.GetBlob(0);
-                CV_BLOB_X(b)  = CV_BLOB_X(first_b);  CV_BLOB_Y(b)  = CV_BLOB_Y(first_b);
-                CV_BLOB_WX(b) = CV_BLOB_WX(first_b); CV_BLOB_WY(b) = CV_BLOB_WY(first_b);
-
-                for( int j = 1; j < m_detected_blob_seq.GetBlobNum(); ++j )
-                {
-                    CvBlob* detected_b = m_detected_blob_seq.GetBlob(j);
-                    pNewBlobList->AddBlob(detected_b);
-                }
-            }
-        }   /* For each new blob. */
-
-        for( i = 0; i < pNewBlobList->GetBlobNum(); ++i )
-        {
-            CvBlob* b = pNewBlobList->GetBlob(i);
-            CvDetectedBlob d_b = cvDetectedBlob( CV_BLOB_X(b), CV_BLOB_Y(b), CV_BLOB_WX(b), CV_BLOB_WY(b), 2 );
-            m_debug_blob_seq.AddBlob(&d_b);
-        }
-    }   // if( m_split_detector )
-#endif
-
-    return result;
-
-}   /* cvDetectNewBlob */
diff --git a/modules/legacy/src/enteringblobdetectionreal.cpp b/modules/legacy/src/enteringblobdetectionreal.cpp
deleted file mode 100644 (file)
index 01a1c76..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
-This file contain implementation of virtual interface of CvBlobDetector
-this implementation based on simple algorithm
-new blob is detected when several successive frames contains connected componets
-which have uniform motion with not high speed.
-Also separation from border and already tracked blobs are considered.
-*/
-
-#include "precomp.hpp"
-
-/* blob detector  based on real data (groundtruth data)*/
-class CvBlobDetectorReal:public CvBlobDetector
-{
-protected:
-    CvTestSeq*      m_pTestSeq;
-    CvBlobSeq       m_DetectedBlobs;
-    CvMemStorage*   m_pMem;
-
-public:
-    CvBlobDetectorReal(CvTestSeq* pTestSeq)
-    {
-        m_pTestSeq = pTestSeq;
-        m_pMem = cvCreateMemStorage(0);
-        SetModuleName("Real");
-    }
-
-    /* Destructor of BlobDetector: */
-   ~CvBlobDetectorReal()
-    {
-        if(m_pMem) cvReleaseMemStorage(&m_pMem);
-    }   /* cvReleaseBlobDetector */
-
-    /* cvDetectNewBlobs:
-     * Return 1 and fill blob pNewBlob with
-     * blob parameters if new blob is detected:
-     */
-    int DetectNewBlob(IplImage* /*pImg*/, IplImage* /*pFGMask*/, CvBlobSeq* pNewBlobList, CvBlobSeq* /*pOldBlobList*/)
-    {
-        int         i;
-        int         TestObjNum;
-        IplImage*   pMask = NULL;
-        IplImage*   pMaskCopy = NULL;
-        CvSeq*      cnts = NULL;
-
-        if(m_pTestSeq==NULL) return 0;
-        TestObjNum = cvTestSeqGetObjectNum(m_pTestSeq);
-        pMask = cvTestSeqGetFGMask(m_pTestSeq);
-        if(pMask == NULL) return 0;
-        pMaskCopy = cvCloneImage(pMask);
-        assert(pMaskCopy);
-
-        cvClearMemStorage(m_pMem);
-        cvFindContours( pMaskCopy, m_pMem, &cnts, sizeof(CvContour), CV_RETR_EXTERNAL);
-        cvReleaseImage(&pMaskCopy);
-
-        for(i=0; i<TestObjNum; ++i)
-        {   /* Check each object: */
-            CvPoint2D32f    RealPos;
-            CvPoint2D32f    RealSize;
-            int             RealPosFlag = cvTestSeqGetObjectPos(m_pTestSeq,i,&RealPos);
-            int             RealSizeFlag = cvTestSeqGetObjectSize(m_pTestSeq,i,&RealSize);
-
-            if(!RealPosFlag) continue;
-            if(m_DetectedBlobs.GetBlobByID(i)) continue;
-
-            if(RealSizeFlag)
-            {   /* Real size is known: */
-                float W2 = RealSize.x * 0.5f;
-                float H2 = RealSize.y * 0.5f;
-                if( RealPos.x > W2 && RealPos.x < (pMask->width-W2) &&
-                    RealPos.y > H2 && RealPos.y < (pMask->height-H2) )
-                {   /* Yes!!  We found new blob, let's add it to list: */
-                    CvBlob  NewBlob;
-                    NewBlob.x = RealPos.x;
-                    NewBlob.y = RealPos.y;
-                    NewBlob.w = RealSize.x;
-                    NewBlob.h = RealSize.y;
-                    NewBlob.ID = i;
-                    m_DetectedBlobs.AddBlob(&NewBlob);
-                    pNewBlobList->AddBlob(&NewBlob);
-                }
-            }   /* Real size is known. */
-            else
-            {
-                CvSeq*  cnt;
-                if(m_DetectedBlobs.GetBlobByID(i)) continue;
-
-                for(cnt=cnts; cnt; cnt=cnt->h_next)
-                {
-                    //CvBlob* pNewBlob = NULL;
-                    CvBlob  NewBlob;
-                    CvRect  r = cvBoundingRect( cnt );
-                    float   x = RealPos.x - r.x;
-                    float   y = RealPos.y - r.y;
-
-                    if(x<0 || x > r.width || y < 0 || y > r.height ) continue;
-
-                    if( r.x <= 1 ||
-                        r.y <= 1 ||
-                        r.x + r.width >= pMask->width - 2 ||
-                        r.y + r.height >= pMask->height - 2 ) continue;
-
-                    /* Yes!!  We found new blob, let's add it to list: */
-                    NewBlob.x = RealPos.x;
-                    NewBlob.y = RealPos.y;
-                    NewBlob.w = (float)r.width;
-                    NewBlob.h = (float)r.height;
-                    NewBlob.ID = i;
-                    m_DetectedBlobs.AddBlob(&NewBlob);
-                    pNewBlobList->AddBlob(&NewBlob);
-                }
-            }   /* Check new blob entrance. */
-        }   /* Check next object. */
-
-        return pNewBlobList->GetBlobNum();
-
-    }   /* cvDetectNewBlob */
-
-    void Release(){delete this;}
-};
-
-/* Blob detector constructor: */
-//CvBlobDetector* cvCreateBlobDetectorReal(CvTestSeq* pTestSeq){return new CvBlobDetectorReal(pTestSeq);}
diff --git a/modules/legacy/src/epilines.cpp b/modules/legacy/src/epilines.cpp
deleted file mode 100644 (file)
index b765240..0000000
+++ /dev/null
@@ -1,3700 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-
-#include "precomp.hpp"
-#include <float.h>
-#include <limits.h>
-
-/* Valery Mosyagin */
-
-#undef quad
-
-#define EPS64D 1e-9
-
-int cvComputeEssentialMatrix(  CvMatr32f rotMatr,
-                                    CvMatr32f transVect,
-                                    CvMatr32f essMatr);
-
-int cvConvertEssential2Fundamental( CvMatr32f essMatr,
-                                         CvMatr32f fundMatr,
-                                         CvMatr32f cameraMatr1,
-                                         CvMatr32f cameraMatr2);
-
-int cvComputeEpipolesFromFundMatrix(CvMatr32f fundMatr,
-                                         CvPoint3D32f* epipole1,
-                                         CvPoint3D32f* epipole2);
-
-void icvTestPoint( CvPoint2D64d testPoint,
-                CvVect64d line1,CvVect64d line2,
-                CvPoint2D64d basePoint,
-                int* result);
-
-
-
-int icvGetSymPoint3D(  CvPoint3D64d pointCorner,
-                            CvPoint3D64d point1,
-                            CvPoint3D64d point2,
-                            CvPoint3D64d *pointSym2)
-{
-    double len1,len2;
-    double alpha;
-    icvGetPieceLength3D(pointCorner,point1,&len1);
-    if( len1 < EPS64D )
-    {
-        return CV_BADARG_ERR;
-    }
-    icvGetPieceLength3D(pointCorner,point2,&len2);
-    alpha = len2 / len1;
-
-    pointSym2->x = pointCorner.x + alpha*(point1.x - pointCorner.x);
-    pointSym2->y = pointCorner.y + alpha*(point1.y - pointCorner.y);
-    pointSym2->z = pointCorner.z + alpha*(point1.z - pointCorner.z);
-    return CV_NO_ERR;
-}
-
-/*  author Valery Mosyagin */
-
-/* Compute 3D point for scanline and alpha betta */
-int icvCompute3DPoint( double alpha,double betta,
-                            CvStereoLineCoeff* coeffs,
-                            CvPoint3D64d* point)
-{
-
-    double partX;
-    double partY;
-    double partZ;
-    double partAll;
-    double invPartAll;
-
-    double alphabetta = alpha*betta;
-
-    partAll = alpha - betta;
-    if( fabs(partAll) > 0.00001  ) /* alpha must be > betta */
-    {
-
-        partX   = coeffs->Xcoef        + coeffs->XcoefA *alpha +
-                  coeffs->XcoefB*betta + coeffs->XcoefAB*alphabetta;
-
-        partY   = coeffs->Ycoef        + coeffs->YcoefA *alpha +
-                  coeffs->YcoefB*betta + coeffs->YcoefAB*alphabetta;
-
-        partZ   = coeffs->Zcoef        + coeffs->ZcoefA *alpha +
-                  coeffs->ZcoefB*betta + coeffs->ZcoefAB*alphabetta;
-
-        invPartAll = 1.0 / partAll;
-
-        point->x = partX * invPartAll;
-        point->y = partY * invPartAll;
-        point->z = partZ * invPartAll;
-        return CV_NO_ERR;
-    }
-    else
-    {
-        return CV_BADFACTOR_ERR;
-    }
-}
-
-/*--------------------------------------------------------------------------------------*/
-
-/* Compute rotate matrix and trans vector for change system */
-int icvCreateConvertMatrVect( CvMatr64d     rotMatr1,
-                                CvMatr64d     transVect1,
-                                CvMatr64d     rotMatr2,
-                                CvMatr64d     transVect2,
-                                CvMatr64d     convRotMatr,
-                                CvMatr64d     convTransVect)
-{
-    double invRotMatr2[9];
-    double tmpVect[3];
-
-
-    icvInvertMatrix_64d(rotMatr2,3,invRotMatr2);
-    /* Test for error */
-
-    icvMulMatrix_64d(   rotMatr1,
-                        3,3,
-                        invRotMatr2,
-                        3,3,
-                        convRotMatr);
-
-    icvMulMatrix_64d(   convRotMatr,
-                        3,3,
-                        transVect2,
-                        1,3,
-                        tmpVect);
-
-    icvSubVector_64d(transVect1,tmpVect,convTransVect,3);
-
-
-    return CV_NO_ERR;
-}
-
-/*--------------------------------------------------------------------------------------*/
-
-/* Compute point coordinates in other system */
-int icvConvertPointSystem(CvPoint3D64d  M2,
-                            CvPoint3D64d* M1,
-                            CvMatr64d     rotMatr,
-                            CvMatr64d     transVect
-                            )
-{
-    double tmpVect[3];
-
-    icvMulMatrix_64d(   rotMatr,
-                        3,3,
-                        (double*)&M2,
-                        1,3,
-                        tmpVect);
-
-    icvAddVector_64d(tmpVect,transVect,(double*)M1,3);
-
-    return CV_NO_ERR;
-}
-/*--------------------------------------------------------------------------------------*/
-static int icvComputeCoeffForStereoV3( double quad1[4][2],
-                                double quad2[4][2],
-                                int    numScanlines,
-                                CvMatr64d    camMatr1,
-                                CvMatr64d    rotMatr1,
-                                CvMatr64d    transVect1,
-                                CvMatr64d    camMatr2,
-                                CvMatr64d    rotMatr2,
-                                CvMatr64d    transVect2,
-                                CvStereoLineCoeff*    startCoeffs,
-                                int* needSwapCamera)
-{
-    /* For each pair */
-    /* In this function we must define position of cameras */
-
-    CvPoint2D64d point1;
-    CvPoint2D64d point2;
-    CvPoint2D64d point3;
-    CvPoint2D64d point4;
-
-    int currLine;
-    *needSwapCamera = 0;
-    for( currLine = 0; currLine < numScanlines; currLine++ )
-    {
-        /* Compute points */
-        double alpha = ((double)currLine)/((double)(numScanlines)); /* maybe - 1 */
-
-        point1.x = (1.0 - alpha) * quad1[0][0] + alpha * quad1[3][0];
-        point1.y = (1.0 - alpha) * quad1[0][1] + alpha * quad1[3][1];
-
-        point2.x = (1.0 - alpha) * quad1[1][0] + alpha * quad1[2][0];
-        point2.y = (1.0 - alpha) * quad1[1][1] + alpha * quad1[2][1];
-
-        point3.x = (1.0 - alpha) * quad2[0][0] + alpha * quad2[3][0];
-        point3.y = (1.0 - alpha) * quad2[0][1] + alpha * quad2[3][1];
-
-        point4.x = (1.0 - alpha) * quad2[1][0] + alpha * quad2[2][0];
-        point4.y = (1.0 - alpha) * quad2[1][1] + alpha * quad2[2][1];
-
-        /* We can compute coeffs for this line */
-        icvComCoeffForLine(    point1,
-                            point2,
-                            point3,
-                            point4,
-                            camMatr1,
-                            rotMatr1,
-                            transVect1,
-                            camMatr2,
-                            rotMatr2,
-                            transVect2,
-                            &startCoeffs[currLine],
-                            needSwapCamera);
-    }
-    return CV_NO_ERR;
-}
-/*--------------------------------------------------------------------------------------*/
-static int icvComputeCoeffForStereoNew(   double quad1[4][2],
-                                        double quad2[4][2],
-                                        int    numScanlines,
-                                        CvMatr32f    camMatr1,
-                                        CvMatr32f    rotMatr1,
-                                        CvMatr32f    transVect1,
-                                        CvMatr32f    camMatr2,
-                                        CvStereoLineCoeff*    startCoeffs,
-                                        int* needSwapCamera)
-{
-    /* Convert data */
-
-    double camMatr1_64d[9];
-    double camMatr2_64d[9];
-
-    double rotMatr1_64d[9];
-    double transVect1_64d[3];
-
-    double rotMatr2_64d[9];
-    double transVect2_64d[3];
-
-    icvCvt_32f_64d(camMatr1,camMatr1_64d,9);
-    icvCvt_32f_64d(camMatr2,camMatr2_64d,9);
-
-    icvCvt_32f_64d(rotMatr1,rotMatr1_64d,9);
-    icvCvt_32f_64d(transVect1,transVect1_64d,3);
-
-    rotMatr2_64d[0] = 1;
-    rotMatr2_64d[1] = 0;
-    rotMatr2_64d[2] = 0;
-    rotMatr2_64d[3] = 0;
-    rotMatr2_64d[4] = 1;
-    rotMatr2_64d[5] = 0;
-    rotMatr2_64d[6] = 0;
-    rotMatr2_64d[7] = 0;
-    rotMatr2_64d[8] = 1;
-
-    transVect2_64d[0] = 0;
-    transVect2_64d[1] = 0;
-    transVect2_64d[2] = 0;
-
-    int status = icvComputeCoeffForStereoV3( quad1,
-                                                quad2,
-                                                numScanlines,
-                                                camMatr1_64d,
-                                                rotMatr1_64d,
-                                                transVect1_64d,
-                                                camMatr2_64d,
-                                                rotMatr2_64d,
-                                                transVect2_64d,
-                                                startCoeffs,
-                                                needSwapCamera);
-
-
-    return status;
-
-}
-/*--------------------------------------------------------------------------------------*/
-int icvComputeCoeffForStereo(  CvStereoCamera* stereoCamera)
-{
-    double quad1[4][2];
-    double quad2[4][2];
-
-    int i;
-    for( i = 0; i < 4; i++ )
-    {
-        quad1[i][0] = stereoCamera->quad[0][i].x;
-        quad1[i][1] = stereoCamera->quad[0][i].y;
-
-        quad2[i][0] = stereoCamera->quad[1][i].x;
-        quad2[i][1] = stereoCamera->quad[1][i].y;
-    }
-
-    icvComputeCoeffForStereoNew(        quad1,
-                                        quad2,
-                                        stereoCamera->warpSize.height,
-                                        stereoCamera->camera[0]->matrix,
-                                        stereoCamera->rotMatrix,
-                                        stereoCamera->transVector,
-                                        stereoCamera->camera[1]->matrix,
-                                        stereoCamera->lineCoeffs,
-                                        &(stereoCamera->needSwapCameras));
-    return CV_OK;
-}
-
-
-/*--------------------------------------------------------------------------------------*/
-int icvComCoeffForLine(   CvPoint2D64d point1,
-                            CvPoint2D64d point2,
-                            CvPoint2D64d point3,
-                            CvPoint2D64d point4,
-                            CvMatr64d    camMatr1,
-                            CvMatr64d    rotMatr1,
-                            CvMatr64d    transVect1,
-                            CvMatr64d    camMatr2,
-                            CvMatr64d    rotMatr2,
-                            CvMatr64d    transVect2,
-                            CvStereoLineCoeff* coeffs,
-                            int* needSwapCamera)
-{
-    /* Get direction for all points */
-    /* Direction for camera 1 */
-
-    CvPoint3D64f direct1;
-    CvPoint3D64f direct2;
-    CvPoint3D64f camPoint1;
-
-    CvPoint3D64f directS3;
-    CvPoint3D64f directS4;
-    CvPoint3D64f direct3;
-    CvPoint3D64f direct4;
-    CvPoint3D64f camPoint2;
-
-    icvGetDirectionForPoint(   point1,
-                            camMatr1,
-                            &direct1);
-
-    icvGetDirectionForPoint(   point2,
-                            camMatr1,
-                            &direct2);
-
-    /* Direction for camera 2 */
-
-    icvGetDirectionForPoint(   point3,
-                            camMatr2,
-                            &directS3);
-
-    icvGetDirectionForPoint(   point4,
-                            camMatr2,
-                            &directS4);
-
-    /* Create convertion for camera 2: two direction and camera point */
-
-    double convRotMatr[9];
-    double convTransVect[3];
-
-    icvCreateConvertMatrVect(  rotMatr1,
-                            transVect1,
-                            rotMatr2,
-                            transVect2,
-                            convRotMatr,
-                            convTransVect);
-
-    CvPoint3D64f zeroVect;
-    zeroVect.x = zeroVect.y = zeroVect.z = 0.0;
-    camPoint1.x = camPoint1.y = camPoint1.z = 0.0;
-
-    icvConvertPointSystem(directS3,&direct3,convRotMatr,convTransVect);
-    icvConvertPointSystem(directS4,&direct4,convRotMatr,convTransVect);
-    icvConvertPointSystem(zeroVect,&camPoint2,convRotMatr,convTransVect);
-
-    CvPoint3D64f pointB;
-
-    int postype = 0;
-
-    /* Changed order */
-    /* Compute point B: xB,yB,zB */
-    icvGetCrossLines(camPoint1,direct2,
-                  camPoint2,direct3,
-                  &pointB);
-
-    if( pointB.z < 0 )/* If negative use other lines for cross */
-    {
-        postype = 1;
-        icvGetCrossLines(camPoint1,direct1,
-                      camPoint2,direct4,
-                      &pointB);
-    }
-
-    CvPoint3D64d pointNewA;
-    CvPoint3D64d pointNewC;
-
-    pointNewA.x = pointNewA.y = pointNewA.z = 0;
-    pointNewC.x = pointNewC.y = pointNewC.z = 0;
-
-    if( postype == 0 )
-    {
-        icvGetSymPoint3D(   camPoint1,
-                            direct1,
-                            pointB,
-                            &pointNewA);
-
-        icvGetSymPoint3D(   camPoint2,
-                            direct4,
-                            pointB,
-                            &pointNewC);
-    }
-    else
-    {/* In this case we must change cameras */
-        *needSwapCamera = 1;
-        icvGetSymPoint3D(   camPoint2,
-                            direct3,
-                            pointB,
-                            &pointNewA);
-
-        icvGetSymPoint3D(   camPoint1,
-                            direct2,
-                            pointB,
-                            &pointNewC);
-    }
-
-
-    double gamma;
-
-    double xA,yA,zA;
-    double xB,yB,zB;
-    double xC,yC,zC;
-
-    xA = pointNewA.x;
-    yA = pointNewA.y;
-    zA = pointNewA.z;
-
-    xB = pointB.x;
-    yB = pointB.y;
-    zB = pointB.z;
-
-    xC = pointNewC.x;
-    yC = pointNewC.y;
-    zC = pointNewC.z;
-
-    double len1,len2;
-    len1 = sqrt( (xA-xB)*(xA-xB) + (yA-yB)*(yA-yB) + (zA-zB)*(zA-zB) );
-    len2 = sqrt( (xB-xC)*(xB-xC) + (yB-yC)*(yB-yC) + (zB-zC)*(zB-zC) );
-    gamma = len2 / len1;
-
-    icvComputeStereoLineCoeffs( pointNewA,
-                                pointB,
-                                camPoint1,
-                                gamma,
-                                coeffs);
-
-    return CV_NO_ERR;
-}
-
-
-/*--------------------------------------------------------------------------------------*/
-
-int icvGetDirectionForPoint(  CvPoint2D64d point,
-                                CvMatr64d camMatr,
-                                CvPoint3D64d* direct)
-{
-    /*  */
-    double invMatr[9];
-
-    /* Invert matrix */
-
-    icvInvertMatrix_64d(camMatr,3,invMatr);
-    /* TEST FOR ERRORS */
-
-    double vect[3];
-    vect[0] = point.x;
-    vect[1] = point.y;
-    vect[2] = 1;
-
-    /* Mul matr */
-    icvMulMatrix_64d(   invMatr,
-                        3,3,
-                        vect,
-                        1,3,
-                        (double*)direct);
-
-    return CV_NO_ERR;
-}
-
-/*--------------------------------------------------------------------------------------*/
-
-int icvGetCrossLines(CvPoint3D64d point11,CvPoint3D64d point12,
-                       CvPoint3D64d point21,CvPoint3D64d point22,
-                       CvPoint3D64d* midPoint)
-{
-    double xM,yM,zM;
-    double xN,yN,zN;
-
-    double xA,yA,zA;
-    double xB,yB,zB;
-
-    double xC,yC,zC;
-    double xD,yD,zD;
-
-    xA = point11.x;
-    yA = point11.y;
-    zA = point11.z;
-
-    xB = point12.x;
-    yB = point12.y;
-    zB = point12.z;
-
-    xC = point21.x;
-    yC = point21.y;
-    zC = point21.z;
-
-    xD = point22.x;
-    yD = point22.y;
-    zD = point22.z;
-
-    double a11,a12,a21,a22;
-    double b1,b2;
-
-    a11 =  (xB-xA)*(xB-xA)+(yB-yA)*(yB-yA)+(zB-zA)*(zB-zA);
-    a12 = -(xD-xC)*(xB-xA)-(yD-yC)*(yB-yA)-(zD-zC)*(zB-zA);
-    a21 =  (xB-xA)*(xD-xC)+(yB-yA)*(yD-yC)+(zB-zA)*(zD-zC);
-    a22 = -(xD-xC)*(xD-xC)-(yD-yC)*(yD-yC)-(zD-zC)*(zD-zC);
-    b1  = -( (xA-xC)*(xB-xA)+(yA-yC)*(yB-yA)+(zA-zC)*(zB-zA) );
-    b2  = -( (xA-xC)*(xD-xC)+(yA-yC)*(yD-yC)+(zA-zC)*(zD-zC) );
-
-    double delta;
-    double deltaA,deltaB;
-    double alpha,betta;
-
-    delta  = a11*a22-a12*a21;
-
-    if( fabs(delta) < EPS64D )
-    {
-        /*return ERROR;*/
-    }
-
-    deltaA = b1*a22-b2*a12;
-    deltaB = a11*b2-b1*a21;
-
-    alpha = deltaA / delta;
-    betta = deltaB / delta;
-
-    xM = xA+alpha*(xB-xA);
-    yM = yA+alpha*(yB-yA);
-    zM = zA+alpha*(zB-zA);
-
-    xN = xC+betta*(xD-xC);
-    yN = yC+betta*(yD-yC);
-    zN = zC+betta*(zD-zC);
-
-    /* Compute middle point */
-    midPoint->x = (xM + xN) * 0.5;
-    midPoint->y = (yM + yN) * 0.5;
-    midPoint->z = (zM + zN) * 0.5;
-
-    return CV_NO_ERR;
-}
-
-/*--------------------------------------------------------------------------------------*/
-
-int icvComputeStereoLineCoeffs(   CvPoint3D64d pointA,
-                                    CvPoint3D64d pointB,
-                                    CvPoint3D64d pointCam1,
-                                    double gamma,
-                                    CvStereoLineCoeff*    coeffs)
-{
-    double x1,y1,z1;
-
-    x1 = pointCam1.x;
-    y1 = pointCam1.y;
-    z1 = pointCam1.z;
-
-    double xA,yA,zA;
-    double xB,yB,zB;
-
-    xA = pointA.x;
-    yA = pointA.y;
-    zA = pointA.z;
-
-    xB = pointB.x;
-    yB = pointB.y;
-    zB = pointB.z;
-
-    if( gamma > 0 )
-    {
-        coeffs->Xcoef   = -x1 + xA;
-        coeffs->XcoefA  =  xB + x1 - xA;
-        coeffs->XcoefB  = -xA - gamma * x1 + gamma * xA;
-        coeffs->XcoefAB = -xB + xA + gamma * xB - gamma * xA;
-
-        coeffs->Ycoef   = -y1 + yA;
-        coeffs->YcoefA  =  yB + y1 - yA;
-        coeffs->YcoefB  = -yA - gamma * y1 + gamma * yA;
-        coeffs->YcoefAB = -yB + yA + gamma * yB - gamma * yA;
-
-        coeffs->Zcoef   = -z1 + zA;
-        coeffs->ZcoefA  =  zB + z1 - zA;
-        coeffs->ZcoefB  = -zA - gamma * z1 + gamma * zA;
-        coeffs->ZcoefAB = -zB + zA + gamma * zB - gamma * zA;
-    }
-    else
-    {
-        gamma = - gamma;
-        coeffs->Xcoef   = -( -x1 + xA);
-        coeffs->XcoefB  = -(  xB + x1 - xA);
-        coeffs->XcoefA  = -( -xA - gamma * x1 + gamma * xA);
-        coeffs->XcoefAB = -( -xB + xA + gamma * xB - gamma * xA);
-
-        coeffs->Ycoef   = -( -y1 + yA);
-        coeffs->YcoefB  = -(  yB + y1 - yA);
-        coeffs->YcoefA  = -( -yA - gamma * y1 + gamma * yA);
-        coeffs->YcoefAB = -( -yB + yA + gamma * yB - gamma * yA);
-
-        coeffs->Zcoef   = -( -z1 + zA);
-        coeffs->ZcoefB  = -(  zB + z1 - zA);
-        coeffs->ZcoefA  = -( -zA - gamma * z1 + gamma * zA);
-        coeffs->ZcoefAB = -( -zB + zA + gamma * zB - gamma * zA);
-    }
-
-
-
-    return CV_NO_ERR;
-}
-/*--------------------------------------------------------------------------------------*/
-
-
-/*---------------------------------------------------------------------------------------*/
-
-/* This function get minimum angle started at point which contains rect */
-int icvGetAngleLine( CvPoint2D64d startPoint, CvSize imageSize,CvPoint2D64d *point1,CvPoint2D64d *point2)
-{
-    /* Get crosslines with image corners */
-
-    /* Find four lines */
-
-    CvPoint2D64d pa,pb,pc,pd;
-
-    pa.x = 0;
-    pa.y = 0;
-
-    pb.x = imageSize.width-1;
-    pb.y = 0;
-
-    pd.x = imageSize.width-1;
-    pd.y = imageSize.height-1;
-
-    pc.x = 0;
-    pc.y = imageSize.height-1;
-
-    /* We can compute points for angle */
-    /* Test for place section */
-
-    if( startPoint.x < 0 )
-    {/* 1,4,7 */
-        if( startPoint.y < 0)
-        {/* 1 */
-            *point1 = pb;
-            *point2 = pc;
-        }
-        else if( startPoint.y > imageSize.height-1 )
-        {/* 7 */
-            *point1 = pa;
-            *point2 = pd;
-        }
-        else
-        {/* 4 */
-            *point1 = pa;
-            *point2 = pc;
-        }
-    }
-    else if ( startPoint.x > imageSize.width-1 )
-    {/* 3,6,9 */
-        if( startPoint.y < 0 )
-        {/* 3 */
-            *point1 = pa;
-            *point2 = pd;
-        }
-        else if ( startPoint.y > imageSize.height-1 )
-        {/* 9 */
-            *point1 = pb;
-            *point2 = pc;
-        }
-        else
-        {/* 6 */
-            *point1 = pb;
-            *point2 = pd;
-        }
-    }
-    else
-    {/* 2,5,8 */
-        if( startPoint.y < 0 )
-        {/* 2 */
-            if( startPoint.x < imageSize.width/2 )
-            {
-                *point1 = pb;
-                *point2 = pa;
-            }
-            else
-            {
-                *point1 = pa;
-                *point2 = pb;
-            }
-        }
-        else if( startPoint.y > imageSize.height-1 )
-        {/* 8 */
-            if( startPoint.x < imageSize.width/2 )
-            {
-                *point1 = pc;
-                *point2 = pd;
-            }
-            else
-            {
-                *point1 = pd;
-                *point2 = pc;
-            }
-        }
-        else
-        {/* 5 - point in the image */
-            return 2;
-        }
-    }
-    return 0;
-}/* GetAngleLine */
-
-/*---------------------------------------------------------------------------------------*/
-
-void icvGetCoefForPiece(   CvPoint2D64d p_start,CvPoint2D64d p_end,
-                        double *a,double *b,double *c,
-                        int* result)
-{
-    double det;
-    double detA,detB,detC;
-
-    det = p_start.x*p_end.y+p_end.x+p_start.y-p_end.y-p_start.y*p_end.x-p_start.x;
-    if( fabs(det) < EPS64D)/* Error */
-    {
-        *result = 0;
-        return;
-    }
-
-    detA = p_start.y - p_end.y;
-    detB = p_end.x - p_start.x;
-    detC = p_start.x*p_end.y - p_end.x*p_start.y;
-
-    double invDet = 1.0 / det;
-    *a = detA * invDet;
-    *b = detB * invDet;
-    *c = detC * invDet;
-
-    *result = 1;
-    return;
-}
-
-/*---------------------------------------------------------------------------------------*/
-
-/* Get common area of rectifying */
-static void icvGetCommonArea( CvSize imageSize,
-                    CvPoint3D64d epipole1,CvPoint3D64d epipole2,
-                    CvMatr64d fundMatr,
-                    CvVect64d coeff11,CvVect64d coeff12,
-                    CvVect64d coeff21,CvVect64d coeff22,
-                    int* result)
-{
-    int res = 0;
-    CvPoint2D64d point11;
-    CvPoint2D64d point12;
-    CvPoint2D64d point21;
-    CvPoint2D64d point22;
-
-    double corr11[3];
-    double corr12[3];
-    double corr21[3];
-    double corr22[3];
-
-    double pointW11[3];
-    double pointW12[3];
-    double pointW21[3];
-    double pointW22[3];
-
-    double transFundMatr[3*3];
-    /* Compute transpose of fundamental matrix */
-    icvTransposeMatrix_64d( fundMatr, 3, 3, transFundMatr );
-
-    CvPoint2D64d epipole1_2d;
-    CvPoint2D64d epipole2_2d;
-
-    if( fabs(epipole1.z) < 1e-8 )
-    {/* epipole1 in infinity */
-        *result = 0;
-        return;
-    }
-    epipole1_2d.x = epipole1.x / epipole1.z;
-    epipole1_2d.y = epipole1.y / epipole1.z;
-
-    if( fabs(epipole2.z) < 1e-8 )
-    {/* epipole2 in infinity */
-        *result = 0;
-        return;
-    }
-    epipole2_2d.x = epipole2.x / epipole2.z;
-    epipole2_2d.y = epipole2.y / epipole2.z;
-
-    int stat = icvGetAngleLine( epipole1_2d, imageSize,&point11,&point12);
-    if( stat == 2 )
-    {
-        /* No angle */
-        *result = 0;
-        return;
-    }
-
-    stat = icvGetAngleLine( epipole2_2d, imageSize,&point21,&point22);
-    if( stat == 2 )
-    {
-        /* No angle */
-        *result = 0;
-        return;
-    }
-
-    /* ============= Computation for line 1 ================ */
-    /* Find correspondence line for angle points11 */
-    /* corr21 = Fund'*p1 */
-
-    pointW11[0] = point11.x;
-    pointW11[1] = point11.y;
-    pointW11[2] = 1.0;
-
-    icvTransformVector_64d( transFundMatr, /* !!! Modified from not transposed */
-                            pointW11,
-                            corr21,
-                            3,3);
-
-    /* Find crossing of line with image 2 */
-    CvPoint2D64d start;
-    CvPoint2D64d end;
-    icvGetCrossRectDirect( imageSize,
-                        corr21[0],corr21[1],corr21[2],
-                        &start,&end,
-                        &res);
-
-    if( res == 0 )
-    {/* We have not cross */
-        /* We must define new angle */
-
-        pointW21[0] = point21.x;
-        pointW21[1] = point21.y;
-        pointW21[2] = 1.0;
-
-        /* Find correspondence line for this angle points */
-        /* We know point and try to get corr line */
-        /* For point21 */
-        /* corr11 = Fund * p21 */
-
-        icvTransformVector_64d( fundMatr, /* !!! Modified */
-                                pointW21,
-                                corr11,
-                                3,3);
-
-        /* We have cross. And it's result cross for up line. Set result coefs */
-
-        /* Set coefs for line 1 image 1 */
-        coeff11[0] = corr11[0];
-        coeff11[1] = corr11[1];
-        coeff11[2] = corr11[2];
-
-        /* Set coefs for line 1 image 2 */
-        icvGetCoefForPiece(    epipole2_2d,point21,
-                            &coeff21[0],&coeff21[1],&coeff21[2],
-                            &res);
-        if( res == 0 )
-        {
-            *result = 0;
-            return;/* Error */
-        }
-    }
-    else
-    {/* Line 1 cross image 2 */
-        /* Set coefs for line 1 image 1 */
-        icvGetCoefForPiece(    epipole1_2d,point11,
-                            &coeff11[0],&coeff11[1],&coeff11[2],
-                            &res);
-        if( res == 0 )
-        {
-            *result = 0;
-            return;/* Error */
-        }
-
-        /* Set coefs for line 1 image 2 */
-        coeff21[0] = corr21[0];
-        coeff21[1] = corr21[1];
-        coeff21[2] = corr21[2];
-
-    }
-
-    /* ============= Computation for line 2 ================ */
-    /* Find correspondence line for angle points11 */
-    /* corr22 = Fund*p2 */
-
-    pointW12[0] = point12.x;
-    pointW12[1] = point12.y;
-    pointW12[2] = 1.0;
-
-    icvTransformVector_64d( transFundMatr,
-                            pointW12,
-                            corr22,
-                            3,3);
-
-    /* Find crossing of line with image 2 */
-    icvGetCrossRectDirect( imageSize,
-                        corr22[0],corr22[1],corr22[2],
-                        &start,&end,
-                        &res);
-
-    if( res == 0 )
-    {/* We have not cross */
-        /* We must define new angle */
-
-        pointW22[0] = point22.x;
-        pointW22[1] = point22.y;
-        pointW22[2] = 1.0;
-
-        /* Find correspondence line for this angle points */
-        /* We know point and try to get corr line */
-        /* For point21 */
-        /* corr2 = Fund' * p1 */
-
-        icvTransformVector_64d( fundMatr,
-                                pointW22,
-                                corr12,
-                                3,3);
-
-
-        /* We have cross. And it's result cross for down line. Set result coefs */
-
-        /* Set coefs for line 2 image 1 */
-        coeff12[0] = corr12[0];
-        coeff12[1] = corr12[1];
-        coeff12[2] = corr12[2];
-
-        /* Set coefs for line 1 image 2 */
-        icvGetCoefForPiece(    epipole2_2d,point22,
-                            &coeff22[0],&coeff22[1],&coeff22[2],
-                            &res);
-        if( res == 0 )
-        {
-            *result = 0;
-            return;/* Error */
-        }
-    }
-    else
-    {/* Line 2 cross image 2 */
-        /* Set coefs for line 2 image 1 */
-        icvGetCoefForPiece(    epipole1_2d,point12,
-                            &coeff12[0],&coeff12[1],&coeff12[2],
-                            &res);
-        if( res == 0 )
-        {
-            *result = 0;
-            return;/* Error */
-        }
-
-        /* Set coefs for line 1 image 2 */
-        coeff22[0] = corr22[0];
-        coeff22[1] = corr22[1];
-        coeff22[2] = corr22[2];
-
-    }
-
-    /* Now we know common area */
-
-    return;
-
-}/* GetCommonArea */
-
-/*---------------------------------------------------------------------------------------*/
-
-/* Get cross for direction1 and direction2 */
-/*  Result = 1 - cross */
-/*  Result = 2 - parallel and not equal */
-/*  Result = 3 - parallel and equal */
-
-void icvGetCrossDirectDirect(  CvVect64d direct1,CvVect64d direct2,
-                            CvPoint2D64d *cross,int* result)
-{
-    double det  = direct1[0]*direct2[1] - direct2[0]*direct1[1];
-    double detx = -direct1[2]*direct2[1] + direct1[1]*direct2[2];
-
-    if( fabs(det) > EPS64D )
-    {/* Have cross */
-        cross->x = detx/det;
-        cross->y = (-direct1[0]*direct2[2] + direct2[0]*direct1[2])/det;
-        *result = 1;
-    }
-    else
-    {/* may be parallel */
-        if( fabs(detx) > EPS64D )
-        {/* parallel and not equal */
-            *result = 2;
-        }
-        else
-        {/* equals */
-            *result = 3;
-        }
-    }
-
-    return;
-}
-
-/*---------------------------------------------------------------------------------------*/
-
-/* Get cross for piece p1,p2 and direction a,b,c */
-/*  Result = 0 - no cross */
-/*  Result = 1 - cross */
-/*  Result = 2 - parallel and not equal */
-/*  Result = 3 - parallel and equal */
-
-void icvGetCrossPieceDirect(   CvPoint2D64d p_start,CvPoint2D64d p_end,
-                            double a,double b,double c,
-                            CvPoint2D64d *cross,int* result)
-{
-
-    if( (a*p_start.x + b*p_start.y + c) * (a*p_end.x + b*p_end.y + c) <= 0 )
-    {/* Have cross */
-        double det;
-        double detxc,detyc;
-
-        det = a * (p_end.x - p_start.x) + b * (p_end.y - p_start.y);
-
-        if( fabs(det) < EPS64D )
-        {/* lines are parallel and may be equal or line is point */
-            if(  fabs(a*p_start.x + b*p_start.y + c) < EPS64D )
-            {/* line is point or not diff */
-                *result = 3;
-                return;
-            }
-            else
-            {
-                *result = 2;
-            }
-            return;
-        }
-
-        detxc = b*(p_end.y*p_start.x - p_start.y*p_end.x) + c*(p_start.x - p_end.x);
-        detyc = a*(p_end.x*p_start.y - p_start.x*p_end.y) + c*(p_start.y - p_end.y);
-
-        cross->x = detxc / det;
-        cross->y = detyc / det;
-        *result = 1;
-
-    }
-    else
-    {
-        *result = 0;
-    }
-    return;
-}
-/*--------------------------------------------------------------------------------------*/
-
-void icvGetCrossPiecePiece( CvPoint2D64d p1_start,CvPoint2D64d p1_end,
-                            CvPoint2D64d p2_start,CvPoint2D64d p2_end,
-                            CvPoint2D64d* cross,
-                            int* result)
-{
-    double ex1,ey1,ex2,ey2;
-    double px1,py1,px2,py2;
-    double del;
-    double delA,delB,delX,delY;
-    double alpha,betta;
-
-    ex1 = p1_start.x;
-    ey1 = p1_start.y;
-    ex2 = p1_end.x;
-    ey2 = p1_end.y;
-
-    px1 = p2_start.x;
-    py1 = p2_start.y;
-    px2 = p2_end.x;
-    py2 = p2_end.y;
-
-    del = (py1-py2)*(ex1-ex2)-(px1-px2)*(ey1-ey2);
-    if( fabs(del) <= EPS64D )
-    {/* May be they are parallel !!! */
-        *result = 0;
-        return;
-    }
-
-    delA =  (ey1-ey2)*(ex1-px1) + (ex1-ex2)*(py1-ey1);
-    delB =  (py1-py2)*(ex1-px1) + (px1-px2)*(py1-ey1);
-
-    alpha = delA / del;
-    betta = delB / del;
-
-    if( alpha < 0 || alpha > 1.0 || betta < 0 || betta > 1.0)
-    {
-        *result = 0;
-        return;
-    }
-
-    delX =  (px1-px2)*(ey1*(ex1-ex2)-ex1*(ey1-ey2))+
-            (ex1-ex2)*(px1*(py1-py2)-py1*(px1-px2));
-
-    delY =  (py1-py2)*(ey1*(ex1-ex2)-ex1*(ey1-ey2))+
-            (ey1-ey2)*(px1*(py1-py2)-py1*(px1-px2));
-
-    cross->x = delX / del;
-    cross->y = delY / del;
-
-    *result = 1;
-    return;
-}
-
-
-/*---------------------------------------------------------------------------------------*/
-
-void icvGetPieceLength(CvPoint2D64d point1,CvPoint2D64d point2,double* dist)
-{
-    double dx = point2.x - point1.x;
-    double dy = point2.y - point1.y;
-    *dist = sqrt( dx*dx + dy*dy );
-    return;
-}
-
-/*---------------------------------------------------------------------------------------*/
-
-void icvGetPieceLength3D(CvPoint3D64d point1,CvPoint3D64d point2,double* dist)
-{
-    double dx = point2.x - point1.x;
-    double dy = point2.y - point1.y;
-    double dz = point2.z - point1.z;
-    *dist = sqrt( dx*dx + dy*dy + dz*dz );
-    return;
-}
-
-/*---------------------------------------------------------------------------------------*/
-
-/* Find line from epipole which cross image rect */
-/* Find points of cross 0 or 1 or 2. Return number of points in cross */
-void icvGetCrossRectDirect(    CvSize imageSize,
-                            double a,double b,double c,
-                            CvPoint2D64d *start,CvPoint2D64d *end,
-                            int* result)
-{
-    CvPoint2D64d frameBeg;
-    CvPoint2D64d frameEnd;
-    CvPoint2D64d cross[4];
-    int     haveCross[4];
-
-    haveCross[0] = 0;
-    haveCross[1] = 0;
-    haveCross[2] = 0;
-    haveCross[3] = 0;
-
-    frameBeg.x = 0;
-    frameBeg.y = 0;
-    frameEnd.x = imageSize.width;
-    frameEnd.y = 0;
-
-    icvGetCrossPieceDirect(frameBeg,frameEnd,a,b,c,&cross[0],&haveCross[0]);
-
-    frameBeg.x = imageSize.width;
-    frameBeg.y = 0;
-    frameEnd.x = imageSize.width;
-    frameEnd.y = imageSize.height;
-    icvGetCrossPieceDirect(frameBeg,frameEnd,a,b,c,&cross[1],&haveCross[1]);
-
-    frameBeg.x = imageSize.width;
-    frameBeg.y = imageSize.height;
-    frameEnd.x = 0;
-    frameEnd.y = imageSize.height;
-    icvGetCrossPieceDirect(frameBeg,frameEnd,a,b,c,&cross[2],&haveCross[2]);
-
-    frameBeg.x = 0;
-    frameBeg.y = imageSize.height;
-    frameEnd.x = 0;
-    frameEnd.y = 0;
-    icvGetCrossPieceDirect(frameBeg,frameEnd,a,b,c,&cross[3],&haveCross[3]);
-
-    double maxDist;
-
-    int maxI=0,maxJ=0;
-
-
-    int i,j;
-
-    maxDist = -1.0;
-
-    double distance;
-
-    for( i = 0; i < 3; i++ )
-    {
-        if( haveCross[i] == 1 )
-        {
-            for( j = i + 1; j < 4; j++ )
-            {
-                if( haveCross[j] == 1)
-                {/* Compute dist */
-                    icvGetPieceLength(cross[i],cross[j],&distance);
-                    if( distance > maxDist )
-                    {
-                        maxI = i;
-                        maxJ = j;
-                        maxDist = distance;
-                    }
-                }
-            }
-        }
-    }
-
-    if( maxDist >= 0 )
-    {/* We have cross */
-        *start = cross[maxI];
-        *result = 1;
-        if( maxDist > 0 )
-        {
-            *end   = cross[maxJ];
-            *result = 2;
-        }
-    }
-    else
-    {
-        *result = 0;
-    }
-
-    return;
-}/* GetCrossRectDirect */
-
-/*---------------------------------------------------------------------------------------*/
-void icvProjectPointToImage(   CvPoint3D64d point,
-                            CvMatr64d camMatr,CvMatr64d rotMatr,CvVect64d transVect,
-                            CvPoint2D64d* projPoint)
-{
-
-    double tmpVect1[3];
-    double tmpVect2[3];
-
-    icvMulMatrix_64d (  rotMatr,
-                        3,3,
-                        (double*)&point,
-                        1,3,
-                        tmpVect1);
-
-    icvAddVector_64d ( tmpVect1, transVect,tmpVect2, 3);
-
-    icvMulMatrix_64d (  camMatr,
-                        3,3,
-                        tmpVect2,
-                        1,3,
-                        tmpVect1);
-
-    projPoint->x = tmpVect1[0] / tmpVect1[2];
-    projPoint->y = tmpVect1[1] / tmpVect1[2];
-
-    return;
-}
-
-/*---------------------------------------------------------------------------------------*/
-/* Get quads for transform images */
-void icvGetQuadsTransform(
-                          CvSize        imageSize,
-                        CvMatr64d     camMatr1,
-                        CvMatr64d     rotMatr1,
-                        CvVect64d     transVect1,
-                        CvMatr64d     camMatr2,
-                        CvMatr64d     rotMatr2,
-                        CvVect64d     transVect2,
-                        CvSize*       warpSize,
-                        double quad1[4][2],
-                        double quad2[4][2],
-                        CvMatr64d     fundMatr,
-                        CvPoint3D64d* epipole1,
-                        CvPoint3D64d* epipole2
-                        )
-{
-    /* First compute fundamental matrix and epipoles */
-    int res;
-
-
-    /* Compute epipoles and fundamental matrix using new functions */
-    {
-        double convRotMatr[9];
-        double convTransVect[3];
-
-        icvCreateConvertMatrVect( rotMatr1,
-                                  transVect1,
-                                  rotMatr2,
-                                  transVect2,
-                                  convRotMatr,
-                                  convTransVect);
-        float convRotMatr_32f[9];
-        float convTransVect_32f[3];
-
-        icvCvt_64d_32f(convRotMatr,convRotMatr_32f,9);
-        icvCvt_64d_32f(convTransVect,convTransVect_32f,3);
-
-        /* We know R and t */
-        /* Compute essential matrix */
-        float essMatr[9];
-        float fundMatr_32f[9];
-
-        float camMatr1_32f[9];
-        float camMatr2_32f[9];
-
-        icvCvt_64d_32f(camMatr1,camMatr1_32f,9);
-        icvCvt_64d_32f(camMatr2,camMatr2_32f,9);
-
-        cvComputeEssentialMatrix(   convRotMatr_32f,
-                                    convTransVect_32f,
-                                    essMatr);
-
-        cvConvertEssential2Fundamental( essMatr,
-                                        fundMatr_32f,
-                                        camMatr1_32f,
-                                        camMatr2_32f);
-
-        CvPoint3D32f epipole1_32f;
-        CvPoint3D32f epipole2_32f;
-
-        cvComputeEpipolesFromFundMatrix( fundMatr_32f,
-                                         &epipole1_32f,
-                                         &epipole2_32f);
-        /* copy to 64d epipoles */
-        epipole1->x = epipole1_32f.x;
-        epipole1->y = epipole1_32f.y;
-        epipole1->z = epipole1_32f.z;
-
-        epipole2->x = epipole2_32f.x;
-        epipole2->y = epipole2_32f.y;
-        epipole2->z = epipole2_32f.z;
-
-        /* Convert fundamental matrix */
-        icvCvt_32f_64d(fundMatr_32f,fundMatr,9);
-    }
-
-    double coeff11[3];
-    double coeff12[3];
-    double coeff21[3];
-    double coeff22[3];
-
-    icvGetCommonArea(   imageSize,
-                        *epipole1,*epipole2,
-                        fundMatr,
-                        coeff11,coeff12,
-                        coeff21,coeff22,
-                        &res);
-
-    CvPoint2D64d point11, point12,point21, point22;
-    double width1,width2;
-    double height1,height2;
-    double tmpHeight1,tmpHeight2;
-
-    CvPoint2D64d epipole1_2d;
-    CvPoint2D64d epipole2_2d;
-
-    /* ----- Image 1 ----- */
-    if( fabs(epipole1->z) < 1e-8 )
-    {
-        return;
-    }
-    epipole1_2d.x = epipole1->x / epipole1->z;
-    epipole1_2d.y = epipole1->y / epipole1->z;
-
-    icvGetCutPiece( coeff11,coeff12,
-                epipole1_2d,
-                imageSize,
-                &point11,&point12,
-                &point21,&point22,
-                &res);
-
-    /* Compute distance */
-    icvGetPieceLength(point11,point21,&width1);
-    icvGetPieceLength(point11,point12,&tmpHeight1);
-    icvGetPieceLength(point21,point22,&tmpHeight2);
-    height1 = MAX(tmpHeight1,tmpHeight2);
-
-    quad1[0][0] = point11.x;
-    quad1[0][1] = point11.y;
-
-    quad1[1][0] = point21.x;
-    quad1[1][1] = point21.y;
-
-    quad1[2][0] = point22.x;
-    quad1[2][1] = point22.y;
-
-    quad1[3][0] = point12.x;
-    quad1[3][1] = point12.y;
-
-    /* ----- Image 2 ----- */
-    if( fabs(epipole2->z) < 1e-8 )
-    {
-        return;
-    }
-    epipole2_2d.x = epipole2->x / epipole2->z;
-    epipole2_2d.y = epipole2->y / epipole2->z;
-
-    icvGetCutPiece( coeff21,coeff22,
-                epipole2_2d,
-                imageSize,
-                &point11,&point12,
-                &point21,&point22,
-                &res);
-
-    /* Compute distance */
-    icvGetPieceLength(point11,point21,&width2);
-    icvGetPieceLength(point11,point12,&tmpHeight1);
-    icvGetPieceLength(point21,point22,&tmpHeight2);
-    height2 = MAX(tmpHeight1,tmpHeight2);
-
-    quad2[0][0] = point11.x;
-    quad2[0][1] = point11.y;
-
-    quad2[1][0] = point21.x;
-    quad2[1][1] = point21.y;
-
-    quad2[2][0] = point22.x;
-    quad2[2][1] = point22.y;
-
-    quad2[3][0] = point12.x;
-    quad2[3][1] = point12.y;
-
-
-    /*=======================================================*/
-    /* This is a new additional way to compute quads. */
-    /* We must correct quads */
-    {
-        double convRotMatr[9];
-        double convTransVect[3];
-
-        double newQuad1[4][2];
-        double newQuad2[4][2];
-
-
-        icvCreateConvertMatrVect( rotMatr1,
-                                  transVect1,
-                                  rotMatr2,
-                                  transVect2,
-                                  convRotMatr,
-                                  convTransVect);
-
-        /* -------------Compute for first image-------------- */
-        CvPoint2D32f pointb1;
-        CvPoint2D32f pointe1;
-
-        CvPoint2D32f pointb2;
-        CvPoint2D32f pointe2;
-
-        pointb1.x = (float)quad1[0][0];
-        pointb1.y = (float)quad1[0][1];
-
-        pointe1.x = (float)quad1[3][0];
-        pointe1.y = (float)quad1[3][1];
-
-        icvComputeeInfiniteProject1(convRotMatr,
-                                    camMatr1,
-                                    camMatr2,
-                                    pointb1,
-                                    &pointb2);
-
-        icvComputeeInfiniteProject1(convRotMatr,
-                                    camMatr1,
-                                    camMatr2,
-                                    pointe1,
-                                    &pointe2);
-
-        /*  JUST TEST FOR POINT */
-
-        /* Compute distances */
-        double dxOld,dyOld;
-        double dxNew,dyNew;
-        double distOld,distNew;
-
-        dxOld = quad2[1][0] - quad2[0][0];
-        dyOld = quad2[1][1] - quad2[0][1];
-        distOld = dxOld*dxOld + dyOld*dyOld;
-
-        dxNew = quad2[1][0] - pointb2.x;
-        dyNew = quad2[1][1] - pointb2.y;
-        distNew = dxNew*dxNew + dyNew*dyNew;
-
-        if( distNew > distOld )
-        {/* Get new points for second quad */
-            newQuad2[0][0] = pointb2.x;
-            newQuad2[0][1] = pointb2.y;
-            newQuad2[3][0] = pointe2.x;
-            newQuad2[3][1] = pointe2.y;
-            newQuad1[0][0] = quad1[0][0];
-            newQuad1[0][1] = quad1[0][1];
-            newQuad1[3][0] = quad1[3][0];
-            newQuad1[3][1] = quad1[3][1];
-        }
-        else
-        {/* Get new points for first quad */
-
-            pointb2.x = (float)quad2[0][0];
-            pointb2.y = (float)quad2[0][1];
-
-            pointe2.x = (float)quad2[3][0];
-            pointe2.y = (float)quad2[3][1];
-
-            icvComputeeInfiniteProject2(convRotMatr,
-                                        camMatr1,
-                                        camMatr2,
-                                        &pointb1,
-                                        pointb2);
-
-            icvComputeeInfiniteProject2(convRotMatr,
-                                        camMatr1,
-                                        camMatr2,
-                                        &pointe1,
-                                        pointe2);
-
-
-            /*  JUST TEST FOR POINT */
-
-            newQuad2[0][0] = quad2[0][0];
-            newQuad2[0][1] = quad2[0][1];
-            newQuad2[3][0] = quad2[3][0];
-            newQuad2[3][1] = quad2[3][1];
-
-            newQuad1[0][0] = pointb1.x;
-            newQuad1[0][1] = pointb1.y;
-            newQuad1[3][0] = pointe1.x;
-            newQuad1[3][1] = pointe1.y;
-        }
-
-        /* -------------Compute for second image-------------- */
-        pointb1.x = (float)quad1[1][0];
-        pointb1.y = (float)quad1[1][1];
-
-        pointe1.x = (float)quad1[2][0];
-        pointe1.y = (float)quad1[2][1];
-
-        icvComputeeInfiniteProject1(convRotMatr,
-                                    camMatr1,
-                                    camMatr2,
-                                    pointb1,
-                                    &pointb2);
-
-        icvComputeeInfiniteProject1(convRotMatr,
-                                    camMatr1,
-                                    camMatr2,
-                                    pointe1,
-                                    &pointe2);
-
-        /* Compute distances */
-
-        dxOld = quad2[0][0] - quad2[1][0];
-        dyOld = quad2[0][1] - quad2[1][1];
-        distOld = dxOld*dxOld + dyOld*dyOld;
-
-        dxNew = quad2[0][0] - pointb2.x;
-        dyNew = quad2[0][1] - pointb2.y;
-        distNew = dxNew*dxNew + dyNew*dyNew;
-
-        if( distNew > distOld )
-        {/* Get new points for second quad */
-            newQuad2[1][0] = pointb2.x;
-            newQuad2[1][1] = pointb2.y;
-            newQuad2[2][0] = pointe2.x;
-            newQuad2[2][1] = pointe2.y;
-            newQuad1[1][0] = quad1[1][0];
-            newQuad1[1][1] = quad1[1][1];
-            newQuad1[2][0] = quad1[2][0];
-            newQuad1[2][1] = quad1[2][1];
-        }
-        else
-        {/* Get new points for first quad */
-
-            pointb2.x = (float)quad2[1][0];
-            pointb2.y = (float)quad2[1][1];
-
-            pointe2.x = (float)quad2[2][0];
-            pointe2.y = (float)quad2[2][1];
-
-            icvComputeeInfiniteProject2(convRotMatr,
-                                        camMatr1,
-                                        camMatr2,
-                                        &pointb1,
-                                        pointb2);
-
-            icvComputeeInfiniteProject2(convRotMatr,
-                                        camMatr1,
-                                        camMatr2,
-                                        &pointe1,
-                                        pointe2);
-
-            newQuad2[1][0] = quad2[1][0];
-            newQuad2[1][1] = quad2[1][1];
-            newQuad2[2][0] = quad2[2][0];
-            newQuad2[2][1] = quad2[2][1];
-
-            newQuad1[1][0] = pointb1.x;
-            newQuad1[1][1] = pointb1.y;
-            newQuad1[2][0] = pointe1.x;
-            newQuad1[2][1] = pointe1.y;
-        }
-
-
-
-/*-------------------------------------------------------------------------------*/
-
-        /* Copy new quads to old quad */
-        int i;
-        for( i = 0; i < 4; i++ )
-        {
-            {
-                quad1[i][0] = newQuad1[i][0];
-                quad1[i][1] = newQuad1[i][1];
-                quad2[i][0] = newQuad2[i][0];
-                quad2[i][1] = newQuad2[i][1];
-            }
-        }
-    }
-    /*=======================================================*/
-
-    double warpWidth,warpHeight;
-
-    warpWidth  = MAX(width1,width2);
-    warpHeight = MAX(height1,height2);
-
-    warpSize->width  = (int)warpWidth;
-    warpSize->height = (int)warpHeight;
-
-    warpSize->width  = cvRound(warpWidth-1);
-    warpSize->height = cvRound(warpHeight-1);
-
-/* !!! by Valery Mosyagin. this lines added just for test no warp */
-    warpSize->width  = imageSize.width;
-    warpSize->height = imageSize.height;
-
-    return;
-}
-
-
-/*---------------------------------------------------------------------------------------*/
-
-static void icvGetQuadsTransformNew(  CvSize        imageSize,
-                            CvMatr32f     camMatr1,
-                            CvMatr32f     camMatr2,
-                            CvMatr32f     rotMatr1,
-                            CvVect32f     transVect1,
-                            CvSize*       warpSize,
-                            double        quad1[4][2],
-                            double        quad2[4][2],
-                            CvMatr32f     fundMatr,
-                            CvPoint3D32f* epipole1,
-                            CvPoint3D32f* epipole2
-                        )
-{
-    /* Convert data */
-    /* Convert camera matrix */
-    double camMatr1_64d[9];
-    double camMatr2_64d[9];
-    double rotMatr1_64d[9];
-    double transVect1_64d[3];
-    double rotMatr2_64d[9];
-    double transVect2_64d[3];
-    double fundMatr_64d[9];
-    CvPoint3D64d epipole1_64d;
-    CvPoint3D64d epipole2_64d;
-
-    icvCvt_32f_64d(camMatr1,camMatr1_64d,9);
-    icvCvt_32f_64d(camMatr2,camMatr2_64d,9);
-    icvCvt_32f_64d(rotMatr1,rotMatr1_64d,9);
-    icvCvt_32f_64d(transVect1,transVect1_64d,3);
-
-    /* Create vector and matrix */
-
-    rotMatr2_64d[0] = 1;
-    rotMatr2_64d[1] = 0;
-    rotMatr2_64d[2] = 0;
-    rotMatr2_64d[3] = 0;
-    rotMatr2_64d[4] = 1;
-    rotMatr2_64d[5] = 0;
-    rotMatr2_64d[6] = 0;
-    rotMatr2_64d[7] = 0;
-    rotMatr2_64d[8] = 1;
-
-    transVect2_64d[0] = 0;
-    transVect2_64d[1] = 0;
-    transVect2_64d[2] = 0;
-
-    icvGetQuadsTransform(   imageSize,
-                            camMatr1_64d,
-                            rotMatr1_64d,
-                            transVect1_64d,
-                            camMatr2_64d,
-                            rotMatr2_64d,
-                            transVect2_64d,
-                            warpSize,
-                            quad1,
-                            quad2,
-                            fundMatr_64d,
-                            &epipole1_64d,
-                            &epipole2_64d
-                        );
-
-    /* Convert epipoles */
-    epipole1->x = (float)(epipole1_64d.x);
-    epipole1->y = (float)(epipole1_64d.y);
-    epipole1->z = (float)(epipole1_64d.z);
-
-    epipole2->x = (float)(epipole2_64d.x);
-    epipole2->y = (float)(epipole2_64d.y);
-    epipole2->z = (float)(epipole2_64d.z);
-
-    /* Convert fundamental matrix */
-    icvCvt_64d_32f(fundMatr_64d,fundMatr,9);
-
-    return;
-}
-
-/*---------------------------------------------------------------------------------------*/
-void icvGetQuadsTransformStruct(  CvStereoCamera* stereoCamera)
-{
-    /* Wrapper for icvGetQuadsTransformNew */
-
-
-    double  quad1[4][2];
-    double  quad2[4][2];
-
-    icvGetQuadsTransformNew(     cvSize(cvRound(stereoCamera->camera[0]->imgSize[0]),cvRound(stereoCamera->camera[0]->imgSize[1])),
-                            stereoCamera->camera[0]->matrix,
-                            stereoCamera->camera[1]->matrix,
-                            stereoCamera->rotMatrix,
-                            stereoCamera->transVector,
-                            &(stereoCamera->warpSize),
-                            quad1,
-                            quad2,
-                            stereoCamera->fundMatr,
-                            &(stereoCamera->epipole[0]),
-                            &(stereoCamera->epipole[1])
-                        );
-
-    int i;
-    for( i = 0; i < 4; i++ )
-    {
-        stereoCamera->quad[0][i] = cvPoint2D32f(quad1[i][0],quad1[i][1]);
-        stereoCamera->quad[1][i] = cvPoint2D32f(quad2[i][0],quad2[i][1]);
-    }
-
-    return;
-}
-
-/*---------------------------------------------------------------------------------------*/
-void icvComputeStereoParamsForCameras(CvStereoCamera* stereoCamera)
-{
-    /* For given intrinsic and extrinsic parameters computes rest parameters
-    **   such as fundamental matrix. warping coeffs, epipoles, ...
-    */
-
-
-    /* compute rotate matrix and translate vector */
-    double rotMatr1[9];
-    double rotMatr2[9];
-
-    double transVect1[3];
-    double transVect2[3];
-
-    double convRotMatr[9];
-    double convTransVect[3];
-
-    /* fill matrices */
-    icvCvt_32f_64d(stereoCamera->camera[0]->rotMatr,rotMatr1,9);
-    icvCvt_32f_64d(stereoCamera->camera[1]->rotMatr,rotMatr2,9);
-
-    icvCvt_32f_64d(stereoCamera->camera[0]->transVect,transVect1,3);
-    icvCvt_32f_64d(stereoCamera->camera[1]->transVect,transVect2,3);
-
-    icvCreateConvertMatrVect(   rotMatr1,
-                                transVect1,
-                                rotMatr2,
-                                transVect2,
-                                convRotMatr,
-                                convTransVect);
-
-    /* copy to stereo camera params */
-    icvCvt_64d_32f(convRotMatr,stereoCamera->rotMatrix,9);
-    icvCvt_64d_32f(convTransVect,stereoCamera->transVector,3);
-
-
-    icvGetQuadsTransformStruct(stereoCamera);
-    icvComputeRestStereoParams(stereoCamera);
-}
-
-
-
-/*---------------------------------------------------------------------------------------*/
-
-/* Get cut line for one image */
-void icvGetCutPiece(   CvVect64d areaLineCoef1,CvVect64d areaLineCoef2,
-                    CvPoint2D64d epipole,
-                    CvSize imageSize,
-                    CvPoint2D64d* point11,CvPoint2D64d* point12,
-                    CvPoint2D64d* point21,CvPoint2D64d* point22,
-                    int* result)
-{
-    /* Compute nearest cut line to epipole */
-    /* Get corners inside sector */
-    /* Collect all candidate point */
-
-    CvPoint2D64d candPoints[8];
-    CvPoint2D64d midPoint;
-    int numPoints = 0;
-    int res;
-    int i;
-
-    double cutLine1[3];
-    double cutLine2[3];
-
-    /* Find middle line of sector */
-    double midLine[3]={0,0,0};
-
-
-    /* Different way  */
-    CvPoint2D64d pointOnLine1;  pointOnLine1.x = pointOnLine1.y = 0;
-    CvPoint2D64d pointOnLine2;  pointOnLine2.x = pointOnLine2.y = 0;
-
-    CvPoint2D64d start1,end1;
-
-    icvGetCrossRectDirect( imageSize,
-                        areaLineCoef1[0],areaLineCoef1[1],areaLineCoef1[2],
-                        &start1,&end1,&res);
-    if( res > 0 )
-    {
-        pointOnLine1 = start1;
-    }
-
-    icvGetCrossRectDirect( imageSize,
-                        areaLineCoef2[0],areaLineCoef2[1],areaLineCoef2[2],
-                        &start1,&end1,&res);
-    if( res > 0 )
-    {
-        pointOnLine2 = start1;
-    }
-
-    icvGetMiddleAnglePoint(epipole,pointOnLine1,pointOnLine2,&midPoint);
-
-    icvGetCoefForPiece(epipole,midPoint,&midLine[0],&midLine[1],&midLine[2],&res);
-
-    /* Test corner points */
-    CvPoint2D64d cornerPoint;
-    CvPoint2D64d tmpPoints[2];
-
-    cornerPoint.x = 0;
-    cornerPoint.y = 0;
-    icvTestPoint( cornerPoint, areaLineCoef1, areaLineCoef2, epipole, &res);
-    if( res == 1 )
-    {/* Add point */
-        candPoints[numPoints] = cornerPoint;
-        numPoints++;
-    }
-
-    cornerPoint.x = imageSize.width;
-    cornerPoint.y = 0;
-    icvTestPoint( cornerPoint, areaLineCoef1, areaLineCoef2, epipole, &res);
-    if( res == 1 )
-    {/* Add point */
-        candPoints[numPoints] = cornerPoint;
-        numPoints++;
-    }
-
-    cornerPoint.x = imageSize.width;
-    cornerPoint.y = imageSize.height;
-    icvTestPoint( cornerPoint, areaLineCoef1, areaLineCoef2, epipole, &res);
-    if( res == 1 )
-    {/* Add point */
-        candPoints[numPoints] = cornerPoint;
-        numPoints++;
-    }
-
-    cornerPoint.x = 0;
-    cornerPoint.y = imageSize.height;
-    icvTestPoint( cornerPoint, areaLineCoef1, areaLineCoef2, epipole, &res);
-    if( res == 1 )
-    {/* Add point */
-        candPoints[numPoints] = cornerPoint;
-        numPoints++;
-    }
-
-    /* Find cross line 1 with image border */
-    icvGetCrossRectDirect( imageSize,
-                        areaLineCoef1[0],areaLineCoef1[1],areaLineCoef1[2],
-                        &tmpPoints[0], &tmpPoints[1],
-                        &res);
-    for( i = 0; i < res; i++ )
-    {
-        candPoints[numPoints++] = tmpPoints[i];
-    }
-
-    /* Find cross line 2 with image border */
-    icvGetCrossRectDirect( imageSize,
-                        areaLineCoef2[0],areaLineCoef2[1],areaLineCoef2[2],
-                        &tmpPoints[0], &tmpPoints[1],
-                        &res);
-
-    for( i = 0; i < res; i++ )
-    {
-        candPoints[numPoints++] = tmpPoints[i];
-    }
-
-    if( numPoints < 2 )
-    {
-        *result = 0;
-        return;/* Error. Not enought points */
-    }
-    /* Project all points to middle line and get max and min */
-
-    CvPoint2D64d projPoint;
-    CvPoint2D64d minPoint; minPoint.x = minPoint.y = FLT_MAX;
-    CvPoint2D64d maxPoint; maxPoint.x = maxPoint.y = -FLT_MAX;
-
-
-    double dist;
-    double maxDist = 0;
-    double minDist = 10000000;
-
-
-    for( i = 0; i < numPoints; i++ )
-    {
-        icvProjectPointToDirect(candPoints[i], midLine, &projPoint);
-        icvGetPieceLength(epipole,projPoint,&dist);
-        if( dist < minDist)
-        {
-            minDist = dist;
-            minPoint = projPoint;
-        }
-
-        if( dist > maxDist)
-        {
-            maxDist = dist;
-            maxPoint = projPoint;
-        }
-    }
-
-    /* We know maximum and minimum points. Now we can compute cut lines */
-
-    icvGetNormalDirect(midLine,minPoint,cutLine1);
-    icvGetNormalDirect(midLine,maxPoint,cutLine2);
-
-    /* Test for begin of line. */
-    CvPoint2D64d tmpPoint2;
-
-    /* Get cross with */
-    icvGetCrossDirectDirect(areaLineCoef1,cutLine1,point11,&res);
-    icvGetCrossDirectDirect(areaLineCoef2,cutLine1,point12,&res);
-
-    icvGetCrossDirectDirect(areaLineCoef1,cutLine2,point21,&res);
-    icvGetCrossDirectDirect(areaLineCoef2,cutLine2,point22,&res);
-
-    if( epipole.x > imageSize.width * 0.5 )
-    {/* Need to change points */
-        tmpPoint2 = *point11;
-        *point11 = *point21;
-        *point21 = tmpPoint2;
-
-        tmpPoint2 = *point12;
-        *point12 = *point22;
-        *point22 = tmpPoint2;
-    }
-
-    return;
-}
-/*---------------------------------------------------------------------------------------*/
-/* Get middle angle */
-void icvGetMiddleAnglePoint(   CvPoint2D64d basePoint,
-                            CvPoint2D64d point1,CvPoint2D64d point2,
-                            CvPoint2D64d* midPoint)
-{/* !!! May be need to return error */
-
-    double dist1;
-    double dist2;
-    icvGetPieceLength(basePoint,point1,&dist1);
-    icvGetPieceLength(basePoint,point2,&dist2);
-    CvPoint2D64d pointNew1;
-    CvPoint2D64d pointNew2;
-    double alpha = dist2/dist1;
-
-    pointNew1.x = basePoint.x + (1.0/alpha) * ( point2.x - basePoint.x );
-    pointNew1.y = basePoint.y + (1.0/alpha) * ( point2.y - basePoint.y );
-
-    pointNew2.x = basePoint.x + alpha * ( point1.x - basePoint.x );
-    pointNew2.y = basePoint.y + alpha * ( point1.y - basePoint.y );
-
-    int res;
-    icvGetCrossPiecePiece(point1,point2,pointNew1,pointNew2,midPoint,&res);
-
-    return;
-}
-
-/*---------------------------------------------------------------------------------------*/
-/* Get normal direct to direct in line */
-void icvGetNormalDirect(CvVect64d direct,CvPoint2D64d point,CvVect64d normDirect)
-{
-    normDirect[0] =   direct[1];
-    normDirect[1] = - direct[0];
-    normDirect[2] = -(normDirect[0]*point.x + normDirect[1]*point.y);
-    return;
-}
-
-/*---------------------------------------------------------------------------------------*/
-CV_IMPL double icvGetVect(CvPoint2D64d basePoint,CvPoint2D64d point1,CvPoint2D64d point2)
-{
-    return  (point1.x - basePoint.x)*(point2.y - basePoint.y) -
-            (point2.x - basePoint.x)*(point1.y - basePoint.y);
-}
-/*---------------------------------------------------------------------------------------*/
-/* Test for point in sector           */
-/* Return 0 - point not inside sector */
-/* Return 1 - point inside sector     */
-void icvTestPoint( CvPoint2D64d testPoint,
-                CvVect64d line1,CvVect64d line2,
-                CvPoint2D64d basePoint,
-                int* result)
-{
-    CvPoint2D64d point1,point2;
-
-    icvProjectPointToDirect(testPoint,line1,&point1);
-    icvProjectPointToDirect(testPoint,line2,&point2);
-
-    double sign1 = icvGetVect(basePoint,point1,point2);
-    double sign2 = icvGetVect(basePoint,point1,testPoint);
-    if( sign1 * sign2 > 0 )
-    {/* Correct for first line */
-        sign1 = - sign1;
-        sign2 = icvGetVect(basePoint,point2,testPoint);
-        if( sign1 * sign2 > 0 )
-        {/* Correct for both lines */
-            *result = 1;
-        }
-        else
-        {
-            *result = 0;
-        }
-    }
-    else
-    {
-        *result = 0;
-    }
-
-    return;
-}
-
-/*---------------------------------------------------------------------------------------*/
-/* Project point to line */
-void icvProjectPointToDirect(  CvPoint2D64d point,CvVect64d lineCoeff,
-                            CvPoint2D64d* projectPoint)
-{
-    double a = lineCoeff[0];
-    double b = lineCoeff[1];
-
-    double det =  1.0 / ( a*a + b*b );
-    double delta =  a*point.y - b*point.x;
-
-    projectPoint->x = ( -a*lineCoeff[2] - b * delta ) * det;
-    projectPoint->y = ( -b*lineCoeff[2] + a * delta ) * det ;
-
-    return;
-}
-
-/*---------------------------------------------------------------------------------------*/
-/* Get distance from point to direction */
-void icvGetDistanceFromPointToDirect( CvPoint2D64d point,CvVect64d lineCoef,double*dist)
-{
-    CvPoint2D64d tmpPoint;
-    icvProjectPointToDirect(point,lineCoef,&tmpPoint);
-    double dx = point.x - tmpPoint.x;
-    double dy = point.y - tmpPoint.y;
-    *dist = sqrt(dx*dx+dy*dy);
-    return;
-}
-/*---------------------------------------------------------------------------------------*/
-
-CV_IMPL IplImage* icvCreateIsometricImage( IplImage* src, IplImage* dst,
-                                       int desired_depth, int desired_num_channels )
-{
-    CvSize src_size ;
-    src_size.width = src->width;
-    src_size.height = src->height;
-
-    CvSize dst_size = src_size;
-
-    if( dst )
-    {
-        dst_size.width = dst->width;
-        dst_size.height = dst->height;
-    }
-
-    if( !dst || dst->depth != desired_depth ||
-        dst->nChannels != desired_num_channels ||
-        dst_size.width != src_size.width ||
-        dst_size.height != src_size.height )
-    {
-        cvReleaseImage( &dst );
-        dst = cvCreateImage( src_size, desired_depth, desired_num_channels );
-        CvRect rect = cvRect(0,0,src_size.width,src_size.height);
-        cvSetImageROI( dst, rect );
-
-    }
-
-    return dst;
-}
-
-static int
-icvCvt_32f_64d( float *src, double *dst, int size )
-{
-    int t;
-
-    if( !src || !dst )
-        return CV_NULLPTR_ERR;
-    if( size <= 0 )
-        return CV_BADRANGE_ERR;
-
-    for( t = 0; t < size; t++ )
-    {
-        dst[t] = (double) (src[t]);
-    }
-
-    return CV_OK;
-}
-
-/*======================================================================================*/
-/* Type conversion double -> float */
-static int
-icvCvt_64d_32f( double *src, float *dst, int size )
-{
-    int t;
-
-    if( !src || !dst )
-        return CV_NULLPTR_ERR;
-    if( size <= 0 )
-        return CV_BADRANGE_ERR;
-
-    for( t = 0; t < size; t++ )
-    {
-        dst[t] = (float) (src[t]);
-    }
-
-    return CV_OK;
-}
-
-/*----------------------------------------------------------------------------------*/
-
-#if 0
-/* Find line which cross frame by line(a,b,c) */
-static void FindLineForEpiline(    CvSize imageSize,
-                            float a,float b,float c,
-                            CvPoint2D32f *start,CvPoint2D32f *end,
-                            int*)
-{
-    CvPoint2D32f frameBeg;
-
-    CvPoint2D32f frameEnd;
-    CvPoint2D32f cross[4];
-    int     haveCross[4];
-    float   dist;
-
-    haveCross[0] = 0;
-    haveCross[1] = 0;
-    haveCross[2] = 0;
-    haveCross[3] = 0;
-
-    frameBeg.x = 0;
-    frameBeg.y = 0;
-    frameEnd.x = (float)(imageSize.width);
-    frameEnd.y = 0;
-    haveCross[0] = icvGetCrossLineDirect(frameBeg,frameEnd,a,b,c,&cross[0]);
-
-    frameBeg.x = (float)(imageSize.width);
-    frameBeg.y = 0;
-    frameEnd.x = (float)(imageSize.width);
-    frameEnd.y = (float)(imageSize.height);
-    haveCross[1] = icvGetCrossLineDirect(frameBeg,frameEnd,a,b,c,&cross[1]);
-
-    frameBeg.x = (float)(imageSize.width);
-    frameBeg.y = (float)(imageSize.height);
-    frameEnd.x = 0;
-    frameEnd.y = (float)(imageSize.height);
-    haveCross[2] = icvGetCrossLineDirect(frameBeg,frameEnd,a,b,c,&cross[2]);
-
-    frameBeg.x = 0;
-    frameBeg.y = (float)(imageSize.height);
-    frameEnd.x = 0;
-    frameEnd.y = 0;
-    haveCross[3] = icvGetCrossLineDirect(frameBeg,frameEnd,a,b,c,&cross[3]);
-
-    int n;
-    float minDist = (float)(INT_MAX);
-    float maxDist = (float)(INT_MIN);
-
-    int maxN = -1;
-    int minN = -1;
-
-    double midPointX = imageSize.width  / 2.0;
-    double midPointY = imageSize.height / 2.0;
-
-    for( n = 0; n < 4; n++ )
-    {
-        if( haveCross[n] > 0 )
-        {
-            dist =  (float)((midPointX - cross[n].x)*(midPointX - cross[n].x) +
-                            (midPointY - cross[n].y)*(midPointY - cross[n].y));
-
-            if( dist < minDist )
-            {
-                minDist = dist;
-                minN = n;
-            }
-
-            if( dist > maxDist )
-            {
-                maxDist = dist;
-                maxN = n;
-            }
-        }
-    }
-
-    if( minN >= 0 && maxN >= 0 && (minN != maxN) )
-    {
-        *start = cross[minN];
-        *end   = cross[maxN];
-    }
-    else
-    {
-        start->x = 0;
-        start->y = 0;
-        end->x = 0;
-        end->y = 0;
-    }
-
-    return;
-
-}
-
-
-/*----------------------------------------------------------------------------------*/
-static int GetAngleLinee( CvPoint2D32f epipole, CvSize imageSize,CvPoint2D32f point1,CvPoint2D32f point2)
-{
-    float width  = (float)(imageSize.width);
-    float height = (float)(imageSize.height);
-
-    /* Get crosslines with image corners */
-
-    /* Find four lines */
-
-    CvPoint2D32f pa,pb,pc,pd;
-
-    pa.x = 0;
-    pa.y = 0;
-
-    pb.x = width;
-    pb.y = 0;
-
-    pd.x = width;
-    pd.y = height;
-
-    pc.x = 0;
-    pc.y = height;
-
-    /* We can compute points for angle */
-    /* Test for place section */
-
-    float x,y;
-    x = epipole.x;
-    y = epipole.y;
-
-    if( x < 0 )
-    {/* 1,4,7 */
-        if( y < 0)
-        {/* 1 */
-            point1 = pb;
-            point2 = pc;
-        }
-        else if( y > height )
-        {/* 7 */
-            point1 = pa;
-            point2 = pd;
-        }
-        else
-        {/* 4 */
-            point1 = pa;
-            point2 = pc;
-        }
-    }
-    else if ( x > width )
-    {/* 3,6,9 */
-        if( y < 0 )
-        {/* 3 */
-            point1 = pa;
-            point2 = pd;
-        }
-        else if ( y > height )
-        {/* 9 */
-            point1 = pc;
-            point2 = pb;
-        }
-        else
-        {/* 6 */
-            point1 = pb;
-            point2 = pd;
-        }
-    }
-    else
-    {/* 2,5,8 */
-        if( y < 0 )
-        {/* 2 */
-            point1 = pa;
-            point2 = pb;
-        }
-        else if( y > height )
-        {/* 8 */
-            point1 = pc;
-            point2 = pd;
-        }
-        else
-        {/* 5 - point in the image */
-            return 2;
-        }
-
-
-    }
-
-
-    return 0;
-}
-
-/*--------------------------------------------------------------------------------------*/
-static void icvComputePerspectiveCoeffs(const CvPoint2D32f srcQuad[4],const CvPoint2D32f dstQuad[4],double coeffs[3][3])
-{/* Computes perspective coeffs for transformation from src to dst quad */
-
-
-    CV_FUNCNAME( "icvComputePerspectiveCoeffs" );
-
-    __BEGIN__;
-
-    double A[64];
-    double b[8];
-    double c[8];
-    CvPoint2D32f pt[4];
-    int i;
-
-    pt[0] = srcQuad[0];
-    pt[1] = srcQuad[1];
-    pt[2] = srcQuad[2];
-    pt[3] = srcQuad[3];
-
-    for( i = 0; i < 4; i++ )
-    {
-#if 0
-        double x = dstQuad[i].x;
-        double y = dstQuad[i].y;
-        double X = pt[i].x;
-        double Y = pt[i].y;
-#else
-        double x = pt[i].x;
-        double y = pt[i].y;
-        double X = dstQuad[i].x;
-        double Y = dstQuad[i].y;
-#endif
-        double* a = A + i*16;
-
-        a[0] = x;
-        a[1] = y;
-        a[2] = 1;
-        a[3] = 0;
-        a[4] = 0;
-        a[5] = 0;
-        a[6] = -X*x;
-        a[7] = -X*y;
-
-        a += 8;
-
-        a[0] = 0;
-        a[1] = 0;
-        a[2] = 0;
-        a[3] = x;
-        a[4] = y;
-        a[5] = 1;
-        a[6] = -Y*x;
-        a[7] = -Y*y;
-
-        b[i*2] = X;
-        b[i*2 + 1] = Y;
-    }
-
-    {
-    double invA[64];
-    CvMat matA = cvMat( 8, 8, CV_64F, A );
-    CvMat matInvA = cvMat( 8, 8, CV_64F, invA );
-    CvMat matB = cvMat( 8, 1, CV_64F, b );
-    CvMat matX = cvMat( 8, 1, CV_64F, c );
-
-    CV_CALL( cvPseudoInverse( &matA, &matInvA ));
-    CV_CALL( cvMatMulAdd( &matInvA, &matB, 0, &matX ));
-    }
-
-    coeffs[0][0] = c[0];
-    coeffs[0][1] = c[1];
-    coeffs[0][2] = c[2];
-    coeffs[1][0] = c[3];
-    coeffs[1][1] = c[4];
-    coeffs[1][2] = c[5];
-    coeffs[2][0] = c[6];
-    coeffs[2][1] = c[7];
-    coeffs[2][2] = 1.0;
-
-    __END__;
-
-    return;
-}
-#endif
-
-/*--------------------------------------------------------------------------------------*/
-
-CV_IMPL void cvComputePerspectiveMap(const double c[3][3], CvArr* rectMapX, CvArr* rectMapY )
-{
-    CV_FUNCNAME( "cvComputePerspectiveMap" );
-
-    __BEGIN__;
-
-    CvSize size;
-    CvMat  stubx, *mapx = (CvMat*)rectMapX;
-    CvMat  stuby, *mapy = (CvMat*)rectMapY;
-    int i, j;
-
-    CV_CALL( mapx = cvGetMat( mapx, &stubx ));
-    CV_CALL( mapy = cvGetMat( mapy, &stuby ));
-
-    if( CV_MAT_TYPE( mapx->type ) != CV_32FC1 || CV_MAT_TYPE( mapy->type ) != CV_32FC1 )
-        CV_ERROR( CV_StsUnsupportedFormat, "" );
-
-    size = cvGetMatSize(mapx);
-    assert( fabs(c[2][2] - 1.) < FLT_EPSILON );
-
-    for( i = 0; i < size.height; i++ )
-    {
-        float* mx = (float*)(mapx->data.ptr + mapx->step*i);
-        float* my = (float*)(mapy->data.ptr + mapy->step*i);
-
-        for( j = 0; j < size.width; j++ )
-        {
-            double w = 1./(c[2][0]*j + c[2][1]*i + 1.);
-            double x = (c[0][0]*j + c[0][1]*i + c[0][2])*w;
-            double y = (c[1][0]*j + c[1][1]*i + c[1][2])*w;
-
-            mx[j] = (float)x;
-            my[j] = (float)y;
-        }
-    }
-
-    __END__;
-}
-
-/*--------------------------------------------------------------------------------------*/
-
-CV_IMPL void cvInitPerspectiveTransform( CvSize size, const CvPoint2D32f quad[4], double matrix[3][3],
-                                              CvArr* rectMap )
-{
-    /* Computes Perspective Transform coeffs and map if need
-        for given image size and given result quad */
-    CV_FUNCNAME( "cvInitPerspectiveTransform" );
-
-    __BEGIN__;
-
-    double A[64];
-    double b[8];
-    double c[8];
-    CvPoint2D32f pt[4];
-    CvMat  mapstub, *map = (CvMat*)rectMap;
-    int i, j;
-
-    if( map )
-    {
-        CV_CALL( map = cvGetMat( map, &mapstub ));
-
-        if( CV_MAT_TYPE( map->type ) != CV_32FC2 )
-            CV_ERROR( CV_StsUnsupportedFormat, "" );
-
-        if( map->width != size.width || map->height != size.height )
-            CV_ERROR( CV_StsUnmatchedSizes, "" );
-    }
-
-    pt[0] = cvPoint2D32f( 0, 0 );
-    pt[1] = cvPoint2D32f( size.width, 0 );
-    pt[2] = cvPoint2D32f( size.width, size.height );
-    pt[3] = cvPoint2D32f( 0, size.height );
-
-    for( i = 0; i < 4; i++ )
-    {
-#if 0
-        double x = quad[i].x;
-        double y = quad[i].y;
-        double X = pt[i].x;
-        double Y = pt[i].y;
-#else
-        double x = pt[i].x;
-        double y = pt[i].y;
-        double X = quad[i].x;
-        double Y = quad[i].y;
-#endif
-        double* a = A + i*16;
-
-        a[0] = x;
-        a[1] = y;
-        a[2] = 1;
-        a[3] = 0;
-        a[4] = 0;
-        a[5] = 0;
-        a[6] = -X*x;
-        a[7] = -X*y;
-
-        a += 8;
-
-        a[0] = 0;
-        a[1] = 0;
-        a[2] = 0;
-        a[3] = x;
-        a[4] = y;
-        a[5] = 1;
-        a[6] = -Y*x;
-        a[7] = -Y*y;
-
-        b[i*2] = X;
-        b[i*2 + 1] = Y;
-    }
-
-    {
-    double invA[64];
-    CvMat matA = cvMat( 8, 8, CV_64F, A );
-    CvMat matInvA = cvMat( 8, 8, CV_64F, invA );
-    CvMat matB = cvMat( 8, 1, CV_64F, b );
-    CvMat matX = cvMat( 8, 1, CV_64F, c );
-
-    CV_CALL( cvPseudoInverse( &matA, &matInvA ));
-    CV_CALL( cvMatMulAdd( &matInvA, &matB, 0, &matX ));
-    }
-
-    matrix[0][0] = c[0];
-    matrix[0][1] = c[1];
-    matrix[0][2] = c[2];
-    matrix[1][0] = c[3];
-    matrix[1][1] = c[4];
-    matrix[1][2] = c[5];
-    matrix[2][0] = c[6];
-    matrix[2][1] = c[7];
-    matrix[2][2] = 1.0;
-
-    if( map )
-    {
-        for( i = 0; i < size.height; i++ )
-        {
-            CvPoint2D32f* maprow = (CvPoint2D32f*)(map->data.ptr + map->step*i);
-            for( j = 0; j < size.width; j++ )
-            {
-                double w = 1./(c[6]*j + c[7]*i + 1.);
-                double x = (c[0]*j + c[1]*i + c[2])*w;
-                double y = (c[3]*j + c[4]*i + c[5])*w;
-
-                maprow[j].x = (float)x;
-                maprow[j].y = (float)y;
-            }
-        }
-    }
-
-    __END__;
-
-    return;
-}
-
-
-/*-----------------------------------------------------------------------*/
-/* Compute projected infinite point for second image if first image point is known */
-void icvComputeeInfiniteProject1(   CvMatr64d     rotMatr,
-                                    CvMatr64d     camMatr1,
-                                    CvMatr64d     camMatr2,
-                                    CvPoint2D32f  point1,
-                                    CvPoint2D32f* point2)
-{
-    double invMatr1[9];
-    icvInvertMatrix_64d(camMatr1,3,invMatr1);
-    double P1[3];
-    double p1[3];
-    p1[0] = (double)(point1.x);
-    p1[1] = (double)(point1.y);
-    p1[2] = 1;
-
-    icvMulMatrix_64d(   invMatr1,
-                        3,3,
-                        p1,
-                        1,3,
-                        P1);
-
-    double invR[9];
-    icvTransposeMatrix_64d( rotMatr, 3, 3, invR );
-
-    /* Change system 1 to system 2 */
-    double P2[3];
-    icvMulMatrix_64d(   invR,
-                        3,3,
-                        P1,
-                        1,3,
-                        P2);
-
-    /* Now we can project this point to image 2 */
-    double projP[3];
-
-    icvMulMatrix_64d(   camMatr2,
-                        3,3,
-                        P2,
-                        1,3,
-                        projP);
-
-    point2->x = (float)(projP[0] / projP[2]);
-    point2->y = (float)(projP[1] / projP[2]);
-
-    return;
-}
-
-/*-----------------------------------------------------------------------*/
-/* Compute projected infinite point for second image if first image point is known */
-void icvComputeeInfiniteProject2(   CvMatr64d     rotMatr,
-                                    CvMatr64d     camMatr1,
-                                    CvMatr64d     camMatr2,
-                                    CvPoint2D32f*  point1,
-                                    CvPoint2D32f point2)
-{
-    double invMatr2[9];
-    icvInvertMatrix_64d(camMatr2,3,invMatr2);
-    double P2[3];
-    double p2[3];
-    p2[0] = (double)(point2.x);
-    p2[1] = (double)(point2.y);
-    p2[2] = 1;
-
-    icvMulMatrix_64d(   invMatr2,
-                        3,3,
-                        p2,
-                        1,3,
-                        P2);
-
-    /* Change system 1 to system 2 */
-
-    double P1[3];
-    icvMulMatrix_64d(   rotMatr,
-                        3,3,
-                        P2,
-                        1,3,
-                        P1);
-
-    /* Now we can project this point to image 2 */
-    double projP[3];
-
-    icvMulMatrix_64d(   camMatr1,
-                        3,3,
-                        P1,
-                        1,3,
-                        projP);
-
-    point1->x = (float)(projP[0] / projP[2]);
-    point1->y = (float)(projP[1] / projP[2]);
-
-    return;
-}
-
-/* Select best R and t for given cameras, points, ... */
-/* For both cameras */
-static int icvSelectBestRt(         int           numImages,
-                                    int*          numPoints,
-                                    CvPoint2D32f* imagePoints1,
-                                    CvPoint2D32f* imagePoints2,
-                                    CvPoint3D32f* objectPoints,
-
-                                    CvMatr32f     cameraMatrix1,
-                                    CvVect32f     distortion1,
-                                    CvMatr32f     rotMatrs1,
-                                    CvVect32f     transVects1,
-
-                                    CvMatr32f     cameraMatrix2,
-                                    CvVect32f     distortion2,
-                                    CvMatr32f     rotMatrs2,
-                                    CvVect32f     transVects2,
-
-                                    CvMatr32f     bestRotMatr,
-                                    CvVect32f     bestTransVect
-                                    )
-{
-
-    /* Need to convert input data 32 -> 64 */
-    CvPoint3D64d* objectPoints_64d;
-
-    double* rotMatrs1_64d;
-    double* rotMatrs2_64d;
-
-    double* transVects1_64d;
-    double* transVects2_64d;
-
-    double cameraMatrix1_64d[9];
-    double cameraMatrix2_64d[9];
-
-    double distortion1_64d[4];
-    double distortion2_64d[4];
-
-    /* allocate memory for 64d data */
-    int totalNum = 0;
-
-    for(int i = 0; i < numImages; i++ )
-    {
-        totalNum += numPoints[i];
-    }
-
-    objectPoints_64d = (CvPoint3D64d*)calloc(totalNum,sizeof(CvPoint3D64d));
-
-    rotMatrs1_64d    = (double*)calloc(numImages,sizeof(double)*9);
-    rotMatrs2_64d    = (double*)calloc(numImages,sizeof(double)*9);
-
-    transVects1_64d  = (double*)calloc(numImages,sizeof(double)*3);
-    transVects2_64d  = (double*)calloc(numImages,sizeof(double)*3);
-
-    /* Convert input data to 64d */
-
-    icvCvt_32f_64d((float*)objectPoints, (double*)objectPoints_64d,  totalNum*3);
-
-    icvCvt_32f_64d(rotMatrs1, rotMatrs1_64d,  numImages*9);
-    icvCvt_32f_64d(rotMatrs2, rotMatrs2_64d,  numImages*9);
-
-    icvCvt_32f_64d(transVects1, transVects1_64d,  numImages*3);
-    icvCvt_32f_64d(transVects2, transVects2_64d,  numImages*3);
-
-    /* Convert to arrays */
-    icvCvt_32f_64d(cameraMatrix1, cameraMatrix1_64d, 9);
-    icvCvt_32f_64d(cameraMatrix2, cameraMatrix2_64d, 9);
-
-    icvCvt_32f_64d(distortion1, distortion1_64d, 4);
-    icvCvt_32f_64d(distortion2, distortion2_64d, 4);
-
-
-    /* for each R and t compute error for image pair */
-    float* errors;
-
-    errors = (float*)calloc(numImages*numImages,sizeof(float));
-    if( errors == 0 )
-    {
-        return CV_OUTOFMEM_ERR;
-    }
-
-    int currImagePair;
-    int currRt;
-    for( currRt = 0; currRt < numImages; currRt++ )
-    {
-        int begPoint = 0;
-        for(currImagePair = 0; currImagePair < numImages; currImagePair++ )
-        {
-            /* For current R,t R,t compute relative position of cameras */
-
-            double convRotMatr[9];
-            double convTransVect[3];
-
-            icvCreateConvertMatrVect( rotMatrs1_64d + currRt*9,
-                                      transVects1_64d + currRt*3,
-                                      rotMatrs2_64d + currRt*9,
-                                      transVects2_64d + currRt*3,
-                                      convRotMatr,
-                                      convTransVect);
-
-            /* Project points using relative position of cameras */
-
-            double convRotMatr2[9];
-            double convTransVect2[3];
-
-            convRotMatr2[0] = 1;
-            convRotMatr2[1] = 0;
-            convRotMatr2[2] = 0;
-
-            convRotMatr2[3] = 0;
-            convRotMatr2[4] = 1;
-            convRotMatr2[5] = 0;
-
-            convRotMatr2[6] = 0;
-            convRotMatr2[7] = 0;
-            convRotMatr2[8] = 1;
-
-            convTransVect2[0] = 0;
-            convTransVect2[1] = 0;
-            convTransVect2[2] = 0;
-
-            /* Compute error for given pair and Rt */
-            /* We must project points to image and compute error */
-
-            CvPoint2D64d* projImagePoints1;
-            CvPoint2D64d* projImagePoints2;
-
-            CvPoint3D64d* points1;
-            CvPoint3D64d* points2;
-
-            int numberPnt;
-            numberPnt = numPoints[currImagePair];
-            projImagePoints1 = (CvPoint2D64d*)calloc(numberPnt,sizeof(CvPoint2D64d));
-            projImagePoints2 = (CvPoint2D64d*)calloc(numberPnt,sizeof(CvPoint2D64d));
-
-            points1 = (CvPoint3D64d*)calloc(numberPnt,sizeof(CvPoint3D64d));
-            points2 = (CvPoint3D64d*)calloc(numberPnt,sizeof(CvPoint3D64d));
-
-            /* Transform object points to first camera position */
-            for(int i = 0; i < numberPnt; i++ )
-            {
-                /* Create second camera point */
-                CvPoint3D64d tmpPoint;
-                tmpPoint.x = (double)(objectPoints[i].x);
-                tmpPoint.y = (double)(objectPoints[i].y);
-                tmpPoint.z = (double)(objectPoints[i].z);
-
-                icvConvertPointSystem(  tmpPoint,
-                                        points2+i,
-                                        rotMatrs2_64d + currImagePair*9,
-                                        transVects2_64d + currImagePair*3);
-
-                /* Create first camera point using R, t */
-                icvConvertPointSystem(  points2[i],
-                                        points1+i,
-                                        convRotMatr,
-                                        convTransVect);
-
-                CvPoint3D64d tmpPoint2 = { 0, 0, 0 };
-                icvConvertPointSystem(  tmpPoint,
-                                        &tmpPoint2,
-                                        rotMatrs1_64d + currImagePair*9,
-                                        transVects1_64d + currImagePair*3);
-                /*double err;
-                double dx,dy,dz;
-                dx = tmpPoint2.x - points1[i].x;
-                dy = tmpPoint2.y - points1[i].y;
-                dz = tmpPoint2.z - points1[i].z;
-                err = sqrt(dx*dx + dy*dy + dz*dz);*/
-            }
-
-#if 0
-            cvProjectPointsSimple(  numPoints[currImagePair],
-                                    objectPoints_64d + begPoint,
-                                    rotMatrs1_64d + currRt*9,
-                                    transVects1_64d + currRt*3,
-                                    cameraMatrix1_64d,
-                                    distortion1_64d,
-                                    projImagePoints1);
-
-            cvProjectPointsSimple(  numPoints[currImagePair],
-                                    objectPoints_64d + begPoint,
-                                    rotMatrs2_64d + currRt*9,
-                                    transVects2_64d + currRt*3,
-                                    cameraMatrix2_64d,
-                                    distortion2_64d,
-                                    projImagePoints2);
-#endif
-
-            /* Project with no translate and no rotation */
-
-#if 0
-            {
-                double nodist[4] = {0,0,0,0};
-                cvProjectPointsSimple(  numPoints[currImagePair],
-                                        points1,
-                                        convRotMatr2,
-                                        convTransVect2,
-                                        cameraMatrix1_64d,
-                                        nodist,
-                                        projImagePoints1);
-
-                cvProjectPointsSimple(  numPoints[currImagePair],
-                                        points2,
-                                        convRotMatr2,
-                                        convTransVect2,
-                                        cameraMatrix2_64d,
-                                        nodist,
-                                        projImagePoints2);
-
-            }
-#endif
-
-            cvProjectPointsSimple(  numPoints[currImagePair],
-                                    points1,
-                                    convRotMatr2,
-                                    convTransVect2,
-                                    cameraMatrix1_64d,
-                                    distortion1_64d,
-                                    projImagePoints1);
-
-            cvProjectPointsSimple(  numPoints[currImagePair],
-                                    points2,
-                                    convRotMatr2,
-                                    convTransVect2,
-                                    cameraMatrix2_64d,
-                                    distortion2_64d,
-                                    projImagePoints2);
-
-            /* points are projected. Compute error */
-
-            int currPoint;
-            double err1 = 0;
-            double err2 = 0;
-            double err;
-            for( currPoint = 0; currPoint < numberPnt; currPoint++ )
-            {
-                double len1,len2;
-                double dx1,dy1;
-                dx1 = imagePoints1[begPoint+currPoint].x - projImagePoints1[currPoint].x;
-                dy1 = imagePoints1[begPoint+currPoint].y - projImagePoints1[currPoint].y;
-                len1 = sqrt(dx1*dx1 + dy1*dy1);
-                err1 += len1;
-
-                double dx2,dy2;
-                dx2 = imagePoints2[begPoint+currPoint].x - projImagePoints2[currPoint].x;
-                dy2 = imagePoints2[begPoint+currPoint].y - projImagePoints2[currPoint].y;
-                len2 = sqrt(dx2*dx2 + dy2*dy2);
-                err2 += len2;
-            }
-
-            err1 /= (float)(numberPnt);
-            err2 /= (float)(numberPnt);
-
-            err = (err1+err2) * 0.5;
-            begPoint += numberPnt;
-
-            /* Set this error to */
-            errors[numImages*currImagePair+currRt] = (float)err;
-
-            free(points1);
-            free(points2);
-            free(projImagePoints1);
-            free(projImagePoints2);
-        }
-    }
-
-    /* Just select R and t with minimal average error */
-
-    int bestnumRt = 0;
-    float minError = 0;/* Just for no warnings. Uses 'first' flag. */
-    int first = 1;
-    for( currRt = 0; currRt < numImages; currRt++ )
-    {
-        float avErr = 0;
-        for(currImagePair = 0; currImagePair < numImages; currImagePair++ )
-        {
-            avErr += errors[numImages*currImagePair+currRt];
-        }
-        avErr /= (float)(numImages);
-
-        if( first )
-        {
-            bestnumRt = 0;
-            minError = avErr;
-            first = 0;
-        }
-        else
-        {
-            if( avErr < minError )
-            {
-                bestnumRt = currRt;
-                minError = avErr;
-            }
-        }
-
-    }
-
-    double bestRotMatr_64d[9];
-    double bestTransVect_64d[3];
-
-    icvCreateConvertMatrVect( rotMatrs1_64d + bestnumRt * 9,
-                              transVects1_64d + bestnumRt * 3,
-                              rotMatrs2_64d + bestnumRt * 9,
-                              transVects2_64d + bestnumRt * 3,
-                              bestRotMatr_64d,
-                              bestTransVect_64d);
-
-    icvCvt_64d_32f(bestRotMatr_64d,bestRotMatr,9);
-    icvCvt_64d_32f(bestTransVect_64d,bestTransVect,3);
-
-
-    free(errors);
-
-    return CV_OK;
-}
-
-
-/* ----------------- Stereo calibration functions --------------------- */
-
-float icvDefinePointPosition(CvPoint2D32f point1,CvPoint2D32f point2,CvPoint2D32f point)
-{
-    float ax = point2.x - point1.x;
-    float ay = point2.y - point1.y;
-
-    float bx = point.x - point1.x;
-    float by = point.y - point1.y;
-
-    return (ax*by - ay*bx);
-}
-
-/* Convert function for stereo warping */
-int icvConvertWarpCoordinates(double coeffs[3][3],
-                                CvPoint2D32f* cameraPoint,
-                                CvPoint2D32f* warpPoint,
-                                int direction)
-{
-    double x,y;
-    double det;
-    if( direction == CV_WARP_TO_CAMERA )
-    {/* convert from camera image to warped image coordinates */
-        x = warpPoint->x;
-        y = warpPoint->y;
-
-        det = (coeffs[2][0] * x + coeffs[2][1] * y + coeffs[2][2]);
-        if( fabs(det) > 1e-8 )
-        {
-            cameraPoint->x = (float)((coeffs[0][0] * x + coeffs[0][1] * y + coeffs[0][2]) / det);
-            cameraPoint->y = (float)((coeffs[1][0] * x + coeffs[1][1] * y + coeffs[1][2]) / det);
-            return CV_OK;
-        }
-    }
-    else if( direction == CV_CAMERA_TO_WARP )
-    {/* convert from warped image to camera image coordinates */
-        x = cameraPoint->x;
-        y = cameraPoint->y;
-
-        det = (coeffs[2][0]*x-coeffs[0][0])*(coeffs[2][1]*y-coeffs[1][1])-(coeffs[2][1]*x-coeffs[0][1])*(coeffs[2][0]*y-coeffs[1][0]);
-
-        if( fabs(det) > 1e-8 )
-        {
-            warpPoint->x = (float)(((coeffs[0][2]-coeffs[2][2]*x)*(coeffs[2][1]*y-coeffs[1][1])-(coeffs[2][1]*x-coeffs[0][1])*(coeffs[1][2]-coeffs[2][2]*y))/det);
-            warpPoint->y = (float)(((coeffs[2][0]*x-coeffs[0][0])*(coeffs[1][2]-coeffs[2][2]*y)-(coeffs[0][2]-coeffs[2][2]*x)*(coeffs[2][0]*y-coeffs[1][0]))/det);
-            return CV_OK;
-        }
-    }
-
-    return CV_BADFACTOR_ERR;
-}
-
-/* Compute stereo params using some camera params */
-/* by Valery Mosyagin. int ComputeRestStereoParams(StereoParams *stereoparams) */
-int icvComputeRestStereoParams(CvStereoCamera *stereoparams)
-{
-
-
-    icvGetQuadsTransformStruct(stereoparams);
-
-    cvInitPerspectiveTransform( stereoparams->warpSize,
-                                stereoparams->quad[0],
-                                stereoparams->coeffs[0],
-                                0);
-
-    cvInitPerspectiveTransform( stereoparams->warpSize,
-                                stereoparams->quad[1],
-                                stereoparams->coeffs[1],
-                                0);
-
-    /* Create border for warped images */
-    CvPoint2D32f corns[4];
-    corns[0].x = 0;
-    corns[0].y = 0;
-
-    corns[1].x = (float)(stereoparams->camera[0]->imgSize[0]-1);
-    corns[1].y = 0;
-
-    corns[2].x = (float)(stereoparams->camera[0]->imgSize[0]-1);
-    corns[2].y = (float)(stereoparams->camera[0]->imgSize[1]-1);
-
-    corns[3].x = 0;
-    corns[3].y = (float)(stereoparams->camera[0]->imgSize[1]-1);
-
-    for(int i = 0; i < 4; i++ )
-    {
-        /* For first camera */
-        icvConvertWarpCoordinates( stereoparams->coeffs[0],
-                                corns+i,
-                                stereoparams->border[0]+i,
-                                CV_CAMERA_TO_WARP);
-
-        /* For second camera */
-        icvConvertWarpCoordinates( stereoparams->coeffs[1],
-                                corns+i,
-                                stereoparams->border[1]+i,
-                                CV_CAMERA_TO_WARP);
-    }
-
-    /* Test compute  */
-    {
-        CvPoint2D32f warpPoints[4];
-        warpPoints[0] = cvPoint2D32f(0,0);
-        warpPoints[1] = cvPoint2D32f(stereoparams->warpSize.width-1,0);
-        warpPoints[2] = cvPoint2D32f(stereoparams->warpSize.width-1,stereoparams->warpSize.height-1);
-        warpPoints[3] = cvPoint2D32f(0,stereoparams->warpSize.height-1);
-
-        CvPoint2D32f camPoints1[4];
-        CvPoint2D32f camPoints2[4];
-
-        for( int i = 0; i < 4; i++ )
-        {
-            icvConvertWarpCoordinates(stereoparams->coeffs[0],
-                                camPoints1+i,
-                                warpPoints+i,
-                                CV_WARP_TO_CAMERA);
-
-            icvConvertWarpCoordinates(stereoparams->coeffs[1],
-                                camPoints2+i,
-                                warpPoints+i,
-                                CV_WARP_TO_CAMERA);
-        }
-    }
-
-
-    /* Allocate memory for scanlines coeffs */
-
-    stereoparams->lineCoeffs = (CvStereoLineCoeff*)calloc(stereoparams->warpSize.height,sizeof(CvStereoLineCoeff));
-
-    /* Compute coeffs for epilines  */
-
-    icvComputeCoeffForStereo( stereoparams);
-
-    /* all coeffs are known */
-    return CV_OK;
-}
-
-/*-------------------------------------------------------------------------------------------*/
-
-int icvStereoCalibration( int numImages,
-                            int* nums,
-                            CvSize imageSize,
-                            CvPoint2D32f* imagePoints1,
-                            CvPoint2D32f* imagePoints2,
-                            CvPoint3D32f* objectPoints,
-                            CvStereoCamera* stereoparams
-                           )
-{
-    /* Firstly we must calibrate both cameras */
-    /*  Alocate memory for data */
-    /* Allocate for translate vectors */
-    float* transVects1;
-    float* transVects2;
-    float* rotMatrs1;
-    float* rotMatrs2;
-
-    transVects1 = (float*)calloc(numImages,sizeof(float)*3);
-    transVects2 = (float*)calloc(numImages,sizeof(float)*3);
-
-    rotMatrs1   = (float*)calloc(numImages,sizeof(float)*9);
-    rotMatrs2   = (float*)calloc(numImages,sizeof(float)*9);
-
-    /* Calibrate first camera */
-    cvCalibrateCamera(  numImages,
-                        nums,
-                        imageSize,
-                        imagePoints1,
-                        objectPoints,
-                        stereoparams->camera[0]->distortion,
-                        stereoparams->camera[0]->matrix,
-                        transVects1,
-                        rotMatrs1,
-                        1);
-
-    /* Calibrate second camera */
-    cvCalibrateCamera(  numImages,
-                        nums,
-                        imageSize,
-                        imagePoints2,
-                        objectPoints,
-                        stereoparams->camera[1]->distortion,
-                        stereoparams->camera[1]->matrix,
-                        transVects2,
-                        rotMatrs2,
-                        1);
-
-    /* Cameras are calibrated */
-
-    stereoparams->camera[0]->imgSize[0] = (float)imageSize.width;
-    stereoparams->camera[0]->imgSize[1] = (float)imageSize.height;
-
-    stereoparams->camera[1]->imgSize[0] = (float)imageSize.width;
-    stereoparams->camera[1]->imgSize[1] = (float)imageSize.height;
-
-    icvSelectBestRt(    numImages,
-                        nums,
-                        imagePoints1,
-                        imagePoints2,
-                        objectPoints,
-                        stereoparams->camera[0]->matrix,
-                        stereoparams->camera[0]->distortion,
-                        rotMatrs1,
-                        transVects1,
-                        stereoparams->camera[1]->matrix,
-                        stereoparams->camera[1]->distortion,
-                        rotMatrs2,
-                        transVects2,
-                        stereoparams->rotMatrix,
-                        stereoparams->transVector
-                        );
-
-    /* Free memory */
-    free(transVects1);
-    free(transVects2);
-    free(rotMatrs1);
-    free(rotMatrs2);
-
-    icvComputeRestStereoParams(stereoparams);
-
-    return CV_NO_ERR;
-}
-
-#if 0
-/* Find line from epipole */
-static void FindLine(CvPoint2D32f epipole,CvSize imageSize,CvPoint2D32f point,CvPoint2D32f *start,CvPoint2D32f *end)
-{
-    CvPoint2D32f frameBeg;
-    CvPoint2D32f frameEnd;
-    CvPoint2D32f cross[4];
-    int     haveCross[4];
-    float   dist;
-
-    haveCross[0] = 0;
-    haveCross[1] = 0;
-    haveCross[2] = 0;
-    haveCross[3] = 0;
-
-    frameBeg.x = 0;
-    frameBeg.y = 0;
-    frameEnd.x = (float)(imageSize.width);
-    frameEnd.y = 0;
-    haveCross[0] = icvGetCrossPieceVector(frameBeg,frameEnd,epipole,point,&cross[0]);
-
-    frameBeg.x = (float)(imageSize.width);
-    frameBeg.y = 0;
-    frameEnd.x = (float)(imageSize.width);
-    frameEnd.y = (float)(imageSize.height);
-    haveCross[1] = icvGetCrossPieceVector(frameBeg,frameEnd,epipole,point,&cross[1]);
-
-    frameBeg.x = (float)(imageSize.width);
-    frameBeg.y = (float)(imageSize.height);
-    frameEnd.x = 0;
-    frameEnd.y = (float)(imageSize.height);
-    haveCross[2] = icvGetCrossPieceVector(frameBeg,frameEnd,epipole,point,&cross[2]);
-
-    frameBeg.x = 0;
-    frameBeg.y = (float)(imageSize.height);
-    frameEnd.x = 0;
-    frameEnd.y = 0;
-    haveCross[3] = icvGetCrossPieceVector(frameBeg,frameEnd,epipole,point,&cross[3]);
-
-    int n;
-    float minDist = (float)(INT_MAX);
-    float maxDist = (float)(INT_MIN);
-
-    int maxN = -1;
-    int minN = -1;
-
-    for( n = 0; n < 4; n++ )
-    {
-        if( haveCross[n] > 0 )
-        {
-            dist =  (epipole.x - cross[n].x)*(epipole.x - cross[n].x) +
-                    (epipole.y - cross[n].y)*(epipole.y - cross[n].y);
-
-            if( dist < minDist )
-            {
-                minDist = dist;
-                minN = n;
-            }
-
-            if( dist > maxDist )
-            {
-                maxDist = dist;
-                maxN = n;
-            }
-        }
-    }
-
-    if( minN >= 0 && maxN >= 0 && (minN != maxN) )
-    {
-        *start = cross[minN];
-        *end   = cross[maxN];
-    }
-    else
-    {
-        start->x = 0;
-        start->y = 0;
-        end->x = 0;
-        end->y = 0;
-    }
-
-    return;
-}
-
-/* Find line which cross frame by line(a,b,c) */
-static void FindLineForEpiline(CvSize imageSize,float a,float b,float c,CvPoint2D32f *start,CvPoint2D32f *end)
-{
-    CvPoint2D32f frameBeg;
-    CvPoint2D32f frameEnd;
-    CvPoint2D32f cross[4];
-    int     haveCross[4];
-    float   dist;
-
-    haveCross[0] = 0;
-    haveCross[1] = 0;
-    haveCross[2] = 0;
-    haveCross[3] = 0;
-
-    frameBeg.x = 0;
-    frameBeg.y = 0;
-    frameEnd.x = (float)(imageSize.width);
-    frameEnd.y = 0;
-    haveCross[0] = icvGetCrossLineDirect(frameBeg,frameEnd,a,b,c,&cross[0]);
-
-    frameBeg.x = (float)(imageSize.width);
-    frameBeg.y = 0;
-    frameEnd.x = (float)(imageSize.width);
-    frameEnd.y = (float)(imageSize.height);
-    haveCross[1] = icvGetCrossLineDirect(frameBeg,frameEnd,a,b,c,&cross[1]);
-
-    frameBeg.x = (float)(imageSize.width);
-    frameBeg.y = (float)(imageSize.height);
-    frameEnd.x = 0;
-    frameEnd.y = (float)(imageSize.height);
-    haveCross[2] = icvGetCrossLineDirect(frameBeg,frameEnd,a,b,c,&cross[2]);
-
-    frameBeg.x = 0;
-    frameBeg.y = (float)(imageSize.height);
-    frameEnd.x = 0;
-    frameEnd.y = 0;
-    haveCross[3] = icvGetCrossLineDirect(frameBeg,frameEnd,a,b,c,&cross[3]);
-
-    int n;
-    float minDist = (float)(INT_MAX);
-    float maxDist = (float)(INT_MIN);
-
-    int maxN = -1;
-    int minN = -1;
-
-    double midPointX = imageSize.width  / 2.0;
-    double midPointY = imageSize.height / 2.0;
-
-    for( n = 0; n < 4; n++ )
-    {
-        if( haveCross[n] > 0 )
-        {
-            dist =  (float)((midPointX - cross[n].x)*(midPointX - cross[n].x) +
-                            (midPointY - cross[n].y)*(midPointY - cross[n].y));
-
-            if( dist < minDist )
-            {
-                minDist = dist;
-                minN = n;
-            }
-
-            if( dist > maxDist )
-            {
-                maxDist = dist;
-                maxN = n;
-            }
-        }
-    }
-
-    if( minN >= 0 && maxN >= 0 && (minN != maxN) )
-    {
-        *start = cross[minN];
-        *end   = cross[maxN];
-    }
-    else
-    {
-        start->x = 0;
-        start->y = 0;
-        end->x = 0;
-        end->y = 0;
-    }
-
-    return;
-
-}
-
-/* Cross lines */
-static int GetCrossLines(CvPoint2D32f p1_start,CvPoint2D32f p1_end,CvPoint2D32f p2_start,CvPoint2D32f p2_end,CvPoint2D32f *cross)
-{
-    double ex1,ey1,ex2,ey2;
-    double px1,py1,px2,py2;
-    double del;
-    double delA,delB,delX,delY;
-    double alpha,betta;
-
-    ex1 = p1_start.x;
-    ey1 = p1_start.y;
-    ex2 = p1_end.x;
-    ey2 = p1_end.y;
-
-    px1 = p2_start.x;
-    py1 = p2_start.y;
-    px2 = p2_end.x;
-    py2 = p2_end.y;
-
-    del = (ex1-ex2)*(py2-py1)+(ey2-ey1)*(px2-px1);
-    if( del == 0)
-    {
-        return -1;
-    }
-
-    delA =  (px1-ex1)*(py1-py2) + (ey1-py1)*(px1-px2);
-    delB =  (ex1-px1)*(ey1-ey2) + (py1-ey1)*(ex1-ex2);
-
-    alpha =  delA / del;
-    betta = -delB / del;
-
-    if( alpha < 0 || alpha > 1.0 || betta < 0 || betta > 1.0)
-    {
-        return -1;
-    }
-
-    delX =  (ex1-ex2)*(py1*(px1-px2)-px1*(py1-py2))+
-            (px1-px2)*(ex1*(ey1-ey2)-ey1*(ex1-ex2));
-
-    delY =  (ey1-ey2)*(px1*(py1-py2)-py1*(px1-px2))+
-            (py1-py2)*(ey1*(ex1-ex2)-ex1*(ey1-ey2));
-
-    cross->x = (float)( delX / del);
-    cross->y = (float)(-delY / del);
-    return 1;
-}
-#endif
-
-int icvGetCrossPieceVector(CvPoint2D32f p1_start,CvPoint2D32f p1_end,CvPoint2D32f v2_start,CvPoint2D32f v2_end,CvPoint2D32f *cross)
-{
-    double ex1 = p1_start.x;
-    double ey1 = p1_start.y;
-    double ex2 = p1_end.x;
-    double ey2 = p1_end.y;
-
-    double px1 = v2_start.x;
-    double py1 = v2_start.y;
-    double px2 = v2_end.x;
-    double py2 = v2_end.y;
-
-    double del = (ex1-ex2)*(py2-py1)+(ey2-ey1)*(px2-px1);
-    if( del == 0)
-    {
-        return -1;
-    }
-
-    double delA =  (px1-ex1)*(py1-py2) + (ey1-py1)*(px1-px2);
-    //double delB =  (ex1-px1)*(ey1-ey2) + (py1-ey1)*(ex1-ex2);
-
-    double alpha =  delA / del;
-    //double betta = -delB / del;
-
-    if( alpha < 0 || alpha > 1.0 )
-    {
-        return -1;
-    }
-
-    double delX =  (ex1-ex2)*(py1*(px1-px2)-px1*(py1-py2))+
-            (px1-px2)*(ex1*(ey1-ey2)-ey1*(ex1-ex2));
-
-    double delY =  (ey1-ey2)*(px1*(py1-py2)-py1*(px1-px2))+
-            (py1-py2)*(ey1*(ex1-ex2)-ex1*(ey1-ey2));
-
-    cross->x = (float)( delX / del);
-    cross->y = (float)(-delY / del);
-    return 1;
-}
-
-
-int icvGetCrossLineDirect(CvPoint2D32f p1,CvPoint2D32f p2,float a,float b,float c,CvPoint2D32f* cross)
-{
-    double del;
-    double delX,delY,delA;
-
-    double px1,px2,py1,py2;
-    double X,Y,alpha;
-
-    px1 = p1.x;
-    py1 = p1.y;
-
-    px2 = p2.x;
-    py2 = p2.y;
-
-    del = a * (px2 - px1) + b * (py2-py1);
-    if( del == 0 )
-    {
-        return -1;
-    }
-
-    delA = - c - a*px1 - b*py1;
-    alpha = delA / del;
-
-    if( alpha < 0 || alpha > 1.0 )
-    {
-        return -1;/* no cross */
-    }
-
-    delX = b * (py1*(px1-px2) - px1*(py1-py2)) + c * (px1-px2);
-    delY = a * (px1*(py1-py2) - py1*(px1-px2)) + c * (py1-py2);
-
-    X = delX / del;
-    Y = delY / del;
-
-    cross->x = (float)X;
-    cross->y = (float)Y;
-
-    return 1;
-}
-
-#if 0
-static int cvComputeEpipoles( CvMatr32f camMatr1,  CvMatr32f camMatr2,
-                            CvMatr32f rotMatr1,  CvMatr32f rotMatr2,
-                            CvVect32f transVect1,CvVect32f transVect2,
-                            CvVect32f epipole1,
-                            CvVect32f epipole2)
-{
-
-    /* Copy matrix */
-
-    CvMat ccamMatr1 = cvMat(3,3,CV_MAT32F,camMatr1);
-    CvMat ccamMatr2 = cvMat(3,3,CV_MAT32F,camMatr2);
-    CvMat crotMatr1 = cvMat(3,3,CV_MAT32F,rotMatr1);
-    CvMat crotMatr2 = cvMat(3,3,CV_MAT32F,rotMatr2);
-    CvMat ctransVect1 = cvMat(3,1,CV_MAT32F,transVect1);
-    CvMat ctransVect2 = cvMat(3,1,CV_MAT32F,transVect2);
-    CvMat cepipole1 = cvMat(3,1,CV_MAT32F,epipole1);
-    CvMat cepipole2 = cvMat(3,1,CV_MAT32F,epipole2);
-
-
-    CvMat cmatrP1   = cvMat(3,3,CV_MAT32F,0); cvmAlloc(&cmatrP1);
-    CvMat cmatrP2   = cvMat(3,3,CV_MAT32F,0); cvmAlloc(&cmatrP2);
-    CvMat cvectp1   = cvMat(3,1,CV_MAT32F,0); cvmAlloc(&cvectp1);
-    CvMat cvectp2   = cvMat(3,1,CV_MAT32F,0); cvmAlloc(&cvectp2);
-    CvMat ctmpF1    = cvMat(3,1,CV_MAT32F,0); cvmAlloc(&ctmpF1);
-    CvMat ctmpM1    = cvMat(3,3,CV_MAT32F,0); cvmAlloc(&ctmpM1);
-    CvMat ctmpM2    = cvMat(3,3,CV_MAT32F,0); cvmAlloc(&ctmpM2);
-    CvMat cinvP1    = cvMat(3,3,CV_MAT32F,0); cvmAlloc(&cinvP1);
-    CvMat cinvP2    = cvMat(3,3,CV_MAT32F,0); cvmAlloc(&cinvP2);
-    CvMat ctmpMatr  = cvMat(3,3,CV_MAT32F,0); cvmAlloc(&ctmpMatr);
-    CvMat ctmpVect1 = cvMat(3,1,CV_MAT32F,0); cvmAlloc(&ctmpVect1);
-    CvMat ctmpVect2 = cvMat(3,1,CV_MAT32F,0); cvmAlloc(&ctmpVect2);
-    CvMat cmatrF1   = cvMat(3,3,CV_MAT32F,0); cvmAlloc(&cmatrF1);
-    CvMat ctmpF     = cvMat(3,3,CV_MAT32F,0); cvmAlloc(&ctmpF);
-    CvMat ctmpE1    = cvMat(3,1,CV_MAT32F,0); cvmAlloc(&ctmpE1);
-    CvMat ctmpE2    = cvMat(3,1,CV_MAT32F,0); cvmAlloc(&ctmpE2);
-
-    /* Compute first */
-    cvmMul( &ccamMatr1, &crotMatr1, &cmatrP1);
-    cvmInvert( &cmatrP1,&cinvP1 );
-    cvmMul( &ccamMatr1, &ctransVect1, &cvectp1 );
-
-    /* Compute second */
-    cvmMul( &ccamMatr2, &crotMatr2, &cmatrP2 );
-    cvmInvert( &cmatrP2,&cinvP2 );
-    cvmMul( &ccamMatr2, &ctransVect2, &cvectp2 );
-
-    cvmMul( &cmatrP1, &cinvP2, &ctmpM1);
-    cvmMul( &ctmpM1, &cvectp2, &ctmpVect1);
-    cvmSub( &cvectp1,&ctmpVect1,&ctmpE1);
-
-    cvmMul( &cmatrP2, &cinvP1, &ctmpM2);
-    cvmMul( &ctmpM2, &cvectp1, &ctmpVect2);
-    cvmSub( &cvectp2, &ctmpVect2, &ctmpE2);
-
-
-    /* Need scale */
-
-    cvmScale(&ctmpE1,&cepipole1,1.0);
-    cvmScale(&ctmpE2,&cepipole2,1.0);
-
-    cvmFree(&cmatrP1);
-    cvmFree(&cmatrP1);
-    cvmFree(&cvectp1);
-    cvmFree(&cvectp2);
-    cvmFree(&ctmpF1);
-    cvmFree(&ctmpM1);
-    cvmFree(&ctmpM2);
-    cvmFree(&cinvP1);
-    cvmFree(&cinvP2);
-    cvmFree(&ctmpMatr);
-    cvmFree(&ctmpVect1);
-    cvmFree(&ctmpVect2);
-    cvmFree(&cmatrF1);
-    cvmFree(&ctmpF);
-    cvmFree(&ctmpE1);
-    cvmFree(&ctmpE2);
-
-    return CV_NO_ERR;
-}/* cvComputeEpipoles */
-#endif
-
-/* Compute epipoles for fundamental matrix */
-int cvComputeEpipolesFromFundMatrix(CvMatr32f fundMatr,
-                                         CvPoint3D32f* epipole1,
-                                         CvPoint3D32f* epipole2)
-{
-    /* Decompose fundamental matrix using SVD ( A = U W V') */
-    CvMat fundMatrC = cvMat(3,3,CV_MAT32F,fundMatr);
-
-    CvMat* matrW = cvCreateMat(3,3,CV_MAT32F);
-    CvMat* matrU = cvCreateMat(3,3,CV_MAT32F);
-    CvMat* matrV = cvCreateMat(3,3,CV_MAT32F);
-
-    /* From svd we need just last vector of U and V or last row from U' and V' */
-    /* We get transposed matrices U and V */
-    cvSVD(&fundMatrC,matrW,matrU,matrV,CV_SVD_V_T|CV_SVD_U_T);
-
-    /* Get last row from U' and compute epipole1 */
-    epipole1->x = matrU->data.fl[6];
-    epipole1->y = matrU->data.fl[7];
-    epipole1->z = matrU->data.fl[8];
-
-    /* Get last row from V' and compute epipole2 */
-    epipole2->x = matrV->data.fl[6];
-    epipole2->y = matrV->data.fl[7];
-    epipole2->z = matrV->data.fl[8];
-
-    cvReleaseMat(&matrW);
-    cvReleaseMat(&matrU);
-    cvReleaseMat(&matrV);
-    return CV_OK;
-}
-
-int cvConvertEssential2Fundamental( CvMatr32f essMatr,
-                                         CvMatr32f fundMatr,
-                                         CvMatr32f cameraMatr1,
-                                         CvMatr32f cameraMatr2)
-{/* Fund = inv(CM1') * Ess * inv(CM2) */
-
-    CvMat essMatrC     = cvMat(3,3,CV_MAT32F,essMatr);
-    CvMat fundMatrC    = cvMat(3,3,CV_MAT32F,fundMatr);
-    CvMat cameraMatr1C = cvMat(3,3,CV_MAT32F,cameraMatr1);
-    CvMat cameraMatr2C = cvMat(3,3,CV_MAT32F,cameraMatr2);
-
-    CvMat* invCM2  = cvCreateMat(3,3,CV_MAT32F);
-    CvMat* tmpMatr = cvCreateMat(3,3,CV_MAT32F);
-    CvMat* invCM1T = cvCreateMat(3,3,CV_MAT32F);
-
-    cvTranspose(&cameraMatr1C,tmpMatr);
-    cvInvert(tmpMatr,invCM1T);
-    cvmMul(invCM1T,&essMatrC,tmpMatr);
-    cvInvert(&cameraMatr2C,invCM2);
-    cvmMul(tmpMatr,invCM2,&fundMatrC);
-
-    /* Scale fundamental matrix */
-    double scale;
-    scale = 1.0/fundMatrC.data.fl[8];
-    cvConvertScale(&fundMatrC,&fundMatrC,scale);
-
-    cvReleaseMat(&invCM2);
-    cvReleaseMat(&tmpMatr);
-    cvReleaseMat(&invCM1T);
-
-    return CV_OK;
-}
-
-/* Compute essential matrix */
-
-int cvComputeEssentialMatrix(  CvMatr32f rotMatr,
-                                    CvMatr32f transVect,
-                                    CvMatr32f essMatr)
-{
-    float transMatr[9];
-
-    /* Make antisymmetric matrix from transpose vector */
-    transMatr[0] =   0;
-    transMatr[1] = - transVect[2];
-    transMatr[2] =   transVect[1];
-
-    transMatr[3] =   transVect[2];
-    transMatr[4] =   0;
-    transMatr[5] = - transVect[0];
-
-    transMatr[6] = - transVect[1];
-    transMatr[7] =   transVect[0];
-    transMatr[8] =   0;
-
-    icvMulMatrix_32f(transMatr,3,3,rotMatr,3,3,essMatr);
-
-    return CV_OK;
-}
diff --git a/modules/legacy/src/extendededges.cpp b/modules/legacy/src/extendededges.cpp
deleted file mode 100644 (file)
index aa2488f..0000000
+++ /dev/null
@@ -1,265 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#if 0
-//#ifdef WIN32 /* make sure it builds under Linux whenever it is included into Makefile.am or not. */
-
-//void icvCutContour( CvSeq* current, IplImage* image );
-CvSeq* icvCutContourRaster( CvSeq* current, CvMemStorage* storage, IplImage* image );
-
-
-//create lists of segments of all contours from image
-CvSeq* cvExtractSingleEdges( IplImage* image, //bw image - it's content will be destroyed by cvFindContours
-                             CvMemStorage* storage )
-{
-    CvMemStorage* tmp_storage = cvCreateChildMemStorage( storage );
-    CvSeq* contours = 0;
-    cvFindContours( image, tmp_storage, &contours, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_NONE );
-    cvZero( image );
-
-    //iterate through contours
-      //iterate through tree
-    CvSeq* current = contours;
-    int number = 0;
-    int level = 1;
-
-    CvSeq* output = 0;
-    CvSeq* tail_seq = 0;
-
-    //actually this loop can iterates through tree,
-    //but still we use CV_RETR_LIST it is not useful
-    while( current )
-    {
-        number++;
-
-        //get vertical list of segments for one contour
-        CvSeq* new_seq = icvCutContourRaster( current, storage,  image );
-
-        //add this vertical list to horisontal list
-        if( new_seq )
-        {
-            if( tail_seq )
-            {
-                tail_seq->h_next = new_seq;
-                new_seq->h_prev = tail_seq;
-                tail_seq = new_seq;
-            }
-            else
-            {
-                output = tail_seq = new_seq;
-            }
-        }
-
-        //iteration through tree
-        if( current->v_next )
-        {
-            //goto child
-            current = current->v_next;
-            level++;
-        }
-        else
-        {
-            //go parent
-            while( !current->h_next )
-            {
-                current = current->v_prev;
-                level--;
-                if( !level ) break;
-            }
-
-            if( current ) //go brother
-                current = current->h_next;
-        }
-    }
-
-    //free temporary memstorage with initial contours
-    cvReleaseMemStorage( &tmp_storage );
-
-    return output;
-}
-
-//makes vertical list of segments for 1 contour
-CvSeq* icvCutContourRaster( CvSeq* current, CvMemStorage* storage, IplImage* image /*tmp image*/)
-{
-    //iplSet(image, 0 ); // this can cause double edges if two contours have common edge
-                       // for example if object is circle with 1 pixel width
-                       // to remove such problem - remove this iplSet
-
-    //approx contour by single edges
-    CvSeqReader reader;
-    CvSeqWriter writer;
-
-    int writing = 0;
-    cvStartReadSeq( current, &reader, 0 );
-    //below line just to avoid warning
-    cvStartWriteSeq( current->flags, sizeof(CvContour), sizeof(CvPoint), storage, &writer );
-
-    CvSeq* output = 0;
-    CvSeq* tail = 0;
-
-    //first pass through contour - compute number of branches at every point
-    int i;
-    for( i = 0; i < current->total; i++ )
-    {
-        CvPoint cur;
-
-        CV_READ_SEQ_ELEM( cur, reader );
-
-        //mark point
-        ((uchar*)image->imageData)[image->widthStep * cur.y + cur.x]++;
-        assert( ((uchar*)image->imageData)[image->widthStep * cur.y + cur.x] != 255 );
-
-    }
-
-    //second pass - create separate edges
-    for( i = 0; i < current->total; i++ )
-    {
-        CvPoint cur;
-
-        CV_READ_SEQ_ELEM( cur, reader );
-
-        //get pixel at this point
-        uchar flag = image->imageData[image->widthStep * cur.y + cur.x];
-        if( flag != 255 && flag < 3) //
-        {
-            if(!writing)
-            {
-                cvStartWriteSeq( current->flags, sizeof(CvContour), sizeof(CvPoint), storage, &writer );
-                writing = 1 ;
-            }
-
-            //mark point
-            if( flag < 3 ) ((uchar*)image->imageData)[image->widthStep * cur.y + cur.x] = 255;
-            //add it to another seq
-            CV_WRITE_SEQ_ELEM( cur, writer );
-
-        }
-        else
-        {
-            //exclude this point from contour
-           if( writing )
-           {
-               CvSeq* newseq = cvEndWriteSeq( &writer );
-               writing = 0;
-
-               if( tail )
-               {
-                   tail->v_next = newseq;
-                   newseq->v_prev = tail;
-                   tail = newseq;
-               }
-               else
-               {
-                   output = tail = newseq;
-               }
-           }
-        }
-    }
-
-
-   if( writing ) //if were not self intersections
-   {
-       CvSeq* newseq = cvEndWriteSeq( &writer );
-       writing = 0;
-
-       if( tail )
-       {
-           tail->v_next = newseq;
-           newseq->v_prev = tail;
-           tail = newseq;
-       }
-       else
-       {
-           output = tail = newseq;
-       }
-   }
-
-
-    return output;
-
-}
-
-
-/*void icvCutContour( CvSeq* current, IplImage* image )
-{
-    //approx contour by single edges
-    CvSeqReader reader;
-    CvSeqReader rev_reader;
-
-    cvStartReadSeq( current, &reader, 0 );
-
-    int64* cur_pt = (int64*)reader.ptr;
-    int64* prev_pt = (int64*)reader.prev_elem;
-
-    //search for point a in aba position
-    for( int i = 0; i < current->total; i++ )
-    {
-        CV_NEXT_SEQ_ELEM( sizeof(int64), reader );
-
-        //compare current reader pos element with old previous
-        if( prev_pt[0] == ((int64*)reader.ptr)[0] )
-        {
-            //return to prev pos
-            CV_PREV_SEQ_ELEM( sizeof(int64), reader );
-
-
-            //this point is end of edge
-            //start going both directions and collect edge
-            cvStartReadSeq( current, &rev_reader, 1 );
-
-            int pos = cvGetSeqReaderPos( &reader );
-            cvSetSeqReaderPos( &rev_reader, pos );
-
-            //walk in both directions
-            while(1);
-
-
-        }
-        int64* cur_pt = (int64*)reader.ptr;
-        int64* prev_pt = (int64*)reader.prev_elem;
-
-    }
-}
-
-*/
-#endif /* WIN32 */
diff --git a/modules/legacy/src/face.cpp b/modules/legacy/src/face.cpp
deleted file mode 100644 (file)
index 2132ea8..0000000
+++ /dev/null
@@ -1,354 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-///////////////////////////////////////////////
-//// Created by Khudyakov V.A. bober@gorodok.net
-//////////////////////////////////////////////
-
-#include "precomp.hpp"
-#include "_facedetection.h"
-
-Face::Face(FaceTemplate * lpFaceTemplate)
-{
-    //init number of face elements;
-    m_lFaceFeaturesNumber = lpFaceTemplate->GetCount();
-
-    //init array of numbers of foundet face elements of each type
-    m_lplFaceFeaturesCount = new long[m_lFaceFeaturesNumber];
-    memset(m_lplFaceFeaturesCount,0,m_lFaceFeaturesNumber*sizeof(long));
-
-    //init array of ideal face features
-    m_lpIdealFace = new FaceFeature[m_lFaceFeaturesNumber];
-
-    //init array of founded features
-    m_lppFoundedFaceFeatures = new FaceFeature*[m_lFaceFeaturesNumber];
-
-    for (int i = 0;i < m_lFaceFeaturesNumber;i ++)
-    {
-        m_lppFoundedFaceFeatures[i] = (new FaceFeature[3*MAX_LAYERS]);
-    }
-
-    //set start weight 0
-    m_dWeight = 0;
-
-}//Face::Face(FaceTemplate * lpFaceTemplate)
-
-Face::~Face()
-{
-    for (int i = 0;i < m_lFaceFeaturesNumber;i ++)
-    {
-        delete [] (m_lppFoundedFaceFeatures[i]);
-    }
-    delete [] m_lppFoundedFaceFeatures;
-
-
-    delete [] m_lplFaceFeaturesCount;
-    delete [] m_lpIdealFace;
-
-}//Face::~Face()
-
-
-#define UP_SCALE    1
-#define DOWN_SCALE  2
-
-
-////////////
-//class RFace(rect based face)
-////////////
-RFace::RFace(FaceTemplate * lpFaceTemplate):Face(lpFaceTemplate)
-{
-    //init ideal face
-    FaceFeature * lpTmp = lpFaceTemplate->GetFeatures();
-
-    for (int j = 0;j < m_lFaceFeaturesNumber;j ++)
-    {
-        CvRect * lpTmpRect = NULL;
-        lpTmpRect = new CvRect;
-        *lpTmpRect = *(CvRect*)lpTmp[j].GetContour();
-
-        m_lpIdealFace[j].SetContour( lpTmpRect );
-        m_lpIdealFace[j].SetWeight( lpTmp[j].GetWeight() );
-        m_lpIdealFace[j].SetFeature( lpTmp[j].isFaceFeature() );
-
-    }
-
-    m_bIsGenerated = false;
-}//RFace::RFace(FaceTemplate * lpFaceTemplate)
-
-RFace::~RFace()
-{
-
-}//RFace::~RFace()
-
-inline bool RFace::isPointInRect(CvPoint p,CvRect rect)
-{
-    if ( (p.x >= rect.x) && (p.y >= rect.y) && (p.x <= rect.x + rect.width) && (p.y <= rect.y + rect.height) )
-        return true;
-
-    return false;
-}//inline bool RFace::isPointInRect(CvPoint,CvRect rect)
-
-double RFace::GetWeight()
-{
-    return m_dWeight;
-}//double RFace::GetWeight()
-
-
-bool RFace::CheckElem(void * lpCandidat,void * lpIdeal)
-{
-
-    CvRect IdealRect = *(CvRect*)lpIdeal;
-    CvRect Rect = *(CvRect*)lpCandidat;
-
-    if (Rect.height > Rect.width)
-        return false;
-
-    long SizeIdeal = IdealRect.width*IdealRect.height;
-    long Size = Rect.width*Rect.height;
-
-    if ( (Size > SizeIdeal) || ( Size < (SizeIdeal/5) ) )
-        return false;
-
-//  CvRect UpRect;
-//  CvRect DownRect;
-//  ResizeRect(IdealRect,&UpRect,UP_SCALE,7);
-//  ResizeRect(IdealRect,&DownRect,DOWN_SCALE,7);
-
-    long x = Rect.x + cvRound(Rect.width/2);
-    long y = Rect.y + cvRound(Rect.height/2);
-
-    if ( isPointInRect(cvPoint(x,y),IdealRect) )
-        return true;
-
-//  if ( isPointInRect(cvPoint(Rect.x,Rect.y),UpRect) &&
-//       isPointInRect(cvPoint(Rect.x + Rect.width,Rect.y + Rect.height),UpRect ) &&
-//       isPointInRect(cvPoint(DownRect.x,DownRect.y),Rect) &&
-//       isPointInRect(cvPoint(DownRect.x + DownRect.width,DownRect.y + DownRect.height),Rect) )
-//      return true;
-
-
-//  if ( isPointInRect(cvPoint(Rect.x,Rect.y),IdealRect) &&
-//       isPointInRect(cvPoint(Rect.x + Rect.width,Rect.y + Rect.height),IdealRect ) )
-//      return true;
-
-    return false;
-}//inline bool RFace::CheckElem(CvRect rect)
-
-
-
-void RFace::CalculateError(FaceData * lpFaceData)
-{
-    CvRect LeftEyeRect = lpFaceData->LeftEyeRect;
-    CvRect RightEyeRect = lpFaceData->RightEyeRect;
-    CvRect MouthRect = lpFaceData->MouthRect;
-
-    long LeftSquare = LeftEyeRect.width*LeftEyeRect.height;
-    long RightSquare = RightEyeRect.width*RightEyeRect.height;
-
-    long dy = LeftEyeRect.y - RightEyeRect.y;
-
-    long dx1 = LeftEyeRect.x + LeftEyeRect.width/2 - MouthRect.x;
-    long dx2 = RightEyeRect.x + RightEyeRect.width/2 - MouthRect.x - MouthRect.width;
-
-
-    lpFaceData->Error = (double)(LeftSquare - RightSquare)*(double)(LeftSquare - RightSquare)/((double)(LeftSquare + RightSquare)*(LeftSquare + RightSquare)) +
-                        (double)(dy*dy)/((double)(LeftEyeRect.height + RightEyeRect.height)*(LeftEyeRect.height + RightEyeRect.height)) +
-                        (double)(dx1*dx1)/((double)MouthRect.width*MouthRect.width) +
-                        (double)(dx2*dx2)/((double)MouthRect.width*MouthRect.width);
-
-}//void RFace::CalculateError(FaceData * lpFaceData)
-
-#define MAX_ERROR 0xFFFFFFFF
-
-void  RFace::CreateFace(void * lpData)
-{
-    FaceData Data;
-    memset(&Data, 0, sizeof(FaceData));
-
-    double Error = MAX_ERROR;
-    double CurError = MAX_ERROR;
-
-    FaceData * lpFaceData = (FaceData*)lpData;
-
-    int im = 0;//mouth was find
-    int jl = 0;//left eye was find
-    int kr = 0;//right eye was find
-
-    long MouthNumber = 0;
-    long LeftEyeNumber = 0;
-    long RightEyeNumber = 0;
-
-    for (int i = 0;i < m_lplFaceFeaturesCount[0] + 1;i ++)
-    {
-
-        if ( !m_lplFaceFeaturesCount[0] )
-            Data.MouthRect = *(CvRect*)m_lpIdealFace[0].GetContour();
-        else
-        {
-            if ( i != m_lplFaceFeaturesCount[0] )
-                Data.MouthRect = *(CvRect*)m_lppFoundedFaceFeatures[0][i].GetContour();
-            im = 1;
-        }
-
-
-        for (int j = 0;j < m_lplFaceFeaturesCount[1] + 1;j ++)
-        {
-
-            if ( !m_lplFaceFeaturesCount[1] )
-                Data.LeftEyeRect = *(CvRect*)m_lpIdealFace[1].GetContour();
-            else
-            {
-                if (j != m_lplFaceFeaturesCount[1] )
-                    Data.LeftEyeRect = *(CvRect*)m_lppFoundedFaceFeatures[1][j].GetContour();
-                jl = 1;
-            }
-
-
-            for (int k = 0;k < m_lplFaceFeaturesCount[2] + 1;k ++)
-            {
-
-                if ( !m_lplFaceFeaturesCount[2] )
-                    Data.RightEyeRect = *(CvRect*)m_lpIdealFace[2].GetContour();
-                else
-                {
-                    if (k != m_lplFaceFeaturesCount[2] )
-                        Data.RightEyeRect = *(CvRect*)m_lppFoundedFaceFeatures[2][k].GetContour();
-                    kr = 1;
-                }
-
-                CalculateError(&Data);
-
-                if ( (im + jl + kr) )
-                {
-                    Error = Data.Error/(im + jl + kr);
-                }else
-                    Error = MAX_ERROR;
-
-                if (CurError > Error)
-                {
-                    CurError = Error;
-                    MouthNumber = i;
-                    LeftEyeNumber = j;
-                    RightEyeNumber = k;
-                }
-
-            }
-
-
-        }
-
-    }
-
-    if ( m_lplFaceFeaturesCount[0] )
-        lpFaceData->MouthRect = *(CvRect*)m_lppFoundedFaceFeatures[0][MouthNumber].GetContour();
-    else
-        lpFaceData->MouthRect = *(CvRect*)m_lpIdealFace[0].GetContour();
-
-    if ( m_lplFaceFeaturesCount[1] )
-        lpFaceData->LeftEyeRect = *(CvRect*)m_lppFoundedFaceFeatures[1][LeftEyeNumber].GetContour();
-    else
-        lpFaceData->LeftEyeRect = *(CvRect*)m_lpIdealFace[1].GetContour();
-
-    if ( m_lplFaceFeaturesCount[2] )
-        lpFaceData->RightEyeRect = *(CvRect*)m_lppFoundedFaceFeatures[2][RightEyeNumber].GetContour();
-    else
-        lpFaceData->RightEyeRect = *(CvRect*)m_lpIdealFace[2].GetContour();
-
-    lpFaceData->Error = CurError;
-
-}//void * RFace::CreateFace()
-
-void RFace::Show(IplImage * Image)
-{
-    for (int i = 0;i < m_lFaceFeaturesNumber;i ++)
-    {
-        if (m_lplFaceFeaturesCount[i])
-        {
-            for (int j = 0;j < m_lplFaceFeaturesCount[i];j ++)
-            {
-                CvRect rect = *(CvRect*)m_lppFoundedFaceFeatures[i][j].GetContour();
-                CvPoint p1 = cvPoint(rect.x,rect.y);
-                CvPoint p2 = cvPoint(rect.x + rect.width,rect.y + rect.height);
-                cvRectangle(Image,p1,p2,CV_RGB(255,0,0),1);
-            }
-        }
-    }
-
-}//void RFace::Show(IplImage * Image)
-
-void RFace::ShowIdeal(IplImage* Image)
-{
-    for (int i = 0;i < m_lFaceFeaturesNumber;i ++)
-    {
-        CvRect Rect = *(CvRect*)m_lpIdealFace[i].GetContour();
-        CvPoint p1 = cvPoint(Rect.x,Rect.y);
-        CvPoint p2 = cvPoint(Rect.x + Rect.width,Rect.y + Rect.height);
-        cvRectangle(Image,p1,p2,CV_RGB(0,0,255),1);
-    }
-}//void RFace::ShowIdeal(IplImage* Image)
-
-
-inline void RFace::ResizeRect(CvRect Rect,CvRect * lpRect,long lDir,long lD)
-{
-    if (lDir == UP_SCALE)
-    {
-        lpRect->x = Rect.x - lD;
-        lpRect->y = Rect.y - lD;
-        lpRect->width = Rect.width + 2*lD;
-        lpRect->height = Rect.height + 2*lD;
-    }
-    if (lDir == DOWN_SCALE)
-    {
-        lpRect->x = Rect.x + lD;
-        lpRect->y = Rect.y + lD;
-        if (Rect.width - 2*lD >= 0)
-        {
-            lpRect->width = Rect.width - 2*lD;
-        }else
-            lpRect->width = 0;
-
-        if (Rect.height - 2*lD >= 0)
-        {
-            lpRect->height = Rect.height - 2*lD;
-        }else
-            lpRect->height = 0;
-    }
-
-}// inline void RFace::ResizeRect(CvRect * lpRect,long lDir,long lD)
diff --git a/modules/legacy/src/face.h b/modules/legacy/src/face.h
deleted file mode 100644 (file)
index 74a96f8..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-///////////////////////////////////////////////
-//// Created by Khudyakov V.A. bober@gorodok.net
-//////////////////////////////////////////////
-
-#ifndef __CVFACE_H__
-#define __CVFACE_H__
-
-#include "cvfacetemplate.h"
-
-#define MAX_LAYERS 64
-
-class Face
-{
-public:
-    Face(FaceTemplate * lpFaceTemplate);
-    virtual ~Face();
-
-    inline bool isFeature(void * lpElem);
-
-    virtual void Show(IplImage * /*Image*/){};
-    virtual    void ShowIdeal(IplImage* /*Image*/){};
-
-    virtual void CreateFace(void * lpData) = 0;
-    virtual bool CheckElem(void * lpCandidat,void * lpIdeal) = 0;
-    virtual double GetWeight() = 0;
-protected:
-    FaceFeature * m_lpIdealFace;             // Ideal face definition.
-    long m_lFaceFeaturesNumber;              // Total number of different face features .
-    long * m_lplFaceFeaturesCount;           // Count of each feature found on this face.
-    FaceFeature ** m_lppFoundedFaceFeatures; // Features found on current face.
-    double m_dWeight;
-};
-
-inline bool Face::isFeature(void * lpElem)
-{
-    for (int i = 0;i < m_lFaceFeaturesNumber;i ++)
-    {
-        void * lpIdeal = m_lpIdealFace[i].GetContour();
-
-        if ( CheckElem( lpElem,lpIdeal) )
-        {
-            if (m_lplFaceFeaturesCount[i] < 3*MAX_LAYERS)
-            {
-                double dWeight = m_lpIdealFace[i].GetWeight();
-                bool bIsFeature = m_lpIdealFace[i].isFaceFeature();
-
-
-                if (bIsFeature)
-                {
-                    m_lppFoundedFaceFeatures[i][m_lplFaceFeaturesCount[i]].SetWeight(dWeight);
-                    m_lppFoundedFaceFeatures[i][m_lplFaceFeaturesCount[i]].SetContour(lpElem);
-                    m_lppFoundedFaceFeatures[i][m_lplFaceFeaturesCount[i]].SetFeature(bIsFeature);
-                    m_lplFaceFeaturesCount[i] ++;
-                }
-
-                m_dWeight += dWeight;
-
-                if (bIsFeature)
-                    return true;
-            }
-        }
-
-    }
-
-    return false;
-}//inline bool RFace::isFeature(void * lpElem);
-
-
-struct FaceData
-{
-    CvRect LeftEyeRect;
-    CvRect RightEyeRect;
-    CvRect MouthRect;
-    double Error;
-};//struct FaceData
-
-class RFace:public Face
-{
-public:
-    RFace(FaceTemplate * lpFaceTemplate);
-    virtual ~RFace();
-    virtual bool CheckElem(void * lpCandidat,void * lpIdeal);
-    virtual void  CreateFace(void * lpData);
-    virtual void Show(IplImage* Image);
-    virtual void ShowIdeal(IplImage* Image);
-    virtual double GetWeight();
-private:
-    bool isPointInRect(CvPoint p,CvRect rect);
-    bool m_bIsGenerated;
-    void ResizeRect(CvRect Rect,CvRect * lpRect,long lDir,long lD);
-    void CalculateError(FaceData * lpFaceData);
-};
-
-
-#endif //__FACE_H__
diff --git a/modules/legacy/src/facedetection.cpp b/modules/legacy/src/facedetection.cpp
deleted file mode 100644 (file)
index b93d9aa..0000000
+++ /dev/null
@@ -1,501 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-///////////////////////////////////////////////
-//// Created by Khudyakov V.A. bober@gorodok.net
-//////////////////////////////////////////////
-// FaceDetection.cpp: implementation of the FaceDetection class.
-//
-//////////////////////////////////////////////////////////////////////
-
-#include "precomp.hpp"
-#include "_facedetection.h"
-
-
-int CV_CDECL CompareContourRect(const void* el1, const void* el2, void* userdata);
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-FaceDetection::FaceDetection()
-{
-
-    m_imgGray = NULL;
-    m_imgThresh = NULL;
-    m_mstgContours = NULL;
-    memset(m_seqContours, 0, sizeof(CvSeq*) * MAX_LAYERS);
-    m_mstgRects = NULL;
-    m_seqRects = NULL;
-    m_iNumLayers = 16;
-    assert(m_iNumLayers <= MAX_LAYERS);
-    m_pFaceList = new FaceDetectionList();
-
-
-
-    m_bBoosting = false;
-
-}// FaceDetection()
-
-FaceDetection::~FaceDetection()
-{
-    if (m_imgGray)
-        cvReleaseImage(&m_imgGray);
-
-    if (m_imgThresh)
-        cvReleaseImage(&m_imgThresh);
-
-    if (m_mstgContours)
-        cvReleaseMemStorage(&m_mstgContours);
-
-    if (m_mstgRects)
-        cvReleaseMemStorage(&m_mstgRects);
-
-
-}// ~FaceDetection()
-
-void FaceDetection::FindContours(IplImage* imgGray)
-{
-    ReallocImage(&m_imgThresh, cvGetSize(imgGray), 1);
-    if (NULL == m_imgThresh)
-        return;
-    //
-    int iNumLayers = m_iNumLayers;
-    int iMinLevel = 0, iMaxLevel = 255, iStep = 255 / iNumLayers;
-    ThresholdingParam(imgGray, iNumLayers, iMinLevel, iMaxLevel, iStep);
-    // init
-    cvReleaseMemStorage(&m_mstgContours);
-    m_mstgContours = cvCreateMemStorage();
-    if (NULL == m_mstgContours)
-        return;
-    memset(m_seqContours, 0, sizeof(CvSeq*) * MAX_LAYERS);
-
-    cvReleaseMemStorage(&m_mstgRects);
-    m_mstgRects = cvCreateMemStorage();
-    if (NULL == m_mstgRects)
-        return;
-    m_seqRects = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvContourRect), m_mstgRects);
-    if (NULL == m_seqRects)
-        return;
-    // find contours
-    for (int l = iMinLevel, i = 0; l < iMaxLevel; l += iStep, i++)
-    {
-        cvThreshold(imgGray, m_imgThresh, (double)l, (double)255, CV_THRESH_BINARY);
-        if (cvFindContours(m_imgThresh, m_mstgContours, &m_seqContours[i], sizeof(CvContour), CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE))
-            AddContours2Rect(m_seqContours[i], l, i);
-    }
-    // sort rects
-    cvSeqSort(m_seqRects, CompareContourRect, NULL);
-}// void FaceDetection::FindContours(IplImage* imgGray)
-
-#define GIST_STEP   10
-#define GIST_NUM    (256 / GIST_STEP)
-#define GIST_MIN    32
-
-void FaceDetection::ThresholdingParam(IplImage *imgGray, int iNumLayers, int &iMinLevel, int &iMaxLevel, int &iStep)
-{
-    assert(imgGray != NULL);
-    assert(imgGray->nChannels == 1);
-    int i, j;
-    // create gistogramm
-    uchar* buffImg = (uchar*)imgGray->imageData;
-    int gistImg[GIST_NUM + 1] = {0};
-
-    for (j = 0; j < imgGray->height; j ++)
-    {
-        for (i = 0; i < imgGray->width; i ++)
-        {
-            int ind = buffImg[i] / GIST_STEP;
-            gistImg[ind] ++;
-        }
-        buffImg += imgGray->widthStep;
-    }
-    // params
-
-    for (i = 0; i <= GIST_NUM; i ++)
-    {
-        if (gistImg[i] >= GIST_MIN)
-            break;
-    }
-
-    iMinLevel = i * GIST_STEP;
-
-    for (i = GIST_NUM; i >= 0; i --)
-    {
-        if (gistImg[i] >= GIST_MIN)
-            break;
-    }
-
-    iMaxLevel = i * GIST_STEP;
-
-    int dLevels = iMaxLevel - iMinLevel;
-    if (dLevels <= 0)
-    {
-        iMinLevel = 0;
-        iMaxLevel = 255;
-    }
-    else if (dLevels <= iNumLayers)
-    {
-        iMinLevel = iMaxLevel - iNumLayers;
-        if (iMinLevel < 0)
-        {
-            iMinLevel = 0;
-            iMaxLevel = iNumLayers;
-        }
-    }
-    iStep = (iMaxLevel - iMinLevel) / iNumLayers;
-
-}// void FaceDetection::ThresholdingParam(IplImage *imgGray, int iNumLayers, int &iMinLevel, int &iMaxLevel, int &iStep)
-
-#ifndef MAX_ERROR
-#define MAX_ERROR 0xFFFFFFFF
-#endif //MAX_ERROR
-
-
-void FaceDetection::CreateResults(CvSeq * lpSeq)
-{
-
-    Face * tmp;
-
-    double Max  = 0;
-    double CurStat = 0;
-
-    FaceData tmpData;
-    if (m_bBoosting)
-    {
-        tmp = m_pFaceList->GetData();
-        tmp->CreateFace(&tmpData);
-
-        CvFace tmpFace;
-        tmpFace.MouthRect = tmpData.MouthRect;
-        tmpFace.LeftEyeRect = tmpData.LeftEyeRect;
-        tmpFace.RightEyeRect = tmpData.RightEyeRect;
-
-        cvSeqPush(lpSeq,&tmpFace);
-
-    }else
-    {
-        while ( (tmp = m_pFaceList->GetData()) != 0 )
-        {
-            CurStat = tmp->GetWeight();
-            if (CurStat > Max)
-                Max = CurStat;
-        }
-
-        while ( (tmp = m_pFaceList->GetData()) != 0 )
-        {
-            tmp->CreateFace(&tmpData);
-            CurStat = tmp->GetWeight();
-
-            if (CurStat == Max)
-            {
-                CvFace tmpFace;
-                tmpFace.MouthRect = tmpData.MouthRect;
-                tmpFace.LeftEyeRect = tmpData.LeftEyeRect;
-                tmpFace.RightEyeRect = tmpData.RightEyeRect;
-                cvSeqPush(lpSeq,&tmpFace);
-
-
-            }
-        }
-    }
-}// void FaceDetection::DrawResult(IplImage* img)
-
-void FaceDetection::ResetImage()
-{
-        delete m_pFaceList;
-        m_pFaceList = new FaceDetectionList();
-
-}//FaceDetection::ResetImage
-
-void FaceDetection::AddContours2Rect(CvSeq *seq, int color, int iLayer)
-{
-    assert(m_mstgRects != NULL);
-    assert(m_seqRects != NULL);
-
-    CvContourRect cr;
-    for (CvSeq* external = seq; external; external = external->h_next)
-    {
-        cr.r = cvContourBoundingRect(external, 1 );
-        cr.pCenter.x = cr.r.x + cr.r.width / 2;
-        cr.pCenter.y = cr.r.y + cr.r.height / 2;
-        cr.iNumber = iLayer;
-        cr.iType = 6;
-        cr.iFlags = 0;
-        cr.seqContour = external;
-        cr.iContourLength = external->total;
-        cr.iColor = color;
-        cvSeqPush(m_seqRects, &cr);
-        for (CvSeq* internal = external->v_next; internal; internal = internal->h_next)
-        {
-            cr.r = cvContourBoundingRect(internal, 0);
-            cr.pCenter.x = cr.r.x + cr.r.width / 2;
-            cr.pCenter.y = cr.r.y + cr.r.height / 2;
-            cr.iNumber = iLayer;
-            cr.iType = 12;
-            cr.iFlags = 0;
-            cr.seqContour = internal;
-            cr.iContourLength = internal->total;
-            cr.iColor = color;
-            cvSeqPush(m_seqRects, &cr);
-        }
-    }
-}// void FaceDetection::AddContours2Rect(CvSeq *seq, int color, int iLayer)
-
-int CV_CDECL CompareContourRect(const void* el1, const void* el2, void* /*userdata*/)
-{
-    return (((CvContourRect*)el1)->pCenter.y - ((CvContourRect*)el2)->pCenter.y);
-}// int CV_CDECL CompareContourRect(const void* el1, const void* el2, void* userdata)
-
-void FaceDetection::FindFace(IplImage *img)
-{
-    // find all contours
-    FindContours(img);
-    //
-    ResetImage();
-
-    if (m_bBoosting)
-        PostBoostingFindCandidats(img);
-    else
-        FindCandidats();
-
-}// void FaceDetection::FindFace(IplImage *img)
-
-
-void FaceDetection::FindCandidats()
-{
-    bool bFound1 = false;
-    MouthFaceTemplate * lpFaceTemplate1 = 0;
-    RFace * lpFace1 = 0;
-    bool bInvalidRect1 = false;
-    CvRect * lpRect1  = NULL;
-
-    try
-    {
-        for (int i = 0; i < m_seqRects->total; i++)
-        {
-            CvContourRect* pRect = (CvContourRect*)cvGetSeqElem(m_seqRects, i);
-            CvRect rect = pRect->r;
-            if (rect.width >= 2*rect.height)
-            {
-
-                lpFaceTemplate1 = new MouthFaceTemplate(3,rect,3*(double)rect.width/(double)4,
-                                                               3*(double)rect.width/(double)4,
-                                                                 (double)rect.width/(double)2,
-                                                                 (double)rect.width/(double)2);
-
-
-                lpFace1 = new RFace(lpFaceTemplate1);
-
-                for (int j = 0; j < m_seqRects->total; j++)
-                {
-                    CvContourRect* prect = (CvContourRect*)cvGetSeqElem(m_seqRects, j);
-
-                    if ( !bInvalidRect1 )
-                    {
-                        lpRect1 = NULL;
-                        lpRect1 = new CvRect();
-                        *lpRect1 = prect->r;
-                    }else
-                    {
-                        delete lpRect1;
-                        lpRect1 = new CvRect();
-                        *lpRect1 = prect->r;
-                    }
-
-
-                    if ( lpFace1->isFeature(lpRect1) )
-                    {
-                        bFound1 = true;
-                        bInvalidRect1 = false;
-                    }else
-                        bInvalidRect1 = true;
-
-
-                }
-
-
-                if (bFound1)
-                {
-                    m_pFaceList->AddElem(lpFace1);
-                    bFound1 = false;
-                    lpFace1 = NULL;
-                }else
-                {
-                    delete lpFace1;
-                    lpFace1 = NULL;
-                }
-
-
-                delete lpFaceTemplate1;
-            }
-
-        }
-    }
-    catch(...)
-    {
-        delete lpFaceTemplate1;
-        delete lpFace1;
-        throw;
-    }
-}
-
-
-void FaceDetection::PostBoostingFindCandidats(IplImage * FaceImage)
-{
-    BoostingFaceTemplate * lpFaceTemplate1 = 0;
-    RFace * lpFace1 = 0;
-    bool bInvalidRect1 = false;
-    CvRect * lpRect1  = NULL;
-
-    try
-    {
-        if ( ( !FaceImage->roi ) )
-            lpFaceTemplate1 = new BoostingFaceTemplate(3,cvRect(0,0,FaceImage->width,FaceImage->height));
-        else
-            lpFaceTemplate1 = new BoostingFaceTemplate(3,cvRect(FaceImage->roi->xOffset,FaceImage->roi->yOffset,
-                                                                FaceImage->roi->width,FaceImage->roi->height));
-
-        lpFace1 = new RFace(lpFaceTemplate1);
-
-        for (int i = 0; i < m_seqRects->total; i++)
-        {
-            CvContourRect* pRect = (CvContourRect*)cvGetSeqElem(m_seqRects, i);
-
-            if ( !bInvalidRect1 )
-            {
-                lpRect1 = NULL;
-                lpRect1 = new CvRect();
-                *lpRect1 = pRect->r;
-            }else
-            {
-                delete lpRect1;
-                lpRect1 = new CvRect();
-                *lpRect1 = pRect->r;
-            }
-
-
-            if ( lpFace1->isFeature(lpRect1) )
-            {
-                //bFound1 = true;
-                bInvalidRect1 = false;
-            }else
-                bInvalidRect1 = true;
-
-
-        }
-
-        m_pFaceList->AddElem(lpFace1);
-        lpFace1 = NULL;
-
-        delete lpFaceTemplate1;
-    }
-    catch(...)
-    {
-        delete lpFace1;
-        delete lpFaceTemplate1;
-        throw;
-    }
-}//void FaceDetection::PostBoostingFindCandidats(IplImage * FaceImage)
-
-/////////////////////////
-//class Face
-
-
-
-//////
-//FaceDetectionList Class
-/////
-FaceDetectionListElem::FaceDetectionListElem()
-{
-    m_pNext = this;
-    m_pPrev = this;
-    m_pFace = NULL;
-}///FaceDetectionListElem::FaceDetectionListElem()
-
-FaceDetectionListElem::FaceDetectionListElem(Face * pFace,FaceDetectionListElem * pHead)
-{
-    m_pNext = pHead;
-    m_pPrev = pHead->m_pPrev;
-    pHead->m_pPrev->m_pNext = this;
-    pHead->m_pPrev = this;
-
-    m_pFace = pFace;
-}//FaceDetectionListElem::FaceDetectionListElem(Face * pFace)
-
-
-
-FaceDetectionListElem::~FaceDetectionListElem()
-{
-    delete m_pFace;
-    m_pNext->m_pPrev = m_pPrev;
-    m_pPrev->m_pNext = m_pNext;
-
-}//FaceDetectionListElem::~FaceDetectionListElem()
-
-FaceDetectionList::FaceDetectionList()
-{
-    m_pHead = new FaceDetectionListElem();
-    m_FacesCount = 0;
-    m_pCurElem = m_pHead;
-}//FaceDetectionList::FaceDetectionList()
-
-FaceDetectionList::~FaceDetectionList()
-{
-    void * tmp;
-    while((tmp = m_pHead->m_pNext->m_pFace) != 0)
-        delete m_pHead->m_pNext;
-
-    delete m_pHead;
-
-}//FaceDetectionList::~FaceDetectionList()
-
-
-int FaceDetectionList::AddElem(Face * pFace)
-{
-    new FaceDetectionListElem(pFace,m_pHead);
-    return m_FacesCount++;
-}//FaceDetectionList::AddElem(Face * pFace)
-
-Face * FaceDetectionList::GetData()
-{
-    m_pCurElem = m_pCurElem->m_pNext;
-    return m_pCurElem->m_pFace;
-}//Face * FaceDetectionList::GetData()
diff --git a/modules/legacy/src/facedetection.h b/modules/legacy/src/facedetection.h
deleted file mode 100644 (file)
index 474bcbe..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-// FaceDetection.h: interface for the FaceDetection class.
-//
-//////////////////////////////////////////////////////////////////////
-
-#ifndef _CVFACEDETECTION_H_
-#define _CVFACEDETECTION_H_
-
-#include "cvfacetemplate.h"
-#include "cvface.h"
-#include "cvboostingtemplate.h"
-
-typedef struct CvContourRect
-{
-    int                iNumber;  //ïîðÿäêîâûé íîìåð àòðèáóòà
-    int                iType;    //òèï îáúåêòà
-    int                iFlags;   //ñâîáîäíîå ïîëå
-    CvSeq      *seqContour; //àäðåñ íà÷àëà çàïèñè îáúåêòà
-    int                iContourLength;  //äëèíà çàïèñè âåêòîðîâ
-    CvRect     r;    //îïèñàíûé ïðÿìîóãîëüíèê
-    CvPoint pCenter; // center of rect
-    int                iColor;//    öâåò çàïîëíåíèÿ êîíòóðà
-} CvContourRect;
-
-//class Face;
-
-class ListElem
-{
-public:
-    ListElem();
-    ListElem(Face * pFace,ListElem * pHead);
-    virtual ~ListElem();
-    ListElem * m_pNext;
-    ListElem * m_pPrev;
-    Face * m_pFace;
-};//class ListElem
-
-class List
-{
-public:
-    List();
-    int AddElem(Face * pFace);
-    virtual ~List();
-    Face* GetData();
-        long m_FacesCount;
-private:
-    ListElem * m_pHead;
-    ListElem * m_pCurElem;
-};//class List
-
-
-class FaceDetection
-{
-public:
-    void FindFace(IplImage* img);
-    void CreateResults(CvSeq * lpSeq);
-    FaceDetection();
-    virtual ~FaceDetection();
-    void SetBoosting(bool bBoosting) {m_bBoosting = bBoosting;}
-    bool isPostBoosting() {return m_bBoosting;}
-protected:
-
-    IplImage* m_imgGray;
-    IplImage* m_imgThresh;
-    int m_iNumLayers;
-    CvMemStorage* m_mstgContours;
-    CvSeq* m_seqContours[MAX_LAYERS];
-    CvMemStorage* m_mstgRects;
-    CvSeq* m_seqRects;
-
-    bool m_bBoosting;
-    List * m_pFaceList;
-
-protected:
-    void ResetImage();
-    void FindContours(IplImage* imgGray);
-    void AddContours2Rect(CvSeq*  seq, int color, int iLayer);
-    void ThresholdingParam(IplImage* imgGray, int iNumLayers, int& iMinLevel, int& iMaxLevel, int& iStep);
-    void FindCandidats();
-    void PostBoostingFindCandidats(IplImage * FaceImage);
-};
-
-inline void ReallocImage(IplImage** ppImage, CvSize sz, long lChNum)
-{
-    IplImage* pImage;
-    if( ppImage == NULL )
-        return;
-    pImage = *ppImage;
-    if( pImage != NULL )
-    {
-        if (pImage->width != sz.width || pImage->height != sz.height || pImage->nChannels != lChNum)
-            cvReleaseImage( &pImage );
-    }
-    if( pImage == NULL )
-        pImage = cvCreateImage( sz, IPL_DEPTH_8U, lChNum);
-    *ppImage = pImage;
-};
-
-
-
-#endif // !defined(AFX_FACEDETECTION_H__55865033_D8E5_4DD5_8925_34C2285BB1BE__INCLUDED_)
diff --git a/modules/legacy/src/facetemplate.cpp b/modules/legacy/src/facetemplate.cpp
deleted file mode 100644 (file)
index 25964fc..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-///////////////////////////////////////////////
-//// Created by Khudyakov V.A. bober@gorodok.net
-//////////////////////////////////////////////
-
-#include "precomp.hpp"
-#include "_facedetection.h"
-
-///class FaceFeature
-FaceFeature::FaceFeature(double dWeight,void * lpContour,bool bIsFeature)
-{
-    m_lpContour = lpContour;
-    m_dWeight = dWeight;
-    m_bIsFaceFeature = bIsFeature;
-}//FaceFeature::FaceFeature(long lWeight,void * lpContour)
-
-FaceFeature::~FaceFeature()
-{
-    if (m_lpContour)
-        delete (char*)m_lpContour;
-}//FaceFeature::~FaceFeature()
-
-FaceFeature::FaceFeature()
-{
-    m_lpContour = NULL;
-    m_dWeight = 0;
-    m_bIsFaceFeature = false;
-}
-
-
-////class FaceTemplate
-
-FaceTemplate::~FaceTemplate()
-{
-    delete [] m_lpFeaturesList;
-}//FaceTemplate::~FaceTemplate()
-
-
-/////
-//class RFaceTemplate
-/////
-
-
-MouthFaceTemplate::~MouthFaceTemplate()
-{
-
-}//RFaceTemplate::~RFaceTemplate()
diff --git a/modules/legacy/src/facetemplate.h b/modules/legacy/src/facetemplate.h
deleted file mode 100644 (file)
index 83f5bc3..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-///////////////////////////////////////////////
-//// Created by Khudyakov V.A. bober@gorodok.net
-//////////////////////////////////////////////
-
-#ifndef __CVFACETEMPLATE_H__
-#define __CVFACETEMPLATE_H__
-
-class FaceFeature
-{
-public:
-    FaceFeature(double dWeight,void * lpContour,bool bIsFeature);
-    FaceFeature();
-    virtual ~FaceFeature();
-    inline bool isFaceFeature();
-    inline void * GetContour();
-    inline double GetWeight();
-    inline void SetContour(void * lpContour);
-    inline void SetWeight(double dWeight);
-    inline void SetFeature(bool bIsFeature);
-private:
-    double m_dWeight;
-    void * m_lpContour;
-    bool m_bIsFaceFeature;
-};//class FaceFeature
-
-inline void FaceFeature::SetFeature(bool bIsFeature)
-{
-    m_bIsFaceFeature = bIsFeature;
-}
-
-inline bool FaceFeature::isFaceFeature()
-{
-    return m_bIsFaceFeature;
-}//inline bool FaceFeature::isFaceFeature()
-
-inline void * FaceFeature::GetContour()
-{
-    return m_lpContour;
-}//inline void * FaceFeature::GetContour()
-
-inline double FaceFeature::GetWeight()
-{
-    return m_dWeight;
-}//inline long FaceFeature::GetWeight()
-
-inline void FaceFeature::SetContour(void * lpContour)
-{
-    m_lpContour = lpContour;
-}//inline void FaceFeature::SetContour(void * lpContour)
-
-inline void FaceFeature::SetWeight(double  dWeight)
-{
-    m_dWeight = dWeight;
-}//inline void FaceFeature::SetWeight(double * dWeight)
-
-
-
-class FaceTemplate
-{
-public:
-    FaceTemplate(long lFeatureCount) {m_lFeturesCount = lFeatureCount; m_lpFeaturesList = new FaceFeature[lFeatureCount];}
-    virtual ~FaceTemplate();
-
-    inline long GetCount();
-    inline FaceFeature * GetFeatures();
-
-protected:
-    FaceFeature * m_lpFeaturesList;
-private:
-    long m_lFeturesCount;
-};//class FaceTemplate
-
-
-inline long FaceTemplate::GetCount()
-{
-    return m_lFeturesCount;
-}//inline long FaceTemplate::GetCount()
-
-
-inline FaceFeature * FaceTemplate::GetFeatures()
-{
-    return m_lpFeaturesList;
-}//inline FaceFeature * FaceTemplate::GetFeatures()
-
-////////////
-//class RFaceTemplate
-///////////
-
-class MouthFaceTemplate:public FaceTemplate
-{
-public:
-    inline MouthFaceTemplate(long lNumber,CvRect rect,double dEyeWidth,double dEyeHeight,double dDistanceBetweenEye,double dDistanceEyeAboveMouth);
-    ~MouthFaceTemplate();
-};//class MouthFaceTemplate:public FaceTemplate
-
-
-inline MouthFaceTemplate::MouthFaceTemplate(long lNumber,CvRect rect,double dEyeWidth,double dEyeHeight,
-                             double dDistanceBetweenEye,double dDistanceEyeAboveMouth):FaceTemplate(lNumber)
-{
-
-    CvRect MouthRect = rect;
-
-
-    CvRect LeftEyeRect = cvRect(cvRound(rect.x - (dEyeWidth + dDistanceBetweenEye/(double)2 - (double)rect.width/(double)2)),
-                                cvRound(rect.y - dDistanceEyeAboveMouth - dEyeHeight),
-                                cvRound(dEyeWidth),
-                                cvRound(dEyeHeight) );
-
-    CvRect RightEyeRect = cvRect(cvRound(rect.x + (double)rect.width/(double)2 + dDistanceBetweenEye/(double)2),
-                                 cvRound(rect.y - dDistanceEyeAboveMouth - dEyeHeight),
-                                 cvRound(dEyeWidth),
-                                 cvRound(dEyeHeight) );
-
-//     CvRect NoseRect = cvRect(cvRound(rect.x + (double)rect.width/(double)4),
-//                                                      cvRound(rect.y - (double)rect.width/(double)2 - (double)rect.height/(double)4),
-//                                                      cvRound((double)rect.width/(double)2),
-//                                                      cvRound((double)rect.width/(double)2) );
-/*
-    CvRect CheenRect = cvRect(rect.x,rect.y + 3*rect.height/2,rect.width,rect.height);
-
-*/
-
-    CvRect * lpMouthRect = new CvRect();
-    *lpMouthRect = MouthRect;
-    m_lpFeaturesList[0].SetContour(lpMouthRect);
-    m_lpFeaturesList[0].SetWeight(1);
-    m_lpFeaturesList[0].SetFeature(false);
-
-
-    CvRect * lpLeftEyeRect = new CvRect();
-    *lpLeftEyeRect = LeftEyeRect;
-    m_lpFeaturesList[1].SetContour(lpLeftEyeRect);
-    m_lpFeaturesList[1].SetWeight(1);
-    m_lpFeaturesList[1].SetFeature(true);
-
-    CvRect * lpRightEyeRect = new CvRect();
-    *lpRightEyeRect = RightEyeRect;
-    m_lpFeaturesList[2].SetContour(lpRightEyeRect);
-    m_lpFeaturesList[2].SetWeight(1);
-    m_lpFeaturesList[2].SetFeature(true);
-
-
-//     CvRect * lpNoseRect = new CvRect();
-//     *lpNoseRect = NoseRect;
-//     m_lpFeaturesList[3].SetContour(lpNoseRect);
-//     m_lpFeaturesList[3].SetWeight(0);
-//     m_lpFeaturesList[3].SetFeature(true);
-
-/*     CvRect * lpCheenRect = new CvRect();
-    *lpCheenRect = CheenRect;
-    m_lpFeaturesList[4].SetContour(lpCheenRect);
-    m_lpFeaturesList[4].SetWeight(1);
-    m_lpFeaturesList[4].SetFeature(false);
-
-*/
-
-};//constructor MouthFaceTemplate(long lNumFeatures,CvRect rect,double dEyeWidth,double dEyeHeight,double dDistanceBetweenEye,double dDistanceEyeAboveMouth);
-
-
-
-#endif//__FACETEMPLATE_H__
diff --git a/modules/legacy/src/features2d.cpp b/modules/legacy/src/features2d.cpp
deleted file mode 100644 (file)
index b2fb3b2..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Original code has been submitted by Liu Liu. Here is the copyright.
-----------------------------------------------------------------------------------
- * An OpenCV Implementation of SURF
- * Further Information Refer to "SURF: Speed-Up Robust Feature"
- * Author: Liu Liu
- * liuliu.1987+opencv@gmail.com
- *
- * There are still serveral lacks for this experimental implementation:
- * 1.The interpolation of sub-pixel mentioned in article was not implemented yet;
- * 2.A comparision with original libSurf.so shows that the hessian detector is not a 100% match to their implementation;
- * 3.Due to above reasons, I recommanded the original one for study and reuse;
- *
- * However, the speed of this implementation is something comparable to original one.
- *
- * Copyright© 2008, Liu Liu All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *  Redistributions of source code must retain the above
- *  copyright notice, this list of conditions and the following
- *  disclaimer.
- *  Redistributions in binary form must reproduce the above
- *  copyright notice, this list of conditions and the following
- *  disclaimer in the documentation and/or other materials
- *  provided with the distribution.
- *  The name of Contributor may not be used to endorse or
- *  promote products derived from this software without
- *  specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- */
-
-#include "precomp.hpp"
-
-using namespace cv;
-
-
-
-CV_IMPL CvSURFParams cvSURFParams(double threshold, int extended)
-{
-    CvSURFParams params;
-    params.hessianThreshold = threshold;
-    params.extended = extended;
-    params.upright = 0;
-    params.nOctaves = 4;
-    params.nOctaveLayers = 2;
-    return params;
-}
-
-CV_IMPL void
-cvExtractSURF( const CvArr* _img, const CvArr* _mask,
-               CvSeq** _keypoints, CvSeq** _descriptors,
-               CvMemStorage* storage, CvSURFParams params,
-               int useProvidedKeyPts)
-{
-    Mat img = cvarrToMat(_img), mask;
-    if(_mask)
-        mask = cvarrToMat(_mask);
-    std::vector<KeyPoint> kpt;
-    Mat descr;
-
-    Ptr<Feature2D> surf = Algorithm::create<Feature2D>("Feature2D.SURF");
-    if( !surf )
-        CV_Error(CV_StsNotImplemented, "OpenCV was built without SURF support");
-
-    surf->set("hessianThreshold", params.hessianThreshold);
-    surf->set("nOctaves", params.nOctaves);
-    surf->set("nOctaveLayers", params.nOctaveLayers);
-    surf->set("upright", params.upright != 0);
-    surf->set("extended", params.extended != 0);
-
-    surf->operator()(img, mask, kpt, _descriptors ? _OutputArray(descr) : (OutputArray)noArray(),
-                     useProvidedKeyPts != 0);
-
-    if( _keypoints )
-        *_keypoints = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvSURFPoint), storage);
-
-    if( _descriptors )
-        *_descriptors = cvCreateSeq(0, sizeof(CvSeq), surf->descriptorSize() * CV_ELEM_SIZE(surf->descriptorType()), storage);
-
-    for( size_t i = 0; i < kpt.size(); i++ )
-    {
-        if( _keypoints )
-        {
-            CvSURFPoint pt = cvSURFPoint(kpt[i].pt, kpt[i].class_id, cvRound(kpt[i].size), kpt[i].angle, kpt[i].response);
-            cvSeqPush(*_keypoints, &pt);
-        }
-        if( _descriptors )
-            cvSeqPush(*_descriptors, descr.ptr((int)i));
-    }
-}
-
-CV_IMPL CvSeq*
-cvGetStarKeypoints( const CvArr* _img, CvMemStorage* storage,
-                    CvStarDetectorParams params )
-{
-    Ptr<StarDetector> star(new StarDetector(params.maxSize, params.responseThreshold,
-                                            params.lineThresholdProjected,
-                                            params.lineThresholdBinarized,
-                                            params.suppressNonmaxSize));
-    std::vector<KeyPoint> kpts;
-    star->detect(cvarrToMat(_img), kpts, Mat());
-
-    CvSeq* seq = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvStarKeypoint), storage);
-    for( size_t i = 0; i < kpts.size(); i++ )
-    {
-        CvStarKeypoint kpt = cvStarKeypoint(kpts[i].pt, cvRound(kpts[i].size), kpts[i].response);
-        cvSeqPush(seq, &kpt);
-    }
-    return seq;
-}
diff --git a/modules/legacy/src/featuretree.cpp b/modules/legacy/src/featuretree.cpp
deleted file mode 100644 (file)
index 2c96d7b..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-//M*//////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "_featuretree.h"
-
-void cvReleaseFeatureTree(CvFeatureTree* tr)
-{
-    delete tr;
-}
-
-// desc is m x d set of candidate points.
-// results is m x k set of row indices of matching points.
-// dist is m x k distance to matching points.
-void cvFindFeatures(CvFeatureTree* tr, const CvMat* desc,
-    CvMat* results, CvMat* dist, int k, int emax)
-{
-    tr->FindFeatures(desc, k, emax, results, dist);
-}
-
-int cvFindFeaturesBoxed(CvFeatureTree* tr,
-    CvMat* bounds_min, CvMat* bounds_max,
-    CvMat* results)
-{
-    return tr->FindOrthoRange(bounds_min, bounds_max, results);
-}
diff --git a/modules/legacy/src/findface.cpp b/modules/legacy/src/findface.cpp
deleted file mode 100644 (file)
index a41c579..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-///////////////////////////////////////////////
-//// Created by Khudyakov V.A. bober@gorodok.net
-//////////////////////////////////////////////
-
-#include "precomp.hpp"
-#include "_facedetection.h"
-
-CvSeq * cvFindFace(IplImage * Image,CvMemStorage* lpStorage)
-{
-    FaceDetection FD;
-    FD.SetBoosting(false);
-    FD.FindFace(Image);
-    CvSeq * lpSeq = cvCreateSeq(0,sizeof(*lpSeq),sizeof(CvFace),lpStorage);
-    FD.CreateResults(lpSeq);
-    return lpSeq;
-}//cvFindFace(IplImage * Image)
-
-CvSeq * cvPostBoostingFindFace(IplImage * Image,CvMemStorage* lpStorage)
-{
-    FaceDetection FD;
-    FD.SetBoosting(true);
-    FD.FindFace(Image);
-    CvSeq * lpSeq = cvCreateSeq(0,sizeof(*lpSeq),sizeof(CvFace),lpStorage);
-    FD.CreateResults(lpSeq);
-
-    return lpSeq;
-}//cvPostBoostingFindFace(IplImage * Image)
diff --git a/modules/legacy/src/findhandregion.cpp b/modules/legacy/src/findhandregion.cpp
deleted file mode 100644 (file)
index 23fc419..0000000
+++ /dev/null
@@ -1,633 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-#define _CV_NORM_L2(a) (float)(icvSqrt32f(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]))
-#define _CV_NORM_L22(a) (float)(a[0]*a[0] + a[1]*a[1] + a[2]*a[2])
-
-/****************************************************************************************\
-
-   find region where hand is   (for gesture recognition)
-   flag = 0 (use left bucket)  flag = 1 (use right bucket)
-
-\****************************************************************************************/
-
-static CvStatus CV_STDCALL
-icvFindHandRegion( CvPoint3D32f * points, int count,
-                   CvSeq * indexs,
-                   float *line, CvSize2D32f size, int flag,
-                   CvPoint3D32f * center,
-                   CvMemStorage * storage, CvSeq ** numbers )
-{
-
-/*    IppmVect32f sub, cros;   */
-    float *sub, *cros;
-    CvSeqWriter writer;
-    CvSeqReader reader;
-
-    CvStatus status;
-    int nbins = 20, i, l, i_point, left, right;
-    int *bin_counts = 0;        //  pointer to the point's counter in the bickets
-    int low_count;              //  low threshold
-
-    CvPoint *tmp_number = 0, *pt;
-    float value, vmin, vmax, vl, bsize, vc;
-    float hand_length, hand_length2, hand_left, hand_right;
-    float threshold, threshold2;
-    float *vv = 0;
-    float a[3];
-
-    status = CV_OK;
-
-    hand_length = size.width;
-    hand_length2 = hand_length / 2;
-
-    threshold = (float) (size.height * 3 / 5.);
-    threshold2 = threshold * threshold;
-
-/*    low_count = count/nbins;     */
-    low_count = (int) (count / 60.);
-
-    assert( points != NULL && line != NULL );
-    if( points == NULL || line == NULL )
-        return CV_NULLPTR_ERR;
-
-    assert( count > 5 );
-    if( count < 5 )
-        return CV_BADFLAG_ERR;
-
-    assert( flag == 0 || flag == 1 );
-    if( flag != 0 && flag != 1 )
-        return CV_BADFLAG_ERR;
-
-/*  create vectors         */
-    sub = icvCreateVector_32f( 3 );
-    cros = icvCreateVector_32f( 3 );
-    if( sub == NULL || cros == NULL )
-        return CV_OUTOFMEM_ERR;
-
-/*  alloc memory for the point's projections on the line    */
-    vv = (float *) cvAlloc( count * sizeof( float ));
-
-    if( vv == NULL )
-        return CV_OUTOFMEM_ERR;
-
-/*  alloc memory for the point's counter in the bickets     */
-    bin_counts = (int *) cvAlloc( nbins * sizeof( int ));
-
-    if( bin_counts == NULL )
-    {
-        status = CV_OUTOFMEM_ERR;
-        goto M_END;
-    }
-    memset( bin_counts, 0, nbins * sizeof( int ));
-
-    cvStartReadSeq( indexs, &reader, 0 );
-
-/*  alloc memory for the temporale point's numbers      */
-    tmp_number = (CvPoint *) cvAlloc( count * sizeof( CvPoint ));
-    if( tmp_number == NULL )
-    {
-        status = CV_OUTOFMEM_ERR;
-        goto M_END;
-    }
-
-/*  find min and max point's projection on the line     */
-    vmin = 1000;
-    vmax = -1000;
-    i_point = 0;
-    for( i = 0; i < count; i++ )
-    {
-/*
-        icvSubVector_32f ((IppmVect32f )&points[i], (IppmVect32f )&line[3], sub, 3);
-
-        icvCrossProduct2L_32f ((IppmVect32f )&line[0], sub, cros);
-*/
-
-        sub[0] = points[i].x - line[3];
-        sub[1] = points[i].y - line[4];
-        sub[2] = points[i].z - line[5];
-        a[0] = sub[0] * line[1] - sub[1] * line[0];
-        a[1] = sub[1] * line[2] - sub[2] * line[1];
-        a[2] = sub[2] * line[0] - sub[0] * line[2];
-
-/*      if(IPPI_NORM_L22 ( cros ) < threshold2)    */
-        if( _CV_NORM_L22( a ) < threshold2 )
-        {
-            value = (float)icvDotProduct_32f( sub, &line[0], 3 );
-            if( value > vmax )
-                vmax = value;
-            if( value < vmin )
-                vmin = value;
-
-            vv[i_point] = value;
-
-            pt = (CvPoint*)cvGetSeqElem( indexs, i );
-            tmp_number[i_point] = *pt;
-            i_point++;
-        }
-    }
-
-/*  compute the length of one bucket             */
-    vl = vmax - vmin;
-    bsize = vl / nbins;
-
-/*  compute the number of points in each bucket   */
-    for( i = 0; i < i_point; i++ )
-    {
-        l = cvRound( (vv[i] - vmin) / bsize );
-        bin_counts[l]++;
-    }
-
-    *numbers = cvCreateSeq( CV_SEQ_POINT_SET, sizeof( CvSeq ), sizeof( CvPoint ), storage );
-    assert( numbers != 0 );
-    if( numbers == NULL )
-    {
-        status = CV_OUTOFMEM_ERR;
-        goto M_END;
-    }
-
-    cvStartAppendToSeq( *numbers, &writer );
-
-    if( flag == 0 )
-    {
-/*  find the leftmost bucket           */
-        for( l = 0; l < nbins; l++ )
-        {
-            if( bin_counts[l] > low_count )
-                break;
-        }
-        left = l;
-
-/*  compute center point of the left hand     */
-        hand_left = vmin + left * bsize;
-        vc = hand_left + hand_length2;
-        hand_right = hand_left + hand_length;
-    }
-    else
-    {
-/*  find the rightmost bucket                */
-        for( l = nbins - 1; l >= 0; l-- )
-        {
-            if( bin_counts[l] > low_count )
-                break;
-        }
-        right = l;
-
-/*  compute center point of the right hand    */
-        hand_right = vmax - (nbins - right - 1) * bsize;
-        vc = hand_right - hand_length2;
-        hand_left = hand_right - hand_length;
-    }
-
-    icvScaleVector_32f( &line[0], sub, 3, vc );
-    icvAddVector_32f( &line[3], sub, (float *) center, 3 );
-
-/*  select hand's points and calculate mean value     */
-
-    //ss.x = ss.y = ss.z = 0;
-    for( l = 0; l < i_point; l++ )
-    {
-        if( vv[l] >= hand_left && vv[l] <= hand_right )
-        {
-            CV_WRITE_SEQ_ELEM( tmp_number[l], writer );
-
-        }
-    }
-
-    cvEndWriteSeq( &writer );
-
-  M_END:
-    if( tmp_number != NULL )
-        cvFree( &tmp_number );
-    if( bin_counts != NULL )
-        cvFree( &bin_counts );
-    if( vv != NULL )
-        cvFree( &vv );
-    if( sub != NULL ) icvDeleteVector (sub);
-    if( cros != NULL ) icvDeleteVector (cros);
-
-    return status;
-
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////
-
-
-#define _CV_NORM_L31(a) (float)(icvSqrt32f(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]))
-#define _CV_NORM_L32(a) (float)(a[0]*a[0] + a[1]*a[1] + a[2]*a[2])
-
-/****************************************************************************************\
-
-   find region where hand is   (for gesture recognition)
-   flag = 0 (use left bucket)  flag = 1 (use right bucket)
-
-\****************************************************************************************/
-
-static CvStatus CV_STDCALL
-icvFindHandRegionA( CvPoint3D32f * points, int count,
-                    CvSeq * indexs,
-                    float *line, CvSize2D32f size, int jc,
-                    CvPoint3D32f * center,
-                    CvMemStorage * storage, CvSeq ** numbers )
-{
-
-/*    IppmVect32f sub, cros;   */
-    float *sub, *cros;
-    float eps = (float) 0.01;
-    CvSeqWriter writer;
-    CvSeqReader reader;
-
-    CvStatus status;
-    float gor[3] = { 1, 0, 0 };
-    float ver[3] = { 0, 1, 0 };
-
-    int nbins = 20, i, l, i_point, left, right, jmin, jmax, jl;
-    int j_left, j_right;
-    int *bin_counts = 0;        //  pointer to the point's counter in the bickets
-
-//    int *bin_countsj = 0;   //  pointer to the index's counter in the bickets
-    int low_count;              //  low threshold
-
-    CvPoint *tmp_number = 0, *pt;
-    float value, vmin, vmax, vl, bsize, bsizej, vc, vcl, vcr;
-    double v_ver, v_gor;
-    float hand_length, hand_length2, hand_left, hand_right;
-    float threshold, threshold2;
-    float *vv = 0;
-    float a[3];
-    char log;
-
-    status = CV_OK;
-
-    hand_length = size.width;
-    hand_length2 = hand_length / 2;
-
-    threshold = (float) (size.height * 3 / 5.);
-    threshold2 = threshold * threshold;
-
-/*    low_count = count/nbins;     */
-    low_count = (int) (count / 60.);
-
-    assert( points != NULL && line != NULL );
-    if( points == NULL || line == NULL )
-        return CV_NULLPTR_ERR;
-
-    assert( count > 5 );
-    if( count < 5 )
-        return CV_BADFLAG_ERR;
-
-/*  create vectors         */
-    sub = icvCreateVector_32f( 3 );
-    cros = icvCreateVector_32f( 3 );
-    if( sub == NULL || cros == NULL )
-        return CV_OUTOFMEM_ERR;
-
-/*  alloc memory for the point's projections on the line    */
-    vv = (float *) cvAlloc( count * sizeof( float ));
-
-    if( vv == NULL )
-        return CV_OUTOFMEM_ERR;
-
-/*  alloc memory for the point's counter in the bickets     */
-    bin_counts = (int *) cvAlloc( nbins * sizeof( int ));
-
-    if( bin_counts == NULL )
-    {
-        status = CV_OUTOFMEM_ERR;
-        goto M_END;
-    }
-    memset( bin_counts, 0, nbins * sizeof( int ));
-
-/*  alloc memory for the point's counter in the bickets     */
-//    bin_countsj = (int*) icvAlloc(nbins*sizeof(int));
-//    if(bin_countsj == NULL) {status = CV_OUTOFMEM_ERR; goto M_END;}
-//    memset(bin_countsj,0,nbins*sizeof(int));
-
-    cvStartReadSeq( indexs, &reader, 0 );
-
-/*  alloc memory for the temporale point's numbers      */
-    tmp_number = (CvPoint *) cvAlloc( count * sizeof( CvPoint ));
-    if( tmp_number == NULL )
-    {
-        status = CV_OUTOFMEM_ERR;
-        goto M_END;
-    }
-
-/*  find min and max point's projection on the line     */
-    vmin = 1000;
-    vmax = -1000;
-    jmin = 1000;
-    jmax = -1000;
-    i_point = 0;
-    for( i = 0; i < count; i++ )
-    {
-/*
-        icvSubVector_32f ((IppmVect32f )&points[i], (IppmVect32f )&line[3], sub, 3);
-
-        icvCrossProduct2L_32f ((IppmVect32f )&line[0], sub, cros);
-*/
-
-        sub[0] = points[i].x - line[3];
-        sub[1] = points[i].y - line[4];
-        sub[2] = points[i].z - line[5];
-
-//      if(fabs(sub[0])<eps||fabs(sub[1])<eps||fabs(sub[2])<eps) continue;
-
-        a[0] = sub[0] * line[1] - sub[1] * line[0];
-        a[1] = sub[1] * line[2] - sub[2] * line[1];
-        a[2] = sub[2] * line[0] - sub[0] * line[2];
-
-        v_gor = icvDotProduct_32f( gor, &line[0], 3 );
-        v_ver = icvDotProduct_32f( ver, &line[0], 3 );
-
-        if( v_ver > v_gor )
-            log = true;
-        else
-            log = false;
-
-
-/*      if(IPPI_NORM_L22 ( cros ) < threshold2)    */
-/*
-        if(fabs(a[0])<eps && fabs(a[1])<eps && fabs(a[2])<eps)
-        {
-            icvDotProduct_32f( sub, &line[0], 3, &value);
-            if(value > vmax) vmax = value;
-            if(value < vmin) vmin = value;
-
-            vv[i_point] = value;
-
-            pt = (CvPoint* )icvGetSeqElem ( indexs, i, 0);
-
-            if(pt->x > jmax) jmax = pt->x;
-            if(pt->x < jmin) jmin = pt->x;
-
-            tmp_number[i_point] = *pt;
-            i_point++;
-        }
-        else
-*/
-        {
-            if( _CV_NORM_L32( a ) < threshold2 )
-            {
-                value = (float)icvDotProduct_32f( sub, &line[0], 3 );
-                if( value > vmax )
-                    vmax = value;
-                if( value < vmin )
-                    vmin = value;
-
-                vv[i_point] = value;
-
-                pt = (CvPoint*)cvGetSeqElem( indexs, i );
-
-                if( !log )
-                {
-                    if( pt->x > jmax )
-                        jmax = pt->x;
-                    if( pt->x < jmin )
-                        jmin = pt->x;
-                }
-                else
-                {
-                    if( pt->y > jmax )
-                        jmax = pt->y;
-                    if( pt->y < jmin )
-                        jmin = pt->y;
-                }
-
-
-                tmp_number[i_point] = *pt;
-                i_point++;
-            }
-        }
-    }
-
-/*  compute the length of one bucket along the line        */
-    vl = vmax - vmin;
-
-/*  examining on the arm's existence  */
-    if( vl < eps )
-    {
-        *numbers = NULL;
-        status = CV_OK;
-        goto M_END;
-    }
-
-    bsize = vl / nbins;
-
-/*  compute the number of points in each bucket along the line  */
-    for( i = 0; i < i_point; i++ )
-    {
-        l = cvRound( (vv[i] - vmin) / bsize );
-        bin_counts[l]++;
-    }
-
-    /*  compute the length of one bucket along the X axe        */
-    jl = jmax - jmin;
-    if( jl <= 1 )
-    {
-        *numbers = NULL;
-        status = CV_OK;
-        goto M_END;
-    }
-
-    bsizej = (float) (jl / (nbins + 0.));
-
-/*  compute the number of points in each bucket along the X axe */
-//    for(i=0;i<i_point;i++)
-//    {
-//        l = cvRound((tmp_number[i].x - jmin)/bsizej);
-//        bin_countsj[l]++;
-//    }
-
-
-    left = right = -1;
-
-/*  find the leftmost and the rightmost buckets           */
-    for( l = 0; l < nbins; l++ )
-    {
-        if( bin_counts[l] > low_count && left == -1 )
-            left = l;
-        else if( bin_counts[l] > low_count && left >= 0 )
-            right = l;
-
-    }
-
-/*  compute center point of the left hand     */
-    if( left == -1 && right == -1 )
-    {
-        *numbers = NULL;
-        status = CV_OK;
-        goto M_END;
-    }
-
-    hand_left = vmin + left * bsize;
-    j_left = (int) (jmin + left * bsizej);
-
-    vcl = hand_left + hand_length2;
-
-/*  compute center point of the right hand    */
-    hand_right = vmax - (nbins - right - 1) * bsize;
-    vcr = hand_right - hand_length2;
-
-    j_right = (int) (jmax - (nbins - right - 1) * bsizej);
-
-    j_left = abs( j_left - jc );
-    j_right = abs( j_right - jc );
-
-    if( j_left <= j_right )
-    {
-        hand_right = hand_left + hand_length;
-        vc = vcl;
-    }
-    else
-    {
-        hand_left = hand_right - hand_length;
-        vc = vcr;
-    }
-
-    icvScaleVector_32f( &line[0], sub, 3, vc );
-    icvAddVector_32f( &line[3], sub, (float *) center, 3 );
-
-/*  select hand's points and calculate mean value     */
-    *numbers = cvCreateSeq( CV_SEQ_POINT_SET, sizeof( CvSeq ), sizeof( CvPoint ), storage );
-    assert( *numbers != 0 );
-    if( *numbers == NULL )
-    {
-        status = CV_OUTOFMEM_ERR;
-        goto M_END;
-    }
-
-    cvStartAppendToSeq( *numbers, &writer );
-
-    for( l = 0; l < i_point; l++ )
-    {
-        if( vv[l] >= hand_left && vv[l] <= hand_right )
-        {
-            CV_WRITE_SEQ_ELEM( tmp_number[l], writer );
-
-        }
-    }
-
-    cvEndWriteSeq( &writer );
-
-  M_END:
-    if( tmp_number != NULL )
-        cvFree( &tmp_number );
-//    if(bin_countsj != NULL) cvFree( &bin_countsj );
-    if( bin_counts != NULL )
-        cvFree( &bin_counts );
-
-    if( vv != NULL )
-        cvFree( &vv );
-
-    if( sub != NULL ) icvDeleteVector (sub);
-    if( cros != NULL ) icvDeleteVector (cros);
-
-    return status;
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name:     cvFindHandRegion
-//    Purpose:  finds hand region in range image data
-//    Context:
-//    Parameters:
-//      points - pointer to the input point's set.
-//      count  - the number of the input points.
-//      indexs - pointer to the input sequence of the point's indexes
-//      line   - pointer to the 3D-line
-//      size   - size of the hand in meters
-//      flag   - hand direction's flag (0 - left, -1 - right,
-//               otherwise j-index of the initial image center)
-//      center - pointer to the output hand center
-//      storage - pointer to the memory storage
-//      numbers - pointer to the output sequence of the point's indexes inside
-//                hand region
-//
-//    Notes:
-//F*/
-CV_IMPL void
-cvFindHandRegion( CvPoint3D32f * points, int count,
-                  CvSeq * indexs,
-                  float *line, CvSize2D32f size, int flag,
-                  CvPoint3D32f * center, CvMemStorage * storage, CvSeq ** numbers )
-{
-    if(flag == 0 || flag == -1)
-    {
-        IPPI_CALL( icvFindHandRegion( points, count, indexs, line, size, -flag,
-                                       center, storage, numbers ));
-    }
-    else
-        IPPI_CALL( icvFindHandRegionA( points, count, indexs, line, size, flag,
-                                        center, storage, numbers ));
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name:     cvFindHandRegionA
-//    Purpose:  finds hand region in range image data
-//    Context:
-//    Parameters:
-//      points - pointer to the input point's set.
-//      count  - the number of the input points.
-//      indexs - pointer to the input sequence of the point's indexes
-//      line   - pointer to the 3D-line
-//      size   - size of the hand in meters
-//      jc     - j-index of the initial image center
-//      center - pointer to the output hand center
-//      storage - pointer to the memory storage
-//      numbers - pointer to the output sequence of the point's indexes inside
-//                hand region
-//
-//    Notes:
-//F*/
-CV_IMPL void
-cvFindHandRegionA( CvPoint3D32f * points, int count,
-                   CvSeq * indexs,
-                   float *line, CvSize2D32f size, int jc,
-                   CvPoint3D32f * center, CvMemStorage * storage, CvSeq ** numbers )
-{
-    IPPI_CALL( icvFindHandRegionA( points, count, indexs, line, size, jc,
-                                    center, storage, numbers ));
-}
diff --git a/modules/legacy/src/hmm.cpp b/modules/legacy/src/hmm.cpp
deleted file mode 100644 (file)
index d1196fe..0000000
+++ /dev/null
@@ -1,1697 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#define LN2PI 1.837877f
-#define BIG_FLT 1.e+10f
-
-
-#define _CV_ERGODIC 1
-#define _CV_CAUSAL 2
-
-#define _CV_LAST_STATE 1
-#define _CV_BEST_STATE 2
-
-
-//*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: _cvCreateObsInfo
-//    Purpose: The function allocates memory for CvImgObsInfo structure
-//             and its inner stuff
-//    Context:
-//    Parameters: obs_info - addres of pointer to CvImgObsInfo structure
-//                num_hor_obs - number of horizontal observation vectors
-//                num_ver_obs - number of horizontal observation vectors
-//                obs_size - length of observation vector
-//
-//    Returns: error status
-//
-//    Notes:
-//F*/
-static CvStatus CV_STDCALL icvCreateObsInfo(  CvImgObsInfo** obs_info,
-                                           CvSize num_obs, int obs_size )
-{
-    int total = num_obs.height * num_obs.width;
-
-    CvImgObsInfo* obs = (CvImgObsInfo*)cvAlloc( sizeof( CvImgObsInfo) );
-
-    obs->obs_x = num_obs.width;
-    obs->obs_y = num_obs.height;
-
-    obs->obs = (float*)cvAlloc( total * obs_size * sizeof(float) );
-
-    obs->state = (int*)cvAlloc( 2 * total * sizeof(int) );
-    obs->mix = (int*)cvAlloc( total * sizeof(int) );
-
-    obs->obs_size = obs_size;
-
-    obs_info[0] = obs;
-
-    return CV_NO_ERR;
-}
-
-static CvStatus CV_STDCALL icvReleaseObsInfo( CvImgObsInfo** p_obs_info )
-{
-    CvImgObsInfo* obs_info = p_obs_info[0];
-
-    cvFree( &(obs_info->obs) );
-    cvFree( &(obs_info->mix) );
-    cvFree( &(obs_info->state) );
-    cvFree( &(obs_info) );
-
-    p_obs_info[0] = NULL;
-
-    return CV_NO_ERR;
-}
-
-
-//*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvCreate2DHMM
-//    Purpose: The function allocates memory for 2-dimensional embedded HMM model
-//             and its inner stuff
-//    Context:
-//    Parameters: hmm - addres of pointer to CvEHMM structure
-//                state_number - array of hmm sizes (size of array == state_number[0]+1 )
-//                num_mix - number of gaussian mixtures in low-level HMM states
-//                          size of array is defined by previous array values
-//                obs_size - length of observation vectors
-//
-//    Returns: error status
-//
-//    Notes: state_number[0] - number of states in external HMM.
-//           state_number[i] - number of states in embedded HMM
-//
-//           example for face recognition: state_number = { 5 3 6 6 6 3 },
-//                                         length of num_mix array = 3+6+6+6+3 = 24//
-//
-//F*/
-static CvStatus CV_STDCALL icvCreate2DHMM( CvEHMM** this_hmm,
-                                         int* state_number, int* num_mix, int obs_size )
-{
-    int i;
-    int real_states = 0;
-
-    CvEHMMState* all_states;
-    CvEHMM* hmm;
-    int total_mix = 0;
-    float* pointers;
-
-    //compute total number of states of all level in 2d EHMM
-    for( i = 1; i <= state_number[0]; i++ )
-    {
-        real_states += state_number[i];
-    }
-
-    /* allocate memory for all hmms (from all levels) */
-    hmm = (CvEHMM*)cvAlloc( (state_number[0] + 1) * sizeof(CvEHMM) );
-
-    /* set number of superstates */
-    hmm[0].num_states = state_number[0];
-    hmm[0].level = 1;
-
-    /* allocate memory for all states */
-    all_states = (CvEHMMState *)cvAlloc( real_states * sizeof( CvEHMMState ) );
-
-    /* assign number of mixtures */
-    for( i = 0; i < real_states; i++ )
-    {
-        all_states[i].num_mix = num_mix[i];
-    }
-
-    /* compute size of inner of all real states */
-    for( i = 0; i < real_states; i++ )
-    {
-        total_mix += num_mix[i];
-    }
-    /* allocate memory for states stuff */
-    pointers = (float*)cvAlloc( total_mix * (2/*for mu invvar */ * obs_size +
-                                 2/*for weight and log_var_val*/ ) * sizeof( float) );
-
-    /* organize memory */
-    for( i = 0; i < real_states; i++ )
-    {
-        all_states[i].mu      = pointers; pointers += num_mix[i] * obs_size;
-        all_states[i].inv_var = pointers; pointers += num_mix[i] * obs_size;
-
-        all_states[i].log_var_val = pointers; pointers += num_mix[i];
-        all_states[i].weight      = pointers; pointers += num_mix[i];
-    }
-
-    /* set pointer to embedded hmm array */
-    hmm->u.ehmm = hmm + 1;
-
-    for( i = 0; i < hmm[0].num_states; i++ )
-    {
-        hmm[i+1].u.state = all_states;
-        all_states += state_number[i+1];
-        hmm[i+1].num_states = state_number[i+1];
-    }
-
-    for( i = 0; i <= state_number[0]; i++ )
-    {
-        hmm[i].transP = icvCreateMatrix_32f( hmm[i].num_states, hmm[i].num_states );
-        hmm[i].obsProb = NULL;
-        hmm[i].level = i ? 0 : 1;
-    }
-
-    /* if all ok - return pointer */
-    *this_hmm = hmm;
-    return CV_NO_ERR;
-}
-
-static CvStatus CV_STDCALL icvRelease2DHMM( CvEHMM** phmm )
-{
-    CvEHMM* hmm = phmm[0];
-    int i;
-    for( i = 0; i < hmm[0].num_states + 1; i++ )
-    {
-        icvDeleteMatrix( hmm[i].transP );
-    }
-
-    if (hmm->obsProb != NULL)
-    {
-        int* tmp = ((int*)(hmm->obsProb)) - 3;
-        cvFree( &(tmp)  );
-    }
-
-    cvFree( &(hmm->u.ehmm->u.state->mu) );
-    cvFree( &(hmm->u.ehmm->u.state) );
-
-
-    /* free hmm structures */
-    cvFree( phmm );
-
-    phmm[0] = NULL;
-
-    return CV_NO_ERR;
-}
-
-/* distance between 2 vectors */
-static float icvSquareDistance( CvVect32f v1, CvVect32f v2, int len )
-{
-    int i;
-    double dist0 = 0;
-    double dist1 = 0;
-
-    for( i = 0; i <= len - 4; i += 4 )
-    {
-        double t0 = v1[i] - v2[i];
-        double t1 = v1[i+1] - v2[i+1];
-        dist0 += t0*t0;
-        dist1 += t1*t1;
-
-        t0 = v1[i+2] - v2[i+2];
-        t1 = v1[i+3] - v2[i+3];
-        dist0 += t0*t0;
-        dist1 += t1*t1;
-    }
-
-    for( ; i < len; i++ )
-    {
-        double t0 = v1[i] - v2[i];
-        dist0 += t0*t0;
-    }
-
-    return (float)(dist0 + dist1);
-}
-
-/*can be used in CHMM & DHMM */
-static CvStatus CV_STDCALL
-icvUniformImgSegm(  CvImgObsInfo* obs_info, CvEHMM* hmm )
-{
-#if 1
-    /* implementation is very bad */
-    int  i, j, counter = 0;
-    CvEHMMState* first_state;
-    float inv_x = 1.f/obs_info->obs_x;
-    float inv_y = 1.f/obs_info->obs_y;
-
-    /* check arguments */
-    if ( !obs_info || !hmm ) return CV_NULLPTR_ERR;
-
-    first_state = hmm->u.ehmm->u.state;
-
-    for (i = 0; i < obs_info->obs_y; i++)
-    {
-        //bad line (division )
-        int superstate = (int)((i * hmm->num_states)*inv_y);/* /obs_info->obs_y; */
-
-        int index = (int)(hmm->u.ehmm[superstate].u.state - first_state);
-
-        for (j = 0; j < obs_info->obs_x; j++, counter++)
-        {
-            int state = (int)((j * hmm->u.ehmm[superstate].num_states)* inv_x); /* / obs_info->obs_x; */
-
-            obs_info->state[2 * counter] = superstate;
-            obs_info->state[2 * counter + 1] = state + index;
-        }
-    }
-#else
-    //this is not ready yet
-
-    int i,j,k,m;
-    CvEHMMState* first_state = hmm->u.ehmm->u.state;
-
-    /* check bad arguments */
-    if ( hmm->num_states > obs_info->obs_y ) return CV_BADSIZE_ERR;
-
-    //compute vertical subdivision
-    float row_per_state = (float)obs_info->obs_y / hmm->num_states;
-    float col_per_state[1024]; /* maximum 1024 superstates */
-
-    //for every horizontal band compute subdivision
-    for( i = 0; i < hmm->num_states; i++ )
-    {
-        CvEHMM* ehmm = &(hmm->u.ehmm[i]);
-        col_per_state[i] = (float)obs_info->obs_x / ehmm->num_states;
-    }
-
-    //compute state bounds
-    int ss_bound[1024];
-    for( i = 0; i < hmm->num_states - 1; i++ )
-    {
-        ss_bound[i] = floor( row_per_state * ( i+1 ) );
-    }
-    ss_bound[hmm->num_states - 1] = obs_info->obs_y;
-
-    //work inside every superstate
-
-    int row = 0;
-
-    for( i = 0; i < hmm->num_states; i++ )
-    {
-        CvEHMM* ehmm = &(hmm->u.ehmm[i]);
-        int index = ehmm->u.state - first_state;
-
-        //calc distribution in superstate
-        int es_bound[1024];
-        for( j = 0; j < ehmm->num_states - 1; j++ )
-        {
-            es_bound[j] = floor( col_per_state[i] * ( j+1 ) );
-        }
-        es_bound[ehmm->num_states - 1] = obs_info->obs_x;
-
-        //assign states to first row of superstate
-        int col = 0;
-        for( j = 0; j < ehmm->num_states; j++ )
-        {
-            for( k = col; k < es_bound[j]; k++, col++ )
-            {
-                obs_info->state[row * obs_info->obs_x + 2 * k] = i;
-                obs_info->state[row * obs_info->obs_x + 2 * k + 1] = j + index;
-            }
-            col = es_bound[j];
-        }
-
-        //copy the same to other rows of superstate
-        for( m = row; m < ss_bound[i]; m++ )
-        {
-            memcpy( &(obs_info->state[m * obs_info->obs_x * 2]),
-                    &(obs_info->state[row * obs_info->obs_x * 2]), obs_info->obs_x * 2 * sizeof(int) );
-        }
-
-        row = ss_bound[i];
-    }
-
-#endif
-
-    return CV_NO_ERR;
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: InitMixSegm
-//    Purpose: The function implements the mixture segmentation of the states of the
-//             embedded HMM
-//    Context: used with the Viterbi training of the embedded HMM
-//             Function uses K-Means algorithm for clustering
-//
-//    Parameters:  obs_info_array - array of pointers to image observations
-//                 num_img - length of above array
-//                 hmm - pointer to HMM structure
-//
-//    Returns: error status
-//
-//    Notes:
-//F*/
-static CvStatus CV_STDCALL
-icvInitMixSegm( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm )
-{
-    int  k, i, j;
-    int* num_samples; /* number of observations in every state */
-    int* counter;     /* array of counters for every state */
-
-    int**  a_class;   /* for every state - characteristic array */
-
-    CvVect32f** samples; /* for every state - pointer to observation vectors */
-    int***  samples_mix;   /* for every state - array of pointers to vectors mixtures */
-
-    CvTermCriteria criteria = cvTermCriteria( CV_TERMCRIT_EPS|CV_TERMCRIT_ITER,
-                                              1000,    /* iter */
-                                              0.01f ); /* eps  */
-
-    int total = 0;
-
-    CvEHMMState* first_state = hmm->u.ehmm->u.state;
-
-    for( i = 0 ; i < hmm->num_states; i++ )
-    {
-        total += hmm->u.ehmm[i].num_states;
-    }
-
-    /* for every state integer is allocated - number of vectors in state */
-    num_samples = (int*)cvAlloc( total * sizeof(int) );
-
-    /* integer counter is allocated for every state */
-    counter = (int*)cvAlloc( total * sizeof(int) );
-
-    samples = (CvVect32f**)cvAlloc( total * sizeof(CvVect32f*) );
-    samples_mix = (int***)cvAlloc( total * sizeof(int**) );
-
-    /* clear */
-    memset( num_samples, 0 , total*sizeof(int) );
-    memset( counter, 0 , total*sizeof(int) );
-
-
-    /* for every state the number of vectors which belong to it is computed (smth. like histogram) */
-    for (k = 0; k < num_img; k++)
-    {
-        CvImgObsInfo* obs = obs_info_array[k];
-        int count = 0;
-
-        for (i = 0; i < obs->obs_y; i++)
-        {
-            for (j = 0; j < obs->obs_x; j++, count++)
-            {
-                int state = obs->state[ 2 * count + 1];
-                num_samples[state] += 1;
-            }
-        }
-    }
-
-    /* for every state int* is allocated */
-    a_class = (int**)cvAlloc( total*sizeof(int*) );
-
-    for (i = 0; i < total; i++)
-    {
-        a_class[i] = (int*)cvAlloc( num_samples[i] * sizeof(int) );
-        samples[i] = (CvVect32f*)cvAlloc( num_samples[i] * sizeof(CvVect32f) );
-        samples_mix[i] = (int**)cvAlloc( num_samples[i] * sizeof(int*) );
-    }
-
-    /* for every state vectors which belong to state are gathered */
-    for (k = 0; k < num_img; k++)
-    {
-        CvImgObsInfo* obs = obs_info_array[k];
-        int num_obs = ( obs->obs_x ) * ( obs->obs_y );
-        float* vector = obs->obs;
-
-        for (i = 0; i < num_obs; i++, vector+=obs->obs_size )
-        {
-            int state = obs->state[2*i+1];
-
-            samples[state][counter[state]] = vector;
-            samples_mix[state][counter[state]] = &(obs->mix[i]);
-            counter[state]++;
-        }
-    }
-
-    /* clear counters */
-    memset( counter, 0, total*sizeof(int) );
-
-    /* do the actual clustering using the K Means algorithm */
-    for (i = 0; i < total; i++)
-    {
-        if ( first_state[i].num_mix == 1)
-        {
-            for (k = 0; k < num_samples[i]; k++)
-            {
-                /* all vectors belong to one mixture */
-                a_class[i][k] = 0;
-            }
-        }
-        else if( num_samples[i] )
-        {
-            /* clusterize vectors  */
-            cvKMeans( first_state[i].num_mix, samples[i], num_samples[i],
-                      obs_info_array[0]->obs_size, criteria, a_class[i] );
-        }
-    }
-
-    /* for every vector number of mixture is assigned */
-    for( i = 0; i < total; i++ )
-    {
-        for (j = 0; j < num_samples[i]; j++)
-        {
-            samples_mix[i][j][0] = a_class[i][j];
-        }
-    }
-
-    for (i = 0; i < total; i++)
-    {
-        cvFree( &(a_class[i]) );
-        cvFree( &(samples[i]) );
-        cvFree( &(samples_mix[i]) );
-    }
-
-    cvFree( &a_class );
-    cvFree( &samples );
-    cvFree( &samples_mix );
-    cvFree( &counter );
-    cvFree( &num_samples );
-
-    return CV_NO_ERR;
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: ComputeUniModeGauss
-//    Purpose: The function computes the Gaussian pdf for a sample vector
-//    Context:
-//    Parameters:  obsVeq - pointer to the sample vector
-//                 mu - pointer to the mean vector of the Gaussian pdf
-//                 var - pointer to the variance vector of the Gaussian pdf
-//                 VecSize - the size of sample vector
-//
-//    Returns: the pdf of the sample vector given the specified Gaussian
-//
-//    Notes:
-//F*/
-/*static float icvComputeUniModeGauss(CvVect32f vect, CvVect32f mu,
-                              CvVect32f inv_var, float log_var_val, int vect_size)
-{
-    int n;
-    double tmp;
-    double prob;
-
-    prob = -log_var_val;
-
-    for (n = 0; n < vect_size; n++)
-    {
-        tmp = (vect[n] - mu[n]) * inv_var[n];
-        prob = prob - tmp * tmp;
-   }
-   //prob *= 0.5f;
-
-   return (float)prob;
-}*/
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: ComputeGaussMixture
-//    Purpose: The function computes the mixture Gaussian pdf of a sample vector.
-//    Context:
-//    Parameters:  obsVeq - pointer to the sample vector
-//                 mu  - two-dimensional pointer to the mean vector of the Gaussian pdf;
-//                       the first dimension is indexed over the number of mixtures and
-//                       the second dimension is indexed along the size of the mean vector
-//                 var - two-dimensional pointer to the variance vector of the Gaussian pdf;
-//                       the first dimension is indexed over the number of mixtures and
-//                       the second dimension is indexed along the size of the variance vector
-//                 VecSize - the size of sample vector
-//                 weight - pointer to the wights of the Gaussian mixture
-//                 NumMix - the number of Gaussian mixtures
-//
-//    Returns: the pdf of the sample vector given the specified Gaussian mixture.
-//
-//    Notes:
-//F*/
-/* Calculate probability of observation at state in logarithmic scale*/
-/*static float
-icvComputeGaussMixture( CvVect32f vect, float* mu,
-                        float* inv_var, float* log_var_val,
-                        int vect_size, float* weight, int num_mix )
-{
-    double prob, l_prob;
-
-    prob = 0.0f;
-
-    if (num_mix == 1)
-    {
-        return icvComputeUniModeGauss( vect, mu, inv_var, log_var_val[0], vect_size);
-    }
-    else
-    {
-        int m;
-        for (m = 0; m < num_mix; m++)
-        {
-            if ( weight[m] > 0.0)
-            {
-                l_prob = icvComputeUniModeGauss(vect, mu + m*vect_size,
-                                                        inv_var + m * vect_size,
-                                                        log_var_val[m],
-                                                        vect_size);
-
-                prob = prob + weight[m]*exp((double)l_prob);
-            }
-        }
-        prob = log(prob);
-    }
-    return (float)prob;
-}*/
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: EstimateObsProb
-//    Purpose: The function computes the probability of every observation in every state
-//    Context:
-//    Parameters:  obs_info - observations
-//                 hmm      - hmm
-//    Returns: error status
-//
-//    Notes:
-//F*/
-static CvStatus CV_STDCALL icvEstimateObsProb( CvImgObsInfo* obs_info, CvEHMM* hmm )
-{
-    int i, j;
-    int total_states = 0;
-
-    /* check if matrix exist and check current size
-       if not sufficient - realloc */
-    int status = 0; /* 1 - not allocated, 2 - allocated but small size,
-                       3 - size is enough, but distribution is bad, 0 - all ok */
-
-    for( j = 0; j < hmm->num_states; j++ )
-    {
-       total_states += hmm->u.ehmm[j].num_states;
-    }
-
-    if ( hmm->obsProb == NULL )
-    {
-        /* allocare memory */
-        int need_size = ( obs_info->obs_x * obs_info->obs_y * total_states * sizeof(float) +
-                          obs_info->obs_y * hmm->num_states * sizeof( CvMatr32f) );
-
-        int* buffer = (int*)cvAlloc( need_size + 3 * sizeof(int) );
-        buffer[0] = need_size;
-        buffer[1] = obs_info->obs_y;
-        buffer[2] = obs_info->obs_x;
-        hmm->obsProb = (float**) (buffer + 3);
-        status = 3;
-
-    }
-    else
-    {
-        /* check current size */
-        int* total= (int*)(((int*)(hmm->obsProb)) - 3);
-        int need_size = ( obs_info->obs_x * obs_info->obs_y * total_states * sizeof(float) +
-                          obs_info->obs_y * hmm->num_states * sizeof( CvMatr32f/*(float*)*/ ) );
-
-        assert( sizeof(float*) == sizeof(int) );
-
-        if ( need_size > (*total) )
-        {
-            int* buffer = ((int*)(hmm->obsProb)) - 3;
-            cvFree( &buffer);
-            buffer = (int*)cvAlloc( need_size + 3 * sizeof(int));
-            buffer[0] = need_size;
-            buffer[1] = obs_info->obs_y;
-            buffer[2] = obs_info->obs_x;
-
-            hmm->obsProb = (float**)(buffer + 3);
-
-            status = 3;
-        }
-    }
-    if (!status)
-    {
-        int* obsx = ((int*)(hmm->obsProb)) - 1;
-        int* obsy = ((int*)(hmm->obsProb)) - 2;
-
-        assert( (*obsx > 0) && (*obsy > 0) );
-
-        /* is good distribution? */
-        if ( (obs_info->obs_x > (*obsx) ) || (obs_info->obs_y > (*obsy) ) )
-            status = 3;
-    }
-
-    /* if bad status - do reallocation actions */
-    assert( (status == 0) || (status == 3) );
-
-    if ( status )
-    {
-        float** tmp = hmm->obsProb;
-        float*  tmpf;
-
-        /* distribute pointers of ehmm->obsProb */
-        for( i = 0; i < hmm->num_states; i++ )
-        {
-            hmm->u.ehmm[i].obsProb = tmp;
-            tmp += obs_info->obs_y;
-        }
-
-        tmpf = (float*)tmp;
-
-        /* distribute pointers of ehmm->obsProb[j] */
-        for( i = 0; i < hmm->num_states; i++ )
-        {
-            CvEHMM* ehmm = &( hmm->u.ehmm[i] );
-
-            for( j = 0; j < obs_info->obs_y; j++ )
-            {
-                ehmm->obsProb[j] = tmpf;
-                tmpf += ehmm->num_states * obs_info->obs_x;
-            }
-        }
-    }/* end of pointer distribution */
-
-#if 1
-    {
-#define MAX_BUF_SIZE  1200
-        float  local_log_mix_prob[MAX_BUF_SIZE];
-        double local_mix_prob[MAX_BUF_SIZE];
-        int    vect_size = obs_info->obs_size;
-        CvStatus res = CV_NO_ERR;
-
-        float*  log_mix_prob = local_log_mix_prob;
-        double* mix_prob = local_mix_prob;
-
-        int  max_size = 0;
-        int  obs_x = obs_info->obs_x;
-
-        /* calculate temporary buffer size */
-        for( i = 0; i < hmm->num_states; i++ )
-        {
-            CvEHMM* ehmm = &(hmm->u.ehmm[i]);
-            CvEHMMState* state = ehmm->u.state;
-
-            int max_mix = 0;
-            for( j = 0; j < ehmm->num_states; j++ )
-            {
-                int t = state[j].num_mix;
-                if( max_mix < t ) max_mix = t;
-            }
-            max_mix *= ehmm->num_states;
-            if( max_size < max_mix ) max_size = max_mix;
-        }
-
-        max_size *= obs_x * vect_size;
-
-        /* allocate buffer */
-        if( max_size > MAX_BUF_SIZE )
-        {
-            log_mix_prob = (float*)cvAlloc( max_size*(sizeof(float) + sizeof(double)));
-            if( !log_mix_prob ) return CV_OUTOFMEM_ERR;
-            mix_prob = (double*)(log_mix_prob + max_size);
-        }
-
-        memset( log_mix_prob, 0, max_size*sizeof(float));
-
-        /*****************computing probabilities***********************/
-
-        /* loop through external states */
-        for( i = 0; i < hmm->num_states; i++ )
-        {
-            CvEHMM* ehmm = &(hmm->u.ehmm[i]);
-            CvEHMMState* state = ehmm->u.state;
-
-            int max_mix = 0;
-            int n_states = ehmm->num_states;
-
-            /* determine maximal number of mixtures (again) */
-            for( j = 0; j < ehmm->num_states; j++ )
-            {
-                int t = state[j].num_mix;
-                if( max_mix < t ) max_mix = t;
-            }
-
-            /* loop through rows of the observation matrix */
-            for( j = 0; j < obs_info->obs_y; j++ )
-            {
-                int  m, n;
-
-                float* obs = obs_info->obs + j * obs_x * vect_size;
-                float* log_mp = max_mix > 1 ? log_mix_prob : ehmm->obsProb[j];
-                double* mp = mix_prob;
-
-                /* several passes are done below */
-
-                /* 1. calculate logarithms of probabilities for each mixture */
-
-                /* loop through mixtures */
-                for( m = 0; m < max_mix; m++ )
-                {
-                    /* set pointer to first observation in the line */
-                    float* vect = obs;
-
-                    /* cycles through obseravtions in the line */
-                    for( n = 0; n < obs_x; n++, vect += vect_size, log_mp += n_states )
-                    {
-                        int k, l;
-                        for( l = 0; l < n_states; l++ )
-                        {
-                            if( state[l].num_mix > m )
-                            {
-                                float* mu = state[l].mu + m*vect_size;
-                                float* inv_var = state[l].inv_var + m*vect_size;
-                                double prob = -state[l].log_var_val[m];
-                                for( k = 0; k < vect_size; k++ )
-                                {
-                                    double t = (vect[k] - mu[k])*inv_var[k];
-                                    prob -= t*t;
-                                }
-                                log_mp[l] = MAX( (float)prob, -500 );
-                            }
-                        }
-                    }
-                }
-
-                /* skip the rest if there is a single mixture */
-                if( max_mix == 1 ) continue;
-
-                /* 2. calculate exponent of log_mix_prob
-                      (i.e. probability for each mixture) */
-                cvbFastExp( log_mix_prob, mix_prob, max_mix * obs_x * n_states );
-
-                /* 3. sum all mixtures with weights */
-                /* 3a. first mixture - simply scale by weight */
-                for( n = 0; n < obs_x; n++, mp += n_states )
-                {
-                    int l;
-                    for( l = 0; l < n_states; l++ )
-                    {
-                        mp[l] *= state[l].weight[0];
-                    }
-                }
-
-                /* 3b. add other mixtures */
-                for( m = 1; m < max_mix; m++ )
-                {
-                    int ofs = -m*obs_x*n_states;
-                    for( n = 0; n < obs_x; n++, mp += n_states )
-                    {
-                        int l;
-                        for( l = 0; l < n_states; l++ )
-                        {
-                            if( m < state[l].num_mix )
-                            {
-                                mp[l + ofs] += mp[l] * state[l].weight[m];
-                            }
-                        }
-                    }
-                }
-
-                /* 4. Put logarithms of summary probabilities to the destination matrix */
-                cvbFastLog( mix_prob, ehmm->obsProb[j], obs_x * n_states );
-            }
-        }
-
-        if( log_mix_prob != local_log_mix_prob ) cvFree( &log_mix_prob );
-        return res;
-#undef MAX_BUF_SIZE
-    }
-#else
-    for( i = 0; i < hmm->num_states; i++ )
-    {
-        CvEHMM* ehmm = &(hmm->u.ehmm[i]);
-        CvEHMMState* state = ehmm->u.state;
-
-        for( j = 0; j < obs_info->obs_y; j++ )
-        {
-            int k,m;
-
-            int obs_index = j * obs_info->obs_x;
-
-            float* B = ehmm->obsProb[j];
-
-            /* cycles through obs and states */
-            for( k = 0; k < obs_info->obs_x; k++ )
-            {
-                CvVect32f vect = (obs_info->obs) + (obs_index + k) * vect_size;
-
-                float* matr_line = B + k * ehmm->num_states;
-
-                for( m = 0; m < ehmm->num_states; m++ )
-                {
-                    matr_line[m] = icvComputeGaussMixture( vect, state[m].mu, state[m].inv_var,
-                                                             state[m].log_var_val, vect_size, state[m].weight,
-                                                             state[m].num_mix );
-                }
-            }
-        }
-    }
-#endif
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: EstimateTransProb
-//    Purpose: The function calculates the state and super state transition probabilities
-//             of the model given the images,
-//             the state segmentation and the input parameters
-//    Context:
-//    Parameters: obs_info_array - array of pointers to image observations
-//                num_img - length of above array
-//                hmm - pointer to HMM structure
-//    Returns: void
-//
-//    Notes:
-//F*/
-static CvStatus CV_STDCALL
-icvEstimateTransProb( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm )
-{
-    int  i, j, k;
-
-    CvEHMMState* first_state = hmm->u.ehmm->u.state;
-    /* as a counter we will use transP matrix */
-
-    /* initialization */
-
-    /* clear transP */
-    icvSetZero_32f( hmm->transP, hmm->num_states, hmm->num_states );
-    for (i = 0; i < hmm->num_states; i++ )
-    {
-        icvSetZero_32f( hmm->u.ehmm[i].transP , hmm->u.ehmm[i].num_states, hmm->u.ehmm[i].num_states );
-    }
-
-    /* compute the counters */
-    for (i = 0; i < num_img; i++)
-    {
-        int counter = 0;
-        CvImgObsInfo* info = obs_info_array[i];
-
-        for (j = 0; j < info->obs_y; j++)
-        {
-            for (k = 0; k < info->obs_x; k++, counter++)
-            {
-                /* compute how many transitions from state to state
-                   occured both in horizontal and vertical direction */
-                int superstate, state;
-                int nextsuperstate, nextstate;
-                int begin_ind;
-
-                superstate = info->state[2 * counter];
-                begin_ind = (int)(hmm->u.ehmm[superstate].u.state - first_state);
-                state = info->state[ 2 * counter + 1] - begin_ind;
-
-                if (j < info->obs_y - 1)
-                {
-                    int transP_size = hmm->num_states;
-
-                    nextsuperstate = info->state[ 2*(counter + info->obs_x) ];
-
-                    hmm->transP[superstate * transP_size + nextsuperstate] += 1;
-                }
-
-                if (k < info->obs_x - 1)
-                {
-                    int transP_size = hmm->u.ehmm[superstate].num_states;
-
-                    nextstate = info->state[2*(counter+1) + 1] - begin_ind;
-                    hmm->u.ehmm[superstate].transP[ state * transP_size + nextstate] += 1;
-                }
-            }
-        }
-    }
-    /* estimate superstate matrix */
-    for( i = 0; i < hmm->num_states; i++)
-    {
-        float total = 0;
-        float inv_total;
-        for( j = 0; j < hmm->num_states; j++)
-        {
-            total += hmm->transP[i * hmm->num_states + j];
-        }
-        //assert( total );
-
-        inv_total = total ? 1.f/total : 0;
-
-        for( j = 0; j < hmm->num_states; j++)
-        {
-            hmm->transP[i * hmm->num_states + j] =
-                hmm->transP[i * hmm->num_states + j] ?
-                (float)log( hmm->transP[i * hmm->num_states + j] * inv_total ) : -BIG_FLT;
-        }
-    }
-
-    /* estimate other matrices */
-    for( k = 0; k < hmm->num_states; k++ )
-    {
-        CvEHMM* ehmm = &(hmm->u.ehmm[k]);
-
-        for( i = 0; i < ehmm->num_states; i++)
-        {
-            float total = 0;
-            float inv_total;
-            for( j = 0; j < ehmm->num_states; j++)
-            {
-                total += ehmm->transP[i*ehmm->num_states + j];
-            }
-            //assert( total );
-            inv_total = total ? 1.f/total :  0;
-
-            for( j = 0; j < ehmm->num_states; j++)
-            {
-                ehmm->transP[i * ehmm->num_states + j] =
-                    (ehmm->transP[i * ehmm->num_states + j]) ?
-                    (float)log( ehmm->transP[i * ehmm->num_states + j] * inv_total) : -BIG_FLT ;
-            }
-        }
-    }
-    return CV_NO_ERR;
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: MixSegmL2
-//    Purpose: The function implements the mixture segmentation of the states of the
-//             embedded HMM
-//    Context: used with the Viterbi training of the embedded HMM
-//
-//    Parameters:
-//             obs_info_array
-//             num_img
-//             hmm
-//    Returns: void
-//
-//    Notes:
-//F*/
-static CvStatus CV_STDCALL
-icvMixSegmL2( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm )
-{
-    int     k, i, j, m;
-
-    CvEHMMState* state = hmm->u.ehmm[0].u.state;
-
-
-    for (k = 0; k < num_img; k++)
-    {
-        int counter = 0;
-        CvImgObsInfo* info = obs_info_array[k];
-
-        for (i = 0; i < info->obs_y; i++)
-        {
-            for (j = 0; j < info->obs_x; j++, counter++)
-            {
-                int e_state = info->state[2 * counter + 1];
-                float min_dist;
-
-                min_dist = icvSquareDistance((info->obs) + (counter * info->obs_size),
-                                               state[e_state].mu, info->obs_size);
-                info->mix[counter] = 0;
-
-                for (m = 1; m < state[e_state].num_mix; m++)
-                {
-                    float dist=icvSquareDistance( (info->obs) + (counter * info->obs_size),
-                                                    state[e_state].mu + m * info->obs_size,
-                                                    info->obs_size);
-                    if (dist < min_dist)
-                    {
-                        min_dist = dist;
-                        /* assign mixture with smallest distance */
-                        info->mix[counter] = m;
-                    }
-                }
-            }
-        }
-    }
-    return CV_NO_ERR;
-}
-
-/*
-CvStatus icvMixSegmProb(CvImgObsInfo* obs_info, int num_img, CvEHMM* hmm )
-{
-    int     k, i, j, m;
-
-    CvEHMMState* state = hmm->ehmm[0].state_info;
-
-
-    for (k = 0; k < num_img; k++)
-    {
-        int counter = 0;
-        CvImgObsInfo* info = obs_info + k;
-
-        for (i = 0; i < info->obs_y; i++)
-        {
-            for (j = 0; j < info->obs_x; j++, counter++)
-            {
-                int e_state = info->in_state[counter];
-                float max_prob;
-
-                max_prob = icvComputeUniModeGauss( info->obs[counter], state[e_state].mu[0],
-                                                    state[e_state].inv_var[0],
-                                                    state[e_state].log_var[0],
-                                                    info->obs_size );
-                info->mix[counter] = 0;
-
-                for (m = 1; m < state[e_state].num_mix; m++)
-                {
-                    float prob=icvComputeUniModeGauss(info->obs[counter], state[e_state].mu[m],
-                                                       state[e_state].inv_var[m],
-                                                       state[e_state].log_var[m],
-                                                       info->obs_size);
-                    if (prob > max_prob)
-                    {
-                        max_prob = prob;
-                        // assign mixture with greatest probability.
-                        info->mix[counter] = m;
-                    }
-                }
-            }
-        }
-    }
-
-    return CV_NO_ERR;
-}
-*/
-static CvStatus CV_STDCALL
-icvViterbiSegmentation( int num_states, int /*num_obs*/, CvMatr32f transP,
-                        CvMatr32f B, int start_obs, int prob_type,
-                        int** q, int min_num_obs, int max_num_obs,
-                        float* prob )
-{
-    // memory allocation
-    int i, j, last_obs;
-    int m_HMMType = _CV_ERGODIC; /* _CV_CAUSAL or _CV_ERGODIC */
-
-    int m_ProbType   = prob_type; /* _CV_LAST_STATE or _CV_BEST_STATE */
-
-    int m_minNumObs  = min_num_obs; /*??*/
-    int m_maxNumObs  = max_num_obs; /*??*/
-
-    int m_numStates  = num_states;
-
-    float* m_pi = (float*)cvAlloc( num_states* sizeof(float) );
-    CvMatr32f m_a = transP;
-
-    // offset brobability matrix to starting observation
-    CvMatr32f m_b = B + start_obs * num_states;
-    //so m_xl will not be used more
-
-    //m_xl = start_obs;
-
-    /*     if (muDur != NULL){
-    m_d = new int[m_numStates];
-    m_l = new double[m_numStates];
-    for (i = 0; i < m_numStates; i++){
-    m_l[i] = muDur[i];
-    }
-    }
-    else{
-    m_d = NULL;
-    m_l = NULL;
-    }
-    */
-
-    CvMatr32f m_Gamma = icvCreateMatrix_32f( num_states, m_maxNumObs );
-    int* m_csi = (int*)cvAlloc( num_states * m_maxNumObs * sizeof(int) );
-
-    //stores maximal result for every ending observation */
-    CvVect32f   m_MaxGamma = prob;
-
-
-//    assert( m_xl + max_num_obs <= num_obs );
-
-    /*??m_q          = new int*[m_maxNumObs - m_minNumObs];
-      ??for (i = 0; i < m_maxNumObs - m_minNumObs; i++)
-      ??     m_q[i] = new int[m_minNumObs + i + 1];
-    */
-
-    /******************************************************************/
-    /*    Viterbi initialization                                      */
-    /* set initial state probabilities, in logarithmic scale */
-    for (i = 0; i < m_numStates; i++)
-    {
-        m_pi[i] = -BIG_FLT;
-    }
-    m_pi[0] = 0.0f;
-
-    for  (i = 0; i < num_states; i++)
-    {
-        m_Gamma[0 * num_states + i] = m_pi[i] + m_b[0 * num_states + i];
-        m_csi[0 * num_states + i] = 0;
-    }
-
-    /******************************************************************/
-    /*    Viterbi recursion                                           */
-
-    if ( m_HMMType == _CV_CAUSAL ) //causal model
-    {
-        int t;
-
-        for (t = 1 ; t < m_maxNumObs; t++)
-        {
-            // evaluate self-to-self transition for state 0
-            m_Gamma[t * num_states + 0] = m_Gamma[(t-1) * num_states + 0] + m_a[0];
-            m_csi[t * num_states + 0] = 0;
-
-            for (j = 1; j < num_states; j++)
-            {
-                float self = m_Gamma[ (t-1) * num_states + j] + m_a[ j * num_states + j];
-                float prev = m_Gamma[ (t-1) * num_states +(j-1)] + m_a[ (j-1) * num_states + j];
-
-                if ( prev > self )
-                {
-                    m_csi[t * num_states + j] = j-1;
-                    m_Gamma[t * num_states + j] = prev;
-                }
-                else
-                {
-                    m_csi[t * num_states + j] = j;
-                    m_Gamma[t * num_states + j] = self;
-                }
-
-                m_Gamma[t * num_states + j] = m_Gamma[t * num_states + j] + m_b[t * num_states + j];
-            }
-        }
-    }
-    else if ( m_HMMType == _CV_ERGODIC ) //ergodic model
-    {
-        int t;
-        for (t = 1 ; t < m_maxNumObs; t++)
-        {
-            for (j = 0; j < num_states; j++)
-            {
-                m_Gamma[ t*num_states + j] = m_Gamma[(t-1) * num_states + 0] + m_a[0*num_states+j];
-                m_csi[t *num_states + j] = 0;
-
-                for (i = 1; i < num_states; i++)
-                {
-                    float currGamma = m_Gamma[(t-1) *num_states + i] + m_a[i *num_states + j];
-                    if (currGamma > m_Gamma[t *num_states + j])
-                    {
-                        m_Gamma[t * num_states + j] = currGamma;
-                        m_csi[t * num_states + j] = i;
-                    }
-                }
-                m_Gamma[t *num_states + j] = m_Gamma[t *num_states + j] + m_b[t * num_states + j];
-            }
-        }
-    }
-
-    for( last_obs = m_minNumObs-1, i = 0; last_obs < m_maxNumObs; last_obs++, i++ )
-    {
-        int t;
-
-        /******************************************************************/
-        /*    Viterbi termination                                         */
-
-        if ( m_ProbType == _CV_LAST_STATE )
-        {
-            m_MaxGamma[i] = m_Gamma[last_obs * num_states + num_states - 1];
-            q[i][last_obs] = num_states - 1;
-        }
-        else if( m_ProbType == _CV_BEST_STATE )
-        {
-            int k;
-            q[i][last_obs] = 0;
-            m_MaxGamma[i] = m_Gamma[last_obs * num_states + 0];
-
-            for(k = 1; k < num_states; k++)
-            {
-                if ( m_Gamma[last_obs * num_states + k] > m_MaxGamma[i] )
-                {
-                    m_MaxGamma[i] = m_Gamma[last_obs * num_states + k];
-                    q[i][last_obs] = k;
-                }
-            }
-        }
-
-        /******************************************************************/
-        /*    Viterbi backtracking                                        */
-        for  (t = last_obs-1; t >= 0; t--)
-        {
-            q[i][t] = m_csi[(t+1) * num_states + q[i][t+1] ];
-        }
-    }
-
-    /* memory free */
-    cvFree( &m_pi );
-    cvFree( &m_csi );
-    icvDeleteMatrix( m_Gamma );
-
-    return CV_NO_ERR;
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvEViterbi
-//    Purpose: The function calculates the embedded Viterbi algorithm
-//             for 1 image
-//    Context:
-//    Parameters:
-//             obs_info - observations
-//             hmm      - HMM
-//
-//    Returns: the Embedded Viterbi probability (float)
-//             and do state segmentation of observations
-//
-//    Notes:
-//F*/
-static float CV_STDCALL icvEViterbi( CvImgObsInfo* obs_info, CvEHMM* hmm )
-{
-    int    i, j, counter;
-    float  log_likelihood;
-
-    float inv_obs_x = 1.f / obs_info->obs_x;
-
-    CvEHMMState* first_state = hmm->u.ehmm->u.state;
-
-    /* memory allocation for superB */
-    CvMatr32f superB = icvCreateMatrix_32f(hmm->num_states, obs_info->obs_y );
-
-    /* memory allocation for q */
-    int*** q = (int***)cvAlloc( hmm->num_states * sizeof(int**) );
-    int* super_q = (int*)cvAlloc( obs_info->obs_y * sizeof(int) );
-
-    for (i = 0; i < hmm->num_states; i++)
-    {
-        q[i] = (int**)cvAlloc( obs_info->obs_y * sizeof(int*) );
-
-        for (j = 0; j < obs_info->obs_y ; j++)
-        {
-            q[i][j] = (int*)cvAlloc( obs_info->obs_x * sizeof(int) );
-        }
-    }
-
-    /* start Viterbi segmentation */
-    for (i = 0; i < hmm->num_states; i++)
-    {
-        CvEHMM* ehmm = &(hmm->u.ehmm[i]);
-
-        for (j = 0; j < obs_info->obs_y; j++)
-        {
-            float max_gamma;
-
-            /* 1D HMM Viterbi segmentation */
-            icvViterbiSegmentation( ehmm->num_states, obs_info->obs_x,
-                ehmm->transP, ehmm->obsProb[j], 0,
-                _CV_LAST_STATE, &q[i][j], obs_info->obs_x,
-                obs_info->obs_x, &max_gamma);
-
-            superB[j * hmm->num_states + i] = max_gamma * inv_obs_x;
-        }
-    }
-
-    /* perform global Viterbi segmentation (i.e. process higher-level HMM) */
-
-    icvViterbiSegmentation( hmm->num_states, obs_info->obs_y,
-                             hmm->transP, superB, 0,
-                             _CV_LAST_STATE, &super_q, obs_info->obs_y,
-                             obs_info->obs_y, &log_likelihood );
-
-    log_likelihood /= obs_info->obs_y ;
-
-
-    counter = 0;
-    /* assign new state to observation vectors */
-    for (i = 0; i < obs_info->obs_y; i++)
-    {
-        for (j = 0; j < obs_info->obs_x; j++, counter++)
-        {
-            int superstate = super_q[i];
-            int state = (int)(hmm->u.ehmm[superstate].u.state - first_state);
-
-            obs_info->state[2 * counter] = superstate;
-            obs_info->state[2 * counter + 1] = state + q[superstate][i][j];
-        }
-    }
-
-    /* memory deallocation for superB */
-    icvDeleteMatrix( superB );
-
-    /*memory deallocation for q */
-    for (i = 0; i < hmm->num_states; i++)
-    {
-        for (j = 0; j < obs_info->obs_y ; j++)
-        {
-            cvFree( &q[i][j] );
-        }
-        cvFree( &q[i] );
-    }
-
-    cvFree( &q );
-    cvFree( &super_q );
-
-    return log_likelihood;
-}
-
-static CvStatus CV_STDCALL
-icvEstimateHMMStateParams( CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm )
-{
-    /* compute gamma, weights, means, vars */
-    int k, i, j, m;
-    int total = 0;
-    int vect_len = obs_info_array[0]->obs_size;
-
-    float start_log_var_val = LN2PI * vect_len;
-
-    CvVect32f tmp_vect = icvCreateVector_32f( vect_len );
-
-    CvEHMMState* first_state = hmm->u.ehmm[0].u.state;
-
-    assert( sizeof(float) == sizeof(int) );
-
-    for(i = 0; i < hmm->num_states; i++ )
-    {
-        total+= hmm->u.ehmm[i].num_states;
-    }
-
-    /***************Gamma***********************/
-    /* initialize gamma */
-    for( i = 0; i < total; i++ )
-    {
-        for (m = 0; m < first_state[i].num_mix; m++)
-        {
-            ((int*)(first_state[i].weight))[m] = 0;
-        }
-    }
-
-    /* maybe gamma must be computed in mixsegm process ?? */
-
-    /* compute gamma */
-    for (k = 0; k < num_img; k++)
-    {
-        CvImgObsInfo* info = obs_info_array[k];
-        int num_obs = info->obs_y * info->obs_x;
-
-        for (i = 0; i < num_obs; i++)
-        {
-            int state, mixture;
-            state = info->state[2*i + 1];
-            mixture = info->mix[i];
-            /* computes gamma - number of observations corresponding
-               to every mixture of every state */
-            ((int*)(first_state[state].weight))[mixture] += 1;
-        }
-    }
-    /***************Mean and Var***********************/
-    /* compute means and variances of every item */
-    /* initially variance placed to inv_var */
-    /* zero mean and variance */
-    for (i = 0; i < total; i++)
-    {
-        memset( (void*)first_state[i].mu, 0, first_state[i].num_mix * vect_len *
-                                                                         sizeof(float) );
-        memset( (void*)first_state[i].inv_var, 0, first_state[i].num_mix * vect_len *
-                                                                         sizeof(float) );
-    }
-
-    /* compute sums */
-    for (i = 0; i < num_img; i++)
-    {
-        CvImgObsInfo* info = obs_info_array[i];
-        int total_obs = info->obs_x * info->obs_y;
-
-        float* vector = info->obs;
-
-        for (j = 0; j < total_obs; j++, vector+=vect_len )
-        {
-            int state = info->state[2 * j + 1];
-            int mixture = info->mix[j];
-
-            CvVect32f mean  = first_state[state].mu + mixture * vect_len;
-            CvVect32f mean2 = first_state[state].inv_var + mixture * vect_len;
-
-            icvAddVector_32f( mean, vector, mean, vect_len );
-            for( k = 0; k < vect_len; k++ )
-                mean2[k] += vector[k]*vector[k];
-        }
-    }
-
-    /*compute the means and variances */
-    /* assume gamma already computed */
-    for (i = 0; i < total; i++)
-    {
-        CvEHMMState* state = &(first_state[i]);
-
-        for (m = 0; m < state->num_mix; m++)
-        {
-            CvVect32f mu  = state->mu + m * vect_len;
-            CvVect32f invar = state->inv_var + m * vect_len;
-
-            if ( ((int*)state->weight)[m] > 1)
-            {
-                float inv_gamma = 1.f/((int*)(state->weight))[m];
-
-                icvScaleVector_32f( mu, mu, vect_len, inv_gamma);
-                icvScaleVector_32f( invar, invar, vect_len, inv_gamma);
-            }
-
-            icvMulVectors_32f(mu, mu, tmp_vect, vect_len);
-            icvSubVector_32f( invar, tmp_vect, invar, vect_len);
-
-            /* low bound of variance - 100 (Ara's experimental result) */
-            for( k = 0; k < vect_len; k++ )
-            {
-                invar[k] = (invar[k] > 100.f) ? invar[k] : 100.f;
-            }
-
-            /* compute log_var */
-            state->log_var_val[m] = start_log_var_val;
-            for( k = 0; k < vect_len; k++ )
-            {
-                state->log_var_val[m] += (float)log( invar[k] );
-            }
-
-            /* SMOLI 27.10.2000 */
-            state->log_var_val[m] *= 0.5;
-
-
-            /* compute inv_var = 1/sqrt(2*variance) */
-            icvScaleVector_32f(invar, invar, vect_len, 2.f );
-            cvbInvSqrt( invar, invar, vect_len );
-        }
-    }
-
-    /***************Weights***********************/
-    /* normilize gammas - i.e. compute mixture weights */
-
-    //compute weights
-    for (i = 0; i < total; i++)
-    {
-        int gamma_total = 0;
-        float norm;
-
-        for (m = 0; m < first_state[i].num_mix; m++)
-        {
-            gamma_total += ((int*)(first_state[i].weight))[m];
-        }
-
-        norm = gamma_total ? (1.f/(float)gamma_total) : 0.f;
-
-        for (m = 0; m < first_state[i].num_mix; m++)
-        {
-            first_state[i].weight[m] = ((int*)(first_state[i].weight))[m] * norm;
-        }
-    }
-
-    icvDeleteVector( tmp_vect);
-    return CV_NO_ERR;
-}
-
-/*
-CvStatus icvLightingCorrection8uC1R( uchar* img, CvSize roi, int src_step )
-{
-    int i, j;
-    int width = roi.width;
-    int height = roi.height;
-
-    float x1, x2, y1, y2;
-    int f[3] = {0, 0, 0};
-    float a[3] = {0, 0, 0};
-
-    float h1;
-    float h2;
-
-    float c1,c2;
-
-    float min = FLT_MAX;
-    float max = -FLT_MAX;
-    float correction;
-
-    float* float_img = icvAlloc( width * height * sizeof(float) );
-
-    x1 = width * (width + 1) / 2.0f; // Sum (1, ... , width)
-    x2 = width * (width + 1 ) * (2 * width + 1) / 6.0f; // Sum (1^2, ... , width^2)
-    y1 = height * (height + 1)/2.0f; // Sum (1, ... , width)
-    y2 = height * (height + 1 ) * (2 * height + 1) / 6.0f; // Sum (1^2, ... , width^2)
-
-
-    // extract grayvalues
-    for (i = 0; i < height; i++)
-    {
-        for (j = 0; j < width; j++)
-        {
-            f[2] = f[2] + j * img[i*src_step + j];
-            f[1] = f[1] + i * img[i*src_step + j];
-            f[0] = f[0] +     img[i*src_step + j];
-        }
-    }
-
-    h1 = (float)f[0] * (float)x1 / (float)width;
-    h2 = (float)f[0] * (float)y1 / (float)height;
-
-    a[2] = ((float)f[2] - h1) / (float)(x2*height - x1*x1*height/(float)width);
-    a[1] = ((float)f[1] - h2) / (float)(y2*width - y1*y1*width/(float)height);
-    a[0] = (float)f[0]/(float)(width*height) - (float)y1*a[1]/(float)height -
-        (float)x1*a[2]/(float)width;
-
-    for (i = 0; i < height; i++)
-    {
-        for (j = 0; j < width; j++)
-        {
-
-            correction = a[0] + a[1]*(float)i + a[2]*(float)j;
-
-            float_img[i*width + j] = img[i*src_step + j] - correction;
-
-            if (float_img[i*width + j] < min) min = float_img[i*width+j];
-            if (float_img[i*width + j] > max) max = float_img[i*width+j];
-        }
-    }
-
-    //rescaling to the range 0:255
-    c2 = 0;
-    if (max == min)
-        c2 = 255.0f;
-    else
-        c2 = 255.0f/(float)(max - min);
-
-    c1 = (-(float)min)*c2;
-
-    for (i = 0; i < height; i++)
-    {
-        for (j = 0; j < width; j++)
-        {
-            int value = (int)floor(c2*float_img[i*width + j] + c1);
-            if (value < 0) value = 0;
-            if (value > 255) value = 255;
-            img[i*src_step + j] = (uchar)value;
-        }
-    }
-
-    cvFree( &float_img );
-    return CV_NO_ERR;
-}
-
-
-CvStatus icvLightingCorrection( icvImage* img )
-{
-    CvSize roi;
-    if ( img->type != IPL_DEPTH_8U || img->channels != 1 )
-    return CV_BADFACTOR_ERR;
-
-    roi = _cvSize( img->roi.width, img->roi.height );
-
-    return _cvLightingCorrection8uC1R( img->data + img->roi.y * img->step + img->roi.x,
-                                        roi, img->step );
-
-}
-
-*/
-
-CV_IMPL CvEHMM*
-cvCreate2DHMM( int *state_number, int *num_mix, int obs_size )
-{
-    CvEHMM* hmm = 0;
-
-    IPPI_CALL( icvCreate2DHMM( &hmm, state_number, num_mix, obs_size ));
-
-    return hmm;
-}
-
-CV_IMPL void
-cvRelease2DHMM( CvEHMM ** hmm )
-{
-    IPPI_CALL( icvRelease2DHMM( hmm ));
-}
-
-CV_IMPL CvImgObsInfo*
-cvCreateObsInfo( CvSize num_obs, int obs_size )
-{
-    CvImgObsInfo *obs_info = 0;
-
-    IPPI_CALL( icvCreateObsInfo( &obs_info, num_obs, obs_size ));
-
-    return obs_info;
-}
-
-CV_IMPL void
-cvReleaseObsInfo( CvImgObsInfo ** obs_info )
-{
-    IPPI_CALL( icvReleaseObsInfo( obs_info ));
-}
-
-
-CV_IMPL void
-cvUniformImgSegm( CvImgObsInfo * obs_info, CvEHMM * hmm )
-{
-    IPPI_CALL( icvUniformImgSegm( obs_info, hmm ));
-}
-
-CV_IMPL void
-cvInitMixSegm( CvImgObsInfo ** obs_info_array, int num_img, CvEHMM * hmm )
-{
-    IPPI_CALL( icvInitMixSegm( obs_info_array, num_img, hmm ));
-}
-
-CV_IMPL void
-cvEstimateHMMStateParams( CvImgObsInfo ** obs_info_array, int num_img, CvEHMM * hmm )
-{
-    IPPI_CALL( icvEstimateHMMStateParams( obs_info_array, num_img, hmm ));
-}
-
-CV_IMPL void
-cvEstimateTransProb( CvImgObsInfo ** obs_info_array, int num_img, CvEHMM * hmm )
-{
-    IPPI_CALL( icvEstimateTransProb( obs_info_array, num_img, hmm ));
-}
-
-CV_IMPL void
-cvEstimateObsProb( CvImgObsInfo * obs_info, CvEHMM * hmm )
-{
-    IPPI_CALL( icvEstimateObsProb( obs_info, hmm ));
-}
-
-CV_IMPL float
-cvEViterbi( CvImgObsInfo * obs_info, CvEHMM * hmm )
-{
-    if( (obs_info == NULL) || (hmm == NULL) )
-        CV_Error( CV_BadDataPtr, "Null pointer." );
-
-    return icvEViterbi( obs_info, hmm );
-}
-
-CV_IMPL void
-cvMixSegmL2( CvImgObsInfo ** obs_info_array, int num_img, CvEHMM * hmm )
-{
-    IPPI_CALL( icvMixSegmL2( obs_info_array, num_img, hmm ));
-}
-
-/* End of file */
diff --git a/modules/legacy/src/hmm1d.cpp b/modules/legacy/src/hmm1d.cpp
deleted file mode 100644 (file)
index 5daee86..0000000
+++ /dev/null
@@ -1,1150 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-
-#include "precomp.hpp"
-
-#if 0
-
-#define LN2PI 1.837877f
-#define BIG_FLT 1.e+10f
-
-
-#define _CV_ERGODIC 1
-#define _CV_CAUSAL 2
-
-#define _CV_LAST_STATE 1
-#define _CV_BEST_STATE 2
-
-//*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvForward1DHMM
-//    Purpose: The function performs baum-welsh algorithm
-//    Context:
-//    Parameters: obs_info - addres of pointer to CvImgObsInfo structure
-//                num_hor_obs - number of horizontal observation vectors
-//                num_ver_obs - number of horizontal observation vectors
-//                obs_size - length of observation vector
-//
-//    Returns: error status
-//
-//    Notes:
-//F*/
-#if 0
-CvStatus icvForward1DHMM( int num_states, int num_obs, CvMatr64d A,
-                          CvMatr64d B,
-                          double* scales)
-{
-    // assume that observation and transition
-    // probabilities already computed
-    int m_HMMType  = _CV_CAUSAL;
-    double* m_pi = icvAlloc( num_states* sizeof( double) );
-
-    /* alpha is matrix
-       rows throuhg states
-       columns through time
-    */
-    double* alpha = icvAlloc( num_states*num_obs * sizeof( double ) );
-
-    /* All calculations will be in non-logarithmic domain */
-
-    /* Initialization */
-    /* set initial state probabilities */
-    m_pi[0] = 1;
-    for (i = 1; i < num_states; i++)
-    {
-        m_pi[i] = 0.0;
-    }
-
-    for  (i = 0; i < num_states; i++)
-    {
-        alpha[i] = m_pi[i] * m_b[ i];
-    }
-
-    /******************************************************************/
-    /*   Induction                                                    */
-
-    if ( m_HMMType == _CV_ERGODIC )
-    {
-        int t;
-        for (t = 1 ; t < num_obs; t++)
-        {
-            for (j = 0; j < num_states; j++)
-            {
-               double sum = 0.0;
-               int i;
-
-                for (i = 0; i < num_states; i++)
-                {
-                     sum += alpha[(t - 1) * num_states + i] * A[i * num_states + j];
-                }
-
-                alpha[(t - 1) * num_states + j] = sum * B[t * num_states + j];
-
-                /* add computed alpha to scale factor */
-                sum_alpha += alpha[(t - 1) * num_states + j];
-            }
-
-            double scale = 1/sum_alpha;
-
-            /* scale alpha */
-            for (j = 0; j < num_states; j++)
-            {
-                alpha[(t - 1) * num_states + j] *= scale;
-            }
-
-            scales[t] = scale;
-
-        }
-    }
-
-#endif
-
-
-
-//*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvCreateObsInfo
-//    Purpose: The function allocates memory for CvImgObsInfo structure
-//             and its inner stuff
-//    Context:
-//    Parameters: obs_info - addres of pointer to CvImgObsInfo structure
-//                num_hor_obs - number of horizontal observation vectors
-//                num_ver_obs - number of horizontal observation vectors
-//                obs_size - length of observation vector
-//
-//    Returns: error status
-//
-//    Notes:
-//F*/
-/*CvStatus icvCreateObsInfo( CvImgObsInfo** obs_info,
-                              CvSize num_obs, int obs_size )
-{
-    int total = num_obs.height * num_obs.width;
-
-    CvImgObsInfo* obs = (CvImgObsInfo*)icvAlloc( sizeof( CvImgObsInfo) );
-
-    obs->obs_x = num_obs.width;
-    obs->obs_y = num_obs.height;
-
-    obs->obs = (float*)icvAlloc( total * obs_size * sizeof(float) );
-
-    obs->state = (int*)icvAlloc( 2 * total * sizeof(int) );
-    obs->mix = (int*)icvAlloc( total * sizeof(int) );
-
-    obs->obs_size = obs_size;
-
-    obs_info[0] = obs;
-
-    return CV_NO_ERR;
-}*/
-
-/*CvStatus icvReleaseObsInfo( CvImgObsInfo** p_obs_info )
-{
-    CvImgObsInfo* obs_info = p_obs_info[0];
-
-    icvFree( &(obs_info->obs) );
-    icvFree( &(obs_info->mix) );
-    icvFree( &(obs_info->state) );
-    icvFree( &(obs_info) );
-
-    p_obs_info[0] = NULL;
-
-    return CV_NO_ERR;
-} */
-
-
-//*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvCreate1DHMM
-//    Purpose: The function allocates memory for 1-dimensional HMM
-//             and its inner stuff
-//    Context:
-//    Parameters: hmm - addres of pointer to CvEHMM structure
-//                state_number - number of states in HMM
-//                num_mix - number of gaussian mixtures in HMM states
-//                          size of array is defined by previous parameter
-//                obs_size - length of observation vectors
-//
-//    Returns: error status
-//    Notes:
-//F*/
-CvStatus icvCreate1DHMM( CvEHMM** this_hmm,
-                         int state_number, int* num_mix, int obs_size )
-{
-    int i;
-    int real_states = state_number;
-
-    CvEHMMState* all_states;
-    CvEHMM* hmm;
-    int total_mix = 0;
-    float* pointers;
-
-    /* allocate memory for hmm */
-    hmm = (CvEHMM*)icvAlloc( sizeof(CvEHMM) );
-
-    /* set number of superstates */
-    hmm->num_states = state_number;
-    hmm->level = 0;
-
-    /* allocate memory for all states */
-    all_states = (CvEHMMState *)icvAlloc( real_states * sizeof( CvEHMMState ) );
-
-    /* assign number of mixtures */
-    for( i = 0; i < real_states; i++ )
-    {
-        all_states[i].num_mix = num_mix[i];
-    }
-
-    /* compute size of inner of all real states */
-    for( i = 0; i < real_states; i++ )
-    {
-        total_mix += num_mix[i];
-    }
-    /* allocate memory for states stuff */
-    pointers = (float*)icvAlloc( total_mix * (2/*for mu invvar */ * obs_size +
-                                 2/*for weight and log_var_val*/ ) * sizeof( float) );
-
-    /* organize memory */
-    for( i = 0; i < real_states; i++ )
-    {
-        all_states[i].mu      = pointers; pointers += num_mix[i] * obs_size;
-        all_states[i].inv_var = pointers; pointers += num_mix[i] * obs_size;
-
-        all_states[i].log_var_val = pointers; pointers += num_mix[i];
-        all_states[i].weight      = pointers; pointers += num_mix[i];
-    }
-    hmm->u.state = all_states;
-
-    hmm->transP = icvCreateMatrix_32f( hmm->num_states, hmm->num_states );
-    hmm->obsProb = NULL;
-
-    /* if all ok - return pointer */
-    *this_hmm = hmm;
-    return CV_NO_ERR;
-}
-
-CvStatus icvRelease1DHMM( CvEHMM** phmm )
-{
-    CvEHMM* hmm = phmm[0];
-    icvDeleteMatrix( hmm->transP );
-
-    if (hmm->obsProb != NULL)
-    {
-        int* tmp = ((int*)(hmm->obsProb)) - 3;
-        icvFree( &(tmp)  );
-    }
-
-    icvFree( &(hmm->u.state->mu) );
-    icvFree( &(hmm->u.state) );
-
-    phmm[0] = NULL;
-
-    return CV_NO_ERR;
-}
-
-/*can be used in CHMM & DHMM */
-CvStatus icvUniform1DSegm( Cv1DObsInfo* obs_info, CvEHMM* hmm )
-{
-    /* implementation is very bad */
-    int  i;
-    CvEHMMState* first_state;
-
-    /* check arguments */
-    if ( !obs_info || !hmm ) return CV_NULLPTR_ERR;
-
-    first_state = hmm->u.state;
-
-    for (i = 0; i < obs_info->obs_x; i++)
-    {
-        //bad line (division )
-        int state = (i * hmm->num_states)/obs_info->obs_x;
-        obs_info->state[i] = state;
-    }
-    return CV_NO_ERR;
-}
-
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: InitMixSegm
-//    Purpose: The function implements the mixture segmentation of the states of the embedded HMM
-//    Context: used with the Viterbi training of the embedded HMM
-//             Function uses K-Means algorithm for clustering
-//
-//    Parameters:  obs_info_array - array of pointers to image observations
-//                 num_img - length of above array
-//                 hmm - pointer to HMM structure
-//
-//    Returns: error status
-//
-//    Notes:
-//F*/
-CvStatus icvInit1DMixSegm(Cv1DObsInfo** obs_info_array, int num_img, CvEHMM* hmm)
-{
-    int  k, i, j;
-    int* num_samples; /* number of observations in every state */
-    int* counter;     /* array of counters for every state */
-
-    int**  a_class;   /* for every state - characteristic array */
-
-    CvVect32f** samples; /* for every state - pointer to observation vectors */
-    int***  samples_mix;   /* for every state - array of pointers to vectors mixtures */
-
-    CvTermCriteria criteria = cvTermCriteria( CV_TERMCRIT_EPS|CV_TERMCRIT_ITER,
-                                              1000,    /* iter */
-                                              0.01f ); /* eps  */
-
-    int total = hmm->num_states;
-    CvEHMMState* first_state = hmm->u.state;
-
-    /* for every state integer is allocated - number of vectors in state */
-    num_samples = (int*)icvAlloc( total * sizeof(int) );
-
-    /* integer counter is allocated for every state */
-    counter = (int*)icvAlloc( total * sizeof(int) );
-
-    samples = (CvVect32f**)icvAlloc( total * sizeof(CvVect32f*) );
-    samples_mix = (int***)icvAlloc( total * sizeof(int**) );
-
-    /* clear */
-    memset( num_samples, 0 , total*sizeof(int) );
-    memset( counter, 0 , total*sizeof(int) );
-
-
-    /* for every state the number of vectors which belong to it is computed (smth. like histogram) */
-    for (k = 0; k < num_img; k++)
-    {
-        CvImgObsInfo* obs = obs_info_array[k];
-
-        for (i = 0; i < obs->obs_x; i++)
-        {
-            int state = obs->state[ i ];
-            num_samples[state] += 1;
-        }
-    }
-
-    /* for every state int* is allocated */
-    a_class = (int**)icvAlloc( total*sizeof(int*) );
-
-    for (i = 0; i < total; i++)
-    {
-        a_class[i] = (int*)icvAlloc( num_samples[i] * sizeof(int) );
-        samples[i] = (CvVect32f*)icvAlloc( num_samples[i] * sizeof(CvVect32f) );
-        samples_mix[i] = (int**)icvAlloc( num_samples[i] * sizeof(int*) );
-    }
-
-    /* for every state vectors which belong to state are gathered */
-    for (k = 0; k < num_img; k++)
-    {
-        CvImgObsInfo* obs = obs_info_array[k];
-        int num_obs = obs->obs_x;
-        float* vector = obs->obs;
-
-        for (i = 0; i < num_obs; i++, vector+=obs->obs_size )
-        {
-            int state = obs->state[i];
-
-            samples[state][counter[state]] = vector;
-            samples_mix[state][counter[state]] = &(obs->mix[i]);
-            counter[state]++;
-        }
-    }
-
-    /* clear counters */
-    memset( counter, 0, total*sizeof(int) );
-
-    /* do the actual clustering using the K Means algorithm */
-    for (i = 0; i < total; i++)
-    {
-        if ( first_state[i].num_mix == 1)
-        {
-            for (k = 0; k < num_samples[i]; k++)
-            {
-                /* all vectors belong to one mixture */
-                a_class[i][k] = 0;
-            }
-        }
-        else if( num_samples[i] )
-        {
-            /* clusterize vectors  */
-            icvKMeans( first_state[i].num_mix, samples[i], num_samples[i],
-                obs_info_array[0]->obs_size, criteria, a_class[i] );
-        }
-    }
-
-    /* for every vector number of mixture is assigned */
-    for( i = 0; i < total; i++ )
-    {
-        for (j = 0; j < num_samples[i]; j++)
-        {
-            samples_mix[i][j][0] = a_class[i][j];
-        }
-    }
-
-   for (i = 0; i < total; i++)
-    {
-        icvFree( &(a_class[i]) );
-        icvFree( &(samples[i]) );
-        icvFree( &(samples_mix[i]) );
-    }
-
-    icvFree( &a_class );
-    icvFree( &samples );
-    icvFree( &samples_mix );
-    icvFree( &counter );
-    icvFree( &num_samples );
-
-
-    return CV_NO_ERR;
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: ComputeUniModeGauss
-//    Purpose: The function computes the Gaussian pdf for a sample vector
-//    Context:
-//    Parameters:  obsVeq - pointer to the sample vector
-//                 mu - pointer to the mean vector of the Gaussian pdf
-//                 var - pointer to the variance vector of the Gaussian pdf
-//                 VecSize - the size of sample vector
-//
-//    Returns: the pdf of the sample vector given the specified Gaussian
-//
-//    Notes:
-//F*/
-/*float icvComputeUniModeGauss(CvVect32f vect, CvVect32f mu,
-                              CvVect32f inv_var, float log_var_val, int vect_size)
-{
-    int n;
-    double tmp;
-    double prob;
-
-    prob = -log_var_val;
-
-    for (n = 0; n < vect_size; n++)
-    {
-        tmp = (vect[n] - mu[n]) * inv_var[n];
-        prob = prob - tmp * tmp;
-   }
-   //prob *= 0.5f;
-
-   return (float)prob;
-}*/
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: ComputeGaussMixture
-//    Purpose: The function computes the mixture Gaussian pdf of a sample vector.
-//    Context:
-//    Parameters:  obsVeq - pointer to the sample vector
-//                 mu  - two-dimensional pointer to the mean vector of the Gaussian pdf;
-//                       the first dimension is indexed over the number of mixtures and
-//                       the second dimension is indexed along the size of the mean vector
-//                 var - two-dimensional pointer to the variance vector of the Gaussian pdf;
-//                       the first dimension is indexed over the number of mixtures and
-//                       the second dimension is indexed along the size of the variance vector
-//                 VecSize - the size of sample vector
-//                 weight - pointer to the wights of the Gaussian mixture
-//                 NumMix - the number of Gaussian mixtures
-//
-//    Returns: the pdf of the sample vector given the specified Gaussian mixture.
-//
-//    Notes:
-//F*/
-/* Calculate probability of observation at state in logarithmic scale*/
-/*float icvComputeGaussMixture( CvVect32f vect, float* mu,
-                                float* inv_var, float* log_var_val,
-                                int vect_size, float* weight, int num_mix )
-{
-    double prob, l_prob;
-
-    prob = 0.0f;
-
-    if (num_mix == 1)
-    {
-        return icvComputeUniModeGauss( vect, mu, inv_var, log_var_val[0], vect_size);
-    }
-    else
-    {
-        int m;
-        for (m = 0; m < num_mix; m++)
-        {
-            if ( weight[m] > 0.0)
-            {
-                l_prob = icvComputeUniModeGauss(vect, mu + m*vect_size,
-                                                        inv_var + m * vect_size,
-                                                        log_var_val[m],
-                                                        vect_size);
-
-                prob = prob + weight[m]*exp((double)l_prob);
-            }
-        }
-        prob = log(prob);
-    }
-    return (float)prob;
-}
-*/
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: EstimateObsProb
-//    Purpose: The function computes the probability of every observation in every state
-//    Context:
-//    Parameters:  obs_info - observations
-//                 hmm      - hmm
-//    Returns: error status
-//
-//    Notes:
-//F*/
-CvStatus icvEstimate1DObsProb(CvImgObsInfo* obs_info, CvEHMM* hmm )
-{
-    int j;
-    int total_states = 0;
-
-    /* check if matrix exist and check current size
-       if not sufficient - realloc */
-    int status = 0; /* 1 - not allocated, 2 - allocated but small size,
-                       3 - size is enough, but distribution is bad, 0 - all ok */
-
-    /*for( j = 0; j < hmm->num_states; j++ )
-    {
-       total_states += hmm->u.ehmm[j].num_states;
-    }*/
-    total_states = hmm->num_states;
-
-    if ( hmm->obsProb == NULL )
-    {
-        /* allocare memory */
-        int need_size = ( obs_info->obs_x /* * obs_info->obs_y*/ * total_states * sizeof(float) /* +
-                          obs_info->obs_y * hmm->num_states * sizeof( CvMatr32f) */);
-
-        int* buffer = (int*)icvAlloc( need_size + 3 * sizeof(int) );
-        buffer[0] = need_size;
-        buffer[1] = obs_info->obs_y;
-        buffer[2] = obs_info->obs_x;
-        hmm->obsProb = (float**) (buffer + 3);
-        status = 3;
-
-    }
-    else
-    {
-        /* check current size */
-        int* total= (int*)(((int*)(hmm->obsProb)) - 3);
-        int need_size = ( obs_info->obs_x /* * obs_info->obs_y*/ * total_states * sizeof(float) /* +
-                           obs_info->obs_y * hmm->num_states * sizeof( CvMatr32f(float*)  )*/ );
-
-        assert( sizeof(float*) == sizeof(int) );
-
-        if ( need_size > (*total) )
-        {
-            int* buffer = ((int*)(hmm->obsProb)) - 3;
-            icvFree( &buffer);
-            buffer = (int*)icvAlloc( need_size + 3);
-            buffer[0] = need_size;
-            buffer[1] = obs_info->obs_y;
-            buffer[2] = obs_info->obs_x;
-
-            hmm->obsProb = (float**)(buffer + 3);
-
-            status = 3;
-        }
-    }
-    if (!status)
-    {
-        int* obsx = ((int*)(hmm->obsProb)) - 1;
-        //int* obsy = ((int*)(hmm->obsProb)) - 2;
-
-        assert( /*(*obsy > 0) &&*/ (*obsx > 0) );
-
-        /* is good distribution? */
-        if ( (obs_info->obs_x > (*obsx) ) /* || (obs_info->obs_y > (*obsy) ) */ )
-            status = 3;
-    }
-
-    assert( (status == 0) || (status == 3) );
-    /* if bad status - do reallocation actions */
-    if ( status )
-    {
-        float** tmp = hmm->obsProb;
-        //float*  tmpf;
-
-        /* distribute pointers of ehmm->obsProb */
-/*        for( i = 0; i < hmm->num_states; i++ )
-        {
-            hmm->u.ehmm[i].obsProb = tmp;
-            tmp += obs_info->obs_y;
-        }
-*/
-        //tmpf = (float*)tmp;
-
-        /* distribute pointers of ehmm->obsProb[j] */
-/*      for( i = 0; i < hmm->num_states; i++ )
-        {
-            CvEHMM* ehmm = &( hmm->u.ehmm[i] );
-
-            for( j = 0; j < obs_info->obs_y; j++ )
-            {
-                ehmm->obsProb[j] = tmpf;
-                tmpf += ehmm->num_states * obs_info->obs_x;
-            }
-        }
-*/
-        hmm->obsProb = tmp;
-
-    }/* end of pointer distribution */
-
-#if 1
-    {
-#define MAX_BUF_SIZE  1200
-        float  local_log_mix_prob[MAX_BUF_SIZE];
-        double local_mix_prob[MAX_BUF_SIZE];
-        int    vect_size = obs_info->obs_size;
-        CvStatus res = CV_NO_ERR;
-
-        float*  log_mix_prob = local_log_mix_prob;
-        double* mix_prob = local_mix_prob;
-
-        int  max_size = 0;
-        int  obs_x = obs_info->obs_x;
-
-        /* calculate temporary buffer size */
-        //for( i = 0; i < hmm->num_states; i++ )
-        //{
-        //    CvEHMM* ehmm = &(hmm->u.ehmm[i]);
-            CvEHMMState* state = hmm->u.state;
-
-            int max_mix = 0;
-            for( j = 0; j < hmm->num_states; j++ )
-            {
-                int t = state[j].num_mix;
-                if( max_mix < t ) max_mix = t;
-            }
-            max_mix *= hmm->num_states;
-            /*if( max_size < max_mix )*/ max_size = max_mix;
-        //}
-
-        max_size *= obs_x * vect_size;
-
-        /* allocate buffer */
-        if( max_size > MAX_BUF_SIZE )
-        {
-            log_mix_prob = (float*)icvAlloc( max_size*(sizeof(float) + sizeof(double)));
-            if( !log_mix_prob ) return CV_OUTOFMEM_ERR;
-            mix_prob = (double*)(log_mix_prob + max_size);
-        }
-
-        memset( log_mix_prob, 0, max_size*sizeof(float));
-
-        /*****************computing probabilities***********************/
-
-        /* loop through external states */
-        //for( i = 0; i < hmm->num_states; i++ )
-        {
-        //    CvEHMM* ehmm = &(hmm->u.ehmm[i]);
-            CvEHMMState* state = hmm->u.state;
-
-            int max_mix = 0;
-            int n_states = hmm->num_states;
-
-            /* determine maximal number of mixtures (again) */
-            for( j = 0; j < hmm->num_states; j++ )
-            {
-                int t = state[j].num_mix;
-                if( max_mix < t ) max_mix = t;
-            }
-
-            /* loop through rows of the observation matrix */
-            //for( j = 0; j < obs_info->obs_y; j++ )
-            {
-                int  m, n;
-
-                float* obs = obs_info->obs;/* + j * obs_x * vect_size; */
-                float* log_mp = max_mix > 1 ? log_mix_prob : (float*)(hmm->obsProb);
-                double* mp = mix_prob;
-
-                /* several passes are done below */
-
-                /* 1. calculate logarithms of probabilities for each mixture */
-
-                /* loop through mixtures */
-    /*  !!!! */     for( m = 0; m < max_mix; m++ )
-                {
-                    /* set pointer to first observation in the line */
-                    float* vect = obs;
-
-                    /* cycles through obseravtions in the line */
-                    for( n = 0; n < obs_x; n++, vect += vect_size, log_mp += n_states )
-                    {
-                        int k, l;
-                        for( l = 0; l < n_states; l++ )
-                        {
-                            if( state[l].num_mix > m )
-                            {
-                                float* mu = state[l].mu + m*vect_size;
-                                float* inv_var = state[l].inv_var + m*vect_size;
-                                double prob = -state[l].log_var_val[m];
-                                for( k = 0; k < vect_size; k++ )
-                                {
-                                    double t = (vect[k] - mu[k])*inv_var[k];
-                                    prob -= t*t;
-                                }
-                                log_mp[l] = MAX( (float)prob, -500 );
-                            }
-                        }
-                    }
-                }
-
-                /* skip the rest if there is a single mixture */
-                if( max_mix != 1 )
-                {
-                    /* 2. calculate exponent of log_mix_prob
-                          (i.e. probability for each mixture) */
-                    res = icvbExp_32f64f( log_mix_prob, mix_prob,
-                                            max_mix * obs_x * n_states );
-                    if( res < 0 ) goto processing_exit;
-
-                    /* 3. sum all mixtures with weights */
-                    /* 3a. first mixture - simply scale by weight */
-                    for( n = 0; n < obs_x; n++, mp += n_states )
-                    {
-                        int l;
-                        for( l = 0; l < n_states; l++ )
-                        {
-                            mp[l] *= state[l].weight[0];
-                        }
-                    }
-
-                    /* 3b. add other mixtures */
-                    for( m = 1; m < max_mix; m++ )
-                    {
-                        int ofs = -m*obs_x*n_states;
-                        for( n = 0; n < obs_x; n++, mp += n_states )
-                        {
-                            int l;
-                            for( l = 0; l < n_states; l++ )
-                            {
-                                if( m < state[l].num_mix )
-                                {
-                                    mp[l + ofs] += mp[l] * state[l].weight[m];
-                                }
-                            }
-                        }
-                    }
-
-                    /* 4. Put logarithms of summary probabilities to the destination matrix */
-                    res = icvbLog_64f32f( mix_prob, (float*)(hmm->obsProb),//[j],
-                                            obs_x * n_states );
-                    if( res < 0 ) goto processing_exit;
-                }
-            }
-        }
-
-processing_exit:
-
-        if( log_mix_prob != local_log_mix_prob ) icvFree( &log_mix_prob );
-        return res;
-#undef MAX_BUF_SIZE
-    }
-#else
-/*    for( i = 0; i < hmm->num_states; i++ )
-    {
-        CvEHMM* ehmm = &(hmm->u.ehmm[i]);
-        CvEHMMState* state = ehmm->u.state;
-
-        for( j = 0; j < obs_info->obs_y; j++ )
-        {
-            int k,m;
-
-            int obs_index = j * obs_info->obs_x;
-
-            float* B = ehmm->obsProb[j];
-
-            // cycles through obs and states
-            for( k = 0; k < obs_info->obs_x; k++ )
-            {
-                CvVect32f vect = (obs_info->obs) + (obs_index + k) * vect_size;
-
-                float* matr_line = B + k * ehmm->num_states;
-
-                for( m = 0; m < ehmm->num_states; m++ )
-                {
-                    matr_line[m] = icvComputeGaussMixture( vect, state[m].mu, state[m].inv_var,
-                                                             state[m].log_var_val, vect_size, state[m].weight,
-                                                             state[m].num_mix );
-                }
-            }
-        }
-    }
-*/
-#endif
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: EstimateTransProb
-//    Purpose: The function calculates the state and super state transition probabilities
-//             of the model given the images,
-//             the state segmentation and the input parameters
-//    Context:
-//    Parameters: obs_info_array - array of pointers to image observations
-//                num_img - length of above array
-//                hmm - pointer to HMM structure
-//    Returns: void
-//
-//    Notes:
-//F*/
-CvStatus icvEstimate1DTransProb( Cv1DObsInfo** obs_info_array,
-                                 int num_seq,
-                                 CvEHMM* hmm )
-{
-    int    i, j, k;
-
-    /* as a counter we will use transP matrix */
-
-    /* initialization */
-
-    /* clear transP */
-    icvSetZero_32f( hmm->transP, hmm->num_states, hmm->num_states );
-
-
-    /* compute the counters */
-    for (i = 0; i < num_seq; i++)
-    {
-        int counter = 0;
-        Cv1DObsInfo* info = obs_info_array[i];
-
-        for (k = 0; k < info->obs_x; k++, counter++)
-        {
-            /* compute how many transitions from state to state
-               occured */
-            int state;
-            int nextstate;
-
-            state = info->state[counter];
-
-            if (k < info->obs_x - 1)
-            {
-                int transP_size = hmm->num_states;
-
-                nextstate = info->state[counter+1];
-                hmm->transP[ state * transP_size + nextstate] += 1;
-            }
-        }
-    }
-
-    /* estimate superstate matrix */
-    for( i = 0; i < hmm->num_states; i++)
-    {
-        float total = 0;
-        float inv_total;
-        for( j = 0; j < hmm->num_states; j++)
-        {
-            total += hmm->transP[i * hmm->num_states + j];
-        }
-        //assert( total );
-
-        inv_total = total ? 1.f/total : 0;
-
-        for( j = 0; j < hmm->num_states; j++)
-        {
-            hmm->transP[i * hmm->num_states + j] =
-                hmm->transP[i * hmm->num_states + j] ?
-                (float)log( hmm->transP[i * hmm->num_states + j] * inv_total ) : -BIG_FLT;
-        }
-    }
-
-    return CV_NO_ERR;
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: MixSegmL2
-//    Purpose: The function implements the mixture segmentation of the states of the embedded HMM
-//    Context: used with the Viterbi training of the embedded HMM
-//
-//    Parameters:
-//             obs_info_array
-//             num_img
-//             hmm
-//    Returns: void
-//
-//    Notes:
-//F*/
-CvStatus icv1DMixSegmL2(CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm )
-{
-    int     k, i, m;
-
-    CvEHMMState* state = hmm->u.state;
-
-    for (k = 0; k < num_img; k++)
-    {
-        //int counter = 0;
-        CvImgObsInfo* info = obs_info_array[k];
-
-        for (i = 0; i < info->obs_x; i++)
-        {
-            int e_state = info->state[i];
-            float min_dist;
-
-            min_dist = icvSquareDistance((info->obs) + (i * info->obs_size),
-                                               state[e_state].mu, info->obs_size);
-            info->mix[i] = 0;
-
-            for (m = 1; m < state[e_state].num_mix; m++)
-            {
-                float dist=icvSquareDistance( (info->obs) + (i * info->obs_size),
-                                               state[e_state].mu + m * info->obs_size,
-                                               info->obs_size);
-                if (dist < min_dist)
-                {
-                    min_dist = dist;
-                    /* assign mixture with smallest distance */
-                    info->mix[i] = m;
-                }
-            }
-        }
-    }
-    return CV_NO_ERR;
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvEViterbi
-//    Purpose: The function calculates the embedded Viterbi algorithm
-//             for 1 image
-//    Context:
-//    Parameters:
-//             obs_info - observations
-//             hmm      - HMM
-//
-//    Returns: the Embedded Viterbi probability (float)
-//             and do state segmentation of observations
-//
-//    Notes:
-//F*/
-float icvViterbi(Cv1DObsInfo* obs_info, CvEHMM* hmm)
-{
-    int    i, counter;
-    float  log_likelihood;
-
-    //CvEHMMState* first_state = hmm->u.state;
-
-    /* memory allocation for superB */
-    /*CvMatr32f superB = picvCreateMatrix_32f(hmm->num_states, obs_info->obs_x );*/
-
-    /* memory allocation for q */
-    int* super_q = (int*)icvAlloc( obs_info->obs_x * sizeof(int) );
-
-    /* perform Viterbi segmentation (process 1D HMM) */
-    icvViterbiSegmentation( hmm->num_states, obs_info->obs_x,
-                            hmm->transP, (float*)(hmm->obsProb), 0,
-                            _CV_LAST_STATE, &super_q, obs_info->obs_x,
-                             obs_info->obs_x, &log_likelihood );
-
-    log_likelihood /= obs_info->obs_x ;
-
-    counter = 0;
-    /* assign new state to observation vectors */
-    for (i = 0; i < obs_info->obs_x; i++)
-    {
-         int state = super_q[i];
-         obs_info->state[i] = state;
-    }
-
-    /* memory deallocation for superB */
-    /*picvDeleteMatrix( superB );*/
-    icvFree( &super_q );
-
-    return log_likelihood;
-}
-
-CvStatus icvEstimate1DHMMStateParams(CvImgObsInfo** obs_info_array, int num_img, CvEHMM* hmm)
-
-{
-    /* compute gamma, weights, means, vars */
-    int k, i, j, m;
-    int counter = 0;
-    int total = 0;
-    int vect_len = obs_info_array[0]->obs_size;
-
-    float start_log_var_val = LN2PI * vect_len;
-
-    CvVect32f tmp_vect = icvCreateVector_32f( vect_len );
-
-    CvEHMMState* first_state = hmm->u.state;
-
-    assert( sizeof(float) == sizeof(int) );
-
-    total+= hmm->num_states;
-
-    /***************Gamma***********************/
-    /* initialize gamma */
-    for( i = 0; i < total; i++ )
-    {
-        for (m = 0; m < first_state[i].num_mix; m++)
-        {
-            ((int*)(first_state[i].weight))[m] = 0;
-        }
-    }
-
-    /* maybe gamma must be computed in mixsegm process ?? */
-
-    /* compute gamma */
-    counter = 0;
-    for (k = 0; k < num_img; k++)
-    {
-        CvImgObsInfo* info = obs_info_array[k];
-        int num_obs = info->obs_y * info->obs_x;
-
-        for (i = 0; i < num_obs; i++)
-        {
-            int state, mixture;
-            state = info->state[i];
-            mixture = info->mix[i];
-            /* computes gamma - number of observations corresponding
-               to every mixture of every state */
-            ((int*)(first_state[state].weight))[mixture] += 1;
-        }
-    }
-    /***************Mean and Var***********************/
-    /* compute means and variances of every item */
-    /* initially variance placed to inv_var */
-    /* zero mean and variance */
-    for (i = 0; i < total; i++)
-    {
-        memset( (void*)first_state[i].mu, 0, first_state[i].num_mix * vect_len *
-                                                                         sizeof(float) );
-        memset( (void*)first_state[i].inv_var, 0, first_state[i].num_mix * vect_len *
-                                                                         sizeof(float) );
-    }
-
-    /* compute sums */
-    for (i = 0; i < num_img; i++)
-    {
-        CvImgObsInfo* info = obs_info_array[i];
-        int total_obs = info->obs_x;// * info->obs_y;
-
-        float* vector = info->obs;
-
-        for (j = 0; j < total_obs; j++, vector+=vect_len )
-        {
-            int state = info->state[j];
-            int mixture = info->mix[j];
-
-            CvVect32f mean  = first_state[state].mu + mixture * vect_len;
-            CvVect32f mean2 = first_state[state].inv_var + mixture * vect_len;
-
-            icvAddVector_32f( mean, vector, mean, vect_len );
-            icvAddSquare_32f_C1IR( vector, vect_len * sizeof(float),
-                                    mean2, vect_len * sizeof(float), cvSize(vect_len, 1) );
-        }
-    }
-
-    /*compute the means and variances */
-    /* assume gamma already computed */
-    counter = 0;
-    for (i = 0; i < total; i++)
-    {
-        CvEHMMState* state = &(first_state[i]);
-
-        for (m = 0; m < state->num_mix; m++)
-        {
-            int k;
-            CvVect32f mu  = state->mu + m * vect_len;
-            CvVect32f invar = state->inv_var + m * vect_len;
-
-            if ( ((int*)state->weight)[m] > 1)
-            {
-                float inv_gamma = 1.f/((int*)(state->weight))[m];
-
-                icvScaleVector_32f( mu, mu, vect_len, inv_gamma);
-                icvScaleVector_32f( invar, invar, vect_len, inv_gamma);
-            }
-
-            icvMulVectors_32f(mu, mu, tmp_vect, vect_len);
-            icvSubVector_32f( invar, tmp_vect, invar, vect_len);
-
-            /* low bound of variance - 0.01 (Ara's experimental result) */
-            for( k = 0; k < vect_len; k++ )
-            {
-                invar[k] = (invar[k] > 0.01f) ? invar[k] : 0.01f;
-            }
-
-            /* compute log_var */
-            state->log_var_val[m] = start_log_var_val;
-            for( k = 0; k < vect_len; k++ )
-            {
-                state->log_var_val[m] += (float)log( invar[k] );
-            }
-
-            state->log_var_val[m] *= 0.5;
-
-            /* compute inv_var = 1/sqrt(2*variance) */
-            icvScaleVector_32f(invar, invar, vect_len, 2.f );
-            icvbInvSqrt_32f(invar, invar, vect_len );
-        }
-    }
-
-    /***************Weights***********************/
-    /* normilize gammas - i.e. compute mixture weights */
-
-    //compute weights
-    for (i = 0; i < total; i++)
-    {
-        int gamma_total = 0;
-        float norm;
-
-        for (m = 0; m < first_state[i].num_mix; m++)
-        {
-            gamma_total += ((int*)(first_state[i].weight))[m];
-        }
-
-        norm = gamma_total ? (1.f/(float)gamma_total) : 0.f;
-
-        for (m = 0; m < first_state[i].num_mix; m++)
-        {
-            first_state[i].weight[m] = ((int*)(first_state[i].weight))[m] * norm;
-        }
-    }
-
-    icvDeleteVector( tmp_vect);
-    return CV_NO_ERR;
-}
-
-
-
-
-
-#endif
diff --git a/modules/legacy/src/hmmobs.cpp b/modules/legacy/src/hmmobs.cpp
deleted file mode 100644 (file)
index 85cb372..0000000
+++ /dev/null
@@ -1,634 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-//*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvImgToObs_DCT_8u32f_C1R
-//    Purpose: The function takes as input an image and returns the sequnce of observations
-//             to be used with an embedded HMM; Each observation is top-left block of DCT
-//             coefficient matrix.
-//    Context:
-//    Parameters: img     - pointer to the original image ROI
-//                imgStep - full row width of the image in bytes
-//                roi     - width and height of ROI in pixels
-//                obs     - pointer to resultant observation vectors
-//                dctSize - size of the block for which DCT is calculated
-//                obsSize - size of top-left block of DCT coeffs matrix, which is treated
-//                          as observation. Each observation vector consists of
-//                          obsSize.width * obsSize.height floats.
-//                          The following conditions should be satisfied:
-//                          0 < objSize.width <= dctSize.width,
-//                          0 < objSize.height <= dctSize.height.
-//                delta   - dctBlocks are overlapped and this parameter specifies horizontal
-//                          and vertical shift.
-//    Returns:
-//      CV_NO_ERR or error code
-//    Notes:
-//      The algorithm is following:
-//          1. First, number of observation vectors per row and per column are calculated:
-//
-//             Nx = floor((roi.width - dctSize.width + delta.width)/delta.width);
-//             Ny = floor((roi.height - dctSize.height + delta.height)/delta.height);
-//
-//             So, total number of observation vectors is Nx*Ny, and total size of
-//             array obs must be >= Nx*Ny*obsSize.width*obsSize.height*sizeof(float).
-//          2. Observation vectors are calculated in the following loop
-//               ( actual implementation may be different ), where
-//               I[x1:x2,y1:y2] means block of pixels from source image with
-//               x1 <= x < x2, y1 <= y < y2,
-//               D[x1:x2,y1:y2] means sub matrix of DCT matrix D.
-//               O[x,y] means observation vector that corresponds to position
-//               (x*delta.width,y*delta.height) in the source image
-//               ( all indices are counted from 0 ).
-//
-//               for( y = 0; y < Ny; y++ )
-//               {
-//                   for( x = 0; x < Nx; x++ )
-//                   {
-//                       D = DCT(I[x*delta.width : x*delta.width + dctSize.width,
-//                                  y*delta.height : y*delta.height + dctSize.height]);
-//                       O[x,y] = D[0:obsSize.width, 0:obsSize.height];
-//                   }
-//               }
-//F*/
-
-/*comment out the following line to make DCT be calculated in floating-point arithmetics*/
-//#define _CV_INT_DCT
-
-/* for integer DCT only */
-#define DCT_SCALE  15
-
-#ifdef _CV_INT_DCT
-typedef int work_t;
-
-#define  DESCALE      CV_DESCALE
-#define  SCALE(x)     CV_FLT_TO_FIX((x),DCT_SCALE)
-#else
-typedef float work_t;
-
-#define  DESCALE(x,n) (float)(x)
-#define  SCALE(x)     (float)(x)
-#endif
-
-/* calculate dct transform matrix */
-static void icvCalcDCTMatrix( work_t * cfs, int n );
-
-#define  MAX_DCT_SIZE  32
-
-static CvStatus CV_STDCALL
-icvImgToObs_DCT_8u32f_C1R( uchar * img, int imgStep, CvSize roi,
-                           float *obs, CvSize dctSize,
-                           CvSize obsSize, CvSize delta )
-{
-    /* dct transform matrices: horizontal and vertical */
-    work_t tab_x[MAX_DCT_SIZE * MAX_DCT_SIZE / 2 + 2];
-    work_t tab_y[MAX_DCT_SIZE * MAX_DCT_SIZE / 2 + 2];
-
-    /* temporary buffers for dct */
-    work_t temp0[MAX_DCT_SIZE * 4];
-    work_t temp1[MAX_DCT_SIZE * 4];
-    work_t *buffer = 0;
-    work_t *buf_limit;
-
-    double s;
-
-    int y;
-    int Nx, Ny;
-
-    int n1 = dctSize.height, m1 = n1 / 2;
-    int n2 = dctSize.width, m2 = n2 / 2;
-
-    if( !img || !obs )
-        return CV_NULLPTR_ERR;
-
-    if( roi.width <= 0 || roi.height <= 0 )
-        return CV_BADSIZE_ERR;
-
-    if( delta.width <= 0 || delta.height <= 0 )
-        return CV_BADRANGE_ERR;
-
-    if( obsSize.width <= 0 || dctSize.width < obsSize.width ||
-        obsSize.height <= 0 || dctSize.height < obsSize.height )
-        return CV_BADRANGE_ERR;
-
-    if( dctSize.width > MAX_DCT_SIZE || dctSize.height > MAX_DCT_SIZE )
-        return CV_BADRANGE_ERR;
-
-    Nx = (roi.width - dctSize.width + delta.width) / delta.width;
-    Ny = (roi.height - dctSize.height + delta.height) / delta.height;
-
-    if( Nx <= 0 || Ny <= 0 )
-        return CV_BADRANGE_ERR;
-
-    buffer = (work_t *)cvAlloc( roi.width * obsSize.height * sizeof( buffer[0] ));
-    if( !buffer )
-        return CV_OUTOFMEM_ERR;
-
-    icvCalcDCTMatrix( tab_x, dctSize.width );
-    icvCalcDCTMatrix( tab_y, dctSize.height );
-
-    buf_limit = buffer + obsSize.height * roi.width;
-
-    for( y = 0; y < Ny; y++, img += delta.height * imgStep )
-    {
-        int x, i, j, k;
-        work_t k0 = 0;
-
-        /* do transfroms for each column. Calc only first obsSize.height DCT coefficients */
-        for( x = 0; x < roi.width; x++ )
-        {
-            float is = 0;
-            work_t *buf = buffer + x;
-            work_t *tab = tab_y + 2;
-
-            if( n1 & 1 )
-            {
-                is = img[x + m1 * imgStep];
-                k0 = ((work_t) is) * tab[-1];
-            }
-
-            /* first coefficient */
-            for( j = 0; j < m1; j++ )
-            {
-                float t0 = img[x + j * imgStep];
-                float t1 = img[x + (n1 - 1 - j) * imgStep];
-                float t2 = t0 + t1;
-
-                t0 -= t1;
-                temp0[j] = (work_t) t2;
-                is += t2;
-                temp1[j] = (work_t) t0;
-            }
-
-            buf[0] = DESCALE( is * tab[-2], PASS1_SHIFT );
-            if( (buf += roi.width) >= buf_limit )
-                continue;
-
-            /* other coefficients */
-            for( ;; )
-            {
-                s = 0;
-
-                for( k = 0; k < m1; k++ )
-                    s += temp1[k] * tab[k];
-
-                buf[0] = DESCALE( s, PASS1_SHIFT );
-                if( (buf += roi.width) >= buf_limit )
-                    break;
-
-                tab += m1;
-                s = 0;
-
-                if( n1 & 1 )
-                {
-                    k0 = -k0;
-                    s = k0;
-                }
-                for( k = 0; k < m1; k++ )
-                    s += temp0[k] * tab[k];
-
-                buf[0] = DESCALE( s, PASS1_SHIFT );
-                tab += m1;
-
-                if( (buf += roi.width) >= buf_limit )
-                    break;
-            }
-        }
-
-        k0 = 0;
-
-        /* do transforms for rows. */
-        for( x = 0; x + dctSize.width <= roi.width; x += delta.width )
-        {
-            for( i = 0; i < obsSize.height; i++ )
-            {
-                work_t *buf = buffer + x + roi.width * i;
-                work_t *tab = tab_x + 2;
-                float *obs_limit = obs + obsSize.width;
-
-                s = 0;
-
-                if( n2 & 1 )
-                {
-                    s = buf[m2];
-                    k0 = (work_t) (s * tab[-1]);
-                }
-
-                /* first coefficient */
-                for( j = 0; j < m2; j++ )
-                {
-                    work_t t0 = buf[j];
-                    work_t t1 = buf[n2 - 1 - j];
-                    work_t t2 = t0 + t1;
-
-                    t0 -= t1;
-                    temp0[j] = (work_t) t2;
-                    s += t2;
-                    temp1[j] = (work_t) t0;
-                }
-
-                *obs++ = (float) DESCALE( s * tab[-2], PASS2_SHIFT );
-
-                if( obs == obs_limit )
-                    continue;
-
-                /* other coefficients */
-                for( ;; )
-                {
-                    s = 0;
-
-                    for( k = 0; k < m2; k++ )
-                        s += temp1[k] * tab[k];
-
-                    obs[0] = (float) DESCALE( s, PASS2_SHIFT );
-                    if( ++obs == obs_limit )
-                        break;
-
-                    tab += m2;
-
-                    s = 0;
-
-                    if( n2 & 1 )
-                    {
-                        k0 = -k0;
-                        s = k0;
-                    }
-                    for( k = 0; k < m2; k++ )
-                        s += temp0[k] * tab[k];
-                    obs[0] = (float) DESCALE( s, PASS2_SHIFT );
-
-                    tab += m2;
-                    if( ++obs == obs_limit )
-                        break;
-                }
-            }
-        }
-    }
-
-    cvFree( &buffer );
-    return CV_NO_ERR;
-}
-
-
-static CvStatus CV_STDCALL
-icvImgToObs_DCT_32f_C1R( float * img, int imgStep, CvSize roi,
-                         float *obs, CvSize dctSize,
-                         CvSize obsSize, CvSize delta )
-{
-    /* dct transform matrices: horizontal and vertical */
-    work_t tab_x[MAX_DCT_SIZE * MAX_DCT_SIZE / 2 + 2];
-    work_t tab_y[MAX_DCT_SIZE * MAX_DCT_SIZE / 2 + 2];
-
-    /* temporary buffers for dct */
-    work_t temp0[MAX_DCT_SIZE * 4];
-    work_t temp1[MAX_DCT_SIZE * 4];
-    work_t *buffer = 0;
-    work_t *buf_limit;
-
-    double s;
-
-    int y;
-    int Nx, Ny;
-
-    int n1 = dctSize.height, m1 = n1 / 2;
-    int n2 = dctSize.width, m2 = n2 / 2;
-
-    if( !img || !obs )
-        return CV_NULLPTR_ERR;
-
-    if( roi.width <= 0 || roi.height <= 0 )
-        return CV_BADSIZE_ERR;
-
-    if( delta.width <= 0 || delta.height <= 0 )
-        return CV_BADRANGE_ERR;
-
-    if( obsSize.width <= 0 || dctSize.width < obsSize.width ||
-        obsSize.height <= 0 || dctSize.height < obsSize.height )
-        return CV_BADRANGE_ERR;
-
-    if( dctSize.width > MAX_DCT_SIZE || dctSize.height > MAX_DCT_SIZE )
-        return CV_BADRANGE_ERR;
-
-    Nx = (roi.width - dctSize.width + delta.width) / delta.width;
-    Ny = (roi.height - dctSize.height + delta.height) / delta.height;
-
-    if( Nx <= 0 || Ny <= 0 )
-        return CV_BADRANGE_ERR;
-
-    buffer = (work_t *)cvAlloc( roi.width * obsSize.height * sizeof( buffer[0] ));
-    if( !buffer )
-        return CV_OUTOFMEM_ERR;
-
-    icvCalcDCTMatrix( tab_x, dctSize.width );
-    icvCalcDCTMatrix( tab_y, dctSize.height );
-
-    buf_limit = buffer + obsSize.height * roi.width;
-
-    imgStep /= sizeof(img[0]);
-
-    for( y = 0; y < Ny; y++, img += delta.height * imgStep )
-    {
-        int x, i, j, k;
-        work_t k0 = 0;
-
-        /* do transfroms for each column. Calc only first obsSize.height DCT coefficients */
-        for( x = 0; x < roi.width; x++ )
-        {
-            float is = 0;
-            work_t *buf = buffer + x;
-            work_t *tab = tab_y + 2;
-
-            if( n1 & 1 )
-            {
-                is = img[x + m1 * imgStep];
-                k0 = ((work_t) is) * tab[-1];
-            }
-
-            /* first coefficient */
-            for( j = 0; j < m1; j++ )
-            {
-                float t0 = img[x + j * imgStep];
-                float t1 = img[x + (n1 - 1 - j) * imgStep];
-                float t2 = t0 + t1;
-
-                t0 -= t1;
-                temp0[j] = (work_t) t2;
-                is += t2;
-                temp1[j] = (work_t) t0;
-            }
-
-            buf[0] = DESCALE( is * tab[-2], PASS1_SHIFT );
-            if( (buf += roi.width) >= buf_limit )
-                continue;
-
-            /* other coefficients */
-            for( ;; )
-            {
-                s = 0;
-
-                for( k = 0; k < m1; k++ )
-                    s += temp1[k] * tab[k];
-
-                buf[0] = DESCALE( s, PASS1_SHIFT );
-                if( (buf += roi.width) >= buf_limit )
-                    break;
-
-                tab += m1;
-                s = 0;
-
-                if( n1 & 1 )
-                {
-                    k0 = -k0;
-                    s = k0;
-                }
-                for( k = 0; k < m1; k++ )
-                    s += temp0[k] * tab[k];
-
-                buf[0] = DESCALE( s, PASS1_SHIFT );
-                tab += m1;
-
-                if( (buf += roi.width) >= buf_limit )
-                    break;
-            }
-        }
-
-        k0 = 0;
-
-        /* do transforms for rows. */
-        for( x = 0; x + dctSize.width <= roi.width; x += delta.width )
-        {
-            for( i = 0; i < obsSize.height; i++ )
-            {
-                work_t *buf = buffer + x + roi.width * i;
-                work_t *tab = tab_x + 2;
-                float *obs_limit = obs + obsSize.width;
-
-                s = 0;
-
-                if( n2 & 1 )
-                {
-                    s = buf[m2];
-                    k0 = (work_t) (s * tab[-1]);
-                }
-
-                /* first coefficient */
-                for( j = 0; j < m2; j++ )
-                {
-                    work_t t0 = buf[j];
-                    work_t t1 = buf[n2 - 1 - j];
-                    work_t t2 = t0 + t1;
-
-                    t0 -= t1;
-                    temp0[j] = (work_t) t2;
-                    s += t2;
-                    temp1[j] = (work_t) t0;
-                }
-
-                *obs++ = (float) DESCALE( s * tab[-2], PASS2_SHIFT );
-
-                if( obs == obs_limit )
-                    continue;
-
-                /* other coefficients */
-                for( ;; )
-                {
-                    s = 0;
-
-                    for( k = 0; k < m2; k++ )
-                        s += temp1[k] * tab[k];
-
-                    obs[0] = (float) DESCALE( s, PASS2_SHIFT );
-                    if( ++obs == obs_limit )
-                        break;
-
-                    tab += m2;
-
-                    s = 0;
-
-                    if( n2 & 1 )
-                    {
-                        k0 = -k0;
-                        s = k0;
-                    }
-                    for( k = 0; k < m2; k++ )
-                        s += temp0[k] * tab[k];
-                    obs[0] = (float) DESCALE( s, PASS2_SHIFT );
-
-                    tab += m2;
-                    if( ++obs == obs_limit )
-                        break;
-                }
-            }
-        }
-    }
-
-    cvFree( &buffer );
-    return CV_NO_ERR;
-}
-
-
-static void
-icvCalcDCTMatrix( work_t * cfs, int n )
-{
-    static const double sqrt2 = 1.4142135623730950488016887242097;
-    static const double pi = 3.1415926535897932384626433832795;
-
-    static const double sincos[16 * 2] = {
-        1.00000000000000000, 0.00000000000000006,
-        0.70710678118654746, 0.70710678118654757,
-        0.49999999999999994, 0.86602540378443871,
-        0.38268343236508978, 0.92387953251128674,
-        0.30901699437494740, 0.95105651629515353,
-        0.25881904510252074, 0.96592582628906831,
-        0.22252093395631439, 0.97492791218182362,
-        0.19509032201612825, 0.98078528040323043,
-        0.17364817766693033, 0.98480775301220802,
-        0.15643446504023087, 0.98768834059513777,
-        0.14231483827328514, 0.98982144188093268,
-        0.13052619222005157, 0.99144486137381038,
-        0.12053668025532305, 0.99270887409805397,
-        0.11196447610330786, 0.99371220989324260,
-        0.10452846326765346, 0.99452189536827329,
-        0.09801714032956060, 0.99518472667219693,
-    };
-
-#define ROTATE( c, s, dc, ds ) \
-    {                              \
-        t = c*dc - s*ds;           \
-        s = c*ds + s*dc;           \
-        c = t;                     \
-    }
-
-#define WRITE2( j, a, b ) \
-    {                         \
-        cfs[j]   = SCALE(a);  \
-        cfs2[j]  = SCALE(b);  \
-    }
-
-    double t, scale = 1. / sqrt( (double)n );
-    int i, j, m = n / 2;
-
-    cfs[0] = SCALE( scale );
-    scale *= sqrt2;
-    cfs[1] = SCALE( scale );
-    cfs += 2 - m;
-
-    if( n > 1 )
-    {
-        double a0, b0;
-        double da0, db0;
-        work_t *cfs2 = cfs + m * n;
-
-        if( n <= 16 )
-        {
-            da0 = a0 = sincos[2 * n - 1];
-            db0 = b0 = sincos[2 * n - 2];
-        }
-        else
-        {
-            t = pi / (2 * n);
-            da0 = a0 = cos( t );
-            db0 = b0 = sin( t );
-        }
-
-        /* other rows */
-        for( i = 1; i <= m; i++ )
-        {
-            double a = a0 * scale;
-            double b = b0 * scale;
-            double da = a0 * a0 - b0 * b0;
-            double db = a0 * b0 + a0 * b0;
-
-            cfs += m;
-            cfs2 -= m;
-
-            for( j = 0; j < m; j += 2 )
-            {
-                WRITE2( j, a, b );
-                ROTATE( a, b, da, db );
-                if( j + 1 < m )
-                {
-                    WRITE2( j + 1, a, -b );
-                    ROTATE( a, b, da, db );
-                }
-            }
-
-            ROTATE( a0, b0, da0, db0 );
-        }
-    }
-#undef ROTATE
-#undef WRITE2
-}
-
-
-CV_IMPL void
-cvImgToObs_DCT( const void* arr, float *obs, CvSize dctSize,
-                CvSize obsSize, CvSize delta )
-{
-    CV_FUNCNAME( "cvImgToObs_DCT" );
-
-    __BEGIN__;
-
-    CvMat stub, *mat = (CvMat*)arr;
-
-    CV_CALL( mat = cvGetMat( arr, &stub ));
-
-    switch( CV_MAT_TYPE( mat->type ))
-    {
-    case CV_8UC1:
-        IPPI_CALL( icvImgToObs_DCT_8u32f_C1R( mat->data.ptr, mat->step,
-                                           cvGetMatSize(mat), obs,
-                                           dctSize, obsSize, delta ));
-        break;
-    case CV_32FC1:
-        IPPI_CALL( icvImgToObs_DCT_32f_C1R( mat->data.fl, mat->step,
-                                           cvGetMatSize(mat), obs,
-                                           dctSize, obsSize, delta ));
-        break;
-    default:
-        CV_ERROR( CV_StsUnsupportedFormat, "" );
-    }
-
-    __END__;
-}
-
-
-/* End of file. */
diff --git a/modules/legacy/src/image.cpp b/modules/legacy/src/image.cpp
deleted file mode 100644 (file)
index a3fc8b9..0000000
+++ /dev/null
@@ -1,332 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/* ////////////////////////////////////////////////////////////////////
-//
-//  C++ classes for image and matrices
-//
-// */
-
-#include "precomp.hpp"
-#include "opencv2/opencv_modules.hpp"
-#ifdef HAVE_OPENCV_HIGHGUI
-#  include "opencv2/highgui/highgui_c.h"
-#endif
-
-/////////////////////////////// CvImage implementation //////////////////////////////////
-
-static bool
-icvIsXmlOrYaml( const char* filename )
-{
-    const char* suffix = strrchr( filename, '.' );
-    return suffix &&
-        (strcmp( suffix, ".xml" ) == 0 ||
-        strcmp( suffix, ".Xml" ) == 0 ||
-        strcmp( suffix, ".XML" ) == 0 ||
-        strcmp( suffix, ".yml" ) == 0 ||
-        strcmp( suffix, ".Yml" ) == 0 ||
-        strcmp( suffix, ".YML" ) == 0 ||
-        strcmp( suffix, ".yaml" ) == 0 ||
-        strcmp( suffix, ".Yaml" ) == 0 ||
-        strcmp( suffix, ".YAML" ) == 0);
-}
-
-
-static IplImage*
-icvRetrieveImage( void* obj )
-{
-    IplImage* img = 0;
-
-    if( CV_IS_IMAGE(obj) )
-        img = (IplImage*)obj;
-    else if( CV_IS_MAT(obj) )
-    {
-        CvMat* m = (CvMat*)obj;
-        img = cvCreateImageHeader( cvSize(m->cols,m->rows),
-                        CV_MAT_DEPTH(m->type), CV_MAT_CN(m->type) );
-        cvSetData( img, m->data.ptr, m->step );
-        img->imageDataOrigin = (char*)m->refcount;
-        m->data.ptr = 0; m->step = 0;
-        cvReleaseMat( &m );
-    }
-    else if( obj )
-    {
-        cvRelease( &obj );
-        CV_Error( CV_StsUnsupportedFormat, "The object is neither an image, nor a matrix" );
-    }
-
-    return img;
-}
-
-
-bool CvImage::load( const char* filename, const char* imgname, int color )
-{
-    IplImage* img = 0;
-
-    if( icvIsXmlOrYaml(filename) )
-    {
-        img = icvRetrieveImage(cvLoad(filename,0,imgname));
-        if( (img->nChannels > 1) != (color == 0) )
-            CV_Error( CV_StsNotImplemented,
-            "RGB<->Grayscale conversion is not implemented for images stored in XML/YAML" );
-        /*{
-            IplImage* temp_img = 0;
-            temp_img = cvCreateImage( cvGetSize(img), img->depth, color > 0 ? 3 : 1 ));
-            cvCvtColor( img, temp_img, color > 0 ? CV_GRAY2BGR : CV_BGR2GRAY );
-            cvReleaseImage( &img );
-            img = temp_img;
-        }*/
-    }
-#ifdef HAVE_OPENCV_HIGHGUI
-    else
-        img = cvLoadImage( filename, color );
-#endif
-
-    attach( img );
-    return img != 0;
-}
-
-
-bool CvImage::read( CvFileStorage* fs, const char* mapname, const char* imgname )
-{
-    void* obj = 0;
-    IplImage* img = 0;
-
-    if( mapname )
-    {
-        CvFileNode* mapnode = cvGetFileNodeByName( fs, 0, mapname );
-        if( !mapnode )
-            obj = cvReadByName( fs, mapnode, imgname );
-    }
-    else
-        obj = cvReadByName( fs, 0, imgname );
-
-    img = icvRetrieveImage(obj);
-    attach( img );
-    return img != 0;
-}
-
-
-bool CvImage::read( CvFileStorage* fs, const char* seqname, int idx )
-{
-    void* obj = 0;
-    IplImage* img = 0;
-    CvFileNode* seqnode = seqname ?
-        cvGetFileNodeByName( fs, 0, seqname ) : cvGetRootFileNode(fs,0);
-
-    if( seqnode && CV_NODE_IS_SEQ(seqnode->tag) )
-        obj = cvRead( fs, (CvFileNode*)cvGetSeqElem( seqnode->data.seq, idx ));
-    img = icvRetrieveImage(obj);
-    attach( img );
-    return img != 0;
-}
-
-
-void CvImage::save( const char* filename, const char* imgname, const int* params )
-{
-    if( !image )
-        return;
-    if( icvIsXmlOrYaml( filename ) )
-        cvSave( filename, image, imgname );
-#ifdef HAVE_OPENCV_HIGHGUI
-    else
-        cvSaveImage( filename, image, params );
-#else
-    (void)params;
-#endif
-}
-
-
-void CvImage::write( CvFileStorage* fs, const char* imgname )
-{
-    if( image )
-        cvWrite( fs, imgname, image );
-}
-
-
-void CvImage::show( const char* window_name )
-{
-#ifdef HAVE_OPENCV_HIGHGUI
-    if( image )
-        cvShowImage( window_name, image );
-#else
-    (void)window_name;
-#endif
-}
-
-
-/////////////////////////////// CvMatrix implementation //////////////////////////////////
-
-CvMatrix::CvMatrix( int _rows, int _cols, int _type, CvMemStorage* storage, bool alloc_data )
-{
-    if( storage )
-    {
-        matrix = (CvMat*)cvMemStorageAlloc( storage, sizeof(*matrix) );
-        cvInitMatHeader( matrix, _rows, _cols, _type, alloc_data ?
-            cvMemStorageAlloc( storage, _rows*_cols*CV_ELEM_SIZE(_type) ) : 0 );
-    }
-    else
-        matrix = 0;
-}
-
-static CvMat*
-icvRetrieveMatrix( void* obj )
-{
-    CvMat* m = 0;
-
-    if( CV_IS_MAT(obj) )
-        m = (CvMat*)obj;
-    else if( CV_IS_IMAGE(obj) )
-    {
-        IplImage* img = (IplImage*)obj;
-        CvMat hdr, *src = cvGetMat( img, &hdr );
-        m = cvCreateMat( src->rows, src->cols, src->type );
-        cvCopy( src, m );
-        cvReleaseImage( &img );
-    }
-    else if( obj )
-    {
-        cvRelease( &obj );
-        CV_Error( CV_StsUnsupportedFormat, "The object is neither an image, nor a matrix" );
-    }
-
-    return m;
-}
-
-
-bool CvMatrix::load( const char* filename, const char* matname, int color )
-{
-    CvMat* m = 0;
-    if( icvIsXmlOrYaml(filename) )
-    {
-        m = icvRetrieveMatrix(cvLoad(filename,0,matname));
-
-        if( (CV_MAT_CN(m->type) > 1) != (color == 0) )
-            CV_Error( CV_StsNotImplemented,
-            "RGB<->Grayscale conversion is not implemented for matrices stored in XML/YAML" );
-        /*{
-            CvMat* temp_mat;
-            temp_mat = cvCreateMat( m->rows, m->cols,
-                CV_MAKETYPE(CV_MAT_DEPTH(m->type), color > 0 ? 3 : 1 )));
-            cvCvtColor( m, temp_mat, color > 0 ? CV_GRAY2BGR : CV_BGR2GRAY );
-            cvReleaseMat( &m );
-            m = temp_mat;
-        }*/
-    }
-#ifdef HAVE_OPENCV_HIGHGUI
-    else
-        m = cvLoadImageM( filename, color );
-#endif
-
-    set( m, false );
-    return m != 0;
-}
-
-
-bool CvMatrix::read( CvFileStorage* fs, const char* mapname, const char* matname )
-{
-    void* obj = 0;
-    CvMat* m = 0;
-
-    if( mapname )
-    {
-        CvFileNode* mapnode = cvGetFileNodeByName( fs, 0, mapname );
-        if( !mapnode )
-            obj = cvReadByName( fs, mapnode, matname );
-    }
-    else
-        obj = cvReadByName( fs, 0, matname );
-
-    m = icvRetrieveMatrix(obj);
-    set( m, false );
-    return m != 0;
-}
-
-
-bool CvMatrix::read( CvFileStorage* fs, const char* seqname, int idx )
-{
-    void* obj = 0;
-    CvMat* m = 0;
-    CvFileNode* seqnode = seqname ?
-        cvGetFileNodeByName( fs, 0, seqname ) : cvGetRootFileNode(fs,0);
-
-    if( seqnode && CV_NODE_IS_SEQ(seqnode->tag) )
-        obj = cvRead( fs, (CvFileNode*)cvGetSeqElem( seqnode->data.seq, idx ));
-    m = icvRetrieveMatrix(obj);
-    set( m, false );
-    return m != 0;
-}
-
-
-void CvMatrix::save( const char* filename, const char* matname, const int* params )
-{
-    if( !matrix )
-        return;
-    if( icvIsXmlOrYaml( filename ) )
-        cvSave( filename, matrix, matname );
-#ifdef HAVE_OPENCV_HIGHGUI
-    else
-        cvSaveImage( filename, matrix, params );
-#else
-    (void)params;
-#endif
-}
-
-
-void CvMatrix::write( CvFileStorage* fs, const char* matname )
-{
-    if( matrix )
-        cvWrite( fs, matname, matrix );
-}
-
-
-void CvMatrix::show( const char* window_name )
-{
-#ifdef HAVE_OPENCV_HIGHGUI
-    if( matrix )
-        cvShowImage( window_name, matrix );
-#else
-    (void)window_name;
-#endif
-}
-
-
-/* End of file. */
diff --git a/modules/legacy/src/kdtree.cpp b/modules/legacy/src/kdtree.cpp
deleted file mode 100644 (file)
index 4183950..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2008, Xavier Delacour, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-// 2008-05-13, Xavier Delacour <xavier.delacour@gmail.com>
-
-#include "precomp.hpp"
-
-#if !defined _MSC_VER || defined __ICL || _MSC_VER >= 1300
-
-#include "_kdtree.hpp"
-#include "_featuretree.h"
-
-class CvKDTreeWrap : public CvFeatureTree {
-  template <class __scalartype, int __cvtype>
-  struct deref {
-    typedef __scalartype scalar_type;
-    typedef double accum_type;
-
-    CvMat* mat;
-    deref(CvMat* _mat) : mat(_mat) {
-      assert(CV_ELEM_SIZE1(__cvtype) == sizeof(__scalartype));
-    }
-    scalar_type operator() (int i, int j) const {
-      return *((scalar_type*)(mat->data.ptr + i * mat->step) + j);
-    }
-  };
-
-#define dispatch_cvtype(mat, c) \
-    switch (CV_MAT_DEPTH((mat)->type)) { \
-    case CV_32F: \
-      { typedef CvKDTree<int, deref<float, CV_32F> > tree_type; c; break; } \
-    case CV_64F: \
-      { typedef CvKDTree<int, deref<double, CV_64F> > tree_type; c; break; } \
-    default: assert(0); \
-    }
-
-  CvMat* mat;
-  void* data;
-
-  template <class __treetype>
-  void find_nn(const CvMat* d, int k, int emax, CvMat* results, CvMat* dist) {
-    __treetype* tr = (__treetype*) data;
-    const uchar* dptr = d->data.ptr;
-    uchar* resultsptr = results->data.ptr;
-    uchar* distptr = dist->data.ptr;
-    typename __treetype::bbf_nn_pqueue nn;
-
-    assert(d->cols == tr->dims());
-    assert(results->rows == d->rows);
-    assert(results->rows == dist->rows);
-    assert(results->cols == k);
-    assert(dist->cols == k);
-
-    for (int j = 0; j < d->rows; ++j)
-    {
-      const typename __treetype::scalar_type* dj = (const typename __treetype::scalar_type*) dptr;
-
-      int* resultsj = (int*) resultsptr;
-      double* distj = (double*) distptr;
-      tr->find_nn_bbf(dj, k, emax, nn);
-
-      assert((int)nn.size() <= k);
-      for (unsigned int i = 0; i < nn.size(); ++i)
-      {
-        *resultsj++ = *nn[i].p;
-        *distj++ = nn[i].dist;
-      }
-      std::fill(resultsj, resultsj + k - nn.size(), -1);
-      std::fill(distj, distj + k - nn.size(), 0);
-
-      dptr += d->step;
-      resultsptr += results->step;
-      distptr += dist->step;
-    }
-  }
-
-  template <class __treetype>
-  int find_ortho_range(CvMat* bounds_min, CvMat* bounds_max,
-           CvMat* results) {
-    int rn = results->rows * results->cols;
-    std::vector<int> inbounds;
-    assert(CV_MAT_DEPTH(mat->type) == CV_32F || CV_MAT_DEPTH(mat->type) == CV_64F);
-    ((__treetype*)data)->find_ortho_range((typename __treetype::scalar_type*)bounds_min->data.ptr,
-             (typename __treetype::scalar_type*)bounds_max->data.ptr,
-             inbounds);
-    std::copy(inbounds.begin(),
-        inbounds.begin() + std::min((int)inbounds.size(), rn),
-        (int*) results->data.ptr);
-    return (int)inbounds.size();
-  }
-
-  CvKDTreeWrap(const CvKDTreeWrap& x);
-  CvKDTreeWrap& operator= (const CvKDTreeWrap& rhs);
-public:
-  CvKDTreeWrap(CvMat* _mat) : mat(_mat) {
-    // * a flag parameter should tell us whether
-    // * (a) user ensures *mat outlives *this and is unchanged,
-    // * (b) we take reference and user ensures mat is unchanged,
-    // * (c) we copy data, (d) we own and release data.
-
-    std::vector<int> tmp(mat->rows);
-    for (unsigned int j = 0; j < tmp.size(); ++j)
-      tmp[j] = j;
-
-    dispatch_cvtype(mat, data = new tree_type
-        (&tmp[0], &tmp[0] + tmp.size(), mat->cols,
-         tree_type::deref_type(mat)));
-  }
-  ~CvKDTreeWrap() {
-    dispatch_cvtype(mat, delete (tree_type*) data);
-  }
-
-  int dims() {
-    int d = 0;
-    dispatch_cvtype(mat, d = ((tree_type*) data)->dims());
-    return d;
-  }
-  int type() {
-    return mat->type;
-  }
-
-  void FindFeatures(const CvMat* desc, int k, int emax, CvMat* results, CvMat* dist) {
-    cv::Ptr<CvMat> tmp_desc;
-
-    if (desc->cols != dims())
-      CV_Error(CV_StsUnmatchedSizes, "desc columns be equal feature dimensions");
-    if (results->rows != desc->rows && results->cols != k)
-      CV_Error(CV_StsUnmatchedSizes, "results and desc must be same height");
-    if (dist->rows != desc->rows && dist->cols != k)
-      CV_Error(CV_StsUnmatchedSizes, "dist and desc must be same height");
-    if (CV_MAT_TYPE(results->type) != CV_32SC1)
-      CV_Error(CV_StsUnsupportedFormat, "results must be CV_32SC1");
-    if (CV_MAT_TYPE(dist->type) != CV_64FC1)
-      CV_Error(CV_StsUnsupportedFormat, "dist must be CV_64FC1");
-
-    if (CV_MAT_TYPE(type()) != CV_MAT_TYPE(desc->type)) {
-      tmp_desc.reset(cvCreateMat(desc->rows, desc->cols, type()));
-      cvConvert(desc, tmp_desc);
-      desc = tmp_desc;
-    }
-
-    assert(CV_MAT_TYPE(desc->type) == CV_MAT_TYPE(mat->type));
-    assert(CV_MAT_TYPE(dist->type) == CV_64FC1);
-    assert(CV_MAT_TYPE(results->type) == CV_32SC1);
-
-    dispatch_cvtype(mat, find_nn<tree_type>
-        (desc, k, emax, results, dist));
-  }
-  int FindOrthoRange(CvMat* bounds_min, CvMat* bounds_max,
-         CvMat* results) {
-    bool free_bounds = false;
-    int count = -1;
-
-    if (bounds_min->cols * bounds_min->rows != dims() ||
-  bounds_max->cols * bounds_max->rows != dims())
-      CV_Error(CV_StsUnmatchedSizes, "bounds_{min,max} must 1 x dims or dims x 1");
-    if (CV_MAT_TYPE(bounds_min->type) != CV_MAT_TYPE(bounds_max->type))
-      CV_Error(CV_StsUnmatchedFormats, "bounds_{min,max} must have same type");
-    if (CV_MAT_TYPE(results->type) != CV_32SC1)
-      CV_Error(CV_StsUnsupportedFormat, "results must be CV_32SC1");
-
-    if (CV_MAT_TYPE(bounds_min->type) != CV_MAT_TYPE(type())) {
-      free_bounds = true;
-
-      CvMat* old_bounds_min = bounds_min;
-      bounds_min = cvCreateMat(bounds_min->rows, bounds_min->cols, type());
-      cvConvert(old_bounds_min, bounds_min);
-
-      CvMat* old_bounds_max = bounds_max;
-      bounds_max = cvCreateMat(bounds_max->rows, bounds_max->cols, type());
-      cvConvert(old_bounds_max, bounds_max);
-    }
-
-    assert(CV_MAT_TYPE(bounds_min->type) == CV_MAT_TYPE(mat->type));
-    assert(CV_MAT_TYPE(bounds_min->type) == CV_MAT_TYPE(bounds_max->type));
-    assert(bounds_min->rows * bounds_min->cols == dims());
-    assert(bounds_max->rows * bounds_max->cols == dims());
-
-    dispatch_cvtype(mat, count = find_ortho_range<tree_type>
-        (bounds_min, bounds_max,results));
-
-    if (free_bounds) {
-      cvReleaseMat(&bounds_min);
-      cvReleaseMat(&bounds_max);
-    }
-
-    return count;
-  }
-};
-
-CvFeatureTree* cvCreateKDTree(CvMat* desc) {
-
-  if (CV_MAT_TYPE(desc->type) != CV_32FC1 &&
-      CV_MAT_TYPE(desc->type) != CV_64FC1)
-    CV_Error(CV_StsUnsupportedFormat, "descriptors must be either CV_32FC1 or CV_64FC1");
-
-  return new CvKDTreeWrap(desc);
-}
-
-#endif
diff --git a/modules/legacy/src/lcm.cpp b/modules/legacy/src/lcm.cpp
deleted file mode 100644 (file)
index 95ab2c6..0000000
+++ /dev/null
@@ -1,720 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/* Hybrid linear-contour model reconstruction */
-#include "precomp.hpp"
-
-#define CV_IMPL CV_EXTERN_C
-
-const float LCM_CONST_ZERO = 1e-6f;
-
-/****************************************************************************************\
-*                                    Auxiliary struct definitions                                 *
-\****************************************************************************************/
-typedef struct CvLCM
-{
-    CvGraph* Graph;
-    CvVoronoiDiagram2D* VoronoiDiagram;
-    CvMemStorage* ContourStorage;
-    CvMemStorage* EdgeStorage;
-    float maxWidth;
-} CvLCM;
-
-typedef struct CvLCMComplexNodeData
-{
-    CvVoronoiNode2D edge_node;
-    CvPoint2D32f site_first_pt;
-    CvPoint2D32f site_last_pt;
-    CvVoronoiSite2D* site_first;
-    CvVoronoiSite2D* site_last;
-    CvVoronoiEdge2D* edge;
-} CvLCMComplexNodeData;
-
-typedef struct CvLCMData
-{
-    CvVoronoiNode2D* pnode;
-    CvVoronoiSite2D* psite;
-    CvVoronoiEdge2D* pedge;
-} CvLCMData;
-
-
-/****************************************************************************************\
-*                                    Function definitions                                *
-\****************************************************************************************/
-
-#define _CV_READ_SEQ_ELEM( elem, reader, type )                       \
-{                                                              \
-    assert( (reader).seq->elem_size == sizeof(*elem));         \
-    elem = (type)(reader).ptr;                                 \
-    CV_NEXT_SEQ_ELEM( sizeof(*elem), reader )                  \
-}
-
-#define _CV_IS_SITE_REFLEX( SITE )  ((SITE) ->node[0] == (SITE) ->node[1])
-#define _CV_IS_EDGE_REFLEX( EDGE )  (( (EDGE)->site[0]->node[0] == (EDGE)->site[0]->node[0] ) || \
-                                      ( (EDGE)->site[1]->node[0] == (EDGE)->site[1]->node[0] ) )
-
-#define _CV_INITIALIZE_CVLCMDATA(STRUCT,SITE,EDGE,NODE)\
-{ (STRUCT)->psite = SITE ; (STRUCT)->pedge = EDGE; (STRUCT)->pnode = NODE;}
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvConstructLCM
-//    Purpose: Function constructs hybrid model
-//    Context:
-//    Parameters:
-//      LCM : in&out.
-//    Returns: 1, if hybrid model was succesfully constructed
-//             0, if some error occures
-//F*/
-CV_IMPL
-int _cvConstructLCM(CvLCM* LCM);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvConstructLCMComplexNode
-//    Purpose: Function constructs Complex Node (node, which consists of
-//             two points and more) of hybrid model
-//    Context:
-//    Parameters:
-//      pLCM : in&out.
-//      pLCMEdge: in, input edge of hybrid model
-//      pLCMInputData: in, input parameters
-//    Returns: pointer to constructed node
-//F*/
-CV_IMPL
-CvLCMNode* _cvConstructLCMComplexNode(CvLCM* pLCM,
-                                      CvLCMEdge* pLCMEdge,
-                                      CvLCMData* pLCMInputData);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvConstructLCMSimpleNode
-//    Purpose: Function constructs Simple Node (node, which consists of
-//             one point) of hybrid model
-//    Context:
-//    Parameters:
-//      pLCM : in&out.
-//      pLCMEdge: in, input edge of hybrid model
-//      pLCMInputData: in, input parameters
-//    Returns: pointer to constructed node
-//F*/
-CV_IMPL
-CvLCMNode* _cvConstructLCMSimpleNode(CvLCM* pLCM,
-                                    CvLCMEdge* pLCMEdge,
-                                    CvLCMData* pLCMInputData);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvConstructLCMSimpleNode
-//    Purpose: Function constructs Edge of hybrid model
-//    Context:
-//    Parameters:
-//      pLCM : in&out.
-//      pLCMInputData: in, input parameters
-//    Returns: pointer to constructed edge
-//F*/
-CV_IMPL
-CvLCMEdge* _cvConstructLCMEdge(CvLCM* pLCM,
-                               CvLCMData* pLCMInputData);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvTreatExeptionalCase
-//    Purpose: Function treats triangles and regular polygons
-//    Context:
-//    Parameters:
-//      pLCM : in, information about graph
-//      pLCMInputData: in, input parameters
-//    Returns: pointer to graph node
-//F*/
-CV_IMPL
-CvLCMNode* _cvTreatExeptionalCase(CvLCM* pLCM,
-                                  CvLCMData* pLCMInputData);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvNodeMultyplicity
-//    Purpose: Function seeks all non-boundary edges incident to
-//              given node and correspondent incident sites
-//    Context:
-//    Parameters:
-//      pEdge : in, original edge
-//      pNode : in, given node
-//      LinkedEdges : out, matrix of incident edges
-//      LinkedSites : out, matrix of incident sites
-//      pSite: in, original site (pNode must be the begin point of pEdge
-//              for this pSite, this property hold out far all edges)
-//    Returns: number of incident edges (must be less than 10)
-//F*/
-CV_IMPL
-int _cvNodeMultyplicity(CvVoronoiSite2D* pSite,
-                        CvVoronoiEdge2D* pEdge,
-                        CvVoronoiNode2D* pNode,
-                        CvVoronoiEdge2D** LinkedEdges,
-                        CvVoronoiSite2D** LinkedSites);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvCreateLCMNode
-//    Purpose: Function create graph node
-//    Context:
-//    Parameters:
-//      pLCM : in, information about graph
-//    Returns: pointer to graph node
-//F*/
-CV_INLINE
-CvLCMNode* _cvCreateLCMNode(CvLCM* pLCM);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvCreateLCMEdge
-//    Purpose: Function create graph edge
-//    Context:
-//    Parameters:
-//      pLCM : in, information about graph
-//    Returns: pointer to graph edge
-//F*/
-CV_INLINE
-CvLCMEdge* _cvCreateLCMEdge(CvLCM* pLCM);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvCreateLCMNode
-//    Purpose: Function establishs the connection between node and ege
-//    Context:
-//    Parameters:
-//      LCMNode : in, graph node
-//      LCMEdge : in, graph edge
-//      LCMEdge_prev : in&out, previous edge, connected with given node
-//      index: in,
-//      i    : =0, if node is initial for edge
-//             =1, if node  is terminal for edge
-//    Returns:
-//F*/
-CV_INLINE
-void _cvAttachLCMEdgeToLCMNode(CvLCMNode* LCMNode,
-                               CvLCMEdge* LCMEdge,
-                               CvLCMEdge* &LCMEdge_prev,
-                               int index,
-                               int i);
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvProjectionPointToSegment
-//    Purpose: Function computes the ortogonal projection of PointO to
-//             to segment[PointA, PointB]
-//    Context:
-//    Parameters:
-//      PointO, PointA,PointB: in, given points
-//      PrPoint : out, projection
-//      dist : distance from PointO to PrPoint
-//    Returns:
-//F*/
-CV_IMPL
-void _cvProjectionPointToSegment(CvPoint2D32f* PointO,
-                                 CvPoint2D32f* PointA,
-                                 CvPoint2D32f* PointB,
-                                 CvPoint2D32f* PrPoint,
-                                 float* dist);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvPrepareData
-//    Purpose: Function fills up the struct CvLCMComplexNodeData
-//    Context:
-//    Parameters:
-//      pLCMData : in
-//      pLCMCCNData : out
-//    Returns:
-//F*/
-CV_INLINE
-void _cvPrepareData(CvLCMComplexNodeData* pLCMCCNData,
-                    CvLCMData* pLCMData);
-
-/****************************************************************************************\
-*                                    Function realization                               *
-\****************************************************************************************/
-
-CV_IMPL CvGraph* cvLinearContorModelFromVoronoiDiagram(CvVoronoiDiagram2D* VoronoiDiagram,
-                                                       float maxWidth)
-{
-    CvMemStorage* LCMstorage;
-    CvSet* SiteSet;
-    CvLCM LCM = {NULL, VoronoiDiagram,NULL,NULL,maxWidth};
-
-    CV_FUNCNAME( "cvLinearContorModelFromVoronoiDiagram" );
-     __BEGIN__;
-
-    if( !VoronoiDiagram )
-        CV_ERROR( CV_StsBadArg,"Voronoi Diagram is not defined" );
-    if( maxWidth < 0 )
-        CV_ERROR( CV_StsBadArg,"Treshold parameter must be non negative" );
-
-    for(SiteSet = VoronoiDiagram->sites;
-        SiteSet != NULL;
-        SiteSet = (CvSet*)SiteSet->h_next)
-        {
-            if(SiteSet->v_next)
-                CV_ERROR( CV_StsBadArg,"Can't operate with multiconnected domains" );
-            if(SiteSet->total > 70000)
-                CV_ERROR( CV_StsBadArg,"Can't operate with large domains" );
-        }
-
-
-    LCMstorage = cvCreateMemStorage(0);
-    LCM.EdgeStorage = cvCreateChildMemStorage(LCMstorage);
-    LCM.ContourStorage = cvCreateChildMemStorage(LCMstorage);
-    LCM.Graph = cvCreateGraph(CV_SEQ_KIND_GRAPH|CV_GRAPH_FLAG_ORIENTED,
-                              sizeof(CvGraph),
-                              sizeof(CvLCMNode),
-                              sizeof(CvLCMEdge),
-                              LCMstorage);
-    if(!_cvConstructLCM(&LCM))
-        cvReleaseLinearContorModelStorage(&LCM.Graph);
-
-
-    __END__;
-    return LCM.Graph;
-}//end of cvLinearContorModelFromVoronoiDiagram
-
-CV_IMPL int cvReleaseLinearContorModelStorage(CvGraph** Graph)
-{
-    CvSeq* LCMNodeSeq, *LCMEdgeSeq;
-    CvLCMNode* pLCMNode;
-    CvLCMEdge* pLCMEdge;
-
-    /*CV_FUNCNAME( "cvReleaseLinearContorModelStorage" );*/
-     __BEGIN__;
-
-    if(!Graph || !(*Graph))
-        return 0;
-
-    LCMNodeSeq = (CvSeq*)(*Graph);
-    LCMEdgeSeq = (CvSeq*)(*Graph)->edges;
-    if(LCMNodeSeq->total > 0)
-    {
-        pLCMNode = (CvLCMNode*)cvGetSeqElem(LCMNodeSeq,0);
-        if(pLCMNode->contour->storage)
-            cvReleaseMemStorage(&pLCMNode->contour->storage);
-    }
-    if(LCMEdgeSeq->total > 0)
-    {
-        pLCMEdge = (CvLCMEdge*)cvGetSeqElem(LCMEdgeSeq,0);
-        if(pLCMEdge->chain->storage)
-            cvReleaseMemStorage(&pLCMEdge->chain->storage);
-    }
-    if((*Graph)->storage)
-        cvReleaseMemStorage(&(*Graph)->storage);
-    *Graph = NULL;
-
-
-    __END__;
-    return 1;
-}//end of cvReleaseLinearContorModelStorage
-
-int _cvConstructLCM(CvLCM* LCM)
-{
-    CvVoronoiSite2D* pSite = 0;
-    CvVoronoiEdge2D* pEdge = 0, *pEdge1;
-    CvVoronoiNode2D* pNode, *pNode1;
-
-    CvVoronoiEdge2D* LinkedEdges[10];
-    CvVoronoiSite2D* LinkedSites[10];
-
-    CvSeqReader reader;
-    CvLCMData LCMdata;
-    int i;
-
-    for(CvSet* SiteSet = LCM->VoronoiDiagram->sites;
-        SiteSet != NULL;
-        SiteSet = (CvSet*)SiteSet->h_next)
-    {
-        cvStartReadSeq((CvSeq*)SiteSet, &reader);
-        for(i = 0; i < SiteSet->total; i++)
-        {
-            _CV_READ_SEQ_ELEM(pSite,reader,CvVoronoiSite2D*);
-            if(pSite->node[0] == pSite->node[1])
-                continue;
-            pEdge = CV_LAST_VORONOIEDGE2D(pSite);
-            pNode = CV_VORONOIEDGE2D_BEGINNODE(pEdge,pSite);
-            if(pNode->radius > LCM->maxWidth)
-                goto PREPARECOMPLEXNODE;
-
-            pEdge1 = CV_PREV_VORONOIEDGE2D(pEdge,pSite);
-            pNode1 = CV_VORONOIEDGE2D_BEGINNODE(pEdge1,pSite);
-            if(pNode1->radius > LCM->maxWidth)
-                goto PREPARECOMPLEXNODE;
-            if(pNode1->radius == 0)
-                continue;
-            if(_cvNodeMultyplicity(pSite, pEdge,pNode,LinkedEdges,LinkedSites) == 1)
-                goto PREPARESIMPLENODE;
-        }
-// treate triangle or regular polygon
-        _CV_INITIALIZE_CVLCMDATA(&LCMdata,pSite,pEdge,CV_VORONOIEDGE2D_ENDNODE(pEdge,pSite));
-        if(!_cvTreatExeptionalCase(LCM,&LCMdata))
-            return 0;
-        continue;
-
-PREPARECOMPLEXNODE:
-        _CV_INITIALIZE_CVLCMDATA(&LCMdata,pSite,pEdge,CV_VORONOIEDGE2D_ENDNODE(pEdge,pSite));
-        if(!_cvConstructLCMComplexNode(LCM,NULL,&LCMdata))
-            return 0;
-        continue;
-
-PREPARESIMPLENODE:
-        _CV_INITIALIZE_CVLCMDATA(&LCMdata,pSite,pEdge,CV_VORONOIEDGE2D_ENDNODE(pEdge,pSite));
-        if(!_cvConstructLCMSimpleNode(LCM,NULL,&LCMdata))
-            return 0;
-        continue;
-    }
-    return 1;
-}//end of _cvConstructLCM
-
-CvLCMNode* _cvConstructLCMComplexNode(CvLCM* pLCM,
-                                      CvLCMEdge* pLCMEdge,
-                                      CvLCMData* pLCMInputData)
-{
-    CvLCMNode* pLCMNode;
-    CvLCMEdge* pLCMEdge_prev = NULL;
-    CvSeqWriter writer;
-    CvVoronoiSite2D* pSite, *pSite_first, *pSite_last;
-    CvVoronoiEdge2D* pEdge, *pEdge_stop;
-    CvVoronoiNode2D* pNode0, *pNode1;
-    CvLCMData LCMOutputData;
-    CvLCMComplexNodeData LCMCCNData;
-    int index = 0;
-
-    _cvPrepareData(&LCMCCNData,pLCMInputData);
-
-    pLCMNode = _cvCreateLCMNode(pLCM);
-    _cvAttachLCMEdgeToLCMNode(pLCMNode,pLCMEdge,pLCMEdge_prev,1,1);
-    cvStartAppendToSeq((CvSeq*)pLCMNode->contour,&writer);
-    CV_WRITE_SEQ_ELEM(LCMCCNData.site_last_pt, writer);
-    index++;
-
-    if(pLCMEdge)
-    {
-        CV_WRITE_SEQ_ELEM(LCMCCNData.edge_node.pt, writer );
-        CV_WRITE_SEQ_ELEM(LCMCCNData.site_first_pt, writer );
-        index+=2;
-    }
-
-    pSite_first = LCMCCNData.site_first;
-    pSite_last = LCMCCNData.site_last;
-    pEdge = LCMCCNData.edge;
-
-    for(pSite = pSite_first;
-        pSite != pSite_last;
-        pSite = CV_NEXT_VORONOISITE2D(pSite),
-        pEdge = CV_PREV_VORONOIEDGE2D(CV_LAST_VORONOIEDGE2D(pSite),pSite))
-    {
-        pEdge_stop = CV_FIRST_VORONOIEDGE2D(pSite);
-        for(;pEdge && pEdge != pEdge_stop;
-             pEdge = CV_PREV_VORONOIEDGE2D(pEdge,pSite))
-        {
-            pNode0 = CV_VORONOIEDGE2D_BEGINNODE(pEdge,pSite);
-            pNode1 = CV_VORONOIEDGE2D_ENDNODE(pEdge,pSite);
-            if(pNode0->radius <= pLCM->maxWidth && pNode1->radius <= pLCM->maxWidth)
-            {
-                _CV_INITIALIZE_CVLCMDATA(&LCMOutputData,pSite,pEdge,pNode1);
-                _cvPrepareData(&LCMCCNData,&LCMOutputData);
-                CV_WRITE_SEQ_ELEM(LCMCCNData.site_first_pt, writer);
-                CV_WRITE_SEQ_ELEM(LCMCCNData.edge_node.pt, writer );
-                index+=2;
-                pLCMEdge = _cvConstructLCMEdge(pLCM,&LCMOutputData);
-                _cvAttachLCMEdgeToLCMNode(pLCMNode,pLCMEdge,pLCMEdge_prev,index - 1,0);
-                CV_WRITE_SEQ_ELEM(LCMCCNData.site_last_pt, writer);
-                index++;
-
-                pSite = CV_TWIN_VORONOISITE2D(pSite,pEdge);
-                pEdge_stop = CV_FIRST_VORONOIEDGE2D(pSite);
-                if(pSite == pSite_last)
-                    break;
-            }
-        }
-        if(pSite == pSite_last)
-            break;
-
-        CV_WRITE_SEQ_ELEM(pSite->node[1]->pt, writer);
-        index++;
-    }
-
-    if(pLCMEdge_prev)
-        pLCMEdge_prev->next[(pLCMEdge_prev == (CvLCMEdge*)pLCMNode->first)] = pLCMNode->first;
-    cvEndWriteSeq(&writer);
-    return pLCMNode;
-}//end of _cvConstructLCMComplexNode
-
-CvLCMNode* _cvConstructLCMSimpleNode(CvLCM* pLCM,
-                                     CvLCMEdge* pLCMEdge,
-                                     CvLCMData* pLCMInputData)
-{
-    CvVoronoiEdge2D* pEdge = pLCMInputData->pedge;
-    CvVoronoiSite2D* pSite = pLCMInputData->psite;
-    CvVoronoiNode2D* pNode = CV_VORONOIEDGE2D_BEGINNODE(pEdge,pSite);
-
-    CvVoronoiEdge2D* LinkedEdges[10];
-    CvVoronoiSite2D* LinkedSites[10];
-    int multyplicity = _cvNodeMultyplicity(pSite,pEdge,pNode,LinkedEdges,LinkedSites);
-    if(multyplicity == 2)
-    {
-        pLCMInputData->pedge = LinkedEdges[1];
-        pLCMInputData->psite = CV_TWIN_VORONOISITE2D(LinkedSites[1],LinkedEdges[1]);
-        return NULL;
-    }
-
-    CvLCMEdge* pLCMEdge_prev = NULL;
-    CvLCMNode* pLCMNode;
-    CvLCMData LCMOutputData;
-
-    pLCMNode = _cvCreateLCMNode(pLCM);
-    cvSeqPush((CvSeq*)pLCMNode->contour,&pNode->pt);
-    _cvAttachLCMEdgeToLCMNode(pLCMNode,pLCMEdge,pLCMEdge_prev,0,1);
-
-    for(int i = (int)(pLCMEdge != NULL);i < multyplicity; i++)
-    {
-        pEdge = LinkedEdges[i];
-        pSite = LinkedSites[i];
-        _CV_INITIALIZE_CVLCMDATA(&LCMOutputData,CV_TWIN_VORONOISITE2D(pSite,pEdge),pEdge,pNode);
-        pLCMEdge = _cvConstructLCMEdge(pLCM,&LCMOutputData);
-        _cvAttachLCMEdgeToLCMNode(pLCMNode,pLCMEdge,pLCMEdge_prev,0,0);
-    }
-    pLCMEdge_prev->next[(pLCMEdge_prev == (CvLCMEdge*)pLCMNode->first)] = pLCMNode->first;
-    return pLCMNode;
-}//end of _cvConstructLCMSimpleNode
-
-CvLCMEdge* _cvConstructLCMEdge(CvLCM* pLCM,
-                               CvLCMData* pLCMInputData)
-{
-    CvVoronoiEdge2D* pEdge = pLCMInputData->pedge;
-    CvVoronoiSite2D* pSite = pLCMInputData->psite;
-    float width = 0;
-
-    CvLCMData LCMData;
-    CvVoronoiNode2D* pNode0,*pNode1;
-
-    CvLCMEdge* pLCMEdge = _cvCreateLCMEdge(pLCM);
-
-    CvSeqWriter writer;
-    cvStartAppendToSeq(pLCMEdge->chain,&writer );
-
-    pNode0 = pNode1 = pLCMInputData->pnode;
-    CV_WRITE_SEQ_ELEM(pNode0->pt, writer);
-    width += pNode0->radius;
-
-    for(int counter = 0;
-            counter < pLCM->VoronoiDiagram->edges->total;
-            counter++)
-    {
-        pNode1 = CV_VORONOIEDGE2D_BEGINNODE(pEdge,pSite);
-        if(pNode1->radius >= pLCM->maxWidth)
-            goto CREATECOMPLEXNODE;
-
-        CV_WRITE_SEQ_ELEM(pNode1->pt,writer);
-        width += pNode1->radius;
-        _CV_INITIALIZE_CVLCMDATA(&LCMData,pSite,pEdge,pNode1);
-        if(_cvConstructLCMSimpleNode(pLCM,pLCMEdge,&LCMData))
-            goto LCMEDGEEXIT;
-
-        pEdge = LCMData.pedge; pSite = LCMData.psite;
-        pNode0 = pNode1;
-    }
-    return NULL;
-
-CREATECOMPLEXNODE:
-    _CV_INITIALIZE_CVLCMDATA(&LCMData,pSite,pEdge,pNode0);
-    CV_WRITE_SEQ_ELEM(LCMData.pnode->pt,writer);
-    width += LCMData.pnode->radius;
-    _cvConstructLCMComplexNode(pLCM,pLCMEdge,&LCMData);
-
-LCMEDGEEXIT:
-    cvEndWriteSeq(&writer);
-    pLCMEdge->width = width/pLCMEdge->chain->total;
-    return pLCMEdge;
-}//end of _cvConstructLCMEdge
-
-CvLCMNode* _cvTreatExeptionalCase(CvLCM* pLCM,
-                                  CvLCMData* pLCMInputData)
-{
-    CvVoronoiEdge2D* pEdge = pLCMInputData->pedge;
-    CvVoronoiSite2D* pSite = pLCMInputData->psite;
-    CvVoronoiNode2D* pNode = CV_VORONOIEDGE2D_BEGINNODE(pEdge,pSite);
-    CvLCMNode* pLCMNode = _cvCreateLCMNode(pLCM);
-    cvSeqPush((CvSeq*)pLCMNode->contour,&pNode->pt);
-    return pLCMNode;
-}//end of _cvConstructLCMEdge
-
-CV_INLINE
-CvLCMNode* _cvCreateLCMNode(CvLCM* pLCM)
-{
-    CvLCMNode* pLCMNode;
-    cvSetAdd((CvSet*)pLCM->Graph, NULL, (CvSetElem**)&pLCMNode );
-    pLCMNode->contour = (CvContour*)cvCreateSeq(0, sizeof(CvContour),
-                                                   sizeof(CvPoint2D32f),pLCM->ContourStorage);
-    pLCMNode->first = NULL;
-    return pLCMNode;
-}//end of _cvCreateLCMNode
-
-CV_INLINE
-CvLCMEdge* _cvCreateLCMEdge(CvLCM* pLCM)
-{
-    CvLCMEdge* pLCMEdge;
-    cvSetAdd( (CvSet*)(pLCM->Graph->edges), 0, (CvSetElem**)&pLCMEdge );
-    pLCMEdge->chain = cvCreateSeq(0, sizeof(CvSeq),sizeof(CvPoint2D32f),pLCM->EdgeStorage);
-    pLCMEdge->next[0] = pLCMEdge->next[1] = NULL;
-    pLCMEdge->vtx[0] =  pLCMEdge->vtx[1] = NULL;
-    pLCMEdge->index1 =  pLCMEdge->index2 = -1;
-    return pLCMEdge;
-}//end of _cvCreateLCMEdge
-
-CV_INLINE
-void _cvAttachLCMEdgeToLCMNode(CvLCMNode* LCMNode,
-                               CvLCMEdge* LCMEdge,
-                               CvLCMEdge* &LCMEdge_prev,
-                               int index,
-                               int i)
-{
-    if(!LCMEdge)
-        return;
-    if(i==0)
-        LCMEdge->index1 = index;
-    else
-        LCMEdge->index2 = index;
-
-    LCMEdge->vtx[i] = (CvGraphVtx*)LCMNode;
-    if(!LCMEdge_prev)
-        LCMNode->first = (CvGraphEdge*)LCMEdge;
-    else
-//      LCMEdge_prev->next[(LCMEdge_prev == (CvLCMEdge*)LCMNode->first)] = (CvGraphEdge*)LCMEdge;
-        LCMEdge_prev->next[(LCMEdge_prev->vtx[0] != (CvGraphVtx*)LCMNode)] = (CvGraphEdge*)LCMEdge;
-
-    LCMEdge->next[i] = LCMNode->first;
-    LCMEdge_prev = LCMEdge;
-}//end of _cvAttachLCMEdgeToLCMNode
-
-
-int _cvNodeMultyplicity(CvVoronoiSite2D* pSite,
-                        CvVoronoiEdge2D* pEdge,
-                        CvVoronoiNode2D* pNode,
-                        CvVoronoiEdge2D** LinkedEdges,
-                        CvVoronoiSite2D** LinkedSites)
-{
-    if(!pNode->radius)
-        return -1;
-    assert(pNode == CV_VORONOIEDGE2D_BEGINNODE(pEdge,pSite));
-
-    int multyplicity = 0;
-    CvVoronoiEdge2D* pEdge_cur = pEdge;
-    do
-    {
-        if(pEdge_cur->node[0]->radius && pEdge_cur->node[1]->radius)
-        {
-            LinkedEdges[multyplicity] = pEdge_cur;
-            LinkedSites[multyplicity] = pSite;
-            multyplicity++;
-        }
-        pEdge_cur = CV_PREV_VORONOIEDGE2D(pEdge_cur,pSite);
-        pSite = CV_TWIN_VORONOISITE2D(pSite,pEdge_cur);
-    }while(pEdge_cur != pEdge);
-    return multyplicity;
-}//end of _cvNodeMultyplicity
-
-
-CV_INLINE
-void _cvPrepareData(CvLCMComplexNodeData* pLCMCCNData,
-                    CvLCMData* pLCMData)
-{
-    pLCMCCNData->site_first = pLCMData->psite;
-    pLCMCCNData->site_last = CV_TWIN_VORONOISITE2D(pLCMData->psite,pLCMData->pedge);
-    if(pLCMData->pedge == CV_LAST_VORONOIEDGE2D(pLCMData->psite))
-    {
-        pLCMCCNData->edge = CV_PREV_VORONOIEDGE2D(pLCMData->pedge,pLCMData->psite);
-        pLCMCCNData->edge_node = *pLCMData->pnode;
-        pLCMCCNData->site_first_pt = pLCMData->psite->node[0]->pt;
-        pLCMCCNData->site_last_pt = pLCMData->psite->node[0]->pt;
-    }
-    else
-    {
-        pLCMCCNData->edge = pLCMData->pedge;
-        pLCMCCNData->edge_node = *pLCMData->pnode;
-        _cvProjectionPointToSegment(&pLCMCCNData->edge_node.pt,
-                                  &pLCMCCNData->site_first->node[0]->pt,
-                                  &pLCMCCNData->site_first->node[1]->pt,
-                                  &pLCMCCNData->site_first_pt,
-                                  NULL);
-        _cvProjectionPointToSegment(&pLCMCCNData->edge_node.pt,
-                                  &pLCMCCNData->site_last->node[0]->pt,
-                                  &pLCMCCNData->site_last->node[1]->pt,
-                                  &pLCMCCNData->site_last_pt,
-                                  NULL);
-    }
-}//end of _cvPrepareData
-
-
-void _cvProjectionPointToSegment(CvPoint2D32f* PointO,
-                                 CvPoint2D32f* PointA,
-                                 CvPoint2D32f* PointB,
-                                 CvPoint2D32f* PrPoint,
-                                 float* dist)
-{
-    float scal_AO_AB, scal_AB_AB;
-    CvPoint2D32f VectorAB(PointB->x - PointA->x, PointB->y - PointA->y);
-    scal_AB_AB = VectorAB.x*VectorAB.x + VectorAB.y*VectorAB.y;
-    if(scal_AB_AB < LCM_CONST_ZERO)
-    {
-        *PrPoint = *PointA;
-        if(dist)
-            *dist = (float)sqrt( (double)(PointO->x -PointA->x)*(PointO->x -PointA->x) + (PointO->y - PointA->y)*(PointO->y - PointA->y));
-        return;
-    }
-
-    CvPoint2D32f VectorAO(PointO->x - PointA->x, PointO->y - PointA->y);
-    scal_AO_AB = VectorAO.x*VectorAB.x + VectorAO.y*VectorAB.y;
-
-    if(dist)
-    {
-        float vector_AO_AB = (float)fabs(VectorAO.x*VectorAB.y - VectorAO.y*VectorAB.x);
-        *dist = (float)(vector_AO_AB/sqrt((double)scal_AB_AB));
-    }
-
-    float alfa = scal_AO_AB/scal_AB_AB;
-    PrPoint->x = PointO->x - VectorAO.x + alfa*VectorAB.x;
-    PrPoint->y = PointO->y - VectorAO.y + alfa*VectorAB.y;
-    return;
-}//end of _cvProjectionPointToSegment
diff --git a/modules/legacy/src/lee.cpp b/modules/legacy/src/lee.cpp
deleted file mode 100644 (file)
index 85fe497..0000000
+++ /dev/null
@@ -1,4715 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/* Reconstruction of contour skeleton */
-#include "precomp.hpp"
-#include <time.h>
-
-#define NEXT_SEQ(seq,seq_first) ((seq) == (seq_first) ? seq->v_next : seq->h_next)
-#define SIGN(x) ( x<0 ? -1:( x>0 ? 1:0 ) )
-
-const float LEE_CONST_ZERO = 1e-6f;
-const float LEE_CONST_DIFF_POINTS = 1e-2f;
-const float LEE_CONST_ACCEPTABLE_ERROR = 1e-4f;
-
-/****************************************************************************************\
-*                                    Auxiliary struct definitions                                 *
-\****************************************************************************************/
-
-template<class T>
-struct CvLeePoint
-{
-    T x,y;
-};
-
-typedef CvLeePoint<float> CvPointFloat;
-typedef CvLeePoint<float> CvDirection;
-
-struct CvVoronoiSiteInt;
-struct CvVoronoiEdgeInt;
-struct CvVoronoiNodeInt;
-struct CvVoronoiParabolaInt;
-struct CvVoronoiChainInt;
-struct CvVoronoiHoleInt;
-
-struct CvVoronoiDiagramInt
-{
-    CvSeq* SiteSeq;
-    CvSeq* EdgeSeq;
-    CvSeq* NodeSeq;
-    CvSeq* ChainSeq;
-    CvSeq* ParabolaSeq;
-    CvSeq* DirectionSeq;
-    CvSeq* HoleSeq;
-    CvVoronoiSiteInt* reflex_site;
-    CvVoronoiHoleInt* top_hole;
-};
-
-struct CvVoronoiStorageInt
-{
-    CvMemStorage* SiteStorage;
-    CvMemStorage* EdgeStorage;
-    CvMemStorage* NodeStorage;
-    CvMemStorage* ChainStorage;
-    CvMemStorage* ParabolaStorage;
-    CvMemStorage* DirectionStorage;
-    CvMemStorage* HoleStorage;
-};
-
-struct CvVoronoiNodeInt
-{
-    CvPointFloat  node;
-    float         radius;
-};
-
-struct CvVoronoiSiteInt
-{
-    CvVoronoiNodeInt* node1;
-    CvVoronoiNodeInt* node2;
-    CvVoronoiEdgeInt* edge1;
-    CvVoronoiEdgeInt* edge2;
-    CvVoronoiSiteInt* next_site;
-    CvVoronoiSiteInt* prev_site;
-    CvDirection* direction;
-};
-
-struct CvVoronoiEdgeInt
-{
-    CvVoronoiNodeInt* node1;
-    CvVoronoiNodeInt* node2;
-    CvVoronoiSiteInt* site;
-    CvVoronoiEdgeInt* next_edge;
-    CvVoronoiEdgeInt* prev_edge;
-    CvVoronoiEdgeInt* twin_edge;
-    CvVoronoiParabolaInt* parabola;
-    CvDirection*  direction;
-};
-
-struct CvVoronoiParabolaInt
-{
-    float map[6];
-    float a;
-    CvVoronoiNodeInt* focus;
-    CvVoronoiSiteInt* directrice;
-};
-
-struct CvVoronoiChainInt
-{
-    CvVoronoiSiteInt * first_site;
-    CvVoronoiSiteInt * last_site;
-    CvVoronoiChainInt* next_chain;
-};
-
-struct CvVoronoiHoleInt
-{
-    CvSeq* SiteSeq;
-    CvSeq* ChainSeq;
-    CvVoronoiSiteInt* site_top;
-    CvVoronoiSiteInt* site_nearest;
-    CvVoronoiSiteInt* site_opposite;
-    CvVoronoiNodeInt* node;
-    CvVoronoiHoleInt* next_hole;
-    bool error;
-    float x_coord;
-};
-
-typedef CvVoronoiSiteInt* pCvVoronoiSite;
-typedef CvVoronoiEdgeInt* pCvVoronoiEdge;
-typedef CvVoronoiNodeInt* pCvVoronoiNode;
-typedef CvVoronoiParabolaInt* pCvVoronoiParabola;
-typedef CvVoronoiChainInt* pCvVoronoiChain;
-typedef CvVoronoiHoleInt* pCvVoronoiHole;
-typedef CvPointFloat* pCvPointFloat;
-typedef CvDirection* pCvDirection;
-
-/****************************************************************************************\
-*                                    Function definitions                                *
-\****************************************************************************************/
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvLee
-//    Purpose: Compute Voronoi Diagram for one given polygon with holes
-//    Context:
-//    Parameters:
-//      ContourSeq : in, vertices of polygon.
-//      VoronoiDiagramInt : in&out, pointer to struct, which contains the
-//                       description of Voronoi Diagram.
-//      VoronoiStorage: in, storage for Voronoi Diagram.
-//      contour_type: in, type of vertices.
-//                    The possible values are CV_LEE_INT,CV_LEE_FLOAT,CV_LEE_DOUBLE.
-//      contour_orientation: in, orientation of polygons.
-//                           = 1, if contour is left - oriented in left coordinat system
-//                           =-1, if contour is left - oriented in right coordinat system
-//      attempt_number: in, number of unsuccessful attemts made by program to compute
-//                          the Voronoi Diagram befor return the error
-//
-//    Returns: 1, if Voronoi Diagram was succesfully computed
-//             0, if some error occures
-//F*/
-static int  _cvLee(CvSeq* ContourSeq,
-                      CvVoronoiDiagramInt* pVoronoiDiagramInt,
-                      CvMemStorage* VoronoiStorage,
-                      CvLeeParameters contour_type,
-                      int contour_orientation,
-                      int attempt_number);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvConstuctSites
-//    Purpose : Compute sites for given polygon with holes
-//                     (site is an edge of polygon or a reflex vertex).
-//    Context:
-//    Parameters:
-//            ContourSeq : in, vertices of polygon
-//       pVoronoiDiagram : in, pointer to struct, which contains the
-//                          description of Voronoi Diagram
-//           contour_type: in, type of vertices.  The possible values are
-//                          CV_LEE_INT,CV_LEE_FLOAT,CV_LEE_DOUBLE.
-//    contour_orientation: in, orientation of polygons.
-//                           = 1, if contour is left - oriented in left coordinat system
-//                           =-1, if contour is left - oriented in right coordinat system
-//     Return: 1, if sites were succesfully constructed
-//             0, if some error occures
-//F*/
-static int _cvConstuctSites(CvSeq* ContourSeq,
-                            CvVoronoiDiagramInt* pVoronoiDiagram,
-                            CvLeeParameters contour_type,
-                            int contour_orientation);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvConstructChains
-//    Purpose : Compute chains for given polygon with holes.
-//    Context:
-//    Parameters:
-//       pVoronoiDiagram : in, pointer to struct, which contains the
-//                          description of Voronoi Diagram
-//     Return: 1, if chains were succesfully constructed
-//             0, if some error occures
-//F*/
-static int _cvConstructChains(CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvConstructSkeleton
-//    Purpose: Compute skeleton for given collection of sites, using Lee algorithm
-//    Context:
-//    Parameters:
-//      VoronoiDiagram : in, pointer to struct, which contains the
-//                       description of Voronoi Diagram.
-//    Returns: 1, if skeleton was succesfully computed
-//             0, if some error occures
-//F*/
-static int _cvConstructSkeleton(CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:  Andrey Sobolev
-//    Name:    _cvConstructSiteTree
-//    Purpose: Construct tree of sites (by analogy with contour tree).
-//    Context:
-//    Parameters:
-//      VoronoiDiagram : in, pointer to struct, which contains the
-//                       description of Voronoi Diagram.
-//    Returns:
-//F*/
-static void _cvConstructSiteTree(CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Author:   Andrey Sobolev
-//    Name:     _cvReleaseVoronoiStorage
-//    Purpose : Function realease storages.
-//                  The storages are divided into two groups:
-//                  SiteStorage, EdgeStorage, NodeStorage form the first group;
-//                  ChainStorage,ParabolaStorage,DirectionStorage,HoleStorage form the second group.
-//    Context:
-//    Parameters:
-//        pVoronoiStorage: in,
-//        group1,group2: in, if group1<>0 then storages from first group released
-//                           if group2<>0 then storages from second group released
-//    Return    :
-//F*/
-static void _cvReleaseVoronoiStorage(CvVoronoiStorageInt* pVoronoiStorage, int group1, int group2);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//  Author:  Andrey Sobolev
-//  Name:  _cvConvert
-//  Purpose :  Function convert internal representation of VD (via
-//                  structs CvVoronoiSiteInt, CvVoronoiEdgeInt,CvVoronoiNodeInt) into
-//                  external representation of VD (via structs CvVoronoiSite2D, CvVoronoiEdge2D,
-//                  CvVoronoiNode2D)
-//    Context:
-//    Parameters:
-//        VoronoiDiagram: in
-//        VoronoiStorage: in
-//        change_orientation: in, if = -1 then the convertion is accompanied with change
-//                            of orientation
-//
-//     Return: 1, if convertion was succesfully completed
-//             0, if some error occures
-//F*/
-/*
-static int _cvConvert(CvVoronoiDiagram2D* VoronoiDiagram,
-                      CvMemStorage* VoronoiStorage,
-                      int change_orientation);
-*/
-static int _cvConvert(CvVoronoiDiagram2D* VoronoiDiagram,
-                       CvVoronoiDiagramInt VoronoiDiagramInt,
-                       CvSet* &NewSiteSeqPrev,
-                       CvSeqWriter &NodeWriter,
-                       CvSeqWriter &EdgeWriter,
-                       CvMemStorage* VoronoiStorage,
-                       int change_orientation);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//  Author:  Andrey Sobolev
-//  Name:  _cvConvertSameOrientation
-//  Purpose :  Function convert internal representation of VD (via
-//                  structs CvVoronoiSiteInt, CvVoronoiEdgeInt,CvVoronoiNodeInt) into
-//                  external representation of VD (via structs CvVoronoiSite2D, CvVoronoiEdge2D,
-//                  CvVoronoiNode2D) without change of orientation
-//    Context:
-//    Parameters:
-//        VoronoiDiagram: in
-//        VoronoiStorage: in
-/
-//     Return: 1, if convertion was succesfully completed
-//             0, if some error occures
-//F*/
-/*
-static int _cvConvertSameOrientation(CvVoronoiDiagram2D* VoronoiDiagram,
-                                      CvMemStorage* VoronoiStorage);
-*/
-static int _cvConvertSameOrientation(CvVoronoiDiagram2D* VoronoiDiagram,
-                       CvVoronoiDiagramInt VoronoiDiagramInt,
-                       CvSet* &NewSiteSeqPrev,
-                       CvSeqWriter &NodeWriter,
-                       CvSeqWriter &EdgeWriter,
-                       CvMemStorage* VoronoiStorage);
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//  Author:  Andrey Sobolev
-//  Name:  _cvConvertChangeOrientation
-//  Purpose :  Function convert internal representation of VD (via
-//                  structs CvVoronoiSiteInt, CvVoronoiEdgeInt,CvVoronoiNodeInt) into
-//                  external representation of VD (via structs CvVoronoiSite2D, CvVoronoiEdge2D,
-//                  CvVoronoiNode2D) with change of orientation
-//    Context:
-//    Parameters:
-//        VoronoiDiagram: in
-//        VoronoiStorage: in
-/
-//     Return: 1, if convertion was succesfully completed
-//             0, if some error occures
-//F*/
-/*
-static int _cvConvertChangeOrientation(CvVoronoiDiagram2D* VoronoiDiagram,
-                                      CvMemStorage* VoronoiStorage);
-                                      */
-static int _cvConvertChangeOrientation(CvVoronoiDiagram2D* VoronoiDiagram,
-                       CvVoronoiDiagramInt VoronoiDiagramInt,
-                       CvSet* &NewSiteSeqPrev,
-                       CvSeqWriter &NodeWriter,
-                       CvSeqWriter &EdgeWriter,
-                       CvMemStorage* VoronoiStorage);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute  sites for external polygon.
-    Arguments
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     ContourSeq : in, vertices of polygon
-     pReflexSite: out, pointer to reflex site,if any exist,else NULL
-     orientation: in, orientation of contour ( = 1 or = -1)
-     type:        in, type of vertices. The possible values are (int)1,
-                   (float)1,(double)1.
-     Return:    1, if sites were succesfully constructed
-                0, if some error occures    :
-    --------------------------------------------------------------------------*/
-template<class T>
-int _cvConstructExtSites(CvVoronoiDiagramInt* pVoronoiDiagram,
-                         CvSeq* ContourSeq,
-                         int orientation,
-                         T /*type*/);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute  sites for internal polygon (for hole).
-    Arguments
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     CurrSiteSeq: in, the sequence for sites to be constructed
-     CurrContourSeq : in, vertices of polygon
-     pTopSite: out, pointer to the most left site of polygon (it is the most left
-                vertex of polygon)
-     orientation: in, orientation of contour ( = 1 or = -1)
-     type:        in, type of vertices. The possible values are (int)1,
-                   (float)1,(double)1.
-     Return:    1, if sites were succesfully constructed
-                0, if some error occures    :
-    --------------------------------------------------------------------------*/
-template<class T>
-int _cvConstructIntSites(CvVoronoiDiagramInt* pVoronoiDiagram,
-                         CvSeq* CurrSiteSeq,
-                         CvSeq* CurrContourSeq,
-                         pCvVoronoiSite &pTopSite,
-                         int orientation,
-                         T /*type*/);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute the simple chains of sites for external polygon.
-    Arguments
-     pVoronoiDiagram : in&out, pointer to struct, which contains the
-                        description of Voronoi Diagram
-
-    Return: 1, if chains were succesfully constructed
-            0, if some error occures
-    --------------------------------------------------------------------------*/
-static int _cvConstructExtChains(CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute the simple chains of sites for internal polygon (= hole)
-    Arguments
-    pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-    CurrSiteSeq : in, the sequence of sites
-   CurrChainSeq : in,the sequence for chains to be constructed
-       pTopSite : in, the most left site of hole
-
-      Return    :
-    --------------------------------------------------------------------------*/
-static void _cvConstructIntChains(CvVoronoiDiagramInt* pVoronoiDiagram,
-                                  CvSeq* CurrChainSeq,
-                                  CvSeq* CurrSiteSeq,
-                                  pCvVoronoiSite pTopSite);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute the initial Voronoi Diagram for single site
-    Arguments
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     pSite: in, pointer to site
-
-     Return :
-    --------------------------------------------------------------------------*/
-static void _cvConstructEdges(pCvVoronoiSite pSite,CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function moves each node on small random value. The nodes are taken
-                    from pVoronoiDiagram->NodeSeq.
-    Arguments
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     begin,end: in, the first and the last nodes in pVoronoiDiagram->NodeSeq,
-                    which moves
-     shift: in, the value of maximal shift.
-     Return :
-    --------------------------------------------------------------------------*/
-static void _cvRandomModification(CvVoronoiDiagramInt* pVoronoiDiagram, int begin, int end, float shift);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute the internal Voronoi Diagram for external polygon.
-    Arguments
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     Return     : 1, if VD was constructed succesfully
-                  0, if some error occure
-    --------------------------------------------------------------------------*/
-static int _cvConstructExtVD(CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute the external Voronoi Diagram for each internal polygon (hole).
-    Arguments
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     Return     :
-    --------------------------------------------------------------------------*/
-static void _cvConstructIntVD(CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function joins the Voronoi Diagrams of different
-                    chains into one Voronoi Diagram
-    Arguments
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     pChain1,pChain1: in, given chains
-     Return     : 1, if joining was succesful
-                  0, if some error occure
-    --------------------------------------------------------------------------*/
-static int _cvJoinChains(pCvVoronoiChain pChain1,
-                         pCvVoronoiChain pChain2,
-                         CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function finds the nearest site for top vertex
-                 (= the most left vertex) of each hole
-    Arguments
-        pVoronoiDiagram : in, pointer to struct, which contains the
-                         description of Voronoi Diagram
-     Return     :
-    --------------------------------------------------------------------------*/
-static void _cvFindNearestSite(CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function seeks for site, which has common bisector in
-                  final VD with top vertex of given hole. It stores in pHole->opposite_site.
-                   The search begins from  Hole->nearest_site and realizes in clockwise
-                   direction around the top vertex of given hole.
-    Arguments
-        pVoronoiDiagram : in, pointer to struct, which contains the
-                          description of Voronoi Diagram
-          pHole : in, given hole
-     Return     : 1, if the search was succesful
-                  0, if some error occure
-    --------------------------------------------------------------------------*/
-static int _cvFindOppositSiteCW(pCvVoronoiHole pHole, CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function seeks for site, which has common bisector in
-                  final VD with top vertex of given hole. It stores in pHole->opposite_site.
-                   The search begins from  Hole->nearest_site and realizes in counterclockwise
-                   direction around the top vertex of given hole.
-    Arguments
-        pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-          pHole : in, given hole
-     Return     : 1, if the search was succesful
-                  0, if some error occure
-    --------------------------------------------------------------------------*/
-static int _cvFindOppositSiteCCW(pCvVoronoiHole pHole,CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function merges external VD of hole and internal VD, which was
-                  constructed ealier.
-    Arguments
-pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-          pHole : in, given hole
-     Return     : 1, if merging was succesful
-                  0, if some error occure
-    --------------------------------------------------------------------------*/
-static int _cvMergeVD(pCvVoronoiHole pHole,CvVoronoiDiagramInt* pVoronoiDiagram);
-
-
-/* ///////////////////////////////////////////////////////////////////////////////////////
-//                               Computation of bisectors                               //
-/////////////////////////////////////////////////////////////////////////////////////// */
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute the bisector of two sites
-    Arguments
-     pSite_left,pSite_right: in, given sites
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     pEdge      : out, bisector
-     Return     :
-    --------------------------------------------------------------------------*/
-void _cvCalcEdge(pCvVoronoiSite pSite_left,
-                pCvVoronoiSite pSite_right,
-                pCvVoronoiEdge pEdge,
-                CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute the bisector of point and site
-    Arguments
-     pSite      : in, site
-     pNode      : in, point
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     pEdge      : out, bisector
-     Return     :
-    --------------------------------------------------------------------------*/
-void _cvCalcEdge(pCvVoronoiSite pSite,
-                pCvVoronoiNode pNode,
-                pCvVoronoiEdge pEdge,
-                CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute the bisector of point and site
-    Arguments
-     pSite      : in, site
-     pNode      : in, point
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     pEdge      : out, bisector
-     Return     :
-    --------------------------------------------------------------------------*/
-void _cvCalcEdge(pCvVoronoiNode pNode,
-                pCvVoronoiSite pSite,
-                pCvVoronoiEdge pEdge,
-                CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute the direction of bisector of two segments
-    Arguments
-     pDirection1: in, direction of first segment
-     pDirection2: in, direction of second segment
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     pEdge      : out, bisector
-     Return     :
-    --------------------------------------------------------------------------*/
-CV_INLINE
-void _cvCalcEdgeLL(pCvDirection pDirection1,
-                  pCvDirection pDirection2,
-                  pCvVoronoiEdge pEdge,
-                  CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute the bisector of two points
-    Arguments
-     pPoint1, pPoint2: in, given points
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     pEdge      : out, bisector
-     Return     :
-    --------------------------------------------------------------------------*/
-CV_INLINE
-void _cvCalcEdgePP(pCvPointFloat pPoint1,
-                  pCvPointFloat pPoint2,
-                  pCvVoronoiEdge pEdge,
-                  CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute the bisector of segment and point. Since
-                    it is parabola, it is defined by its focus (site - point)
-                    and directrice(site-segment)
-    Arguments
-     pFocus    : in, point, which defines the focus of parabola
-     pDirectrice: in, site - segment, which defines the directrice of parabola
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     pEdge      : out, bisector
-     Return     :
-    --------------------------------------------------------------------------*/
-CV_INLINE
-void _cvCalcEdgePL(pCvVoronoiNode pFocus,
-                  pCvVoronoiSite pDirectrice,
-                  pCvVoronoiEdge pEdge,
-                  CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Compute the bisector of segment and point. Since
-                    it is parabola, it is defined by its focus (site - point)
-                    and directrice(site-segment)
-    Arguments
-     pFocus    : in, point, which defines the focus of parabola
-     pDirectrice: in, site - segment, which defines the directrice of parabola
-     pVoronoiDiagram : in, pointer to struct, which contains the
-                        description of Voronoi Diagram
-     pEdge      : out, bisector
-     Return     :
-    --------------------------------------------------------------------------*/
-CV_INLINE
-void _cvCalcEdgeLP(pCvVoronoiSite pDirectrice,
-                  pCvVoronoiNode pFocus,
-                  pCvVoronoiEdge pEdge,
-                  CvVoronoiDiagramInt* pVoronoiDiagram);
-
-/* ///////////////////////////////////////////////////////////////////////////////////////
-//                  Computation of intersections of bisectors                           //
-/////////////////////////////////////////////////////////////////////////////////////// */
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes intersection of two edges. Intersection
-                    must be the nearest to the marked point on pEdge1
-                    (this marked point is pEdge1->node1->node).
-    Arguments
-    pEdge1,pEdge2: in, two edges
-        pPoint: out, intersection of pEdge1 and pEdge2
-        Radius: out, distance between pPoint and sites, assosiated
-                    with pEdge1 and pEdge2 (pPoint is situated on the equal
-                    distance from site, assosiated with pEdge1 and from
-                    site,assosiated with pEdge2)
-      Return    : distance between pPoint and marked point on pEdge1 or
-                : -1, if edges have no intersections
-    --------------------------------------------------------------------------*/
-static
-float _cvCalcEdgeIntersection(pCvVoronoiEdge pEdge1,
-                              pCvVoronoiEdge pEdge2,
-                              CvPointFloat* pPoint,
-                              float &Radius);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes intersection of two edges. Intersection
-                    must be the nearest to the marked point on pEdge1
-                    (this marked point is pEdge1->node1->node).
-    Arguments
-    pEdge1 : in, straight ray
-    pEdge2: in, straight ray or segment
-        pPoint: out, intersection of pEdge1 and pEdge2
-        Radius: out, distance between pPoint and sites, assosiated
-                    with pEdge1 and pEdge2 (pPoint is situated on the equal
-                    distance from site, assosiated with pEdge1 and from
-                    site,assosiated with pEdge2)
-     Return : distance between pPoint and marked point on pEdge1 or
-                : -1, if edges have no intersections
-    --------------------------------------------------------------------------*/
-static
-float _cvLine_LineIntersection(pCvVoronoiEdge pEdge1,
-                                pCvVoronoiEdge pEdge2,
-                                pCvPointFloat  pPoint,
-                                float &Radius);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes intersection of two edges. Intersection
-                    must be the nearest to the marked point on pEdge1
-                    (this marked point is pEdge1->node1->node).
-    Arguments
-    pEdge1 : in, straight ray
-    pEdge2: in, parabolic ray or segment
-        pPoint: out, intersection of pEdge1 and pEdge2
-        Radius: out, distance between pPoint and sites, assosiated
-                    with pEdge1 and pEdge2 (pPoint is situated on the equal
-                    distance from site, assosiated with pEdge1 and from
-                    site,assosiated with pEdge2)
-      Return    : distance between pPoint and marked point on pEdge1 or
-                : -1, if edges have no intersections
-    --------------------------------------------------------------------------*/
-static
-float _cvLine_ParIntersection(pCvVoronoiEdge pEdge1,
-                                pCvVoronoiEdge pEdge2,
-                                pCvPointFloat  pPoint,
-                                float &Radius);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes intersection of two edges. Intersection
-                    must be the nearest to the marked point on pEdge1
-                    (this marked point is pEdge1->node1->node).
-    Arguments
-    pEdge1 : in, straight ray
-    pEdge2: in, parabolic segment
-        pPoint: out, intersection of pEdge1 and pEdge2
-        Radius: out, distance between pPoint and sites, assosiated
-                    with pEdge1 and pEdge2 (pPoint is situated on the equal
-                    distance from site, assosiated with pEdge1 and from
-                    site,assosiated with pEdge2)
-      Return    : distance between pPoint and marked point on pEdge1 or
-                : -1, if edges have no intersections
-    --------------------------------------------------------------------------*/
-static
-float _cvLine_CloseParIntersection(pCvVoronoiEdge pEdge1,
-                                pCvVoronoiEdge pEdge2,
-                                pCvPointFloat  pPoint,
-                                float &Radius);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes intersection of two edges. Intersection
-                    must be the nearest to the marked point on pEdge1
-                    (this marked point is pEdge1->node1->node).
-    Arguments
-    pEdge1 : in, straight ray
-    pEdge2: in, parabolic ray
-        pPoint: out, intersection of pEdge1 and pEdge2
-        Radius: out, distance between pPoint and sites, assosiated
-                    with pEdge1 and pEdge2 (pPoint is situated on the equal
-                    distance from site, assosiated with pEdge1 and from
-                    site,assosiated with pEdge2)
-      Return    : distance between pPoint and marked point on pEdge1 or
-                : -1, if edges have no intersections
-    --------------------------------------------------------------------------*/
-static
-float _cvLine_OpenParIntersection(pCvVoronoiEdge pEdge1,
-                                pCvVoronoiEdge pEdge2,
-                                pCvPointFloat  pPoint,
-                                float &Radius);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes intersection of two edges. Intersection
-                    must be the nearest to the marked point on pEdge1
-                    (this marked point is pEdge1->node1->node).
-    Arguments
-    pEdge1 : in,  parabolic ray
-    pEdge2: in,  straight ray or segment
-        pPoint: out, intersection of pEdge1 and pEdge2
-        Radius: out, distance between pPoint and sites, assosiated
-                    with pEdge1 and pEdge2 (pPoint is situated on the equal
-                    distance from site, assosiated with pEdge1 and from
-                    site,assosiated with pEdge2)
-      Return    : distance between pPoint and marked point on pEdge1 or
-                : -1, if edges have no intersections
-    --------------------------------------------------------------------------*/
-static
-float _cvPar_LineIntersection(pCvVoronoiEdge pEdge1,
-                                pCvVoronoiEdge pEdge2,
-                                pCvPointFloat  pPoint,
-                                float &Radius);
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes intersection of two edges. Intersection
-                    must be the nearest to the marked point on pEdge1
-                    (this marked point is pEdge1->node1->node).
-    Arguments
-    pEdge1 : in,  parabolic ray
-    pEdge2: in,  straight ray
-        pPoint: out, intersection of pEdge1 and pEdge2
-        Radius: out, distance between pPoint and sites, assosiated
-                    with pEdge1 and pEdge2 (pPoint is situated on the equal
-                    distance from site, assosiated with pEdge1 and from
-                    site,assosiated with pEdge2)
-      Return    : distance between pPoint and marked point on pEdge1 or
-                : -1, if edges have no intersections
-    --------------------------------------------------------------------------*/
-static
-float _cvPar_OpenLineIntersection(pCvVoronoiEdge pEdge1,
-                                pCvVoronoiEdge pEdge2,
-                                pCvPointFloat  pPoint,
-                                float &Radius);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes intersection of two edges. Intersection
-                    must be the nearest to the marked point on pEdge1
-                    (this marked point is pEdge1->node1->node).
-    Arguments
-    pEdge1 : in,  parabolic ray
-    pEdge2: in,  straight segment
-        pPoint: out, intersection of pEdge1 and pEdge2
-        Radius: out, distance between pPoint and sites, assosiated
-                    with pEdge1 and pEdge2 (pPoint is situated on the equal
-                    distance from site, assosiated with pEdge1 and from
-                    site,assosiated with pEdge2)
-      Return    : distance between pPoint and marked point on pEdge1 or
-                : -1, if edges have no intersections
-    --------------------------------------------------------------------------*/
-static
-float _cvPar_CloseLineIntersection(pCvVoronoiEdge pEdge1,
-                                    pCvVoronoiEdge pEdge2,
-                                    pCvPointFloat  pPoint,
-                                    float &Radius);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes intersection of two edges. Intersection
-                    must be the nearest to the marked point on pEdge1
-                    (this marked point is pEdge1->node1->node).
-    Arguments
-    pEdge1 : in,  parabolic ray
-    pEdge2: in,  parabolic ray or segment
-        pPoint: out, intersection of pEdge1 and pEdge2
-        Radius: out, distance between pPoint and sites, assosiated
-                    with pEdge1 and pEdge2 (pPoint is situated on the equal
-                    distance from site, assosiated with pEdge1 and from
-                    site,assosiated with pEdge2)
-      Return    : distance between pPoint and marked point on pEdge1 or
-                : -1, if edges have no intersections
-    --------------------------------------------------------------------------*/
-static
-float _cvPar_ParIntersection(pCvVoronoiEdge pEdge1,
-                                pCvVoronoiEdge pEdge2,
-                                pCvPointFloat  pPoint,
-                                float &Radius);
-
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes intersection of two edges. Intersection
-                    must be the nearest to the marked point on pEdge1
-                    (this marked point is pEdge1->node1->node).
-    Arguments
-    pEdge1 : in,  parabolic ray
-    pEdge2: in,  parabolic ray
-        pPoint: out, intersection of pEdge1 and pEdge2
-        Radius: out, distance between pPoint and sites, assosiated
-                    with pEdge1 and pEdge2 (pPoint is situated on the equal
-                    distance from site, assosiated with pEdge1 and from
-                    site,assosiated with pEdge2)
-      Return    : distance between pPoint and marked point on pEdge1 or
-                : -1, if edges have no intersections
-    --------------------------------------------------------------------------*/
-static
-float _cvPar_OpenParIntersection(pCvVoronoiEdge pEdge1,
-                            pCvVoronoiEdge pEdge2,
-                            pCvPointFloat  pPoint,
-                            float &Radius);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes intersection of two edges. Intersection
-                    must be the nearest to the marked point on pEdge1
-                    (this marked point is pEdge1->node1->node).
-    Arguments
-    pEdge1 : in,  parabolic ray
-    pEdge2: in,  parabolic segment
-        pPoint: out, intersection of pEdge1 and pEdge2
-        Radius: out, distance between pPoint and sites, assosiated
-                    with pEdge1 and pEdge2 (pPoint is situated on the equal
-                    distance from site, assosiated with pEdge1 and from
-                    site,assosiated with pEdge2)
-      Return    : distance between pPoint and marked point on pEdge1 or
-                : -1, if edges have no intersections
-    --------------------------------------------------------------------------*/
-static
-float _cvPar_CloseParIntersection(pCvVoronoiEdge pEdge1,
-                            pCvVoronoiEdge pEdge2,
-                            pCvPointFloat  pPoint,
-                            float &Radius);
-
-/* ///////////////////////////////////////////////////////////////////////////////////////
-//                           Subsidiary functions                                       //
-/////////////////////////////////////////////////////////////////////////////////////// */
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description :
-    Arguments
-        pEdge1  : in
-        pEdge2  : out
-     Return     :
-    --------------------------------------------------------------------------*/
-CV_INLINE
-void _cvMakeTwinEdge(pCvVoronoiEdge pEdge2,
-                     pCvVoronoiEdge pEdge1);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description :
-    Arguments
-        pEdge   : in&out
-        pEdge_left_prev : in&out
-        pSite_left : in&out
-     Return     :
-    --------------------------------------------------------------------------*/
-CV_INLINE
-void _cvStickEdgeLeftBegin(pCvVoronoiEdge pEdge,
-                          pCvVoronoiEdge pEdge_left_prev,
-                          pCvVoronoiSite pSite_left);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description :
-    Arguments
-        pEdge   : in&out
-        pEdge_right_next : in&out
-        pSite_right : in&out
-     Return     :
-    --------------------------------------------------------------------------*/
-CV_INLINE
-void _cvStickEdgeRightBegin(pCvVoronoiEdge pEdge,
-                          pCvVoronoiEdge pEdge_right_next,
-                          pCvVoronoiSite pSite_right);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description :
-    Arguments
-        pEdge   : in&out
-        pEdge_left_next : in&out
-        pSite_left : in&out
-     Return     :
-    --------------------------------------------------------------------------*/
-CV_INLINE
-void _cvStickEdgeLeftEnd(pCvVoronoiEdge pEdge,
-                        pCvVoronoiEdge pEdge_left_next,
-                        pCvVoronoiSite pSite_left);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description :
-    Arguments
-        pEdge   : in&out
-        pEdge_right_prev : in&out
-        pSite_right : in&out
-     Return     :
-    --------------------------------------------------------------------------*/
-CV_INLINE
-void _cvStickEdgeRightEnd(pCvVoronoiEdge pEdge,
-                         pCvVoronoiEdge pEdge_right_prev,
-                         pCvVoronoiSite pSite_right);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description :
-    Arguments
-        pEdge_left_cur  : in
-        pEdge_left : in
-     Return     :
-    --------------------------------------------------------------------------*/
-CV_INLINE
-void _cvTwinNULLLeft(pCvVoronoiEdge pEdge_left_cur,
-                    pCvVoronoiEdge pEdge_left);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description :
-    Arguments
-        pEdge_right_cur : in
-        pEdge_right : in
-     Return     :
-    --------------------------------------------------------------------------*/
-CV_INLINE
-void _cvTwinNULLRight(pCvVoronoiEdge pEdge_right_cur,
-                     pCvVoronoiEdge pEdge_right);
-
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : function initializes the struct CvVoronoiNode
-    Arguments
-        pNode   : out
-         pPoint : in,
-        radius  : in
-     Return     :
-    --------------------------------------------------------------------------*/
-template <class T> CV_INLINE
-void _cvInitVoronoiNode(pCvVoronoiNode pNode,
-                       T pPoint, float radius = 0);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : function initializes the struct CvVoronoiSite
-    Arguments
-        pSite   : out
-         pNode1,pNode2,pPrev_site : in
-     Return     :
-    --------------------------------------------------------------------------*/
-CV_INLINE
-void _cvInitVoronoiSite(pCvVoronoiSite pSite,
-                       pCvVoronoiNode pNode1,
-                       pCvVoronoiNode pNode2,
-                       pCvVoronoiSite pPrev_site);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : function pushs the element in the end of the sequence
-                    end returns its adress
-    Arguments
-            Seq : in, pointer to the sequence
-           Elem : in, element
-     Return     : pointer to the element in the sequence
-    --------------------------------------------------------------------------*/
-template <class T> CV_INLINE
-T _cvSeqPush(CvSeq* Seq, T pElem);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : function pushs the element in the begin of the sequence
-                    end returns its adress
-    Arguments
-            Seq : in, pointer to the sequence
-           Elem : in, element
-     Return     : pointer to the element in the sequence
-    --------------------------------------------------------------------------*/
-template <class T> CV_INLINE
-T _cvSeqPushFront(CvSeq* Seq, T pElem);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : function pushs the element pHole in pHoleHierarchy->HoleSeq
-                     so as all elements in this sequence would be normalized
-                     according to field .x_coord of element. pHoleHierarchy->TopHole
-                     points to hole with smallest x_coord.
-    Arguments
-pHoleHierarchy  : in, pointer to the structur
-          pHole : in, element
-     Return     : pointer to the element in the sequence
-    --------------------------------------------------------------------------*/
-CV_INLINE
-void _cvSeqPushInOrder(CvVoronoiDiagramInt* pVoronoiDiagram, pCvVoronoiHole pHole);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : function intersects given edge pEdge (and his twin edge)
-                    by point pNode on two parts
-    Arguments
-        pEdge   : in, given edge
-          pNode : in, given point
-        EdgeSeq : in
-     Return     : one of parts
-    --------------------------------------------------------------------------*/
-CV_INLINE
-pCvVoronoiEdge _cvDivideRightEdge(pCvVoronoiEdge pEdge,
-                                 pCvVoronoiNode pNode,
-                                 CvSeq* EdgeSeq);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : function intersects given edge pEdge (and his twin edge)
-                    by point pNode on two parts
-    Arguments
-        pEdge   : in, given edge
-          pNode : in, given point
-        EdgeSeq : in
-     Return     : one of parts
-    --------------------------------------------------------------------------*/
-CV_INLINE
-pCvVoronoiEdge _cvDivideLeftEdge(pCvVoronoiEdge pEdge,
-                                pCvVoronoiNode pNode,
-                                CvSeq* EdgeSeq);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : function pushs the element in the end of the sequence
-                    end returns its adress
-    Arguments
-          writer: in, writer associated with sequence
-          pElem : in, element
-     Return     : pointer to the element in the sequence
-    --------------------------------------------------------------------------*/
-template<class T> CV_INLINE
-T _cvWriteSeqElem(T pElem, CvSeqWriter &writer);
-
-/* ///////////////////////////////////////////////////////////////////////////////////////
-//                           Mathematical functions                                     //
-/////////////////////////////////////////////////////////////////////////////////////// */
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function changes x and y
-    Arguments
-            x,y : in&out
-      Return    :
-    --------------------------------------------------------------------------*/
-template <class T> CV_INLINE
-void _cvSwap(T &x, T &y);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes the inverse map to the
-                    given ortogonal affine map
-    Arguments
-            A   : in, given ortogonal affine map
-            B   : out, inverse map
-      Return    : 1, if inverse map exist
-                  0, else
-    --------------------------------------------------------------------------*/
-template <class T> CV_INLINE
-int _cvCalcOrtogInverse(T* B, T* A);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes the composition of two affine maps
-    Arguments
-            A,B : in, given affine maps
-            Result: out, composition of A and B (Result = AB)
-      Return    :
-    --------------------------------------------------------------------------*/
-template <class T> CV_INLINE
-void _cvCalcComposition(T* Result,T* A,T* B);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes the image of point under
-                    given affin map
-    Arguments
-            A   : in, affine maps
-        pPoint  : in, pointer to point
-        pImgPoint:out, pointer to image of point
-      Return    :
-    --------------------------------------------------------------------------*/
-template<class T> CV_INLINE
-void _cvCalcPointImage(pCvPointFloat pImgPoint,pCvPointFloat pPoint,T* A);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes the image of vector under
-                    given affin map
-    Arguments
-            A   : in, affine maps
-        pVector : in, pointer to vector
-        pImgVector:out, pointer to image of vector
-      Return    :
-    --------------------------------------------------------------------------*/
-template<class T> CV_INLINE
-void _cvCalcVectorImage(pCvDirection pImgVector,pCvDirection pVector,T* A);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes the distance between the point
-                    and site. Internal function.
-    Arguments
-        pPoint  : in, point
-        pSite   : in, site
-      Return    : distance
-    --------------------------------------------------------------------------*/
-CV_INLINE
-float _cvCalcDist(pCvPointFloat pPoint, pCvVoronoiSite pSite);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes the distance between two points
-    Arguments
-    pPoint1,pPoint2 : in, two points
-      Return    : distance
-    --------------------------------------------------------------------------*/
-CV_INLINE
-float _cvPPDist(pCvPointFloat pPoint1,pCvPointFloat pPoint2);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function computes the distance betwin point and
-                    segment. Internal function.
-    Arguments
-          pPoint: in, point
-    pPoint1,pPoint2 : in, segment [pPoint1,pPoint2]
-       Return   : distance
-    --------------------------------------------------------------------------*/
-CV_INLINE
-float _cvPLDist(pCvPointFloat pPoint,pCvPointFloat pPoint1,pCvDirection pDirection);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function solves the squar equation with real coefficients
-                    T - float or double
-    Arguments
-     c2,c1,c0: in, real coefficients of polynom
-               X: out, array of roots
-     Return     : number of roots
-    --------------------------------------------------------------------------*/
-template <class T>
-int _cvSolveEqu2thR(T c2, T c1, T c0, T* X);
-
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : Function solves the linear equation with real or complex coefficients
-                    T - float or double or complex
-    Arguments
-        c1,c0: in, real or complex coefficients of polynom
-               X: out, array of roots
-     Return     : number of roots
-    --------------------------------------------------------------------------*/
-template <class T> CV_INLINE
-int _cvSolveEqu1th(T c1, T c0, T* X);
-
-/****************************************************************************************\
-*                             Storage Block Increase                                    *
-\****************************************************************************************/
-/*--------------------------------------------------------------------------
-    Author      : Andrey Sobolev
-    Description : For each sequence function creates the memory block sufficient to store
-                  all elements of sequnce
-    Arguments
-        pVoronoiDiagramInt: in, pointer to struct, which contains the
-                            description of Voronoi Diagram.
-        vertices_number: in, number of vertices in polygon
-     Return     :
-    --------------------------------------------------------------------------*/
-static void _cvSetSeqBlockSize(CvVoronoiDiagramInt* pVoronoiDiagramInt,int vertices_number)
-{
-    int N = 2*vertices_number;
-    cvSetSeqBlockSize(pVoronoiDiagramInt->SiteSeq,N*pVoronoiDiagramInt->SiteSeq->elem_size);
-    cvSetSeqBlockSize(pVoronoiDiagramInt->EdgeSeq,3*N*pVoronoiDiagramInt->EdgeSeq->elem_size);
-    cvSetSeqBlockSize(pVoronoiDiagramInt->NodeSeq,5*N*pVoronoiDiagramInt->NodeSeq->elem_size);
-    cvSetSeqBlockSize(pVoronoiDiagramInt->ParabolaSeq,N*pVoronoiDiagramInt->ParabolaSeq->elem_size);
-    cvSetSeqBlockSize(pVoronoiDiagramInt->DirectionSeq,3*N*pVoronoiDiagramInt->DirectionSeq->elem_size);
-    cvSetSeqBlockSize(pVoronoiDiagramInt->ChainSeq,N*pVoronoiDiagramInt->DirectionSeq->elem_size);
-    cvSetSeqBlockSize(pVoronoiDiagramInt->HoleSeq,100*pVoronoiDiagramInt->HoleSeq->elem_size);
-}
-
-/****************************************************************************************\
-*                                    Function realization                               *
-\****************************************************************************************/
-
-
-CV_IMPL int   cvVoronoiDiagramFromContour(CvSeq* ContourSeq,
-                                           CvVoronoiDiagram2D** VoronoiDiagram,
-                                           CvMemStorage* VoronoiStorage,
-                                           CvLeeParameters contour_type,
-                                           int contour_orientation,
-                                           int attempt_number)
-{
-    CV_FUNCNAME( "cvVoronoiDiagramFromContour" );
-
-    __BEGIN__;
-
-    CvSet* SiteSeq = NULL;
-    CvSeq* CurContourSeq = NULL;
-    CvVoronoiDiagramInt VoronoiDiagramInt;
-    CvSeqWriter NodeWriter, EdgeWriter;
-    CvMemStorage* storage;
-
-    memset( &VoronoiDiagramInt, 0, sizeof(VoronoiDiagramInt) );
-
-    if( !ContourSeq )
-        CV_ERROR( CV_StsBadArg,"Contour sequence is empty" );
-
-    if(!VoronoiStorage)
-        CV_ERROR( CV_StsBadArg,"Storage is not initialized" );
-
-    if( contour_type < 0 || contour_type > 2)
-        CV_ERROR( CV_StsBadArg,"Unsupported parameter: type" );
-
-    if( contour_orientation != 1 &&  contour_orientation != -1)
-        CV_ERROR( CV_StsBadArg,"Unsupported parameter: orientation" );
-
-    storage = cvCreateChildMemStorage(VoronoiStorage);
-    (*VoronoiDiagram) = (CvVoronoiDiagram2D*)cvCreateSet(0,sizeof(CvVoronoiDiagram2D),sizeof(CvVoronoiNode2D), storage);
-    storage = cvCreateChildMemStorage(VoronoiStorage);
-    (*VoronoiDiagram)->edges = cvCreateSet(0,sizeof(CvSet),sizeof(CvVoronoiEdge2D), storage);
-    cvStartAppendToSeq((CvSeq*)(*VoronoiDiagram)->edges, &EdgeWriter);
-    cvStartAppendToSeq((CvSeq*)(*VoronoiDiagram), &NodeWriter);
-
-        for(CurContourSeq = ContourSeq;\
-            CurContourSeq != NULL;\
-            CurContourSeq = CurContourSeq->h_next)
-        {
-            if(_cvLee(CurContourSeq, &VoronoiDiagramInt,VoronoiStorage,contour_type,contour_orientation,attempt_number))
-
-            {
-                if(!_cvConvert(*VoronoiDiagram,VoronoiDiagramInt,SiteSeq,NodeWriter,EdgeWriter,VoronoiStorage,contour_orientation))
-                    goto exit;
-            }
-            else if(CurContourSeq->total >= 3)
-                goto exit;
-        }
-
-        cvEndWriteSeq(&EdgeWriter);
-        cvEndWriteSeq(&NodeWriter);
-        if(SiteSeq != NULL)
-            return 1;
-
-
-    __END__;
-    return 0;
-}//end of cvVoronoiDiagramFromContour
-
-CV_IMPL int   cvVoronoiDiagramFromImage(IplImage* pImage,
-                                         CvSeq** ContourSeq,
-                                         CvVoronoiDiagram2D** VoronoiDiagram,
-                                         CvMemStorage* VoronoiStorage,
-                                         CvLeeParameters regularization_method,
-                                         float approx_precision)
-{
-    CV_FUNCNAME( "cvVoronoiDiagramFromContour" );
-    int RESULT = 0;
-
-    __BEGIN__;
-
-    IplImage* pWorkImage = NULL;
-    CvSize image_size;
-    int i, multiplicator = 3;
-
-    int approx_method;
-    CvMemStorage* ApproxContourStorage = NULL;
-    CvSeq* ApproxContourSeq = NULL;
-
-    if( !ContourSeq )
-        CV_ERROR( CV_StsBadArg,"Contour sequence is not initialized" );
-
-    if( (*ContourSeq)->total != 0)
-        CV_ERROR( CV_StsBadArg,"Contour sequence is not empty" );
-
-    if(!VoronoiStorage)
-        CV_ERROR( CV_StsBadArg,"Storage is not initialized" );
-
-    if(!pImage)
-        CV_ERROR( CV_StsBadArg,"Image is not initialized" );
-
-    if(pImage->nChannels != 1 || pImage->depth != 8)
-        CV_ERROR( CV_StsBadArg,"Unsupported image format" );
-
-    if(approx_precision<0 && approx_precision != CV_LEE_AUTO)
-        CV_ERROR( CV_StsBadArg,"Unsupported presision value" );
-
-    switch(regularization_method)
-    {
-        case CV_LEE_ERODE:  image_size.width = pImage->width;
-                            image_size.height = pImage->height;
-                            pWorkImage = cvCreateImage(image_size,8,1);
-                            cvErode(pImage,pWorkImage,0,1);
-                            approx_method = CV_CHAIN_APPROX_TC89_L1;
-                            break;
-        case CV_LEE_ZOOM:   image_size.width = multiplicator*pImage->width;
-                            image_size.height = multiplicator*pImage->height;
-                            pWorkImage = cvCreateImage(image_size,8,1);
-                            cvResize(pImage, pWorkImage, CV_INTER_NN);
-                            approx_method = CV_CHAIN_APPROX_TC89_L1;
-                            break;
-        case CV_LEE_NON:    pWorkImage = pImage;
-                            approx_method = CV_CHAIN_APPROX_TC89_L1;
-                            break;
-        default:            CV_ERROR( CV_StsBadArg,"Unsupported regularisation method" );
-                            break;
-
-    }
-
-    cvFindContours(pWorkImage, (*ContourSeq)->storage, ContourSeq, \
-                            sizeof(CvContour), CV_RETR_CCOMP, approx_method );
-
-    if(pWorkImage && pWorkImage != pImage )
-        cvReleaseImage(&pWorkImage);
-
-    ApproxContourStorage = cvCreateMemStorage(0);
-    if(approx_precision > 0)
-    {
-        ApproxContourSeq = cvApproxPoly(*ContourSeq, sizeof(CvContour), ApproxContourStorage,\
-                                        CV_POLY_APPROX_DP,approx_precision,1);
-
-        RESULT = cvVoronoiDiagramFromContour(ApproxContourSeq,VoronoiDiagram,VoronoiStorage,CV_LEE_INT,-1,10);
-    }
-    else if(approx_precision == CV_LEE_AUTO)
-    {
-        ApproxContourSeq = *ContourSeq;
-        for(i = 1; i < 50; i++)
-        {
-            RESULT = cvVoronoiDiagramFromContour(ApproxContourSeq,VoronoiDiagram,VoronoiStorage,CV_LEE_INT,-1,1);
-            if(RESULT)
-                break;
-            ApproxContourSeq = cvApproxPoly(ApproxContourSeq, sizeof(CvContour),ApproxContourStorage,\
-                                            CV_POLY_APPROX_DP,(float)i,1);
-        }
-    }
-    else
-        RESULT = cvVoronoiDiagramFromContour(*ContourSeq,VoronoiDiagram,VoronoiStorage,CV_LEE_INT,-1,10);
-/*
-    if(ApproxContourSeq)
-    {
-        cvClearMemStorage( (*ContourSeq)->storage );
-        *ContourSeq = cvCreateSeq(0,sizeof(CvSeq),sizeof(CvPoint),(*ContourSeq)->storage);
-        CvSeqReader reader;
-        CvSeqWriter writer;
-        CvPoint Point;
-        cvStartAppendToSeq(*ContourSeq, &writer);
-        cvStartReadSeq(ApproxContourSeq, &reader);
-        for(int i = 0;i < ApproxContourSeq->total;i++)
-        {
-            CV_READ_SEQ_ELEM(Point,reader);
-            Point.y = 600 - Point.y;
-            CV_WRITE_SEQ_ELEM(Point,writer);
-        }
-        cvEndWriteSeq(&writer);
-    }
-    */
-
-    cvReleaseMemStorage(&ApproxContourStorage);
-
-
-    __END__;
-    return RESULT;
-}//end of cvVoronoiDiagramFromImage
-
-CV_IMPL void cvReleaseVoronoiStorage(CvVoronoiDiagram2D* VoronoiDiagram,
-                                     CvMemStorage** pVoronoiStorage)
-{
-    /*CV_FUNCNAME( "cvReleaseVoronoiStorage" );*/
-    __BEGIN__;
-
-    CvSeq* Seq;
-
-    if(VoronoiDiagram->storage)
-        cvReleaseMemStorage(&VoronoiDiagram->storage);
-    for(Seq = (CvSeq*)VoronoiDiagram->sites; Seq != NULL; Seq = Seq->h_next)
-        if(Seq->storage)
-            cvReleaseMemStorage(&Seq->storage);
-    for(Seq = (CvSeq*)VoronoiDiagram->edges; Seq != NULL; Seq = Seq->h_next)
-        if(Seq->storage)
-            cvReleaseMemStorage(&Seq->storage);
-
-    if(*pVoronoiStorage)
-        cvReleaseMemStorage(pVoronoiStorage);
-
-    __END__;
-}//end of cvReleaseVoronoiStorage
-
-static int  _cvLee(CvSeq* ContourSeq,
-                    CvVoronoiDiagramInt* pVoronoiDiagramInt,
-                    CvMemStorage* VoronoiStorage,
-                    CvLeeParameters contour_type,
-                    int contour_orientation,
-                    int attempt_number)
-{
-    //orientation = 1 for left coordinat system
-    //orientation = -1 for right coordinat system
-    if(ContourSeq->total<3)
-        return 0;
-
-    int attempt = 0;
-    CvVoronoiStorageInt VoronoiStorageInt;
-
-    srand((int)cvGetTickCount());
-
-NEXTATTEMPT:
-    VoronoiStorageInt.SiteStorage = cvCreateChildMemStorage(VoronoiStorage);
-    VoronoiStorageInt.NodeStorage = cvCreateChildMemStorage(VoronoiStorage);
-    VoronoiStorageInt.EdgeStorage = cvCreateChildMemStorage(VoronoiStorage);
-    VoronoiStorageInt.ParabolaStorage = cvCreateMemStorage(0);
-    VoronoiStorageInt.ChainStorage = cvCreateMemStorage(0);
-    VoronoiStorageInt.DirectionStorage = cvCreateMemStorage(0);
-    VoronoiStorageInt.HoleStorage = cvCreateMemStorage(0);
-
-    pVoronoiDiagramInt->SiteSeq = cvCreateSeq(0,sizeof(CvSeq),sizeof(CvVoronoiSiteInt),VoronoiStorageInt.SiteStorage);
-    pVoronoiDiagramInt->NodeSeq = cvCreateSeq(0,sizeof(CvSeq),sizeof(CvVoronoiNodeInt),VoronoiStorageInt.NodeStorage);
-    pVoronoiDiagramInt->EdgeSeq = cvCreateSeq(0,sizeof(CvSeq),sizeof(CvVoronoiEdgeInt),VoronoiStorageInt.EdgeStorage);
-    pVoronoiDiagramInt->ChainSeq  = cvCreateSeq(0,sizeof(CvSeq),sizeof(CvVoronoiChainInt),VoronoiStorageInt.ChainStorage);
-    pVoronoiDiagramInt->DirectionSeq = cvCreateSeq(0,sizeof(CvSeq),sizeof(CvDirection),VoronoiStorageInt.DirectionStorage);
-    pVoronoiDiagramInt->ParabolaSeq =  cvCreateSeq(0,sizeof(CvSeq),sizeof(CvVoronoiParabolaInt),VoronoiStorageInt.ParabolaStorage);
-    pVoronoiDiagramInt->HoleSeq =  cvCreateSeq(0,sizeof(CvSeq),sizeof(CvVoronoiHoleInt),VoronoiStorageInt.HoleStorage);
-
-    _cvSetSeqBlockSize(pVoronoiDiagramInt,ContourSeq->total);
-
-    if(!_cvConstuctSites(ContourSeq, pVoronoiDiagramInt, contour_type,contour_orientation))
-    {
-        attempt = attempt_number;
-        goto FAULT;
-    }
-    _cvRandomModification(pVoronoiDiagramInt, 0,pVoronoiDiagramInt->NodeSeq->total,0.2f);
-
-    if(!_cvConstructChains(pVoronoiDiagramInt))
-    {
-        attempt = attempt_number;
-        goto FAULT;
-    }
-
-    if(!_cvConstructSkeleton(pVoronoiDiagramInt))
-        goto FAULT;
-
-    _cvConstructSiteTree(pVoronoiDiagramInt);
-
-//SUCCESS:
-    _cvReleaseVoronoiStorage(&VoronoiStorageInt,0,1);
-    return 1;
-
-FAULT:
-    _cvReleaseVoronoiStorage(&VoronoiStorageInt,1,1);
-    if(++attempt < attempt_number)
-        goto NEXTATTEMPT;
-
-    return 0;
-}// end of _cvLee
-
-static int _cvConstuctSites(CvSeq* ContourSeq,
-                            CvVoronoiDiagramInt* pVoronoiDiagram,
-                            CvLeeParameters contour_type,
-                            int contour_orientation)
-{
-    pVoronoiDiagram->reflex_site = NULL;
-    pVoronoiDiagram->top_hole = NULL;
-    int result = 0;
-
-    switch(contour_type)
-    {
-        case CV_LEE_INT :    result = _cvConstructExtSites(pVoronoiDiagram,ContourSeq,contour_orientation,(int)1);
-                             break;
-        case CV_LEE_FLOAT :  result = _cvConstructExtSites(pVoronoiDiagram,ContourSeq,contour_orientation,(float)1);
-                             break;
-        case CV_LEE_DOUBLE : result = _cvConstructExtSites(pVoronoiDiagram,ContourSeq,contour_orientation,(double)1);
-                             break;
-        default:             return 0;
-    }
-
-    if(!result)
-        return 0;
-
-    CvSeq* CurSiteSeq;
-    CvVoronoiHoleInt Hole = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,false,0};
-    pCvVoronoiSite pTopSite = 0;
-    for(CvSeq* CurContourSeq = ContourSeq->v_next;\
-        CurContourSeq != NULL;\
-        CurContourSeq = CurContourSeq->h_next)
-    {
-        if(CurContourSeq->total == 0)
-            continue;
-
-        CurSiteSeq = cvCreateSeq(0,sizeof(CvSeq),sizeof(CvVoronoiSiteInt),pVoronoiDiagram->SiteSeq->storage);
-        switch(contour_type)
-        {
-            case CV_LEE_INT :   result = _cvConstructIntSites(pVoronoiDiagram,CurSiteSeq,CurContourSeq,pTopSite,contour_orientation,(int)1);
-                                break;
-            case CV_LEE_FLOAT : result = _cvConstructIntSites(pVoronoiDiagram,CurSiteSeq,CurContourSeq,pTopSite,contour_orientation,(float)1);
-                                break;
-            case CV_LEE_DOUBLE :result = _cvConstructIntSites(pVoronoiDiagram,CurSiteSeq,CurContourSeq,pTopSite,contour_orientation,(double)1);
-                                break;
-            default:            result = 0;
-        }
-        if(!result)
-            continue;
-
-        Hole.SiteSeq = CurSiteSeq;
-        Hole.site_top = pTopSite;
-        Hole.x_coord = pTopSite->node1->node.x;
-        Hole.error = false;
-        _cvSeqPushInOrder(pVoronoiDiagram, &Hole);
-    }
-    return 1;
-}//end of _cvConstuctSites
-
-static int _cvConstructChains(CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    if(!_cvConstructExtChains(pVoronoiDiagram))
-        return 0;
-
-    CvSeq* CurrChainSeq;
-    for(pCvVoronoiHole pHole = pVoronoiDiagram->top_hole;\
-        pHole != NULL; \
-        pHole = pHole->next_hole)
-        {
-            pHole->error = false;
-            CurrChainSeq = cvCreateSeq(0,sizeof(CvSeq),sizeof(CvVoronoiChainInt),pVoronoiDiagram->ChainSeq->storage);
-            _cvConstructIntChains(pVoronoiDiagram,CurrChainSeq,pHole->SiteSeq,pHole->site_top);
-            pHole->ChainSeq = CurrChainSeq;
-        }
-    return 1;
-}//end of _cvConstructChains
-
-static int _cvConstructSkeleton(CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    if(!_cvConstructExtVD(pVoronoiDiagram))
-        return 0;
-    _cvConstructIntVD(pVoronoiDiagram);
-    _cvFindNearestSite(pVoronoiDiagram);
-
-    float dx,dy;
-    int result;
-    for(pCvVoronoiHole pHole = pVoronoiDiagram->top_hole;\
-        pHole != NULL; pHole = pHole->next_hole)
-    {
-        if(pHole->error)
-            continue;
-        dx = pHole->node->node.x - pHole->site_top->node1->node.x;
-        dy = pHole->node->node.y - pHole->site_top->node1->node.y;
-
-        if(fabs(dy) < 0.01 && dx < 0)
-            pHole->site_opposite = pHole->site_nearest;
-        else
-        {
-            if(dy > 0)
-                result = _cvFindOppositSiteCCW(pHole,pVoronoiDiagram);
-            else
-                result = _cvFindOppositSiteCW(pHole,pVoronoiDiagram);
-
-            if(!result)
-            {
-                pHole->error = true;
-                continue;
-            }
-        }
-
-        if(!_cvMergeVD(pHole,pVoronoiDiagram))
-            return 0;
-    }
-    return 1;
-}//end of _cvConstructSkeleton
-
-static void _cvConstructSiteTree(CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    CvSeq* CurSeq = pVoronoiDiagram->SiteSeq;
-    for(pCvVoronoiHole pHole = pVoronoiDiagram->top_hole;\
-        pHole != NULL; pHole = pHole->next_hole)
-    {
-        if(pHole->error)
-            continue;
-        if(CurSeq == pVoronoiDiagram->SiteSeq)
-        {
-            CurSeq->v_next = pHole->SiteSeq;
-            pHole->SiteSeq->v_prev = CurSeq;
-        }
-        else
-        {
-            CurSeq->h_next = pHole->SiteSeq;
-            pHole->SiteSeq->h_prev = CurSeq;
-            pHole->SiteSeq->v_prev = pVoronoiDiagram->SiteSeq;
-        }
-        CurSeq = pHole->SiteSeq;
-    }
-    CurSeq->h_next = NULL;
-}//end of _cvConstructSiteTree
-
-static void _cvRandomModification(CvVoronoiDiagramInt* pVoronoiDiagram, int begin, int end, float shift)
-{
-    CvSeqReader Reader;
-    pCvVoronoiNode pNode;
-    const float rnd_const = shift/RAND_MAX;
-    int i;
-
-    cvStartReadSeq(pVoronoiDiagram->NodeSeq, &Reader,0);
-    for( i = begin; i < end; i++)
-    {
-        pNode = (pCvVoronoiNode)Reader.ptr;
-        pNode->node.x = (float)cvFloor(pNode->node.x) + rand()*rnd_const;
-        pNode->node.y = (float)cvFloor(pNode->node.y) + rand()*rnd_const;
-        CV_NEXT_SEQ_ELEM( sizeof(CvVoronoiNodeInt), Reader );
-    }
-
-    for(pCvVoronoiHole pHole = pVoronoiDiagram->top_hole;\
-        pHole != NULL;\
-        pHole = pHole->next_hole)
-    {
-        pHole->site_top->node1->node.x = (float)cvFloor(pHole->site_top->node1->node.x);
-    }
-
-}//end of _cvRandomModification
-
-static void _cvReleaseVoronoiStorage(CvVoronoiStorageInt* pVoronoiStorage, int group1, int group2)
-{
-    //if group1 = 1 then SiteSeq, NodeSeq, EdgeSeq released
-    //if group2 = 1 then DirectionSeq, ParabolaSeq, ChainSeq, HoleSeq released
-    if(group1 == 1)
-    {
-        if(pVoronoiStorage->SiteStorage!=NULL)
-            cvReleaseMemStorage(&pVoronoiStorage->SiteStorage);
-        if(pVoronoiStorage->EdgeStorage!=NULL)
-            cvReleaseMemStorage(&pVoronoiStorage->EdgeStorage);
-        if(pVoronoiStorage->NodeStorage!=NULL)
-            cvReleaseMemStorage(&pVoronoiStorage->NodeStorage);
-    }
-    if(group2 == 1)
-    {
-        if(pVoronoiStorage->ParabolaStorage!=NULL)
-            cvReleaseMemStorage(&pVoronoiStorage->ParabolaStorage);
-        if(pVoronoiStorage->ChainStorage!=NULL)
-            cvReleaseMemStorage(&pVoronoiStorage->ChainStorage);
-        if(pVoronoiStorage->DirectionStorage!=NULL)
-            cvReleaseMemStorage(&pVoronoiStorage->DirectionStorage);
-        if(pVoronoiStorage->HoleStorage != NULL)
-            cvReleaseMemStorage(&pVoronoiStorage->HoleStorage);
-    }
-}// end of _cvReleaseVoronoiStorage
-
-static int _cvConvert(CvVoronoiDiagram2D* VoronoiDiagram,
-                       CvVoronoiDiagramInt VoronoiDiagramInt,
-                       CvSet* &SiteSeq,
-                       CvSeqWriter &NodeWriter,
-                       CvSeqWriter &EdgeWriter,
-                       CvMemStorage* VoronoiStorage,
-                       int contour_orientation)
-{
-    if(contour_orientation == 1)
-        return _cvConvertSameOrientation(VoronoiDiagram,VoronoiDiagramInt,SiteSeq,NodeWriter,
-                                        EdgeWriter,VoronoiStorage);
-    else
-        return _cvConvertChangeOrientation(VoronoiDiagram,VoronoiDiagramInt,SiteSeq,NodeWriter,
-                                        EdgeWriter,VoronoiStorage);
-}// end of _cvConvert
-
-static int _cvConvertSameOrientation(CvVoronoiDiagram2D* VoronoiDiagram,
-                                      CvVoronoiDiagramInt VoronoiDiagramInt,
-                                      CvSet* &NewSiteSeqPrev,
-                                      CvSeqWriter &NodeWriter,
-                                      CvSeqWriter &EdgeWriter,
-                                      CvMemStorage* VoronoiStorage)
-{
-    CvSeq* SiteSeq = VoronoiDiagramInt.SiteSeq;
-    CvSeq* EdgeSeq = VoronoiDiagramInt.EdgeSeq;
-    CvSeq* NodeSeq = VoronoiDiagramInt.NodeSeq;
-
-
-    CvMemStorage *NewSiteStorage = cvCreateChildMemStorage(VoronoiStorage);
-    CvSet *NewSiteSeq = NULL,*CurrNewSiteSeq = NULL, *PrevNewSiteSeq = NULL;;
-    CvSeqWriter SiteWriter;
-
-    CvVoronoiSite2D NewSite = {{0,0},{0,0},{0,0}},NewSite_prev = {{0,0},{0,0},{0,0}};
-    CvVoronoiSite2D *pNewSite, *pNewSite_prev = &NewSite_prev;
-    pCvVoronoiSite pSite,pFirstSite;
-
-    CvVoronoiEdge2D NewEdge = {{0,0},{0,0},{0,0,0,0}};
-    CvVoronoiEdge2D *pNewEdge1, *pNewEdge2;
-    pCvVoronoiEdge pEdge;
-
-    CvVoronoiNode2D* pNode1, *pNode2;
-    CvVoronoiNode2D Node;
-    Node.next_free = NULL;
-
-    for(CvSeq* CurrSiteSeq = SiteSeq;\
-        CurrSiteSeq != NULL;\
-        CurrSiteSeq = NEXT_SEQ(CurrSiteSeq,SiteSeq))
-    {
-        CurrNewSiteSeq = cvCreateSet(0,sizeof(CvSet),sizeof(CvVoronoiSite2D), NewSiteStorage);
-        if(!NewSiteSeq)
-            NewSiteSeq = PrevNewSiteSeq = CurrNewSiteSeq;
-        else if(PrevNewSiteSeq->v_prev == NULL)
-        {
-            PrevNewSiteSeq->v_next = (CvSeq*)CurrNewSiteSeq;
-            CurrNewSiteSeq->v_prev = (CvSeq*)PrevNewSiteSeq;
-        }
-        else
-        {
-            PrevNewSiteSeq->h_next = (CvSeq*)CurrNewSiteSeq;
-            CurrNewSiteSeq->h_prev = (CvSeq*)PrevNewSiteSeq;
-            CurrNewSiteSeq->v_prev = (CvSeq*)PrevNewSiteSeq->v_prev;
-        }
-        PrevNewSiteSeq = CurrNewSiteSeq;
-
-        pSite = pFirstSite = (pCvVoronoiSite)cvGetSeqElem(CurrSiteSeq, 0);
-        while(pSite->prev_site->node1 == pSite->prev_site->node2)\
-            pSite = pSite->next_site;
-        pFirstSite = pSite;
-
-        pNewSite_prev = &NewSite_prev;
-        cvStartAppendToSeq((CvSeq*)CurrNewSiteSeq, &SiteWriter);
-        do
-        {
-            pNewSite = _cvWriteSeqElem(&NewSite,SiteWriter);
-            pNewSite->next[0] = pNewSite_prev;
-            pNewSite_prev->next[1] = pNewSite;
-            pEdge = pSite->edge1;
-            if(!pEdge || !pEdge->node1 || !pEdge->node2)
-                return 0;
-
-            if(pEdge->site == NULL)
-            {
-                pNewEdge1 = (CvVoronoiEdge2D*)pEdge->twin_edge;
-                pNewEdge1->site[1] = pNewSite;
-                pNewSite->node[0] = pNewEdge1->node[0];
-            }
-            else
-            {
-                pNewEdge1 = _cvWriteSeqElem(&NewEdge,EdgeWriter);
-                pNewEdge1->site[0] = pNewSite;
-
-                pNode1 = _cvWriteSeqElem(&Node,NodeWriter);
-                pNode2 = _cvWriteSeqElem(&Node,NodeWriter);
-                pNode1->pt.x = pEdge->node1->node.x;
-                pNode1->pt.y = pEdge->node1->node.y;
-                pNode1->radius = pEdge->node1->radius;
-                pNode2->pt.x = pEdge->node2->node.x;
-                pNode2->pt.y = pEdge->node2->node.y;
-                pNode2->radius = pEdge->node2->radius;
-                pNewEdge1->node[0] = pNode1;
-                pNewEdge1->node[1] = pNode2;
-
-                pNewSite->node[0] = pNewEdge1->node[1];
-
-                if(!pNewEdge1->node[0] || !pNewEdge1->node[1])
-                    return 0;
-                pEdge->twin_edge->site = NULL;
-                pEdge->twin_edge->twin_edge = (pCvVoronoiEdge)pNewEdge1;
-            }
-            pNewSite->edge[1] = pNewEdge1;
-            pEdge = pEdge->prev_edge;
-            while((pEdge != NULL && CurrSiteSeq->total>1) ||
-                  (pEdge != pSite->edge2 && CurrSiteSeq->total == 1))
-            {
-                if(pEdge->site == NULL)
-                {
-                    pNewEdge2 = (CvVoronoiEdge2D*)pEdge->twin_edge;
-                    pNewEdge2->site[1] = pNewSite;
-                    if(CV_VORONOIEDGE2D_BEGINNODE(pNewEdge1,pNewSite) != pNewEdge2->node[0])
-                    {
-                        cvFlushSeqWriter(&NodeWriter);
-//                      cvSetRemove((CvSet*)VoronoiDiagram,VoronoiDiagram->total-1);
-                        pNewEdge1->node[0] = pNewEdge2->node[0];
-                    }
-                }
-                else
-                {
-                    pNewEdge2 = _cvWriteSeqElem(&NewEdge,EdgeWriter);
-                    pNewEdge2->site[0] = pNewSite;
-
-                    pNode1 = _cvWriteSeqElem(&Node,NodeWriter);
-                    pNode1->pt.x = pEdge->node1->node.x;
-                    pNode1->pt.y = pEdge->node1->node.y;
-                    pNode1->radius = pEdge->node1->radius;
-                    pNewEdge2->node[0] = pNode1;
-
-                    if(pNewEdge1->site[0] == pNewSite)
-                        pNewEdge2->node[1] = pNewEdge1->node[0];
-                    else
-                        pNewEdge2->node[1] = pNewEdge1->node[1];
-
-                    if(!pNewEdge1->node[0] || !pNewEdge1->node[1])
-                        return 0;
-                    pEdge->twin_edge->site = NULL;
-                    pEdge->twin_edge->twin_edge = (pCvVoronoiEdge)pNewEdge2;
-                }
-                if(pNewEdge1->site[0] == pNewSite)
-                    pNewEdge1->next[2] = pNewEdge2;
-                else
-                    pNewEdge1->next[3] = pNewEdge2;
-
-                if(pNewEdge2->site[0] == pNewSite)
-                    pNewEdge2->next[0] = pNewEdge1;
-                else
-                    pNewEdge2->next[1] = pNewEdge1;
-
-                pEdge = pEdge->prev_edge;
-                pNewEdge1 = pNewEdge2;
-            }
-            pNewSite->edge[0] = pNewEdge1;
-            pNewSite->node[1] = pNewEdge1->node[0];
-
-            if(pSite->node1 == pSite->node2 && pSite != pSite->next_site && pNewEdge1->node[0] != pNewEdge1->node[1])
-            {
-                cvFlushSeqWriter(&NodeWriter);
-//              cvSetRemove((CvSet*)VoronoiDiagram,VoronoiDiagram->total-1);
-                pNewSite->node[1] = pNewEdge1->node[0] = pNewSite->node[0];
-            }
-
-            pNewSite_prev = pNewSite;
-            pSite = pSite->next_site;
-        }while(pSite != pFirstSite);
-        pNewSite->node[1] = pNewEdge1->node[1];
-        if(pSite == pSite->next_site)
-        {
-            Node.pt.x = pSite->node1->node.x;
-            Node.pt.y = pSite->node1->node.y;
-            Node.radius = 0;
-            pNewSite->node[0] = pNewSite->node[1] = _cvWriteSeqElem(&Node,NodeWriter);
-        }
-
-        cvEndWriteSeq(&SiteWriter);
-        pNewSite = (CvVoronoiSite2D*)cvGetSetElem(CurrNewSiteSeq, 0);
-        pNewSite->next[0] = pNewSite_prev;
-        pNewSite_prev->next[1] = pNewSite;
-    }
-
-    cvReleaseMemStorage(&(SiteSeq->storage));
-    cvReleaseMemStorage(&(EdgeSeq->storage));
-    cvReleaseMemStorage(&(NodeSeq->storage));
-
-    if(NewSiteSeqPrev == NULL)
-        VoronoiDiagram->sites = NewSiteSeq;
-    else
-    {
-        NewSiteSeqPrev->h_next = (CvSeq*)NewSiteSeq;
-        NewSiteSeq->h_prev = (CvSeq*)NewSiteSeqPrev;
-    }
-
-    NewSiteSeqPrev = NewSiteSeq;
-    return 1;
-}//end of _cvConvertSameOrientation
-
-static int _cvConvertChangeOrientation(CvVoronoiDiagram2D* VoronoiDiagram,
-                                        CvVoronoiDiagramInt VoronoiDiagramInt,
-                                        CvSet* &NewSiteSeqPrev,
-                                        CvSeqWriter &NodeWriter,
-                                        CvSeqWriter &EdgeWriter,
-                                        CvMemStorage* VoronoiStorage)
-{
-    // pNewSite->edge[1] = pSite->edge2
-    // pNewSite->edge[0] = pSite->edge1
-
-    CvSeq* SiteSeq = VoronoiDiagramInt.SiteSeq;
-    CvSeq* EdgeSeq = VoronoiDiagramInt.EdgeSeq;
-    CvSeq* NodeSeq = VoronoiDiagramInt.NodeSeq;
-
-
-    CvMemStorage *NewSiteStorage = cvCreateChildMemStorage(VoronoiStorage);
-    CvSet *NewSiteSeq = NULL,*CurrNewSiteSeq = NULL, *PrevNewSiteSeq = NULL;;
-    CvSeqWriter SiteWriter;
-
-    CvVoronoiSite2D NewSite = {{0,0},{0,0},{0,0}},NewSite_prev = {{0,0},{0,0},{0,0}};
-    CvVoronoiSite2D *pNewSite, *pNewSite_prev = &NewSite_prev;
-    pCvVoronoiSite pSite,pFirstSite;
-
-    CvVoronoiEdge2D NewEdge = {{0,0},{0,0},{0,0,0,0}};
-    CvVoronoiEdge2D *pNewEdge1, *pNewEdge2;
-    pCvVoronoiEdge pEdge;
-
-    CvVoronoiNode2D* pNode1, *pNode2;
-    CvVoronoiNode2D Node;
-    Node.next_free = NULL;
-
-    for(CvSeq* CurrSiteSeq = SiteSeq;\
-        CurrSiteSeq != NULL;\
-        CurrSiteSeq = NEXT_SEQ(CurrSiteSeq,SiteSeq))
-    {
-        CurrNewSiteSeq = cvCreateSet(0,sizeof(CvSet),sizeof(CvVoronoiSite2D), NewSiteStorage);
-        if(!NewSiteSeq)
-            NewSiteSeq = PrevNewSiteSeq = CurrNewSiteSeq;
-        else if(PrevNewSiteSeq->v_prev == NULL)
-        {
-            PrevNewSiteSeq->v_next = (CvSeq*)CurrNewSiteSeq;
-            CurrNewSiteSeq->v_prev = (CvSeq*)PrevNewSiteSeq;
-        }
-        else
-        {
-            PrevNewSiteSeq->h_next = (CvSeq*)CurrNewSiteSeq;
-            CurrNewSiteSeq->h_prev = (CvSeq*)PrevNewSiteSeq;
-            CurrNewSiteSeq->v_prev = (CvSeq*)PrevNewSiteSeq->v_prev;
-        }
-        PrevNewSiteSeq = CurrNewSiteSeq;
-
-        pSite = (pCvVoronoiSite)cvGetSeqElem(CurrSiteSeq, 0);
-        while(pSite->next_site->node1 == pSite->next_site->node2)\
-            pSite = pSite->next_site;
-        pFirstSite = pSite;
-
-        pNewSite_prev = &NewSite_prev;
-        cvStartAppendToSeq((CvSeq*)CurrNewSiteSeq, &SiteWriter);
-        do
-        {
-            pNewSite = _cvWriteSeqElem(&NewSite,SiteWriter);
-            pNewSite->next[0] = pNewSite_prev;
-            pNewSite_prev->next[1] = pNewSite;
-
-            pEdge = pSite->edge2;
-            if(!pEdge || !pEdge->node1 || !pEdge->node2)
-                return 0;
-
-            if(pEdge->site == NULL)
-            {
-                pNewEdge1 = (CvVoronoiEdge2D*)pEdge->twin_edge;
-                pNewEdge1->site[1] = pNewSite;
-                pNewSite->node[0] = pNewEdge1->node[0];
-            }
-            else
-            {
-                pNewEdge1 = _cvWriteSeqElem(&NewEdge,EdgeWriter);
-                pNewEdge1->site[0] = pNewSite;
-
-                pNode1 = _cvWriteSeqElem(&Node,NodeWriter);
-                pNode2 = _cvWriteSeqElem(&Node,NodeWriter);
-                pNode1->pt.x = pEdge->node1->node.x;
-                pNode1->pt.y = pEdge->node1->node.y;
-                pNode1->radius = pEdge->node1->radius;
-                pNode2->pt.x = pEdge->node2->node.x;
-                pNode2->pt.y = pEdge->node2->node.y;
-                pNode2->radius = pEdge->node2->radius;
-                pNewEdge1->node[0] = pNode2;
-                pNewEdge1->node[1] = pNode1;
-
-                pNewSite->node[0] = pNewEdge1->node[1];
-
-                if(!pNewEdge1->node[0] || !pNewEdge1->node[1])
-                    return 0;
-                pEdge->twin_edge->site = NULL;
-                pEdge->twin_edge->twin_edge = (pCvVoronoiEdge)pNewEdge1;
-            }
-            pNewSite->edge[1] = pNewEdge1;
-
-
-            pEdge = pEdge->next_edge;
-            while((pEdge != NULL && CurrSiteSeq->total>1) ||
-                  (pEdge != pSite->edge1 && CurrSiteSeq->total == 1))
-            {
-                if(pEdge->site == NULL)
-                {
-                    pNewEdge2 = (CvVoronoiEdge2D*)pEdge->twin_edge;
-                    pNewEdge2->site[1] = pNewSite;
-                    if(CV_VORONOIEDGE2D_BEGINNODE(pNewEdge1,pNewSite) != pNewEdge2->node[0])
-                    {
-                        cvFlushSeqWriter(&NodeWriter);
-//                      cvSetRemove((CvSet*)VoronoiDiagram,VoronoiDiagram->total-1);
-                        pNewEdge1->node[0] = pNewEdge2->node[0];
-                    }
-                }
-                else
-                {
-                    pNewEdge2 = _cvWriteSeqElem(&NewEdge,EdgeWriter);
-                    pNewEdge2->site[0] = pNewSite;
-
-                    pNode2 = _cvWriteSeqElem(&Node,NodeWriter);
-                    pNode2->pt.x = pEdge->node2->node.x;
-                    pNode2->pt.y = pEdge->node2->node.y;
-                    pNode2->radius = pEdge->node2->radius;
-                    pNewEdge2->node[0] = pNode2;
-
-                    if(pNewEdge1->site[0] == pNewSite)
-                        pNewEdge2->node[1] = pNewEdge1->node[0];
-                    else
-                        pNewEdge2->node[1] = pNewEdge1->node[1];
-
-                    if(!pNewEdge1->node[0] || !pNewEdge1->node[1])
-                        return 0;
-                    pEdge->twin_edge->site = NULL;
-                    pEdge->twin_edge->twin_edge = (pCvVoronoiEdge)pNewEdge2;
-                }
-                if(pNewEdge1->site[0] == pNewSite)
-                    pNewEdge1->next[2] = pNewEdge2;
-                else
-                    pNewEdge1->next[3] = pNewEdge2;
-
-                if(pNewEdge2->site[0] == pNewSite)
-                    pNewEdge2->next[0] = pNewEdge1;
-                else
-                    pNewEdge2->next[1] = pNewEdge1;
-
-                pEdge = pEdge->next_edge;
-                pNewEdge1 = pNewEdge2;
-            }
-            pNewSite->edge[0] = pNewEdge1;
-            pNewSite->node[1] = pNewEdge1->node[0];
-
-            if(pSite->node1 == pSite->node2 && pSite != pSite->next_site && pNewEdge1->node[0] != pNewEdge1->node[1])
-            {
-                cvFlushSeqWriter(&NodeWriter);
-//              cvSetRemove((CvSet*)VoronoiDiagram,VoronoiDiagram->total-1);
-                pNewSite->node[1] = pNewEdge1->node[0] = pNewSite->node[0];
-            }
-
-            pNewSite_prev = pNewSite;
-            pSite = pSite->prev_site;
-        }while(pSite != pFirstSite);
-        pNewSite->node[1] = pNewEdge1->node[1];
-        if(pSite == pSite->next_site)
-        {
-            Node.pt.x = pSite->node1->node.x;
-            Node.pt.y = pSite->node1->node.y;
-            Node.radius = 0;
-            pNewSite->node[0] = pNewSite->node[1] = _cvWriteSeqElem(&Node,NodeWriter);
-        }
-
-        cvEndWriteSeq(&SiteWriter);
-        pNewSite = (CvVoronoiSite2D*)cvGetSetElem(CurrNewSiteSeq, 0);
-        pNewSite->next[0] = pNewSite_prev;
-        pNewSite_prev->next[1] = pNewSite;
-    }
-
-    cvReleaseMemStorage(&(SiteSeq->storage));
-    cvReleaseMemStorage(&(EdgeSeq->storage));
-    cvReleaseMemStorage(&(NodeSeq->storage));
-
-    if(NewSiteSeqPrev == NULL)
-        VoronoiDiagram->sites = NewSiteSeq;
-    else
-    {
-        NewSiteSeqPrev->h_next = (CvSeq*)NewSiteSeq;
-        NewSiteSeq->h_prev = (CvSeq*)NewSiteSeqPrev;
-    }
-    NewSiteSeqPrev = NewSiteSeq;
-    return 1;
-}//end of _cvConvert
-
-template<class T>
-int _cvConstructExtSites(CvVoronoiDiagramInt* pVoronoiDiagram,
-                         CvSeq* ContourSeq,
-                         int orientation,
-                         T /*type*/)
-{
-    const double angl_eps = 0.03;
-    CvSeq* SiteSeq = pVoronoiDiagram->SiteSeq;
-    CvSeq* NodeSeq = pVoronoiDiagram->NodeSeq;
-    //CvSeq* DirectionSeq = pVoronoiDiagram->DirectionSeq;
-    CvPointFloat Vertex1,Vertex2,Vertex3;
-    CvLeePoint<T> VertexT1,VertexT2,VertexT3;
-
-    CvSeqReader ContourReader;
-    CvVoronoiSiteInt Site = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};
-    CvVoronoiSiteInt SiteTemp = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};
-    CvVoronoiNodeInt Node;
-    pCvVoronoiNode pNode1,pNode2;
-    pCvVoronoiSite pSite = &SiteTemp,pSite_prev = &SiteTemp;
-    pCvVoronoiSite pReflexSite = NULL;
-    int NReflexSite = 0;
-
-    float delta_x_rc, delta_x_cl, delta_y_rc, delta_y_cl;
-    float norm_cl,norm_rc, mult_cl_rc;
-    float _sin, _cos;
-    int i;
-
-    if(orientation == 1)
-    {
-        cvStartReadSeq(ContourSeq, &ContourReader,0);
-        CV_READ_SEQ_ELEM(VertexT1,ContourReader);
-        CV_READ_SEQ_ELEM(VertexT2,ContourReader);
-    }
-    else
-    {
-        cvStartReadSeq(ContourSeq, &ContourReader,1);
-        CV_REV_READ_SEQ_ELEM(VertexT1,ContourReader);
-        CV_REV_READ_SEQ_ELEM(VertexT2,ContourReader);
-    }
-
-    Vertex1.x = (float)VertexT1.x;
-    Vertex1.y = (float)VertexT1.y;
-    Vertex2.x = (float)VertexT2.x;
-    Vertex2.y = (float)VertexT2.y;
-
-    _cvInitVoronoiNode(&Node, &Vertex2);
-    pNode1 = _cvSeqPush(NodeSeq, &Node);
-
-    delta_x_cl = Vertex2.x - Vertex1.x;
-    delta_y_cl = Vertex2.y - Vertex1.y;
-    norm_cl = (float)sqrt((double)delta_x_cl*delta_x_cl + delta_y_cl*delta_y_cl);
-
-    for( i = 0;i<ContourSeq->total;i++)
-    {
-        if(orientation == 1)
-        {
-            CV_READ_SEQ_ELEM(VertexT3,ContourReader);
-        }
-        else
-        {
-            CV_REV_READ_SEQ_ELEM(VertexT3,ContourReader);
-        }
-
-        Vertex3.x = (float)VertexT3.x;
-        Vertex3.y = (float)VertexT3.y;
-
-        _cvInitVoronoiNode(&Node, &Vertex3);
-        pNode2 = _cvSeqPush(NodeSeq, &Node);
-
-        delta_x_rc = Vertex3.x - Vertex2.x;
-        delta_y_rc = Vertex3.y - Vertex2.y;
-        norm_rc = (float)sqrt((double)delta_x_rc*delta_x_rc + delta_y_rc*delta_y_rc);
-        if(norm_rc==0)
-            continue;
-
-        mult_cl_rc = norm_cl*norm_rc;
-        _sin = (delta_y_rc* delta_x_cl - delta_x_rc* delta_y_cl)/mult_cl_rc;
-        _cos = -(delta_x_cl*delta_x_rc + delta_y_cl*delta_y_rc)/mult_cl_rc;
-
-        if((_sin > angl_eps) || (_sin > 0 && _cos > 0))
-        {
-            pSite = _cvSeqPush(SiteSeq, &Site);
-            _cvInitVoronoiSite(pSite,pNode1,pNode2,pSite_prev);
-            pSite_prev->next_site = pSite;
-        }
-        else if((_sin < -angl_eps) || (_sin < 0 && _cos > 0))
-        {
-            pSite = _cvSeqPush(SiteSeq, &Site);
-            _cvInitVoronoiSite(pSite,pNode1,pNode1,pSite_prev);
-            pReflexSite = pSite;
-            NReflexSite++;
-            pSite_prev->next_site = pSite;
-
-            pSite_prev = pSite;
-            pSite = _cvSeqPush(SiteSeq, &Site);
-            _cvInitVoronoiSite(pSite,pNode1,pNode2,pSite_prev);
-            pSite_prev->next_site = pSite;
-        }
-        else
-        {
-            Vertex2 = Vertex3;
-            delta_y_rc = delta_y_cl + delta_y_rc;
-            delta_x_rc = delta_x_cl + delta_x_rc;
-            pSite->node2 = pNode2;
-
-            norm_rc = (float)sqrt((double)delta_y_rc*delta_y_rc + delta_x_rc*delta_x_rc);
-        }
-        Vertex2=Vertex3;
-        delta_y_cl= delta_y_rc;
-        delta_x_cl= delta_x_rc;
-        norm_cl = norm_rc;
-        pSite_prev = pSite;
-        pNode1 = pNode2;
-    }
-
-    if(SiteTemp.next_site==NULL)
-        return 0;
-
-    if(ContourSeq->total - NReflexSite<2)
-        return 0;
-
-    if(SiteSeq->total<3)
-        return 0;
-
-    pSite->node2 = SiteTemp.next_site->node1;
-    pSite->next_site = SiteTemp.next_site;
-    SiteTemp.next_site->prev_site = pSite;
-
-    i = 0;
-    if(pReflexSite!=NULL)
-        for(i=0; i<SiteSeq->total; i++)
-        {
-            if(pReflexSite->next_site->next_site->node1 !=
-              pReflexSite->next_site->next_site->node2)
-              break;
-            else
-                pReflexSite = pReflexSite->next_site->next_site;
-        }
-    pVoronoiDiagram->reflex_site = pReflexSite;
-    return (i<SiteSeq->total);
-}//end of _cvConstructExtSites
-
-template<class T>
-int _cvConstructIntSites(CvVoronoiDiagramInt* pVoronoiDiagram,
-                                 CvSeq* CurrSiteSeq,
-                                 CvSeq* CurrContourSeq,
-                                 pCvVoronoiSite &pTopSite,
-                                 int orientation,
-                                 T /*type*/)
-{
-    const double angl_eps = 0.03;
-    float min_x = (float)999999999;
-    CvSeq* SiteSeq = CurrSiteSeq;
-    CvSeq* NodeSeq = pVoronoiDiagram->NodeSeq;
-    //CvSeq* DirectionSeq = pVoronoiDiagram->DirectionSeq;
-    CvPointFloat Vertex1,Vertex2,Vertex3;
-    CvLeePoint<T> VertexT1,VertexT2,VertexT3;
-
-    CvSeqReader ContourReader;
-    CvVoronoiSiteInt Site = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};
-    CvVoronoiSiteInt SiteTemp = {NULL,NULL,NULL,NULL,NULL,NULL,NULL};
-    CvVoronoiNodeInt Node;
-    pCvVoronoiNode pNode1,pNode2;
-    pCvVoronoiSite pSite = &SiteTemp,pSite_prev = &SiteTemp;
-    pTopSite = NULL;
-    int NReflexSite = 0;
-
-    if(CurrContourSeq->total == 1)
-    {
-        cvStartReadSeq(CurrContourSeq, &ContourReader,0);
-        CV_READ_SEQ_ELEM(VertexT1,ContourReader);
-        Vertex1.x = (float)VertexT1.x;
-        Vertex1.y = (float)VertexT1.y;
-
-        _cvInitVoronoiNode(&Node, &Vertex1);
-        pNode1 = _cvSeqPush(NodeSeq, &Node);
-        pTopSite = pSite = _cvSeqPush(SiteSeq, &Site);
-        _cvInitVoronoiSite(pSite,pNode1,pNode1,pSite);
-        pSite->next_site = pSite;
-        return 1;
-    }
-
-    float delta_x_rc, delta_x_cl, delta_y_rc, delta_y_cl;
-    float norm_cl,norm_rc, mult_cl_rc;
-    float _sin, _cos;
-    int i;
-
-    if(orientation == 1)
-    {
-        cvStartReadSeq(CurrContourSeq, &ContourReader,0);
-        CV_READ_SEQ_ELEM(VertexT1,ContourReader);
-        CV_READ_SEQ_ELEM(VertexT2,ContourReader);
-    }
-    else
-    {
-        cvStartReadSeq(CurrContourSeq, &ContourReader,1);
-        CV_REV_READ_SEQ_ELEM(VertexT1,ContourReader);
-        CV_REV_READ_SEQ_ELEM(VertexT2,ContourReader);
-    }
-
-    Vertex1.x = (float)VertexT1.x;
-    Vertex1.y = (float)VertexT1.y;
-    Vertex2.x = (float)VertexT2.x;
-    Vertex2.y = (float)VertexT2.y;
-
-    _cvInitVoronoiNode(&Node, &Vertex2);
-    pNode1 = _cvSeqPush(NodeSeq, &Node);
-
-    delta_x_cl = Vertex2.x - Vertex1.x;
-    delta_y_cl = Vertex2.y - Vertex1.y;
-    norm_cl = (float)sqrt((double)delta_x_cl*delta_x_cl + delta_y_cl*delta_y_cl);
-    for( i = 0;i<CurrContourSeq->total;i++)
-    {
-        if(orientation == 1)
-        {
-            CV_READ_SEQ_ELEM(VertexT3,ContourReader);
-        }
-        else
-        {
-            CV_REV_READ_SEQ_ELEM(VertexT3,ContourReader);
-        }
-        Vertex3.x = (float)VertexT3.x;
-        Vertex3.y = (float)VertexT3.y;
-
-        _cvInitVoronoiNode(&Node, &Vertex3);
-        pNode2 = _cvSeqPush(NodeSeq, &Node);
-
-        delta_x_rc = Vertex3.x - Vertex2.x;
-        delta_y_rc = Vertex3.y - Vertex2.y;
-        norm_rc = (float)sqrt((double)delta_x_rc*delta_x_rc + delta_y_rc*delta_y_rc);
-        if(norm_rc==0)
-            continue;
-
-        mult_cl_rc = norm_cl*norm_rc;
-        _sin = (delta_y_rc* delta_x_cl - delta_x_rc* delta_y_cl)/mult_cl_rc;
-        _cos = -(delta_x_cl*delta_x_rc + delta_y_cl*delta_y_rc)/mult_cl_rc;
-        if((_sin > angl_eps) || (_sin > 0 && _cos > 0))
-        {
-            pSite = _cvSeqPush(SiteSeq, &Site);
-            _cvInitVoronoiSite(pSite,pNode1,pNode2,pSite_prev);
-            pSite_prev->next_site = pSite;
-        }
-        else if((_sin < -angl_eps) || (_sin < 0 && _cos > 0) || (_sin == 0 && CurrContourSeq->total == 2))
-        {
-            pSite = _cvSeqPush(SiteSeq, &Site);
-            _cvInitVoronoiSite(pSite,pNode1,pNode1,pSite_prev);
-            if(pNode1->node.x < min_x)
-            {
-                min_x = pNode1->node.x;
-                pTopSite = pSite;
-            }
-            NReflexSite++;
-            pSite_prev->next_site = pSite;
-
-            pSite_prev = pSite;
-            pSite = _cvSeqPush(SiteSeq, &Site);
-            _cvInitVoronoiSite(pSite,pNode1,pNode2,pSite_prev);
-            pSite_prev->next_site = pSite;
-        }
-        else
-        {
-            Vertex2 = Vertex3;
-            delta_y_rc = delta_y_cl + delta_y_rc;
-            delta_x_rc = delta_x_cl + delta_x_rc;
-            norm_rc = (float)sqrt((double)delta_y_rc*delta_y_rc + delta_x_rc*delta_x_rc);
-            pSite->node2 = pNode2;
-        }
-
-        Vertex1=Vertex2;
-        Vertex2=Vertex3;
-        delta_y_cl= delta_y_rc;
-        delta_x_cl= delta_x_rc;
-        norm_cl = norm_rc;
-        pSite_prev = pSite;
-        pNode1 = pNode2;
-    }
-
-    if(SiteTemp.next_site==NULL)
-        return 0;
-
-    if((NReflexSite < 3 && CurrContourSeq->total > 2) || NReflexSite < 2)
-        return 0;
-
-    pSite->node2 = SiteTemp.next_site->node1;
-    pSite->next_site = SiteTemp.next_site;
-    SiteTemp.next_site->prev_site = pSite;
-
-    return 1;
-}//end of _cvConstructIntSites
-
-static int _cvConstructExtChains(CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    CvSeq* SiteSeq = pVoronoiDiagram->SiteSeq;
-    CvSeq* ChainSeq = pVoronoiDiagram->ChainSeq;
-
-    CvVoronoiChainInt Chain;
-    pCvVoronoiChain pChain,pChainFirst;
-    pCvVoronoiSite pSite, pSite_prev, pSiteFirst,pReflexSite = pVoronoiDiagram->reflex_site;
-
-    if(pReflexSite==NULL)
-        pSite = pSiteFirst = (pCvVoronoiSite)cvGetSeqElem(SiteSeq, 0);
-    else
-    {
-        while(pReflexSite->next_site->next_site->node1==
-              pReflexSite->next_site->next_site->node2)
-            pReflexSite = pReflexSite->next_site->next_site;
-
-        pSite = pSiteFirst = pReflexSite->next_site;
-    }
-
-    Chain.last_site = pSite;
-    _cvConstructEdges(pSite,pVoronoiDiagram);
-    pSite_prev = pSite;
-    pSite = pSite->prev_site;
-    do
-    {
-        if(pSite->node1!=pSite->node2)
-        {
-            Chain.first_site = pSite_prev;
-            pChain = _cvSeqPushFront(ChainSeq,&Chain);
-
-            _cvConstructEdges(pSite,pVoronoiDiagram);
-            Chain.last_site = pSite;
-            Chain.next_chain = pChain;
-        }
-        else
-        {
-            pSite=pSite->prev_site;
-            _cvConstructEdges(pSite,pVoronoiDiagram);
-            _cvConstructEdges(pSite->next_site,pVoronoiDiagram);
-        }
-        pSite_prev = pSite;
-        pSite = pSite->prev_site;
-    }while(pSite!=pSiteFirst);
-
-    Chain.first_site = pSite_prev;
-    pChain = _cvSeqPushFront(ChainSeq,&Chain);
-    pChainFirst = (pCvVoronoiChain)cvGetSeqElem(ChainSeq,ChainSeq->total - 1);
-    pChainFirst->next_chain = pChain;
-    if(ChainSeq->total < 3)
-        return 0;
-    else
-        return 1;
-}// end of _cvConstructExtChains
-
-static void _cvConstructIntChains(CvVoronoiDiagramInt* pVoronoiDiagram,
-                                   CvSeq* CurrChainSeq,
-                                   CvSeq* CurrSiteSeq,
-                                   pCvVoronoiSite pTopSite)
-{
-    CvSeq* ChainSeq = CurrChainSeq;
-
-    if(CurrSiteSeq->total == 1)
-        return;
-
-    CvVoronoiChainInt Chain = {NULL,NULL,NULL};
-    pCvVoronoiChain pChain,pChainFirst;;
-    pCvVoronoiSite pSite, pSite_prev, pSiteFirst;
-    pSite = pSiteFirst = pTopSite->next_site;
-
-    Chain.last_site = pSite;
-    _cvConstructEdges(pSite,pVoronoiDiagram);
-    pSite_prev = pSite;
-    pSite = pSite->prev_site;
-    do
-    {
-        if(pSite->node1!=pSite->node2)
-        {
-            Chain.first_site = pSite_prev;
-            pChain = _cvSeqPushFront(ChainSeq,&Chain);
-
-            _cvConstructEdges(pSite,pVoronoiDiagram);
-            Chain.last_site = pSite;
-            Chain.next_chain = pChain;
-        }
-        else
-        {
-            pSite=pSite->prev_site;
-            if(pSite != pSiteFirst)
-                _cvConstructEdges(pSite,pVoronoiDiagram);
-            _cvConstructEdges(pSite->next_site,pVoronoiDiagram);
-        }
-        pSite_prev = pSite;
-        pSite = pSite->prev_site;
-    }while(pSite!=pSiteFirst && pSite!= pSiteFirst->prev_site);
-
-    if(pSite == pSiteFirst->prev_site && ChainSeq->total == 0)
-        return;
-
-    Chain.first_site = pSite_prev;
-    if(pSite == pSiteFirst->prev_site)
-    {
-        pChainFirst = (pCvVoronoiChain)cvGetSeqElem(ChainSeq,ChainSeq->total - 1);
-        pChainFirst->last_site = Chain.last_site;
-        pChainFirst->next_chain = Chain.next_chain;
-        return;
-    }
-    else
-    {
-        pChain = _cvSeqPushFront(ChainSeq,&Chain);
-        pChainFirst = (pCvVoronoiChain)cvGetSeqElem(ChainSeq,ChainSeq->total - 1);
-        pChainFirst->next_chain = pChain;
-        return;
-    }
-}// end of _cvConstructIntChains
-
-CV_INLINE void _cvConstructEdges(pCvVoronoiSite pSite,CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    CvSeq* EdgeSeq = pVoronoiDiagram->EdgeSeq;
-    CvSeq* DirectionSeq = pVoronoiDiagram->DirectionSeq;
-    CvVoronoiEdgeInt Edge = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
-    pCvVoronoiEdge pEdge1,pEdge2;
-    CvDirection EdgeDirection,SiteDirection;
-    float site_lengh;
-
-    Edge.site = pSite;
-    if(pSite->node1!=pSite->node2)
-    {
-        SiteDirection.x = pSite->node2->node.x - pSite->node1->node.x;
-        SiteDirection.y = pSite->node2->node.y - pSite->node1->node.y;
-        site_lengh = (float)sqrt((double)SiteDirection.x*SiteDirection.x + SiteDirection.y * SiteDirection.y);
-        SiteDirection.x /= site_lengh;
-        SiteDirection.y /= site_lengh;
-        EdgeDirection.x = -SiteDirection.y;
-        EdgeDirection.y = SiteDirection.x;
-        Edge.direction = _cvSeqPush(DirectionSeq,&EdgeDirection);
-        pSite->direction = _cvSeqPush(DirectionSeq,&SiteDirection);
-
-        pEdge1 = _cvSeqPush(EdgeSeq,&Edge);
-        pEdge2 = _cvSeqPush(EdgeSeq,&Edge);
-    }
-    else
-    {
-        pCvVoronoiSite pSite_prev = pSite->prev_site;
-        pCvVoronoiSite pSite_next = pSite->next_site;
-
-        pEdge1 = _cvSeqPush(EdgeSeq,&Edge);
-        pEdge2 = _cvSeqPush(EdgeSeq,&Edge);
-
-        pEdge2->direction = pSite_next->edge1->direction;
-        pEdge2->twin_edge = pSite_next->edge1;
-        pSite_next->edge1->twin_edge = pEdge2;
-
-        pEdge1->direction = pSite_prev->edge2->direction;
-        pEdge1->twin_edge = pSite_prev->edge2;
-        pSite_prev->edge2->twin_edge = pEdge1;
-    }
-
-        pEdge2->node1 = pSite->node2;
-        pEdge1->node2 = pSite->node1;
-        pSite->edge1 = pEdge1;
-        pSite->edge2 = pEdge2;
-        pEdge2->next_edge = pEdge1;
-        pEdge1->prev_edge = pEdge2;
-}// end of _cvConstructEdges
-
-static int _cvConstructExtVD(CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    pCvVoronoiSite pSite_right = 0,pSite_left = 0;
-    pCvVoronoiEdge pEdge_left,pEdge_right;
-    pCvVoronoiChain pChain1, pChain2;
-
-    pChain1 = (pCvVoronoiChain)cvGetSeqElem(pVoronoiDiagram->ChainSeq,0);
-    do
-    {
-        pChain2 = pChain1->next_chain;
-        if(pChain2->next_chain==pChain1)
-        {
-            pSite_right = pChain1->first_site;
-            pSite_left = pChain2->last_site;
-            pEdge_left = pSite_left->edge2->next_edge;
-            pEdge_right = pSite_right->edge1->prev_edge;
-            pEdge_left->prev_edge = NULL;
-            pEdge_right->next_edge = NULL;
-            pSite_right->edge1 = NULL;
-            pSite_left->edge2 = NULL;
-        }
-
-        if(!_cvJoinChains(pChain1,pChain2,pVoronoiDiagram))
-            return 0;
-
-        pChain1->last_site = pChain2->last_site;
-        pChain1->next_chain = pChain2->next_chain;
-        pChain1 = pChain1->next_chain;
-    }while(pChain1->next_chain != pChain1);
-
-    pCvVoronoiNode pEndNode = pSite_left->node2;
-    if(pSite_right->edge1==NULL)
-        return 0;
-    else
-        pSite_right->edge1->node2 = pEndNode;
-
-    if(pSite_left->edge2==NULL)
-        return 0;
-    else
-        pSite_left->edge2->node1 = pEndNode;
-
-    return 1;
-}//end of _cvConstructExtVD
-
-static int _cvJoinChains(pCvVoronoiChain pChain1,
-                          pCvVoronoiChain pChain2,
-                          CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    const double dist_eps = 0.05;
-    if(pChain1->first_site == NULL || pChain1->last_site == NULL ||
-        pChain2->first_site == NULL || pChain2->last_site == NULL)
-        return 0;
-
-    CvVoronoiEdgeInt EdgeNULL = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
-
-    CvSeq* NodeSeq = pVoronoiDiagram->NodeSeq;
-    CvSeq* EdgeSeq = pVoronoiDiagram->EdgeSeq;
-
-    pCvVoronoiSite pSite_left = pChain1->last_site;
-    pCvVoronoiSite pSite_right = pChain2->first_site;
-
-    pCvVoronoiEdge pEdge_left = pSite_left->edge2->next_edge;
-    pCvVoronoiEdge pEdge_right = pSite_right->edge1->prev_edge;
-
-    pCvVoronoiEdge pEdge_left_cur = pEdge_left;
-    pCvVoronoiEdge pEdge_right_cur = pEdge_right;
-
-    pCvVoronoiEdge pEdge_left_prev = NULL;
-    pCvVoronoiEdge pEdge_right_next = NULL;
-
-    pCvVoronoiNode pNode_siteleft = pChain1->first_site->node1;
-    pCvVoronoiNode pNode_siteright = pChain2->last_site->node2;
-    /*CvVoronoiSiteInt Site_left_chain = {pNode_siteleft,pNode_siteleft,NULL,NULL,NULL,NULL};
-    CvVoronoiSiteInt Site_right_chain = {pNode_siteright,pNode_siteright,NULL,NULL,NULL,NULL};*/
-
-    pCvVoronoiEdge pEdge1,pEdge2;
-    CvPointFloat Point1 = {0,0}, Point2 = {0,0};
-
-    float radius1,radius2,dist1,dist2;
-    bool left = true,right = true;
-
-    CvVoronoiNodeInt Node;
-    pCvVoronoiNode pNode_begin = pSite_left->node2;
-
-    pEdge1 = pSite_left->edge2;
-    pEdge1->node2 = NULL;
-    pEdge2 = pSite_right->edge1;
-    pEdge2->node1 = NULL;
-
-    for(;;)
-    {
-
-        if(left)
-            pEdge1->node1 = pNode_begin;
-        if(right)
-            pEdge2->node2 = pNode_begin;
-
-        pEdge_left = pEdge_left_cur;
-        pEdge_right = pEdge_right_cur;
-
-        if(left&&right)
-        {
-            _cvCalcEdge(pSite_left,pSite_right,pEdge1,pVoronoiDiagram);
-            _cvMakeTwinEdge(pEdge2,pEdge1);
-            _cvStickEdgeLeftBegin(pEdge1,pEdge_left_prev,pSite_left);
-            _cvStickEdgeRightBegin(pEdge2,pEdge_right_next,pSite_right);
-        }
-        else if(!left)
-        {
-            _cvCalcEdge(pNode_siteleft,pSite_right,pEdge2,pVoronoiDiagram);
-            _cvStickEdgeRightBegin(pEdge2,pEdge_right_next,pSite_right);
-        }
-        else if(!right)
-        {
-            _cvCalcEdge(pSite_left,pNode_siteright,pEdge1,pVoronoiDiagram);
-            _cvStickEdgeLeftBegin(pEdge1,pEdge_left_prev,pSite_left);
-        }
-
-        dist1=dist2=-1;
-        radius1 = -1; radius2 = -2;
-
-        while(pEdge_left!=NULL)
-        {
-            if(pEdge_left->node2 == NULL)
-            {
-                pEdge_left_cur = pEdge_left = pEdge_left->next_edge;
-                if(pEdge_left == NULL)
-                    break;
-            }
-
-            if(left)
-                dist1 = _cvCalcEdgeIntersection(pEdge1, pEdge_left, &Point1,radius1);
-            else
-                dist1 = _cvCalcEdgeIntersection(pEdge2, pEdge_left, &Point1,radius1);
-
-            if(dist1>=0)
-                break;
-
-            pEdge_left = pEdge_left->next_edge;
-        }
-
-        while(pEdge_right!=NULL)
-        {
-            if(pEdge_right->node1 == NULL)
-            {
-                pEdge_right_cur = pEdge_right = pEdge_right->prev_edge;
-                if(pEdge_right == NULL)
-                    break;
-            }
-
-            if(left)
-                dist2 = _cvCalcEdgeIntersection(pEdge1, pEdge_right, &Point2, radius2);
-            else
-                dist2 = _cvCalcEdgeIntersection(pEdge2, pEdge_right, &Point2, radius2);
-
-            if(dist2>=0)
-                break;
-
-            pEdge_right = pEdge_right->prev_edge;
-        }
-
-        if(dist1<0&&dist2<0)
-        {
-            if(left)
-            {
-                pEdge_left = pSite_left->edge1;
-                if(pEdge_left==NULL)
-                    _cvStickEdgeLeftEnd(pEdge1,NULL,pSite_left);
-                else
-                {
-                    while(pEdge_left->node1!=NULL
-                        &&pEdge_left->node1==pEdge_left->prev_edge->node2)
-                    {
-                        pEdge_left = pEdge_left->prev_edge;
-                        if(pEdge_left==NULL || pEdge_left->prev_edge == NULL)
-                            return 0;
-                    }
-                    _cvStickEdgeLeftEnd(pEdge1,pEdge_left,pSite_left);
-                }
-            }
-            if(right)
-            {
-                pEdge_right = pSite_right->edge2;
-                if(pEdge_right==NULL)
-                    _cvStickEdgeRightEnd(pEdge2,NULL,pSite_right);
-                else
-                {
-                    while(pEdge_right->node2!=NULL
-                        &&  pEdge_right->node2==pEdge_right->next_edge->node1)
-                    {
-                        pEdge_right = pEdge_right->next_edge;
-                        if(pEdge_right==NULL || pEdge_right->next_edge == NULL )
-                            return 0;
-                    }
-                    _cvStickEdgeRightEnd(pEdge2,pEdge_right,pSite_right);
-                }
-            }
-            return 1;
-        }
-
-        if(fabs(dist1 - dist2)<dist_eps)
-        {
-            pNode_begin = _cvSeqPush(NodeSeq,&Node);
-            _cvInitVoronoiNode(pNode_begin, &Point2,radius2);
-
-            pEdge1->node2 = pNode_begin;
-            pEdge2->node1 = pNode_begin;
-
-            _cvStickEdgeLeftEnd(pEdge1,pEdge_left,pSite_left);
-            _cvTwinNULLLeft(pEdge_left_cur,pEdge_left);
-
-            _cvStickEdgeRightEnd(pEdge2,pEdge_right,pSite_right);
-            _cvTwinNULLRight(pEdge_right_cur,pEdge_right);
-
-            if(pEdge_left->twin_edge!=NULL&&pEdge_right->twin_edge!=NULL)
-            {
-                pEdge_left_prev = pEdge_left->twin_edge;
-                if(!pEdge_left_prev)
-                    return 0;
-                pEdge_left_cur = pEdge_left_prev->next_edge;
-                pEdge_right_next = pEdge_right->twin_edge;
-                if(!pEdge_right_next)
-                    return 0;
-                pEdge_right_cur = pEdge_right_next->prev_edge;
-                pSite_right = pEdge_right_next->site;
-                pEdge2 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-                pSite_left = pEdge_left_prev->site;
-                pEdge1 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-                continue;
-            }
-
-            if(pEdge_left->twin_edge==NULL&&pEdge_right->twin_edge!=NULL)
-            {
-                pEdge_right_next = pEdge_right->twin_edge;
-                if(!pEdge_right_next)
-                    return 0;
-                pEdge_right_cur = pEdge_right_next->prev_edge;
-                pSite_right = pEdge_right_next->site;
-                pEdge2 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-                pEdge_left_cur = NULL;
-                left = false;
-                continue;
-            }
-
-            if(pEdge_left->twin_edge!=NULL&&pEdge_right->twin_edge==NULL)
-            {
-                pEdge_left_prev = pEdge_left->twin_edge;
-                if(!pEdge_left_prev)
-                    return 0;
-                pEdge_left_cur = pEdge_left_prev->next_edge;
-                pSite_left = pEdge_left_prev->site;
-                pEdge1 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-                pEdge_right_cur = NULL;
-                right = false;
-                continue;
-            }
-            if(pEdge_left->twin_edge==NULL&&pEdge_right->twin_edge==NULL)
-                return 1;
-        }
-
-        if((dist1<dist2&&dist1>=0)||(dist1>=0&&dist2<0))
-        {
-
-            pNode_begin = _cvSeqPush(NodeSeq,&Node);
-            _cvInitVoronoiNode(pNode_begin, &Point1,radius1);
-            pEdge1->node2 = pNode_begin;
-            _cvTwinNULLLeft(pEdge_left_cur,pEdge_left);
-            _cvStickEdgeLeftEnd(pEdge1,pEdge_left,pSite_left);
-            if(right)
-            {
-                pEdge2->node1 = pNode_begin;
-                pEdge_right_next = pEdge2;
-                pEdge2 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-                if(pEdge_left->twin_edge!=NULL)
-                {
-                    pEdge_left_prev = pEdge_left->twin_edge;
-                    if(!pEdge_left_prev)
-                        return 0;
-                    pEdge_left_cur = pEdge_left_prev->next_edge;
-                    pSite_left = pEdge_left_prev->site;
-                    pEdge1 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-                    continue;
-                }
-                else
-                {
-                    pEdge_left_cur = NULL;
-                    left = false;
-                    continue;
-                }
-            }
-            else
-            {
-                if(pEdge_left->twin_edge!=NULL)
-                {
-                    pEdge_left_prev = pEdge_left->twin_edge;
-                    if(!pEdge_left_prev)
-                        return 0;
-                    pEdge_left_cur = pEdge_left_prev->next_edge;
-                    pSite_left = pEdge_left_prev->site;
-                    pEdge1 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-                    continue;
-                }
-                else
-                    return 1;
-
-            }
-
-        }
-
-        if((dist1>dist2&&dist2>=0)||(dist1<0&&dist2>=0))
-        {
-            pNode_begin = _cvSeqPush(NodeSeq,&Node);
-            _cvInitVoronoiNode(pNode_begin, &Point2,radius2);
-            pEdge2->node1 = pNode_begin;
-            _cvTwinNULLRight(pEdge_right_cur,pEdge_right);
-            _cvStickEdgeRightEnd(pEdge2,pEdge_right,pSite_right);
-            if(left)
-            {
-                pEdge1->node2 = pNode_begin;
-                pEdge_left_prev = pEdge1;
-                pEdge1 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-                if(pEdge_right->twin_edge!=NULL)
-                {
-                    pEdge_right_next = pEdge_right->twin_edge;
-                    if(!pEdge_right_next)
-                        return 0;
-                    pEdge_right_cur = pEdge_right_next->prev_edge;
-                    pSite_right = pEdge_right_next->site;
-                    pEdge2 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-                    continue;
-                }
-                else
-                {
-                    pEdge_right_cur = NULL;
-                    right = false;
-                    continue;
-                }
-            }
-            else
-            {
-                if(pEdge_right->twin_edge!=NULL)
-                {
-                    pEdge_right_next = pEdge_right->twin_edge;
-                    if(!pEdge_right_next)
-                        return 0;
-                    pEdge_right_cur = pEdge_right_next->prev_edge;
-                    pSite_right = pEdge_right_next->site;
-                    pEdge2 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-                    continue;
-                }
-                else
-                    return 1;
-            }
-
-        }
-    }
-
-}// end of _cvJoinChains
-
-static void _cvFindNearestSite(CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    pCvVoronoiHole pCurrHole, pHole = pVoronoiDiagram->top_hole;
-    pCvPointFloat pTopPoint,pPoint1,pPoint2;
-    CvPointFloat Direction;
-    pCvVoronoiSite pSite;
-    CvVoronoiNodeInt Node;
-    CvSeq* CurrSeq;
-    float min_distance,distance;
-    int i;
-    for(;pHole != NULL; pHole = pHole->next_hole)
-    {
-        if(pHole->error)
-            continue;
-        pTopPoint = &pHole->site_top->node1->node;
-        pCurrHole = NULL;
-        CurrSeq = pVoronoiDiagram->SiteSeq;
-        min_distance = (float)3e+34;
-        while(pCurrHole != pHole)
-        {
-            if(pCurrHole && pCurrHole->error)
-                continue;
-            pSite = (pCvVoronoiSite)cvGetSeqElem(CurrSeq,0);
-            if(CurrSeq->total == 1)
-            {
-                distance = _cvCalcDist(pTopPoint, pSite);
-                if(distance < min_distance)
-                {
-                    min_distance = distance;
-                    pHole->site_nearest = pSite;
-                }
-            }
-            else
-            {
-                for(i = 0; i < CurrSeq->total;i++, pSite = pSite->next_site)
-                {
-                    if(pSite->node1 != pSite->node2)
-                    {
-                        pPoint1 = &pSite->node1->node;
-                        pPoint2 = &pSite->node2->node;
-
-                        Direction.x = -pSite->direction->y;
-                        Direction.y = pSite->direction->x;
-
-                        if(
-                                 (pTopPoint->x - pPoint2->x)*Direction.y -
-                                 (pTopPoint->y - pPoint2->y)*Direction.x > 0
-                            ||
-                                 (pTopPoint->x - pPoint1->x)*Direction.y -
-                                 (pTopPoint->y - pPoint1->y)*Direction.x < 0
-                            ||
-                                 (pTopPoint->x - pPoint1->x)*pSite->direction->y -
-                                 (pTopPoint->y - pPoint1->y)*pSite->direction->x > 0
-                           )
-                                continue;
-
-                        distance = _cvCalcDist(pTopPoint, pSite);
-                    }
-                    else
-                    {
-                        pPoint1 = &pSite->node1->node;
-                        if(
-                                 (pTopPoint->x - pPoint1->x)*pSite->edge2->direction->y -
-                                 (pTopPoint->y - pPoint1->y)*pSite->edge2->direction->x > 0
-                            ||
-                                 (pTopPoint->x - pPoint1->x)*pSite->edge1->direction->y -
-                                 (pTopPoint->y - pPoint1->y)*pSite->edge1->direction->x < 0
-                           )
-                                continue;
-
-                        distance = _cvCalcDist(pTopPoint, pSite);
-                    }
-
-
-                    if(distance < min_distance)
-                    {
-                        min_distance = distance;
-                        pHole->site_nearest = pSite;
-                    }
-                }
-            }
-
-            if(pCurrHole == NULL)
-                pCurrHole = pVoronoiDiagram->top_hole;
-            else
-                pCurrHole = pCurrHole->next_hole;
-
-            CurrSeq = pCurrHole->SiteSeq;
-        }
-        pHole->x_coord = min_distance;
-
-        if(pHole->site_nearest->node1 == pHole->site_nearest->node2)
-        {
-            Direction.x = (pHole->site_nearest->node1->node.x - pHole->site_top->node1->node.x)/2;
-            Direction.y = (pHole->site_nearest->node1->node.y - pHole->site_top->node1->node.y)/2;
-        }
-        else
-        {
-
-            Direction.x = pHole->site_nearest->direction->y * min_distance / 2;
-            Direction.y = - pHole->site_nearest->direction->x * min_distance / 2;
-        }
-
-        Node.node.x = pHole->site_top->node1->node.x + Direction.x;
-        Node.node.y = pHole->site_top->node1->node.y + Direction.y;
-        pHole->node = _cvSeqPush(pVoronoiDiagram->NodeSeq, &Node);
-    }
-}//end of _cvFindNearestSite
-
-static void _cvConstructIntVD(CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    pCvVoronoiChain pChain1, pChain2;
-    pCvVoronoiHole pHole;
-    int i;
-
-    pHole = pVoronoiDiagram->top_hole;
-
-    for(;pHole != NULL; pHole = pHole->next_hole)
-    {
-        if(pHole->ChainSeq->total == 0)
-            continue;
-        pChain1 = (pCvVoronoiChain)cvGetSeqElem(pHole->ChainSeq,0);
-        for(i = pHole->ChainSeq->total; i > 0;i--)
-        {
-            pChain2 = pChain1->next_chain;
-            if(!_cvJoinChains(pChain1,pChain2,pVoronoiDiagram))
-            {
-                pHole->error = true;
-                break;
-            }
-
-            pChain1->last_site = pChain2->last_site;
-            pChain1->next_chain = pChain2->next_chain;
-            pChain1 = pChain1->next_chain;
-        }
-    }
-}// end of _cvConstructIntVD
-
-static int _cvFindOppositSiteCW(pCvVoronoiHole pHole, CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    pCvVoronoiSite pSite_left = pHole->site_nearest;
-    pCvVoronoiSite pSite_right = pHole->site_top;
-    pCvVoronoiNode pNode = pHole->node;
-
-    CvDirection Direction = {-1,0};
-    CvVoronoiEdgeInt Edge_right = {NULL,pSite_right->node1,pSite_right,NULL,NULL,NULL,NULL,&Direction};
-
-    pCvVoronoiEdge pEdge_left = pSite_left->edge2->next_edge;
-    pCvVoronoiEdge pEdge_right = &Edge_right;
-
-    CvVoronoiEdgeInt Edge     = {NULL,pNode,pSite_right,NULL,NULL,NULL,NULL,NULL};
-    CvVoronoiEdgeInt Edge_cur = {NULL,NULL, NULL,       NULL,NULL,NULL,NULL,NULL};
-    pCvVoronoiEdge pEdge = &Edge;
-
-    float radius1, radius2,dist1, dist2;
-    CvPointFloat Point1 = {0,0}, Point2 = {0,0};
-
-    for(;;)
-    {
-        pEdge->direction = NULL;
-        pEdge->parabola = NULL;
-        _cvCalcEdge(pSite_left,pSite_right,pEdge,pVoronoiDiagram);
-
-        dist1=dist2=-1;
-        radius1 = -1; radius2 = -2;
-        while(pEdge_left!=NULL)
-        {
-            dist1 = _cvCalcEdgeIntersection(pEdge, pEdge_left, &Point1,radius1);
-            if(dist1>=0)
-                break;
-            pEdge_left = pEdge_left->next_edge;
-        }
-
-        dist2 = _cvCalcEdgeIntersection(pEdge, pEdge_right, &Point2, radius2);
-        if(dist2>=0 && dist1 >= dist2)
-        {
-            pHole->site_opposite = pSite_left;
-            pNode->node = Point2;
-            return 1;
-        }
-
-        if(dist1<0)
-            return 0;
-
-        Edge_cur = *pEdge_left->twin_edge;
-        Edge_cur.node1 = pNode;
-        pEdge_left = &Edge_cur;
-
-        pSite_left = pEdge_left->site;
-        pNode->node = Point1;
-    }
-}//end of _cvFindOppositSiteCW
-
-static int _cvFindOppositSiteCCW(pCvVoronoiHole pHole,CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    pCvVoronoiSite pSite_right = pHole->site_nearest;
-    pCvVoronoiSite pSite_left = pHole->site_top;
-    pCvVoronoiNode pNode = pHole->node;
-
-    CvDirection Direction = {-1,0};
-    CvVoronoiEdgeInt Edge_left = {pSite_left->node1,NULL,pSite_left,NULL,NULL,NULL, NULL, &Direction};
-
-    pCvVoronoiEdge pEdge_left = &Edge_left;
-    pCvVoronoiEdge pEdge_right = pSite_right->edge1->prev_edge;
-
-    CvVoronoiEdgeInt Edge     = {NULL,pNode,pSite_left,NULL,NULL,NULL,NULL,NULL};
-    CvVoronoiEdgeInt Edge_cur = {NULL,NULL, NULL,      NULL,NULL,NULL,NULL,NULL};
-    pCvVoronoiEdge pEdge = &Edge;
-
-    double dist1, dist2;
-    float radius1, radius2;
-    CvPointFloat Point1 = {0,0}, Point2 = {0,0};
-
-    for(;;)
-    {
-        pEdge->direction = NULL;
-        pEdge->parabola = NULL;
-        _cvCalcEdge(pSite_left,pSite_right,pEdge,pVoronoiDiagram);
-
-        dist1=dist2=-1;
-        radius1 = -1; radius2 = -2;
-        while(pEdge_right!=NULL)
-        {
-            dist1 = _cvCalcEdgeIntersection(pEdge, pEdge_right, &Point1,radius2);
-            if(dist1>=0)
-                break;
-            pEdge_right = pEdge_right->prev_edge;
-        }
-
-        dist2 = _cvCalcEdgeIntersection(pEdge, pEdge_left, &Point2, radius1);
-        if(dist2>=0 && dist1 > dist2)
-        {
-            pHole->site_opposite = pSite_right;
-            pNode->node = Point2;
-            return 1;
-        }
-
-        if(dist1<0)
-            return 0;
-
-        Edge_cur = *pEdge_right->twin_edge;
-        Edge_cur.node2 = pNode;
-        pEdge_right = &Edge_cur;
-
-        pSite_right = pEdge_right->site;
-        pNode->node = Point1;
-    }
-}//end of _cvFindOppositSiteCCW
-
-static int _cvMergeVD(pCvVoronoiHole pHole,CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    pCvVoronoiSite pSite_left_first = pHole->site_top;
-    pCvVoronoiSite pSite_right_first = pHole->site_opposite;
-    pCvVoronoiNode pNode_begin = pHole->node;
-    if(pSite_left_first == NULL || pSite_right_first == NULL || pNode_begin == NULL)
-        return 0;
-
-    pCvVoronoiSite pSite_left = pSite_left_first;
-    pCvVoronoiSite pSite_right = pSite_right_first;
-
-    const double dist_eps = 0.05;
-    CvVoronoiEdgeInt EdgeNULL = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
-
-    CvSeq* NodeSeq = pVoronoiDiagram->NodeSeq;
-    CvSeq* EdgeSeq = pVoronoiDiagram->EdgeSeq;
-
-    pCvVoronoiEdge pEdge_left = NULL;
-    if(pSite_left->edge2 != NULL)
-        pEdge_left = pSite_left->edge2->next_edge;
-
-    pCvVoronoiEdge pEdge_right = pSite_right->edge1;
-    pCvVoronoiEdge pEdge_left_cur = pEdge_left;
-    pCvVoronoiEdge pEdge_right_cur = pEdge_right;
-
-    pCvVoronoiEdge pEdge_left_prev = NULL;
-    pCvVoronoiEdge pEdge_right_next = NULL;
-
-    pCvVoronoiEdge pEdge1,pEdge2,pEdge1_first, pEdge2_first;
-    CvPointFloat Point1 = {0,0}, Point2 = {0,0};
-
-    float radius1,radius2,dist1,dist2;
-
-    CvVoronoiNodeInt Node;
-
-    pEdge1_first = pEdge1 = _cvSeqPush(EdgeSeq, &EdgeNULL);;
-    pEdge2_first = pEdge2 = _cvSeqPush(EdgeSeq, &EdgeNULL);;
-    pEdge1->site = pSite_left_first;
-    pEdge2->site = pSite_right_first;
-
-    do
-    {
-        pEdge1->node1 = pEdge2->node2 = pNode_begin;
-
-        pEdge_left = pEdge_left_cur;
-        pEdge_right = pEdge_right_cur->prev_edge;
-
-        _cvCalcEdge(pSite_left,pSite_right,pEdge1,pVoronoiDiagram);
-        _cvMakeTwinEdge(pEdge2,pEdge1);
-
-        if(pEdge_left_prev != NULL)
-            _cvStickEdgeLeftBegin(pEdge1,pEdge_left_prev,pSite_left);
-        if(pEdge_right_next != NULL)
-            _cvStickEdgeRightBegin(pEdge2,pEdge_right_next,pSite_right);
-
-        dist1=dist2=-1;
-        radius1 = -1; radius2 = -2;
-
-//LEFT:
-        while(pEdge_left!=NULL)
-        {
-            if(pEdge_left->node2 == NULL)
-                pEdge_left_cur = pEdge_left = pEdge_left->next_edge;
-
-            dist1 = _cvCalcEdgeIntersection(pEdge1, pEdge_left, &Point1,radius1);
-            if(dist1>=0)
-                goto RIGHT;
-            pEdge_left = pEdge_left->next_edge;
-        }
-
-RIGHT:
-        while(pEdge_right!=NULL)
-        {
-            dist2 = _cvCalcEdgeIntersection(pEdge1, pEdge_right, &Point2,radius2);
-            if(dist2>=0)
-                goto RESULTHANDLING;
-
-            pEdge_right = pEdge_right->prev_edge;
-        }
-        pEdge_right = pEdge_right_cur;
-        dist2 = _cvCalcEdgeIntersection(pEdge1, pEdge_right, &Point2, radius2);
-
-RESULTHANDLING:
-        if(dist1<0&&dist2<0)
-            return 0;
-
-        if(fabs(dist1 - dist2)<dist_eps)
-        {
-            pNode_begin = _cvSeqPush(NodeSeq,&Node);
-            _cvInitVoronoiNode(pNode_begin, &Point2,radius2);
-
-            pEdge1->node2 = pNode_begin;
-            pEdge2->node1 = pNode_begin;
-
-            pEdge_right_cur = _cvDivideRightEdge(pEdge_right,pNode_begin,EdgeSeq);
-
-            _cvStickEdgeLeftEnd(pEdge1,pEdge_left,pSite_left);
-            _cvStickEdgeRightEnd(pEdge2,pEdge_right,pSite_right);
-
-            pEdge_left_prev = pEdge_left->twin_edge;
-            if(!pEdge_left_prev)
-                return 0;
-            pEdge_left_cur = pEdge_left_prev->next_edge;
-            pSite_left = pEdge_left_prev->site;
-            pEdge1 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-
-            pEdge_right_next = pEdge_right->twin_edge;
-            if(!pEdge_right_next)
-                return 0;
-            pSite_right = pEdge_right_next->site;
-            pEdge2 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-
-            continue;
-        }
-
-        if((dist1<dist2&&dist1>=0)||(dist1>=0&&dist2<0))
-        {
-            pNode_begin = _cvSeqPush(NodeSeq,&Node);
-            _cvInitVoronoiNode(pNode_begin, &Point1,radius1);
-
-            pEdge1->node2 = pNode_begin;
-            _cvStickEdgeLeftEnd(pEdge1,pEdge_left,pSite_left);
-
-            pEdge2->node1 = pNode_begin;
-            pEdge_right_next = pEdge2;
-            pEdge2 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-
-            pEdge_left_prev = pEdge_left->twin_edge;
-            if(!pEdge_left_prev)
-                return 0;
-            pEdge_left_cur = pEdge_left_prev->next_edge;
-            pSite_left = pEdge_left_prev->site;
-            pEdge1 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-
-            continue;
-        }
-
-        if((dist1>dist2&&dist2>=0)||(dist1<0&&dist2>=0))
-        {
-            pNode_begin = _cvSeqPush(NodeSeq,&Node);
-            _cvInitVoronoiNode(pNode_begin, &Point2,radius2);
-
-            pEdge_right_cur = _cvDivideRightEdge(pEdge_right,pNode_begin,EdgeSeq);
-
-            pEdge2->node1 = pNode_begin;
-            _cvStickEdgeRightEnd(pEdge2,pEdge_right,pSite_right);
-
-            pEdge1->node2 = pNode_begin;
-            pEdge_left_prev = pEdge1;
-            pEdge1 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-
-            pEdge_right_next = pEdge_right->twin_edge;
-            if(!pEdge_right_next)
-                return 0;
-            pSite_right = pEdge_right_next->site;
-            pEdge2 = _cvSeqPush(EdgeSeq, &EdgeNULL);
-
-            continue;
-        }
-
-    }while(!(pSite_left == pSite_left_first && pSite_right == pSite_right_first));
-
-        pEdge1_first->node1 = pNode_begin;
-        pEdge2_first->node2 = pNode_begin;
-        _cvStickEdgeLeftBegin(pEdge1_first,pEdge_left_prev,pSite_left_first);
-        _cvStickEdgeRightBegin(pEdge2_first,pEdge_right_next,pSite_right_first);
-
-        if(pSite_left_first->edge2 == NULL)
-            pSite_left_first->edge2 = pSite_left_first->edge1 = pEdge1_first;
-        return 1;
-}// end of _cvMergeVD
-
-
-/* ///////////////////////////////////////////////////////////////////////////////////////
-//                               Computation of bisectors                               //
-/////////////////////////////////////////////////////////////////////////////////////// */
-
-void _cvCalcEdge(pCvVoronoiSite pSite_left,
-                 pCvVoronoiSite pSite_right,
-                 pCvVoronoiEdge pEdge,
-                 CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    if((pSite_left->node1!=pSite_left->node2)&&
-        (pSite_right->node1!=pSite_right->node2))
-        _cvCalcEdgeLL(pSite_left->direction,
-                     pSite_right->direction,
-                     pEdge,pVoronoiDiagram);
-
-    else if((pSite_left->node1!=pSite_left->node2)&&
-            (pSite_right->node1 == pSite_right->node2))
-        _cvCalcEdgeLP(pSite_left,pSite_right->node1,pEdge,pVoronoiDiagram);
-
-    else if((pSite_left->node1==pSite_left->node2)&&
-            (pSite_right->node1!=pSite_right->node2))
-        _cvCalcEdgePL(pSite_left->node1,pSite_right,pEdge,pVoronoiDiagram);
-
-    else
-        _cvCalcEdgePP(&(pSite_left->node1->node),
-                     &(pSite_right->node1->node),
-                     pEdge,pVoronoiDiagram);
-}//end of _cvCalcEdge
-
-void _cvCalcEdge(pCvVoronoiSite pSite,
-                 pCvVoronoiNode pNode,
-                 pCvVoronoiEdge pEdge,
-                 CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    if(pSite->node1!=pSite->node2)
-        _cvCalcEdgeLP(pSite, pNode, pEdge,pVoronoiDiagram);
-    else
-        _cvCalcEdgePP(&(pSite->node1->node),
-                     &pNode->node,
-                     pEdge,pVoronoiDiagram);
-}//end of _cvCalcEdge
-
-void _cvCalcEdge(pCvVoronoiNode pNode,
-                         pCvVoronoiSite pSite,
-                         pCvVoronoiEdge pEdge,
-                         CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    if(pSite->node1!=pSite->node2)
-        _cvCalcEdgePL(pNode,pSite,pEdge,pVoronoiDiagram);
-    else
-        _cvCalcEdgePP(&pNode->node,&pSite->node1->node,pEdge,pVoronoiDiagram);
-}//end of _cvCalcEdge
-
-CV_INLINE
-void _cvCalcEdgeLL(pCvDirection pDirection1,
-                  pCvDirection pDirection2,
-                  pCvVoronoiEdge pEdge,
-                  CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    CvDirection Direction = {pDirection2->x - pDirection1->x, pDirection2->y - pDirection1->y};
-    if((fabs(Direction.x)<LEE_CONST_ZERO)&&(fabs(Direction.y)<LEE_CONST_ZERO))
-            Direction = *pDirection2;
-    pEdge->direction = _cvSeqPush(pVoronoiDiagram->DirectionSeq,&Direction);;
-}//end of _cvCalcEdgeLL
-
-CV_INLINE
-void _cvCalcEdgePP(pCvPointFloat pPoint1,
-                  pCvPointFloat pPoint2,
-                  pCvVoronoiEdge pEdge,
-                  CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    CvDirection Direction = {pPoint1->y - pPoint2->y,pPoint2->x - pPoint1->x};
-    pEdge->direction = _cvSeqPush(pVoronoiDiagram->DirectionSeq,&Direction);
-}//end of _cvCalcEdgePP
-
-CV_INLINE
-void _cvCalcEdgePL(pCvVoronoiNode pFocus,
-                  pCvVoronoiSite pDirectrice,
-                  pCvVoronoiEdge pEdge,
-                  CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    pCvPointFloat pPoint0 = &pFocus->node;
-    pCvPointFloat pPoint1 = &pDirectrice->node1->node;
-
-    CvDirection Vector01 = {pPoint0->x - pPoint1->x,pPoint0->y - pPoint1->y};
-    float half_h = (Vector01.y*pDirectrice->direction->x - Vector01.x*pDirectrice->direction->y)/2;
-    CvDirection Normal = {-pDirectrice->direction->y,pDirectrice->direction->x};
-    if(half_h < LEE_CONST_ZERO)
-    {
-        pEdge->direction = _cvSeqPush(pVoronoiDiagram->DirectionSeq,&Normal);
-        return;
-    }
-    CvVoronoiParabolaInt Parabola;
-    pCvVoronoiParabola  pParabola = _cvSeqPush(pVoronoiDiagram->ParabolaSeq,&Parabola);
-    float* map = pParabola->map;
-
-    map[1] = Normal.x;
-    map[4] = Normal.y;
-    map[0] = Normal.y;
-    map[3] = -Normal.x;
-    map[2] = pPoint0->x - Normal.x*half_h;
-    map[5] = pPoint0->y - Normal.y*half_h;
-
-    pParabola->a = 1/(4*half_h);
-    pParabola->focus = pFocus;
-    pParabola->directrice = pDirectrice;
-    pEdge->parabola = pParabola;
-}//end of _cvCalcEdgePL
-
-CV_INLINE
-void _cvCalcEdgeLP(pCvVoronoiSite pDirectrice,
-                  pCvVoronoiNode pFocus,
-                  pCvVoronoiEdge pEdge,
-                  CvVoronoiDiagramInt* pVoronoiDiagram)
-{
-    pCvPointFloat pPoint0 = &pFocus->node;
-    pCvPointFloat pPoint1 = &pDirectrice->node1->node;
-
-    CvDirection Vector01 = {pPoint0->x - pPoint1->x,pPoint0->y - pPoint1->y};
-    float half_h = (Vector01.y*pDirectrice->direction->x - Vector01.x*pDirectrice->direction->y)/2;
-    CvDirection Normal = {-pDirectrice->direction->y,pDirectrice->direction->x};
-    if(half_h < LEE_CONST_ZERO)
-    {
-        pEdge->direction = _cvSeqPush(pVoronoiDiagram->DirectionSeq,&Normal);
-        return;
-    }
-    CvVoronoiParabolaInt Parabola;
-    pCvVoronoiParabola  pParabola = _cvSeqPush(pVoronoiDiagram->ParabolaSeq,&Parabola);
-    float* map = pParabola->map;
-
-    map[1] = Normal.x;
-    map[4] = Normal.y;
-    map[0] = -Normal.y;
-    map[3] = Normal.x;
-    map[2] = pPoint0->x - Normal.x*half_h;
-    map[5] = pPoint0->y - Normal.y*half_h;
-
-    pParabola->a = 1/(4*half_h);
-    pParabola->focus = pFocus;
-    pParabola->directrice = pDirectrice;
-    pEdge->parabola = pParabola;
-}//end of _cvCalcEdgeLP
-
-/* ///////////////////////////////////////////////////////////////////////////////////////
-//                  Computation of intersections of bisectors                           //
-/////////////////////////////////////////////////////////////////////////////////////// */
-
-static
-float _cvCalcEdgeIntersection(pCvVoronoiEdge pEdge1,
-                              pCvVoronoiEdge pEdge2,
-                              CvPointFloat* pPoint,
-                              float &Radius)
-{
-    if((pEdge1->parabola==NULL)&&(pEdge2->parabola==NULL))
-        return _cvLine_LineIntersection(pEdge1,pEdge2,pPoint,Radius);
-    if((pEdge1->parabola==NULL)&&(pEdge2->parabola!=NULL))
-        return _cvLine_ParIntersection(pEdge1,pEdge2,pPoint,Radius);
-    if((pEdge1->parabola!=NULL)&&(pEdge2->parabola==NULL))
-        return _cvPar_LineIntersection(pEdge1,pEdge2,pPoint,Radius);
-    //if((pEdge1->parabola!=NULL)&&(pEdge2->parabola!=NULL))
-        return _cvPar_ParIntersection(pEdge1,pEdge2,pPoint,Radius);
-    //return -1;
-}//end of _cvCalcEdgeIntersection
-
-static
-float _cvLine_LineIntersection(pCvVoronoiEdge pEdge1,
-                                pCvVoronoiEdge pEdge2,
-                                pCvPointFloat  pPoint,
-                                float &Radius)
-{
-    if(((pEdge1->node1 == pEdge2->node1 ||
-        pEdge1->node1 == pEdge2->node2) &&
-        pEdge1->node1 != NULL)||
-       ((pEdge1->node2 == pEdge2->node1 ||
-        pEdge1->node2 == pEdge2->node2) &&
-        pEdge1->node2 != NULL))
-        return -1;
-
-    CvPointFloat Point1,Point3;
-    float det;
-    float k,m;
-    float x21,x43,y43,y21,x31,y31;
-
-    if(pEdge1->node1!=NULL)
-    {
-        Point1.x = pEdge1->node1->node.x;
-        Point1.y = pEdge1->node1->node.y;
-    }
-    else
-    {
-        Point1.x = pEdge1->node2->node.x;
-        Point1.y = pEdge1->node2->node.y;
-    }
-    x21 = pEdge1->direction->x;
-    y21 = pEdge1->direction->y;
-
-    if(pEdge2->node2==NULL)
-    {
-        Point3.x = pEdge2->node1->node.x;
-        Point3.y = pEdge2->node1->node.y;
-        x43 = pEdge2->direction->x;
-        y43 = pEdge2->direction->y;
-
-    }
-    else if(pEdge2->node1==NULL)
-    {
-        Point3.x = pEdge2->node2->node.x;
-        Point3.y = pEdge2->node2->node.y;
-        x43 = pEdge2->direction->x;
-        y43 = pEdge2->direction->y;
-    }
-    else
-    {
-        Point3.x = pEdge2->node1->node.x;
-        Point3.y = pEdge2->node1->node.y;
-        x43 = pEdge2->node2->node.x - Point3.x;
-        y43 = pEdge2->node2->node.y - Point3.y;
-    }
-
-    x31 = Point3.x - Point1.x;
-    y31 = Point3.y - Point1.y;
-
-    det = y21*x43 - x21*y43;
-    if(fabs(det) < LEE_CONST_ZERO)
-        return -1;
-
-    k = (x43*y31 - y43*x31)/det;
-    m = (x21*y31 - y21*x31)/det;
-
-    if(k<-LEE_CONST_ACCEPTABLE_ERROR||m<-LEE_CONST_ACCEPTABLE_ERROR)
-        return -1;
-    if(((pEdge1->node2!=NULL)&&(pEdge1->node1!=NULL))&&(k>1.f+LEE_CONST_ACCEPTABLE_ERROR))
-        return -1;
-    if(((pEdge2->node2!=NULL)&&(pEdge2->node1!=NULL))&&(m>1.f+LEE_CONST_ACCEPTABLE_ERROR))
-        return -1;
-
-    pPoint->x = (float)(k*x21) + Point1.x;
-    pPoint->y = (float)(k*y21) + Point1.y;
-
-    Radius = _cvCalcDist(pPoint,pEdge1->site);
-    return _cvPPDist(pPoint,&Point1);;
-}//end of _cvLine_LineIntersection
-
-static
-float _cvLine_ParIntersection(pCvVoronoiEdge pEdge1,
-                                pCvVoronoiEdge pEdge2,
-                                pCvPointFloat  pPoint,
-                                float &Radius)
-{
-    if(pEdge2->node1==NULL||pEdge2->node2==NULL)
-        return _cvLine_OpenParIntersection(pEdge1,pEdge2,pPoint,Radius);
-    return _cvLine_CloseParIntersection(pEdge1,pEdge2,pPoint,Radius);
-}//end of _cvLine_ParIntersection
-
-static
-float _cvLine_OpenParIntersection(pCvVoronoiEdge pEdge1,
-                                pCvVoronoiEdge pEdge2,
-                                pCvPointFloat  pPoint,
-                                float &Radius)
-{
-    int IntersectionNumber = 1;
-    if(((pEdge1->node1 == pEdge2->node1 ||
-        pEdge1->node1 == pEdge2->node2) &&
-        pEdge1->node1 != NULL)||
-       ((pEdge1->node2 == pEdge2->node1 ||
-        pEdge1->node2 == pEdge2->node2) &&
-        pEdge1->node2 != NULL))
-        IntersectionNumber = 2;
-
-    pCvPointFloat pRayPoint1;
-    if(pEdge1->node1!=NULL)
-        pRayPoint1 = &(pEdge1->node1->node);
-    else
-        pRayPoint1 = &(pEdge1->node2->node);
-
-    pCvDirection pDirection = pEdge1->direction;
-    float* Parabola = pEdge2->parabola->map;
-
-    pCvPointFloat pParPoint1;
-    if(pEdge2->node1==NULL)
-        pParPoint1 = &(pEdge2->node2->node);
-    else
-        pParPoint1 = &(pEdge2->node1->node);
-
-    float InversParabola[6]={0,0,0,0,0,0};
-    _cvCalcOrtogInverse(InversParabola, Parabola);
-
-    CvPointFloat  Point,ParPoint1_img,RayPoint1_img;
-    CvDirection Direction_img;
-    _cvCalcPointImage(&RayPoint1_img, pRayPoint1, InversParabola);
-    _cvCalcVectorImage(&Direction_img,pDirection, InversParabola);
-
-    float c2 = pEdge2->parabola->a*Direction_img.x;
-    float c1 = -Direction_img.y;
-    float c0 = Direction_img.y* RayPoint1_img.x - Direction_img.x*RayPoint1_img.y;
-    float X[2];
-    int N = _cvSolveEqu2thR(c2,c1,c0,X);
-    if(N==0)
-        return -1;
-
-    _cvCalcPointImage(&ParPoint1_img, pParPoint1, InversParabola);
-    int sign_x = SIGN(Direction_img.x);
-    int sign_y = SIGN(Direction_img.y);
-    if(N==1)
-    {
-        if(X[0]<ParPoint1_img.x - LEE_CONST_ACCEPTABLE_ERROR)
-            return -1;
-        float pr0 = (X[0]-RayPoint1_img.x)*sign_x + \
-                    (pEdge2->parabola->a*X[0]*X[0]-RayPoint1_img.y)*sign_y;
-        if(pr0 <= -LEE_CONST_ACCEPTABLE_ERROR)
-            return -1;
-    }
-    else
-    {
-        if(X[1]<ParPoint1_img.x - LEE_CONST_ACCEPTABLE_ERROR)
-            return -1;
-        float pr0 = (X[0]-RayPoint1_img.x)*sign_x + \
-                        (pEdge2->parabola->a*X[0]*X[0]-RayPoint1_img.y)*sign_y;
-        float pr1 = (X[1]-RayPoint1_img.x)*sign_x + \
-                        (pEdge2->parabola->a*X[1]*X[1]-RayPoint1_img.y)*sign_y;
-
-        if(pr0 <= -LEE_CONST_ACCEPTABLE_ERROR &&pr1 <= -LEE_CONST_ACCEPTABLE_ERROR)
-            return -1;
-
-        if(pr0 >- LEE_CONST_ACCEPTABLE_ERROR && pr1 >- LEE_CONST_ACCEPTABLE_ERROR)
-        {
-            if(X[0] >= ParPoint1_img.x - LEE_CONST_ACCEPTABLE_ERROR)
-            {
-                if(pr0>pr1)
-                    _cvSwap(X[0],X[1]);
-            }
-            else
-            {
-                N=1;
-                X[0] = X[1];
-            }
-        }
-        else if(pr0 >- LEE_CONST_ACCEPTABLE_ERROR)
-        {
-            N = 1;
-            if(X[0] < ParPoint1_img.x - LEE_CONST_ACCEPTABLE_ERROR)
-                return -1;
-        }
-        else if(pr1 >- LEE_CONST_ACCEPTABLE_ERROR)
-        {
-            N=1;
-            X[0] = X[1];
-        }
-        else
-            return -1;
-    }
-
-    Point.x = X[(N-1)*(IntersectionNumber - 1)];
-    Point.y = pEdge2->parabola->a*Point.x*Point.x;
-
-    Radius = Point.y + 1.f/(4*pEdge2->parabola->a);
-    _cvCalcPointImage(pPoint,&Point,Parabola);
-    float dist = _cvPPDist(pPoint, pRayPoint1);
-    if(IntersectionNumber == 2 && dist < LEE_CONST_DIFF_POINTS)
-        return -1;
-    else
-        return dist;
-}// end of _cvLine_OpenParIntersection
-
-static
-float _cvLine_CloseParIntersection(pCvVoronoiEdge pEdge1,
-                                pCvVoronoiEdge pEdge2,
-                                pCvPointFloat  pPoint,
-                                float &Radius)
-{
-    int IntersectionNumber = 1;
-    if(((pEdge1->node1 == pEdge2->node1 ||
-        pEdge1->node1 == pEdge2->node2) &&
-        pEdge1->node1 != NULL)||
-       ((pEdge1->node2 == pEdge2->node1 ||
-        pEdge1->node2 == pEdge2->node2) &&
-        pEdge1->node2 != NULL))
-        IntersectionNumber = 2;
-
-    pCvPointFloat pRayPoint1;
-    if(pEdge1->node1!=NULL)
-        pRayPoint1 = &(pEdge1->node1->node);
-    else
-        pRayPoint1 = &(pEdge1->node2->node);
-
-    pCvDirection pDirection = pEdge1->direction;
-    float* Parabola = pEdge2->parabola->map;
-
-    pCvPointFloat pParPoint1,pParPoint2;
-    pParPoint2 = &(pEdge2->node1->node);
-    pParPoint1 = &(pEdge2->node2->node);
-
-
-    float InversParabola[6]={0,0,0,0,0,0};
-    _cvCalcOrtogInverse(InversParabola, Parabola);
-
-    CvPointFloat  Point,ParPoint1_img,ParPoint2_img,RayPoint1_img;
-    CvDirection Direction_img;
-    _cvCalcPointImage(&RayPoint1_img, pRayPoint1, InversParabola);
-    _cvCalcVectorImage(&Direction_img,pDirection, InversParabola);
-
-    float c2 = pEdge2->parabola->a*Direction_img.x;
-    float c1 = -Direction_img.y;
-    float c0 = Direction_img.y* RayPoint1_img.x - Direction_img.x*RayPoint1_img.y;
-    float X[2];
-    int N = _cvSolveEqu2thR(c2,c1,c0,X);
-    if(N==0)
-        return -1;
-
-    _cvCalcPointImage(&ParPoint1_img, pParPoint1, InversParabola);
-    _cvCalcPointImage(&ParPoint2_img, pParPoint2, InversParabola);
-    if(ParPoint1_img.x>ParPoint2_img.x)
-        _cvSwap(ParPoint1_img,ParPoint2_img);
-    int sign_x = SIGN(Direction_img.x);
-    int sign_y = SIGN(Direction_img.y);
-    if(N==1)
-    {
-        if((X[0]<ParPoint1_img.x - LEE_CONST_ACCEPTABLE_ERROR) ||
-           (X[0]>ParPoint2_img.x + LEE_CONST_ACCEPTABLE_ERROR))
-            return -1;
-        float pr0 = (X[0]-RayPoint1_img.x)*sign_x + \
-                    (pEdge2->parabola->a*X[0]*X[0]-RayPoint1_img.y)*sign_y;
-        if(pr0 <= -LEE_CONST_ACCEPTABLE_ERROR)
-            return -1;
-    }
-    else
-    {
-        if((X[1]<ParPoint1_img.x - LEE_CONST_ACCEPTABLE_ERROR) ||
-           (X[0]>ParPoint2_img.x + LEE_CONST_ACCEPTABLE_ERROR))
-            return -1;
-
-        if((X[0]<ParPoint1_img.x - LEE_CONST_ACCEPTABLE_ERROR) &&
-           (X[1]>ParPoint2_img.x + LEE_CONST_ACCEPTABLE_ERROR))
-            return -1;
-
-        float pr0 = (X[0]-RayPoint1_img.x)*sign_x + \
-                    (pEdge2->parabola->a*X[0]*X[0]-RayPoint1_img.y)*sign_y;
-        float pr1 = (X[1]-RayPoint1_img.x)*sign_x + \
-                    (pEdge2->parabola->a*X[1]*X[1]-RayPoint1_img.y)*sign_y;
-
-        if(pr0 <= -LEE_CONST_ACCEPTABLE_ERROR && pr1 <= -LEE_CONST_ACCEPTABLE_ERROR)
-            return -1;
-
-        if(pr0 > -LEE_CONST_ACCEPTABLE_ERROR && pr1 > -LEE_CONST_ACCEPTABLE_ERROR)
-        {
-            if(X[0] >= ParPoint1_img.x - LEE_CONST_ACCEPTABLE_ERROR)
-            {
-                if(X[1] <= ParPoint2_img.x + LEE_CONST_ACCEPTABLE_ERROR)
-                {
-                    if(pr0>pr1)
-                        _cvSwap(X[0], X[1]);
-                }
-                else
-                    N=1;
-            }
-            else
-            {
-                N=1;
-                X[0] = X[1];
-            }
-        }
-        else if(pr0 > -LEE_CONST_ACCEPTABLE_ERROR)
-        {
-
-            if(X[0] >= ParPoint1_img.x - LEE_CONST_ACCEPTABLE_ERROR)
-                N=1;
-            else
-                return -1;
-        }
-        else if(pr1 > -LEE_CONST_ACCEPTABLE_ERROR)
-        {
-            if(X[1] <= ParPoint2_img.x + LEE_CONST_ACCEPTABLE_ERROR)
-            {
-                N=1;
-                X[0] = X[1];
-            }
-            else
-                return -1;
-        }
-        else
-            return -1;
-    }
-
-    Point.x = X[(N-1)*(IntersectionNumber - 1)];
-    Point.y = pEdge2->parabola->a*Point.x*Point.x;
-    Radius = Point.y + 1.f/(4*pEdge2->parabola->a);
-    _cvCalcPointImage(pPoint,&Point,Parabola);
-    float dist = _cvPPDist(pPoint, pRayPoint1);
-    if(IntersectionNumber == 2 && dist < LEE_CONST_DIFF_POINTS)
-        return -1;
-    else
-        return dist;
-}// end of _cvLine_CloseParIntersection
-
-static
-float _cvPar_LineIntersection(pCvVoronoiEdge pEdge1,
-                                pCvVoronoiEdge pEdge2,
-                                pCvPointFloat  pPoint,
-                                float &Radius)
-{
-    if(pEdge2->node1==NULL||pEdge2->node2==NULL)
-        return _cvPar_OpenLineIntersection(pEdge1,pEdge2,pPoint,Radius);
-    return _cvPar_CloseLineIntersection(pEdge1,pEdge2,pPoint,Radius);
-}//end _cvPar_LineIntersection
-
-static
-float _cvPar_OpenLineIntersection(pCvVoronoiEdge pEdge1,
-                                pCvVoronoiEdge pEdge2,
-                                pCvPointFloat  pPoint,
-                                float &Radius)
-{
-    int i, IntersectionNumber = 1;
-    if(((pEdge1->node1 == pEdge2->node1 ||
-        pEdge1->node1 == pEdge2->node2) &&
-        pEdge1->node1 != NULL)||
-       ((pEdge1->node2 == pEdge2->node1 ||
-        pEdge1->node2 == pEdge2->node2) &&
-        pEdge1->node2 != NULL))
-        IntersectionNumber = 2;
-
-    float* Parabola = pEdge1->parabola->map;
-    pCvPointFloat pParPoint1;
-    if(pEdge1->node1!=NULL)
-        pParPoint1 = &(pEdge1->node1->node);
-    else
-        pParPoint1 = &(pEdge1->node2->node);
-
-    pCvPointFloat pRayPoint1;
-    if(pEdge2->node1==NULL)
-        pRayPoint1 = &(pEdge2->node2->node);
-    else
-        pRayPoint1 = &(pEdge2->node1->node);
-    pCvDirection pDirection = pEdge2->direction;
-
-
-    float InversParabola[6]={0,0,0,0,0,0};
-    _cvCalcOrtogInverse(InversParabola, Parabola);
-
-    CvPointFloat  Point = {0,0},ParPoint1_img,RayPoint1_img;
-    CvDirection Direction_img;
-    _cvCalcVectorImage(&Direction_img,pDirection, InversParabola);
-    _cvCalcPointImage(&RayPoint1_img, pRayPoint1, InversParabola);
-
-
-    float q = RayPoint1_img.y - pEdge1->parabola->a*RayPoint1_img.x*RayPoint1_img.x;
-    if((pEdge2->site->node1 == pEdge2->site->node2 && q < 0) ||
-        (pEdge2->site->node1 != pEdge2->site->node2 && q > 0))
-        return -1;
-
-    float c2 = pEdge1->parabola->a*Direction_img.x;
-    float c1 = -Direction_img.y;
-    float c0 = Direction_img.y* RayPoint1_img.x - Direction_img.x*RayPoint1_img.y;
-    float X[2];
-    int N = _cvSolveEqu2thR(c2,c1,c0,X);
-    if(N==0)
-        return -1;
-
-    _cvCalcPointImage(&ParPoint1_img, pParPoint1, InversParabola);
-    int sign_x = SIGN(Direction_img.x);
-    int sign_y = SIGN(Direction_img.y);
-    float pr;
-
-    if(N==2 && IntersectionNumber == 2)
-        _cvSwap(X[0], X[1]);
-
-    for( i=0;i<N;i++)
-    {
-        if(X[i]<=ParPoint1_img.x - LEE_CONST_ACCEPTABLE_ERROR)
-            continue;
-        pr = (X[i]-RayPoint1_img.x)*sign_x +
-                        (pEdge1->parabola->a*X[i]*X[i]-RayPoint1_img.y)*sign_y;
-        if(pr <= -LEE_CONST_ACCEPTABLE_ERROR)
-            continue;
-        else
-        {
-            Point.x = X[i];
-            break;
-        }
-    }
-
-    if(i==N)
-        return -1;
-
-    Point.y = pEdge1->parabola->a*Point.x*Point.x;
-    Radius = Point.y + 1.f/(4*pEdge1->parabola->a);
-    _cvCalcPointImage(pPoint,&Point,Parabola);
-    float dist = Point.x - ParPoint1_img.x;
-    if(IntersectionNumber == 2 && dist < LEE_CONST_DIFF_POINTS)
-        return -1;
-    else
-        return dist;
-}// end of _cvPar_OpenLineIntersection
-
-static
-float _cvPar_CloseLineIntersection(pCvVoronoiEdge pEdge1,
-                                    pCvVoronoiEdge pEdge2,
-                                    pCvPointFloat  pPoint,
-                                    float &Radius)
-{
-    int i, IntersectionNumber = 1;
-    if(((pEdge1->node1 == pEdge2->node1 ||
-        pEdge1->node1 == pEdge2->node2) &&
-        pEdge1->node1 != NULL)||
-       ((pEdge1->node2 == pEdge2->node1 ||
-        pEdge1->node2 == pEdge2->node2) &&
-        pEdge1->node2 != NULL))
-        IntersectionNumber = 2;
-
-    float* Parabola = pEdge1->parabola->map;
-    pCvPointFloat pParPoint1;
-    if(pEdge1->node1!=NULL)
-        pParPoint1 = &(pEdge1->node1->node);
-    else
-        pParPoint1 = &(pEdge1->node2->node);
-
-    pCvPointFloat pRayPoint1,pRayPoint2;
-    pRayPoint2 = &(pEdge2->node1->node);
-    pRayPoint1 = &(pEdge2->node2->node);
-
-    pCvDirection pDirection = pEdge2->direction;
-    float InversParabola[6]={0,0,0,0,0,0};
-    _cvCalcOrtogInverse(InversParabola, Parabola);
-
-    CvPointFloat  Point={0,0},ParPoint1_img,RayPoint1_img,RayPoint2_img;
-    CvDirection Direction_img;
-    _cvCalcPointImage(&RayPoint1_img, pRayPoint1, InversParabola);
-    _cvCalcPointImage(&RayPoint2_img, pRayPoint2, InversParabola);
-
-    float q;
-    if(Radius == -1)
-    {
-         q = RayPoint1_img.y - pEdge1->parabola->a*RayPoint1_img.x*RayPoint1_img.x;
-         if((pEdge2->site->node1 == pEdge2->site->node2 && q < 0) ||
-            (pEdge2->site->node1 != pEdge2->site->node2 && q > 0))
-                return -1;
-    }
-    if(Radius == -2)
-    {
-         q = RayPoint2_img.y - pEdge1->parabola->a*RayPoint2_img.x*RayPoint2_img.x;
-        if((pEdge2->site->node1 == pEdge2->site->node2 && q < 0) ||
-            (pEdge2->site->node1 != pEdge2->site->node2 && q > 0))
-                return -1;
-    }
-
-    _cvCalcPointImage(&ParPoint1_img, pParPoint1, InversParabola);
-    _cvCalcVectorImage(&Direction_img,pDirection, InversParabola);
-
-    float c2 = pEdge1->parabola->a*Direction_img.x;
-    float c1 = -Direction_img.y;
-    float c0 = Direction_img.y* RayPoint1_img.x - Direction_img.x*RayPoint1_img.y;
-    float X[2];
-    int N = _cvSolveEqu2thR(c2,c1,c0,X);
-    if(N==0)
-        return -1;
-    int sign_x = SIGN(RayPoint2_img.x - RayPoint1_img.x);
-    int sign_y = SIGN(RayPoint2_img.y - RayPoint1_img.y);
-    float pr_dir = (RayPoint2_img.x - RayPoint1_img.x)*sign_x +
-                   (RayPoint2_img.y - RayPoint1_img.y)*sign_y;
-    float pr;
-
-    if(N==2 && IntersectionNumber == 2)
-        _cvSwap(X[0], X[1]);
-
-    for( i =0;i<N;i++)
-    {
-        if(X[i] <= ParPoint1_img.x - LEE_CONST_ACCEPTABLE_ERROR)
-            continue;
-        pr = (X[i]-RayPoint1_img.x)*sign_x + \
-             (pEdge1->parabola->a*X[i]*X[i]-RayPoint1_img.y)*sign_y;
-        if(pr <= -LEE_CONST_ACCEPTABLE_ERROR || pr>=pr_dir + LEE_CONST_ACCEPTABLE_ERROR)
-            continue;
-        else
-        {
-            Point.x = X[i];
-            break;
-        }
-    }
-
-    if(i==N)
-        return -1;
-
-    Point.y = pEdge1->parabola->a*Point.x*Point.x;
-    Radius = Point.y + 1.f/(4*pEdge1->parabola->a);
-    _cvCalcPointImage(pPoint,&Point,Parabola);
-    float dist = Point.x - ParPoint1_img.x;
-    if(IntersectionNumber == 2 && dist < LEE_CONST_DIFF_POINTS)
-        return -1;
-    else
-        return dist;
-}// end of _cvPar_CloseLineIntersection
-
-static
-float _cvPar_ParIntersection(pCvVoronoiEdge pEdge1,
-                            pCvVoronoiEdge pEdge2,
-                            pCvPointFloat  pPoint,
-                            float &Radius)
-{
-    if(pEdge2->node1==NULL||pEdge2->node2==NULL)
-        return _cvPar_OpenParIntersection(pEdge1,pEdge2,pPoint,Radius);
-    return _cvPar_CloseParIntersection(pEdge1,pEdge2,pPoint,Radius);
-}// end of _cvPar_ParIntersection
-
-static
-float _cvPar_OpenParIntersection(pCvVoronoiEdge pEdge1,
-                            pCvVoronoiEdge pEdge2,
-                            pCvPointFloat  pPoint,
-                            float &Radius)
-{
-    int i, IntersectionNumber = 1;
-    if(((pEdge1->node1 == pEdge2->node1 ||
-        pEdge1->node1 == pEdge2->node2) &&
-        pEdge1->node1 != NULL)||
-       ((pEdge1->node2 == pEdge2->node1 ||
-        pEdge1->node2 == pEdge2->node2) &&
-        pEdge1->node2 != NULL))
-        IntersectionNumber = 2;
-
-    float* Parabola1 = pEdge1->parabola->map;
-    pCvPointFloat pPar1Point1;
-    if(pEdge1->node1!=NULL)
-        pPar1Point1 = &(pEdge1->node1->node);
-    else
-        pPar1Point1 = &(pEdge1->node2->node);
-
-    float* Parabola2 = pEdge2->parabola->map;
-    pCvPointFloat pPar2Point1;
-    if(pEdge2->node1!=NULL)
-        pPar2Point1 = &(pEdge2->node1->node);
-    else
-        pPar2Point1 = &(pEdge2->node2->node);
-
-    CvPointFloat Point;
-    CvDirection Direction;
-    if(pEdge1->parabola->directrice==pEdge2->parabola->directrice)  //common site is segment -> different focuses
-    {
-        pCvPointFloat pFocus1 = &(pEdge1->parabola->focus->node);
-        pCvPointFloat pFocus2 = &(pEdge2->parabola->focus->node);
-
-        Point.x = (pFocus1->x + pFocus2->x)/2;
-        Point.y = (pFocus1->y + pFocus2->y)/2;
-        Direction.x = pFocus1->y - pFocus2->y;
-        Direction.y = pFocus2->x - pFocus1->x;
-    }
-    else//common site is focus -> different directrices
-    {
-        pCvVoronoiSite pDirectrice1 = pEdge1->parabola->directrice;
-        pCvPointFloat pPoint1 = &(pDirectrice1->node1->node);
-        pCvDirection pVector21 = pDirectrice1->direction;
-
-        pCvVoronoiSite pDirectrice2 = pEdge2->parabola->directrice;
-        pCvPointFloat pPoint3 = &(pDirectrice2->node1->node);
-        pCvDirection pVector43 = pDirectrice2->direction;
-
-        Direction.x = pVector43->x - pVector21->x;
-        Direction.y = pVector43->y - pVector21->y;
-
-        if((fabs(Direction.x) < LEE_CONST_ZERO) &&
-           (fabs(Direction.y) < LEE_CONST_ZERO))
-                Direction = *pVector43;
-
-        float det = pVector21->y * pVector43->x - pVector21->x * pVector43->y;
-        if(fabs(det) < LEE_CONST_ZERO)
-        {
-            Point.x = (pPoint1->x + pPoint3->x)/2;
-            Point.y = (pPoint1->y + pPoint3->y)/2;
-        }
-        else
-        {
-            float d1 = pVector21->y*pPoint1->x - pVector21->x*pPoint1->y;
-            float d2 = pVector43->y*pPoint3->x - pVector43->x*pPoint3->y;
-            Point.x = (float)((pVector43->x*d1 - pVector21->x*d2)/det);
-            Point.y = (float)((pVector43->y*d1 - pVector21->y*d2)/det);
-        }
-    }
-
-    float InversParabola2[6]={0,0,0,0,0,0};
-    _cvCalcOrtogInverse(InversParabola2, Parabola2);
-
-    CvPointFloat  Par2Point1_img,Point_img;
-    CvDirection Direction_img;
-    _cvCalcVectorImage(&Direction_img,&Direction, InversParabola2);
-    _cvCalcPointImage(&Point_img, &Point, InversParabola2);
-
-    float a1 = pEdge1->parabola->a;
-    float a2 = pEdge2->parabola->a;
-    float c2 = a2*Direction_img.x;
-    float c1 = -Direction_img.y;
-    float c0 = Direction_img.y* Point_img.x - Direction_img.x*Point_img.y;
-    float X[2];
-    int N = _cvSolveEqu2thR(c2,c1,c0,X);
-
-    if(N==0)
-        return -1;
-
-    _cvCalcPointImage(&Par2Point1_img, pPar2Point1, InversParabola2);
-
-    if(X[N-1]<Par2Point1_img.x)
-        return -1;
-
-    if(X[0]<Par2Point1_img.x)
-    {
-        X[0] = X[1];
-        N=1;
-    }
-
-    float InversParabola1[6]={0,0,0,0,0,0};
-    CvPointFloat Par1Point1_img;
-    _cvCalcOrtogInverse(InversParabola1, Parabola1);
-    _cvCalcPointImage(&Par1Point1_img, pPar1Point1, InversParabola1);
-    float InvPar1_Par2[6];
-    _cvCalcComposition(InvPar1_Par2,InversParabola1,Parabola2);
-    for(i=0;i<N;i++)
-        X[i] = (InvPar1_Par2[1]*a2*X[i] + InvPar1_Par2[0])*X[i] +  InvPar1_Par2[2];
-
-    if(N!=1)
-    {
-        if((X[0]>X[1] && IntersectionNumber == 1)||
-            (X[0]<X[1] && IntersectionNumber == 2))
-            _cvSwap(X[0], X[1]);
-    }
-
-    for(i = 0;i<N;i++)
-    {
-        Point.x = X[i];
-        Point.y = a1*Point.x*Point.x;
-        if(Point.x < Par1Point1_img.x - LEE_CONST_ACCEPTABLE_ERROR)
-            continue;
-        else
-            break;
-    }
-
-    if(i==N)
-        return -1;
-
-    Radius = Point.y + 1.f/(4*pEdge1->parabola->a);
-    _cvCalcPointImage(pPoint,&Point,Parabola1);
-    float dist = Point.x - Par1Point1_img.x;
-    if(IntersectionNumber == 2 && dist < LEE_CONST_DIFF_POINTS)
-        return -1;
-    else
-        return dist;
-}// end of _cvPar_OpenParIntersection
-
-static
-float _cvPar_CloseParIntersection(pCvVoronoiEdge pEdge1,
-                                  pCvVoronoiEdge pEdge2,
-                                  pCvPointFloat  pPoint,
-                                  float &Radius)
-{
-    int i, IntersectionNumber = 1;
-    if(((pEdge1->node1 == pEdge2->node1 ||
-        pEdge1->node1 == pEdge2->node2) &&
-        pEdge1->node1 != NULL)||
-       ((pEdge1->node2 == pEdge2->node1 ||
-        pEdge1->node2 == pEdge2->node2) &&
-        pEdge1->node2 != NULL))
-        IntersectionNumber = 2;
-
-    float* Parabola1 = pEdge1->parabola->map;
-    float* Parabola2 = pEdge2->parabola->map;
-    pCvPointFloat pPar1Point1;
-    if(pEdge1->node1!=NULL)
-        pPar1Point1 = &(pEdge1->node1->node);
-    else
-        pPar1Point1 = &(pEdge1->node2->node);
-
-    pCvPointFloat pPar2Point1 = &(pEdge2->node1->node);
-    pCvPointFloat pPar2Point2 = &(pEdge2->node2->node);
-
-    CvPointFloat Point;
-    CvDirection Direction;
-    if(pEdge1->parabola->directrice==pEdge2->parabola->directrice)  //common site is segment -> different focuses
-    {
-        pCvPointFloat pFocus1 = &(pEdge1->parabola->focus->node);
-        pCvPointFloat pFocus2 = &(pEdge2->parabola->focus->node);
-
-        Point.x = (pFocus1->x + pFocus2->x)/2;
-        Point.y = (pFocus1->y + pFocus2->y)/2;
-        Direction.x = pFocus1->y - pFocus2->y;
-        Direction.y = pFocus2->x - pFocus1->x;
-    }
-    else//common site is focus -> different directrices
-    {
-        pCvVoronoiSite pDirectrice1 = pEdge1->parabola->directrice;
-        pCvPointFloat pPoint1 = &(pDirectrice1->node1->node);
-        pCvDirection pVector21 = pDirectrice1->direction;
-
-        pCvVoronoiSite pDirectrice2 = pEdge2->parabola->directrice;
-        pCvPointFloat pPoint3 = &(pDirectrice2->node1->node);
-        pCvDirection pVector43 = pDirectrice2->direction;
-
-        Direction.x = pVector43->x - pVector21->x;
-        Direction.y = pVector43->y - pVector21->y;
-
-        if((fabs(Direction.x) < LEE_CONST_ZERO) &&
-           (fabs(Direction.y) < LEE_CONST_ZERO))
-                Direction = *pVector43;
-
-        float det = pVector21->y * pVector43->x - pVector21->x * pVector43->y;
-        if(fabs(det) < LEE_CONST_ZERO)
-        {
-            Point.x = (pPoint1->x + pPoint3->x)/2;
-            Point.y = (pPoint1->y + pPoint3->y)/2;
-        }
-        else
-        {
-            float d1 = pVector21->y*pPoint1->x - pVector21->x*pPoint1->y;
-            float d2 = pVector43->y*pPoint3->x - pVector43->x*pPoint3->y;
-            Point.x = (float)((pVector43->x*d1 - pVector21->x*d2)/det);
-            Point.y = (float)((pVector43->y*d1 - pVector21->y*d2)/det);
-        }
-    }
-
-
-
-    float InversParabola2[6]={0,0,0,0,0,0};
-    _cvCalcOrtogInverse(InversParabola2, Parabola2);
-
-    CvPointFloat  Par2Point1_img,Par2Point2_img,Point_img;
-    CvDirection Direction_img;
-    _cvCalcVectorImage(&Direction_img,&Direction, InversParabola2);
-    _cvCalcPointImage(&Point_img, &Point, InversParabola2);
-
-    float a1 = pEdge1->parabola->a;
-    float a2 = pEdge2->parabola->a;
-    float c2 = a2*Direction_img.x;
-    float c1 = -Direction_img.y;
-    float c0 = Direction_img.y* Point_img.x - Direction_img.x*Point_img.y;
-    float X[2];
-    int N = _cvSolveEqu2thR(c2,c1,c0,X);
-
-    if(N==0)
-        return -1;
-
-    _cvCalcPointImage(&Par2Point1_img, pPar2Point1, InversParabola2);
-    _cvCalcPointImage(&Par2Point2_img, pPar2Point2, InversParabola2);
-    if(Par2Point1_img.x>Par2Point2_img.x)
-        _cvSwap(Par2Point1_img,Par2Point2_img);
-
-    if(X[0]>Par2Point2_img.x||X[N-1]<Par2Point1_img.x)
-        return -1;
-
-    if(X[0]<Par2Point1_img.x)
-    {
-        if(X[1]<Par2Point2_img.x)
-        {
-            X[0] = X[1];
-            N=1;
-        }
-        else
-            return -1;
-    }
-    else if(X[N-1]>Par2Point2_img.x)
-            N=1;
-
-    float InversParabola1[6]={0,0,0,0,0,0};
-    CvPointFloat Par1Point1_img;
-    _cvCalcOrtogInverse(InversParabola1, Parabola1);
-    _cvCalcPointImage(&Par1Point1_img, pPar1Point1, InversParabola1);
-    float InvPar1_Par2[6];
-    _cvCalcComposition(InvPar1_Par2,InversParabola1,Parabola2);
-    for(i=0;i<N;i++)
-        X[i] = (InvPar1_Par2[1]*a2*X[i] + InvPar1_Par2[0])*X[i] +  InvPar1_Par2[2];
-
-    if(N!=1)
-    {
-        if((X[0]>X[1] && IntersectionNumber == 1)||
-            (X[0]<X[1] && IntersectionNumber == 2))
-            _cvSwap(X[0], X[1]);
-    }
-
-
-    for(i = 0;i<N;i++)
-    {
-        Point.x = (float)X[i];
-        Point.y = (float)a1*Point.x*Point.x;
-        if(Point.x < Par1Point1_img.x - LEE_CONST_ACCEPTABLE_ERROR)
-            continue;
-        else
-            break;
-    }
-
-    if(i==N)
-        return -1;
-
-    Radius = Point.y + 1.f/(4*a1);
-    _cvCalcPointImage(pPoint,&Point,Parabola1);
-    float dist = Point.x - Par1Point1_img.x;
-    if(IntersectionNumber == 2 && dist < LEE_CONST_DIFF_POINTS)
-        return -1;
-    else
-        return dist;
-}// end of _cvPar_CloseParIntersection
-
-/* ///////////////////////////////////////////////////////////////////////////////////////
-//                           Subsidiary functions                                       //
-/////////////////////////////////////////////////////////////////////////////////////// */
-
-CV_INLINE
-void _cvMakeTwinEdge(pCvVoronoiEdge pEdge2,
-                    pCvVoronoiEdge pEdge1)
-{
-    pEdge2->direction = pEdge1->direction;
-    pEdge2->parabola = pEdge1->parabola;
-    pEdge2->node1 = pEdge1->node2;
-    pEdge2->twin_edge = pEdge1;
-    pEdge1->twin_edge = pEdge2;
-}//end of _cvMakeTwinEdge
-
-CV_INLINE
-void _cvStickEdgeLeftBegin(pCvVoronoiEdge pEdge,
-                          pCvVoronoiEdge pEdge_left_prev,
-                          pCvVoronoiSite pSite_left)
-{
-    pEdge->prev_edge = pEdge_left_prev;
-    pEdge->site = pSite_left;
-    if(pEdge_left_prev == NULL)
-        pSite_left->edge2 = pEdge;
-    else
-    {
-        pEdge_left_prev->node2 = pEdge->node1;
-        pEdge_left_prev->next_edge = pEdge;
-    }
-}//end of _cvStickEdgeLeftBegin
-
-CV_INLINE
-void _cvStickEdgeRightBegin(pCvVoronoiEdge pEdge,
-                          pCvVoronoiEdge pEdge_right_next,
-                          pCvVoronoiSite pSite_right)
-{
-    pEdge->next_edge = pEdge_right_next;
-    pEdge->site = pSite_right;
-    if(pEdge_right_next == NULL)
-        pSite_right->edge1 = pEdge;
-    else
-    {
-        pEdge_right_next->node1 = pEdge->node2;
-        pEdge_right_next->prev_edge = pEdge;
-    }
-}// end of _cvStickEdgeRightBegin
-
-CV_INLINE
-void _cvStickEdgeLeftEnd(pCvVoronoiEdge pEdge,
-                        pCvVoronoiEdge pEdge_left_next,
-                        pCvVoronoiSite pSite_left)
-{
-    pEdge->next_edge = pEdge_left_next;
-    if(pEdge_left_next == NULL)
-        pSite_left->edge1 = pEdge;
-    else
-    {
-        pEdge_left_next->node1 = pEdge->node2;
-        pEdge_left_next->prev_edge = pEdge;
-    }
-}//end of _cvStickEdgeLeftEnd
-
-CV_INLINE
-void _cvStickEdgeRightEnd(pCvVoronoiEdge pEdge,
-                         pCvVoronoiEdge pEdge_right_prev,
-                         pCvVoronoiSite pSite_right)
-{
-    pEdge->prev_edge = pEdge_right_prev;
-    if(pEdge_right_prev == NULL)
-        pSite_right->edge2 = pEdge;
-    else
-    {
-        pEdge_right_prev->node2 = pEdge->node1;
-        pEdge_right_prev->next_edge = pEdge;
-    }
-}//end of _cvStickEdgeRightEnd
-
-template <class T> CV_INLINE
-void _cvInitVoronoiNode(pCvVoronoiNode pNode,
-                        T pPoint,
-                        float radius)
-{
-    pNode->node.x = (float)pPoint->x;
-    pNode->node.y = (float)pPoint->y;
-    pNode->radius = radius;
-}//end of _cvInitVoronoiNode
-
-CV_INLINE
-void _cvInitVoronoiSite(pCvVoronoiSite pSite,
-                       pCvVoronoiNode pNode1,
-                       pCvVoronoiNode pNode2,
-                       pCvVoronoiSite pPrev_site)
-{
-    pSite->node1 = pNode1;
-    pSite->node2 = pNode2;
-    pSite->prev_site = pPrev_site;
-}//end of _cvInitVoronoiSite
-
-template <class T> CV_INLINE
-T _cvSeqPush(CvSeq* Seq, T pElem)
-{
-    cvSeqPush(Seq, pElem);
-    return (T)(Seq->ptr - Seq->elem_size);
-//  return (T)cvGetSeqElem(Seq, Seq->total - 1,NULL);
-}//end of _cvSeqPush
-
-template <class T> CV_INLINE
-T _cvSeqPushFront(CvSeq* Seq, T pElem)
-{
-    cvSeqPushFront(Seq,pElem);
-    return (T)Seq->first->data;
-//  return (T)cvGetSeqElem(Seq,0,NULL);
-}//end of _cvSeqPushFront
-
-CV_INLINE
-void _cvTwinNULLLeft(pCvVoronoiEdge pEdge_left_cur,
-                    pCvVoronoiEdge pEdge_left)
-{
-    while(pEdge_left_cur!=pEdge_left)
-    {
-        if(pEdge_left_cur->twin_edge!=NULL)
-            pEdge_left_cur->twin_edge->twin_edge = NULL;
-        pEdge_left_cur = pEdge_left_cur->next_edge;
-    }
-}//end of _cvTwinNULLLeft
-
-CV_INLINE
-void _cvTwinNULLRight(pCvVoronoiEdge pEdge_right_cur,
-                     pCvVoronoiEdge pEdge_right)
-{
-    while(pEdge_right_cur!=pEdge_right)
-    {
-        if(pEdge_right_cur->twin_edge!=NULL)
-            pEdge_right_cur->twin_edge->twin_edge = NULL;
-        pEdge_right_cur = pEdge_right_cur->prev_edge;
-    }
-}//end of _cvTwinNULLRight
-
-CV_INLINE
-void _cvSeqPushInOrder(CvVoronoiDiagramInt* pVoronoiDiagram, pCvVoronoiHole pHole)
-{
-    pHole = _cvSeqPush(pVoronoiDiagram->HoleSeq, pHole);
-    if(pVoronoiDiagram->HoleSeq->total == 1)
-    {
-        pVoronoiDiagram->top_hole = pHole;
-        return;
-    }
-
-    pCvVoronoiHole pTopHole = pVoronoiDiagram->top_hole;
-    pCvVoronoiHole pCurrHole;
-    if(pTopHole->x_coord >= pHole->x_coord)
-    {
-        pHole->next_hole = pTopHole;
-        pVoronoiDiagram->top_hole = pHole;
-        return;
-    }
-
-    for(pCurrHole = pTopHole; \
-        pCurrHole->next_hole != NULL; \
-        pCurrHole = pCurrHole->next_hole)
-        if(pCurrHole->next_hole->x_coord >= pHole->x_coord)
-            break;
-    pHole->next_hole = pCurrHole->next_hole;
-    pCurrHole->next_hole = pHole;
-}//end of _cvSeqPushInOrder
-
-CV_INLINE
-pCvVoronoiEdge _cvDivideRightEdge(pCvVoronoiEdge pEdge,pCvVoronoiNode pNode, CvSeq* EdgeSeq)
-{
-    CvVoronoiEdgeInt Edge1 = *pEdge;
-    CvVoronoiEdgeInt Edge2 = *pEdge->twin_edge;
-    pCvVoronoiEdge pEdge1, pEdge2;
-
-    pEdge1 = _cvSeqPush(EdgeSeq, &Edge1);
-    pEdge2 = _cvSeqPush(EdgeSeq, &Edge2);
-
-    if(pEdge1->next_edge != NULL)
-        pEdge1->next_edge->prev_edge = pEdge1;
-    pEdge1->prev_edge = NULL;
-
-    if(pEdge2->prev_edge != NULL)
-        pEdge2->prev_edge->next_edge = pEdge2;
-    pEdge2->next_edge = NULL;
-
-    pEdge1->node1 = pEdge2->node2= pNode;
-    pEdge1->twin_edge = pEdge2;
-    pEdge2->twin_edge = pEdge1;
-    return pEdge2;
-}//end of _cvDivideRightEdge
-
-CV_INLINE
-pCvVoronoiEdge _cvDivideLeftEdge(pCvVoronoiEdge pEdge,pCvVoronoiNode pNode, CvSeq* EdgeSeq)
-{
-    CvVoronoiEdgeInt Edge1 = *pEdge;
-    CvVoronoiEdgeInt Edge2 = *pEdge->twin_edge;
-    pCvVoronoiEdge pEdge1, pEdge2;
-
-    pEdge1 = _cvSeqPush(EdgeSeq, &Edge1);
-    pEdge2 = _cvSeqPush(EdgeSeq, &Edge2);
-
-    if(pEdge2->next_edge != NULL)
-        pEdge2->next_edge->prev_edge = pEdge2;
-    pEdge2->prev_edge = NULL;
-
-    if(pEdge1->prev_edge != NULL)
-        pEdge1->prev_edge->next_edge = pEdge1;
-    pEdge1->next_edge = NULL;
-
-    pEdge1->node2 = pEdge2->node1= pNode;
-    pEdge1->twin_edge = pEdge2;
-    pEdge2->twin_edge = pEdge1;
-    return pEdge2;
-}//end of _cvDivideLeftEdge
-
-template<class T> CV_INLINE
-T _cvWriteSeqElem(T pElem, CvSeqWriter &writer)
-{
-    if( writer.ptr >= writer.block_max )
-          cvCreateSeqBlock( &writer);
-
-    T ptr = (T)writer.ptr;
-    memcpy(writer.ptr, pElem, sizeof(*pElem));
-    writer.ptr += sizeof(*pElem);
-    return ptr;
-}//end of _cvWriteSeqElem
-
-/* ///////////////////////////////////////////////////////////////////////////////////////
-//                           Mathematical functions                                     //
-/////////////////////////////////////////////////////////////////////////////////////// */
-
-template<class T> CV_INLINE
-void _cvCalcPointImage(pCvPointFloat pImgPoint,pCvPointFloat pPoint,T* A)
-{
-    pImgPoint->x = (float)(A[0]*pPoint->x + A[1]*pPoint->y + A[2]);
-    pImgPoint->y = (float)(A[3]*pPoint->x + A[4]*pPoint->y + A[5]);
-}//end of _cvCalcPointImage
-
-template <class T> CV_INLINE
-void _cvSwap(T &x, T &y)
-{
-    T z; z=x; x=y; y=z;
-}//end of _cvSwap
-
-template <class T> CV_INLINE
-int _cvCalcOrtogInverse(T* B, T* A)
-{
-    int sign_det = SIGN(A[0]*A[4] - A[1]*A[3]);
-
-    if(sign_det)
-    {
-        B[0] =  A[4]*sign_det;
-        B[1] = -A[1]*sign_det;
-        B[3] = -A[3]*sign_det;
-        B[4] =  A[0]*sign_det;
-        B[2] = - (B[0]*A[2]+B[1]*A[5]);
-        B[5] = - (B[3]*A[2]+B[4]*A[5]);
-        return 1;
-    }
-    else
-        return 0;
-}//end of _cvCalcOrtogInverse
-
-template<class T> CV_INLINE
-void _cvCalcVectorImage(pCvDirection pImgVector,pCvDirection pVector,T* A)
-{
-    pImgVector->x = A[0]*pVector->x + A[1]*pVector->y;
-    pImgVector->y = A[3]*pVector->x + A[4]*pVector->y;
-}//end of _cvCalcVectorImage
-
-template <class T> CV_INLINE
-void _cvCalcComposition(T* Result,T* A,T* B)
-{
-    Result[0] = A[0]*B[0] + A[1]*B[3];
-    Result[1] = A[0]*B[1] + A[1]*B[4];
-    Result[3] = A[3]*B[0] + A[4]*B[3];
-    Result[4] = A[3]*B[1] + A[4]*B[4];
-    Result[2] = A[0]*B[2] + A[1]*B[5] + A[2];
-    Result[5] = A[3]*B[2] + A[4]*B[5] + A[5];
-}//end of _cvCalcComposition
-
-CV_INLINE
-float _cvCalcDist(pCvPointFloat pPoint, pCvVoronoiSite pSite)
-{
-    if(pSite->node1==pSite->node2)
-        return _cvPPDist(pPoint,&(pSite->node1->node));
-    else
-        return _cvPLDist(pPoint,&(pSite->node1->node),pSite->direction);
-}//end of _cvCalcComposition
-
-CV_INLINE
-float _cvPPDist(pCvPointFloat pPoint1,pCvPointFloat pPoint2)
-{
-    float delta_x = pPoint1->x - pPoint2->x;
-    float delta_y = pPoint1->y - pPoint2->y;
-    return (float)sqrt((double)delta_x*delta_x + delta_y*delta_y);
-}//end of _cvPPDist
-
-
-CV_INLINE
-float _cvPLDist(pCvPointFloat pPoint,pCvPointFloat pPoint1,pCvDirection pDirection)
-{
-    return (float)fabs(pDirection->x*(pPoint->y - pPoint1->y) -
-                     pDirection->y*(pPoint->x - pPoint1->x));
-}//end of _cvPLDist
-
-template <class T>
-int _cvSolveEqu2thR(T c2, T c1, T c0, T* X)
-{
-    const T eps = (T)1e-6;
-    if(fabs(c2)<eps)
-        return _cvSolveEqu1th(c1,c0,X);
-
-    T Discr = c1*c1 - c2*c0*4;
-    if(Discr<-eps)
-        return 0;
-    Discr = (T)sqrt((double)fabs(Discr));
-
-    if(fabs(Discr)<eps)
-    {
-        X[0] = -c1/(c2*2);
-        if(fabs(X[0])<eps)
-            X[0]=0;
-        return 1;
-    }
-    else
-    {
-        if(c1 >=0)
-        {
-            if(c2>0)
-            {
-                X[0] = (-c1 - Discr)/(2*c2);
-                X[1] = -2*c0/(c1+Discr);
-                return 2;
-            }
-            else
-            {
-                X[1] = (-c1 - Discr)/(2*c2);
-                X[0] = -2*c0/(c1+Discr);
-                return 2;
-            }
-        }
-        else
-        {
-            if(c2>0)
-            {
-                X[1] = (-c1 + Discr)/(2*c2);
-                X[0] = -2*c0/(c1-Discr);
-                return 2;
-            }
-            else
-            {
-                X[0] = (-c1 + Discr)/(2*c2);
-                X[1] = -2*c0/(c1-Discr);
-                return 2;
-            }
-        }
-    }
-}//end of _cvSolveEqu2thR
-
-template <class T> CV_INLINE
-int _cvSolveEqu1th(T c1, T c0, T* X)
-{
-    const T eps = (T)1e-6;
-    if(fabs(c1)<eps)
-        return 0;
-
-    X[0] = -c0/c1;
-    return 1;
-}//end of _cvSolveEqu1th
diff --git a/modules/legacy/src/levmar.cpp b/modules/legacy/src/levmar.cpp
deleted file mode 100644 (file)
index c65ec04..0000000
+++ /dev/null
@@ -1,317 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include <float.h>
-#include <limits.h>
-
-/* Valery Mosyagin */
-
-//#define TRACKLEVMAR
-
-typedef void (*pointer_LMJac)( const CvMat* src, CvMat* dst );
-typedef void (*pointer_LMFunc)( const CvMat* src, CvMat* dst );
-
-#if 0
-/* Optimization using Levenberg-Marquardt */
-void cvLevenbergMarquardtOptimization(pointer_LMJac JacobianFunction,
-                                    pointer_LMFunc function,
-                                    /*pointer_Err error_function,*/
-                                    CvMat *X0,CvMat *observRes,CvMat *resultX,
-                                    int maxIter,double epsilon)
-{
-    /* This is not sparse method */
-    /* Make optimization using  */
-    /* func - function to compute */
-    /* uses function to compute jacobian */
-
-    /* Allocate memory */
-    CvMat *vectX = 0;
-    CvMat *vectNewX = 0;
-    CvMat *resFunc = 0;
-    CvMat *resNewFunc = 0;
-    CvMat *error = 0;
-    CvMat *errorNew = 0;
-    CvMat *Jac = 0;
-    CvMat *delta = 0;
-    CvMat *matrJtJ = 0;
-    CvMat *matrJtJN = 0;
-    CvMat *matrJt = 0;
-    CvMat *vectB = 0;
-
-    CV_FUNCNAME( "cvLevenbegrMarquardtOptimization" );
-    __BEGIN__;
-
-
-    if( JacobianFunction == 0 || function == 0 || X0 == 0 || observRes == 0 || resultX == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(X0) || !CV_IS_MAT(observRes) || !CV_IS_MAT(resultX) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Some of input parameters must be a matrices" );
-    }
-
-
-    int numVal;
-    int numFunc;
-    double valError;
-    double valNewError;
-
-    numVal = X0->rows;
-    numFunc = observRes->rows;
-
-    /* test input data */
-    if( X0->cols != 1 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of colomn of vector X0 must be 1" );
-    }
-
-    if( observRes->cols != 1 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of colomn of vector observed rusult must be 1" );
-    }
-
-    if( resultX->cols != 1 || resultX->rows != numVal )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of result vector X must be equals to X0" );
-    }
-
-    if( maxIter <= 0  )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of maximum iteration must be > 0" );
-    }
-
-    if( epsilon < 0 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Epsilon must be >= 0" );
-    }
-
-    /* copy x0 to current value of x */
-    CV_CALL( vectX      = cvCreateMat(numVal, 1,      CV_64F) );
-    CV_CALL( vectNewX   = cvCreateMat(numVal, 1,      CV_64F) );
-    CV_CALL( resFunc    = cvCreateMat(numFunc,1,      CV_64F) );
-    CV_CALL( resNewFunc = cvCreateMat(numFunc,1,      CV_64F) );
-    CV_CALL( error      = cvCreateMat(numFunc,1,      CV_64F) );
-    CV_CALL( errorNew   = cvCreateMat(numFunc,1,      CV_64F) );
-    CV_CALL( Jac        = cvCreateMat(numFunc,numVal, CV_64F) );
-    CV_CALL( delta      = cvCreateMat(numVal, 1,      CV_64F) );
-    CV_CALL( matrJtJ    = cvCreateMat(numVal, numVal, CV_64F) );
-    CV_CALL( matrJtJN   = cvCreateMat(numVal, numVal, CV_64F) );
-    CV_CALL( matrJt     = cvCreateMat(numVal, numFunc,CV_64F) );
-    CV_CALL( vectB      = cvCreateMat(numVal, 1,      CV_64F) );
-
-    cvCopy(X0,vectX);
-
-    /* ========== Main optimization loop ============ */
-    double change;
-    int currIter;
-    double alpha;
-
-    change = 1;
-    currIter = 0;
-    alpha = 0.001;
-
-    do {
-
-        /* Compute value of function */
-        function(vectX,resFunc);
-        /* Print result of function to file */
-
-        /* Compute error */
-        cvSub(observRes,resFunc,error);
-
-        //valError = error_function(observRes,resFunc);
-        /* Need to use new version of computing error (norm) */
-        valError = cvNorm(observRes,resFunc);
-
-        /* Compute Jacobian for given point vectX */
-        JacobianFunction(vectX,Jac);
-
-        /* Define optimal delta for J'*J*delta=J'*error */
-        /* compute J'J */
-        cvMulTransposed(Jac,matrJtJ,1);
-
-        cvCopy(matrJtJ,matrJtJN);
-
-        /* compute J'*error */
-        cvTranspose(Jac,matrJt);
-        cvmMul(matrJt,error,vectB);
-
-
-        /* Solve normal equation for given alpha and Jacobian */
-        do
-        {
-            /* Increase diagonal elements by alpha */
-            for( int i = 0; i < numVal; i++ )
-            {
-                double val;
-                val = cvmGet(matrJtJ,i,i);
-                cvmSet(matrJtJN,i,i,(1+alpha)*val);
-            }
-
-            /* Solve system to define delta */
-            cvSolve(matrJtJN,vectB,delta,CV_SVD);
-
-            /* We know delta and we can define new value of vector X */
-            cvAdd(vectX,delta,vectNewX);
-
-            /* Compute result of function for new vector X */
-            function(vectNewX,resNewFunc);
-            cvSub(observRes,resNewFunc,errorNew);
-
-            valNewError = cvNorm(observRes,resNewFunc);
-
-            currIter++;
-
-            if( valNewError < valError )
-            {/* accept new value */
-                valError = valNewError;
-
-                /* Compute relative change of required parameter vectorX. change = norm(curr-prev) / norm(curr) )  */
-                change = cvNorm(vectX, vectNewX, CV_RELATIVE_L2);
-
-                alpha /= 10;
-                cvCopy(vectNewX,vectX);
-                break;
-            }
-            else
-            {
-                alpha *= 10;
-            }
-
-        } while ( currIter < maxIter  );
-        /* new value of X and alpha were accepted */
-
-    } while ( change > epsilon && currIter < maxIter );
-
-
-    /* result was computed */
-    cvCopy(vectX,resultX);
-
-    __END__;
-
-    cvReleaseMat(&vectX);
-    cvReleaseMat(&vectNewX);
-    cvReleaseMat(&resFunc);
-    cvReleaseMat(&resNewFunc);
-    cvReleaseMat(&error);
-    cvReleaseMat(&errorNew);
-    cvReleaseMat(&Jac);
-    cvReleaseMat(&delta);
-    cvReleaseMat(&matrJtJ);
-    cvReleaseMat(&matrJtJN);
-    cvReleaseMat(&matrJt);
-    cvReleaseMat(&vectB);
-
-    return;
-}
-#endif
-
-/*------------------------------------------------------------------------------*/
-#if 0
-//tests
-void Jac_Func2(CvMat *vectX,CvMat *Jac)
-{
-    double x = cvmGet(vectX,0,0);
-    double y = cvmGet(vectX,1,0);
-    cvmSet(Jac,0,0,2*(x-2));
-    cvmSet(Jac,0,1,2*(y+3));
-
-    cvmSet(Jac,1,0,1);
-    cvmSet(Jac,1,1,1);
-    return;
-}
-
-void Res_Func2(CvMat *vectX,CvMat *res)
-{
-    double x = cvmGet(vectX,0,0);
-    double y = cvmGet(vectX,1,0);
-    cvmSet(res,0,0,(x-2)*(x-2)+(y+3)*(y+3));
-    cvmSet(res,1,0,x+y);
-
-    return;
-}
-
-
-double Err_Func2(CvMat *obs,CvMat *res)
-{
-    CvMat *tmp;
-    tmp = cvCreateMat(obs->rows,1,CV_64F);
-    cvSub(obs,res,tmp);
-
-    double e;
-    e = cvNorm(tmp);
-
-    return e;
-}
-
-
-void TestOptimX2Y2()
-{
-    CvMat vectX0;
-    double vectX0_dat[2];
-    vectX0 = cvMat(2,1,CV_64F,vectX0_dat);
-    vectX0_dat[0] = 5;
-    vectX0_dat[1] = -7;
-
-    CvMat observRes;
-    double observRes_dat[2];
-    observRes = cvMat(2,1,CV_64F,observRes_dat);
-    observRes_dat[0] = 0;
-    observRes_dat[1] = -1;
-    observRes_dat[0] = 0;
-    observRes_dat[1] = -1.2;
-
-    CvMat optimX;
-    double optimX_dat[2];
-    optimX = cvMat(2,1,CV_64F,optimX_dat);
-
-
-    LevenbegrMarquardtOptimization( Jac_Func2, Res_Func2, Err_Func2,
-                                    &vectX0,&observRes,&optimX,100,0.000001);
-
-    return;
-
-}
-
-#endif
diff --git a/modules/legacy/src/levmarprojbandle.cpp b/modules/legacy/src/levmarprojbandle.cpp
deleted file mode 100644 (file)
index 545a96e..0000000
+++ /dev/null
@@ -1,1779 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-
-#include "precomp.hpp"
-#include <float.h>
-#include <limits.h>
-#include <stdio.h>
-
-void icvReconstructPoints4DStatus(CvMat** projPoints, CvMat **projMatrs, CvMat** presPoints, CvMat *points4D,int numImages,CvMat **projError=0);
-
-/* Valery Mosyagin */
-
-/* If you want to save internal debug info to files uncomment next lines and set paths to files if need */
-/* Note these file may be very large */
-/*
-#define TRACK_BUNDLE
-#define TRACK_BUNDLE_FILE            "d:\\test\\bundle.txt"
-#define TRACK_BUNDLE_FILE_JAC        "d:\\test\\bundle.txt"
-#define TRACK_BUNDLE_FILE_JACERRPROJ "d:\\test\\JacErrProj.txt"
-#define TRACK_BUNDLE_FILE_JACERRPNT  "d:\\test\\JacErrPoint.txt"
-#define TRACK_BUNDLE_FILE_MATRW      "d:\\test\\matrWt.txt"
-#define TRACK_BUNDLE_FILE_DELTAP     "d:\\test\\deltaP.txt"
-*/
-#define TRACK_BUNDLE_FILE            "d:\\test\\bundle.txt"
-
-void cvOptimizeLevenbergMarquardtBundle( CvMat** projMatrs, CvMat** observProjPoints,
-                                       CvMat** pointsPres, int numImages,
-                                       CvMat** resultProjMatrs, CvMat* resultPoints4D,int maxIter,double epsilon );
-
-
-/* ============== Bundle adjustment optimization ================= */
-static void icvComputeDerivateProj(CvMat *points4D,CvMat *projMatr, CvMat *status, CvMat *derivProj)
-{
-    /* Compute derivate for given projection matrix points and status of points */
-
-    CV_FUNCNAME( "icvComputeDerivateProj" );
-    __BEGIN__;
-
-
-    /* ----- Test input params for errors ----- */
-    if( points4D == 0 || projMatr == 0 || status == 0 || derivProj == 0)
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(points4D) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "points4D must be a matrix 4xN" );
-    }
-
-    /* Compute number of points */
-    int numPoints;
-    numPoints = points4D->cols;
-
-    if( numPoints < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points4D must be more than zero" );
-    }
-
-    if( points4D->rows != 4 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of coordinates of points4D must be 4" );
-    }
-
-    if( !CV_IS_MAT(projMatr) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "projMatr must be a matrix 3x4" );
-    }
-
-    if( projMatr->rows != 3 || projMatr->cols != 4 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Size of projection matrix (projMatr) must be 3x4" );
-    }
-
-    if( !CV_IS_MAT(status) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Status must be a matrix 1xN" );
-    }
-
-    if( status->rows != 1 || status->cols != numPoints )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Size of status of points must be 1xN" );
-    }
-
-    if( !CV_IS_MAT(derivProj) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "derivProj must be a matrix VisN x 12" );
-    }
-
-    if( derivProj->cols != 12 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "derivProj must be a matrix VisN x 12" );
-    }
-    /* ----- End test ----- */
-
-    /* Allocate memory for derivates */
-
-    double p[12];
-    /* Copy projection matrix */
-    for(int i = 0; i < 12; i++ )
-    {
-        p[i] = cvmGet(projMatr,i/4,i%4);
-    }
-
-    /* Fill deriv matrix */
-    int currVisPoint;
-    int currPoint;
-
-    currVisPoint = 0;
-    for( currPoint = 0; currPoint < numPoints; currPoint++ )
-    {
-        if( cvmGet(status,0,currPoint) > 0 )
-        {
-            double X[4];
-            X[0] = cvmGet(points4D,0,currVisPoint);
-            X[1] = cvmGet(points4D,1,currVisPoint);
-            X[2] = cvmGet(points4D,2,currVisPoint);
-            X[3] = cvmGet(points4D,3,currVisPoint);
-
-            /* Compute derivate for this point */
-
-            double piX[3];
-            piX[0] = X[0]*p[0] + X[1]*p[1] + X[2]*p[2]  + X[3]*p[3];
-            piX[1] = X[0]*p[4] + X[1]*p[5] + X[2]*p[6]  + X[3]*p[7];
-            piX[2] = X[0]*p[8] + X[1]*p[9] + X[2]*p[10] + X[3]*p[11];
-
-            /* fill derivate by point */
-
-            double tmp3 = 1/(piX[2]*piX[2]);
-
-            double tmp1 = -piX[0]*tmp3;
-            double tmp2 = -piX[1]*tmp3;
-
-            /* fill derivate by projection matrix */
-            for(int i = 0; i < 4; i++ )
-            {
-                /* derivate for x */
-                cvmSet(derivProj,currVisPoint*2,i,X[i]/piX[2]);//x' p1i
-                cvmSet(derivProj,currVisPoint*2,4+i,0);//x' p1i
-                cvmSet(derivProj,currVisPoint*2,8+i,X[i]*tmp1);//x' p3i
-
-                /* derivate for y */
-                cvmSet(derivProj,currVisPoint*2+1,i,0);//y' p2i
-                cvmSet(derivProj,currVisPoint*2+1,4+i,X[i]/piX[2]);//y' p2i
-                cvmSet(derivProj,currVisPoint*2+1,8+i,X[i]*tmp2);//y' p3i
-            }
-
-            currVisPoint++;
-        }
-    }
-
-    if( derivProj->rows != currVisPoint * 2 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "derivProj must be a matrix 2VisN x 12" );
-    }
-
-
-    __END__;
-    return;
-}
-/*======================================================================================*/
-
-static void icvComputeDerivateProjAll(CvMat *points4D, CvMat **projMatrs, CvMat **pointPres, int numImages,CvMat **projDerives)
-{
-    CV_FUNCNAME( "icvComputeDerivateProjAll" );
-    __BEGIN__;
-
-    /* ----- Test input params for errors ----- */
-    if( numImages < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of images must more than zero" );
-    }
-    if( projMatrs == 0 || pointPres == 0 || projDerives == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-    /* ----- End test ----- */
-
-    int currImage;
-    for( currImage = 0; currImage < numImages; currImage++ )
-    {
-        icvComputeDerivateProj(points4D,projMatrs[currImage], pointPres[currImage], projDerives[currImage]);
-    }
-
-    __END__;
-    return;
-}
-/*======================================================================================*/
-
-static void icvComputeDerivatePoints(CvMat *points4D,CvMat *projMatr, CvMat *presPoints, CvMat *derivPoint)
-{
-
-    CV_FUNCNAME( "icvComputeDerivatePoints" );
-    __BEGIN__;
-
-    /* ----- Test input params for errors ----- */
-    if( points4D == 0 || projMatr == 0 || presPoints == 0 || derivPoint == 0)
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(points4D) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "points4D must be a matrix N x 4" );
-    }
-
-    int numPoints;
-    numPoints = presPoints->cols;
-
-    if( numPoints < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points must be more than zero" );
-    }
-
-    if( points4D->rows != 4 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "points4D must be a matrix N x 4" );
-    }
-
-    if( !CV_IS_MAT(projMatr) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "projMatr must be a matrix 3x4" );
-    }
-
-    if( projMatr->rows != 3 || projMatr->cols != 4 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Size of projection matrix (projMatr) must be 3x4" );
-    }
-
-    if( !CV_IS_MAT(presPoints) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Status must be a matrix 1xN" );
-    }
-
-    if( presPoints->rows != 1 || presPoints->cols != numPoints )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Size of presPoints status must be 1xN" );
-    }
-
-    if( !CV_IS_MAT(derivPoint) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "derivPoint must be a matrix 2 x 4VisNum" );
-    }
-    /* ----- End test ----- */
-
-    /* Compute derivates by points */
-
-    double p[12];
-    for(int i = 0; i < 12; i++ )
-    {
-        p[i] = cvmGet(projMatr,i/4,i%4);
-    }
-
-    int currVisPoint;
-    int currProjPoint;
-
-    currVisPoint = 0;
-    for( currProjPoint = 0; currProjPoint < numPoints; currProjPoint++ )
-    {
-        if( cvmGet(presPoints,0,currProjPoint) > 0 )
-        {
-            double X[4];
-            X[0] = cvmGet(points4D,0,currProjPoint);
-            X[1] = cvmGet(points4D,1,currProjPoint);
-            X[2] = cvmGet(points4D,2,currProjPoint);
-            X[3] = cvmGet(points4D,3,currProjPoint);
-
-            double piX[3];
-            piX[0] = X[0]*p[0] + X[1]*p[1] + X[2]*p[2]  + X[3]*p[3];
-            piX[1] = X[0]*p[4] + X[1]*p[5] + X[2]*p[6]  + X[3]*p[7];
-            piX[2] = X[0]*p[8] + X[1]*p[9] + X[2]*p[10] + X[3]*p[11];
-
-            double tmp3 = 1/(piX[2]*piX[2]);
-
-            for(int j = 0; j < 2; j++ )//for x and y
-            {
-                for(int i = 0; i < 4; i++ )// for X,Y,Z,W
-                {
-                    cvmSet( derivPoint,
-                            j, currVisPoint*4+i,
-                            (p[j*4+i]*piX[2]-p[8+i]*piX[j]) * tmp3  );
-                }
-            }
-            currVisPoint++;
-        }
-    }
-
-    if( derivPoint->rows != 2 || derivPoint->cols != currVisPoint*4 )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "derivPoint must be a matrix 2 x 4VisNum" );
-    }
-
-    __END__;
-    return;
-}
-
-/*======================================================================================*/
-static void icvComputeDerivatePointsAll(CvMat *points4D, CvMat **projMatrs, CvMat **pointPres, int numImages,CvMat **pointDerives)
-{
-    CV_FUNCNAME( "icvComputeDerivatePointsAll" );
-    __BEGIN__;
-
-    /* ----- Test input params for errors ----- */
-    if( numImages < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of images must more than zero" );
-    }
-    if( projMatrs == 0 || pointPres == 0 || pointDerives == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-    /* ----- End test ----- */
-
-    int currImage;
-    for( currImage = 0; currImage < numImages; currImage++ )
-    {
-        icvComputeDerivatePoints(points4D, projMatrs[currImage], pointPres[currImage], pointDerives[currImage]);
-    }
-
-    __END__;
-    return;
-}
-/*======================================================================================*/
-static void icvComputeMatrixVAll(int numImages,CvMat **pointDeriv,CvMat **presPoints, CvMat **matrV)
-{
-    int *shifts = 0;
-
-    CV_FUNCNAME( "icvComputeMatrixVAll" );
-    __BEGIN__;
-
-    /* ----- Test input params for errors ----- */
-    if( numImages < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of images must more than zero" );
-    }
-    if( pointDeriv == 0 || presPoints == 0 || matrV == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-    /*  !!! not tested all parameters */
-    /* ----- End test ----- */
-
-    /* Compute all matrices U */
-    int currImage;
-    int currPoint;
-    int numPoints;
-    numPoints = presPoints[0]->cols;
-    CV_CALL(shifts = (int*)cvAlloc(sizeof(int)*numImages));
-    memset(shifts,0,sizeof(int)*numImages);
-
-    for( currPoint = 0; currPoint < numPoints; currPoint++ )//For each point (matrix V)
-    {
-        int i,j;
-
-        for( i = 0; i < 4; i++ )
-        {
-            for( j = 0; j < 4; j++ )
-            {
-                double sum = 0;
-                for( currImage = 0; currImage < numImages; currImage++ )
-                {
-                    if( cvmGet(presPoints[currImage],0,currPoint) > 0 )
-                    {
-                        sum += cvmGet(pointDeriv[currImage],0,shifts[currImage]*4+i) *
-                               cvmGet(pointDeriv[currImage],0,shifts[currImage]*4+j);
-
-                        sum += cvmGet(pointDeriv[currImage],1,shifts[currImage]*4+i) *
-                               cvmGet(pointDeriv[currImage],1,shifts[currImage]*4+j);
-                    }
-                }
-
-                cvmSet(matrV[currPoint],i,j,sum);
-            }
-        }
-
-
-        /* shift position of visible points */
-        for( currImage = 0; currImage < numImages; currImage++ )
-        {
-            if( cvmGet(presPoints[currImage],0,currPoint) > 0 )
-            {
-                shifts[currImage]++;
-            }
-        }
-    }
-
-    __END__;
-    cvFree( &shifts);
-
-    return;
-}
-/*======================================================================================*/
-static void icvComputeMatrixUAll(int numImages,CvMat **projDeriv,CvMat** matrU)
-{
-    CV_FUNCNAME( "icvComputeMatrixVAll" );
-    __BEGIN__;
-    /* ----- Test input params for errors ----- */
-    if( numImages < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of images must more than zero" );
-    }
-    if( projDeriv == 0 || matrU == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-    /* !!! Not tested all input parameters */
-    /* ----- End test ----- */
-
-    /* Compute matrices V */
-    int currImage;
-    for( currImage = 0; currImage < numImages; currImage++ )
-    {
-        cvMulTransposed(projDeriv[currImage],matrU[currImage],1);
-    }
-
-    __END__;
-    return;
-}
-/*======================================================================================*/
-static void icvComputeMatrixW(int numImages, CvMat **projDeriv, CvMat **pointDeriv, CvMat **presPoints, CvMat *matrW)
-{
-    CV_FUNCNAME( "icvComputeMatrixW" );
-    __BEGIN__;
-
-    /* ----- Test input params for errors ----- */
-    if( numImages < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of images must more than zero" );
-    }
-    if( projDeriv == 0 || pointDeriv == 0 || presPoints == 0 || matrW == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-    int numPoints;
-    numPoints = presPoints[0]->cols;
-    if( numPoints < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points must more than zero" );
-    }
-    if( !CV_IS_MAT(matrW) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "matrW must be a matrix 12NumIm x 4NumPnt" );
-    }
-    if( matrW->rows != numImages*12 || matrW->cols != numPoints*4 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "matrW must be a matrix 12NumIm x 4NumPnt" );
-    }
-    /* !!! Not tested all input parameters */
-    /* ----- End test ----- */
-
-    /* Compute number of points */
-    /* Compute matrix W using derivate proj and points */
-
-    int currImage;
-
-    for( currImage = 0; currImage < numImages; currImage++ )
-    {
-        for( int currLine = 0; currLine < 12; currLine++ )
-        {
-            int currVis = 0;
-            for( int currPoint = 0; currPoint < numPoints; currPoint++ )
-            {
-                if( cvmGet(presPoints[currImage],0,currPoint) > 0 )
-                {
-
-                    for( int currCol = 0; currCol < 4; currCol++ )
-                    {
-                        double sum;
-                        sum = cvmGet(projDeriv[currImage],currVis*2+0,currLine) *
-                              cvmGet(pointDeriv[currImage],0,currVis*4+currCol);
-
-                        sum += cvmGet(projDeriv[currImage],currVis*2+1,currLine) *
-                              cvmGet(pointDeriv[currImage],1,currVis*4+currCol);
-
-                        cvmSet(matrW,currImage*12+currLine,currPoint*4+currCol,sum);
-                    }
-                    currVis++;
-                }
-                else
-                {/* set all sub elements to zero */
-                    for( int currCol = 0; currCol < 4; currCol++ )
-                    {
-                        cvmSet(matrW,currImage*12+currLine,currPoint*4+currCol,0);
-                    }
-                }
-            }
-        }
-    }
-
-#ifdef TRACK_BUNDLE
-    {
-        FILE *file;
-        file = fopen( TRACK_BUNDLE_FILE_MATRW ,"w");
-        int currPoint,currImage;
-        for( currPoint = 0; currPoint < numPoints; currPoint++ )
-        {
-            fprintf(file,"\nPoint=%d\n",currPoint);
-            int currRow;
-            for( currRow = 0; currRow < 4; currRow++  )
-            {
-                for( currImage = 0; currImage< numImages; currImage++ )
-                {
-                    int i;
-                    for( i = 0; i < 12; i++ )
-                    {
-                        double val = cvmGet(matrW, currImage * 12 + i, currPoint * 4 + currRow);
-                        fprintf(file,"%lf ",val);
-                    }
-                }
-                fprintf(file,"\n");
-            }
-        }
-        fclose(file);
-    }
-#endif
-
-    __END__;
-    return;
-}
-
-/*======================================================================================*/
-/* Compute jacobian mult projection matrices error */
-static void icvComputeJacErrorProj(int numImages,CvMat **projDeriv,CvMat **projErrors,CvMat *jacProjErr )
-{
-    CV_FUNCNAME( "icvComputeJacErrorProj" );
-    __BEGIN__;
-
-    /* ----- Test input params for errors ----- */
-    if( numImages < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of images must more than zero" );
-    }
-    if( projDeriv == 0 || projErrors == 0 || jacProjErr == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-    if( !CV_IS_MAT(jacProjErr) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "jacProjErr must be a matrix 12NumIm x 1" );
-    }
-    if( jacProjErr->rows != numImages*12 || jacProjErr->cols != 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "jacProjErr must be a matrix 12NumIm x 1" );
-    }
-    /* !!! Not tested all input parameters */
-    /* ----- End test ----- */
-
-    int currImage;
-    for( currImage = 0; currImage < numImages; currImage++ )
-    {
-        for( int currCol = 0; currCol < 12; currCol++ )
-        {
-            int num = projDeriv[currImage]->rows;
-            double sum = 0;
-            for( int i = 0; i < num; i++ )
-            {
-                sum += cvmGet(projDeriv[currImage],i,currCol) *
-                       cvmGet(projErrors[currImage],i%2,i/2);
-            }
-            cvmSet(jacProjErr,currImage*12+currCol,0,sum);
-        }
-    }
-
-#ifdef TRACK_BUNDLE
-    {
-        FILE *file;
-        file = fopen( TRACK_BUNDLE_FILE_JACERRPROJ ,"w");
-        int currImage;
-        for( currImage = 0; currImage < numImages; currImage++ )
-        {
-            fprintf(file,"\nImage=%d\n",currImage);
-            int currRow;
-            for( currRow = 0; currRow < 12; currRow++  )
-            {
-                double val = cvmGet(jacProjErr, currImage * 12 + currRow, 0);
-                fprintf(file,"%lf\n",val);
-            }
-            fprintf(file,"\n");
-        }
-        fclose(file);
-    }
-#endif
-
-
-    __END__;
-    return;
-}
-
-/*======================================================================================*/
-/* Compute jacobian mult points error */
-static void icvComputeJacErrorPoint(int numImages,CvMat **pointDeriv,CvMat **projErrors, CvMat **presPoints,CvMat *jacPointErr )
-{
-    int *shifts = 0;
-
-    CV_FUNCNAME( "icvComputeJacErrorPoint" );
-    __BEGIN__;
-
-    /* ----- Test input params for errors ----- */
-    if( numImages < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of images must more than zero" );
-    }
-
-    if( pointDeriv == 0 || projErrors == 0 || presPoints == 0 || jacPointErr == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    int numPoints;
-    numPoints = presPoints[0]->cols;
-    if( numPoints < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points must more than zero" );
-    }
-
-    if( !CV_IS_MAT(jacPointErr) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "jacPointErr must be a matrix 4NumPnt x 1" );
-    }
-
-    if( jacPointErr->rows != numPoints*4 || jacPointErr->cols != 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "jacPointErr must be a matrix 4NumPnt x 1" );
-    }
-    /* !!! Not tested all input parameters */
-    /* ----- End test ----- */
-
-    int currImage;
-    int currPoint;
-    CV_CALL(shifts = (int*)cvAlloc(sizeof(int)*numImages));
-    memset(shifts,0,sizeof(int)*numImages);
-    for( currPoint = 0; currPoint < numPoints; currPoint++ )
-    {
-        for( int currCoord = 0; currCoord < 4; currCoord++ )
-        {
-            double sum = 0;
-            {
-                int currVis = 0;
-                for( currImage = 0; currImage < numImages; currImage++ )
-                {
-                    if( cvmGet(presPoints[currImage],0,currPoint) > 0 )
-                    {
-                        sum += cvmGet(pointDeriv[currImage],0,shifts[currImage]*4+currCoord) *
-                               cvmGet(projErrors[currImage],0,shifts[currImage]);//currVis);
-
-                        sum += cvmGet(pointDeriv[currImage],1,shifts[currImage]*4+currCoord) *
-                               cvmGet(projErrors[currImage],1,shifts[currImage]);//currVis);
-
-                        currVis++;
-                    }
-                }
-            }
-
-            cvmSet(jacPointErr,currPoint*4+currCoord,0,sum);
-        }
-
-        /* Increase shifts */
-        for( currImage = 0; currImage < numImages; currImage++ )
-        {
-            if( cvmGet(presPoints[currImage],0,currPoint) > 0 )
-            {
-                shifts[currImage]++;
-            }
-        }
-    }
-
-
-#ifdef TRACK_BUNDLE
-    {
-        FILE *file;
-        file = fopen(TRACK_BUNDLE_FILE_JACERRPNT,"w");
-        int currPoint;
-        for( currPoint = 0; currPoint < numPoints; currPoint++ )
-        {
-            fprintf(file,"\nPoint=%d\n",currPoint);
-            int currRow;
-            for( currRow = 0; currRow < 4; currRow++  )
-            {
-                double val = cvmGet(jacPointErr, currPoint * 4 + currRow, 0);
-                fprintf(file,"%lf\n",val);
-            }
-            fprintf(file,"\n");
-        }
-        fclose(file);
-    }
-#endif
-
-
-
-    __END__;
-    cvFree( &shifts);
-
-}
-/*======================================================================================*/
-
-
-/* Reconstruct 4D points using status */
-void icvReconstructPoints4DStatus(CvMat** projPoints, CvMat **projMatrs, CvMat** presPoints,
-                                  CvMat *points4D,int numImages,CvMat **projError)
-{
-
-    double* matrA_dat = 0;
-    double* matrW_dat = 0;
-
-    CV_FUNCNAME( "icvReconstructPoints4DStatus" );
-
-    __BEGIN__;
-
-    /* ----- Test input params for errors ----- */
-    if( numImages < 2 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of images must be more than one" );
-    }
-
-    if( projPoints == 0 || projMatrs == 0 || presPoints == 0 || points4D == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    int numPoints;
-    numPoints = points4D->cols;
-    if( numPoints < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points4D must be more than zero" );
-    }
-
-    if( points4D->rows != 4 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Points must have 4 cordinates" );
-    }
-
-
-    /* !!! Not tested all input parameters */
-    /* ----- End test ----- */
-
-    int currImage;
-    int currPoint;
-
-    /* Allocate maximum data */
-
-    {
-        double matrV_dat[4*4];
-        CvMat matrV = cvMat(4,4,CV_64F,matrV_dat);
-
-        CV_CALL(matrA_dat = (double*)cvAlloc(3*numImages * 4 * sizeof(double)));
-        CV_CALL(matrW_dat = (double*)cvAlloc(3*numImages * 4 * sizeof(double)));
-
-        /* reconstruct each point */
-        for( currPoint = 0; currPoint < numPoints; currPoint++ )
-        {
-            /* Reconstruct current point */
-            /* Define number of visible projections */
-            int numVisProj = 0;
-            for( currImage = 0; currImage < numImages; currImage++ )
-            {
-                if( cvmGet(presPoints[currImage],0,currPoint) > 0 )
-                {
-                    numVisProj++;
-                }
-            }
-
-            if( numVisProj < 2 )
-            {
-                /* This point can't be reconstructed */
-                continue;
-            }
-
-            /* Allocate memory and create matrices */
-            CvMat matrA;
-            matrA = cvMat(3*numVisProj,4,CV_64F,matrA_dat);
-
-            CvMat matrW;
-            matrW = cvMat(3*numVisProj,4,CV_64F,matrW_dat);
-
-            int currVisProj = 0;
-            for( currImage = 0; currImage < numImages; currImage++ )/* For each view */
-            {
-                if( cvmGet(presPoints[currImage],0,currPoint) > 0 )
-                {
-                    double x,y;
-                    x = cvmGet(projPoints[currImage],0,currPoint);
-                    y = cvmGet(projPoints[currImage],1,currPoint);
-                    for( int k = 0; k < 4; k++ )
-                    {
-                        matrA_dat[currVisProj*12   + k] =
-                               x * cvmGet(projMatrs[currImage],2,k) -     cvmGet(projMatrs[currImage],0,k);
-
-                        matrA_dat[currVisProj*12+4 + k] =
-                               y * cvmGet(projMatrs[currImage],2,k) -     cvmGet(projMatrs[currImage],1,k);
-
-                        matrA_dat[currVisProj*12+8 + k] =
-                               x * cvmGet(projMatrs[currImage],1,k) - y * cvmGet(projMatrs[currImage],0,k);
-                    }
-                    currVisProj++;
-                }
-            }
-
-            /* Solve system for current point */
-            {
-                cvSVD(&matrA,&matrW,0,&matrV,CV_SVD_V_T);
-
-                /* Copy computed point */
-                cvmSet(points4D,0,currPoint,cvmGet(&matrV,3,0));//X
-                cvmSet(points4D,1,currPoint,cvmGet(&matrV,3,1));//Y
-                cvmSet(points4D,2,currPoint,cvmGet(&matrV,3,2));//Z
-                cvmSet(points4D,3,currPoint,cvmGet(&matrV,3,3));//W
-            }
-
-        }
-    }
-
-    {/* Compute projection error */
-        for( currImage = 0; currImage < numImages; currImage++ )
-        {
-            CvMat point4D;
-            CvMat point3D;
-            double point3D_dat[3];
-            point3D = cvMat(3,1,CV_64F,point3D_dat);
-
-            int numVis = 0;
-            double totalError = 0;
-            for(int curPoint = 0; curPoint < numPoints; curPoint++ )
-            {
-                if( cvmGet(presPoints[currImage],0,curPoint) > 0)
-                {
-                    double  dx,dy;
-                    cvGetCol(points4D,&point4D,curPoint);
-                    cvmMul(projMatrs[currImage],&point4D,&point3D);
-                    double w = point3D_dat[2];
-                    double x = point3D_dat[0] / w;
-                    double y = point3D_dat[1] / w;
-
-                    dx = cvmGet(projPoints[currImage],0,curPoint) - x;
-                    dy = cvmGet(projPoints[currImage],1,curPoint) - y;
-                    if( projError )
-                    {
-                        cvmSet(projError[currImage],0,curPoint,dx);
-                        cvmSet(projError[currImage],1,curPoint,dy);
-                    }
-                    totalError += sqrt(dx*dx+dy*dy);
-                    numVis++;
-                }
-            }
-
-            //double meanError = totalError / (double)numVis;
-
-        }
-
-    }
-
-    __END__;
-
-    cvFree( &matrA_dat);
-    cvFree( &matrW_dat);
-
-    return;
-}
-
-/*======================================================================================*/
-
-static void icvProjPointsStatusFunc( int numImages, CvMat *points4D, CvMat **projMatrs, CvMat **pointsPres, CvMat **projPoints)
-{
-    CV_FUNCNAME( "icvProjPointsStatusFunc" );
-    __BEGIN__;
-
-    /* ----- Test input params for errors ----- */
-    if( numImages < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of images must be more than zero" );
-    }
-
-    if( points4D == 0 || projMatrs == 0 || pointsPres == 0 || projPoints == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-    {
-    int numPoints;
-    numPoints = points4D->cols;
-    if( numPoints < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points4D must be more than zero" );
-    }
-
-    if( points4D->rows != 4 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Points must have 4 cordinates" );
-    }
-
-    /* !!! Not tested all input parameters */
-    /* ----- End test ----- */
-
-    CvMat point4D;
-    CvMat point3D;
-    double point4D_dat[4];
-    double point3D_dat[3];
-    point4D = cvMat(4,1,CV_64F,point4D_dat);
-    point3D = cvMat(3,1,CV_64F,point3D_dat);
-
-#ifdef TRACK_BUNDLE
-        {
-            FILE *file;
-            file = fopen( TRACK_BUNDLE_FILE ,"a");
-            fprintf(file,"\n----- test 14.01 icvProjPointsStatusFunc -----\n");
-            fclose(file);
-        }
-#endif
-
-    int currImage;
-    for( currImage = 0; currImage < numImages; currImage++ )
-    {
-        /* Get project matrix */
-        /* project visible points using current projection matrix */
-        int currVisPoint = 0;
-        for( int currPoint = 0; currPoint < numPoints; currPoint++ )
-        {
-            if( cvmGet(pointsPres[currImage],0,currPoint) > 0 )
-            {
-                /* project current point */
-                cvGetSubRect(points4D,&point4D,cvRect(currPoint,0,1,4));
-
-#ifdef TRACK_BUNDLE
-                {
-                    FILE *file;
-                    file = fopen( TRACK_BUNDLE_FILE ,"a");
-                    fprintf(file,"\n----- test 14.02 point4D (%lf, %lf, %lf, %lf) -----\n",
-                                 cvmGet(&point4D,0,0),
-                                 cvmGet(&point4D,1,0),
-                                 cvmGet(&point4D,2,0),
-                                 cvmGet(&point4D,3,0));
-                    fclose(file);
-                }
-#endif
-
-                cvmMul(projMatrs[currImage],&point4D,&point3D);
-                double w = point3D_dat[2];
-                cvmSet(projPoints[currImage],0,currVisPoint,point3D_dat[0]/w);
-                cvmSet(projPoints[currImage],1,currVisPoint,point3D_dat[1]/w);
-
-#ifdef TRACK_BUNDLE
-                {
-                    FILE *file;
-                    file = fopen( TRACK_BUNDLE_FILE ,"a");
-                    fprintf(file,"\n----- test 14.03 (%lf, %lf, %lf) -> (%lf, %lf)-----\n",
-                                 point3D_dat[0],
-                                 point3D_dat[1],
-                                 point3D_dat[2],
-                                 point3D_dat[0]/w,
-                                 point3D_dat[1]/w
-                                 );
-                    fclose(file);
-                }
-#endif
-                currVisPoint++;
-            }
-        }
-    }
-    }
-    __END__;
-}
-
-/*======================================================================================*/
-static void icvFreeMatrixArray(CvMat ***matrArray,int numMatr)
-{
-    /* Free each matrix */
-    int currMatr;
-
-    if( *matrArray != 0 )
-    {/* Need delete */
-        for( currMatr = 0; currMatr < numMatr; currMatr++ )
-        {
-            cvReleaseMat((*matrArray)+currMatr);
-        }
-        cvFree( matrArray);
-    }
-    return;
-}
-
-/*======================================================================================*/
-static void *icvClearAlloc(int size)
-{
-    void *ptr = 0;
-
-    CV_FUNCNAME( "icvClearAlloc" );
-    __BEGIN__;
-
-    if( size > 0 )
-    {
-        CV_CALL(ptr = cvAlloc(size));
-        memset(ptr,0,size);
-    }
-
-    __END__;
-    return ptr;
-}
-
-/*======================================================================================*/
-#if 0
-void cvOptimizeLevenbergMarquardtBundleWraper( CvMat** projMatrs, CvMat** observProjPoints,
-                                       CvMat** pointsPres, int numImages,
-                                       CvMat** resultProjMatrs, CvMat* resultPoints4D,int maxIter,double epsilon )
-{
-    /* Delete al sparse points */
-
-int icvDeleteSparsInPoints(  int numImages,
-                             CvMat **points,
-                             CvMat **status,
-                             CvMat *wasStatus)/* status of previous configuration */
-
-}
-#endif
-
-/*======================================================================================*/
-/* !!! may be useful to return norm of error */
-/* !!! may be does not work correct with not all visible 4D points */
-void cvOptimizeLevenbergMarquardtBundle( CvMat** projMatrs, CvMat** observProjPoints,
-                                       CvMat** pointsPres, int numImages,
-                                       CvMat** resultProjMatrs, CvMat* resultPoints4D,int maxIter,double epsilon )
-{
-
-    CvMat  *vectorX_points4D = 0;
-    CvMat **vectorX_projMatrs = 0;
-
-    CvMat  *newVectorX_points4D = 0;
-    CvMat **newVectorX_projMatrs = 0;
-
-    CvMat  *changeVectorX_points4D = 0;
-    CvMat  *changeVectorX_projMatrs = 0;
-
-    CvMat **observVisPoints = 0;
-    CvMat **projVisPoints = 0;
-    CvMat **errorProjPoints = 0;
-    CvMat **DerivProj = 0;
-    CvMat **DerivPoint = 0;
-    CvMat *matrW = 0;
-    CvMat **matrsUk = 0;
-    CvMat **workMatrsUk = 0;
-    CvMat **matrsVi = 0;
-    CvMat *workMatrVi = 0;
-    CvMat **workMatrsInvVi = 0;
-    CvMat *jacProjErr = 0;
-    CvMat *jacPointErr = 0;
-
-    CvMat *matrTmpSys1 = 0;
-    CvMat *matrSysDeltaP = 0;
-    CvMat *vectTmpSys3 = 0;
-    CvMat *vectSysDeltaP = 0;
-    CvMat *deltaP = 0;
-    CvMat *deltaM = 0;
-    CvMat *vectTmpSysM = 0;
-
-    int numPoints = 0;
-
-
-    CV_FUNCNAME( "cvOptimizeLevenbergMarquardtBundle" );
-    __BEGIN__;
-
-    /* ----- Test input params for errors ----- */
-    if( numImages < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of images must be more than zero" );
-    }
-
-    if( maxIter < 1 || maxIter > 2000 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Maximum number of iteration must be in [1..1000]" );
-    }
-
-    if( epsilon < 0  )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Epsilon parameter must be >= 0" );
-    }
-
-    if( !CV_IS_MAT(resultPoints4D) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "resultPoints4D must be a matrix 4 x NumPnt" );
-    }
-
-    numPoints = resultPoints4D->cols;
-    if( numPoints < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points must be more than zero" );//!!!
-    }
-
-    if( resultPoints4D->rows != 4 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "resultPoints4D must have 4 cordinates" );
-    }
-
-    /* ----- End test ----- */
-
-    /* Optimization using bundle adjustment */
-    /* work with non visible points */
-
-    CV_CALL( vectorX_points4D  = cvCreateMat(4,numPoints,CV_64F));
-    CV_CALL( vectorX_projMatrs = (CvMat**)icvClearAlloc(sizeof(CvMat*)*numImages));
-
-    CV_CALL( newVectorX_points4D  = cvCreateMat(4,numPoints,CV_64F));
-    CV_CALL( newVectorX_projMatrs = (CvMat**)icvClearAlloc(sizeof(CvMat*)*numImages));
-
-    CV_CALL( changeVectorX_points4D  = cvCreateMat(4,numPoints,CV_64F));
-    CV_CALL( changeVectorX_projMatrs = cvCreateMat(3,4,CV_64F));
-
-    /* ----- Test input params ----- */
-    for(int currImage = 0; currImage < numImages; currImage++ )
-    {
-        /* Test size of input initial and result projection matrices */
-        if( !CV_IS_MAT(projMatrs[currImage]) )
-        {
-            CV_ERROR( CV_StsUnsupportedFormat, "each of initial projMatrs must be a matrix 3 x 4" );
-        }
-        if( projMatrs[currImage]->rows != 3 || projMatrs[currImage]->cols != 4 )
-        {
-            CV_ERROR( CV_StsOutOfRange, "each of initial projMatrs must be a matrix 3 x 4" );
-        }
-
-
-        if( !CV_IS_MAT(observProjPoints[currImage]) )
-        {
-            CV_ERROR( CV_StsUnsupportedFormat, "each of observProjPoints must be a matrix 2 x NumPnts" );
-        }
-        if( observProjPoints[currImage]->rows != 2 || observProjPoints[currImage]->cols != numPoints )
-        {
-            CV_ERROR( CV_StsOutOfRange, "each of observProjPoints must be a matrix 2 x NumPnts" );
-        }
-
-        if( !CV_IS_MAT(pointsPres[currImage]) )
-        {
-            CV_ERROR( CV_StsUnsupportedFormat, "each of pointsPres must be a matrix 1 x NumPnt" );
-        }
-        if( pointsPres[currImage]->rows != 1 || pointsPres[currImage]->cols != numPoints )
-        {
-            CV_ERROR( CV_StsOutOfRange, "each of pointsPres must be a matrix 1 x NumPnt" );
-        }
-
-        if( !CV_IS_MAT(resultProjMatrs[currImage]) )
-        {
-            CV_ERROR( CV_StsUnsupportedFormat, "each of resultProjMatrs must be a matrix 3 x 4" );
-        }
-        if( resultProjMatrs[currImage]->rows != 3 || resultProjMatrs[currImage]->cols != 4 )
-        {
-            CV_ERROR( CV_StsOutOfRange, "each of resultProjMatrs must be a matrix 3 x 4" );
-        }
-
-    }
-    /* ----- End test ----- */
-
-    /* Copy projection matrices to vectorX0 */
-    for(int currImage = 0; currImage < numImages; currImage++ )
-    {
-        CV_CALL( vectorX_projMatrs[currImage] = cvCreateMat(3,4,CV_64F));
-        CV_CALL( newVectorX_projMatrs[currImage] = cvCreateMat(3,4,CV_64F));
-        cvCopy(projMatrs[currImage],vectorX_projMatrs[currImage]);
-    }
-
-    /* Reconstruct points4D using projection matrices and status information */
-    icvReconstructPoints4DStatus(observProjPoints, projMatrs, pointsPres, vectorX_points4D, numImages);
-
-    /* ----- Allocate memory for work matrices ----- */
-    /* Compute number of good points on each images */
-
-    CV_CALL( observVisPoints = (CvMat**)icvClearAlloc(sizeof(CvMat*)*numImages) );
-    CV_CALL( projVisPoints   = (CvMat**)icvClearAlloc(sizeof(CvMat*)*numImages) );
-    CV_CALL( errorProjPoints = (CvMat**)icvClearAlloc(sizeof(CvMat*)*numImages) );
-    CV_CALL( DerivProj       = (CvMat**)icvClearAlloc(sizeof(CvMat*)*numImages) );
-    CV_CALL( DerivPoint      = (CvMat**)icvClearAlloc(sizeof(CvMat*)*numImages) );
-    CV_CALL( matrW           = cvCreateMat(12*numImages,4*numPoints,CV_64F) );
-    CV_CALL( matrsUk         = (CvMat**)icvClearAlloc(sizeof(CvMat*)*numImages) );
-    CV_CALL( workMatrsUk     = (CvMat**)icvClearAlloc(sizeof(CvMat*)*numImages) );
-    CV_CALL( matrsVi         = (CvMat**)icvClearAlloc(sizeof(CvMat*)*numPoints) );
-    CV_CALL( workMatrVi      = cvCreateMat(4,4,CV_64F) );
-    CV_CALL( workMatrsInvVi  = (CvMat**)icvClearAlloc(sizeof(CvMat*)*numPoints) );
-
-    CV_CALL( jacProjErr      = cvCreateMat(12*numImages,1,CV_64F) );
-    CV_CALL( jacPointErr     = cvCreateMat(4*numPoints,1,CV_64F) );
-
-
-    int i;
-    for( i = 0; i < numPoints; i++ )
-    {
-        CV_CALL( matrsVi[i]        = cvCreateMat(4,4,CV_64F) );
-        CV_CALL( workMatrsInvVi[i] = cvCreateMat(4,4,CV_64F) );
-    }
-
-    for(int currImage = 0; currImage < numImages; currImage++ )
-    {
-        CV_CALL( matrsUk[currImage]     = cvCreateMat(12,12,CV_64F) );
-        CV_CALL( workMatrsUk[currImage] = cvCreateMat(12,12,CV_64F) );
-
-        int currVisPoint = 0, currPoint, numVisPoint;
-        for( currPoint = 0; currPoint < numPoints; currPoint++ )
-        {
-            if( cvmGet(pointsPres[currImage],0,currPoint) > 0 )
-            {
-                currVisPoint++;
-            }
-        }
-
-        numVisPoint = currVisPoint;
-
-        /* Allocate memory for current image data */
-        CV_CALL( observVisPoints[currImage]  = cvCreateMat(2,numVisPoint,CV_64F) );
-        CV_CALL( projVisPoints[currImage]    = cvCreateMat(2,numVisPoint,CV_64F) );
-
-        /* create error matrix */
-        CV_CALL( errorProjPoints[currImage] = cvCreateMat(2,numVisPoint,CV_64F) );
-
-        /* Create derivate matrices */
-        CV_CALL( DerivProj[currImage]  = cvCreateMat(2*numVisPoint,12,CV_64F) );
-        CV_CALL( DerivPoint[currImage] = cvCreateMat(2,numVisPoint*4,CV_64F) );
-
-        /* Copy observed projected visible points */
-        currVisPoint = 0;
-        for( currPoint = 0; currPoint < numPoints; currPoint++ )
-        {
-            if( cvmGet(pointsPres[currImage],0,currPoint) > 0 )
-            {
-                cvmSet(observVisPoints[currImage],0,currVisPoint,cvmGet(observProjPoints[currImage],0,currPoint));
-                cvmSet(observVisPoints[currImage],1,currVisPoint,cvmGet(observProjPoints[currImage],1,currPoint));
-                currVisPoint++;
-            }
-        }
-    }
-    /*---------------------------------------------------*/
-
-    CV_CALL( matrTmpSys1   = cvCreateMat(numPoints*4, numImages*12, CV_64F) );
-    CV_CALL( matrSysDeltaP = cvCreateMat(numImages*12, numImages*12, CV_64F) );
-    CV_CALL( vectTmpSys3   = cvCreateMat(numPoints*4,1,CV_64F) );
-    CV_CALL( vectSysDeltaP = cvCreateMat(numImages*12,1,CV_64F) );
-    CV_CALL( deltaP        = cvCreateMat(numImages*12,1,CV_64F) );
-    CV_CALL( deltaM        = cvCreateMat(numPoints*4,1,CV_64F) );
-    CV_CALL( vectTmpSysM   = cvCreateMat(numPoints*4,1,CV_64F) );
-
-
-//#ifdef TRACK_BUNDLE
-#if 1
-    {
-        /* Create file to track */
-        FILE* file;
-        file = fopen( TRACK_BUNDLE_FILE ,"w");
-        fprintf(file,"begin\n");
-        fclose(file);
-    }
-#endif
-
-    /* ============= main optimization loop ============== */
-
-    /* project all points using current vector X */
-    icvProjPointsStatusFunc(numImages, vectorX_points4D, vectorX_projMatrs, pointsPres, projVisPoints);
-
-    /* Compute error with observed value and computed projection */
-    double prevError;
-    prevError = 0;
-    for(int currImage = 0; currImage < numImages; currImage++ )
-    {
-        cvSub(observVisPoints[currImage],projVisPoints[currImage],errorProjPoints[currImage]);
-        double currNorm = cvNorm(errorProjPoints[currImage]);
-        prevError += currNorm * currNorm;
-    }
-    prevError = sqrt(prevError);
-
-    int currIter;
-    double change;
-    double alpha;
-
-//#ifdef TRACK_BUNDLE
-#if 1
-    {
-        /* Create file to track */
-        FILE* file;
-        file = fopen( TRACK_BUNDLE_FILE ,"a");
-        fprintf(file,"\n========================================\n");;
-        fprintf(file,"Iter=0\n");
-        fprintf(file,"Error = %20.15lf\n",prevError);
-        fprintf(file,"Change = %20.15lf\n",1.0);
-
-        fprintf(file,"projection errors\n");
-
-        /* Print all proejction errors */
-        for(int currImage = 0; currImage < numImages; currImage++)
-        {
-            fprintf(file,"\nImage=%d\n",currImage);
-            int numPn = errorProjPoints[currImage]->cols;
-            for( int currPoint = 0; currPoint < numPn; currPoint++ )
-            {
-                double ex,ey;
-                ex = cvmGet(errorProjPoints[currImage],0,currPoint);
-                ey = cvmGet(errorProjPoints[currImage],1,currPoint);
-                fprintf(file,"%40.35lf, %40.35lf\n",ex,ey);
-            }
-        }
-        fclose(file);
-    }
-#endif
-
-    currIter = 0;
-    change = 1;
-    alpha = 0.001;
-
-
-    do
-    {
-
-#ifdef TRACK_BUNDLE
-        {
-            FILE *file;
-            file = fopen( TRACK_BUNDLE_FILE ,"a");
-            fprintf(file,"\n----- test 6 do main -----\n");
-
-            double norm = cvNorm(vectorX_points4D);
-            fprintf(file,"        test 6.01 prev normPnts=%lf\n",norm);
-
-            for( int i=0;i<numImages;i++ )
-            {
-                double norm = cvNorm(vectorX_projMatrs[i]);
-                fprintf(file,"        test 6.01 prev normProj=%lf\n",norm);
-            }
-
-            fclose(file);
-        }
-#endif
-
-        /* Compute derivates by projectinon matrices */
-        icvComputeDerivateProjAll(vectorX_points4D,vectorX_projMatrs,pointsPres,numImages,DerivProj);
-
-        /* Compute derivates by 4D points */
-        icvComputeDerivatePointsAll(vectorX_points4D,vectorX_projMatrs,pointsPres,numImages,DerivPoint);
-
-        /* Compute matrces Uk */
-        icvComputeMatrixUAll(numImages,DerivProj,matrsUk);
-        icvComputeMatrixVAll(numImages,DerivPoint,pointsPres,matrsVi);
-        icvComputeMatrixW(numImages,DerivProj,DerivPoint,pointsPres,matrW);
-
-
-#ifdef TRACK_BUNDLE
-        {
-            FILE *file;
-            file = fopen( TRACK_BUNDLE_FILE ,"a");
-            fprintf(file,"\n----- test 6.03 do matrs U V -----\n");
-
-            int i;
-            for( i = 0; i < numImages; i++ )
-            {
-                double norm = cvNorm(matrsUk[i]);
-                fprintf(file,"        test 6.01 prev matrsUk=%lf\n",norm);
-            }
-
-            for( i = 0; i < numPoints; i++ )
-            {
-                double norm = cvNorm(matrsVi[i]);
-                fprintf(file,"        test 6.01 prev matrsVi=%lf\n",norm);
-            }
-
-            fclose(file);
-        }
-#endif
-
-        /* Compute jac errors */
-        icvComputeJacErrorProj(numImages, DerivProj, errorProjPoints, jacProjErr);
-        icvComputeJacErrorPoint(numImages, DerivPoint, errorProjPoints, pointsPres, jacPointErr);
-
-#ifdef TRACK_BUNDLE
-        {
-            FILE *file;
-            file = fopen( TRACK_BUNDLE_FILE ,"a");
-            fprintf(file,"\n----- test 6 do main -----\n");
-            double norm1 = cvNorm(vectorX_points4D);
-            fprintf(file,"        test 6.02 post normPnts=%lf\n",norm1);
-            fclose(file);
-        }
-#endif
-        /* Copy matrices Uk to work matrices Uk */
-        for(int currImage = 0; currImage < numImages; currImage++ )
-        {
-            cvCopy(matrsUk[currImage],workMatrsUk[currImage]);
-        }
-
-#ifdef TRACK_BUNDLE
-        {
-            FILE *file;
-            file = fopen( TRACK_BUNDLE_FILE ,"a");
-            fprintf(file,"\n----- test 60.3 do matrs U V -----\n");
-
-            int i;
-            for( i = 0; i < numImages; i++ )
-            {
-                double norm = cvNorm(matrsUk[i]);
-                fprintf(file,"        test 6.01 post1 matrsUk=%lf\n",norm);
-            }
-
-            for( i = 0; i < numPoints; i++ )
-            {
-                double norm = cvNorm(matrsVi[i]);
-                fprintf(file,"        test 6.01 post1 matrsVi=%lf\n",norm);
-            }
-
-            fclose(file);
-        }
-#endif
-
-        /* ========== Solve normal equation for given alpha and Jacobian ============ */
-
-        do
-        {
-            /* ---- Add alpha to matrices --- */
-            /* Add alpha to matrInvVi and make workMatrsInvVi */
-
-            int currV;
-            for( currV = 0; currV < numPoints; currV++ )
-            {
-                cvCopy(matrsVi[currV],workMatrVi);
-
-                for( i = 0; i < 4; i++ )
-                {
-                    cvmSet(workMatrVi,i,i,cvmGet(matrsVi[currV],i,i)*(1+alpha) );
-                }
-
-                cvInvert(workMatrVi,workMatrsInvVi[currV],CV_LU/*,&currV*/);
-            }
-
-            /* Add alpha to matrUk and make matrix workMatrsUk */
-            for(int currImage = 0; currImage< numImages; currImage++ )
-            {
-
-                for( i = 0; i < 12; i++ )
-                {
-                    cvmSet(workMatrsUk[currImage],i,i,cvmGet(matrsUk[currImage],i,i)*(1+alpha));
-                }
-
-
-            }
-
-            /* Fill matrix to make system for computing delta P (matrTmpSys1 = inv(V)*tr(W) )*/
-            for( currV = 0; currV < numPoints; currV++ )
-            {
-                int currRowV;
-                for( currRowV = 0; currRowV < 4; currRowV++ )
-                {
-                    for(int currImage = 0; currImage < numImages; currImage++ )
-                    {
-                        for( int currCol = 0; currCol < 12; currCol++ )/* For each column of transposed matrix W */
-                        {
-                            double sum = 0;
-                            for( i = 0; i < 4; i++ )
-                            {
-                                sum += cvmGet(workMatrsInvVi[currV],currRowV,i) *
-                                       cvmGet(matrW,currImage*12+currCol,currV*4+i);
-                            }
-                            cvmSet(matrTmpSys1,currV*4+currRowV,currImage*12+currCol,sum);
-                        }
-                    }
-                }
-            }
-
-
-            /* Fill matrix to make system for computing delta P (matrTmpSys2 = W * matrTmpSys ) */
-            cvmMul(matrW,matrTmpSys1,matrSysDeltaP);
-
-            /* need to compute U-matrTmpSys2. But we compute matTmpSys2-U */
-            for(int currImage = 0; currImage < numImages; currImage++ )
-            {
-                CvMat subMatr;
-                cvGetSubRect(matrSysDeltaP,&subMatr,cvRect(currImage*12,currImage*12,12,12));
-                cvSub(&subMatr,workMatrsUk[currImage],&subMatr);
-            }
-
-            /* Compute right side of normal equation  */
-            for( currV = 0; currV < numPoints; currV++ )
-            {
-                CvMat subMatrErPnts;
-                CvMat subMatr;
-                cvGetSubRect(jacPointErr,&subMatrErPnts,cvRect(0,currV*4,1,4));
-                cvGetSubRect(vectTmpSys3,&subMatr,cvRect(0,currV*4,1,4));
-                cvmMul(workMatrsInvVi[currV],&subMatrErPnts,&subMatr);
-            }
-
-            cvmMul(matrW,vectTmpSys3,vectSysDeltaP);
-            cvSub(vectSysDeltaP,jacProjErr,vectSysDeltaP);
-
-            /* Now we can compute part of normal system - deltaP */
-            cvSolve(matrSysDeltaP ,vectSysDeltaP, deltaP, CV_SVD);
-
-            /* Print deltaP to file */
-
-#ifdef TRACK_BUNDLE
-            {
-                FILE* file;
-                file = fopen( TRACK_BUNDLE_FILE_DELTAP ,"w");
-
-                for(int currImage = 0; currImage < numImages; currImage++ )
-                {
-                    fprintf(file,"\nImage=%d\n",currImage);
-                    int i;
-                    for( i = 0; i < 12; i++ )
-                    {
-                        double val;
-                        val = cvmGet(deltaP,currImage*12+i,0);
-                        fprintf(file,"%lf\n",val);
-                    }
-                    fprintf(file,"\n");
-                }
-                fclose(file);
-            }
-#endif
-            /* We know deltaP and now we can compute system for deltaM */
-            for( i = 0; i < numPoints * 4; i++ )
-            {
-                double sum = 0;
-                for( int j = 0; j < numImages * 12; j++ )
-                {
-                    sum += cvmGet(matrW,j,i) * cvmGet(deltaP,j,0);
-                }
-                cvmSet(vectTmpSysM,i,0,cvmGet(jacPointErr,i,0)-sum);
-            }
-
-            /* Compute deltaM */
-            for( currV = 0; currV < numPoints; currV++ )
-            {
-                CvMat subMatr;
-                CvMat subMatrM;
-                cvGetSubRect(vectTmpSysM,&subMatr,cvRect(0,currV*4,1,4));
-                cvGetSubRect(deltaM,&subMatrM,cvRect(0,currV*4,1,4));
-                cvmMul(workMatrsInvVi[currV],&subMatr,&subMatrM);
-            }
-
-            /* We know delta and compute new value of vector X: nextVectX = vectX + deltas */
-
-            /* Compute new P */
-            for(int currImage = 0; currImage < numImages; currImage++ )
-            {
-                for( i = 0; i < 3; i++ )
-                {
-                    for( int j = 0; j < 4; j++ )
-                    {
-                        cvmSet(newVectorX_projMatrs[currImage],i,j,
-                                cvmGet(vectorX_projMatrs[currImage],i,j) + cvmGet(deltaP,currImage*12+i*4+j,0));
-                    }
-                }
-            }
-
-            /* Compute new M */
-            int currPoint;
-            for( currPoint = 0; currPoint < numPoints; currPoint++ )
-            {
-                for( i = 0; i < 4; i++ )
-                {
-                    cvmSet(newVectorX_points4D,i,currPoint,
-                        cvmGet(vectorX_points4D,i,currPoint) + cvmGet(deltaM,currPoint*4+i,0));
-                }
-            }
-
-            /* ----- Compute errors for new vectorX ----- */
-            /* Project points using new vectorX and status of each point */
-            icvProjPointsStatusFunc(numImages, newVectorX_points4D, newVectorX_projMatrs, pointsPres, projVisPoints);
-            /* Compute error with observed value and computed projection */
-            double newError = 0;
-            for(int currImage = 0; currImage < numImages; currImage++ )
-            {
-                cvSub(observVisPoints[currImage],projVisPoints[currImage],errorProjPoints[currImage]);
-                double currNorm = cvNorm(errorProjPoints[currImage]);
-
-//#ifdef TRACK_BUNDLE
-#if 1
-                {
-                    FILE *file;
-                    file = fopen( TRACK_BUNDLE_FILE ,"a");
-                    fprintf(file,"\n----- test 13,01 currImage=%d currNorm=%lf -----\n",currImage,currNorm);
-                    fclose(file);
-                }
-#endif
-                newError += currNorm * currNorm;
-            }
-            newError = sqrt(newError);
-
-            currIter++;
-
-
-
-
-//#ifdef TRACK_BUNDLE
-#if 1
-            {
-                /* Create file to track */
-                FILE* file;
-                file = fopen( TRACK_BUNDLE_FILE ,"a");
-                fprintf(file,"\n========================================\n");
-                fprintf(file,"numPoints=%d\n",numPoints);
-                fprintf(file,"Iter=%d\n",currIter);
-                fprintf(file,"Error = %20.15lf\n",newError);
-                fprintf(file,"Change = %20.15lf\n",change);
-
-
-                /* Print all projection errors */
-#if 0
-                fprintf(file,"projection errors\n");
-                for(int currImage = 0; currImage < numImages; currImage++)
-                {
-                    fprintf(file,"\nImage=%d\n",currImage);
-                    int numPn = errorProjPoints[currImage]->cols;
-                    for( int currPoint = 0; currPoint < numPn; currPoint++ )
-                    {
-                        double ex,ey;
-                        ex = cvmGet(errorProjPoints[currImage],0,currPoint);
-                        ey = cvmGet(errorProjPoints[currImage],1,currPoint);
-                        fprintf(file,"%lf,%lf\n",ex,ey);
-                    }
-                }
-                fprintf(file,"\n---- test 0 -----\n");
-#endif
-
-                fclose(file);
-            }
-#endif
-
-
-
-            /* Compare new error and last error */
-            if( newError < prevError )
-            {/* accept new value */
-                prevError = newError;
-                /* Compute relative change of required parameter vectorX. change = norm(curr-prev) / norm(curr) )  */
-                {
-                    double normAll1 = 0;
-                    double normAll2 = 0;
-                    double currNorm1 = 0;
-                    double currNorm2 = 0;
-                    /* compute norm for projection matrices */
-                    for(int currImage = 0; currImage < numImages; currImage++ )
-                    {
-                        currNorm1 = cvNorm(newVectorX_projMatrs[currImage],vectorX_projMatrs[currImage]);
-                        currNorm2 = cvNorm(newVectorX_projMatrs[currImage]);
-
-                        normAll1 += currNorm1 * currNorm1;
-                        normAll2 += currNorm2 * currNorm2;
-                    }
-
-                    /* compute norm for points */
-                    currNorm1 = cvNorm(newVectorX_points4D,vectorX_points4D);
-                    currNorm2 = cvNorm(newVectorX_points4D);
-
-                    normAll1 += currNorm1 * currNorm1;
-                    normAll2 += currNorm2 * currNorm2;
-
-                    /* compute change */
-                    change = sqrt(normAll1) / sqrt(normAll2);
-
-
-//#ifdef TRACK_BUNDLE
-#if 1
-                    {
-                        /* Create file to track */
-                        FILE* file;
-                        file = fopen( TRACK_BUNDLE_FILE ,"a");
-                        fprintf(file,"\nChange inside newVal change = %20.15lf\n",change);
-                        fprintf(file,"   normAll1= %20.15lf\n",sqrt(normAll1));
-                        fprintf(file,"   normAll2= %20.15lf\n",sqrt(normAll2));
-
-                        fclose(file);
-                    }
-#endif
-
-                }
-
-                alpha /= 10;
-                for(int currImage = 0; currImage < numImages; currImage++ )
-                {
-                    cvCopy(newVectorX_projMatrs[currImage],vectorX_projMatrs[currImage]);
-                }
-                cvCopy(newVectorX_points4D,vectorX_points4D);
-
-                break;
-            }
-            else
-            {
-                alpha *= 10;
-            }
-
-        } while( change > epsilon && currIter < maxIter );/* solve normal equation using current alpha */
-
-//#ifdef TRACK_BUNDLE
-#if 1
-        {
-            FILE* file;
-            file = fopen( TRACK_BUNDLE_FILE ,"a");
-            fprintf(file,"\nBest error = %40.35lf\n",prevError);
-            fclose(file);
-        }
-
-#endif
-
-
-    } while( change > epsilon && currIter < maxIter );
-
-    /*--------------------------------------------*/
-    /* Optimization complete copy computed params */
-    /* Copy projection matrices */
-    for(int currImage = 0; currImage < numImages; currImage++ )
-    {
-        cvCopy(newVectorX_projMatrs[currImage],resultProjMatrs[currImage]);
-    }
-    /* Copy 4D points */
-    cvCopy(newVectorX_points4D,resultPoints4D);
-
-//    free(memory);
-
-    __END__;
-
-    /* Free allocated memory */
-
-    /* Free simple matrices */
-    cvFree(&vectorX_points4D);
-    cvFree(&newVectorX_points4D);
-    cvFree(&changeVectorX_points4D);
-    cvFree(&changeVectorX_projMatrs);
-    cvFree(&matrW);
-    cvFree(&workMatrVi);
-    cvFree(&jacProjErr);
-    cvFree(&jacPointErr);
-    cvFree(&matrTmpSys1);
-    cvFree(&matrSysDeltaP);
-    cvFree(&vectTmpSys3);
-    cvFree(&vectSysDeltaP);
-    cvFree(&deltaP);
-    cvFree(&deltaM);
-    cvFree(&vectTmpSysM);
-
-    /* Free arrays of matrices */
-    icvFreeMatrixArray(&vectorX_projMatrs,numImages);
-    icvFreeMatrixArray(&newVectorX_projMatrs,numImages);
-    icvFreeMatrixArray(&observVisPoints,numImages);
-    icvFreeMatrixArray(&projVisPoints,numImages);
-    icvFreeMatrixArray(&errorProjPoints,numImages);
-    icvFreeMatrixArray(&DerivProj,numImages);
-    icvFreeMatrixArray(&DerivPoint,numImages);
-    icvFreeMatrixArray(&matrsUk,numImages);
-    icvFreeMatrixArray(&workMatrsUk,numImages);
-    icvFreeMatrixArray(&matrsVi,numPoints);
-    icvFreeMatrixArray(&workMatrsInvVi,numPoints);
-
-    return;
-}
diff --git a/modules/legacy/src/levmartrif.cpp b/modules/legacy/src/levmartrif.cpp
deleted file mode 100644 (file)
index e86b52f..0000000
+++ /dev/null
@@ -1,498 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#include <float.h>
-#include <limits.h>
-
-/* Valery Mosyagin */
-
-#if 0
-
-typedef void (*pointer_LMJac)( const CvMat* src, CvMat* dst );
-typedef void (*pointer_LMFunc)( const CvMat* src, CvMat* dst );
-
-void cvLevenbergMarquardtOptimization(pointer_LMJac JacobianFunction,
-                                    pointer_LMFunc function,
-                                    /*pointer_Err error_function,*/
-                                    CvMat *X0,CvMat *observRes,CvMat *resultX,
-                                    int maxIter,double epsilon);
-
-void icvReconstructPointsFor3View( CvMat* projMatr1,CvMat* projMatr2,CvMat* projMatr3,
-                                CvMat* projPoints1,CvMat* projPoints2,CvMat* projPoints3,
-                                CvMat* points4D);
-
-
-/* Jacobian computation for trifocal case */
-static void icvJacobianFunction_ProjTrifocal(const CvMat *vectX,CvMat *Jacobian)
-{
-    CV_FUNCNAME( "icvJacobianFunction_ProjTrifocal" );
-    __BEGIN__;
-
-    /* Test data for errors */
-    if( vectX == 0 || Jacobian == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(vectX) || !CV_IS_MAT(Jacobian) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-    int numPoints;
-    numPoints = (vectX->rows - 36)/4;
-
-    if( numPoints < 1 )//!!! Need to correct this minimal number of points
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "number of points must be more than 0" );
-    }
-
-    if( Jacobian->rows == numPoints*6 || Jacobian->cols != 36+numPoints*4 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of Jacobian is not correct it must be 6*numPoints x (36+numPoints*4)" );
-    }
-
-    /* Computed Jacobian in a given point */
-    /* This is for function with 3 projection matrices */
-    /* vector X consists of projection matrices and points3D */
-    /* each 3D points has X,Y,Z,W */
-    /* each projection matrices has 3x4 coeffs */
-    /* For N points 4D we have Jacobian 2N x (12*3+4N) */
-
-    /* Will store derivates as  */
-    /* Fill Jacobian matrix */
-    int currProjPoint;
-    int currMatr;
-
-    cvZero(Jacobian);
-    for( currMatr = 0; currMatr < 3; currMatr++ )
-    {
-        double p[12];
-        for( int i=0;i<12;i++ )
-        {
-            p[i] = cvmGet(vectX,currMatr*12+i,0);
-        }
-
-        int currVal = 36;
-        for( currProjPoint = 0; currProjPoint < numPoints; currProjPoint++ )
-        {
-            /* Compute */
-            double X[4];
-            X[0] = cvmGet(vectX,currVal++,0);
-            X[1] = cvmGet(vectX,currVal++,0);
-            X[2] = cvmGet(vectX,currVal++,0);
-            X[3] = cvmGet(vectX,currVal++,0);
-
-            double piX[3];
-            piX[0] = X[0]*p[0] + X[1]*p[1] + X[2]*p[2]  + X[3]*p[3];
-            piX[1] = X[0]*p[4] + X[1]*p[5] + X[2]*p[6]  + X[3]*p[7];
-            piX[2] = X[0]*p[8] + X[1]*p[9] + X[2]*p[10] + X[3]*p[11];
-
-            int i,j;
-            /* fill derivate by point */
-
-            double tmp3 = 1/(piX[2]*piX[2]);
-
-            double tmp1 = -piX[0]*tmp3;
-            double tmp2 = -piX[1]*tmp3;
-            for( j = 0; j < 2; j++ )//for x and y
-            {
-                for( i = 0; i < 4; i++ )// for X,Y,Z,W
-                {
-                    cvmSet( Jacobian,
-                            currMatr*numPoints*2+currProjPoint*2+j, 36+currProjPoint*4+i,
-                            (p[j*4+i]*piX[2]-p[8+i]*piX[j]) * tmp3  );
-                }
-            }
-                /* fill derivate by projection matrix */
-            for( i = 0; i < 4; i++ )
-            {
-                /* derivate for x */
-                cvmSet(Jacobian,currMatr*numPoints*2+currProjPoint*2,currMatr*12+i,X[i]/piX[2]);//x' p1i
-                cvmSet(Jacobian,currMatr*numPoints*2+currProjPoint*2,currMatr*12+8+i,X[i]*tmp1);//x' p3i
-
-                /* derivate for y */
-                cvmSet(Jacobian,currMatr*numPoints*2+currProjPoint*2+1,currMatr*12+4+i,X[i]/piX[2]);//y' p2i
-                cvmSet(Jacobian,currMatr*numPoints*2+currProjPoint*2+1,currMatr*12+8+i,X[i]*tmp2);//y' p3i
-            }
-
-        }
-    }
-
-    __END__;
-    return;
-}
-
-static void icvFunc_ProjTrifocal(const CvMat *vectX, CvMat *resFunc)
-{
-    /* Computes function in a given point */
-    /* Computers project points using 3 projection matrices and points 3D */
-
-    /* vector X consists of projection matrices and points3D */
-    /* each projection matrices has 3x4 coeffs */
-    /* each 3D points has X,Y,Z,W(?) */
-
-    /* result of function is projection of N 3D points using 3 projection matrices */
-    /* projected points store as (projection by matrix P1),(projection by matrix P2),(projection by matrix P3) */
-    /* each projection is x1,y1,x2,y2,x3,y3,x4,y4 */
-
-    /* Compute projection of points */
-
-    /* Fill projection matrices */
-
-    CV_FUNCNAME( "icvFunc_ProjTrifocal" );
-    __BEGIN__;
-
-    /* Test data for errors */
-    if( vectX == 0 || resFunc == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(vectX) || !CV_IS_MAT(resFunc) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-    int numPoints;
-    numPoints = (vectX->rows - 36)/4;
-
-    if( numPoints < 1 )//!!! Need to correct this minimal number of points
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "number of points must be more than 0" );
-    }
-
-    if( resFunc->rows == 2*numPoints*3 || resFunc->cols != 1 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of resFunc is not correct it must be 2*numPoints*3 x 1");
-    }
-
-
-    CvMat projMatrs[3];
-    double projMatrs_dat[36];
-    projMatrs[0] = cvMat(3,4,CV_64F,projMatrs_dat);
-    projMatrs[1] = cvMat(3,4,CV_64F,projMatrs_dat+12);
-    projMatrs[2] = cvMat(3,4,CV_64F,projMatrs_dat+24);
-
-    CvMat point3D;
-    double point3D_dat[3];
-    point3D = cvMat(3,1,CV_64F,point3D_dat);
-
-    int currMatr;
-    int currV;
-    int i,j;
-
-    currV=0;
-    for( currMatr = 0; currMatr < 3; currMatr++ )
-    {
-        for( i = 0; i < 3; i++ )
-        {
-            for( j = 0;j < 4; j++ )
-            {
-                double val = cvmGet(vectX,currV,0);
-                cvmSet(&projMatrs[currMatr],i,j,val);
-                currV++;
-            }
-        }
-    }
-
-    /* Project points */
-    int currPoint;
-    CvMat point4D;
-    double point4D_dat[4];
-    point4D = cvMat(4,1,CV_64F,point4D_dat);
-    for( currPoint = 0; currPoint < numPoints; currPoint++ )
-    {
-        /* get curr point */
-        point4D_dat[0] = cvmGet(vectX,currV++,0);
-        point4D_dat[1] = cvmGet(vectX,currV++,0);
-        point4D_dat[2] = cvmGet(vectX,currV++,0);
-        point4D_dat[3] = cvmGet(vectX,currV++,0);
-
-        for( currMatr = 0; currMatr < 3; currMatr++ )
-        {
-            /* Compute projection for current point */
-            cvmMul(&projMatrs[currMatr],&point4D,&point3D);
-            double z = point3D_dat[2];
-            cvmSet(resFunc,currMatr*numPoints*2 + currPoint*2,  0,point3D_dat[0]/z);
-            cvmSet(resFunc,currMatr*numPoints*2 + currPoint*2+1,0,point3D_dat[1]/z);
-        }
-    }
-
-    __END__;
-    return;
-}
-
-
-/*----------------------------------------------------------------------------------------*/
-
-static void icvOptimizeProjectionTrifocal(CvMat **projMatrs,CvMat **projPoints,
-                                CvMat **resultProjMatrs, CvMat *resultPoints4D)
-{
-
-    CvMat *optimX    = 0;
-    CvMat *points4D  = 0;
-    CvMat *vectorX0  = 0;
-    CvMat *observRes = 0;
-    //CvMat *error     = 0;
-
-    CV_FUNCNAME( "icvOptimizeProjectionTrifocal" );
-    __BEGIN__;
-
-    /* Test data for errors */
-    if( projMatrs == 0 || projPoints == 0 || resultProjMatrs == 0 || resultPoints4D == 0)
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(resultPoints4D) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "resultPoints4D must be a matrix" );
-    }
-
-    int numPoints;
-    numPoints = resultPoints4D->cols;
-    if( numPoints < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number points of resultPoints4D must be more than 0" );
-    }
-
-    if( resultPoints4D->rows != 4 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of coordinates of points4D must be 4" );
-    }
-
-    int i;
-    for( i = 0; i < 3; i++ )
-    {
-        if( projMatrs[i] == 0 )
-        {
-            CV_ERROR( CV_StsNullPtr, "Some of projMatrs is a NULL pointer" );
-        }
-
-        if( projPoints[i] == 0 )
-        {
-            CV_ERROR( CV_StsNullPtr, "Some of projPoints is a NULL pointer" );
-        }
-
-        if( resultProjMatrs[i] == 0 )
-        {
-            CV_ERROR( CV_StsNullPtr, "Some of resultProjMatrs is a NULL pointer" );
-        }
-
-        /* ----------- test for matrix ------------- */
-        if( !CV_IS_MAT(projMatrs[i]) )
-        {
-            CV_ERROR( CV_StsUnsupportedFormat, "Each of projMatrs must be a matrix" );
-        }
-
-        if( !CV_IS_MAT(projPoints[i]) )
-        {
-            CV_ERROR( CV_StsUnsupportedFormat, "Each of projPoints must be a matrix" );
-        }
-
-        if( !CV_IS_MAT(resultProjMatrs[i]) )
-        {
-            CV_ERROR( CV_StsUnsupportedFormat, "Each of resultProjMatrs must be a matrix" );
-        }
-
-        /* ------------- Test sizes --------------- */
-        if( projMatrs[i]->rows != 3 || projMatrs[i]->cols != 4 )
-        {
-            CV_ERROR( CV_StsUnmatchedSizes, "Size of projMatr must be 3x4" );
-        }
-
-        if( projPoints[i]->rows != 2 || projPoints[i]->cols != numPoints )
-        {
-            CV_ERROR( CV_StsUnmatchedSizes, "Size of resultProjMatrs must be 3x4" );
-        }
-
-        if( resultProjMatrs[i]->rows != 3 || resultProjMatrs[i]->cols != 4 )
-        {
-            CV_ERROR( CV_StsUnmatchedSizes, "Size of resultProjMatrs must be 3x4" );
-        }
-    }
-
-
-    /* Allocate memory for points 4D */
-    CV_CALL( points4D  = cvCreateMat(4,numPoints,CV_64F) );
-    CV_CALL( vectorX0  = cvCreateMat(36 + numPoints*4,1,CV_64F) );
-    CV_CALL( observRes = cvCreateMat(2*numPoints*3,1,CV_64F) );
-    CV_CALL( optimX    = cvCreateMat(36+numPoints*4,1,CV_64F) );
-    //CV_CALL( error     = cvCreateMat(numPoints*2*3,1,CV_64F) );
-
-
-    /* Reconstruct points 4D using projected points and projection matrices */
-    icvReconstructPointsFor3View( projMatrs[0],projMatrs[1],projMatrs[2],
-                                  projPoints[0],projPoints[1],projPoints[2],
-                                  points4D);
-
-
-
-    /* Fill observed points on images */
-    /* result of function is projection of N 3D points using 3 projection matrices */
-    /* projected points store as (projection by matrix P1),(projection by matrix P2),(projection by matrix P3) */
-    /* each projection is x1,y1,x2,y2,x3,y3,x4,y4 */
-    int currMatr;
-    for( currMatr = 0; currMatr < 3; currMatr++ )
-    {
-        for( i = 0; i < numPoints; i++ )
-        {
-            cvmSet(observRes,currMatr*numPoints*2+i*2  ,0,cvmGet(projPoints[currMatr],0,i) );/* x */
-            cvmSet(observRes,currMatr*numPoints*2+i*2+1,0,cvmGet(projPoints[currMatr],1,i) );/* y */
-        }
-    }
-
-    /* Fill with projection matrices */
-    for( currMatr = 0; currMatr < 3; currMatr++ )
-    {
-        int i;
-        for( i = 0; i < 12; i++ )
-        {
-            cvmSet(vectorX0,currMatr*12+i,0,cvmGet(projMatrs[currMatr],i/4,i%4));
-        }
-    }
-
-    /* Fill with 4D points */
-
-    int currPoint;
-    for( currPoint = 0; currPoint < numPoints; currPoint++ )
-    {
-        cvmSet(vectorX0,36 + currPoint*4 + 0,0,cvmGet(points4D,0,currPoint));
-        cvmSet(vectorX0,36 + currPoint*4 + 1,0,cvmGet(points4D,1,currPoint));
-        cvmSet(vectorX0,36 + currPoint*4 + 2,0,cvmGet(points4D,2,currPoint));
-        cvmSet(vectorX0,36 + currPoint*4 + 3,0,cvmGet(points4D,3,currPoint));
-    }
-
-
-    /* Allocate memory for result */
-    cvLevenbergMarquardtOptimization( icvJacobianFunction_ProjTrifocal, icvFunc_ProjTrifocal,
-                                      vectorX0,observRes,optimX,100,1e-6);
-
-    /* Copy results */
-    for( currMatr = 0; currMatr < 3; currMatr++ )
-    {
-        /* Copy projection matrices */
-        for(int i=0;i<12;i++)
-        {
-            cvmSet(resultProjMatrs[currMatr],i/4,i%4,cvmGet(optimX,currMatr*12+i,0));
-        }
-    }
-
-    /* Copy 4D points */
-    for( currPoint = 0; currPoint < numPoints; currPoint++ )
-    {
-        cvmSet(resultPoints4D,0,currPoint,cvmGet(optimX,36 + currPoint*4,0));
-        cvmSet(resultPoints4D,1,currPoint,cvmGet(optimX,36 + currPoint*4+1,0));
-        cvmSet(resultPoints4D,2,currPoint,cvmGet(optimX,36 + currPoint*4+2,0));
-        cvmSet(resultPoints4D,3,currPoint,cvmGet(optimX,36 + currPoint*4+3,0));
-    }
-
-    __END__;
-
-    /* Free allocated memory */
-    cvReleaseMat(&optimX);
-    cvReleaseMat(&points4D);
-    cvReleaseMat(&vectorX0);
-    cvReleaseMat(&observRes);
-
-    return;
-
-
-}
-
-/*------------------------------------------------------------------------------*/
-/* Create good points using status information */
-static void icvCreateGoodPoints(CvMat *points,CvMat **goodPoints, CvMat *status)
-{
-    *goodPoints = 0;
-
-    CV_FUNCNAME( "icvCreateGoodPoints" );
-    __BEGIN__;
-
-    int numPoints;
-    numPoints = points->cols;
-
-    if( numPoints < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points must be more than 0" );
-    }
-
-    int numCoord;
-    numCoord = points->rows;
-    if( numCoord < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points coordinates must be more than 0" );
-    }
-
-    /* Define number of good points */
-    int goodNum;
-    int i,j;
-
-    goodNum = 0;
-    for( i = 0; i < numPoints; i++)
-    {
-        if( cvmGet(status,0,i) > 0 )
-            goodNum++;
-    }
-
-    /* Allocate memory for good points */
-    CV_CALL( *goodPoints = cvCreateMat(numCoord,goodNum,CV_64F) );
-
-    for( i = 0; i < numCoord; i++ )
-    {
-        int currPoint = 0;
-        for( j = 0; j < numPoints; j++)
-        {
-            if( cvmGet(status,0,j) > 0 )
-            {
-                cvmSet(*goodPoints,i,currPoint,cvmGet(points,i,j));
-                currPoint++;
-            }
-        }
-    }
-    __END__;
-    return;
-}
-
-#endif
diff --git a/modules/legacy/src/lines.cpp b/modules/legacy/src/lines.cpp
deleted file mode 100644 (file)
index 48eaf79..0000000
+++ /dev/null
@@ -1,479 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-#if 0
-CvStatus
-icvFetchLine8uC3R( uchar * src, int src_step,
-                   uchar * dst, int *dst_num, CvSize src_size, CvPoint start, CvPoint end )
-{
-    int i;
-    int dx = end.x - start.x, dy = end.y - start.y;
-    int err;
-
-    if( !src || !dst || (src_size.width | src_size.height) < 0 ||
-        src_step < src_size.width * 3 ||
-        (unsigned) start.x >= (unsigned) src_size.width ||
-        (unsigned) start.y >= (unsigned) src_size.height ||
-        (unsigned) end.x >= (unsigned) src_size.width ||
-        (unsigned) end.y >= (unsigned) src_size.height )
-        return CV_BADFACTOR_ERR;
-
-    if( dx < 0 )
-    {
-        dx = -dx;
-        dy = -dy;
-        start.x = end.x;
-        start.y = end.y;
-    }
-
-    src += start.y * src_step + start.x * 3;
-
-    i = dy >> 31;
-    dy = (dy ^ i) - i;
-    src_step = (src_step ^ i) - i;
-
-    if( dx > dy )
-    {
-        if( dst_num )
-        {
-            if( *dst_num <= dx )
-                return CV_BADSIZE_ERR;
-            *dst_num = dx + 1;
-        }
-        err = dx;
-        dx += dx;
-        dy += dy;
-        for( i = dx; i >= 0; i -= 2, dst += 3 )
-        {
-            int mask = (err -= dy) < 0 ? -1 : 0;
-
-            dst[0] = src[0];
-            dst[1] = src[1];
-            dst[2] = src[2];
-
-            err += dx & mask;
-            src += (src_step & mask) + 3;
-        }
-    }
-    else
-    {
-        if( dst_num )
-        {
-            if( *dst_num <= dy )
-                return CV_BADSIZE_ERR;
-            *dst_num = dy + 1;
-        }
-        err = dy;
-        dx += dx;
-        dy += dy;
-        for( i = dy; i >= 0; i -= 2, dst += 3 )
-        {
-            int mask = (err -= dx) < 0 ? -1 : 0;
-
-            dst[0] = src[0];
-            dst[1] = src[1];
-            dst[2] = src[2];
-
-            err += dy & mask;
-            src += src_step + (mask & 3);
-        }
-    }
-    return CV_NO_ERR;
-}
-
-CvStatus
-icvDrawLine8uC3R( uchar * src, int src_num,
-                  uchar * dst, int dst_step, CvSize dst_size, CvPoint start, CvPoint end )
-{
-    int i;
-    int dx = end.x - start.x, dy = end.y - start.y;
-    int err;
-
-    if( !src || !dst || (dst_size.width | dst_size.height) < 0 ||
-        dst_step < dst_size.width * 3 ||
-        (unsigned) start.x >= (unsigned) dst_size.width ||
-        (unsigned) start.y >= (unsigned) dst_size.height ||
-        (unsigned) end.x >= (unsigned) dst_size.width ||
-        (unsigned) end.y >= (unsigned) dst_size.height )
-        return CV_BADFACTOR_ERR;
-
-    if( dx < 0 )
-    {
-        dx = -dx;
-        dy = -dy;
-        start.x = end.x;
-        start.y = end.y;
-    }
-
-    dst += start.y * dst_step + start.x * 3;
-
-    i = dy >> 31;
-    dy = (dy ^ i) - i;
-    dst_step = (dst_step ^ i) - i;
-
-    if( dx > dy )
-    {
-        if( (unsigned) (src_num - 1) < (unsigned) dx )
-            return CV_BADSIZE_ERR;
-        err = dx;
-        dx += dx;
-        dy += dy;
-        for( i = dx; i >= 0; i -= 2, src += 3 )
-        {
-            int mask = (err -= dy) < 0 ? -1 : 0;
-
-            dst[0] = src[0];
-            dst[1] = src[1];
-            dst[2] = src[2];
-            err += dx & mask;
-            dst += (dst_step & mask) + 3;
-        }
-    }
-    else
-    {
-        if( (unsigned) (src_num - 1) < (unsigned) dy )
-            return CV_BADSIZE_ERR;
-        err = dy;
-        dx += dx;
-        dy += dy;
-        for( i = dy; i >= 0; i -= 2, src += 3 )
-        {
-            int mask = (err -= dx) < 0 ? -1 : 0;
-
-            dst[0] = src[0];
-            dst[1] = src[1];
-            dst[2] = src[2];
-            err += dy & mask;
-            dst += dst_step + (mask & 3);
-        }
-    }
-    return CV_NO_ERR;
-}
-#endif
-
-/*======================================================================================*/
-
-static CvStatus
-icvPreWarpImage8uC3R( int numLines,     /* number of scanlines   */
-                      uchar * src,      /* source image          */
-                      int src_step,     /* line step         */
-                      uchar * dst,      /* dest buffers          */
-                      int *dst_nums,    /* lens of buffer        */
-                      CvSize src_size,  /* image size in pixels */
-                      int *scanlines )  /* scanlines array       */
-{
-    int k;
-    CvPoint start;
-    CvPoint end;
-    int curr;
-    int curr_dst;
-    CvMat mat;
-
-    curr = 0;
-    curr_dst = 0;
-
-    cvInitMatHeader( &mat, src_size.height, src_size.width, CV_8UC3, src, src_step );
-
-    for( k = 0; k < numLines; k++ )
-    {
-        start.x = scanlines[curr++];
-        start.y = scanlines[curr++];
-
-        end.x = scanlines[curr++];
-        end.y = scanlines[curr++];
-
-#ifdef _DEBUG
-        {
-        CvLineIterator iterator;
-        assert( cvInitLineIterator( &mat, start, end, &iterator, 8 ) == dst_nums[k] );
-        }
-#endif
-        cvSampleLine( &mat, start, end, dst + curr_dst, 8 );
-        curr_dst += dst_nums[k] * 3;
-
-    }
-
-    return CV_NO_ERR;
-}
-
-
-/*======================================================================================*/
-
-static CvStatus
-icvPostWarpImage8uC3R( int numLines,    /* number of scanlines  */
-                       uchar * src,     /* source buffers       */
-                       int *src_nums,   /* lens of buffers      */
-                       uchar * dst,     /* dest image           */
-                       int dst_step,    /* dest image step      */
-                       CvSize dst_size, /* dest image size      */
-                       int *scanlines ) /* scanline             */
-{
-    int i, k;
-    CvPoint start;
-    CvPoint end;
-    int curr;
-    int src_num;
-    int curr_src;
-    CvMat mat;
-    CvLineIterator iterator;
-
-    curr = 0;
-    curr_src = 0;
-
-    cvInitMatHeader( &mat, dst_size.height, dst_size.width, CV_8UC3, dst, dst_step );
-
-    for( k = 0; k < numLines; k++ )
-    {
-        start.x = scanlines[curr++];
-        start.y = scanlines[curr++];
-
-        end.x = scanlines[curr++];
-        end.y = scanlines[curr++];
-
-        src_num = src_nums[k];
-
-        if( cvInitLineIterator( &mat, start, end, &iterator, 8 ) != src_num )
-        {
-            assert(0);
-            return CV_NOTDEFINED_ERR;
-        }
-
-        for( i = 0; i < src_num; i++ )
-        {
-            memcpy( iterator.ptr, src + curr_src, 3 );
-            CV_NEXT_LINE_POINT( iterator );
-            curr_src += 3;
-        }
-
-#if 0
-        err = icvDrawLine8uC3R( src + curr_src, /* sourse buffer    */
-                                src_num,        /* len of buffer    */
-                                dst,    /* dest image       */
-                                dst_step,       /* dest image step  */
-                                dst_size,       /* dest image size  */
-                                start,  /* start point      */
-                                end );  /* end point        */
-        curr_src += src_num * 3;
-#endif
-    }
-
-    return CV_NO_ERR;
-
-}
-
-
-/*======================================================================================*/
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name:    icvDeleteMoire8uC3R
-//    Purpose:
-//      Function deletes moire - replaces black uncovered pixels with their neighboors.
-//    Context:
-//    Parameters:
-//      img       - image data
-//      img_step  - distance between lines in bytes
-//      img_size  - width and height of the image in pixels
-//    Returns:
-//      CV_NO_ERR if all Ok or error code
-//    Notes:
-//F*/
-static CvStatus
-icvDeleteMoire8u( uchar * img, int img_step, CvSize img_size, int cn )
-{
-    int x, y;
-    uchar *src = img, *dst = img + img_step;
-
-    if( !img || img_size.width <= 0 || img_size.height <= 0 || img_step < img_size.width * 3 )
-        return CV_BADFACTOR_ERR;
-
-    img_size.width *= cn;
-
-    for( y = 1; y < img_size.height; y++, src = dst, dst += img_step )
-    {
-        switch( cn )
-        {
-        case 1:
-            for( x = 0; x < img_size.width; x++ )
-            {
-                if( dst[x] == 0 )
-                    dst[x] = src[x];
-            }
-            break;
-        case 3:
-            for( x = 0; x < img_size.width; x += 3 )
-            {
-                if( dst[x] == 0 && dst[x + 1] == 0 && dst[x + 2] == 0 )
-                {
-                    dst[x] = src[x];
-                    dst[x + 1] = src[x + 1];
-                    dst[x + 2] = src[x + 2];
-                }
-            }
-            break;
-        default:
-            assert(0);
-            break;
-        }
-    }
-
-    return CV_NO_ERR;
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: cvDeleteMoire
-//    Purpose: The functions delete moire on the image after ViewMorphing
-//    Context:
-//    Parameters:  img        - image on which will delete moire
-//
-//    Notes:
-//F*/
-CV_IMPL void
-cvDeleteMoire( IplImage * img )
-{
-    uchar *img_data = 0;
-    int img_step = 0;
-    CvSize img_size;
-
-    CV_FUNCNAME( "cvDeleteMoire" );
-
-    __BEGIN__;
-
-    cvGetImageRawData( img, &img_data, &img_step, &img_size );
-
-    if( img->nChannels != 1 && img->nChannels != 3 )
-        CV_ERROR( CV_BadNumChannels, "Source image must have 3 channel." );
-    if( img->depth != IPL_DEPTH_8U )
-        CV_ERROR( CV_BadDepth, "Channel depth of source image must be 8." );
-
-    CV_CALL( icvDeleteMoire8u( img_data, img_step, img_size, img->nChannels ));
-
-    __END__;
-
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: cvPreWarpImage
-//    Purpose: The functions warp image for next stage of ViewMorphing
-//    Context:
-//    Parameters:  img        - initial image (in the beginning)
-//
-//    Notes:
-//F*/
-CV_IMPL void
-cvPreWarpImage( int numLines,   /* number of scanlines */
-                IplImage * img, /* Source Image       */
-                uchar * dst,    /* dest buffers       */
-                int *dst_nums,  /* lens of buffer     */
-                int *scanlines /* scanlines array    */  )
-{
-    uchar *img_data = 0;
-    int img_step = 0;
-    CvSize img_size;
-
-    CV_FUNCNAME( "cvPreWarpImage" );
-
-    __BEGIN__;
-
-    cvGetImageRawData( img, &img_data, &img_step, &img_size );
-
-    if( img->nChannels != 3 )
-        CV_ERROR( CV_BadNumChannels, "Source image must have 3 channel." );
-    if( img->depth != IPL_DEPTH_8U )
-        CV_ERROR( CV_BadDepth, "Channel depth of image must be 8." );
-
-    CV_CALL( icvPreWarpImage8uC3R( numLines,    /* number of scanlines  */
-                                   img_data,    /* source image         */
-                                   img_step,    /* line step            */
-                                   dst, /* dest buffers         */
-                                   dst_nums,    /* lens of buffer       */
-                                   img_size,    /* image size in pixels */
-                                   scanlines /* scanlines array      */  ));
-
-    __END__;
-
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: cvPostWarpImage
-//    Purpose: The functions postwarp the image after morphing
-//    Context:
-//    Parameters:  img        - initial image (in the beginning)
-//
-//    Notes:
-//F*/
-CV_IMPL void
-cvPostWarpImage( int numLines,  /* number of scanlines  */
-                 uchar * src,   /* source buffers       */
-                 int *src_nums, /* lens of buffers      */
-                 IplImage * img,        /* dest image           */
-                 int *scanlines /* scanline             */  )
-{
-    uchar *img_data = 0;
-    int img_step = 0;
-    CvSize img_size;
-
-    CV_FUNCNAME( "cvPostWarpImage" );
-
-    __BEGIN__;
-
-    cvGetImageRawData( img, &img_data, &img_step, &img_size );
-
-    if( img->nChannels != 3 )
-        CV_ERROR( CV_BadNumChannels, "Source image must have 3 channel." );
-    if( img->depth != IPL_DEPTH_8U )
-        CV_ERROR( CV_BadDepth, "Channel depth of image must be 8." );
-
-    CV_CALL( icvPostWarpImage8uC3R( numLines,   /* number of scanlines   */
-                                    src,        /* source buffers       */
-                                    src_nums,   /* lens of buffers      */
-                                    img_data,   /* dest image           */
-                                    img_step,   /* dest image step      */
-                                    img_size,   /* dest image size      */
-                                    scanlines /* scanline             */  ));
-
-    __END__;
-}
-
-/* End of file */
diff --git a/modules/legacy/src/lmeds.cpp b/modules/legacy/src/lmeds.cpp
deleted file mode 100644 (file)
index f05f2a0..0000000
+++ /dev/null
@@ -1,1695 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-#include "_vm.h"
-#include <stdlib.h>
-
-#define Sgn(x)              ( (x)<0 ? -1:1 )    /* Sgn(0) = 1 ! */
-/*===========================================================================*/
-CvStatus
-icvLMedS( int *points1, int *points2, int numPoints, CvMatrix3 * fundamentalMatrix )
-{
-    int sample, j, amount_samples, done;
-    int amount_solutions;
-    int ml7[21], mr7[21];
-
-    double F_try[9 * 3];
-    double F[9];
-    double Mj, Mj_new;
-
-    int i, num;
-
-    int *ml;
-    int *mr;
-    int *new_ml;
-    int *new_mr;
-    int new_num;
-    CvStatus error;
-
-    error = CV_NO_ERR;
-
-    if( fundamentalMatrix == 0 )
-        return CV_BADFACTOR_ERR;
-
-    num = numPoints;
-
-    if( num < 6 )
-    {
-        return CV_BADFACTOR_ERR;
-    }                           /* if */
-
-    ml = (int *) cvAlloc( sizeof( int ) * num * 3 );
-    mr = (int *) cvAlloc( sizeof( int ) * num * 3 );
-
-    for( i = 0; i < num; i++ )
-    {
-
-        ml[i * 3] = points1[i * 2];
-        ml[i * 3 + 1] = points1[i * 2 + 1];
-
-        ml[i * 3 + 2] = 1;
-
-        mr[i * 3] = points2[i * 2];
-        mr[i * 3 + 1] = points2[i * 2 + 1];
-
-        mr[i * 3 + 2] = 1;
-    }                           /* for */
-
-    if( num > 7 )
-    {
-
-        Mj = -1;
-        amount_samples = 1000;  /*  -------  Must be changed !  --------- */
-
-        for( sample = 0; sample < amount_samples; sample++ )
-        {
-
-            icvChoose7( ml, mr, num, ml7, mr7 );
-            icvPoint7( ml7, mr7, F_try, &amount_solutions );
-
-            for( i = 0; i < amount_solutions / 9; i++ )
-            {
-
-                Mj_new = icvMedian( ml, mr, num, F_try + i * 9 );
-
-                if( Mj_new >= 0 && (Mj == -1 || Mj_new < Mj) )
-                {
-
-                    for( j = 0; j < 9; j++ )
-                    {
-
-                        F[j] = F_try[i * 9 + j];
-                    }           /* for */
-
-                    Mj = Mj_new;
-                }               /* if */
-            }                   /* for */
-        }                       /* for */
-
-        if( Mj == -1 )
-            return CV_BADFACTOR_ERR;
-
-        done = icvBoltingPoints( ml, mr, num, F, Mj, &new_ml, &new_mr, &new_num );
-
-        if( done == -1 )
-        {
-
-            cvFree( &mr );
-            cvFree( &ml );
-            return CV_OUTOFMEM_ERR;
-        }                       /* if */
-
-        if( done > 7 )
-            error = icvPoints8( new_ml, new_mr, new_num, F );
-
-        cvFree( &new_mr );
-        cvFree( &new_ml );
-
-    }
-    else
-    {
-        error = icvPoint7( ml, mr, F, &i );
-    }                           /* if */
-
-    if( error == CV_NO_ERR )
-        error = icvRank2Constraint( F );
-
-    for( i = 0; i < 3; i++ )
-        for( j = 0; j < 3; j++ )
-            fundamentalMatrix->m[i][j] = (float) F[i * 3 + j];
-
-    return error;
-
-}                               /* icvLMedS */
-
-/*===========================================================================*/
-/*===========================================================================*/
-
-#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Warray-bounds"
-#endif
-
-void
-icvChoose7( int *ml, int *mr, int num, int *ml7, int *mr7 )
-{
-    int indexes[7], i, j;
-
-    if( !ml || !mr || num < 7 || !ml7 || !mr7 )
-        return;
-
-    for( i = 0; i < 7; i++ )
-    {
-
-        indexes[i] = (int) ((double) rand() / RAND_MAX * num);
-
-        for( j = 0; j < i; j++ )
-        {
-
-            if( indexes[i] == indexes[j] )
-                i--;
-        }                       /* for */
-    }                           /* for */
-
-    for( i = 0; i < 21; i++ )
-    {
-
-        ml7[i] = ml[3 * indexes[i / 3] + i % 3];
-        mr7[i] = mr[3 * indexes[i / 3] + i % 3];
-    }                           /* for */
-}                               /* cs_Choose7 */
-
-/*===========================================================================*/
-/*===========================================================================*/
-CvStatus
-icvCubic( double a2, double a1, double a0, double *squares )
-{
-    double p, q, D, c1, c2, b1, b2, ro1, ro2, fi1, fi2, tt;
-    double x[6][3];
-    int i, j, t;
-
-    if( !squares )
-        return CV_BADFACTOR_ERR;
-
-    p = a1 - a2 * a2 / 3;
-    q = (9 * a1 * a2 - 27 * a0 - 2 * a2 * a2 * a2) / 27;
-    D = q * q / 4 + p * p * p / 27;
-
-    if( D < 0 )
-    {
-
-        c1 = q / 2;
-        c2 = c1;
-        b1 = sqrt( -D );
-        b2 = -b1;
-
-        ro1 = sqrt( c1 * c1 - D );
-        ro2 = ro1;
-
-        fi1 = atan2( b1, c1 );
-        fi2 = -fi1;
-    }
-    else
-    {
-
-        c1 = q / 2 + sqrt( D );
-        c2 = q / 2 - sqrt( D );
-        b1 = 0;
-        b2 = 0;
-
-        ro1 = fabs( c1 );
-        ro2 = fabs( c2 );
-        fi1 = CV_PI * (1 - SIGN( c1 )) / 2;
-        fi2 = CV_PI * (1 - SIGN( c2 )) / 2;
-    }                           /* if */
-
-    for( i = 0; i < 6; i++ )
-    {
-
-        x[i][0] = -a2 / 3;
-        x[i][1] = 0;
-        x[i][2] = 0;
-
-        squares[i] = x[i][i % 2];
-    }                           /* for */
-
-    if( !REAL_ZERO( ro1 ))
-    {
-        tt = SIGN( ro1 ) * pow( fabs( ro1 ), 0.333333333333 );
-        c1 = tt - p / (3. * tt);
-        c2 = tt + p / (3. * tt);
-    }                           /* if */
-
-    if( !REAL_ZERO( ro2 ))
-    {
-        tt = SIGN( ro2 ) * pow( fabs( ro2 ), 0.333333333333 );
-        b1 = tt - p / (3. * tt);
-        b2 = tt + p / (3. * tt);
-    }                           /* if */
-
-    for( i = 0; i < 6; i++ )
-    {
-
-        if( i < 3 )
-        {
-
-            if( !REAL_ZERO( ro1 ))
-            {
-
-                x[i][0] = cos( fi1 / 3. + 2 * CV_PI * (i % 3) / 3. ) * c1 - a2 / 3;
-                x[i][1] = sin( fi1 / 3. + 2 * CV_PI * (i % 3) / 3. ) * c2;
-            }
-            else
-            {
-
-                x[i][2] = 1;
-            }                   /* if */
-        }
-        else
-        {
-
-            if( !REAL_ZERO( ro2 ))
-            {
-
-                x[i][0] = cos( fi2 / 3. + 2 * CV_PI * (i % 3) / 3. ) * b1 - a2 / 3;
-                x[i][1] = sin( fi2 / 3. + 2 * CV_PI * (i % 3) / 3. ) * b2;
-            }
-            else
-            {
-
-                x[i][2] = 1;
-            }                   /* if */
-        }                       /* if */
-    }                           /* for */
-
-    t = 0;
-
-    for( i = 0; i < 6; i++ )
-    {
-
-        if( !x[i][2] )
-        {
-
-            squares[t++] = x[i][0];
-            squares[t++] = x[i][1];
-            x[i][2] = 1;
-
-            for( j = i + 1; j < 6; j++ )
-            {
-
-                if( !x[j][2] && REAL_ZERO( x[i][0] - x[j][0] )
-                    && REAL_ZERO( x[i][1] - x[j][1] ))
-                {
-
-                    x[j][2] = 1;
-                    break;
-                }               /* if */
-            }                   /* for */
-        }                       /* if */
-    }                           /* for */
-    return CV_NO_ERR;
-}                               /* icvCubic */
-
-#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
-# pragma GCC diagnostic pop
-#endif
-
-/*======================================================================================*/
-double
-icvDet( double *M )
-{
-    double value;
-
-    if( !M )
-        return 0;
-
-    value = M[0] * M[4] * M[8] + M[2] * M[3] * M[7] + M[1] * M[5] * M[6] -
-        M[2] * M[4] * M[6] - M[0] * M[5] * M[7] - M[1] * M[3] * M[8];
-
-    return value;
-
-}                               /* icvDet */
-
-/*===============================================================================*/
-double
-icvMinor( double *M, int x, int y )
-{
-    int row1, row2, col1, col2;
-    double value;
-
-    if( !M || x < 0 || x > 2 || y < 0 || y > 2 )
-        return 0;
-
-    row1 = (y == 0 ? 1 : 0);
-    row2 = (y == 2 ? 1 : 2);
-    col1 = (x == 0 ? 1 : 0);
-    col2 = (x == 2 ? 1 : 2);
-
-    value = M[row1 * 3 + col1] * M[row2 * 3 + col2] - M[row2 * 3 + col1] * M[row1 * 3 + col2];
-
-    value *= 1 - (x + y) % 2 * 2;
-
-    return value;
-
-}                               /* icvMinor */
-
-/*======================================================================================*/
-CvStatus
-icvGetCoef( double *f1, double *f2, double *a2, double *a1, double *a0 )
-{
-    double G[9], a3;
-    int i;
-
-    if( !f1 || !f2 || !a0 || !a1 || !a2 )
-        return CV_BADFACTOR_ERR;
-
-    for( i = 0; i < 9; i++ )
-    {
-
-        G[i] = f1[i] - f2[i];
-    }                           /* for */
-
-    a3 = icvDet( G );
-
-    if( REAL_ZERO( a3 ))
-        return CV_BADFACTOR_ERR;
-
-    *a2 = 0;
-    *a1 = 0;
-    *a0 = icvDet( f2 );
-
-    for( i = 0; i < 9; i++ )
-    {
-
-        *a2 += f2[i] * icvMinor( G, (int) (i % 3), (int) (i / 3) );
-        *a1 += G[i] * icvMinor( f2, (int) (i % 3), (int) (i / 3) );
-    }                           /* for */
-
-    *a0 /= a3;
-    *a1 /= a3;
-    *a2 /= a3;
-
-    return CV_NO_ERR;
-
-}                               /* icvGetCoef */
-
-/*===========================================================================*/
-double
-icvMedian( int *ml, int *mr, int num, double *F )
-{
-    double l1, l2, l3, d1, d2, value;
-    double *deviation;
-    int i, i3;
-
-    if( !ml || !mr || !F )
-        return -1;
-
-    deviation = (double *) cvAlloc( (num) * sizeof( double ));
-
-    if( !deviation )
-        return -1;
-
-    for( i = 0, i3 = 0; i < num; i++, i3 += 3 )
-    {
-
-        l1 = F[0] * mr[i3] + F[1] * mr[i3 + 1] + F[2];
-        l2 = F[3] * mr[i3] + F[4] * mr[i3 + 1] + F[5];
-        l3 = F[6] * mr[i3] + F[7] * mr[i3 + 1] + F[8];
-
-        d1 = (l1 * ml[i3] + l2 * ml[i3 + 1] + l3) / sqrt( l1 * l1 + l2 * l2 );
-
-        l1 = F[0] * ml[i3] + F[3] * ml[i3 + 1] + F[6];
-        l2 = F[1] * ml[i3] + F[4] * ml[i3 + 1] + F[7];
-        l3 = F[2] * ml[i3] + F[5] * ml[i3 + 1] + F[8];
-
-        d2 = (l1 * mr[i3] + l2 * mr[i3 + 1] + l3) / sqrt( l1 * l1 + l2 * l2 );
-
-        deviation[i] = (double) (d1 * d1 + d2 * d2);
-    }                           /* for */
-
-    if( icvSort( deviation, num ) != CV_NO_ERR )
-    {
-
-        cvFree( &deviation );
-        return -1;
-    }                           /* if */
-
-    value = deviation[num / 2];
-    cvFree( &deviation );
-    return value;
-
-}                               /* cs_Median */
-
-/*===========================================================================*/
-CvStatus
-icvSort( double *array, int length )
-{
-    int i, j, index;
-    double swapd;
-
-    if( !array || length < 1 )
-        return CV_BADFACTOR_ERR;
-
-    for( i = 0; i < length - 1; i++ )
-    {
-
-        index = i;
-
-        for( j = i + 1; j < length; j++ )
-        {
-
-            if( array[j] < array[index] )
-                index = j;
-        }                       /* for */
-
-        if( index - i )
-        {
-
-            swapd = array[i];
-            array[i] = array[index];
-            array[index] = swapd;
-        }                       /* if */
-    }                           /* for */
-
-    return CV_NO_ERR;
-
-}                               /* cs_Sort */
-
-/*===========================================================================*/
-int
-icvBoltingPoints( int *ml, int *mr,
-                  int num, double *F, double Mj, int **new_ml, int **new_mr, int *new_num )
-{
-    double l1, l2, l3, d1, d2, sigma;
-    int i, j, length;
-    int *index;
-
-    if( !ml || !mr || num < 1 || !F || Mj < 0 )
-        return -1;
-
-    index = (int *) cvAlloc( (num) * sizeof( int ));
-
-    if( !index )
-        return -1;
-
-    length = 0;
-    sigma = (double) (2.5 * 1.4826 * (1 + 5. / (num - 7)) * sqrt( Mj ));
-
-    for( i = 0; i < num * 3; i += 3 )
-    {
-
-        l1 = F[0] * mr[i] + F[1] * mr[i + 1] + F[2];
-        l2 = F[3] * mr[i] + F[4] * mr[i + 1] + F[5];
-        l3 = F[6] * mr[i] + F[7] * mr[i + 1] + F[8];
-
-        d1 = (l1 * ml[i] + l2 * ml[i + 1] + l3) / sqrt( l1 * l1 + l2 * l2 );
-
-        l1 = F[0] * ml[i] + F[3] * ml[i + 1] + F[6];
-        l2 = F[1] * ml[i] + F[4] * ml[i + 1] + F[7];
-        l3 = F[2] * ml[i] + F[5] * ml[i + 1] + F[8];
-
-        d2 = (l1 * mr[i] + l2 * mr[i + 1] + l3) / sqrt( l1 * l1 + l2 * l2 );
-
-        if( d1 * d1 + d2 * d2 <= sigma * sigma )
-        {
-
-            index[i / 3] = 1;
-            length++;
-        }
-        else
-        {
-
-            index[i / 3] = 0;
-        }                       /* if */
-    }                           /* for */
-
-    *new_num = length;
-
-    *new_ml = (int *) cvAlloc( (length * 3) * sizeof( int ));
-
-    if( !new_ml )
-    {
-
-        cvFree( &index );
-        return -1;
-    }                           /* if */
-
-    *new_mr = (int *) cvAlloc( (length * 3) * sizeof( int ));
-
-    if( !new_mr )
-    {
-
-        cvFree( &new_ml );
-        cvFree( &index );
-        return -1;
-    }                           /* if */
-
-    j = 0;
-
-    for( i = 0; i < num * 3; )
-    {
-
-        if( index[i / 3] )
-        {
-
-            (*new_ml)[j] = ml[i];
-            (*new_mr)[j++] = mr[i++];
-            (*new_ml)[j] = ml[i];
-            (*new_mr)[j++] = mr[i++];
-            (*new_ml)[j] = ml[i];
-            (*new_mr)[j++] = mr[i++];
-        }
-        else
-            i += 3;
-    }                           /* for */
-
-    cvFree( &index );
-    return length;
-
-}                               /* cs_BoltingPoints */
-
-/*===========================================================================*/
-CvStatus
-icvPoints8( int *ml, int *mr, int num, double *F )
-{
-    double *U;
-    double l1, l2, w, old_norm = -1, new_norm = -2, summ;
-    int i3, i9, j, num3, its = 0, a, t;
-
-    if( !ml || !mr || num < 8 || !F )
-        return CV_BADFACTOR_ERR;
-
-    U = (double *) cvAlloc( (num * 9) * sizeof( double ));
-
-    if( !U )
-        return CV_OUTOFMEM_ERR;
-
-    num3 = num * 3;
-
-    while( !REAL_ZERO( new_norm - old_norm ))
-    {
-
-        if( its++ > 1e+2 )
-        {
-
-            cvFree( &U );
-            return CV_BADFACTOR_ERR;
-        }                       /* if */
-
-        old_norm = new_norm;
-
-        for( i3 = 0, i9 = 0; i3 < num3; i3 += 3, i9 += 9 )
-        {
-
-            l1 = F[0] * mr[i3] + F[1] * mr[i3 + 1] + F[2];
-            l2 = F[3] * mr[i3] + F[4] * mr[i3 + 1] + F[5];
-
-            if( REAL_ZERO( l1 ) && REAL_ZERO( l2 ))
-            {
-
-                cvFree( &U );
-                return CV_BADFACTOR_ERR;
-            }                   /* if */
-
-            w = 1 / (l1 * l1 + l2 * l2);
-
-            l1 = F[0] * ml[i3] + F[3] * ml[i3 + 1] + F[6];
-            l2 = F[1] * ml[i3] + F[4] * ml[i3 + 1] + F[7];
-
-            if( REAL_ZERO( l1 ) && REAL_ZERO( l2 ))
-            {
-
-                cvFree( &U );
-                return CV_BADFACTOR_ERR;
-            }                   /* if */
-
-            w += 1 / (l1 * l1 + l2 * l2);
-            w = sqrt( w );
-
-            for( j = 0; j < 9; j++ )
-            {
-
-                U[i9 + j] = w * (double) ml[i3 + j / 3] * (double) mr[i3 + j % 3];
-            }                   /* for */
-        }                       /* for */
-
-        new_norm = 0;
-
-        for( a = 0; a < num; a++ )
-        {                       /* row */
-
-            summ = 0;
-
-            for( t = 0; t < 9; t++ )
-            {
-
-                summ += U[a * 9 + t] * F[t];
-            }                   /* for */
-
-            new_norm += summ * summ;
-        }                       /* for */
-
-        new_norm = sqrt( new_norm );
-
-        icvAnalyticPoints8( U, num, F );
-    }                           /* while */
-
-    cvFree( &U );
-    return CV_NO_ERR;
-
-}                               /* cs_Points8 */
-
-/*===========================================================================*/
-double
-icvAnalyticPoints8( double *A, int num, double *F )
-{
-    double *U;
-    double V[8 * 8];
-    double W[8];
-    double *f;
-    double solution[9];
-    double temp1[8 * 8];
-    double *temp2;
-    double *A_short;
-    double norm, summ, best_norm;
-    int num8 = num * 8, num9 = num * 9;
-    int i, j, j8, j9, value, a, a8, a9, a_num, b, b8, t;
-
-    /* --------- Initialization data ------------------ */
-
-    if( !A || num < 8 || !F )
-        return -1;
-
-    best_norm = -1;
-    U = (double *) cvAlloc( (num8) * sizeof( double ));
-
-    if( !U )
-        return -1;
-
-    f = (double *) cvAlloc( (num) * sizeof( double ));
-
-    if( !f )
-    {
-        cvFree( &U );
-        return -1;
-    }                           /* if */
-
-    temp2 = (double *) cvAlloc( (num8) * sizeof( double ));
-
-    if( !temp2 )
-    {
-        cvFree( &f );
-        cvFree( &U );
-        return -1;
-    }                           /* if */
-
-    A_short = (double *) cvAlloc( (num8) * sizeof( double ));
-
-    if( !A_short )
-    {
-        cvFree( &temp2 );
-        cvFree( &f );
-        cvFree( &U );
-        return -1;
-    }                           /* if */
-
-    for( i = 0; i < 8; i++ )
-    {
-        for( j8 = 0, j9 = 0; j9 < num9; j8 += 8, j9 += 9 )
-        {
-            A_short[j8 + i] = A[j9 + i + 1];
-        }                       /* for */
-    }                           /* for */
-
-    for( i = 0; i < 9; i++ )
-    {
-
-        for( j = 0, j8 = 0, j9 = 0; j < num; j++, j8 += 8, j9 += 9 )
-        {
-
-            f[j] = -A[j9 + i];
-
-            if( i )
-                A_short[j8 + i - 1] = A[j9 + i - 1];
-        }                       /* for */
-
-        value = icvSingularValueDecomposition( num, 8, A_short, W, 1, U, 1, V );
-
-        if( !value )
-        {                       /* -----------  computing the solution  ----------- */
-
-            /*  -----------  W = W(-1)  ----------- */
-            for( j = 0; j < 8; j++ )
-            {
-                if( !REAL_ZERO( W[j] ))
-                    W[j] = 1 / W[j];
-            }                   /* for */
-
-            /* -----------  temp1 = V * W(-1)  ----------- */
-            for( a8 = 0; a8 < 64; a8 += 8 )
-            {                   /* row */
-                for( b = 0; b < 8; b++ )
-                {               /* column */
-                    temp1[a8 + b] = V[a8 + b] * W[b];
-                }               /* for */
-            }                   /* for */
-
-            /*  -----------  temp2 = V * W(-1) * U(T)  ----------- */
-            for( a8 = 0, a_num = 0; a8 < 64; a8 += 8, a_num += num )
-            {                   /* row */
-                for( b = 0, b8 = 0; b < num; b++, b8 += 8 )
-                {               /* column */
-
-                    temp2[a_num + b] = 0;
-
-                    for( t = 0; t < 8; t++ )
-                    {
-
-                        temp2[a_num + b] += temp1[a8 + t] * U[b8 + t];
-                    }           /* for */
-                }               /* for */
-            }                   /* for */
-
-            /* -----------  solution = V * W(-1) * U(T) * f  ----------- */
-            for( a = 0, a_num = 0; a < 8; a++, a_num += num )
-            {                   /* row */
-                for( b = 0; b < num; b++ )
-                {               /* column */
-
-                    solution[a] = 0;
-
-                    for( t = 0; t < num && W[a]; t++ )
-                    {
-                        solution[a] += temp2[a_num + t] * f[t];
-                    }           /* for */
-                }               /* for */
-            }                   /* for */
-
-            for( a = 8; a > 0; a-- )
-            {
-
-                if( a == i )
-                    break;
-                solution[a] = solution[a - 1];
-            }                   /* for */
-
-            solution[a] = 1;
-
-            norm = 0;
-
-            for( a9 = 0; a9 < num9; a9 += 9 )
-            {                   /* row */
-
-                summ = 0;
-
-                for( t = 0; t < 9; t++ )
-                {
-
-                    summ += A[a9 + t] * solution[t];
-                }               /* for */
-
-                norm += summ * summ;
-            }                   /* for */
-
-            norm = sqrt( norm );
-
-            if( best_norm == -1 || norm < best_norm )
-            {
-
-                for( j = 0; j < 9; j++ )
-                    F[j] = solution[j];
-
-                best_norm = norm;
-            }                   /* if */
-        }                       /* if */
-    }                           /* for */
-
-    cvFree( &A_short );
-    cvFree( &temp2 );
-    cvFree( &f );
-    cvFree( &U );
-
-    return best_norm;
-
-}                               /* cs_AnalyticPoints8 */
-
-/*===========================================================================*/
-CvStatus
-icvRank2Constraint( double *F )
-{
-    double U[9], V[9], W[3];
-    double aW[3];
-    int i, i3, j, j3, t;
-
-    if( F == 0 )
-        return CV_BADFACTOR_ERR;
-
-    if( icvSingularValueDecomposition( 3, 3, F, W, 1, U, 1, V ))
-        return CV_BADFACTOR_ERR;
-
-    aW[0] = fabs(W[0]);
-    aW[1] = fabs(W[1]);
-    aW[2] = fabs(W[2]);
-
-    if( aW[0] < aW[1] )
-    {
-        if( aW[0] < aW[2] )
-        {
-
-            if( REAL_ZERO( W[0] ))
-                return CV_NO_ERR;
-            else
-                W[0] = 0;
-        }
-        else
-        {
-
-            if( REAL_ZERO( W[2] ))
-                return CV_NO_ERR;
-            else
-                W[2] = 0;
-        }                       /* if */
-    }
-    else
-    {
-
-        if( aW[1] < aW[2] )
-        {
-
-            if( REAL_ZERO( W[1] ))
-                return CV_NO_ERR;
-            else
-                W[1] = 0;
-        }
-        else
-        {
-            if( REAL_ZERO( W[2] ))
-                return CV_NO_ERR;
-            else
-                W[2] = 0;
-        }                       /* if */
-    }                           /* if */
-
-    for( i = 0; i < 3; i++ )
-    {
-        for( j3 = 0; j3 < 9; j3 += 3 )
-        {
-            U[j3 + i] *= W[i];
-        }                       /* for */
-    }                           /* for */
-
-    for( i = 0, i3 = 0; i < 3; i++, i3 += 3 )
-    {
-        for( j = 0, j3 = 0; j < 3; j++, j3 += 3 )
-        {
-
-            F[i3 + j] = 0;
-
-            for( t = 0; t < 3; t++ )
-            {
-                F[i3 + j] += U[i3 + t] * V[j3 + t];
-            }                   /* for */
-        }                       /* for */
-    }                           /* for */
-
-    return CV_NO_ERR;
-}                               /* cs_Rank2Constraint */
-
-
-/*===========================================================================*/
-
-int
-icvSingularValueDecomposition( int M,
-                               int N,
-                               double *A,
-                               double *W, int get_U, double *U, int get_V, double *V )
-{
-    int i = 0, j, k, l = 0, i1, k1, l1 = 0;
-    int iterations, error = 0, jN, iN, kN, lN = 0;
-    double *rv1;
-    double c, f, g, h, s, x, y, z, scale, anorm;
-    double af, ag, ah, t;
-    int MN = M * N;
-    int NN = N * N;
-
-    /*  max_iterations - maximum number QR-iterations
-       cc - reduces requirements to number stitch (cc>1)
-     */
-
-    int max_iterations = 100;
-    double cc = 100;
-
-    if( M < N )
-        return N;
-
-    rv1 = (double *) cvAlloc( N * sizeof( double ));
-
-    if( rv1 == 0 )
-        return N;
-
-    for( iN = 0; iN < MN; iN += N )
-    {
-        for( j = 0; j < N; j++ )
-            U[iN + j] = A[iN + j];
-    }                           /* for */
-
-    /*  Adduction to bidiagonal type (transformations of reflection).
-       Bidiagonal matrix is located in W (diagonal elements)
-       and in rv1 (upperdiagonal elements)
-     */
-
-    g = 0;
-    scale = 0;
-    anorm = 0;
-
-    for( i = 0, iN = 0; i < N; i++, iN += N )
-    {
-
-        l = i + 1;
-        lN = iN + N;
-        rv1[i] = scale * g;
-
-        /*  Multiplyings on the left  */
-
-        g = 0;
-        s = 0;
-        scale = 0;
-
-        for( kN = iN; kN < MN; kN += N )
-            scale += fabs( U[kN + i] );
-
-        if( !REAL_ZERO( scale ))
-        {
-
-            for( kN = iN; kN < MN; kN += N )
-            {
-
-                U[kN + i] /= scale;
-                s += U[kN + i] * U[kN + i];
-            }                   /* for */
-
-            f = U[iN + i];
-            g = -sqrt( s ) * Sgn( f );
-            h = f * g - s;
-            U[iN + i] = f - g;
-
-            for( j = l; j < N; j++ )
-            {
-
-                s = 0;
-
-                for( kN = iN; kN < MN; kN += N )
-                {
-
-                    s += U[kN + i] * U[kN + j];
-                }               /* for */
-
-                f = s / h;
-
-                for( kN = iN; kN < MN; kN += N )
-                {
-
-                    U[kN + j] += f * U[kN + i];
-                }               /* for */
-            }                   /* for */
-
-            for( kN = iN; kN < MN; kN += N )
-                U[kN + i] *= scale;
-        }                       /* if */
-
-        W[i] = scale * g;
-
-        /*  Multiplyings on the right  */
-
-        g = 0;
-        s = 0;
-        scale = 0;
-
-        for( k = l; k < N; k++ )
-            scale += fabs( U[iN + k] );
-
-        if( !REAL_ZERO( scale ))
-        {
-
-            for( k = l; k < N; k++ )
-            {
-
-                U[iN + k] /= scale;
-                s += (U[iN + k]) * (U[iN + k]);
-            }                   /* for */
-
-            f = U[iN + l];
-            g = -sqrt( s ) * Sgn( f );
-            h = f * g - s;
-            U[i * N + l] = f - g;
-
-            for( k = l; k < N; k++ )
-                rv1[k] = U[iN + k] / h;
-
-            for( jN = lN; jN < MN; jN += N )
-            {
-
-                s = 0;
-
-                for( k = l; k < N; k++ )
-                    s += U[jN + k] * U[iN + k];
-
-                for( k = l; k < N; k++ )
-                    U[jN + k] += s * rv1[k];
-
-            }                   /* for */
-
-            for( k = l; k < N; k++ )
-                U[iN + k] *= scale;
-        }                       /* if */
-
-        t = fabs( W[i] );
-        t += fabs( rv1[i] );
-        anorm = MAX( anorm, t );
-    }                           /* for */
-
-    anorm *= cc;
-
-    /*  accumulation of right transformations, if needed  */
-
-    if( get_V )
-    {
-
-        for( i = N - 1, iN = NN - N; i >= 0; i--, iN -= N )
-        {
-
-            if( i < N - 1 )
-            {
-
-                /*  pass-by small g  */
-                if( !REAL_ZERO( g ))
-                {
-
-                    for( j = l, jN = lN; j < N; j++, jN += N )
-                        V[jN + i] = U[iN + j] / U[iN + l] / g;
-
-                    for( j = l; j < N; j++ )
-                    {
-
-                        s = 0;
-
-                        for( k = l, kN = lN; k < N; k++, kN += N )
-                            s += U[iN + k] * V[kN + j];
-
-                        for( kN = lN; kN < NN; kN += N )
-                            V[kN + j] += s * V[kN + i];
-                    }           /* for */
-                }               /* if */
-
-                for( j = l, jN = lN; j < N; j++, jN += N )
-                {
-                    V[iN + j] = 0;
-                    V[jN + i] = 0;
-                }               /* for */
-            }                   /* if */
-
-            V[iN + i] = 1;
-            g = rv1[i];
-            l = i;
-            lN = iN;
-        }                       /* for */
-    }                           /* if */
-
-    /*  accumulation of left transformations, if needed  */
-
-    if( get_U )
-    {
-
-        for( i = N - 1, iN = NN - N; i >= 0; i--, iN -= N )
-        {
-
-            l = i + 1;
-            lN = iN + N;
-            g = W[i];
-
-            for( j = l; j < N; j++ )
-                U[iN + j] = 0;
-
-            /*  pass-by small g  */
-            if( !REAL_ZERO( g ))
-            {
-
-                for( j = l; j < N; j++ )
-                {
-
-                    s = 0;
-
-                    for( kN = lN; kN < MN; kN += N )
-                        s += U[kN + i] * U[kN + j];
-
-                    f = s / U[iN + i] / g;
-
-                    for( kN = iN; kN < MN; kN += N )
-                        U[kN + j] += f * U[kN + i];
-                }               /* for */
-
-                for( jN = iN; jN < MN; jN += N )
-                    U[jN + i] /= g;
-            }
-            else
-            {
-
-                for( jN = iN; jN < MN; jN += N )
-                    U[jN + i] = 0;
-            }                   /* if */
-
-            U[iN + i] += 1;
-        }                       /* for */
-    }                           /* if */
-
-    /*  Iterations QR-algorithm for bidiagonal matrices
-       W[i] - is the main diagonal
-       rv1[i] - is the top diagonal, rv1[0]=0.
-     */
-
-    for( k = N - 1; k >= 0; k-- )
-    {
-
-        k1 = k - 1;
-        iterations = 0;
-
-        for( ;; )
-        {
-
-            /*  Cycle: checking a possibility of fission matrix  */
-            for( l = k; l >= 0; l-- )
-            {
-
-                l1 = l - 1;
-
-                if( REAL_ZERO( rv1[l] ) || REAL_ZERO( W[l1] ))
-                    break;
-            }                   /* for */
-
-            if( !REAL_ZERO( rv1[l] ))
-            {
-
-                /*  W[l1] = 0,  matrix possible to fission
-                   by clearing out rv1[l]  */
-
-                c = 0;
-                s = 1;
-
-                for( i = l; i <= k; i++ )
-                {
-
-                    f = s * rv1[i];
-                    rv1[i] = c * rv1[i];
-
-                    /*  Rotations are done before the end of the block,
-                       or when element in the line is finagle.
-                     */
-
-                    if( REAL_ZERO( f ))
-                        break;
-
-                    g = W[i];
-
-                    /*  Scaling prevents finagling H ( F!=0!) */
-
-                    af = fabs( f );
-                    ag = fabs( g );
-
-                    if( af < ag )
-                        h = ag * sqrt( 1 + (f / g) * (f / g) );
-                    else
-                        h = af * sqrt( 1 + (f / g) * (f / g) );
-
-                    W[i] = h;
-                    c = g / h;
-                    s = -f / h;
-
-                    if( get_U )
-                    {
-
-                        for( jN = 0; jN < MN; jN += N )
-                        {
-
-                            y = U[jN + l1];
-                            z = U[jN + i];
-                            U[jN + l1] = y * c + z * s;
-                            U[jN + i] = -y * s + z * c;
-                        }       /* for */
-                    }           /* if */
-                }               /* for */
-            }                   /* if */
-
-
-            /*  Output in this place of program means,
-               that rv1[L] = 0, matrix fissioned
-               Iterations of the process of the persecution
-               will be executed always for
-               the bottom block ( from l before k ),
-               with increase l possible.
-             */
-
-            z = W[k];
-
-            if( l == k )
-                break;
-
-            /*  Completion iterations: lower block
-               became trivial ( rv1[K]=0)  */
-
-            if( iterations++ == max_iterations )
-                return k;
-
-            /*  Shift is computed on the lowest order 2 minor.  */
-
-            x = W[l];
-            y = W[k1];
-            g = rv1[k1];
-            h = rv1[k];
-
-            /*  consequent fission prevents forming a machine zero  */
-            f = ((y - z) * (y + z) + (g - h) * (g + h)) / (2 * h) / y;
-
-            /*  prevented overflow  */
-            if( fabs( f ) > 1 )
-            {
-                g = fabs( f );
-                g *= sqrt( 1 + (1 / f) * (1 / f) );
-            }
-            else
-                g = sqrt( f * f + 1 );
-
-            f = ((x - z) * (x + z) + h * (y / (f + fabs( g ) * Sgn( f )) - h)) / x;
-            c = 1;
-            s = 1;
-
-            for( i1 = l; i1 <= k1; i1++ )
-            {
-
-                i = i1 + 1;
-                g = rv1[i];
-                y = W[i];
-                h = s * g;
-                g *= c;
-
-                /*  Scaling at calculation Z prevents its clearing,
-                   however if F and H both are zero - pass-by of fission on Z.
-                 */
-
-                af = fabs( f );
-                ah = fabs( h );
-
-                if( af < ah )
-                    z = ah * sqrt( 1 + (f / h) * (f / h) );
-
-                else
-                {
-
-                    z = 0;
-                    if( !REAL_ZERO( af ))
-                        z = af * sqrt( 1 + (h / f) * (h / f) );
-                }               /* if */
-
-                rv1[i1] = z;
-
-                /*  if Z=0, the rotation is free.  */
-                if( !REAL_ZERO( z ))
-                {
-
-                    c = f / z;
-                    s = h / z;
-                }               /* if */
-
-                f = x * c + g * s;
-                g = -x * s + g * c;
-                h = y * s;
-                y *= c;
-
-                if( get_V )
-                {
-
-                    for( jN = 0; jN < NN; jN += N )
-                    {
-
-                        x = V[jN + i1];
-                        z = V[jN + i];
-                        V[jN + i1] = x * c + z * s;
-                        V[jN + i] = -x * s + z * c;
-                    }           /* for */
-                }               /* if */
-
-                af = fabs( f );
-                ah = fabs( h );
-
-                if( af < ah )
-                    z = ah * sqrt( 1 + (f / h) * (f / h) );
-                else
-                {
-
-                    z = 0;
-                    if( !REAL_ZERO( af ))
-                        z = af * sqrt( 1 + (h / f) * (h / f) );
-                }               /* if */
-
-                W[i1] = z;
-
-                if( !REAL_ZERO( z ))
-                {
-
-                    c = f / z;
-                    s = h / z;
-                }               /* if */
-
-                f = c * g + s * y;
-                x = -s * g + c * y;
-
-                if( get_U )
-                {
-
-                    for( jN = 0; jN < MN; jN += N )
-                    {
-
-                        y = U[jN + i1];
-                        z = U[jN + i];
-                        U[jN + i1] = y * c + z * s;
-                        U[jN + i] = -y * s + z * c;
-                    }           /* for */
-                }               /* if */
-            }                   /* for */
-
-            rv1[l] = 0;
-            rv1[k] = f;
-            W[k] = x;
-        }                       /* for */
-
-        if( z < 0 )
-        {
-
-            W[k] = -z;
-
-            if( get_V )
-            {
-
-                for( jN = 0; jN < NN; jN += N )
-                    V[jN + k] *= -1;
-            }                   /* if */
-        }                       /* if */
-    }                           /* for */
-
-    cvFree( &rv1 );
-
-    return error;
-
-}                               /* vm_SingularValueDecomposition */
-
-/*========================================================================*/
-
-/* Obsolete functions. Just for ViewMorping */
-/*=====================================================================================*/
-
-int
-icvGaussMxN( double *A, double *B, int M, int N, double **solutions )
-{
-    int *variables;
-    int row, swapi, i, i_best = 0, j, j_best = 0, t;
-    double swapd, ratio, bigest;
-
-    if( !A || !B || !M || !N )
-        return -1;
-
-    variables = (int *) cvAlloc( (size_t) N * sizeof( int ));
-
-    if( variables == 0 )
-        return -1;
-
-    for( i = 0; i < N; i++ )
-    {
-        variables[i] = i;
-    }                           /* for */
-
-    /* -----  Direct way  ----- */
-
-    for( row = 0; row < M; row++ )
-    {
-
-        bigest = 0;
-
-        for( j = row; j < M; j++ )
-        {                       /* search non null element */
-            for( i = row; i < N; i++ )
-            {
-                double a = fabs( A[j * N + i] ), b = fabs( bigest );
-                if( a > b )
-                {
-                    bigest = A[j * N + i];
-                    i_best = i;
-                    j_best = j;
-                }               /* if */
-            }                   /* for */
-        }                       /* for */
-
-        if( REAL_ZERO( bigest ))
-            break;              /* if all shank elements are null */
-
-        if( j_best - row )
-        {
-
-            for( t = 0; t < N; t++ )
-            {                   /* swap a rows */
-
-                swapd = A[row * N + t];
-                A[row * N + t] = A[j_best * N + t];
-                A[j_best * N + t] = swapd;
-            }                   /* for */
-
-            swapd = B[row];
-            B[row] = B[j_best];
-            B[j_best] = swapd;
-        }                       /* if */
-
-        if( i_best - row )
-        {
-
-            for( t = 0; t < M; t++ )
-            {                   /* swap a columns  */
-
-                swapd = A[t * N + i_best];
-                A[t * N + i_best] = A[t * N + row];
-                A[t * N + row] = swapd;
-            }                   /* for */
-
-            swapi = variables[row];
-            variables[row] = variables[i_best];
-            variables[i_best] = swapi;
-        }                       /* if */
-
-        for( i = row + 1; i < M; i++ )
-        {                       /* recounting A and B */
-
-            ratio = -A[i * N + row] / A[row * N + row];
-            B[i] += B[row] * ratio;
-
-            for( j = N - 1; j >= row; j-- )
-            {
-
-                A[i * N + j] += A[row * N + j] * ratio;
-            }                   /* for */
-        }                       /* for */
-    }                           /* for */
-
-    if( row < M )
-    {                           /* if rank(A)<M */
-
-        for( j = row; j < M; j++ )
-        {
-            if( !REAL_ZERO( B[j] ))
-            {
-
-                cvFree( &variables );
-                return -1;      /* if system is antithetic */
-            }                   /* if */
-        }                       /* for */
-
-        M = row;                /* decreasing size of the task */
-    }                           /* if */
-
-    /* ----- Reverse way ----- */
-
-    if( M < N )
-    {                           /* if solution are not exclusive */
-
-        *solutions = (double *) cvAlloc( ((N - M + 1) * N) * sizeof( double ));
-
-        if( *solutions == 0 )
-        {
-            cvFree( &variables );
-            return -1;
-        }
-
-
-        for( t = M; t <= N; t++ )
-        {
-            for( j = M; j < N; j++ )
-            {
-
-                (*solutions)[(t - M) * N + variables[j]] = (double) (t == j);
-            }                   /* for */
-
-            for( i = M - 1; i >= 0; i-- )
-            {                   /* finding component of solution */
-
-                if( t < N )
-                {
-                    (*solutions)[(t - M) * N + variables[i]] = 0;
-                }
-                else
-                {
-                    (*solutions)[(t - M) * N + variables[i]] = B[i] / A[i * N + i];
-                }               /* if */
-
-                for( j = i + 1; j < N; j++ )
-                {
-
-                    (*solutions)[(t - M) * N + variables[i]] -=
-                        (*solutions)[(t - M) * N + variables[j]] * A[i * N + j] / A[i * N + i];
-                }               /* for */
-            }                   /* for */
-        }                       /* for */
-
-        cvFree( &variables );
-        return N - M;
-    }                           /* if */
-
-    *solutions = (double *) cvAlloc( (N) * sizeof( double ));
-
-    if( solutions == 0 )
-        return -1;
-
-    for( i = N - 1; i >= 0; i-- )
-    {                           /* finding exclusive solution */
-
-        (*solutions)[variables[i]] = B[i] / A[i * N + i];
-
-        for( j = i + 1; j < N; j++ )
-        {
-
-            (*solutions)[variables[i]] -=
-                (*solutions)[variables[j]] * A[i * N + j] / A[i * N + i];
-        }                       /* for */
-    }                           /* for */
-
-    cvFree( &variables );
-    return 0;
-
-}                               /* icvGaussMxN */
-
-
-/*======================================================================================*/
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name:    icvPoint7
-//    Purpose:
-//
-//
-//    Context:
-//    Parameters:
-//
-//
-//
-//
-//
-//
-//
-//    Returns:
-//      CV_NO_ERR if all Ok or error code
-//    Notes:
-//F*/
-
-CvStatus
-icvPoint7( int *ml, int *mr, double *F, int *amount )
-{
-    double A[63], B[7];
-    double *solutions = 0;
-    double a2, a1, a0;
-    double squares[6];
-    int i, j;
-
-/*    int         amount; */
-/*    float*     F; */
-
-    CvStatus error = CV_BADFACTOR_ERR;
-
-/*    F = (float*)matrix->m; */
-
-    if( !ml || !mr || !F )
-        return CV_BADFACTOR_ERR;
-
-    for( i = 0; i < 7; i++ )
-    {
-        for( j = 0; j < 9; j++ )
-        {
-
-            A[i * 9 + j] = (double) ml[i * 3 + j / 3] * (double) mr[i * 3 + j % 3];
-        }                       /* for */
-        B[i] = 0;
-    }                           /* for */
-
-    *amount = 0;
-
-    if( icvGaussMxN( A, B, 7, 9, &solutions ) == 2 )
-    {
-        if( icvGetCoef( solutions, solutions + 9, &a2, &a1, &a0 ) == CV_NO_ERR )
-        {
-            icvCubic( a2, a1, a0, squares );
-
-            for( i = 0; i < 1; i++ )
-            {
-
-                if( REAL_ZERO( squares[i * 2 + 1] ))
-                {
-
-                    for( j = 0; j < 9; j++ )
-                    {
-
-                        F[*amount + j] = (float) (squares[i] * solutions[j] +
-                                                  (1 - squares[i]) * solutions[j + 9]);
-                    }           /* for */
-
-                    *amount += 9;
-
-                    error = CV_NO_ERR;
-                }               /* if */
-            }                   /* for */
-
-            cvFree( &solutions );
-            return error;
-        }
-        else
-        {
-            cvFree( &solutions );
-        }                       /* if */
-
-    }
-    else
-    {
-        cvFree( &solutions );
-    }                           /* if */
-
-    return error;
-}                               /* icvPoint7 */
diff --git a/modules/legacy/src/lsh.cpp b/modules/legacy/src/lsh.cpp
deleted file mode 100644 (file)
index 6fdff76..0000000
+++ /dev/null
@@ -1,462 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2009, Xavier Delacour, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-// 2009-01-12, Xavier Delacour <xavier.delacour@gmail.com>
-
-
-// * hash perf could be improved
-// * in particular, implement integer only (converted fixed from float input)
-
-// * number of hash functions could be reduced (andoni paper)
-
-// * redundant distance computations could be suppressed
-
-// * rework CvLSHOperations interface-- move some of the loops into it to
-// * allow efficient async storage
-
-
-// Datar, M., Immorlica, N., Indyk, P., and Mirrokni, V. S. 2004. Locality-sensitive hashing
-// scheme based on p-stable distributions. In Proceedings of the Twentieth Annual Symposium on
-// Computational Geometry (Brooklyn, New York, USA, June 08 - 11, 2004). SCG '04. ACM, New York,
-// NY, 253-262. DOI= http://doi.acm.org/10.1145/997817.997857
-
-#include "precomp.hpp"
-#include <math.h>
-#include <vector>
-#include <algorithm>
-#include <limits>
-
-template <class T>
-class memory_hash_ops : public CvLSHOperations {
-  int d;
-  std::vector<T> data;
-  std::vector<int> free_data;
-  struct node {
-    int i, h2, next;
-  };
-  std::vector<node> nodes;
-  std::vector<int> free_nodes;
-  std::vector<int> bins;
-
-public:
-  memory_hash_ops(int _d, int n) : d(_d) {
-    bins.resize(n, -1);
-  }
-
-  virtual int vector_add(const void* _p) {
-    const T* p = (const T*)_p;
-    int i;
-    if (free_data.empty()) {
-      i = (int)data.size();
-      data.insert(data.end(), d, 0);
-    } else {
-      i = free_data.end()[-1];
-      free_data.pop_back();
-    }
-    std::copy(p, p + d, data.begin() + i);
-    return i / d;
-  }
-  virtual void vector_remove(int i) {
-    free_data.push_back(i * d);
-  }
-  virtual const void* vector_lookup(int i) {
-    return &data[i * d];
-  }
-  virtual void vector_reserve(int n) {
-    data.reserve(n * d);
-  }
-  virtual unsigned int vector_count() {
-    return (unsigned)(data.size() / d - free_data.size());
-  }
-
-  virtual void hash_insert(lsh_hash h, int /*l*/, int i) {
-    int ii;
-    if (free_nodes.empty()) {
-      ii = (int)nodes.size();
-      nodes.push_back(node());
-    } else {
-      ii = free_nodes.end()[-1];
-      free_nodes.pop_back();
-    }
-    node& n = nodes[ii];
-    int h1 = (int)(h.h1 % bins.size());
-    n.i = i;
-    n.h2 = h.h2;
-    n.next = bins[h1];
-    bins[h1] = ii;
-  }
-  virtual void hash_remove(lsh_hash h, int /*l*/, int i) {
-    int h1 = (int)(h.h1 % bins.size());
-    for (int ii = bins[h1], iin, iip = -1; ii != -1; iip = ii, ii = iin) {
-      iin = nodes[ii].next;
-      if (nodes[ii].h2 == h.h2 && nodes[ii].i == i) {
-    free_nodes.push_back(ii);
-    if (iip == -1)
-      bins[h1] = iin;
-    else
-      nodes[iip].next = iin;
-      }
-    }
-  }
-  virtual int hash_lookup(lsh_hash h, int /*l*/, int* ret_i, int ret_i_max) {
-    int h1 = (int)(h.h1 % bins.size());
-    int k = 0;
-    for (int ii = bins[h1]; ii != -1 && k < ret_i_max; ii = nodes[ii].next)
-      if (nodes[ii].h2 == h.h2)
-    ret_i[k++] = nodes[ii].i;
-    return k;
-  }
-};
-
-template <class T,int cvtype>
-class pstable_l2_func {
-  CvMat *a, *b, *r1, *r2;
-  int d, k;
-  double r;
-  pstable_l2_func(const pstable_l2_func& x);
-  pstable_l2_func& operator= (const pstable_l2_func& rhs);
-public:
-  typedef T scalar_type;
-  typedef T accum_type;
-  pstable_l2_func(int _d, int _k, double _r, CvRNG& rng)
-    : d(_d), k(_k), r(_r) {
-    assert(sizeof(T) == CV_ELEM_SIZE1(cvtype));
-    a = cvCreateMat(k, d, cvtype);
-    b = cvCreateMat(k, 1, cvtype);
-    r1 = cvCreateMat(k, 1, CV_32SC1);
-    r2 = cvCreateMat(k, 1, CV_32SC1);
-    cvRandArr(&rng, a, CV_RAND_NORMAL, cvScalar(0), cvScalar(1));
-    cvRandArr(&rng, b, CV_RAND_UNI, cvScalar(0), cvScalar(r));
-    cvRandArr(&rng, r1, CV_RAND_UNI,
-          cvScalar(std::numeric_limits<int>::min()),
-          cvScalar(std::numeric_limits<int>::max()));
-    cvRandArr(&rng, r2, CV_RAND_UNI,
-          cvScalar(std::numeric_limits<int>::min()),
-          cvScalar(std::numeric_limits<int>::max()));
-  }
-  ~pstable_l2_func() {
-    cvReleaseMat(&a);
-    cvReleaseMat(&b);
-    cvReleaseMat(&r1);
-    cvReleaseMat(&r2);
-  }
-
-  // * factor all L functions into this (reduces number of matrices to 4 total;
-  // * simpler syntax in lsh_table). give parameter l here that tells us which
-  // * row to use etc.
-
-  lsh_hash operator() (const T* x) const {
-    const T* aj = (const T*)a->data.ptr;
-    const T* bj = (const T*)b->data.ptr;
-
-    lsh_hash h;
-    h.h1 = h.h2 = 0;
-    for (int j = 0; j < k; ++j) {
-      accum_type s = 0;
-      for (int jj = 0; jj < d; ++jj)
-    s += aj[jj] * x[jj];
-      s += *bj;
-      s = accum_type(s/r);
-      int si = int(s);
-      h.h1 += r1->data.i[j] * si;
-      h.h2 += r2->data.i[j] * si;
-
-      aj += d;
-      bj++;
-    }
-    return h;
-  }
-  accum_type distance(const T* p, const T* q) const {
-    accum_type s = 0;
-    for (int j = 0; j < d; ++j) {
-      accum_type d1 = p[j] - q[j];
-      s += d1 * d1;
-    }
-    return s;
-  }
-};
-
-template <class H>
-class lsh_table {
-public:
-  typedef typename H::scalar_type scalar_type;
-  typedef typename H::accum_type accum_type;
-private:
-  std::vector<H*> g;
-  CvLSHOperations* ops;
-  int d, L, k;
-  double r;
-
-  static accum_type comp_dist(const std::pair<int,accum_type>& x,
-                  const std::pair<int,accum_type>& y) {
-    return x.second < y.second;
-  }
-
-  lsh_table(const lsh_table& x);
-  lsh_table& operator= (const lsh_table& rhs);
-public:
-  lsh_table(CvLSHOperations* _ops, int _d, int Lval, int _k, double _r, CvRNG& rng)
-    : ops(_ops), d(_d), L(Lval), k(_k), r(_r) {
-    g.resize(L);
-    for (int j = 0; j < L; ++j)
-      g[j] = new H(d, k, r, rng);
-  }
-  ~lsh_table() {
-    for (int j = 0; j < L; ++j)
-      delete g[j];
-    delete ops;
-  }
-
-  int dims() const {
-    return d;
-  }
-  unsigned int size() const {
-    return ops->vector_count();
-  }
-
-  void add(const scalar_type* data, int n, int* ret_indices = 0) {
-    for (int j=0;j<n;++j) {
-      const scalar_type* x = data+j*d;
-      int i = ops->vector_add(x);
-      if (ret_indices)
-    ret_indices[j] = i;
-
-      for (int l = 0; l < L; ++l) {
-    lsh_hash h = (*g[l])(x);
-    ops->hash_insert(h, l, i);
-      }
-    }
-  }
-  void remove(const int* indices, int n) {
-    for (int j = 0; j < n; ++j) {
-      int i = indices[n];
-      const scalar_type* x = (const scalar_type*)ops->vector_lookup(i);
-
-      for (int l = 0; l < L; ++l) {
-    lsh_hash h = (*g[l])(x);
-    ops->hash_remove(h, l, i);
-      }
-      ops->vector_remove(i);
-    }
-  }
-  void query(const scalar_type* q, int k0, int emax, double* dist, int* results) {
-    cv::AutoBuffer<int> tmp(emax);
-    typedef std::pair<int, accum_type> dr_type; // * swap int and accum_type here, for naming consistency
-    cv::AutoBuffer<dr_type> dr(k0);
-    int k1 = 0;
-
-    // * handle k0 >= emax, in which case don't track max distance
-
-    for (int l = 0; l < L && emax > 0; ++l) {
-      lsh_hash h = (*g[l])(q);
-      int m = ops->hash_lookup(h, l, tmp, emax);
-      for (int j = 0; j < m && emax > 0; ++j, --emax) {
-    int i = tmp[j];
-    const scalar_type* p = (const scalar_type*)ops->vector_lookup(i);
-    accum_type pd = (*g[l]).distance(p, q);
-    if (k1 < k0) {
-      dr[k1++] = std::make_pair(i, pd);
-      std::push_heap(&dr[0], &dr[k1], comp_dist);
-    } else if (pd < dr[0].second) {
-      std::pop_heap(&dr[0], &dr[k0], comp_dist);
-      dr[k0 - 1] = std::make_pair(i, pd);
-      std::push_heap(&dr[0], &dr[k0], comp_dist);
-    }
-      }
-    }
-
-    for (int j = 0; j < k1; ++j)
-      dist[j] = dr[j].second, results[j] = dr[j].first;
-    std::fill(dist + k1, dist + k0, 0);
-    std::fill(results + k1, results + k0, -1);
-  }
-  void query(const scalar_type* data, int n, int k0, int emax, double* dist, int* results) {
-    for (int j = 0; j < n; ++j) {
-      query(data, k0, emax, dist, results);
-      data += d; // * this may not agree with step for some scalar_types
-      dist += k0;
-      results += k0;
-    }
-  }
-};
-
-typedef lsh_table<pstable_l2_func<float, CV_32FC1> > lsh_pstable_l2_32f;
-typedef lsh_table<pstable_l2_func<double, CV_64FC1> > lsh_pstable_l2_64f;
-
-struct CvLSH {
-  int type;
-  union {
-    lsh_pstable_l2_32f* lsh_32f;
-    lsh_pstable_l2_64f* lsh_64f;
-  } u;
-};
-
-CvLSH* cvCreateLSH(CvLSHOperations* ops, int d, int L, int k, int type, double r, int64 seed) {
-  CvLSH* lsh = 0;
-  CvRNG rng = cvRNG(seed);
-
-  if (type != CV_32FC1 && type != CV_64FC1)
-    CV_Error(CV_StsUnsupportedFormat, "vectors must be either CV_32FC1 or CV_64FC1");
-  lsh = new CvLSH;
-  try
-  {
-      lsh->type = type;
-      switch (type) {
-      case CV_32FC1: lsh->u.lsh_32f = new lsh_pstable_l2_32f(ops, d, L, k, r, rng); break;
-      case CV_64FC1: lsh->u.lsh_64f = new lsh_pstable_l2_64f(ops, d, L, k, r, rng); break;
-      }
-  }
-  catch(...)
-  {
-      delete lsh;
-      throw;
-  }
-
-  return lsh;
-}
-
-CvLSH* cvCreateMemoryLSH(int d, int n, int L, int k, int type, double r, int64 seed) {
-  CvLSHOperations* ops = 0;
-
-  switch (type) {
-  case CV_32FC1: ops = new memory_hash_ops<float>(d,n); break;
-  case CV_64FC1: ops = new memory_hash_ops<double>(d,n); break;
-  }
-  return cvCreateLSH(ops, d, L, k, type, r, seed);
-}
-
-void cvReleaseLSH(CvLSH** lsh) {
-  switch ((*lsh)->type) {
-  case CV_32FC1: delete (*lsh)->u.lsh_32f; break;
-  case CV_64FC1: delete (*lsh)->u.lsh_64f; break;
-  default: assert(0);
-  }
-  delete *lsh;
-  *lsh = 0;
-}
-
-unsigned int LSHSize(CvLSH* lsh) {
-  switch (lsh->type) {
-  case CV_32FC1: return lsh->u.lsh_32f->size(); break;
-  case CV_64FC1: return lsh->u.lsh_64f->size(); break;
-  default: assert(0);
-  }
-  return 0;
-}
-
-
-void cvLSHAdd(CvLSH* lsh, const CvMat* data, CvMat* indices) {
-  int dims, n;
-  int* ret_indices = 0;
-
-  switch (lsh->type) {
-  case CV_32FC1: dims = lsh->u.lsh_32f->dims(); break;
-  case CV_64FC1: dims = lsh->u.lsh_64f->dims(); break;
-  default: assert(0); return;
-  }
-
-  n = data->rows;
-
-  if (dims != data->cols)
-    CV_Error(CV_StsBadSize, "data must be n x d, where d is what was used to construct LSH");
-
-  if (CV_MAT_TYPE(data->type) != lsh->type)
-    CV_Error(CV_StsUnsupportedFormat, "type of data and constructed LSH must agree");
-  if (indices) {
-    if (CV_MAT_TYPE(indices->type) != CV_32SC1)
-      CV_Error(CV_StsUnsupportedFormat, "indices must be CV_32SC1");
-    if (indices->rows * indices->cols != n)
-      CV_Error(CV_StsBadSize, "indices must be n x 1 or 1 x n for n x d data");
-    ret_indices = indices->data.i;
-  }
-
-  switch (lsh->type) {
-  case CV_32FC1: lsh->u.lsh_32f->add(data->data.fl, n, ret_indices); break;
-  case CV_64FC1: lsh->u.lsh_64f->add(data->data.db, n, ret_indices); break;
-  default: assert(0); return;
-  }
-}
-
-void cvLSHRemove(CvLSH* lsh, const CvMat* indices) {
-  int n;
-
-  if (CV_MAT_TYPE(indices->type) != CV_32SC1)
-    CV_Error(CV_StsUnsupportedFormat, "indices must be CV_32SC1");
-  n = indices->rows * indices->cols;
-  switch (lsh->type) {
-  case CV_32FC1: lsh->u.lsh_32f->remove(indices->data.i, n); break;
-  case CV_64FC1: lsh->u.lsh_64f->remove(indices->data.i, n); break;
-  default: assert(0); return;
-  }
-}
-
-void cvLSHQuery(CvLSH* lsh, const CvMat* data, CvMat* indices, CvMat* dist, int k, int emax) {
-  int dims;
-
-  switch (lsh->type) {
-  case CV_32FC1: dims = lsh->u.lsh_32f->dims(); break;
-  case CV_64FC1: dims = lsh->u.lsh_64f->dims(); break;
-  default: assert(0); return;
-  }
-
-  if (k<1)
-    CV_Error(CV_StsOutOfRange, "k must be positive");
-  if (CV_MAT_TYPE(data->type) != lsh->type)
-    CV_Error(CV_StsUnsupportedFormat, "type of data and constructed LSH must agree");
-  if (dims != data->cols)
-    CV_Error(CV_StsBadSize, "data must be n x d, where d is what was used to construct LSH");
-  if (dist->rows != data->rows || dist->cols != k)
-    CV_Error(CV_StsBadSize, "dist must be n x k for n x d data");
-  if (dist->rows != indices->rows || dist->cols != indices->cols)
-    CV_Error(CV_StsBadSize, "dist and indices must be same size");
-  if (CV_MAT_TYPE(dist->type) != CV_64FC1)
-    CV_Error(CV_StsUnsupportedFormat, "dist must be CV_64FC1");
-  if (CV_MAT_TYPE(indices->type) != CV_32SC1)
-    CV_Error(CV_StsUnsupportedFormat, "indices must be CV_32SC1");
-
-  switch (lsh->type) {
-  case CV_32FC1: lsh->u.lsh_32f->query(data->data.fl, data->rows,
-                       k, emax, dist->data.db, indices->data.i); break;
-  case CV_64FC1: lsh->u.lsh_64f->query(data->data.db, data->rows,
-                       k, emax, dist->data.db, indices->data.i); break;
-  default: assert(0); return;
-  }
-}
diff --git a/modules/legacy/src/morphcontours.cpp b/modules/legacy/src/morphcontours.cpp
deleted file mode 100644 (file)
index b04cdd4..0000000
+++ /dev/null
@@ -1,856 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#define PATH_TO_E       1
-#define PATH_TO_SE      2
-#define PATH_TO_S       3
-
-#define K_S         2
-#define E_S         2
-#define C_S         .01
-#define K_Z         5000
-#define K_NM        50000
-#define K_B         40
-#define NULL_EDGE   0.001f
-#define inf         DBL_MAX
-
-typedef struct __CvWork
-{
-    double w_east;
-    double w_southeast;
-    double w_south;
-    char path_e;
-    char path_se;
-    char path_s;
-}_CvWork;
-
-
-double _cvBendingWork(  CvPoint2D32f* B0,
-                        CvPoint2D32f* F0,
-                        CvPoint2D32f* B1,
-                        CvPoint2D32f* F1/*,
-                        CvPoint* K */);
-
-double _cvStretchingWork(CvPoint2D32f* P1,
-                         CvPoint2D32f* P2);
-
-void _cvWorkEast     (int i, int j, _CvWork** W, CvPoint2D32f* edges1, CvPoint2D32f* edges2);
-void _cvWorkSouthEast(int i, int j, _CvWork** W, CvPoint2D32f* edges1, CvPoint2D32f* edges2);
-void _cvWorkSouth    (int i, int j, _CvWork** W, CvPoint2D32f* edges1, CvPoint2D32f* edges2);
-
-static CvPoint2D32f null_edge;
-
-double _cvStretchingWork(CvPoint2D32f* P1,
-                         CvPoint2D32f* P2)
-{
-    double L1,L2, L_min, dL;
-
-    L1 = sqrt( (double)P1->x*P1->x + P1->y*P1->y);
-    L2 = sqrt( (double)P2->x*P2->x + P2->y*P2->y);
-
-    L_min = MIN(L1, L2);
-    dL = fabs( L1 - L2 );
-
-    return K_S * pow( dL, E_S ) / ( L_min + C_S*dL );
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////
-CvPoint2D32f Q( CvPoint2D32f q0, CvPoint2D32f q1, CvPoint2D32f q2, double t );
-double angle( CvPoint2D32f A, CvPoint2D32f B );
-
-double _cvBendingWork(  CvPoint2D32f* B0,
-                        CvPoint2D32f* F0,
-                        CvPoint2D32f* B1,
-                        CvPoint2D32f* F1/*,
-                        CvPoint* K*/)
-{
-    CvPoint2D32f Q0, Q1, Q2;
-    CvPoint2D32f Q1_nm, Q2_nm;
-    double d0, d1, d2, des, t_zero;
-    double k_zero, k_nonmon;
-    CvPoint2D32f center;
-    double check01, check02;
-    char check_origin;
-    double d_angle, d_nm_angle;
-/*
-    if( (B0->x==0) && (B0->y==0) )
-    {
-        if( (F0->x==0) && (F0->y==0) )
-        {
-            B1->x = -B1->x;
-            B1->y = -B1->y;
-
-            d_angle = acos( (B1->x*F1->x + B1->y*F1->y)/sqrt( (B1->x*B1->x + B1->y*B1->y)*(F1->x*F1->x + F1->y*F1->y) ) );
-            d_angle = CV_PI - d_angle;
-
-            B1->x = -B1->x;
-            B1->y = -B1->y;
-
-            //return d_angle*K_B;
-            return 100;
-        }
-        K->x = -K->x;
-        K->y = -K->y;
-        B1->x = -B1->x;
-        B1->y = -B1->y;
-
-        d_angle = acos( (B1->x*F1->x + B1->y*F1->y)/sqrt( (B1->x*B1->x + B1->y*B1->y)*(F1->x*F1->x + F1->y*F1->y) ) );
-        d_angle = d_angle - acos( (F0->x*K->x + F0->y*K->y)/sqrt( (F0->x*F0->x + F0->y*F0->y)*(K->x*K->x + K->y*K->y) ) );
-        d_angle = d_angle - CV_PI*0.5;
-        d_angle = fabs(d_angle);
-
-
-        K->x = -K->x;
-        K->y = -K->y;
-        B1->x = -B1->x;
-        B1->y = -B1->y;
-
-        //return d_angle*K_B;
-        return 100;
-    }
-
-
-    if( (F0->x==0) && (F0->y==0) )
-        {
-            K->x = -K->x;
-            K->y = -K->y;
-            B1->x = -B1->x;
-            B1->y = -B1->y;
-
-            d_angle = acos( (B1->x*F1->x + B1->y*F1->y)/sqrt( (B1->x*B1->x + B1->y*B1->y)*(F1->x*F1->x + F1->y*F1->y) ) );
-            d_angle = d_angle - acos( (B0->x*K->x + B0->y*K->y)/sqrt( (B0->x*B0->x + B0->y*B0->y)*(K->x*K->x + K->y*K->y) ) );
-            d_angle = d_angle - CV_PI*0.5;
-            d_angle = fabs(d_angle);
-
-            K->x = -K->x;
-            K->y = -K->y;
-            B1->x = -B1->x;
-            B1->y = -B1->y;
-
-            //return d_angle*K_B;
-            return 100;
-        }
-///////////////
-
-    if( (B1->x==0) && (B1->y==0) )
-    {
-        if( (F1->x==0) && (F1->y==0) )
-        {
-            B0->x = -B0->x;
-            B0->y = -B0->y;
-
-            d_angle = acos( (B0->x*F0->x + B0->y*F0->y)/sqrt( (B0->x*B0->x + B0->y*B0->y)*(F0->x*F0->x + F0->y*F0->y) ) );
-            d_angle = CV_PI - d_angle;
-
-            B0->x = -B0->x;
-            B0->y = -B0->y;
-
-            //return d_angle*K_B;
-            return 100;
-        }
-        K->x = -K->x;
-        K->y = -K->y;
-        B0->x = -B0->x;
-        B0->y = -B0->y;
-
-        d_angle = acos( (B0->x*F0->x + B0->y*F0->y)/sqrt( (B0->x*B0->x + B0->y*B0->y)*(F0->x*F0->x + F0->y*F0->y) ) );
-        d_angle = d_angle - acos( (F1->x*K->x + F1->y*K->y)/sqrt( (F1->x*F1->x + F1->y*F1->y)*(K->x*K->x + K->y*K->y) ) );
-        d_angle = d_angle - CV_PI*0.5;
-        d_angle = fabs(d_angle);
-
-        K->x = -K->x;
-        K->y = -K->y;
-        B0->x = -B0->x;
-        B0->y = -B0->y;
-
-        //return d_angle*K_B;
-        return 100;
-    }
-
-
-    if( (F1->x==0) && (F1->y==0) )
-        {
-            K->x = -K->x;
-            K->y = -K->y;
-            B0->x = -B0->x;
-            B0->y = -B0->y;
-
-            d_angle = acos( (B0->x*F0->x + B0->y*F0->y)/sqrt( (B0->x*B0->x + B0->y*B0->y)*(F0->x*F0->x + F0->y*F0->y) ) );
-            d_angle = d_angle - acos( (B1->x*K->x + B1->y*K->y)/sqrt( (B1->x*B1->x + B1->y*B1->y)*(K->x*K->x + K->y*K->y) ) );
-            d_angle = d_angle - CV_PI*0.5;
-            d_angle = fabs(d_angle);
-
-            K->x  = -K->x;
-            K->y  = -K->y;
-            B0->x = -B0->x;
-            B0->y = -B0->y;
-
-            //return d_angle*K_B;
-            return 100;
-        }
-
-*/
-
-/*
-    B0->x = -B0->x;
-    B0->y = -B0->y;
-    B1->x = -B1->x;
-    B1->y = -B1->y;
-*/
-    Q0.x = F0->x * (-B0->x) + F0->y * (-B0->y);
-    Q0.y = F0->x * (-B0->y) - F0->y * (-B0->x);
-
-    Q1.x = 0.5f*( (F1->x * (-B0->x) + F1->y * (-B0->y)) + (F0->x * (-B1->x) + F0->y * (-B1->y)) );
-    Q1.y = 0.5f*( (F1->x * (-B0->y) - F1->y * (-B0->x)) + (F0->x * (-B1->y) - F0->y * (-B1->x)) );
-
-    Q2.x = F1->x * (-B1->x) + F1->y * (-B1->y);
-    Q2.y = F1->x * (-B1->y) - F1->y * (-B1->x);
-
-    d0 = Q0.x * Q1.y - Q0.y * Q1.x;
-    d1 = 0.5f*(Q0.x * Q2.y - Q0.y * Q2.x);
-    d2 = Q1.x * Q2.y - Q1.y * Q2.x;
-
-    // Check angles goes to zero
-    des = Q1.y*Q1.y - Q0.y*Q2.y;
-
-    k_zero = 0;
-
-    if( des >= 0 )
-    {
-        t_zero = ( Q0.y - Q1.y + sqrt(des) )/( Q0.y - 2*Q1.y + Q2.y );
-
-        if( (0 < t_zero) && (t_zero < 1) && ( Q(Q0, Q1, Q2, t_zero).x > 0 ) )
-        {
-            k_zero = inf;
-        }
-
-        t_zero = ( Q0.y - Q1.y - sqrt(des) )/( Q0.y - 2*Q1.y + Q2.y );
-
-        if( (0 < t_zero) && (t_zero < 1) && ( Q(Q0, Q1, Q2, t_zero).x > 0 ) )
-        {
-            k_zero = inf;
-        }
-    }
-
-    // Check nonmonotonic
-    des = d1*d1 - d0*d2;
-
-    k_nonmon = 0;
-
-    if( des >= 0 )
-    {
-        t_zero = ( d0 - d1 - sqrt(des) )/( d0 - 2*d1 + d2 );
-
-        if( (0 < t_zero) && (t_zero < 1) )
-        {
-            k_nonmon = 1;
-            Q1_nm = Q(Q0, Q1, Q2, t_zero);
-        }
-
-        t_zero = ( d0 - d1 + sqrt(des) )/( d0 - 2*d1 + d2 );
-
-        if( (0 < t_zero) && (t_zero < 1) )
-        {
-            k_nonmon += 2;
-            Q2_nm = Q(Q0, Q1, Q2, t_zero);
-        }
-    }
-
-    // Finde origin lie in Q0Q1Q2
-    check_origin = 1;
-
-    center.x = (Q0.x + Q1.x + Q2.x)/3;
-    center.y = (Q0.y + Q1.y + Q2.y)/3;
-
-    check01 = (center.x - Q0.x)*(Q1.y - Q0.y) + (center.y - Q0.y)*(Q1.x - Q0.x);
-    check02 = (-Q0.x)*(Q1.y - Q0.y) + (-Q0.y)*(Q1.x - Q0.x);
-    if( check01*check02 > 0 )
-    {
-        check01 = (center.x - Q1.x)*(Q2.y - Q1.y) + (center.y - Q1.y)*(Q2.x - Q1.x);
-        check02 = (-Q1.x)*(Q2.y - Q1.y) + (-Q1.y)*(Q2.x - Q1.x);
-        if( check01*check02 > 0 )
-        {
-            check01 = (center.x - Q2.x)*(Q0.y - Q2.y) + (center.y - Q2.y)*(Q0.x - Q2.x);
-            check02 = (-Q2.x)*(Q0.y - Q2.y) + (-Q2.y)*(Q0.x - Q2.x);
-            if( check01*check02 > 0 )
-            {
-                check_origin = 0;
-            }
-        }
-    }
-
-    // Calculate angle
-    d_nm_angle = 0;
-    d_angle = angle(Q0,Q2);
-    if( k_nonmon == 0 )
-    {
-        if( check_origin == 0 )
-        {
-        }
-        else
-        {
-            d_angle = 2*CV_PI - d_angle;
-        }
-    }
-    else
-    {
-        if( k_nonmon == 1 )
-        {
-            d_nm_angle = angle(Q0,Q1_nm);
-            if(d_nm_angle > d_angle)
-            {
-                d_nm_angle = d_nm_angle - d_angle;
-            }
-        }
-
-        if( k_nonmon == 2 )
-        {
-            d_nm_angle = angle(Q0,Q2_nm);
-            if(d_nm_angle > d_angle)
-            {
-                d_nm_angle = d_nm_angle - d_angle;
-            }
-        }
-
-        if( k_nonmon == 3 )
-        {
-            d_nm_angle = angle(Q0,Q1_nm);
-            if(d_nm_angle > d_angle)
-            {
-                d_nm_angle = d_nm_angle - d_angle;
-                d_nm_angle = d_nm_angle + angle(Q0, Q2_nm);
-            }
-            else
-            {
-                d_nm_angle = d_nm_angle + angle(Q2,Q2_nm);
-            }
-        }
-    }
-/*
-    B0->x = -B0->x;
-    B0->y = -B0->y;
-    B1->x = -B1->x;
-    B1->y = -B1->y;
-*/
-    return d_angle*K_B + d_nm_angle*K_NM + k_zero*K_Z;
-    //return 0;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////
-void _cvWorkEast(int i, int j, _CvWork** W, CvPoint2D32f* edges1, CvPoint2D32f* edges2)
-{
-    double w1,w2;
-    CvPoint2D32f small_edge;
-
-    //W[i,j].w_east
-    w1 = W[i-1][j].w_east /*+ _cvBendingWork(   &edges1[i-2],
-                                            &edges1[i-1],
-                                            &null_edge ,
-                                            &null_edge,
-                                            NULL)*/;
-
-    small_edge.x = NULL_EDGE*edges1[i-1].x;
-    small_edge.y = NULL_EDGE*edges1[i-1].y;
-
-    w2 = W[i-1][j].w_southeast + _cvBendingWork(&edges1[i-2],
-                                                &edges1[i-1],
-                                                &edges2[j-1],
-                                                /*&null_edge*/&small_edge/*,
-                                                &edges2[j]*/);
-
-    if(w1<w2)
-    {
-        W[i][j].w_east = w1 + _cvStretchingWork( &edges1[i-1], &null_edge );
-        W[i][j].path_e = PATH_TO_E;
-    }
-    else
-    {
-        W[i][j].w_east = w2 + _cvStretchingWork( &edges1[i-1], &null_edge );
-        W[i][j].path_e = PATH_TO_SE;
-    }
-}
-
-
-
-
-
-////////////////////////////////////////////////////////////////////////////////////
-void _cvWorkSouthEast(int i, int j, _CvWork** W, CvPoint2D32f* edges1, CvPoint2D32f* edges2)
-{
-    double w1,w2,w3;
-    CvPoint2D32f small_edge;
-
-    //W[i,j].w_southeast
-    small_edge.x = NULL_EDGE*edges1[i-2].x;
-    small_edge.y = NULL_EDGE*edges1[i-2].y;
-
-    w1 = W[i-1][j-1].w_east + _cvBendingWork(&edges1[i-2],
-                                            &edges1[i-1],
-                                            /*&null_edge*/&small_edge,
-                                            &edges2[j-1]/*,
-                                            &edges2[j-2]*/);
-
-    w2 = W[i-1][j-1].w_southeast + _cvBendingWork(  &edges1[i-2],
-                                                    &edges1[i-1],
-                                                    &edges2[j-2],
-                                                    &edges2[j-1]/*,
-                                                    NULL*/);
-
-    small_edge.x = NULL_EDGE*edges2[j-2].x;
-    small_edge.y = NULL_EDGE*edges2[j-2].y;
-
-    w3 = W[i-1][j-1].w_south + _cvBendingWork(  /*&null_edge*/&small_edge,
-                                                &edges1[i-1],
-                                                &edges2[j-2],
-                                                &edges2[j-1]/*,
-                                                &edges1[i-2]*/);
-
-    if( w1<w2 )
-    {
-        if(w1<w3)
-        {
-            W[i][j].w_southeast = w1 + _cvStretchingWork( &edges1[i-1], &edges2[j-1] );
-            W[i][j].path_se = PATH_TO_E;
-        }
-        else
-        {
-            W[i][j].w_southeast = w3 + _cvStretchingWork( &edges1[i-1], &edges2[j-1] );
-            W[i][j].path_se = 3;
-        }
-    }
-    else
-    {
-        if( w2<w3)
-        {
-            W[i][j].w_southeast = w2 + _cvStretchingWork( &edges1[i-1], &edges2[j-1] );
-            W[i][j].path_se = PATH_TO_SE;
-        }
-        else
-        {
-            W[i][j].w_southeast = w3 + _cvStretchingWork( &edges1[i-1], &edges2[j-1] );
-            W[i][j].path_se = 3;
-        }
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-void _cvWorkSouth(int i, int j, _CvWork** W, CvPoint2D32f* edges1, CvPoint2D32f* edges2)
-{
-    double w1,w2;
-    CvPoint2D32f small_edge;
-
-    //W[i,j].w_south
-
-    small_edge.x = NULL_EDGE*edges2[j-1].x;
-    small_edge.y = NULL_EDGE*edges2[j-1].y;
-
-    w1 = W[i][j-1].w_southeast + _cvBendingWork(&edges1[i-1],
-                                                /*&null_edge*/&small_edge,
-                                                &edges2[j-2],
-                                                &edges2[j-1]/*,
-                                                &edges1[i]*/);
-
-    w2 = W[i][j-1].w_south /*+ _cvBendingWork(  &null_edge ,
-                                            &null_edge,
-                                            &edges2[j-2],
-                                            &edges2[j-1],
-                                            NULL)*/;
-
-    if( w1<w2 )
-    {
-        W[i][j].w_south = w1 + _cvStretchingWork( &null_edge, &edges2[j-1] );
-        W[i][j].path_s = PATH_TO_SE;
-    }
-    else
-    {
-        W[i][j].w_south = w2 + _cvStretchingWork( &null_edge, &edges2[j-1] );
-        W[i][j].path_s = 3;
-    }
-}
-
-
-//===================================================
-CvPoint2D32f Q(CvPoint2D32f q0,CvPoint2D32f q1,CvPoint2D32f q2,double t)
-{
-    CvPoint2D32f q;
-
-    q.x = (float)(q0.x*(1-t)*(1-t) + 2*q1.x*t*(1-t) + q2.x*t*t);
-    q.y = (float)(q0.y*(1-t)*(1-t) + 2*q1.y*t*(1-t) + q2.y*t*t);
-
-    return q;
-}
-
-double angle(CvPoint2D32f A, CvPoint2D32f B)
-{
-    return acos( (A.x*B.x + A.y*B.y)/sqrt( (double)(A.x*A.x + A.y*A.y)*(B.x*B.x + B.y*B.y) ) );
-}
-#if 0
-/***************************************************************************************\
-*
-*   This function compute intermediate polygon between contour1 and contour2
-*
-*   Correspondence between points of contours specify by corr
-*
-*   param = [0,1];  0 correspondence to contour1, 1 - contour2
-*
-\***************************************************************************************/
-static CvSeq* icvBlendContours(CvSeq* contour1,
-                        CvSeq* contour2,
-                        CvSeq* corr,
-                        double param,
-                        CvMemStorage* storage)
-{
-    int j;
-
-    CvSeqWriter writer01;
-    CvSeqReader reader01;
-
-    int Ni,Nj;              // size of contours
-    int i;                  // counter
-
-    CvPoint* point1;        // array of first contour point
-    CvPoint* point2;        // array of second contour point
-
-    CvPoint point_output;   // intermediate storage of ouput point
-
-    int corr_point;
-
-    // Create output sequence.
-    CvSeq* output = cvCreateSeq(0,
-                                sizeof(CvSeq),
-                                sizeof(CvPoint),
-                                storage );
-
-    // Find size of contours.
-    Ni = contour1->total + 1;
-    Nj = contour2->total + 1;
-
-    point1 = (CvPoint* )malloc( Ni*sizeof(CvPoint) );
-    point2 = (CvPoint* )malloc( Nj*sizeof(CvPoint) );
-
-    // Initialize arrays of point
-    cvCvtSeqToArray( contour1, point1, CV_WHOLE_SEQ );
-    cvCvtSeqToArray( contour2, point2, CV_WHOLE_SEQ );
-
-    // First and last point mast be equal.
-    point1[Ni-1] = point1[0];
-    point2[Nj-1] = point2[0];
-
-    // Initializes process of writing to sequence.
-    cvStartAppendToSeq( output, &writer01);
-
-    i = Ni-1; //correspondence to points of contour1
-    for( ; corr; corr = corr->h_next )
-    {
-        //Initializes process of sequential reading from sequence
-        cvStartReadSeq( corr, &reader01, 0 );
-
-        for(j=0; j < corr->total; j++)
-        {
-            // Read element from sequence.
-            CV_READ_SEQ_ELEM( corr_point, reader01 );
-
-            // Compute point of intermediate polygon.
-            point_output.x = cvRound(point1[i].x + param*( point2[corr_point].x - point1[i].x ));
-            point_output.y = cvRound(point1[i].y + param*( point2[corr_point].y - point1[i].y ));
-
-            // Write element to sequence.
-            CV_WRITE_SEQ_ELEM( point_output, writer01 );
-        }
-        i--;
-    }
-    // Updates sequence header.
-    cvFlushSeqWriter( &writer01 );
-
-    return output;
-}
-
-/**************************************************************************************************
-*
-*
-*
-*
-*
-*
-*
-*
-*
-*
-**************************************************************************************************/
-
-
-static void icvCalcContoursCorrespondence(CvSeq* contour1,
-                                   CvSeq* contour2,
-                                   CvSeq** corr,
-                                   CvMemStorage* storage)
-{
-    int i,j;                    // counter of cycles
-    int Ni,Nj;                  // size of contours
-    _CvWork** W;                // graph for search minimum of work
-
-    CvPoint* point1;            // array of first contour point
-    CvPoint* point2;            // array of second contour point
-    CvPoint2D32f* edges1;       // array of first contour edge
-    CvPoint2D32f* edges2;       // array of second contour edge
-
-    //CvPoint null_edge = {0,0};    //
-    CvPoint2D32f small_edge;
-    //double inf;                   // infinity
-
-    CvSeq* corr01;
-    CvSeqWriter writer;
-
-    char path;                  //
-
-    // Find size of contours
-    Ni = contour1->total + 1;
-    Nj = contour2->total + 1;
-
-    // Create arrays
-    W = (_CvWork**)malloc(sizeof(_CvWork*)*Ni);
-    for(i=0; i<Ni; i++)
-    {
-        W[i] = (_CvWork*)malloc(sizeof(_CvWork)*Nj);
-    }
-
-    point1 = (CvPoint* )malloc( Ni*sizeof(CvPoint) );
-    point2 = (CvPoint* )malloc( Nj*sizeof(CvPoint) );
-    edges1 = (CvPoint2D32f* )malloc( (Ni-1)*sizeof(CvPoint2D32f) );
-    edges2 = (CvPoint2D32f* )malloc( (Nj-1)*sizeof(CvPoint2D32f) );
-
-    // Initialize arrays of point
-    cvCvtSeqToArray( contour1, point1, CV_WHOLE_SEQ );
-    cvCvtSeqToArray( contour2, point2, CV_WHOLE_SEQ );
-
-    point1[Ni-1] = point1[0];
-    point2[Nj-1] = point2[0];
-
-    for(i=0;i<Ni-1;i++)
-    {
-        edges1[i].x = (float)( point1[i+1].x - point1[i].x );
-        edges1[i].y = (float)( point1[i+1].y - point1[i].y );
-    };
-
-    for(i=0;i<Nj-1;i++)
-    {
-        edges2[i].x = (float)( point2[i+1].x - point2[i].x );
-        edges2[i].y = (float)( point2[i+1].y - point2[i].y );
-    };
-
-    // Find infinity constant
-    //inf=1;
-/////////////
-
-//Find min path in graph
-
-/////////////
-    W[0][0].w_east      = 0;
-    W[0][0].w_south     = 0;
-    W[0][0].w_southeast = 0;
-
-    W[1][1].w_southeast = _cvStretchingWork( &edges1[0], &edges2[0] );
-    W[1][1].w_east = inf;
-    W[1][1].w_south = inf;
-    W[1][1].path_se = PATH_TO_SE;
-
-    W[0][1].w_south =  _cvStretchingWork( &null_edge, &edges2[0] );
-    W[0][1].path_s = 3;
-    W[1][0].w_east =  _cvStretchingWork( &edges2[0], &null_edge );
-    W[1][0].path_e = PATH_TO_E;
-
-    for( i=1; i<Ni; i++ )
-    {
-        W[i][0].w_south     = inf;
-        W[i][0].w_southeast = inf;
-    }
-
-    for(j=1; j<Nj; j++)
-    {
-        W[0][j].w_east      = inf;
-        W[0][j].w_southeast = inf;
-    }
-
-    for(i=2; i<Ni; i++)
-    {
-        j=0;/////////
-        W[i][j].w_east = W[i-1][j].w_east;
-        W[i][j].w_east = W[i][j].w_east /*+
-            _cvBendingWork( &edges1[i-2], &edges1[i-1], &null_edge, &null_edge, NULL )*/;
-        W[i][j].w_east = W[i][j].w_east + _cvStretchingWork( &edges2[i-1], &null_edge );
-        W[i][j].path_e = PATH_TO_E;
-
-        j=1;//////////
-        W[i][j].w_south = inf;
-
-        _cvWorkEast (i, j, W, edges1, edges2);
-
-        W[i][j].w_southeast = W[i-1][j-1].w_east;
-        W[i][j].w_southeast = W[i][j].w_southeast + _cvStretchingWork( &edges1[i-1], &edges2[j-1] );
-
-        small_edge.x = NULL_EDGE*edges1[i-2].x;
-        small_edge.y = NULL_EDGE*edges1[i-2].y;
-
-        W[i][j].w_southeast = W[i][j].w_southeast +
-            _cvBendingWork( &edges1[i-2], &edges1[i-1], /*&null_edge*/&small_edge, &edges2[j-1]/*, &edges2[Nj-2]*/);
-
-        W[i][j].path_se = PATH_TO_E;
-    }
-
-    for(j=2; j<Nj; j++)
-    {
-        i=0;//////////
-        W[i][j].w_south = W[i][j-1].w_south;
-        W[i][j].w_south = W[i][j].w_south + _cvStretchingWork( &null_edge, &edges2[j-1] );
-        W[i][j].w_south = W[i][j].w_south /*+
-            _cvBendingWork( &null_edge, &null_edge, &edges2[j-2], &edges2[j-1], NULL )*/;
-        W[i][j].path_s = 3;
-
-        i=1;///////////
-        W[i][j].w_east= inf;
-
-        _cvWorkSouth(i, j, W, edges1, edges2);
-
-        W[i][j].w_southeast = W[i-1][j-1].w_south;
-        W[i][j].w_southeast = W[i][j].w_southeast + _cvStretchingWork( &edges1[i-1], &edges2[j-1] );
-
-        small_edge.x = NULL_EDGE*edges2[j-2].x;
-        small_edge.y = NULL_EDGE*edges2[j-2].y;
-
-        W[i][j].w_southeast = W[i][j].w_southeast +
-            _cvBendingWork( /*&null_edge*/&small_edge, &edges1[i-1], &edges2[j-2], &edges2[j-1]/*, &edges1[Ni-2]*/);
-        W[i][j].path_se = 3;
-    }
-
-    for(i=2; i<Ni; i++)
-        for(j=2; j<Nj; j++)
-        {
-            _cvWorkEast     (i, j, W, edges1, edges2);
-            _cvWorkSouthEast(i, j, W, edges1, edges2);
-            _cvWorkSouth    (i, j, W, edges1, edges2);
-        }
-
-    i=Ni-1;j=Nj-1;
-
-    *corr = cvCreateSeq(0,
-                        sizeof(CvSeq),
-                        sizeof(int),
-                        storage );
-
-    corr01 = *corr;
-    cvStartAppendToSeq( corr01, &writer );
-    if( W[i][j].w_east > W[i][j].w_southeast )
-        {
-            if( W[i][j].w_southeast > W[i][j].w_south )
-            {
-                path = 3;
-            }
-            else
-            {
-                path = PATH_TO_SE;
-            }
-        }
-        else
-        {
-            if( W[i][j].w_east < W[i][j].w_south )
-            {
-                path = PATH_TO_E;
-            }
-            else
-            {
-                path = 3;
-            }
-        }
-    do
-    {
-        CV_WRITE_SEQ_ELEM( j, writer );
-
-        switch( path )
-        {
-        case PATH_TO_E:
-            path = W[i][j].path_e;
-            i--;
-            cvFlushSeqWriter( &writer );
-            corr01->h_next = cvCreateSeq(   0,
-                                            sizeof(CvSeq),
-                                            sizeof(int),
-                                            storage );
-            corr01 = corr01->h_next;
-            cvStartAppendToSeq( corr01, &writer );
-            break;
-
-        case PATH_TO_SE:
-            path = W[i][j].path_se;
-            j--; i--;
-            cvFlushSeqWriter( &writer );
-            corr01->h_next = cvCreateSeq(   0,
-                                            sizeof(CvSeq),
-                                            sizeof(int),
-                                            storage );
-            corr01 = corr01->h_next;
-            cvStartAppendToSeq( corr01, &writer );
-            break;
-
-        case 3:
-            path = W[i][j].path_s;
-            j--;
-            break;
-        }
-
-    } while( (i>=0) && (j>=0) );
-    cvFlushSeqWriter( &writer );
-
-    // Free memory
-    for(i=1;i<Ni;i++)
-    {
-        free(W[i]);
-    }
-    free(W);
-    free(point1);
-    free(point2);
-    free(edges1);
-    free(edges2);
-}
-#endif
diff --git a/modules/legacy/src/morphing.cpp b/modules/legacy/src/morphing.cpp
deleted file mode 100644 (file)
index ab85b3b..0000000
+++ /dev/null
@@ -1,391 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-#include <assert.h>
-
-
-static CvStatus
-icvMorphEpilines8uC3( uchar * first_pix,        /* raster epiline from image 1      */
-                      uchar * second_pix,       /* raster epiline from image 2      */
-                      uchar * dst_pix,  /* raster epiline from dest image   */
-                      /* (it's an output parameter)       */
-                      float alpha,      /* relative position of camera      */
-                      int *first,       /* first sequence of runs           */
-                      int first_runs,   /* it's length                      */
-                      int *second,      /* second sequence of runs          */
-                      int second_runs, int *first_corr, /* corr data for the 1st seq        */
-                      int *second_corr, /* corr data for the 2nd seq        */
-                      int dst_len )
-{
-
-    float alpha1;               /* alpha - 1.0 */
-    int s, s1;                  /* integer variant of alpha and alpha1 ( 0 <= s,s1 <= 256 ) */
-    int curr;                   /* current index in run's array */
-
-    float begLine;              /* begin of current run */
-    float endLine;              /* end   of current run */
-
-    float begCorr;              /* begin of correspondence destination of run */
-    float endCorr;              /* end   of correspondence destination of run */
-
-    int begDestLine;            /* begin of current destanation of run */
-    int endDestLine;            /* end   of current destanation of run */
-    int begLineIndex;
-    int endLineIndex;
-    int indexImg1;
-    float step = 0;
-    int n;
-
-    memset( dst_pix, 0, dst_len );
-    alpha1 = (float) (1.0 - alpha);
-
-    s = (int) (alpha * 256);
-    s1 = 256 - s;
-
-    /* --------------Create first line------------- */
-
-    begLineIndex = first[0];
-    begLine = (float) begLineIndex;
-
-    curr = 0;
-
-    for( n = 0; n < first_runs; n++ )
-    {                           /* for each run */
-
-        begCorr = (float) first_corr[curr];
-        curr++;
-        endCorr = (float) first_corr[curr];
-        curr++;
-        endLineIndex = first[curr];
-        endLine = (float) endLineIndex;
-
-        begDestLine = (int) (alpha * begLine + alpha1 * begCorr);
-        endDestLine = (int) (alpha * endLine + alpha1 * endCorr);
-
-        indexImg1 = begDestLine * 3;
-
-        step = 0;
-        if( endDestLine != begDestLine )
-            step = (endLine - begLine) / ((float) (endDestLine - begDestLine));
-
-        if( begCorr != endCorr )
-        {
-
-            for( ; begDestLine < endDestLine; begDestLine++ )
-            {
-                /* for each pixel */
-
-                begLineIndex = (int) begLine;
-                begLineIndex *= 3;
-
-                /* Blend R */
-                dst_pix[indexImg1] = (uchar) (((int) (first_pix[begLineIndex]) * s) >> 8);
-
-                indexImg1++;
-
-                /* Blend G */
-                dst_pix[indexImg1] = (uchar) (((int) (first_pix[begLineIndex + 1]) * s) >> 8);
-
-                indexImg1++;
-
-                /* Blend B */
-                dst_pix[indexImg1] = (uchar) (((int) (first_pix[begLineIndex + 2]) * s) >> 8);
-
-                indexImg1++;
-
-                begLine += step;
-
-            }                   /* for */
-        }
-        else
-        {
-
-            for( ; begDestLine < endDestLine; begDestLine++ )
-            {
-                /* for each pixel */
-
-                begLineIndex = (int) begLine;
-                begLineIndex *= 3;
-
-                /* Blend R */
-                dst_pix[indexImg1] = first_pix[begLineIndex];
-                indexImg1++;
-
-                /* Blend G */
-                dst_pix[indexImg1] = first_pix[begLineIndex + 1];
-                indexImg1++;
-
-                /* Blend B */
-                dst_pix[indexImg1] = first_pix[begLineIndex + 2];
-
-                indexImg1++;
-
-                begLine += step;
-
-            }                   /* for */
-        }                       /* if */
-
-        begLineIndex = endLineIndex;
-        begLine = endLine;
-
-
-    }                           /* for each runs in first line */
-
-    begLineIndex = second[0];
-    begLine = (float) begLineIndex;
-
-    curr = 0;
-
-    /* --------------Create second line------------- */
-    curr = 0;;
-    for( n = 0; n < second_runs; n++ )
-    {                           /* for each run */
-
-        begCorr = (float) second_corr[curr];
-        curr++;
-        endCorr = (float) second_corr[curr];
-        curr++;
-        endLineIndex = second[curr];
-        endLine = (float) endLineIndex;
-
-        begDestLine = (int) (alpha1 * begLine + alpha * begCorr);
-        endDestLine = (int) (alpha1 * endLine + alpha * endCorr);
-
-        indexImg1 = begDestLine * 3;
-
-        step = 0;
-        if (endDestLine != begDestLine)
-            step = (endLine - begLine) / ((float) (endDestLine - begDestLine));
-
-        if( begCorr != endCorr )
-        {
-
-            for( ; begDestLine < endDestLine; begDestLine++ )
-            {
-                /* for each pixel */
-
-                begLineIndex = (int) begLine;
-                begLineIndex *= 3;
-
-                /* Blend R */
-                dst_pix[indexImg1] =
-                    (uchar) (dst_pix[indexImg1] +
-                             (uchar) (((unsigned int) (second_pix[begLineIndex]) * s1) >> 8));
-
-                indexImg1++;
-
-                /* Blend G */
-                dst_pix[indexImg1] =
-                    (uchar) (dst_pix[indexImg1] +
-                             (uchar) (((unsigned int) (second_pix[begLineIndex + 1]) * s1) >>
-                                      8));
-
-                indexImg1++;
-
-                /* Blend B */
-                dst_pix[indexImg1] =
-                    (uchar) (dst_pix[indexImg1] +
-                             (uchar) (((unsigned int) (second_pix[begLineIndex + 2]) * s1) >>
-                                      8));
-
-                indexImg1++;
-
-                begLine += step;
-
-            }                   /* for */
-        }
-        else
-        {
-
-            for( ; begDestLine < endDestLine; begDestLine++ )
-            {
-                /* for each pixel */
-
-                begLineIndex = (int) begLine;
-                begLineIndex *= 3;
-
-                /* Blend R */
-                dst_pix[indexImg1] = (uchar) (dst_pix[indexImg1] + second_pix[begLineIndex]);
-                indexImg1++;
-
-                /* Blend G */
-                dst_pix[indexImg1] =
-                    (uchar) (dst_pix[indexImg1] + second_pix[begLineIndex + 1]);
-                indexImg1++;
-
-                /* Blend B */
-                dst_pix[indexImg1] =
-                    (uchar) (dst_pix[indexImg1] + second_pix[begLineIndex + 2]);
-                /*assert(indexImg1 < dst_len); */
-
-                indexImg1++;
-
-                begLine += step;
-
-            }                   /* for */
-        }                       /* if */
-
-        begLineIndex = endLineIndex;
-        begLine = endLine;
-
-    }                           /* for each runs in second line */
-
-    return CV_NO_ERR;
-
-}                               /* icvMorphEpilines8uC3 */
-
-
-/*======================================================================================*/
-
-static CvStatus
-icvMorphEpilines8uC3Multi( int lines,   /* number of lines                              */
-                           uchar * first_pix,   /* raster epilines from the first image         */
-                           int *first_num,      /* numbers of pixel in first line               */
-                           uchar * second_pix,  /* raster epilines from the second image        */
-                           int *second_num,     /* numbers of pixel in second line              */
-                           uchar * dst_pix,     /* raster epiline from the destination image    */
-                           /* (it's an output parameter)                   */
-                           int *dst_num,        /* numbers of pixel in output line              */
-                           float alpha, /* relative position of camera                  */
-                           int *first,  /* first sequence of runs                       */
-                           int *first_runs,     /* it's length                                  */
-                           int *second, /* second sequence of runs                      */
-                           int *second_runs, int *first_corr,   /* correspond information for the 1st seq       */
-                           int *second_corr )   /* correspond information for the 2nd seq       */
-{
-    CvStatus error;
-    int currLine;
-    int currFirstPix = 0;
-    //int currFirstNum = 0;
-    int currSecondPix = 0;
-    //int currSecondNum = 0;
-    int currDstPix = 0;
-    int currFirst = 0;
-    //int currFirstRuns = 0;
-    int currSecond = 0;
-    //int currSecondRuns = 0;
-    int currFirstCorr = 0;
-    int currSecondCorr = 0;
-
-    if( lines < 1 ||
-        first_pix == 0 ||
-        first_num == 0 ||
-        second_pix == 0 ||
-        second_num == 0 ||
-        dst_pix == 0 ||
-        dst_num == 0 ||
-        alpha < 0 ||
-        alpha > 1 ||
-        first == 0 ||
-        first_runs == 0 ||
-        second == 0 || second_runs == 0 || first_corr == 0 || second_corr == 0 )
-        return CV_BADFACTOR_ERR;
-
-    for( currLine = 0; currLine < lines; currLine++ )
-    {
-
-        error = icvMorphEpilines8uC3( &(first_pix[currFirstPix]),
-                                      &(second_pix[currSecondPix]),
-                                      &(dst_pix[currDstPix]),
-                                      alpha,
-                                      &(first[currFirst]),
-                                      first_runs[currLine],
-                                      &(second[currSecond]),
-                                      second_runs[currLine],
-                                      &(first_corr[currFirstCorr]),
-                                      &(second_corr[currSecondCorr]), dst_num[currLine] * 3 );
-
-
-        if( error != CV_NO_ERR )
-            return CV_NO_ERR;
-
-        currFirstPix += first_num[currLine] * 3;
-        currSecondPix += second_num[currLine] * 3;
-        currDstPix += dst_num[currLine] * 3;
-        currFirst += (first_runs[currLine] * 2) + 1;
-        currSecond += (second_runs[currLine] * 2) + 1;
-        currFirstCorr += first_runs[currLine] * 2;
-        currSecondCorr += second_runs[currLine] * 2;
-
-    }                           /* for */
-
-    return CV_NO_ERR;
-
-}                               /* icvMorphEpilines8uC3Multi */
-
-
-
-
-/*======================================================================================*/
-
-CV_IMPL void
-cvMorphEpilinesMulti( int lines,        /* number of lines             */
-                      uchar * first_pix,        /* raster epilines from the first image      */
-                      int *first_num,   /* numbers of pixel in first line            */
-                      uchar * second_pix,       /* raster epilines from the second image     */
-                      int *second_num,  /* numbers of pixel in second line           */
-                      uchar * dst_pix,  /* raster epiline from the destination image */
-                      /* (it's an output parameter)                */
-                      int *dst_num,     /* numbers of pixel in output line           */
-                      float alpha,      /* relative position of camera               */
-                      int *first,       /* first sequence of runs                    */
-                      int *first_runs,  /* it's length                               */
-                      int *second,      /* second sequence of runs                   */
-                      int *second_runs, int *first_corr,        /* correspond information for the 1st seq    */
-                      int *second_corr  /* correspond information for the 2nd seq     */
-     )
-{
-    IPPI_CALL( icvMorphEpilines8uC3Multi( lines,        /* number of lines                           */
-                                          first_pix,    /* raster epilines from the first image      */
-                                          first_num,    /* numbers of pixel in first line            */
-                                          second_pix,   /* raster epilines from the second image     */
-                                          second_num,   /* numbers of pixel in second line           */
-                                          dst_pix,      /* raster epiline from the destination image */
-                                          /* (it's an output parameter)                   */
-                                          dst_num,      /* numbers of pixel in output line           */
-                                          alpha,        /* relative position of camera               */
-                                          first,        /* first sequence of runs                    */
-                                          first_runs,   /* it's length                               */
-                                          second,       /* second sequence of runs                   */
-                                          second_runs, first_corr,      /* correspond information for the 1st seq    */
-                                          second_corr   /* correspond information for the 2nd seq     */
-                ));
-}
diff --git a/modules/legacy/src/oneway.cpp b/modules/legacy/src/oneway.cpp
deleted file mode 100644 (file)
index 09826ae..0000000
+++ /dev/null
@@ -1,2309 +0,0 @@
-/*
- *  cvoneway.cpp
- *  one_way_sample
- *
- *  Created by Victor  Eruhimov on 3/23/10.
- *  Copyright 2010 Argus Corp. All rights reserved.
- *
- */
-
-#include "precomp.hpp"
-#include "opencv2/opencv_modules.hpp"
-#ifdef HAVE_OPENCV_HIGHGUI
-#  include "opencv2/highgui.hpp"
-#endif
-#include <stdio.h>
-
-namespace cv{
-
-    inline int round(float value)
-    {
-        if(value > 0)
-        {
-            return int(value + 0.5f);
-        }
-        else
-        {
-            return int(value - 0.5f);
-        }
-    }
-
-    inline CvRect resize_rect(CvRect rect, float alpha)
-    {
-        return cvRect(rect.x + round((float)(0.5*(1 - alpha)*rect.width)), rect.y + round((float)(0.5*(1 - alpha)*rect.height)),
-                      round(rect.width*alpha), round(rect.height*alpha));
-    }
-
-    CvMat* ConvertImageToMatrix(IplImage* patch);
-
-    class CvCameraPose
-        {
-        public:
-            CvCameraPose()
-            {
-                m_rotation = cvCreateMat(1, 3, CV_32FC1);
-                m_translation = cvCreateMat(1, 3, CV_32FC1);
-            };
-
-            ~CvCameraPose()
-            {
-                cvReleaseMat(&m_rotation);
-                cvReleaseMat(&m_translation);
-            };
-
-            void SetPose(CvMat* rotation, CvMat* translation)
-            {
-                cvCopy(rotation, m_rotation);
-                cvCopy(translation, m_translation);
-            };
-
-            CvMat* GetRotation() {return m_rotation;}
-            CvMat* GetTranslation() {return m_translation;}
-
-        protected:
-            CvMat* m_rotation;
-            CvMat* m_translation;
-        };
-
-    // AffineTransformPatch: generates an affine transformed image patch.
-    // - src: source image (roi is supported)
-    // - dst: output image. ROI of dst image should be 2 times smaller than ROI of src.
-    // - pose: parameters of an affine transformation
-    void AffineTransformPatch(IplImage* src, IplImage* dst, CvAffinePose pose);
-
-    // GenerateAffineTransformFromPose: generates an affine transformation matrix from CvAffinePose instance
-    // - size: the size of image patch
-    // - pose: affine transformation
-    // - transform: 2x3 transformation matrix
-    void GenerateAffineTransformFromPose(CvSize size, CvAffinePose pose, CvMat* transform);
-
-    // Generates a random affine pose
-    CvAffinePose GenRandomAffinePose();
-
-
-    const static int num_mean_components = 500;
-    const static float noise_intensity = 0.15f;
-
-
-    static inline CvPoint rect_center(CvRect rect)
-    {
-        return cvPoint(rect.x + rect.width/2, rect.y + rect.height/2);
-    }
-
-    // static void homography_transform(IplImage* frontal, IplImage* result, CvMat* homography)
-    // {
-    //     cvWarpPerspective(frontal, result, homography);
-    // }
-
-    static CvAffinePose perturbate_pose(CvAffinePose pose, float noise)
-    {
-        // perturbate the matrix
-        float noise_mult_factor = 1 + (0.5f - float(rand())/RAND_MAX)*noise;
-        float noise_add_factor = noise_mult_factor - 1;
-
-        CvAffinePose pose_pert = pose;
-        pose_pert.phi += noise_add_factor;
-        pose_pert.theta += noise_mult_factor;
-        pose_pert.lambda1 *= noise_mult_factor;
-        pose_pert.lambda2 *= noise_mult_factor;
-
-        return pose_pert;
-    }
-
-    static void generate_mean_patch(IplImage* frontal, IplImage* result, CvAffinePose pose, int pose_count, float noise)
-    {
-        IplImage* sum = cvCreateImage(cvSize(result->width, result->height), IPL_DEPTH_32F, 1);
-        IplImage* workspace = cvCloneImage(result);
-        IplImage* workspace_float = cvCloneImage(sum);
-
-        cvSetZero(sum);
-        for(int i = 0; i < pose_count; i++)
-        {
-            CvAffinePose pose_pert = perturbate_pose(pose, noise);
-
-            AffineTransformPatch(frontal, workspace, pose_pert);
-            cvConvertScale(workspace, workspace_float);
-            cvAdd(sum, workspace_float, sum);
-        }
-
-        cvConvertScale(sum, result, 1.0f/pose_count);
-
-        cvReleaseImage(&workspace);
-        cvReleaseImage(&sum);
-        cvReleaseImage(&workspace_float);
-    }
-
-    // static void generate_mean_patch_fast(IplImage* /*frontal*/, IplImage* /*result*/, CvAffinePose /*pose*/,
-    //                               CvMat* /*pca_hr_avg*/, CvMat* /*pca_hr_eigenvectors*/, const OneWayDescriptor* /*pca_descriptors*/)
-    // {
-    //     /*for(int i = 0; i < pca_hr_eigenvectors->cols; i++)
-    //     {
-
-    //     }*/
-    // }
-
-    void readPCAFeatures(const char *filename, CvMat** avg, CvMat** eigenvectors, const char *postfix = "");
-    void readPCAFeatures(const FileNode &fn, CvMat** avg, CvMat** eigenvectors, const char* postfix = "");
-    void savePCAFeatures(FileStorage &fs, const char* postfix, CvMat* avg, CvMat* eigenvectors);
-    void calcPCAFeatures(std::vector<IplImage*>& patches, FileStorage &fs, const char* postfix, CvMat** avg,
-                         CvMat** eigenvectors);
-    void loadPCAFeatures(const char* path, const char* images_list, std::vector<IplImage*>& patches, CvSize patch_size);
-    void generatePCAFeatures(const char* path, const char* img_filename, FileStorage& fs, const char* postfix,
-                             CvSize patch_size, CvMat** avg, CvMat** eigenvectors);
-
-    void eigenvector2image(CvMat* eigenvector, IplImage* img);
-
-    void FindOneWayDescriptor(int desc_count, const OneWayDescriptor* descriptors, IplImage* patch, int& desc_idx, int& pose_idx, float& distance,
-                              CvMat* avg = 0, CvMat* eigenvalues = 0);
-
-    void FindOneWayDescriptor(int desc_count, const OneWayDescriptor* descriptors, IplImage* patch, int n,
-                              std::vector<int>& desc_idxs, std::vector<int>&  pose_idxs, std::vector<float>& distances,
-                              CvMat* avg = 0, CvMat* eigenvalues = 0);
-
-    void FindOneWayDescriptor(cv::flann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, int& desc_idx, int& pose_idx, float& distance,
-                              CvMat* avg = 0, CvMat* eigenvalues = 0);
-
-    void FindOneWayDescriptorEx(int desc_count, const OneWayDescriptor* descriptors, IplImage* patch,
-                                float scale_min, float scale_max, float scale_step,
-                                int& desc_idx, int& pose_idx, float& distance, float& scale,
-                                CvMat* avg, CvMat* eigenvectors);
-
-    void FindOneWayDescriptorEx(int desc_count, const OneWayDescriptor* descriptors, IplImage* patch,
-                                float scale_min, float scale_max, float scale_step,
-                                int n, std::vector<int>& desc_idxs, std::vector<int>& pose_idxs,
-                                std::vector<float>& distances, std::vector<float>& scales,
-                                CvMat* avg, CvMat* eigenvectors);
-
-    void FindOneWayDescriptorEx(cv::flann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch,
-                                float scale_min, float scale_max, float scale_step,
-                                int& desc_idx, int& pose_idx, float& distance, float& scale,
-                                CvMat* avg, CvMat* eigenvectors);
-
-    inline CvRect fit_rect_roi_fixedsize(CvRect rect, CvRect roi)
-    {
-        CvRect fit = rect;
-        fit.x = MAX(fit.x, roi.x);
-        fit.y = MAX(fit.y, roi.y);
-        fit.x = MIN(fit.x, roi.x + roi.width - fit.width - 1);
-        fit.y = MIN(fit.y, roi.y + roi.height - fit.height - 1);
-        return(fit);
-    }
-
-    inline CvRect fit_rect_fixedsize(CvRect rect, IplImage* img)
-    {
-        CvRect roi = cvGetImageROI(img);
-        return fit_rect_roi_fixedsize(rect, roi);
-    }
-
-    OneWayDescriptor::OneWayDescriptor()
-    {
-        m_pose_count = 0;
-        m_samples = 0;
-        m_input_patch = 0;
-        m_train_patch = 0;
-        m_pca_coeffs = 0;
-        m_affine_poses = 0;
-        m_transforms = 0;
-        m_pca_dim_low = 100;
-        m_pca_dim_high = 100;
-    }
-
-    OneWayDescriptor::~OneWayDescriptor()
-    {
-        if(m_pose_count)
-        {
-            for(int i = 0; i < m_pose_count; i++)
-            {
-                cvReleaseImage(&m_samples[i]);
-                cvReleaseMat(&m_pca_coeffs[i]);
-            }
-            cvReleaseImage(&m_input_patch);
-            cvReleaseImage(&m_train_patch);
-            delete []m_samples;
-            delete []m_pca_coeffs;
-
-            if(!m_transforms)
-            {
-                delete []m_affine_poses;
-            }
-        }
-    }
-
-    void OneWayDescriptor::Allocate(int pose_count, CvSize size, int nChannels)
-    {
-        m_pose_count = pose_count;
-        m_samples = new IplImage* [m_pose_count];
-        m_pca_coeffs = new CvMat* [m_pose_count];
-        m_patch_size = cvSize(size.width/2, size.height/2);
-
-        if(!m_transforms)
-        {
-            m_affine_poses = new CvAffinePose[m_pose_count];
-        }
-
-        int length = m_pca_dim_low;//roi.width*roi.height;
-        for(int i = 0; i < m_pose_count; i++)
-        {
-            m_samples[i] = cvCreateImage(cvSize(size.width/2, size.height/2), IPL_DEPTH_32F, nChannels);
-            m_pca_coeffs[i] = cvCreateMat(1, length, CV_32FC1);
-        }
-
-        m_input_patch = cvCreateImage(GetPatchSize(), IPL_DEPTH_8U, 1);
-        m_train_patch = cvCreateImage(GetInputPatchSize(), IPL_DEPTH_8U, 1);
-    }
-
-    // static void cvmSet2DPoint(CvMat* matrix, int row, int col, CvPoint2D32f point)
-    // {
-    //     cvmSet(matrix, row, col, point.x);
-    //     cvmSet(matrix, row, col + 1, point.y);
-    // }
-
-    // static void cvmSet3DPoint(CvMat* matrix, int row, int col, CvPoint3D32f point)
-    // {
-    //     cvmSet(matrix, row, col, point.x);
-    //     cvmSet(matrix, row, col + 1, point.y);
-    //     cvmSet(matrix, row, col + 2, point.z);
-    // }
-
-    CvAffinePose GenRandomAffinePose()
-    {
-        const float scale_min = 0.8f;
-        const float scale_max = 1.2f;
-        CvAffinePose pose;
-        pose.theta = float(rand())/RAND_MAX*120 - 60;
-        pose.phi = float(rand())/RAND_MAX*360;
-        pose.lambda1 = scale_min + float(rand())/RAND_MAX*(scale_max - scale_min);
-        pose.lambda2 = scale_min + float(rand())/RAND_MAX*(scale_max - scale_min);
-
-        return pose;
-    }
-
-    void GenerateAffineTransformFromPose(CvSize size, CvAffinePose pose, CvMat* transform)
-    {
-        CvMat* temp = cvCreateMat(3, 3, CV_32FC1);
-        CvMat* final = cvCreateMat(3, 3, CV_32FC1);
-        cvmSet(temp, 2, 0, 0.0f);
-        cvmSet(temp, 2, 1, 0.0f);
-        cvmSet(temp, 2, 2, 1.0f);
-
-        CvMat rotation;
-        cvGetSubRect(temp, &rotation, cvRect(0, 0, 3, 2));
-
-        cv2DRotationMatrix(cvPoint2D32f(size.width/2, size.height/2), pose.phi, 1.0, &rotation);
-        cvCopy(temp, final);
-
-        cvmSet(temp, 0, 0, pose.lambda1);
-        cvmSet(temp, 0, 1, 0.0f);
-        cvmSet(temp, 1, 0, 0.0f);
-        cvmSet(temp, 1, 1, pose.lambda2);
-        cvmSet(temp, 0, 2, size.width/2*(1 - pose.lambda1));
-        cvmSet(temp, 1, 2, size.height/2*(1 - pose.lambda2));
-        cvMatMul(temp, final, final);
-
-        cv2DRotationMatrix(cvPoint2D32f(size.width/2, size.height/2), pose.theta - pose.phi, 1.0, &rotation);
-        cvMatMul(temp, final, final);
-
-        cvGetSubRect(final, &rotation, cvRect(0, 0, 3, 2));
-        cvCopy(&rotation, transform);
-
-        cvReleaseMat(&temp);
-        cvReleaseMat(&final);
-    }
-
-    void AffineTransformPatch(IplImage* src, IplImage* dst, CvAffinePose pose)
-    {
-        CvRect src_large_roi = cvGetImageROI(src);
-
-        IplImage* temp = cvCreateImage(cvSize(src_large_roi.width, src_large_roi.height), IPL_DEPTH_32F, src->nChannels);
-        cvSetZero(temp);
-        IplImage* temp2 = cvCloneImage(temp);
-        CvMat* rotation_phi = cvCreateMat(2, 3, CV_32FC1);
-
-        CvSize new_size = cvSize(cvRound(temp->width*pose.lambda1), cvRound(temp->height*pose.lambda2));
-        IplImage* temp3 = cvCreateImage(new_size, IPL_DEPTH_32F, src->nChannels);
-
-        cvConvertScale(src, temp);
-        cvResetImageROI(temp);
-
-
-        cv2DRotationMatrix(cvPoint2D32f(temp->width/2, temp->height/2), pose.phi, 1.0, rotation_phi);
-        cvWarpAffine(temp, temp2, rotation_phi);
-
-        cvSetZero(temp);
-
-        cvResize(temp2, temp3);
-
-        cv2DRotationMatrix(cvPoint2D32f(temp3->width/2, temp3->height/2), pose.theta - pose.phi, 1.0, rotation_phi);
-        cvWarpAffine(temp3, temp, rotation_phi);
-
-        cvSetImageROI(temp, cvRect(temp->width/2 - src_large_roi.width/4, temp->height/2 - src_large_roi.height/4,
-                                   src_large_roi.width/2, src_large_roi.height/2));
-        cvConvertScale(temp, dst);
-        cvReleaseMat(&rotation_phi);
-
-        cvReleaseImage(&temp3);
-        cvReleaseImage(&temp2);
-        cvReleaseImage(&temp);
-    }
-
-    void OneWayDescriptor::GenerateSamples(int pose_count, IplImage* frontal, int norm)
-    {
-        /*    if(m_transforms)
-         {
-         GenerateSamplesWithTransforms(pose_count, frontal);
-         return;
-         }
-         */
-        CvRect roi = cvGetImageROI(frontal);
-        IplImage* patch_8u = cvCreateImage(cvSize(roi.width/2, roi.height/2), frontal->depth, frontal->nChannels);
-        for(int i = 0; i < pose_count; i++)
-        {
-            if(!m_transforms)
-            {
-                m_affine_poses[i] = GenRandomAffinePose();
-            }
-            //AffineTransformPatch(frontal, patch_8u, m_affine_poses[i]);
-            generate_mean_patch(frontal, patch_8u, m_affine_poses[i], num_mean_components, noise_intensity);
-
-            double scale = 1.0f;
-            if(norm)
-            {
-                double sum = cvSum(patch_8u).val[0];
-                scale = 1/sum;
-            }
-            cvConvertScale(patch_8u, m_samples[i], scale);
-
-#if 0
-            double maxval;
-            cvMinMaxLoc(m_samples[i], 0, &maxval);
-            IplImage* test = cvCreateImage(cvSize(roi.width/2, roi.height/2), IPL_DEPTH_8U, 1);
-            cvConvertScale(m_samples[i], test, 255.0/maxval);
-            cvNamedWindow("1", 1);
-            cvShowImage("1", test);
-            cvWaitKey(0);
-#endif
-        }
-        cvReleaseImage(&patch_8u);
-    }
-
-    void OneWayDescriptor::GenerateSamplesFast(IplImage* frontal, CvMat* pca_hr_avg,
-                                               CvMat* pca_hr_eigenvectors, OneWayDescriptor* pca_descriptors)
-    {
-        CvRect roi = cvGetImageROI(frontal);
-        if(roi.width != GetInputPatchSize().width || roi.height != GetInputPatchSize().height)
-        {
-            cvResize(frontal, m_train_patch);
-            frontal = m_train_patch;
-        }
-
-        CvMat* pca_coeffs = cvCreateMat(1, pca_hr_eigenvectors->cols, CV_32FC1);
-        double maxval;
-        cvMinMaxLoc(frontal, 0, &maxval);
-        CvMat* frontal_data = ConvertImageToMatrix(frontal);
-
-        double sum = cvSum(frontal_data).val[0];
-        cvConvertScale(frontal_data, frontal_data, 1.0f/sum);
-        cvProjectPCA(frontal_data, pca_hr_avg, pca_hr_eigenvectors, pca_coeffs);
-        for(int i = 0; i < m_pose_count; i++)
-        {
-            cvSetZero(m_samples[i]);
-            for(int j = 0; j < m_pca_dim_high; j++)
-            {
-                double coeff = cvmGet(pca_coeffs, 0, j);
-                IplImage* patch = pca_descriptors[j + 1].GetPatch(i);
-                cvAddWeighted(m_samples[i], 1.0, patch, coeff, 0, m_samples[i]);
-
-#if 0
-                printf("coeff%d = %f\n", j, coeff);
-                IplImage* test = cvCreateImage(cvSize(12, 12), IPL_DEPTH_8U, 1);
-                double maxval;
-                cvMinMaxLoc(patch, 0, &maxval);
-                cvConvertScale(patch, test, 255.0/maxval);
-                cvNamedWindow("1", 1);
-                cvShowImage("1", test);
-                cvWaitKey(0);
-#endif
-            }
-
-            cvAdd(pca_descriptors[0].GetPatch(i), m_samples[i], m_samples[i]);
-            double sm = cvSum(m_samples[i]).val[0];
-            cvConvertScale(m_samples[i], m_samples[i], 1.0/sm);
-
-#if 0
-            IplImage* test = cvCreateImage(cvSize(12, 12), IPL_DEPTH_8U, 1);
-            /*        IplImage* temp1 = cvCreateImage(cvSize(12, 12), IPL_DEPTH_32F, 1);
-             eigenvector2image(pca_hr_avg, temp1);
-             IplImage* test = cvCreateImage(cvSize(12, 12), IPL_DEPTH_8U, 1);
-             cvAdd(m_samples[i], temp1, temp1);
-             cvMinMaxLoc(temp1, 0, &maxval);
-             cvConvertScale(temp1, test, 255.0/maxval);*/
-            cvMinMaxLoc(m_samples[i], 0, &maxval);
-            cvConvertScale(m_samples[i], test, 255.0/maxval);
-
-            cvNamedWindow("1", 1);
-            cvShowImage("1", frontal);
-            cvNamedWindow("2", 1);
-            cvShowImage("2", test);
-            cvWaitKey(0);
-#endif
-        }
-
-        cvReleaseMat(&pca_coeffs);
-        cvReleaseMat(&frontal_data);
-    }
-
-    void OneWayDescriptor::SetTransforms(CvAffinePose* poses, CvMat** transforms)
-    {
-        if(m_affine_poses)
-        {
-            delete []m_affine_poses;
-        }
-
-        m_affine_poses = poses;
-        m_transforms = transforms;
-    }
-
-    void OneWayDescriptor::Initialize(int pose_count, IplImage* frontal, const char* feature_name, int norm)
-    {
-        m_feature_name = String(feature_name);
-        CvRect roi = cvGetImageROI(frontal);
-        m_center = rect_center(roi);
-
-        Allocate(pose_count, cvSize(roi.width, roi.height), frontal->nChannels);
-
-        GenerateSamples(pose_count, frontal, norm);
-    }
-
-    void OneWayDescriptor::InitializeFast(int pose_count, IplImage* frontal, const char* feature_name,
-                                          CvMat* pca_hr_avg, CvMat* pca_hr_eigenvectors, OneWayDescriptor* pca_descriptors)
-    {
-        if(pca_hr_avg == 0)
-        {
-            Initialize(pose_count, frontal, feature_name, 1);
-            return;
-        }
-        m_feature_name = String(feature_name);
-        CvRect roi = cvGetImageROI(frontal);
-        m_center = rect_center(roi);
-
-        Allocate(pose_count, cvSize(roi.width, roi.height), frontal->nChannels);
-
-        GenerateSamplesFast(frontal, pca_hr_avg, pca_hr_eigenvectors, pca_descriptors);
-    }
-
-    void OneWayDescriptor::InitializePCACoeffs(CvMat* avg, CvMat* eigenvectors)
-    {
-        for(int i = 0; i < m_pose_count; i++)
-        {
-            ProjectPCASample(m_samples[i], avg, eigenvectors, m_pca_coeffs[i]);
-        }
-    }
-
-    void OneWayDescriptor::ProjectPCASample(IplImage* patch, CvMat* avg, CvMat* eigenvectors, CvMat* pca_coeffs) const
-    {
-        CvMat* patch_mat = ConvertImageToMatrix(patch);
-        //    CvMat eigenvectorsr;
-        //    cvGetSubRect(eigenvectors, &eigenvectorsr, cvRect(0, 0, eigenvectors->cols, pca_coeffs->cols));
-        CvMat* temp = cvCreateMat(1, eigenvectors->cols, CV_32FC1);
-        cvProjectPCA(patch_mat, avg, eigenvectors, temp);
-        CvMat temp1;
-        cvGetSubRect(temp, &temp1, cvRect(0, 0, pca_coeffs->cols, 1));
-        cvCopy(&temp1, pca_coeffs);
-
-        cvReleaseMat(&temp);
-        cvReleaseMat(&patch_mat);
-    }
-
-    void OneWayDescriptor::EstimatePosePCA(CvArr* patch, int& pose_idx, float& distance, CvMat* avg, CvMat* eigenvectors) const
-    {
-        if(avg == 0)
-        {
-            // do not use pca
-            if (!CV_IS_MAT(patch))
-            {
-                EstimatePose((IplImage*)patch, pose_idx, distance);
-            }
-            else
-            {
-
-            }
-            return;
-        }
-        CvRect roi;
-        if (!CV_IS_MAT(patch))
-        {
-            roi = cvGetImageROI((IplImage*)patch);
-            if(roi.width != GetPatchSize().width || roi.height != GetPatchSize().height)
-            {
-                cvResize(patch, m_input_patch);
-                patch = m_input_patch;
-                roi = cvGetImageROI((IplImage*)patch);
-            }
-        }
-
-        CvMat* pca_coeffs = cvCreateMat(1, m_pca_dim_low, CV_32FC1);
-
-        if (CV_IS_MAT(patch))
-        {
-            cvCopy((CvMat*)patch, pca_coeffs);
-        }
-        else
-        {
-            IplImage* patch_32f = cvCreateImage(cvSize(roi.width, roi.height), IPL_DEPTH_32F, 1);
-            double sum = cvSum(patch).val[0];
-            cvConvertScale(patch, patch_32f, 1.0f/sum);
-            ProjectPCASample(patch_32f, avg, eigenvectors, pca_coeffs);
-            cvReleaseImage(&patch_32f);
-        }
-
-
-        distance = 1e10;
-        pose_idx = -1;
-
-        for(int i = 0; i < m_pose_count; i++)
-        {
-            double dist = cvNorm(m_pca_coeffs[i], pca_coeffs);
-            //      float dist = 0;
-            //      float data1, data2;
-            //      //CvMat* pose_pca_coeffs = m_pca_coeffs[i];
-            //      for (int x=0; x < pca_coeffs->width; x++)
-            //          for (int y =0 ; y < pca_coeffs->height; y++)
-            //          {
-            //              data1 = ((float*)(pca_coeffs->data.ptr + pca_coeffs->step*x))[y];
-            //              data2 = ((float*)(m_pca_coeffs[i]->data.ptr + m_pca_coeffs[i]->step*x))[y];
-            //              dist+=(data1-data2)*(data1-data2);
-            //          }
-            ////#if 1
-            //      for (int j = 0; j < m_pca_dim_low; j++)
-            //      {
-            //          dist += (pose_pca_coeffs->data.fl[j]- pca_coeffs->data.fl[j])*(pose_pca_coeffs->data.fl[j]- pca_coeffs->data.fl[j]);
-            //      }
-            //#else
-            //      for (int j = 0; j <= m_pca_dim_low - 4; j += 4)
-            //      {
-            //          dist += (pose_pca_coeffs->data.fl[j]- pca_coeffs->data.fl[j])*
-            //              (pose_pca_coeffs->data.fl[j]- pca_coeffs->data.fl[j]);
-            //          dist += (pose_pca_coeffs->data.fl[j+1]- pca_coeffs->data.fl[j+1])*
-            //              (pose_pca_coeffs->data.fl[j+1]- pca_coeffs->data.fl[j+1]);
-            //          dist += (pose_pca_coeffs->data.fl[j+2]- pca_coeffs->data.fl[j+2])*
-            //              (pose_pca_coeffs->data.fl[j+2]- pca_coeffs->data.fl[j+2]);
-            //          dist += (pose_pca_coeffs->data.fl[j+3]- pca_coeffs->data.fl[j+3])*
-            //              (pose_pca_coeffs->data.fl[j+3]- pca_coeffs->data.fl[j+3]);
-            //      }
-            //#endif
-            if(dist < distance)
-            {
-                distance = (float)dist;
-                pose_idx = i;
-            }
-        }
-
-        cvReleaseMat(&pca_coeffs);
-    }
-
-    void OneWayDescriptor::EstimatePose(IplImage* patch, int& pose_idx, float& distance) const
-    {
-        distance = 1e10;
-        pose_idx = -1;
-
-        CvRect roi = cvGetImageROI(patch);
-        IplImage* patch_32f = cvCreateImage(cvSize(roi.width, roi.height), IPL_DEPTH_32F, patch->nChannels);
-        double sum = cvSum(patch).val[0];
-        cvConvertScale(patch, patch_32f, 1/sum);
-
-        for(int i = 0; i < m_pose_count; i++)
-        {
-            if(m_samples[i]->width != patch_32f->width || m_samples[i]->height != patch_32f->height)
-            {
-                continue;
-            }
-            double dist = cvNorm(m_samples[i], patch_32f);
-            //float dist = 0.0f;
-            //float i1,i2;
-
-            //for (int y = 0; y<patch_32f->height; y++)
-            //  for (int x = 0; x< patch_32f->width; x++)
-            //  {
-            //      i1 = ((float*)(m_samples[i]->imageData + m_samples[i]->widthStep*y))[x];
-            //      i2 = ((float*)(patch_32f->imageData + patch_32f->widthStep*y))[x];
-            //      dist+= (i1-i2)*(i1-i2);
-            //  }
-
-            if(dist < distance)
-            {
-                distance = (float)dist;
-                pose_idx = i;
-            }
-
-#if 0
-            IplImage* img1 = cvCreateImage(cvSize(roi.width, roi.height), IPL_DEPTH_8U, 1);
-            IplImage* img2 = cvCreateImage(cvSize(roi.width, roi.height), IPL_DEPTH_8U, 1);
-            double maxval;
-            cvMinMaxLoc(m_samples[i], 0, &maxval);
-            cvConvertScale(m_samples[i], img1, 255.0/maxval);
-            cvMinMaxLoc(patch_32f, 0, &maxval);
-            cvConvertScale(patch_32f, img2, 255.0/maxval);
-
-            cvNamedWindow("1", 1);
-            cvShowImage("1", img1);
-            cvNamedWindow("2", 1);
-            cvShowImage("2", img2);
-            printf("Distance = %f\n", dist);
-            cvWaitKey(0);
-#endif
-        }
-
-        cvReleaseImage(&patch_32f);
-    }
-
-    void OneWayDescriptor::Save(const char* path)
-    {
-        for(int i = 0; i < m_pose_count; i++)
-        {
-            char buf[1024];
-            sprintf(buf, "%s/patch_%04d.png", path, i);
-            IplImage* patch = cvCreateImage(cvSize(m_samples[i]->width, m_samples[i]->height), IPL_DEPTH_8U, m_samples[i]->nChannels);
-
-            double maxval;
-            cvMinMaxLoc(m_samples[i], 0, &maxval);
-            cvConvertScale(m_samples[i], patch, 255/maxval);
-
-#ifdef HAVE_OPENCV_HIGHGUI
-            cv::imwrite(buf, cv::cvarrToMat(patch));
-#else
-            CV_Error(CV_StsNotImplemented, "OpenCV has been compiled without image I/O support");
-#endif
-
-            cvReleaseImage(&patch);
-        }
-    }
-
-    void OneWayDescriptor::Write(CvFileStorage* fs, const char* name)
-    {
-        CvMat* mat = cvCreateMat(m_pose_count, m_samples[0]->width*m_samples[0]->height, CV_32FC1);
-
-        // prepare data to write as a single matrix
-        for(int i = 0; i < m_pose_count; i++)
-        {
-            for(int y = 0; y < m_samples[i]->height; y++)
-            {
-                for(int x = 0; x < m_samples[i]->width; x++)
-                {
-                    float val = *((float*)(m_samples[i]->imageData + m_samples[i]->widthStep*y) + x);
-                    cvmSet(mat, i, y*m_samples[i]->width + x, val);
-                }
-            }
-        }
-
-        cvWrite(fs, name, mat);
-
-        cvReleaseMat(&mat);
-    }
-
-    int OneWayDescriptor::ReadByName(const FileNode &parent, const char* name)
-    {
-        CvMat* mat = reinterpret_cast<CvMat*> (parent[name].readObj ());
-        if(!mat)
-        {
-            return 0;
-        }
-
-
-        for(int i = 0; i < m_pose_count; i++)
-        {
-            for(int y = 0; y < m_samples[i]->height; y++)
-            {
-                for(int x = 0; x < m_samples[i]->width; x++)
-                {
-                    float val = (float)cvmGet(mat, i, y*m_samples[i]->width + x);
-                    *((float*)(m_samples[i]->imageData + y*m_samples[i]->widthStep) + x) = val;
-                }
-            }
-        }
-
-        cvReleaseMat(&mat);
-        return 1;
-    }
-
-    int OneWayDescriptor::ReadByName(CvFileStorage* fs, CvFileNode* parent, const char* name)
-    {
-        return ReadByName (FileNode (fs, parent), name);
-    }
-
-    IplImage* OneWayDescriptor::GetPatch(int index)
-    {
-        return m_samples[index];
-    }
-
-    CvAffinePose OneWayDescriptor::GetPose(int index) const
-    {
-        return m_affine_poses[index];
-    }
-
-    void FindOneWayDescriptor(int desc_count, const OneWayDescriptor* descriptors, IplImage* patch, int& desc_idx, int& pose_idx, float& distance,
-                              CvMat* avg, CvMat* eigenvectors)
-    {
-        desc_idx = -1;
-        pose_idx = -1;
-        distance = 1e10;
-        //--------
-        //PCA_coeffs precalculating
-        int m_pca_dim_low = descriptors[0].GetPCADimLow();
-        CvMat* pca_coeffs = cvCreateMat(1, m_pca_dim_low, CV_32FC1);
-        int patch_width = descriptors[0].GetPatchSize().width;
-        int patch_height = descriptors[0].GetPatchSize().height;
-        if (avg)
-        {
-            CvRect _roi = cvGetImageROI((IplImage*)patch);
-            IplImage* test_img = cvCreateImage(cvSize(patch_width,patch_height), IPL_DEPTH_8U, 1);
-            if(_roi.width != patch_width|| _roi.height != patch_height)
-            {
-
-                cvResize(patch, test_img);
-                _roi = cvGetImageROI(test_img);
-            }
-            else
-            {
-                cvCopy(patch,test_img);
-            }
-            IplImage* patch_32f = cvCreateImage(cvSize(_roi.width, _roi.height), IPL_DEPTH_32F, 1);
-            double sum = cvSum(test_img).val[0];
-            cvConvertScale(test_img, patch_32f, 1.0f/sum);
-
-            //ProjectPCASample(patch_32f, avg, eigenvectors, pca_coeffs);
-            //Projecting PCA
-            CvMat* patch_mat = ConvertImageToMatrix(patch_32f);
-            CvMat* temp = cvCreateMat(1, eigenvectors->cols, CV_32FC1);
-            cvProjectPCA(patch_mat, avg, eigenvectors, temp);
-            CvMat temp1;
-            cvGetSubRect(temp, &temp1, cvRect(0, 0, pca_coeffs->cols, 1));
-            cvCopy(&temp1, pca_coeffs);
-            cvReleaseMat(&temp);
-            cvReleaseMat(&patch_mat);
-            //End of projecting
-
-            cvReleaseImage(&patch_32f);
-            cvReleaseImage(&test_img);
-        }
-
-        //--------
-
-
-
-        for(int i = 0; i < desc_count; i++)
-        {
-            int _pose_idx = -1;
-            float _distance = 0;
-
-#if 0
-            descriptors[i].EstimatePose(patch, _pose_idx, _distance);
-#else
-            if (!avg)
-            {
-                descriptors[i].EstimatePosePCA(patch, _pose_idx, _distance, avg, eigenvectors);
-            }
-            else
-            {
-                descriptors[i].EstimatePosePCA(pca_coeffs, _pose_idx, _distance, avg, eigenvectors);
-            }
-#endif
-
-            if(_distance < distance)
-            {
-                desc_idx = i;
-                pose_idx = _pose_idx;
-                distance = _distance;
-            }
-        }
-        cvReleaseMat(&pca_coeffs);
-    }
-
-#if defined(_KDTREE)
-
-    void FindOneWayDescriptor(cv::flann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low, int m_pose_count, IplImage* patch, int& desc_idx, int& pose_idx, float& distance,
-                              CvMat* avg, CvMat* eigenvectors)
-    {
-        desc_idx = -1;
-        pose_idx = -1;
-        distance = 1e10;
-        //--------
-        //PCA_coeffs precalculating
-        CvMat* pca_coeffs = cvCreateMat(1, m_pca_dim_low, CV_32FC1);
-        int patch_width = patch_size.width;
-        int patch_height = patch_size.height;
-        //if (avg)
-        //{
-        CvRect _roi = cvGetImageROI((IplImage*)patch);
-        IplImage* test_img = cvCreateImage(cvSize(patch_width,patch_height), IPL_DEPTH_8U, 1);
-        if(_roi.width != patch_width|| _roi.height != patch_height)
-        {
-
-            cvResize(patch, test_img);
-            _roi = cvGetImageROI(test_img);
-        }
-        else
-        {
-            cvCopy(patch,test_img);
-        }
-        IplImage* patch_32f = cvCreateImage(cvSize(_roi.width, _roi.height), IPL_DEPTH_32F, 1);
-        float sum = cvSum(test_img).val[0];
-        cvConvertScale(test_img, patch_32f, 1.0f/sum);
-
-        //ProjectPCASample(patch_32f, avg, eigenvectors, pca_coeffs);
-        //Projecting PCA
-        CvMat* patch_mat = ConvertImageToMatrix(patch_32f);
-        CvMat* temp = cvCreateMat(1, eigenvectors->cols, CV_32FC1);
-        cvProjectPCA(patch_mat, avg, eigenvectors, temp);
-        CvMat temp1;
-        cvGetSubRect(temp, &temp1, cvRect(0, 0, pca_coeffs->cols, 1));
-        cvCopy(&temp1, pca_coeffs);
-        cvReleaseMat(&temp);
-        cvReleaseMat(&patch_mat);
-        //End of projecting
-
-        cvReleaseImage(&patch_32f);
-        cvReleaseImage(&test_img);
-        //  }
-
-        //--------
-
-        //float* target = new float[m_pca_dim_low];
-        //::cvflann::KNNResultSet res(1,pca_coeffs->data.fl,m_pca_dim_low);
-        //::cvflann::SearchParams params;
-        //params.checks = -1;
-
-        //int maxDepth = 1000000;
-        //int neighbors_count = 1;
-        //int* neighborsIdx = new int[neighbors_count];
-        //float* distances = new float[neighbors_count];
-        //if (m_pca_descriptors_tree->findNearest(pca_coeffs->data.fl,neighbors_count,maxDepth,neighborsIdx,0,distances) > 0)
-        //{
-        //  desc_idx = neighborsIdx[0] / m_pose_count;
-        //  pose_idx = neighborsIdx[0] % m_pose_count;
-        //  distance = distances[0];
-        //}
-        //delete[] neighborsIdx;
-        //delete[] distances;
-
-        cv::Mat m_object(1, m_pca_dim_low, CV_32F);
-        cv::Mat m_indices(1, 1, CV_32S);
-        cv::Mat m_dists(1, 1, CV_32F);
-
-        float* object_ptr = m_object.ptr<float>(0);
-        for (int i=0;i<m_pca_dim_low;i++)
-        {
-            object_ptr[i] = pca_coeffs->data.fl[i];
-        }
-
-        m_pca_descriptors_tree->knnSearch(m_object, m_indices, m_dists, 1, cv::flann::SearchParams(-1) );
-
-        desc_idx = ((int*)(m_indices.ptr<int>(0)))[0] / m_pose_count;
-        pose_idx = ((int*)(m_indices.ptr<int>(0)))[0] % m_pose_count;
-        distance = ((float*)(m_dists.ptr<float>(0)))[0];
-
-        //  delete[] target;
-
-
-        //    for(int i = 0; i < desc_count; i++)
-        //    {
-        //        int _pose_idx = -1;
-        //        float _distance = 0;
-        //
-        //#if 0
-        //        descriptors[i].EstimatePose(patch, _pose_idx, _distance);
-        //#else
-        //      if (!avg)
-        //      {
-        //          descriptors[i].EstimatePosePCA(patch, _pose_idx, _distance, avg, eigenvectors);
-        //      }
-        //      else
-        //      {
-        //          descriptors[i].EstimatePosePCA(pca_coeffs, _pose_idx, _distance, avg, eigenvectors);
-        //      }
-        //#endif
-        //
-        //        if(_distance < distance)
-        //        {
-        //            desc_idx = i;
-        //            pose_idx = _pose_idx;
-        //            distance = _distance;
-        //        }
-        //    }
-        cvReleaseMat(&pca_coeffs);
-    }
-#endif
-    //**
-    void FindOneWayDescriptor(int desc_count, const OneWayDescriptor* descriptors, IplImage* patch, int n,
-                              std::vector<int>& desc_idxs, std::vector<int>&  pose_idxs, std::vector<float>& distances,
-                              CvMat* avg, CvMat* eigenvectors)
-    {
-        for (int i=0;i<n;i++)
-        {
-            desc_idxs[i] = -1;
-            pose_idxs[i] = -1;
-            distances[i] = 1e10;
-        }
-        //--------
-        //PCA_coeffs precalculating
-        int m_pca_dim_low = descriptors[0].GetPCADimLow();
-        CvMat* pca_coeffs = cvCreateMat(1, m_pca_dim_low, CV_32FC1);
-        int patch_width = descriptors[0].GetPatchSize().width;
-        int patch_height = descriptors[0].GetPatchSize().height;
-        if (avg)
-        {
-            CvRect _roi = cvGetImageROI((IplImage*)patch);
-            IplImage* test_img = cvCreateImage(cvSize(patch_width,patch_height), IPL_DEPTH_8U, 1);
-            if(_roi.width != patch_width|| _roi.height != patch_height)
-            {
-
-                cvResize(patch, test_img);
-                _roi = cvGetImageROI(test_img);
-            }
-            else
-            {
-                cvCopy(patch,test_img);
-            }
-            IplImage* patch_32f = cvCreateImage(cvSize(_roi.width, _roi.height), IPL_DEPTH_32F, 1);
-            double sum = cvSum(test_img).val[0];
-            cvConvertScale(test_img, patch_32f, 1.0f/sum);
-
-            //ProjectPCASample(patch_32f, avg, eigenvectors, pca_coeffs);
-            //Projecting PCA
-            CvMat* patch_mat = ConvertImageToMatrix(patch_32f);
-            CvMat* temp = cvCreateMat(1, eigenvectors->cols, CV_32FC1);
-            cvProjectPCA(patch_mat, avg, eigenvectors, temp);
-            CvMat temp1;
-            cvGetSubRect(temp, &temp1, cvRect(0, 0, pca_coeffs->cols, 1));
-            cvCopy(&temp1, pca_coeffs);
-            cvReleaseMat(&temp);
-            cvReleaseMat(&patch_mat);
-            //End of projecting
-
-            cvReleaseImage(&patch_32f);
-            cvReleaseImage(&test_img);
-        }
-        //--------
-
-
-
-        for(int i = 0; i < desc_count; i++)
-        {
-            int _pose_idx = -1;
-            float _distance = 0;
-
-#if 0
-            descriptors[i].EstimatePose(patch, _pose_idx, _distance);
-#else
-            if (!avg)
-            {
-                descriptors[i].EstimatePosePCA(patch, _pose_idx, _distance, avg, eigenvectors);
-            }
-            else
-            {
-                descriptors[i].EstimatePosePCA(pca_coeffs, _pose_idx, _distance, avg, eigenvectors);
-            }
-#endif
-
-            for (int j=0;j<n;j++)
-            {
-                if(_distance < distances[j])
-                {
-                    for (int k=(n-1);k > j;k--)
-                    {
-                        desc_idxs[k] = desc_idxs[k-1];
-                        pose_idxs[k] = pose_idxs[k-1];
-                        distances[k] = distances[k-1];
-                    }
-                    desc_idxs[j] = i;
-                    pose_idxs[j] = _pose_idx;
-                    distances[j] = _distance;
-                    break;
-                }
-            }
-        }
-        cvReleaseMat(&pca_coeffs);
-    }
-
-    void FindOneWayDescriptorEx(int desc_count, const OneWayDescriptor* descriptors, IplImage* patch,
-                                float scale_min, float scale_max, float scale_step,
-                                int& desc_idx, int& pose_idx, float& distance, float& scale,
-                                CvMat* avg, CvMat* eigenvectors)
-    {
-        CvSize patch_size = descriptors[0].GetPatchSize();
-        IplImage* input_patch;
-        CvRect roi;
-
-        input_patch= cvCreateImage(patch_size, IPL_DEPTH_8U, 1);
-        roi = cvGetImageROI((IplImage*)patch);
-
-        int _desc_idx, _pose_idx;
-        float _distance;
-        distance = 1e10;
-        for(float cur_scale = scale_min; cur_scale < scale_max; cur_scale *= scale_step)
-        {
-            //        printf("Scale = %f\n", cur_scale);
-
-            CvRect roi_scaled = resize_rect(roi, cur_scale);
-            cvSetImageROI(patch, roi_scaled);
-            cvResize(patch, input_patch);
-
-
-#if 0
-            if(roi.x > 244 && roi.y < 200)
-            {
-                cvNamedWindow("1", 1);
-                cvShowImage("1", input_patch);
-                cvWaitKey(0);
-            }
-#endif
-
-            FindOneWayDescriptor(desc_count, descriptors, input_patch, _desc_idx, _pose_idx, _distance, avg, eigenvectors);
-            if(_distance < distance)
-            {
-                distance = _distance;
-                desc_idx = _desc_idx;
-                pose_idx = _pose_idx;
-                scale = cur_scale;
-            }
-        }
-
-
-        cvSetImageROI((IplImage*)patch, roi);
-        cvReleaseImage(&input_patch);
-
-    }
-
-    void FindOneWayDescriptorEx(int desc_count, const OneWayDescriptor* descriptors, IplImage* patch,
-                                float scale_min, float scale_max, float scale_step,
-                                int n, std::vector<int>& desc_idxs, std::vector<int>& pose_idxs,
-                                std::vector<float>& distances, std::vector<float>& scales,
-                                CvMat* avg, CvMat* eigenvectors)
-    {
-        CvSize patch_size = descriptors[0].GetPatchSize();
-        IplImage* input_patch;
-        CvRect roi;
-
-        input_patch= cvCreateImage(patch_size, IPL_DEPTH_8U, 1);
-        roi = cvGetImageROI((IplImage*)patch);
-
-        //  float min_distance = 1e10;
-        std::vector<int> _desc_idxs;
-        _desc_idxs.resize(n);
-        std::vector<int> _pose_idxs;
-        _pose_idxs.resize(n);
-        std::vector<float> _distances;
-        _distances.resize(n);
-
-
-        for (int i=0;i<n;i++)
-        {
-            distances[i] = 1e10;
-        }
-
-        for(float cur_scale = scale_min; cur_scale < scale_max; cur_scale *= scale_step)
-        {
-
-            CvRect roi_scaled = resize_rect(roi, cur_scale);
-            cvSetImageROI(patch, roi_scaled);
-            cvResize(patch, input_patch);
-
-
-
-            FindOneWayDescriptor(desc_count, descriptors, input_patch, n,_desc_idxs, _pose_idxs, _distances, avg, eigenvectors);
-            for (int i=0;i<n;i++)
-            {
-                if(_distances[i] < distances[i])
-                {
-                    distances[i] = _distances[i];
-                    desc_idxs[i] = _desc_idxs[i];
-                    pose_idxs[i] = _pose_idxs[i];
-                    scales[i] = cur_scale;
-                }
-            }
-        }
-
-
-
-        cvSetImageROI((IplImage*)patch, roi);
-        cvReleaseImage(&input_patch);
-    }
-
-#if defined(_KDTREE)
-    void FindOneWayDescriptorEx(cv::flann::Index* m_pca_descriptors_tree, CvSize patch_size, int m_pca_dim_low,
-                                int m_pose_count, IplImage* patch,
-                                float scale_min, float scale_max, float scale_step,
-                                int& desc_idx, int& pose_idx, float& distance, float& scale,
-                                CvMat* avg, CvMat* eigenvectors)
-    {
-        IplImage* input_patch;
-        CvRect roi;
-
-        input_patch= cvCreateImage(patch_size, IPL_DEPTH_8U, 1);
-        roi = cvGetImageROI((IplImage*)patch);
-
-        int _desc_idx, _pose_idx;
-        float _distance;
-        distance = 1e10;
-        for(float cur_scale = scale_min; cur_scale < scale_max; cur_scale *= scale_step)
-        {
-            //        printf("Scale = %f\n", cur_scale);
-
-            CvRect roi_scaled = resize_rect(roi, cur_scale);
-            cvSetImageROI(patch, roi_scaled);
-            cvResize(patch, input_patch);
-
-            FindOneWayDescriptor(m_pca_descriptors_tree, patch_size, m_pca_dim_low, m_pose_count, input_patch, _desc_idx, _pose_idx, _distance, avg, eigenvectors);
-            if(_distance < distance)
-            {
-                distance = _distance;
-                desc_idx = _desc_idx;
-                pose_idx = _pose_idx;
-                scale = cur_scale;
-            }
-        }
-
-
-        cvSetImageROI((IplImage*)patch, roi);
-        cvReleaseImage(&input_patch);
-
-    }
-#endif
-
-    const char* OneWayDescriptor::GetFeatureName() const
-    {
-        return m_feature_name.c_str();
-    }
-
-    CvPoint OneWayDescriptor::GetCenter() const
-    {
-        return m_center;
-    }
-
-    int OneWayDescriptor::GetPCADimLow() const
-    {
-        return m_pca_dim_low;
-    }
-
-    int OneWayDescriptor::GetPCADimHigh() const
-    {
-        return m_pca_dim_high;
-    }
-
-    CvMat* ConvertImageToMatrix(IplImage* patch)
-    {
-        CvRect roi = cvGetImageROI(patch);
-        CvMat* mat = cvCreateMat(1, roi.width*roi.height, CV_32FC1);
-
-        if(patch->depth == 32)
-        {
-            for(int y = 0; y < roi.height; y++)
-            {
-                for(int x = 0; x < roi.width; x++)
-                {
-                    mat->data.fl[y*roi.width + x] = *((float*)(patch->imageData + (y + roi.y)*patch->widthStep) + x + roi.x);
-                }
-            }
-        }
-        else if(patch->depth == 8)
-        {
-            for(int y = 0; y < roi.height; y++)
-            {
-                for(int x = 0; x < roi.width; x++)
-                {
-                    mat->data.fl[y*roi.width + x] = (float)(unsigned char)patch->imageData[(y + roi.y)*patch->widthStep + x + roi.x];
-                }
-            }
-        }
-        else
-        {
-            printf("Image depth %d is not supported\n", patch->depth);
-            return 0;
-        }
-
-        return mat;
-    }
-
-    OneWayDescriptorBase::OneWayDescriptorBase(CvSize patch_size, int pose_count, const char* train_path,
-                                               const char* pca_config, const char* pca_hr_config,
-                                               const char* pca_desc_config, int pyr_levels,
-                                               int pca_dim_high, int pca_dim_low)
-    : m_pca_dim_high(pca_dim_high), m_pca_dim_low(pca_dim_low), scale_min (0.7f), scale_max(1.5f), scale_step (1.2f)
-    {
-#if defined(_KDTREE)
-        m_pca_descriptors_matrix = 0;
-        m_pca_descriptors_tree = 0;
-#endif
-        //  m_pca_descriptors_matrix = 0;
-        m_patch_size = patch_size;
-        m_pose_count = pose_count;
-        m_pyr_levels = pyr_levels;
-        m_poses = 0;
-        m_transforms = 0;
-
-        m_pca_avg = 0;
-        m_pca_eigenvectors = 0;
-        m_pca_hr_avg = 0;
-        m_pca_hr_eigenvectors = 0;
-        m_pca_descriptors = 0;
-
-        m_descriptors = 0;
-
-        if(train_path == 0 || strlen(train_path) == 0)
-        {
-            // skip pca loading
-            return;
-        }
-        char pca_config_filename[1024];
-        sprintf(pca_config_filename, "%s/%s", train_path, pca_config);
-        readPCAFeatures(pca_config_filename, &m_pca_avg, &m_pca_eigenvectors);
-        if(pca_hr_config && strlen(pca_hr_config) > 0)
-        {
-            char pca_hr_config_filename[1024];
-            sprintf(pca_hr_config_filename, "%s/%s", train_path, pca_hr_config);
-            readPCAFeatures(pca_hr_config_filename, &m_pca_hr_avg, &m_pca_hr_eigenvectors);
-        }
-
-        m_pca_descriptors = new OneWayDescriptor[m_pca_dim_high + 1];
-
-#if !defined(_GH_REGIONS)
-        if(pca_desc_config && strlen(pca_desc_config) > 0)
-            //    if(0)
-        {
-            //printf("Loading the descriptors...");
-            char pca_desc_config_filename[1024];
-            sprintf(pca_desc_config_filename, "%s/%s", train_path, pca_desc_config);
-            LoadPCADescriptors(pca_desc_config_filename);
-            //printf("done.\n");
-        }
-        else
-        {
-            printf("Initializing the descriptors...\n");
-            InitializePoseTransforms();
-            CreatePCADescriptors();
-            SavePCADescriptors("pca_descriptors.yml");
-        }
-#endif //_GH_REGIONS
-        //    SavePCADescriptors("./pca_descriptors.yml");
-
-    }
-
-    OneWayDescriptorBase::OneWayDescriptorBase(CvSize patch_size, int pose_count, const String &pca_filename,
-                                               const String &train_path, const String &images_list, float _scale_min, float _scale_max,
-                                               float _scale_step, int pyr_levels,
-                                               int pca_dim_high, int pca_dim_low)
-    : m_pca_dim_high(pca_dim_high), m_pca_dim_low(pca_dim_low), scale_min(_scale_min), scale_max(_scale_max), scale_step(_scale_step)
-    {
-#if defined(_KDTREE)
-        m_pca_descriptors_matrix = 0;
-        m_pca_descriptors_tree = 0;
-#endif
-        m_patch_size = patch_size;
-        m_pose_count = pose_count;
-        m_pyr_levels = pyr_levels;
-        m_poses = 0;
-        m_transforms = 0;
-
-        m_pca_avg = 0;
-        m_pca_eigenvectors = 0;
-        m_pca_hr_avg = 0;
-        m_pca_hr_eigenvectors = 0;
-        m_pca_descriptors = 0;
-
-        m_descriptors = 0;
-
-
-        if (pca_filename.length() == 0)
-        {
-            return;
-        }
-
-        CvFileStorage* fs = cvOpenFileStorage(pca_filename.c_str(), NULL, CV_STORAGE_READ);
-        if (fs != 0)
-        {
-            cvReleaseFileStorage(&fs);
-
-            readPCAFeatures(pca_filename.c_str(), &m_pca_avg, &m_pca_eigenvectors, "_lr");
-            readPCAFeatures(pca_filename.c_str(), &m_pca_hr_avg, &m_pca_hr_eigenvectors, "_hr");
-            m_pca_descriptors = new OneWayDescriptor[m_pca_dim_high + 1];
-#if !defined(_GH_REGIONS)
-            LoadPCADescriptors(pca_filename.c_str());
-#endif //_GH_REGIONS
-        }
-        else
-        {
-            GeneratePCA(train_path.c_str(), images_list.c_str());
-            m_pca_descriptors = new OneWayDescriptor[m_pca_dim_high + 1];
-            char pca_default_filename[1024];
-            sprintf(pca_default_filename, "%s/%s", train_path.c_str(), GetPCAFilename().c_str());
-            LoadPCADescriptors(pca_default_filename);
-        }
-    }
-
-    void OneWayDescriptorBase::Read (const FileNode &fn)
-    {
-        clear ();
-
-        m_pose_count = fn["poseCount"];
-        int patch_width = fn["patchWidth"];
-        int patch_height = fn["patchHeight"];
-        m_patch_size = cvSize (patch_width, patch_height);
-        m_pyr_levels = fn["pyrLevels"];
-        m_pca_dim_high = fn["pcaDimHigh"];
-        m_pca_dim_low = fn["pcaDimLow"];
-        scale_min = fn["minScale"];
-        scale_max = fn["maxScale"];
-        scale_step = fn["stepScale"];
-
-    LoadPCAall (fn);
-    }
-
-    void OneWayDescriptorBase::LoadPCAall (const FileNode &fn)
-    {
-        readPCAFeatures(fn, &m_pca_avg, &m_pca_eigenvectors, "_lr");
-        readPCAFeatures(fn, &m_pca_hr_avg, &m_pca_hr_eigenvectors, "_hr");
-        m_pca_descriptors = new OneWayDescriptor[m_pca_dim_high + 1];
-#if !defined(_GH_REGIONS)
-        LoadPCADescriptors(fn);
-#endif //_GH_REGIONS
-    }
-
-    OneWayDescriptorBase::~OneWayDescriptorBase()
-    {
-        cvReleaseMat(&m_pca_avg);
-        cvReleaseMat(&m_pca_eigenvectors);
-
-        if(m_pca_hr_eigenvectors)
-        {
-            delete[] m_pca_descriptors;
-            cvReleaseMat(&m_pca_hr_avg);
-            cvReleaseMat(&m_pca_hr_eigenvectors);
-        }
-
-
-        if(m_descriptors)
-            delete []m_descriptors;
-
-        if(m_poses)
-            delete []m_poses;
-
-        if (m_transforms)
-        {
-            for(int i = 0; i < m_pose_count; i++)
-            {
-                cvReleaseMat(&m_transforms[i]);
-            }
-            delete []m_transforms;
-        }
-#if defined(_KDTREE)
-        if (m_pca_descriptors_matrix)
-        {
-            cvReleaseMat(&m_pca_descriptors_matrix);
-        }
-        if (m_pca_descriptors_tree)
-        {
-            delete m_pca_descriptors_tree;
-        }
-#endif
-    }
-
-    void OneWayDescriptorBase::clear(){
-        if (m_descriptors)
-        {
-            delete []m_descriptors;
-            m_descriptors = 0;
-        }
-
-#if defined(_KDTREE)
-        if (m_pca_descriptors_matrix)
-        {
-            cvReleaseMat(&m_pca_descriptors_matrix);
-            m_pca_descriptors_matrix = 0;
-        }
-        if (m_pca_descriptors_tree)
-        {
-            delete m_pca_descriptors_tree;
-            m_pca_descriptors_tree = 0;
-        }
-#endif
-    }
-
-    void OneWayDescriptorBase::InitializePoses()
-    {
-        m_poses = new CvAffinePose[m_pose_count];
-        for(int i = 0; i < m_pose_count; i++)
-        {
-            m_poses[i] = GenRandomAffinePose();
-        }
-    }
-
-    void OneWayDescriptorBase::InitializeTransformsFromPoses()
-    {
-        m_transforms = new CvMat*[m_pose_count];
-        for(int i = 0; i < m_pose_count; i++)
-        {
-            m_transforms[i] = cvCreateMat(2, 3, CV_32FC1);
-            GenerateAffineTransformFromPose(cvSize(m_patch_size.width*2, m_patch_size.height*2), m_poses[i], m_transforms[i]);
-        }
-    }
-
-    void OneWayDescriptorBase::InitializePoseTransforms()
-    {
-        InitializePoses();
-        InitializeTransformsFromPoses();
-    }
-
-    void OneWayDescriptorBase::InitializeDescriptor(int desc_idx, IplImage* train_image, const KeyPoint& keypoint, const char* feature_label)
-    {
-
-        // TBD add support for octave != 0
-        CvPoint center = keypoint.pt;
-
-        CvRect roi = cvRect(center.x - m_patch_size.width/2, center.y - m_patch_size.height/2, m_patch_size.width, m_patch_size.height);
-        cvResetImageROI(train_image);
-        roi = fit_rect_fixedsize(roi, train_image);
-        cvSetImageROI(train_image, roi);
-        if(roi.width != m_patch_size.width || roi.height != m_patch_size.height)
-        {
-            return;
-        }
-
-        InitializeDescriptor(desc_idx, train_image, feature_label);
-        cvResetImageROI(train_image);
-    }
-
-    void OneWayDescriptorBase::InitializeDescriptor(int desc_idx, IplImage* train_image, const char* feature_label)
-    {
-        m_descriptors[desc_idx].SetPCADimHigh(m_pca_dim_high);
-        m_descriptors[desc_idx].SetPCADimLow(m_pca_dim_low);
-        m_descriptors[desc_idx].SetTransforms(m_poses, m_transforms);
-
-        if(!m_pca_hr_eigenvectors)
-        {
-            m_descriptors[desc_idx].Initialize(m_pose_count, train_image, feature_label);
-        }
-        else
-        {
-            m_descriptors[desc_idx].InitializeFast(m_pose_count, train_image, feature_label,
-                                                   m_pca_hr_avg, m_pca_hr_eigenvectors, m_pca_descriptors);
-        }
-
-        if(m_pca_avg)
-        {
-            m_descriptors[desc_idx].InitializePCACoeffs(m_pca_avg, m_pca_eigenvectors);
-        }
-    }
-
-    void OneWayDescriptorBase::FindDescriptor(IplImage* src, cv::Point2f pt, int& desc_idx, int& pose_idx, float& distance) const
-    {
-        CvRect roi = cvRect(cvRound(pt.x - m_patch_size.width/4),
-                            cvRound(pt.y - m_patch_size.height/4),
-                            m_patch_size.width/2, m_patch_size.height/2);
-        cvSetImageROI(src, roi);
-
-        FindDescriptor(src, desc_idx, pose_idx, distance);
-        cvResetImageROI(src);
-    }
-
-    void OneWayDescriptorBase::FindDescriptor(IplImage* patch, int& desc_idx, int& pose_idx, float& distance, float* _scale, float* scale_ranges) const
-    {
-#if 0
-        ::FindOneWayDescriptor(m_train_feature_count, m_descriptors, patch, desc_idx, pose_idx, distance, m_pca_avg, m_pca_eigenvectors);
-#else
-        float min = scale_min;
-        float max = scale_max;
-        float step = scale_step;
-
-        if (scale_ranges)
-        {
-            min = scale_ranges[0];
-            max = scale_ranges[1];
-        }
-
-        float scale = 1.0f;
-
-#if !defined(_KDTREE)
-        cv::FindOneWayDescriptorEx(m_train_feature_count, m_descriptors, patch,
-                                   min, max, step, desc_idx, pose_idx, distance, scale,
-                                   m_pca_avg, m_pca_eigenvectors);
-#else
-        cv::FindOneWayDescriptorEx(m_pca_descriptors_tree, m_descriptors[0].GetPatchSize(), m_descriptors[0].GetPCADimLow(), m_pose_count, patch,
-                                   min, max, step, desc_idx, pose_idx, distance, scale,
-                                   m_pca_avg, m_pca_eigenvectors);
-#endif
-
-        if (_scale)
-            *_scale = scale;
-
-#endif
-    }
-
-    void OneWayDescriptorBase::FindDescriptor(IplImage* patch, int n, std::vector<int>& desc_idxs, std::vector<int>& pose_idxs,
-                                              std::vector<float>& distances, std::vector<float>& _scales, float* scale_ranges) const
-    {
-        float min = scale_min;
-        float max = scale_max;
-        float step = scale_step;
-
-        if (scale_ranges)
-        {
-            min = scale_ranges[0];
-            max = scale_ranges[1];
-        }
-
-        distances.resize(n);
-        _scales.resize(n);
-        desc_idxs.resize(n);
-        pose_idxs.resize(n);
-        /*float scales = 1.0f;*/
-
-        cv::FindOneWayDescriptorEx(m_train_feature_count, m_descriptors, patch,
-                                   min, max, step ,n, desc_idxs, pose_idxs, distances, _scales,
-                                   m_pca_avg, m_pca_eigenvectors);
-
-    }
-
-    void OneWayDescriptorBase::SetPCAHigh(CvMat* avg, CvMat* eigenvectors)
-    {
-        m_pca_hr_avg = cvCloneMat(avg);
-        m_pca_hr_eigenvectors = cvCloneMat(eigenvectors);
-    }
-
-    void OneWayDescriptorBase::SetPCALow(CvMat* avg, CvMat* eigenvectors)
-    {
-        m_pca_avg = cvCloneMat(avg);
-        m_pca_eigenvectors = cvCloneMat(eigenvectors);
-    }
-
-    void OneWayDescriptorBase::AllocatePCADescriptors()
-    {
-        m_pca_descriptors = new OneWayDescriptor[m_pca_dim_high + 1];
-        for(int i = 0; i < m_pca_dim_high + 1; i++)
-        {
-            m_pca_descriptors[i].SetPCADimHigh(m_pca_dim_high);
-            m_pca_descriptors[i].SetPCADimLow(m_pca_dim_low);
-        }
-    }
-
-    void OneWayDescriptorBase::CreatePCADescriptors()
-    {
-        if(m_pca_descriptors == 0)
-        {
-            AllocatePCADescriptors();
-        }
-        IplImage* frontal = cvCreateImage(m_patch_size, IPL_DEPTH_32F, 1);
-
-        eigenvector2image(m_pca_hr_avg, frontal);
-        m_pca_descriptors[0].SetTransforms(m_poses, m_transforms);
-        m_pca_descriptors[0].Initialize(m_pose_count, frontal, "", 0);
-
-        for(int j = 0; j < m_pca_dim_high; j++)
-        {
-            CvMat eigenvector;
-            cvGetSubRect(m_pca_hr_eigenvectors, &eigenvector, cvRect(0, j, m_pca_hr_eigenvectors->cols, 1));
-            eigenvector2image(&eigenvector, frontal);
-
-            m_pca_descriptors[j + 1].SetTransforms(m_poses, m_transforms);
-            m_pca_descriptors[j + 1].Initialize(m_pose_count, frontal, "", 0);
-
-            printf("Created descriptor for PCA component %d\n", j);
-        }
-
-        cvReleaseImage(&frontal);
-    }
-
-
-    int OneWayDescriptorBase::LoadPCADescriptors(const char* filename)
-    {
-        FileStorage fs = FileStorage (filename, FileStorage::READ);
-        if(!fs.isOpened ())
-        {
-            printf("File %s not found...\n", filename);
-            return 0;
-        }
-
-        LoadPCADescriptors (fs.root ());
-
-        printf("Successfully read %d pca components\n", m_pca_dim_high);
-        fs.release ();
-
-        return 1;
-    }
-
-    int OneWayDescriptorBase::LoadPCADescriptors(const FileNode &fn)
-    {
-        // read affine poses
-//            FileNode* node = cvGetFileNodeByName(fs, 0, "affine poses");
-        CvMat* poses = reinterpret_cast<CvMat*> (fn["affine_poses"].readObj ());
-        if (poses == 0)
-        {
-            poses = reinterpret_cast<CvMat*> (fn["affine poses"].readObj ());
-            if (poses == 0)
-                return 0;
-        }
-
-
-        if(m_poses)
-        {
-            delete m_poses;
-        }
-        m_poses = new CvAffinePose[m_pose_count];
-        for(int i = 0; i < m_pose_count; i++)
-        {
-            m_poses[i].phi = (float)cvmGet(poses, i, 0);
-            m_poses[i].theta = (float)cvmGet(poses, i, 1);
-            m_poses[i].lambda1 = (float)cvmGet(poses, i, 2);
-            m_poses[i].lambda2 = (float)cvmGet(poses, i, 3);
-        }
-        cvReleaseMat(&poses);
-
-        // now initialize pose transforms
-        InitializeTransformsFromPoses();
-
-        m_pca_dim_high = (int) fn["pca_components_number"];
-        if (m_pca_dim_high == 0)
-        {
-            m_pca_dim_high = (int) fn["pca components number"];
-        }
-        if(m_pca_descriptors)
-        {
-            delete []m_pca_descriptors;
-        }
-        AllocatePCADescriptors();
-        for(int i = 0; i < m_pca_dim_high + 1; i++)
-        {
-            m_pca_descriptors[i].Allocate(m_pose_count, m_patch_size, 1);
-            m_pca_descriptors[i].SetTransforms(m_poses, m_transforms);
-            char buf[1024];
-            sprintf(buf, "descriptor_for_pca_component_%d", i);
-
-            if (! m_pca_descriptors[i].ReadByName(fn, buf))
-            {
-                sprintf(buf, "descriptor for pca component %d", i);
-                m_pca_descriptors[i].ReadByName(fn, buf);
-            }
-        }
-        return 1;
-    }
-
-
-    void savePCAFeatures(FileStorage &fs, const char* postfix, CvMat* avg, CvMat* eigenvectors)
-    {
-        char buf[1024];
-        sprintf(buf, "avg_%s", postfix);
-        fs.writeObj(buf, avg);
-        sprintf(buf, "eigenvectors_%s", postfix);
-        fs.writeObj(buf, eigenvectors);
-    }
-
-    void calcPCAFeatures(std::vector<IplImage*>& patches, FileStorage &fs, const char* postfix, CvMat** avg,
-                         CvMat** eigenvectors)
-    {
-        int width = patches[0]->width;
-        int height = patches[0]->height;
-        int length = width * height;
-        int patch_count = (int)patches.size();
-
-        CvMat* data = cvCreateMat(patch_count, length, CV_32FC1);
-        *avg = cvCreateMat(1, length, CV_32FC1);
-        CvMat* eigenvalues = cvCreateMat(1, length, CV_32FC1);
-        *eigenvectors = cvCreateMat(length, length, CV_32FC1);
-
-        for (int i = 0; i < patch_count; i++)
-        {
-            float nf = (float)(1./cvSum(patches[i]).val[0]);
-            for (int y = 0; y < height; y++)
-            {
-                for (int x = 0; x < width; x++)
-                {
-                    *((float*)(data->data.ptr + data->step * i) + y * width + x)
-                            = (unsigned char)patches[i]->imageData[y * patches[i]->widthStep + x] * nf;
-                }
-            }
-        }
-
-        //printf("Calculating PCA...");
-        cvCalcPCA(data, *avg, eigenvalues, *eigenvectors, CV_PCA_DATA_AS_ROW);
-        //printf("done\n");
-
-        // save pca data
-        savePCAFeatures(fs, postfix, *avg, *eigenvectors);
-
-        cvReleaseMat(&data);
-        cvReleaseMat(&eigenvalues);
-    }
-
-    static void extractPatches (IplImage *img, std::vector<IplImage*>& patches, CvSize patch_size)
-    {
-        std::vector<KeyPoint> features;
-        Ptr<FeatureDetector> surf_extractor = FeatureDetector::create("SURF");
-        if( !surf_extractor )
-            CV_Error(CV_StsNotImplemented, "OpenCV was built without SURF support");
-        surf_extractor->set("hessianThreshold", 1.0);
-        //printf("Extracting SURF features...");
-        surf_extractor->detect(cv::cvarrToMat(img), features);
-        //printf("done\n");
-
-        for (int j = 0; j < (int)features.size(); j++)
-        {
-            int patch_width = patch_size.width;
-            int patch_height = patch_size.height;
-
-            CvPoint center = features[j].pt;
-
-            CvRect roi = cvRect(center.x - patch_width / 2, center.y - patch_height / 2, patch_width, patch_height);
-            cvSetImageROI(img, roi);
-            roi = cvGetImageROI(img);
-            if (roi.width != patch_width || roi.height != patch_height)
-            {
-                continue;
-            }
-
-            IplImage* patch = cvCreateImage(cvSize(patch_width, patch_height), IPL_DEPTH_8U, 1);
-            cvCopy(img, patch);
-            patches.push_back(patch);
-            cvResetImageROI(img);
-        }
-        //printf("Completed file, extracted %d features\n", (int)features.size());
-    }
-
-/*
-    void loadPCAFeatures(const FileNode &fn, std::vector<IplImage*>& patches, CvSize patch_size)
-    {
-        FileNodeIterator begin = fn.begin();
-        for (FileNodeIterator i = fn.begin(); i != fn.end(); i++)
-        {
-            IplImage *img = reinterpret_cast<IplImage*> ((*i).readObj());
-            extractPatches (img, patches, patch_size);
-            cvReleaseImage(&img);
-        }
-    }
-*/
-
-    void loadPCAFeatures(const char* path, const char* images_list, std::vector<IplImage*>& patches, CvSize patch_size)
-    {
-        char images_filename[1024];
-        sprintf(images_filename, "%s/%s", path, images_list);
-        FILE *pFile = fopen(images_filename, "r");
-        if (pFile == 0)
-        {
-            printf("Cannot open images list file %s\n", images_filename);
-            return;
-        }
-        while (!feof(pFile))
-        {
-            char imagename[1024];
-            if (fscanf(pFile, "%s", imagename) <= 0)
-            {
-                break;
-            }
-
-            char filename[1024];
-            sprintf(filename, "%s/%s", path, imagename);
-
-            //printf("Reading image %s...", filename);
-            IplImage img;
-#ifdef HAVE_OPENCV_HIGHGUI
-            Mat img2 = cv::imread(filename, IMREAD_GRAYSCALE);
-            img = img2;
-#else
-            CV_Error(CV_StsNotImplemented, "OpenCV has been compiled without image I/O support");
-#endif
-            //printf("done\n");
-
-            extractPatches (&img, patches, patch_size);
-        }
-        fclose(pFile);
-    }
-
-    void generatePCAFeatures(const char* path, const char* img_filename, FileStorage& fs, const char* postfix,
-                             CvSize patch_size, CvMat** avg, CvMat** eigenvectors)
-    {
-        std::vector<IplImage*> patches;
-        loadPCAFeatures(path, img_filename, patches, patch_size);
-        calcPCAFeatures(patches, fs, postfix, avg, eigenvectors);
-    }
-
-/*
-    void generatePCAFeatures(const FileNode &fn, const char* postfix,
-                             CvSize patch_size, CvMat** avg, CvMat** eigenvectors)
-    {
-        std::vector<IplImage*> patches;
-        loadPCAFeatures(fn, patches, patch_size);
-        calcPCAFeatures(patches, fs, postfix, avg, eigenvectors);
-    }
-
-
-    void OneWayDescriptorBase::GeneratePCA(const FileNode &fn, int pose_count)
-    {
-        generatePCAFeatures(fn, "hr", m_patch_size, &m_pca_hr_avg, &m_pca_hr_eigenvectors);
-        generatePCAFeatures(fn, "lr", cvSize(m_patch_size.width / 2, m_patch_size.height / 2),
-                            &m_pca_avg, &m_pca_eigenvectors);
-
-
-        OneWayDescriptorBase descriptors(m_patch_size, pose_count);
-        descriptors.SetPCAHigh(m_pca_hr_avg, m_pca_hr_eigenvectors);
-        descriptors.SetPCALow(m_pca_avg, m_pca_eigenvectors);
-
-        printf("Calculating %d PCA descriptors (you can grab a coffee, this will take a while)...\n",
-               descriptors.GetPCADimHigh());
-        descriptors.InitializePoseTransforms();
-        descriptors.CreatePCADescriptors();
-        descriptors.SavePCADescriptors(*fs);
-    }
-*/
-
-    void OneWayDescriptorBase::GeneratePCA(const char* img_path, const char* images_list, int pose_count)
-    {
-        char pca_filename[1024];
-        sprintf(pca_filename, "%s/%s", img_path, GetPCAFilename().c_str());
-        FileStorage fs = FileStorage(pca_filename, FileStorage::WRITE);
-
-        generatePCAFeatures(img_path, images_list, fs, "hr", m_patch_size, &m_pca_hr_avg, &m_pca_hr_eigenvectors);
-        generatePCAFeatures(img_path, images_list, fs, "lr", cvSize(m_patch_size.width / 2, m_patch_size.height / 2),
-                            &m_pca_avg, &m_pca_eigenvectors);
-
-        OneWayDescriptorBase descriptors(m_patch_size, pose_count);
-        descriptors.SetPCAHigh(m_pca_hr_avg, m_pca_hr_eigenvectors);
-        descriptors.SetPCALow(m_pca_avg, m_pca_eigenvectors);
-
-        printf("Calculating %d PCA descriptors (you can grab a coffee, this will take a while)...\n",
-               descriptors.GetPCADimHigh());
-        descriptors.InitializePoseTransforms();
-        descriptors.CreatePCADescriptors();
-        descriptors.SavePCADescriptors(*fs);
-
-        fs.release();
-    }
-
-    void OneWayDescriptorBase::Write (FileStorage &fs) const
-    {
-        fs << "poseCount" << m_pose_count;
-        fs << "patchWidth" << m_patch_size.width;
-        fs << "patchHeight" << m_patch_size.height;
-        fs << "minScale" << scale_min;
-        fs << "maxScale" << scale_max;
-        fs << "stepScale" << scale_step;
-        fs << "pyrLevels" << m_pyr_levels;
-        fs << "pcaDimHigh" << m_pca_dim_high;
-        fs << "pcaDimLow" << m_pca_dim_low;
-
-        SavePCAall (fs);
-    }
-
-    void OneWayDescriptorBase::SavePCAall (FileStorage &fs) const
-    {
-        savePCAFeatures(fs, "hr", m_pca_hr_avg, m_pca_hr_eigenvectors);
-        savePCAFeatures(fs, "lr", m_pca_avg, m_pca_eigenvectors);
-        SavePCADescriptors(*fs);
-    }
-
-    void OneWayDescriptorBase::SavePCADescriptors(const char* filename)
-    {
-        CvMemStorage* storage = cvCreateMemStorage();
-        CvFileStorage* fs = cvOpenFileStorage(filename, storage, CV_STORAGE_WRITE);
-
-        SavePCADescriptors (fs);
-
-        cvReleaseMemStorage(&storage);
-        cvReleaseFileStorage(&fs);
-    }
-
-    void OneWayDescriptorBase::SavePCADescriptors(CvFileStorage *fs) const
-    {
-        cvWriteInt(fs, "pca_components_number", m_pca_dim_high);
-        cvWriteComment(
-                       fs,
-                       "The first component is the average Vector, so the total number of components is <pca components number> + 1",
-                       0);
-        cvWriteInt(fs, "patch_width", m_patch_size.width);
-        cvWriteInt(fs, "patch_height", m_patch_size.height);
-
-        // pack the affine transforms into a single CvMat and write them
-        CvMat* poses = cvCreateMat(m_pose_count, 4, CV_32FC1);
-        for (int i = 0; i < m_pose_count; i++)
-        {
-            cvmSet(poses, i, 0, m_poses[i].phi);
-            cvmSet(poses, i, 1, m_poses[i].theta);
-            cvmSet(poses, i, 2, m_poses[i].lambda1);
-            cvmSet(poses, i, 3, m_poses[i].lambda2);
-        }
-        cvWrite(fs, "affine_poses", poses);
-        cvReleaseMat(&poses);
-
-        for (int i = 0; i < m_pca_dim_high + 1; i++)
-        {
-            char buf[1024];
-            sprintf(buf, "descriptor_for_pca_component_%d", i);
-            m_pca_descriptors[i].Write(fs, buf);
-        }
-    }
-
-
-    void OneWayDescriptorBase::Allocate(int train_feature_count)
-    {
-        m_train_feature_count = train_feature_count;
-        m_descriptors = new OneWayDescriptor[m_train_feature_count];
-        for(int i = 0; i < m_train_feature_count; i++)
-        {
-            m_descriptors[i].SetPCADimHigh(m_pca_dim_high);
-            m_descriptors[i].SetPCADimLow(m_pca_dim_low);
-        }
-    }
-
-    void OneWayDescriptorBase::InitializeDescriptors(IplImage* train_image, const std::vector<KeyPoint>& features,
-                                                     const char* feature_label, int desc_start_idx)
-    {
-        for(int i = 0; i < (int)features.size(); i++)
-        {
-            InitializeDescriptor(desc_start_idx + i, train_image, features[i], feature_label);
-
-        }
-        cvResetImageROI(train_image);
-
-#if defined(_KDTREE)
-        ConvertDescriptorsArrayToTree();
-#endif
-    }
-
-    void OneWayDescriptorBase::CreateDescriptorsFromImage(IplImage* src, const std::vector<KeyPoint>& features)
-    {
-        m_train_feature_count = (int)features.size();
-
-        m_descriptors = new OneWayDescriptor[m_train_feature_count];
-
-        InitializeDescriptors(src, features);
-
-    }
-
-#if defined(_KDTREE)
-    void OneWayDescriptorBase::ConvertDescriptorsArrayToTree()
-    {
-        int n = this->GetDescriptorCount();
-        if (n<1)
-            return;
-        int pca_dim_low = this->GetDescriptor(0)->GetPCADimLow();
-
-        //if (!m_pca_descriptors_matrix)
-        //  m_pca_descriptors_matrix = new ::cvflann::Matrix<float>(n*m_pose_count,pca_dim_low);
-        //else
-        //{
-        //  if ((m_pca_descriptors_matrix->cols != pca_dim_low)&&(m_pca_descriptors_matrix->rows != n*m_pose_count))
-        //  {
-        //      delete m_pca_descriptors_matrix;
-        //      m_pca_descriptors_matrix = new ::cvflann::Matrix<float>(n*m_pose_count,pca_dim_low);
-        //  }
-        //}
-
-        m_pca_descriptors_matrix = cvCreateMat(n*m_pose_count,pca_dim_low,CV_32FC1);
-        for (int i=0;i<n;i++)
-        {
-            CvMat** pca_coeffs = m_descriptors[i].GetPCACoeffs();
-            for (int j = 0;j<m_pose_count;j++)
-            {
-                for (int k=0;k<pca_dim_low;k++)
-                {
-                    m_pca_descriptors_matrix->data.fl[(i*m_pose_count+j)*m_pca_dim_low + k] = pca_coeffs[j]->data.fl[k];
-                }
-            }
-        }
-        cv::Mat pca_descriptors_mat(m_pca_descriptors_matrix,false);
-
-        //::cvflann::KDTreeIndexParams params;
-        //params.trees = 1;
-        //m_pca_descriptors_tree = new KDTree(pca_descriptors_mat);
-        m_pca_descriptors_tree = new cv::flann::Index(pca_descriptors_mat,cv::flann::KDTreeIndexParams(1));
-        //cvReleaseMat(&m_pca_descriptors_matrix);
-        //m_pca_descriptors_tree->buildIndex();
-    }
-#endif
-
-    void OneWayDescriptorObject::Allocate(int train_feature_count, int object_feature_count)
-    {
-        OneWayDescriptorBase::Allocate(train_feature_count);
-        m_object_feature_count = object_feature_count;
-
-        m_part_id = new int[m_object_feature_count];
-    }
-
-
-    void OneWayDescriptorObject::InitializeObjectDescriptors(IplImage* train_image, const std::vector<KeyPoint>& features,
-                                                             const char* feature_label, int desc_start_idx, float scale, int is_background)
-    {
-        InitializeDescriptors(train_image, features, feature_label, desc_start_idx);
-
-        for(int i = 0; i < (int)features.size(); i++)
-        {
-            CvPoint center = features[i].pt;
-
-            if(!is_background)
-            {
-                // remember descriptor part id
-                CvPoint center_scaled = cvPoint(round(center.x*scale), round(center.y*scale));
-                m_part_id[i + desc_start_idx] = MatchPointToPart(center_scaled);
-            }
-        }
-        cvResetImageROI(train_image);
-    }
-
-    int OneWayDescriptorObject::IsDescriptorObject(int desc_idx) const
-    {
-        return desc_idx < m_object_feature_count ? 1 : 0;
-    }
-
-    int OneWayDescriptorObject::MatchPointToPart(CvPoint pt) const
-    {
-        int idx = -1;
-        const int max_dist = 10;
-        for(int i = 0; i < (int)m_train_features.size(); i++)
-        {
-            if(norm(Point2f(pt) - m_train_features[i].pt) < max_dist)
-            {
-                idx = i;
-                break;
-            }
-        }
-
-        return idx;
-    }
-
-    int OneWayDescriptorObject::GetDescriptorPart(int desc_idx) const
-    {
-        //    return MatchPointToPart(GetDescriptor(desc_idx)->GetCenter());
-        return desc_idx < m_object_feature_count ? m_part_id[desc_idx] : -1;
-    }
-
-    OneWayDescriptorObject::OneWayDescriptorObject(CvSize patch_size, int pose_count, const char* train_path,
-                                                   const char* pca_config, const char* pca_hr_config, const char* pca_desc_config, int pyr_levels) :
-    OneWayDescriptorBase(patch_size, pose_count, train_path, pca_config, pca_hr_config, pca_desc_config, pyr_levels)
-    {
-        m_part_id = 0;
-    }
-
-    OneWayDescriptorObject::OneWayDescriptorObject(CvSize patch_size, int pose_count, const String &pca_filename,
-                                                   const String &train_path, const String &images_list, float _scale_min, float _scale_max, float _scale_step, int pyr_levels) :
-    OneWayDescriptorBase(patch_size, pose_count, pca_filename, train_path, images_list, _scale_min, _scale_max, _scale_step, pyr_levels)
-    {
-        m_part_id = 0;
-    }
-
-    OneWayDescriptorObject::~OneWayDescriptorObject()
-    {
-        if (m_part_id)
-            delete []m_part_id;
-    }
-
-    std::vector<KeyPoint> OneWayDescriptorObject::_GetLabeledFeatures() const
-    {
-        std::vector<KeyPoint> features;
-        for(size_t i = 0; i < m_train_features.size(); i++)
-        {
-            features.push_back(m_train_features[i]);
-        }
-
-        return features;
-    }
-
-    void eigenvector2image(CvMat* eigenvector, IplImage* img)
-    {
-        CvRect roi = cvGetImageROI(img);
-        if(img->depth == 32)
-        {
-            for(int y = 0; y < roi.height; y++)
-            {
-                for(int x = 0; x < roi.width; x++)
-                {
-                    float val = (float)cvmGet(eigenvector, 0, roi.width*y + x);
-                    *((float*)(img->imageData + (roi.y + y)*img->widthStep) + roi.x + x) = val;
-                }
-            }
-        }
-        else
-        {
-            for(int y = 0; y < roi.height; y++)
-            {
-                for(int x = 0; x < roi.width; x++)
-                {
-                    float val = (float)cvmGet(eigenvector, 0, roi.width*y + x);
-                    img->imageData[(roi.y + y)*img->widthStep + roi.x + x] = (unsigned char)val;
-                }
-            }
-        }
-    }
-
-    void readPCAFeatures(const char* filename, CvMat** avg, CvMat** eigenvectors, const char* postfix)
-    {
-        FileStorage fs = FileStorage(filename, FileStorage::READ);
-        if (!fs.isOpened ())
-        {
-            printf("Cannot open file %s! Exiting!", filename);
-        }
-
-        readPCAFeatures (fs.root (), avg, eigenvectors, postfix);
-        fs.release ();
-    }
-
-    void readPCAFeatures(const FileNode &fn, CvMat** avg, CvMat** eigenvectors, const char* postfix)
-    {
-        String str = String ("avg") + postfix;
-        CvMat* _avg = reinterpret_cast<CvMat*> (fn[str].readObj());
-        if (_avg != 0)
-        {
-            *avg = cvCloneMat(_avg);
-            cvReleaseMat(&_avg);
-        }
-
-        str = String ("eigenvectors") + postfix;
-        CvMat* _eigenvectors = reinterpret_cast<CvMat*> (fn[str].readObj());
-        if (_eigenvectors != 0)
-        {
-            *eigenvectors = cvCloneMat(_eigenvectors);
-            cvReleaseMat(&_eigenvectors);
-        }
-    }
-
-    /****************************************************************************************\
-     *                                OneWayDescriptorMatcher                                  *
-     \****************************************************************************************/
-
-    OneWayDescriptorMatcher::Params::Params( int _poseCount, Size _patchSize, String _pcaFilename,
-                                            String _trainPath, String _trainImagesList,
-                                            float _minScale, float _maxScale, float _stepScale ) :
-    poseCount(_poseCount), patchSize(_patchSize), pcaFilename(_pcaFilename),
-    trainPath(_trainPath), trainImagesList(_trainImagesList),
-    minScale(_minScale), maxScale(_maxScale), stepScale(_stepScale)
-    {}
-
-
-    OneWayDescriptorMatcher::OneWayDescriptorMatcher( const Params& _params)
-    {
-        initialize(_params);
-    }
-
-    OneWayDescriptorMatcher::~OneWayDescriptorMatcher()
-    {}
-
-    void OneWayDescriptorMatcher::initialize( const Params& _params, const Ptr<OneWayDescriptorBase>& _base )
-    {
-        clear();
-
-        if( !_base )
-            base = _base;
-
-        params = _params;
-    }
-
-    void OneWayDescriptorMatcher::clear()
-    {
-        GenericDescriptorMatcher::clear();
-
-        prevTrainCount = 0;
-        if( base )
-            base->clear();
-    }
-
-    void OneWayDescriptorMatcher::train()
-    {
-        if( !base || prevTrainCount < (int)trainPointCollection.keypointCount() )
-        {
-            base.reset(
-                new OneWayDescriptorObject( params.patchSize, params.poseCount, params.pcaFilename,
-                                            params.trainPath, params.trainImagesList, params.minScale, params.maxScale, params.stepScale ));
-
-            base->Allocate( (int)trainPointCollection.keypointCount() );
-            prevTrainCount = (int)trainPointCollection.keypointCount();
-
-            const std::vector<std::vector<KeyPoint> >& points = trainPointCollection.getKeypoints();
-            int count = 0;
-            for( size_t i = 0; i < points.size(); i++ )
-            {
-                IplImage _image = trainPointCollection.getImage((int)i);
-                for( size_t j = 0; j < points[i].size(); j++ )
-                    base->InitializeDescriptor( count++, &_image, points[i][j], "" );
-            }
-
-#if defined(_KDTREE)
-            base->ConvertDescriptorsArrayToTree();
-#endif
-        }
-    }
-
-    bool OneWayDescriptorMatcher::isMaskSupported()
-    {
-        return false;
-    }
-
-    void OneWayDescriptorMatcher::knnMatchImpl( InputArray _queryImage, std::vector<KeyPoint>& queryKeypoints,
-                                               std::vector<std::vector<DMatch> >& matches, int knn,
-                                               InputArrayOfArrays /*masks*/, bool /*compactResult*/ )
-    {
-        Mat queryImage = _queryImage.getMat();
-        train();
-
-        CV_Assert( knn == 1 ); // knn > 1 unsupported because of bug in OneWayDescriptorBase for this case
-
-        matches.resize( queryKeypoints.size() );
-        IplImage _qimage = queryImage;
-        for( size_t i = 0; i < queryKeypoints.size(); i++ )
-        {
-            int descIdx = -1, poseIdx = -1;
-            float distance;
-            base->FindDescriptor( &_qimage, queryKeypoints[i].pt, descIdx, poseIdx, distance );
-            matches[i].push_back( DMatch((int)i, descIdx, distance) );
-        }
-    }
-
-    void OneWayDescriptorMatcher::radiusMatchImpl( InputArray _queryImage, std::vector<KeyPoint>& queryKeypoints,
-                                                  std::vector<std::vector<DMatch> >& matches, float maxDistance,
-                                                   InputArrayOfArrays /*masks*/, bool /*compactResult*/ )
-    {
-        Mat queryImage = _queryImage.getMat();
-
-        train();
-
-        matches.resize( queryKeypoints.size() );
-        IplImage _qimage = queryImage;
-        for( size_t i = 0; i < queryKeypoints.size(); i++ )
-        {
-            int descIdx = -1, poseIdx = -1;
-            float distance;
-            base->FindDescriptor( &_qimage, queryKeypoints[i].pt, descIdx, poseIdx, distance );
-            if( distance < maxDistance )
-                matches[i].push_back( DMatch((int)i, descIdx, distance) );
-        }
-    }
-
-    void OneWayDescriptorMatcher::read( const FileNode &fn )
-    {
-        base.reset(
-            new OneWayDescriptorObject( params.patchSize, params.poseCount, String (), String (), String (),
-                                        params.minScale, params.maxScale, params.stepScale ));
-        base->Read (fn);
-    }
-
-    void OneWayDescriptorMatcher::write( FileStorage& fs ) const
-    {
-        base->Write (fs);
-    }
-
-    bool OneWayDescriptorMatcher::empty() const
-    {
-        return !base || base->empty();
-    }
-
-    Ptr<GenericDescriptorMatcher> OneWayDescriptorMatcher::clone( bool emptyTrainData ) const
-    {
-        Ptr<OneWayDescriptorMatcher> matcher = makePtr<OneWayDescriptorMatcher>( params );
-
-        if( !emptyTrainData )
-        {
-            CV_Error( CV_StsNotImplemented, "deep clone functionality is not implemented, because "
-                     "OneWayDescriptorBase has not copy constructor or clone method ");
-
-            //matcher->base;
-            matcher->params = params;
-            matcher->prevTrainCount = prevTrainCount;
-            matcher->trainPointCollection = trainPointCollection;
-        }
-        return matcher;
-    }
-}
diff --git a/modules/legacy/src/optflowbm.cpp b/modules/legacy/src/optflowbm.cpp
deleted file mode 100644 (file)
index 91b55cd..0000000
+++ /dev/null
@@ -1,302 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-
-static inline int cmpBlocks(const uchar* A, const uchar* B, int Bstep, CvSize blockSize )
-{
-    int x, s = 0;
-    for( ; blockSize.height--; A += blockSize.width, B += Bstep )
-    {
-        for( x = 0; x <= blockSize.width - 4; x += 4 )
-            s += std::abs(A[x] - B[x]) + std::abs(A[x+1] - B[x+1]) +
-                std::abs(A[x+2] - B[x+2]) + std::abs(A[x+3] - B[x+3]);
-        for( ; x < blockSize.width; x++ )
-            s += std::abs(A[x] - B[x]);
-    }
-    return s;
-}
-
-
-CV_IMPL void
-cvCalcOpticalFlowBM( const void* srcarrA, const void* srcarrB,
-                     CvSize blockSize, CvSize shiftSize,
-                     CvSize maxRange, int usePrevious,
-                     void* velarrx, void* velarry )
-{
-    CvMat stubA, *srcA = cvGetMat( srcarrA, &stubA );
-    CvMat stubB, *srcB = cvGetMat( srcarrB, &stubB );
-
-    CvMat stubx, *velx = cvGetMat( velarrx, &stubx );
-    CvMat stuby, *vely = cvGetMat( velarry, &stuby );
-
-    if( !CV_ARE_TYPES_EQ( srcA, srcB ))
-        CV_Error( CV_StsUnmatchedFormats, "Source images have different formats" );
-
-    if( !CV_ARE_TYPES_EQ( velx, vely ))
-        CV_Error( CV_StsUnmatchedFormats, "Destination images have different formats" );
-
-    CvSize velSize(
-        (srcA->width - blockSize.width + shiftSize.width)/shiftSize.width,
-        (srcA->height - blockSize.height + shiftSize.height)/shiftSize.height
-    );
-
-    if( !CV_ARE_SIZES_EQ( srcA, srcB ) ||
-        !CV_ARE_SIZES_EQ( velx, vely ) ||
-        velx->width != velSize.width ||
-        vely->height != velSize.height )
-        CV_Error( CV_StsUnmatchedSizes, "" );
-
-    if( CV_MAT_TYPE( srcA->type ) != CV_8UC1 ||
-        CV_MAT_TYPE( velx->type ) != CV_32FC1 )
-        CV_Error( CV_StsUnsupportedFormat, "Source images must have 8uC1 type and "
-                                           "destination images must have 32fC1 type" );
-
-    if( srcA->step != srcB->step || velx->step != vely->step )
-        CV_Error( CV_BadStep, "two source or two destination images have different steps" );
-
-    const int SMALL_DIFF=2;
-    const int BIG_DIFF=128;
-
-    // scanning scheme coordinates
-    std::vector<CvPoint> _ss((2 * maxRange.width + 1) * (2 * maxRange.height + 1));
-    CvPoint* ss = &_ss[0];
-    int ss_count = 0;
-
-    int blWidth = blockSize.width, blHeight = blockSize.height;
-    int blSize = blWidth*blHeight;
-    int acceptLevel = blSize * SMALL_DIFF;
-    int escapeLevel = blSize * BIG_DIFF;
-
-    int i, j;
-
-    std::vector<uchar> _blockA(cvAlign(blSize + 16, 16));
-    uchar* blockA = (uchar*)cvAlignPtr(&_blockA[0], 16);
-
-    // Calculate scanning scheme
-    int min_count = MIN( maxRange.width, maxRange.height );
-
-    // use spiral search pattern
-    //
-    //     9 10 11 12
-    //     8  1  2 13
-    //     7  *  3 14
-    //     6  5  4 15
-    //... 20 19 18 17
-    //
-
-    for( i = 0; i < min_count; i++ )
-    {
-        // four cycles along sides
-        int x = -i-1, y = x;
-
-        // upper side
-        for( j = -i; j <= i + 1; j++, ss_count++ )
-        {
-            ss[ss_count].x = ++x;
-            ss[ss_count].y = y;
-        }
-
-        // right side
-        for( j = -i; j <= i + 1; j++, ss_count++ )
-        {
-            ss[ss_count].x = x;
-            ss[ss_count].y = ++y;
-        }
-
-        // bottom side
-        for( j = -i; j <= i + 1; j++, ss_count++ )
-        {
-            ss[ss_count].x = --x;
-            ss[ss_count].y = y;
-        }
-
-        // left side
-        for( j = -i; j <= i + 1; j++, ss_count++ )
-        {
-            ss[ss_count].x = x;
-            ss[ss_count].y = --y;
-        }
-    }
-
-    // the rest part
-    if( maxRange.width < maxRange.height )
-    {
-        int xleft = -min_count;
-
-        // cycle by neighbor rings
-        for( i = min_count; i < maxRange.height; i++ )
-        {
-            // two cycles by x
-            int y = -(i + 1);
-            int x = xleft;
-
-            // upper side
-            for( j = -maxRange.width; j <= maxRange.width; j++, ss_count++, x++ )
-            {
-                ss[ss_count].x = x;
-                ss[ss_count].y = y;
-            }
-
-            x = xleft;
-            y = -y;
-            // bottom side
-            for( j = -maxRange.width; j <= maxRange.width; j++, ss_count++, x++ )
-            {
-                ss[ss_count].x = x;
-                ss[ss_count].y = y;
-            }
-        }
-    }
-    else if( maxRange.width > maxRange.height )
-    {
-        int yupper = -min_count;
-
-        // cycle by neighbor rings
-        for( i = min_count; i < maxRange.width; i++ )
-        {
-            // two cycles by y
-            int x = -(i + 1);
-            int y = yupper;
-
-            // left side
-            for( j = -maxRange.height; j <= maxRange.height; j++, ss_count++, y++ )
-            {
-                ss[ss_count].x = x;
-                ss[ss_count].y = y;
-            }
-
-            y = yupper;
-            x = -x;
-            // right side
-            for( j = -maxRange.height; j <= maxRange.height; j++, ss_count++, y++ )
-            {
-                ss[ss_count].x = x;
-                ss[ss_count].y = y;
-            }
-        }
-    }
-
-    int maxX = srcB->cols - blockSize.width, maxY = srcB->rows - blockSize.height;
-    const uchar* Adata = srcA->data.ptr;
-    const uchar* Bdata = srcB->data.ptr;
-    int Astep = srcA->step, Bstep = srcB->step;
-
-    // compute the flow
-    for( i = 0; i < velx->rows; i++ )
-    {
-        float* vx = (float*)(velx->data.ptr + velx->step*i);
-        float* vy = (float*)(vely->data.ptr + vely->step*i);
-
-        for( j = 0; j < velx->cols; j++ )
-        {
-            int X1 = j*shiftSize.width, Y1 = i*shiftSize.height, X2, Y2;
-            int offX = 0, offY = 0;
-
-            if( usePrevious )
-            {
-                offX = cvRound(vx[j]);
-                offY = cvRound(vy[j]);
-            }
-
-            int k;
-            for( k = 0; k < blHeight; k++ )
-                memcpy( blockA + k*blWidth, Adata + Astep*(Y1 + k) + X1, blWidth );
-
-            X2 = X1 + offX;
-            Y2 = Y1 + offY;
-            int dist = INT_MAX;
-            if( 0 <= X2 && X2 <= maxX && 0 <= Y2 && Y2 <= maxY )
-                dist = cmpBlocks( blockA, Bdata + Bstep*Y2 + X2, Bstep, blockSize );
-
-            int countMin = 1;
-            int sumx = offX, sumy = offY;
-
-            if( dist > acceptLevel )
-            {
-                // do brute-force search
-                for( k = 0; k < ss_count; k++ )
-                {
-                    int dx = offX + ss[k].x;
-                    int dy = offY + ss[k].y;
-                    X2 = X1 + dx;
-                    Y2 = Y1 + dy;
-
-                    if( !(0 <= X2 && X2 <= maxX && 0 <= Y2 && Y2 <= maxY) )
-                        continue;
-
-                    int tmpDist = cmpBlocks( blockA, Bdata + Bstep*Y2 + X2, Bstep, blockSize );
-                    if( tmpDist < acceptLevel )
-                    {
-                        sumx = dx; sumy = dy;
-                        countMin = 1;
-                        break;
-                    }
-
-                    if( tmpDist < dist )
-                    {
-                        dist = tmpDist;
-                        sumx = dx; sumy = dy;
-                        countMin = 1;
-                    }
-                    else if( tmpDist == dist )
-                    {
-                        sumx += dx; sumy += dy;
-                        countMin++;
-                    }
-                }
-
-                if( dist > escapeLevel )
-                {
-                    sumx = offX;
-                    sumy = offY;
-                    countMin = 1;
-                }
-            }
-
-            vx[j] = (float)sumx/countMin;
-            vy[j] = (float)sumy/countMin;
-        }
-    }
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/optflowhs.cpp b/modules/legacy/src/optflowhs.cpp
deleted file mode 100644 (file)
index ef7e025..0000000
+++ /dev/null
@@ -1,524 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-#define CONV( A, B, C)  ( (float)( A +  (B<<1)  + C ) )
-
-typedef struct
-{
-    float xx;
-    float xy;
-    float yy;
-    float xt;
-    float yt;
-    float alpha;                /* alpha = 1 / ( 1/lambda + xx + yy ) */
-}
-icvDerProductEx;
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvCalcOpticalFlowHS_8u32fR (Horn & Schunck method )
-//    Purpose: calculate Optical flow for 2 images using Horn & Schunck algorithm
-//    Context:
-//    Parameters:
-//            imgA          -  pointer to first frame ROI
-//            imgB          -  pointer to second frame ROI
-//            imgStep       -  width of single row of source images in bytes
-//            imgSize       -  size of the source image ROI
-//            usePrevious   - use previous (input) velocity field.
-//            velocityX     - pointer to horizontal and
-//            velocityY     - vertical components of optical flow ROI
-//            velStep       - width of single row of velocity frames in bytes
-//            lambda        - Lagrangian multiplier
-//            criteria      - criteria of termination processmaximum number of iterations
-//
-//    Returns: CV_OK         - all ok
-//             CV_OUTOFMEM_ERR  - insufficient memory for function work
-//             CV_NULLPTR_ERR - if one of input pointers is NULL
-//             CV_BADSIZE_ERR   - wrong input sizes interrelation
-//
-//    Notes:  1.Optical flow to be computed for every pixel in ROI
-//            2.For calculating spatial derivatives we use 3x3 Sobel operator.
-//            3.We use the following border mode.
-//              The last row or column is replicated for the border
-//              ( IPL_BORDER_REPLICATE in IPL ).
-//
-//
-//F*/
-static CvStatus CV_STDCALL
-icvCalcOpticalFlowHS_8u32fR( uchar*  imgA,
-                             uchar*  imgB,
-                             int     imgStep,
-                             CvSize imgSize,
-                             int     usePrevious,
-                             float*  velocityX,
-                             float*  velocityY,
-                             int     velStep,
-                             float   lambda,
-                             CvTermCriteria criteria )
-{
-    /* Loops indexes */
-    int i, j, k, address;
-
-    /* Buffers for Sobel calculations */
-    float *MemX[2];
-    float *MemY[2];
-
-    float ConvX, ConvY;
-    float GradX, GradY, GradT;
-
-    int imageWidth = imgSize.width;
-    int imageHeight = imgSize.height;
-
-    int ConvLine;
-    int LastLine;
-
-    int BufferSize;
-
-    float Ilambda = 1 / lambda;
-    int iter = 0;
-    int Stop;
-
-    /* buffers derivatives product */
-    icvDerProductEx *II;
-
-    float *VelBufX[2];
-    float *VelBufY[2];
-
-    /* variables for storing number of first pixel of image line */
-    int Line1;
-    int Line2;
-    int Line3;
-
-    int pixNumber;
-
-    /* auxiliary */
-    int NoMem = 0;
-
-    /* Checking bad arguments */
-    if( imgA == NULL )
-        return CV_NULLPTR_ERR;
-    if( imgB == NULL )
-        return CV_NULLPTR_ERR;
-
-    if( imgSize.width <= 0 )
-        return CV_BADSIZE_ERR;
-    if( imgSize.height <= 0 )
-        return CV_BADSIZE_ERR;
-    if( imgSize.width > imgStep )
-        return CV_BADSIZE_ERR;
-
-    if( (velStep & 3) != 0 )
-        return CV_BADSIZE_ERR;
-
-    velStep /= 4;
-
-    /****************************************************************************************/
-    /* Allocating memory for all buffers                                                    */
-    /****************************************************************************************/
-    for( k = 0; k < 2; k++ )
-    {
-        MemX[k] = (float *) cvAlloc( (imgSize.height) * sizeof( float ));
-
-        if( MemX[k] == NULL )
-            NoMem = 1;
-        MemY[k] = (float *) cvAlloc( (imgSize.width) * sizeof( float ));
-
-        if( MemY[k] == NULL )
-            NoMem = 1;
-
-        VelBufX[k] = (float *) cvAlloc( imageWidth * sizeof( float ));
-
-        if( VelBufX[k] == NULL )
-            NoMem = 1;
-        VelBufY[k] = (float *) cvAlloc( imageWidth * sizeof( float ));
-
-        if( VelBufY[k] == NULL )
-            NoMem = 1;
-    }
-
-    BufferSize = imageHeight * imageWidth;
-
-    II = (icvDerProductEx *) cvAlloc( BufferSize * sizeof( icvDerProductEx ));
-    if( II == NULL )
-        NoMem = 1;
-
-    if( NoMem )
-    {
-        for( k = 0; k < 2; k++ )
-        {
-            if( MemX[k] )
-                cvFree( &MemX[k] );
-
-            if( MemY[k] )
-                cvFree( &MemY[k] );
-
-            if( VelBufX[k] )
-                cvFree( &VelBufX[k] );
-
-            if( VelBufY[k] )
-                cvFree( &VelBufY[k] );
-        }
-        if( II )
-            cvFree( &II );
-        return CV_OUTOFMEM_ERR;
-    }
-/****************************************************************************************\
-*         Calculate first line of memX and memY                                          *
-\****************************************************************************************/
-    MemY[0][0] = MemY[1][0] = CONV( imgA[0], imgA[0], imgA[1] );
-    MemX[0][0] = MemX[1][0] = CONV( imgA[0], imgA[0], imgA[imgStep] );
-
-    for( j = 1; j < imageWidth - 1; j++ )
-    {
-        MemY[0][j] = MemY[1][j] = CONV( imgA[j - 1], imgA[j], imgA[j + 1] );
-    }
-
-    pixNumber = imgStep;
-    for( i = 1; i < imageHeight - 1; i++ )
-    {
-        MemX[0][i] = MemX[1][i] = CONV( imgA[pixNumber - imgStep],
-                                        imgA[pixNumber], imgA[pixNumber + imgStep] );
-        pixNumber += imgStep;
-    }
-
-    MemY[0][imageWidth - 1] =
-        MemY[1][imageWidth - 1] = CONV( imgA[imageWidth - 2],
-                                        imgA[imageWidth - 1], imgA[imageWidth - 1] );
-
-    MemX[0][imageHeight - 1] =
-        MemX[1][imageHeight - 1] = CONV( imgA[pixNumber - imgStep],
-                                         imgA[pixNumber], imgA[pixNumber] );
-
-
-/****************************************************************************************\
-*     begin scan image, calc derivatives                                                 *
-\****************************************************************************************/
-
-    ConvLine = 0;
-    Line2 = -imgStep;
-    address = 0;
-    LastLine = imgStep * (imageHeight - 1);
-    while( ConvLine < imageHeight )
-    {
-        /*Here we calculate derivatives for line of image */
-        int memYline = (ConvLine + 1) & 1;
-
-        Line2 += imgStep;
-        Line1 = Line2 - ((Line2 == 0) ? 0 : imgStep);
-        Line3 = Line2 + ((Line2 == LastLine) ? 0 : imgStep);
-
-        /* Process first pixel */
-        ConvX = CONV( imgA[Line1 + 1], imgA[Line2 + 1], imgA[Line3 + 1] );
-        ConvY = CONV( imgA[Line3], imgA[Line3], imgA[Line3 + 1] );
-
-        GradY = (ConvY - MemY[memYline][0]) * 0.125f;
-        GradX = (ConvX - MemX[1][ConvLine]) * 0.125f;
-
-        MemY[memYline][0] = ConvY;
-        MemX[1][ConvLine] = ConvX;
-
-        GradT = (float) (imgB[Line2] - imgA[Line2]);
-
-        II[address].xx = GradX * GradX;
-        II[address].xy = GradX * GradY;
-        II[address].yy = GradY * GradY;
-        II[address].xt = GradX * GradT;
-        II[address].yt = GradY * GradT;
-
-        II[address].alpha = 1 / (Ilambda + II[address].xx + II[address].yy);
-        address++;
-
-        /* Process middle of line */
-        for( j = 1; j < imageWidth - 1; j++ )
-        {
-            ConvX = CONV( imgA[Line1 + j + 1], imgA[Line2 + j + 1], imgA[Line3 + j + 1] );
-            ConvY = CONV( imgA[Line3 + j - 1], imgA[Line3 + j], imgA[Line3 + j + 1] );
-
-            GradY = (ConvY - MemY[memYline][j]) * 0.125f;
-            GradX = (ConvX - MemX[(j - 1) & 1][ConvLine]) * 0.125f;
-
-            MemY[memYline][j] = ConvY;
-            MemX[(j - 1) & 1][ConvLine] = ConvX;
-
-            GradT = (float) (imgB[Line2 + j] - imgA[Line2 + j]);
-
-            II[address].xx = GradX * GradX;
-            II[address].xy = GradX * GradY;
-            II[address].yy = GradY * GradY;
-            II[address].xt = GradX * GradT;
-            II[address].yt = GradY * GradT;
-
-            II[address].alpha = 1 / (Ilambda + II[address].xx + II[address].yy);
-            address++;
-        }
-        /* Process last pixel of line */
-        ConvX = CONV( imgA[Line1 + imageWidth - 1], imgA[Line2 + imageWidth - 1],
-                      imgA[Line3 + imageWidth - 1] );
-
-        ConvY = CONV( imgA[Line3 + imageWidth - 2], imgA[Line3 + imageWidth - 1],
-                      imgA[Line3 + imageWidth - 1] );
-
-
-        GradY = (ConvY - MemY[memYline][imageWidth - 1]) * 0.125f;
-        GradX = (ConvX - MemX[(imageWidth - 2) & 1][ConvLine]) * 0.125f;
-
-        MemY[memYline][imageWidth - 1] = ConvY;
-
-        GradT = (float) (imgB[Line2 + imageWidth - 1] - imgA[Line2 + imageWidth - 1]);
-
-        II[address].xx = GradX * GradX;
-        II[address].xy = GradX * GradY;
-        II[address].yy = GradY * GradY;
-        II[address].xt = GradX * GradT;
-        II[address].yt = GradY * GradT;
-
-        II[address].alpha = 1 / (Ilambda + II[address].xx + II[address].yy);
-        address++;
-
-        ConvLine++;
-    }
-/****************************************************************************************\
-*      Prepare initial approximation                                                     *
-\****************************************************************************************/
-    if( !usePrevious )
-    {
-        float *vx = velocityX;
-        float *vy = velocityY;
-
-        for( i = 0; i < imageHeight; i++ )
-        {
-            memset( vx, 0, imageWidth * sizeof( float ));
-            memset( vy, 0, imageWidth * sizeof( float ));
-
-            vx += velStep;
-            vy += velStep;
-        }
-    }
-/****************************************************************************************\
-*      Perform iterations                                                                *
-\****************************************************************************************/
-    iter = 0;
-    Stop = 0;
-    LastLine = velStep * (imageHeight - 1);
-    while( !Stop )
-    {
-        float Eps = 0;
-        address = 0;
-
-        iter++;
-/****************************************************************************************\
-*     begin scan velocity and update it                                                  *
-\****************************************************************************************/
-        Line2 = -velStep;
-        for( i = 0; i < imageHeight; i++ )
-        {
-            /* Here average velocity */
-
-            float averageX;
-            float averageY;
-            float tmp;
-
-            Line2 += velStep;
-            Line1 = Line2 - ((Line2 == 0) ? 0 : velStep);
-            Line3 = Line2 + ((Line2 == LastLine) ? 0 : velStep);
-            /* Process first pixel */
-            averageX = (velocityX[Line2] +
-                        velocityX[Line2 + 1] + velocityX[Line1] + velocityX[Line3]) / 4;
-
-            averageY = (velocityY[Line2] +
-                        velocityY[Line2 + 1] + velocityY[Line1] + velocityY[Line3]) / 4;
-
-            VelBufX[i & 1][0] = averageX -
-                (II[address].xx * averageX +
-                 II[address].xy * averageY + II[address].xt) * II[address].alpha;
-
-            VelBufY[i & 1][0] = averageY -
-                (II[address].xy * averageX +
-                 II[address].yy * averageY + II[address].yt) * II[address].alpha;
-
-            /* update Epsilon */
-            if( criteria.type & CV_TERMCRIT_EPS )
-            {
-                tmp = (float)fabs(velocityX[Line2] - VelBufX[i & 1][0]);
-                Eps = MAX( tmp, Eps );
-                tmp = (float)fabs(velocityY[Line2] - VelBufY[i & 1][0]);
-                Eps = MAX( tmp, Eps );
-            }
-            address++;
-            /* Process middle of line */
-            for( j = 1; j < imageWidth - 1; j++ )
-            {
-                averageX = (velocityX[Line2 + j - 1] +
-                            velocityX[Line2 + j + 1] +
-                            velocityX[Line1 + j] + velocityX[Line3 + j]) / 4;
-                averageY = (velocityY[Line2 + j - 1] +
-                            velocityY[Line2 + j + 1] +
-                            velocityY[Line1 + j] + velocityY[Line3 + j]) / 4;
-
-                VelBufX[i & 1][j] = averageX -
-                    (II[address].xx * averageX +
-                     II[address].xy * averageY + II[address].xt) * II[address].alpha;
-
-                VelBufY[i & 1][j] = averageY -
-                    (II[address].xy * averageX +
-                     II[address].yy * averageY + II[address].yt) * II[address].alpha;
-                /* update Epsilon */
-                if( criteria.type & CV_TERMCRIT_EPS )
-                {
-                    tmp = (float)fabs(velocityX[Line2 + j] - VelBufX[i & 1][j]);
-                    Eps = MAX( tmp, Eps );
-                    tmp = (float)fabs(velocityY[Line2 + j] - VelBufY[i & 1][j]);
-                    Eps = MAX( tmp, Eps );
-                }
-                address++;
-            }
-            /* Process last pixel of line */
-            averageX = (velocityX[Line2 + imageWidth - 2] +
-                        velocityX[Line2 + imageWidth - 1] +
-                        velocityX[Line1 + imageWidth - 1] +
-                        velocityX[Line3 + imageWidth - 1]) / 4;
-
-            averageY = (velocityY[Line2 + imageWidth - 2] +
-                        velocityY[Line2 + imageWidth - 1] +
-                        velocityY[Line1 + imageWidth - 1] +
-                        velocityY[Line3 + imageWidth - 1]) / 4;
-
-
-            VelBufX[i & 1][imageWidth - 1] = averageX -
-                (II[address].xx * averageX +
-                 II[address].xy * averageY + II[address].xt) * II[address].alpha;
-
-            VelBufY[i & 1][imageWidth - 1] = averageY -
-                (II[address].xy * averageX +
-                 II[address].yy * averageY + II[address].yt) * II[address].alpha;
-
-            /* update Epsilon */
-            if( criteria.type & CV_TERMCRIT_EPS )
-            {
-                tmp = (float)fabs(velocityX[Line2 + imageWidth - 1] -
-                                  VelBufX[i & 1][imageWidth - 1]);
-                Eps = MAX( tmp, Eps );
-                tmp = (float)fabs(velocityY[Line2 + imageWidth - 1] -
-                                  VelBufY[i & 1][imageWidth - 1]);
-                Eps = MAX( tmp, Eps );
-            }
-            address++;
-
-            /* store new velocity from old buffer to velocity frame */
-            if( i > 0 )
-            {
-                memcpy( &velocityX[Line1], VelBufX[(i - 1) & 1], imageWidth * sizeof( float ));
-                memcpy( &velocityY[Line1], VelBufY[(i - 1) & 1], imageWidth * sizeof( float ));
-            }
-        }                       /*for */
-        /* store new velocity from old buffer to velocity frame */
-        memcpy( &velocityX[imageWidth * (imageHeight - 1)],
-                VelBufX[(imageHeight - 1) & 1], imageWidth * sizeof( float ));
-
-        memcpy( &velocityY[imageWidth * (imageHeight - 1)],
-                VelBufY[(imageHeight - 1) & 1], imageWidth * sizeof( float ));
-
-        if( (criteria.type & CV_TERMCRIT_ITER) && (iter == criteria.max_iter) )
-            Stop = 1;
-        if( (criteria.type & CV_TERMCRIT_EPS) && (Eps < criteria.epsilon) )
-            Stop = 1;
-    }
-    /* Free memory */
-    for( k = 0; k < 2; k++ )
-    {
-        cvFree( &MemX[k] );
-        cvFree( &MemY[k] );
-        cvFree( &VelBufX[k] );
-        cvFree( &VelBufY[k] );
-    }
-    cvFree( &II );
-
-    return CV_OK;
-} /*icvCalcOpticalFlowHS_8u32fR*/
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name:    cvCalcOpticalFlowHS
-//    Purpose: Optical flow implementation
-//    Context:
-//    Parameters:
-//             srcA, srcB - source image
-//             velx, vely - destination image
-//    Returns:
-//
-//    Notes:
-//F*/
-CV_IMPL void
-cvCalcOpticalFlowHS( const void* srcarrA, const void* srcarrB, int usePrevious,
-                     void* velarrx, void* velarry,
-                     double lambda, CvTermCriteria criteria )
-{
-    CvMat stubA, *srcA = cvGetMat( srcarrA, &stubA );
-    CvMat stubB, *srcB = cvGetMat( srcarrB, &stubB );
-    CvMat stubx, *velx = cvGetMat( velarrx, &stubx );
-    CvMat stuby, *vely = cvGetMat( velarry, &stuby );
-
-    if( !CV_ARE_TYPES_EQ( srcA, srcB ))
-        CV_Error( CV_StsUnmatchedFormats, "Source images have different formats" );
-
-    if( !CV_ARE_TYPES_EQ( velx, vely ))
-        CV_Error( CV_StsUnmatchedFormats, "Destination images have different formats" );
-
-    if( !CV_ARE_SIZES_EQ( srcA, srcB ) ||
-        !CV_ARE_SIZES_EQ( velx, vely ) ||
-        !CV_ARE_SIZES_EQ( srcA, velx ))
-        CV_Error( CV_StsUnmatchedSizes, "" );
-
-    if( CV_MAT_TYPE( srcA->type ) != CV_8UC1 ||
-        CV_MAT_TYPE( velx->type ) != CV_32FC1 )
-        CV_Error( CV_StsUnsupportedFormat, "Source images must have 8uC1 type and "
-                                           "destination images must have 32fC1 type" );
-
-    if( srcA->step != srcB->step || velx->step != vely->step )
-        CV_Error( CV_BadStep, "source and destination images have different step" );
-
-    IPPI_CALL( icvCalcOpticalFlowHS_8u32fR( (uchar*)srcA->data.ptr, (uchar*)srcB->data.ptr,
-                                            srcA->step, cvGetMatSize( srcA ), usePrevious,
-                                            velx->data.fl, vely->data.fl,
-                                            velx->step, (float)lambda, criteria ));
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/optflowlk.cpp b/modules/legacy/src/optflowlk.cpp
deleted file mode 100644 (file)
index aabbb45..0000000
+++ /dev/null
@@ -1,599 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-typedef struct
-{
-    float xx;
-    float xy;
-    float yy;
-    float xt;
-    float yt;
-}
-icvDerProduct;
-
-
-#define CONV( A, B, C)  ((float)( A +  (B<<1)  + C ))
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvCalcOpticalFlowLK_8u32fR ( Lucas & Kanade method )
-//    Purpose: calculate Optical flow for 2 images using Lucas & Kanade algorithm
-//    Context:
-//    Parameters:
-//            imgA,         // pointer to first frame ROI
-//            imgB,         // pointer to second frame ROI
-//            imgStep,      // width of single row of source images in bytes
-//            imgSize,      // size of the source image ROI
-//            winSize,      // size of the averaging window used for grouping
-//            velocityX,    // pointer to horizontal and
-//            velocityY,    // vertical components of optical flow ROI
-//            velStep       // width of single row of velocity frames in bytes
-//
-//    Returns: CV_OK         - all ok
-//             CV_OUTOFMEM_ERR  - insufficient memory for function work
-//             CV_NULLPTR_ERR - if one of input pointers is NULL
-//             CV_BADSIZE_ERR   - wrong input sizes interrelation
-//
-//    Notes:  1.Optical flow to be computed for every pixel in ROI
-//            2.For calculating spatial derivatives we use 3x3 Sobel operator.
-//            3.We use the following border mode.
-//              The last row or column is replicated for the border
-//              ( IPL_BORDER_REPLICATE in IPL ).
-//
-//
-//F*/
-static CvStatus CV_STDCALL
-icvCalcOpticalFlowLK_8u32fR( uchar * imgA,
-                             uchar * imgB,
-                             int imgStep,
-                             CvSize imgSize,
-                             CvSize winSize,
-                             float *velocityX,
-                             float *velocityY, int velStep )
-{
-    /* Loops indexes */
-    int i, j, k;
-
-    /* Gaussian separable kernels */
-    float GaussX[16];
-    float GaussY[16];
-    float *KerX;
-    float *KerY;
-
-    /* Buffers for Sobel calculations */
-    float *MemX[2];
-    float *MemY[2];
-
-    float ConvX, ConvY;
-    float GradX, GradY, GradT;
-
-    int winWidth = winSize.width;
-    int winHeight = winSize.height;
-
-    int imageWidth = imgSize.width;
-    int imageHeight = imgSize.height;
-
-    int HorRadius = (winWidth - 1) >> 1;
-    int VerRadius = (winHeight - 1) >> 1;
-
-    int PixelLine;
-    int ConvLine;
-
-    int BufferAddress;
-
-    int BufferHeight = 0;
-    int BufferWidth;
-    int BufferSize;
-
-    /* buffers derivatives product */
-    icvDerProduct *II;
-
-    /* buffers for gaussian horisontal convolution */
-    icvDerProduct *WII;
-
-    /* variables for storing number of first pixel of image line */
-    int Line1;
-    int Line2;
-    int Line3;
-
-    /* we must have 2*2 linear system coeffs
-       | A1B2  B1 |  {u}   {C1}   {0}
-       |          |  { } + {  } = { }
-       | A2  A1B2 |  {v}   {C2}   {0}
-     */
-    float A1B2, A2, B1, C1, C2;
-
-    int pixNumber;
-
-    /* auxiliary */
-    int NoMem = 0;
-
-    velStep /= sizeof(velocityX[0]);
-
-    /* Checking bad arguments */
-    if( imgA == NULL )
-        return CV_NULLPTR_ERR;
-    if( imgB == NULL )
-        return CV_NULLPTR_ERR;
-
-    if( imageHeight < winHeight )
-        return CV_BADSIZE_ERR;
-    if( imageWidth < winWidth )
-        return CV_BADSIZE_ERR;
-
-    if( winHeight >= 16 )
-        return CV_BADSIZE_ERR;
-    if( winWidth >= 16 )
-        return CV_BADSIZE_ERR;
-
-    if( !(winHeight & 1) )
-        return CV_BADSIZE_ERR;
-    if( !(winWidth & 1) )
-        return CV_BADSIZE_ERR;
-
-    BufferHeight = winHeight;
-    BufferWidth = imageWidth;
-
-    /****************************************************************************************/
-    /* Computing Gaussian coeffs                                                            */
-    /****************************************************************************************/
-    GaussX[0] = 1;
-    GaussY[0] = 1;
-    for( i = 1; i < winWidth; i++ )
-    {
-        GaussX[i] = 1;
-        for( j = i - 1; j > 0; j-- )
-        {
-            GaussX[j] += GaussX[j - 1];
-        }
-    }
-    for( i = 1; i < winHeight; i++ )
-    {
-        GaussY[i] = 1;
-        for( j = i - 1; j > 0; j-- )
-        {
-            GaussY[j] += GaussY[j - 1];
-        }
-    }
-    KerX = &GaussX[HorRadius];
-    KerY = &GaussY[VerRadius];
-
-    /****************************************************************************************/
-    /* Allocating memory for all buffers                                                    */
-    /****************************************************************************************/
-    for( k = 0; k < 2; k++ )
-    {
-        MemX[k] = (float *) cvAlloc( (imgSize.height) * sizeof( float ));
-
-        if( MemX[k] == NULL )
-            NoMem = 1;
-        MemY[k] = (float *) cvAlloc( (imgSize.width) * sizeof( float ));
-
-        if( MemY[k] == NULL )
-            NoMem = 1;
-    }
-
-    BufferSize = BufferHeight * BufferWidth;
-
-    II = (icvDerProduct *) cvAlloc( BufferSize * sizeof( icvDerProduct ));
-    WII = (icvDerProduct *) cvAlloc( BufferSize * sizeof( icvDerProduct ));
-
-
-    if( (II == NULL) || (WII == NULL) )
-        NoMem = 1;
-
-    if( NoMem )
-    {
-        for( k = 0; k < 2; k++ )
-        {
-            if( MemX[k] )
-                cvFree( &MemX[k] );
-
-            if( MemY[k] )
-                cvFree( &MemY[k] );
-        }
-        if( II )
-            cvFree( &II );
-        if( WII )
-            cvFree( &WII );
-
-        return CV_OUTOFMEM_ERR;
-    }
-
-    /****************************************************************************************/
-    /*        Calculate first line of memX and memY                                         */
-    /****************************************************************************************/
-    MemY[0][0] = MemY[1][0] = CONV( imgA[0], imgA[0], imgA[1] );
-    MemX[0][0] = MemX[1][0] = CONV( imgA[0], imgA[0], imgA[imgStep] );
-
-    for( j = 1; j < imageWidth - 1; j++ )
-    {
-        MemY[0][j] = MemY[1][j] = CONV( imgA[j - 1], imgA[j], imgA[j + 1] );
-    }
-
-    pixNumber = imgStep;
-    for( i = 1; i < imageHeight - 1; i++ )
-    {
-        MemX[0][i] = MemX[1][i] = CONV( imgA[pixNumber - imgStep],
-                                        imgA[pixNumber], imgA[pixNumber + imgStep] );
-        pixNumber += imgStep;
-    }
-
-    MemY[0][imageWidth - 1] =
-        MemY[1][imageWidth - 1] = CONV( imgA[imageWidth - 2],
-                                        imgA[imageWidth - 1], imgA[imageWidth - 1] );
-
-    MemX[0][imageHeight - 1] =
-        MemX[1][imageHeight - 1] = CONV( imgA[pixNumber - imgStep],
-                                         imgA[pixNumber], imgA[pixNumber] );
-
-
-    /****************************************************************************************/
-    /*    begin scan image, calc derivatives and solve system                               */
-    /****************************************************************************************/
-
-    PixelLine = -VerRadius;
-    ConvLine = 0;
-    BufferAddress = -BufferWidth;
-
-    while( PixelLine < imageHeight )
-    {
-        if( ConvLine < imageHeight )
-        {
-            /*Here we calculate derivatives for line of image */
-            int address;
-
-            i = ConvLine;
-            int L1 = i - 1;
-            int L2 = i;
-            int L3 = i + 1;
-
-            int memYline = L3 & 1;
-
-            if( L1 < 0 )
-                L1 = 0;
-            if( L3 >= imageHeight )
-                L3 = imageHeight - 1;
-
-            BufferAddress += BufferWidth;
-            BufferAddress -= ((BufferAddress >= BufferSize) ? 0xffffffff : 0) & BufferSize;
-
-            address = BufferAddress;
-
-            Line1 = L1 * imgStep;
-            Line2 = L2 * imgStep;
-            Line3 = L3 * imgStep;
-
-            /* Process first pixel */
-            ConvX = CONV( imgA[Line1 + 1], imgA[Line2 + 1], imgA[Line3 + 1] );
-            ConvY = CONV( imgA[Line3], imgA[Line3], imgA[Line3 + 1] );
-
-            GradY = ConvY - MemY[memYline][0];
-            GradX = ConvX - MemX[1][L2];
-
-            MemY[memYline][0] = ConvY;
-            MemX[1][L2] = ConvX;
-
-            GradT = (float) (imgB[Line2] - imgA[Line2]);
-
-            II[address].xx = GradX * GradX;
-            II[address].xy = GradX * GradY;
-            II[address].yy = GradY * GradY;
-            II[address].xt = GradX * GradT;
-            II[address].yt = GradY * GradT;
-            address++;
-            /* Process middle of line */
-            for( j = 1; j < imageWidth - 1; j++ )
-            {
-                ConvX = CONV( imgA[Line1 + j + 1], imgA[Line2 + j + 1], imgA[Line3 + j + 1] );
-                ConvY = CONV( imgA[Line3 + j - 1], imgA[Line3 + j], imgA[Line3 + j + 1] );
-
-                GradY = ConvY - MemY[memYline][j];
-                GradX = ConvX - MemX[(j - 1) & 1][L2];
-
-                MemY[memYline][j] = ConvY;
-                MemX[(j - 1) & 1][L2] = ConvX;
-
-                GradT = (float) (imgB[Line2 + j] - imgA[Line2 + j]);
-
-                II[address].xx = GradX * GradX;
-                II[address].xy = GradX * GradY;
-                II[address].yy = GradY * GradY;
-                II[address].xt = GradX * GradT;
-                II[address].yt = GradY * GradT;
-
-                address++;
-            }
-            /* Process last pixel of line */
-            ConvX = CONV( imgA[Line1 + imageWidth - 1], imgA[Line2 + imageWidth - 1],
-                          imgA[Line3 + imageWidth - 1] );
-
-            ConvY = CONV( imgA[Line3 + imageWidth - 2], imgA[Line3 + imageWidth - 1],
-                          imgA[Line3 + imageWidth - 1] );
-
-
-            GradY = ConvY - MemY[memYline][imageWidth - 1];
-            GradX = ConvX - MemX[(imageWidth - 2) & 1][L2];
-
-            MemY[memYline][imageWidth - 1] = ConvY;
-
-            GradT = (float) (imgB[Line2 + imageWidth - 1] - imgA[Line2 + imageWidth - 1]);
-
-            II[address].xx = GradX * GradX;
-            II[address].xy = GradX * GradY;
-            II[address].yy = GradY * GradY;
-            II[address].xt = GradX * GradT;
-            II[address].yt = GradY * GradT;
-            address++;
-
-            /* End of derivatives for line */
-
-            /****************************************************************************************/
-            /* ---------Calculating horizontal convolution of processed line----------------------- */
-            /****************************************************************************************/
-            address -= BufferWidth;
-            /* process first HorRadius pixels */
-            for( j = 0; j < HorRadius; j++ )
-            {
-                int jj;
-
-                WII[address].xx = 0;
-                WII[address].xy = 0;
-                WII[address].yy = 0;
-                WII[address].xt = 0;
-                WII[address].yt = 0;
-
-                for( jj = -j; jj <= HorRadius; jj++ )
-                {
-                    float Ker = KerX[jj];
-
-                    WII[address].xx += II[address + jj].xx * Ker;
-                    WII[address].xy += II[address + jj].xy * Ker;
-                    WII[address].yy += II[address + jj].yy * Ker;
-                    WII[address].xt += II[address + jj].xt * Ker;
-                    WII[address].yt += II[address + jj].yt * Ker;
-                }
-                address++;
-            }
-            /* process inner part of line */
-            for( j = HorRadius; j < imageWidth - HorRadius; j++ )
-            {
-                int jj;
-                float Ker0 = KerX[0];
-
-                WII[address].xx = 0;
-                WII[address].xy = 0;
-                WII[address].yy = 0;
-                WII[address].xt = 0;
-                WII[address].yt = 0;
-
-                for( jj = 1; jj <= HorRadius; jj++ )
-                {
-                    float Ker = KerX[jj];
-
-                    WII[address].xx += (II[address - jj].xx + II[address + jj].xx) * Ker;
-                    WII[address].xy += (II[address - jj].xy + II[address + jj].xy) * Ker;
-                    WII[address].yy += (II[address - jj].yy + II[address + jj].yy) * Ker;
-                    WII[address].xt += (II[address - jj].xt + II[address + jj].xt) * Ker;
-                    WII[address].yt += (II[address - jj].yt + II[address + jj].yt) * Ker;
-                }
-                WII[address].xx += II[address].xx * Ker0;
-                WII[address].xy += II[address].xy * Ker0;
-                WII[address].yy += II[address].yy * Ker0;
-                WII[address].xt += II[address].xt * Ker0;
-                WII[address].yt += II[address].yt * Ker0;
-
-                address++;
-            }
-            /* process right side */
-            for( j = imageWidth - HorRadius; j < imageWidth; j++ )
-            {
-                int jj;
-
-                WII[address].xx = 0;
-                WII[address].xy = 0;
-                WII[address].yy = 0;
-                WII[address].xt = 0;
-                WII[address].yt = 0;
-
-                for( jj = -HorRadius; jj < imageWidth - j; jj++ )
-                {
-                    float Ker = KerX[jj];
-
-                    WII[address].xx += II[address + jj].xx * Ker;
-                    WII[address].xy += II[address + jj].xy * Ker;
-                    WII[address].yy += II[address + jj].yy * Ker;
-                    WII[address].xt += II[address + jj].xt * Ker;
-                    WII[address].yt += II[address + jj].yt * Ker;
-                }
-                address++;
-            }
-        }
-
-        /****************************************************************************************/
-        /*  Calculating velocity line                                                           */
-        /****************************************************************************************/
-        if( PixelLine >= 0 )
-        {
-            int USpace;
-            int BSpace;
-            int address;
-
-            if( PixelLine < VerRadius )
-                USpace = PixelLine;
-            else
-                USpace = VerRadius;
-
-            if( PixelLine >= imageHeight - VerRadius )
-                BSpace = imageHeight - PixelLine - 1;
-            else
-                BSpace = VerRadius;
-
-            address = ((PixelLine - USpace) % BufferHeight) * BufferWidth;
-            for( j = 0; j < imageWidth; j++ )
-            {
-                int addr = address;
-
-                A1B2 = 0;
-                A2 = 0;
-                B1 = 0;
-                C1 = 0;
-                C2 = 0;
-
-                for( i = -USpace; i <= BSpace; i++ )
-                {
-                    A2 += WII[addr + j].xx * KerY[i];
-                    A1B2 += WII[addr + j].xy * KerY[i];
-                    B1 += WII[addr + j].yy * KerY[i];
-                    C2 += WII[addr + j].xt * KerY[i];
-                    C1 += WII[addr + j].yt * KerY[i];
-
-                    addr += BufferWidth;
-                    addr -= ((addr >= BufferSize) ? 0xffffffff : 0) & BufferSize;
-                }
-                /****************************************************************************************\
-                * Solve Linear System                                                                    *
-                \****************************************************************************************/
-                {
-                    float delta = (A1B2 * A1B2 - A2 * B1);
-
-                    if( delta )
-                    {
-                        /* system is not singular - solving by Kramer method */
-                        float deltaX;
-                        float deltaY;
-                        float Idelta = 8 / delta;
-
-                        deltaX = -(C1 * A1B2 - C2 * B1);
-                        deltaY = -(A1B2 * C2 - A2 * C1);
-
-                        velocityX[j] = deltaX * Idelta;
-                        velocityY[j] = deltaY * Idelta;
-                    }
-                    else
-                    {
-                        /* singular system - find optical flow in gradient direction */
-                        float Norm = (A1B2 + A2) * (A1B2 + A2) + (B1 + A1B2) * (B1 + A1B2);
-
-                        if( Norm )
-                        {
-                            float IGradNorm = 8 / Norm;
-                            float temp = -(C1 + C2) * IGradNorm;
-
-                            velocityX[j] = (A1B2 + A2) * temp;
-                            velocityY[j] = (B1 + A1B2) * temp;
-
-                        }
-                        else
-                        {
-                            velocityX[j] = 0;
-                            velocityY[j] = 0;
-                        }
-                    }
-                }
-                /****************************************************************************************\
-                * End of Solving Linear System                                                           *
-                \****************************************************************************************/
-            }                   /*for */
-            velocityX += velStep;
-            velocityY += velStep;
-        }                       /*for */
-        PixelLine++;
-        ConvLine++;
-    }
-
-    /* Free memory */
-    for( k = 0; k < 2; k++ )
-    {
-        cvFree( &MemX[k] );
-        cvFree( &MemY[k] );
-    }
-    cvFree( &II );
-    cvFree( &WII );
-
-    return CV_OK;
-} /*icvCalcOpticalFlowLK_8u32fR*/
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name:    cvCalcOpticalFlowLK
-//    Purpose: Optical flow implementation
-//    Context:
-//    Parameters:
-//             srcA, srcB - source image
-//             velx, vely - destination image
-//    Returns:
-//
-//    Notes:
-//F*/
-CV_IMPL void
-cvCalcOpticalFlowLK( const void* srcarrA, const void* srcarrB, CvSize winSize,
-                     void* velarrx, void* velarry )
-{
-    CvMat stubA, *srcA = cvGetMat( srcarrA, &stubA );
-    CvMat stubB, *srcB = cvGetMat( srcarrB, &stubB );
-    CvMat stubx, *velx = cvGetMat( velarrx, &stubx );
-    CvMat stuby, *vely = cvGetMat( velarry, &stuby );
-
-    if( !CV_ARE_TYPES_EQ( srcA, srcB ))
-        CV_Error( CV_StsUnmatchedFormats, "Source images have different formats" );
-
-    if( !CV_ARE_TYPES_EQ( velx, vely ))
-        CV_Error( CV_StsUnmatchedFormats, "Destination images have different formats" );
-
-    if( !CV_ARE_SIZES_EQ( srcA, srcB ) ||
-        !CV_ARE_SIZES_EQ( velx, vely ) ||
-        !CV_ARE_SIZES_EQ( srcA, velx ))
-        CV_Error( CV_StsUnmatchedSizes, "" );
-
-    if( CV_MAT_TYPE( srcA->type ) != CV_8UC1 ||
-        CV_MAT_TYPE( velx->type ) != CV_32FC1 )
-        CV_Error( CV_StsUnsupportedFormat, "Source images must have 8uC1 type and "
-                                           "destination images must have 32fC1 type" );
-
-    if( srcA->step != srcB->step || velx->step != vely->step )
-        CV_Error( CV_BadStep, "source and destination images have different step" );
-
-    IPPI_CALL( icvCalcOpticalFlowLK_8u32fR( (uchar*)srcA->data.ptr, (uchar*)srcB->data.ptr,
-                                            srcA->step, cvGetMatSize( srcA ), winSize,
-                                            velx->data.fl, vely->data.fl, velx->step ));
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/pgh.cpp b/modules/legacy/src/pgh.cpp
deleted file mode 100644 (file)
index 101ab11..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-#define _CV_ACOS_TABLE_SIZE  513
-
-static const float icv_acos_table[_CV_ACOS_TABLE_SIZE] = {
-    3.14159265f, 3.05317551f, 3.01651113f, 2.98834964f, 2.96458497f, 2.94362719f,
-    2.92466119f, 2.90720289f, 2.89093699f, 2.87564455f, 2.86116621f, 2.84738169f,
-    2.83419760f, 2.82153967f, 2.80934770f, 2.79757211f, 2.78617145f, 2.77511069f,
-    2.76435988f, 2.75389319f, 2.74368816f, 2.73372510f, 2.72398665f, 2.71445741f,
-    2.70512362f, 2.69597298f, 2.68699438f, 2.67817778f, 2.66951407f, 2.66099493f,
-    2.65261279f, 2.64436066f, 2.63623214f, 2.62822133f, 2.62032277f, 2.61253138f,
-    2.60484248f, 2.59725167f, 2.58975488f, 2.58234828f, 2.57502832f, 2.56779164f,
-    2.56063509f, 2.55355572f, 2.54655073f, 2.53961750f, 2.53275354f, 2.52595650f,
-    2.51922417f, 2.51255441f, 2.50594525f, 2.49939476f, 2.49290115f, 2.48646269f,
-    2.48007773f, 2.47374472f, 2.46746215f, 2.46122860f, 2.45504269f, 2.44890314f,
-    2.44280867f, 2.43675809f, 2.43075025f, 2.42478404f, 2.41885841f, 2.41297232f,
-    2.40712480f, 2.40131491f, 2.39554173f, 2.38980439f, 2.38410204f, 2.37843388f,
-    2.37279910f, 2.36719697f, 2.36162673f, 2.35608768f, 2.35057914f, 2.34510044f,
-    2.33965094f, 2.33423003f, 2.32883709f, 2.32347155f, 2.31813284f, 2.31282041f,
-    2.30753373f, 2.30227228f, 2.29703556f, 2.29182309f, 2.28663439f, 2.28146900f,
-    2.27632647f, 2.27120637f, 2.26610827f, 2.26103177f, 2.25597646f, 2.25094195f,
-    2.24592786f, 2.24093382f, 2.23595946f, 2.23100444f, 2.22606842f, 2.22115104f,
-    2.21625199f, 2.21137096f, 2.20650761f, 2.20166166f, 2.19683280f, 2.19202074f,
-    2.18722520f, 2.18244590f, 2.17768257f, 2.17293493f, 2.16820274f, 2.16348574f,
-    2.15878367f, 2.15409630f, 2.14942338f, 2.14476468f, 2.14011997f, 2.13548903f,
-    2.13087163f, 2.12626757f, 2.12167662f, 2.11709859f, 2.11253326f, 2.10798044f,
-    2.10343994f, 2.09891156f, 2.09439510f, 2.08989040f, 2.08539725f, 2.08091550f,
-    2.07644495f, 2.07198545f, 2.06753681f, 2.06309887f, 2.05867147f, 2.05425445f,
-    2.04984765f, 2.04545092f, 2.04106409f, 2.03668703f, 2.03231957f, 2.02796159f,
-    2.02361292f, 2.01927344f, 2.01494300f, 2.01062146f, 2.00630870f, 2.00200457f,
-    1.99770895f, 1.99342171f, 1.98914271f, 1.98487185f, 1.98060898f, 1.97635399f,
-    1.97210676f, 1.96786718f, 1.96363511f, 1.95941046f, 1.95519310f, 1.95098292f,
-    1.94677982f, 1.94258368f, 1.93839439f, 1.93421185f, 1.93003595f, 1.92586659f,
-    1.92170367f, 1.91754708f, 1.91339673f, 1.90925250f, 1.90511432f, 1.90098208f,
-    1.89685568f, 1.89273503f, 1.88862003f, 1.88451060f, 1.88040664f, 1.87630806f,
-    1.87221477f, 1.86812668f, 1.86404371f, 1.85996577f, 1.85589277f, 1.85182462f,
-    1.84776125f, 1.84370256f, 1.83964848f, 1.83559892f, 1.83155381f, 1.82751305f,
-    1.82347658f, 1.81944431f, 1.81541617f, 1.81139207f, 1.80737194f, 1.80335570f,
-    1.79934328f, 1.79533460f, 1.79132959f, 1.78732817f, 1.78333027f, 1.77933581f,
-    1.77534473f, 1.77135695f, 1.76737240f, 1.76339101f, 1.75941271f, 1.75543743f,
-    1.75146510f, 1.74749565f, 1.74352900f, 1.73956511f, 1.73560389f, 1.73164527f,
-    1.72768920f, 1.72373560f, 1.71978441f, 1.71583556f, 1.71188899f, 1.70794462f,
-    1.70400241f, 1.70006228f, 1.69612416f, 1.69218799f, 1.68825372f, 1.68432127f,
-    1.68039058f, 1.67646160f, 1.67253424f, 1.66860847f, 1.66468420f, 1.66076139f,
-    1.65683996f, 1.65291986f, 1.64900102f, 1.64508338f, 1.64116689f, 1.63725148f,
-    1.63333709f, 1.62942366f, 1.62551112f, 1.62159943f, 1.61768851f, 1.61377831f,
-    1.60986877f, 1.60595982f, 1.60205142f, 1.59814349f, 1.59423597f, 1.59032882f,
-    1.58642196f, 1.58251535f, 1.57860891f, 1.57470259f, 1.57079633f, 1.56689007f,
-    1.56298375f, 1.55907731f, 1.55517069f, 1.55126383f, 1.54735668f, 1.54344917f,
-    1.53954124f, 1.53563283f, 1.53172389f, 1.52781434f, 1.52390414f, 1.51999323f,
-    1.51608153f, 1.51216900f, 1.50825556f, 1.50434117f, 1.50042576f, 1.49650927f,
-    1.49259163f, 1.48867280f, 1.48475270f, 1.48083127f, 1.47690845f, 1.47298419f,
-    1.46905841f, 1.46513106f, 1.46120207f, 1.45727138f, 1.45333893f, 1.44940466f,
-    1.44546850f, 1.44153038f, 1.43759024f, 1.43364803f, 1.42970367f, 1.42575709f,
-    1.42180825f, 1.41785705f, 1.41390346f, 1.40994738f, 1.40598877f, 1.40202755f,
-    1.39806365f, 1.39409701f, 1.39012756f, 1.38615522f, 1.38217994f, 1.37820164f,
-    1.37422025f, 1.37023570f, 1.36624792f, 1.36225684f, 1.35826239f, 1.35426449f,
-    1.35026307f, 1.34625805f, 1.34224937f, 1.33823695f, 1.33422072f, 1.33020059f,
-    1.32617649f, 1.32214834f, 1.31811607f, 1.31407960f, 1.31003885f, 1.30599373f,
-    1.30194417f, 1.29789009f, 1.29383141f, 1.28976803f, 1.28569989f, 1.28162688f,
-    1.27754894f, 1.27346597f, 1.26937788f, 1.26528459f, 1.26118602f, 1.25708205f,
-    1.25297262f, 1.24885763f, 1.24473698f, 1.24061058f, 1.23647833f, 1.23234015f,
-    1.22819593f, 1.22404557f, 1.21988898f, 1.21572606f, 1.21155670f, 1.20738080f,
-    1.20319826f, 1.19900898f, 1.19481283f, 1.19060973f, 1.18639955f, 1.18218219f,
-    1.17795754f, 1.17372548f, 1.16948589f, 1.16523866f, 1.16098368f, 1.15672081f,
-    1.15244994f, 1.14817095f, 1.14388370f, 1.13958808f, 1.13528396f, 1.13097119f,
-    1.12664966f, 1.12231921f, 1.11797973f, 1.11363107f, 1.10927308f, 1.10490563f,
-    1.10052856f, 1.09614174f, 1.09174500f, 1.08733820f, 1.08292118f, 1.07849378f,
-    1.07405585f, 1.06960721f, 1.06514770f, 1.06067715f, 1.05619540f, 1.05170226f,
-    1.04719755f, 1.04268110f, 1.03815271f, 1.03361221f, 1.02905939f, 1.02449407f,
-    1.01991603f, 1.01532509f, 1.01072102f, 1.00610363f, 1.00147268f, 0.99682798f,
-    0.99216928f, 0.98749636f, 0.98280898f, 0.97810691f, 0.97338991f, 0.96865772f,
-    0.96391009f, 0.95914675f, 0.95436745f, 0.94957191f, 0.94475985f, 0.93993099f,
-    0.93508504f, 0.93022170f, 0.92534066f, 0.92044161f, 0.91552424f, 0.91058821f,
-    0.90563319f, 0.90065884f, 0.89566479f, 0.89065070f, 0.88561619f, 0.88056088f,
-    0.87548438f, 0.87038629f, 0.86526619f, 0.86012366f, 0.85495827f, 0.84976956f,
-    0.84455709f, 0.83932037f, 0.83405893f, 0.82877225f, 0.82345981f, 0.81812110f,
-    0.81275556f, 0.80736262f, 0.80194171f, 0.79649221f, 0.79101352f, 0.78550497f,
-    0.77996593f, 0.77439569f, 0.76879355f, 0.76315878f, 0.75749061f, 0.75178826f,
-    0.74605092f, 0.74027775f, 0.73446785f, 0.72862033f, 0.72273425f, 0.71680861f,
-    0.71084240f, 0.70483456f, 0.69878398f, 0.69268952f, 0.68654996f, 0.68036406f,
-    0.67413051f, 0.66784794f, 0.66151492f, 0.65512997f, 0.64869151f, 0.64219789f,
-    0.63564741f, 0.62903824f, 0.62236849f, 0.61563615f, 0.60883911f, 0.60197515f,
-    0.59504192f, 0.58803694f, 0.58095756f, 0.57380101f, 0.56656433f, 0.55924437f,
-    0.55183778f, 0.54434099f, 0.53675018f, 0.52906127f, 0.52126988f, 0.51337132f,
-    0.50536051f, 0.49723200f, 0.48897987f, 0.48059772f, 0.47207859f, 0.46341487f,
-    0.45459827f, 0.44561967f, 0.43646903f, 0.42713525f, 0.41760600f, 0.40786755f,
-    0.39790449f, 0.38769946f, 0.37723277f, 0.36648196f, 0.35542120f, 0.34402054f,
-    0.33224495f, 0.32005298f, 0.30739505f, 0.29421096f, 0.28042645f, 0.26594810f,
-    0.25065566f, 0.23438976f, 0.21693146f, 0.19796546f, 0.17700769f, 0.15324301f,
-    0.12508152f, 0.08841715f, 0.00000000f
-};
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: icvCalcPGH
-//    Purpose:
-//      Calculates PGH(pairwise geometric histogram) for contour given.
-//    Context:
-//    Parameters:
-//      contour  - pointer to input contour object.
-//      pgh      - output histogram
-//      ang_dim  - number of angle bins (vertical size of histogram)
-//      dist_dim - number of distance bins (horizontal size of histogram)
-//    Returns:
-//      CV_OK or error code
-//    Notes:
-//F*/
-static CvStatus
-icvCalcPGH( const CvSeq * contour, float *pgh, int angle_dim, int dist_dim )
-{
-    char local_buffer[(1 << 14) + 32];
-    float *local_buffer_ptr = (float *)cvAlignPtr(local_buffer,32);
-    float *buffer = local_buffer_ptr;
-    double angle_scale = (angle_dim - 0.51) / icv_acos_table[0];
-    double dist_scale = DBL_EPSILON;
-    int buffer_size;
-    int i, count, pass;
-    int *pghi = (int *) pgh;
-    int hist_size = angle_dim * dist_dim;
-    CvSeqReader reader1, reader2;       /* external and internal readers */
-
-    if( !contour || !pgh )
-        return CV_NULLPTR_ERR;
-
-    if( angle_dim <= 0 || angle_dim > 180 || dist_dim <= 0 )
-        return CV_BADRANGE_ERR;
-
-    if( !CV_IS_SEQ_POINT_SET( contour ))
-        return CV_BADFLAG_ERR;
-
-    memset( pgh, 0, hist_size * sizeof( pgh[0] ));
-
-    count = contour->total;
-
-    /* allocate buffer for distances */
-    buffer_size = count * sizeof( float );
-
-    if( buffer_size > (int)sizeof(local_buffer) - 32 )
-    {
-        buffer = (float *) cvAlloc( buffer_size );
-        if( !buffer )
-            return CV_OUTOFMEM_ERR;
-    }
-
-    cvStartReadSeq( contour, &reader1, 0 );
-    cvStartReadSeq( contour, &reader2, 0 );
-
-    /* calc & store squared edge lengths, calculate maximal distance between edges */
-    for( i = 0; i < count; i++ )
-    {
-        CvPoint pt1, pt2;
-        double dx, dy;
-
-        CV_READ_EDGE( pt1, pt2, reader1 );
-
-        dx = pt2.x - pt1.x;
-        dy = pt2.y - pt1.y;
-        buffer[i] = (float)(1./sqrt(dx * dx + dy * dy));
-    }
-
-    /*
-       do 2 passes.
-       First calculates maximal distance.
-       Second calculates histogram itself.
-     */
-    for( pass = 1; pass <= 2; pass++ )
-    {
-        double dist_coeff = 0, angle_coeff = 0;
-
-        /* run external loop */
-        for( i = 0; i < count; i++ )
-        {
-            CvPoint pt1, pt2;
-            int dx, dy;
-            int dist = 0;
-
-            CV_READ_EDGE( pt1, pt2, reader1 );
-
-            dx = pt2.x - pt1.x;
-            dy = pt2.y - pt1.y;
-
-            if( (dx | dy) != 0 )
-            {
-                int j;
-
-                if( pass == 2 )
-                {
-                    dist_coeff = buffer[i] * dist_scale;
-                    angle_coeff = buffer[i] * (_CV_ACOS_TABLE_SIZE / 2);
-                }
-
-                /* run internal loop (for current edge) */
-                for( j = 0; j < count; j++ )
-                {
-                    CvPoint pt3, pt4;
-
-                    CV_READ_EDGE( pt3, pt4, reader2 );
-
-                    if( i != j )        /* process edge pair */
-                    {
-                        int d1 = (pt3.y - pt1.y) * dx - (pt3.x - pt1.x) * dy;
-                        int d2 = (pt4.y - pt1.y) * dx - (pt2.x - pt1.x) * dy;
-                        int cross_flag;
-                        int *hist_row = 0;
-
-                        if( pass == 2 )
-                        {
-                            int dp = (pt4.x - pt3.x) * dx + (pt4.y - pt3.y) * dy;
-
-                            dp = cvRound( dp * angle_coeff * buffer[j] ) +
-                                (_CV_ACOS_TABLE_SIZE / 2);
-                            dp = MAX( dp, 0 );
-                            dp = MIN( dp, _CV_ACOS_TABLE_SIZE - 1 );
-                            hist_row = pghi + dist_dim *
-                                cvRound( icv_acos_table[dp] * angle_scale );
-
-                            d1 = cvRound( d1 * dist_coeff );
-                            d2 = cvRound( d2 * dist_coeff );
-                        }
-
-                        cross_flag = (d1 ^ d2) < 0;
-
-                        d1 = CV_IABS( d1 );
-                        d2 = CV_IABS( d2 );
-
-                        if( pass == 2 )
-                        {
-                            if( d1 >= dist_dim )
-                                d1 = dist_dim - 1;
-                            if( d2 >= dist_dim )
-                                d2 = dist_dim - 1;
-
-                            if( !cross_flag )
-                            {
-                                if( d1 > d2 )   /* make d1 <= d2 */
-                                {
-                                    d1 ^= d2;
-                                    d2 ^= d1;
-                                    d1 ^= d2;
-                                }
-
-                                for( ; d1 <= d2; d1++ )
-                                    hist_row[d1]++;
-                            }
-                            else
-                            {
-                                for( ; d1 >= 0; d1-- )
-                                    hist_row[d1]++;
-                                for( ; d2 >= 0; d2-- )
-                                    hist_row[d2]++;
-                            }
-                        }
-                        else    /* 1st pass */
-                        {
-                            d1 = CV_IMAX( d1, d2 );
-                            dist = CV_IMAX( dist, d1 );
-                        }
-                    }           /* end of processing of edge pair */
-
-                }               /* end of internal loop */
-
-                if( pass == 1 )
-                {
-                    double scale = dist * buffer[i];
-
-                    dist_scale = MAX( dist_scale, scale );
-                }
-            }
-        }                       /* end of external loop */
-
-        if( pass == 1 )
-        {
-            dist_scale = (dist_dim - 0.51) / dist_scale;
-        }
-
-    }                           /* end of pass on loops */
-
-
-    /* convert hist to floats */
-    for( i = 0; i < hist_size; i++ )
-    {
-        ((float *) pghi)[i] = (float) pghi[i];
-    }
-
-    if( buffer != local_buffer_ptr )
-        cvFree( &buffer );
-
-    return CV_OK;
-}
-
-
-CV_IMPL void
-cvCalcPGH( const CvSeq * contour, CvHistogram * hist )
-{
-    int size[CV_MAX_DIM];
-    int dims;
-
-    if( !CV_IS_HIST(hist))
-        CV_Error( CV_StsBadArg, "The histogram header is invalid " );
-
-    if( CV_IS_SPARSE_HIST( hist ))
-        CV_Error( CV_StsUnsupportedFormat, "Sparse histogram are not supported" );
-
-    dims = cvGetDims( hist->bins, size );
-
-    if( dims != 2 )
-        CV_Error( CV_StsBadSize, "The histogram must be two-dimensional" );
-
-    if( !CV_IS_SEQ_POINT_SET( contour ) || CV_SEQ_ELTYPE( contour ) != CV_32SC2 )
-        CV_Error( CV_StsUnsupportedFormat, "The contour is not valid or the point type is not supported" );
-
-    IPPI_CALL( icvCalcPGH( contour, ((CvMatND*)(hist->bins))->data.fl, size[0], size[1] ));
-}
-
-
-/* End of file. */
diff --git a/modules/legacy/src/planardetect.cpp b/modules/legacy/src/planardetect.cpp
deleted file mode 100644 (file)
index 304e800..0000000
+++ /dev/null
@@ -1,1582 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "opencv2/calib3d.hpp"
-#include <stdio.h>
-
-namespace cv
-{
-
-/*
-  The code below implements keypoint detector, fern-based point classifier and a planar object detector.
-
-  References:
-   1. Mustafa Özuysal, Michael Calonder, Vincent Lepetit, Pascal Fua,
-      "Fast KeyPoint Recognition Using Random Ferns,"
-      IEEE Transactions on Pattern Analysis and Machine Intelligence, 15 Jan. 2009.
-
-   2. Vincent Lepetit, Pascal Fua,
-      "Towards Recognizing Feature Points Using Classification Trees,"
-      Technical Report IC/2004/74, EPFL, 2004.
-*/
-
-const int progressBarSize = 50;
-
-//////////////////////////// Patch Generator //////////////////////////////////
-
-static const double DEFAULT_BACKGROUND_MIN = 0;
-static const double DEFAULT_BACKGROUND_MAX = 256;
-static const double DEFAULT_NOISE_RANGE = 5;
-static const double DEFAULT_LAMBDA_MIN = 0.6;
-static const double DEFAULT_LAMBDA_MAX = 1.5;
-static const double DEFAULT_THETA_MIN = -CV_PI;
-static const double DEFAULT_THETA_MAX = CV_PI;
-static const double DEFAULT_PHI_MIN = -CV_PI;
-static const double DEFAULT_PHI_MAX = CV_PI;
-
-PatchGenerator::PatchGenerator()
-: backgroundMin(DEFAULT_BACKGROUND_MIN), backgroundMax(DEFAULT_BACKGROUND_MAX),
-noiseRange(DEFAULT_NOISE_RANGE), randomBlur(true), lambdaMin(DEFAULT_LAMBDA_MIN),
-lambdaMax(DEFAULT_LAMBDA_MAX), thetaMin(DEFAULT_THETA_MIN),
-thetaMax(DEFAULT_THETA_MAX), phiMin(DEFAULT_PHI_MIN),
-phiMax(DEFAULT_PHI_MAX)
-{
-}
-
-
-PatchGenerator::PatchGenerator(double _backgroundMin, double _backgroundMax,
-                               double _noiseRange, bool _randomBlur,
-                               double _lambdaMin, double _lambdaMax,
-                               double _thetaMin, double _thetaMax,
-                               double _phiMin, double _phiMax )
-: backgroundMin(_backgroundMin), backgroundMax(_backgroundMax),
-noiseRange(_noiseRange), randomBlur(_randomBlur),
-lambdaMin(_lambdaMin), lambdaMax(_lambdaMax),
-thetaMin(_thetaMin), thetaMax(_thetaMax),
-phiMin(_phiMin), phiMax(_phiMax)
-{
-}
-
-
-void PatchGenerator::generateRandomTransform(Point2f srcCenter, Point2f dstCenter,
-                                             Mat& transform, RNG& rng, bool inverse) const
-{
-    double lambda1 = rng.uniform(lambdaMin, lambdaMax);
-    double lambda2 = rng.uniform(lambdaMin, lambdaMax);
-    double theta = rng.uniform(thetaMin, thetaMax);
-    double phi = rng.uniform(phiMin, phiMax);
-
-    // Calculate random parameterized affine transformation A,
-    // A = T(patch center) * R(theta) * R(phi)' *
-    //     S(lambda1, lambda2) * R(phi) * T(-pt)
-    double st = sin(theta);
-    double ct = cos(theta);
-    double sp = sin(phi);
-    double cp = cos(phi);
-    double c2p = cp*cp;
-    double s2p = sp*sp;
-
-    double A = lambda1*c2p + lambda2*s2p;
-    double B = (lambda2 - lambda1)*sp*cp;
-    double C = lambda1*s2p + lambda2*c2p;
-
-    double Ax_plus_By = A*srcCenter.x + B*srcCenter.y;
-    double Bx_plus_Cy = B*srcCenter.x + C*srcCenter.y;
-
-    transform.create(2, 3, CV_64F);
-    Mat_<double>& T = (Mat_<double>&)transform;
-    T(0,0) = A*ct - B*st;
-    T(0,1) = B*ct - C*st;
-    T(0,2) = -ct*Ax_plus_By + st*Bx_plus_Cy + dstCenter.x;
-    T(1,0) = A*st + B*ct;
-    T(1,1) = B*st + C*ct;
-    T(1,2) = -st*Ax_plus_By - ct*Bx_plus_Cy + dstCenter.y;
-
-    if( inverse )
-        invertAffineTransform(T, T);
-}
-
-
-void PatchGenerator::operator ()(const Mat& image, Point2f pt, Mat& patch, Size patchSize, RNG& rng) const
-{
-    double buffer[6];
-    Mat_<double> T(2, 3, buffer);
-
-    generateRandomTransform(pt, Point2f((patchSize.width-1)*0.5f, (patchSize.height-1)*0.5f), T, rng);
-    (*this)(image, T, patch, patchSize, rng);
-}
-
-
-void PatchGenerator::operator ()(const Mat& image, const Mat& T,
-                                 Mat& patch, Size patchSize, RNG& rng) const
-{
-    patch.create( patchSize, image.type() );
-    if( backgroundMin != backgroundMax )
-    {
-        rng.fill(patch, RNG::UNIFORM, Scalar::all(backgroundMin), Scalar::all(backgroundMax));
-        warpAffine(image, patch, T, patchSize, INTER_LINEAR, BORDER_TRANSPARENT);
-    }
-    else
-        warpAffine(image, patch, T, patchSize, INTER_LINEAR, BORDER_CONSTANT, Scalar::all(backgroundMin));
-
-    int ksize = randomBlur ? (unsigned)rng % 9 - 5 : 0;
-    if( ksize > 0 )
-    {
-        ksize = ksize*2 + 1;
-        GaussianBlur(patch, patch, Size(ksize, ksize), 0, 0);
-    }
-
-    if( noiseRange > 0 )
-    {
-        AutoBuffer<uchar> _noiseBuf( patchSize.width*patchSize.height*image.elemSize() );
-        Mat noise(patchSize, image.type(), (uchar*)_noiseBuf);
-        int delta = image.depth() == CV_8U ? 128 : image.depth() == CV_16U ? 32768 : 0;
-        rng.fill(noise, RNG::NORMAL, Scalar::all(delta), Scalar::all(noiseRange));
-        if( backgroundMin != backgroundMax )
-            addWeighted(patch, 1, noise, 1, -delta, patch);
-        else
-        {
-            for( int i = 0; i < patchSize.height; i++ )
-            {
-                uchar* prow = patch.ptr<uchar>(i);
-                const uchar* nrow =  noise.ptr<uchar>(i);
-                for( int j = 0; j < patchSize.width; j++ )
-                    if( prow[j] != backgroundMin )
-                        prow[j] = saturate_cast<uchar>(prow[j] + nrow[j] - delta);
-            }
-        }
-    }
-}
-
-void PatchGenerator::warpWholeImage(const Mat& image, Mat& matT, Mat& buf,
-                                    Mat& warped, int border, RNG& rng) const
-{
-    Mat_<double> T = matT;
-    Rect roi(INT_MAX, INT_MAX, INT_MIN, INT_MIN);
-
-    for( int k = 0; k < 4; k++ )
-    {
-        Point2f pt0, pt1;
-        pt0.x = (float)(k == 0 || k == 3 ? 0 : image.cols);
-        pt0.y = (float)(k < 2 ? 0 : image.rows);
-        pt1.x = (float)(T(0,0)*pt0.x + T(0,1)*pt0.y + T(0,2));
-        pt1.y = (float)(T(1,0)*pt0.x + T(1,1)*pt0.y + T(1,2));
-
-        roi.x = std::min(roi.x, cvFloor(pt1.x));
-        roi.y = std::min(roi.y, cvFloor(pt1.y));
-        roi.width = std::max(roi.width, cvCeil(pt1.x));
-        roi.height = std::max(roi.height, cvCeil(pt1.y));
-    }
-
-    roi.width -= roi.x - 1;
-    roi.height -= roi.y - 1;
-    int dx = border - roi.x;
-    int dy = border - roi.y;
-
-    if( (roi.width+border*2)*(roi.height+border*2) > buf.cols )
-        buf.create(1, (roi.width+border*2)*(roi.height+border*2), image.type());
-
-    warped = Mat(roi.height + border*2, roi.width + border*2,
-                 image.type(), buf.data);
-
-    T(0,2) += dx;
-    T(1,2) += dy;
-    (*this)(image, T, warped, warped.size(), rng);
-
-    if( T.data != matT.data )
-        T.convertTo(matT, matT.type());
-}
-
-
-// Params are assumed to be symmetrical: lambda w.r.t. 1, theta and phi w.r.t. 0
-void PatchGenerator::setAffineParam(double lambda, double theta, double phi)
-{
-   lambdaMin = 1. - lambda;
-   lambdaMax = 1. + lambda;
-   thetaMin = -theta;
-   thetaMax = theta;
-   phiMin = -phi;
-   phiMax = phi;
-}
-
-
-/////////////////////////////////////// LDetector //////////////////////////////////////////////
-
-LDetector::LDetector() : radius(7), threshold(20), nOctaves(3), nViews(1000),
-    verbose(false), baseFeatureSize(32), clusteringDistance(2)
-{
-}
-
-LDetector::LDetector(int _radius, int _threshold, int _nOctaves, int _nViews,
-                     double _baseFeatureSize, double _clusteringDistance)
-: radius(_radius), threshold(_threshold), nOctaves(_nOctaves), nViews(_nViews),
-    verbose(false), baseFeatureSize(_baseFeatureSize), clusteringDistance(_clusteringDistance)
-{
-}
-
-static void getDiscreteCircle(int R, std::vector<Point>& circle, std::vector<int>& filledHCircle)
-{
-    int x = R, y = 0;
-    for( ;;y++ )
-    {
-        x = cvRound(std::sqrt((double)R*R - y*y));
-        if( x < y )
-            break;
-        circle.push_back(Point(x,y));
-        if( x == y )
-            break;
-    }
-
-    int i, n8 = (int)circle.size() - (x == y), n8_ = n8 - (x != y), n4 = n8 + n8_, n = n4*4;
-    CV_Assert(n8 > 0);
-    circle.resize(n);
-
-    for( i = 0; i < n8; i++ )
-    {
-        Point p = circle[i];
-        circle[i+n4] = Point(-p.y, p.x);
-        circle[i+n4*2] = Point(-p.x, -p.y);
-        circle[i+n4*3] = Point(p.y, -p.x);
-    }
-
-    for( i = n8; i < n4; i++ )
-    {
-        Point p = circle[n4 - i], q = Point(p.y, p.x);
-        circle[i] = q;
-        circle[i+n4] = Point(-q.y, q.x);
-        circle[i+n4*2] = Point(-q.x, -q.y);
-        circle[i+n4*3] = Point(q.y, -q.x);
-    }
-
-    // the filled upper half of the circle is encoded as sequence of integers,
-    // i-th element is the coordinate of right-most circle point in each horizontal line y=i.
-    // the left-most point will be -filledHCircle[i].
-    for( i = 0, y = -1; i < n4; i++ )
-    {
-        Point p = circle[i];
-        if( p.y != y )
-        {
-            filledHCircle.push_back(p.x);
-            y = p.y;
-            if( y == R )
-                break;
-        }
-    }
-}
-
-
-struct CmpKeypointScores
-{
-    bool operator ()(const KeyPoint& a, const KeyPoint& b) const { return std::abs(a.response) > std::abs(b.response); }
-};
-
-
-void LDetector::getMostStable2D(const Mat& image, std::vector<KeyPoint>& keypoints,
-                                int maxPoints, const PatchGenerator& _patchGenerator) const
-{
-    PatchGenerator patchGenerator = _patchGenerator;
-    patchGenerator.backgroundMin = patchGenerator.backgroundMax = 128;
-
-    Mat warpbuf, warped;
-    Mat matM(2, 3, CV_64F), _iM(2, 3, CV_64F);
-    double *M = (double*)matM.data, *iM = (double*)_iM.data;
-    RNG& rng = theRNG();
-    int i, k;
-    std::vector<KeyPoint> tempKeypoints;
-    double d2 = clusteringDistance*clusteringDistance;
-    keypoints.clear();
-
-    // TODO: this loop can be run in parallel, for that we need
-    // a separate accumulator keypoint lists for different threads.
-    for( i = 0; i < nViews; i++ )
-    {
-        // 1. generate random transform
-        // 2. map the source image corners and compute the ROI in canvas
-        // 3. select the ROI in canvas, adjust the transformation matrix
-        // 4. apply the transformation
-        // 5. run keypoint detector in pyramids
-        // 6. map each point back and update the lists of most stable points
-
-        if(verbose && (i+1)*progressBarSize/nViews != i*progressBarSize/nViews)
-            putchar('.');
-
-        if( i > 0 )
-            patchGenerator.generateRandomTransform(Point2f(), Point2f(), matM, rng);
-        else
-        {
-            // identity transformation
-            M[0] = M[4] = 1;
-            M[1] = M[3] = M[2] = M[5] = 0;
-        }
-
-        patchGenerator.warpWholeImage(image, matM, warpbuf, warped, cvCeil(baseFeatureSize*0.5+radius), rng);
-        (*this)(warped, tempKeypoints, maxPoints*3);
-        invertAffineTransform(matM, _iM);
-
-        int j, sz0 = (int)tempKeypoints.size(), sz1;
-        for( j = 0; j < sz0; j++ )
-        {
-            KeyPoint kpt1 = tempKeypoints[j];
-            KeyPoint kpt0((float)(iM[0]*kpt1.pt.x + iM[1]*kpt1.pt.y + iM[2]),
-                          (float)(iM[3]*kpt1.pt.x + iM[4]*kpt1.pt.y + iM[5]),
-                          kpt1.size, -1.f, 1.f, kpt1.octave);
-            float r = kpt1.size*0.5f;
-            if( kpt0.pt.x < r || kpt0.pt.x >= image.cols - r ||
-               kpt0.pt.y < r || kpt0.pt.y >= image.rows - r )
-                continue;
-
-            sz1 = (int)keypoints.size();
-            for( k = 0; k < sz1; k++ )
-            {
-                KeyPoint kpt = keypoints[k];
-                if( kpt.octave != kpt0.octave )
-                    continue;
-                double dx = kpt.pt.x - kpt0.pt.x, dy = kpt.pt.y - kpt0.pt.y;
-                if( dx*dx + dy*dy <= d2*(1 << kpt.octave*2) )
-                {
-                    keypoints[k] = KeyPoint((kpt.pt.x*kpt.response + kpt0.pt.x)/(kpt.response+1),
-                                            (kpt.pt.y*kpt.response + kpt0.pt.y)/(kpt.response+1),
-                                            kpt.size, -1.f, kpt.response + 1, kpt.octave);
-                    break;
-                }
-            }
-            if( k == sz1 )
-                keypoints.push_back(kpt0);
-        }
-    }
-
-    if( verbose )
-        putchar('\n');
-
-    if( (int)keypoints.size() > maxPoints )
-    {
-        std::sort(keypoints.begin(), keypoints.end(), CmpKeypointScores());
-        keypoints.resize(maxPoints);
-    }
-}
-
-
-static inline int computeLResponse(const uchar* ptr, const int* cdata, int csize)
-{
-    int i, csize2 = csize/2, sum = -ptr[0]*csize;
-    for( i = 0; i < csize2; i++ )
-    {
-        int ofs = cdata[i];
-        sum += ptr[ofs] + ptr[-ofs];
-    }
-    return sum;
-}
-
-
-static Point2f adjustCorner(const float* fval, float& fvaln)
-{
-    double bx = (fval[3] - fval[5])*0.5;
-    double by = (fval[2] - fval[7])*0.5;
-    double Axx = fval[3] - fval[4]*2 + fval[5];
-    double Axy = (fval[0] - fval[2] - fval[6] + fval[8])*0.25;
-    double Ayy = fval[1] - fval[4]*2 + fval[7];
-    double D = Axx*Ayy - Axy*Axy;
-    D = D != 0 ? 1./D : 0;
-    double dx = (bx*Ayy - by*Axy)*D;
-    double dy = (by*Axx - bx*Axy)*D;
-    dx = std::min(std::max(dx, -1.), 1.);
-    dy = std::min(std::max(dy, -1.), 1.);
-    fvaln = (float)(fval[4] + (bx*dx + by*dy)*0.5);
-    if(fvaln*fval[4] < 0 || std::abs(fvaln) < std::abs(fval[4]))
-        fvaln = fval[4];
-
-    return Point2f((float)dx, (float)dy);
-}
-
-void LDetector::operator()(const Mat& image, std::vector<KeyPoint>& keypoints, int maxCount, bool scaleCoords) const
-{
-    std::vector<Mat> pyr;
-    buildPyramid(image, pyr, std::max(nOctaves-1, 0));
-    (*this)(pyr, keypoints, maxCount, scaleCoords);
-}
-
-void LDetector::operator()(const std::vector<Mat>& pyr, std::vector<KeyPoint>& keypoints, int maxCount, bool scaleCoords) const
-{
-    const int lthreshold = 3;
-    int L, x, y, i, j, k, tau = lthreshold;
-    Mat scoreBuf(pyr[0].size(), CV_16S), maskBuf(pyr[0].size(), CV_8U);
-    int scoreElSize = (int)scoreBuf.elemSize();
-    std::vector<Point> circle0;
-    std::vector<int> fhcircle0, circle, fcircle_s, fcircle;
-    getDiscreteCircle(radius, circle0, fhcircle0);
-    CV_Assert(fhcircle0.size() == (size_t)(radius+1) && circle0.size() % 2 == 0);
-    keypoints.clear();
-
-    for( L = 0; L < nOctaves; L++ )
-    {
-        //  Pyramidal keypoint detector body:
-        //    1. build next pyramid layer
-        //    2. scan points, check the circular neighborhood, compute the score
-        //    3. do non-maxima suppression
-        //    4. adjust the corners (sub-pix)
-        double cscale = scaleCoords ? 1 << L : 1;
-        Size layerSize = pyr[L].size();
-        if( layerSize.width < radius*2 + 3 || layerSize.height < radius*2 + 3 )
-            break;
-        Mat scoreLayer(layerSize, scoreBuf.type(), scoreBuf.data);
-        Mat maskLayer(layerSize, maskBuf.type(), maskBuf.data);
-        const Mat& pyrLayer = pyr[L];
-        int sstep = (int)(scoreLayer.step/sizeof(short));
-        int mstep = (int)maskLayer.step;
-
-        int csize = (int)circle0.size(), csize2 = csize/2;
-        circle.resize(csize*3);
-        for( i = 0; i < csize; i++ )
-            circle[i] = circle[i+csize] = circle[i+csize*2] = (int)((-circle0[i].y)*pyrLayer.step + circle0[i].x);
-        fcircle.clear();
-        fcircle_s.clear();
-        for( i = -radius; i <= radius; i++ )
-        {
-            x = fhcircle0[std::abs(i)];
-            for( j = -x; j <= x; j++ )
-            {
-                fcircle_s.push_back(i*sstep + j);
-                fcircle.push_back((int)(i*pyrLayer.step + j));
-            }
-        }
-        int nsize = (int)fcircle.size();
-        const int* cdata = &circle[0];
-        const int* ndata = &fcircle[0];
-        const int* ndata_s = &fcircle_s[0];
-
-        for( y = 0; y < radius; y++ )
-        {
-            memset( scoreLayer.ptr<short>(y), 0, layerSize.width*scoreElSize );
-            memset( scoreLayer.ptr<short>(layerSize.height-y-1), 0, layerSize.width*scoreElSize );
-            memset( maskLayer.ptr<uchar>(y), 0, layerSize.width );
-            memset( maskLayer.ptr<uchar>(layerSize.height-y-1), 0, layerSize.width );
-        }
-
-        int vradius = (int)(radius*pyrLayer.step);
-
-        for( y = radius; y < layerSize.height - radius; y++ )
-        {
-            const uchar* img = pyrLayer.ptr<uchar>(y) + radius;
-            short* scores = scoreLayer.ptr<short>(y);
-            uchar* mask = maskLayer.ptr<uchar>(y);
-
-            for( x = 0; x < radius; x++ )
-            {
-                scores[x] = scores[layerSize.width - 1 - x] = 0;
-                mask[x] = mask[layerSize.width - 1 - x] = 0;
-            }
-
-            for( x = radius; x < layerSize.width - radius; x++, img++ )
-            {
-                int val0 = *img;
-                if( (std::abs(val0 - img[radius]) < tau && std::abs(val0 - img[-radius]) < tau) ||
-                   (std::abs(val0 - img[vradius]) < tau && std::abs(val0 - img[-vradius]) < tau))
-                {
-                    scores[x] = 0;
-                    mask[x] = 0;
-                    continue;
-                }
-
-                for( k = 0; k < csize; k++ )
-                {
-                    if( std::abs(val0 - img[cdata[k]]) < tau &&
-                       (std::abs(val0 - img[cdata[k + csize2]]) < tau ||
-                        std::abs(val0 - img[cdata[k + csize2 - 1]]) < tau ||
-                        std::abs(val0 - img[cdata[k + csize2 + 1]]) < tau ||
-                        std::abs(val0 - img[cdata[k + csize2 - 2]]) < tau ||
-                        std::abs(val0 - img[cdata[k + csize2 + 2]]) < tau/* ||
-                     std::abs(val0 - img[cdata[k + csize2 - 3]]) < tau ||
-                     std::abs(val0 - img[cdata[k + csize2 + 3]]) < tau*/) )
-                        break;
-                }
-
-                if( k < csize )
-                {
-                    scores[x] = 0;
-                    mask[x] = 0;
-                }
-                else
-                {
-                    scores[x] = (short)computeLResponse(img, cdata, csize);
-                    mask[x] = 1;
-                }
-            }
-        }
-
-        for( y = radius+1; y < layerSize.height - radius-1; y++ )
-        {
-            const uchar* img = pyrLayer.ptr<uchar>(y) + radius+1;
-            short* scores = scoreLayer.ptr<short>(y) + radius+1;
-            const uchar* mask = maskLayer.ptr<uchar>(y) + radius+1;
-
-            for( x = radius+1; x < layerSize.width - radius-1; x++, img++, scores++, mask++ )
-            {
-                int val0 = *scores;
-                if( !*mask || std::abs(val0) < lthreshold ||
-                   (mask[-1] + mask[1] + mask[-mstep-1] + mask[-mstep] + mask[-mstep+1]+
-                    mask[mstep-1] + mask[mstep] + mask[mstep+1] < 3))
-                    continue;
-                bool recomputeZeroScores = radius*2 < y && y < layerSize.height - radius*2 &&
-                radius*2 < x && x < layerSize.width - radius*2;
-
-                if( val0 > 0 )
-                {
-                    for( k = 0; k < nsize; k++ )
-                    {
-                        int val = scores[ndata_s[k]];
-                        if( val == 0 && recomputeZeroScores )
-                            scores[ndata_s[k]] = (short)(val =
-                                computeLResponse(img + ndata[k], cdata, csize));
-                        if( val0 < val )
-                            break;
-                    }
-                }
-                else
-                {
-                    for( k = 0; k < nsize; k++ )
-                    {
-                        int val = scores[ndata_s[k]];
-                        if( val == 0 && recomputeZeroScores )
-                            scores[ndata_s[k]] = (short)(val =
-                                computeLResponse(img + ndata[k], cdata, csize));
-                        if( val0 > val )
-                            break;
-                    }
-                }
-                if( k < nsize )
-                    continue;
-                float fval[9], fvaln = 0;
-                for( int i1 = -1; i1 <= 1; i1++ )
-                    for( int j1 = -1; j1 <= 1; j1++ )
-                    {
-                        fval[(i1+1)*3 + j1 + 1] = (float)(scores[sstep*i1+j1] ? scores[sstep*i1+j1] :
-                            computeLResponse(img + pyrLayer.step*i1 + j1, cdata, csize));
-                    }
-                Point2f pt = adjustCorner(fval, fvaln);
-                pt.x += x;
-                pt.y += y;
-                keypoints.push_back(KeyPoint((float)(pt.x*cscale), (float)(pt.y*cscale),
-                                             (float)(baseFeatureSize*cscale), -1, fvaln, L));
-            }
-        }
-    }
-
-    if( maxCount > 0 && keypoints.size() > (size_t)maxCount )
-    {
-        std::sort(keypoints.begin(), keypoints.end(), CmpKeypointScores());
-        keypoints.resize(maxCount);
-    }
-}
-
-void LDetector::read(const FileNode& objnode)
-{
-    radius = (int)objnode["radius"];
-    threshold = (int)objnode["threshold"];
-    nOctaves = (int)objnode["noctaves"];
-    nViews = (int)objnode["nviews"];
-    baseFeatureSize = (int)objnode["base-feature-size"];
-    clusteringDistance = (int)objnode["clustering-distance"];
-}
-
-void LDetector::write(FileStorage& fs, const String& name) const
-{
-    internal::WriteStructContext ws(fs, name, CV_NODE_MAP);
-
-    fs << "radius" << radius
-    << "threshold" << threshold
-    << "noctaves" << nOctaves
-    << "nviews" << nViews
-    << "base-feature-size" << baseFeatureSize
-    << "clustering-distance" << clusteringDistance;
-}
-
-void LDetector::setVerbose(bool _verbose)
-{
-    verbose = _verbose;
-}
-
-/////////////////////////////////////// FernClassifier ////////////////////////////////////////////
-
-FernClassifier::FernClassifier()
-{
-    verbose = false;
-    clear();
-}
-
-
-FernClassifier::FernClassifier(const FileNode& node)
-{
-    verbose = false;
-    clear();
-    read(node);
-}
-
-FernClassifier::~FernClassifier()
-{
-}
-
-
-int FernClassifier::getClassCount() const
-{
-    return nclasses;
-}
-
-
-int FernClassifier::getStructCount() const
-{
-    return nstructs;
-}
-
-
-int FernClassifier::getStructSize() const
-{
-    return structSize;
-}
-
-
-int FernClassifier::getSignatureSize() const
-{
-    return signatureSize;
-}
-
-
-int FernClassifier::getCompressionMethod() const
-{
-    return compressionMethod;
-}
-
-
-Size FernClassifier::getPatchSize() const
-{
-    return patchSize;
-}
-
-
-FernClassifier::FernClassifier(const std::vector<std::vector<Point2f> >& points,
-                               const std::vector<Mat>& refimgs,
-                               const std::vector<std::vector<int> >& labels,
-                               int _nclasses, int _patchSize,
-                               int _signatureSize, int _nstructs,
-                               int _structSize, int _nviews, int _compressionMethod,
-                               const PatchGenerator& patchGenerator)
-{
-    verbose = false;
-    clear();
-    train(points, refimgs, labels, _nclasses, _patchSize,
-          _signatureSize, _nstructs, _structSize, _nviews,
-          _compressionMethod, patchGenerator);
-}
-
-
-void FernClassifier::write(FileStorage& fs, const String& objname) const
-{
-    internal::WriteStructContext ws(fs, objname, CV_NODE_MAP);
-
-    cv::write(fs, "nstructs", nstructs);
-    cv::write(fs, "struct-size", structSize);
-    cv::write(fs, "nclasses", nclasses);
-    cv::write(fs, "signature-size", signatureSize);
-    cv::write(fs, "compression-method", compressionMethod);
-    cv::write(fs, "patch-size", patchSize.width);
-    {
-        internal::WriteStructContext wsf(fs, "features", CV_NODE_SEQ + CV_NODE_FLOW);
-        int i, nfeatures = (int)features.size();
-        for( i = 0; i < nfeatures; i++ )
-        {
-            cv::write(fs, features[i].y1*patchSize.width + features[i].x1);
-            cv::write(fs, features[i].y2*patchSize.width + features[i].x2);
-        }
-    }
-    {
-        internal::WriteStructContext wsp(fs, "posteriors", CV_NODE_SEQ + CV_NODE_FLOW);
-        cv::write(fs, posteriors);
-    }
-}
-
-
-void FernClassifier::read(const FileNode& objnode)
-{
-    clear();
-
-    nstructs = (int)objnode["nstructs"];
-    structSize = (int)objnode["struct-size"];
-    nclasses = (int)objnode["nclasses"];
-    signatureSize = (int)objnode["signature-size"];
-    compressionMethod = (int)objnode["compression-method"];
-    patchSize.width = patchSize.height = (int)objnode["patch-size"];
-    leavesPerStruct = 1 << structSize;
-
-    FileNode _nodes = objnode["features"];
-    int i, nfeatures = structSize*nstructs;
-    features.resize(nfeatures);
-    FileNodeIterator it = _nodes.begin(), it_end = _nodes.end();
-    for( i = 0; i < nfeatures && it != it_end; i++ )
-    {
-        int ofs1, ofs2;
-        it >> ofs1 >> ofs2;
-        features[i] = Feature(ofs1%patchSize.width, ofs1/patchSize.width,
-                              ofs2%patchSize.width, ofs2/patchSize.width);
-    }
-
-    FileNode _posteriors = objnode["posteriors"];
-    int psz = leavesPerStruct*nstructs*signatureSize;
-    posteriors.reserve(psz);
-    _posteriors >> posteriors;
-}
-
-
-void FernClassifier::clear()
-{
-    signatureSize = nclasses = nstructs = structSize = compressionMethod = leavesPerStruct = 0;
-    std::vector<Feature>().swap(features);
-    std::vector<float>().swap(posteriors);
-}
-
-bool FernClassifier::empty() const
-{
-    return features.empty();
-}
-
-int FernClassifier::getLeaf(int fern, const Mat& _patch) const
-{
-    assert( 0 <= fern && fern < nstructs );
-    size_t fofs = fern*structSize, idx = 0;
-    const Mat_<uchar>& patch = (const Mat_<uchar>&)_patch;
-
-    for( int i = 0; i < structSize; i++ )
-    {
-        const Feature& f = features[fofs + i];
-        idx = (idx << 1) + f(patch);
-    }
-
-    return (int)(fern*leavesPerStruct + idx);
-}
-
-
-void FernClassifier::prepare(int _nclasses, int _patchSize, int _signatureSize,
-                             int _nstructs, int _structSize,
-                             int _nviews, int _compressionMethod)
-{
-    clear();
-
-    CV_Assert( _nclasses > 1 && _patchSize >= 5 && _nstructs > 0 &&
-              _nviews > 0 && _structSize > 0 &&
-              (_compressionMethod == COMPRESSION_NONE ||
-               _compressionMethod == COMPRESSION_RANDOM_PROJ ||
-               _compressionMethod == COMPRESSION_PCA) );
-
-    nclasses = _nclasses;
-    patchSize = Size(_patchSize, _patchSize);
-    nstructs = _nstructs;
-    structSize = _structSize;
-    signatureSize = _compressionMethod == COMPRESSION_NONE ? nclasses : std::min(_signatureSize, nclasses);
-    compressionMethod = signatureSize == nclasses ? COMPRESSION_NONE : _compressionMethod;
-
-    leavesPerStruct = 1 << structSize;
-
-    int i, nfeatures = structSize*nstructs;
-
-    features = std::vector<Feature>( nfeatures );
-    posteriors = std::vector<float>( leavesPerStruct*nstructs*nclasses, 1.f );
-    classCounters = std::vector<int>( nclasses, leavesPerStruct );
-
-    CV_Assert( patchSize.width <= 256 && patchSize.height <= 256 );
-    RNG& rng = theRNG();
-
-    for( i = 0; i < nfeatures; i++ )
-    {
-        int x1 = (unsigned)rng % patchSize.width;
-        int y1 = (unsigned)rng % patchSize.height;
-        int x2 = (unsigned)rng % patchSize.width;
-        int y2 = (unsigned)rng % patchSize.height;
-        features[i] = Feature(x1, y1, x2, y2);
-    }
-}
-
-static int calcNumPoints( const std::vector<std::vector<Point2f> >& points )
-{
-    size_t count = 0;
-    for( size_t i = 0; i < points.size(); i++ )
-        count += points[i].size();
-    return (int)count;
-}
-
-void FernClassifier::train(const std::vector<std::vector<Point2f> >& points,
-                           const std::vector<Mat>& refimgs,
-                           const std::vector<std::vector<int> >& labels,
-                           int _nclasses, int _patchSize,
-                           int _signatureSize, int _nstructs,
-                           int _structSize, int _nviews, int _compressionMethod,
-                           const PatchGenerator& patchGenerator)
-{
-    CV_Assert( points.size() == refimgs.size() );
-    int numPoints = calcNumPoints( points );
-    _nclasses = (!labels.empty() && _nclasses>0) ? _nclasses : numPoints;
-    CV_Assert( labels.empty() || labels.size() == points.size() );
-
-
-    prepare(_nclasses, _patchSize, _signatureSize, _nstructs,
-            _structSize, _nviews, _compressionMethod);
-
-    // pass all the views of all the samples through the generated trees and accumulate
-    // the statistics (posterior probabilities) in leaves.
-    Mat patch;
-    RNG& rng = theRNG();
-
-    int globalPointIdx = 0;
-    for( size_t imgIdx = 0; imgIdx < points.size(); imgIdx++ )
-    {
-        const Point2f* imgPoints = &points[imgIdx][0];
-        const int* imgLabels = labels.empty() ? 0 : &labels[imgIdx][0];
-        for( size_t pointIdx = 0; pointIdx < points[imgIdx].size(); pointIdx++, globalPointIdx++ )
-        {
-            Point2f pt = imgPoints[pointIdx];
-            const Mat& src = refimgs[imgIdx];
-            int classId = imgLabels==0 ? globalPointIdx : imgLabels[pointIdx];
-            if( verbose && (globalPointIdx+1)*progressBarSize/numPoints != globalPointIdx*progressBarSize/numPoints )
-                putchar('.');
-            CV_Assert( 0 <= classId && classId < nclasses );
-            classCounters[classId] += _nviews;
-            for( int v = 0; v < _nviews; v++ )
-            {
-                patchGenerator(src, pt, patch, patchSize, rng);
-                for( int f = 0; f < nstructs; f++ )
-                    posteriors[getLeaf(f, patch)*nclasses + classId]++;
-            }
-        }
-    }
-    if( verbose )
-        putchar('\n');
-
-    finalize(rng);
-}
-
-
-void FernClassifier::trainFromSingleView(const Mat& image,
-                                         const std::vector<KeyPoint>& keypoints,
-                                         int _patchSize, int _signatureSize,
-                                         int _nstructs, int _structSize,
-                                         int _nviews, int _compressionMethod,
-                                         const PatchGenerator& patchGenerator)
-{
-    prepare((int)keypoints.size(), _patchSize, _signatureSize, _nstructs,
-            _structSize, _nviews, _compressionMethod);
-    int i, j, k, nsamples = (int)keypoints.size(), maxOctave = 0;
-    for( i = 0; i < nsamples; i++ )
-    {
-        classCounters[i] = _nviews;
-        maxOctave = std::max(maxOctave, keypoints[i].octave);
-    }
-
-    double maxScale = patchGenerator.lambdaMax*2;
-    Mat canvas(cvRound(std::max(image.cols,image.rows)*maxScale + patchSize.width*2 + 10),
-               cvRound(std::max(image.cols,image.rows)*maxScale + patchSize.width*2 + 10), image.type());
-    Mat noisebuf;
-    std::vector<Mat> pyrbuf(maxOctave+1), pyr(maxOctave+1);
-    Point2f center0((image.cols-1)*0.5f, (image.rows-1)*0.5f),
-    center1((canvas.cols - 1)*0.5f, (canvas.rows - 1)*0.5f);
-    Mat matM(2, 3, CV_64F);
-    double *M = (double*)matM.data;
-    RNG& rng = theRNG();
-
-    Mat patch(patchSize, CV_8U);
-
-    for( i = 0; i < _nviews; i++ )
-    {
-        patchGenerator.generateRandomTransform(center0, center1, matM, rng);
-
-        CV_Assert(matM.type() == CV_64F);
-        Rect roi(INT_MAX, INT_MAX, INT_MIN, INT_MIN);
-
-        for( k = 0; k < 4; k++ )
-        {
-            Point2f pt0, pt1;
-            pt0.x = (float)(k == 0 || k == 3 ? 0 : image.cols);
-            pt0.y = (float)(k < 2 ? 0 : image.rows);
-            pt1.x = (float)(M[0]*pt0.x + M[1]*pt0.y + M[2]);
-            pt1.y = (float)(M[3]*pt0.x + M[4]*pt0.y + M[5]);
-
-            roi.x = std::min(roi.x, cvFloor(pt1.x));
-            roi.y = std::min(roi.y, cvFloor(pt1.y));
-            roi.width = std::max(roi.width, cvCeil(pt1.x));
-            roi.height = std::max(roi.height, cvCeil(pt1.y));
-        }
-
-        roi.width -= roi.x + 1;
-        roi.height -= roi.y + 1;
-
-        Mat canvas_roi(canvas, roi);
-        M[2] -= roi.x;
-        M[5] -= roi.y;
-
-        Size size = canvas_roi.size();
-        rng.fill(canvas_roi, RNG::UNIFORM, Scalar::all(0), Scalar::all(256));
-        warpAffine( image, canvas_roi, matM, size, INTER_LINEAR, BORDER_TRANSPARENT);
-
-        pyr[0] = canvas_roi;
-        for( j = 1; j <= maxOctave; j++ )
-        {
-            size = Size((size.width+1)/2, (size.height+1)/2);
-            if( pyrbuf[j].cols < size.width*size.height )
-                pyrbuf[j].create(1, size.width*size.height, image.type());
-            pyr[j] = Mat(size, image.type(), pyrbuf[j].data);
-            pyrDown(pyr[j-1], pyr[j]);
-        }
-
-        if( patchGenerator.noiseRange > 0 )
-        {
-            const int noiseDelta = 128;
-            if( noisebuf.cols < pyr[0].cols*pyr[0].rows )
-                noisebuf.create(1, pyr[0].cols*pyr[0].rows, image.type());
-            for( j = 0; j <= maxOctave; j++ )
-            {
-                Mat noise(pyr[j].size(), image.type(), noisebuf.data);
-                rng.fill(noise, RNG::UNIFORM, Scalar::all(-patchGenerator.noiseRange + noiseDelta),
-                         Scalar::all(patchGenerator.noiseRange + noiseDelta));
-                addWeighted(pyr[j], 1, noise, 1, -noiseDelta, pyr[j]);
-            }
-        }
-
-        for( j = 0; j < nsamples; j++ )
-        {
-            KeyPoint kpt = keypoints[j];
-            float scale = 1.f/(1 << kpt.octave);
-            Point2f pt((float)((M[0]*kpt.pt.x + M[1]*kpt.pt.y + M[2])*scale),
-                       (float)((M[3]*kpt.pt.x + M[4]*kpt.pt.y + M[5])*scale));
-            getRectSubPix(pyr[kpt.octave], patchSize, pt, patch, patch.type());
-            for( int f = 0; f < nstructs; f++ )
-                posteriors[getLeaf(f, patch)*nclasses + j]++;
-        }
-
-        if( verbose && (i+1)*progressBarSize/_nviews != i*progressBarSize/_nviews )
-            putchar('.');
-    }
-    if( verbose )
-        putchar('\n');
-
-    finalize(rng);
-}
-
-
-int FernClassifier::operator()(const Mat& img, Point2f pt, std::vector<float>& signature) const
-{
-    Mat patch;
-    getRectSubPix(img, patchSize, pt, patch, img.type());
-    return (*this)(patch, signature);
-}
-
-
-int FernClassifier::operator()(const Mat& patch, std::vector<float>& signature) const
-{
-    if( posteriors.empty() )
-        CV_Error(CV_StsNullPtr,
-                 "The descriptor has not been trained or "
-                 "the floating-point posteriors have been deleted");
-    CV_Assert(patch.size() == patchSize);
-
-    int i, j, sz = signatureSize;
-    signature.resize(sz);
-    float* s = &signature[0];
-
-    for( j = 0; j < sz; j++ )
-        s[j] = 0;
-
-    for( i = 0; i < nstructs; i++ )
-    {
-        int lf = getLeaf(i, patch);
-        const float* ldata = &posteriors[lf*signatureSize];
-        for( j = 0; j <= sz - 4; j += 4 )
-        {
-            float t0 = s[j] + ldata[j];
-            float t1 = s[j+1] + ldata[j+1];
-            s[j] = t0; s[j+1] = t1;
-            t0 = s[j+2] + ldata[j+2];
-            t1 = s[j+3] + ldata[j+3];
-            s[j+2] = t0; s[j+3] = t1;
-        }
-        for( ; j < sz; j++ )
-            s[j] += ldata[j];
-    }
-
-    j = 0;
-    if( signatureSize == nclasses && compressionMethod == COMPRESSION_NONE )
-    {
-        for( i = 1; i < nclasses; i++ )
-            if( s[j] < s[i] )
-                j = i;
-    }
-    return j;
-}
-
-
-void FernClassifier::finalize(RNG&)
-{
-    int i, j, k, n = nclasses;
-    std::vector<double> invClassCounters(n);
-    Mat_<double> _temp(1, n);
-    double* temp = &_temp(0,0);
-
-    for( i = 0; i < n; i++ )
-        invClassCounters[i] = 1./classCounters[i];
-
-    for( i = 0; i < nstructs; i++ )
-    {
-        for( j = 0; j < leavesPerStruct; j++ )
-        {
-            float* P = &posteriors[(i*leavesPerStruct + j)*nclasses];
-            double sum = 0;
-            for( k = 0; k < n; k++ )
-                sum += P[k]*invClassCounters[k];
-            sum = 1./sum;
-            for( k = 0; k < n; k++ )
-                temp[k] = P[k]*invClassCounters[k]*sum;
-            log(_temp, _temp);
-            for( k = 0; k < n; k++ )
-                P[k] = (float)temp[k];
-        }
-    }
-
-#if 0
-    // do the first pass over the data.
-    if( compressionMethod == COMPRESSION_RANDOM_PROJ )
-    {
-        // In case of random projection
-        // we generate a random m x n matrix consisting of -1's and 1's
-        // (called Bernoulli matrix) and multiply it by each vector
-        // of posterior probabilities.
-        // the product is stored back into the same input vector.
-
-        Mat_<uchar> csmatrix;
-        if( m < n )
-        {
-            // generate random Bernoulli matrix:
-            //   -1's are replaced with 0's and 1's stay 1's.
-            csmatrix.create(m, n);
-            rng.fill(csmatrix, RNG::UNIFORM, Scalar::all(0), Scalar::all(2));
-        }
-        std::vector<float> dst(m);
-
-        for( i = 0; i < totalLeaves; i++ )
-        {
-            int S = sampleCounters[i];
-            if( S == 0 )
-                continue;
-
-            float scale = 1.f/(S*(m < n ? std::sqrt((float)m) : 1.f));
-            const int* leaf = (const int*)&posteriors[i*n];
-            float* out_leaf = (float*)&posteriors[i*m];
-
-            for( j = 0; j < m; j++ )
-            {
-                float val = 0;
-                if( m < n )
-                {
-                    const uchar* csrow = csmatrix.ptr(j);
-                    // Because -1's in the Bernoulli matrix are encoded as 0's,
-                    // the real dot product value will be
-                    // A - B, where A is the sum of leaf[j]'s for which csrow[j]==1 and
-                    // B is the sum of leaf[j]'s for which csrow[j]==0.
-                    // since A + B = S, then A - B = A - (S - A) = 2*A - S.
-                    int A = 0;
-                    for( k = 0; k < n; k++ )
-                        A += leaf[k] & -(int)csrow[k];
-                    val = (A*2 - S)*scale;
-                }
-                else
-                    val = leaf[j]*scale;
-                dst[j] = val;
-            }
-
-            // put the vector back (since it's shorter than the original, we can do it in-place)
-            for( j = 0; j < m; j++ )
-                out_leaf[j] = dst[j];
-        }
-    }
-    else if( compressionMethod == COMPRESSION_PCA )
-    {
-        // In case of PCA we do 3 passes over the data:
-        //   first, we compute the mean vector
-        //   second, we compute the covariation matrix
-        //     then we do eigen decomposition of the matrix and construct the PCA
-        //     projection matrix
-        //   and on the third pass we actually do PCA compression.
-
-        int nonEmptyLeaves = 0;
-        Mat_<double> _mean(1, n), _vec(1, n), _dvec(m, 1),
-        _cov(n, n), _evals(n, 1), _evects(n, n);
-        _mean = 0.;
-        double* mean = &_mean(0,0);
-        double* vec = &_vec(0,0);
-        double* dvec = &_dvec(0,0);
-
-        for( i = 0; i < totalLeaves; i++ )
-        {
-            int S = sampleCounters[i];
-            if( S == 0 )
-                continue;
-            float invS = 1.f/S;
-            const int* leaf = (const int*)&posteriors[0] + i*n;
-            float* out_leaf = (float*)&posteriors[0] + i*n;
-
-            for( j = 0; j < n; j++ )
-            {
-                float t = leaf[j]*invS;
-                out_leaf[j] = t;
-                mean[j] += t;
-            }
-            nonEmptyLeaves++;
-        }
-
-        CV_Assert( nonEmptyLeaves >= ntrees );
-        _mean *= 1./nonEmptyLeaves;
-
-        for( i = 0; i < totalLeaves; i++ )
-        {
-            int S = sampleCounters[i];
-            if( S == 0 )
-                continue;
-            const float* leaf = (const float*)&posteriors[0] + i*n;
-            for( j = 0; j < n; j++ )
-                vec[j] = leaf[j] - mean[j];
-            gemm(_vec, _vec, 1, _cov, 1, _cov, GEMM_1_T);
-        }
-
-        _cov *= 1./nonEmptyLeaves;
-        eigen(_cov, _evals, _evects);
-        // use the first m eigenvectors (stored as rows of the eigenvector matrix)
-        // as the projection matrix in PCA
-        _evects = _evects(Range(0, m), Range::all());
-
-        for( i = 0; i < totalLeaves; i++ )
-        {
-            int S = sampleCounters[i];
-            if( S == 0 )
-                continue;
-            const float* leaf = (const float*)&posteriors[0] + i*n;
-            float* out_leaf = (float*)&posteriors[0] + i*m;
-
-            for( j = 0; j < n; j++ )
-                vec[j] = leaf[j] - mean[j];
-            gemm(_evects, _vec, 1, Mat(), 0, _dvec, GEMM_2_T);
-
-            for( j = 0; j < m; j++ )
-                out_leaf[j] = (float)dvec[j];
-        }
-    }
-    else
-        CV_Error( CV_StsBadArg,
-                 "Unknown compression method; use COMPRESSION_RANDOM_PROJ or COMPRESSION_PCA" );
-
-    // and shrink the vector
-    posteriors.resize(totalLeaves*m);
-#endif
-}
-
-void FernClassifier::setVerbose(bool _verbose)
-{
-    verbose = _verbose;
-}
-
-
-/****************************************************************************************\
-*                                  FernDescriptorMatcher                                 *
-\****************************************************************************************/
-FernDescriptorMatcher::Params::Params( int _nclasses, int _patchSize, int _signatureSize,
-                                      int _nstructs, int _structSize, int _nviews, int _compressionMethod,
-                                      const PatchGenerator& _patchGenerator ) :
-nclasses(_nclasses), patchSize(_patchSize), signatureSize(_signatureSize),
-nstructs(_nstructs), structSize(_structSize), nviews(_nviews),
-compressionMethod(_compressionMethod), patchGenerator(_patchGenerator)
-{}
-
-FernDescriptorMatcher::Params::Params( const String& _filename )
-{
-    filename = _filename;
-}
-
-FernDescriptorMatcher::FernDescriptorMatcher( const Params& _params )
-{
-    prevTrainCount = 0;
-    params = _params;
-    if( !params.filename.empty() )
-    {
-        classifier = makePtr<FernClassifier>();
-        FileStorage fs(params.filename, FileStorage::READ);
-        if( fs.isOpened() )
-            classifier->read( fs.getFirstTopLevelNode() );
-    }
-}
-
-FernDescriptorMatcher::~FernDescriptorMatcher()
-{}
-
-void FernDescriptorMatcher::clear()
-{
-    GenericDescriptorMatcher::clear();
-
-    classifier.release();
-    prevTrainCount = 0;
-}
-
-void FernDescriptorMatcher::train()
-{
-    if( !classifier || prevTrainCount < (int)trainPointCollection.keypointCount() )
-    {
-        assert( params.filename.empty() );
-
-        std::vector<std::vector<Point2f> > points( trainPointCollection.imageCount() );
-        for( size_t imgIdx = 0; imgIdx < trainPointCollection.imageCount(); imgIdx++ )
-            KeyPoint::convert( trainPointCollection.getKeypoints((int)imgIdx), points[imgIdx] );
-
-        classifier.reset(
-            new FernClassifier( points, trainPointCollection.getImages(), std::vector<std::vector<int> >(), 0, // each points is a class
-                                params.patchSize, params.signatureSize, params.nstructs, params.structSize,
-                                params.nviews, params.compressionMethod, params.patchGenerator ));
-    }
-}
-
-bool FernDescriptorMatcher::isMaskSupported()
-{
-    return false;
-}
-
-void FernDescriptorMatcher::calcBestProbAndMatchIdx( const Mat& image, const Point2f& pt,
-                                                    float& bestProb, int& bestMatchIdx, std::vector<float>& signature )
-{
-    (*classifier)( image, pt, signature);
-
-    bestProb = -FLT_MAX;
-    bestMatchIdx = -1;
-    for( int ci = 0; ci < classifier->getClassCount(); ci++ )
-    {
-        if( signature[ci] > bestProb )
-        {
-            bestProb = signature[ci];
-            bestMatchIdx = ci;
-        }
-    }
-}
-
-void FernDescriptorMatcher::knnMatchImpl( InputArray _queryImage, std::vector<KeyPoint>& queryKeypoints,
-                                         std::vector<std::vector<DMatch> >& matches, int knn,
-                                         InputArrayOfArrays /*masks*/, bool /*compactResult*/ )
-{
-    Mat queryImage = _queryImage.getMat();
-
-    train();
-
-    matches.resize( queryKeypoints.size() );
-    std::vector<float> signature( (size_t)classifier->getClassCount() );
-
-    for( size_t queryIdx = 0; queryIdx < queryKeypoints.size(); queryIdx++ )
-    {
-        (*classifier)( queryImage, queryKeypoints[queryIdx].pt, signature);
-
-        for( int k = 0; k < knn; k++ )
-        {
-            DMatch bestMatch;
-            size_t best_ci = 0;
-            for( size_t ci = 0; ci < signature.size(); ci++ )
-            {
-                if( -signature[ci] < bestMatch.distance )
-                {
-                    int imgIdx = -1, trainIdx = -1;
-                    trainPointCollection.getLocalIdx( (int)ci , imgIdx, trainIdx );
-                    bestMatch = DMatch( (int)queryIdx, trainIdx, imgIdx, -signature[ci] );
-                    best_ci = ci;
-                }
-            }
-
-            if( bestMatch.trainIdx == -1 )
-                break;
-            signature[best_ci] = -std::numeric_limits<float>::max();
-            matches[queryIdx].push_back( bestMatch );
-        }
-    }
-}
-
-void FernDescriptorMatcher::radiusMatchImpl( InputArray _queryImage, std::vector<KeyPoint>& queryKeypoints,
-                                            std::vector<std::vector<DMatch> >& matches, float maxDistance,
-                                            InputArrayOfArrays /*masks*/, bool /*compactResult*/ )
-{
-    Mat queryImage = _queryImage.getMat();
-    train();
-    matches.resize( queryKeypoints.size() );
-    std::vector<float> signature( (size_t)classifier->getClassCount() );
-
-    for( size_t i = 0; i < queryKeypoints.size(); i++ )
-    {
-        (*classifier)( queryImage, queryKeypoints[i].pt, signature);
-
-        for( int ci = 0; ci < classifier->getClassCount(); ci++ )
-        {
-            if( -signature[ci] < maxDistance )
-            {
-                int imgIdx = -1, trainIdx = -1;
-                trainPointCollection.getLocalIdx( ci , imgIdx, trainIdx );
-                matches[i].push_back( DMatch( (int)i, trainIdx, imgIdx, -signature[ci] ) );
-            }
-        }
-    }
-}
-
-void FernDescriptorMatcher::read( const FileNode &fn )
-{
-    params.nclasses = fn["nclasses"];
-    params.patchSize = fn["patchSize"];
-    params.signatureSize = fn["signatureSize"];
-    params.nstructs = fn["nstructs"];
-    params.structSize = fn["structSize"];
-    params.nviews = fn["nviews"];
-    params.compressionMethod = fn["compressionMethod"];
-
-    //classifier->read(fn);
-}
-
-void FernDescriptorMatcher::write( FileStorage& fs ) const
-{
-    fs << "nclasses" << params.nclasses;
-    fs << "patchSize" << params.patchSize;
-    fs << "signatureSize" << params.signatureSize;
-    fs << "nstructs" << params.nstructs;
-    fs << "structSize" << params.structSize;
-    fs << "nviews" << params.nviews;
-    fs << "compressionMethod" << params.compressionMethod;
-
-    //    classifier->write(fs);
-}
-
-bool FernDescriptorMatcher::empty() const
-{
-    return !classifier || classifier->empty();
-}
-
-Ptr<GenericDescriptorMatcher> FernDescriptorMatcher::clone( bool emptyTrainData ) const
-{
-    Ptr<FernDescriptorMatcher> matcher = makePtr<FernDescriptorMatcher>( params );
-    if( !emptyTrainData )
-    {
-        CV_Error( CV_StsNotImplemented, "deep clone dunctionality is not implemented, because "
-                 "FernClassifier has not copy constructor or clone method ");
-
-        //matcher->classifier;
-        matcher->params = params;
-        matcher->prevTrainCount = prevTrainCount;
-        matcher->trainPointCollection = trainPointCollection;
-    }
-    return matcher;
-}
-
-////////////////////////////////////// Planar Object Detector ////////////////////////////////////
-
-PlanarObjectDetector::PlanarObjectDetector()
-{
-}
-
-PlanarObjectDetector::PlanarObjectDetector(const FileNode& node)
-{
-    read(node);
-}
-
-PlanarObjectDetector::PlanarObjectDetector(const std::vector<Mat>& pyr, int npoints,
-                                           int patchSize, int nstructs, int structSize,
-                                           int nviews, const LDetector& detector,
-                                           const PatchGenerator& patchGenerator)
-{
-    train(pyr, npoints, patchSize, nstructs,
-          structSize, nviews, detector, patchGenerator);
-}
-
-PlanarObjectDetector::~PlanarObjectDetector()
-{
-}
-
-std::vector<KeyPoint> PlanarObjectDetector::getModelPoints() const
-{
-    return modelPoints;
-}
-
-void PlanarObjectDetector::train(const std::vector<Mat>& pyr, int npoints,
-                                 int patchSize, int nstructs, int structSize,
-                                 int nviews, const LDetector& detector,
-                                 const PatchGenerator& patchGenerator)
-{
-    modelROI = Rect(0, 0, pyr[0].cols, pyr[0].rows);
-    ldetector = detector;
-    ldetector.setVerbose(verbose);
-    ldetector.getMostStable2D(pyr[0], modelPoints, npoints, patchGenerator);
-
-    npoints = (int)modelPoints.size();
-    fernClassifier.setVerbose(verbose);
-    fernClassifier.trainFromSingleView(pyr[0], modelPoints,
-                                       patchSize, (int)modelPoints.size(), nstructs, structSize, nviews,
-                                       FernClassifier::COMPRESSION_NONE, patchGenerator);
-}
-
-void PlanarObjectDetector::train(const std::vector<Mat>& pyr, const std::vector<KeyPoint>& keypoints,
-                                 int patchSize, int nstructs, int structSize,
-                                 int nviews, const LDetector& detector,
-                                 const PatchGenerator& patchGenerator)
-{
-    modelROI = Rect(0, 0, pyr[0].cols, pyr[0].rows);
-    ldetector = detector;
-    ldetector.setVerbose(verbose);
-    modelPoints.resize(keypoints.size());
-    std::copy(keypoints.begin(), keypoints.end(), modelPoints.begin());
-
-    fernClassifier.setVerbose(verbose);
-    fernClassifier.trainFromSingleView(pyr[0], modelPoints,
-                                       patchSize, (int)modelPoints.size(), nstructs, structSize, nviews,
-                                       FernClassifier::COMPRESSION_NONE, patchGenerator);
-}
-
-void PlanarObjectDetector::read(const FileNode& node)
-{
-    FileNodeIterator it = node["model-roi"].begin(), it_end;
-    it >> modelROI.x >> modelROI.y >> modelROI.width >> modelROI.height;
-    ldetector.read(node["detector"]);
-    fernClassifier.read(node["fern-classifier"]);
-    cv::read(node["model-points"], modelPoints);
-    CV_Assert(modelPoints.size() == (size_t)fernClassifier.getClassCount());
-}
-
-
-void PlanarObjectDetector::write(FileStorage& fs, const String& objname) const
-{
-    internal::WriteStructContext ws(fs, objname, CV_NODE_MAP);
-
-    {
-        internal::WriteStructContext wsroi(fs, "model-roi", CV_NODE_SEQ + CV_NODE_FLOW);
-        cv::write(fs, modelROI.x);
-        cv::write(fs, modelROI.y);
-        cv::write(fs, modelROI.width);
-        cv::write(fs, modelROI.height);
-    }
-    ldetector.write(fs, "detector");
-    cv::write(fs, "model-points", modelPoints);
-    fernClassifier.write(fs, "fern-classifier");
-}
-
-
-bool PlanarObjectDetector::operator()(const Mat& image, Mat& H, std::vector<Point2f>& corners) const
-{
-    std::vector<Mat> pyr;
-    buildPyramid(image, pyr, ldetector.nOctaves - 1);
-    std::vector<KeyPoint> keypoints;
-    ldetector(pyr, keypoints);
-
-    return (*this)(pyr, keypoints, H, corners);
-}
-
-bool PlanarObjectDetector::operator()(const std::vector<Mat>& pyr, const std::vector<KeyPoint>& keypoints,
-                                      Mat& matH, std::vector<Point2f>& corners, std::vector<int>* pairs) const
-{
-    int i, j, m = (int)modelPoints.size(), n = (int)keypoints.size();
-    std::vector<int> bestMatches(m, -1);
-    std::vector<float> maxLogProb(m, -FLT_MAX);
-    std::vector<float> signature;
-    std::vector<Point2f> fromPt, toPt;
-
-    for( i = 0; i < n; i++ )
-    {
-        KeyPoint kpt = keypoints[i];
-        CV_Assert(0 <= kpt.octave && kpt.octave < (int)pyr.size());
-        kpt.pt.x /= (float)(1 << kpt.octave);
-        kpt.pt.y /= (float)(1 << kpt.octave);
-        int k = fernClassifier(pyr[kpt.octave], kpt.pt, signature);
-        if( k >= 0 && (bestMatches[k] < 0 || signature[k] > maxLogProb[k]) )
-        {
-            maxLogProb[k] = signature[k];
-            bestMatches[k] = i;
-        }
-    }
-
-    if(pairs)
-        pairs->resize(0);
-
-    for( i = 0; i < m; i++ )
-        if( bestMatches[i] >= 0 )
-        {
-            fromPt.push_back(modelPoints[i].pt);
-            toPt.push_back(keypoints[bestMatches[i]].pt);
-        }
-
-    if( fromPt.size() < 4 )
-        return false;
-
-    std::vector<uchar> mask;
-    matH = findHomography(fromPt, toPt, RANSAC, 10, mask);
-    if( matH.data )
-    {
-        const Mat_<double>& H = matH;
-        corners.resize(4);
-        for( i = 0; i < 4; i++ )
-        {
-            Point2f pt((float)(modelROI.x + (i == 0 || i == 3 ? 0 : modelROI.width)),
-                       (float)(modelROI.y + (i <= 1 ? 0 : modelROI.height)));
-            double w = 1./(H(2,0)*pt.x + H(2,1)*pt.y + H(2,2));
-            corners[i] = Point2f((float)((H(0,0)*pt.x + H(0,1)*pt.y + H(0,2))*w),
-                                 (float)((H(1,0)*pt.x + H(1,1)*pt.y + H(1,2))*w));
-        }
-    }
-
-    if( pairs )
-    {
-        for( i = j = 0; i < m; i++ )
-            if( bestMatches[i] >= 0 && mask[j++] )
-            {
-                pairs->push_back(i);
-                pairs->push_back(bestMatches[i]);
-            }
-    }
-
-    return matH.data != 0;
-}
-
-
-void PlanarObjectDetector::setVerbose(bool _verbose)
-{
-    verbose = _verbose;
-}
-
-}
diff --git a/modules/legacy/src/precomp.hpp b/modules/legacy/src/precomp.hpp
deleted file mode 100644 (file)
index 7093f9f..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#ifndef __OPENCV_PRECOMP_H__
-#define __OPENCV_PRECOMP_H__
-
-#include "opencv2/legacy.hpp"
-
-#include "opencv2/video.hpp"
-#include "opencv2/legacy/blobtrack.hpp"
-#include "opencv2/legacy/compat.hpp"
-#include "opencv2/core/utility.hpp"
-
-#include "opencv2/core/private.hpp"
-
-#define __BEGIN__ __CV_BEGIN__
-#define __END__ __CV_END__
-#define EXIT __CV_EXIT__
-
-#include "_matrix.h"
-
-CV_INLINE bool operator == (CvSize size1, CvSize size2 );
-CV_INLINE bool operator == (CvSize size1, CvSize size2 )
-{
-    return size1.width == size2.width && size1.height == size2.height;
-}
-
-CV_INLINE bool operator != (CvSize size1, CvSize size2 );
-CV_INLINE bool operator != (CvSize size1, CvSize size2 )
-{
-    return size1.width != size2.width || size1.height != size2.height;
-}
-
-#endif /* __CVAUX_H__ */
diff --git a/modules/legacy/src/prewarp.cpp b/modules/legacy/src/prewarp.cpp
deleted file mode 100644 (file)
index b9b28f0..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-#include "_vm.h"
-
-/* Valery Mosyagin */
-
-static CvStatus
-icvFindRuns( int numLines,      /* number of scanlines      */
-             uchar * prewarp_1, /* prewarp image 1          */
-             uchar * prewarp_2, /* prewarp image 2          */
-             int *line_lens_1,  /* line lengths 1           */
-             int *line_lens_2,  /* line lengths 2           */
-             int *runs_1,       /* result runs  1           */
-             int *runs_2,       /* result runs  2           */
-             int *num_runs_1,   /* numbers of first runs    */
-             int *num_runs_2 )
-{
-    CvStatus err;
-
-    err = icvFindRunsInOneImage( numLines, prewarp_1, line_lens_1, runs_1, num_runs_1 );
-
-    if( err != CV_NO_ERR )
-        return err;
-
-    err = icvFindRunsInOneImage( numLines, prewarp_2, line_lens_2, runs_2, num_runs_2 );
-
-    return err;
-
-}
-
-
-/*======================================================================================*/
-
-CV_INLINE int
-icvGetColor( uchar * valueRGB )
-{
-    int R = *valueRGB;
-    int G = *(valueRGB + 1);
-    int B = *(valueRGB + 2);
-
-    return ( ((R + G + B) >> 3) & 0xFFFC );
-}                               /* vm_GetColor */
-
-
-/*======================================================================================*/
-
-CvStatus
-icvFindRunsInOneImage( int numLines,    /* number of scanlines      */
-                       uchar * prewarp, /* prewarp image            */
-                       int *line_lens,  /* line lengths in pixels   */
-                       int *runs,       /* result runs              */
-                       int *num_runs )
-{
-    int epiLine;
-    int run_index;
-    int curr_color;
-    int index;
-    int color;
-    uchar *curr_point;
-    int num;
-
-
-    run_index = 0;
-
-    curr_point = prewarp;
-
-    for( epiLine = 0; epiLine < numLines; epiLine++ )
-    {
-
-        curr_color = icvGetColor( curr_point );
-
-        runs[run_index++] = 0;
-        runs[run_index++] = curr_color;
-
-        curr_point += 3;
-
-        num = 1;
-        for( index = 1; index < line_lens[epiLine]; index++ )
-        {
-
-            color = icvGetColor( curr_point );
-
-            if( color != curr_color )
-            {
-                runs[run_index++] = index;
-                runs[run_index++] = color;
-                curr_color = color;
-                num++;
-            }
-
-            curr_point += 3;
-        }
-
-        runs[run_index++] = index;
-        num_runs[epiLine] = num;
-    }
-
-    return CV_NO_ERR;
-}
-
-
-/*======================================================================================*/
-
-CV_IMPL void
-cvFindRuns( int numLines,       /* number of scanlines   */
-            uchar * prewarp_1,  /* prewarp image 1       */
-            uchar * prewarp_2,  /* prewarp image 2       */
-            int *line_lens_1,   /* line lengths 1        */
-            int *line_lens_2,   /* line lengths 2        */
-            int *runs_1,        /* result runs  1        */
-            int *runs_2,        /* result runs  2        */
-            int *num_runs_1,    /* numbers of first runs */
-            int *num_runs_2 )
-{
-    IPPI_CALL( icvFindRuns( numLines,   /* number of scanlines   */
-                            prewarp_1,  /* prewarp image 1       */
-                            prewarp_2,  /* prewarp image 2       */
-                            line_lens_1,        /* line lengths 1        */
-                            line_lens_2,        /* line lengths 2        */
-                            runs_1,     /* result runs  1        */
-                            runs_2,     /* result runs  2        */
-                            num_runs_1, /* numbers of first runs */
-                            num_runs_2 ));
-}
diff --git a/modules/legacy/src/pyrsegmentation.cpp b/modules/legacy/src/pyrsegmentation.cpp
deleted file mode 100644 (file)
index 03a4678..0000000
+++ /dev/null
@@ -1,1880 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-typedef struct _CvRGBf
-{   float blue;
-    float green;
-    float red;
-}
-_CvRGBf;
-
-typedef struct _CvRect16u
-{
-    ushort x1, y1, x2, y2;
-}
-_CvRect16u;
-
-typedef struct _CvPyramid
-{
-    float c;
-    struct _CvPyramid *p;
-    int a;
-    _CvRect16u rect;      /*  ROI for the connected component    */
-} _CvPyramid;
-
-/* element of base layer */
-typedef struct _CvPyramidBase
-{
-    float c;
-    struct _CvPyramid *p;
-}
-_CvPyramidBase;
-
-typedef struct _CvPyramidC3
-{
-    _CvRGBf c;
-    struct _CvPyramidC3 *p;
-    int a;
-    _CvRect16u rect;      /*  ROI for the connected component    */
-} _CvPyramidC3;
-
-/* element of base layer */
-typedef struct _CvPyramidBaseC3
-{
-    _CvRGBf c;
-    struct _CvPyramidC3 *p;
-}
-_CvPyramidBaseC3;
-
-typedef struct _CvListNode
-{
-    struct _CvListNode* next;
-    void* data;
-}
-_CvListNode;
-
-
-static CvStatus  icvSegmentClusterC1( CvSeq* cmp_seq, CvSeq* res_seq,
-                                 double threshold,
-                                 _CvPyramid* first_level_end,
-                                 CvSize first_level_size );
-
-static CvStatus  icvSegmentClusterC3( CvSeq* cmp_seq, CvSeq* res_seq,
-                                 double threshold,
-                                 _CvPyramidC3* first_level_end,
-                                 CvSize first_level_size );
-
-typedef void (CV_CDECL * CvWriteNodeFunction)(void* seq,void* node);
-
-static CvStatus icvUpdatePyrLinks_8u_C1
-    (int layer, void *layer_data, CvSize size, void *parent_layer,
-     void *_writer, float threshold, int is_last_iter, void *_stub, CvWriteNodeFunction /*func*/);
-
-static CvStatus icvUpdatePyrLinks_8u_C3
-    (int layer, void *layer_data, CvSize size, void *parent_layer,
-     void *_writer, float threshold, int is_last_iter, void *_stub, CvWriteNodeFunction /*func*/);
-
-static void icvMaxRoi( _CvRect16u *max_rect, _CvRect16u* cur_rect );
-static void icvMaxRoi1( _CvRect16u *max_rect, int x, int y );
-
-
-#define _CV_CHECK( icvFun )                                             \
-  {                                                                     \
-    if( icvFun != CV_OK )                                               \
-     goto M_END;                                                        \
-  }
-
-
-#define _CV_MAX3( a, b, c) ((a)>(b) ? ((a)>(c) ? (a) : (c)) : ((b)>(c) ? (b) : (c)))
-
-/*#define _CV_RGB_DIST(a, b)  _CV_MAX3((float)fabs((a).red - (b).red),      \
-                                       (float)fabs((a).green - (b).green),  \
-                                       (float)fabs((a).blue - (b).blue))*/
-
-#define _CV_NEXT_BASE_C1(p,n) (_CvPyramid*)((char*)(p) + (n)*sizeof(_CvPyramidBase))
-#define _CV_NEXT_BASE_C3(p,n) (_CvPyramidC3*)((char*)(p) + (n)*sizeof(_CvPyramidBaseC3))
-
-
-CV_INLINE float icvRGBDist_Max( const _CvRGBf& a, const _CvRGBf& b )
-{
-    float tr = (float)fabs(a.red - b.red);
-    float tg = (float)fabs(a.green - b.green);
-    float tb = (float)fabs(a.blue - b.blue);
-
-    return _CV_MAX3( tr, tg, tb );
-}
-
-CV_INLINE float icvRGBDist_Sum( const _CvRGBf& a, const _CvRGBf& b )
-{
-    float tr = (float)fabs(a.red - b.red);
-    float tg = (float)fabs(a.green - b.green);
-    float tb = (float)fabs(a.blue - b.blue);
-
-    return (tr + tg + tb);
-}
-
-#if 1
-#define _CV_RGB_DIST  icvRGBDist_Max
-#define _CV_RGB_THRESH_SCALE   1
-#else
-#define _CV_RGB_DIST  icvRGBDist_Sum
-#define _CV_RGB_THRESH_SCALE   3
-#endif
-
-#define _CV_INV_TAB_SIZE   32
-
-static const float icvInvTab[ /*_CV_INV_TAB_SIZE*/ ] =
-{
-    1.00000000f, 0.50000000f, 0.33333333f, 0.25000000f, 0.20000000f, 0.16666667f,
-    0.14285714f, 0.12500000f, 0.11111111f, 0.10000000f, 0.09090909f, 0.08333333f,
-    0.07692308f, 0.07142857f, 0.06666667f, 0.06250000f, 0.05882353f, 0.05555556f,
-    0.05263158f, 0.05000000f, 0.04761905f, 0.04545455f, 0.04347826f, 0.04166667f,
-    0.04000000f, 0.03846154f, 0.03703704f, 0.03571429f, 0.03448276f, 0.03333333f,
-    0.03225806f, 0.03125000f
-};
-
-static void
-icvWritePyrNode( void *elem, void *writer )
-{
-    CV_WRITE_SEQ_ELEM( *(_CvListNode *) elem, *(CvSeqWriter *) writer );
-}
-
-
-static CvStatus
-icvPyrSegmentation8uC1R( uchar * src_image, int src_step,
-                         uchar * dst_image, int dst_step,
-                         CvSize roi, int filter,
-                         CvSeq ** dst_comp, CvMemStorage * storage,
-                         int level, int threshold1, int threshold2 )
-{
-    int i, j, l;
-    int step;
-    const int max_iter = 3;     /* maximum number of iterations */
-    int cur_iter = 0;           /* current iteration */
-
-    _CvPyramid *pyram[16];      /* pointers to the pyramid down up to level */
-
-    float *pyramida = 0;
-    _CvPyramid stub;
-
-    _CvPyramid *p_cur;
-    _CvPyramidBase *p_base;
-    _CvListNode cmp_node;
-
-    CvSeq *cmp_seq = 0;
-    CvSeq *res_seq = 0;
-    CvMemStorage *temp_storage = 0;
-    CvSize size;
-    CvStatus status;
-    CvSeqWriter writer;
-
-    int buffer_size;
-    char *buffer = 0;
-
-    status = CV_OK;
-
-    /* clear pointer to resultant sequence */
-    if( dst_comp )
-        *dst_comp = 0;
-
-    /* check args */
-    if( !src_image || !dst_image || !storage || !dst_comp )
-        return CV_NULLPTR_ERR;
-    if( roi.width <= 0 || roi.height <= 0 || src_step < roi.width || dst_step < roi.width )
-        return CV_BADSIZE_ERR;
-    if( filter != CV_GAUSSIAN_5x5 )
-        return CV_BADRANGE_ERR;
-    if( threshold1 < 0 || threshold2 < 0 )
-        return CV_BADRANGE_ERR;
-    if( level <= 0 )
-        return CV_BADRANGE_ERR;
-
-    if( ((roi.width | roi.height) & ((1 << level) - 1)) != 0 )
-        return CV_BADCOEF_ERR;
-
-    temp_storage = cvCreateChildMemStorage( storage );
-
-    /* sequence for temporary components */
-    cmp_seq = cvCreateSeq( 0, sizeof( CvSeq ), sizeof( _CvListNode ), temp_storage );
-    assert( cmp_seq != 0 );
-
-    res_seq = cvCreateSeq( CV_SEQ_CONNECTED_COMP, sizeof( CvSeq ),
-                           sizeof( CvConnectedComp ), storage );
-    assert( res_seq != 0 );
-
-    /* calculate buffer size */
-    buffer_size = roi.width * roi.height * (sizeof( float ) + sizeof( _CvPyramidBase ));
-
-    for( l = 1; l <= level; l++ )
-        buffer_size += ((roi.width >> l) + 1) * ((roi.height >> l) + 1) * sizeof(_CvPyramid);
-
-    /* allocate buffer */
-    buffer = (char *) cvAlloc( buffer_size );
-    if( !buffer )
-    {
-        status = CV_OUTOFMEM_ERR;
-        goto M_END;
-    }
-
-    pyramida = (float *) buffer;
-
-    /* initialization pyramid-linking properties down up to level */
-    step = roi.width * sizeof( float );
-
-    {
-        CvMat _src;
-        CvMat _pyramida;
-        cvInitMatHeader( &_src, roi.height, roi.width, CV_8UC1, src_image, src_step );
-        cvInitMatHeader( &_pyramida, roi.height, roi.width, CV_32FC1, pyramida, step );
-        cvConvert( &_src, &_pyramida );
-        /*_CV_CHECK( icvCvtTo_32f_C1R( src_image, src_step, pyramida, step, roi, CV_8UC1 ));*/
-    }
-    p_base = (_CvPyramidBase *) (buffer + step * roi.height);
-    pyram[0] = (_CvPyramid *) p_base;
-
-    /* fill base level of pyramid */
-    for( i = 0; i < roi.height; i++ )
-    {
-        for( j = 0; j < roi.width; j++, p_base++ )
-        {
-            p_base->c = pyramida[i * roi.width + j];
-            p_base->p = &stub;
-        }
-    }
-
-    p_cur = (_CvPyramid *) p_base;
-    size = roi;
-
-    /* calculate initial pyramid */
-    for( l = 1; l <= level; l++ )
-    {
-        CvSize dst_size(size.width/2+1, size.height/2+1);
-        CvMat prev_level = cvMat( size.height, size.width, CV_32FC1 );
-        CvMat next_level = cvMat( dst_size.height, dst_size.width, CV_32FC1 );
-
-        cvSetData( &prev_level, pyramida, step );
-        cvSetData( &next_level, pyramida, step );
-        cvPyrDown( &prev_level, &next_level );
-
-        //_CV_CHECK( icvPyrDown_Gauss5x5_32f_C1R( pyramida, step, pyramida, step, size, buff ));
-        //_CV_CHECK( icvPyrDownBorder_32f_CnR( pyramida, step, size, pyramida, step, dst_size, 1 ));
-        pyram[l] = p_cur;
-
-        size.width = dst_size.width - 1;
-        size.height = dst_size.height - 1;
-
-        /* fill layer #l */
-        for( i = 0; i <= size.height; i++ )
-        {
-            for( j = 0; j <= size.width; j++, p_cur++ )
-            {
-                p_cur->c = pyramida[i * roi.width + j];
-                p_cur->p = &stub;
-                p_cur->a = 0;
-                p_cur->rect.x2 = 0;
-            }
-        }
-    }
-
-    cvStartAppendToSeq( cmp_seq, &writer );
-
-    /* do several iterations to determine son-father links */
-    for( cur_iter = 0; cur_iter < max_iter; cur_iter++ )
-    {
-        int is_last_iter = cur_iter == max_iter - 1;
-
-        size = roi;
-
-        /* build son-father links down up to level */
-        for( l = 0; l < level; l++ )
-        {
-            icvUpdatePyrLinks_8u_C1( l, pyram[l], size, pyram[l + 1], &writer,
-                                      (float) threshold1, is_last_iter, &stub,
-                                      icvWritePyrNode );
-
-            /* clear last border row */
-            if( l > 0 )
-            {
-                p_cur = pyram[l] + (size.width + 1) * size.height;
-                for( j = 0; j <= size.width; j++ )
-                    p_cur[j].c = 0;
-            }
-
-            size.width >>= 1;
-            size.height >>= 1;
-        }
-
-/*  clear the old c value for the last level     */
-        p_cur = pyram[level];
-        for( i = 0; i <= size.height; i++, p_cur += size.width + 1 )
-            for( j = 0; j <= size.width; j++ )
-                p_cur[j].c = 0;
-
-        size = roi;
-        step = roi.width;
-
-/* calculate average c value for the 0 < l <=level   */
-        for( l = 0; l < level; l++, step = (step >> 1) + 1 )
-        {
-            _CvPyramid *p_prev, *p_row_prev;
-
-            stub.c = 0;
-
-            /* calculate average c value for the next level   */
-            if( l == 0 )
-            {
-                p_base = (_CvPyramidBase *) pyram[0];
-                for( i = 0; i < roi.height; i++, p_base += size.width )
-                {
-                    for( j = 0; j < size.width; j += 2 )
-                    {
-                        _CvPyramid *p1 = p_base[j].p;
-                        _CvPyramid *p2 = p_base[j + 1].p;
-
-                        p1->c += p_base[j].c;
-                        p2->c += p_base[j + 1].c;
-                    }
-                }
-            }
-            else
-            {
-                p_cur = pyram[l];
-                for( i = 0; i < size.height; i++, p_cur += size.width + 1 )
-                {
-                    for( j = 0; j < size.width; j += 2 )
-                    {
-                        _CvPyramid *p1 = p_cur[j].p;
-                        _CvPyramid *p2 = p_cur[j + 1].p;
-
-                        float t0 = (float) p_cur[j].a * p_cur[j].c;
-                        float t1 = (float) p_cur[j + 1].a * p_cur[j + 1].c;
-
-                        p1->c += t0;
-                        p2->c += t1;
-
-                        if( !is_last_iter )
-                            p_cur[j].a = p_cur[j + 1].a = 0;
-                    }
-                    if( !is_last_iter )
-                        p_cur[size.width].a = 0;
-                }
-                if( !is_last_iter )
-                {
-                    for( j = 0; j <= size.width; j++ )
-                    {
-                        p_cur[j].a = 0;
-                    }
-                }
-            }
-
-            /* assign random values of the next level null c   */
-            p_cur = pyram[l + 1];
-            p_row_prev = p_prev = pyram[l];
-
-            size.width >>= 1;
-            size.height >>= 1;
-
-            for( i = 0; i <= size.height; i++, p_cur += size.width + 1 )
-            {
-                if( i < size.height || !is_last_iter )
-                {
-                    for( j = 0; j < size.width; j++ )
-                    {
-                        int a = p_cur[j].a;
-
-                        if( a != 0 )
-                        {
-                            if( a <= _CV_INV_TAB_SIZE )
-                            {
-                                p_cur[j].c *= icvInvTab[a - 1];
-                            }
-                            else
-                            {
-                                p_cur[j].c /= a;
-                            }
-                        }
-                        else
-                        {
-                            p_cur[j].c = p_prev->c;
-                        }
-
-                        if( l == 0 )
-                            p_prev = _CV_NEXT_BASE_C1(p_prev,2);
-                        else
-                            p_prev += 2;
-                    }
-
-                    if( p_cur[size.width].a == 0 )
-                    {
-                        p_cur[size.width].c = p_prev[(l != 0) - 1].c;
-                    }
-                    else
-                    {
-                        p_cur[size.width].c /= p_cur[size.width].a;
-                        if( is_last_iter )
-                        {
-                            cmp_node.data = p_cur + size.width;
-                            CV_WRITE_SEQ_ELEM( cmp_node, writer );
-                        }
-                    }
-                }
-                else
-                {
-                    for( j = 0; j <= size.width; j++ )
-                    {
-                        int a = p_cur[j].a;
-
-                        if( a != 0 )
-                        {
-                            if( a <= _CV_INV_TAB_SIZE )
-                            {
-                                p_cur[j].c *= icvInvTab[a - 1];
-                            }
-                            else
-                            {
-                                p_cur[j].c /= a;
-                            }
-
-                            cmp_node.data = p_cur + j;
-                            CV_WRITE_SEQ_ELEM( cmp_node, writer );
-                        }
-                        else
-                        {
-                            p_cur[j].c = p_prev->c;
-                        }
-
-                        if( l == 0 )
-                        {
-                            p_prev = _CV_NEXT_BASE_C1(p_prev, (j * 2 < step - 2 ? 2 : 1));
-                        }
-                        else
-                        {
-                            p_prev++;
-                        }
-                    }
-                }
-
-                if( l + 1 == level && !is_last_iter )
-                    for( j = 0; j <= size.width; j++ )
-                        p_cur[j].a = 0;
-
-                if( !(i & 1) )
-                {
-                    p_prev = p_row_prev;
-                }
-                else
-                {
-                    p_prev = (_CvPyramid*)((char*)p_row_prev + step *
-                        (l == 0 ? sizeof(_CvPyramidBase) : sizeof(_CvPyramid)));
-                }
-            }
-        }
-    }                           /*  end of the iteration process  */
-
-    /* construct a connected  components   */
-    size.width = roi.width >> level;
-    size.height = roi.height >> level;
-
-    p_cur = pyram[level];
-
-    for( i = 0; i < size.height; i++, p_cur += size.width + 1 )
-    {
-        for( j = 0; j < size.width; j++ )
-        {
-            if( p_cur[j].a != 0 )
-            {
-                cmp_node.data = p_cur + j;
-                CV_WRITE_SEQ_ELEM( cmp_node, writer );
-            }
-        }
-    }
-
-    cvEndWriteSeq( &writer );
-
-/* clusterization segmented components and construction
-   output connected components                            */
-    icvSegmentClusterC1( cmp_seq, res_seq, threshold2, pyram[1], roi );
-
-/* convert (inplace) resultant segment values to int (top level) */
-
-/* propagate segment values top down */
-    for( l = level - 1; l >= 0; l-- )
-    {
-        p_cur = pyram[l];
-
-        size.width <<= 1;
-        size.height <<= 1;
-
-        if( l == 0 )
-        {
-            size.width--;
-            size.height--;
-        }
-
-        for( i = 0; i <= size.height; i++ )
-        {
-            for( j = 0; j <= size.width; j++ )
-            {
-                _CvPyramid *p = p_cur->p;
-
-                assert( p != 0 );
-                if( p != &stub )
-                    p_cur->c = p->c;
-
-                if( l == 0 )
-                {
-                    Cv32suf _c;
-                    /* copy the segmented values to destination image */
-                    _c.f = p_cur->c; dst_image[j] = (uchar)_c.i;
-                    p_cur = _CV_NEXT_BASE_C1(p_cur, 1);
-                }
-                else
-                {
-                    p_cur++;
-                }
-            }
-            if( l == 0 )
-                dst_image += dst_step;
-        }
-    }
-  M_END:
-
-    cvFree( &buffer );
-    cvReleaseMemStorage( &temp_storage );
-
-    if( status == CV_OK )
-        *dst_comp = res_seq;
-
-    return status;
-}
-
-
-
-/****************************************************************************************\
-    color!!!  image segmentation by pyramid-linking
-\****************************************************************************************/
-static CvStatus
-icvPyrSegmentation8uC3R( uchar * src_image, int src_step,
-                         uchar * dst_image, int dst_step,
-                         CvSize roi, int filter,
-                         CvSeq ** dst_comp, CvMemStorage * storage,
-                         int level, int threshold1, int threshold2 )
-{
-    int i, j, l;
-
-    int step;
-    const int max_iter = 3;     /* maximum number of iterations */
-    int cur_iter = 0;           /* current iteration */
-
-    _CvPyramidC3 *pyram[16];    /* pointers to the pyramid down up to level */
-
-    float *pyramida = 0;
-    _CvPyramidC3 stub;
-
-    _CvPyramidC3 *p_cur;
-    _CvPyramidBaseC3 *p_base;
-    _CvListNode cmp_node;
-
-    CvSeq *cmp_seq = 0;
-    CvSeq *res_seq = 0;
-    CvMemStorage *temp_storage = 0;
-    CvSize size;
-    CvStatus status;
-    CvSeqWriter writer;
-
-    int buffer_size;
-    char *buffer = 0;
-
-    status = CV_OK;
-
-    threshold1 *= _CV_RGB_THRESH_SCALE;
-    threshold2 *= _CV_RGB_THRESH_SCALE;
-
-    /* clear pointer to resultant sequence */
-    if( dst_comp )
-        *dst_comp = 0;
-
-    /* check args */
-    if( !src_image || !dst_image || !storage || !dst_comp )
-        return CV_NULLPTR_ERR;
-    if( roi.width <= 0 || roi.height <= 0 ||
-        src_step < roi.width * 3 || dst_step < roi.width * 3 ) return CV_BADSIZE_ERR;
-    if( filter != CV_GAUSSIAN_5x5 )
-        return CV_BADRANGE_ERR;
-    if( threshold1 < 0 || threshold2 < 0 )
-        return CV_BADRANGE_ERR;
-    if( level <= 0 )
-        return CV_BADRANGE_ERR;
-
-    if( ((roi.width | roi.height) & ((1 << level) - 1)) != 0 )
-        return CV_BADCOEF_ERR;
-
-    temp_storage = cvCreateChildMemStorage( storage );
-
-    /* sequence for temporary components */
-    cmp_seq = cvCreateSeq( 0, sizeof( CvSeq ), sizeof( _CvListNode ), temp_storage );
-    assert( cmp_seq != 0 );
-
-    res_seq = cvCreateSeq( CV_SEQ_CONNECTED_COMP, sizeof( CvSeq ),
-                           sizeof( CvConnectedComp ), storage );
-    assert( res_seq != 0 );
-
-    /* calculate buffer size */
-    buffer_size = roi.width * roi.height * (sizeof( _CvRGBf ) + sizeof( _CvPyramidBaseC3 ));
-
-    for( l = 1; l <= level; l++ )
-        buffer_size += ((roi.width >> l) + 1) * ((roi.height >> l) + 1) * sizeof(_CvPyramidC3);
-
-    /* allocate buffer */
-    buffer = (char *) cvAlloc( buffer_size );
-    if( !buffer )
-    {
-        status = CV_OUTOFMEM_ERR;
-        goto M_END;
-    }
-
-    pyramida = (float *) buffer;
-
-    /* initialization pyramid-linking properties down up to level */
-    step = roi.width * sizeof( _CvRGBf );
-
-    {
-        CvMat _src;
-        CvMat _pyramida;
-        cvInitMatHeader( &_src, roi.height, roi.width, CV_8UC3, src_image, src_step );
-        cvInitMatHeader( &_pyramida, roi.height, roi.width, CV_32FC3, pyramida, step );
-        cvConvert( &_src, &_pyramida );
-        /*_CV_CHECK( icvCvtTo_32f_C1R( src_image, src_step, pyramida, step,
-                                 cvSize( roi.width * 3, roi.height ), CV_8UC1 ));*/
-    }
-
-    p_base = (_CvPyramidBaseC3 *) (buffer + step * roi.height);
-    pyram[0] = (_CvPyramidC3 *) p_base;
-
-    /* fill base level of pyramid */
-    for( i = 0; i < roi.height; i++ )
-    {
-        for( j = 0; j < roi.width; j++, p_base++ )
-        {
-            p_base->c = ((_CvRGBf *) pyramida)[i * roi.width + j];
-            p_base->p = &stub;
-        }
-    }
-
-    p_cur = (_CvPyramidC3 *) p_base;
-    size = roi;
-
-    /* calculate initial pyramid */
-    for( l = 1; l <= level; l++ )
-    {
-        CvSize dst_size(size.width/2 + 1, size.height/2 + 1);
-        CvMat prev_level = cvMat( size.height, size.width, CV_32FC3 );
-        CvMat next_level = cvMat( dst_size.height, dst_size.width, CV_32FC3 );
-
-        cvSetData( &prev_level, pyramida, step );
-        cvSetData( &next_level, pyramida, step );
-        cvPyrDown( &prev_level, &next_level );
-
-        //_CV_CHECK( icvPyrDown_Gauss5x5_32f_C3R( pyramida, step, pyramida, step, size, buff ));
-        //_CV_CHECK( icvPyrDownBorder_32f_CnR( pyramida, step, size, pyramida, step, dst_size, 3 ));
-        pyram[l] = p_cur;
-
-        size.width = dst_size.width - 1;
-        size.height = dst_size.height - 1;
-
-        /* fill layer #l */
-        for( i = 0; i <= size.height; i++ )
-        {
-            assert( (char*)p_cur - buffer < buffer_size );
-            for( j = 0; j <= size.width; j++, p_cur++ )
-            {
-                p_cur->c = ((_CvRGBf *) pyramida)[i * roi.width + j];
-                p_cur->p = &stub;
-                p_cur->a = 0;
-                p_cur->rect.x2 = 0;
-            }
-        }
-    }
-
-    cvStartAppendToSeq( cmp_seq, &writer );
-
-    /* do several iterations to determine son-father links */
-    for( cur_iter = 0; cur_iter < max_iter; cur_iter++ )
-    {
-        int is_last_iter = cur_iter == max_iter - 1;
-
-        size = roi;
-
-        /* build son-father links down up to level */
-        for( l = 0; l < level; l++ )
-        {
-            icvUpdatePyrLinks_8u_C3( l, pyram[l], size, pyram[l + 1], &writer,
-                                      (float) threshold1, is_last_iter, &stub,
-                                      icvWritePyrNode );
-
-            /* clear last border row */
-            if( l > 0 )
-            {
-                p_cur = pyram[l] + (size.width + 1) * size.height;
-                for( j = 0; j <= size.width; j++ )
-                    p_cur[j].c.blue = p_cur[j].c.green = p_cur[j].c.red = 0;
-            }
-
-            size.width >>= 1;
-            size.height >>= 1;
-        }
-
-/*  clear the old c value for the last level     */
-        p_cur = pyram[level];
-        for( i = 0; i <= size.height; i++, p_cur += size.width + 1 )
-            for( j = 0; j <= size.width; j++ )
-                p_cur[j].c.blue = p_cur[j].c.green = p_cur[j].c.red = 0;
-
-        size = roi;
-        step = roi.width;
-
-/* calculate average c value for the 0 < l <=level   */
-        for( l = 0; l < level; l++, step = (step >> 1) + 1 )
-        {
-            _CvPyramidC3 *p_prev, *p_row_prev;
-
-            stub.c.blue = stub.c.green = stub.c.red = 0;
-
-            /* calculate average c value for the next level   */
-            if( l == 0 )
-            {
-                p_base = (_CvPyramidBaseC3 *) pyram[0];
-                for( i = 0; i < roi.height; i++, p_base += size.width )
-                {
-                    for( j = 0; j < size.width; j++ )
-                    {
-                        _CvPyramidC3 *p = p_base[j].p;
-
-                        p->c.blue += p_base[j].c.blue;
-                        p->c.green += p_base[j].c.green;
-                        p->c.red += p_base[j].c.red;
-                    }
-                }
-            }
-            else
-            {
-                p_cur = pyram[l];
-                for( i = 0; i < size.height; i++, p_cur += size.width + 1 )
-                {
-                    for( j = 0; j < size.width; j++ )
-                    {
-                        _CvPyramidC3 *p = p_cur[j].p;
-                        float a = (float) p_cur[j].a;
-
-                        p->c.blue += a * p_cur[j].c.blue;
-                        p->c.green += a * p_cur[j].c.green;
-                        p->c.red += a * p_cur[j].c.red;
-
-                        if( !is_last_iter )
-                            p_cur[j].a = 0;
-                    }
-                    if( !is_last_iter )
-                        p_cur[size.width].a = 0;
-                }
-                if( !is_last_iter )
-                {
-                    for( j = 0; j <= size.width; j++ )
-                    {
-                        p_cur[j].a = 0;
-                    }
-                }
-            }
-
-            /* assign random values of the next level null c   */
-            p_cur = pyram[l + 1];
-            p_row_prev = p_prev = pyram[l];
-
-            size.width >>= 1;
-            size.height >>= 1;
-
-            for( i = 0; i <= size.height; i++, p_cur += size.width + 1 )
-            {
-                if( i < size.height || !is_last_iter )
-                {
-                    for( j = 0; j < size.width; j++ )
-                    {
-                        int a = p_cur[j].a;
-
-                        if( a != 0 )
-                        {
-                            float inv_a;
-
-                            if( a <= _CV_INV_TAB_SIZE )
-                            {
-                                inv_a = icvInvTab[a - 1];
-                            }
-                            else
-                            {
-                                inv_a = 1.f / a;
-                            }
-                            p_cur[j].c.blue *= inv_a;
-                            p_cur[j].c.green *= inv_a;
-                            p_cur[j].c.red *= inv_a;
-                        }
-                        else
-                        {
-                            p_cur[j].c = p_prev->c;
-                        }
-
-                        if( l == 0 )
-                            p_prev = _CV_NEXT_BASE_C3( p_prev, 2 );
-                        else
-                            p_prev += 2;
-                    }
-
-                    if( p_cur[size.width].a == 0 )
-                    {
-                        p_cur[size.width].c = p_prev[(l != 0) - 1].c;
-                    }
-                    else
-                    {
-                        p_cur[size.width].c.blue /= p_cur[size.width].a;
-                        p_cur[size.width].c.green /= p_cur[size.width].a;
-                        p_cur[size.width].c.red /= p_cur[size.width].a;
-                        if( is_last_iter )
-                        {
-                            cmp_node.data = p_cur + size.width;
-                            CV_WRITE_SEQ_ELEM( cmp_node, writer );
-                        }
-                    }
-                }
-                else
-                {
-                    for( j = 0; j <= size.width; j++ )
-                    {
-                        int a = p_cur[j].a;
-
-                        if( a != 0 )
-                        {
-                            float inv_a;
-
-                            if( a <= _CV_INV_TAB_SIZE )
-                            {
-                                inv_a = icvInvTab[a - 1];
-                            }
-                            else
-                            {
-                                inv_a = 1.f / a;
-                            }
-                            p_cur[j].c.blue *= inv_a;
-                            p_cur[j].c.green *= inv_a;
-                            p_cur[j].c.red *= inv_a;
-
-                            cmp_node.data = p_cur + j;
-                            CV_WRITE_SEQ_ELEM( cmp_node, writer );
-                        }
-                        else
-                        {
-                            p_cur[j].c = p_prev->c;
-                        }
-
-                        if( l == 0 )
-                        {
-                            p_prev = _CV_NEXT_BASE_C3( p_prev, (j * 2 < step - 2 ? 2 : 1));
-                        }
-                        else
-                        {
-                            p_prev++;
-                        }
-                    }
-                }
-
-                if( l + 1 == level && !is_last_iter )
-                    for( j = 0; j <= size.width; j++ )
-                        p_cur[j].a = 0;
-
-                if( !(i & 1) )
-                {
-                    p_prev = p_row_prev;
-                }
-                else
-                {
-                    p_prev = (_CvPyramidC3*)((char*)p_row_prev + step *
-                        (l == 0 ? sizeof( _CvPyramidBaseC3 ) : sizeof( _CvPyramidC3 )));
-                }
-            }
-        }
-    }                           /*  end of the iteration process  */
-
-    /* construct a connected  components   */
-    size.width = roi.width >> level;
-    size.height = roi.height >> level;
-
-    p_cur = pyram[level];
-
-    for( i = 0; i < size.height; i++, p_cur += size.width + 1 )
-    {
-        for( j = 0; j < size.width; j++ )
-        {
-            if( p_cur[j].a != 0 )
-            {
-                cmp_node.data = p_cur + j;
-                CV_WRITE_SEQ_ELEM( cmp_node, writer );
-            }
-        }
-    }
-
-    cvEndWriteSeq( &writer );
-
-/* clusterization segmented components and construction
-   output connected components                            */
-    icvSegmentClusterC3( cmp_seq, res_seq, threshold2, pyram[1], roi );
-
-/* convert (inplace) resultant segment values to int (top level) */
-
-/* propagate segment values top down */
-    for( l = level - 1; l >= 0; l-- )
-    {
-        p_cur = pyram[l];
-
-        size.width <<= 1;
-        size.height <<= 1;
-
-        if( l == 0 )
-        {
-            size.width--;
-            size.height--;
-        }
-
-        for( i = 0; i <= size.height; i++ )
-        {
-            for( j = 0; j <= size.width; j++ )
-            {
-                _CvPyramidC3 *p = p_cur->p;
-
-                assert( p != 0 );
-                if( p != &stub )
-                {
-                    p_cur->c = p->c;
-                }
-
-                if( l == 0 )
-                {
-                    Cv32suf _c;
-                    /* copy the segmented values to destination image */
-                    _c.f = p_cur->c.blue; dst_image[j*3] = (uchar)_c.i;
-                    _c.f = p_cur->c.green; dst_image[j*3+1] = (uchar)_c.i;
-                    _c.f = p_cur->c.red; dst_image[j*3+2] = (uchar)_c.i;
-                    p_cur = _CV_NEXT_BASE_C3(p_cur,1);
-                }
-                else
-                {
-                    p_cur++;
-                }
-            }
-            if( l == 0 )
-                dst_image += dst_step;
-        }
-    }
-
-  M_END:
-
-    cvFree( &buffer );
-    cvReleaseMemStorage( &temp_storage );
-
-    if( status == CV_OK )
-        *dst_comp = res_seq;
-
-    return status;
-}
-
-
-static CvStatus icvUpdatePyrLinks_8u_C1
-    (int layer, void *layer_data, CvSize size, void *parent_layer,
-     void *_writer, float threshold, int is_last_iter, void *_stub, CvWriteNodeFunction /*func*/)
-{
-    int i, j;
-    _CvListNode cmp_node;
-
-    _CvPyramid *stub = (_CvPyramid *) _stub;
-    _CvPyramid *p_cur = (_CvPyramid *) layer_data;
-    _CvPyramid *p_next1 = (_CvPyramid *) parent_layer;
-    _CvPyramid *p_next3 = p_next1 + (size.width >> 1) + 1;
-
-    CvSeqWriter & writer = *(CvSeqWriter *) _writer;
-
-    for( i = 0; i < size.height; i++ )
-    {
-        for( j = 0; j < size.width; j += 2 )
-        {
-            float c0, c1, c2, c3, c4;
-            _CvPyramid *p;
-
-/* son-father threshold linking for the current node establish */
-            c0 = p_cur->c;
-
-/* find pointer for the first pixel */
-            c1 = (float) fabs( c0 - p_next1[0].c );
-            c2 = (float) fabs( c0 - p_next1[1].c );
-            c3 = (float) fabs( c0 - p_next3[0].c );
-            c4 = (float) fabs( c0 - p_next3[1].c );
-
-            p = p_next1;
-
-            if( c1 > c2 )
-            {
-                p = p_next1 + 1;
-                c1 = c2;
-            }
-            if( c1 > c3 )
-            {
-                p = p_next3;
-                c1 = c3;
-            }
-            if( c1 > c4 )
-            {
-                p = p_next3 + 1;
-                c1 = c4;
-            }
-
-            if( c1 <= threshold )
-            {
-                p_cur->p = p;
-
-                if( layer == 0 )
-                {
-                    p->a++;
-                    p_cur = (_CvPyramid*)((char*)p_cur + sizeof(_CvPyramidBase));
-                    if( is_last_iter )
-                        icvMaxRoi1( &(p->rect), j, i );
-                }
-                else
-                {
-                    int a = p_cur->a;
-
-                    p->a += a;
-                    p_cur->c = 0;
-                    p_cur++;
-                    if( is_last_iter && a != 0 )
-                        icvMaxRoi( &(p->rect), &(p_cur[-1].rect) );
-                }
-            }
-            else
-            {
-                p_cur->p = stub;
-                if( is_last_iter )
-                {
-                    cmp_node.data = p_cur;
-                    CV_WRITE_SEQ_ELEM( cmp_node, writer );
-                }
-                if( layer == 0 )
-                {
-                    p_cur = _CV_NEXT_BASE_C1(p_cur,1);
-                }
-                else
-                {
-                    p_cur->c = 0;
-                    p_cur++;
-                }
-            }
-
-            /* find pointer for the second pixel */
-            c0 = p_cur->c;
-
-            c1 = (float) fabs( c0 - p_next1[0].c );
-            c2 = (float) fabs( c0 - p_next1[1].c );
-            c3 = (float) fabs( c0 - p_next3[0].c );
-            c4 = (float) fabs( c0 - p_next3[1].c );
-
-            p = p_next1;
-            p_next1++;
-
-            if( c1 > c2 )
-            {
-                p = p_next1;
-                c1 = c2;
-            }
-            if( c1 > c3 )
-            {
-                p = p_next3;
-                c1 = c3;
-            }
-
-            p_next3++;
-            if( c1 > c4 )
-            {
-                p = p_next3;
-                c1 = c4;
-            }
-
-            if( c1 <= threshold )
-            {
-                p_cur->p = p;
-
-                if( layer == 0 )
-                {
-                    p->a++;
-                    p_cur = _CV_NEXT_BASE_C1(p_cur,1);
-                    if( is_last_iter )
-                        icvMaxRoi1( &(p->rect), j + 1, i );
-                }
-                else
-                {
-                    int a = p_cur->a;
-
-                    p->a += a;
-                    p_cur->c = 0;
-                    p_cur++;
-                    if( is_last_iter && a != 0 )
-                        icvMaxRoi( &(p->rect), &(p_cur[-1].rect) );
-                }
-            }
-            else
-            {
-                p_cur->p = stub;
-                if( is_last_iter )
-                {
-                    cmp_node.data = p_cur;
-                    CV_WRITE_SEQ_ELEM( cmp_node, writer );
-                }
-                if( layer == 0 )
-                {
-                    p_cur = _CV_NEXT_BASE_C1(p_cur,1);
-                }
-                else
-                {
-                    p_cur->c = 0;
-                    p_cur++;
-                }
-            }
-        }
-
-        /* clear c's */
-        if( layer > 0 )
-        {
-            p_cur->c = 0;
-            p_cur++;
-        }
-
-        if( !(i & 1) )
-        {
-            p_next1 -= size.width >> 1;
-            p_next3 -= size.width >> 1;
-        }
-        else
-        {
-            p_next1++;
-            p_next3++;
-        }
-    }
-
-    return CV_OK;
-}
-
-
-static CvStatus icvUpdatePyrLinks_8u_C3
-    (int layer, void *layer_data, CvSize size, void *parent_layer,
-     void *_writer, float threshold, int is_last_iter, void *_stub, CvWriteNodeFunction /*func*/)
-{
-    int i, j;
-    _CvListNode cmp_node;
-
-    _CvPyramidC3 *stub = (_CvPyramidC3 *) _stub;
-    _CvPyramidC3 *p_cur = (_CvPyramidC3 *) layer_data;
-    _CvPyramidC3 *p_next1 = (_CvPyramidC3 *) parent_layer;
-    _CvPyramidC3 *p_next3 = p_next1 + (size.width >> 1) + 1;
-
-    CvSeqWriter & writer = *(CvSeqWriter *) _writer;
-
-    for( i = 0; i < size.height; i++ )
-    {
-        for( j = 0; j < size.width; j += 2 )
-        {
-            float c1, c2, c3, c4;
-            _CvPyramidC3 *p;
-
-/* find pointer for the first pixel */
-            c1 = _CV_RGB_DIST( p_cur->c, p_next1[0].c );
-            c2 = _CV_RGB_DIST( p_cur->c, p_next1[1].c );
-            c3 = _CV_RGB_DIST( p_cur->c, p_next3[0].c );
-            c4 = _CV_RGB_DIST( p_cur->c, p_next3[1].c );
-
-            p = p_next1;
-
-            if( c1 > c2 )
-            {
-                p = p_next1 + 1;
-                c1 = c2;
-            }
-            if( c1 > c3 )
-            {
-                p = p_next3;
-                c1 = c3;
-            }
-            if( c1 > c4 )
-            {
-                p = p_next3 + 1;
-                c1 = c4;
-            }
-
-            if( c1 < threshold )
-            {
-                p_cur->p = p;
-
-                if( layer == 0 )
-                {
-                    p->a++;
-                    p_cur = _CV_NEXT_BASE_C3(p_cur,1);
-                    if( is_last_iter )
-                        icvMaxRoi1( &(p->rect), j, i );
-                }
-                else
-                {
-                    int a = p_cur->a;
-
-                    p->a += a;
-                    p_cur->c.blue = p_cur->c.green = p_cur->c.red = 0;
-                    p_cur++;
-                    if( is_last_iter && a != 0 )
-                        icvMaxRoi( &(p->rect), &(p_cur[-1].rect) );
-                }
-            }
-            else
-            {
-                p_cur->p = stub;
-                if( is_last_iter /* && ( == 0 || p_cur->a != 0) */  )
-                {
-                    cmp_node.data = p_cur;
-                    CV_WRITE_SEQ_ELEM( cmp_node, writer );
-                }
-
-                if( layer == 0 )
-                {
-                    p_cur = _CV_NEXT_BASE_C3(p_cur,1);
-                }
-                else
-                {
-                    p_cur->c.blue = p_cur->c.green = p_cur->c.red = 0;
-                    p_cur++;
-                }
-            }
-
-            /* find pointer for the second pixel */
-            c1 = _CV_RGB_DIST( p_cur->c, p_next1[0].c );
-            c2 = _CV_RGB_DIST( p_cur->c, p_next1[1].c );
-            c3 = _CV_RGB_DIST( p_cur->c, p_next3[0].c );
-            c4 = _CV_RGB_DIST( p_cur->c, p_next3[1].c );
-
-            p = p_next1;
-            p_next1++;
-
-            if( c1 > c2 )
-            {
-                p = p_next1;
-                c1 = c2;
-            }
-            if( c1 > c3 )
-            {
-                p = p_next3;
-                c1 = c3;
-            }
-
-            p_next3++;
-            if( c1 > c4 )
-            {
-                p = p_next3;
-                c1 = c4;
-            }
-
-            if( c1 < threshold )
-            {
-                p_cur->p = p;
-
-                if( layer == 0 )
-                {
-                    p->a++;
-                    p_cur = _CV_NEXT_BASE_C3(p_cur,1);
-                    if( is_last_iter )
-                        icvMaxRoi1( &(p->rect), j + 1, i );
-                }
-                else
-                {
-                    int a = p_cur->a;
-
-                    p->a += a;
-                    p_cur->c.blue = p_cur->c.green = p_cur->c.red = 0;
-                    p_cur++;
-                    if( is_last_iter && a != 0 )
-                        icvMaxRoi( &(p->rect), &(p_cur[-1].rect) );
-                }
-            }
-            else
-            {
-                p_cur->p = stub;
-                if( is_last_iter /* && ( == 0 || p_cur->a != 0) */  )
-                {
-                    cmp_node.data = p_cur;
-                    CV_WRITE_SEQ_ELEM( cmp_node, writer );
-                }
-                if( layer == 0 )
-                {
-                    p_cur = _CV_NEXT_BASE_C3(p_cur,1);
-                }
-                else
-                {
-                    p_cur->c.blue = p_cur->c.green = p_cur->c.red = 0;
-                    p_cur++;
-                }
-            }
-        }
-
-        /* clear c's */
-        if( layer > 0 )
-        {
-            p_cur->c.blue = p_cur->c.green = p_cur->c.red = 0;
-            p_cur++;
-        }
-
-        if( !(i & 1) )
-        {
-            p_next1 -= size.width >> 1;
-            p_next3 -= size.width >> 1;
-        }
-        else
-        {
-            p_next1++;
-            p_next3++;
-        }
-    }
-
-    return CV_OK;
-}
-
-
-
-/****************************************************************************************\
-
-    clusterization segmented components
-
-\****************************************************************************************/
-static void
-icvExpandBaseLevelC1( _CvPyramid * base_p, _CvPyramid * p, _CvPyramidBase * start, int width )
-{
-    int x = (int)((_CvPyramidBase *) base_p - start);
-    int y = x / width;
-
-    x -= y * width;
-    p->a = 1;
-    p->rect.x1 = (ushort) x;
-    p->rect.y1 = (ushort) y;
-    p->rect.x2 = (ushort) (x + 1);
-    p->rect.y2 = (ushort) (y + 1);
-    p->c = base_p->c;
-}
-
-CvStatus
-icvSegmentClusterC1( CvSeq * cmp_seq, CvSeq * res_seq,
-                     double threshold, _CvPyramid * first_level_end, CvSize first_level_size )
-{
-    const double eps = 1.;
-    CvSeqWriter writer;
-    CvSeqReader reader;
-    _CvPyramid temp_cmp;
-    _CvPyramidBase *first_level_start = (_CvPyramidBase *) first_level_end -
-        first_level_size.width * first_level_size.height;
-    int c, i, count = cmp_seq->total;
-
-    cvStartReadSeq( cmp_seq, &reader, 0 );
-    cvStartAppendToSeq( res_seq, &writer );
-
-    if( threshold < eps )
-    {
-        /* if threshold is too small then simply copy all
-           the components to the output sequence */
-        for( i = 0; i < count; i++ )
-        {
-            CvConnectedComp comp;
-            _CvPyramid *cmp = (_CvPyramid *) (((_CvListNode *) reader.ptr)->data);
-            Cv32suf _c;
-
-            if( cmp < first_level_end )
-            {
-                icvExpandBaseLevelC1( cmp, &temp_cmp, first_level_start,
-                                      first_level_size.width );
-                cmp = &temp_cmp;
-            }
-
-            _c.i = cvRound( cmp->c );
-            cmp->c = _c.f;
-            comp.value = cvRealScalar(_c.i);
-            comp.area = cmp->a;
-            comp.rect.x = cmp->rect.x1;
-            comp.rect.y = cmp->rect.y1;
-            comp.rect.width = cmp->rect.x2 - cmp->rect.x1;
-            comp.rect.height = cmp->rect.y2 - cmp->rect.y1;
-            comp.contour = 0;
-
-            CV_WRITE_SEQ_ELEM( comp, writer );
-            CV_NEXT_SEQ_ELEM( sizeof( _CvListNode ), reader );
-        }
-    }
-    else
-    {
-        _CvListNode stub_node;
-        _CvListNode *prev = &stub_node;
-
-        stub_node.next = 0;
-
-        for( i = 0; i < count; i++ )
-        {
-            _CvListNode *node = (_CvListNode *) reader.ptr;
-
-            prev->next = node;
-            prev = node;
-            CV_NEXT_SEQ_ELEM( sizeof( _CvListNode ), reader );
-        }
-        prev->next = 0;
-        prev = stub_node.next;
-
-        while( prev )
-        {
-            _CvListNode *node = prev->next;
-            _CvListNode *acc = prev;
-            _CvPyramid *cmp = (_CvPyramid *) (acc->data);
-            CvConnectedComp comp;
-            float c0 = cmp->c;
-
-            if( cmp < first_level_end )
-            {
-                icvExpandBaseLevelC1( cmp, &temp_cmp, first_level_start,
-                                      first_level_size.width );
-            }
-            else
-            {
-                temp_cmp = *cmp;
-                temp_cmp.c *= temp_cmp.a;
-            }
-
-            acc->next = 0;
-            stub_node.next = 0;
-            prev = &stub_node;
-
-            while( node )
-            {
-                cmp = (_CvPyramid *) (node->data);
-                if( fabs( c0 - cmp->c ) < threshold )
-                {
-                    _CvPyramid temp;
-
-                    /* exclude from global list and add to list of joint component */
-                    prev->next = node->next;
-                    node->next = acc;
-                    acc = node;
-
-                    if( cmp < first_level_end )
-                    {
-                        icvExpandBaseLevelC1( cmp, &temp, first_level_start,
-                                              first_level_size.width );
-                        cmp = &temp;
-                    }
-
-                    temp_cmp.a += cmp->a;
-                    temp_cmp.c += cmp->c * cmp->a;
-                    icvMaxRoi( &(temp_cmp.rect), &(cmp->rect) );
-                }
-                else
-                {
-                    if( prev == &stub_node )
-                    {
-                        stub_node.next = node;
-                    }
-                    prev = node;
-                }
-                node = prev->next;
-            }
-
-            if( temp_cmp.a != 0 )
-            {
-                c = cvRound( temp_cmp.c / temp_cmp.a );
-            }
-            else
-            {
-                c = cvRound( c0 );
-            }
-            node = acc;
-
-            while( node )
-            {
-                Cv32suf _c;
-                cmp = (_CvPyramid *) (node->data);
-                _c.i = c; cmp->c = _c.f;
-                node = node->next;
-            }
-
-            comp.value = cvRealScalar(c);
-            comp.area = temp_cmp.a;
-            comp.rect.x = temp_cmp.rect.x1;
-            comp.rect.y = temp_cmp.rect.y1;
-            comp.rect.width = temp_cmp.rect.x2 - temp_cmp.rect.x1;
-            comp.rect.height = temp_cmp.rect.y2 - temp_cmp.rect.y1;
-            comp.contour = 0;
-
-            CV_WRITE_SEQ_ELEM( comp, writer );
-            prev = stub_node.next;
-        }
-    }
-
-    cvEndWriteSeq( &writer );
-    return CV_OK;
-}
-
-/****************************************************************************************\
-
-    clusterization segmented components
-
-\****************************************************************************************/
-static void
-icvExpandBaseLevelC3( _CvPyramidC3 * base_p, _CvPyramidC3 * p,
-                      _CvPyramidBaseC3 * start, int width )
-{
-    int x = (int)((_CvPyramidBaseC3 *) base_p - start);
-    int y = x / width;
-
-    x -= y * width;
-    p->a = 1;
-    p->rect.x1 = (ushort) x;
-    p->rect.y1 = (ushort) y;
-    p->rect.x2 = (ushort) (x + 1);
-    p->rect.y2 = (ushort) (y + 1);
-    p->c = base_p->c;
-}
-
-CvStatus
-icvSegmentClusterC3( CvSeq * cmp_seq, CvSeq * res_seq,
-                     double threshold,
-                     _CvPyramidC3 * first_level_end, CvSize first_level_size )
-{
-    const double eps = 1.;
-    CvSeqWriter writer;
-    CvSeqReader reader;
-    _CvPyramidC3 temp_cmp;
-    _CvPyramidBaseC3 *first_level_start = (_CvPyramidBaseC3 *) first_level_end -
-        first_level_size.width * first_level_size.height;
-    int i, count = cmp_seq->total;
-    int c_blue, c_green, c_red;
-
-    cvStartReadSeq( cmp_seq, &reader, 0 );
-    cvStartAppendToSeq( res_seq, &writer );
-
-    if( threshold < eps )
-    {
-        /* if threshold is too small then simply copy all
-           the components to the output sequence */
-        for( i = 0; i < count; i++ )
-        {
-            CvConnectedComp comp;
-            _CvPyramidC3 *cmp = (_CvPyramidC3 *) (((_CvListNode *) reader.ptr)->data);
-            Cv32suf _c;
-
-            if( cmp < first_level_end )
-            {
-                icvExpandBaseLevelC3( cmp, &temp_cmp, first_level_start,
-                                      first_level_size.width );
-                cmp = &temp_cmp;
-            }
-
-            c_blue = cvRound( cmp->c.blue );
-            c_green = cvRound( cmp->c.green );
-            c_red = cvRound( cmp->c.red );
-            _c.i = c_blue; cmp->c.blue = _c.f;
-            _c.i = c_green; cmp->c.green = _c.f;
-            _c.i = c_red; cmp->c.red = _c.f;
-            comp.value = cvScalar( c_blue, c_green, c_red );
-            comp.area = cmp->a;
-            comp.rect.x = cmp->rect.x1;
-            comp.rect.y = cmp->rect.y1;
-            comp.rect.width = cmp->rect.x2 - cmp->rect.x1;
-            comp.rect.height = cmp->rect.y2 - cmp->rect.y1;
-            comp.contour = 0;
-
-            CV_WRITE_SEQ_ELEM( comp, writer );
-            CV_NEXT_SEQ_ELEM( sizeof( _CvListNode ), reader );
-        }
-    }
-    else
-    {
-        _CvListNode stub_node;
-        _CvListNode *prev = &stub_node;
-
-        stub_node.next = 0;
-
-        for( i = 0; i < count; i++ )
-        {
-            _CvListNode *node = (_CvListNode *) reader.ptr;
-
-            prev->next = node;
-            prev = node;
-            CV_NEXT_SEQ_ELEM( sizeof( _CvListNode ), reader );
-        }
-        prev->next = 0;
-        prev = stub_node.next;
-
-        while( prev )
-        {
-            _CvListNode *node = prev->next;
-            _CvListNode *acc = prev;
-            _CvPyramidC3 *cmp = (_CvPyramidC3 *) (acc->data);
-            CvConnectedComp comp;
-            _CvRGBf c0 = cmp->c;
-
-            if( cmp < first_level_end )
-            {
-                icvExpandBaseLevelC3( cmp, &temp_cmp, first_level_start,
-                                      first_level_size.width );
-            }
-            else
-            {
-                temp_cmp = *cmp;
-                temp_cmp.c.blue *= temp_cmp.a;
-                temp_cmp.c.green *= temp_cmp.a;
-                temp_cmp.c.red *= temp_cmp.a;
-            }
-
-            acc->next = 0;
-            stub_node.next = 0;
-            prev = &stub_node;
-
-            while( node )
-            {
-                cmp = (_CvPyramidC3 *) (node->data);
-                if( _CV_RGB_DIST( c0, cmp->c ) < threshold )
-                {
-                    _CvPyramidC3 temp;
-
-                    /* exclude from global list and add to list of joint component */
-                    prev->next = node->next;
-                    node->next = acc;
-                    acc = node;
-
-                    if( cmp < first_level_end )
-                    {
-                        icvExpandBaseLevelC3( cmp, &temp, first_level_start,
-                                              first_level_size.width );
-                        cmp = &temp;
-                    }
-
-                    temp_cmp.a += cmp->a;
-                    temp_cmp.c.blue += cmp->c.blue * cmp->a;
-                    temp_cmp.c.green += cmp->c.green * cmp->a;
-                    temp_cmp.c.red += cmp->c.red * cmp->a;
-                    icvMaxRoi( &(temp_cmp.rect), &(cmp->rect) );
-                }
-                else
-                {
-                    if( prev == &stub_node )
-                    {
-                        stub_node.next = node;
-                    }
-                    prev = node;
-                }
-                node = prev->next;
-            }
-
-            if( temp_cmp.a != 0 )
-            {
-                c_blue = cvRound( temp_cmp.c.blue / temp_cmp.a );
-                c_green = cvRound( temp_cmp.c.green / temp_cmp.a );
-                c_red = cvRound( temp_cmp.c.red / temp_cmp.a );
-            }
-            else
-            {
-                c_blue = cvRound( c0.blue );
-                c_green = cvRound( c0.green );
-                c_red = cvRound( c0.red );
-            }
-            node = acc;
-
-            while( node )
-            {
-                Cv32suf _c;
-                cmp = (_CvPyramidC3 *) (node->data);
-                _c.i = c_blue; cmp->c.blue = _c.f;
-                _c.i = c_green; cmp->c.green = _c.f;
-                _c.i = c_red; cmp->c.red = _c.f;
-                node = node->next;
-            }
-
-            comp.value = cvScalar( c_blue, c_green, c_red );
-            comp.area = temp_cmp.a;
-            comp.rect.x = temp_cmp.rect.x1;
-            comp.rect.y = temp_cmp.rect.y1;
-            comp.rect.width = temp_cmp.rect.x2 - temp_cmp.rect.x1;
-            comp.rect.height = temp_cmp.rect.y2 - temp_cmp.rect.y1;
-            comp.contour = 0;
-
-            CV_WRITE_SEQ_ELEM( comp, writer );
-            prev = stub_node.next;
-        }
-    }
-
-    cvEndWriteSeq( &writer );
-    return CV_OK;
-}
-
-/****************************************************************************************\
-
-                 definition of the maximum roi size
-
-\****************************************************************************************/
-void
-icvMaxRoi( _CvRect16u * max_rect, _CvRect16u * cur_rect )
-{
-    if( max_rect->x2 == 0 )
-        *max_rect = *cur_rect;
-    else
-    {
-        if( max_rect->x1 > cur_rect->x1 )
-            max_rect->x1 = cur_rect->x1;
-        if( max_rect->y1 > cur_rect->y1 )
-            max_rect->y1 = cur_rect->y1;
-
-        if( max_rect->x2 < cur_rect->x2 )
-            max_rect->x2 = cur_rect->x2;
-        if( max_rect->y2 < cur_rect->y2 )
-            max_rect->y2 = cur_rect->y2;
-    }
-}
-
-void
-icvMaxRoi1( _CvRect16u * max_rect, int x, int y )
-{
-    if( max_rect->x2 == 0 )
-    {
-        max_rect->x1 = (ushort) x;
-        max_rect->y1 = (ushort) y;
-
-        ++x;
-        ++y;
-
-        max_rect->x2 = (ushort) x;
-        max_rect->y2 = (ushort) y;
-    }
-    else
-    {
-        if( max_rect->x1 > x )
-            max_rect->x1 = (ushort) x;
-        if( max_rect->y1 > y )
-            max_rect->y1 = (ushort) y;
-
-        ++x;
-        ++y;
-
-        if( max_rect->x2 < x )
-            max_rect->x2 = (ushort) x;
-        if( max_rect->y2 < y )
-            max_rect->y2 = (ushort) y;
-    }
-}
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name:    cvPyrSegmentation
-//    Purpose:
-//      segments an image using pyramid-linking technique
-//    Context:
-//    Parameters:
-//      src - source image
-//      dst - destination image
-//      comp - pointer to returned connected component sequence
-//      storage - where the sequence is stored
-//      level - maximal pyramid level
-//      threshold1 - first threshold, affecting on detalization level when pyramid
-//                   is built.
-//      threshold2 - second threshold - affects on final components merging.
-//    Returns:
-//    Notes:
-//      Source and destination image must be equal types and channels
-//F*/
-CV_IMPL void
-cvPyrSegmentation( IplImage * src,
-                   IplImage * dst,
-                   CvMemStorage * storage,
-                   CvSeq ** comp, int level, double threshold1, double threshold2 )
-{
-    CvSize src_size, dst_size;
-    uchar *src_data = 0;
-    uchar *dst_data = 0;
-    int src_step = 0, dst_step = 0;
-    int thresh1 = cvRound( threshold1 );
-    int thresh2 = cvRound( threshold2 );
-
-    if( src->depth != IPL_DEPTH_8U )
-        CV_Error( CV_BadDepth, "Unsupported format" );
-
-    if( src->depth != dst->depth || src->nChannels != dst->nChannels )
-        CV_Error( CV_StsBadArg, "src and dst have different formats" );
-
-    cvGetRawData( src, &src_data, &src_step, &src_size );
-    cvGetRawData( dst, &dst_data, &dst_step, &dst_size );
-
-    if( src_size.width != dst_size.width ||
-        src_size.height != dst_size.height )
-        CV_Error( CV_StsBadArg, "src and dst have different ROIs" );
-
-    switch (src->nChannels)
-    {
-    case 1:
-        IPPI_CALL( icvPyrSegmentation8uC1R( src_data, src_step,
-                                            dst_data, dst_step,
-                                            src_size,
-                                            CV_GAUSSIAN_5x5,
-                                            comp, storage, level, thresh1, thresh2 ));
-        break;
-    case 3:
-        IPPI_CALL( icvPyrSegmentation8uC3R( src_data, src_step,
-                                            dst_data, dst_step,
-                                            src_size,
-                                            CV_GAUSSIAN_5x5,
-                                            comp, storage, level, thresh1, thresh2 ));
-        break;
-    default:
-        CV_Error( CV_BadNumChannels, "Unsupported format" );
-    }
-}
-
-
-/* End of file. */
diff --git a/modules/legacy/src/scanlines.cpp b/modules/legacy/src/scanlines.cpp
deleted file mode 100644 (file)
index b83da83..0000000
+++ /dev/null
@@ -1,2016 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-#include "_vm.h"
-
-//#define REAL_ZERO(x) ( (x) < 1e-8 && (x) > -1e-8)
-
-static CvStatus
-icvGetNormalVector3( CvMatrix3 * Matrix, float *v )
-{
-/*  return vector v that is any 3-vector perpendicular
-    to all the row vectors of Matrix */
-
-    double *solutions = 0;
-    double M[3 * 3];
-    double B[3] = { 0.f, 0.f, 0.f };
-    int i, j, res;
-
-    if( Matrix == 0 || v == 0 )
-        return CV_NULLPTR_ERR;
-
-    for( i = 0; i < 3; i++ )
-    {
-        for( j = 0; j < 3; j++ )
-            M[i * 3 + j] = (double) (Matrix->m[i][j]);
-    }                           /* for */
-
-    res = icvGaussMxN( M, B, 3, 3, &solutions );
-
-    if( res == -1 )
-        return CV_BADFACTOR_ERR;
-
-    if( res > 0 && solutions )
-    {
-        v[0] = (float) solutions[0];
-        v[1] = (float) solutions[1];
-        v[2] = (float) solutions[2];
-        res = 0;
-    }
-    else
-        res = 1;
-
-    if( solutions )
-        cvFree( &solutions );
-
-    if( res )
-        return CV_BADFACTOR_ERR;
-    else
-        return CV_NO_ERR;
-
-}                               /* icvgetNormalVector3 */
-
-
-/*=====================================================================================*/
-
-static CvStatus
-icvMultMatrixVector3( CvMatrix3 * m, float *src, float *dst )
-{
-    if( m == 0 || src == 0 || dst == 0 )
-        return CV_NULLPTR_ERR;
-
-    dst[0] = m->m[0][0] * src[0] + m->m[0][1] * src[1] + m->m[0][2] * src[2];
-    dst[1] = m->m[1][0] * src[0] + m->m[1][1] * src[1] + m->m[1][2] * src[2];
-    dst[2] = m->m[2][0] * src[0] + m->m[2][1] * src[1] + m->m[2][2] * src[2];
-
-    return CV_NO_ERR;
-
-}                               /* icvMultMatrixVector3 */
-
-
-/*=====================================================================================*/
-
-static CvStatus
-icvMultMatrixTVector3( CvMatrix3 * m, float *src, float *dst )
-{
-    if( m == 0 || src == 0 || dst == 0 )
-        return CV_NULLPTR_ERR;
-
-    dst[0] = m->m[0][0] * src[0] + m->m[1][0] * src[1] + m->m[2][0] * src[2];
-    dst[1] = m->m[0][1] * src[0] + m->m[1][1] * src[1] + m->m[2][1] * src[2];
-    dst[2] = m->m[0][2] * src[0] + m->m[1][2] * src[1] + m->m[2][2] * src[2];
-
-    return CV_NO_ERR;
-
-}                               /* icvMultMatrixTVector3 */
-
-/*=====================================================================================*/
-
-static CvStatus
-icvCrossLines( float *line1, float *line2, float *cross_point )
-{
-    float delta;
-
-    if( line1 == 0 && line2 == 0 && cross_point == 0 )
-        return CV_NULLPTR_ERR;
-
-    delta = line1[0] * line2[1] - line1[1] * line2[0];
-
-    if( REAL_ZERO( delta ))
-        return CV_BADFACTOR_ERR;
-
-    cross_point[0] = (-line1[2] * line2[1] + line1[1] * line2[2]) / delta;
-    cross_point[1] = (-line1[0] * line2[2] + line1[2] * line2[0]) / delta;
-    cross_point[2] = 1;
-
-    return CV_NO_ERR;
-}                               /* icvCrossLines */
-
-
-
-/*======================================================================================*/
-
-static CvStatus
-icvMakeScanlines( CvMatrix3 * matrix,
-                  CvSize imgSize,
-                  int *scanlines_1, int *scanlines_2, int *lens_1, int *lens_2, int *numlines )
-{
-
-    CvStatus error = icvGetCoefficient( matrix, imgSize, scanlines_2, scanlines_1, numlines );
-
-    /* Make Length of scanlines */
-    if( scanlines_1 == 0 && scanlines_2 == 0 )
-        return error;
-
-    icvMakeScanlinesLengths( scanlines_1, *numlines, lens_1 );
-    icvMakeScanlinesLengths( scanlines_2, *numlines, lens_2 );
-
-    return CV_NO_ERR;
-}                               /* icvMakeScanlines */
-
-
-/*======================================================================================*/
-
-CvStatus
-icvMakeScanlinesLengths( int *scanlines, int numlines, int *lens )
-{
-    int index;
-    int x1, y1, x2, y2, dx, dy;
-    int curr;
-
-    curr = 0;
-
-    for( index = 0; index < numlines; index++ )
-    {
-
-        x1 = scanlines[curr++];
-        y1 = scanlines[curr++];
-        x2 = scanlines[curr++];
-        y2 = scanlines[curr++];
-
-        dx = abs( x1 - x2 ) + 1;
-        dy = abs( y1 - y2 ) + 1;
-
-        lens[index] = MAX( dx, dy );
-
-    }
-    return CV_NO_ERR;
-}
-
-/*======================================================================================*/
-
-static CvStatus
-icvMakeAlphaScanlines( int *scanlines_1,
-                       int *scanlines_2,
-                       int *scanlines_a, int *lens, int numlines, float alpha )
-{
-    int index;
-    int x1, y1, x2, y2;
-    int curr;
-    int dx, dy;
-    int curr_len;
-
-    curr = 0;
-    curr_len = 0;
-    for( index = 0; index < numlines; index++ )
-    {
-
-        x1 = (int) (scanlines_1[curr] * alpha + scanlines_2[curr] * (1.0 - alpha));
-
-        scanlines_a[curr++] = x1;
-
-        y1 = (int) (scanlines_1[curr] * alpha + scanlines_2[curr] * (1.0 - alpha));
-
-        scanlines_a[curr++] = y1;
-
-        x2 = (int) (scanlines_1[curr] * alpha + scanlines_2[curr] * (1.0 - alpha));
-
-        scanlines_a[curr++] = x2;
-
-        y2 = (int) (scanlines_1[curr] * alpha + scanlines_2[curr] * (1.0 - alpha));
-
-        scanlines_a[curr++] = y2;
-
-        dx = abs( x1 - x2 ) + 1;
-        dy = abs( y1 - y2 ) + 1;
-
-        lens[curr_len++] = MAX( dx, dy );
-
-    }
-
-    return CV_NO_ERR;
-}
-
-/*======================================================================================*/
-
-
-
-
-
-
-
-/* //////////////////////////////////////////////////////////////////////////////////// */
-
-CvStatus
-icvGetCoefficient( CvMatrix3 * matrix,
-                   CvSize imgSize, int *scanlines_1, int *scanlines_2, int *numlines )
-{
-    float l_epipole[3];
-    float r_epipole[3];
-    CvMatrix3 *F;
-    CvMatrix3 Ft;
-    CvStatus error;
-    int i, j;
-
-    F = matrix;
-
-    l_epipole[2] = -1;
-    r_epipole[2] = -1;
-
-    if( F == 0 )
-    {
-        error = icvGetCoefficientDefault( matrix,
-                                          imgSize, scanlines_1, scanlines_2, numlines );
-        return error;
-    }
-
-
-    for( i = 0; i < 3; i++ )
-        for( j = 0; j < 3; j++ )
-            Ft.m[i][j] = F->m[j][i];
-
-
-    error = icvGetNormalVector3( &Ft, l_epipole );
-    if( error == CV_NO_ERR && !REAL_ZERO( l_epipole[2] ) && !REAL_ZERO( l_epipole[2] - 1 ))
-    {
-
-        l_epipole[0] /= l_epipole[2];
-        l_epipole[1] /= l_epipole[2];
-        l_epipole[2] = 1;
-    }                           /* if */
-
-    error = icvGetNormalVector3( F, r_epipole );
-    if( error == CV_NO_ERR && !REAL_ZERO( r_epipole[2] ) && !REAL_ZERO( r_epipole[2] - 1 ))
-    {
-
-        r_epipole[0] /= r_epipole[2];
-        r_epipole[1] /= r_epipole[2];
-        r_epipole[2] = 1;
-    }                           /* if */
-
-    if( REAL_ZERO( l_epipole[2] - 1 ) && REAL_ZERO( r_epipole[2] - 1 ))
-    {
-        error = icvGetCoefficientStereo( matrix,
-                                         imgSize,
-                                         l_epipole,
-                                         r_epipole, scanlines_1, scanlines_2, numlines );
-        if( error == CV_NO_ERR )
-            return CV_NO_ERR;
-    }
-    else
-    {
-        if( REAL_ZERO( l_epipole[2] ) && REAL_ZERO( r_epipole[2] ))
-        {
-            error = icvGetCoefficientOrto( matrix,
-                                           imgSize, scanlines_1, scanlines_2, numlines );
-            if( error == CV_NO_ERR )
-                return CV_NO_ERR;
-        }
-    }
-
-
-    error = icvGetCoefficientDefault( matrix, imgSize, scanlines_1, scanlines_2, numlines );
-
-    return error;
-
-}                               /* icvlGetCoefficient */
-
-/*===========================================================================*/
-CvStatus
-icvGetCoefficientDefault( CvMatrix3 *,
-                          CvSize imgSize, int *scanlines_1, int *scanlines_2, int *numlines )
-{
-    int curr;
-    int y;
-
-    *numlines = imgSize.height;
-
-    if( scanlines_1 == 0 && scanlines_2 == 0 )
-        return CV_NO_ERR;
-
-    curr = 0;
-    for( y = 0; y < imgSize.height; y++ )
-    {
-        scanlines_1[curr] = 0;
-        scanlines_1[curr + 1] = y;
-        scanlines_1[curr + 2] = imgSize.width - 1;
-        scanlines_1[curr + 3] = y;
-
-        scanlines_2[curr] = 0;
-        scanlines_2[curr + 1] = y;
-        scanlines_2[curr + 2] = imgSize.width - 1;
-        scanlines_2[curr + 3] = y;
-
-        curr += 4;
-    }
-
-    return CV_NO_ERR;
-
-}                               /* icvlGetCoefficientDefault */
-
-/*===========================================================================*/
-CvStatus
-icvGetCoefficientOrto( CvMatrix3 * matrix,
-                       CvSize imgSize, int *scanlines_1, int *scanlines_2, int *numlines )
-{
-    float l_start_end[4], r_start_end[4];
-    double a, b;
-    CvStatus error;
-    CvMatrix3 *F;
-
-    F = matrix;
-
-    if( F->m[0][2] * F->m[1][2] < 0 )
-    {                           /* on left / */
-
-        if( F->m[2][0] * F->m[2][1] < 0 )
-        {                       /* on right / */
-            error = icvGetStartEnd1( F, imgSize, l_start_end, r_start_end );
-
-
-        }
-        else
-        {                       /* on right \ */
-            error = icvGetStartEnd2( F, imgSize, l_start_end, r_start_end );
-        }                       /* if */
-
-    }
-    else
-    {                           /* on left \ */
-
-        if( F->m[2][0] * F->m[2][1] < 0 )
-        {                       /* on right / */
-            error = icvGetStartEnd3( F, imgSize, l_start_end, r_start_end );
-        }
-        else
-        {                       /* on right \ */
-            error = icvGetStartEnd4( F, imgSize, l_start_end, r_start_end );
-        }                       /* if */
-    }                           /* if */
-
-    if( error != CV_NO_ERR )
-        return error;
-
-    a = fabs( l_start_end[0] - l_start_end[2] );
-    b = fabs( r_start_end[0] - r_start_end[2] );
-    if( a > b )
-    {
-
-        error = icvBuildScanlineLeft( F,
-                                      imgSize,
-                                      scanlines_1, scanlines_2, l_start_end, numlines );
-
-    }
-    else
-    {
-
-        error = icvBuildScanlineRight( F,
-                                       imgSize,
-                                       scanlines_1, scanlines_2, r_start_end, numlines );
-
-    }                           /* if */
-
-    return error;
-
-}                               /* icvlGetCoefficientOrto */
-
-/*===========================================================================*/
-CvStatus
-icvGetStartEnd1( CvMatrix3 * matrix, CvSize imgSize, float *l_start_end, float *r_start_end )
-{
-
-    CvMatrix3 *F;
-    int width, height;
-    float l_diagonal[3];
-    float r_diagonal[3];
-    float l_point[3]={0,0,0}, r_point[3], epiline[3]={0,0,0};
-    CvStatus error = CV_OK;
-
-    F = matrix;
-    width = imgSize.width - 1;
-    height = imgSize.height - 1;
-
-    l_diagonal[0] = (float) 1 / width;
-    l_diagonal[1] = (float) 1 / height;
-    l_diagonal[2] = -1;
-
-    r_diagonal[0] = (float) 1 / width;
-    r_diagonal[1] = (float) 1 / height;
-    r_diagonal[2] = -1;
-
-    r_point[0] = (float) width;
-    r_point[1] = 0;
-    r_point[2] = 1;
-
-    icvMultMatrixVector3( F, r_point, epiline );
-    error = icvCrossLines( l_diagonal, epiline, l_point );
-
-    assert( error == CV_NO_ERR );
-
-    if( l_point[0] >= 0 && l_point[0] <= width )
-    {
-
-        l_start_end[0] = l_point[0];
-        l_start_end[1] = l_point[1];
-
-        r_start_end[0] = r_point[0];
-        r_start_end[1] = r_point[1];
-
-    }
-    else
-    {
-
-        if( l_point[0] < 0 )
-        {
-
-            l_point[0] = 0;
-            l_point[1] = (float) height;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-                l_start_end[0] = l_point[0];
-                l_start_end[1] = l_point[1];
-
-                r_start_end[0] = r_point[0];
-                r_start_end[1] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-
-        }
-        else
-        {                       /* if( l_point[0] > width ) */
-
-            l_point[0] = (float) width;
-            l_point[1] = 0;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[0] = l_point[0];
-                l_start_end[1] = l_point[1];
-
-                r_start_end[0] = r_point[0];
-                r_start_end[1] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-
-        }                       /* if */
-    }                           /* if */
-
-    r_point[0] = 0;
-    r_point[1] = (float) height;
-    r_point[2] = 1;
-
-    icvMultMatrixVector3( F, r_point, epiline );
-    error = icvCrossLines( l_diagonal, epiline, l_point );
-    assert( error == CV_NO_ERR );
-
-    if( l_point[0] >= 0 && l_point[0] <= width )
-    {
-
-        l_start_end[2] = l_point[0];
-        l_start_end[3] = l_point[1];
-
-        r_start_end[2] = r_point[0];
-        r_start_end[3] = r_point[1];
-
-    }
-    else
-    {
-
-        if( l_point[0] < 0 )
-        {
-
-            l_point[0] = 0;
-            l_point[1] = (float) height;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[2] = l_point[0];
-                l_start_end[3] = l_point[1];
-
-                r_start_end[2] = r_point[0];
-                r_start_end[3] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-
-        }
-        else
-        {                       /* if( l_point[0] > width ) */
-
-            l_point[0] = (float) width;
-            l_point[1] = 0;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[2] = l_point[0];
-                l_start_end[3] = l_point[1];
-
-                r_start_end[2] = r_point[0];
-                r_start_end[3] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-        }                       /* if */
-    }                           /* if */
-
-    return error;
-
-}                               /* icvlGetStartEnd1 */
-
-/*===========================================================================*/
-CvStatus
-icvGetStartEnd2( CvMatrix3 * matrix, CvSize imgSize, float *l_start_end, float *r_start_end )
-{
-
-
-    CvMatrix3 *F;
-    int width, height;
-    float l_diagonal[3];
-    float r_diagonal[3];
-    float l_point[3]={0,0,0}, r_point[3], epiline[3]={0,0,0};
-    CvStatus error = CV_OK;
-
-    F = matrix;
-
-    width = imgSize.width - 1;
-    height = imgSize.height - 1;
-
-    l_diagonal[0] = (float) 1 / width;
-    l_diagonal[1] = (float) 1 / height;
-    l_diagonal[2] = -1;
-
-    r_diagonal[0] = (float) height / width;
-    r_diagonal[1] = -1;
-    r_diagonal[2] = 0;
-
-    r_point[0] = 0;
-    r_point[1] = 0;
-    r_point[2] = 1;
-
-    icvMultMatrixVector3( F, r_point, epiline );
-
-    error = icvCrossLines( l_diagonal, epiline, l_point );
-
-    assert( error == CV_NO_ERR );
-
-    if( l_point[0] >= 0 && l_point[0] <= width )
-    {
-
-        l_start_end[0] = l_point[0];
-        l_start_end[1] = l_point[1];
-
-        r_start_end[0] = r_point[0];
-        r_start_end[1] = r_point[1];
-
-    }
-    else
-    {
-
-        if( l_point[0] < 0 )
-        {
-
-            l_point[0] = 0;
-            l_point[1] = (float) height;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[0] = l_point[0];
-                l_start_end[1] = l_point[1];
-
-                r_start_end[0] = r_point[0];
-                r_start_end[1] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-
-        }
-        else
-        {                       /* if( l_point[0] > width ) */
-
-            l_point[0] = (float) width;
-            l_point[1] = 0;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[0] = l_point[0];
-                l_start_end[1] = l_point[1];
-
-                r_start_end[0] = r_point[0];
-                r_start_end[1] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-        }                       /* if */
-    }                           /* if */
-
-    r_point[0] = (float) width;
-    r_point[1] = (float) height;
-    r_point[2] = 1;
-
-    icvMultMatrixVector3( F, r_point, epiline );
-    error = icvCrossLines( l_diagonal, epiline, l_point );
-    assert( error == CV_NO_ERR );
-
-    if( l_point[0] >= 0 && l_point[0] <= width )
-    {
-
-        l_start_end[2] = l_point[0];
-        l_start_end[3] = l_point[1];
-
-        r_start_end[2] = r_point[0];
-        r_start_end[3] = r_point[1];
-
-    }
-    else
-    {
-
-        if( l_point[0] < 0 )
-        {
-
-            l_point[0] = 0;
-            l_point[1] = (float) height;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[2] = l_point[0];
-                l_start_end[3] = l_point[1];
-
-                r_start_end[2] = r_point[0];
-                r_start_end[3] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-
-        }
-        else
-        {                       /* if( l_point[0] > width ) */
-
-            l_point[0] = (float) width;
-            l_point[1] = 0;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[2] = l_point[0];
-                l_start_end[3] = l_point[1];
-
-                r_start_end[2] = r_point[0];
-                r_start_end[3] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-        }
-    }                           /* if */
-
-    return error;
-
-}                               /* icvlGetStartEnd2 */
-
-/*===========================================================================*/
-CvStatus
-icvGetStartEnd3( CvMatrix3 * matrix, CvSize imgSize, float *l_start_end, float *r_start_end )
-{
-
-    CvMatrix3 *F;
-    int width, height;
-    float l_diagonal[3];
-    float r_diagonal[3];
-    float l_point[3]={0,0,0}, r_point[3], epiline[3]={0,0,0};
-    CvStatus error = CV_OK;
-
-    F = matrix;
-
-    width = imgSize.width - 1;
-    height = imgSize.height - 1;
-
-    l_diagonal[0] = (float) height / width;
-    l_diagonal[1] = -1;
-    l_diagonal[2] = 0;
-
-    r_diagonal[0] = (float) 1 / width;
-    r_diagonal[1] = (float) 1 / height;
-    r_diagonal[2] = -1;
-
-    r_point[0] = 0;
-    r_point[1] = 0;
-    r_point[2] = 1;
-
-    icvMultMatrixVector3( F, r_point, epiline );
-
-    error = icvCrossLines( l_diagonal, epiline, l_point );
-
-    assert( error == CV_NO_ERR );
-
-    if( l_point[0] >= 0 && l_point[0] <= width )
-    {
-
-        l_start_end[0] = l_point[0];
-        l_start_end[1] = l_point[1];
-
-        r_start_end[0] = r_point[0];
-        r_start_end[1] = r_point[1];
-
-    }
-    else
-    {
-
-        if( l_point[0] < 0 )
-        {
-
-            l_point[0] = 0;
-            l_point[1] = (float) height;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[0] = l_point[0];
-                l_start_end[1] = l_point[1];
-
-                r_start_end[0] = r_point[0];
-                r_start_end[1] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-
-        }
-        else
-        {                       /* if( l_point[0] > width ) */
-
-            l_point[0] = (float) width;
-            l_point[1] = 0;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[0] = l_point[0];
-                l_start_end[1] = l_point[1];
-
-                r_start_end[0] = r_point[0];
-                r_start_end[1] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-        }                       /* if */
-    }                           /* if */
-
-    r_point[0] = (float) width;
-    r_point[1] = (float) height;
-    r_point[2] = 1;
-
-    icvMultMatrixVector3( F, r_point, epiline );
-    error = icvCrossLines( l_diagonal, epiline, l_point );
-    assert( error == CV_NO_ERR );
-
-    if( l_point[0] >= 0 && l_point[0] <= width )
-    {
-
-        l_start_end[2] = l_point[0];
-        l_start_end[3] = l_point[1];
-
-        r_start_end[2] = r_point[0];
-        r_start_end[3] = r_point[1];
-
-    }
-    else
-    {
-
-        if( l_point[0] < 0 )
-        {
-
-            l_point[0] = 0;
-            l_point[1] = (float) height;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[2] = l_point[0];
-                l_start_end[3] = l_point[1];
-
-                r_start_end[2] = r_point[0];
-                r_start_end[3] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-
-        }
-        else
-        {                       /* if( l_point[0] > width ) */
-
-            l_point[0] = (float) width;
-            l_point[1] = 0;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[2] = l_point[0];
-                l_start_end[3] = l_point[1];
-
-                r_start_end[2] = r_point[0];
-                r_start_end[3] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-        }                       /* if */
-    }                           /* if */
-
-    return error;
-
-}                               /* icvlGetStartEnd3 */
-
-/*===========================================================================*/
-CvStatus
-icvGetStartEnd4( CvMatrix3 * matrix, CvSize imgSize, float *l_start_end, float *r_start_end )
-{
-    CvMatrix3 *F;
-    int width, height;
-    float l_diagonal[3];
-    float r_diagonal[3];
-    float l_point[3], r_point[3], epiline[3]={0,0,0};
-    CvStatus error;
-
-    F = matrix;
-
-    width = imgSize.width - 1;
-    height = imgSize.height - 1;
-
-    l_diagonal[0] = (float) height / width;
-    l_diagonal[1] = -1;
-    l_diagonal[2] = 0;
-
-    r_diagonal[0] = (float) height / width;
-    r_diagonal[1] = -1;
-    r_diagonal[2] = 0;
-
-    r_point[0] = 0;
-    r_point[1] = 0;
-    r_point[2] = 1;
-
-    icvMultMatrixVector3( F, r_point, epiline );
-    error = icvCrossLines( l_diagonal, epiline, l_point );
-
-    if( error != CV_NO_ERR )
-        return error;
-
-    if( l_point[0] >= 0 && l_point[0] <= width )
-    {
-
-        l_start_end[0] = l_point[0];
-        l_start_end[1] = l_point[1];
-
-        r_start_end[0] = r_point[0];
-        r_start_end[1] = r_point[1];
-
-    }
-    else
-    {
-
-        if( l_point[0] < 0 )
-        {
-
-            l_point[0] = 0;
-            l_point[1] = 0;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[0] = l_point[0];
-                l_start_end[1] = l_point[1];
-
-                r_start_end[0] = r_point[0];
-                r_start_end[1] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-
-        }
-        else
-        {                       /* if( l_point[0] > width ) */
-
-            l_point[0] = (float) width;
-            l_point[1] = (float) height;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[0] = l_point[0];
-                l_start_end[1] = l_point[1];
-
-                r_start_end[0] = r_point[0];
-                r_start_end[1] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-        }                       /* if */
-    }                           /* if */
-
-    r_point[0] = (float) width;
-    r_point[1] = (float) height;
-    r_point[2] = 1;
-
-    icvMultMatrixVector3( F, r_point, epiline );
-    error = icvCrossLines( l_diagonal, epiline, l_point );
-    assert( error == CV_NO_ERR );
-
-    if( l_point[0] >= 0 && l_point[0] <= width )
-    {
-
-        l_start_end[2] = l_point[0];
-        l_start_end[3] = l_point[1];
-
-        r_start_end[2] = r_point[0];
-        r_start_end[3] = r_point[1];
-
-    }
-    else
-    {
-
-        if( l_point[0] < 0 )
-        {
-
-            l_point[0] = 0;
-            l_point[1] = 0;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[2] = l_point[0];
-                l_start_end[3] = l_point[1];
-
-                r_start_end[2] = r_point[0];
-                r_start_end[3] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-
-        }
-        else
-        {                       /* if( l_point[0] > width ) */
-
-            l_point[0] = (float) width;
-            l_point[1] = (float) height;
-            l_point[2] = 1;
-
-            icvMultMatrixTVector3( F, l_point, epiline );
-            error = icvCrossLines( r_diagonal, epiline, r_point );
-            assert( error == CV_NO_ERR );
-
-            if( r_point[0] >= 0 && r_point[0] <= width )
-            {
-
-                l_start_end[2] = l_point[0];
-                l_start_end[3] = l_point[1];
-
-                r_start_end[2] = r_point[0];
-                r_start_end[3] = r_point[1];
-            }
-            else
-                return CV_BADFACTOR_ERR;
-        }                       /* if */
-    }                           /* if */
-
-    return CV_NO_ERR;
-
-}                               /* icvlGetStartEnd4 */
-
-/*===========================================================================*/
-CvStatus
-icvBuildScanlineLeft( CvMatrix3 * matrix,
-                      CvSize imgSize,
-                      int *scanlines_1, int *scanlines_2, float *l_start_end, int *numlines )
-{
-    int prewarp_height;
-    float l_point[3];
-    float r_point[3];
-    float height;
-    float delta_x;
-    float delta_y;
-    CvStatus error = CV_OK;
-    CvMatrix3 *F;
-    float i;
-    int offset;
-    float epiline[3] = {0,};
-    double a, b;
-
-    assert( l_start_end != 0 );
-
-    a = fabs( l_start_end[2] - l_start_end[0] );
-    b = fabs( l_start_end[3] - l_start_end[1] );
-    prewarp_height = cvRound( MAX(a, b) );
-
-    *numlines = prewarp_height;
-
-    if( scanlines_1 == 0 && scanlines_2 == 0 )
-        return CV_NO_ERR;
-
-    F = matrix;
-
-
-    l_point[2] = 1;
-    height = (float) prewarp_height;
-
-    delta_x = (l_start_end[2] - l_start_end[0]) / height;
-
-    l_start_end[0] += delta_x;
-    l_start_end[2] -= delta_x;
-
-    delta_x = (l_start_end[2] - l_start_end[0]) / height;
-    delta_y = (l_start_end[3] - l_start_end[1]) / height;
-
-    l_start_end[1] += delta_y;
-    l_start_end[3] -= delta_y;
-
-    delta_y = (l_start_end[3] - l_start_end[1]) / height;
-
-    for( i = 0, offset = 0; i < height; i++, offset += 4 )
-    {
-
-        l_point[0] = l_start_end[0] + i * delta_x;
-        l_point[1] = l_start_end[1] + i * delta_y;
-
-        icvMultMatrixTVector3( F, l_point, epiline );
-
-        error = icvGetCrossEpilineFrame( imgSize, epiline,
-                                         scanlines_2 + offset,
-                                         scanlines_2 + offset + 1,
-                                         scanlines_2 + offset + 2, scanlines_2 + offset + 3 );
-
-
-
-        assert( error == CV_NO_ERR );
-
-        r_point[0] = -(float) (*(scanlines_2 + offset));
-        r_point[1] = -(float) (*(scanlines_2 + offset + 1));
-        r_point[2] = -1;
-
-        icvMultMatrixVector3( F, r_point, epiline );
-
-        error = icvGetCrossEpilineFrame( imgSize, epiline,
-                                         scanlines_1 + offset,
-                                         scanlines_1 + offset + 1,
-                                         scanlines_1 + offset + 2, scanlines_1 + offset + 3 );
-
-        assert( error == CV_NO_ERR );
-    }                           /* for */
-
-    *numlines = prewarp_height;
-
-    return error;
-
-} /*icvlBuildScanlineLeft */
-
-/*===========================================================================*/
-CvStatus
-icvBuildScanlineRight( CvMatrix3 * matrix,
-                       CvSize imgSize,
-                       int *scanlines_1, int *scanlines_2, float *r_start_end, int *numlines )
-{
-    int prewarp_height;
-    float l_point[3];
-    float r_point[3];
-    float height;
-    float delta_x;
-    float delta_y;
-    CvStatus error = CV_OK;
-    CvMatrix3 *F;
-    float i;
-    int offset;
-    float epiline[3] = {0,};
-    double a, b;
-
-    assert( r_start_end != 0 );
-
-    a = fabs( r_start_end[2] - r_start_end[0] );
-    b = fabs( r_start_end[3] - r_start_end[1] );
-    prewarp_height = cvRound( MAX(a, b) );
-
-    *numlines = prewarp_height;
-
-    if( scanlines_1 == 0 && scanlines_2 == 0 )
-        return CV_NO_ERR;
-
-    F = matrix;
-
-    r_point[2] = 1;
-    height = (float) prewarp_height;
-
-    delta_x = (r_start_end[2] - r_start_end[0]) / height;
-
-    r_start_end[0] += delta_x;
-    r_start_end[2] -= delta_x;
-
-    delta_x = (r_start_end[2] - r_start_end[0]) / height;
-    delta_y = (r_start_end[3] - r_start_end[1]) / height;
-
-    r_start_end[1] += delta_y;
-    r_start_end[3] -= delta_y;
-
-    delta_y = (r_start_end[3] - r_start_end[1]) / height;
-
-    for( i = 0, offset = 0; i < height; i++, offset += 4 )
-    {
-
-        r_point[0] = r_start_end[0] + i * delta_x;
-        r_point[1] = r_start_end[1] + i * delta_y;
-
-        icvMultMatrixVector3( F, r_point, epiline );
-
-        error = icvGetCrossEpilineFrame( imgSize, epiline,
-                                         scanlines_1 + offset,
-                                         scanlines_1 + offset + 1,
-                                         scanlines_1 + offset + 2, scanlines_1 + offset + 3 );
-
-
-        assert( error == CV_NO_ERR );
-
-        l_point[0] = -(float) (*(scanlines_1 + offset));
-        l_point[1] = -(float) (*(scanlines_1 + offset + 1));
-
-        l_point[2] = -1;
-
-        icvMultMatrixTVector3( F, l_point, epiline );
-        error = icvGetCrossEpilineFrame( imgSize, epiline,
-                                         scanlines_2 + offset,
-                                         scanlines_2 + offset + 1,
-                                         scanlines_2 + offset + 2, scanlines_2 + offset + 3 );
-
-
-        assert( error == CV_NO_ERR );
-    }                           /* for */
-
-    *numlines = prewarp_height;
-
-    return error;
-
-} /*icvlBuildScanlineRight */
-
-/*===========================================================================*/
-#define Abs(x)              ( (x)<0 ? -(x):(x) )
-#define Sgn(x)              ( (x)<0 ? -1:1 )    /* Sgn(0) = 1 ! */
-
-static CvStatus
-icvBuildScanline( CvSize imgSize, float *epiline, float *kx, float *cx, float *ky, float *cy )
-{
-    float point[4][2], d;
-    int sign[4], i;
-
-    float width, height;
-
-    if( REAL_ZERO( epiline[0] ) && REAL_ZERO( epiline[1] ))
-        return CV_BADFACTOR_ERR;
-
-    width = (float) imgSize.width - 1;
-    height = (float) imgSize.height - 1;
-
-    sign[0] = Sgn( epiline[2] );
-    sign[1] = Sgn( epiline[0] * width + epiline[2] );
-    sign[2] = Sgn( epiline[1] * height + epiline[2] );
-    sign[3] = Sgn( epiline[0] * width + epiline[1] * height + epiline[2] );
-
-    i = 0;
-
-    if( sign[0] * sign[1] < 0 )
-    {
-
-        point[i][0] = -epiline[2] / epiline[0];
-        point[i][1] = 0;
-        i++;
-    }                           /* if */
-
-    if( sign[0] * sign[2] < 0 )
-    {
-
-        point[i][0] = 0;
-        point[i][1] = -epiline[2] / epiline[1];
-        i++;
-    }                           /* if */
-
-    if( sign[1] * sign[3] < 0 )
-    {
-
-        point[i][0] = width;
-        point[i][1] = -(epiline[0] * width + epiline[2]) / epiline[1];
-        i++;
-    }                           /* if */
-
-    if( sign[2] * sign[3] < 0 )
-    {
-
-        point[i][0] = -(epiline[1] * height + epiline[2]) / epiline[0];
-        point[i][1] = height;
-    }                           /* if */
-
-    if( sign[0] == sign[1] && sign[0] == sign[2] && sign[0] == sign[3] )
-        return CV_BADFACTOR_ERR;
-
-    if( !kx && !ky && !cx && !cy )
-        return CV_BADFACTOR_ERR;
-
-    if( kx && ky )
-    {
-
-        *kx = -epiline[1];
-        *ky = epiline[0];
-
-        d = (float) MAX( Abs( *kx ), Abs( *ky ));
-
-        *kx /= d;
-        *ky /= d;
-    }                           /* if */
-
-    if( cx && cy )
-    {
-
-        if( (point[0][0] - point[1][0]) * epiline[1] +
-            (point[1][1] - point[0][1]) * epiline[0] > 0 )
-        {
-
-            *cx = point[0][0];
-            *cy = point[0][1];
-
-        }
-        else
-        {
-
-            *cx = point[1][0];
-            *cy = point[1][1];
-        }                       /* if */
-    }                           /* if */
-
-    return CV_NO_ERR;
-
-}                               /* icvlBuildScanline */
-
-/*===========================================================================*/
-CvStatus
-icvGetCoefficientStereo( CvMatrix3 * matrix,
-                         CvSize imgSize,
-                         float *l_epipole,
-                         float *r_epipole, int *scanlines_1, int *scanlines_2, int *numlines )
-{
-    int i, j, turn;
-    float width, height;
-    float l_angle[2], r_angle[2];
-    float l_radius, r_radius;
-    float r_point[3], l_point[3];
-    float l_epiline[3] = {0,};
-    float r_epiline[3] = {0,};
-    float x, y;
-    float swap;
-
-    float radius1, radius2, radius3, radius4;
-
-    float l_start_end[4], r_start_end[4];
-    CvMatrix3 *F;
-    CvStatus error;
-    float Region[3][3][4] = {
-       {{0.f, 0.f, 1.f, 1.f}, {0.f, 1.f, 1.f, 1.f}, {0.f, 1.f, 1.f, 0.f}},
-        {{0.f, 0.f, 0.f, 1.f}, {2.f, 2.f, 2.f, 2.f}, {1.f, 1.f, 1.f, 0.f}},
-        {{1.f, 0.f, 0.f, 1.f}, {1.f, 0.f, 0.f, 0.f}, {1.f, 1.f, 0.f, 0.f}}
-    };
-
-
-    width = (float) imgSize.width - 1;
-    height = (float) imgSize.height - 1;
-
-    F = matrix;
-
-    if( F->m[0][0] * F->m[1][1] - F->m[1][0] * F->m[0][1] > 0 )
-        turn = 1;
-    else
-        turn = -1;
-
-    if( l_epipole[0] < 0 )
-        i = 0;
-    else if( l_epipole[0] < width )
-        i = 1;
-    else
-        i = 2;
-
-    if( l_epipole[1] < 0 )
-        j = 2;
-    else if( l_epipole[1] < height )
-        j = 1;
-    else
-        j = 0;
-
-    l_start_end[0] = Region[j][i][0];
-    l_start_end[1] = Region[j][i][1];
-    l_start_end[2] = Region[j][i][2];
-    l_start_end[3] = Region[j][i][3];
-
-    if( r_epipole[0] < 0 )
-        i = 0;
-    else if( r_epipole[0] < width )
-        i = 1;
-    else
-        i = 2;
-
-    if( r_epipole[1] < 0 )
-        j = 2;
-    else if( r_epipole[1] < height )
-        j = 1;
-    else
-        j = 0;
-
-    r_start_end[0] = Region[j][i][0];
-    r_start_end[1] = Region[j][i][1];
-    r_start_end[2] = Region[j][i][2];
-    r_start_end[3] = Region[j][i][3];
-
-    radius1 = l_epipole[0] * l_epipole[0] + (l_epipole[1] - height) * (l_epipole[1] - height);
-
-    radius2 = (l_epipole[0] - width) * (l_epipole[0] - width) +
-        (l_epipole[1] - height) * (l_epipole[1] - height);
-
-    radius3 = l_epipole[0] * l_epipole[0] + l_epipole[1] * l_epipole[1];
-
-    radius4 = (l_epipole[0] - width) * (l_epipole[0] - width) + l_epipole[1] * l_epipole[1];
-
-
-    l_radius = (float) sqrt( (double)MAX( MAX( radius1, radius2 ), MAX( radius3, radius4 )));
-
-    radius1 = r_epipole[0] * r_epipole[0] + (r_epipole[1] - height) * (r_epipole[1] - height);
-
-    radius2 = (r_epipole[0] - width) * (r_epipole[0] - width) +
-        (r_epipole[1] - height) * (r_epipole[1] - height);
-
-    radius3 = r_epipole[0] * r_epipole[0] + r_epipole[1] * r_epipole[1];
-
-    radius4 = (r_epipole[0] - width) * (r_epipole[0] - width) + r_epipole[1] * r_epipole[1];
-
-
-    r_radius = (float) sqrt( (double)MAX( MAX( radius1, radius2 ), MAX( radius3, radius4 )));
-
-    if( l_start_end[0] == 2 && r_start_end[0] == 2 )
-    {
-        if( l_radius > r_radius )
-        {
-
-            l_angle[0] = 0.0f;
-            l_angle[1] = (float) CV_PI;
-
-            error = icvBuildScanlineLeftStereo( imgSize,
-                                                matrix,
-                                                l_epipole,
-                                                l_angle,
-                                                l_radius, scanlines_1, scanlines_2, numlines );
-
-            return error;
-        }
-        else
-        {
-
-            r_angle[0] = 0.0f;
-            r_angle[1] = (float) CV_PI;
-
-            error = icvBuildScanlineRightStereo( imgSize,
-                                                 matrix,
-                                                 r_epipole,
-                                                 r_angle,
-                                                 r_radius,
-                                                 scanlines_1, scanlines_2, numlines );
-
-            return error;
-        }                       /* if */
-    }
-
-    if( l_start_end[0] == 2 )
-    {
-
-        r_angle[0] = (float) atan2( r_start_end[1] * height - r_epipole[1],
-                                    r_start_end[0] * width - r_epipole[0] );
-        r_angle[1] = (float) atan2( r_start_end[3] * height - r_epipole[1],
-                                    r_start_end[2] * width - r_epipole[0] );
-
-        if( r_angle[0] > r_angle[1] )
-            r_angle[1] += (float) (CV_PI * 2);
-
-        error = icvBuildScanlineRightStereo( imgSize,
-                                             matrix,
-                                             r_epipole,
-                                             r_angle,
-                                             r_radius, scanlines_1, scanlines_2, numlines );
-
-        return error;
-    }                           /* if */
-
-    if( r_start_end[0] == 2 )
-    {
-
-        l_point[0] = l_start_end[0] * width;
-        l_point[1] = l_start_end[1] * height;
-        l_point[2] = 1;
-
-        icvMultMatrixTVector3( F, l_point, r_epiline );
-
-        l_angle[0] = (float) atan2( l_start_end[1] * height - l_epipole[1],
-                                    l_start_end[0] * width - l_epipole[0] );
-        l_angle[1] = (float) atan2( l_start_end[3] * height - l_epipole[1],
-                                    l_start_end[2] * width - l_epipole[0] );
-
-        if( l_angle[0] > l_angle[1] )
-            l_angle[1] += (float) (CV_PI * 2);
-
-        error = icvBuildScanlineLeftStereo( imgSize,
-                                            matrix,
-                                            l_epipole,
-                                            l_angle,
-                                            l_radius, scanlines_1, scanlines_2, numlines );
-
-        return error;
-
-    }                           /* if */
-
-    l_start_end[0] *= width;
-    l_start_end[1] *= height;
-    l_start_end[2] *= width;
-    l_start_end[3] *= height;
-
-    r_start_end[0] *= width;
-    r_start_end[1] *= height;
-    r_start_end[2] *= width;
-    r_start_end[3] *= height;
-
-    r_point[0] = r_start_end[0];
-    r_point[1] = r_start_end[1];
-    r_point[2] = 1;
-
-    icvMultMatrixVector3( F, r_point, l_epiline );
-    error = icvBuildScanline( imgSize, l_epiline, 0, &x, 0, &y );
-
-    if( error == CV_NO_ERR )
-    {
-
-        l_angle[0] = (float) atan2( y - l_epipole[1], x - l_epipole[0] );
-
-        r_angle[0] = (float) atan2( r_point[1] - r_epipole[1], r_point[0] - r_epipole[0] );
-
-    }
-    else
-    {
-
-        if( turn == 1 )
-        {
-
-            l_point[0] = l_start_end[0];
-            l_point[1] = l_start_end[1];
-
-        }
-        else
-        {
-
-            l_point[0] = l_start_end[2];
-            l_point[1] = l_start_end[3];
-        }                       /* if */
-
-        l_point[2] = 1;
-
-        icvMultMatrixTVector3( F, l_point, r_epiline );
-        error = icvBuildScanline( imgSize, r_epiline, 0, &x, 0, &y );
-
-        if( error == CV_NO_ERR )
-        {
-
-            r_angle[0] = (float) atan2( y - r_epipole[1], x - r_epipole[0] );
-
-            l_angle[0] = (float) atan2( l_point[1] - l_epipole[1], l_point[0] - l_epipole[0] );
-
-        }
-        else
-            return CV_BADFACTOR_ERR;
-    }                           /* if */
-
-    r_point[0] = r_start_end[2];
-    r_point[1] = r_start_end[3];
-    r_point[2] = 1;
-
-    icvMultMatrixVector3( F, r_point, l_epiline );
-    error = icvBuildScanline( imgSize, l_epiline, 0, &x, 0, &y );
-
-    if( error == CV_NO_ERR )
-    {
-
-        l_angle[1] = (float) atan2( y - l_epipole[1], x - l_epipole[0] );
-
-        r_angle[1] = (float) atan2( r_point[1] - r_epipole[1], r_point[0] - r_epipole[0] );
-
-    }
-    else
-    {
-
-        if( turn == 1 )
-        {
-
-            l_point[0] = l_start_end[2];
-            l_point[1] = l_start_end[3];
-
-        }
-        else
-        {
-
-            l_point[0] = l_start_end[0];
-            l_point[1] = l_start_end[1];
-        }                       /* if */
-
-        l_point[2] = 1;
-
-        icvMultMatrixTVector3( F, l_point, r_epiline );
-        error = icvBuildScanline( imgSize, r_epiline, 0, &x, 0, &y );
-
-        if( error == CV_NO_ERR )
-        {
-
-            r_angle[1] = (float) atan2( y - r_epipole[1], x - r_epipole[0] );
-
-            l_angle[1] = (float) atan2( l_point[1] - l_epipole[1], l_point[0] - l_epipole[0] );
-
-        }
-        else
-            return CV_BADFACTOR_ERR;
-    }                           /* if */
-
-    if( l_angle[0] > l_angle[1] )
-    {
-
-        swap = l_angle[0];
-        l_angle[0] = l_angle[1];
-        l_angle[1] = swap;
-    }                           /* if */
-
-    if( l_angle[1] - l_angle[0] > CV_PI )
-    {
-
-        swap = l_angle[0];
-        l_angle[0] = l_angle[1];
-        l_angle[1] = swap + (float) (CV_PI * 2);
-    }                           /* if */
-
-    if( r_angle[0] > r_angle[1] )
-    {
-
-        swap = r_angle[0];
-        r_angle[0] = r_angle[1];
-        r_angle[1] = swap;
-    }                           /* if */
-
-    if( r_angle[1] - r_angle[0] > CV_PI )
-    {
-
-        swap = r_angle[0];
-        r_angle[0] = r_angle[1];
-        r_angle[1] = swap + (float) (CV_PI * 2);
-    }                           /* if */
-
-    if( l_radius * (l_angle[1] - l_angle[0]) > r_radius * (r_angle[1] - r_angle[0]) )
-        error = icvBuildScanlineLeftStereo( imgSize,
-                                            matrix,
-                                            l_epipole,
-                                            l_angle,
-                                            l_radius, scanlines_1, scanlines_2, numlines );
-
-    else
-        error = icvBuildScanlineRightStereo( imgSize,
-                                             matrix,
-                                             r_epipole,
-                                             r_angle,
-                                             r_radius, scanlines_1, scanlines_2, numlines );
-
-
-    return error;
-
-}                               /* icvGetCoefficientStereo */
-
-/*===========================================================================*/
-CvStatus
-icvBuildScanlineLeftStereo( CvSize imgSize,
-                            CvMatrix3 * matrix,
-                            float *l_epipole,
-                            float *l_angle,
-                            float l_radius, int *scanlines_1, int *scanlines_2, int *numlines )
-{
-    //int prewarp_width;
-    int prewarp_height;
-    float i;
-    int offset;
-    float height;
-    float delta;
-    float angle;
-    float l_point[3];
-    float l_epiline[3] = {0,};
-    float r_epiline[3] = {0,};
-    CvStatus error = CV_OK;
-    CvMatrix3 *F;
-
-
-    assert( l_angle != 0 && !REAL_ZERO( l_radius ));
-
-    /*prewarp_width = (int) (sqrt( image_width * image_width +
-                                 image_height * image_height ) + 1);*/
-
-    prewarp_height = (int) (l_radius * (l_angle[1] - l_angle[0]));
-
-    *numlines = prewarp_height;
-
-    if( scanlines_1 == 0 && scanlines_2 == 0 )
-        return CV_NO_ERR;
-
-    F = matrix;
-
-    l_point[2] = 1;
-    height = (float) prewarp_height;
-
-    delta = (l_angle[1] - l_angle[0]) / height;
-
-    l_angle[0] += delta;
-    l_angle[1] -= delta;
-
-    delta = (l_angle[1] - l_angle[0]) / height;
-
-    for( i = 0, offset = 0; i < height; i++, offset += 4 )
-    {
-
-        angle = l_angle[0] + i * delta;
-
-        l_point[0] = l_epipole[0] + l_radius * (float) cos( angle );
-        l_point[1] = l_epipole[1] + l_radius * (float) sin( angle );
-
-        icvMultMatrixTVector3( F, l_point, r_epiline );
-
-        error = icvGetCrossEpilineFrame( imgSize, r_epiline,
-                                         scanlines_2 + offset,
-                                         scanlines_2 + offset + 1,
-                                         scanlines_2 + offset + 2, scanlines_2 + offset + 3 );
-
-
-        l_epiline[0] = l_point[1] - l_epipole[1];
-        l_epiline[1] = l_epipole[0] - l_point[0];
-        l_epiline[2] = l_point[0] * l_epipole[1] - l_point[1] * l_epipole[0];
-
-        if( Sgn( l_epiline[0] * r_epiline[0] + l_epiline[1] * r_epiline[1] ) < 0 )
-        {
-
-            l_epiline[0] = -l_epiline[0];
-            l_epiline[1] = -l_epiline[1];
-            l_epiline[2] = -l_epiline[2];
-        }                       /* if */
-
-        error = icvGetCrossEpilineFrame( imgSize, l_epiline,
-                                         scanlines_1 + offset,
-                                         scanlines_1 + offset + 1,
-                                         scanlines_1 + offset + 2, scanlines_1 + offset + 3 );
-
-    }                           /* for */
-
-    *numlines = prewarp_height;
-
-    return error;
-
-}                               /* icvlBuildScanlineLeftStereo */
-
-/*===========================================================================*/
-CvStatus
-icvBuildScanlineRightStereo( CvSize imgSize,
-                             CvMatrix3 * matrix,
-                             float *r_epipole,
-                             float *r_angle,
-                             float r_radius,
-                             int *scanlines_1, int *scanlines_2, int *numlines )
-{
-    //int prewarp_width;
-    int prewarp_height;
-    float i;
-    int offset;
-    float height;
-    float delta;
-    float angle;
-    float r_point[3];
-    float l_epiline[3] = {0,};
-    float r_epiline[3] = {0,};
-    CvStatus error = CV_OK;
-    CvMatrix3 *F;
-
-    assert( r_angle != 0 && !REAL_ZERO( r_radius ));
-
-    /*prewarp_width = (int) (sqrt( image_width * image_width +
-                                 image_height * image_height ) + 1);*/
-
-    prewarp_height = (int) (r_radius * (r_angle[1] - r_angle[0]));
-
-    *numlines = prewarp_height;
-
-    if( scanlines_1 == 0 && scanlines_2 == 0 )
-        return CV_NO_ERR;
-
-    F = matrix;
-
-    r_point[2] = 1;
-    height = (float) prewarp_height;
-
-    delta = (r_angle[1] - r_angle[0]) / height;
-
-    r_angle[0] += delta;
-    r_angle[1] -= delta;
-
-    delta = (r_angle[1] - r_angle[0]) / height;
-
-    for( i = 0, offset = 0; i < height; i++, offset += 4 )
-    {
-
-        angle = r_angle[0] + i * delta;
-
-        r_point[0] = r_epipole[0] + r_radius * (float) cos( angle );
-        r_point[1] = r_epipole[1] + r_radius * (float) sin( angle );
-
-        icvMultMatrixVector3( F, r_point, l_epiline );
-
-        error = icvGetCrossEpilineFrame( imgSize, l_epiline,
-                                         scanlines_1 + offset,
-                                         scanlines_1 + offset + 1,
-                                         scanlines_1 + offset + 2, scanlines_1 + offset + 3 );
-
-        assert( error == CV_NO_ERR );
-
-        r_epiline[0] = r_point[1] - r_epipole[1];
-        r_epiline[1] = r_epipole[0] - r_point[0];
-        r_epiline[2] = r_point[0] * r_epipole[1] - r_point[1] * r_epipole[0];
-
-        if( Sgn( l_epiline[0] * r_epiline[0] + l_epiline[1] * r_epiline[1] ) < 0 )
-        {
-
-            r_epiline[0] = -r_epiline[0];
-            r_epiline[1] = -r_epiline[1];
-            r_epiline[2] = -r_epiline[2];
-        }                       /* if */
-
-        error = icvGetCrossEpilineFrame( imgSize, r_epiline,
-                                         scanlines_2 + offset,
-                                         scanlines_2 + offset + 1,
-                                         scanlines_2 + offset + 2, scanlines_2 + offset + 3 );
-
-        assert( error == CV_NO_ERR );
-    }                           /* for */
-
-    *numlines = prewarp_height;
-
-    return error;
-
-}                               /* icvlBuildScanlineRightStereo */
-
-/*===========================================================================*/
-CvStatus
-icvGetCrossEpilineFrame( CvSize imgSize, float *epiline, int *x1, int *y1, int *x2, int *y2 )
-{
-    int tx, ty;
-    float point[2][2];
-    int sign[4], i;
-    float width, height;
-    double tmpvalue;
-
-    if( REAL_ZERO( epiline[0] ) && REAL_ZERO( epiline[1] ))
-        return CV_BADFACTOR_ERR;
-
-    width = (float) imgSize.width - 1;
-    height = (float) imgSize.height - 1;
-
-    tmpvalue = epiline[2];
-    sign[0] = SIGN( tmpvalue );
-
-    tmpvalue = epiline[0] * width + epiline[2];
-    sign[1] = SIGN( tmpvalue );
-
-    tmpvalue = epiline[1] * height + epiline[2];
-    sign[2] = SIGN( tmpvalue );
-
-    tmpvalue = epiline[0] * width + epiline[1] * height + epiline[2];
-    sign[3] = SIGN( tmpvalue );
-
-    i = 0;
-    for( tx = 0; tx < 2; tx++ )
-    {
-        for( ty = 0; ty < 2; ty++ )
-        {
-
-            if( sign[ty * 2 + tx] == 0 )
-            {
-
-                point[i][0] = width * tx;
-                point[i][1] = height * ty;
-                i++;
-
-            }                   /* if */
-        }                       /* for */
-    }                           /* for */
-
-    if( sign[0] * sign[1] < 0 )
-    {
-        point[i][0] = -epiline[2] / epiline[0];
-        point[i][1] = 0;
-        i++;
-    }                           /* if */
-
-    if( sign[0] * sign[2] < 0 )
-    {
-        point[i][0] = 0;
-        point[i][1] = -epiline[2] / epiline[1];
-        i++;
-    }                           /* if */
-
-    if( sign[1] * sign[3] < 0 )
-    {
-        point[i][0] = width;
-        point[i][1] = -(epiline[0] * width + epiline[2]) / epiline[1];
-        i++;
-    }                           /* if */
-
-    if( sign[2] * sign[3] < 0 )
-    {
-        point[i][0] = -(epiline[1] * height + epiline[2]) / epiline[0];
-        point[i][1] = height;
-    }                           /* if */
-
-    if( sign[0] == sign[1] && sign[0] == sign[2] && sign[0] == sign[3] )
-        return CV_BADFACTOR_ERR;
-
-    if( (point[0][0] - point[1][0]) * epiline[1] +
-        (point[1][1] - point[0][1]) * epiline[0] > 0 )
-    {
-        *x1 = (int) point[0][0];
-        *y1 = (int) point[0][1];
-        *x2 = (int) point[1][0];
-        *y2 = (int) point[1][1];
-    }
-    else
-    {
-        *x1 = (int) point[1][0];
-        *y1 = (int) point[1][1];
-        *x2 = (int) point[0][0];
-        *y2 = (int) point[0][1];
-    }                           /* if */
-
-    return CV_NO_ERR;
-}                               /* icvlGetCrossEpilineFrame */
-
-/*=====================================================================================*/
-
-CV_IMPL void
-cvMakeScanlines( const CvMatrix3* matrix, CvSize imgSize,
-                 int *scanlines_1, int *scanlines_2,
-                 int *lens_1, int *lens_2, int *numlines )
-{
-    IPPI_CALL( icvMakeScanlines( (CvMatrix3*)matrix, imgSize, scanlines_1,
-                                 scanlines_2, lens_1, lens_2, numlines ));
-}
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name: cvDeleteMoire
-//    Purpose: The functions
-//    Context:
-//    Parameters:
-//
-//    Notes:
-//F*/
-CV_IMPL void
-cvMakeAlphaScanlines( int *scanlines_1,
-                      int *scanlines_2,
-                      int *scanlines_a, int *lens, int numlines, float alpha )
-{
-    IPPI_CALL( icvMakeAlphaScanlines( scanlines_1, scanlines_2, scanlines_a,
-                                      lens, numlines, alpha ));
-}
diff --git a/modules/legacy/src/segment.cpp b/modules/legacy/src/segment.cpp
deleted file mode 100644 (file)
index e61eead..0000000
+++ /dev/null
@@ -1,585 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-typedef struct Seg
-{
-    ushort y;
-    ushort l;
-    ushort r;
-    ushort Prevl;
-    ushort Prevr;
-    short  fl;
-}
-Seg;
-
-#define UP 1
-#define DOWN -1
-
-#define PUSH(Y,IL,IR,IPL,IPR,FL) {  stack[StIn].y=(ushort)(Y); \
-                                    stack[StIn].l=(ushort)(IL); \
-                                    stack[StIn].r=(ushort)(IR); \
-                                    stack[StIn].Prevl=(ushort)(IPL); \
-                                    stack[StIn].Prevr=(ushort)(IPR); \
-                                    stack[StIn].fl=(short)(FL); \
-                                    StIn++; }
-
-#define POP(Y,IL,IR,IPL,IPR,FL)  {  StIn--; \
-                                    Y=stack[StIn].y; \
-                                    IL=stack[StIn].l; \
-                                    IR=stack[StIn].r;\
-                                    IPL=stack[StIn].Prevl; \
-                                    IPR=stack[StIn].Prevr; \
-                                    FL=stack[StIn].fl; }
-
-
-#define DIFF(p1,p2) ((unsigned)((p1)[0] - (p2)[0] + d_lw)<=Interval && \
-                     (unsigned)((p1)[1] - (p2)[1] + d_lw)<=Interval && \
-                     (unsigned)((p1)[2] - (p2)[2] + d_lw)<=Interval)
-
-/*#define DIFF(p1,p2) (CV_IABS((p1)[0] - (p2)[0]) + \
-                     CV_IABS((p1)[1] - (p2)[1]) + \
-                     CV_IABS((p1)[2] - (p2)[2]) <=Interval )*/
-
-static CvStatus
-icvSegmFloodFill_Stage1( uchar* pImage, int step,
-                         uchar* pMask, int maskStep,
-                         CvSize /*roi*/, CvPoint seed,
-                         int* newVal, int d_lw, int d_up,
-                         CvConnectedComp * region,
-                         void *pStack )
-{
-    uchar* img = pImage + step * seed.y;
-    uchar* mask = pMask + maskStep * (seed.y + 1);
-    unsigned Interval = (unsigned) (d_up + d_lw);
-    Seg *stack = (Seg*)pStack;
-    int StIn = 0;
-    int i, L, R;
-    int area = 0;
-    int sum[] = { 0, 0, 0 };
-    int XMin, XMax, YMin = seed.y, YMax = seed.y;
-    int val0[3];
-
-    L = R = seed.x;
-    img = pImage + seed.y*step;
-    mask = pMask + seed.y*maskStep;
-    mask[L] = 1;
-
-    val0[0] = img[seed.x*3];
-    val0[1] = img[seed.x*3 + 1];
-    val0[2] = img[seed.x*3 + 2];
-
-    while( DIFF( img + (R+1)*3, /*img + R*3*/val0 ) && !mask[R + 1] )
-        mask[++R] = 2;
-
-    while( DIFF( img + (L-1)*3, /*img + L*3*/val0 ) && !mask[L - 1] )
-        mask[--L] = 2;
-
-    XMax = R;
-    XMin = L;
-    PUSH( seed.y, L, R, R + 1, R, UP );
-
-    while( StIn )
-    {
-        int k, YC, PL, PR, flag/*, curstep*/;
-
-        POP( YC, L, R, PL, PR, flag );
-
-        int data[][3] = { {-flag, L, R}, {flag, L, PL-1}, {flag,PR+1,R}};
-
-        if( XMax < R )
-            XMax = R;
-
-        if( XMin > L )
-            XMin = L;
-
-        if( YMax < YC )
-            YMax = YC;
-
-        if( YMin > YC )
-            YMin = YC;
-
-        for( k = 0; k < 3; k++ )
-        {
-            flag = data[k][0];
-            /*curstep = flag * step;*/
-            img = pImage + (YC + flag) * step;
-            mask = pMask + (YC + flag) * maskStep;
-            int left = data[k][1];
-            int right = data[k][2];
-
-            for( i = left; i <= right; i++ )
-            {
-                if( !mask[i] && DIFF( img + i*3, /*img - curstep + i*3*/val0 ))
-                {
-                    int j = i;
-                    mask[i] = 2;
-                    while( !mask[j - 1] && DIFF( img + (j - 1)*3, /*img + j*3*/val0 ))
-                        mask[--j] = 2;
-
-                    while( !mask[i + 1] &&
-                           (DIFF( img + (i+1)*3, /*img + i*3*/val0 ) ||
-                           (DIFF( img + (i+1)*3, /*img + (i+1)*3 - curstep*/val0) && i < R)))
-                        mask[++i] = 2;
-
-                    PUSH( YC + flag, j, i, L, R, -flag );
-                    i++;
-                }
-            }
-        }
-
-        img = pImage + YC * step;
-
-        for( i = L; i <= R; i++ )
-        {
-            sum[0] += img[i*3];
-            sum[1] += img[i*3 + 1];
-            sum[2] += img[i*3 + 2];
-        }
-
-        area += R - L + 1;
-    }
-
-    region->area = area;
-    region->rect.x = XMin;
-    region->rect.y = YMin;
-    region->rect.width = XMax - XMin + 1;
-    region->rect.height = YMax - YMin + 1;
-    region->value = cvScalarAll(0);
-
-    {
-        double inv_area = area ? 1./area : 0;
-        newVal[0] = cvRound( sum[0] * inv_area );
-        newVal[1] = cvRound( sum[1] * inv_area );
-        newVal[2] = cvRound( sum[2] * inv_area );
-    }
-
-    return CV_NO_ERR;
-}
-
-
-#undef PUSH
-#undef POP
-#undef DIFF
-
-
-static CvStatus
-icvSegmFloodFill_Stage2( uchar* pImage, int step,
-                         uchar* pMask, int maskStep,
-                         CvSize /*roi*/, int* newVal,
-                         CvRect rect )
-{
-    uchar* img = pImage + step * rect.y + rect.x * 3;
-    uchar* mask = pMask + maskStep * rect.y + rect.x;
-    uchar uv[] = { (uchar)newVal[0], (uchar)newVal[1], (uchar)newVal[2] };
-    int x, y;
-
-    for( y = 0; y < rect.height; y++, img += step, mask += maskStep )
-        for( x = 0; x < rect.width; x++ )
-            if( mask[x] == 2 )
-            {
-                mask[x] = 1;
-                img[x*3] = uv[0];
-                img[x*3+1] = uv[1];
-                img[x*3+2] = uv[2];
-            }
-
-    return CV_OK;
-}
-
-#if 0
-static void color_derv( const CvArr* srcArr, CvArr* dstArr, int thresh )
-{
-    static int tab[] = { 0, 2, 2, 1 };
-
-    uchar *src = 0, *dst = 0;
-    int dst_step, src_step;
-    int x, y;
-    CvSize size;
-
-    cvGetRawData( srcArr, (uchar**)&src, &src_step, &size );
-    cvGetRawData( dstArr, (uchar**)&dst, &dst_step, 0 );
-
-    memset( dst, 0, size.width*sizeof(dst[0]));
-    memset( (uchar*)dst + dst_step*(size.height-1), 0, size.width*sizeof(dst[0]));
-    src += 3;
-
-    #define  CV_IABS(a)     (((a) ^ ((a) < 0 ? -1 : 0)) - ((a) < 0 ? -1 : 0))
-
-    for( y = 1; y < size.height - 1; y++ )
-    {
-        src += src_step;
-        dst += dst_step;
-        uchar* src0 = src;
-
-        dst[0] = dst[size.width - 1] = 0;
-
-        for( x = 1; x < size.width - 1; x++, src += 3 )
-        {
-            /*int d[3];
-            int ad[3];
-            int f0, f1;
-            int val;*/
-            int m[3];
-            double val;
-            //double xx, yy;
-            int dh[3];
-            int dv[3];
-            dh[0] = src[0] - src[-3];
-            dv[0] = src[0] - src[-src_step];
-            dh[1] = src[1] - src[-2];
-            dv[1] = src[1] - src[1-src_step];
-            dh[2] = src[2] - src[-1];
-            dv[2] = src[2] - src[2-src_step];
-
-            m[0] = dh[0]*dh[0] + dh[1]*dh[1] + dh[2]*dh[2];
-            m[2] = dh[0]*dv[0] + dh[1]*dv[1] + dh[2]*dv[2];
-            m[1] = dv[0]*dv[0] + dv[1]*dv[1] + dh[2]*dh[2];
-
-            val = (m[0] + m[2]) +
-                sqrt(((double)((double)m[0] - m[2]))*(m[0] - m[2]) + (4.*m[1])*m[1]);
-
-            /*
-
-            xx = m[1];
-            yy = v - m[0];
-            v /= sqrt(xx*xx + yy*yy) + 1e-7;
-            xx *= v;
-            yy *= v;
-
-            dx[x] = (short)cvRound(xx);
-            dy[x] = (short)cvRound(yy);
-
-            //dx[x] = (short)cvRound(v);
-
-            //dx[x] = dy[x] = (short)v;
-            d[0] = src[0] - src[-3];
-            ad[0] = CV_IABS(d[0]);
-
-            d[1] = src[1] - src[-2];
-            ad[1] = CV_IABS(d[1]);
-
-            d[2] = src[2] - src[-1];
-            ad[2] = CV_IABS(d[2]);
-
-            f0 = ad[1] > ad[0];
-            f1 = ad[2] > ad[f0];
-
-            val = d[tab[f0*2 + f1]];
-
-            d[0] = src[0] - src[-src_step];
-            ad[0] = CV_IABS(d[0]);
-
-            d[1] = src[1] - src[1-src_step];
-            ad[1] = CV_IABS(d[1]);
-
-            d[2] = src[2] - src[2-src_step];
-            ad[2] = CV_IABS(d[2]);
-
-            f0 = ad[1] > ad[0];
-            f1 = ad[2] > ad[f0];
-
-            dst[x] = (uchar)(val + d[tab[f0*2 + f1]] > thresh ? 255 : 0);*/
-            dst[x] = (uchar)(val > thresh);
-        }
-
-        src = src0;
-    }
-
-}
-#endif
-
-static const CvPoint icvCodeDeltas[8] =
-    { CvPoint(1, 0), CvPoint(1, -1), CvPoint(0, -1), CvPoint(-1, -1), CvPoint(-1, 0), CvPoint(-1, 1), CvPoint(0, 1), CvPoint(1, 1) };
-
-static CvSeq*
-icvGetComponent( uchar* img, int step, CvRect rect,
-                 CvMemStorage* storage )
-{
-    const char nbd = 4;
-    int  deltas[16];
-    int  x, y;
-    CvSeq* exterior = 0;
-    char* ptr;
-
-    /* initialize local state */
-    CV_INIT_3X3_DELTAS( deltas, step, 1 );
-    memcpy( deltas + 8, deltas, 8 * sizeof( deltas[0] ));
-
-    ptr = (char*)(img + step*rect.y);
-    rect.width += rect.x;
-    rect.height += rect.y;
-
-    for( y = rect.y; y < rect.height; y++, ptr += step )
-    {
-        int prev = ptr[rect.x - 1] & -2;
-
-        for( x = rect.x; x < rect.width; x++ )
-        {
-            int p = ptr[x] & -2;
-
-            //assert( exterior || ((p | prev) & -4) == 0 );
-
-            if( p != prev )
-            {
-                CvSeq *seq = 0;
-                int is_hole = 0;
-                CvSeqWriter  writer;
-                char  *i0, *i1, *i3, *i4 = 0;
-                int  prev_s = -1, s, s_end;
-                CvPoint pt(x, y);
-
-                if( !(prev == 0 && p == 2) )    /* if not external contour */
-                {
-                    /* check hole */
-                    if( p != 0 || prev < 1 )
-                    {
-                        prev = p;
-                        continue;
-                    }
-
-                    is_hole = 1;
-                    if( !exterior )
-                    {
-                        assert(0);
-                        return 0;
-                    }
-                }
-
-                cvStartWriteSeq( CV_SEQ_CONTOUR | (is_hole ? CV_SEQ_FLAG_HOLE : 0),
-                                 sizeof(CvContour), sizeof(CvPoint), storage, &writer );
-                s_end = s = is_hole ? 0 : 4;
-                i0 = ptr + x - is_hole;
-
-                do
-                {
-                    s = (s - 1) & 7;
-                    i1 = i0 + deltas[s];
-                    if( (*i1 & -2) != 0 )
-                        break;
-                }
-                while( s != s_end );
-
-                if( s == s_end )            /* single pixel domain */
-                {
-                    *i0 = (char) (nbd | -128);
-                    CV_WRITE_SEQ_ELEM( pt, writer );
-                }
-                else
-                {
-                    i3 = i0;
-                    prev_s = s ^ 4;
-
-                    /* follow border */
-                    for( ;; )
-                    {
-                        s_end = s;
-
-                        for( ;; )
-                        {
-                            i4 = i3 + deltas[++s];
-                            if( (*i4 & -2) != 0 )
-                                break;
-                        }
-                        s &= 7;
-
-                        /* check "right" bound */
-                        if( (unsigned) (s - 1) < (unsigned) s_end )
-                        {
-                            *i3 = (char) (nbd | -128);
-                        }
-                        else if( *i3 > 0 )
-                        {
-                            *i3 = nbd;
-                        }
-
-                        if( s != prev_s )
-                        {
-                            CV_WRITE_SEQ_ELEM( pt, writer );
-                            prev_s = s;
-                        }
-
-                        pt.x += icvCodeDeltas[s].x;
-                        pt.y += icvCodeDeltas[s].y;
-
-                        if( i4 == i0 && i3 == i1 )
-                            break;
-
-                        i3 = i4;
-                        s = (s + 4) & 7;
-                    }                       /* end of border following loop */
-                }
-
-                seq = cvEndWriteSeq( &writer );
-                cvContourBoundingRect( seq, 1 );
-
-                if( !is_hole )
-                    exterior = seq;
-                else
-                {
-                    seq->v_prev = exterior;
-                    seq->h_next = exterior->v_next;
-                    if( seq->h_next )
-                        seq->h_next->h_prev = seq;
-                    exterior->v_next = seq;
-                }
-
-                prev = ptr[x] & -2;
-            }
-        }
-    }
-
-    return exterior;
-}
-
-
-
-CV_IMPL CvSeq*
-cvSegmentImage( const CvArr* srcarr, CvArr* dstarr,
-                double canny_threshold,
-                double ffill_threshold,
-                CvMemStorage* storage )
-{
-    CvSeq* root = 0;
-    CvMat* gray = 0;
-    CvMat* canny = 0;
-    //CvMat* temp = 0;
-    void* stack = 0;
-
-    CV_FUNCNAME( "cvSegmentImage" );
-
-    __BEGIN__;
-
-    CvMat srcstub, *src;
-    CvMat dststub, *dst;
-    CvMat* mask;
-    CvSize size;
-    CvPoint pt;
-    int ffill_lw_up = cvRound( fabs(ffill_threshold) );
-    CvSeq* prev_seq = 0;
-
-    CV_CALL( src = cvGetMat( srcarr, &srcstub ));
-    CV_CALL( dst = cvGetMat( dstarr, &dststub ));
-
-    size = cvGetSize( src );
-
-    CV_CALL( gray = cvCreateMat( size.height, size.width, CV_8UC1 ));
-    CV_CALL( canny = cvCreateMat( size.height, size.width, CV_8UC1 ));
-    //CV_CALL( temp = cvCreateMat( size.height/2, size.width/2, CV_8UC3 ));
-
-    CV_CALL( stack = cvAlloc( size.width * size.height * sizeof(Seg)));
-
-    cvCvtColor( src, gray, CV_BGR2GRAY );
-    cvCanny( gray, canny, 0/*canny_threshold*0.4*/, canny_threshold, 3 );
-    cvThreshold( canny, canny, 1, 1, CV_THRESH_BINARY );
-    //cvZero( canny );
-    //color_derv( src, canny, canny_threshold );
-
-    //cvPyrDown( src, temp );
-    //cvPyrUp( temp, dst );
-
-    //src = dst;
-    mask = canny; // a new name for new role
-
-    // make a non-zero border.
-    cvRectangle( mask, cvPoint(0,0), cvPoint(size.width-1,size.height-1), cvScalarAll(1), 1 );
-
-    for( pt.y = 0; pt.y < size.height; pt.y++ )
-    {
-        for( pt.x = 0; pt.x < size.width; pt.x++ )
-        {
-            if( mask->data.ptr[mask->step*pt.y + pt.x] == 0 )
-            {
-                CvConnectedComp region;
-                int avgVal[3] = { 0, 0, 0 };
-
-                icvSegmFloodFill_Stage1( src->data.ptr, src->step,
-                                         mask->data.ptr, mask->step,
-                                         size, pt, avgVal,
-                                         ffill_lw_up, ffill_lw_up,
-                                         &region, stack );
-
-                /*avgVal[0] = (avgVal[0] + 15) & -32;
-                if( avgVal[0] > 255 )
-                    avgVal[0] = 255;
-                avgVal[1] = (avgVal[1] + 15) & -32;
-                if( avgVal[1] > 255 )
-                    avgVal[1] = 255;
-                avgVal[2] = (avgVal[2] + 15) & -32;
-                if( avgVal[2] > 255 )
-                    avgVal[2] = 255;*/
-
-                if( storage )
-                {
-                    CvSeq* tmpseq = icvGetComponent( mask->data.ptr, mask->step,
-                                                     region.rect, storage );
-                    if( tmpseq != 0 )
-                    {
-                        ((CvContour*)tmpseq)->color = avgVal[0] + (avgVal[1] << 8) + (avgVal[2] << 16);
-                        tmpseq->h_prev = prev_seq;
-                        if( prev_seq )
-                            prev_seq->h_next = tmpseq;
-                        else
-                            root = tmpseq;
-                        prev_seq = tmpseq;
-                    }
-                }
-
-                icvSegmFloodFill_Stage2( dst->data.ptr, dst->step,
-                                         mask->data.ptr, mask->step,
-                                         size, avgVal,
-                                         region.rect );
-            }
-        }
-    }
-
-    __END__;
-
-    //cvReleaseMat( &temp );
-    cvReleaseMat( &gray );
-    cvReleaseMat( &canny );
-    cvFree( &stack );
-
-    return root;
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/snakes.cpp b/modules/legacy/src/snakes.cpp
deleted file mode 100644 (file)
index 68c1bc7..0000000
+++ /dev/null
@@ -1,428 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-#include "precomp.hpp"
-
-#define _CV_SNAKE_BIG 2.e+38f
-#define _CV_SNAKE_IMAGE 1
-#define _CV_SNAKE_GRAD  2
-
-
-/*F///////////////////////////////////////////////////////////////////////////////////////
-//    Name:      icvSnake8uC1R
-//    Purpose:
-//    Context:
-//    Parameters:
-//               src - source image,
-//               srcStep - its step in bytes,
-//               roi - size of ROI,
-//               pt - pointer to snake points array
-//               n - size of points array,
-//               alpha - pointer to coefficient of continuity energy,
-//               beta - pointer to coefficient of curvature energy,
-//               gamma - pointer to coefficient of image energy,
-//               coeffUsage - if CV_VALUE - alpha, beta, gamma point to single value
-//                            if CV_MATAY - point to arrays
-//               criteria - termination criteria.
-//               scheme - image energy scheme
-//                         if _CV_SNAKE_IMAGE - image intensity is energy
-//                         if _CV_SNAKE_GRAD  - magnitude of gradient is energy
-//    Returns:
-//F*/
-
-static CvStatus
-icvSnake8uC1R( unsigned char *src,
-               int srcStep,
-               CvSize roi,
-               CvPoint * pt,
-               int n,
-               float *alpha,
-               float *beta,
-               float *gamma,
-               int coeffUsage, CvSize win, CvTermCriteria criteria, int scheme )
-{
-    int i, j, k;
-    int neighbors = win.height * win.width;
-
-    int centerx = win.width >> 1;
-    int centery = win.height >> 1;
-
-    float invn;
-    int iteration = 0;
-    int converged = 0;
-
-
-    float *Econt;
-    float *Ecurv;
-    float *Eimg;
-    float *E;
-
-    float _alpha, _beta, _gamma;
-
-    /*#ifdef GRAD_SNAKE */
-    float *gradient = NULL;
-    uchar *map = NULL;
-    int map_width = ((roi.width - 1) >> 3) + 1;
-    int map_height = ((roi.height - 1) >> 3) + 1;
-    #define WTILE_SIZE 8
-    #define TILE_SIZE (WTILE_SIZE + 2)
-    short dx[TILE_SIZE*TILE_SIZE], dy[TILE_SIZE*TILE_SIZE];
-    CvMat _dx = cvMat( TILE_SIZE, TILE_SIZE, CV_16SC1, dx );
-    CvMat _dy = cvMat( TILE_SIZE, TILE_SIZE, CV_16SC1, dy );
-    CvMat _src = cvMat( roi.height, roi.width, CV_8UC1, src );
-    cv::Ptr<cv::FilterEngine> pX, pY;
-
-    /* inner buffer of convolution process */
-    //char ConvBuffer[400];
-
-    /*#endif */
-
-
-    /* check bad arguments */
-    if( src == NULL )
-        return CV_NULLPTR_ERR;
-    if( (roi.height <= 0) || (roi.width <= 0) )
-        return CV_BADSIZE_ERR;
-    if( srcStep < roi.width )
-        return CV_BADSIZE_ERR;
-    if( pt == NULL )
-        return CV_NULLPTR_ERR;
-    if( n < 3 )
-        return CV_BADSIZE_ERR;
-    if( alpha == NULL )
-        return CV_NULLPTR_ERR;
-    if( beta == NULL )
-        return CV_NULLPTR_ERR;
-    if( gamma == NULL )
-        return CV_NULLPTR_ERR;
-    if( coeffUsage != CV_VALUE && coeffUsage != CV_ARRAY )
-        return CV_BADFLAG_ERR;
-    if( (win.height <= 0) || (!(win.height & 1)))
-        return CV_BADSIZE_ERR;
-    if( (win.width <= 0) || (!(win.width & 1)))
-        return CV_BADSIZE_ERR;
-
-    invn = 1 / ((float) n);
-
-    if( scheme == _CV_SNAKE_GRAD )
-    {
-        pX = cv::createDerivFilter( CV_8U, CV_16S, 1, 0, 3, cv::BORDER_REPLICATE );
-        pY = cv::createDerivFilter( CV_8U, CV_16S, 0, 1, 3, cv::BORDER_REPLICATE );
-        gradient = (float *) cvAlloc( roi.height * roi.width * sizeof( float ));
-
-        map = (uchar *) cvAlloc( map_width * map_height );
-        /* clear map - no gradient computed */
-        memset( (void *) map, 0, map_width * map_height );
-    }
-    Econt = (float *) cvAlloc( neighbors * sizeof( float ));
-    Ecurv = (float *) cvAlloc( neighbors * sizeof( float ));
-    Eimg = (float *) cvAlloc( neighbors * sizeof( float ));
-    E = (float *) cvAlloc( neighbors * sizeof( float ));
-
-    while( !converged )
-    {
-        float ave_d = 0;
-        int moved = 0;
-
-        converged = 0;
-        iteration++;
-        /* compute average distance */
-        for( i = 1; i < n; i++ )
-        {
-            int diffx = pt[i - 1].x - pt[i].x;
-            int diffy = pt[i - 1].y - pt[i].y;
-
-            ave_d += cvSqrt( (float) (diffx * diffx + diffy * diffy) );
-        }
-        ave_d += cvSqrt( (float) ((pt[0].x - pt[n - 1].x) *
-                                  (pt[0].x - pt[n - 1].x) +
-                                  (pt[0].y - pt[n - 1].y) * (pt[0].y - pt[n - 1].y)));
-
-        ave_d *= invn;
-        /* average distance computed */
-        for( i = 0; i < n; i++ )
-        {
-            /* Calculate Econt */
-            float maxEcont = 0;
-            float maxEcurv = 0;
-            float maxEimg = 0;
-            float minEcont = _CV_SNAKE_BIG;
-            float minEcurv = _CV_SNAKE_BIG;
-            float minEimg = _CV_SNAKE_BIG;
-            float Emin = _CV_SNAKE_BIG;
-
-            int offsetx = 0;
-            int offsety = 0;
-            float tmp;
-
-            /* compute bounds */
-            int left = MIN( pt[i].x, win.width >> 1 );
-            int right = MIN( roi.width - 1 - pt[i].x, win.width >> 1 );
-            int upper = MIN( pt[i].y, win.height >> 1 );
-            int bottom = MIN( roi.height - 1 - pt[i].y, win.height >> 1 );
-
-            maxEcont = 0;
-            minEcont = _CV_SNAKE_BIG;
-            for( j = -upper; j <= bottom; j++ )
-            {
-                for( k = -left; k <= right; k++ )
-                {
-                    int diffx, diffy;
-                    float energy;
-
-                    if( i == 0 )
-                    {
-                        diffx = pt[n - 1].x - (pt[i].x + k);
-                        diffy = pt[n - 1].y - (pt[i].y + j);
-                    }
-                    else
-                    {
-                        diffx = pt[i - 1].x - (pt[i].x + k);
-                        diffy = pt[i - 1].y - (pt[i].y + j);
-                    }
-                    Econt[(j + centery) * win.width + k + centerx] = energy =
-                        (float) fabs( ave_d -
-                                      cvSqrt( (float) (diffx * diffx + diffy * diffy) ));
-
-                    maxEcont = MAX( maxEcont, energy );
-                    minEcont = MIN( minEcont, energy );
-                }
-            }
-            tmp = maxEcont - minEcont;
-            tmp = (tmp == 0) ? 0 : (1 / tmp);
-            for( k = 0; k < neighbors; k++ )
-            {
-                Econt[k] = (Econt[k] - minEcont) * tmp;
-            }
-
-            /*  Calculate Ecurv */
-            maxEcurv = 0;
-            minEcurv = _CV_SNAKE_BIG;
-            for( j = -upper; j <= bottom; j++ )
-            {
-                for( k = -left; k <= right; k++ )
-                {
-                    int tx, ty;
-                    float energy;
-
-                    if( i == 0 )
-                    {
-                        tx = pt[n - 1].x - 2 * (pt[i].x + k) + pt[i + 1].x;
-                        ty = pt[n - 1].y - 2 * (pt[i].y + j) + pt[i + 1].y;
-                    }
-                    else if( i == n - 1 )
-                    {
-                        tx = pt[i - 1].x - 2 * (pt[i].x + k) + pt[0].x;
-                        ty = pt[i - 1].y - 2 * (pt[i].y + j) + pt[0].y;
-                    }
-                    else
-                    {
-                        tx = pt[i - 1].x - 2 * (pt[i].x + k) + pt[i + 1].x;
-                        ty = pt[i - 1].y - 2 * (pt[i].y + j) + pt[i + 1].y;
-                    }
-                    Ecurv[(j + centery) * win.width + k + centerx] = energy =
-                        (float) (tx * tx + ty * ty);
-                    maxEcurv = MAX( maxEcurv, energy );
-                    minEcurv = MIN( minEcurv, energy );
-                }
-            }
-            tmp = maxEcurv - minEcurv;
-            tmp = (tmp == 0) ? 0 : (1 / tmp);
-            for( k = 0; k < neighbors; k++ )
-            {
-                Ecurv[k] = (Ecurv[k] - minEcurv) * tmp;
-            }
-
-            /* Calculate Eimg */
-            for( j = -upper; j <= bottom; j++ )
-            {
-                for( k = -left; k <= right; k++ )
-                {
-                    float energy;
-
-                    if( scheme == _CV_SNAKE_GRAD )
-                    {
-                        /* look at map and check status */
-                        int x = (pt[i].x + k)/WTILE_SIZE;
-                        int y = (pt[i].y + j)/WTILE_SIZE;
-
-                        if( map[y * map_width + x] == 0 )
-                        {
-                            int l, m;
-
-                            /* evaluate block location */
-                            int upshift = y ? 1 : 0;
-                            int leftshift = x ? 1 : 0;
-                            int bottomshift = MIN( 1, roi.height - (y + 1)*WTILE_SIZE );
-                            int rightshift = MIN( 1, roi.width - (x + 1)*WTILE_SIZE );
-                            CvRect g_roi(x*WTILE_SIZE - leftshift, y*WTILE_SIZE - upshift,
-                                leftshift + WTILE_SIZE + rightshift, upshift + WTILE_SIZE + bottomshift);
-                            CvMat _src1;
-                            cvGetSubArr( &_src, &_src1, g_roi );
-
-                            cv::Mat _src_ = cv::cvarrToMat(&_src1);
-                            cv::Mat _dx_ = cv::cvarrToMat(&_dx);
-                            cv::Mat _dy_ = cv::cvarrToMat(&_dy);
-
-                            pX->apply( _src_, _dx_, cv::Rect(0,0,-1,-1), cv::Point(), true );
-                            pY->apply( _src_, _dy_, cv::Rect(0,0,-1,-1), cv::Point(), true );
-
-                            for( l = 0; l < WTILE_SIZE + bottomshift; l++ )
-                            {
-                                for( m = 0; m < WTILE_SIZE + rightshift; m++ )
-                                {
-                                    gradient[(y*WTILE_SIZE + l) * roi.width + x*WTILE_SIZE + m] =
-                                        (float) (dx[(l + upshift) * TILE_SIZE + m + leftshift] *
-                                                 dx[(l + upshift) * TILE_SIZE + m + leftshift] +
-                                                 dy[(l + upshift) * TILE_SIZE + m + leftshift] *
-                                                 dy[(l + upshift) * TILE_SIZE + m + leftshift]);
-                                }
-                            }
-                            map[y * map_width + x] = 1;
-                        }
-                        Eimg[(j + centery) * win.width + k + centerx] = energy =
-                            gradient[(pt[i].y + j) * roi.width + pt[i].x + k];
-                    }
-                    else
-                    {
-                        Eimg[(j + centery) * win.width + k + centerx] = energy =
-                            src[(pt[i].y + j) * srcStep + pt[i].x + k];
-                    }
-
-                    maxEimg = MAX( maxEimg, energy );
-                    minEimg = MIN( minEimg, energy );
-                }
-            }
-
-            tmp = (maxEimg - minEimg);
-            tmp = (tmp == 0) ? 0 : (1 / tmp);
-
-            for( k = 0; k < neighbors; k++ )
-            {
-                Eimg[k] = (minEimg - Eimg[k]) * tmp;
-            }
-
-            /* locate coefficients */
-            if( coeffUsage == CV_VALUE)
-            {
-                _alpha = *alpha;
-                _beta = *beta;
-                _gamma = *gamma;
-            }
-            else
-            {
-                _alpha = alpha[i];
-                _beta = beta[i];
-                _gamma = gamma[i];
-            }
-
-            /* Find Minimize point in the neighbors */
-            for( k = 0; k < neighbors; k++ )
-            {
-                E[k] = _alpha * Econt[k] + _beta * Ecurv[k] + _gamma * Eimg[k];
-            }
-            Emin = _CV_SNAKE_BIG;
-            for( j = -upper; j <= bottom; j++ )
-            {
-                for( k = -left; k <= right; k++ )
-                {
-
-                    if( E[(j + centery) * win.width + k + centerx] < Emin )
-                    {
-                        Emin = E[(j + centery) * win.width + k + centerx];
-                        offsetx = k;
-                        offsety = j;
-                    }
-                }
-            }
-
-            if( offsetx || offsety )
-            {
-                pt[i].x += offsetx;
-                pt[i].y += offsety;
-                moved++;
-            }
-        }
-        converged = (moved == 0);
-        if( (criteria.type & CV_TERMCRIT_ITER) && (iteration >= criteria.max_iter) )
-            converged = 1;
-        if( (criteria.type & CV_TERMCRIT_EPS) && (moved <= criteria.epsilon) )
-            converged = 1;
-    }
-
-    cvFree( &Econt );
-    cvFree( &Ecurv );
-    cvFree( &Eimg );
-    cvFree( &E );
-
-    if( scheme == _CV_SNAKE_GRAD )
-    {
-        cvFree( &gradient );
-        cvFree( &map );
-    }
-    return CV_OK;
-}
-
-
-CV_IMPL void
-cvSnakeImage( const IplImage* src, CvPoint* points,
-              int length, float *alpha,
-              float *beta, float *gamma,
-              int coeffUsage, CvSize win,
-              CvTermCriteria criteria, int calcGradient )
-{
-    uchar *data;
-    CvSize size;
-    int step;
-
-    if( src->nChannels != 1 )
-        CV_Error( CV_BadNumChannels, "input image has more than one channel" );
-
-    if( src->depth != IPL_DEPTH_8U )
-        CV_Error( CV_BadDepth, "Unsupported format" );
-
-    cvGetRawData( src, &data, &step, &size );
-
-    IPPI_CALL( icvSnake8uC1R( data, step, size, points, length,
-                              alpha, beta, gamma, coeffUsage, win, criteria,
-                              calcGradient ? _CV_SNAKE_GRAD : _CV_SNAKE_IMAGE ));
-}
-
-/* end of file */
diff --git a/modules/legacy/src/spilltree.cpp b/modules/legacy/src/spilltree.cpp
deleted file mode 100644 (file)
index c252649..0000000
+++ /dev/null
@@ -1,498 +0,0 @@
-/* Original code has been submitted by Liu Liu.
-   ----------------------------------------------------------------------------------
-   * Spill-Tree for Approximate KNN Search
-   * Author: Liu Liu
-   * mailto: liuliu.1987+opencv@gmail.com
-   * Refer to Paper:
-   * An Investigation of Practical Approximate Nearest Neighbor Algorithms
-   * cvMergeSpillTree TBD
-   *
-   * Redistribution and use in source and binary forms, with or
-   * without modification, are permitted provided that the following
-   * conditions are met:
-   *   Redistributions of source code must retain the above
-   *   copyright notice, this list of conditions and the following
-   *   disclaimer.
-   *   Redistributions in binary form must reproduce the above
-   *   copyright notice, this list of conditions and the following
-   *   disclaimer in the documentation and/or other materials
-   *   provided with the distribution.
-   *   The name of Contributor may not be used to endorse or
-   *   promote products derived from this software without
-   *   specific prior written permission.
-   *
-   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-   * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-   * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-   * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-   * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-   * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
-   * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-   * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-   * OF SUCH DAMAGE.
-   */
-
-#include "precomp.hpp"
-#include "_featuretree.h"
-
-struct CvSpillTreeNode
-{
-  bool leaf; // is leaf or not (leaf is the point that have no more child)
-  bool spill; // is not a non-overlapping point (defeatist search)
-  CvSpillTreeNode* lc; // left child (<)
-  CvSpillTreeNode* rc; // right child (>)
-  int cc; // child count
-  CvMat* u; // projection vector
-  CvMat* center; // center
-  int i; // original index
-  double r; // radius of remaining feature point
-  double ub; // upper bound
-  double lb; // lower bound
-  double mp; // mean point
-  double p; // projection value
-};
-
-struct CvSpillTree
-{
-  CvSpillTreeNode* root;
-  CvMat** refmat; // leaf ref matrix
-  int total; // total leaves
-  int naive; // under this value, we perform naive search
-  int type; // mat type
-  double rho; // under this value, it is a spill tree
-  double tau; // the overlapping buffer ratio
-};
-
-struct CvResult
-{
-  int index;
-  double distance;
-};
-
-// find the farthest node in the "list" from "node"
-static inline CvSpillTreeNode*
-icvFarthestNode( CvSpillTreeNode* node,
-         CvSpillTreeNode* list,
-         int total )
-{
-  double farthest = -1.;
-  CvSpillTreeNode* result = NULL;
-  for ( int i = 0; i < total; i++ )
-    {
-      double norm = cvNorm( node->center, list->center );
-      if ( norm > farthest )
-    {
-      farthest = norm;
-      result = list;
-    }
-      list = list->rc;
-    }
-  return result;
-}
-
-// clone a new tree node
-static inline CvSpillTreeNode*
-icvCloneSpillTreeNode( CvSpillTreeNode* node )
-{
-  CvSpillTreeNode* result = (CvSpillTreeNode*)cvAlloc( sizeof(CvSpillTreeNode) );
-  memcpy( result, node, sizeof(CvSpillTreeNode) );
-  return result;
-}
-
-// append the link-list of a tree node
-static inline void
-icvAppendSpillTreeNode( CvSpillTreeNode* node,
-            CvSpillTreeNode* append )
-{
-  if ( node->lc == NULL )
-    {
-      node->lc = node->rc = append;
-      node->lc->lc = node->rc->rc = NULL;
-    } else {
-      append->lc = node->rc;
-      append->rc = NULL;
-      node->rc->rc = append;
-      node->rc = append;
-    }
-  node->cc++;
-}
-
-#define _dispatch_mat_ptr(x, step) (CV_MAT_DEPTH((x)->type) == CV_32F ? (void*)((x)->data.fl+(step)) : (CV_MAT_DEPTH((x)->type) == CV_64F ? (void*)((x)->data.db+(step)) : (void*)(0)))
-
-static void
-icvDFSInitSpillTreeNode( const CvSpillTree* tr,
-             const int d,
-             CvSpillTreeNode* node )
-{
-  if ( node->cc <= tr->naive )
-    {
-      // already get to a leaf, terminate the recursion.
-      node->leaf = true;
-      node->spill = false;
-      return;
-    }
-
-  // random select a node, then find a farthest node from this one, then find a farthest from that one...
-  // to approximate the farthest node-pair
-  static CvRNG rng_state = cvRNG(0xdeadbeef);
-  int rn = cvRandInt( &rng_state ) % node->cc;
-  CvSpillTreeNode* lnode = NULL;
-  CvSpillTreeNode* rnode = node->lc;
-  for ( int i = 0; i < rn; i++ )
-    rnode = rnode->rc;
-  lnode = icvFarthestNode( rnode, node->lc, node->cc );
-  rnode = icvFarthestNode( lnode, node->lc, node->cc );
-
-  // u is the projection vector
-  node->u = cvCreateMat( 1, d, tr->type );
-  cvSub( lnode->center, rnode->center, node->u );
-  cvNormalize( node->u, node->u );
-
-  // find the center of node in hyperspace
-  node->center = cvCreateMat( 1, d, tr->type );
-  cvZero( node->center );
-  CvSpillTreeNode* it = node->lc;
-  for ( int i = 0; i < node->cc; i++ )
-    {
-      cvAdd( it->center, node->center, node->center );
-      it = it->rc;
-    }
-  cvConvertScale( node->center, node->center, 1./node->cc );
-
-  // project every node to "u", and find the mean point "mp"
-  it = node->lc;
-  node->r = -1.;
-  node->mp = 0;
-  for ( int i = 0; i < node->cc; i++ )
-    {
-      node->mp += ( it->p = cvDotProduct( it->center, node->u ) );
-      double norm = cvNorm( node->center, it->center );
-      if ( norm > node->r )
-    node->r = norm;
-      it = it->rc;
-    }
-  node->mp = node->mp / node->cc;
-
-  // overlapping buffer and upper bound, lower bound
-  double ob = (lnode->p-rnode->p)*tr->tau*.5;
-  node->ub = node->mp+ob;
-  node->lb = node->mp-ob;
-  int sl = 0, l = 0;
-  int sr = 0, r = 0;
-  it = node->lc;
-  for ( int i = 0; i < node->cc; i++ )
-    {
-      if ( it->p <= node->ub )
-    sl++;
-      if ( it->p >= node->lb )
-    sr++;
-      if ( it->p < node->mp )
-    l++;
-      else
-    r++;
-      it = it->rc;
-    }
-  // precision problem, return the node as it is.
-  if (( l == 0 )||( r == 0 ))
-    {
-      cvReleaseMat( &(node->u) );
-      cvReleaseMat( &(node->center) );
-      node->leaf = true;
-      node->spill = false;
-      return;
-    }
-  CvSpillTreeNode* lc = (CvSpillTreeNode*)cvAlloc( sizeof(CvSpillTreeNode) );
-  memset(lc, 0, sizeof(CvSpillTreeNode));
-  CvSpillTreeNode* rc = (CvSpillTreeNode*)cvAlloc( sizeof(CvSpillTreeNode) );
-  memset(rc, 0, sizeof(CvSpillTreeNode));
-  lc->lc = lc->rc = rc->lc = rc->rc = NULL;
-  lc->cc = rc->cc = 0;
-  int undo = cvRound(node->cc*tr->rho);
-  if (( sl >= undo )||( sr >= undo ))
-    {
-      // it is not a spill point (defeatist search disabled)
-      it = node->lc;
-      for ( int i = 0; i < node->cc; i++ )
-    {
-      CvSpillTreeNode* next = it->rc;
-      if ( it->p < node->mp )
-        icvAppendSpillTreeNode( lc, it );
-      else
-        icvAppendSpillTreeNode( rc, it );
-      it = next;
-    }
-      node->spill = false;
-    } else {
-      // a spill point
-      it = node->lc;
-      for ( int i = 0; i < node->cc; i++ )
-    {
-      CvSpillTreeNode* next = it->rc;
-      if ( it->p < node->lb )
-        icvAppendSpillTreeNode( lc, it );
-      else if ( it->p > node->ub )
-        icvAppendSpillTreeNode( rc, it );
-      else {
-        CvSpillTreeNode* cit = icvCloneSpillTreeNode( it );
-        icvAppendSpillTreeNode( lc, it );
-        icvAppendSpillTreeNode( rc, cit );
-      }
-      it = next;
-    }
-      node->spill = true;
-    }
-  node->lc = lc;
-  node->rc = rc;
-
-  // recursion process
-  icvDFSInitSpillTreeNode( tr, d, node->lc );
-  icvDFSInitSpillTreeNode( tr, d, node->rc );
-}
-
-static CvSpillTree*
-icvCreateSpillTree( const CvMat* raw_data,
-            const int naive,
-            const double rho,
-            const double tau )
-{
-  int n = raw_data->rows;
-  int d = raw_data->cols;
-
-  CvSpillTree* tr = (CvSpillTree*)cvAlloc( sizeof(CvSpillTree) );
-  tr->root = (CvSpillTreeNode*)cvAlloc( sizeof(CvSpillTreeNode) );
-  memset(tr->root, 0, sizeof(CvSpillTreeNode));
-  tr->refmat = (CvMat**)cvAlloc( sizeof(CvMat*)*n );
-  tr->total = n;
-  tr->naive = naive;
-  tr->rho = rho;
-  tr->tau = tau;
-  tr->type = raw_data->type;
-
-  // tie a link-list to the root node
-  tr->root->lc = (CvSpillTreeNode*)cvAlloc( sizeof(CvSpillTreeNode) );
-  memset(tr->root->lc, 0, sizeof(CvSpillTreeNode));
-  tr->root->lc->center = cvCreateMatHeader( 1, d, tr->type );
-  cvSetData( tr->root->lc->center, _dispatch_mat_ptr(raw_data, 0), raw_data->step );
-  tr->refmat[0] = tr->root->lc->center;
-  tr->root->lc->lc = NULL;
-  tr->root->lc->leaf = true;
-  tr->root->lc->i = 0;
-  CvSpillTreeNode* node = tr->root->lc;
-  for ( int i = 1; i < n; i++ )
-    {
-      CvSpillTreeNode* newnode = (CvSpillTreeNode*)cvAlloc( sizeof(CvSpillTreeNode) );
-      memset(newnode, 0, sizeof(CvSpillTreeNode));
-      newnode->center = cvCreateMatHeader( 1, d, tr->type );
-      cvSetData( newnode->center, _dispatch_mat_ptr(raw_data, i*d), raw_data->step );
-      tr->refmat[i] = newnode->center;
-      newnode->lc = node;
-      newnode->i = i;
-      newnode->leaf = true;
-      newnode->rc = NULL;
-      node->rc = newnode;
-      node = newnode;
-    }
-  tr->root->rc = node;
-  tr->root->cc = n;
-  icvDFSInitSpillTreeNode( tr, d, tr->root );
-  return tr;
-}
-
-static void
-icvSpillTreeNodeHeapify( CvResult * heap,
-             int i,
-             const int k )
-{
-  if ( heap[i].index == -1 )
-    return;
-  int l, r, largest = i;
-  CvResult inp;
-  do {
-    i = largest;
-    r = (i+1)<<1;
-    l = r-1;
-    if (( l < k )&&( heap[l].index == -1 ))
-      largest = l;
-    else if (( r < k )&&( heap[r].index == -1 ))
-      largest = r;
-    else {
-      if (( l < k )&&( heap[l].distance > heap[i].distance ))
-        largest = l;
-      if (( r < k )&&( heap[r].distance > heap[largest].distance ))
-        largest = r;
-    }
-    if ( largest != i )
-      CV_SWAP( heap[largest], heap[i], inp );
-  } while ( largest != i );
-}
-
-static void
-icvSpillTreeDFSearch( CvSpillTree* tr,
-              CvSpillTreeNode* node,
-              CvResult* heap,
-              int* es,
-              const CvMat* desc,
-              const int k,
-              const int emax,
-                      bool * cache)
-{
-  if ((emax > 0)&&( *es >= emax ))
-    return;
-  double dist, p=0;
-  double distance;
-  while ( node->spill )
-    {
-      // defeatist search
-      if ( !node->leaf )
-    p = cvDotProduct( node->u, desc );
-      if ( p < node->lb && node->lc->cc >= k ) // check the number of children larger than k otherwise you'll skip over better neighbor
-    node = node->lc;
-      else if ( p > node->ub && node->rc->cc >= k )
-    node = node->rc;
-      else
-    break;
-      if ( NULL == node )
-    return;
-    }
-  if ( node->leaf )
-    {
-      // a leaf, naive search
-      CvSpillTreeNode* it = node->lc;
-      for ( int i = 0; i < node->cc; i++ )
-        {
-          if ( !cache[it->i] )
-          {
-        distance = cvNorm( it->center, desc );
-            cache[it->i] = true;
-        if (( heap[0].index == -1)||( distance < heap[0].distance ))
-          {
-                CvResult  current_result;
-                current_result.index = it->i;
-                current_result.distance = distance;
-                heap[0] = current_result;
-            icvSpillTreeNodeHeapify( heap, 0, k );
-        (*es)++;
-          }
-          }
-          it = it->rc;
-    }
-      return;
-    }
-  dist = cvNorm( node->center, desc );
-  // impossible case, skip
-  if (( heap[0].index != -1 )&&( dist-node->r > heap[0].distance ))
-    return;
-  p = cvDotProduct( node->u, desc );
-  // guided dfs
-  if ( p < node->mp )
-    {
-      icvSpillTreeDFSearch( tr, node->lc, heap, es, desc, k, emax, cache );
-      icvSpillTreeDFSearch( tr, node->rc, heap, es, desc, k, emax, cache );
-    } else {
-    icvSpillTreeDFSearch( tr, node->rc, heap, es, desc, k, emax, cache );
-    icvSpillTreeDFSearch( tr, node->lc, heap, es, desc, k, emax, cache );
-    }
-}
-
-static void
-icvFindSpillTreeFeatures( CvSpillTree* tr,
-              const CvMat* desc,
-              CvMat* results,
-              CvMat* dist,
-              const int k,
-              const int emax )
-{
-  assert( desc->type == tr->type );
-  CvResult* heap = (CvResult*)cvAlloc( k*sizeof(heap[0]) );
-  bool* cache = (bool*)cvAlloc( sizeof(bool)*tr->total );
-  for ( int j = 0; j < desc->rows; j++ )
-    {
-      CvMat _desc = cvMat( 1, desc->cols, desc->type, _dispatch_mat_ptr(desc, j*desc->cols) );
-      for ( int i = 0; i < k; i++ ) {
-        CvResult current;
-        current.index=-1;
-        current.distance=-1;
-    heap[i] = current;
-      }
-      memset( cache, 0, sizeof(bool)*tr->total );
-      int es = 0;
-      icvSpillTreeDFSearch( tr, tr->root, heap, &es, &_desc, k, emax, cache );
-      CvResult inp;
-      for ( int i = k-1; i > 0; i-- )
-    {
-      CV_SWAP( heap[i], heap[0], inp );
-      icvSpillTreeNodeHeapify( heap, 0, i );
-    }
-      int* rs = results->data.i+j*results->cols;
-      double* dt = dist->data.db+j*dist->cols;
-      for ( int i = 0; i < k; i++, rs++, dt++ )
-    if ( heap[i].index != -1 )
-      {
-        *rs = heap[i].index;
-        *dt = heap[i].distance;
-      } else
-        *rs = -1;
-    }
-  cvFree( &heap );
-  cvFree( &cache );
-}
-
-static void
-icvDFSReleaseSpillTreeNode( CvSpillTreeNode* node )
-{
-  if ( node->leaf )
-    {
-      CvSpillTreeNode* it = node->lc;
-      for ( int i = 0; i < node->cc; i++ )
-        {
-          CvSpillTreeNode* s = it;
-          it = it->rc;
-          cvFree( &s );
-        }
-    } else {
-      cvReleaseMat( &node->u );
-      cvReleaseMat( &node->center );
-      icvDFSReleaseSpillTreeNode( node->lc );
-      icvDFSReleaseSpillTreeNode( node->rc );
-    }
-  cvFree( &node );
-}
-
-static void
-icvReleaseSpillTree( CvSpillTree** tr )
-{
-  for ( int i = 0; i < (*tr)->total; i++ )
-    cvReleaseMat( &((*tr)->refmat[i]) );
-  cvFree( &((*tr)->refmat) );
-  icvDFSReleaseSpillTreeNode( (*tr)->root );
-  cvFree( tr );
-}
-
-class CvSpillTreeWrap : public CvFeatureTree {
-  CvSpillTree* tr;
-public:
-  CvSpillTreeWrap(const CvMat* raw_data,
-          const int naive,
-          const double rho,
-          const double tau) {
-    tr = icvCreateSpillTree(raw_data, naive, rho, tau);
-  }
-  ~CvSpillTreeWrap() {
-    icvReleaseSpillTree(&tr);
-  }
-
-  void FindFeatures(const CvMat* desc, int k, int emax, CvMat* results, CvMat* dist) {
-    icvFindSpillTreeFeatures(tr, desc, results, dist, k, emax);
-  }
-};
-
-CvFeatureTree* cvCreateSpillTree( const CvMat* raw_data,
-                  const int naive,
-                  const double rho,
-                  const double tau ) {
-  return new CvSpillTreeWrap(raw_data, naive, rho, tau);
-}
diff --git a/modules/legacy/src/stereogc.cpp b/modules/legacy/src/stereogc.cpp
deleted file mode 100644 (file)
index 72182e9..0000000
+++ /dev/null
@@ -1,948 +0,0 @@
-//M*//////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#undef INFINITY
-#define INFINITY 10000
-#define OCCLUSION_PENALTY 10000
-#define OCCLUSION_PENALTY2 1000
-#define DENOMINATOR 16
-#undef OCCLUDED
-#define OCCLUDED CV_STEREO_GC_OCCLUDED
-#define CUTOFF 1000
-#define IS_BLOCKED(d1, d2) ((d1) > (d2))
-
-typedef struct GCVtx
-{
-    GCVtx *next;
-    int parent;
-    int first;
-    int ts;
-    int dist;
-    short weight;
-    uchar t;
-}
-GCVtx;
-
-typedef struct GCEdge
-{
-    GCVtx* dst;
-    int next;
-    int weight;
-}
-GCEdge;
-
-typedef struct CvStereoGCState2
-{
-    int Ithreshold, interactionRadius;
-    int lambda, lambda1, lambda2, K;
-    int dataCostFuncTab[CUTOFF+1];
-    int smoothnessR[CUTOFF*2+1];
-    int smoothnessGrayDiff[512];
-    GCVtx** orphans;
-    int maxOrphans;
-}
-CvStereoGCState2;
-
-// truncTab[x+255] = MAX(x-255,0)
-static uchar icvTruncTab[512];
-// cutoffSqrTab[x] = MIN(x*x, CUTOFF)
-static int icvCutoffSqrTab[256];
-
-static void icvInitStereoConstTabs()
-{
-    static volatile int initialized = 0;
-    if( !initialized )
-    {
-        int i;
-        for( i = 0; i < 512; i++ )
-            icvTruncTab[i] = (uchar)MIN(MAX(i-255,0),255);
-        for( i = 0; i < 256; i++ )
-            icvCutoffSqrTab[i] = MIN(i*i, CUTOFF);
-        initialized = 1;
-    }
-}
-
-static void icvInitStereoTabs( CvStereoGCState2* state2 )
-{
-    int i, K = state2->K;
-
-    for( i = 0; i <= CUTOFF; i++ )
-        state2->dataCostFuncTab[i] = MIN(i*DENOMINATOR - K, 0);
-
-    for( i = 0; i < CUTOFF*2 + 1; i++ )
-        state2->smoothnessR[i] = MIN(abs(i-CUTOFF), state2->interactionRadius);
-
-    for( i = 0; i < 512; i++ )
-    {
-        int diff = abs(i - 255);
-        state2->smoothnessGrayDiff[i] = diff < state2->Ithreshold ? state2->lambda1 : state2->lambda2;
-    }
-}
-
-
-static int icvGCResizeOrphansBuf( GCVtx**& orphans, int norphans )
-{
-    int i, newNOrphans = MAX(norphans*3/2, 256);
-    GCVtx** newOrphans = (GCVtx**)cvAlloc( newNOrphans*sizeof(orphans[0]) );
-    for( i = 0; i < norphans; i++ )
-        newOrphans[i] = orphans[i];
-    cvFree( &orphans );
-    orphans = newOrphans;
-    return newNOrphans;
-}
-
-static int64 icvGCMaxFlow( GCVtx* vtx, int nvtx, GCEdge* edges, GCVtx**& _orphans, int& _maxOrphans )
-{
-    const int TERMINAL = -1, ORPHAN = -2;
-    GCVtx stub, *nilNode = &stub, *first = nilNode, *last = nilNode;
-    int i, k;
-    int curr_ts = 0;
-    int64 flow = 0;
-    int norphans = 0, maxOrphans = _maxOrphans;
-    GCVtx** orphans = _orphans;
-    stub.next = nilNode;
-
-    // initialize the active queue and the graph vertices
-    for( i = 0; i < nvtx; i++ )
-    {
-        GCVtx* v = vtx + i;
-        v->ts = 0;
-        if( v->weight != 0 )
-        {
-            last = last->next = v;
-            v->dist = 1;
-            v->parent = TERMINAL;
-            v->t = v->weight < 0;
-        }
-        else
-            v->parent = 0;
-    }
-
-    first = first->next;
-    last->next = nilNode;
-    nilNode->next = 0;
-
-    // run the search-path -> augment-graph -> restore-trees loop
-    for(;;)
-    {
-        GCVtx* v, *u;
-        int e0 = -1, ei = 0, ej = 0, min_weight, weight;
-        uchar vt;
-
-        // grow S & T search trees, find an edge connecting them
-        while( first != nilNode )
-        {
-            v = first;
-            if( v->parent )
-            {
-                vt = v->t;
-                for( ei = v->first; ei != 0; ei = edges[ei].next )
-                {
-                    if( edges[ei^vt].weight == 0 )
-                        continue;
-                    u = edges[ei].dst;
-                    if( !u->parent )
-                    {
-                        u->t = vt;
-                        u->parent = ei ^ 1;
-                        u->ts = v->ts;
-                        u->dist = v->dist + 1;
-                        if( !u->next )
-                        {
-                            u->next = nilNode;
-                            last = last->next = u;
-                        }
-                        continue;
-                    }
-
-                    if( u->t != vt )
-                    {
-                        e0 = ei ^ vt;
-                        break;
-                    }
-
-                    if( u->dist > v->dist+1 && u->ts <= v->ts )
-                    {
-                        // reassign the parent
-                        u->parent = ei ^ 1;
-                        u->ts = v->ts;
-                        u->dist = v->dist + 1;
-                    }
-                }
-                if( e0 > 0 )
-                    break;
-            }
-            // exclude the vertex from the active list
-            first = first->next;
-            v->next = 0;
-        }
-
-        if( e0 <= 0 )
-            break;
-
-        // find the minimum edge weight along the path
-        min_weight = edges[e0].weight;
-        assert( min_weight > 0 );
-        // k = 1: source tree, k = 0: destination tree
-        for( k = 1; k >= 0; k-- )
-        {
-            for( v = edges[e0^k].dst;; v = edges[ei].dst )
-            {
-                if( (ei = v->parent) < 0 )
-                    break;
-                weight = edges[ei^k].weight;
-                min_weight = MIN(min_weight, weight);
-                assert( min_weight > 0 );
-            }
-            weight = abs(v->weight);
-            min_weight = MIN(min_weight, weight);
-            assert( min_weight > 0 );
-        }
-
-        // modify weights of the edges along the path and collect orphans
-        edges[e0].weight -= min_weight;
-        edges[e0^1].weight += min_weight;
-        flow += min_weight;
-
-        // k = 1: source tree, k = 0: destination tree
-        for( k = 1; k >= 0; k-- )
-        {
-            for( v = edges[e0^k].dst;; v = edges[ei].dst )
-            {
-                if( (ei = v->parent) < 0 )
-                    break;
-                edges[ei^(k^1)].weight += min_weight;
-                if( (edges[ei^k].weight -= min_weight) == 0 )
-                {
-                    if( norphans >= maxOrphans )
-                        maxOrphans = icvGCResizeOrphansBuf( orphans, norphans );
-                    orphans[norphans++] = v;
-                    v->parent = ORPHAN;
-                }
-            }
-
-            v->weight = (short)(v->weight + min_weight*(1-k*2));
-            if( v->weight == 0 )
-            {
-                if( norphans >= maxOrphans )
-                    maxOrphans = icvGCResizeOrphansBuf( orphans, norphans );
-                orphans[norphans++] = v;
-                v->parent = ORPHAN;
-            }
-        }
-
-        // restore the search trees by finding new parents for the orphans
-        curr_ts++;
-        while( norphans > 0 )
-        {
-            GCVtx* v1 = orphans[--norphans];
-            int d, min_dist = INT_MAX;
-            e0 = 0;
-            vt = v1->t;
-
-            for( ei = v1->first; ei != 0; ei = edges[ei].next )
-            {
-                if( edges[ei^(vt^1)].weight == 0 )
-                    continue;
-                u = edges[ei].dst;
-                if( u->t != vt || u->parent == 0 )
-                    continue;
-                // compute the distance to the tree root
-                for( d = 0;; )
-                {
-                    if( u->ts == curr_ts )
-                    {
-                        d += u->dist;
-                        break;
-                    }
-                    ej = u->parent;
-                    d++;
-                    if( ej < 0 )
-                    {
-                        if( ej == ORPHAN )
-                            d = INT_MAX-1;
-                        else
-                        {
-                            u->ts = curr_ts;
-                            u->dist = 1;
-                        }
-                        break;
-                    }
-                    u = edges[ej].dst;
-                }
-
-                // update the distance
-                if( ++d < INT_MAX )
-                {
-                    if( d < min_dist )
-                    {
-                        min_dist = d;
-                        e0 = ei;
-                    }
-                    for( u = edges[ei].dst; u->ts != curr_ts; u = edges[u->parent].dst )
-                    {
-                        u->ts = curr_ts;
-                        u->dist = --d;
-                    }
-                }
-            }
-
-            if( (v1->parent = e0) > 0 )
-            {
-                v1->ts = curr_ts;
-                v1->dist = min_dist;
-                continue;
-            }
-
-            /* no parent is found */
-            v1->ts = 0;
-            for( ei = v1->first; ei != 0; ei = edges[ei].next )
-            {
-                u = edges[ei].dst;
-                ej = u->parent;
-                if( u->t != vt || !ej )
-                    continue;
-                if( edges[ei^(vt^1)].weight && !u->next )
-                {
-                    u->next = nilNode;
-                    last = last->next = u;
-                }
-                if( ej > 0 && edges[ej].dst == v1 )
-                {
-                    if( norphans >= maxOrphans )
-                        maxOrphans = icvGCResizeOrphansBuf( orphans, norphans );
-                    orphans[norphans++] = u;
-                    u->parent = ORPHAN;
-                }
-            }
-        }
-    }
-
-    _orphans = orphans;
-    _maxOrphans = maxOrphans;
-
-    return flow;
-}
-
-
-CvStereoGCState* cvCreateStereoGCState( int numberOfDisparities, int maxIters )
-{
-    CvStereoGCState* state = 0;
-
-    state = (CvStereoGCState*)cvAlloc( sizeof(*state) );
-    memset( state, 0, sizeof(*state) );
-    state->minDisparity = 0;
-    state->numberOfDisparities = numberOfDisparities;
-    state->maxIters = maxIters <= 0 ? 3 : maxIters;
-    state->Ithreshold = 5;
-    state->interactionRadius = 1;
-    state->K = state->lambda = state->lambda1 = state->lambda2 = -1.f;
-    state->occlusionCost = OCCLUSION_PENALTY;
-
-    return state;
-}
-
-void cvReleaseStereoGCState( CvStereoGCState** _state )
-{
-    CvStereoGCState* state;
-
-    if( !_state && !*_state )
-        return;
-
-    state = *_state;
-    cvReleaseMat( &state->left );
-    cvReleaseMat( &state->right );
-    cvReleaseMat( &state->ptrLeft );
-    cvReleaseMat( &state->ptrRight );
-    cvReleaseMat( &state->vtxBuf );
-    cvReleaseMat( &state->edgeBuf );
-    cvFree( _state );
-}
-
-// ||I(x) - J(x')|| =
-// min(CUTOFF,
-//   min(
-//     max(
-//       max(minJ(x') - I(x), 0),
-//       max(I(x) - maxJ(x'), 0)),
-//     max(
-//       max(minI(x) - J(x'), 0),
-//       max(J(x') - maxI(x), 0)))**2) ==
-// min(CUTOFF,
-//   min(
-//       max(minJ(x') - I(x), 0) +
-//       max(I(x) - maxJ(x'), 0),
-//
-//       max(minI(x) - J(x'), 0) +
-//       max(J(x') - maxI(x), 0)))**2)
-// where (I, minI, maxI) and
-//       (J, minJ, maxJ) are stored as interleaved 3-channel images.
-// minI, maxI are computed from I,
-// minJ, maxJ are computed from J - see icvInitGraySubPix.
-static inline int icvDataCostFuncGraySubpix( const uchar* a, const uchar* b )
-{
-    int va = a[0], vb = b[0];
-    int da = icvTruncTab[b[1] - va + 255] + icvTruncTab[va - b[2] + 255];
-    int db = icvTruncTab[a[1] - vb + 255] + icvTruncTab[vb - a[2] + 255];
-    return icvCutoffSqrTab[MIN(da,db)];
-}
-
-static inline int icvSmoothnessCostFunc( int da, int db, int maxR, const int* stabR, int scale )
-{
-    return da == db ? 0 : (da == OCCLUDED || db == OCCLUDED ? maxR : stabR[da - db])*scale;
-}
-
-static void icvInitGraySubpix( const CvMat* left, const CvMat* right,
-                               CvMat* left3, CvMat* right3 )
-{
-    int k, x, y, rows = left->rows, cols = left->cols;
-
-    for( k = 0; k < 2; k++ )
-    {
-        const CvMat* src = k == 0 ? left : right;
-        CvMat* dst = k == 0 ? left3 : right3;
-        int sstep = src->step;
-
-        for( y = 0; y < rows; y++ )
-        {
-            const uchar* sptr = src->data.ptr + sstep*y;
-            const uchar* sptr_prev = y > 0 ? sptr - sstep : sptr;
-            const uchar* sptr_next = y < rows-1 ? sptr + sstep : sptr;
-            uchar* dptr = dst->data.ptr + dst->step*y;
-            int v_prev = sptr[0];
-
-            for( x = 0; x < cols; x++, dptr += 3 )
-            {
-                int v = sptr[x], v1, minv = v, maxv = v;
-
-                v1 = (v + v_prev)/2;
-                minv = MIN(minv, v1); maxv = MAX(maxv, v1);
-                v1 = (v + sptr_prev[x])/2;
-                minv = MIN(minv, v1); maxv = MAX(maxv, v1);
-                v1 = (v + sptr_next[x])/2;
-                minv = MIN(minv, v1); maxv = MAX(maxv, v1);
-                if( x < cols-1 )
-                {
-                    v1 = (v + sptr[x+1])/2;
-                    minv = MIN(minv, v1); maxv = MAX(maxv, v1);
-                }
-                v_prev = v;
-                dptr[0] = (uchar)v;
-                dptr[1] = (uchar)minv;
-                dptr[2] = (uchar)maxv;
-            }
-        }
-    }
-}
-
-// Optimal K is computed as avg_x(k-th-smallest_d(||I(x)-J(x+d)||)),
-// where k = number_of_disparities*0.25.
-static float
-icvComputeK( CvStereoGCState* state )
-{
-    int x, y, x1, d, i, j, rows = state->left->rows, cols = state->left->cols, n = 0;
-    int mind = state->minDisparity, nd = state->numberOfDisparities, maxd = mind + nd;
-    int k = MIN(MAX((nd + 2)/4, 3), nd), delta, t, sum = 0;
-    std::vector<int> _arr(k+1);
-    int *arr = &_arr[0];
-
-    for( y = 0; y < rows; y++ )
-    {
-        const uchar* lptr = state->left->data.ptr + state->left->step*y;
-        const uchar* rptr = state->right->data.ptr + state->right->step*y;
-
-        for( x = 0; x < cols; x++ )
-        {
-            for( d = maxd-1, i = 0; d >= mind; d-- )
-            {
-                x1 = x - d;
-                if( (unsigned)x1 >= (unsigned)cols )
-                    continue;
-                delta = icvDataCostFuncGraySubpix( lptr + x*3, rptr + x1*3 );
-                if( i < k )
-                    arr[i++] = delta;
-                else
-                    for( i = 0; i < k; i++ )
-                        if( delta < arr[i] )
-                            CV_SWAP( arr[i], delta, t );
-            }
-            delta = arr[0];
-            for( j = 1; j < i; j++ )
-                delta = MAX(delta, arr[j]);
-            sum += delta;
-            n++;
-        }
-    }
-
-    return (float)sum/n;
-}
-
-static int64 icvComputeEnergy( const CvStereoGCState* state, const CvStereoGCState2* state2,
-                               bool allOccluded )
-{
-    int x, y, rows = state->left->rows, cols = state->left->cols;
-    int64 E = 0;
-    const int* dtab = state2->dataCostFuncTab;
-    int maxR = state2->interactionRadius;
-    const int* stabR = state2->smoothnessR + CUTOFF;
-    const int* stabI = state2->smoothnessGrayDiff + 255;
-    const uchar* left = state->left->data.ptr;
-    const uchar* right = state->right->data.ptr;
-    short* dleft = state->dispLeft->data.s;
-    short* dright = state->dispRight->data.s;
-    int step = state->left->step;
-    int dstep = (int)(state->dispLeft->step/sizeof(short));
-
-    assert( state->left->step == state->right->step &&
-        state->dispLeft->step == state->dispRight->step );
-
-    if( allOccluded )
-        return (int64)OCCLUSION_PENALTY*rows*cols*2;
-
-    for( y = 0; y < rows; y++, left += step, right += step, dleft += dstep, dright += dstep )
-    {
-        for( x = 0; x < cols; x++ )
-        {
-            int d = dleft[x], x1, d1;
-            if( d == OCCLUDED )
-                E += OCCLUSION_PENALTY;
-            else
-            {
-                x1 = x + d;
-                if( (unsigned)x1 >= (unsigned)cols )
-                    continue;
-                d1 = dright[x1];
-                if( d == -d1 )
-                    E += dtab[icvDataCostFuncGraySubpix( left + x*3, right + x1*3 )];
-            }
-
-            if( x < cols-1 )
-            {
-                d1 = dleft[x+1];
-                E += icvSmoothnessCostFunc(d, d1, maxR, stabR, stabI[left[x*3] - left[x*3+3]] );
-            }
-            if( y < rows-1 )
-            {
-                d1 = dleft[x+dstep];
-                E += icvSmoothnessCostFunc(d, d1, maxR, stabR, stabI[left[x*3] - left[x*3+step]] );
-            }
-
-            d = dright[x];
-            if( d == OCCLUDED )
-                E += OCCLUSION_PENALTY;
-
-            if( x < cols-1 )
-            {
-                d1 = dright[x+1];
-                E += icvSmoothnessCostFunc(d, d1, maxR, stabR, stabI[right[x*3] - right[x*3+3]] );
-            }
-            if( y < rows-1 )
-            {
-                d1 = dright[x+dstep];
-                E += icvSmoothnessCostFunc(d, d1, maxR, stabR, stabI[right[x*3] - right[x*3+step]] );
-            }
-            assert( E >= 0 );
-        }
-    }
-
-    return E;
-}
-
-static inline void icvAddEdge( GCVtx *x, GCVtx* y, GCEdge* edgeBuf, int nedges, int w, int rw )
-{
-    GCEdge *xy = edgeBuf + nedges, *yx = xy + 1;
-
-    assert( x != 0 && y != 0 );
-    xy->dst = y;
-    xy->next = x->first;
-    xy->weight = (short)w;
-    x->first = nedges;
-
-    yx->dst = x;
-    yx->next = y->first;
-    yx->weight = (short)rw;
-    y->first = nedges+1;
-}
-
-static inline int icvAddTWeights( GCVtx* vtx, int sourceWeight, int sinkWeight )
-{
-    int w = vtx->weight;
-    if( w > 0 )
-        sourceWeight += w;
-    else
-        sinkWeight -= w;
-    vtx->weight = (short)(sourceWeight - sinkWeight);
-    return MIN(sourceWeight, sinkWeight);
-}
-
-static inline int icvAddTerm( GCVtx* x, GCVtx* y, int A, int B, int C, int D,
-                              GCEdge* edgeBuf, int& nedges )
-{
-    int dE = 0, w;
-
-    assert(B - A + C - D >= 0);
-    if( B < A )
-    {
-        dE += icvAddTWeights(x, D, B);
-        dE += icvAddTWeights(y, 0, A - B);
-        if( (w = B - A + C - D) != 0 )
-        {
-            icvAddEdge( x, y, edgeBuf, nedges, 0, w );
-            nedges += 2;
-        }
-    }
-    else if( C < D )
-    {
-        dE += icvAddTWeights(x, D, A + D - C);
-        dE += icvAddTWeights(y, 0, C - D);
-        if( (w = B - A + C - D) != 0 )
-        {
-            icvAddEdge( x, y, edgeBuf, nedges, w, 0 );
-            nedges += 2;
-        }
-    }
-    else
-    {
-        dE += icvAddTWeights(x, D, A);
-        if( B != A || C != D )
-        {
-            icvAddEdge( x, y, edgeBuf, nedges, B - A, C - D );
-            nedges += 2;
-        }
-    }
-    return dE;
-}
-
-static int64 icvAlphaExpand( int64 Eprev, int alpha, CvStereoGCState* state, CvStereoGCState2* state2 )
-{
-    GCVtx *var, *var1;
-    int64 E = 0;
-    int delta, E00=0, E0a=0, Ea0=0, Eaa=0;
-    int k, a, d, d1, x, y, x1, y1, rows = state->left->rows, cols = state->left->cols;
-    int nvtx = 0, nedges = 2;
-    GCVtx* vbuf = (GCVtx*)state->vtxBuf->data.ptr;
-    GCEdge* ebuf = (GCEdge*)state->edgeBuf->data.ptr;
-    int maxR = state2->interactionRadius;
-    const int* dtab = state2->dataCostFuncTab;
-    const int* stabR = state2->smoothnessR + CUTOFF;
-    const int* stabI = state2->smoothnessGrayDiff + 255;
-    const uchar* left0 = state->left->data.ptr;
-    const uchar* right0 = state->right->data.ptr;
-    short* dleft0 = state->dispLeft->data.s;
-    short* dright0 = state->dispRight->data.s;
-    GCVtx** pleft0 = (GCVtx**)state->ptrLeft->data.ptr;
-    GCVtx** pright0 = (GCVtx**)state->ptrRight->data.ptr;
-    int step = state->left->step;
-    int dstep = (int)(state->dispLeft->step/sizeof(short));
-    int pstep = (int)(state->ptrLeft->step/sizeof(GCVtx*));
-    int aa[] = { alpha, -alpha };
-
-    //double t = (double)cvGetTickCount();
-
-    assert( state->left->step == state->right->step &&
-            state->dispLeft->step == state->dispRight->step &&
-            state->ptrLeft->step == state->ptrRight->step );
-    for( k = 0; k < 2; k++ )
-    {
-        ebuf[k].dst = 0;
-        ebuf[k].next = 0;
-        ebuf[k].weight = 0;
-    }
-
-    for( y = 0; y < rows; y++ )
-    {
-        const uchar* left = left0 + step*y;
-        const uchar* right = right0 + step*y;
-        const short* dleft = dleft0 + dstep*y;
-        const short* dright = dright0 + dstep*y;
-        GCVtx** pleft = pleft0 + pstep*y;
-        GCVtx** pright = pright0 + pstep*y;
-        const uchar* lr[] = { left, right };
-        const short* dlr[] = { dleft, dright };
-        GCVtx** plr[] = { pleft, pright };
-
-        for( k = 0; k < 2; k++ )
-        {
-            a = aa[k];
-            for( y1 = y+(y>0); y1 <= y+(y<rows-1); y1++ )
-            {
-                const short* disp = (k == 0 ? dleft0 : dright0) + y1*dstep;
-                GCVtx** ptr = (k == 0 ? pleft0 : pright0) + y1*pstep;
-                for( x = 0; x < cols; x++ )
-                {
-                    GCVtx* v = ptr[x] = &vbuf[nvtx++];
-                    v->first = 0;
-                    v->weight = disp[x] == (short)(OCCLUDED ? -OCCLUSION_PENALTY2 : 0);
-                }
-            }
-        }
-
-        for( x = 0; x < cols; x++ )
-        {
-            d = dleft[x];
-            x1 = x + d;
-            var = pleft[x];
-
-            // (left + x, right + x + d)
-            if( d != alpha && d != OCCLUDED && (unsigned)x1 < (unsigned)cols )
-            {
-                var1 = pright[x1];
-                d1 = dright[x1];
-                if( d == -d1 )
-                {
-                    assert( var1 != 0 );
-                    delta = IS_BLOCKED(alpha, d) ? INFINITY : 0;
-                    //add inter edge
-                    E += icvAddTerm( var, var1,
-                        dtab[icvDataCostFuncGraySubpix( left + x*3, right + x1*3 )],
-                        delta, delta, 0, ebuf, nedges );
-                }
-                else if( IS_BLOCKED(alpha, d) )
-                    E += icvAddTerm( var, var1, 0, INFINITY, 0, 0, ebuf, nedges );
-            }
-
-            // (left + x, right + x + alpha)
-            x1 = x + alpha;
-            if( (unsigned)x1 < (unsigned)cols )
-            {
-                var1 = pright[x1];
-                d1 = dright[x1];
-
-                E0a = IS_BLOCKED(d, alpha) ? INFINITY : 0;
-                Ea0 = IS_BLOCKED(-d1, alpha) ? INFINITY : 0;
-                Eaa = dtab[icvDataCostFuncGraySubpix( left + x*3, right + x1*3 )];
-                E += icvAddTerm( var, var1, 0, E0a, Ea0, Eaa, ebuf, nedges );
-            }
-
-            // smoothness
-            for( k = 0; k < 2; k++ )
-            {
-                GCVtx** p = plr[k];
-                const short* disp = dlr[k];
-                const uchar* img = lr[k] + x*3;
-                int scale;
-                var = p[x];
-                d = disp[x];
-                a = aa[k];
-
-                if( x < cols - 1 )
-                {
-                    var1 = p[x+1];
-                    d1 = disp[x+1];
-                    scale = stabI[img[0] - img[3]];
-                    E0a = icvSmoothnessCostFunc( d, a, maxR, stabR, scale );
-                    Ea0 = icvSmoothnessCostFunc( a, d1, maxR, stabR, scale );
-                    E00 = icvSmoothnessCostFunc( d, d1, maxR, stabR, scale );
-                    E += icvAddTerm( var, var1, E00, E0a, Ea0, 0, ebuf, nedges );
-                }
-
-                if( y < rows - 1 )
-                {
-                    var1 = p[x+pstep];
-                    d1 = disp[x+dstep];
-                    scale = stabI[img[0] - img[step]];
-                    E0a = icvSmoothnessCostFunc( d, a, maxR, stabR, scale );
-                    Ea0 = icvSmoothnessCostFunc( a, d1, maxR, stabR, scale );
-                    E00 = icvSmoothnessCostFunc( d, d1, maxR, stabR, scale );
-                    E += icvAddTerm( var, var1, E00, E0a, Ea0, 0, ebuf, nedges );
-                }
-            }
-
-            // visibility term
-            if( d != OCCLUDED && IS_BLOCKED(alpha, -d))
-            {
-                x1 = x + d;
-                if( (unsigned)x1 < (unsigned)cols )
-                {
-                    if( d != -dleft[x1] )
-                    {
-                        var1 = pleft[x1];
-                        E += icvAddTerm( var, var1, 0, INFINITY, 0, 0, ebuf, nedges );
-                    }
-                }
-            }
-        }
-    }
-
-    //t = (double)cvGetTickCount() - t;
-    ebuf[0].weight = ebuf[1].weight = 0;
-    E += icvGCMaxFlow( vbuf, nvtx, ebuf, state2->orphans, state2->maxOrphans );
-
-    if( E < Eprev )
-    {
-        for( y = 0; y < rows; y++ )
-        {
-            short* dleft = dleft0 + dstep*y;
-            short* dright = dright0 + dstep*y;
-            GCVtx** pleft = pleft0 + pstep*y;
-            GCVtx** pright = pright0 + pstep*y;
-            for( x = 0; x < cols; x++ )
-            {
-                GCVtx* var2 = pleft[x];
-                if( var2 && var2->parent && var2->t )
-                    dleft[x] = (short)alpha;
-
-                var2 = pright[x];
-                if( var2 && var2->parent && var2->t )
-                    dright[x] = (short)-alpha;
-            }
-        }
-    }
-
-    return MIN(E, Eprev);
-}
-
-
-CV_IMPL void cvFindStereoCorrespondenceGC( const CvArr* _left, const CvArr* _right,
-    CvArr* _dispLeft, CvArr* _dispRight, CvStereoGCState* state, int useDisparityGuess )
-{
-    CvStereoGCState2 state2;
-    state2.orphans = 0;
-    state2.maxOrphans = 0;
-
-    CvMat lstub, *left = cvGetMat( _left, &lstub );
-    CvMat rstub, *right = cvGetMat( _right, &rstub );
-    CvMat dlstub, *dispLeft = cvGetMat( _dispLeft, &dlstub );
-    CvMat drstub, *dispRight = cvGetMat( _dispRight, &drstub );
-    CvSize size;
-    int iter, i, nZeroExpansions = 0;
-    CvRNG rng = cvRNG(-1);
-    int64 E;
-
-    CV_Assert( state != 0 );
-    CV_Assert( CV_ARE_SIZES_EQ(left, right) && CV_ARE_TYPES_EQ(left, right) &&
-               CV_MAT_TYPE(left->type) == CV_8UC1 );
-    CV_Assert( !dispLeft ||
-        (CV_ARE_SIZES_EQ(dispLeft, left) && CV_MAT_CN(dispLeft->type) == 1) );
-    CV_Assert( !dispRight ||
-        (CV_ARE_SIZES_EQ(dispRight, left) && CV_MAT_CN(dispRight->type) == 1) );
-
-    size = cvGetSize(left);
-    if( !state->left || state->left->width != size.width || state->left->height != size.height )
-    {
-        int pcn = (int)(sizeof(GCVtx*)/sizeof(int));
-        int vcn = (int)(sizeof(GCVtx)/sizeof(int));
-        int ecn = (int)(sizeof(GCEdge)/sizeof(int));
-        cvReleaseMat( &state->left );
-        cvReleaseMat( &state->right );
-        cvReleaseMat( &state->ptrLeft );
-        cvReleaseMat( &state->ptrRight );
-        cvReleaseMat( &state->dispLeft );
-        cvReleaseMat( &state->dispRight );
-
-        state->left = cvCreateMat( size.height, size.width, CV_8UC3 );
-        state->right = cvCreateMat( size.height, size.width, CV_8UC3 );
-        state->dispLeft = cvCreateMat( size.height, size.width, CV_16SC1 );
-        state->dispRight = cvCreateMat( size.height, size.width, CV_16SC1 );
-        state->ptrLeft = cvCreateMat( size.height, size.width, CV_32SC(pcn) );
-        state->ptrRight = cvCreateMat( size.height, size.width, CV_32SC(pcn) );
-        state->vtxBuf = cvCreateMat( 1, size.height*size.width*2, CV_32SC(vcn) );
-        state->edgeBuf = cvCreateMat( 1, size.height*size.width*12 + 16, CV_32SC(ecn) );
-    }
-
-    if( !useDisparityGuess )
-    {
-        cvSet( state->dispLeft, cvScalarAll(OCCLUDED));
-        cvSet( state->dispRight, cvScalarAll(OCCLUDED));
-    }
-    else
-    {
-        CV_Assert( dispLeft && dispRight );
-        cvConvert( dispLeft, state->dispLeft );
-        cvConvert( dispRight, state->dispRight );
-    }
-
-    state2.Ithreshold = state->Ithreshold;
-    state2.interactionRadius = state->interactionRadius;
-    state2.lambda = cvRound(state->lambda*DENOMINATOR);
-    state2.lambda1 = cvRound(state->lambda1*DENOMINATOR);
-    state2.lambda2 = cvRound(state->lambda2*DENOMINATOR);
-    state2.K = cvRound(state->K*DENOMINATOR);
-
-    icvInitStereoConstTabs();
-    icvInitGraySubpix( left, right, state->left, state->right );
-
-    std::vector<int> disp(state->numberOfDisparities);
-    CvMat _disp = cvMat( 1, (int)disp.size(), CV_32S, &disp[0] );
-    cvRange( &_disp, state->minDisparity, state->minDisparity + state->numberOfDisparities );
-    cvRandShuffle( &_disp, &rng );
-
-    if( state2.lambda < 0 && (state2.K < 0 || state2.lambda1 < 0 || state2.lambda2 < 0) )
-    {
-        float L = icvComputeK(state)*0.2f;
-        state2.lambda = cvRound(L*DENOMINATOR);
-    }
-
-    if( state2.K < 0 )
-        state2.K = state2.lambda*5;
-    if( state2.lambda1 < 0 )
-        state2.lambda1 = state2.lambda*3;
-    if( state2.lambda2 < 0 )
-        state2.lambda2 = state2.lambda;
-
-    icvInitStereoTabs( &state2 );
-
-    E = icvComputeEnergy( state, &state2, !useDisparityGuess );
-    for( iter = 0; iter < state->maxIters; iter++ )
-    {
-        for( i = 0; i < state->numberOfDisparities; i++ )
-        {
-            int alpha = disp[i];
-            int64 Enew = icvAlphaExpand( E, -alpha, state, &state2 );
-            if( Enew < E )
-            {
-                nZeroExpansions = 0;
-                E = Enew;
-            }
-            else if( ++nZeroExpansions >= state->numberOfDisparities )
-                break;
-        }
-    }
-
-    if( dispLeft )
-        cvConvert( state->dispLeft, dispLeft );
-    if( dispRight )
-        cvConvert( state->dispRight, dispRight );
-
-    cvFree( &state2.orphans );
-}
diff --git a/modules/legacy/src/subdiv2.cpp b/modules/legacy/src/subdiv2.cpp
deleted file mode 100644 (file)
index b2fbcf6..0000000
+++ /dev/null
@@ -1,879 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-CV_IMPL CvSubdiv2D *
-cvCreateSubdiv2D( int subdiv_type, int header_size,
-                  int vtx_size, int quadedge_size, CvMemStorage * storage )
-{
-    if( !storage )
-        CV_Error( CV_StsNullPtr, "" );
-
-    if( header_size < (int)sizeof( CvSubdiv2D ) ||
-        quadedge_size < (int)sizeof( CvQuadEdge2D ) ||
-        vtx_size < (int)sizeof( CvSubdiv2DPoint ))
-        CV_Error( CV_StsBadSize, "" );
-
-    return (CvSubdiv2D *)cvCreateGraph( subdiv_type, header_size,
-                                        vtx_size, quadedge_size, storage );
-}
-
-
-/****************************************************************************************\
-*                                    Quad Edge  algebra                                  *
-\****************************************************************************************/
-
-static CvSubdiv2DEdge
-cvSubdiv2DMakeEdge( CvSubdiv2D * subdiv )
-{
-    if( !subdiv )
-        CV_Error( CV_StsNullPtr, "" );
-
-    CvQuadEdge2D* edge = (CvQuadEdge2D*)cvSetNew( (CvSet*)subdiv->edges );
-    memset( edge->pt, 0, sizeof( edge->pt ));
-    CvSubdiv2DEdge edgehandle = (CvSubdiv2DEdge) edge;
-
-    edge->next[0] = edgehandle;
-    edge->next[1] = edgehandle + 3;
-    edge->next[2] = edgehandle + 2;
-    edge->next[3] = edgehandle + 1;
-
-    subdiv->quad_edges++;
-    return edgehandle;
-}
-
-
-static CvSubdiv2DPoint *
-cvSubdiv2DAddPoint( CvSubdiv2D * subdiv, CvPoint2D32f pt, int is_virtual )
-{
-    CvSubdiv2DPoint* subdiv_point = (CvSubdiv2DPoint*)cvSetNew( (CvSet*)subdiv );
-    if( subdiv_point )
-    {
-        memset( subdiv_point, 0, subdiv->elem_size );
-        subdiv_point->pt = pt;
-        subdiv_point->first = 0;
-        subdiv_point->flags |= is_virtual ? CV_SUBDIV2D_VIRTUAL_POINT_FLAG : 0;
-        subdiv_point->id = -1;
-    }
-
-    return subdiv_point;
-}
-
-
-static void
-cvSubdiv2DSplice( CvSubdiv2DEdge edgeA, CvSubdiv2DEdge edgeB )
-{
-    CvSubdiv2DEdge *a_next = &CV_SUBDIV2D_NEXT_EDGE( edgeA );
-    CvSubdiv2DEdge *b_next = &CV_SUBDIV2D_NEXT_EDGE( edgeB );
-    CvSubdiv2DEdge a_rot = cvSubdiv2DRotateEdge( *a_next, 1 );
-    CvSubdiv2DEdge b_rot = cvSubdiv2DRotateEdge( *b_next, 1 );
-    CvSubdiv2DEdge *a_rot_next = &CV_SUBDIV2D_NEXT_EDGE( a_rot );
-    CvSubdiv2DEdge *b_rot_next = &CV_SUBDIV2D_NEXT_EDGE( b_rot );
-    CvSubdiv2DEdge t;
-
-    CV_SWAP( *a_next, *b_next, t );
-    CV_SWAP( *a_rot_next, *b_rot_next, t );
-}
-
-
-static void
-cvSubdiv2DSetEdgePoints( CvSubdiv2DEdge edge,
-                         CvSubdiv2DPoint * org_pt, CvSubdiv2DPoint * dst_pt )
-{
-    CvQuadEdge2D *quadedge = (CvQuadEdge2D *) (edge & ~3);
-
-    if( !quadedge )
-        CV_Error( CV_StsNullPtr, "" );
-
-    quadedge->pt[edge & 3] = org_pt;
-    quadedge->pt[(edge + 2) & 3] = dst_pt;
-}
-
-
-static void
-cvSubdiv2DDeleteEdge( CvSubdiv2D * subdiv, CvSubdiv2DEdge edge )
-{
-    CvQuadEdge2D *quadedge = (CvQuadEdge2D *) (edge & ~3);
-
-    if( !subdiv || !quadedge )
-        CV_Error( CV_StsNullPtr, "" );
-
-    cvSubdiv2DSplice( edge, cvSubdiv2DGetEdge( edge, CV_PREV_AROUND_ORG ));
-
-    CvSubdiv2DEdge sym_edge = cvSubdiv2DSymEdge( edge );
-    cvSubdiv2DSplice( sym_edge, cvSubdiv2DGetEdge( sym_edge, CV_PREV_AROUND_ORG ));
-
-    cvSetRemoveByPtr( (CvSet*)(subdiv->edges), quadedge );
-    subdiv->quad_edges--;
-}
-
-
-static CvSubdiv2DEdge
-cvSubdiv2DConnectEdges( CvSubdiv2D * subdiv, CvSubdiv2DEdge edgeA, CvSubdiv2DEdge edgeB )
-{
-    if( !subdiv )
-        CV_Error( CV_StsNullPtr, "" );
-
-    CvSubdiv2DEdge new_edge = cvSubdiv2DMakeEdge( subdiv );
-
-    cvSubdiv2DSplice( new_edge, cvSubdiv2DGetEdge( edgeA, CV_NEXT_AROUND_LEFT ));
-    cvSubdiv2DSplice( cvSubdiv2DSymEdge( new_edge ), edgeB );
-
-    CvSubdiv2DPoint* dstA = cvSubdiv2DEdgeDst( edgeA );
-    CvSubdiv2DPoint* orgB = cvSubdiv2DEdgeOrg( edgeB );
-    cvSubdiv2DSetEdgePoints( new_edge, dstA, orgB );
-
-    return new_edge;
-}
-
-
-static void
-cvSubdiv2DSwapEdges( CvSubdiv2DEdge edge )
-{
-    CvSubdiv2DEdge sym_edge = cvSubdiv2DSymEdge( edge );
-    CvSubdiv2DEdge a = cvSubdiv2DGetEdge( edge, CV_PREV_AROUND_ORG );
-    CvSubdiv2DEdge b = cvSubdiv2DGetEdge( sym_edge, CV_PREV_AROUND_ORG );
-    CvSubdiv2DPoint *dstB, *dstA;
-
-    cvSubdiv2DSplice( edge, a );
-    cvSubdiv2DSplice( sym_edge, b );
-
-    dstA = cvSubdiv2DEdgeDst( a );
-    dstB = cvSubdiv2DEdgeDst( b );
-    cvSubdiv2DSetEdgePoints( edge, dstA, dstB );
-
-    cvSubdiv2DSplice( edge, cvSubdiv2DGetEdge( a, CV_NEXT_AROUND_LEFT ));
-    cvSubdiv2DSplice( sym_edge, cvSubdiv2DGetEdge( b, CV_NEXT_AROUND_LEFT ));
-}
-
-
-static int
-icvIsRightOf( CvPoint2D32f& pt, CvSubdiv2DEdge edge )
-{
-    CvSubdiv2DPoint *org = cvSubdiv2DEdgeOrg(edge), *dst = cvSubdiv2DEdgeDst(edge);
-    double cw_area = cvTriangleArea( pt, dst->pt, org->pt );
-
-    return (cw_area > 0) - (cw_area < 0);
-}
-
-
-CV_IMPL CvSubdiv2DPointLocation
-cvSubdiv2DLocate( CvSubdiv2D * subdiv, CvPoint2D32f pt,
-                  CvSubdiv2DEdge * _edge, CvSubdiv2DPoint ** _point )
-{
-    CvSubdiv2DPoint *point = 0;
-    int right_of_curr = 0;
-
-    if( !subdiv )
-        CV_Error( CV_StsNullPtr, "" );
-
-    if( !CV_IS_SUBDIV2D(subdiv) )
-        CV_Error( CV_StsBadFlag, "" );
-
-    int i, max_edges = subdiv->quad_edges * 4;
-    CvSubdiv2DEdge edge = subdiv->recent_edge;
-
-    if( max_edges == 0 )
-        CV_Error( CV_StsBadSize, "" );
-    CV_Assert(edge != 0);
-
-    if( pt.x < subdiv->topleft.x || pt.y < subdiv->topleft.y ||
-        pt.x >= subdiv->bottomright.x || pt.y >= subdiv->bottomright.y )
-        CV_Error( CV_StsOutOfRange, "" );
-
-    CvSubdiv2DPointLocation location = CV_PTLOC_ERROR;
-
-    right_of_curr = icvIsRightOf( pt, edge );
-    if( right_of_curr > 0 )
-    {
-        edge = cvSubdiv2DSymEdge( edge );
-        right_of_curr = -right_of_curr;
-    }
-
-    for( i = 0; i < max_edges; i++ )
-    {
-        CvSubdiv2DEdge onext_edge = cvSubdiv2DNextEdge( edge );
-        CvSubdiv2DEdge dprev_edge = cvSubdiv2DGetEdge( edge, CV_PREV_AROUND_DST );
-
-        int right_of_onext = icvIsRightOf( pt, onext_edge );
-        int right_of_dprev = icvIsRightOf( pt, dprev_edge );
-
-        if( right_of_dprev > 0 )
-        {
-            if( right_of_onext > 0 || (right_of_onext == 0 && right_of_curr == 0) )
-            {
-                location = CV_PTLOC_INSIDE;
-                goto exit;
-            }
-            else
-            {
-                right_of_curr = right_of_onext;
-                edge = onext_edge;
-            }
-        }
-        else
-        {
-            if( right_of_onext > 0 )
-            {
-                if( right_of_dprev == 0 && right_of_curr == 0 )
-                {
-                    location = CV_PTLOC_INSIDE;
-                    goto exit;
-                }
-                else
-                {
-                    right_of_curr = right_of_dprev;
-                    edge = dprev_edge;
-                }
-            }
-            else if( right_of_curr == 0 &&
-                     icvIsRightOf( cvSubdiv2DEdgeDst( onext_edge )->pt, edge ) >= 0 )
-            {
-                edge = cvSubdiv2DSymEdge( edge );
-            }
-            else
-            {
-                right_of_curr = right_of_onext;
-                edge = onext_edge;
-            }
-        }
-    }
-exit:
-
-    subdiv->recent_edge = edge;
-
-    if( location == CV_PTLOC_INSIDE )
-    {
-        double t1, t2, t3;
-        CvPoint2D32f org_pt = cvSubdiv2DEdgeOrg( edge )->pt;
-        CvPoint2D32f dst_pt = cvSubdiv2DEdgeDst( edge )->pt;
-
-        t1 = fabs( pt.x - org_pt.x );
-        t1 += fabs( pt.y - org_pt.y );
-        t2 = fabs( pt.x - dst_pt.x );
-        t2 += fabs( pt.y - dst_pt.y );
-        t3 = fabs( org_pt.x - dst_pt.x );
-        t3 += fabs( org_pt.y - dst_pt.y );
-
-        if( t1 < FLT_EPSILON )
-        {
-            location = CV_PTLOC_VERTEX;
-            point = cvSubdiv2DEdgeOrg( edge );
-            edge = 0;
-        }
-        else if( t2 < FLT_EPSILON )
-        {
-            location = CV_PTLOC_VERTEX;
-            point = cvSubdiv2DEdgeDst( edge );
-            edge = 0;
-        }
-        else if( (t1 < t3 || t2 < t3) &&
-                 fabs( cvTriangleArea( pt, org_pt, dst_pt )) < FLT_EPSILON )
-        {
-            location = CV_PTLOC_ON_EDGE;
-            point = 0;
-        }
-    }
-
-    if( location == CV_PTLOC_ERROR )
-    {
-        edge = 0;
-        point = 0;
-    }
-
-    if( _edge )
-        *_edge = edge;
-    if( _point )
-        *_point = point;
-
-    return location;
-}
-
-
-CV_INLINE int
-icvIsPtInCircle3( CvPoint2D32f pt, CvPoint2D32f a, CvPoint2D32f b, CvPoint2D32f c )
-{
-    const double eps = FLT_EPSILON*0.125;
-    double val = ((double)a.x * a.x + (double)a.y * a.y) * cvTriangleArea( b, c, pt );
-    val -= ((double)b.x * b.x + (double)b.y * b.y) * cvTriangleArea( a, c, pt );
-    val += ((double)c.x * c.x + (double)c.y * c.y) * cvTriangleArea( a, b, pt );
-    val -= ((double)pt.x * pt.x + (double)pt.y * pt.y) * cvTriangleArea( a, b, c );
-
-    return val > eps ? 1 : val < -eps ? -1 : 0;
-}
-
-
-CV_IMPL CvSubdiv2DPoint *
-cvSubdivDelaunay2DInsert( CvSubdiv2D * subdiv, CvPoint2D32f pt )
-{
-    CvSubdiv2DPointLocation location = CV_PTLOC_ERROR;
-
-    CvSubdiv2DPoint *curr_point = 0, *first_point = 0;
-    CvSubdiv2DEdge curr_edge = 0, deleted_edge = 0, base_edge = 0;
-    int i, max_edges;
-
-    if( !subdiv )
-        CV_Error( CV_StsNullPtr, "" );
-
-    if( !CV_IS_SUBDIV2D(subdiv) )
-        CV_Error( CV_StsBadFlag, "" );
-
-    location = cvSubdiv2DLocate( subdiv, pt, &curr_edge, &curr_point );
-
-    switch (location)
-    {
-    case CV_PTLOC_ERROR:
-        CV_Error( CV_StsBadSize, "" );
-
-    case CV_PTLOC_OUTSIDE_RECT:
-        CV_Error( CV_StsOutOfRange, "" );
-
-    case CV_PTLOC_VERTEX:
-        break;
-
-    case CV_PTLOC_ON_EDGE:
-        deleted_edge = curr_edge;
-        subdiv->recent_edge = curr_edge = cvSubdiv2DGetEdge( curr_edge, CV_PREV_AROUND_ORG );
-        cvSubdiv2DDeleteEdge( subdiv, deleted_edge );
-        /* no break */
-
-    case CV_PTLOC_INSIDE:
-
-        assert( curr_edge != 0 );
-        subdiv->is_geometry_valid = 0;
-
-        curr_point = cvSubdiv2DAddPoint( subdiv, pt, 0 );
-        base_edge = cvSubdiv2DMakeEdge( subdiv );
-        first_point = cvSubdiv2DEdgeOrg( curr_edge );
-        cvSubdiv2DSetEdgePoints( base_edge, first_point, curr_point );
-        cvSubdiv2DSplice( base_edge, curr_edge );
-
-        do
-        {
-            base_edge = cvSubdiv2DConnectEdges( subdiv, curr_edge,
-                                                cvSubdiv2DSymEdge( base_edge ));
-            curr_edge = cvSubdiv2DGetEdge( base_edge, CV_PREV_AROUND_ORG );
-        }
-        while( cvSubdiv2DEdgeDst( curr_edge ) != first_point );
-
-        curr_edge = cvSubdiv2DGetEdge( base_edge, CV_PREV_AROUND_ORG );
-
-        max_edges = subdiv->quad_edges * 4;
-
-        for( i = 0; i < max_edges; i++ )
-        {
-            CvSubdiv2DPoint *temp_dst = 0, *curr_org = 0, *curr_dst = 0;
-            CvSubdiv2DEdge temp_edge = cvSubdiv2DGetEdge( curr_edge, CV_PREV_AROUND_ORG );
-
-            temp_dst = cvSubdiv2DEdgeDst( temp_edge );
-            curr_org = cvSubdiv2DEdgeOrg( curr_edge );
-            curr_dst = cvSubdiv2DEdgeDst( curr_edge );
-
-            if( icvIsRightOf( temp_dst->pt, curr_edge ) > 0 &&
-                icvIsPtInCircle3( curr_org->pt, temp_dst->pt,
-                                  curr_dst->pt, curr_point->pt ) < 0 )
-            {
-                cvSubdiv2DSwapEdges( curr_edge );
-                curr_edge = cvSubdiv2DGetEdge( curr_edge, CV_PREV_AROUND_ORG );
-            }
-            else if( curr_org == first_point )
-            {
-                break;
-            }
-            else
-            {
-                curr_edge = cvSubdiv2DGetEdge( cvSubdiv2DNextEdge( curr_edge ),
-                                               CV_PREV_AROUND_LEFT );
-            }
-        }
-        break;
-    default:
-        CV_Error_(CV_StsError, ("cvSubdiv2DLocate returned invalid location = %d", location) );
-    }
-
-    return curr_point;
-}
-
-
-CV_IMPL void
-cvInitSubdivDelaunay2D( CvSubdiv2D * subdiv, CvRect rect )
-{
-    float big_coord = 3.f * MAX( rect.width, rect.height );
-    CvPoint2D32f ppA, ppB, ppC;
-    CvSubdiv2DPoint *pA, *pB, *pC;
-    CvSubdiv2DEdge edge_AB, edge_BC, edge_CA;
-    float rx = (float) rect.x;
-    float ry = (float) rect.y;
-
-    if( !subdiv )
-        CV_Error( CV_StsNullPtr, "" );
-
-    cvClearSet( (CvSet *) (subdiv->edges) );
-    cvClearSet( (CvSet *) subdiv );
-
-    subdiv->quad_edges = 0;
-    subdiv->recent_edge = 0;
-    subdiv->is_geometry_valid = 0;
-
-    subdiv->topleft = cvPoint2D32f( rx, ry );
-    subdiv->bottomright = cvPoint2D32f( rx + rect.width, ry + rect.height );
-
-    ppA = cvPoint2D32f( rx + big_coord, ry );
-    ppB = cvPoint2D32f( rx, ry + big_coord );
-    ppC = cvPoint2D32f( rx - big_coord, ry - big_coord );
-
-    pA = cvSubdiv2DAddPoint( subdiv, ppA, 0 );
-    pB = cvSubdiv2DAddPoint( subdiv, ppB, 0 );
-    pC = cvSubdiv2DAddPoint( subdiv, ppC, 0 );
-
-    edge_AB = cvSubdiv2DMakeEdge( subdiv );
-    edge_BC = cvSubdiv2DMakeEdge( subdiv );
-    edge_CA = cvSubdiv2DMakeEdge( subdiv );
-
-    cvSubdiv2DSetEdgePoints( edge_AB, pA, pB );
-    cvSubdiv2DSetEdgePoints( edge_BC, pB, pC );
-    cvSubdiv2DSetEdgePoints( edge_CA, pC, pA );
-
-    cvSubdiv2DSplice( edge_AB, cvSubdiv2DSymEdge( edge_CA ));
-    cvSubdiv2DSplice( edge_BC, cvSubdiv2DSymEdge( edge_AB ));
-    cvSubdiv2DSplice( edge_CA, cvSubdiv2DSymEdge( edge_BC ));
-
-    subdiv->recent_edge = edge_AB;
-}
-
-
-CV_IMPL void
-cvClearSubdivVoronoi2D( CvSubdiv2D * subdiv )
-{
-    int elem_size;
-    int i, total;
-    CvSeqReader reader;
-
-    if( !subdiv )
-        CV_Error( CV_StsNullPtr, "" );
-
-    /* clear pointers to voronoi points */
-    total = subdiv->edges->total;
-    elem_size = subdiv->edges->elem_size;
-
-    cvStartReadSeq( (CvSeq *) (subdiv->edges), &reader, 0 );
-
-    for( i = 0; i < total; i++ )
-    {
-        CvQuadEdge2D *quadedge = (CvQuadEdge2D *) reader.ptr;
-
-        quadedge->pt[1] = quadedge->pt[3] = 0;
-        CV_NEXT_SEQ_ELEM( elem_size, reader );
-    }
-
-    /* remove voronoi points */
-    total = subdiv->total;
-    elem_size = subdiv->elem_size;
-
-    cvStartReadSeq( (CvSeq *) subdiv, &reader, 0 );
-
-    for( i = 0; i < total; i++ )
-    {
-        CvSubdiv2DPoint *pt = (CvSubdiv2DPoint *) reader.ptr;
-
-        /* check for virtual point. it is also check that the point exists */
-        if( pt->flags & CV_SUBDIV2D_VIRTUAL_POINT_FLAG )
-        {
-            cvSetRemoveByPtr( (CvSet*)subdiv, pt );
-        }
-        CV_NEXT_SEQ_ELEM( elem_size, reader );
-    }
-
-    subdiv->is_geometry_valid = 0;
-}
-
-
-static void
-icvCreateCenterNormalLine( CvSubdiv2DEdge edge, double *_a, double *_b, double *_c )
-{
-    CvPoint2D32f org = cvSubdiv2DEdgeOrg( edge )->pt;
-    CvPoint2D32f dst = cvSubdiv2DEdgeDst( edge )->pt;
-
-    double a = dst.x - org.x;
-    double b = dst.y - org.y;
-    double c = -(a * (dst.x + org.x) + b * (dst.y + org.y));
-
-    *_a = a + a;
-    *_b = b + b;
-    *_c = c;
-}
-
-
-static void
-icvIntersectLines3( double *a0, double *b0, double *c0,
-                   double *a1, double *b1, double *c1, CvPoint2D32f * point )
-{
-    double det = a0[0] * b1[0] - a1[0] * b0[0];
-
-    if( det != 0 )
-    {
-        det = 1. / det;
-        point->x = (float) ((b0[0] * c1[0] - b1[0] * c0[0]) * det);
-        point->y = (float) ((a1[0] * c0[0] - a0[0] * c1[0]) * det);
-    }
-    else
-    {
-        point->x = point->y = FLT_MAX;
-    }
-}
-
-
-CV_IMPL void
-cvCalcSubdivVoronoi2D( CvSubdiv2D * subdiv )
-{
-    CvSeqReader reader;
-    int i, total, elem_size;
-
-    if( !subdiv )
-        CV_Error( CV_StsNullPtr, "" );
-
-    /* check if it is already calculated */
-    if( subdiv->is_geometry_valid )
-        return;
-
-    total = subdiv->edges->total;
-    elem_size = subdiv->edges->elem_size;
-
-    cvClearSubdivVoronoi2D( subdiv );
-
-    cvStartReadSeq( (CvSeq *) (subdiv->edges), &reader, 0 );
-
-    if( total <= 3 )
-        return;
-
-    /* skip first three edges (bounding triangle) */
-    for( i = 0; i < 3; i++ )
-        CV_NEXT_SEQ_ELEM( elem_size, reader );
-
-    /* loop through all quad-edges */
-    for( ; i < total; i++ )
-    {
-        CvQuadEdge2D *quadedge = (CvQuadEdge2D *) (reader.ptr);
-
-        if( CV_IS_SET_ELEM( quadedge ))
-        {
-            CvSubdiv2DEdge edge0 = (CvSubdiv2DEdge) quadedge, edge1, edge2;
-            double a0, b0, c0, a1, b1, c1;
-            CvPoint2D32f virt_point;
-            CvSubdiv2DPoint *voronoi_point;
-
-            if( !quadedge->pt[3] )
-            {
-                edge1 = cvSubdiv2DGetEdge( edge0, CV_NEXT_AROUND_LEFT );
-                edge2 = cvSubdiv2DGetEdge( edge1, CV_NEXT_AROUND_LEFT );
-
-                icvCreateCenterNormalLine( edge0, &a0, &b0, &c0 );
-                icvCreateCenterNormalLine( edge1, &a1, &b1, &c1 );
-
-                icvIntersectLines3( &a0, &b0, &c0, &a1, &b1, &c1, &virt_point );
-                if( fabs( virt_point.x ) < FLT_MAX * 0.5 &&
-                    fabs( virt_point.y ) < FLT_MAX * 0.5 )
-                {
-                    voronoi_point = cvSubdiv2DAddPoint( subdiv, virt_point, 1 );
-
-                    quadedge->pt[3] =
-                        ((CvQuadEdge2D *) (edge1 & ~3))->pt[3 - (edge1 & 2)] =
-                        ((CvQuadEdge2D *) (edge2 & ~3))->pt[3 - (edge2 & 2)] = voronoi_point;
-                }
-            }
-
-            if( !quadedge->pt[1] )
-            {
-                edge1 = cvSubdiv2DGetEdge( edge0, CV_NEXT_AROUND_RIGHT );
-                edge2 = cvSubdiv2DGetEdge( edge1, CV_NEXT_AROUND_RIGHT );
-
-                icvCreateCenterNormalLine( edge0, &a0, &b0, &c0 );
-                icvCreateCenterNormalLine( edge1, &a1, &b1, &c1 );
-
-                icvIntersectLines3( &a0, &b0, &c0, &a1, &b1, &c1, &virt_point );
-
-                if( fabs( virt_point.x ) < FLT_MAX * 0.5 &&
-                    fabs( virt_point.y ) < FLT_MAX * 0.5 )
-                {
-                    voronoi_point = cvSubdiv2DAddPoint( subdiv, virt_point, 1 );
-
-                    quadedge->pt[1] =
-                        ((CvQuadEdge2D *) (edge1 & ~3))->pt[1 + (edge1 & 2)] =
-                        ((CvQuadEdge2D *) (edge2 & ~3))->pt[1 + (edge2 & 2)] = voronoi_point;
-                }
-            }
-        }
-
-        CV_NEXT_SEQ_ELEM( elem_size, reader );
-    }
-
-    subdiv->is_geometry_valid = 1;
-}
-
-
-static int
-icvIsRightOf2( const CvPoint2D32f& pt, const CvPoint2D32f& org, const CvPoint2D32f& diff )
-{
-    double cw_area = ((double)org.x - pt.x)*diff.y - ((double)org.y - pt.y)*diff.x;
-    return (cw_area > 0) - (cw_area < 0);
-}
-
-
-CV_IMPL CvSubdiv2DPoint*
-cvFindNearestPoint2D( CvSubdiv2D* subdiv, CvPoint2D32f pt )
-{
-    CvSubdiv2DPoint* point = 0;
-    CvPoint2D32f start;
-    CvPoint2D32f diff;
-    CvSubdiv2DPointLocation loc;
-    CvSubdiv2DEdge edge;
-    int i;
-
-    if( !subdiv )
-        CV_Error( CV_StsNullPtr, "" );
-
-    if( !CV_IS_SUBDIV2D( subdiv ))
-        CV_Error( CV_StsNullPtr, "" );
-
-    if( subdiv->edges->active_count <= 3 )
-        return 0;
-
-    if( !subdiv->is_geometry_valid )
-        cvCalcSubdivVoronoi2D( subdiv );
-
-    loc = cvSubdiv2DLocate( subdiv, pt, &edge, &point );
-
-    switch( loc )
-    {
-    case CV_PTLOC_ON_EDGE:
-    case CV_PTLOC_INSIDE:
-        break;
-    default:
-        return point;
-    }
-
-    point = 0;
-
-    start = cvSubdiv2DEdgeOrg( edge )->pt;
-    diff.x = pt.x - start.x;
-    diff.y = pt.y - start.y;
-
-    edge = cvSubdiv2DRotateEdge( edge, 1 );
-
-    for( i = 0; i < subdiv->total; i++ )
-    {
-        CvPoint2D32f t;
-
-        for(;;)
-        {
-            assert( cvSubdiv2DEdgeDst( edge ));
-
-            t = cvSubdiv2DEdgeDst( edge )->pt;
-            if( icvIsRightOf2( t, start, diff ) >= 0 )
-                break;
-
-            edge = cvSubdiv2DGetEdge( edge, CV_NEXT_AROUND_LEFT );
-        }
-
-        for(;;)
-        {
-            assert( cvSubdiv2DEdgeOrg( edge ));
-
-            t = cvSubdiv2DEdgeOrg( edge )->pt;
-            if( icvIsRightOf2( t, start, diff ) < 0 )
-                break;
-
-            edge = cvSubdiv2DGetEdge( edge, CV_PREV_AROUND_LEFT );
-        }
-
-        {
-            CvPoint2D32f tempDiff = cvSubdiv2DEdgeDst( edge )->pt;
-            t = cvSubdiv2DEdgeOrg( edge )->pt;
-            tempDiff.x -= t.x;
-            tempDiff.y -= t.y;
-
-            if( icvIsRightOf2( pt, t, tempDiff ) >= 0 )
-            {
-                point = cvSubdiv2DEdgeOrg( cvSubdiv2DRotateEdge( edge, 3 ));
-                break;
-            }
-        }
-
-        edge = cvSubdiv2DSymEdge( edge );
-    }
-
-    return point;
-}
-
-CV_IMPL int
-icvSubdiv2DCheck( CvSubdiv2D* subdiv )
-{
-    int i, j, total = subdiv->edges->total;
-    CV_Assert( subdiv != 0 );
-
-    for( i = 0; i < total; i++ )
-    {
-        CvQuadEdge2D* edge = (CvQuadEdge2D*)cvGetSetElem(subdiv->edges,i);
-
-        if( edge && CV_IS_SET_ELEM( edge ))
-        {
-            for( j = 0; j < 4; j++ )
-            {
-                CvSubdiv2DEdge e = (CvSubdiv2DEdge)edge + j;
-                CvSubdiv2DEdge o_next = cvSubdiv2DNextEdge(e);
-                CvSubdiv2DEdge o_prev = cvSubdiv2DGetEdge(e, CV_PREV_AROUND_ORG );
-                CvSubdiv2DEdge d_prev = cvSubdiv2DGetEdge(e, CV_PREV_AROUND_DST );
-                CvSubdiv2DEdge d_next = cvSubdiv2DGetEdge(e, CV_NEXT_AROUND_DST );
-
-                // check points
-                if( cvSubdiv2DEdgeOrg(e) != cvSubdiv2DEdgeOrg(o_next))
-                    return 0;
-                if( cvSubdiv2DEdgeOrg(e) != cvSubdiv2DEdgeOrg(o_prev))
-                    return 0;
-                if( cvSubdiv2DEdgeDst(e) != cvSubdiv2DEdgeDst(d_next))
-                    return 0;
-                if( cvSubdiv2DEdgeDst(e) != cvSubdiv2DEdgeDst(d_prev))
-                    return 0;
-                if( j % 2 == 0 )
-                {
-                    if( cvSubdiv2DEdgeDst(o_next) != cvSubdiv2DEdgeOrg(d_prev))
-                        return 0;
-                    if( cvSubdiv2DEdgeDst(o_prev) != cvSubdiv2DEdgeOrg(d_next))
-                        return 0;
-                    if( cvSubdiv2DGetEdge(cvSubdiv2DGetEdge(cvSubdiv2DGetEdge(
-                        e,CV_NEXT_AROUND_LEFT),CV_NEXT_AROUND_LEFT),CV_NEXT_AROUND_LEFT) != e )
-                        return 0;
-                    if( cvSubdiv2DGetEdge(cvSubdiv2DGetEdge(cvSubdiv2DGetEdge(
-                        e,CV_NEXT_AROUND_RIGHT),CV_NEXT_AROUND_RIGHT),CV_NEXT_AROUND_RIGHT) != e)
-                        return 0;
-                }
-            }
-        }
-    }
-
-    return 1;
-}
-
-
-
-static void
-draw_subdiv_facet( CvSubdiv2D * subdiv, IplImage * dst, IplImage * src, CvSubdiv2DEdge edge )
-{
-    CvSubdiv2DEdge t = edge;
-    int i, count = 0;
-    CvPoint local_buf[100];
-    CvPoint *buf = local_buf;
-
-    // count number of edges in facet
-    do
-    {
-        count++;
-        t = cvSubdiv2DGetEdge( t, CV_NEXT_AROUND_LEFT );
-    }
-    while( t != edge && count < subdiv->quad_edges * 4 );
-
-    if( count * sizeof( buf[0] ) > sizeof( local_buf ))
-    {
-        buf = (CvPoint *) malloc( count * sizeof( buf[0] ));
-    }
-
-    // gather points
-    t = edge;
-    for( i = 0; i < count; i++ )
-    {
-        CvSubdiv2DPoint *pt = cvSubdiv2DEdgeOrg( t );
-
-        if( !pt )
-            break;
-        assert( fabs( pt->pt.x ) < 10000 && fabs( pt->pt.y ) < 10000 );
-        buf[i] = cvPoint( cvRound( pt->pt.x ), cvRound( pt->pt.y ));
-        t = cvSubdiv2DGetEdge( t, CV_NEXT_AROUND_LEFT );
-    }
-
-    if( i == count )
-    {
-        CvSubdiv2DPoint *pt = cvSubdiv2DEdgeDst( cvSubdiv2DRotateEdge( edge, 1 ));
-        CvPoint ip = cvPoint( cvRound( pt->pt.x ), cvRound( pt->pt.y ));
-        CvScalar color(0);
-
-        //printf("count = %d, (%d,%d)\n", ip.x, ip.y );
-
-        if( 0 <= ip.x && ip.x < src->width && 0 <= ip.y && ip.y < src->height )
-        {
-            uchar *ptr = (uchar*)(src->imageData + ip.y * src->widthStep + ip.x * 3);
-            color = CV_RGB( ptr[2], ptr[1], ptr[0] );
-        }
-
-        cvFillConvexPoly( dst, buf, count, color );
-        //draw_subdiv_point( dst, pt->pt, CV_RGB(0,0,0));
-    }
-
-    if( buf != local_buf )
-        free( buf );
-}
-
-
-CV_IMPL void
-icvDrawMosaic( CvSubdiv2D * subdiv, IplImage * src, IplImage * dst )
-{
-    int i, total = subdiv->edges->total;
-
-    cvCalcSubdivVoronoi2D( subdiv );
-
-    //icvSet( dst, 255 );
-    for( i = 0; i < total; i++ )
-    {
-        CvQuadEdge2D *edge = (CvQuadEdge2D *) cvGetSetElem( subdiv->edges, i );
-
-        if( edge && CV_IS_SET_ELEM( edge ))
-        {
-            CvSubdiv2DEdge e = (CvSubdiv2DEdge) edge;
-
-            // left
-            draw_subdiv_facet( subdiv, dst, src, cvSubdiv2DRotateEdge( e, 1 ));
-            // right
-            draw_subdiv_facet( subdiv, dst, src, cvSubdiv2DRotateEdge( e, 3 ));
-        }
-    }
-}
-
-/* End of file. */
diff --git a/modules/legacy/src/testseq.cpp b/modules/legacy/src/testseq.cpp
deleted file mode 100644 (file)
index af4da33..0000000
+++ /dev/null
@@ -1,1369 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
-This file contain implementation of virtual interface of CvTestSeq
-*/
-
-#include "precomp.hpp" /* virtual interface if CvTestSeq */
-
-
-void cvAddNoise(IplImage* pImg, int noise_type, double Ampl, CvRandState* rnd_state = NULL);
-
-#define FG_BG_THRESHOLD 3
-
-#define SRC_TYPE_AVI 1
-#define SRC_TYPE_IMAGE 0
-
-/* Transformation structure: */
-typedef struct CvTSTrans
-{
-    float           T[6]; /* geometry transformation */
-    CvPoint2D32f    Shift;
-    CvPoint2D32f    Scale;
-    float           I;
-    float           C;
-    float           GN; /* standart deviation of added gaussian noise */
-    float           NoiseAmp; /* amplifier of noise power */
-    float           angle;
-} CvTSTrans;
-
-static void SET_TRANS_0(CvTSTrans *pT)
-{
-    memset(pT,0,sizeof(CvTSTrans));
-    pT->C = 1;
-    pT->Scale.x = 1;
-    pT->Scale.y = 1;
-    pT->T[4] = pT->T[0] = 1;
-    pT->NoiseAmp = 1;
-}
-
-/* === Some definitions and functions for transformation update: ===*/
-#define P_ANGLE 0
-#define P_S     1
-#define P_SX    2
-#define P_SY    3
-#define P_DX    4
-#define P_DY    5
-#define P_I     6
-#define P_C     7
-#define P_GN    8
-#define P_NAmp  9
-static const char*   param_name[] =    {"angle","s","sx","sy","dx","dy","I","C","GN","NoiseAmp", NULL};
-static float   param_defval[] =  { 0,      1,  1,   1,   0,   0,   0,  1,  0,   1};
-static void icvUpdateTrans(CvTSTrans* pTrans, int param, double val, float MaxX, float MaxY)
-{
-    assert(pTrans);
-    if(param==P_ANGLE)
-    {
-
-        double  C = cos(3.1415926535897932384626433832795*val/180.0);
-        double  S = sin(3.1415926535897932384626433832795*val/180.0);
-        float*  T = pTrans->T;
-        double  TR[6];
-        int     i;
-        pTrans->angle = (float)(pTrans->angle + val);
-        TR[0] = C*T[0]-S*T[3];
-        TR[1] = C*T[1]-S*T[4];
-        TR[2] = C*T[2]-S*T[5];
-        TR[3] = S*T[0]+C*T[3];
-        TR[4] = S*T[1]+C*T[4];
-        TR[5] = S*T[2]+C*T[5];
-        for(i=0;i<6;++i)T[i]=(float)TR[i];
-    }
-
-    if(param==P_S)
-    {
-        int i;
-        for(i=0;i<6;++i)pTrans->T[i] = (float)(pTrans->T[i]*val);
-        pTrans->Scale.x = (float)(pTrans->Scale.x *val);
-        pTrans->Scale.y = (float)(pTrans->Scale.y *val);
-        pTrans->Shift.x = (float)(pTrans->Shift.x *val);
-        pTrans->Shift.y = (float)(pTrans->Shift.y *val);
-    }
-
-    if(param==P_SX)
-    {
-        int i;
-        for(i=0;i<3;++i)pTrans->T[i] = (float)(pTrans->T[i]*val);
-        pTrans->Scale.x = (float)(pTrans->Scale.x*val);
-        pTrans->Shift.x = (float)(pTrans->Shift.x*val);
-    }
-
-    if(param==P_SY)
-    {
-        int i;
-        for(i=0;i<3;++i)pTrans->T[i+3] = (float)(pTrans->T[i+3]*val);
-        pTrans->Scale.y = (float)(pTrans->Scale.y *val);
-        pTrans->Shift.y = (float)(pTrans->Shift.y *val);
-    }
-
-    if(param==P_DX)
-    {
-        pTrans->Shift.x = (float)(pTrans->Shift.x +val);
-        pTrans->T[2] = (float)(pTrans->T[2] +val*MaxX);
-    }
-
-    if(param==P_DY)
-    {
-        pTrans->Shift.y = (float)(pTrans->Shift.y +val);
-        pTrans->T[5] = (float)(pTrans->T[5] +val*MaxY);
-    }
-
-    if(param==P_C)
-    {
-        pTrans->C = (float)(pTrans->C *val);
-        pTrans->I = (float)(pTrans->I *val);
-    }
-
-    if(param==P_I) pTrans->I = (float)(pTrans->I +val);
-
-    if(param==P_GN)
-    {
-        pTrans->GN = (float)sqrt(val*val+pTrans->GN*pTrans->GN);
-    }
-
-    if(param==P_NAmp) pTrans->NoiseAmp = (float)(pTrans->NoiseAmp *val);
-}   /* icvUpdateTrans */
-
-/* === END some defenitions and function for transformation update ===*/
-
-typedef struct CvTestSeqElem
-{
-    const char*     pObjName;
-    const char*     pFileName;
-    int             type; /* video or image */
-    CvPoint2D32f*   pPos; /* positions of object in sequence */
-    int             PosNum;
-    CvPoint2D32f*   pSize; /* sizes of object in sequence */
-    int             SizeNum;
-    CvTSTrans*      pTrans; /* transforation of image in sequence */
-    int             TransNum;
-    int             ShiftByPos;
-    CvPoint2D32f    ShiftBegin;
-    CvPoint2D32f    ShiftEnd;
-    int             FrameBegin;
-    int             FrameNum;
-    IplImage*       pImg;
-    IplImage*       pImgMask;
-    void*           pAVI;
-    //CvCapture*      pAVI;
-    int             AVILen;
-    int             BG; /* flag is it background (1) or foreground (0) */
-    int             Mask; /* flag is it foreground mask (1) or usual video (0) */
-    CvTestSeqElem   *next;
-    int             noise_type;
-    CvRandState     rnd_state;
-    int             ObjID;
-} CvTestSeqElem;
-
-/* Test seq main structure: */
-typedef struct CvTestSeq_
-{
-    int             ID;
-    CvFileStorage*  pFileStorage;
-    CvTestSeqElem*  pElemList;
-    int             ListNum;
-    IplImage*       pImg;
-    IplImage*       pImgMask;
-    int             CurFrame;
-    int             FrameNum;
-    int             noise_type;
-    double          noise_ampl;
-    float           IVar_DI;
-    float           IVar_MinI;
-    float           IVar_MaxI;
-    float           IVar_CurDI;
-    float           IVar_CurI;
-    int             ObjNum;
-
-} CvTestSeq_;
-
-
-CvSize cvTestSeqGetImageSize(CvTestSeq* pTestSeq){return cvSize(((CvTestSeq_*)(pTestSeq))->pImg->width,((CvTestSeq_*)(pTestSeq))->pImg->height);}
-int cvTestSeqFrameNum(CvTestSeq* pTestSeq){return ((CvTestSeq_*)(pTestSeq))->FrameNum;}
-
-static void icvTestSeqCreateMask(IplImage* pImg,IplImage* pImgMask, int threshold)
-{
-    if(pImg->nChannels > 1)
-    {
-        cvCvtColor( pImg,pImgMask,CV_BGR2GRAY);
-        cvThreshold(pImgMask,pImgMask,threshold,255,CV_THRESH_BINARY);
-    }
-    else
-    {
-        cvThreshold(pImg,pImgMask,threshold,255,CV_THRESH_BINARY);
-    }
-}   /* icvTestSeqCreateMask */
-
-
-static void icvTestSeqQureyFrameElem(CvTestSeqElem* p, int /*frame*/)
-{   /* Read next frame from avi for one record: */
-    if(p->type == SRC_TYPE_AVI)
-    {
-        IplImage*   pI = NULL;
-        //int         frameNum = p->AVILen;
-
-        if(p->pAVI == NULL && p->pFileName)
-        {   /* Open avi file if necessary: */
-            p->pAVI = 0;//cvCaptureFromFile(p->pFileName);
-            if(p->pAVI == NULL)
-            {
-                printf("WARNING!!! Can not open avi file %s\n",p->pFileName);
-                return;
-            }
-        }   /* Open avi file if necessary. */
-
-        assert(p->pAVI);
-        //if(frame >= frameNum)
-        {   /* Set new position: */
-            //int N = frame%frameNum;
-
-            /*if( N==0 ||
-                N != (int)cvGetCaptureProperty(p->pAVI,CV_CAP_PROP_POS_FRAMES))
-            {
-                cvSetCaptureProperty(p->pAVI,CV_CAP_PROP_POS_FRAMES,N);
-            }*/
-        }   /* Set new position. */
-
-        //pI = cvQueryFrame(p->pAVI);
-        if(pI)
-        {
-            if(pI->origin != p->pImg->origin)
-                cvFlip( pI, p->pImg, 0 );
-            else
-                cvCopy(pI, p->pImg);
-        }
-
-        if(p->pImg)
-        {
-            if(p->pImgMask==NULL)
-            {
-                p->pImgMask = cvCreateImage(
-                    cvSize(p->pImg->width,p->pImg->height),
-                    IPL_DEPTH_8U,1);
-            }
-            icvTestSeqCreateMask(p->pImg,p->pImgMask,p->Mask?128:FG_BG_THRESHOLD);
-        }
-    }
-
-}   /* icvTestSeqQureyFrameElem */
-
-/*------------- Recursive function to read all images, ------------------------*/
-/*------------- videos and objects from config file.   ------------------------*/
-
-static CvTestSeqElem* icvTestSeqReadElemAll(CvTestSeq_* pTS, CvFileStorage* fs, const char* name);
-
-static void icvTestSeqAllocTrans(CvTestSeqElem* p)
-{   /* Allocate transformation array if necessary */
-    /* work with transformation */
-    if(p->pTrans == NULL/* && p->FrameNum>0*/)
-    {   /* Allocate transformation array: */
-        int num = MAX(1,p->FrameNum);
-        p->pTrans = (CvTSTrans*)cvAlloc(sizeof(CvTSTrans)*num);
-        p->TransNum = num;
-        while(num--)SET_TRANS_0(p->pTrans+num);
-    }
-
-    if(p->FrameNum > p->TransNum)
-    {   /* Allocate new transformation array: */
-        int         i;
-        int         num = p->FrameNum;
-        CvTSTrans*  pNewTrans = (CvTSTrans*)cvAlloc(sizeof(CvTSTrans)*num);
-
-        for(i=0; i<num; ++i)
-        {
-            if(p->pTrans)
-                pNewTrans[i] = p->pTrans[i%p->TransNum];
-            else
-                SET_TRANS_0(pNewTrans+i);
-        }
-        if(p->pTrans)cvFree(&p->pTrans);
-        p->pTrans = pNewTrans;
-        p->TransNum = num;
-    }   /* Allocate new transformation array. */
-}   /*  Allocate transformation array if necessary. */
-
-static CvTestSeqElem* icvTestSeqReadElemOne(CvTestSeq_* pTS, CvFileStorage* fs, CvFileNode* node)
-{
-    int             noise_type = CV_NOISE_NONE;;
-    CvTestSeqElem*  pElem = NULL;
-    const char*     pVideoName = cvReadStringByName( fs, node,"Video", NULL);
-    const char*     pVideoObjName = cvReadStringByName( fs, node,"VideoObj", NULL);
-
-    if(pVideoName)
-    {   /* Check to noise flag: */
-        if( cv_stricmp(pVideoName,"noise_gaussian") == 0 ||
-            cv_stricmp(pVideoName,"noise_normal") == 0) noise_type = CV_NOISE_GAUSSIAN;
-        if( cv_stricmp(pVideoName,"noise_uniform") == 0) noise_type = CV_NOISE_UNIFORM;
-        if( cv_stricmp(pVideoName,"noise_speckle") == 0) noise_type = CV_NOISE_SPECKLE;
-        if( cv_stricmp(pVideoName,"noise_salt_and_pepper") == 0) noise_type = CV_NOISE_SALT_AND_PEPPER;
-    }
-
-    if((pVideoName || pVideoObjName ) && noise_type == CV_NOISE_NONE)
-    {   /* Read other elements: */
-        if(pVideoName) pElem = icvTestSeqReadElemAll(pTS, fs, pVideoName);
-        if(pVideoObjName)
-        {
-            CvTestSeqElem* pE;
-            pElem = icvTestSeqReadElemAll(pTS, fs, pVideoObjName);
-            for(pE=pElem;pE;pE=pE->next)
-            {
-                pE->ObjID = pTS->ObjNum;
-                pE->pObjName = pVideoObjName;
-            }
-            pTS->ObjNum++;
-        }
-    }   /* Read other elements. */
-    else
-    {   /* Create new element: */
-        CvFileNode* pPosNode = cvGetFileNodeByName( fs, node,"Pos");
-        CvFileNode* pSizeNode = cvGetFileNodeByName( fs, node,"Size");
-        int AutoSize = (pSizeNode && CV_NODE_IS_STRING(pSizeNode->tag) && cv_stricmp("auto",cvReadString(pSizeNode,""))==0);
-        int AutoPos = (pPosNode && CV_NODE_IS_STRING(pPosNode->tag) && cv_stricmp("auto",cvReadString(pPosNode,""))==0);
-        const char* pFileName = cvReadStringByName( fs, node,"File", NULL);
-        pElem = (CvTestSeqElem*)cvAlloc(sizeof(CvTestSeqElem));
-        memset(pElem,0,sizeof(CvTestSeqElem));
-
-        pElem->ObjID = -1;
-        pElem->noise_type = noise_type;
-        cvRandInit( &pElem->rnd_state, 1, 0, 0,CV_RAND_NORMAL);
-
-        if(pFileName && pElem->noise_type == CV_NOISE_NONE)
-        {   /* If AVI or BMP: */
-            size_t  l = strlen(pFileName);
-            pElem->pFileName = pFileName;
-
-            pElem->type = SRC_TYPE_IMAGE;
-            if(cv_stricmp(".avi",pFileName+l-4) == 0)pElem->type = SRC_TYPE_AVI;
-
-            if(pElem->type == SRC_TYPE_IMAGE)
-            {
-                //pElem->pImg = cvLoadImage(pFileName);
-                if(pElem->pImg)
-                {
-                    pElem->FrameNum = 1;
-                    if(pElem->pImgMask)cvReleaseImage(&(pElem->pImgMask));
-
-                    pElem->pImgMask = cvCreateImage(
-                        cvSize(pElem->pImg->width,pElem->pImg->height),
-                        IPL_DEPTH_8U,1);
-                    icvTestSeqCreateMask(pElem->pImg,pElem->pImgMask,FG_BG_THRESHOLD);
-                }
-            }
-
-            if(pElem->type == SRC_TYPE_AVI && pFileName)
-            {
-                //pElem->pAVI = cvCaptureFromFile(pFileName);
-
-                if(pElem->pAVI)
-                {
-                    IplImage* pImg = 0;//cvQueryFrame(pElem->pAVI);
-                    pElem->pImg = cvCloneImage(pImg);
-                    pElem->pImg->origin = 0;
-                    //cvSetCaptureProperty(pElem->pAVI,CV_CAP_PROP_POS_FRAMES,0);
-                    pElem->FrameBegin = 0;
-                    pElem->AVILen = pElem->FrameNum = 0;//(int)cvGetCaptureProperty(pElem->pAVI, CV_CAP_PROP_FRAME_COUNT);
-                    //cvReleaseCapture(&pElem->pAVI);
-                    pElem->pAVI = NULL;
-                }
-                else
-                {
-                    printf("WARNING!!! Cannot open avi file %s\n",pFileName);
-                }
-            }
-
-        }   /* If AVI or BMP. */
-
-        if(pPosNode)
-        {   /* Read positions: */
-            if(CV_NODE_IS_SEQ(pPosNode->tag))
-            {
-                int num = pPosNode->data.seq->total;
-                pElem->pPos = (CvPoint2D32f*)cvAlloc(sizeof(float)*num);
-                cvReadRawData( fs, pPosNode, pElem->pPos, "f" );
-                pElem->PosNum = num/2;
-                if(pElem->FrameNum == 0) pElem->FrameNum = pElem->PosNum;
-            }
-        }
-
-        if(pSizeNode)
-        {   /* Read sizes: */
-            if(CV_NODE_IS_SEQ(pSizeNode->tag))
-            {
-                int num = pSizeNode->data.seq->total;
-                pElem->pSize = (CvPoint2D32f*)cvAlloc(sizeof(float)*num);
-                cvReadRawData( fs, pSizeNode, pElem->pSize, "f" );
-                pElem->SizeNum = num/2;
-            }
-        }
-
-        if(AutoPos || AutoSize)
-        {   /* Auto size and pos: */
-            int     i;
-            int     num = (pElem->type == SRC_TYPE_AVI)?pElem->AVILen:1;
-            if(AutoSize)
-            {
-                pElem->pSize = (CvPoint2D32f*)cvAlloc(sizeof(CvPoint2D32f)*num);
-                pElem->SizeNum = num;
-            }
-            if(AutoPos)
-            {
-                pElem->pPos = (CvPoint2D32f*)cvAlloc(sizeof(CvPoint2D32f)*num);
-                pElem->PosNum = num;
-            }
-
-            for(i=0; i<num; ++i)
-            {
-                IplImage* pFG = NULL;
-                CvPoint2D32f* pPos = AutoPos?(pElem->pPos + i):NULL;
-                CvPoint2D32f* pSize = AutoSize?(pElem->pSize + i):NULL;
-
-                icvTestSeqQureyFrameElem(pElem,i);
-                pFG = pElem->pImgMask;
-
-                if(pPos)
-                {
-                    pPos->x = 0.5f;
-                    pPos->y = 0.5f;
-                }
-                if(pSize)
-                {
-                    pSize->x = 0;
-                    pSize->y = 0;
-                }
-
-                if(pFG)
-                {
-                    double      M00;
-                    CvMoments   m;
-                    cvMoments( pElem->pImgMask, &m, 0 );
-                    M00 = cvGetSpatialMoment( &m, 0, 0 );
-
-                    if(M00 > 0 && pSize )
-                    {
-                        double X = cvGetSpatialMoment( &m, 1, 0 )/M00;
-                        double Y = cvGetSpatialMoment( &m, 0, 1 )/M00;
-                        double XX = (cvGetSpatialMoment( &m, 2, 0 )/M00) - X*X;
-                        double YY = (cvGetSpatialMoment( &m, 0, 2 )/M00) - Y*Y;
-                        pSize->x = (float)(4*sqrt(XX))/(pElem->pImgMask->width-1);
-                        pSize->y = (float)(4*sqrt(YY))/(pElem->pImgMask->height-1);
-                    }
-
-                    if(M00 > 0 && pPos)
-                    {
-                        pPos->x = (float)(cvGetSpatialMoment( &m, 1, 0 )/(M00*(pElem->pImgMask->width-1)));
-                        pPos->y = (float)(cvGetSpatialMoment( &m, 0, 1 )/(M00*(pElem->pImgMask->height-1)));
-                    }
-
-                    if(pPos)
-                    {   /* Another way to calculate y pos
-                         * using object median:
-                         */
-                        int y0=0, y1=pFG->height-1;
-                        for(y0=0; y0<pFG->height; ++y0)
-                        {
-                            CvMat       tmp;
-                            CvScalar    s = cvSum(cvGetRow(pFG, &tmp, y0));
-                            if(s.val[0] > 255*7) break;
-                        }
-
-                        for(y1=pFG->height-1; y1>0; --y1)
-                        {
-                            CvMat tmp;
-                            CvScalar s = cvSum(cvGetRow(pFG, &tmp, y1));
-                            if(s.val[0] > 255*7) break;
-                        }
-
-                        pPos->y = (y0+y1)*0.5f/(pFG->height-1);
-                    }
-                }   /* pFG */
-            }   /* Next frame. */
-
-            //if(pElem->pAVI) cvReleaseCapture(&pElem->pAVI);
-
-            pElem->pAVI = NULL;
-
-        }   /* End auto position creation. */
-    }   /*  Create new element. */
-
-    if(pElem)
-    {   /* Read transforms and: */
-        int             FirstFrame, LastFrame;
-        CvTestSeqElem*  p=pElem;
-        CvFileNode*     pTransNode = NULL;
-        CvFileNode*     pS = NULL;
-        int             ShiftByPos = 0;
-        int             KeyFrames[1024];
-        CvSeq*          pTransSeq = NULL;
-        int             KeyFrameNum = 0;
-
-        pTransNode = cvGetFileNodeByName( fs, node,"Trans");
-
-        while( pTransNode &&
-               CV_NODE_IS_STRING(pTransNode->tag) &&
-               cv_stricmp("auto",cvReadString(pTransNode,""))!=0)
-        {   /* Trans is reference: */
-            pTransNode = cvGetFileNodeByName( fs, NULL,cvReadString(pTransNode,""));
-        }
-
-        pS = cvGetFileNodeByName( fs, node,"Shift");
-        ShiftByPos = 0;
-        pTransSeq = pTransNode?(CV_NODE_IS_SEQ(pTransNode->tag)?pTransNode->data.seq:NULL):NULL;
-        KeyFrameNum = pTransSeq?pTransSeq->total:1;
-
-        if(   (pS && CV_NODE_IS_STRING(pS->tag) && cv_stricmp("auto",cvReadString(pS,""))==0)
-            ||(pTransNode && CV_NODE_IS_STRING(pTransNode->tag) && cv_stricmp("auto",cvReadString(pTransNode,""))==0))
-        {
-            ShiftByPos = 1;
-        }
-
-        FirstFrame = pElem->FrameBegin;
-        LastFrame = pElem->FrameBegin+pElem->FrameNum-1;
-
-        /* Calculate length of video and reallocate
-         * transformation array:
-         */
-        for(p=pElem; p; p=p->next)
-        {
-            int v;
-            v = cvReadIntByName( fs, node, "BG", -1 );
-            if(v!=-1)p->BG = v;
-            v = cvReadIntByName( fs, node, "Mask", -1 );
-            if(v!=-1)p->Mask = v;
-
-            p->FrameBegin += cvReadIntByName( fs, node, "FrameBegin", 0 );
-            p->FrameNum = cvReadIntByName( fs, node, "FrameNum", p->FrameNum );
-            p->FrameNum = cvReadIntByName( fs, node, "Dur", p->FrameNum );
-            {
-                int lastFrame = cvReadIntByName( fs, node, "LastFrame", p->FrameBegin+p->FrameNum-1 );
-                p->FrameNum = MIN(p->FrameNum,lastFrame - p->FrameBegin+1);
-            }
-
-            icvTestSeqAllocTrans(p);
-
-            {   /* New range estimation: */
-                int LF = p->FrameBegin+p->FrameNum-1;
-                if(p==pElem || FirstFrame > p->FrameBegin)FirstFrame = p->FrameBegin;
-                if(p==pElem || LastFrame < LF)LastFrame = LF;
-            }   /* New range estimation. */
-        }   /*  End allocate new transfrom array. */
-
-        if(ShiftByPos)
-        {
-            for(p=pElem;p;p=p->next)
-            {   /* Modify transformation to make autoshift: */
-                int         i;
-                int         num = p->FrameNum;
-                assert(num <= p->TransNum);
-                p->TransNum = MAX(1,num);
-
-                for(i=0; i<num; ++i)
-                {
-                    CvTSTrans*  pT = p->pTrans+i;
-                    //float   t = (num>1)?((float)i/(num-1)):0.0f;
-                    float newx = p->pPos[i%p->PosNum].x;
-                    float newy = p->pPos[i%p->PosNum].y;
-                    pT->Shift.x = -newx*pT->Scale.x;
-                    pT->Shift.y = -newy*pT->Scale.y;
-
-                    if(p->pImg)
-                    {
-                        newx *= p->pImg->width-1;
-                        newy *= p->pImg->height-1;
-                    }
-
-                    pT->T[2] = -(pT->T[0]*newx+pT->T[1]*newy);
-                    pT->T[5] = -(pT->T[3]*newx+pT->T[4]*newy);
-                }
-            }   /* Modify transformation old. */
-        }   /*  Next record. */
-
-        /* Initialize frame number array: */
-        KeyFrames[0] = FirstFrame;
-
-        if(pTransSeq&&KeyFrameNum>1)
-        {
-            int i0,i1;
-            for(int i=0; i<KeyFrameNum; ++i)
-            {
-                CvFileNode* pTN = (CvFileNode*)cvGetSeqElem(pTransSeq,i);
-                KeyFrames[i] = cvReadIntByName(fs,pTN,"frame",-1);
-            }
-
-            if(KeyFrames[0]<0)KeyFrames[0]=FirstFrame;
-            if(KeyFrames[KeyFrameNum-1]<0)KeyFrames[KeyFrameNum-1]=LastFrame;
-
-            for(i0=0, i1=1; i1<KeyFrameNum;)
-            {
-                for(i1=i0+1; i1<KeyFrameNum && KeyFrames[i1]<0; i1++) {}
-
-                assert(i1<KeyFrameNum);
-                assert(i1>i0);
-
-                for(int i=i0+1; i<i1; ++i)
-                {
-                    KeyFrames[i] = cvRound(KeyFrames[i0] + (float)(i-i0)*(float)(KeyFrames[i1] - KeyFrames[i0])/(float)(i1-i0));
-                }
-                i0 = i1;
-                i1++;
-            }   /* Next key run. */
-        }   /*  Initialize frame number array. */
-
-        if(pTransNode || pTransSeq)
-        {   /* More complex transform. */
-            int     param;
-            CvFileNode* pTN = pTransSeq?(CvFileNode*)cvGetSeqElem(pTransSeq,0):pTransNode;
-
-            for(p=pElem; p; p=p->next)
-            {
-                //int trans_num = p->TransNum;
-                for(param=0; param_name[param]; ++param)
-                {
-                    const char*   name = param_name[param];
-                    float   defv = param_defval[param];
-                    if(KeyFrameNum==1)
-                    {   /* Only one transform record: */
-                        int     i;
-                        double  val;
-                        CvFileNode* fnode = cvGetFileNodeByName( fs, pTN,name);
-                        if(fnode == NULL) continue;
-                        val = cvReadReal(fnode,defv);
-
-                        for(i=0; i<p->TransNum; ++i)
-                        {
-                            icvUpdateTrans(
-                                p->pTrans+i, param, val,
-                                p->pImg?(float)(p->pImg->width-1):1.0f,
-                                p->pImg?(float)(p->pImg->height-1):1.0f);
-                        }
-                    }   /* Next record. */
-                    else
-                    {   /* Several transforms: */
-                        int         i0,i1;
-                        double      v0;
-                        double      v1;
-
-                        CvFileNode* pTN1 = (CvFileNode*)cvGetSeqElem(pTransSeq,0);
-                        v0 = cvReadRealByName(fs, pTN1,name,defv);
-
-                        for(i1=1,i0=0; i1<KeyFrameNum; ++i1)
-                        {
-                            int         f0,f1;
-                            int         i;
-                            CvFileNode* pTN2 = (CvFileNode*)cvGetSeqElem(pTransSeq,i1);
-                            CvFileNode* pVN = cvGetFileNodeByName(fs,pTN2,name);
-
-                            if(pVN)v1 = cvReadReal(pVN,defv);
-                            else if(pVN == NULL && i1 == KeyFrameNum-1) v1 = defv;
-                            else continue;
-
-                            f0 = KeyFrames[i0];
-                            f1 = KeyFrames[i1];
-
-                            if(i1==(KeyFrameNum-1)) f1++;
-
-                            for(i=f0; i<f1; ++i)
-                            {
-                                double   val;
-                                double   t = (float)(i-f0);
-                                int      li = i - p->FrameBegin;
-                                if(li<0) continue;
-                                if(li>= p->TransNum) break;
-                                if(KeyFrames[i1]>KeyFrames[i0]) t /=(float)(KeyFrames[i1]-KeyFrames[i0]);
-                                val = t*(v1-v0)+v0;
-
-                                icvUpdateTrans(
-                                    p->pTrans+li, param, val,
-                                    p->pImg?(float)(p->pImg->width-1):1.0f,
-                                    p->pImg?(float)(p->pImg->height-1):1.0f);
-
-                            }   /* Next transform. */
-                            i0 = i1;
-                            v0 = v1;
-
-                        }   /* Next value run. */
-                    }   /*  Several transforms. */
-                }   /*  Next parameter. */
-            }   /*  Next record. */
-        }   /*  More complex transform. */
-    }   /*  Read transfroms. */
-
-    return pElem;
-
-}   /* icvTestSeqReadElemOne */
-
-static CvTestSeqElem* icvTestSeqReadElemAll(CvTestSeq_* pTS, CvFileStorage* fs, const char* name)
-{
-    CvTestSeqElem*  pElem = NULL;
-    CvFileNode*     node;
-
-    if(name == NULL) return NULL;
-
-    node = cvGetFileNodeByName( fs, NULL, name );
-
-    if(node == NULL)
-    {
-        printf("WARNING!!! - Video %s does not exist!\n", name);
-        return NULL;
-    }
-
-    printf("Read node %s\n",name);
-
-    if(CV_NODE_IS_SEQ(node->tag))
-    {   /* Read all element in sequence: */
-        int             i;
-        CvSeq*          seq = node->data.seq;
-        CvTestSeqElem*  pElemLast = NULL;
-
-        for(i=0; i<seq->total; ++i)
-        {
-            CvFileNode*     next_node = (CvFileNode*)cvGetSeqElem( seq, i );
-            CvTestSeqElem*  pElemNew = icvTestSeqReadElemOne(pTS, fs, next_node );
-            CvFileNode*     pDurNode = cvGetFileNodeByName( fs, next_node,"Dur");
-
-            if(pElemNew == NULL )
-            {
-                printf("WARNING in parsing %s record!!! Cannot read array element\n", name);
-                continue;
-            }
-
-            if(pElem && pElemLast)
-            {
-                pElemLast->next = pElemNew;
-                if(pDurNode)
-                {
-                    pElemNew->FrameBegin = pElemLast->FrameBegin + pElemLast->FrameNum;
-                }
-            }
-            else
-            {
-                pElem = pElemNew;
-            }
-
-            /* Find last element: */
-            for(pElemLast=pElemNew;pElemLast && pElemLast->next;pElemLast= pElemLast->next) {}
-
-        }   /* Next element. */
-    }   /*  Read all element in sequence. */
-    else
-    {   /* Read one element: */
-        pElem = icvTestSeqReadElemOne(pTS, fs, node );
-    }
-
-    return pElem;
-
-}   /* icvTestSeqReadElemAll */
-
-static void icvTestSeqReleaseAll(CvTestSeqElem** ppElemList)
-{
-    CvTestSeqElem* p = ppElemList[0];
-
-    while(p)
-    {
-        CvTestSeqElem* pd = p;
-        if(p->pAVI)
-        {
-            //cvReleaseCapture(&p->pAVI);
-        }
-        if(p->pImg)cvReleaseImage(&p->pImg);
-        if(p->pImgMask)cvReleaseImage(&p->pImgMask);
-        if(p->pPos)cvFree(&p->pPos);
-        if(p->pTrans)cvFree(&p->pTrans);
-        if(p->pSize)cvFree(&p->pSize);
-        p=p->next;
-        cvFree(&pd);
-
-    }   /* Next element. */
-
-    ppElemList[0] = NULL;
-
-}   /* icvTestSeqReleaseAll */
-
-CvTestSeq* cvCreateTestSeq(char* pConfigfile, char** videos, int numvideo, float Scale, int noise_type, double noise_ampl)
-{
-    int             size = sizeof(CvTestSeq_);
-    CvTestSeq_*     pTS = (CvTestSeq_*)cvAlloc(size);
-    CvFileStorage*  fs = cvOpenFileStorage( pConfigfile, NULL, CV_STORAGE_READ);
-    int         i;
-
-    if(pTS == NULL || fs == NULL) return NULL;
-    memset(pTS,0,size);
-
-    pTS->pFileStorage = fs;
-    pTS->noise_ampl = noise_ampl;
-    pTS->noise_type = noise_type;
-    pTS->IVar_DI = 0;
-    pTS->ObjNum = 0;
-
-    /* Read all videos: */
-    for (i=0; i<numvideo; ++i)
-    {
-        CvTestSeqElem*  pElemNew = icvTestSeqReadElemAll(pTS, fs, videos[i]);
-
-        if(pTS->pElemList==NULL)pTS->pElemList = pElemNew;
-        else
-        {
-            CvTestSeqElem* p = NULL;
-            for(p=pTS->pElemList;p->next;p=p->next) {}
-            p->next = pElemNew;
-        }
-    }   /* Read all videos. */
-
-    {   /* Calculate elements and image size and video length: */
-        CvTestSeqElem*  p = pTS->pElemList;
-        int             num = 0;
-        CvSize          MaxSize;
-        int             MaxFN = 0;
-
-        for(p = pTS->pElemList; p; p=p->next, num++)
-        {
-            int     FN = p->FrameBegin+p->FrameNum;
-            CvSize  S;
-
-            if(p->pImg && p->BG)
-            {
-                S.width = p->pImg->width;
-                S.height = p->pImg->height;
-            }
-
-            if(MaxSize.width < S.width) MaxSize.width = S.width;
-            if(MaxSize.height < S.height) MaxSize.height = S.height;
-            if(MaxFN < FN)MaxFN = FN;
-        }
-
-        pTS->ListNum = num;
-
-        if(MaxSize.width == 0)MaxSize.width = 320;
-        if(MaxSize.height == 0)MaxSize.height = 240;
-
-        MaxSize.width = cvRound(Scale*MaxSize.width);
-        MaxSize.height = cvRound(Scale*MaxSize.height);
-
-        pTS->pImg = cvCreateImage(MaxSize,IPL_DEPTH_8U,3);
-        pTS->pImgMask = cvCreateImage(MaxSize,IPL_DEPTH_8U,1);
-        pTS->FrameNum = MaxFN;
-
-        for(p = pTS->pElemList; p; p=p->next)
-        {
-            if(p->FrameNum<=0)p->FrameNum=MaxFN;
-        }
-    }   /* Calculate elements and image size. */
-
-    return (CvTestSeq*)pTS;
-
-}   /* cvCreateTestSeq */
-
-void cvReleaseTestSeq(CvTestSeq** ppTestSeq)
-{
-    CvTestSeq_* pTS = (CvTestSeq_*)ppTestSeq[0];
-
-    icvTestSeqReleaseAll(&pTS->pElemList);
-    if(pTS->pImg) cvReleaseImage(&pTS->pImg);
-    if(pTS->pImgMask) cvReleaseImage(&pTS->pImgMask);
-    if(pTS->pFileStorage)cvReleaseFileStorage(&pTS->pFileStorage);
-
-    cvFree(ppTestSeq);
-
-}   /* cvReleaseTestSeq */
-
-void cvTestSeqSetFrame(CvTestSeq* pTestSeq, int n)
-{
-    CvTestSeq_*     pTS = (CvTestSeq_*)pTestSeq;
-    pTS->CurFrame = n;
-}
-
-IplImage* cvTestSeqQueryFrame(CvTestSeq* pTestSeq)
-{
-    CvTestSeq_*     pTS = (CvTestSeq_*)pTestSeq;
-    CvTestSeqElem*  p = pTS->pElemList;
-    IplImage*       pImg = pTS->pImg;
-    IplImage*       pImgAdd = cvCloneImage(pTS->pImg);
-    IplImage*       pImgAddG = cvCreateImage(cvSize(pImgAdd->width,pImgAdd->height),IPL_DEPTH_8U,1);
-    IplImage*       pImgMask = pTS->pImgMask;
-    IplImage*       pImgMaskAdd = cvCloneImage(pTS->pImgMask);
-    CvMat*          pT = cvCreateMat(2,3,CV_32F);
-
-    if(pTS->CurFrame >= pTS->FrameNum) return NULL;
-    cvZero(pImg);
-    cvZero(pImgMask);
-
-    for(p=pTS->pElemList; p; p=p->next)
-    {
-        int             DirectCopy = 0;
-        int             frame = pTS->CurFrame - p->FrameBegin;
-        //float           t = p->FrameNum>1?((float)frame/(p->FrameNum-1)):0;
-        CvTSTrans*      pTrans = p->pTrans + frame%p->TransNum;
-
-        assert(pTrans);
-
-        if( p->FrameNum > 0 && (frame < 0 || frame >= p->FrameNum) )
-        {   /* Current frame is out of range: */
-            //if(p->pAVI)cvReleaseCapture(&p->pAVI);
-            p->pAVI = NULL;
-            continue;
-        }
-
-        cvZero(pImgAdd);
-        cvZero(pImgAddG);
-        cvZero(pImgMaskAdd);
-
-        if(p->noise_type == CV_NOISE_NONE)
-        {   /* For not noise:  */
-            /* Get next frame: */
-            icvTestSeqQureyFrameElem(p, frame);
-            if(p->pImg == NULL) continue;
-
-#if 1 /* transform using T filed in Trans */
-            {   /* Calculate transform matrix: */
-                float   W = (float)(pImgAdd->width-1);
-                float   H = (float)(pImgAdd->height-1);
-                float   W0 = (float)(p->pImg->width-1);
-                float   H0 = (float)(p->pImg->height-1);
-                cvZero(pT);
-                {   /* Calcualte inverse matrix: */
-                    CvMat   mat = cvMat(2,3,CV_32F, pTrans->T);
-                    mat.width--;
-                    pT->width--;
-                    cvInvert(&mat, pT);
-                    pT->width++;
-                }
-
-                CV_MAT_ELEM(pT[0], float, 0, 2) =
-                    CV_MAT_ELEM(pT[0], float, 0, 0)*(W0/2-pTrans->T[2])+
-                    CV_MAT_ELEM(pT[0], float, 0, 1)*(H0/2-pTrans->T[5]);
-
-                CV_MAT_ELEM(pT[0], float, 1, 2) =
-                    CV_MAT_ELEM(pT[0], float, 1, 0)*(W0/2-pTrans->T[2])+
-                    CV_MAT_ELEM(pT[0], float, 1, 1)*(H0/2-pTrans->T[5]);
-
-                CV_MAT_ELEM(pT[0], float, 0, 0) *= W0/W;
-                CV_MAT_ELEM(pT[0], float, 0, 1) *= H0/H;
-                CV_MAT_ELEM(pT[0], float, 1, 0) *= W0/W;
-                CV_MAT_ELEM(pT[0], float, 1, 1) *= H0/H;
-
-            }   /* Calculate transform matrix. */
-#else
-            {   /* Calculate transform matrix: */
-                float   SX = (float)(p->pImg->width-1)/((pImgAdd->width-1)*pTrans->Scale.x);
-                float   SY = (float)(p->pImg->height-1)/((pImgAdd->height-1)*pTrans->Scale.y);
-                float   DX = pTrans->Shift.x;
-                float   DY = pTrans->Shift.y;;
-                cvZero(pT);
-                ((float*)(pT->data.ptr+pT->step*0))[0]=SX;
-                ((float*)(pT->data.ptr+pT->step*1))[1]=SY;
-                ((float*)(pT->data.ptr+pT->step*0))[2]=SX*(pImgAdd->width-1)*(0.5f-DX);
-                ((float*)(pT->data.ptr+pT->step*1))[2]=SY*(pImgAdd->height-1)*(0.5f-DY);
-            }   /* Calculate transform matrix. */
-#endif
-
-
-            {   /* Check for direct copy: */
-                DirectCopy = 1;
-                if( fabs(CV_MAT_ELEM(pT[0],float,0,0)-1) > 0.00001) DirectCopy = 0;
-                if( fabs(CV_MAT_ELEM(pT[0],float,1,0)) > 0.00001) DirectCopy = 0;
-                if( fabs(CV_MAT_ELEM(pT[0],float,0,1)) > 0.00001) DirectCopy = 0;
-                if( fabs(CV_MAT_ELEM(pT[0],float,0,1)) > 0.00001) DirectCopy = 0;
-                if( fabs(CV_MAT_ELEM(pT[0],float,0,2)-(pImg->width-1)*0.5) > 0.5) DirectCopy = 0;
-                if( fabs(CV_MAT_ELEM(pT[0],float,1,2)-(pImg->height-1)*0.5) > 0.5) DirectCopy = 0;
-            }
-
-            /* Extract image and mask: */
-            if(p->pImg->nChannels == 1)
-            {
-                if(DirectCopy)
-                {
-                    cvCvtColor( p->pImg,pImgAdd,CV_GRAY2BGR);
-                }
-                else
-                {
-                    cvGetQuadrangleSubPix( p->pImg, pImgAddG, pT);
-                    cvCvtColor( pImgAddG,pImgAdd,CV_GRAY2BGR);
-                }
-            }
-
-            if(p->pImg->nChannels == 3)
-            {
-                if(DirectCopy)
-                    cvCopy(p->pImg, pImgAdd);
-                else
-                    cvGetQuadrangleSubPix( p->pImg, pImgAdd, pT);
-            }
-
-            if(p->pImgMask)
-            {
-                if(DirectCopy)
-                    cvCopy(p->pImgMask, pImgMaskAdd);
-                else
-                    cvGetQuadrangleSubPix( p->pImgMask, pImgMaskAdd, pT);
-
-                cvThreshold(pImgMaskAdd,pImgMaskAdd,128,255,CV_THRESH_BINARY);
-            }
-
-            if(pTrans->C != 1 || pTrans->I != 0)
-            {   /* Intensity transformation: */
-                cvScale(pImgAdd, pImgAdd, pTrans->C,pTrans->I);
-            }   /* Intensity transformation: */
-
-            if(pTrans->GN > 0)
-            {   /* Add noise: */
-                IplImage* pImgN = cvCloneImage(pImgAdd);
-                cvRandSetRange( &p->rnd_state, pTrans->GN, 0, -1 );
-                cvRand(&p->rnd_state, pImgN);
-                cvAdd(pImgN,pImgAdd,pImgAdd);
-                cvReleaseImage(&pImgN);
-            }   /* Add noise. */
-
-            if(p->Mask)
-            {   /* Update only mask: */
-                cvOr(pImgMaskAdd, pImgMask, pImgMask);
-            }
-            else
-            {   /* Add image and mask to exist main image and mask: */
-                if(p->BG)
-                {   /* If image is background: */
-                    cvCopy( pImgAdd, pImg, NULL);
-                }
-                else
-                {   /* If image is foreground: */
-                    cvCopy( pImgAdd, pImg, pImgMaskAdd);
-                    if(p->ObjID>=0)
-                        cvOr(pImgMaskAdd, pImgMask, pImgMask);
-                }
-            }   /* Not mask. */
-        }   /*  For not noise. */
-        else
-        {   /* Process noise video: */
-
-            if( p->noise_type == CV_NOISE_GAUSSIAN ||
-                p->noise_type == CV_NOISE_UNIFORM)
-
-            {   /* Gaussan and uniform additive noise: */
-                cvAddNoise(pImg,p->noise_type,pTrans->NoiseAmp * pTrans->C, &p->rnd_state);
-            }   /* Gaussan and uniform additive noise. */
-
-            if( p->noise_type == CV_NOISE_SPECKLE)
-            {   /* Speckle -- multiplicative noise: */
-                if(pTrans->I != 0)cvSubS(pImg,cvScalar(pTrans->I,pTrans->I,pTrans->I),pImg);
-                cvAddNoise(pImg,p->noise_type,pTrans->NoiseAmp, &p->rnd_state);
-                if(pTrans->I != 0)cvAddS(pImg,cvScalar(pTrans->I,pTrans->I,pTrans->I),pImg);
-            }   /* Speckle -- multiplicative noise. */
-
-            if( p->noise_type == CV_NOISE_SALT_AND_PEPPER)
-            {   /* Salt and pepper: */
-                cvAddNoise(pImg,p->noise_type,pTrans->NoiseAmp, &p->rnd_state);
-            }   /* Salt and pepper. */
-        }   /*  Process noise video.*/
-    }   /*  Next item. */
-
-    if(pImg)
-    {
-        if(pTS->noise_type != CV_NOISE_NONE)
-        {   /* Add noise: */
-            cvAddNoise(pImg,pTS->noise_type,pTS->noise_ampl);
-        }
-
-        if(pTS->IVar_DI != 0)
-        {   /* Change intensity: */
-            float   I = MIN(pTS->IVar_CurI,pTS->IVar_MaxI);
-            I = MAX(I,pTS->IVar_MinI);
-            cvScale(pImg,pImg,1,I);
-
-            if(pTS->IVar_CurI >= pTS->IVar_MaxI)
-                pTS->IVar_CurDI = (float)-fabs(pTS->IVar_DI);
-
-            if(pTS->IVar_CurI <= pTS->IVar_MinI)
-                pTS->IVar_CurDI = (float)+fabs(pTS->IVar_DI);
-
-            pTS->IVar_CurI += pTS->IVar_CurDI;
-        }
-    }
-
-
-    pTS->CurFrame++;
-    cvReleaseImage(&pImgAdd);
-    cvReleaseImage(&pImgAddG);
-    cvReleaseImage(&pImgMaskAdd);
-    cvReleaseMat(&pT);
-    return pImg;
-
-}   /*cvTestSeqQueryFrame*/
-
-IplImage* cvTestSeqGetFGMask(CvTestSeq* pTestSeq)
-{
-    return ((CvTestSeq_*)pTestSeq)->pImgMask;
-}
-
-IplImage* cvTestSeqGetImage(CvTestSeq* pTestSeq)
-{
-    return ((CvTestSeq_*)pTestSeq)->pImg;
-}
-
-int cvTestSeqGetObjectNum(CvTestSeq* pTestSeq)
-{
-    //return ((CvTestSeq_*)pTestSeq)->ListNum;
-    return ((CvTestSeq_*)pTestSeq)->ObjNum;
-}
-
-int cvTestSeqGetObjectPos(CvTestSeq* pTestSeq, int ObjIndex, CvPoint2D32f* pPos)
-{
-    CvTestSeq_*     pTS = (CvTestSeq_*)pTestSeq;
-    CvTestSeqElem*  p = pTS->pElemList;
-    if(pTS->CurFrame > pTS->FrameNum) return 0;
-
-    for(p=pTS->pElemList; p; p=p->next)
-    {
-        int frame = pTS->CurFrame - p->FrameBegin - 1;
-        if(ObjIndex==p->ObjID && frame >= 0 && frame < p->FrameNum) break;
-    }
-
-    if(p && p->pPos && p->PosNum>0)
-    {
-        CvTSTrans*  pTrans;
-        int         frame = pTS->CurFrame - p->FrameBegin - 1;
-        if(frame < 0 || frame >= p->FrameNum) return 0;
-        //float t = (p->FrameNum>1)?((float)frame / (p->FrameNum-1)):0;
-        pTrans = p->pTrans + frame%p->TransNum;
-        pPos[0] = p->pPos[frame%p->PosNum];
-
-#if 1   /* Transform using T filed in Trans: */
-        {
-            float x = pPos->x * (p->pImg?(p->pImg->width-1):1);
-            float y = pPos->y * (p->pImg?(p->pImg->height-1):1);
-
-            pPos->x = pTrans->T[0]*x+pTrans->T[1]*y+pTrans->T[2];
-            pPos->y = pTrans->T[3]*x+pTrans->T[4]*y+pTrans->T[5];
-
-            if(p->pImg)
-            {
-                pPos->x /= p->pImg->width-1;
-                pPos->y /= p->pImg->height-1;
-            }
-
-        }
-
-
-#else
-        pPos->x = pPos->x * pTrans->Scale.x + pTrans->Shift.x;
-        pPos->y = pPos->y * pTrans->Scale.y + pTrans->Shift.y;
-#endif
-        pPos->x *= pTS->pImg->width-1;
-        pPos->y *= pTS->pImg->height-1;
-        return 1;
-    }
-    return 0;
-
-}   /* cvTestSeqGetObjectPos */
-
-int cvTestSeqGetObjectSize(CvTestSeq* pTestSeq, int ObjIndex, CvPoint2D32f* pSize)
-{
-    CvTestSeq_*     pTS = (CvTestSeq_*)pTestSeq;
-    CvTestSeqElem*  p = pTS->pElemList;
-    if(pTS->CurFrame > pTS->FrameNum) return 0;
-
-    for(p=pTS->pElemList; p; p=p->next)
-    {
-        int frame = pTS->CurFrame - p->FrameBegin - 1;
-        if(ObjIndex==p->ObjID && frame >= 0 && frame < p->FrameNum) break;
-    }
-
-    if(p && p->pSize && p->SizeNum>0)
-    {
-        CvTSTrans*  pTrans;
-        int         frame = pTS->CurFrame - p->FrameBegin - 1;
-
-        if(frame < 0 || frame >= p->FrameNum) return 0;
-
-        //float t = (p->FrameNum>1)?((float)frame / (p->FrameNum-1)):0;
-        pTrans = p->pTrans + frame%p->TransNum;
-        pSize[0] = p->pSize[frame%p->SizeNum];
-
-#if 1   /* Transform using T filed in Trans: */
-        {
-            float x = pSize->x * (p->pImg?(p->pImg->width-1):1);
-            float y = pSize->y * (p->pImg?(p->pImg->height-1):1);
-            float   dx1, dx2;
-            float   dy1, dy2;
-
-            dx1 = (float)fabs(pTrans->T[0]*x+pTrans->T[1]*y);
-            dy1 = (float)fabs(pTrans->T[3]*x+pTrans->T[4]*y);
-
-            dx2 = (float)fabs(pTrans->T[0]*x - pTrans->T[1]*y);
-            dy2 = (float)fabs(pTrans->T[3]*x - pTrans->T[4]*y);
-
-            pSize->x = MAX(dx1,dx2);
-            pSize->y = MAX(dy1,dy2);
-
-            if(p->pImg)
-            {
-                pSize->x /= p->pImg->width-1;
-                pSize->y /= p->pImg->height-1;
-            }
-
-        }
-
-
-#else
-        pSize->x = pSize->x * pTrans->Scale.x;
-        pSize->y = pSize->y * pTrans->Scale.y;
-#endif
-        pSize->x *= pTS->pImg->width-1;
-        pSize->y *= pTS->pImg->height-1;
-        return 1;
-    }
-
-    return 0;
-
-}   /* cvTestSeqGetObjectSize */
-
-/* Add noise to finile image: */
-void cvTestSeqAddNoise(CvTestSeq* pTestSeq, int noise_type, double noise_ampl)
-{
-    CvTestSeq_*     pTS = (CvTestSeq_*)pTestSeq;
-    pTS->noise_type = noise_type;
-    pTS->noise_ampl = noise_ampl;
-}
-
-/* Add Intensity variation: */
-void cvTestSeqAddIntensityVariation(CvTestSeq* pTestSeq, float DI_per_frame, float MinI, float MaxI)
-{
-    CvTestSeq_* pTS = (CvTestSeq_*)pTestSeq;
-    pTS->IVar_CurDI = pTS->IVar_DI = DI_per_frame;
-    pTS->IVar_MaxI = MaxI;
-    pTS->IVar_MinI = MinI;
-}
-
-void cvAddNoise(IplImage* pImg, int noise_type, double Ampl, CvRandState* rnd_state)
-{   /* Add noise to image: */
-    CvSize      S = cvSize(pImg->width,pImg->height);
-    IplImage*   pImgAdd = cvCreateImage(S,pImg->depth,pImg->nChannels);
-    static CvRandState local_rnd_state;
-    static int  first = 1;
-
-    if(first)
-    {
-        first = 0;
-        cvRandInit( &local_rnd_state, 1, 0, 0,CV_RAND_NORMAL);
-    }
-
-    if(rnd_state == NULL)rnd_state = &local_rnd_state;
-
-    if( noise_type == CV_NOISE_GAUSSIAN ||
-        noise_type == CV_NOISE_UNIFORM)
-    {   /* Gaussan and uniform additive noise: */
-        int set_zero = 0;
-
-        if( noise_type == CV_NOISE_GAUSSIAN)
-        {
-            rnd_state->disttype = CV_RAND_NORMAL;
-            cvRandSetRange( rnd_state,  Ampl, 0, -1 );
-            if(Ampl <= 0) set_zero = 1;
-        }
-
-        if( noise_type == CV_NOISE_UNIFORM)
-        {
-            double max_val =
-                1.7320508075688772935274463415059 * Ampl;
-            rnd_state->disttype = CV_RAND_UNI;
-            cvRandSetRange( rnd_state, -max_val, max_val, -1 );
-            if(max_val < 1) set_zero = 1;
-        }
-
-        if(!set_zero)
-        {
-            IplImage*   pImgNoise = cvCreateImage(S,IPL_DEPTH_32F,pImg->nChannels);
-            IplImage*   pImgOrg = cvCreateImage(S,IPL_DEPTH_32F,pImg->nChannels);
-            cvConvert(pImg, pImgOrg);
-            cvRand(rnd_state, pImgNoise);
-            cvAdd(pImgOrg,pImgNoise,pImgOrg);
-            cvConvert(pImgOrg,pImg);
-            cvReleaseImage(&pImgNoise);
-            cvReleaseImage(&pImgOrg);
-        }
-    }   /* Gaussan and uniform additive noise. */
-
-    if( noise_type == CV_NOISE_SPECKLE)
-    {   /* Speckle -- multiplicative noise: */
-        IplImage* pImgSP = cvCreateImage( S,IPL_DEPTH_32F, pImg->nChannels );
-        IplImage* pImgTemp = cvCreateImage(S,IPL_DEPTH_32F, pImg->nChannels );
-        rnd_state->disttype = CV_RAND_NORMAL;
-        cvRandSetRange( rnd_state, Ampl, 0, -1 );
-        cvRand(rnd_state, pImgSP);
-        cvConvert(pImg,pImgTemp);
-        cvMul(pImgSP,pImgTemp,pImgSP);
-        cvAdd(pImgTemp,pImgSP,pImgTemp);
-        cvConvert(pImgTemp,pImg);
-        cvReleaseImage(&pImgSP);
-        cvReleaseImage(&pImgTemp);
-    }   /* Speckle -- multiplicative noise. */
-
-    if( noise_type == CV_NOISE_SALT_AND_PEPPER && Ampl > 0)
-    {   /* Salt and pepper: */
-        IplImage* pImgMask = cvCreateImage( S,IPL_DEPTH_32F, 1 );
-        IplImage* pImgMaskBin = cvCreateImage( S,IPL_DEPTH_8U, 1 );
-        IplImage* pImgVal = cvCreateImage( S,IPL_DEPTH_8U, 1 );
-        rnd_state->disttype = CV_RAND_UNI;
-
-        /* Create mask: */
-        cvRandSetRange( rnd_state, 0, 1, -1 );
-        cvRand(rnd_state, pImgMask);
-        cvThreshold(pImgMask,pImgMask, Ampl, 255, CV_THRESH_BINARY_INV );
-        cvConvert(pImgMask,pImgMaskBin);
-
-        /* Create vals: */
-        cvRandSetRange( rnd_state, 0, 255, -1 );
-        cvRand(rnd_state, pImgVal);
-        cvThreshold(pImgVal,pImgVal,128, 255, CV_THRESH_BINARY );
-        cvMerge(
-            pImgAdd->nChannels>0?pImgVal:NULL,
-            pImgAdd->nChannels>1?pImgVal:NULL,
-            pImgAdd->nChannels>2?pImgVal:NULL,
-            pImgAdd->nChannels>3?pImgVal:NULL,
-            pImgAdd);
-        cvCopy(pImgAdd, pImg, pImgMaskBin);
-        cvReleaseImage(&pImgMask);
-        cvReleaseImage(&pImgMaskBin);
-        cvReleaseImage(&pImgVal);
-
-    }   /* Salt and pepper. */
-
-    cvReleaseImage(&pImgAdd);
-
-}   /* cvAddNoise */
diff --git a/modules/legacy/src/texture.cpp b/modules/legacy/src/texture.cpp
deleted file mode 100644 (file)
index 07fd087..0000000
+++ /dev/null
@@ -1,647 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/****************************************************************************************\
-
-      Calculation of a texture descriptors from GLCM (Grey Level Co-occurrence Matrix'es)
-      The code was submitted by Daniel Eaton [danieljameseaton@yahoo.com]
-
-\****************************************************************************************/
-
-#include "precomp.hpp"
-
-#include <math.h>
-#include <assert.h>
-
-#define CV_MAX_NUM_GREY_LEVELS_8U  256
-
-struct CvGLCM
-{
-    int matrixSideLength;
-    int numMatrices;
-    double*** matrices;
-
-    int  numLookupTableElements;
-    int  forwardLookupTable[CV_MAX_NUM_GREY_LEVELS_8U];
-    int  reverseLookupTable[CV_MAX_NUM_GREY_LEVELS_8U];
-
-    double** descriptors;
-    int numDescriptors;
-    int descriptorOptimizationType;
-    int optimizationType;
-};
-
-
-static void icvCreateGLCM_LookupTable_8u_C1R( const uchar* srcImageData, int srcImageStep,
-                                             CvSize srcImageSize, CvGLCM* destGLCM,
-                                             int* steps, int numSteps, int* memorySteps );
-
-static void
-icvCreateGLCMDescriptors_AllowDoubleNest( CvGLCM* destGLCM, int matrixIndex );
-
-
-CV_IMPL CvGLCM*
-cvCreateGLCM( const IplImage* srcImage,
-              int stepMagnitude,
-              const int* srcStepDirections,/* should be static array..
-                                          or if not the user should handle de-allocation */
-              int numStepDirections,
-              int optimizationType )
-{
-    static const int defaultStepDirections[] = { 0,1, -1,1, -1,0, -1,-1 };
-
-    int* memorySteps = 0;
-    CvGLCM* newGLCM = 0;
-    int* stepDirections = 0;
-
-    CV_FUNCNAME( "cvCreateGLCM" );
-
-    __BEGIN__;
-
-    uchar* srcImageData = 0;
-    CvSize srcImageSize;
-    int srcImageStep;
-    int stepLoop;
-    const int maxNumGreyLevels8u = CV_MAX_NUM_GREY_LEVELS_8U;
-
-    if( !srcImage )
-        CV_ERROR( CV_StsNullPtr, "" );
-
-    if( srcImage->nChannels != 1 )
-        CV_ERROR( CV_BadNumChannels, "Number of channels must be 1");
-
-    if( srcImage->depth != IPL_DEPTH_8U )
-        CV_ERROR( CV_BadDepth, "Depth must be equal IPL_DEPTH_8U");
-
-    // no Directions provided, use the default ones - 0 deg, 45, 90, 135
-    if( !srcStepDirections )
-    {
-        srcStepDirections = defaultStepDirections;
-    }
-
-    CV_CALL( stepDirections = (int*)cvAlloc( numStepDirections*2*sizeof(stepDirections[0])));
-    memcpy( stepDirections, srcStepDirections, numStepDirections*2*sizeof(stepDirections[0]));
-
-    cvGetImageRawData( srcImage, &srcImageData, &srcImageStep, &srcImageSize );
-
-    // roll together Directions and magnitudes together with knowledge of image (step)
-    CV_CALL( memorySteps = (int*)cvAlloc( numStepDirections*sizeof(memorySteps[0])));
-
-    for( stepLoop = 0; stepLoop < numStepDirections; stepLoop++ )
-    {
-        stepDirections[stepLoop*2 + 0] *= stepMagnitude;
-        stepDirections[stepLoop*2 + 1] *= stepMagnitude;
-
-        memorySteps[stepLoop] = stepDirections[stepLoop*2 + 0]*srcImageStep +
-                                stepDirections[stepLoop*2 + 1];
-    }
-
-    CV_CALL( newGLCM = (CvGLCM*)cvAlloc(sizeof(newGLCM)));
-    memset( newGLCM, 0, sizeof(*newGLCM) );
-
-    newGLCM->matrices = 0;
-    newGLCM->numMatrices = numStepDirections;
-    newGLCM->optimizationType = optimizationType;
-
-    if( optimizationType <= CV_GLCM_OPTIMIZATION_LUT )
-    {
-        int lookupTableLoop, imageColLoop, imageRowLoop, lineOffset = 0;
-
-        // if optimization type is set to lut, then make one for the image
-        if( optimizationType == CV_GLCM_OPTIMIZATION_LUT )
-        {
-            for( imageRowLoop = 0; imageRowLoop < srcImageSize.height;
-                                   imageRowLoop++, lineOffset += srcImageStep )
-            {
-                for( imageColLoop = 0; imageColLoop < srcImageSize.width; imageColLoop++ )
-                {
-                    newGLCM->forwardLookupTable[srcImageData[lineOffset+imageColLoop]]=1;
-                }
-            }
-
-            newGLCM->numLookupTableElements = 0;
-
-            for( lookupTableLoop = 0; lookupTableLoop < maxNumGreyLevels8u; lookupTableLoop++ )
-            {
-                if( newGLCM->forwardLookupTable[ lookupTableLoop ] != 0 )
-                {
-                    newGLCM->forwardLookupTable[ lookupTableLoop ] =
-                        newGLCM->numLookupTableElements;
-                    newGLCM->reverseLookupTable[ newGLCM->numLookupTableElements ] =
-                        lookupTableLoop;
-
-                    newGLCM->numLookupTableElements++;
-                }
-            }
-        }
-        // otherwise make a "LUT" which contains all the gray-levels (for code-reuse)
-        else if( optimizationType == CV_GLCM_OPTIMIZATION_NONE )
-        {
-            for( lookupTableLoop = 0; lookupTableLoop <maxNumGreyLevels8u; lookupTableLoop++ )
-            {
-                newGLCM->forwardLookupTable[ lookupTableLoop ] = lookupTableLoop;
-                newGLCM->reverseLookupTable[ lookupTableLoop ] = lookupTableLoop;
-            }
-            newGLCM->numLookupTableElements = maxNumGreyLevels8u;
-        }
-
-        newGLCM->matrixSideLength = newGLCM->numLookupTableElements;
-        icvCreateGLCM_LookupTable_8u_C1R( srcImageData, srcImageStep, srcImageSize,
-                                          newGLCM, stepDirections,
-                                          numStepDirections, memorySteps );
-    }
-    else if( optimizationType == CV_GLCM_OPTIMIZATION_HISTOGRAM )
-    {
-        CV_ERROR( CV_StsBadFlag, "Histogram-based method is not implemented" );
-
-    /*  newGLCM->numMatrices *= 2;
-        newGLCM->matrixSideLength = maxNumGreyLevels8u*2;
-
-        icvCreateGLCM_Histogram_8uC1R( srcImageStep, srcImageSize, srcImageData,
-                                       newGLCM, numStepDirections,
-                                       stepDirections, memorySteps );
-    */
-    }
-
-    __END__;
-
-    cvFree( &memorySteps );
-    cvFree( &stepDirections );
-
-    if( cvGetErrStatus() < 0 )
-    {
-        cvFree( &newGLCM );
-    }
-
-    return newGLCM;
-}
-
-
-CV_IMPL void
-cvReleaseGLCM( CvGLCM** GLCM, int flag )
-{
-    CV_FUNCNAME( "cvReleaseGLCM" );
-
-    __BEGIN__;
-
-    int matrixLoop;
-
-    if( !GLCM )
-        CV_ERROR( CV_StsNullPtr, "" );
-
-    if( *GLCM )
-        EXIT; // repeated deallocation: just skip it.
-
-    if( (flag == CV_GLCM_GLCM || flag == CV_GLCM_ALL) && (*GLCM)->matrices )
-    {
-        for( matrixLoop = 0; matrixLoop < (*GLCM)->numMatrices; matrixLoop++ )
-        {
-            if( (*GLCM)->matrices[ matrixLoop ] )
-            {
-                cvFree( (*GLCM)->matrices[matrixLoop] );
-                cvFree( (*GLCM)->matrices + matrixLoop );
-            }
-        }
-
-        cvFree( &((*GLCM)->matrices) );
-    }
-
-    if( (flag == CV_GLCM_DESC || flag == CV_GLCM_ALL) && (*GLCM)->descriptors )
-    {
-        for( matrixLoop = 0; matrixLoop < (*GLCM)->numMatrices; matrixLoop++ )
-        {
-            cvFree( (*GLCM)->descriptors + matrixLoop );
-        }
-        cvFree( &((*GLCM)->descriptors) );
-    }
-
-    if( flag == CV_GLCM_ALL )
-    {
-        cvFree( GLCM );
-    }
-
-    __END__;
-}
-
-
-static void
-icvCreateGLCM_LookupTable_8u_C1R( const uchar* srcImageData,
-                                  int srcImageStep,
-                                  CvSize srcImageSize,
-                                  CvGLCM* destGLCM,
-                                  int* steps,
-                                  int numSteps,
-                                  int* memorySteps )
-{
-    int* stepIncrementsCounter = 0;
-
-    CV_FUNCNAME( "icvCreateGLCM_LookupTable_8u_C1R" );
-
-    __BEGIN__;
-
-    int matrixSideLength = destGLCM->matrixSideLength;
-    int stepLoop, sideLoop1, sideLoop2;
-    int colLoop, rowLoop, lineOffset = 0;
-    double*** matrices = 0;
-
-    // allocate memory to the matrices
-    CV_CALL( destGLCM->matrices = (double***)cvAlloc( sizeof(matrices[0])*numSteps ));
-    matrices = destGLCM->matrices;
-
-    for( stepLoop=0; stepLoop<numSteps; stepLoop++ )
-    {
-        CV_CALL( matrices[stepLoop] = (double**)cvAlloc( sizeof(matrices[0])*matrixSideLength ));
-        CV_CALL( matrices[stepLoop][0] = (double*)cvAlloc( sizeof(matrices[0][0])*
-                                                  matrixSideLength*matrixSideLength ));
-
-        memset( matrices[stepLoop][0], 0, matrixSideLength*matrixSideLength*
-                                          sizeof(matrices[0][0]) );
-
-        for( sideLoop1 = 1; sideLoop1 < matrixSideLength; sideLoop1++ )
-        {
-            matrices[stepLoop][sideLoop1] = matrices[stepLoop][sideLoop1-1] + matrixSideLength;
-        }
-    }
-
-    CV_CALL( stepIncrementsCounter = (int*)cvAlloc( numSteps*sizeof(stepIncrementsCounter[0])));
-    memset( stepIncrementsCounter, 0, numSteps*sizeof(stepIncrementsCounter[0]) );
-
-    // generate GLCM for each step
-    for( rowLoop=0; rowLoop<srcImageSize.height; rowLoop++, lineOffset+=srcImageStep )
-    {
-        for( colLoop=0; colLoop<srcImageSize.width; colLoop++ )
-        {
-            int pixelValue1 = destGLCM->forwardLookupTable[srcImageData[lineOffset + colLoop]];
-
-            for( stepLoop=0; stepLoop<numSteps; stepLoop++ )
-            {
-                int col2, row2;
-                row2 = rowLoop + steps[stepLoop*2 + 0];
-                col2 = colLoop + steps[stepLoop*2 + 1];
-
-                if( col2>=0 && row2>=0 && col2<srcImageSize.width && row2<srcImageSize.height )
-                {
-                    int memoryStep = memorySteps[ stepLoop ];
-                    int pixelValue2 = destGLCM->forwardLookupTable[ srcImageData[ lineOffset + colLoop + memoryStep ] ];
-
-                    // maintain symmetry
-                    matrices[stepLoop][pixelValue1][pixelValue2] ++;
-                    matrices[stepLoop][pixelValue2][pixelValue1] ++;
-
-                    // incremenet counter of total number of increments
-                    stepIncrementsCounter[stepLoop] += 2;
-                }
-            }
-        }
-    }
-
-    // normalize matrices. each element is a probability of gray value i,j adjacency in direction/magnitude k
-    for( sideLoop1=0; sideLoop1<matrixSideLength; sideLoop1++ )
-    {
-        for( sideLoop2=0; sideLoop2<matrixSideLength; sideLoop2++ )
-        {
-            for( stepLoop=0; stepLoop<numSteps; stepLoop++ )
-            {
-                matrices[stepLoop][sideLoop1][sideLoop2] /= double(stepIncrementsCounter[stepLoop]);
-            }
-        }
-    }
-
-    destGLCM->matrices = matrices;
-
-    __END__;
-
-    cvFree( &stepIncrementsCounter );
-
-    if( cvGetErrStatus() < 0 )
-        cvReleaseGLCM( &destGLCM, CV_GLCM_GLCM );
-}
-
-
-CV_IMPL void
-cvCreateGLCMDescriptors( CvGLCM* destGLCM, int descriptorOptimizationType )
-{
-    CV_FUNCNAME( "cvCreateGLCMDescriptors" );
-
-    __BEGIN__;
-
-    int matrixLoop;
-
-    if( !destGLCM )
-        CV_ERROR( CV_StsNullPtr, "" );
-
-    if( !(destGLCM->matrices) )
-        CV_ERROR( CV_StsNullPtr, "Matrices are not allocated" );
-
-    CV_CALL( cvReleaseGLCM( &destGLCM, CV_GLCM_DESC ));
-
-    if( destGLCM->optimizationType != CV_GLCM_OPTIMIZATION_HISTOGRAM )
-    {
-        destGLCM->descriptorOptimizationType = destGLCM->numDescriptors = descriptorOptimizationType;
-    }
-    else
-    {
-        CV_ERROR( CV_StsBadFlag, "Histogram-based method is not implemented" );
-//      destGLCM->descriptorOptimizationType = destGLCM->numDescriptors = CV_GLCMDESC_OPTIMIZATION_HISTOGRAM;
-    }
-
-    CV_CALL( destGLCM->descriptors = (double**)
-            cvAlloc( destGLCM->numMatrices*sizeof(destGLCM->descriptors[0])));
-
-    for( matrixLoop = 0; matrixLoop < destGLCM->numMatrices; matrixLoop ++ )
-    {
-        CV_CALL( destGLCM->descriptors[ matrixLoop ] =
-                (double*)cvAlloc( destGLCM->numDescriptors*sizeof(destGLCM->descriptors[0][0])));
-        memset( destGLCM->descriptors[matrixLoop], 0, destGLCM->numDescriptors*sizeof(double) );
-
-        switch( destGLCM->descriptorOptimizationType )
-        {
-            case CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST:
-                icvCreateGLCMDescriptors_AllowDoubleNest( destGLCM, matrixLoop );
-                break;
-            default:
-                CV_ERROR( CV_StsBadFlag,
-                "descriptorOptimizationType different from CV_GLCMDESC_OPTIMIZATION_ALLOWDOUBLENEST\n"
-                "is not supported" );
-            /*
-            case CV_GLCMDESC_OPTIMIZATION_ALLOWTRIPLENEST:
-                icvCreateGLCMDescriptors_AllowTripleNest( destGLCM, matrixLoop );
-                break;
-            case CV_GLCMDESC_OPTIMIZATION_HISTOGRAM:
-                if(matrixLoop < destGLCM->numMatrices>>1)
-                    icvCreateGLCMDescriptors_Histogram( destGLCM, matrixLoop);
-                    break;
-            */
-        }
-    }
-
-    __END__;
-
-    if( cvGetErrStatus() < 0 )
-        cvReleaseGLCM( &destGLCM, CV_GLCM_DESC );
-}
-
-
-static void
-icvCreateGLCMDescriptors_AllowDoubleNest( CvGLCM* destGLCM, int matrixIndex )
-{
-    int sideLoop1, sideLoop2;
-    int matrixSideLength = destGLCM->matrixSideLength;
-
-    double** matrix = destGLCM->matrices[ matrixIndex ];
-    double* descriptors = destGLCM->descriptors[ matrixIndex ];
-
-    double* marginalProbability =
-        (double*)cvAlloc( matrixSideLength * sizeof(marginalProbability[0]));
-    memset( marginalProbability, 0, matrixSideLength * sizeof(double) );
-
-    double maximumProbability = 0;
-    double marginalProbabilityEntropy = 0;
-    double correlationMean = 0, correlationStdDeviation = 0, correlationProductTerm = 0;
-
-    for( sideLoop1=0; sideLoop1<matrixSideLength; sideLoop1++ )
-    {
-        int actualSideLoop1 = destGLCM->reverseLookupTable[ sideLoop1 ];
-
-        for( sideLoop2=0; sideLoop2<matrixSideLength; sideLoop2++ )
-        {
-            double entryValue = matrix[ sideLoop1 ][ sideLoop2 ];
-
-            int actualSideLoop2 = destGLCM->reverseLookupTable[ sideLoop2 ];
-            int sideLoopDifference = actualSideLoop1 - actualSideLoop2;
-            int sideLoopDifferenceSquared = sideLoopDifference*sideLoopDifference;
-
-            marginalProbability[ sideLoop1 ] += entryValue;
-            correlationMean += actualSideLoop1*entryValue;
-
-            maximumProbability = MAX( maximumProbability, entryValue );
-
-            if( actualSideLoop2 > actualSideLoop1 )
-            {
-                descriptors[ CV_GLCMDESC_CONTRAST ] += sideLoopDifferenceSquared * entryValue;
-            }
-
-            descriptors[ CV_GLCMDESC_HOMOGENITY ] += entryValue / ( 1.0 + sideLoopDifferenceSquared );
-
-            if( entryValue > 0 )
-            {
-                descriptors[ CV_GLCMDESC_ENTROPY ] += entryValue * log( entryValue );
-            }
-
-            descriptors[ CV_GLCMDESC_ENERGY ] += entryValue*entryValue;
-        }
-
-        if( marginalProbability[ actualSideLoop1 ] > 0 )
-            marginalProbabilityEntropy += marginalProbability[ actualSideLoop1 ]*log(marginalProbability[ actualSideLoop1 ]);
-    }
-
-    marginalProbabilityEntropy = -marginalProbabilityEntropy;
-
-    descriptors[ CV_GLCMDESC_CONTRAST ] += descriptors[ CV_GLCMDESC_CONTRAST ];
-    descriptors[ CV_GLCMDESC_ENTROPY ] = -descriptors[ CV_GLCMDESC_ENTROPY ];
-    descriptors[ CV_GLCMDESC_MAXIMUMPROBABILITY ] = maximumProbability;
-
-    double HXY = 0, HXY1 = 0, HXY2 = 0;
-
-    HXY = descriptors[ CV_GLCMDESC_ENTROPY ];
-
-    for( sideLoop1=0; sideLoop1<matrixSideLength; sideLoop1++ )
-    {
-        double sideEntryValueSum = 0;
-        int actualSideLoop1 = destGLCM->reverseLookupTable[ sideLoop1 ];
-
-        for( sideLoop2=0; sideLoop2<matrixSideLength; sideLoop2++ )
-        {
-            double entryValue = matrix[ sideLoop1 ][ sideLoop2 ];
-
-            sideEntryValueSum += entryValue;
-
-            int actualSideLoop2 = destGLCM->reverseLookupTable[ sideLoop2 ];
-
-            correlationProductTerm += (actualSideLoop1 - correlationMean) * (actualSideLoop2 - correlationMean) * entryValue;
-
-            double clusterTerm = actualSideLoop1 + actualSideLoop2 - correlationMean - correlationMean;
-
-            descriptors[ CV_GLCMDESC_CLUSTERTENDENCY ] += clusterTerm * clusterTerm * entryValue;
-            descriptors[ CV_GLCMDESC_CLUSTERSHADE ] += clusterTerm * clusterTerm * clusterTerm * entryValue;
-
-            double HXYValue = marginalProbability[ actualSideLoop1 ] * marginalProbability[ actualSideLoop2 ];
-            if( HXYValue>0 )
-            {
-                double HXYValueLog = log( HXYValue );
-                HXY1 += entryValue * HXYValueLog;
-                HXY2 += HXYValue * HXYValueLog;
-            }
-        }
-
-        correlationStdDeviation += (actualSideLoop1-correlationMean) * (actualSideLoop1-correlationMean) * sideEntryValueSum;
-    }
-
-    HXY1 = -HXY1;
-    HXY2 = -HXY2;
-
-    descriptors[ CV_GLCMDESC_CORRELATIONINFO1 ] = ( HXY - HXY1 ) / ( correlationMean );
-    descriptors[ CV_GLCMDESC_CORRELATIONINFO2 ] = sqrt( 1.0 - exp( -2.0 * (HXY2 - HXY ) ) );
-
-    correlationStdDeviation = sqrt( correlationStdDeviation );
-
-    descriptors[ CV_GLCMDESC_CORRELATION ] = correlationProductTerm / (correlationStdDeviation*correlationStdDeviation );
-
-    delete [] marginalProbability;
-}
-
-
-CV_IMPL double cvGetGLCMDescriptor( CvGLCM* GLCM, int step, int descriptor )
-{
-    double value = DBL_MAX;
-
-    CV_FUNCNAME( "cvGetGLCMDescriptor" );
-
-    __BEGIN__;
-
-    if( !GLCM )
-        CV_ERROR( CV_StsNullPtr, "" );
-
-    if( !(GLCM->descriptors) )
-        CV_ERROR( CV_StsNullPtr, "" );
-
-    if( (unsigned)step >= (unsigned)(GLCM->numMatrices))
-        CV_ERROR( CV_StsOutOfRange, "step is not in 0 .. GLCM->numMatrices - 1" );
-
-    if( (unsigned)descriptor >= (unsigned)(GLCM->numDescriptors))
-        CV_ERROR( CV_StsOutOfRange, "descriptor is not in 0 .. GLCM->numDescriptors - 1" );
-
-    value = GLCM->descriptors[step][descriptor];
-
-    __END__;
-
-    return value;
-}
-
-
-CV_IMPL void
-cvGetGLCMDescriptorStatistics( CvGLCM* GLCM, int descriptor,
-                               double* _average, double* _standardDeviation )
-{
-    CV_FUNCNAME( "cvGetGLCMDescriptorStatistics" );
-
-    if( _average )
-        *_average = DBL_MAX;
-
-    if( _standardDeviation )
-        *_standardDeviation = DBL_MAX;
-
-    __BEGIN__;
-
-    int matrixLoop, numMatrices;
-    double average = 0, squareSum = 0;
-
-    if( !GLCM )
-        CV_ERROR( CV_StsNullPtr, "" );
-
-    if( !(GLCM->descriptors))
-        CV_ERROR( CV_StsNullPtr, "Descriptors are not calculated" );
-
-    if( (unsigned)descriptor >= (unsigned)(GLCM->numDescriptors) )
-        CV_ERROR( CV_StsOutOfRange, "Descriptor index is out of range" );
-
-    numMatrices = GLCM->numMatrices;
-
-    for( matrixLoop = 0; matrixLoop < numMatrices; matrixLoop++ )
-    {
-        double temp = GLCM->descriptors[ matrixLoop ][ descriptor ];
-        average += temp;
-        squareSum += temp*temp;
-    }
-
-    average /= numMatrices;
-
-    if( _average )
-        *_average = average;
-
-    if( _standardDeviation )
-        *_standardDeviation = sqrt( (squareSum - average*average*numMatrices)/(numMatrices-1));
-
-    __END__;
-}
-
-
-CV_IMPL IplImage*
-cvCreateGLCMImage( CvGLCM* GLCM, int step )
-{
-    IplImage* dest = 0;
-
-    CV_FUNCNAME( "cvCreateGLCMImage" );
-
-    __BEGIN__;
-
-    float* destData;
-    int sideLoop1, sideLoop2;
-
-    if( !GLCM )
-        CV_ERROR( CV_StsNullPtr, "" );
-
-    if( !(GLCM->matrices) )
-        CV_ERROR( CV_StsNullPtr, "Matrices are not allocated" );
-
-    if( (unsigned)step >= (unsigned)(GLCM->numMatrices) )
-        CV_ERROR( CV_StsOutOfRange, "The step index is out of range" );
-
-    dest = cvCreateImage( cvSize( GLCM->matrixSideLength, GLCM->matrixSideLength ), IPL_DEPTH_32F, 1 );
-    destData = (float*)(dest->imageData);
-
-    for( sideLoop1 = 0; sideLoop1 < GLCM->matrixSideLength;
-                        sideLoop1++, (float*&)destData += dest->widthStep )
-    {
-        for( sideLoop2=0; sideLoop2 < GLCM->matrixSideLength; sideLoop2++ )
-        {
-            double matrixValue = GLCM->matrices[step][sideLoop1][sideLoop2];
-            destData[ sideLoop2 ] = (float)matrixValue;
-        }
-    }
-
-    __END__;
-
-    if( cvGetErrStatus() < 0 )
-        cvReleaseImage( &dest );
-
-    return dest;
-}
diff --git a/modules/legacy/src/trifocal.cpp b/modules/legacy/src/trifocal.cpp
deleted file mode 100644 (file)
index a527537..0000000
+++ /dev/null
@@ -1,2784 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "opencv2/calib3d/calib3d_c.h"
-
-#include <float.h>
-#include <limits.h>
-#include <stdio.h>
-
-/* Valery Mosyagin */
-
-/* Function defenitions */
-
-/* ----------------- */
-
-void cvOptimizeLevenbergMarquardtBundle( CvMat** projMatrs, CvMat** observProjPoints,
-                                       CvMat** pointsPres, int numImages,
-                                       CvMat** resultProjMatrs, CvMat* resultPoints4D,int maxIter,double epsilon );
-
-int icvComputeProjectMatrices6Points(  CvMat* points1,CvMat* points2,CvMat* points3,
-                                        CvMat* projMatr1,CvMat* projMatr2,CvMat* projMatr3);
-
-void icvFindBaseTransform(CvMat* points,CvMat* resultT);
-
-void GetGeneratorReduceFundSolution(CvMat* points1,CvMat* points2,CvMat* fundReduceCoef1,CvMat* fundReduceCoef2);
-
-int GetGoodReduceFundamMatrFromTwo(CvMat* fundReduceCoef1,CvMat* fundReduceCoef2,CvMat* resFundReduceCoef);
-
-void GetProjMatrFromReducedFundamental(CvMat* fundReduceCoefs,CvMat* projMatrCoefs);
-
-void icvComputeProjectMatrix(CvMat* objPoints,CvMat* projPoints,CvMat* projMatr);
-
-void icvComputeTransform4D(CvMat* points1,CvMat* points2,CvMat* transMatr);
-
-int icvComputeProjectMatricesNPoints(  CvMat* points1,CvMat* points2,CvMat* points3,
-                                       CvMat* projMatr1,CvMat* projMatr2,CvMat* projMatr3,
-                                       double threshold,/* Threshold for good point */
-                                       double p,/* Probability of good result. */
-                                       CvMat* status,
-                                       CvMat* points4D);
-
-int icvComputeProjectMatricesNPoints(  CvMat* points1,CvMat* points2,CvMat* points3,
-                                       CvMat* projMatr1,CvMat* projMatr2,CvMat* projMatr3,
-                                       double threshold,/* Threshold for good point */
-                                       double p,/* Probability of good result. */
-                                       CvMat* status,
-                                       CvMat* points4D);
-
-void icvReconstructPointsFor3View( CvMat* projMatr1,CvMat* projMatr2,CvMat* projMatr3,
-                                CvMat* projPoints1,CvMat* projPoints2,CvMat* projPoints3,
-                                CvMat* points4D);
-
-void icvReconstructPointsFor3View( CvMat* projMatr1,CvMat* projMatr2,CvMat* projMatr3,
-                                CvMat* projPoints1,CvMat* projPoints2,CvMat* projPoints3,
-                                CvMat* points4D);
-
-/*==========================================================================================*/
-/*                        Functions for calculation the tensor                              */
-/*==========================================================================================*/
-#if 0
-#if 1
-static void fprintMatrix(FILE* file,CvMat* matrix)
-{
-    int i,j;
-    fprintf(file,"\n");
-    for( i=0;i<matrix->rows;i++ )
-    {
-        for(j=0;j<matrix->cols;j++)
-        {
-            fprintf(file,"%10.7lf  ",cvmGet(matrix,i,j));
-        }
-        fprintf(file,"\n");
-    }
-}
-#endif
-/*==========================================================================================*/
-
-static void icvNormalizePoints( CvMat* points, CvMat* normPoints,CvMat* cameraMatr )
-{
-    /* Normalize image points using camera matrix */
-
-    CV_FUNCNAME( "icvNormalizePoints" );
-    __BEGIN__;
-
-    /* Test for null pointers */
-    if( points == 0 || normPoints == 0 || cameraMatr == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(points) || !CV_IS_MAT(normPoints) || !CV_IS_MAT(cameraMatr) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-    int numPoints;
-    numPoints = points->cols;
-    if( numPoints <= 0 || numPoints != normPoints->cols )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of points must be the same and more than 0" );
-    }
-
-    if( normPoints->rows != 2 || normPoints->rows != points->rows )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Points must have 2 coordinates" );
-    }
-
-    if(cameraMatr->rows != 3 || cameraMatr->cols != 3)
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of camera matrix must be 3x3" );
-    }
-
-    double fx,fy,cx,cy;
-
-    fx = cvmGet(cameraMatr,0,0);
-    fy = cvmGet(cameraMatr,1,1);
-    cx = cvmGet(cameraMatr,0,2);
-    cy = cvmGet(cameraMatr,1,2);
-
-    int i;
-    for( i = 0; i < numPoints; i++ )
-    {
-        cvmSet(normPoints, 0, i, (cvmGet(points,0,i) - cx) / fx );
-        cvmSet(normPoints, 1, i, (cvmGet(points,1,i) - cy) / fy );
-    }
-
-    __END__;
-
-    return;
-}
-#endif
-
-/*=====================================================================================*/
-/*
-Computes projection matrices for given 6 points on 3 images
-May returns 3 results. */
-int icvComputeProjectMatrices6Points( CvMat* points1,CvMat* points2,CvMat* points3,
-                                      CvMat* projMatr1,CvMat* projMatr2,CvMat* projMatr3/*,
-                                      CvMat* points4D*/)
-{
-    /* Test input data correctness */
-
-    int numSol = 0;
-
-    CV_FUNCNAME( "icvComputeProjectMatrices6Points" );
-    __BEGIN__;
-
-    /* Test for null pointers */
-    if( points1   == 0 || points2   == 0 || points3   == 0 ||
-        projMatr1 == 0 || projMatr2 == 0 || projMatr3 == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(points1)   || !CV_IS_MAT(points2)   || !CV_IS_MAT(points3)   ||
-        !CV_IS_MAT(projMatr1) || !CV_IS_MAT(projMatr2) || !CV_IS_MAT(projMatr3)  )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-    if( (points1->cols != points2->cols) || (points1->cols != points3->cols) || (points1->cols != 6) /* || (points4D->cols !=6) */)
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of points must be same and == 6" );
-    }
-
-    if( points1->rows != 2 || points2->rows != 2 || points3->rows != 2 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of points coordinates must be 2" );
-    }
-
-    if( projMatr1->cols != 4 || projMatr2->cols != 4 || projMatr3->cols != 4 ||
-        (!(projMatr1->rows == 3 && projMatr2->rows == 3 && projMatr3->rows == 3) &&
-        !(projMatr1->rows == 9 && projMatr2->rows == 9 && projMatr3->rows == 9)) )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of project matrix must be 3x4 or 9x4 (for 3 matrices)" );
-    }
-
-#if 0
-    if( points4D->row != 4 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of coordinates of points4D  must be 4" );
-    }
-#endif
-    {
-    /* Find transform matrix for each camera */
-    int i;
-    CvMat* points[3];
-    points[0] = points1;
-    points[1] = points2;
-    points[2] = points3;
-
-    CvMat* projMatrs[3];
-    projMatrs[0] = projMatr1;
-    projMatrs[1] = projMatr2;
-    projMatrs[2] = projMatr3;
-
-    CvMat transMatr;
-    double transMatr_dat[9];
-    transMatr = cvMat(3,3,CV_64F,transMatr_dat);
-
-    CvMat corrPoints1;
-    CvMat corrPoints2;
-
-    double corrPoints_dat[3*3*2];/* 3-point(images) by 3-coordinates by 2-correspondence*/
-
-    corrPoints1 = cvMat(3,3,CV_64F,corrPoints_dat);  /* 3-coordinates for each of 3-points(3-image) */
-    corrPoints2 = cvMat(3,3,CV_64F,corrPoints_dat+9);/* 3-coordinates for each of 3-points(3-image) */
-
-    for( i = 0; i < 3; i++ )/* for each image */
-    {
-        /* Get last 4 points for computing transformation */
-        CvMat tmpPoints;
-        /* find base points transform for last four points on i-th image */
-        cvGetSubRect(points[i],&tmpPoints,cvRect(2,0,4,2));
-        icvFindBaseTransform(&tmpPoints,&transMatr);
-
-        {/* We have base transform. Compute error scales for three first points */
-            CvMat trPoint;
-            double trPoint_dat[3*3];
-            trPoint = cvMat(3,3,CV_64F,trPoint_dat);
-            /* fill points */
-            for( int kk = 0; kk < 3; kk++ )
-            {
-                cvmSet(&trPoint,0,kk,cvmGet(points[i],0,kk+2));
-                cvmSet(&trPoint,1,kk,cvmGet(points[i],1,kk+2));
-                cvmSet(&trPoint,2,kk,1);
-            }
-
-            /* Transform points */
-            CvMat resPnts;
-            double resPnts_dat[9];
-            resPnts = cvMat(3,3,CV_64F,resPnts_dat);
-            cvmMul(&transMatr,&trPoint,&resPnts);
-        }
-
-        /* Transform two first points */
-        for( int j = 0; j < 2; j++ )
-        {
-            CvMat pnt;
-            double pnt_dat[3];
-            pnt = cvMat(3,1,CV_64F,pnt_dat);
-            pnt_dat[0] = cvmGet(points[i],0,j);
-            pnt_dat[1] = cvmGet(points[i],1,j);
-            pnt_dat[2] = 1.0;
-
-            CvMat trPnt;
-            double trPnt_dat[3];
-            trPnt = cvMat(3,1,CV_64F,trPnt_dat);
-
-            cvmMul(&transMatr,&pnt,&trPnt);
-
-            /* Collect transformed points  */
-            corrPoints_dat[j * 9 + 0 * 3 + i] = trPnt_dat[0];/* x */
-            corrPoints_dat[j * 9 + 1 * 3 + i] = trPnt_dat[1];/* y */
-            corrPoints_dat[j * 9 + 2 * 3 + i] = trPnt_dat[2];/* w */
-        }
-    }
-
-    /* We have computed corr points. Now we can compute generators for reduced fundamental matrix */
-
-    /* Compute generators for reduced fundamental matrix from 3 pair of collect points */
-    CvMat fundReduceCoef1;
-    CvMat fundReduceCoef2;
-    double fundReduceCoef1_dat[5];
-    double fundReduceCoef2_dat[5];
-
-    fundReduceCoef1 = cvMat(1,5,CV_64F,fundReduceCoef1_dat);
-    fundReduceCoef2 = cvMat(1,5,CV_64F,fundReduceCoef2_dat);
-
-    GetGeneratorReduceFundSolution(&corrPoints1, &corrPoints2, &fundReduceCoef1, &fundReduceCoef2);
-
-    /* Choose best solutions for two generators. We can get 3 solutions */
-    CvMat resFundReduceCoef;
-    double resFundReduceCoef_dat[3*5];
-
-    resFundReduceCoef = cvMat(3,5,CV_64F,resFundReduceCoef_dat);
-
-    numSol = GetGoodReduceFundamMatrFromTwo(&fundReduceCoef1, &fundReduceCoef2,&resFundReduceCoef);
-
-    int maxSol;
-    maxSol = projMatrs[0]->rows / 3;
-
-    int currSol;
-    for( currSol = 0; (currSol < numSol && currSol < maxSol); currSol++ )
-    {
-        /* For current solution compute projection matrix */
-        CvMat fundCoefs;
-        cvGetSubRect(&resFundReduceCoef, &fundCoefs, cvRect(0,currSol,5,1));
-
-        CvMat projMatrCoefs;
-        double projMatrCoefs_dat[4];
-        projMatrCoefs = cvMat(1,4,CV_64F,projMatrCoefs_dat);
-
-        GetProjMatrFromReducedFundamental(&fundCoefs,&projMatrCoefs);
-        /* we have computed coeffs for reduced project matrix */
-
-        CvMat objPoints;
-        double objPoints_dat[4*6];
-        objPoints  = cvMat(4,6,CV_64F,objPoints_dat);
-        cvZero(&objPoints);
-
-        /* fill object points */
-        for( i =0; i < 4; i++ )
-        {
-            objPoints_dat[i*6]   = 1;
-            objPoints_dat[i*6+1] = projMatrCoefs_dat[i];
-            objPoints_dat[i*7+2] = 1;
-        }
-
-        int currCamera;
-        for( currCamera = 0; currCamera < 3; currCamera++ )
-        {
-
-            CvMat projPoints;
-            double projPoints_dat[3*6];
-            projPoints = cvMat(3,6,CV_64F,projPoints_dat);
-
-            /* fill projected points for current camera */
-            for( i = 0; i < 6; i++ )/* for each points for current camera */
-            {
-                projPoints_dat[6*0+i] = cvmGet(points[currCamera],0,i);/* x */
-                projPoints_dat[6*1+i] = cvmGet(points[currCamera],1,i);/* y */
-                projPoints_dat[6*2+i] = 1;/* w */
-            }
-
-            /* compute project matrix for current camera */
-            CvMat projMatrix;
-            double projMatrix_dat[3*4];
-            projMatrix = cvMat(3,4,CV_64F,projMatrix_dat);
-
-            icvComputeProjectMatrix(&objPoints,&projPoints,&projMatrix);
-
-            /* Add this matrix to result */
-            CvMat tmpSubRes;
-            cvGetSubRect(projMatrs[currCamera],&tmpSubRes,cvRect(0,currSol*3,4,3));
-            cvConvert(&projMatrix,&tmpSubRes);
-        }
-
-        /* We know project matrices. And we can reconstruct 6 3D-points if need */
-#if 0
-        if( points4D )
-        {
-            if( currSol < points4D->rows / 4 )
-            {
-                CvMat tmpPoints4D;
-                double tmpPoints4D_dat[4*6];
-                tmpPoints4D = cvMat(4,6,CV_64F,tmpPoints4D_dat);
-
-                icvReconstructPointsFor3View( &wProjMatr[0], &wProjMatr[1], &wProjMatr[2],
-                                           points1, points2, points3,
-                                           &tmpPoints4D);
-
-                CvMat tmpSubRes;
-                cvGetSubRect(points4D,tmpSubRes,cvRect(0,currSol*4,6,4));
-                cvConvert(tmpPoints4D,points4D);
-            }
-        }
-#endif
-
-    }/* for all sollutions */
-    }
-    __END__;
-    return numSol;
-}
-
-/*==========================================================================================*/
-static int icvGetRandNumbers(int range,int count,int* arr)
-{
-    /* Generate random numbers [0,range-1] */
-
-    CV_FUNCNAME( "icvGetRandNumbers" );
-    __BEGIN__;
-
-    /* Test input data */
-    if( arr == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Parameter 'arr' is a NULL pointer" );
-    }
-
-
-    /* Test for errors input data  */
-    if( range < count || range <= 0 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Can't generate such numbers. Count must be <= range and range must be > 0" );
-    }
-
-    int i,j;
-    int newRand;
-    for( i = 0; i < count; i++ )
-    {
-
-        int haveRep = 0;/* firstly we have not repeats */
-        do
-        {
-            /* generate new number */
-            newRand = rand()%range;
-            haveRep = 0;
-            /* Test for repeats in previous numbers */
-            for( j = 0; j < i; j++ )
-            {
-                if( arr[j] == newRand )
-                {
-                    haveRep = 1;
-                    break;
-                }
-            }
-        } while(haveRep);
-
-        /* We have good random number */
-        arr[i] = newRand;
-    }
-    __END__;
-    return 1;
-}
-/*==========================================================================================*/
-static void icvSelectColsByNumbers(CvMat* srcMatr, CvMat* dstMatr, int* indexes,int number)
-{
-
-    CV_FUNCNAME( "icvSelectColsByNumbers" );
-    __BEGIN__;
-
-    /* Test input data */
-    if( srcMatr == 0 || dstMatr == 0 || indexes == 0)
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(srcMatr) || !CV_IS_MAT(dstMatr) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "srcMatr and dstMatr must be a matrices" );
-    }
-
-    int srcSize;
-    int numRows;
-    numRows = srcMatr->rows;
-    srcSize = srcMatr->cols;
-
-    if( numRows != dstMatr->rows )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of rows of matrices must be the same" );
-    }
-
-    int dst;
-    for( dst = 0; dst < number; dst++ )
-    {
-        int src = indexes[dst];
-        if( src >=0 && src < srcSize )
-        {
-            /* Copy each elements in column */
-            int i;
-            for( i = 0; i < numRows; i++ )
-            {
-                cvmSet(dstMatr,i,dst,cvmGet(srcMatr,i,src));
-            }
-        }
-    }
-
-    __END__;
-    return;
-}
-
-/*==========================================================================================*/
-static void icvProject4DPoints(CvMat* points4D,CvMat* projMatr, CvMat* projPoints)
-{
-
-    CvMat* tmpProjPoints = 0;
-
-    CV_FUNCNAME( "icvProject4DPoints" );
-
-    __BEGIN__;
-
-    if( points4D == 0 || projMatr == 0 || projPoints == 0)
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(points4D) || !CV_IS_MAT(projMatr) || !CV_IS_MAT(projPoints) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-    int numPoints;
-    numPoints = points4D->cols;
-    if( numPoints < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points4D must be more than zero" );
-    }
-
-    if( numPoints != projPoints->cols )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of points must be the same");
-    }
-
-    if( projPoints->rows != 2 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of coordinates of projected points must be 2");
-    }
-
-    if( points4D->rows != 4 )
-    {
-        CV_ERROR(CV_StsUnmatchedSizes, "Number of coordinates of 4D points must be 4");
-    }
-
-    if( projMatr->cols != 4 || projMatr->rows != 3 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of projection matrix must be 3x4");
-    }
-
-
-    CV_CALL( tmpProjPoints = cvCreateMat(3,numPoints,CV_64F) );
-
-    cvmMul(projMatr,points4D,tmpProjPoints);
-
-    /* Scale points */
-    int i;
-    for( i = 0; i < numPoints; i++ )
-    {
-        double scale,x,y;
-
-        scale = cvmGet(tmpProjPoints,2,i);
-        x = cvmGet(tmpProjPoints,0,i);
-        y = cvmGet(tmpProjPoints,1,i);
-
-        if( fabs(scale) > 1e-7 )
-        {
-            x /= scale;
-            y /= scale;
-        }
-        else
-        {
-            x = 1e8;
-            y = 1e8;
-        }
-
-        cvmSet(projPoints,0,i,x);
-        cvmSet(projPoints,1,i,y);
-    }
-
-    __END__;
-
-    cvReleaseMat(&tmpProjPoints);
-
-    return;
-}
-/*==========================================================================================*/
-#if 0
-static int icvCompute3ProjectMatricesNPointsStatus( CvMat** points,/* 3 arrays of points on image  */
-                                             CvMat** projMatrs,/* array of 3 prejection matrices */
-                                             CvMat** statuses,/* 3 arrays of status of points */
-                                             double threshold,/* Threshold for good point */
-                                             double p,/* Probability of good result. */
-                                             CvMat* resStatus,
-                                             CvMat* points4D)
-{
-    int numProjMatrs = 0;
-    unsigned char *comStat = 0;
-    CvMat *triPoints[3] = {0,0,0};
-    CvMat *status = 0;
-    CvMat *triPoints4D = 0;
-
-    CV_FUNCNAME( "icvCompute3ProjectMatricesNPointsStatus" );
-    __BEGIN__;
-
-    /* Test for errors */
-    if( points == 0 || projMatrs == 0 || statuses == 0 || resStatus == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    int currImage;
-    for( currImage = 0; currImage < 3; currImage++ )
-    {
-        /* Test for null pointers */
-        if( points[currImage] == 0 )
-        {
-            CV_ERROR( CV_StsNullPtr, "Some of points arrays is a NULL pointer" );
-        }
-
-        if( projMatrs[currImage] == 0 )
-        {
-            CV_ERROR( CV_StsNullPtr, "Some of projMatr is a NULL pointer" );
-        }
-
-        if( statuses[currImage] == 0 )
-        {
-            CV_ERROR( CV_StsNullPtr, "Some of status arrays is a NULL pointer" );
-        }
-
-        /* Test for matrices */
-        if( !CV_IS_MAT(points[currImage]) )
-        {
-            CV_ERROR( CV_StsNullPtr, "Some of points arrays is not a matrix" );
-        }
-
-        if( !CV_IS_MAT(projMatrs[currImage]) )
-        {
-            CV_ERROR( CV_StsNullPtr, "Some of projMatr is not a matrix" );
-        }
-
-        if( !CV_IS_MASK_ARR(statuses[currImage]) )
-        {
-            CV_ERROR( CV_StsNullPtr, "Some of status arrays is not a mask array" );
-        }
-    }
-
-    int numPoints;
-    numPoints = points[0]->cols;
-    if( numPoints < 6 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number points must be more than 6" );
-    }
-
-    for( currImage = 0; currImage < 3; currImage++ )
-    {
-        if( points[currImage]->cols != numPoints || statuses[currImage]->cols != numPoints )
-        {
-            CV_ERROR( CV_StsUnmatchedSizes, "Number of points and statuses must be the same" );
-        }
-
-        if( points[currImage]->rows != 2 )
-        {
-            CV_ERROR( CV_StsOutOfRange, "Number of points coordinates must be == 2" );
-        }
-
-        if( statuses[currImage]->rows != 1 )
-        {
-            CV_ERROR( CV_StsOutOfRange, "Each of status must be matrix 1xN" );
-        }
-
-        if( projMatrs[currImage]->rows != 3 || projMatrs[currImage]->cols != 4 )
-        {
-            CV_ERROR( CV_StsOutOfRange, "Each of projection matrix must be 3x4" );
-        }
-    }
-
-
-    /* Create common status for all points */
-
-    int i;
-
-    CV_CALL( comStat = (unsigned char*)cvAlloc(sizeof(unsigned char)*numPoints) );
-
-    unsigned char *stats[3];
-
-    stats[0] = statuses[0]->data.ptr;
-    stats[1] = statuses[1]->data.ptr;
-    stats[2] = statuses[2]->data.ptr;
-
-    int numTripl;
-    numTripl = 0;
-    for( i = 0; i < numPoints; i++ )
-    {
-        comStat[i] = (unsigned char)(stats[0][i] * stats[1][i] * stats[2][i]);
-        numTripl += comStat[i];
-    }
-
-    if( numTripl > 0 )
-    {
-        /* Create new arrays with points */
-        CV_CALL( triPoints[0] = cvCreateMat(2,numTripl,CV_64F) );
-        CV_CALL( triPoints[1] = cvCreateMat(2,numTripl,CV_64F) );
-        CV_CALL( triPoints[2] = cvCreateMat(2,numTripl,CV_64F) );
-        if( points4D )
-        {
-            CV_CALL( triPoints4D  = cvCreateMat(4,numTripl,CV_64F) );
-        }
-
-        /* Create status array */
-        CV_CALL( status = cvCreateMat(1,numTripl,CV_64F) );
-
-        /* Copy points to new arrays */
-        int currPnt = 0;
-        for( i = 0; i < numPoints; i++ )
-        {
-            if( comStat[i] )
-            {
-                for( currImage = 0; currImage < 3; currImage++ )
-                {
-                    cvmSet(triPoints[currImage],0,currPnt,cvmGet(points[currImage],0,i));
-                    cvmSet(triPoints[currImage],1,currPnt,cvmGet(points[currImage],1,i));
-                }
-                currPnt++;
-            }
-        }
-
-        /* Call function */
-        numProjMatrs = icvComputeProjectMatricesNPoints( triPoints[0],triPoints[1],triPoints[2],
-                                                         projMatrs[0],projMatrs[1],projMatrs[2],
-                                                         threshold,/* Threshold for good point */
-                                                         p,/* Probability of good result. */
-                                                         status,
-                                                         triPoints4D);
-
-        /* Get computed status and set to result */
-        cvZero(resStatus);
-        currPnt = 0;
-        for( i = 0; i < numPoints; i++ )
-        {
-            if( comStat[i] )
-            {
-                if( cvmGet(status,0,currPnt) > 0 )
-                {
-                    resStatus->data.ptr[i] = 1;
-                }
-                currPnt++;
-            }
-        }
-
-        if( triPoints4D )
-        {
-            /* Copy copmuted 4D points */
-            cvZero(points4D);
-            currPnt = 0;
-            for( i = 0; i < numPoints; i++ )
-            {
-                if( comStat[i] )
-                {
-                    if( cvmGet(status,0,currPnt) > 0 )
-                    {
-                        cvmSet( points4D, 0, i, cvmGet( triPoints4D , 0, currPnt) );
-                        cvmSet( points4D, 1, i, cvmGet( triPoints4D , 1, currPnt) );
-                        cvmSet( points4D, 2, i, cvmGet( triPoints4D , 2, currPnt) );
-                        cvmSet( points4D, 3, i, cvmGet( triPoints4D , 3, currPnt) );
-                    }
-                    currPnt++;
-                }
-            }
-        }
-    }
-
-    __END__;
-
-    /* Free allocated memory */
-    cvReleaseMat(&status);
-    cvFree( &comStat);
-    cvReleaseMat(&status);
-
-    cvReleaseMat(&triPoints[0]);
-    cvReleaseMat(&triPoints[1]);
-    cvReleaseMat(&triPoints[2]);
-    cvReleaseMat(&triPoints4D);
-
-    return numProjMatrs;
-
-}
-#endif
-
-/*==========================================================================================*/
-int icvComputeProjectMatricesNPoints(  CvMat* points1,CvMat* points2,CvMat* points3,
-                                       CvMat* projMatr1,CvMat* projMatr2,CvMat* projMatr3,
-                                       double threshold,/* Threshold for good point */
-                                       double p,/* Probability of good result. */
-                                       CvMat* status,
-                                       CvMat* points4D)
-{
-    /* Returns status for each point, Good or bad */
-
-    /* Compute projection matrices using N points */
-
-    char* flags = 0;
-    char* bestFlags = 0;
-
-    int numProjMatrs = 0;
-
-    CvMat* tmpProjPoints[3]={0,0,0};
-    CvMat* recPoints4D = 0;
-    CvMat *reconPoints4D = 0;
-
-
-    CV_FUNCNAME( "icvComputeProjectMatricesNPoints" );
-    __BEGIN__;
-
-    CvMat* points[3];
-    points[0] = points1;
-    points[1] = points2;
-    points[2] = points3;
-
-    /* Test for errors */
-    if( points1   == 0 || points2   == 0 || points3   == 0 ||
-        projMatr1 == 0 || projMatr2 == 0 || projMatr3 == 0 ||
-        status == 0)
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(points1)   || !CV_IS_MAT(points2)   || !CV_IS_MAT(points3)   ||
-        !CV_IS_MAT(projMatr1) || !CV_IS_MAT(projMatr2) || !CV_IS_MAT(projMatr3)  ||
-        !CV_IS_MAT(status) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-    int numPoints;
-    numPoints = points1->cols;
-
-    if( numPoints < 6 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number points must be more than 6" );
-    }
-
-    if( numPoints != points2->cols || numPoints != points3->cols )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "number of points must be the same" );
-    }
-
-    if( p < 0 || p > 1.0 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Probability must be >=0 and <=1" );
-    }
-
-    if( threshold < 0 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Threshold for good points must be at least >= 0" );
-    }
-
-    CvMat* projMatrs[3];
-
-    projMatrs[0] = projMatr1;
-    projMatrs[1] = projMatr2;
-    projMatrs[2] = projMatr3;
-
-    for(int i = 0; i < 3; i++ )
-    {
-        if( projMatrs[i]->cols != 4 || projMatrs[i]->rows != 3 )
-        {
-            CV_ERROR( CV_StsUnmatchedSizes, "Size of projection matrices must be 3x4" );
-        }
-    }
-
-    for(int i = 0; i < 3; i++ )
-    {
-        if( points[i]->rows != 2)
-        {
-            CV_ERROR( CV_StsUnmatchedSizes, "Number of coordinates of points must be 2" );
-        }
-    }
-
-    /* use RANSAC algorithm to compute projection matrices */
-
-    CV_CALL( recPoints4D = cvCreateMat(4,numPoints,CV_64F) );
-    CV_CALL( tmpProjPoints[0] = cvCreateMat(2,numPoints,CV_64F) );
-    CV_CALL( tmpProjPoints[1] = cvCreateMat(2,numPoints,CV_64F) );
-    CV_CALL( tmpProjPoints[2] = cvCreateMat(2,numPoints,CV_64F) );
-
-    CV_CALL( flags = (char*)cvAlloc(sizeof(char)*numPoints) );
-    CV_CALL( bestFlags = (char*)cvAlloc(sizeof(char)*numPoints) );
-
-    {
-        int NumSamples = 500;/* just init number of samples */
-        int wasCount = 0;  /* count of choosing samples */
-        int maxGoodPoints = 0;
-        int numGoodPoints = 0;
-
-        double bestProjMatrs_dat[36];
-        CvMat  bestProjMatrs[3];
-        bestProjMatrs[0] = cvMat(3,4,CV_64F,bestProjMatrs_dat);
-        bestProjMatrs[1] = cvMat(3,4,CV_64F,bestProjMatrs_dat+12);
-        bestProjMatrs[2] = cvMat(3,4,CV_64F,bestProjMatrs_dat+24);
-
-        double tmpProjMatr_dat[36*3];
-        CvMat  tmpProjMatr[3];
-        tmpProjMatr[0] = cvMat(9,4,CV_64F,tmpProjMatr_dat);
-        tmpProjMatr[1] = cvMat(9,4,CV_64F,tmpProjMatr_dat+36);
-        tmpProjMatr[2] = cvMat(9,4,CV_64F,tmpProjMatr_dat+72);
-
-        /* chosen points */
-
-        while( wasCount < NumSamples )
-        {
-            /* select samples */
-            int randNumbs[6];
-            icvGetRandNumbers(numPoints,6,randNumbs);
-
-            /* random numbers of points was generated */
-            /* select points */
-
-            double selPoints_dat[2*6*3];
-            CvMat selPoints[3];
-            selPoints[0] = cvMat(2,6,CV_64F,selPoints_dat);
-            selPoints[1] = cvMat(2,6,CV_64F,selPoints_dat+12);
-            selPoints[2] = cvMat(2,6,CV_64F,selPoints_dat+24);
-
-            /* Copy 6 point for random indexes */
-            icvSelectColsByNumbers( points[0], &selPoints[0], randNumbs,6);
-            icvSelectColsByNumbers( points[1], &selPoints[1], randNumbs,6);
-            icvSelectColsByNumbers( points[2], &selPoints[2], randNumbs,6);
-
-            /* Compute projection matrices for this points */
-            int numProj = icvComputeProjectMatrices6Points( &selPoints[0],&selPoints[1],&selPoints[2],
-                                                            &tmpProjMatr[0],&tmpProjMatr[1],&tmpProjMatr[2]);
-
-            /* Compute number of good points for each matrix */
-            CvMat proj6[3];
-            for( int currProj = 0; currProj < numProj; currProj++ )
-            {
-                cvGetSubArr(&tmpProjMatr[0],&proj6[0],cvRect(0,currProj*3,4,3));
-                cvGetSubArr(&tmpProjMatr[1],&proj6[1],cvRect(0,currProj*3,4,3));
-                cvGetSubArr(&tmpProjMatr[2],&proj6[2],cvRect(0,currProj*3,4,3));
-
-                /* Reconstruct points for projection matrices */
-                icvReconstructPointsFor3View( &proj6[0],&proj6[1],&proj6[2],
-                                           points[0], points[1], points[2],
-                                           recPoints4D);
-
-                /* Project points to images using projection matrices */
-                icvProject4DPoints(recPoints4D,&proj6[0],tmpProjPoints[0]);
-                icvProject4DPoints(recPoints4D,&proj6[1],tmpProjPoints[1]);
-                icvProject4DPoints(recPoints4D,&proj6[2],tmpProjPoints[2]);
-
-                /* Compute distances and number of good points (inliers) */
-                int currImage;
-                numGoodPoints = 0;
-                for(int i = 0; i < numPoints; i++ )
-                {
-                    double dist=-1;
-                    dist = 0;
-                    /* Choose max distance for each of three points */
-                    for( currImage = 0; currImage < 3; currImage++ )
-                    {
-                        double x1,y1,x2,y2;
-                        x1 = cvmGet(tmpProjPoints[currImage],0,i);
-                        y1 = cvmGet(tmpProjPoints[currImage],1,i);
-                        x2 = cvmGet(points[currImage],0,i);
-                        y2 = cvmGet(points[currImage],1,i);
-
-                        double dx,dy;
-                        dx = x1-x2;
-                        dy = y1-y2;
-#if 1
-                        double newDist = dx*dx+dy*dy;
-                        if( newDist > dist )
-                        {
-                            dist = newDist;
-                        }
-#else
-                        dist += sqrt(dx*dx+dy*dy)/3.0;
-#endif
-                    }
-                    dist = sqrt(dist);
-                    flags[i] = (char)(dist > threshold ? 0 : 1);
-                    numGoodPoints += flags[i];
-
-                }
-
-
-                if( numGoodPoints > maxGoodPoints )
-                {/* Copy current projection matrices as best */
-
-                    cvCopy(&proj6[0],&bestProjMatrs[0]);
-                    cvCopy(&proj6[1],&bestProjMatrs[1]);
-                    cvCopy(&proj6[2],&bestProjMatrs[2]);
-
-                    maxGoodPoints = numGoodPoints;
-                    /* copy best flags */
-                    memcpy(bestFlags,flags,sizeof(flags[0])*numPoints);
-
-                    /* Adaptive number of samples to count*/
-                    double ep = 1 - (double)numGoodPoints / (double)numPoints;
-                    if( ep == 1 )
-                    {
-                        ep = 0.5;/* if there is not good points set ration of outliers to 50% */
-                    }
-
-                    double newNumSamples = (log(1-p) / log(1-pow(1-ep,6)));
-                    if(  newNumSamples < double(NumSamples) )
-                    {
-                        NumSamples = cvRound(newNumSamples);
-                    }
-                }
-            }
-
-            wasCount++;
-        }
-#if 0
-        char str[300];
-        sprintf(str,"Initial numPoints = %d\nmaxGoodPoints=%d\nRANSAC made %d steps",
-                    numPoints,
-                    maxGoodPoints,
-                    cvRound(wasCount));
-        MessageBox(0,str,"Info",MB_OK|MB_TASKMODAL);
-#endif
-
-        /* we may have best 6-point projection matrices. */
-        /* and best points */
-        /* use these points to improve matrices */
-
-        if( maxGoodPoints < 6 )
-        {
-            /*  matrix not found */
-            numProjMatrs = 0;
-        }
-        else
-        {
-            /* We may Improove matrices using ---- method */
-            /* We may try to use Levenberg-Marquardt optimization */
-            //int currIter = 0;
-            int finalGoodPoints = 0;
-            char *goodFlags = 0;
-            goodFlags = (char*)cvAlloc(numPoints*sizeof(char));
-
-            int needRepeat;
-            do
-            {
-#if 0
-/* Version without using status for Levenberg-Marquardt minimization */
-
-                CvMat *optStatus;
-                optStatus = cvCreateMat(1,numPoints,CV_64F);
-                int testNumber = 0;
-                for(int i=0;i<numPoints;i++ )
-                {
-                    cvmSet(optStatus,0,i,(double)bestFlags[i]);
-                    testNumber += bestFlags[i];
-                }
-
-                char str2[200];
-                sprintf(str2,"test good num=%d\nmaxGoodPoints=%d",testNumber,maxGoodPoints);
-                MessageBox(0,str2,"Info",MB_OK|MB_TASKMODAL);
-
-                CvMat *gPresPoints;
-                gPresPoints = cvCreateMat(1,maxGoodPoints,CV_64F);
-                for(int i = 0; i < maxGoodPoints; i++)
-                {
-                    cvmSet(gPresPoints,0,i,1.0);
-                }
-
-                /* Create array of points pres */
-                CvMat *pointsPres[3];
-                pointsPres[0] = gPresPoints;
-                pointsPres[1] = gPresPoints;
-                pointsPres[2] = gPresPoints;
-
-                /* Create just good points 2D */
-                CvMat *gPoints[3];
-                icvCreateGoodPoints(points[0],&gPoints[0],optStatus);
-                icvCreateGoodPoints(points[1],&gPoints[1],optStatus);
-                icvCreateGoodPoints(points[2],&gPoints[2],optStatus);
-
-                /* Create 4D points array for good points */
-                CvMat *resPoints4D;
-                resPoints4D = cvCreateMat(4,maxGoodPoints,CV_64F);
-
-                CvMat* projMs[3];
-
-                projMs[0] = &bestProjMatrs[0];
-                projMs[1] = &bestProjMatrs[1];
-                projMs[2] = &bestProjMatrs[2];
-
-
-                CvMat resProjMatrs[3];
-                double resProjMatrs_dat[36];
-                resProjMatrs[0] = cvMat(3,4,CV_64F,resProjMatrs_dat);
-                resProjMatrs[1] = cvMat(3,4,CV_64F,resProjMatrs_dat+12);
-                resProjMatrs[2] = cvMat(3,4,CV_64F,resProjMatrs_dat+24);
-
-                CvMat* resMatrs[3];
-                resMatrs[0] = &resProjMatrs[0];
-                resMatrs[1] = &resProjMatrs[1];
-                resMatrs[2] = &resProjMatrs[2];
-
-                cvOptimizeLevenbergMarquardtBundle( projMs,//projMs,
-                                                    gPoints,//points,//points2D,
-                                                    pointsPres,//pointsPres,
-                                                    3,
-                                                    resMatrs,//resProjMatrs,
-                                                    resPoints4D,//resPoints4D,
-                                                    100, 1e-9 );
-
-                /* We found optimized projection matrices */
-
-                CvMat *reconPoints4D;
-                reconPoints4D = cvCreateMat(4,numPoints,CV_64F);
-
-                /* Reconstruct all points using found projection matrices */
-                icvReconstructPointsFor3View( &resProjMatrs[0],&resProjMatrs[1],&resProjMatrs[2],
-                                              points[0], points[1], points[2],
-                                              reconPoints4D);
-
-                /* Project points to images using projection matrices */
-                icvProject4DPoints(reconPoints4D,&resProjMatrs[0],tmpProjPoints[0]);
-                icvProject4DPoints(reconPoints4D,&resProjMatrs[1],tmpProjPoints[1]);
-                icvProject4DPoints(reconPoints4D,&resProjMatrs[2],tmpProjPoints[2]);
-
-
-                /* Compute error for each point and select good */
-
-                int currImage;
-                finalGoodPoints = 0;
-                for(int i = 0; i < numPoints; i++ )
-                {
-                    double dist=-1;
-                    /* Choose max distance for each of three points */
-                    for( currImage = 0; currImage < 3; currImage++ )
-                    {
-                        double x1,y1,x2,y2;
-                        x1 = cvmGet(tmpProjPoints[currImage],0,i);
-                        y1 = cvmGet(tmpProjPoints[currImage],1,i);
-                        x2 = cvmGet(points[currImage],0,i);
-                        y2 = cvmGet(points[currImage],1,i);
-
-                        double dx,dy;
-                        dx = x1-x2;
-                        dy = y1-y2;
-
-                        double newDist = dx*dx+dy*dy;
-                        if( newDist > dist )
-                        {
-                            dist = newDist;
-                        }
-                    }
-                    dist = sqrt(dist);
-                    goodFlags[i] = (char)(dist > threshold ? 0 : 1);
-                    finalGoodPoints += goodFlags[i];
-                }
-
-                char str[200];
-                sprintf(str,"Was num = %d\nNew num=%d",maxGoodPoints,finalGoodPoints);
-                MessageBox(0,str,"Info",MB_OK|MB_TASKMODAL);
-                if( finalGoodPoints > maxGoodPoints )
-                {
-                    /* Copy new version of projection matrices */
-                    cvCopy(&resProjMatrs[0],&bestProjMatrs[0]);
-                    cvCopy(&resProjMatrs[1],&bestProjMatrs[1]);
-                    cvCopy(&resProjMatrs[2],&bestProjMatrs[2]);
-                    memcpy(bestFlags,goodFlags,numPoints*sizeof(char));
-                    maxGoodPoints = finalGoodPoints;
-                }
-
-                cvReleaseMat(&optStatus);
-                cvReleaseMat(&resPoints4D);
-#else
-/* Version with using status for Levenberd-Marquardt minimization */
-
-                /* Create status */
-                CvMat *optStatus;
-                optStatus = cvCreateMat(1,numPoints,CV_64F);
-                for(int i=0;i<numPoints;i++ )
-                {
-                    cvmSet(optStatus,0,i,(double)bestFlags[i]);
-                }
-
-                CvMat *pointsPres[3];
-                pointsPres[0] = optStatus;
-                pointsPres[1] = optStatus;
-                pointsPres[2] = optStatus;
-
-                /* Create 4D points array for good points */
-                CvMat *resPoints4D;
-                resPoints4D = cvCreateMat(4,numPoints,CV_64F);
-
-                CvMat* projMs[3];
-
-                projMs[0] = &bestProjMatrs[0];
-                projMs[1] = &bestProjMatrs[1];
-                projMs[2] = &bestProjMatrs[2];
-
-                CvMat resProjMatrs[3];
-                double resProjMatrs_dat[36];
-                resProjMatrs[0] = cvMat(3,4,CV_64F,resProjMatrs_dat);
-                resProjMatrs[1] = cvMat(3,4,CV_64F,resProjMatrs_dat+12);
-                resProjMatrs[2] = cvMat(3,4,CV_64F,resProjMatrs_dat+24);
-
-                CvMat* resMatrs[3];
-                resMatrs[0] = &resProjMatrs[0];
-                resMatrs[1] = &resProjMatrs[1];
-                resMatrs[2] = &resProjMatrs[2];
-
-                cvOptimizeLevenbergMarquardtBundle( projMs,//projMs,
-                                                    points,//points2D,
-                                                    pointsPres,//pointsPres,
-                                                    3,
-                                                    resMatrs,//resProjMatrs,
-                                                    resPoints4D,//resPoints4D,
-                                                    100, 1e-9 );
-
-                /* We found optimized projection matrices */
-
-                reconPoints4D = cvCreateMat(4,numPoints,CV_64F);
-
-                /* Reconstruct all points using found projection matrices */
-                icvReconstructPointsFor3View( &resProjMatrs[0],&resProjMatrs[1],&resProjMatrs[2],
-                                              points[0], points[1], points[2],
-                                              reconPoints4D);
-
-                /* Project points to images using projection matrices */
-                icvProject4DPoints(reconPoints4D,&resProjMatrs[0],tmpProjPoints[0]);
-                icvProject4DPoints(reconPoints4D,&resProjMatrs[1],tmpProjPoints[1]);
-                icvProject4DPoints(reconPoints4D,&resProjMatrs[2],tmpProjPoints[2]);
-
-
-                /* Compute error for each point and select good */
-
-                int currImage;
-                finalGoodPoints = 0;
-                for(int i = 0; i < numPoints; i++ )
-                {
-                    double dist=-1;
-                    /* Choose max distance for each of three points */
-                    for( currImage = 0; currImage < 3; currImage++ )
-                    {
-                        double x1,y1,x2,y2;
-                        x1 = cvmGet(tmpProjPoints[currImage],0,i);
-                        y1 = cvmGet(tmpProjPoints[currImage],1,i);
-                        x2 = cvmGet(points[currImage],0,i);
-                        y2 = cvmGet(points[currImage],1,i);
-
-                        double dx,dy;
-                        dx = x1-x2;
-                        dy = y1-y2;
-
-                        double newDist = dx*dx+dy*dy;
-                        if( newDist > dist )
-                        {
-                            dist = newDist;
-                        }
-                    }
-                    dist = sqrt(dist);
-                    goodFlags[i] = (char)(dist > threshold ? 0 : 1);
-                    finalGoodPoints += goodFlags[i];
-                }
-
-                /*char str[200];
-                sprintf(str,"Was num = %d\nNew num=%d",maxGoodPoints,finalGoodPoints);
-                MessageBox(0,str,"Info",MB_OK|MB_TASKMODAL);*/
-
-                needRepeat = 0;
-                if( finalGoodPoints > maxGoodPoints )
-                {
-                    /* Copy new version of projection matrices */
-                    cvCopy(&resProjMatrs[0],&bestProjMatrs[0]);
-                    cvCopy(&resProjMatrs[1],&bestProjMatrs[1]);
-                    cvCopy(&resProjMatrs[2],&bestProjMatrs[2]);
-                    memcpy(bestFlags,goodFlags,numPoints*sizeof(char));
-                    maxGoodPoints = finalGoodPoints;
-                    needRepeat = 1;
-                }
-
-                cvReleaseMat(&optStatus);
-                cvReleaseMat(&resPoints4D);
-
-
-#endif
-            } while ( needRepeat );
-
-            cvFree( &goodFlags);
-
-
-
-
-            numProjMatrs = 1;
-
-            /* Copy projection matrices */
-            cvConvert(&bestProjMatrs[0],projMatr1);
-            cvConvert(&bestProjMatrs[1],projMatr2);
-            cvConvert(&bestProjMatrs[2],projMatr3);
-
-            if( status )
-            {
-                /* copy status for each points if need */
-                for( int i = 0; i < numPoints; i++)
-                {
-                    cvmSet(status,0,i,(double)bestFlags[i]);
-                }
-            }
-        }
-    }
-
-    if( points4D )
-    {/* Fill reconstructed points */
-
-        cvZero(points4D);
-        icvReconstructPointsFor3View( projMatr1,projMatr2,projMatr3,
-                                      points[0], points[1], points[2],
-                                      points4D);
-    }
-
-
-
-    __END__;
-
-    cvFree( &flags);
-    cvFree( &bestFlags);
-
-    cvReleaseMat(&recPoints4D);
-    cvReleaseMat(&tmpProjPoints[0]);
-    cvReleaseMat(&tmpProjPoints[1]);
-    cvReleaseMat(&tmpProjPoints[2]);
-
-    return numProjMatrs;
-}
-
-/*==========================================================================================*/
-
-void icvFindBaseTransform(CvMat* points,CvMat* resultT)
-{
-
-    CV_FUNCNAME( "icvFindBaseTransform" );
-    __BEGIN__;
-
-    if( points == 0 || resultT == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(points) || !CV_IS_MAT(resultT) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "points and resultT must be a matrices" );
-    }
-
-    if( points->rows != 2 || points->cols != 4 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of points must be 4. And they must have 2 coordinates" );
-    }
-
-    if( resultT->rows != 3 || resultT->cols != 3 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "size of matrix resultT must be 3x3" );
-    }
-
-    /* Function gets four points and compute transformation to e1=(100) e2=(010) e3=(001) e4=(111) */
-
-    /* !!! test each three points not collinear. Need to test */
-    {
-    /* Create matrices */
-    CvMat matrA;
-    CvMat vectB;
-    double matrA_dat[3*3];
-    double vectB_dat[3];
-    matrA = cvMat(3,3,CV_64F,matrA_dat);
-    vectB = cvMat(3,1,CV_64F,vectB_dat);
-
-    /* fill matrices */
-    int i;
-    for( i = 0; i < 3; i++ )
-    {
-        cvmSet(&matrA,0,i,cvmGet(points,0,i));
-        cvmSet(&matrA,1,i,cvmGet(points,1,i));
-        cvmSet(&matrA,2,i,1);
-    }
-
-    /* Fill vector B */
-    cvmSet(&vectB,0,0,cvmGet(points,0,3));
-    cvmSet(&vectB,1,0,cvmGet(points,1,3));
-    cvmSet(&vectB,2,0,1);
-
-    /* result scale */
-    CvMat scale;
-    double scale_dat[3];
-    scale = cvMat(3,1,CV_64F,scale_dat);
-
-    cvSolve(&matrA,&vectB,&scale,CV_SVD);
-
-    /* multiply by scale */
-    int j;
-    for( j = 0; j < 3; j++ )
-    {
-        double sc = scale_dat[j];
-        for( i = 0; i < 3; i++ )
-        {
-            matrA_dat[i*3+j] *= sc;
-        }
-    }
-
-    /* Convert inverse matrix */
-    CvMat tmpRes;
-    double tmpRes_dat[9];
-    tmpRes = cvMat(3,3,CV_64F,tmpRes_dat);
-    cvInvert(&matrA,&tmpRes);
-
-    cvConvert(&tmpRes,resultT);
-    }
-    __END__;
-
-    return;
-}
-
-
-/*==========================================================================================*/
-void GetGeneratorReduceFundSolution(CvMat* points1,CvMat* points2,CvMat* fundReduceCoef1,CvMat* fundReduceCoef2)
-{
-
-    CV_FUNCNAME( "GetGeneratorReduceFundSolution" );
-    __BEGIN__;
-
-    /* Test input data for errors */
-
-    if( points1 == 0 || points2 == 0 || fundReduceCoef1 == 0 || fundReduceCoef2 == 0)
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(points1) || !CV_IS_MAT(points2) || !CV_IS_MAT(fundReduceCoef1) || !CV_IS_MAT(fundReduceCoef2) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-
-
-    if( points1->rows != 3 || points1->cols != 3 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of points1 must be 3 and and have 3 coordinates" );
-    }
-
-    if( points2->rows != 3 || points2->cols != 3 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of points2 must be 3 and and have 3 coordinates" );
-    }
-
-    if( fundReduceCoef1->rows != 1 || fundReduceCoef1->cols != 5 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of fundReduceCoef1 must be 1x5" );
-    }
-
-    if( fundReduceCoef2->rows != 1 || fundReduceCoef2->cols != 5 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of fundReduceCoef2 must be 1x5" );
-    }
-
-    /* Using 3 corr. points compute reduce */
-    {
-    /* Create matrix */
-    CvMat matrA;
-    double matrA_dat[3*5];
-    matrA = cvMat(3,5,CV_64F,matrA_dat);
-    int i;
-    for( i = 0; i < 3; i++ )
-    {
-        double x1,y1,w1,x2,y2,w2;
-        x1 = cvmGet(points1,0,i);
-        y1 = cvmGet(points1,1,i);
-        w1 = cvmGet(points1,2,i);
-
-        x2 = cvmGet(points2,0,i);
-        y2 = cvmGet(points2,1,i);
-        w2 = cvmGet(points2,2,i);
-
-        cvmSet(&matrA,i,0,y1*x2-y1*w2);
-        cvmSet(&matrA,i,1,w1*x2-y1*w2);
-        cvmSet(&matrA,i,2,x1*y2-y1*w2);
-        cvmSet(&matrA,i,3,w1*y2-y1*w2);
-        cvmSet(&matrA,i,4,x1*w2-y1*w2);
-    }
-
-    /* solve system using svd */
-    CvMat matrU;
-    CvMat matrW;
-    CvMat matrV;
-
-    double matrU_dat[3*3];
-    double matrW_dat[3*5];
-    double matrV_dat[5*5];
-
-    matrU = cvMat(3,3,CV_64F,matrU_dat);
-    matrW = cvMat(3,5,CV_64F,matrW_dat);
-    matrV = cvMat(5,5,CV_64F,matrV_dat);
-
-    /* From svd we need just two last vectors of V or two last row V' */
-    /* We get transposed matrices U and V */
-
-    cvSVD(&matrA,&matrW,0,&matrV,CV_SVD_V_T);
-
-    /* copy results to fundamental matrices */
-    for(i=0;i<5;i++)
-    {
-        cvmSet(fundReduceCoef1,0,i,cvmGet(&matrV,3,i));
-        cvmSet(fundReduceCoef2,0,i,cvmGet(&matrV,4,i));
-    }
-    }
-    __END__;
-    return;
-
-}
-
-/*==========================================================================================*/
-
-int GetGoodReduceFundamMatrFromTwo(CvMat* fundReduceCoef1,CvMat* fundReduceCoef2,CvMat* resFundReduceCoef)
-{
-    int numRoots = 0;
-
-    CV_FUNCNAME( "GetGoodReduceFundamMatrFromTwo" );
-    __BEGIN__;
-
-    if( fundReduceCoef1 == 0 || fundReduceCoef2 == 0 || resFundReduceCoef == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(fundReduceCoef1) || !CV_IS_MAT(fundReduceCoef2) || !CV_IS_MAT(resFundReduceCoef) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-    /* using two fundamental matrix comute matrices for det(F)=0 */
-    /* May compute 1 or 3 matrices. Returns number of solutions */
-    /* Here we will use case F=a*F1+(1-a)*F2  instead of F=m*F1+l*F2 */
-
-    /* Test for errors */
-    if( fundReduceCoef1->rows != 1 || fundReduceCoef1->cols != 5 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of fundReduceCoef1 must be 1x5" );
-    }
-
-    if( fundReduceCoef2->rows != 1 || fundReduceCoef2->cols != 5 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of fundReduceCoef2 must be 1x5" );
-    }
-
-    if( (resFundReduceCoef->rows != 1 && resFundReduceCoef->rows != 3)  || resFundReduceCoef->cols != 5 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of resFundReduceCoef must be 1x5" );
-    }
-    {
-    double p1,q1,r1,s1,t1;
-    double p2,q2,r2,s2,t2;
-    p1 = cvmGet(fundReduceCoef1,0,0);
-    q1 = cvmGet(fundReduceCoef1,0,1);
-    r1 = cvmGet(fundReduceCoef1,0,2);
-    s1 = cvmGet(fundReduceCoef1,0,3);
-    t1 = cvmGet(fundReduceCoef1,0,4);
-
-    p2 = cvmGet(fundReduceCoef2,0,0);
-    q2 = cvmGet(fundReduceCoef2,0,1);
-    r2 = cvmGet(fundReduceCoef2,0,2);
-    s2 = cvmGet(fundReduceCoef2,0,3);
-    t2 = cvmGet(fundReduceCoef2,0,4);
-
-    /* solve equation */
-    CvMat result;
-    CvMat coeffs;
-    double result_dat[2*3];
-    double coeffs_dat[4];
-    result = cvMat(2,3,CV_64F,result_dat);
-    coeffs = cvMat(1,4,CV_64F,coeffs_dat);
-
-    coeffs_dat[0] = ((r1-r2)*(-p1-q1-r1-s1-t1+p2+q2+r2+s2+t2)*(q1-q2)+(p1-p2)*(s1-s2)*(t1-t2));/* *a^3 */
-    coeffs_dat[1] = ((r2*(-p1-q1-r1-s1-t1+p2+q2+r2+s2+t2)+(r1-r2)*(-p2-q2-r2-s2-t2))*(q1-q2)+(r1-r2)*(-p1-q1-r1-s1-t1+p2+q2+r2+s2+t2)*q2+(p2*(s1-s2)+(p1-p2)*s2)*(t1-t2)+(p1-p2)*(s1-s2)*t2);/* *a^2 */
-    coeffs_dat[2] = (r2*(-p2-q2-r2-s2-t2)*(q1-q2)+(r2*(-p1-q1-r1-s1-t1+p2+q2+r2+s2+t2)+(r1-r2)*(-p2-q2-r2-s2-t2))*q2+p2*s2*(t1-t2)+(p2*(s1-s2)+(p1-p2)*s2)*t2);/* *a */
-    coeffs_dat[3] = r2*(-p2-q2-r2-s2-t2)*q2+p2*s2*t2;/* 1 */
-
-    int num;
-    num = cvSolveCubic(&coeffs,&result);
-
-
-    /* test number of solutions and test for real solutions */
-    int i;
-    for( i = 0; i < num; i++ )
-    {
-        if( fabs(cvmGet(&result,1,i)) < 1e-8 )
-        {
-            double alpha = cvmGet(&result,0,i);
-            int j;
-            for( j = 0; j < 5; j++ )
-            {
-                cvmSet(resFundReduceCoef,numRoots,j,
-                    alpha * cvmGet(fundReduceCoef1,0,j) + (1-alpha) * cvmGet(fundReduceCoef2,0,j) );
-            }
-            numRoots++;
-        }
-    }
-    }
-    __END__;
-    return numRoots;
-}
-
-/*==========================================================================================*/
-
-void GetProjMatrFromReducedFundamental(CvMat* fundReduceCoefs,CvMat* projMatrCoefs)
-{
-    CV_FUNCNAME( "GetProjMatrFromReducedFundamental" );
-    __BEGIN__;
-
-    /* Test for errors */
-    if( fundReduceCoefs == 0 || projMatrCoefs == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(fundReduceCoefs) || !CV_IS_MAT(projMatrCoefs) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-
-    if( fundReduceCoefs->rows != 1 || fundReduceCoefs->cols != 5 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of fundReduceCoefs must be 1x5" );
-    }
-
-    if( projMatrCoefs->rows != 1 || projMatrCoefs->cols != 4 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of projMatrCoefs must be 1x4" );
-    }
-
-    /* Computes project matrix from given reduced matrix */
-    /* we have p,q,r,s,t and need get a,b,c,d */
-    /* Fill matrix to compute ratio a:b:c as A:B:C */
-    {
-    CvMat matrA;
-    double matrA_dat[3*3];
-    matrA = cvMat(3,3,CV_64F,matrA_dat);
-
-    double p,q,r,s,t;
-    p = cvmGet(fundReduceCoefs,0,0);
-    q = cvmGet(fundReduceCoefs,0,1);
-    r = cvmGet(fundReduceCoefs,0,2);
-    s = cvmGet(fundReduceCoefs,0,3);
-    t = cvmGet(fundReduceCoefs,0,4);
-
-    matrA_dat[0] = p;
-    matrA_dat[1] = r;
-    matrA_dat[2] = 0;
-
-    matrA_dat[3] = q;
-    matrA_dat[4] = 0;
-    matrA_dat[5] = t;
-
-    matrA_dat[6] = 0;
-    matrA_dat[7] = s;
-    matrA_dat[8] = -(p+q+r+s+t);
-
-    CvMat matrW;
-    CvMat matrV;
-
-    double matrW_dat[3*3];
-    double matrV_dat[3*3];
-
-    matrW = cvMat(3,3,CV_64F,matrW_dat);
-    matrV = cvMat(3,3,CV_64F,matrV_dat);
-
-    /* From svd we need just last vector of V or last row V' */
-    /* We get transposed matrices U and V */
-
-    cvSVD(&matrA,&matrW,0,&matrV,CV_SVD_V_T);
-
-    double A1,B1,C1;
-    A1 = matrV_dat[6];
-    B1 = matrV_dat[7];
-    C1 = matrV_dat[8];
-
-    /* Get second coeffs */
-    matrA_dat[0] = 0;
-    matrA_dat[1] = r;
-    matrA_dat[2] = t;
-
-    matrA_dat[3] = p;
-    matrA_dat[4] = 0;
-    matrA_dat[5] = -(p+q+r+s+t);
-
-    matrA_dat[6] = q;
-    matrA_dat[7] = s;
-    matrA_dat[8] = 0;
-
-    cvSVD(&matrA,&matrW,0,&matrV,CV_SVD_V_T);
-
-    double A2,B2,C2;
-    A2 = matrV_dat[6];
-    B2 = matrV_dat[7];
-    C2 = matrV_dat[8];
-
-    double a,b,c,d;
-    {
-        CvMat matrK;
-        double matrK_dat[36];
-        matrK = cvMat(6,6,CV_64F,matrK_dat);
-        cvZero(&matrK);
-
-        matrK_dat[0]  = 1;
-        matrK_dat[7]  = 1;
-        matrK_dat[14] = 1;
-
-        matrK_dat[18] = -1;
-        matrK_dat[25] = -1;
-        matrK_dat[32] = -1;
-
-        matrK_dat[21] = 1;
-        matrK_dat[27] = 1;
-        matrK_dat[33] = 1;
-
-        matrK_dat[0*6+4] = -A1;
-        matrK_dat[1*6+4] = -B1;
-        matrK_dat[2*6+4] = -C1;
-
-        matrK_dat[3*6+5] = -A2;
-        matrK_dat[4*6+5] = -B2;
-        matrK_dat[5*6+5] = -C2;
-
-        CvMat matrW1;
-        CvMat matrV1;
-
-        double matrW_dat1[36];
-        double matrV_dat1[36];
-
-        matrW1 = cvMat(6,6,CV_64F,matrW_dat1);
-        matrV1 = cvMat(6,6,CV_64F,matrV_dat1);
-
-        /* From svd we need just last vector of V or last row V' */
-        /* We get transposed matrices U and V */
-
-        cvSVD(&matrK,&matrW1,0,&matrV1,CV_SVD_V_T);
-
-        a = matrV_dat1[6*5+0];
-        b = matrV_dat1[6*5+1];
-        c = matrV_dat1[6*5+2];
-        d = matrV_dat1[6*5+3];
-        /* we don't need last two coefficients. Because it just a k1,k2 */
-
-        cvmSet(projMatrCoefs,0,0,a);
-        cvmSet(projMatrCoefs,0,1,b);
-        cvmSet(projMatrCoefs,0,2,c);
-        cvmSet(projMatrCoefs,0,3,d);
-
-    }
-    }
-    __END__;
-    return;
-}
-
-/*==========================================================================================*/
-
-void icvComputeProjectMatrix(CvMat* objPoints,CvMat* projPoints,CvMat* projMatr)
-{/* Using SVD method */
-
-    /* Reconstruct points using object points and projected points */
-    /* Number of points must be >=6 */
-
-    CvMat matrV;
-    CvMat* matrA = 0;
-    CvMat* matrW = 0;
-    CvMat* workProjPoints = 0;
-    CvMat* tmpProjPoints = 0;
-
-    CV_FUNCNAME( "icvComputeProjectMatrix" );
-    __BEGIN__;
-
-    /* Test for errors */
-    if( objPoints == 0 || projPoints == 0 || projMatr == 0)
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(objPoints) || !CV_IS_MAT(projPoints) || !CV_IS_MAT(projMatr) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-    if( projMatr->rows != 3 || projMatr->cols != 4 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of projMatr must be 3x4" );
-    }
-
-    int numPoints;
-    numPoints = projPoints->cols;
-    if( numPoints < 6 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points must be at least 6" );
-    }
-
-    if( numPoints != objPoints->cols )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of points must be same" );
-    }
-
-    if( objPoints->rows != 4 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Object points must have 4 coordinates" );
-    }
-
-    if( projPoints->rows != 3 &&  projPoints->rows != 2 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Projected points must have 2 or 3 coordinates" );
-    }
-
-    /* Create and fill matrix A */
-    CV_CALL( matrA = cvCreateMat(numPoints*3, 12, CV_64F) );
-    CV_CALL( matrW = cvCreateMat(numPoints*3, 12, CV_64F) );
-
-    if( projPoints->rows == 2 )
-    {
-        CV_CALL( tmpProjPoints = cvCreateMat(3,numPoints,CV_64F) );
-        cvMake3DPoints(projPoints,tmpProjPoints);
-        workProjPoints = tmpProjPoints;
-    }
-    else
-    {
-        workProjPoints = projPoints;
-    }
-
-    double matrV_dat[144];
-    matrV = cvMat(12,12,CV_64F,matrV_dat);
-    int i;
-
-    char* dat;
-    dat = (char*)(matrA->data.db);
-
-#if 1
-    FILE *file;
-    file = fopen("d:\\test\\recProjMatr.txt","w");
-
-#endif
-    for( i = 0;i < numPoints; i++ )
-    {
-        double x,y,w;
-        double X,Y,Z,W;
-        double*  matrDat = (double*)dat;
-
-        x = cvmGet(workProjPoints,0,i);
-        y = cvmGet(workProjPoints,1,i);
-        w = cvmGet(workProjPoints,2,i);
-
-
-        X = cvmGet(objPoints,0,i);
-        Y = cvmGet(objPoints,1,i);
-        Z = cvmGet(objPoints,2,i);
-        W = cvmGet(objPoints,3,i);
-
-#if 1
-        fprintf(file,"%d (%lf %lf %lf %lf) - (%lf %lf %lf)\n",i,X,Y,Z,W,x,y,w );
-#endif
-
-/*---*/
-        matrDat[ 0] = 0;
-        matrDat[ 1] = 0;
-        matrDat[ 2] = 0;
-        matrDat[ 3] = 0;
-
-        matrDat[ 4] = -w*X;
-        matrDat[ 5] = -w*Y;
-        matrDat[ 6] = -w*Z;
-        matrDat[ 7] = -w*W;
-
-        matrDat[ 8] = y*X;
-        matrDat[ 9] = y*Y;
-        matrDat[10] = y*Z;
-        matrDat[11] = y*W;
-/*---*/
-        matrDat[12] = w*X;
-        matrDat[13] = w*Y;
-        matrDat[14] = w*Z;
-        matrDat[15] = w*W;
-
-        matrDat[16] = 0;
-        matrDat[17] = 0;
-        matrDat[18] = 0;
-        matrDat[19] = 0;
-
-        matrDat[20] = -x*X;
-        matrDat[21] = -x*Y;
-        matrDat[22] = -x*Z;
-        matrDat[23] = -x*W;
-/*---*/
-        matrDat[24] = -y*X;
-        matrDat[25] = -y*Y;
-        matrDat[26] = -y*Z;
-        matrDat[27] = -y*W;
-
-        matrDat[28] = x*X;
-        matrDat[29] = x*Y;
-        matrDat[30] = x*Z;
-        matrDat[31] = x*W;
-
-        matrDat[32] = 0;
-        matrDat[33] = 0;
-        matrDat[34] = 0;
-        matrDat[35] = 0;
-/*---*/
-        dat += (matrA->step)*3;
-    }
-#if 1
-    fclose(file);
-
-#endif
-
-    /* Solve this system */
-
-    /* From svd we need just last vector of V or last row V' */
-    /* We get transposed matrix V */
-
-    cvSVD(matrA,matrW,0,&matrV,CV_SVD_V_T);
-
-    /* projected matrix was computed */
-    for( i = 0; i < 12; i++ )
-    {
-        cvmSet(projMatr,i/4,i%4,cvmGet(&matrV,11,i));
-    }
-
-    cvReleaseMat(&matrA);
-    cvReleaseMat(&matrW);
-    cvReleaseMat(&tmpProjPoints);
-    __END__;
-}
-
-
-/*==========================================================================================*/
-/*  May be useless function */
-void icvComputeTransform4D(CvMat* points1,CvMat* points2,CvMat* transMatr)
-{
-    CvMat* matrA = 0;
-    CvMat* matrW = 0;
-
-    double matrV_dat[256];
-    CvMat  matrV = cvMat(16,16,CV_64F,matrV_dat);
-
-    CV_FUNCNAME( "icvComputeTransform4D" );
-    __BEGIN__;
-
-    if( points1 == 0 || points2 == 0 || transMatr == 0)
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(points1) || !CV_IS_MAT(points2) || !CV_IS_MAT(transMatr) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-    /* Computes transformation matrix (4x4) for points1 -> points2 */
-    /* p2=H*p1 */
-
-    /* Test for errors */
-    int numPoints;
-    numPoints = points1->cols;
-
-    /* we must have at least 5 points */
-    if( numPoints < 5 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of points must be at least 5" );
-    }
-
-    if( numPoints != points2->cols )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of points must be the same" );
-    }
-
-    if( transMatr->rows != 4 || transMatr->cols != 4 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of transMatr must be 4x4" );
-    }
-
-    if( points1->rows != 4 || points2->rows != 4 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of coordinates of points must be 4" );
-    }
-
-    /* Create matrix */
-    CV_CALL( matrA = cvCreateMat(6*numPoints,16,CV_64F) );
-    CV_CALL( matrW = cvCreateMat(6*numPoints,16,CV_64F) );
-
-    cvZero(matrA);
-
-    /* Fill matrices */
-    int i;
-    for( i = 0; i < numPoints; i++ )/* For each point */
-    {
-        double X1,Y1,Z1,W1;
-        double P[4];
-
-        P[0] = cvmGet(points1,0,i);
-        P[1] = cvmGet(points1,1,i);
-        P[2] = cvmGet(points1,2,i);
-        P[3] = cvmGet(points1,3,i);
-
-        X1 = cvmGet(points2,0,i);
-        Y1 = cvmGet(points2,1,i);
-        Z1 = cvmGet(points2,2,i);
-        W1 = cvmGet(points2,3,i);
-
-        /* Fill matrA */
-        for( int j = 0; j < 4; j++ )/* For each coordinate */
-        {
-            double x,y,z,w;
-
-            x = X1*P[j];
-            y = Y1*P[j];
-            z = Z1*P[j];
-            w = W1*P[j];
-
-            cvmSet(matrA,6*i+0,4*0+j,y);
-            cvmSet(matrA,6*i+0,4*1+j,-x);
-
-            cvmSet(matrA,6*i+1,4*0+j,z);
-            cvmSet(matrA,6*i+1,4*2+j,-x);
-
-            cvmSet(matrA,6*i+2,4*0+j,w);
-            cvmSet(matrA,6*i+2,4*3+j,-x);
-
-            cvmSet(matrA,6*i+3,4*1+j,-z);
-            cvmSet(matrA,6*i+3,4*2+j,y);
-
-            cvmSet(matrA,6*i+4,4*1+j,-w);
-            cvmSet(matrA,6*i+4,4*3+j,y);
-
-            cvmSet(matrA,6*i+5,4*2+j,-w);
-            cvmSet(matrA,6*i+5,4*3+j,z);
-        }
-    }
-
-    /* From svd we need just two last vectors of V or two last row V' */
-    /* We get transposed matrices U and V */
-
-    cvSVD(matrA,matrW,0,&matrV,CV_SVD_V_T);
-
-    /* Copy result to result matrix */
-    for( i = 0; i < 16; i++ )
-    {
-        cvmSet(transMatr,i/4,i%4,cvmGet(&matrV,15,i));
-    }
-
-    cvReleaseMat(&matrA);
-    cvReleaseMat(&matrW);
-
-    __END__;
-    return;
-}
-
-/*==========================================================================================*/
-
-void icvReconstructPointsFor3View( CvMat* projMatr1,CvMat* projMatr2,CvMat* projMatr3,
-                                CvMat* projPoints1,CvMat* projPoints2,CvMat* projPoints3,
-                                CvMat* points4D)
-{
-    CV_FUNCNAME( "icvReconstructPointsFor3View" );
-    __BEGIN__;
-
-    if( projMatr1 == 0 || projMatr2 == 0 || projMatr3 == 0 ||
-        projPoints1 == 0 || projPoints2 == 0 || projPoints3 == 0 ||
-        points4D == 0)
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(projMatr1) || !CV_IS_MAT(projMatr2) || !CV_IS_MAT(projMatr3) ||
-        !CV_IS_MAT(projPoints1) || !CV_IS_MAT(projPoints2) || !CV_IS_MAT(projPoints3)  ||
-        !CV_IS_MAT(points4D) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-    int numPoints;
-    numPoints = projPoints1->cols;
-
-    if( numPoints < 1 )
-    {
-        CV_ERROR( CV_StsOutOfRange, "Number of points must be more than zero" );
-    }
-
-    if( projPoints2->cols != numPoints || projPoints3->cols != numPoints || points4D->cols != numPoints )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of points must be the same" );
-    }
-
-    if( projPoints1->rows != 2 || projPoints2->rows != 2 || projPoints3->rows != 2)
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of proj points coordinates must be == 2" );
-    }
-
-    if( points4D->rows != 4 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of world points coordinates must be == 4" );
-    }
-
-    if( projMatr1->cols != 4 || projMatr1->rows != 3 ||
-        projMatr2->cols != 4 || projMatr2->rows != 3 ||
-        projMatr3->cols != 4 || projMatr3->rows != 3)
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of projection matrices must be 3x4" );
-    }
-    {
-    CvMat matrA;
-    double matrA_dat[36];
-    matrA = cvMat(9,4,CV_64F,matrA_dat);
-
-    //CvMat matrU;
-    CvMat matrW;
-    CvMat matrV;
-    //double matrU_dat[9*9];
-    double matrW_dat[9*4];
-    double matrV_dat[4*4];
-
-    //matrU = cvMat(9,9,CV_64F,matrU_dat);
-    matrW = cvMat(9,4,CV_64F,matrW_dat);
-    matrV = cvMat(4,4,CV_64F,matrV_dat);
-
-    CvMat* projPoints[3];
-    CvMat* projMatrs[3];
-
-    projPoints[0] = projPoints1;
-    projPoints[1] = projPoints2;
-    projPoints[2] = projPoints3;
-
-    projMatrs[0] = projMatr1;
-    projMatrs[1] = projMatr2;
-    projMatrs[2] = projMatr3;
-
-    /* Solve system for each point */
-    int i,j;
-    for( i = 0; i < numPoints; i++ )/* For each point */
-    {
-        /* Fill matrix for current point */
-        for( j = 0; j < 3; j++ )/* For each view */
-        {
-            double x,y;
-            x = cvmGet(projPoints[j],0,i);
-            y = cvmGet(projPoints[j],1,i);
-            for( int k = 0; k < 4; k++ )
-            {
-                cvmSet(&matrA, j*3+0, k, x * cvmGet(projMatrs[j],2,k) -     cvmGet(projMatrs[j],0,k) );
-                cvmSet(&matrA, j*3+1, k, y * cvmGet(projMatrs[j],2,k) -     cvmGet(projMatrs[j],1,k) );
-                cvmSet(&matrA, j*3+2, k, x * cvmGet(projMatrs[j],1,k) - y * cvmGet(projMatrs[j],0,k) );
-            }
-        }
-        /* Solve system for current point */
-        {
-            cvSVD(&matrA,&matrW,0,&matrV,CV_SVD_V_T);
-
-            /* Copy computed point */
-            cvmSet(points4D,0,i,cvmGet(&matrV,3,0));/* X */
-            cvmSet(points4D,1,i,cvmGet(&matrV,3,1));/* Y */
-            cvmSet(points4D,2,i,cvmGet(&matrV,3,2));/* Z */
-            cvmSet(points4D,3,i,cvmGet(&matrV,3,3));/* W */
-        }
-    }
-
-    /* Points was reconstructed. Try to reproject points */
-    /* We can compute reprojection error if need */
-    /*{
-        int i;
-        CvMat point3D;
-        double point3D_dat[4];
-        point3D = cvMat(4,1,CV_64F,point3D_dat);
-
-        CvMat point2D;
-        double point2D_dat[3];
-        point2D = cvMat(3,1,CV_64F,point2D_dat);
-
-        for( i = 0; i < numPoints; i++ )
-        {
-            double W = cvmGet(points4D,3,i);
-
-            point3D_dat[0] = cvmGet(points4D,0,i)/W;
-            point3D_dat[1] = cvmGet(points4D,1,i)/W;
-            point3D_dat[2] = cvmGet(points4D,2,i)/W;
-            point3D_dat[3] = 1;
-
-                // !!! Project this point for each camera
-                for( int currCamera = 0; currCamera < 3; currCamera++ )
-                {
-                    cvmMul(projMatrs[currCamera], &point3D, &point2D);
-
-                    float x,y;
-                    float xr,yr,wr;
-                    x = (float)cvmGet(projPoints[currCamera],0,i);
-                    y = (float)cvmGet(projPoints[currCamera],1,i);
-
-                    wr = (float)point2D_dat[2];
-                    xr = (float)(point2D_dat[0]/wr);
-                    yr = (float)(point2D_dat[1]/wr);
-
-                    float deltaX,deltaY;
-                    deltaX = (float)fabs(x-xr);
-                    deltaY = (float)fabs(y-yr);
-                }
-        }
-    }*/
-    }
-    __END__;
-    return;
-}
-
-
-
-
-#if 0
-void ReconstructPointsFor3View_bySolve( CvMat* projMatr1,CvMat* projMatr2,CvMat* projMatr3,
-                                CvMat* projPoints1,CvMat* projPoints2,CvMat* projPoints3,
-                                CvMat* points3D)
-{
-    CV_FUNCNAME( "ReconstructPointsFor3View" );
-    __BEGIN__;
-
-
-    int numPoints;
-    numPoints = projPoints1->cols;
-    if( projPoints2->cols != numPoints || projPoints3->cols != numPoints || points3D->cols != numPoints )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of points must be the same" );
-    }
-
-    if( projPoints1->rows != 2 || projPoints2->rows != 2 || projPoints3->rows != 2)
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of proj points coordinates must be == 2" );
-    }
-
-    if( points3D->rows != 4 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of world points coordinates must be == 4" );
-    }
-
-    if( projMatr1->cols != 4 || projMatr1->rows != 3 ||
-        projMatr2->cols != 4 || projMatr2->rows != 3 ||
-        projMatr3->cols != 4 || projMatr3->rows != 3)
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of proj matrix must be 3x4" );
-    }
-
-    CvMat matrA;
-    double matrA_dat[3*3*3];
-    matrA = cvMat(3*3,3,CV_64F,matrA_dat);
-
-    CvMat vectB;
-    double vectB_dat[9];
-    vectB = cvMat(9,1,CV_64F,vectB_dat);
-
-    CvMat result;
-    double result_dat[3];
-    result = cvMat(3,1,CV_64F,result_dat);
-
-    CvMat* projPoints[3];
-    CvMat* projMatrs[3];
-
-    projPoints[0] = projPoints1;
-    projPoints[1] = projPoints2;
-    projPoints[2] = projPoints3;
-
-    projMatrs[0] = projMatr1;
-    projMatrs[1] = projMatr2;
-    projMatrs[2] = projMatr3;
-
-    /* Solve system for each point */
-    int i,j;
-    for( i = 0; i < numPoints; i++ )/* For each point */
-    {
-        /* Fill matrix for current point */
-        for( j = 0; j < 3; j++ )/* For each view */
-        {
-            double x,y;
-            x = cvmGet(projPoints[j],0,i);
-            y = cvmGet(projPoints[j],1,i);
-
-            cvmSet(&vectB,j*3+0,0,x-cvmGet(projMatrs[j],0,3));
-            cvmSet(&vectB,j*3+1,0,y-cvmGet(projMatrs[j],1,3));
-            cvmSet(&vectB,j*3+2,0,1-cvmGet(projMatrs[j],2,3));
-
-            for( int t = 0; t < 3; t++ )
-            {
-                for( int k = 0; k < 3; k++ )
-                {
-                    cvmSet(&matrA, j*3+t, k, cvmGet(projMatrs[j],t,k) );
-                }
-            }
-        }
-
-
-        /* Solve system for current point */
-        cvSolve(&matrA,&vectB,&result,CV_SVD);
-
-        cvmSet(points3D,0,i,result_dat[0]);/* X */
-        cvmSet(points3D,1,i,result_dat[1]);/* Y */
-        cvmSet(points3D,2,i,result_dat[2]);/* Z */
-        cvmSet(points3D,3,i,1);/* W */
-
-    }
-
-    /* Points was reconstructed. Try to reproject points */
-    {
-        int i;
-        CvMat point3D;
-        double point3D_dat[4];
-        point3D = cvMat(4,1,CV_64F,point3D_dat);
-
-        CvMat point2D;
-        double point2D_dat[3];
-        point2D = cvMat(3,1,CV_64F,point2D_dat);
-
-        for( i = 0; i < numPoints; i++ )
-        {
-            double W = cvmGet(points3D,3,i);
-
-            point3D_dat[0] = cvmGet(points3D,0,i)/W;
-            point3D_dat[1] = cvmGet(points3D,1,i)/W;
-            point3D_dat[2] = cvmGet(points3D,2,i)/W;
-            point3D_dat[3] = 1;
-
-                /* Project this point for each camera */
-                for( int currCamera = 0; currCamera < 3; currCamera++ )
-                {
-                    cvmMul(projMatrs[currCamera], &point3D, &point2D);
-                    float x,y;
-                    float xr,yr,wr;
-                    x = (float)cvmGet(projPoints[currCamera],0,i);
-                    y = (float)cvmGet(projPoints[currCamera],1,i);
-
-                    wr = (float)point2D_dat[2];
-                    xr = (float)(point2D_dat[0]/wr);
-                    yr = (float)(point2D_dat[1]/wr);
-
-                }
-        }
-    }
-
-    __END__;
-    return;
-}
-#endif
-
-/*==========================================================================================*/
-#if 0
-static void icvComputeCameraExrinnsicByPosition(CvMat* camPos, CvMat* rotMatr, CvMat* transVect)
-{
-    /* We know position of camera. we must to compute rotate matrix and translate vector */
-
-    CV_FUNCNAME( "icvComputeCameraExrinnsicByPosition" );
-    __BEGIN__;
-
-    /* Test input paramaters */
-    if( camPos == 0 || rotMatr == 0 || transVect == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(camPos) || !CV_IS_MAT(rotMatr) || !CV_IS_MAT(transVect) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-    if( camPos->cols != 1 || camPos->rows != 3 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of coordinates of camera position must be 3x1 vector" );
-    }
-
-    if( rotMatr->cols != 3 || rotMatr->rows != 3 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Rotate matrix must be 3x3" );
-    }
-
-    if( transVect->cols != 1 || transVect->rows != 3 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Translate vector must be 3x1" );
-    }
-
-    double x,y,z;
-    x = cvmGet(camPos,0,0);
-    y = cvmGet(camPos,1,0);
-    z = cvmGet(camPos,2,0);
-
-    /* Set translate vector. It same as camea position */
-    cvmSet(transVect,0,0,x);
-    cvmSet(transVect,1,0,y);
-    cvmSet(transVect,2,0,z);
-
-    /* Compute rotate matrix. Compute each unit transformed vector */
-
-    /* normalize flat direction x,y */
-    double vectorX[3];
-    double vectorY[3];
-    double vectorZ[3];
-
-    vectorX[0] = -z;
-    vectorX[1] =  0;
-    vectorX[2] =  x;
-
-    vectorY[0] =  x*y;
-    vectorY[1] =  x*x+z*z;
-    vectorY[2] =  z*y;
-
-    vectorZ[0] = -x;
-    vectorZ[1] = -y;
-    vectorZ[2] = -z;
-
-    /* normaize vectors */
-    double norm;
-    int i;
-
-    /* Norm X */
-    norm = 0;
-    for( i = 0; i < 3; i++ )
-        norm += vectorX[i]*vectorX[i];
-    norm = sqrt(norm);
-    for( i = 0; i < 3; i++ )
-        vectorX[i] /= norm;
-
-    /* Norm Y */
-    norm = 0;
-    for( i = 0; i < 3; i++ )
-        norm += vectorY[i]*vectorY[i];
-    norm = sqrt(norm);
-    for( i = 0; i < 3; i++ )
-        vectorY[i] /= norm;
-
-    /* Norm Z */
-    norm = 0;
-    for( i = 0; i < 3; i++ )
-        norm += vectorZ[i]*vectorZ[i];
-    norm = sqrt(norm);
-    for( i = 0; i < 3; i++ )
-        vectorZ[i] /= norm;
-
-    /* Set output results */
-
-    for( i = 0; i < 3; i++ )
-    {
-        cvmSet(rotMatr,i,0,vectorX[i]);
-        cvmSet(rotMatr,i,1,vectorY[i]);
-        cvmSet(rotMatr,i,2,vectorZ[i]);
-    }
-
-    {/* Try to inverse rotate matrix */
-        CvMat tmpInvRot;
-        double tmpInvRot_dat[9];
-        tmpInvRot = cvMat(3,3,CV_64F,tmpInvRot_dat);
-        cvInvert(rotMatr,&tmpInvRot,CV_SVD);
-        cvConvert(&tmpInvRot,rotMatr);
-
-
-
-    }
-
-    __END__;
-
-    return;
-}
-
-/*==========================================================================================*/
-
-static void FindTransformForProjectMatrices(CvMat* projMatr1,CvMat* projMatr2,CvMat* rotMatr,CvMat* transVect)
-{
-    /* Computes homography for project matrix be "canonical" form */
-    CV_FUNCNAME( "computeProjMatrHomography" );
-    __BEGIN__;
-
-    /* Test input paramaters */
-    if( projMatr1 == 0 || projMatr2 == 0 || rotMatr == 0 || transVect == 0 )
-    {
-        CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
-    }
-
-    if( !CV_IS_MAT(projMatr1) || !CV_IS_MAT(projMatr2) || !CV_IS_MAT(rotMatr) || !CV_IS_MAT(transVect) )
-    {
-        CV_ERROR( CV_StsUnsupportedFormat, "Input parameters must be a matrices" );
-    }
-
-    if( projMatr1->cols != 4 || projMatr1->rows != 3 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of project matrix 1 must be 3x4" );
-    }
-
-    if( projMatr2->cols != 4 || projMatr2->rows != 3 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of project matrix 2 must be 3x4" );
-    }
-
-    if( rotMatr->cols != 3 || rotMatr->rows != 3 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of rotation matrix must be 3x3" );
-    }
-
-    if( transVect->cols != 1 || transVect->rows != 3 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of translation vector must be 3x1" );
-    }
-
-    CvMat matrA;
-    double matrA_dat[12*12];
-    matrA = cvMat(12,12,CV_64F,matrA_dat);
-    CvMat vectB;
-    double vectB_dat[12];
-    vectB = cvMat(12,1,CV_64F,vectB_dat);
-
-    cvZero(&matrA);
-    cvZero(&vectB);
-    int i,j;
-    for( i = 0; i < 12; i++ )
-    {
-        for( j = 0; j < 12; j++ )
-        {
-            cvmSet(&matrA,i,j,cvmGet(projMatr1,i/4,j%4));
-        }
-        /* Fill vector B */
-
-        double val = cvmGet(projMatr2,i/4,i%4);
-        if( (i+1)%4 == 0 )
-        {
-            val -= cvmGet(projMatr1,i/4,3);
-
-        }
-        cvmSet(&vectB,i,0,val);
-    }
-
-    /* Solve system */
-    CvMat resVect;
-    double resVect_dat[12];
-    resVect = cvMat(12,1,CV_64F,resVect_dat);
-
-    cvSolve(&matrA,&vectB,&resVect);
-
-    /* Fill rotation matrix */
-    for( i = 0; i < 12; i++ )
-    {
-        double val = cvmGet(&resVect,i,0);
-        if( i < 9 )
-            cvmSet(rotMatr,i%3,i/3,val);
-        else
-            cvmSet(transVect,i-9,0,val);
-    }
-
-    __END__;
-
-    return;
-}
-
-/*==========================================================================================*/
-#if 0
-void icvComputeQknowPrincipalPoint(int numImages, CvMat **projMatrs,CvMat *matrQ, double cx,double cy)
-{
-    /* Computes matrix Q */
-    /* focal x and y eqauls () */
-    /* we know principal point for camera */
-    /* focal may differ from image to image */
-    /* image skew is 0 */
-
-    if( numImages < 10 )
-    {
-        return;
-        //Error. Number of images too few
-    }
-
-    /* Create  */
-
-
-    return;
-}
-#endif
-
-/*==========================================================================================*/
-
-/*==========================================================================================*/
-/*==========================================================================================*/
-/*==========================================================================================*/
-/*==========================================================================================*/
-/* Part with metric reconstruction */
-
-#if 1
-static void icvComputeQ(int numMatr, CvMat** projMatr, CvMat** cameraMatr, CvMat* matrQ)
-{
-    /* K*K' = P*Q*P' */
-    /* try to solve Q by linear method */
-
-    CvMat* matrA = 0;
-    CvMat* vectB = 0;
-
-    CV_FUNCNAME( "ComputeQ" );
-    __BEGIN__;
-
-    /* Define number of projection matrices */
-    if( numMatr < 2 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Number of projection matrices must be at least 2" );
-    }
-
-
-    /* test matrices sizes */
-    if( matrQ->cols != 4 || matrQ->rows != 4 )
-    {
-        CV_ERROR( CV_StsUnmatchedSizes, "Size of matrix Q must be 3x3" );
-    }
-
-    int currMatr;
-    for( currMatr = 0; currMatr < numMatr; currMatr++ )
-    {
-
-        if( cameraMatr[currMatr]->cols != 3 || cameraMatr[currMatr]->rows != 3 )
-        {
-            CV_ERROR( CV_StsUnmatchedSizes, "Size of each camera matrix must be 3x3" );
-        }
-
-        if( projMatr[currMatr]->cols != 4 || projMatr[currMatr]->rows != 3 )
-        {
-            CV_ERROR( CV_StsUnmatchedSizes, "Size of each camera matrix must be 3x3" );
-        }
-    }
-
-    CvMat matrw;
-    double matrw_dat[9];
-    matrw = cvMat(3,3,CV_64F,matrw_dat);
-
-    CvMat matrKt;
-    double matrKt_dat[9];
-    matrKt = cvMat(3,3,CV_64F,matrKt_dat);
-
-
-    /* Create matrix A and vector B */
-    CV_CALL( matrA = cvCreateMat(9*numMatr,10,CV_64F) );
-    CV_CALL( vectB = cvCreateMat(9*numMatr,1,CV_64F) );
-
-    double dataQ[16];
-
-    for( currMatr = 0; currMatr < numMatr; currMatr++ )
-    {
-        int ord10[10] = {0,1,2,3,5,6,7,10,11,15};
-        /* Fill atrix A by data from matrices  */
-
-        /* Compute matrix w for current camera matrix */
-        cvTranspose(cameraMatr[currMatr],&matrKt);
-        cvmMul(cameraMatr[currMatr],&matrKt,&matrw);
-
-        /* Fill matrix A and vector B */
-
-        int currWi,currWj;
-        int currMatr;
-        for( currMatr = 0; currMatr < numMatr; currMatr++ )
-        {
-            for( currWi = 0; currWi < 3; currWi++ )
-            {
-                for( currWj = 0; currWj < 3; currWj++ )
-                {
-                    int i,j;
-                    for( i = 0; i < 4; i++ )
-                    {
-                        for( j = 0; j < 4; j++ )
-                        {
-                            /* get elements from current projection matrix */
-                            dataQ[i*4+j] = cvmGet(projMatr[currMatr],currWi,j) *
-                                           cvmGet(projMatr[currMatr],currWj,i);
-                        }
-                    }
-
-                    /* we know 16 elements in dataQ move them to matrQ 10 */
-                    dataQ[1]  += dataQ[4];
-                    dataQ[2]  += dataQ[8];
-                    dataQ[3]  += dataQ[12];
-                    dataQ[6]  += dataQ[9];
-                    dataQ[7]  += dataQ[13];
-                    dataQ[11] += dataQ[14];
-                    /* Now first 10 elements has coeffs */
-
-                    /* copy to matrix A */
-                    for( i = 0; i < 10; i++ )
-                    {
-                        cvmSet(matrA,currMatr*9 + currWi*3+currWj,i,dataQ[ord10[i]]);
-                    }
-                }
-            }
-
-            /* Fill vector B */
-            for( int i = 0; i < 9; i++ )
-            {
-                cvmSet(vectB,currMatr*9+i,0,matrw_dat[i]);
-            }
-        }
-    }
-
-    /* Matrix A and vector B filled and we can solve system */
-
-    /* Solve system */
-    CvMat resQ;
-    double resQ_dat[10];
-    resQ = cvMat(10,1,CV_64F,resQ_dat);
-
-    cvSolve(matrA,vectB,&resQ,CV_SVD);
-
-    /* System was solved. We know matrix Q. But we must have condition det Q=0 */
-    /* Just copy result matrix Q */
-    {
-        int curr = 0;
-        int ord16[16] = {0,1,2,3,1,4,5,6,2,5,7,8,3,6,8,9};
-
-        for( int i = 0; i < 4; i++ )
-        {
-            for( int j = 0; j < 4; j++ )
-            {
-                cvmSet(matrQ,i,j,resQ_dat[ord16[curr++]]);
-            }
-        }
-    }
-
-
-    __END__;
-
-    /* Free allocated memory */
-    cvReleaseMat(&matrA);
-    cvReleaseMat(&vectB);
-
-    return;
-}
-#endif
-/*-----------------------------------------------------------------------------------------------------*/
-
-static void icvDecomposeQ(CvMat* /*matrQ*/,CvMat* /*matrH*/)
-{
-#if 0
-    /* Use SVD to decompose matrix Q=H*I*H' */
-    /* test input data */
-
-    CvMat matrW;
-    CvMat matrU;
-//    CvMat matrV;
-    double matrW_dat[16];
-    double matrU_dat[16];
-//    double matrV_dat[16];
-
-    matrW = cvMat(4,4,CV_64F,matrW_dat);
-    matrU = cvMat(4,4,CV_64F,matrU_dat);
-//    matrV = cvMat(4,4,CV_64F,matrV_dat);
-
-    cvSVD(matrQ,&matrW,&matrU,0);
-
-    double eig[3];
-    eig[0] = fsqrt(cvmGet(&matrW,0,0));
-    eig[1] = fsqrt(cvmGet(&matrW,1,1));
-    eig[2] = fsqrt(cvmGet(&matrW,2,2));
-
-    CvMat matrIS;
-    double matrIS_dat[16];
-    matrIS =
-
-
-
-
-/* det for matrix Q with q1-q10 */
-/*
-+ q1*q5*q8*q10
-- q1*q5*q9*q9
-- q1*q6*q6*q10
-+ 2*q1*q6*q7*q9
-- q1*q7*q7*q8
-- q2*q2*q8*q10
-+ q2*q2*q9*q9
-+ 2*q2*q6*q3*q10
-- 2*q2*q6*q4*q9
-- 2*q2*q7*q3*q9
-+ 2*q2*q7*q4*q8
-- q5*q3*q3*q10
-+ 2*q3*q5*q4*q9
-+ q3*q3*q7*q7
-- 2*q3*q7*q4*q6
-- q5*q4*q4*q8
-+ q4*q4*q6*q6
-*/
-
-//  (1-a)^4 = 1  -  4 * a  +  6 * a * a  -  4 * a * a * a  +  a * a * a * a;
-
-
-#endif
-}
-
-#endif
diff --git a/modules/legacy/src/vecfacetracking.cpp b/modules/legacy/src/vecfacetracking.cpp
deleted file mode 100644 (file)
index b2a03b4..0000000
+++ /dev/null
@@ -1,973 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/****************************************************************************************\
-      Contour-based face feature tracking
-      The code was created by Tatiana Cherepanova (tata@sl.iae.nsk.su)
-\****************************************************************************************/
-
-#include "precomp.hpp"
-#include "_vectrack.h"
-
-#define NUM_FACE_ELEMENTS   3
-enum
-{
-    MOUTH = 0,
-    LEYE = 1,
-    REYE = 2
-};
-
-#define MAX_LAYERS      64
-
-const double pi = 3.1415926535;
-
-struct CvFaceTracker;
-struct CvTrackingRect;
-class CvFaceElement;
-
-void ThresholdingParam(IplImage *imgGray, int iNumLayers, int &iMinLevel, int &iMaxLevel, float &step, float& power, int iHistMin /*= HIST_MIN*/);
-int ChoiceTrackingFace3(CvFaceTracker* pTF, const int nElements, const CvFaceElement* big_face, CvTrackingRect* face, int& new_energy);
-int ChoiceTrackingFace2(CvFaceTracker* pTF, const int nElements, const CvFaceElement* big_face, CvTrackingRect* face, int& new_energy, int noel);
-inline int GetEnergy(CvTrackingRect** ppNew, const CvTrackingRect* pPrev, CvPoint* ptTempl, CvRect* rTempl);
-inline int GetEnergy2(CvTrackingRect** ppNew, const CvTrackingRect* pPrev, CvPoint* ptTempl, CvRect* rTempl, int* element);
-inline double CalculateTransformationLMS3_0( CvPoint* pTemplPoints, CvPoint* pSrcPoints);
-inline double CalculateTransformationLMS3( CvPoint* pTemplPoints,
-                                   CvPoint* pSrcPoints,
-                                   double*       pdbAverageScale,
-                                   double*       pdbAverageRotate,
-                                   double*       pdbAverageShiftX,
-                                   double*       pdbAverageShiftY );
-
-struct CvTrackingRect
-{
-    CvRect r;
-    CvPoint ptCenter;
-    int iColor;
-    int iEnergy;
-    int nRectsInThis;
-    int nRectsOnLeft;
-    int nRectsOnRight;
-    int nRectsOnTop;
-    int nRectsOnBottom;
-    CvTrackingRect() { memset(this, 0, sizeof(CvTrackingRect)); };
-    int Energy(const CvTrackingRect& prev)
-    {
-        int prev_color = 0 == prev.iColor ? iColor : prev.iColor;
-        iEnergy =   1 * pow2(r.width - prev.r.width) +
-            1 * pow2(r.height - prev.r.height) +
-            1 * pow2(iColor - prev_color) / 4 +
-            - 1 * nRectsInThis +
-            - 0 * nRectsOnTop +
-            + 0 * nRectsOnLeft +
-            + 0 * nRectsOnRight +
-            + 0 * nRectsOnBottom;
-        return iEnergy;
-    }
-};
-
-struct CvFaceTracker
-{
-    CvTrackingRect face[NUM_FACE_ELEMENTS];
-    int iTrackingFaceType;
-    double dbRotateDelta;
-    double dbRotateAngle;
-    CvPoint ptRotate;
-
-    CvPoint ptTempl[NUM_FACE_ELEMENTS];
-    CvRect rTempl[NUM_FACE_ELEMENTS];
-
-    IplImage* imgGray;
-    IplImage* imgThresh;
-    CvMemStorage* mstgContours;
-    CvFaceTracker()
-    {
-        ptRotate.x = 0;
-        ptRotate.y = 0;
-        dbRotateDelta = 0;
-        dbRotateAngle = 0;
-        iTrackingFaceType = -1;
-        imgThresh = NULL;
-        imgGray = NULL;
-        mstgContours = NULL;
-    };
-    ~CvFaceTracker()
-    {
-        if (NULL != imgGray)
-            delete imgGray;
-        if (NULL != imgThresh)
-            delete imgThresh;
-        if (NULL != mstgContours)
-            cvReleaseMemStorage(&mstgContours);
-    };
-    int Init(CvRect* pRects, IplImage* imgray)
-    {
-        for (int i = 0; i < NUM_FACE_ELEMENTS; i++)
-        {
-            face[i].r = pRects[i];
-            face[i].ptCenter = Center(face[i].r);
-            ptTempl[i] = face[i].ptCenter;
-            rTempl[i] = face[i].r;
-        }
-        imgray = cvCreateImage(cvSize(imgray->width, imgray->height), 8, 1);
-        imgThresh = cvCreateImage(cvSize(imgray->width, imgray->height), 8, 1);
-        mstgContours = cvCreateMemStorage();
-        if ((NULL == imgray) ||
-            (NULL == imgThresh) ||
-            (NULL == mstgContours))
-            return 0;
-        return 1;
-    };
-    int InitNextImage(IplImage* img)
-    {
-        CvSize sz(img->width, img->height);
-        ReallocImage(&imgGray, sz, 1);
-        ReallocImage(&imgThresh, sz, 1);
-        ptRotate = face[MOUTH].ptCenter;
-        float m[6];
-        CvMat mat = cvMat( 2, 3, CV_32FC1, m );
-
-        if (NULL == imgGray || NULL == imgThresh)
-            return 0;
-
-        /*m[0] = (float)cos(-dbRotateAngle*CV_PI/180.);
-        m[1] = (float)sin(-dbRotateAngle*CV_PI/180.);
-        m[2] = (float)ptRotate.x;
-        m[3] = -m[1];
-        m[4] = m[0];
-        m[5] = (float)ptRotate.y;*/
-        cv2DRotationMatrix( cvPointTo32f(ptRotate), -dbRotateAngle, 1., &mat );
-        cvWarpAffine( img, imgGray, &mat );
-
-        if (NULL == mstgContours)
-            mstgContours = cvCreateMemStorage();
-        else
-            cvClearMemStorage(mstgContours);
-        if (NULL == mstgContours)
-            return 0;
-        return 1;
-    }
-};
-
-class CvFaceElement
-{
-public:
-    CvSeq* m_seqRects;
-    CvMemStorage* m_mstgRects;
-    CvRect m_rROI;
-    CvTrackingRect m_trPrev;
-    inline CvFaceElement()
-    {
-        m_seqRects = NULL;
-        m_mstgRects = NULL;
-        m_rROI.x = 0;
-        m_rROI.y = 0;
-        m_rROI.width = 0;
-        m_rROI.height = 0;
-    };
-    inline int Init(const CvRect& roi, const CvTrackingRect& prev, CvMemStorage* mstg = NULL)
-    {
-        m_rROI = roi;
-        m_trPrev = prev;
-        if (NULL != mstg)
-            m_mstgRects = mstg;
-        if (NULL == m_mstgRects)
-            return 0;
-        if (NULL == m_seqRects)
-            m_seqRects = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvTrackingRect), m_mstgRects);
-        else
-            cvClearSeq(m_seqRects);
-        if (NULL == m_seqRects)
-            return 0;
-        return 1;
-    };
-    void FindRects(IplImage* img, IplImage* thresh, int nLayers, int dMinSize);
-protected:
-    void FindContours(IplImage* img, IplImage* thresh, int nLayers, int dMinSize);
-    void MergeRects(int d);
-    void Energy();
-}; //class CvFaceElement
-
-inline int CV_CDECL CompareEnergy(const void* el1, const void* el2, void*)
-{
-    return ((CvTrackingRect*)el1)->iEnergy - ((CvTrackingRect*)el2)->iEnergy;
-}// int CV_CDECL CompareEnergy(const void* el1, const void* el2, void*)
-
-void CvFaceElement::FindRects(IplImage* img, IplImage* thresh, int nLayers, int dMinSize)
-{
-    FindContours(img, thresh, nLayers, dMinSize / 4);
-    if (0 == m_seqRects->total)
-        return;
-    Energy();
-    cvSeqSort(m_seqRects, CompareEnergy, NULL);
-    CvTrackingRect* pR = (CvTrackingRect*)cvGetSeqElem(m_seqRects, 0);
-    if (m_seqRects->total < 32)
-    {
-        MergeRects(dMinSize / 8);
-        Energy();
-        cvSeqSort(m_seqRects, CompareEnergy, NULL);
-    }
-    pR = (CvTrackingRect*)cvGetSeqElem(m_seqRects, 0);
-    if ((pR->iEnergy > 100 && m_seqRects->total < 32) || (m_seqRects->total < 16))
-    {
-        MergeRects(dMinSize / 4);
-        Energy();
-        cvSeqSort(m_seqRects, CompareEnergy, NULL);
-    }
-    pR = (CvTrackingRect*)cvGetSeqElem(m_seqRects, 0);
-    if ((pR->iEnergy > 100 && m_seqRects->total < 16) || (pR->iEnergy > 200 && m_seqRects->total < 32))
-    {
-        MergeRects(dMinSize / 2);
-        Energy();
-        cvSeqSort(m_seqRects, CompareEnergy, NULL);
-    }
-
-}// void CvFaceElement::FindRects(IplImage* img, IplImage* thresh, int nLayers, int dMinSize)
-
-void CvFaceElement::FindContours(IplImage* img, IplImage* thresh, int nLayers, int dMinSize)
-{
-    CvSeq* seq;
-    CvRect roi = m_rROI;
-    Extend(roi, 1);
-    cvSetImageROI(img, roi);
-    cvSetImageROI(thresh, roi);
-    // layers
-    int colors[MAX_LAYERS] = {0};
-    int iMinLevel = 0, iMaxLevel = 255;
-    float step, power;
-    ThresholdingParam(img, nLayers / 2, iMinLevel, iMaxLevel, step, power, 4);
-    int iMinLevelPrev = iMinLevel;
-    int iMaxLevelPrev = iMinLevel;
-    if (m_trPrev.iColor != 0)
-    {
-        iMinLevelPrev = m_trPrev.iColor - nLayers / 2;
-        iMaxLevelPrev = m_trPrev.iColor + nLayers / 2;
-    }
-    if (iMinLevelPrev < iMinLevel)
-    {
-        iMaxLevelPrev += iMinLevel - iMinLevelPrev;
-        iMinLevelPrev = iMinLevel;
-    }
-    if (iMaxLevelPrev > iMaxLevel)
-    {
-        iMinLevelPrev -= iMaxLevelPrev - iMaxLevel;
-        if (iMinLevelPrev < iMinLevel)
-            iMinLevelPrev = iMinLevel;
-        iMaxLevelPrev = iMaxLevel;
-    }
-    int n = nLayers;
-    n -= (iMaxLevelPrev - iMinLevelPrev + 1) / 2;
-    step = float(iMinLevelPrev - iMinLevel + iMaxLevel - iMaxLevelPrev) / float(n);
-    int j = 0;
-    float level;
-    for (level = (float)iMinLevel; level < iMinLevelPrev && j < nLayers; level += step, j++)
-        colors[j] = int(level + 0.5);
-    for (level = (float)iMinLevelPrev; level < iMaxLevelPrev && j < nLayers; level += 2.0, j++)
-        colors[j] = int(level + 0.5);
-    for (level = (float)iMaxLevelPrev; level < iMaxLevel && j < nLayers; level += step, j++)
-        colors[j] = int(level + 0.5);
-    //
-    for (int i = 0; i < nLayers; i++)
-    {
-        cvThreshold(img, thresh, colors[i], 255.0, CV_THRESH_BINARY);
-        if (cvFindContours(thresh, m_mstgRects, &seq, sizeof(CvContour), CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE))
-        {
-            CvTrackingRect cr;
-            for (CvSeq* external = seq; external; external = external->h_next)
-            {
-                cr.r = cvContourBoundingRect(external);
-                Move(cr.r, roi.x, roi.y);
-                if (RectInRect(cr.r, m_rROI) && cr.r.width > dMinSize  && cr.r.height > dMinSize)
-                {
-                    cr.ptCenter = Center(cr.r);
-                    cr.iColor = colors[i];
-                    cvSeqPush(m_seqRects, &cr);
-                }
-                for (CvSeq* internal = external->v_next; internal; internal = internal->h_next)
-                {
-                    cr.r = cvContourBoundingRect(internal);
-                    Move(cr.r, roi.x, roi.y);
-                    if (RectInRect(cr.r, m_rROI) && cr.r.width > dMinSize  && cr.r.height > dMinSize)
-                    {
-                        cr.ptCenter = Center(cr.r);
-                        cr.iColor = colors[i];
-                        cvSeqPush(m_seqRects, &cr);
-                    }
-                }
-            }
-            cvClearSeq(seq);
-        }
-    }
-    cvResetImageROI(img);
-    cvResetImageROI(thresh);
-}//void CvFaceElement::FindContours(IplImage* img, IplImage* thresh, int nLayers)
-
-void CvFaceElement::MergeRects(int d)
-{
-    int nRects = m_seqRects->total;
-    CvSeqReader reader, reader2;
-    cvStartReadSeq( m_seqRects, &reader );
-    int i, j;
-    for (i = 0; i < nRects; i++)
-    {
-        CvTrackingRect* pRect1 = (CvTrackingRect*)(reader.ptr);
-        cvStartReadSeq( m_seqRects, &reader2 );
-        cvSetSeqReaderPos(&reader2, i + 1);
-        for (j = i + 1; j < nRects; j++)
-        {
-            CvTrackingRect* pRect2 = (CvTrackingRect*)(reader2.ptr);
-            if (abs(pRect1->ptCenter.y - pRect2->ptCenter.y) < d &&
-                abs(pRect1->r.height - pRect2->r.height) < d)
-            {
-                CvTrackingRect rNew;
-                rNew.iColor = (pRect1->iColor + pRect2->iColor + 1) / 2;
-                rNew.r.x = min(pRect1->r.x, pRect2->r.x);
-                rNew.r.y = min(pRect1->r.y, pRect2->r.y);
-                rNew.r.width = max(pRect1->r.x + pRect1->r.width, pRect2->r.x + pRect2->r.width) - rNew.r.x;
-                rNew.r.height = min(pRect1->r.y + pRect1->r.height, pRect2->r.y + pRect2->r.height) - rNew.r.y;
-                if (rNew.r != pRect1->r && rNew.r != pRect2->r)
-                {
-                    rNew.ptCenter = Center(rNew.r);
-                    cvSeqPush(m_seqRects, &rNew);
-                }
-            }
-            CV_NEXT_SEQ_ELEM( sizeof(CvTrackingRect), reader2 );
-        }
-        CV_NEXT_SEQ_ELEM( sizeof(CvTrackingRect), reader );
-    }
-    // delete equal rects
-    for (i = 0; i < m_seqRects->total; i++)
-    {
-        CvTrackingRect* pRect1 = (CvTrackingRect*)cvGetSeqElem(m_seqRects, i);
-        int j_begin = i + 1;
-        for (j = j_begin; j < m_seqRects->total;)
-        {
-            CvTrackingRect* pRect2 = (CvTrackingRect*)cvGetSeqElem(m_seqRects, j);
-            if (pRect1->r == pRect2->r)
-                cvSeqRemove(m_seqRects, j);
-            else
-                j++;
-        }
-    }
-
-}//void CvFaceElement::MergeRects(int d)
-
-void CvFaceElement::Energy()
-{
-    CvSeqReader reader, reader2;
-    cvStartReadSeq( m_seqRects, &reader );
-    for (int i = 0; i < m_seqRects->total; i++)
-    {
-        CvTrackingRect* pRect = (CvTrackingRect*)(reader.ptr);
-        // outside and inside rects
-        cvStartReadSeq( m_seqRects, &reader2 );
-        for (int j = 0; j < m_seqRects->total; j++)
-        {
-            CvTrackingRect* pRect2 = (CvTrackingRect*)(reader2.ptr);
-            if (i != j)
-            {
-                if (RectInRect(pRect2->r, pRect->r))
-                    pRect->nRectsInThis ++;
-                else if (pRect2->r.y + pRect2->r.height <= pRect->r.y)
-                    pRect->nRectsOnTop ++;
-                else if (pRect2->r.y >= pRect->r.y + pRect->r.height)
-                    pRect->nRectsOnBottom ++;
-                else if (pRect2->r.x + pRect2->r.width <= pRect->r.x)
-                    pRect->nRectsOnLeft ++;
-                else if (pRect2->r.x >= pRect->r.x + pRect->r.width)
-                    pRect->nRectsOnRight ++;
-            }
-            CV_NEXT_SEQ_ELEM( sizeof(CvTrackingRect), reader2 );
-        }
-        // energy
-        pRect->Energy(m_trPrev);
-        CV_NEXT_SEQ_ELEM( sizeof(CvTrackingRect), reader );
-    }
-}//void CvFaceElement::Energy()
-
-CV_IMPL CvFaceTracker*
-cvInitFaceTracker(CvFaceTracker* pFaceTracker, const IplImage* imgGray, CvRect* pRects, int nRects)
-{
-    assert(NULL != imgGray);
-    assert(NULL != pRects);
-    assert(nRects >= NUM_FACE_ELEMENTS);
-    if ((NULL == imgGray) ||
-        (NULL == pRects) ||
-        (nRects < NUM_FACE_ELEMENTS))
-        return NULL;
-
-    //int new_face = 0;
-    CvFaceTracker* pFace = pFaceTracker;
-    if (NULL == pFace)
-    {
-        pFace = new CvFaceTracker;
-        if (NULL == pFace)
-            return NULL;
-        //new_face = 1;
-    }
-    pFace->Init(pRects, (IplImage*)imgGray);
-    return pFace;
-}//CvFaceTracker* InitFaceTracker(IplImage* imgGray, CvRect* pRects, int nRects)
-
-CV_IMPL void
-cvReleaseFaceTracker(CvFaceTracker** ppFaceTracker)
-{
-    if (NULL == *ppFaceTracker)
-        return;
-    delete *ppFaceTracker;
-    *ppFaceTracker = NULL;
-}//void ReleaseFaceTracker(CvFaceTracker** ppFaceTracker)
-
-
-CV_IMPL int
-cvTrackFace(CvFaceTracker* pFaceTracker, IplImage* imgGray, CvRect* pRects, int nRects, CvPoint* ptRotate, double* dbAngleRotate)
-{
-    assert(NULL != pFaceTracker);
-    assert(NULL != imgGray);
-    assert(NULL != pRects && nRects >= NUM_FACE_ELEMENTS);
-    if ((NULL == pFaceTracker) ||
-        (NULL == imgGray))
-        return 0;
-    pFaceTracker->InitNextImage(imgGray);
-    *ptRotate = pFaceTracker->ptRotate;
-    *dbAngleRotate = pFaceTracker->dbRotateAngle;
-
-    int nElements = 16;
-    double dx = pFaceTracker->face[LEYE].ptCenter.x - pFaceTracker->face[REYE].ptCenter.x;
-    double dy = pFaceTracker->face[LEYE].ptCenter.y - pFaceTracker->face[REYE].ptCenter.y;
-    double d_eyes = sqrt(dx*dx + dy*dy);
-    int d = cvRound(0.25 * d_eyes);
-    int dMinSize = d;
-    int nRestarts = 0;
-
-    int elem;
-
-    CvFaceElement big_face[NUM_FACE_ELEMENTS];
-START:
-    // init
-    for (elem = 0; elem < NUM_FACE_ELEMENTS; elem++)
-    {
-        CvRect r = pFaceTracker->face[elem].r;
-        Extend(r, d);
-        if (r.width < 4*d)
-        {
-            r.x -= (4*d - r.width) / 2;
-            r.width += 4*d - r.width;
-        }
-        if (r.height < 3*d)
-        {
-            r.y -= (3*d - r.height) / 2;
-            r.height += 3*d - r.height;
-        }
-        if (r.x < 1)
-            r.x = 1;
-        if (r.y < 1)
-            r.y = 1;
-        if (r.x + r.width > pFaceTracker->imgGray->width - 2)
-            r.width = pFaceTracker->imgGray->width - 2 - r.x;
-        if (r.y + r.height > pFaceTracker->imgGray->height - 2)
-            r.height = pFaceTracker->imgGray->height - 2 - r.y;
-        if (!big_face[elem].Init(r, pFaceTracker->face[elem], pFaceTracker->mstgContours))
-            return 0;
-    }
-    // find contours
-    for (elem = 0; elem < NUM_FACE_ELEMENTS; elem++)
-        big_face[elem].FindRects(pFaceTracker->imgGray, pFaceTracker->imgThresh, 32, dMinSize);
-    // candidats
-    CvTrackingRect new_face[NUM_FACE_ELEMENTS];
-    int new_energy = 0;
-    int found = ChoiceTrackingFace3(pFaceTracker, nElements, big_face, new_face, new_energy);
-    int restart = 0;
-    int find2 = 0;
-    int noel = -1;
-    if (found)
-    {
-        if (new_energy > 100000 && -1 != pFaceTracker->iTrackingFaceType)
-            find2 = 1;
-        else if (new_energy > 150000)
-        {
-            int elements = 0;
-            for (int el = 0; el < NUM_FACE_ELEMENTS; el++)
-            {
-                if (big_face[el].m_seqRects->total > 16 || (big_face[el].m_seqRects->total > 8 && new_face[el].iEnergy < 100))
-                    elements++;
-                else
-                    noel = el;
-            }
-            if (2 == elements)
-                find2 = 1;
-            else
-                restart = 1;
-        }
-    }
-    else
-    {
-        if (-1 != pFaceTracker->iTrackingFaceType)
-            find2 = 1;
-        else
-            restart = 1;
-    }
-RESTART:
-    if (restart)
-    {
-        if (nRestarts++ < 2)
-        {
-            d = d + d/4;
-            goto START;
-        }
-    }
-    else if (find2)
-    {
-        if (-1 != pFaceTracker->iTrackingFaceType)
-            noel = pFaceTracker->iTrackingFaceType;
-        int found2 = ChoiceTrackingFace2(pFaceTracker, nElements, big_face, new_face, new_energy, noel);
-        if (found2 && new_energy < 100000)
-        {
-            pFaceTracker->iTrackingFaceType = noel;
-            found = 1;
-        }
-        else
-        {
-            restart = 1;
-            goto RESTART;
-        }
-    }
-
-    if (found)
-    {
-        // angle by mouth & eyes
-        double vx_prev = double(pFaceTracker->face[LEYE].ptCenter.x + pFaceTracker->face[REYE].ptCenter.x) / 2.0 - pFaceTracker->face[MOUTH].ptCenter.x;
-        double vy_prev = double(pFaceTracker->face[LEYE].ptCenter.y + pFaceTracker->face[REYE].ptCenter.y) / 2.0 - pFaceTracker->face[MOUTH].ptCenter.y;
-        double vx_prev1 = vx_prev * cos(pFaceTracker->dbRotateDelta) - vy_prev * sin(pFaceTracker->dbRotateDelta);
-        double vy_prev1 = vx_prev * sin(pFaceTracker->dbRotateDelta) + vy_prev * cos(pFaceTracker->dbRotateDelta);
-        vx_prev = vx_prev1;
-        vy_prev = vy_prev1;
-        for (elem = 0; elem < NUM_FACE_ELEMENTS; elem++)
-            pFaceTracker->face[elem] = new_face[elem];
-        double vx = double(pFaceTracker->face[LEYE].ptCenter.x + pFaceTracker->face[REYE].ptCenter.x) / 2.0 - pFaceTracker->face[MOUTH].ptCenter.x;
-        double vy = double(pFaceTracker->face[LEYE].ptCenter.y + pFaceTracker->face[REYE].ptCenter.y) / 2.0 - pFaceTracker->face[MOUTH].ptCenter.y;
-        pFaceTracker->dbRotateDelta = 0;
-        double n1_n2 = (vx * vx + vy * vy) * (vx_prev * vx_prev + vy_prev * vy_prev);
-        if (n1_n2 != 0)
-            pFaceTracker->dbRotateDelta = asin((vx * vy_prev - vx_prev * vy) / sqrt(n1_n2));
-        pFaceTracker->dbRotateAngle -= pFaceTracker->dbRotateDelta;
-    }
-    else
-    {
-        pFaceTracker->dbRotateDelta = 0;
-        pFaceTracker->dbRotateAngle = 0;
-    }
-    if ((pFaceTracker->dbRotateAngle >= pi/2 && pFaceTracker->dbRotateAngle > 0) ||
-        (pFaceTracker->dbRotateAngle <= -pi/2 && pFaceTracker->dbRotateAngle < 0))
-    {
-        pFaceTracker->dbRotateDelta = 0;
-        pFaceTracker->dbRotateAngle = 0;
-        found = 0;
-    }
-    if (found)
-    {
-        for (int i = 0; i < NUM_FACE_ELEMENTS && i < nRects; i++)
-            pRects[i] = pFaceTracker->face[i].r;
-    }
-    return found;
-}//int FindFaceTracker(CvFaceTracker* pFaceTracker, IplImage* imgGray, CvRect* pRects, int nRects, CvPoint& ptRotate, double& dbAngleRotate)
-
-void ThresholdingParam(IplImage *imgGray, int iNumLayers, int &iMinLevel, int &iMaxLevel, float &step, float& power, int iHistMin /*= HIST_MIN*/)
-{
-    assert(imgGray != NULL);
-    assert(imgGray->nChannels == 1);
-    int i, j;
-    // create histogram
-    int histImg[256] = {0};
-    uchar* buffImg = (uchar*)imgGray->imageData;
-    CvRect rROI = cvGetImageROI(imgGray);
-    buffImg += rROI.y * imgGray->widthStep + rROI.x;
-    for (j = 0; j < rROI.height; j++)
-    {
-        for (i = 0; i < rROI.width; i++)
-            histImg[buffImg[i]] ++;
-        buffImg += imgGray->widthStep;
-    }
-    // params
-    for (i = 0; i < 256; i++)
-    {
-        if (histImg[i] > iHistMin)
-            break;
-    }
-    iMinLevel = i;
-    for (i = 255; i >= 0; i--)
-    {
-        if (histImg[i] > iHistMin)
-            break;
-    }
-    iMaxLevel = i;
-    if (iMaxLevel <= iMinLevel)
-    {
-        iMaxLevel = 255;
-        iMinLevel = 0;
-    }
-    // power
-    double black = 1;
-    double white = 1;
-    for (i = iMinLevel; i < (iMinLevel + iMaxLevel) / 2; i++)
-        black += histImg[i];
-    for (i = (iMinLevel + iMaxLevel) / 2; i < iMaxLevel; i++)
-        white += histImg[i];
-    power = float(black) / float(2 * white);
-    //
-    step = float(iMaxLevel - iMinLevel) / float(iNumLayers);
-    if (step < 1.0)
-        step = 1.0;
-}// void ThresholdingParam(IplImage *imgGray, int iNumLayers, int &iMinLevel, int &iMaxLevel, int &iStep)
-
-int ChoiceTrackingFace3(CvFaceTracker* pTF, const int nElements, const CvFaceElement* big_face, CvTrackingRect* face, int& new_energy)
-{
-    CvTrackingRect* curr_face[NUM_FACE_ELEMENTS] = {NULL};
-    CvTrackingRect* new_face[NUM_FACE_ELEMENTS] = {NULL};
-    new_energy = 0x7fffffff;
-    int curr_energy = 0x7fffffff;
-    int found = 0;
-    int N = 0;
-    CvSeqReader reader_m, reader_l, reader_r;
-    cvStartReadSeq( big_face[MOUTH].m_seqRects, &reader_m );
-    for (int i_mouth = 0; i_mouth < big_face[MOUTH].m_seqRects->total && i_mouth < nElements; i_mouth++)
-    {
-        curr_face[MOUTH] = (CvTrackingRect*)(reader_m.ptr);
-        cvStartReadSeq( big_face[LEYE].m_seqRects, &reader_l );
-        for (int i_left = 0; i_left < big_face[LEYE].m_seqRects->total && i_left < nElements; i_left++)
-        {
-            curr_face[LEYE] = (CvTrackingRect*)(reader_l.ptr);
-            if (curr_face[LEYE]->r.y + curr_face[LEYE]->r.height < curr_face[MOUTH]->r.y)
-            {
-                cvStartReadSeq( big_face[REYE].m_seqRects, &reader_r );
-                for (int i_right = 0; i_right < big_face[REYE].m_seqRects->total && i_right < nElements; i_right++)
-                {
-                    curr_face[REYE] = (CvTrackingRect*)(reader_r.ptr);
-                    if (curr_face[REYE]->r.y + curr_face[REYE]->r.height < curr_face[MOUTH]->r.y &&
-                        curr_face[REYE]->r.x > curr_face[LEYE]->r.x + curr_face[LEYE]->r.width)
-                    {
-                        curr_energy = GetEnergy(curr_face, pTF->face, pTF->ptTempl, pTF->rTempl);
-                        if (curr_energy < new_energy)
-                        {
-                            for (int elem = 0; elem < NUM_FACE_ELEMENTS; elem++)
-                                new_face[elem] = curr_face[elem];
-                            new_energy = curr_energy;
-                            found = 1;
-                        }
-                        N++;
-                    }
-                }
-            }
-        }
-    }
-    if (found)
-    {
-        for (int elem = 0; elem < NUM_FACE_ELEMENTS; elem++)
-            face[elem] = *(new_face[elem]);
-    }
-    return found;
-} // int ChoiceTrackingFace3(const CvTrackingRect* tr_face, CvTrackingRect* new_face, int& new_energy)
-
-int ChoiceTrackingFace2(CvFaceTracker* pTF, const int nElements, const CvFaceElement* big_face, CvTrackingRect* face, int& new_energy, int noel)
-{
-    int element[NUM_FACE_ELEMENTS];
-    for (int i = 0, elem = 0; i < NUM_FACE_ELEMENTS; i++)
-    {
-        if (i != noel)
-        {
-            element[elem] = i;
-            elem ++;
-        }
-        else
-            element[2] = i;
-    }
-    CvTrackingRect* curr_face[NUM_FACE_ELEMENTS] = {NULL};
-    CvTrackingRect* new_face[NUM_FACE_ELEMENTS] = {NULL};
-    new_energy = 0x7fffffff;
-    int curr_energy = 0x7fffffff;
-    int found = 0;
-    int N = 0;
-    CvSeqReader reader0, reader1;
-    cvStartReadSeq( big_face[element[0]].m_seqRects, &reader0 );
-    for (int i0 = 0; i0 < big_face[element[0]].m_seqRects->total && i0 < nElements; i0++)
-    {
-        curr_face[element[0]] = (CvTrackingRect*)(reader0.ptr);
-        cvStartReadSeq( big_face[element[1]].m_seqRects, &reader1 );
-        for (int i1 = 0; i1 < big_face[element[1]].m_seqRects->total && i1 < nElements; i1++)
-        {
-            curr_face[element[1]] = (CvTrackingRect*)(reader1.ptr);
-            curr_energy = GetEnergy2(curr_face, pTF->face, pTF->ptTempl, pTF->rTempl, element);
-            if (curr_energy < new_energy)
-            {
-                for (int elem = 0; elem < NUM_FACE_ELEMENTS; elem++)
-                    new_face[elem] = curr_face[elem];
-                new_energy = curr_energy;
-                found = 1;
-            }
-            N++;
-        }
-    }
-    if (found)
-    {
-        face[element[0]] = *(new_face[element[0]]);
-        face[element[1]] = *(new_face[element[1]]);
-        // 3 element find by template
-        CvPoint templ_v01(pTF->ptTempl[element[1]].x - pTF->ptTempl[element[0]].x, pTF->ptTempl[element[1]].y - pTF->ptTempl[element[0]].y);
-        CvPoint templ_v02(pTF->ptTempl[element[2]].x - pTF->ptTempl[element[0]].x, pTF->ptTempl[element[2]].y - pTF->ptTempl[element[0]].y);
-        CvPoint prev_v01(pTF->face[element[1]].ptCenter.x - pTF->face[element[0]].ptCenter.x, pTF->face[element[1]].ptCenter.y - pTF->face[element[0]].ptCenter.y);
-        CvPoint prev_v02(pTF->face[element[2]].ptCenter.x - pTF->face[element[0]].ptCenter.x, pTF->face[element[2]].ptCenter.y - pTF->face[element[0]].ptCenter.y);
-        CvPoint new_v01(new_face[element[1]]->ptCenter.x - new_face[element[0]]->ptCenter.x, new_face[element[1]]->ptCenter.y - new_face[element[0]]->ptCenter.y);
-        double templ_d01 = sqrt((double)templ_v01.x*templ_v01.x + templ_v01.y*templ_v01.y);
-        double templ_d02 = sqrt((double)templ_v02.x*templ_v02.x + templ_v02.y*templ_v02.y);
-        double prev_d01 = sqrt((double)prev_v01.x*prev_v01.x + prev_v01.y*prev_v01.y);
-        double prev_d02 = sqrt((double)prev_v02.x*prev_v02.x + prev_v02.y*prev_v02.y);
-        double new_d01 = sqrt((double)new_v01.x*new_v01.x + new_v01.y*new_v01.y);
-        double scale = templ_d01 / new_d01;
-        double new_d02 = templ_d02 / scale;
-        double sin_a = double(prev_v01.x * prev_v02.y - prev_v01.y * prev_v02.x) / (prev_d01 * prev_d02);
-        double cos_a = cos(asin(sin_a));
-        double x = double(new_v01.x) * cos_a - double(new_v01.y) * sin_a;
-        double y = double(new_v01.x) * sin_a + double(new_v01.y) * cos_a;
-        x = x * new_d02 / new_d01;
-        y = y * new_d02 / new_d01;
-        CvPoint new_v02(int(x + 0.5), int(y + 0.5));
-        face[element[2]].iColor = 0;
-        face[element[2]].iEnergy = 0;
-        face[element[2]].nRectsInThis = 0;
-        face[element[2]].nRectsOnBottom = 0;
-        face[element[2]].nRectsOnLeft = 0;
-        face[element[2]].nRectsOnRight = 0;
-        face[element[2]].nRectsOnTop = 0;
-        face[element[2]].ptCenter.x = new_v02.x + new_face[element[0]]->ptCenter.x;
-        face[element[2]].ptCenter.y = new_v02.y + new_face[element[0]]->ptCenter.y;
-        face[element[2]].r.width = int(double(pTF->rTempl[element[2]].width) / (scale) + 0.5);
-        face[element[2]].r.height = int(double(pTF->rTempl[element[2]].height) / (scale) + 0.5);
-        face[element[2]].r.x = face[element[2]].ptCenter.x - (face[element[2]].r.width + 1) / 2;
-        face[element[2]].r.y = face[element[2]].ptCenter.y - (face[element[2]].r.height + 1) / 2;
-        assert(face[LEYE].r.x + face[LEYE].r.width <= face[REYE].r.x);
-    }
-    return found;
-} // int ChoiceTrackingFace3(const CvTrackingRect* tr_face, CvTrackingRect* new_face, int& new_energy)
-
-inline int GetEnergy(CvTrackingRect** ppNew, const CvTrackingRect* pPrev, CvPoint* ptTempl, CvRect* rTempl)
-{
-    int energy = 0;
-    CvPoint ptNew[NUM_FACE_ELEMENTS];
-    CvPoint ptPrev[NUM_FACE_ELEMENTS];
-    for (int i = 0; i < NUM_FACE_ELEMENTS; i++)
-    {
-        ptNew[i] = ppNew[i]->ptCenter;
-        ptPrev[i] = pPrev[i].ptCenter;
-        energy += ppNew[i]->iEnergy - 2 * ppNew[i]->nRectsInThis;
-    }
-    double dx = 0, dy = 0, scale = 1, rotate = 0;
-    double e_templ = CalculateTransformationLMS3(ptTempl, ptNew, &scale, &rotate, &dx, &dy);
-    double e_prev = CalculateTransformationLMS3_0(ptPrev, ptNew);
-    double w_eye = double(ppNew[LEYE]->r.width + ppNew[REYE]->r.width) * scale / 2.0;
-    double h_eye = double(ppNew[LEYE]->r.height + ppNew[REYE]->r.height) * scale / 2.0;
-    double w_mouth = double(ppNew[MOUTH]->r.width) * scale;
-    double h_mouth = double(ppNew[MOUTH]->r.height) * scale;
-    energy +=
-        int(512.0 * (e_prev + 16.0 * e_templ)) +
-        4 * pow2(ppNew[LEYE]->r.width - ppNew[REYE]->r.width) +
-        4 * pow2(ppNew[LEYE]->r.height - ppNew[REYE]->r.height) +
-        4 * (int)pow(w_eye - double(rTempl[LEYE].width + rTempl[REYE].width) / 2.0, 2) +
-        2 * (int)pow(h_eye - double(rTempl[LEYE].height + rTempl[REYE].height) / 2.0, 2) +
-        1 * (int)pow(w_mouth - double(rTempl[MOUTH].width), 2) +
-        1 * (int)pow(h_mouth - double(rTempl[MOUTH].height), 2) +
-        0;
-    return energy;
-}
-
-inline int GetEnergy2(CvTrackingRect** ppNew, const CvTrackingRect* pPrev, CvPoint* ptTempl, CvRect* rTempl, int* element)
-{
-    CvPoint new_v(ppNew[element[0]]->ptCenter.x - ppNew[element[1]]->ptCenter.x,
-        ppNew[element[0]]->ptCenter.y - ppNew[element[1]]->ptCenter.y);
-    CvPoint prev_v(pPrev[element[0]].ptCenter.x - pPrev[element[1]].ptCenter.x,
-        pPrev[element[0]].ptCenter.y - pPrev[element[1]].ptCenter.y);
-    double new_d = sqrt((double)new_v.x*new_v.x + new_v.y*new_v.y);
-    double prev_d = sqrt((double)prev_v.x*prev_v.x + prev_v.y*prev_v.y);
-    double dx = ptTempl[element[0]].x - ptTempl[element[1]].x;
-    double dy = ptTempl[element[0]].y - ptTempl[element[1]].y;
-    double templ_d = sqrt(dx*dx + dy*dy);
-    double scale_templ = new_d / templ_d;
-    double w0 = (double)ppNew[element[0]]->r.width * scale_templ;
-    double h0 = (double)ppNew[element[0]]->r.height * scale_templ;
-    double w1 = (double)ppNew[element[1]]->r.width * scale_templ;
-    double h1 = (double)ppNew[element[1]]->r.height * scale_templ;
-
-    int energy = ppNew[element[0]]->iEnergy + ppNew[element[1]]->iEnergy +
-        - 2 * (ppNew[element[0]]->nRectsInThis - ppNew[element[1]]->nRectsInThis) +
-        (int)pow(w0 - (double)rTempl[element[0]].width, 2) +
-        (int)pow(h0 - (double)rTempl[element[0]].height, 2) +
-        (int)pow(w1 - (double)rTempl[element[1]].width, 2) +
-        (int)pow(h1 - (double)rTempl[element[1]].height, 2) +
-        (int)pow(new_d - prev_d, 2) +
-        0;
-
-    return energy;
-}
-
-inline double CalculateTransformationLMS3( CvPoint* pTemplPoints,
-                                   CvPoint* pSrcPoints,
-                                   double*       pdbAverageScale,
-                                   double*       pdbAverageRotate,
-                                   double*       pdbAverageShiftX,
-                                   double*       pdbAverageShiftY )
-{
-//    double WS = 0;
-    double dbAverageScale = 1;
-    double dbAverageRotate = 0;
-    double dbAverageShiftX = 0;
-    double dbAverageShiftY = 0;
-    double dbLMS = 0;
-
-    assert( NULL != pTemplPoints);
-    assert( NULL != pSrcPoints);
-
-    double dbXt = double(pTemplPoints[0].x + pTemplPoints[1].x + pTemplPoints[2].x) / 3.0;
-    double dbYt = double(pTemplPoints[0].y + pTemplPoints[1].y + pTemplPoints[2].y ) / 3.0;
-    double dbXs = double(pSrcPoints[0].x + pSrcPoints[1].x + pSrcPoints[2].x) / 3.0;
-    double dbYs = double(pSrcPoints[0].y + pSrcPoints[1].y + pSrcPoints[2].y) / 3.0;
-
-    double dbXtXt = double(pow2(pTemplPoints[0].x) + pow2(pTemplPoints[1].x) + pow2(pTemplPoints[2].x)) / 3.0;
-    double dbYtYt = double(pow2(pTemplPoints[0].y) + pow2(pTemplPoints[1].y) + pow2(pTemplPoints[2].y)) / 3.0;
-
-    double dbXsXs = double(pow2(pSrcPoints[0].x) + pow2(pSrcPoints[1].x) + pow2(pSrcPoints[2].x)) / 3.0;
-    double dbYsYs = double(pow2(pSrcPoints[0].y) + pow2(pSrcPoints[1].y) + pow2(pSrcPoints[2].y)) / 3.0;
-
-    double dbXtXs = double(pTemplPoints[0].x * pSrcPoints[0].x +
-        pTemplPoints[1].x * pSrcPoints[1].x +
-        pTemplPoints[2].x * pSrcPoints[2].x) / 3.0;
-    double dbYtYs = double(pTemplPoints[0].y * pSrcPoints[0].y +
-        pTemplPoints[1].y * pSrcPoints[1].y +
-        pTemplPoints[2].y * pSrcPoints[2].y) / 3.0;
-
-    double dbXtYs = double(pTemplPoints[0].x * pSrcPoints[0].y +
-        pTemplPoints[1].x * pSrcPoints[1].y +
-        pTemplPoints[2].x * pSrcPoints[2].y) / 3.0;
-    double dbYtXs = double(pTemplPoints[0].y * pSrcPoints[0].x +
-        pTemplPoints[1].y * pSrcPoints[1].x +
-        pTemplPoints[2].y * pSrcPoints[2].x ) / 3.0;
-
-    dbXtXt -= dbXt * dbXt;
-    dbYtYt -= dbYt * dbYt;
-
-    dbXsXs -= dbXs * dbXs;
-    dbYsYs -= dbYs * dbYs;
-
-    dbXtXs -= dbXt * dbXs;
-    dbYtYs -= dbYt * dbYs;
-
-    dbXtYs -= dbXt * dbYs;
-    dbYtXs -= dbYt * dbXs;
-
-    dbAverageRotate = atan2( dbXtYs - dbYtXs, dbXtXs + dbYtYs );
-
-    double cosR = cos(dbAverageRotate);
-    double sinR = sin(dbAverageRotate);
-    double del = dbXsXs + dbYsYs;
-    if( del != 0 )
-    {
-        dbAverageScale = (double(dbXtXs + dbYtYs) * cosR + double(dbXtYs - dbYtXs) * sinR) / del;
-        dbLMS = dbXtXt + dbYtYt - ((double)pow(dbXtXs + dbYtYs,2) + (double)pow(dbXtYs - dbYtXs,2)) / del;
-    }
-
-    dbAverageShiftX = double(dbXt) - dbAverageScale * (double(dbXs) * cosR + double(dbYs) * sinR);
-    dbAverageShiftY = double(dbYt) - dbAverageScale * (double(dbYs) * cosR - double(dbXs) * sinR);
-
-    if( pdbAverageScale != NULL ) *pdbAverageScale = dbAverageScale;
-    if( pdbAverageRotate != NULL ) *pdbAverageRotate = dbAverageRotate;
-    if( pdbAverageShiftX != NULL ) *pdbAverageShiftX = dbAverageShiftX;
-    if( pdbAverageShiftY != NULL ) *pdbAverageShiftY = dbAverageShiftY;
-
-    assert(dbLMS >= 0);
-    return dbLMS;
-}
-
-inline double CalculateTransformationLMS3_0( CvPoint* pTemplPoints, CvPoint* pSrcPoints)
-{
-    double dbLMS = 0;
-
-    assert( NULL != pTemplPoints);
-    assert( NULL != pSrcPoints);
-
-    double dbXt = double(pTemplPoints[0].x + pTemplPoints[1].x + pTemplPoints[2].x) / 3.0;
-    double dbYt = double(pTemplPoints[0].y + pTemplPoints[1].y + pTemplPoints[2].y ) / 3.0;
-    double dbXs = double(pSrcPoints[0].x + pSrcPoints[1].x + pSrcPoints[2].x) / 3.0;
-    double dbYs = double(pSrcPoints[0].y + pSrcPoints[1].y + pSrcPoints[2].y) / 3.0;
-
-    double dbXtXt = double(pow2(pTemplPoints[0].x) + pow2(pTemplPoints[1].x) + pow2(pTemplPoints[2].x)) / 3.0;
-    double dbYtYt = double(pow2(pTemplPoints[0].y) + pow2(pTemplPoints[1].y) + pow2(pTemplPoints[2].y)) / 3.0;
-
-    double dbXsXs = double(pow2(pSrcPoints[0].x) + pow2(pSrcPoints[1].x) + pow2(pSrcPoints[2].x)) / 3.0;
-    double dbYsYs = double(pow2(pSrcPoints[0].y) + pow2(pSrcPoints[1].y) + pow2(pSrcPoints[2].y)) / 3.0;
-
-    double dbXtXs = double(pTemplPoints[0].x * pSrcPoints[0].x +
-        pTemplPoints[1].x * pSrcPoints[1].x +
-        pTemplPoints[2].x * pSrcPoints[2].x) / 3.0;
-    double dbYtYs = double(pTemplPoints[0].y * pSrcPoints[0].y +
-        pTemplPoints[1].y * pSrcPoints[1].y +
-        pTemplPoints[2].y * pSrcPoints[2].y) / 3.0;
-
-    double dbXtYs = double(pTemplPoints[0].x * pSrcPoints[0].y +
-        pTemplPoints[1].x * pSrcPoints[1].y +
-        pTemplPoints[2].x * pSrcPoints[2].y) / 3.0;
-    double dbYtXs = double(pTemplPoints[0].y * pSrcPoints[0].x +
-        pTemplPoints[1].y * pSrcPoints[1].x +
-        pTemplPoints[2].y * pSrcPoints[2].x ) / 3.0;
-
-    dbXtXt -= dbXt * dbXt;
-    dbYtYt -= dbYt * dbYt;
-
-    dbXsXs -= dbXs * dbXs;
-    dbYsYs -= dbYs * dbYs;
-
-    dbXtXs -= dbXt * dbXs;
-    dbYtYs -= dbYt * dbYs;
-
-    dbXtYs -= dbXt * dbYs;
-    dbYtXs -= dbYt * dbXs;
-
-    double del = dbXsXs + dbYsYs;
-    if( del != 0 )
-        dbLMS = dbXtXt + dbYtYt - ((double)pow(dbXtXs + dbYtYs,2) + (double)pow(dbXtYs - dbYtXs,2)) / del;
-    return dbLMS;
-}
diff --git a/modules/legacy/src/video.cpp b/modules/legacy/src/video.cpp
deleted file mode 100644 (file)
index f0bb6bc..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-CV_IMPL void
-cvDeInterlace( const CvArr* framearr, CvArr* fieldEven, CvArr* fieldOdd )
-{
-    CV_FUNCNAME("cvDeInterlace");
-
-    __BEGIN__;
-
-    CvMat frame_stub, *frame = (CvMat*)framearr;
-    CvMat even_stub, *even = (CvMat*)fieldEven;
-    CvMat odd_stub, *odd = (CvMat*)fieldOdd;
-    CvSize size;
-    int y;
-
-    CV_CALL( frame = cvGetMat( frame, &frame_stub ));
-    CV_CALL( even = cvGetMat( even, &even_stub ));
-    CV_CALL( odd = cvGetMat( odd, &odd_stub ));
-
-    if( !CV_ARE_TYPES_EQ( frame, even ) || !CV_ARE_TYPES_EQ( frame, odd ))
-        CV_ERROR( CV_StsUnmatchedFormats, "All the input images must have the same type" );
-
-    if( frame->cols != even->cols || frame->cols != odd->cols ||
-        frame->rows != even->rows*2 || odd->rows != even->rows )
-        CV_ERROR( CV_StsUnmatchedSizes, "Uncorrelated sizes of the input image and output fields" );
-
-    size = cvGetMatSize( even );
-    size.width *= CV_ELEM_SIZE( even->type );
-
-    for( y = 0; y < size.height; y++ )
-    {
-        memcpy( even->data.ptr + even->step*y,
-                frame->data.ptr + frame->step*y*2, size.width );
-        memcpy( odd->data.ptr + even->step*y,
-                frame->data.ptr + frame->step*(y*2+1), size.width );
-    }
-
-    __END__;
-}
-
-/* End of file. */
diff --git a/modules/legacy/test/test_bruteforcematcher.cpp b/modules/legacy/test/test_bruteforcematcher.cpp
deleted file mode 100644 (file)
index 3259563..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-#include "test_precomp.hpp"
-
-using namespace std;
-using namespace cv;
-
-struct CV_EXPORTS L2Fake : public L2<float>
-{
-    enum { normType = NORM_L2 };
-};
-
-class CV_BruteForceMatcherTest : public cvtest::BaseTest
-{
-public:
-    CV_BruteForceMatcherTest() {}
-protected:
-    void run( int )
-    {
-        const int dimensions = 64;
-        const int descriptorsNumber = 5000;
-
-        Mat train = Mat( descriptorsNumber, dimensions, CV_32FC1);
-        Mat query = Mat( descriptorsNumber, dimensions, CV_32FC1);
-
-        Mat permutation( 1, descriptorsNumber, CV_32SC1 );
-        for( int i=0;i<descriptorsNumber;i++ )
-            permutation.at<int>( 0, i ) = i;
-
-        //RNG rng = RNG( cvGetTickCount() );
-        RNG rng;
-        randShuffle( permutation, 1, &rng );
-
-        float boundary =  500.f;
-        for( int row=0;row<descriptorsNumber;row++ )
-        {
-            for( int col=0;col<dimensions;col++ )
-            {
-                int bit = rng( 2 );
-                train.at<float>( permutation.at<int>( 0, row ), col ) = bit*boundary + rng.uniform( 0.f, boundary );
-                query.at<float>( row, col ) = bit*boundary + rng.uniform( 0.f, boundary );
-            }
-        }
-
-        vector<DMatch> specMatches, genericMatches;
-        BruteForceMatcher<L2<float> > specMatcher;
-        BruteForceMatcher<L2Fake > genericMatcher;
-
-        int64 time0 = cvGetTickCount();
-        specMatcher.match( query, train, specMatches );
-        int64 time1 = cvGetTickCount();
-        genericMatcher.match( query, train, genericMatches );
-        int64 time2 = cvGetTickCount();
-
-        float specMatcherTime = float(time1 - time0)/(float)cvGetTickFrequency();
-        ts->printf( cvtest::TS::LOG, "Matching by matrix multiplication time s: %f, us per pair: %f\n",
-                   specMatcherTime*1e-6, specMatcherTime/( descriptorsNumber*descriptorsNumber ) );
-
-        float genericMatcherTime = float(time2 - time1)/(float)cvGetTickFrequency();
-        ts->printf( cvtest::TS::LOG, "Matching without matrix multiplication time s: %f, us per pair: %f\n",
-                   genericMatcherTime*1e-6, genericMatcherTime/( descriptorsNumber*descriptorsNumber ) );
-
-        if( (int)specMatches.size() != descriptorsNumber || (int)genericMatches.size() != descriptorsNumber )
-            ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );
-        for( int i=0;i<descriptorsNumber;i++ )
-        {
-            float epsilon = 0.01f;
-            bool isEquiv = fabs( specMatches[i].distance - genericMatches[i].distance ) < epsilon &&
-                           specMatches[i].queryIdx == genericMatches[i].queryIdx &&
-                           specMatches[i].trainIdx == genericMatches[i].trainIdx;
-            if( !isEquiv || specMatches[i].trainIdx != permutation.at<int>( 0, i ) )
-            {
-                ts->set_failed_test_info( cvtest::TS::FAIL_MISMATCH );
-                break;
-            }
-        }
-
-
-        //Test mask
-        Mat mask( query.rows, train.rows, CV_8UC1 );
-        rng.fill( mask, RNG::UNIFORM, 0, 2 );
-
-
-        time0 = cvGetTickCount();
-        specMatcher.match( query, train, specMatches, mask );
-        time1 = cvGetTickCount();
-        genericMatcher.match( query, train, genericMatches, mask );
-        time2 = cvGetTickCount();
-
-        specMatcherTime = float(time1 - time0)/(float)cvGetTickFrequency();
-        ts->printf( cvtest::TS::LOG, "Matching by matrix multiplication time with mask s: %f, us per pair: %f\n",
-                   specMatcherTime*1e-6, specMatcherTime/( descriptorsNumber*descriptorsNumber ) );
-
-        genericMatcherTime = float(time2 - time1)/(float)cvGetTickFrequency();
-        ts->printf( cvtest::TS::LOG, "Matching without matrix multiplication time with mask s: %f, us per pair: %f\n",
-                   genericMatcherTime*1e-6, genericMatcherTime/( descriptorsNumber*descriptorsNumber ) );
-
-        if( specMatches.size() != genericMatches.size() )
-            ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );
-
-        for( size_t i=0;i<specMatches.size();i++ )
-        {
-            //float epsilon = 1e-2;
-            float epsilon = 10000000;
-            bool isEquiv = fabs( specMatches[i].distance - genericMatches[i].distance ) < epsilon &&
-                           specMatches[i].queryIdx == genericMatches[i].queryIdx &&
-                           specMatches[i].trainIdx == genericMatches[i].trainIdx;
-            if( !isEquiv )
-            {
-                ts->set_failed_test_info( cvtest::TS::FAIL_MISMATCH );
-                break;
-            }
-        }
-    }
-};
-
-TEST(Legacy_BruteForceMatcher, accuracy) { CV_BruteForceMatcherTest test; test.safe_run(); }
diff --git a/modules/legacy/test/test_em.cpp b/modules/legacy/test/test_em.cpp
deleted file mode 100644 (file)
index c03a9e4..0000000
+++ /dev/null
@@ -1,450 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-using namespace std;
-using namespace cv;
-
-static
-void defaultDistribs( Mat& means, vector<Mat>& covs, int type=CV_32FC1 )
-{
-    float mp0[] = {0.0f, 0.0f}, cp0[] = {0.67f, 0.0f, 0.0f, 0.67f};
-    float mp1[] = {5.0f, 0.0f}, cp1[] = {1.0f, 0.0f, 0.0f, 1.0f};
-    float mp2[] = {1.0f, 5.0f}, cp2[] = {1.0f, 0.0f, 0.0f, 1.0f};
-    means.create(3, 2, type);
-    Mat m0( 1, 2, CV_32FC1, mp0 ), c0( 2, 2, CV_32FC1, cp0 );
-    Mat m1( 1, 2, CV_32FC1, mp1 ), c1( 2, 2, CV_32FC1, cp1 );
-    Mat m2( 1, 2, CV_32FC1, mp2 ), c2( 2, 2, CV_32FC1, cp2 );
-    means.resize(3), covs.resize(3);
-
-    Mat mr0 = means.row(0);
-    m0.convertTo(mr0, type);
-    c0.convertTo(covs[0], type);
-
-    Mat mr1 = means.row(1);
-    m1.convertTo(mr1, type);
-    c1.convertTo(covs[1], type);
-
-    Mat mr2 = means.row(2);
-    m2.convertTo(mr2, type);
-    c2.convertTo(covs[2], type);
-}
-
-// generate points sets by normal distributions
-static
-void generateData( Mat& data, Mat& labels, const vector<int>& sizes, const Mat& _means, const vector<Mat>& covs, int dataType, int labelType )
-{
-    vector<int>::const_iterator sit = sizes.begin();
-    int total = 0;
-    for( ; sit != sizes.end(); ++sit )
-        total += *sit;
-    CV_Assert( _means.rows == (int)sizes.size() && covs.size() == sizes.size() );
-    CV_Assert( !data.empty() && data.rows == total );
-    CV_Assert( data.type() == dataType );
-
-    labels.create( data.rows, 1, labelType );
-
-    randn( data, Scalar::all(-1.0), Scalar::all(1.0) );
-    vector<Mat> means(sizes.size());
-    for(int i = 0; i < _means.rows; i++)
-        means[i] = _means.row(i);
-    vector<Mat>::const_iterator mit = means.begin(), cit = covs.begin();
-    int bi, ei = 0;
-    sit = sizes.begin();
-    for( int p = 0, l = 0; sit != sizes.end(); ++sit, ++mit, ++cit, l++ )
-    {
-        bi = ei;
-        ei = bi + *sit;
-        assert( mit->rows == 1 && mit->cols == data.cols );
-        assert( cit->rows == data.cols && cit->cols == data.cols );
-        for( int i = bi; i < ei; i++, p++ )
-        {
-            Mat r = data.row(i);
-            r =  r * (*cit) + *mit;
-            if( labelType == CV_32FC1 )
-                labels.at<float>(p, 0) = (float)l;
-            else if( labelType == CV_32SC1 )
-                labels.at<int>(p, 0) = l;
-            else
-            {
-                CV_DbgAssert(0);
-            }
-        }
-    }
-}
-
-static
-int maxIdx( const vector<int>& count )
-{
-    int idx = -1;
-    int maxVal = -1;
-    vector<int>::const_iterator it = count.begin();
-    for( int i = 0; it != count.end(); ++it, i++ )
-    {
-        if( *it > maxVal)
-        {
-            maxVal = *it;
-            idx = i;
-        }
-    }
-    assert( idx >= 0);
-    return idx;
-}
-
-static
-bool getLabelsMap( const Mat& labels, const vector<int>& sizes, vector<int>& labelsMap, bool checkClusterUniq=true )
-{
-    size_t total = 0, nclusters = sizes.size();
-    for(size_t i = 0; i < sizes.size(); i++)
-        total += sizes[i];
-
-    assert( !labels.empty() );
-    assert( labels.total() == total && (labels.cols == 1 || labels.rows == 1));
-    assert( labels.type() == CV_32SC1 || labels.type() == CV_32FC1 );
-
-    bool isFlt = labels.type() == CV_32FC1;
-
-    labelsMap.resize(nclusters);
-
-    vector<bool> buzy(nclusters, false);
-    int startIndex = 0;
-    for( size_t clusterIndex = 0; clusterIndex < sizes.size(); clusterIndex++ )
-    {
-        vector<int> count( nclusters, 0 );
-        for( int i = startIndex; i < startIndex + sizes[clusterIndex]; i++)
-        {
-            int lbl = isFlt ? (int)labels.at<float>(i) : labels.at<int>(i);
-            CV_Assert(lbl < (int)nclusters);
-            count[lbl]++;
-            CV_Assert(count[lbl] < (int)total);
-        }
-        startIndex += sizes[clusterIndex];
-
-        int cls = maxIdx( count );
-        CV_Assert( !checkClusterUniq || !buzy[cls] );
-
-        labelsMap[clusterIndex] = cls;
-
-        buzy[cls] = true;
-    }
-
-    if(checkClusterUniq)
-    {
-        for(size_t i = 0; i < buzy.size(); i++)
-            if(!buzy[i])
-                return false;
-    }
-
-    return true;
-}
-
-static
-bool calcErr( const Mat& labels, const Mat& origLabels, const vector<int>& sizes, float& err, bool labelsEquivalent, bool checkClusterUniq )
-{
-    err = 0;
-    CV_Assert( !labels.empty() && !origLabels.empty() );
-    CV_Assert( labels.rows == 1 || labels.cols == 1 );
-    CV_Assert( origLabels.rows == 1 || origLabels.cols == 1 );
-    CV_Assert( labels.total() == origLabels.total() );
-    CV_Assert( labels.type() == CV_32SC1 || labels.type() == CV_32FC1 );
-    CV_Assert( origLabels.type() == labels.type() );
-
-    vector<int> labelsMap;
-    bool isFlt = labels.type() == CV_32FC1;
-    if( !labelsEquivalent )
-    {
-        if( !getLabelsMap( labels, sizes, labelsMap, checkClusterUniq ) )
-            return false;
-
-        for( int i = 0; i < labels.rows; i++ )
-            if( isFlt )
-                err += labels.at<float>(i) != labelsMap[(int)origLabels.at<float>(i)] ? 1.f : 0.f;
-            else
-                err += labels.at<int>(i) != labelsMap[origLabels.at<int>(i)] ? 1.f : 0.f;
-    }
-    else
-    {
-        for( int i = 0; i < labels.rows; i++ )
-            if( isFlt )
-                err += labels.at<float>(i) != origLabels.at<float>(i) ? 1.f : 0.f;
-            else
-                err += labels.at<int>(i) != origLabels.at<int>(i) ? 1.f : 0.f;
-    }
-    err /= (float)labels.rows;
-    return true;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-class CV_CvEMTest : public cvtest::BaseTest
-{
-public:
-    CV_CvEMTest() {}
-protected:
-    virtual void run( int start_from );
-    int runCase( int caseIndex, const CvEMParams& params,
-                  const cv::Mat& trainData, const cv::Mat& trainLabels,
-                  const cv::Mat& testData, const cv::Mat& testLabels,
-                  const vector<int>& sizes);
-};
-
-int CV_CvEMTest::runCase( int caseIndex, const CvEMParams& params,
-                        const cv::Mat& trainData, const cv::Mat& trainLabels,
-                        const cv::Mat& testData, const cv::Mat& testLabels,
-                        const vector<int>& sizes )
-{
-    int code = cvtest::TS::OK;
-
-    cv::Mat labels;
-    float err;
-
-    CvEM em;
-    em.train( trainData, Mat(), params, &labels );
-
-    // check train error
-    if( !calcErr( labels, trainLabels, sizes, err , false, false ) )
-    {
-        ts->printf( cvtest::TS::LOG, "Case index %i : Bad output labels.\n", caseIndex );
-        code = cvtest::TS::FAIL_INVALID_OUTPUT;
-    }
-    else if( err > 0.006f )
-    {
-        ts->printf( cvtest::TS::LOG, "Case index %i : Bad accuracy (%f) on train data.\n", caseIndex, err );
-        code = cvtest::TS::FAIL_BAD_ACCURACY;
-    }
-
-    // check test error
-    labels.create( testData.rows, 1, CV_32SC1 );
-    for( int i = 0; i < testData.rows; i++ )
-    {
-        Mat sample = testData.row(i);
-        labels.at<int>(i,0) = (int)em.predict( sample, 0 );
-    }
-    if( !calcErr( labels, testLabels, sizes, err, false, false ) )
-    {
-        ts->printf( cvtest::TS::LOG, "Case index %i : Bad output labels.\n", caseIndex );
-        code = cvtest::TS::FAIL_INVALID_OUTPUT;
-    }
-    else if( err > 0.006f )
-    {
-        ts->printf( cvtest::TS::LOG, "Case index %i : Bad accuracy (%f) on test data.\n", caseIndex, err );
-        code = cvtest::TS::FAIL_BAD_ACCURACY;
-    }
-
-    return code;
-}
-
-void CV_CvEMTest::run( int /*start_from*/ )
-{
-    int sizesArr[] = { 500, 700, 800 };
-    int pointsCount = sizesArr[0]+ sizesArr[1] + sizesArr[2];
-
-    // Points distribution
-    Mat means;
-    vector<Mat> covs;
-    defaultDistribs( means, covs );
-
-    // train data
-    Mat trainData( pointsCount, 2, CV_32FC1 ), trainLabels;
-    vector<int> sizes( sizesArr, sizesArr + sizeof(sizesArr) / sizeof(sizesArr[0]) );
-    generateData( trainData, trainLabels, sizes, means, covs, CV_32FC1, CV_32SC1 );
-
-    // test data
-    Mat testData( pointsCount, 2, CV_32FC1 ), testLabels;
-    generateData( testData, testLabels, sizes, means, covs, CV_32FC1, CV_32SC1 );
-
-    CvEMParams params;
-    params.nclusters = 3;
-    Mat probs(trainData.rows, params.nclusters, CV_32FC1, cv::Scalar(1));
-    CvMat probsHdr = probs;
-    params.probs = &probsHdr;
-    Mat weights(1, params.nclusters, CV_32FC1, cv::Scalar(1));
-    CvMat weightsHdr = weights;
-    params.weights = &weightsHdr;
-    CvMat meansHdr = means;
-    params.means = &meansHdr;
-    std::vector<CvMat> covsHdrs(params.nclusters);
-    std::vector<const CvMat*> covsPtrs(params.nclusters);
-    for(int i = 0; i < params.nclusters; i++)
-    {
-        covsHdrs[i] = covs[i];
-        covsPtrs[i] = &covsHdrs[i];
-    }
-    params.covs = &covsPtrs[0];
-
-    int code = cvtest::TS::OK;
-    int caseIndex = 0;
-    {
-        params.start_step = cv::EM::START_AUTO_STEP;
-        params.cov_mat_type = cv::EM::COV_MAT_GENERIC;
-        int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
-        code = currCode == cvtest::TS::OK ? code : currCode;
-    }
-    {
-        params.start_step = cv::EM::START_AUTO_STEP;
-        params.cov_mat_type = cv::EM::COV_MAT_DIAGONAL;
-        int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
-        code = currCode == cvtest::TS::OK ? code : currCode;
-    }
-    {
-        params.start_step = cv::EM::START_AUTO_STEP;
-        params.cov_mat_type = cv::EM::COV_MAT_SPHERICAL;
-        int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
-        code = currCode == cvtest::TS::OK ? code : currCode;
-    }
-    {
-        params.start_step = cv::EM::START_M_STEP;
-        params.cov_mat_type = cv::EM::COV_MAT_GENERIC;
-        int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
-        code = currCode == cvtest::TS::OK ? code : currCode;
-    }
-    {
-        params.start_step = cv::EM::START_M_STEP;
-        params.cov_mat_type = cv::EM::COV_MAT_DIAGONAL;
-        int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
-        code = currCode == cvtest::TS::OK ? code : currCode;
-    }
-    {
-        params.start_step = cv::EM::START_M_STEP;
-        params.cov_mat_type = cv::EM::COV_MAT_SPHERICAL;
-        int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
-        code = currCode == cvtest::TS::OK ? code : currCode;
-    }
-    {
-        params.start_step = cv::EM::START_E_STEP;
-        params.cov_mat_type = cv::EM::COV_MAT_GENERIC;
-        int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
-        code = currCode == cvtest::TS::OK ? code : currCode;
-    }
-    {
-        params.start_step = cv::EM::START_E_STEP;
-        params.cov_mat_type = cv::EM::COV_MAT_DIAGONAL;
-        int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
-        code = currCode == cvtest::TS::OK ? code : currCode;
-    }
-    {
-        params.start_step = cv::EM::START_E_STEP;
-        params.cov_mat_type = cv::EM::COV_MAT_SPHERICAL;
-        int currCode = runCase(caseIndex++, params, trainData, trainLabels, testData, testLabels, sizes);
-        code = currCode == cvtest::TS::OK ? code : currCode;
-    }
-
-    ts->set_failed_test_info( code );
-}
-
-class CV_CvEMTest_SaveLoad : public cvtest::BaseTest {
-public:
-    CV_CvEMTest_SaveLoad() {}
-protected:
-    virtual void run( int /*start_from*/ )
-    {
-        int code = cvtest::TS::OK;
-
-        Mat samples = Mat(3,1,CV_32F);
-        samples.at<float>(0,0) = 1;
-        samples.at<float>(1,0) = 2;
-        samples.at<float>(2,0) = 3;
-
-        Mat labels(samples.rows, 1, CV_32S);
-
-        CvEMParams params;
-        params.nclusters = 2;
-
-        CvMat samples_c = samples, labels_c = labels;
-
-        CvEM em(&samples_c, 0, params, &labels_c);
-
-        Mat firstResult(samples.rows, 1, CV_32FC1);
-        for( int i = 0; i < samples.rows; i++)
-            firstResult.at<float>(i) = em.predict( samples.row(i) );
-
-        // Write out
-
-        string filename = cv::tempfile(".xml");
-        {
-            FileStorage fs = FileStorage(filename, FileStorage::WRITE);
-            try
-            {
-                em.write(fs.fs, "em");
-            }
-            catch(...)
-            {
-                ts->printf( cvtest::TS::LOG, "Crash in write method.\n" );
-                ts->set_failed_test_info( cvtest::TS::FAIL_EXCEPTION );
-            }
-        }
-
-        em.clear();
-
-        // Read in
-        {
-            FileStorage fs = FileStorage(filename, FileStorage::READ);
-            CV_Assert(fs.isOpened());
-            FileNode fn = fs["em"];
-            try
-            {
-                em.read(fs.fs, (CvFileNode*)fn.node);
-            }
-            catch(...)
-            {
-                ts->printf( cvtest::TS::LOG, "Crash in read method.\n" );
-                ts->set_failed_test_info( cvtest::TS::FAIL_EXCEPTION );
-            }
-        }
-
-        remove( filename.c_str() );
-
-        int errCaseCount = 0;
-        for( int i = 0; i < samples.rows; i++)
-            errCaseCount = std::abs(em.predict(samples.row(i)) - firstResult.at<float>(i)) < FLT_EPSILON ? 0 : 1;
-
-        if( errCaseCount > 0 )
-        {
-            ts->printf( cvtest::TS::LOG, "Different prediction results before writeing and after reading (errCaseCount=%d).\n", errCaseCount );
-            code = cvtest::TS::FAIL_BAD_ACCURACY;
-        }
-
-        ts->set_failed_test_info( code );
-    }
-};
-
-TEST(Legacy_CvEM, accuracy) { CV_CvEMTest test; test.safe_run(); }
-TEST(Legacy_CvEM, save_load) { CV_CvEMTest_SaveLoad test; test.safe_run(); }
diff --git a/modules/legacy/test/test_main.cpp b/modules/legacy/test/test_main.cpp
deleted file mode 100644 (file)
index 6b24993..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "test_precomp.hpp"
-
-CV_TEST_MAIN("cv")
diff --git a/modules/legacy/test/test_nearestneighbors.cpp b/modules/legacy/test/test_nearestneighbors.cpp
deleted file mode 100644 (file)
index 1f0b972..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-#include <algorithm>
-#include <vector>
-#include <iostream>
-
-using namespace cv;
-using namespace cv::flann;
-
-//--------------------------------------------------------------------------------
-class NearestNeighborTest : public cvtest::BaseTest
-{
-public:
-    NearestNeighborTest() {}
-protected:
-    static const int minValue = 0;
-    static const int maxValue = 1;
-    static const int dims = 30;
-    static const int featuresCount = 2000;
-    static const int K = 1; // * should also test 2nd nn etc.?
-
-
-    virtual void run( int start_from );
-    virtual void createModel( const Mat& data ) = 0;
-    virtual int findNeighbors( Mat& points, Mat& neighbors ) = 0;
-    virtual int checkGetPoins( const Mat& data );
-    virtual int checkFindBoxed();
-    virtual int checkFind( const Mat& data );
-    virtual void releaseModel() = 0;
-};
-
-int NearestNeighborTest::checkGetPoins( const Mat& )
-{
-   return cvtest::TS::OK;
-}
-
-int NearestNeighborTest::checkFindBoxed()
-{
-    return cvtest::TS::OK;
-}
-
-int NearestNeighborTest::checkFind( const Mat& data )
-{
-    int code = cvtest::TS::OK;
-    int pointsCount = 1000;
-    float noise = 0.2f;
-
-    RNG rng;
-    Mat points( pointsCount, dims, CV_32FC1 );
-    Mat results( pointsCount, K, CV_32SC1 );
-
-    std::vector<int> fmap( pointsCount );
-    for( int pi = 0; pi < pointsCount; pi++ )
-    {
-        int fi = rng.next() % featuresCount;
-        fmap[pi] = fi;
-        for( int d = 0; d < dims; d++ )
-            points.at<float>(pi, d) = data.at<float>(fi, d) + rng.uniform(0.0f, 1.0f) * noise;
-    }
-
-    code = findNeighbors( points, results );
-
-    if( code == cvtest::TS::OK )
-    {
-        int correctMatches = 0;
-        for( int pi = 0; pi < pointsCount; pi++ )
-        {
-            if( fmap[pi] == results.at<int>(pi, 0) )
-                correctMatches++;
-        }
-
-        double correctPerc = correctMatches / (double)pointsCount;
-        if (correctPerc < .75)
-        {
-            ts->printf( cvtest::TS::LOG, "correct_perc = %d\n", correctPerc );
-            code = cvtest::TS::FAIL_BAD_ACCURACY;
-        }
-    }
-
-    return code;
-}
-
-void NearestNeighborTest::run( int /*start_from*/ ) {
-    int code = cvtest::TS::OK, tempCode;
-    Mat desc( featuresCount, dims, CV_32FC1 );
-    randu( desc, Scalar(minValue), Scalar(maxValue) );
-
-    createModel( desc );
-
-    tempCode = checkGetPoins( desc );
-    if( tempCode != cvtest::TS::OK )
-    {
-        ts->printf( cvtest::TS::LOG, "bad accuracy of GetPoints \n" );
-        code = tempCode;
-    }
-
-    tempCode = checkFindBoxed();
-    if( tempCode != cvtest::TS::OK )
-    {
-        ts->printf( cvtest::TS::LOG, "bad accuracy of FindBoxed \n" );
-        code = tempCode;
-    }
-
-    tempCode = checkFind( desc );
-    if( tempCode != cvtest::TS::OK )
-    {
-        ts->printf( cvtest::TS::LOG, "bad accuracy of Find \n" );
-        code = tempCode;
-    }
-
-    releaseModel();
-
-    ts->set_failed_test_info( code );
-}
-
-//--------------------------------------------------------------------------------
-class CV_LSHTest : public NearestNeighborTest
-{
-public:
-    CV_LSHTest() {}
-protected:
-    virtual void createModel( const Mat& data );
-    virtual int findNeighbors( Mat& points, Mat& neighbors );
-    virtual void releaseModel();
-    struct CvLSH* lsh;
-    CvMat desc;
-};
-
-void CV_LSHTest::createModel( const Mat& data )
-{
-    desc = data;
-    lsh = cvCreateMemoryLSH( data.cols, data.rows, 70, 20, CV_32FC1 );
-    cvLSHAdd( lsh, &desc );
-}
-
-int CV_LSHTest::findNeighbors( Mat& points, Mat& neighbors )
-{
-    const int emax = 20;
-    Mat dist( points.rows, neighbors.cols, CV_64FC1);
-    CvMat _dist = dist, _points = points, _neighbors = neighbors;
-    cvLSHQuery( lsh, &_points, &_neighbors, &_dist, neighbors.cols, emax );
-    return cvtest::TS::OK;
-}
-
-void CV_LSHTest::releaseModel()
-{
-    cvReleaseLSH( &lsh );
-}
-
-//--------------------------------------------------------------------------------
-class CV_FeatureTreeTest_C : public NearestNeighborTest
-{
-public:
-    CV_FeatureTreeTest_C() {}
-protected:
-    virtual int findNeighbors( Mat& points, Mat& neighbors );
-    virtual void releaseModel();
-    CvFeatureTree* tr;
-    CvMat desc;
-};
-
-int CV_FeatureTreeTest_C::findNeighbors( Mat& points, Mat& neighbors )
-{
-    const int emax = 20;
-    Mat dist( points.rows, neighbors.cols, CV_64FC1);
-    CvMat _dist = dist, _points = points, _neighbors = neighbors;
-    cvFindFeatures( tr, &_points, &_neighbors, &_dist, neighbors.cols, emax );
-    return cvtest::TS::OK;
-}
-
-void CV_FeatureTreeTest_C::releaseModel()
-{
-    cvReleaseFeatureTree( tr );
-}
-
-//--------------------------------------
-class CV_SpillTreeTest_C : public CV_FeatureTreeTest_C
-{
-public:
-    CV_SpillTreeTest_C() {}
-protected:
-    virtual void createModel( const Mat& data );
-};
-
-void CV_SpillTreeTest_C::createModel( const Mat& data )
-{
-    desc = data;
-    tr = cvCreateSpillTree( &desc );
-}
-
-//--------------------------------------
-class CV_KDTreeTest_C : public CV_FeatureTreeTest_C
-{
-public:
-    CV_KDTreeTest_C() {}
-protected:
-    virtual void createModel( const Mat& data );
-    virtual int checkFindBoxed();
-};
-
-void CV_KDTreeTest_C::createModel( const Mat& data )
-{
-    desc = data;
-    tr = cvCreateKDTree( &desc );
-}
-
-int CV_KDTreeTest_C::checkFindBoxed()
-{
-    Mat min(1, dims, CV_32FC1 ), max(1, dims, CV_32FC1 ), indices( 1, 1, CV_32SC1 );
-    float l = minValue, r = maxValue;
-    min.setTo(Scalar(l)), max.setTo(Scalar(r));
-    CvMat _min = min, _max = max, _indices = indices;
-    // TODO check indices
-    if( cvFindFeaturesBoxed( tr, &_min, &_max, &_indices ) != featuresCount )
-        return cvtest::TS::FAIL_BAD_ACCURACY;
-    return cvtest::TS::OK;
-}
-
-
-TEST(Legacy_LSH, regression) { CV_LSHTest test; test.safe_run(); }
-TEST(Legacy_SpillTree, regression) { CV_SpillTreeTest_C test; test.safe_run(); }
-TEST(Legacy_KDTree_C, regression) { CV_KDTreeTest_C test; test.safe_run(); }
diff --git a/modules/legacy/test/test_optflow.cpp b/modules/legacy/test/test_optflow.cpp
deleted file mode 100644 (file)
index c5b35e9..0000000
+++ /dev/null
@@ -1,355 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-#include "opencv2/video/tracking.hpp"
-#include "opencv2/video/tracking_c.h"
-
-#include <string>
-#include <iostream>
-#include <fstream>
-#include <iterator>
-#include <limits>
-
-using namespace cv;
-using namespace std;
-
-class CV_OptFlowTest : public cvtest::BaseTest
-{
-public:
-    CV_OptFlowTest();
-    ~CV_OptFlowTest();
-protected:
-    void run(int);
-
-    bool runDense(const Point& shift = Point(3, 0));
-    bool runSparse();
-};
-
-CV_OptFlowTest::CV_OptFlowTest() {}
-CV_OptFlowTest::~CV_OptFlowTest() {}
-
-
-Mat copnvert2flow(const Mat& velx, const Mat& vely)
-{
-    Mat flow(velx.size(), CV_32FC2);
-    for(int y = 0 ; y < flow.rows; ++y)
-        for(int x = 0 ; x < flow.cols; ++x)
-            flow.at<Point2f>(y, x) = Point2f(velx.at<float>(y, x), vely.at<float>(y, x));
-    return flow;
-}
-
-void calcOpticalFlowLK( const Mat& prev, const Mat& curr, Size winSize, Mat& flow )
-{
-    Mat velx(prev.size(), CV_32F), vely(prev.size(), CV_32F);
-    CvMat cvvelx = velx;    CvMat cvvely = vely;
-    CvMat cvprev = prev;    CvMat cvcurr = curr;
-    cvCalcOpticalFlowLK( &cvprev, &cvcurr, winSize, &cvvelx, &cvvely );
-    flow = copnvert2flow(velx, vely);
-}
-
-void calcOpticalFlowBM( const Mat& prev, const Mat& curr, Size bSize, Size shiftSize, Size maxRange, int usePrevious, Mat& flow )
-{
-    Size sz((curr.cols - bSize.width + shiftSize.width)/shiftSize.width, (curr.rows - bSize.height + shiftSize.height)/shiftSize.height);
-    Mat velx(sz, CV_32F), vely(sz, CV_32F);
-
-    CvMat cvvelx = velx;    CvMat cvvely = vely;
-    CvMat cvprev = prev;    CvMat cvcurr = curr;
-    cvCalcOpticalFlowBM( &cvprev, &cvcurr, bSize, shiftSize, maxRange, usePrevious, &cvvelx, &cvvely);
-    flow = copnvert2flow(velx, vely);
-}
-
-void calcOpticalFlowHS( const Mat& prev, const Mat& curr, int usePrevious, double lambda, TermCriteria criteria, Mat& flow)
-{
-    Mat velx(prev.size(), CV_32F), vely(prev.size(), CV_32F);
-    CvMat cvvelx = velx;    CvMat cvvely = vely;
-    CvMat cvprev = prev;    CvMat cvcurr = curr;
-    cvCalcOpticalFlowHS( &cvprev, &cvcurr, usePrevious, &cvvelx, &cvvely, lambda, criteria );
-    flow = copnvert2flow(velx, vely);
-}
-
-void calcAffineFlowPyrLK( const Mat& prev, const Mat& curr,
-                          const vector<Point2f>& prev_features, vector<Point2f>& curr_features,
-                          vector<uchar>& status, vector<float>& track_error, vector<float>& matrices,
-                          TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS,30, 0.01),
-                          Size win_size = Size(15, 15), int level = 3, int flags = 0)
-{
-    CvMat cvprev = prev;
-    CvMat cvcurr = curr;
-
-    size_t count = prev_features.size();
-    curr_features.resize(count);
-    status.resize(count);
-    track_error.resize(count);
-    matrices.resize(count * 6);
-
-    cvCalcAffineFlowPyrLK( &cvprev, &cvcurr, 0, 0,
-        (const CvPoint2D32f*)&prev_features[0], (CvPoint2D32f*)&curr_features[0], &matrices[0],
-        (int)count, win_size, level, (char*)&status[0], &track_error[0], criteria, flags );
-}
-
-double showFlowAndCalcError(const string& name, const Mat& gray, const Mat& flow,
-                            const Rect& where, const Point& d,
-                            bool showImages = false, bool writeError = false)
-{
-    const int mult = 16;
-
-    if (showImages)
-    {
-        Mat tmp, cflow;
-        resize(gray, tmp, gray.size() * mult, 0, 0, INTER_NEAREST);
-        cvtColor(tmp, cflow, CV_GRAY2BGR);
-
-        const float m2 = 0.3f;
-        const float minVel = 0.1f;
-
-        for(int y = 0; y < flow.rows; ++y)
-            for(int x = 0; x < flow.cols; ++x)
-            {
-                Point2f f = flow.at<Point2f>(y, x);
-
-                if (f.x * f.x + f.y * f.y > minVel * minVel)
-                {
-                    Point p1 = Point(x, y) * mult;
-                    Point p2 = Point(cvRound((x + f.x*m2) * mult), cvRound((y + f.y*m2) * mult));
-
-                    line(cflow, p1, p2, CV_RGB(0, 255, 0));
-                    circle(cflow, Point(x, y) * mult, 2, CV_RGB(255, 0, 0));
-                }
-            }
-
-        rectangle(cflow, (where.tl() + d) * mult, (where.br() + d - Point(1,1)) * mult, CV_RGB(0, 0, 255));
-        namedWindow(name, 1); imshow(name, cflow);
-    }
-
-    double angle = atan2((float)d.y, (float)d.x);
-    double error = 0;
-
-    bool all = true;
-    Mat inner = flow(where);
-    for(int y = 0; y < inner.rows; ++y)
-        for(int x = 0; x < inner.cols; ++x)
-        {
-            const Point2f f = inner.at<Point2f>(y, x);
-
-            if (f.x == 0 && f.y == 0)
-                continue;
-
-            all = false;
-
-            double a = atan2(f.y, f.x);
-            error += fabs(angle - a);
-        }
-        double res = all ? numeric_limits<double>::max() : error / (inner.cols * inner.rows);
-
-        if (writeError)
-            cout << "Error " + name << " = " << res << endl;
-
-        return res;
-}
-
-
-Mat generateImage(const Size& sz, bool doBlur = true)
-{
-    RNG rng;
-    Mat mat(sz, CV_8U);
-    mat = Scalar(0);
-    for(int y = 0; y < mat.rows; ++y)
-        for(int x = 0; x < mat.cols; ++x)
-            mat.at<uchar>(y, x) = (uchar)rng;
-    if (doBlur)
-        blur(mat, mat, Size(3, 3));
-    return mat;
-}
-
-Mat generateSample(const Size& sz)
-{
-    Mat smpl(sz, CV_8U);
-    smpl = Scalar(0);
-    Point sc(smpl.cols/2, smpl.rows/2);
-    rectangle(smpl, Point(0,0), sc - Point(1,1), Scalar(255), CV_FILLED);
-    rectangle(smpl, sc, Point(smpl.cols, smpl.rows), Scalar(255), CV_FILLED);
-    return smpl;
-}
-
-bool CV_OptFlowTest::runDense(const Point& d)
-{
-    Size matSize(40, 40);
-    Size movSize(8, 8);
-
-    Mat smpl = generateSample(movSize);
-    Mat prev = generateImage(matSize);
-    Mat curr = prev.clone();
-
-    Rect rect(Point(prev.cols/2, prev.rows/2) - Point(movSize.width/2, movSize.height/2), movSize);
-
-    Mat flowLK, flowBM, flowHS, flowFB, flowFB_G, flowBM_received, m1;
-
-    m1 = prev(rect);                                smpl.copyTo(m1);
-    m1 = curr(Rect(rect.tl() + d, rect.br() + d));  smpl.copyTo(m1);
-
-    calcOpticalFlowLK( prev, curr, Size(15, 15), flowLK);
-    calcOpticalFlowBM( prev, curr, Size(15, 15), Size(1, 1), Size(15, 15), 0, flowBM_received);
-    calcOpticalFlowHS( prev, curr, 0, 5, TermCriteria(TermCriteria::MAX_ITER, 400, 0), flowHS);
-    calcOpticalFlowFarneback( prev, curr, flowFB, 0.5, 3, std::max(d.x, d.y) + 10, 100, 6, 2, 0);
-    calcOpticalFlowFarneback( prev, curr, flowFB_G, 0.5, 3, std::max(d.x, d.y) + 10, 100, 6, 2, OPTFLOW_FARNEBACK_GAUSSIAN);
-
-    flowBM.create(prev.size(), CV_32FC2);
-    flowBM = Scalar(0);
-    Point origin((flowBM.cols - flowBM_received.cols)/2, (flowBM.rows - flowBM_received.rows)/2);
-    Mat wcp = flowBM(Rect(origin, flowBM_received.size()));
-    flowBM_received.copyTo(wcp);
-
-    double errorLK = showFlowAndCalcError("LK", prev, flowLK, rect, d);
-    double errorBM = showFlowAndCalcError("BM", prev, flowBM, rect, d);
-    double errorFB = showFlowAndCalcError("FB", prev, flowFB, rect, d);
-    double errorFBG = showFlowAndCalcError("FBG", prev, flowFB_G, rect, d);
-    double errorHS = showFlowAndCalcError("HS", prev, flowHS, rect, d); (void)errorHS;
-    //waitKey();
-
-    const double thres = 0.2;
-    if (errorLK > thres || errorBM > thres || errorFB > thres || errorFBG > thres /*|| errorHS > thres */)
-    {
-        ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
-        return false;
-    }
-    return true;
-}
-
-
-bool CV_OptFlowTest::runSparse()
-{
-    Mat prev = imread(string(ts->get_data_path()) + "optflow/rock_1.bmp", 0);
-    Mat next = imread(string(ts->get_data_path()) + "optflow/rock_2.bmp", 0);
-
-    if (prev.empty() || next.empty())
-    {
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );
-        return false;
-    }
-
-    Mat cprev, cnext;
-    cvtColor(prev, cprev, CV_GRAY2BGR);
-    cvtColor(next, cnext, CV_GRAY2BGR);
-
-    vector<Point2f> prev_pts;
-    vector<Point2f> next_ptsOpt;
-    vector<Point2f> next_ptsAff;
-    vector<uchar> status_Opt;
-    vector<uchar> status_Aff;
-    vector<float> error;
-    vector<float> matrices;
-
-    Size netSize(10, 10);
-    Point2f center = Point(prev.cols/2, prev.rows/2);
-
-    for(int i = 0 ; i < netSize.width; ++i)
-        for(int j = 0 ; j < netSize.width; ++j)
-        {
-            Point2f p(i * float(prev.cols)/netSize.width, j * float(prev.rows)/netSize.height);
-            prev_pts.push_back((p - center) * 0.5f + center);
-        }
-
-    calcOpticalFlowPyrLK( prev, next, prev_pts, next_ptsOpt, status_Opt, error );
-    calcAffineFlowPyrLK ( prev, next, prev_pts, next_ptsAff, status_Aff, error, matrices);
-
-    const double expected_shift = 25;
-    const double thres = 1;
-    for(size_t i = 0; i < prev_pts.size(); ++i)
-    {
-        circle(cprev, prev_pts[i], 2, CV_RGB(255, 0, 0));
-
-        if (status_Opt[i])
-        {
-            circle(cnext, next_ptsOpt[i], 2, CV_RGB(0, 0, 255));
-            Point2f shift = prev_pts[i] - next_ptsOpt[i];
-
-            double n = sqrt(shift.ddot(shift));
-            if (fabs(n - expected_shift) > thres)
-            {
-                ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
-                return false;
-            }
-        }
-
-        if (status_Aff[i])
-        {
-            circle(cnext, next_ptsAff[i], 4, CV_RGB(0, 255, 0));
-            Point2f shift = prev_pts[i] - next_ptsAff[i];
-
-            double n = sqrt(shift.ddot(shift));
-            if (fabs(n - expected_shift) > thres)
-            {
-                ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
-                return false;
-            }
-        }
-
-    }
-
-    /*namedWindow("P");  imshow("P", cprev);
-    namedWindow("N"); imshow("N", cnext);
-    waitKey();*/
-
-    return true;
-}
-
-
-void CV_OptFlowTest::run( int /* start_from */)
-{
-
-    if (!runDense(Point(3, 0)))
-        return;
-
-    if (!runDense(Point(0, 3)))
-        return;
-
-    //if (!runDense(Point(3, 3))) return;  //probably LK works incorrectly in this case.
-
-    if (!runSparse())
-        return;
-
-    ts->set_failed_test_info(cvtest::TS::OK);
-}
-
-
-TEST(Legacy_OpticalFlow, accuracy) { CV_OptFlowTest test; test.safe_run(); }
diff --git a/modules/legacy/test/test_precomp.hpp b/modules/legacy/test/test_precomp.hpp
deleted file mode 100644 (file)
index 52b92fb..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifdef __GNUC__
-#  pragma GCC diagnostic ignored "-Wmissing-declarations"
-#  if defined __clang__ || defined __APPLE__
-#    pragma GCC diagnostic ignored "-Wmissing-prototypes"
-#    pragma GCC diagnostic ignored "-Wextra"
-#  endif
-#endif
-
-#ifndef __OPENCV_TEST_PRECOMP_HPP__
-#define __OPENCV_TEST_PRECOMP_HPP__
-
-#include <iostream>
-#include "opencv2/ts.hpp"
-#include "opencv2/imgproc.hpp"
-#include "opencv2/imgproc/imgproc_c.h"
-#include "opencv2/highgui.hpp"
-#include "opencv2/highgui/highgui_c.h"
-#include "opencv2/legacy.hpp"
-
-#endif
diff --git a/modules/legacy/test/test_pyrsegmentation.cpp b/modules/legacy/test/test_pyrsegmentation.cpp
deleted file mode 100644 (file)
index 3bd278c..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-using namespace cv;
-using namespace std;
-
-class CV_PyrSegmentationTest : public cvtest::BaseTest
-{
-public:
-    CV_PyrSegmentationTest();
-protected:
-    void run(int);
-};
-
-#define SCAN  0
-
-CV_PyrSegmentationTest::CV_PyrSegmentationTest()
-{
-}
-
-void CV_PyrSegmentationTest::run( int /*start_from*/ )
-{
-    Mat _image_f, _image, _image_s;
-    const int level = 5;
-    const double range = 15;
-
-    int code = cvtest::TS::OK;
-
-    CvPoint _cp[] ={ CvPoint(33,33), CvPoint(43,33), CvPoint(43,43), CvPoint(33,43)};
-    CvPoint _cp2[] ={CvPoint(50,50), CvPoint(70,50), CvPoint(70,70), CvPoint(50,70)};
-    CvPoint* cp = _cp;
-    CvPoint* cp2 = _cp2;
-    CvConnectedComp *dst_comp[3];
-    CvRect rect[3] = {CvRect(50,50,21,21), CvRect(0,0,128,128), CvRect(33,33,11,11)};
-    double a[3] = {441.0, 15822.0, 121.0};
-
-/*    ippiPoint cp3[] ={130,130, 150,130, 150,150, 130,150};  */
-/*     CvPoint cp[] ={0,0, 5,5, 5,0, 10,5, 10,0, 15,5, 15,0};  */
-    int nPoints = 4;
-    int block_size = 1000;
-
-    CvMemStorage *storage;   /*   storage for connected component writing  */
-    CvSeq *comp;
-
-    RNG& rng = ts->get_rng();
-    int i, j, iter;
-
-    IplImage *image, *image_f, *image_s;
-    CvSize size(128, 128);
-    const int threshold1 = 50, threshold2 = 50;
-
-    rect[1].width = size.width;
-    rect[1].height = size.height;
-    a[1] = size.width*size.height - a[0] - a[2];
-
-    OPENCV_CALL( storage = cvCreateMemStorage( block_size ) );
-
-    for( iter = 0; iter < 2; iter++ )
-    {
-        int channels = iter == 0 ? 1 : 3;
-        int mask[] = {0,0,0};
-
-        image = cvCreateImage(size, 8, channels );
-        image_s = cvCloneImage( image );
-        image_f = cvCloneImage( image );
-
-        if( channels == 1 )
-        {
-            int color1 = 30, color2 = 110, color3 = 190;
-
-            cvSet( image, cvScalarAll(color1));
-            cvFillPoly( image, &cp, &nPoints, 1, cvScalar(color2));
-            cvFillPoly( image, &cp2, &nPoints, 1, cvScalar(color3));
-        }
-        else
-        {
-            CvScalar color1 = CV_RGB(30,30,30), color2 = CV_RGB(255,0,0), color3 = CV_RGB(0,255,0);
-
-            assert( channels == 3 );
-            cvSet( image, color1 );
-            cvFillPoly( image, &cp, &nPoints, 1, color2);
-            cvFillPoly( image, &cp2, &nPoints, 1, color3);
-        }
-
-        _image_f = cvarrToMat(image_f);
-        cvtest::randUni( rng, _image_f, cvScalarAll(0), cvScalarAll(range*2) );
-        cvAddWeighted( image, 1, image_f, 1, -range, image_f );
-
-        cvPyrSegmentation( image_f, image_s,
-                           storage, &comp,
-                           level, threshold1, threshold2 );
-
-        if(comp->total != 3)
-        {
-            ts->printf( cvtest::TS::LOG,
-                "The segmentation function returned %d (not 3) components\n", comp->total );
-            code = cvtest::TS::FAIL_INVALID_OUTPUT;
-            goto _exit_;
-        }
-        /*  read the connected components     */
-        dst_comp[0] = (CvConnectedComp*)CV_GET_SEQ_ELEM( CvConnectedComp, comp, 0 );
-        dst_comp[1] = (CvConnectedComp*)CV_GET_SEQ_ELEM( CvConnectedComp, comp, 1 );
-        dst_comp[2] = (CvConnectedComp*)CV_GET_SEQ_ELEM( CvConnectedComp, comp, 2 );
-
-        /*{
-            for( i = 0; i < 3; i++ )
-            {
-                CvRect r = dst_comp[i]->rect;
-                cvRectangle( image_s, cvPoint(r.x,r.y), cvPoint(r.x+r.width,r.y+r.height),
-                    CV_RGB(255,255,255), 3, 8, 0 );
-            }
-
-            cvNamedWindow( "test", 1 );
-            cvShowImage( "test", image_s );
-            cvWaitKey(0);
-        }*/
-
-        _image = cvarrToMat(image);
-        _image_s = cvarrToMat(image_s);
-        code = cvtest::cmpEps2( ts, _image, _image_s, 10, false, "the output image" );
-        if( code < 0 )
-            goto _exit_;
-
-        for( i = 0; i < 3; i++)
-        {
-            for( j = 0; j < 3; j++ )
-            {
-                if( !mask[j] && dst_comp[i]->area == a[j] &&
-                    dst_comp[i]->rect.x == rect[j].x &&
-                    dst_comp[i]->rect.y == rect[j].y &&
-                    dst_comp[i]->rect.width == rect[j].width &&
-                    dst_comp[i]->rect.height == rect[j].height )
-                {
-                    mask[j] = 1;
-                    break;
-                }
-            }
-            if( j == 3 )
-            {
-                ts->printf( cvtest::TS::LOG, "The component #%d is incorrect\n", i );
-                code = cvtest::TS::FAIL_BAD_ACCURACY;
-                goto _exit_;
-            }
-        }
-
-        cvReleaseImage(&image_f);
-        cvReleaseImage(&image);
-        cvReleaseImage(&image_s);
-    }
-
-_exit_:
-
-    cvReleaseMemStorage( &storage );
-    cvReleaseImage(&image_f);
-    cvReleaseImage(&image);
-    cvReleaseImage(&image_s);
-
-    if( code < 0 )
-        ts->set_failed_test_info( code );
-}
-
-TEST(Legacy_PyrSegmentation, regression) { CV_PyrSegmentationTest test; test.safe_run(); }
-
-/* End of file. */
diff --git a/modules/legacy/test/test_stereomatching.cpp b/modules/legacy/test/test_stereomatching.cpp
deleted file mode 100644 (file)
index 95aa97b..0000000
+++ /dev/null
@@ -1,722 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-/*
-  This is a regression test for stereo matching algorithms. This test gets some quality metrics
-  discribed in "A Taxonomy and Evaluation of Dense Two-Frame Stereo Correspondence Algorithms".
-  Daniel Scharstein, Richard Szeliski
-*/
-
-#include "test_precomp.hpp"
-#include <limits>
-#include <cstdio>
-
-using namespace std;
-using namespace cv;
-
-const float EVAL_BAD_THRESH = 1.f;
-const int EVAL_TEXTURELESS_WIDTH = 3;
-const float EVAL_TEXTURELESS_THRESH = 4.f;
-const float EVAL_DISP_THRESH = 1.f;
-const float EVAL_DISP_GAP = 2.f;
-const int EVAL_DISCONT_WIDTH = 9;
-const int EVAL_IGNORE_BORDER = 10;
-
-const int ERROR_KINDS_COUNT = 6;
-
-//============================== quality measuring functions =================================================
-
-/*
-  Calculate textureless regions of image (regions where the squared horizontal intensity gradient averaged over
-  a square window of size=evalTexturelessWidth is below a threshold=evalTexturelessThresh) and textured regions.
-*/
-void computeTextureBasedMasks( const Mat& _img, Mat* texturelessMask, Mat* texturedMask,
-             int texturelessWidth = EVAL_TEXTURELESS_WIDTH, float texturelessThresh = EVAL_TEXTURELESS_THRESH )
-{
-    if( !texturelessMask && !texturedMask )
-        return;
-    if( _img.empty() )
-        CV_Error( CV_StsBadArg, "img is empty" );
-
-    Mat img = _img;
-    if( _img.channels() > 1)
-    {
-        Mat tmp; cvtColor( _img, tmp, CV_BGR2GRAY ); img = tmp;
-    }
-    Mat dxI; Sobel( img, dxI, CV_32FC1, 1, 0, 3 );
-    Mat dxI2; pow( dxI / 8.f/*normalize*/, 2, dxI2 );
-    Mat avgDxI2; boxFilter( dxI2, avgDxI2, CV_32FC1, Size(texturelessWidth,texturelessWidth) );
-
-    if( texturelessMask )
-        *texturelessMask = avgDxI2 < texturelessThresh;
-    if( texturedMask )
-        *texturedMask = avgDxI2 >= texturelessThresh;
-}
-
-void checkTypeAndSizeOfDisp( const Mat& dispMap, const Size* sz )
-{
-    if( dispMap.empty() )
-        CV_Error( CV_StsBadArg, "dispMap is empty" );
-    if( dispMap.type() != CV_32FC1 )
-        CV_Error( CV_StsBadArg, "dispMap must have CV_32FC1 type" );
-    if( sz && (dispMap.rows != sz->height || dispMap.cols != sz->width) )
-        CV_Error( CV_StsBadArg, "dispMap has incorrect size" );
-}
-
-void checkTypeAndSizeOfMask( const Mat& mask, Size sz )
-{
-    if( mask.empty() )
-        CV_Error( CV_StsBadArg, "mask is empty" );
-    if( mask.type() != CV_8UC1 )
-        CV_Error( CV_StsBadArg, "mask must have CV_8UC1 type" );
-    if( mask.rows != sz.height || mask.cols != sz.width )
-        CV_Error( CV_StsBadArg, "mask has incorrect size" );
-}
-
-void checkDispMapsAndUnknDispMasks( const Mat& leftDispMap, const Mat& rightDispMap,
-                                    const Mat& leftUnknDispMask, const Mat& rightUnknDispMask )
-{
-    // check type and size of disparity maps
-    checkTypeAndSizeOfDisp( leftDispMap, 0 );
-    if( !rightDispMap.empty() )
-    {
-        Size sz = leftDispMap.size();
-        checkTypeAndSizeOfDisp( rightDispMap, &sz );
-    }
-
-    // check size and type of unknown disparity maps
-    if( !leftUnknDispMask.empty() )
-        checkTypeAndSizeOfMask( leftUnknDispMask, leftDispMap.size() );
-    if( !rightUnknDispMask.empty() )
-        checkTypeAndSizeOfMask( rightUnknDispMask, rightDispMap.size() );
-
-    // check values of disparity maps (known disparity values musy be positive)
-    double leftMinVal = 0, rightMinVal = 0;
-    if( leftUnknDispMask.empty() )
-        minMaxLoc( leftDispMap, &leftMinVal );
-    else
-        minMaxLoc( leftDispMap, &leftMinVal, 0, 0, 0, ~leftUnknDispMask );
-    if( !rightDispMap.empty() )
-    {
-        if( rightUnknDispMask.empty() )
-            minMaxLoc( rightDispMap, &rightMinVal );
-        else
-            minMaxLoc( rightDispMap, &rightMinVal, 0, 0, 0, ~rightUnknDispMask );
-    }
-    if( leftMinVal < 0 || rightMinVal < 0)
-        CV_Error( CV_StsBadArg, "known disparity values must be positive" );
-}
-
-/*
-  Calculate occluded regions of reference image (left image) (regions that are occluded in the matching image (right image),
-  i.e., where the forward-mapped disparity lands at a location with a larger (nearer) disparity) and non occluded regions.
-*/
-void computeOcclusionBasedMasks( const Mat& leftDisp, const Mat& _rightDisp,
-                             Mat* occludedMask, Mat* nonOccludedMask,
-                             const Mat& leftUnknDispMask = Mat(), const Mat& rightUnknDispMask = Mat(),
-                             float dispThresh = EVAL_DISP_THRESH )
-{
-    if( !occludedMask && !nonOccludedMask )
-        return;
-    checkDispMapsAndUnknDispMasks( leftDisp, _rightDisp, leftUnknDispMask, rightUnknDispMask );
-
-    Mat rightDisp;
-    if( _rightDisp.empty() )
-    {
-        if( !rightUnknDispMask.empty() )
-           CV_Error( CV_StsBadArg, "rightUnknDispMask must be empty if _rightDisp is empty" );
-        rightDisp.create(leftDisp.size(), CV_32FC1);
-        rightDisp.setTo(Scalar::all(0) );
-        for( int leftY = 0; leftY < leftDisp.rows; leftY++ )
-        {
-            for( int leftX = 0; leftX < leftDisp.cols; leftX++ )
-            {
-                if( !leftUnknDispMask.empty() && leftUnknDispMask.at<uchar>(leftY,leftX) )
-                    continue;
-                float leftDispVal = leftDisp.at<float>(leftY, leftX);
-                int rightX = leftX - cvRound(leftDispVal), rightY = leftY;
-                if( rightX >= 0)
-                    rightDisp.at<float>(rightY,rightX) = max(rightDisp.at<float>(rightY,rightX), leftDispVal);
-            }
-        }
-    }
-    else
-        _rightDisp.copyTo(rightDisp);
-
-    if( occludedMask )
-    {
-        occludedMask->create(leftDisp.size(), CV_8UC1);
-        occludedMask->setTo(Scalar::all(0) );
-    }
-    if( nonOccludedMask )
-    {
-        nonOccludedMask->create(leftDisp.size(), CV_8UC1);
-        nonOccludedMask->setTo(Scalar::all(0) );
-    }
-    for( int leftY = 0; leftY < leftDisp.rows; leftY++ )
-    {
-        for( int leftX = 0; leftX < leftDisp.cols; leftX++ )
-        {
-            if( !leftUnknDispMask.empty() && leftUnknDispMask.at<uchar>(leftY,leftX) )
-                continue;
-            float leftDispVal = leftDisp.at<float>(leftY, leftX);
-            int rightX = leftX - cvRound(leftDispVal), rightY = leftY;
-            if( rightX < 0 && occludedMask )
-                occludedMask->at<uchar>(leftY, leftX) = 255;
-            else
-            {
-                if( !rightUnknDispMask.empty() && rightUnknDispMask.at<uchar>(rightY,rightX) )
-                    continue;
-                float rightDispVal = rightDisp.at<float>(rightY, rightX);
-                if( rightDispVal > leftDispVal + dispThresh )
-                {
-                    if( occludedMask )
-                        occludedMask->at<uchar>(leftY, leftX) = 255;
-                }
-                else
-                {
-                    if( nonOccludedMask )
-                        nonOccludedMask->at<uchar>(leftY, leftX) = 255;
-                }
-            }
-        }
-    }
-}
-
-/*
-  Calculate depth discontinuty regions: pixels whose neiboring disparities differ by more than
-  dispGap, dilated by window of width discontWidth.
-*/
-void computeDepthDiscontMask( const Mat& disp, Mat& depthDiscontMask, const Mat& unknDispMask = Mat(),
-                                 float dispGap = EVAL_DISP_GAP, int discontWidth = EVAL_DISCONT_WIDTH )
-{
-    if( disp.empty() )
-        CV_Error( CV_StsBadArg, "disp is empty" );
-    if( disp.type() != CV_32FC1 )
-        CV_Error( CV_StsBadArg, "disp must have CV_32FC1 type" );
-    if( !unknDispMask.empty() )
-        checkTypeAndSizeOfMask( unknDispMask, disp.size() );
-
-    Mat curDisp; disp.copyTo( curDisp );
-    if( !unknDispMask.empty() )
-        curDisp.setTo( Scalar(numeric_limits<float>::min()), unknDispMask );
-    Mat maxNeighbDisp; dilate( curDisp, maxNeighbDisp, Mat(3, 3, CV_8UC1, Scalar(1)) );
-    if( !unknDispMask.empty() )
-        curDisp.setTo( Scalar(numeric_limits<float>::max()), unknDispMask );
-    Mat minNeighbDisp; erode( curDisp, minNeighbDisp, Mat(3, 3, CV_8UC1, Scalar(1)) );
-    depthDiscontMask = max( (Mat)(maxNeighbDisp-disp), (Mat)(disp-minNeighbDisp) ) > dispGap;
-    if( !unknDispMask.empty() )
-        depthDiscontMask &= ~unknDispMask;
-    dilate( depthDiscontMask, depthDiscontMask, Mat(discontWidth, discontWidth, CV_8UC1, Scalar(1)) );
-}
-
-/*
-   Get evaluation masks excluding a border.
-*/
-Mat getBorderedMask( Size maskSize, int border = EVAL_IGNORE_BORDER )
-{
-    CV_Assert( border >= 0 );
-    Mat mask(maskSize, CV_8UC1, Scalar(0));
-    int w = maskSize.width - 2*border, h = maskSize.height - 2*border;
-    if( w < 0 ||  h < 0 )
-        mask.setTo(Scalar(0));
-    else
-        mask( Rect(Point(border,border),Size(w,h)) ).setTo(Scalar(255));
-    return mask;
-}
-
-/*
-  Calculate root-mean-squared error between the computed disparity map (computedDisp) and ground truth map (groundTruthDisp).
-*/
-float dispRMS( const Mat& computedDisp, const Mat& groundTruthDisp, const Mat& mask )
-{
-    checkTypeAndSizeOfDisp( groundTruthDisp, 0 );
-    Size sz = groundTruthDisp.size();
-    checkTypeAndSizeOfDisp( computedDisp, &sz );
-
-    int pointsCount = sz.height*sz.width;
-    if( !mask.empty() )
-    {
-        checkTypeAndSizeOfMask( mask, sz );
-        pointsCount = countNonZero(mask);
-    }
-    return 1.f/sqrt((float)pointsCount) * (float)cvtest::norm(computedDisp, groundTruthDisp, NORM_L2, mask);
-}
-
-/*
-  Calculate fraction of bad matching pixels.
-*/
-float badMatchPxlsFraction( const Mat& computedDisp, const Mat& groundTruthDisp, const Mat& mask,
-                            float _badThresh = EVAL_BAD_THRESH )
-{
-    int badThresh = cvRound(_badThresh);
-    checkTypeAndSizeOfDisp( groundTruthDisp, 0 );
-    Size sz = groundTruthDisp.size();
-    checkTypeAndSizeOfDisp( computedDisp, &sz );
-
-    Mat badPxlsMap;
-    absdiff( computedDisp, groundTruthDisp, badPxlsMap );
-    badPxlsMap = badPxlsMap > badThresh;
-    int pointsCount = sz.height*sz.width;
-    if( !mask.empty() )
-    {
-        checkTypeAndSizeOfMask( mask, sz );
-        badPxlsMap = badPxlsMap & mask;
-        pointsCount = countNonZero(mask);
-    }
-    return 1.f/pointsCount * countNonZero(badPxlsMap);
-}
-
-//===================== regression test for stereo matching algorithms ==============================
-
-const string ALGORITHMS_DIR = "stereomatching/algorithms/";
-const string DATASETS_DIR = "stereomatching/datasets/";
-const string DATASETS_FILE = "datasets.xml";
-
-const string RUN_PARAMS_FILE = "_params.xml";
-const string RESULT_FILE = "_res.xml";
-
-const string LEFT_IMG_NAME = "im2.png";
-const string RIGHT_IMG_NAME = "im6.png";
-const string TRUE_LEFT_DISP_NAME = "disp2.png";
-const string TRUE_RIGHT_DISP_NAME = "disp6.png";
-
-string ERROR_PREFIXES[] = { "borderedAll",
-                            "borderedNoOccl",
-                            "borderedOccl",
-                            "borderedTextured",
-                            "borderedTextureless",
-                            "borderedDepthDiscont" }; // size of ERROR_KINDS_COUNT
-
-
-const string RMS_STR = "RMS";
-const string BAD_PXLS_FRACTION_STR = "BadPxlsFraction";
-
-class QualityEvalParams
-{
-public:
-    QualityEvalParams() { setDefaults(); }
-    QualityEvalParams( int _ignoreBorder )
-    {
-        setDefaults();
-        ignoreBorder = _ignoreBorder;
-    }
-    void setDefaults()
-    {
-        badThresh = EVAL_BAD_THRESH;
-        texturelessWidth = EVAL_TEXTURELESS_WIDTH;
-        texturelessThresh = EVAL_TEXTURELESS_THRESH;
-        dispThresh = EVAL_DISP_THRESH;
-        dispGap = EVAL_DISP_GAP;
-        discontWidth = EVAL_DISCONT_WIDTH;
-        ignoreBorder = EVAL_IGNORE_BORDER;
-    }
-    float badThresh;
-    int texturelessWidth;
-    float texturelessThresh;
-    float dispThresh;
-    float dispGap;
-    int discontWidth;
-    int ignoreBorder;
-};
-
-class CV_StereoMatchingTest : public cvtest::BaseTest
-{
-public:
-    CV_StereoMatchingTest()
-    { rmsEps.resize( ERROR_KINDS_COUNT, 0.01f );  fracEps.resize( ERROR_KINDS_COUNT, 1.e-6f ); }
-protected:
-    // assumed that left image is a reference image
-    virtual int runStereoMatchingAlgorithm( const Mat& leftImg, const Mat& rightImg,
-                   Mat& leftDisp, Mat& rightDisp, int caseIdx ) = 0; // return ignored border width
-
-    int readDatasetsParams( FileStorage& fs );
-    virtual int readRunParams( FileStorage& fs );
-    void writeErrors( const string& errName, const vector<float>& errors, FileStorage* fs = 0 );
-    void readErrors( FileNode& fn, const string& errName, vector<float>& errors );
-    int compareErrors( const vector<float>& calcErrors, const vector<float>& validErrors,
-                       const vector<float>& eps, const string& errName );
-    int processStereoMatchingResults( FileStorage& fs, int caseIdx, bool isWrite,
-                  const Mat& leftImg, const Mat& rightImg,
-                  const Mat& trueLeftDisp, const Mat& trueRightDisp,
-                  const Mat& leftDisp, const Mat& rightDisp,
-                  const QualityEvalParams& qualityEvalParams  );
-    void run( int );
-
-    vector<float> rmsEps;
-    vector<float> fracEps;
-
-    struct DatasetParams
-    {
-        int dispScaleFactor;
-        int dispUnknVal;
-    };
-    map<string, DatasetParams> datasetsParams;
-
-    vector<string> caseNames;
-    vector<string> caseDatasets;
-};
-
-void CV_StereoMatchingTest::run(int)
-{
-    string dataPath = ts->get_data_path();
-    string algorithmName = name;
-    assert( !algorithmName.empty() );
-    if( dataPath.empty() )
-    {
-        ts->printf( cvtest::TS::LOG, "dataPath is empty" );
-        ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ARG_CHECK );
-        return;
-    }
-
-    FileStorage datasetsFS( dataPath + DATASETS_DIR + DATASETS_FILE, FileStorage::READ );
-    int code = readDatasetsParams( datasetsFS );
-    if( code != cvtest::TS::OK )
-    {
-        ts->set_failed_test_info( code );
-        return;
-    }
-    FileStorage runParamsFS( dataPath + ALGORITHMS_DIR + algorithmName + RUN_PARAMS_FILE, FileStorage::READ );
-    code = readRunParams( runParamsFS );
-    if( code != cvtest::TS::OK )
-    {
-        ts->set_failed_test_info( code );
-        return;
-    }
-
-    string fullResultFilename = dataPath + ALGORITHMS_DIR + algorithmName + RESULT_FILE;
-    FileStorage resFS( fullResultFilename, FileStorage::READ );
-    bool isWrite = true; // write or compare results
-    if( resFS.isOpened() )
-        isWrite = false;
-    else
-    {
-        resFS.open( fullResultFilename, FileStorage::WRITE );
-        if( !resFS.isOpened() )
-        {
-            ts->printf( cvtest::TS::LOG, "file %s can not be read or written\n", fullResultFilename.c_str() );
-            ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ARG_CHECK );
-            return;
-        }
-        resFS << "stereo_matching" << "{";
-    }
-
-    int progress = 0, caseCount = (int)caseNames.size();
-    for( int ci = 0; ci < caseCount; ci++)
-    {
-        progress = update_progress( progress, ci, caseCount, 0 );
-        printf("progress: %d%%\n", progress);
-        fflush(stdout);
-        string datasetName = caseDatasets[ci];
-        string datasetFullDirName = dataPath + DATASETS_DIR + datasetName + "/";
-        Mat leftImg = imread(datasetFullDirName + LEFT_IMG_NAME);
-        Mat rightImg = imread(datasetFullDirName + RIGHT_IMG_NAME);
-        Mat trueLeftDisp = imread(datasetFullDirName + TRUE_LEFT_DISP_NAME, 0);
-        Mat trueRightDisp = imread(datasetFullDirName + TRUE_RIGHT_DISP_NAME, 0);
-
-        if( leftImg.empty() || rightImg.empty() || trueLeftDisp.empty() )
-        {
-            ts->printf( cvtest::TS::LOG, "images or left ground-truth disparities of dataset %s can not be read", datasetName.c_str() );
-            code = cvtest::TS::FAIL_INVALID_TEST_DATA;
-            continue;
-        }
-        int dispScaleFactor = datasetsParams[datasetName].dispScaleFactor;
-        Mat tmp; trueLeftDisp.convertTo( tmp, CV_32FC1, 1.f/dispScaleFactor ); trueLeftDisp = tmp; tmp.release();
-        if( !trueRightDisp.empty() )
-            trueRightDisp.convertTo( tmp, CV_32FC1, 1.f/dispScaleFactor ); trueRightDisp = tmp; tmp.release();
-
-        Mat leftDisp, rightDisp;
-        int ignBorder = max(runStereoMatchingAlgorithm(leftImg, rightImg, leftDisp, rightDisp, ci), EVAL_IGNORE_BORDER);
-        leftDisp.convertTo( tmp, CV_32FC1 ); leftDisp = tmp; tmp.release();
-        rightDisp.convertTo( tmp, CV_32FC1 ); rightDisp = tmp; tmp.release();
-
-        int tempCode = processStereoMatchingResults( resFS, ci, isWrite,
-                   leftImg, rightImg, trueLeftDisp, trueRightDisp, leftDisp, rightDisp, QualityEvalParams(ignBorder));
-        code = tempCode==cvtest::TS::OK ? code : tempCode;
-    }
-
-    if( isWrite )
-        resFS << "}"; // "stereo_matching"
-
-    ts->set_failed_test_info( code );
-}
-
-void calcErrors( const Mat& leftImg, const Mat& /*rightImg*/,
-                 const Mat& trueLeftDisp, const Mat& trueRightDisp,
-                 const Mat& trueLeftUnknDispMask, const Mat& trueRightUnknDispMask,
-                 const Mat& calcLeftDisp, const Mat& /*calcRightDisp*/,
-                 vector<float>& rms, vector<float>& badPxlsFractions,
-                 const QualityEvalParams& qualityEvalParams )
-{
-    Mat texturelessMask, texturedMask;
-    computeTextureBasedMasks( leftImg, &texturelessMask, &texturedMask,
-                              qualityEvalParams.texturelessWidth, qualityEvalParams.texturelessThresh );
-    Mat occludedMask, nonOccludedMask;
-    computeOcclusionBasedMasks( trueLeftDisp, trueRightDisp, &occludedMask, &nonOccludedMask,
-                                trueLeftUnknDispMask, trueRightUnknDispMask, qualityEvalParams.dispThresh);
-    Mat depthDiscontMask;
-    computeDepthDiscontMask( trueLeftDisp, depthDiscontMask, trueLeftUnknDispMask,
-                             qualityEvalParams.dispGap, qualityEvalParams.discontWidth);
-
-    Mat borderedKnownMask = getBorderedMask( leftImg.size(), qualityEvalParams.ignoreBorder ) & ~trueLeftUnknDispMask;
-
-    nonOccludedMask &= borderedKnownMask;
-    occludedMask &= borderedKnownMask;
-    texturedMask &= nonOccludedMask; // & borderedKnownMask
-    texturelessMask &= nonOccludedMask; // & borderedKnownMask
-    depthDiscontMask &= nonOccludedMask; // & borderedKnownMask
-
-    rms.resize(ERROR_KINDS_COUNT);
-    rms[0] = dispRMS( calcLeftDisp, trueLeftDisp, borderedKnownMask );
-    rms[1] = dispRMS( calcLeftDisp, trueLeftDisp, nonOccludedMask );
-    rms[2] = dispRMS( calcLeftDisp, trueLeftDisp, occludedMask );
-    rms[3] = dispRMS( calcLeftDisp, trueLeftDisp, texturedMask );
-    rms[4] = dispRMS( calcLeftDisp, trueLeftDisp, texturelessMask );
-    rms[5] = dispRMS( calcLeftDisp, trueLeftDisp, depthDiscontMask );
-
-    badPxlsFractions.resize(ERROR_KINDS_COUNT);
-    badPxlsFractions[0] = badMatchPxlsFraction( calcLeftDisp, trueLeftDisp, borderedKnownMask, qualityEvalParams.badThresh );
-    badPxlsFractions[1] = badMatchPxlsFraction( calcLeftDisp, trueLeftDisp, nonOccludedMask, qualityEvalParams.badThresh );
-    badPxlsFractions[2] = badMatchPxlsFraction( calcLeftDisp, trueLeftDisp, occludedMask, qualityEvalParams.badThresh );
-    badPxlsFractions[3] = badMatchPxlsFraction( calcLeftDisp, trueLeftDisp, texturedMask, qualityEvalParams.badThresh );
-    badPxlsFractions[4] = badMatchPxlsFraction( calcLeftDisp, trueLeftDisp, texturelessMask, qualityEvalParams.badThresh );
-    badPxlsFractions[5] = badMatchPxlsFraction( calcLeftDisp, trueLeftDisp, depthDiscontMask, qualityEvalParams.badThresh );
-}
-
-int CV_StereoMatchingTest::processStereoMatchingResults( FileStorage& fs, int caseIdx, bool isWrite,
-              const Mat& leftImg, const Mat& rightImg,
-              const Mat& trueLeftDisp, const Mat& trueRightDisp,
-              const Mat& leftDisp, const Mat& rightDisp,
-              const QualityEvalParams& qualityEvalParams )
-{
-    // rightDisp is not used in current test virsion
-    int code = cvtest::TS::OK;
-    assert( fs.isOpened() );
-    assert( trueLeftDisp.type() == CV_32FC1 && trueRightDisp.type() == CV_32FC1 );
-    assert( leftDisp.type() == CV_32FC1 && rightDisp.type() == CV_32FC1 );
-
-    // get masks for unknown ground truth disparity values
-    Mat leftUnknMask, rightUnknMask;
-    DatasetParams params = datasetsParams[caseDatasets[caseIdx]];
-    absdiff( trueLeftDisp, Scalar(params.dispUnknVal), leftUnknMask );
-    leftUnknMask = leftUnknMask < numeric_limits<float>::epsilon();
-    assert(leftUnknMask.type() == CV_8UC1);
-    if( !trueRightDisp.empty() )
-    {
-        absdiff( trueRightDisp, Scalar(params.dispUnknVal), rightUnknMask );
-        rightUnknMask = rightUnknMask < numeric_limits<float>::epsilon();
-        assert(leftUnknMask.type() == CV_8UC1);
-    }
-
-    // calculate errors
-    vector<float> rmss, badPxlsFractions;
-    calcErrors( leftImg, rightImg, trueLeftDisp, trueRightDisp, leftUnknMask, rightUnknMask,
-                leftDisp, rightDisp, rmss, badPxlsFractions, qualityEvalParams );
-
-    if( isWrite )
-    {
-        fs << caseNames[caseIdx] << "{";
-        cvWriteComment( fs.fs, RMS_STR.c_str(), 0 );
-        writeErrors( RMS_STR, rmss, &fs );
-        cvWriteComment( fs.fs, BAD_PXLS_FRACTION_STR.c_str(), 0 );
-        writeErrors( BAD_PXLS_FRACTION_STR, badPxlsFractions, &fs );
-        fs << "}"; // datasetName
-    }
-    else // compare
-    {
-        ts->printf( cvtest::TS::LOG, "\nquality of case named %s\n", caseNames[caseIdx].c_str() );
-        ts->printf( cvtest::TS::LOG, "%s\n", RMS_STR.c_str() );
-        writeErrors( RMS_STR, rmss );
-        ts->printf( cvtest::TS::LOG, "%s\n", BAD_PXLS_FRACTION_STR.c_str() );
-        writeErrors( BAD_PXLS_FRACTION_STR, badPxlsFractions );
-
-        FileNode fn = fs.getFirstTopLevelNode()[caseNames[caseIdx]];
-        vector<float> validRmss, validBadPxlsFractions;
-
-        readErrors( fn, RMS_STR, validRmss );
-        readErrors( fn, BAD_PXLS_FRACTION_STR, validBadPxlsFractions );
-        int tempCode = compareErrors( rmss, validRmss, rmsEps, RMS_STR );
-        code = tempCode==cvtest::TS::OK ? code : tempCode;
-        tempCode = compareErrors( badPxlsFractions, validBadPxlsFractions, fracEps, BAD_PXLS_FRACTION_STR );
-        code = tempCode==cvtest::TS::OK ? code : tempCode;
-    }
-    return code;
-}
-
-int CV_StereoMatchingTest::readDatasetsParams( FileStorage& fs )
-{
-    if( !fs.isOpened() )
-    {
-        ts->printf( cvtest::TS::LOG, "datasetsParams can not be read " );
-        return cvtest::TS::FAIL_INVALID_TEST_DATA;
-    }
-    datasetsParams.clear();
-    FileNode fn = fs.getFirstTopLevelNode();
-    assert(fn.isSeq());
-    for( int i = 0; i < (int)fn.size(); i+=3 )
-    {
-        String nm = fn[i];
-        DatasetParams params;
-        String sf = fn[i+1]; params.dispScaleFactor = atoi(sf.c_str());
-        String uv = fn[i+2]; params.dispUnknVal = atoi(uv.c_str());
-        datasetsParams[nm] = params;
-    }
-    return cvtest::TS::OK;
-}
-
-int CV_StereoMatchingTest::readRunParams( FileStorage& fs )
-{
-    if( !fs.isOpened() )
-    {
-        ts->printf( cvtest::TS::LOG, "runParams can not be read " );
-        return cvtest::TS::FAIL_INVALID_TEST_DATA;
-    }
-    caseNames.clear();;
-    caseDatasets.clear();
-    return cvtest::TS::OK;
-}
-
-void CV_StereoMatchingTest::writeErrors( const string& errName, const vector<float>& errors, FileStorage* fs )
-{
-    assert( (int)errors.size() == ERROR_KINDS_COUNT );
-    vector<float>::const_iterator it = errors.begin();
-    if( fs )
-        for( int i = 0; i < ERROR_KINDS_COUNT; i++, ++it )
-            *fs << ERROR_PREFIXES[i] + errName << *it;
-    else
-        for( int i = 0; i < ERROR_KINDS_COUNT; i++, ++it )
-            ts->printf( cvtest::TS::LOG, "%s = %f\n", string(ERROR_PREFIXES[i]+errName).c_str(), *it );
-}
-
-void CV_StereoMatchingTest::readErrors( FileNode& fn, const string& errName, vector<float>& errors )
-{
-    errors.resize( ERROR_KINDS_COUNT );
-    vector<float>::iterator it = errors.begin();
-    for( int i = 0; i < ERROR_KINDS_COUNT; i++, ++it )
-        fn[ERROR_PREFIXES[i]+errName] >> *it;
-}
-
-int CV_StereoMatchingTest::compareErrors( const vector<float>& calcErrors, const vector<float>& validErrors,
-                   const vector<float>& eps, const string& errName )
-{
-    assert( (int)calcErrors.size() == ERROR_KINDS_COUNT );
-    assert( (int)validErrors.size() == ERROR_KINDS_COUNT );
-    assert( (int)eps.size() == ERROR_KINDS_COUNT );
-    vector<float>::const_iterator calcIt = calcErrors.begin(),
-                                  validIt = validErrors.begin(),
-                                  epsIt = eps.begin();
-    bool ok = true;
-    for( int i = 0; i < ERROR_KINDS_COUNT; i++, ++calcIt, ++validIt, ++epsIt )
-        if( *calcIt - *validIt > *epsIt )
-        {
-            ts->printf( cvtest::TS::LOG, "bad accuracy of %s (valid=%f; calc=%f)\n", string(ERROR_PREFIXES[i]+errName).c_str(), *validIt, *calcIt );
-            ok = false;
-        }
-    return ok ? cvtest::TS::OK : cvtest::TS::FAIL_BAD_ACCURACY;
-}
-
-//----------------------------------- StereoGC test -----------------------------------------------------
-
-class CV_StereoGCTest : public CV_StereoMatchingTest
-{
-public:
-    CV_StereoGCTest()
-    {
-        name = "stereogc";
-        fill(rmsEps.begin(), rmsEps.end(), 3.f);
-        fracEps[0] = 0.05f; // all
-        fracEps[1] = 0.05f; // noOccl
-        fracEps[2] = 0.25f; // occl
-        fracEps[3] = 0.05f; // textured
-        fracEps[4] = 0.10f; // textureless
-        fracEps[5] = 0.10f; // borderedDepthDiscont
-    }
-protected:
-    struct RunParams
-    {
-        int ndisp;
-        int iterCount;
-    };
-    vector<RunParams> caseRunParams;
-
-    virtual int readRunParams( FileStorage& fs )
-    {
-        int code = CV_StereoMatchingTest::readRunParams(fs);
-        FileNode fn = fs.getFirstTopLevelNode();
-        assert(fn.isSeq());
-        for( int i = 0; i < (int)fn.size(); i+=4 )
-        {
-            String caseName = fn[i], datasetName = fn[i+1];
-            RunParams params;
-            String ndisp = fn[i+2]; params.ndisp = atoi(ndisp.c_str());
-            String iterCount = fn[i+3]; params.iterCount = atoi(iterCount.c_str());
-            caseNames.push_back( caseName );
-            caseDatasets.push_back( datasetName );
-            caseRunParams.push_back( params );
-        }
-        return code;
-    }
-
-    virtual int runStereoMatchingAlgorithm( const Mat& _leftImg, const Mat& _rightImg,
-                   Mat& leftDisp, Mat& rightDisp, int caseIdx )
-    {
-        RunParams params = caseRunParams[caseIdx];
-        assert( _leftImg.type() == CV_8UC3 && _rightImg.type() == CV_8UC3 );
-        Mat leftImg, rightImg, tmp;
-        cvtColor( _leftImg, leftImg, CV_BGR2GRAY );
-        cvtColor( _rightImg, rightImg, CV_BGR2GRAY );
-
-        leftDisp.create( leftImg.size(), CV_16SC1 );
-        rightDisp.create( rightImg.size(), CV_16SC1 );
-
-        CvMat _limg = leftImg, _rimg = rightImg, _ldisp = leftDisp, _rdisp = rightDisp;
-        CvStereoGCState *state = cvCreateStereoGCState( params.ndisp, params.iterCount );
-        cvFindStereoCorrespondenceGC( &_limg, &_rimg, &_ldisp, &_rdisp, state );
-        cvReleaseStereoGCState( &state );
-
-        leftDisp = - leftDisp;
-        return 0;
-    }
-
-};
-
-
-TEST(Legacy_StereoGC, regression) { CV_StereoGCTest test; test.safe_run(); }
diff --git a/modules/legacy/test/test_subdivisions.cpp b/modules/legacy/test/test_subdivisions.cpp
deleted file mode 100644 (file)
index 0df71ab..0000000
+++ /dev/null
@@ -1,340 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-using namespace cv;
-using namespace std;
-
-class CV_SubdivTest : public cvtest::BaseTest
-{
-public:
-    CV_SubdivTest();
-    ~CV_SubdivTest();
-    void clear();
-
-protected:
-    int read_params( CvFileStorage* fs );
-    int prepare_test_case( int test_case_idx );
-    int validate_test_results( int test_case_idx );
-    void run_func();
-
-    int min_log_img_size, max_log_img_size;
-    CvSize img_size;
-    int min_log_point_count;
-    int max_log_point_count;
-    int point_count;
-    CvSubdiv2D* subdiv;
-    CvMemStorage* storage;
-};
-
-
-CV_SubdivTest::CV_SubdivTest()
-{
-    test_case_count = 100;
-    min_log_point_count = 1;
-    max_log_point_count = 10;
-    min_log_img_size = 1;
-    max_log_img_size = 10;
-
-    storage = 0;
-}
-
-
-CV_SubdivTest::~CV_SubdivTest()
-{
-    clear();
-}
-
-
-void CV_SubdivTest::clear()
-{
-    cvtest::BaseTest::clear();
-    cvReleaseMemStorage( &storage );
-}
-
-
-int CV_SubdivTest::read_params( CvFileStorage* fs )
-{
-    int code = cvtest::BaseTest::read_params( fs );
-    int t;
-
-    if( code < 0 )
-        return code;
-
-    test_case_count = cvReadInt( find_param( fs, "test_case_count" ), test_case_count );
-    min_log_point_count = cvReadInt( find_param( fs, "min_log_point_count" ), min_log_point_count );
-    max_log_point_count = cvReadInt( find_param( fs, "max_log_point_count" ), max_log_point_count );
-    min_log_img_size = cvReadInt( find_param( fs, "min_log_img_size" ), min_log_img_size );
-    max_log_img_size = cvReadInt( find_param( fs, "max_log_img_size" ), max_log_img_size );
-
-    min_log_point_count = cvtest::clipInt( min_log_point_count, 1, 10 );
-    max_log_point_count = cvtest::clipInt( max_log_point_count, 1, 10 );
-    if( min_log_point_count > max_log_point_count )
-        CV_SWAP( min_log_point_count, max_log_point_count, t );
-
-    min_log_img_size = cvtest::clipInt( min_log_img_size, 1, 10 );
-    max_log_img_size = cvtest::clipInt( max_log_img_size, 1, 10 );
-    if( min_log_img_size > max_log_img_size )
-        CV_SWAP( min_log_img_size, max_log_img_size, t );
-
-    return 0;
-}
-
-
-int CV_SubdivTest::prepare_test_case( int test_case_idx )
-{
-    RNG& rng = ts->get_rng();
-    int code = cvtest::BaseTest::prepare_test_case( test_case_idx );
-    if( code < 0 )
-        return code;
-
-    clear();
-
-    point_count = cvRound(exp((cvtest::randReal(rng)*
-        (max_log_point_count - min_log_point_count) + min_log_point_count)*CV_LOG2));
-    img_size.width = cvRound(exp((cvtest::randReal(rng)*
-        (max_log_img_size - min_log_img_size) + min_log_img_size)*CV_LOG2));
-    img_size.height = cvRound(exp((cvtest::randReal(rng)*
-        (max_log_img_size - min_log_img_size) + min_log_img_size)*CV_LOG2));
-
-    storage = cvCreateMemStorage( 1 << 10 );
-    return 1;
-}
-
-
-void CV_SubdivTest::run_func()
-{
-}
-
-
-static inline double sqdist( CvPoint2D32f pt1, CvPoint2D32f pt2 )
-{
-    double dx = pt1.x - pt2.x;
-    double dy = pt1.y - pt2.y;
-
-    return dx*dx + dy*dy;
-}
-
-
-static int
-subdiv2DCheck( CvSubdiv2D* subdiv )
-{
-    int i, j, total = subdiv->edges->total;
-    CV_Assert( subdiv != 0 );
-
-    for( i = 0; i < total; i++ )
-    {
-        CvQuadEdge2D* edge = (CvQuadEdge2D*)cvGetSetElem(subdiv->edges,i);
-
-        if( edge && CV_IS_SET_ELEM( edge ))
-        {
-            for( j = 0; j < 4; j++ )
-            {
-                CvSubdiv2DEdge e = (CvSubdiv2DEdge)edge + j;
-                CvSubdiv2DEdge o_next = cvSubdiv2DNextEdge(e);
-                CvSubdiv2DEdge o_prev = cvSubdiv2DGetEdge(e, CV_PREV_AROUND_ORG );
-                CvSubdiv2DEdge d_prev = cvSubdiv2DGetEdge(e, CV_PREV_AROUND_DST );
-                CvSubdiv2DEdge d_next = cvSubdiv2DGetEdge(e, CV_NEXT_AROUND_DST );
-
-                // check points
-                if( cvSubdiv2DEdgeOrg(e) != cvSubdiv2DEdgeOrg(o_next))
-                    return 0;
-                if( cvSubdiv2DEdgeOrg(e) != cvSubdiv2DEdgeOrg(o_prev))
-                    return 0;
-                if( cvSubdiv2DEdgeDst(e) != cvSubdiv2DEdgeDst(d_next))
-                    return 0;
-                if( cvSubdiv2DEdgeDst(e) != cvSubdiv2DEdgeDst(d_prev))
-                    return 0;
-                if( j % 2 == 0 )
-                {
-                    if( cvSubdiv2DEdgeDst(o_next) != cvSubdiv2DEdgeOrg(d_prev))
-                        return 0;
-                    if( cvSubdiv2DEdgeDst(o_prev) != cvSubdiv2DEdgeOrg(d_next))
-                        return 0;
-                    if( cvSubdiv2DGetEdge(cvSubdiv2DGetEdge(cvSubdiv2DGetEdge(
-                                    e,CV_NEXT_AROUND_LEFT),CV_NEXT_AROUND_LEFT),CV_NEXT_AROUND_LEFT) != e )
-                        return 0;
-                    if( cvSubdiv2DGetEdge(cvSubdiv2DGetEdge(cvSubdiv2DGetEdge(
-                                    e,CV_NEXT_AROUND_RIGHT),CV_NEXT_AROUND_RIGHT),CV_NEXT_AROUND_RIGHT) != e)
-                        return 0;
-                }
-            }
-        }
-    }
-
-    return 1;
-}
-
-
-// the whole testing is done here, run_func() is not utilized in this test
-int CV_SubdivTest::validate_test_results( int /*test_case_idx*/ )
-{
-    int code = cvtest::TS::OK;
-    RNG& rng = ts->get_rng();
-    int j, k, real_count = point_count;
-    double xrange = img_size.width*(1 - FLT_EPSILON);
-    double yrange = img_size.height*(1 - FLT_EPSILON);
-
-    subdiv = cvCreateSubdivDelaunay2D(
-        cvRect( 0, 0, img_size.width, img_size.height ), storage );
-
-    CvSeq* seq = cvCreateSeq( 0, sizeof(*seq), sizeof(CvPoint2D32f), storage );
-    CvSeqWriter writer;
-    cvStartAppendToSeq( seq, &writer );
-
-    // insert random points
-    for( j = 0; j < point_count; j++ )
-    {
-        CvPoint2D32f pt;
-        CvSubdiv2DPoint* point;
-
-        pt.x = (float)(cvtest::randReal(rng)*xrange);
-        pt.y = (float)(cvtest::randReal(rng)*yrange);
-
-        CvSubdiv2DPointLocation loc =
-            cvSubdiv2DLocate( subdiv, pt, 0, &point );
-
-        if( loc == CV_PTLOC_VERTEX )
-        {
-            int index = cvSeqElemIdx( (CvSeq*)subdiv, point );
-            CvPoint2D32f* pt1;
-            cvFlushSeqWriter( &writer );
-            pt1 = (CvPoint2D32f*)cvGetSeqElem( seq, index - 3 );
-
-            if( !pt1 ||
-                fabs(pt1->x - pt.x) > FLT_EPSILON ||
-                fabs(pt1->y - pt.y) > FLT_EPSILON )
-            {
-                ts->printf( cvtest::TS::LOG, "The point #%d: (%.1f,%.1f) is said to coinside with a subdivision vertex, "
-                    "however it could be found in a sequence of inserted points\n", j, pt.x, pt.y );
-                code = cvtest::TS::FAIL_INVALID_OUTPUT;
-                goto _exit_;
-            }
-            real_count--;
-        }
-
-        point = cvSubdivDelaunay2DInsert( subdiv, pt );
-        if( point->pt.x != pt.x || point->pt.y != pt.y )
-        {
-            ts->printf( cvtest::TS::LOG, "The point #%d: (%.1f,%.1f) has been incorrectly added\n", j, pt.x, pt.y );
-            code = cvtest::TS::FAIL_INVALID_OUTPUT;
-            goto _exit_;
-        }
-
-        if( (j + 1) % 10 == 0 || j == point_count - 1 )
-        {
-            if( !subdiv2DCheck( subdiv ))
-            {
-                ts->printf( cvtest::TS::LOG, "Subdivision consistency check failed after inserting the point #%d\n", j );
-                code = cvtest::TS::FAIL_INVALID_OUTPUT;
-                goto _exit_;
-            }
-        }
-
-        if( loc != CV_PTLOC_VERTEX )
-        {
-            CV_WRITE_SEQ_ELEM( pt, writer );
-        }
-    }
-
-    if( code < 0 )
-        goto _exit_;
-
-    cvCalcSubdivVoronoi2D( subdiv );
-    seq = cvEndWriteSeq( &writer );
-
-    if( !subdiv2DCheck( subdiv ))
-    {
-        ts->printf( cvtest::TS::LOG, "The subdivision failed consistency check after building the Voronoi tesselation\n" );
-        code = cvtest::TS::FAIL_INVALID_OUTPUT;
-        goto _exit_;
-    }
-
-    for( j = 0; j < MAX((point_count - 5)/10 + 5, 10); j++ )
-    {
-        CvPoint2D32f pt;
-        double minDistance;
-
-        pt.x = (float)(cvtest::randReal(rng)*xrange);
-        pt.y = (float)(cvtest::randReal(rng)*yrange);
-
-        CvSubdiv2DPoint* point = cvFindNearestPoint2D( subdiv, pt );
-        CvSeqReader reader;
-
-        if( !point )
-        {
-            ts->printf( cvtest::TS::LOG, "There is no nearest point (?!) for the point (%.1f, %.1f) in the subdivision\n",
-                pt.x, pt.y );
-            code = cvtest::TS::FAIL_INVALID_OUTPUT;
-            goto _exit_;
-        }
-
-        cvStartReadSeq( seq, &reader );
-        minDistance = sqdist( pt, point->pt );
-
-        for( k = 0; k < seq->total; k++ )
-        {
-            CvPoint2D32f ptt;
-            CV_READ_SEQ_ELEM( ptt, reader );
-
-            double distance = sqdist( pt, ptt );
-            if( minDistance > distance && sqdist(ptt, point->pt) > FLT_EPSILON*1000 )
-            {
-                ts->printf( cvtest::TS::LOG, "The triangulation vertex (%.3f,%.3f) was said to be nearest to (%.3f,%.3f),\n"
-                    "whereas another vertex (%.3f,%.3f) is closer\n",
-                    point->pt.x, point->pt.y, pt.x, pt.y, ptt.x, ptt.y );
-                code = cvtest::TS::FAIL_BAD_ACCURACY;
-                goto _exit_;
-            }
-        }
-    }
-
-_exit_:
-    if( code < 0 )
-        ts->set_failed_test_info( code );
-
-    return code;
-}
-
-TEST(Legacy_Subdiv, correctness) { CV_SubdivTest test; test.safe_run(); }
-
-/* End of file. */
index d62e529..6ba8ff3 100644 (file)
@@ -46,7 +46,6 @@
 
 #include "opencv2/core.hpp"
 
-typedef struct CvLatentSvmDetector CvLatentSvmDetector;
 typedef struct CvHaarClassifierCascade CvHaarClassifierCascade;
 
 namespace cv
@@ -54,45 +53,6 @@ namespace cv
 
 ///////////////////////////// Object Detection ////////////////////////////
 
-/*
- * This is a class wrapping up the structure CvLatentSvmDetector and functions working with it.
- * The class goals are:
- * 1) provide c++ interface;
- * 2) make it possible to load and detect more than one class (model) unlike CvLatentSvmDetector.
- */
-class CV_EXPORTS LatentSvmDetector
-{
-public:
-    struct CV_EXPORTS ObjectDetection
-    {
-        ObjectDetection();
-        ObjectDetection( const Rect& rect, float score, int classID = -1 );
-        Rect rect;
-        float score;
-        int classID;
-    };
-
-    LatentSvmDetector();
-    LatentSvmDetector( const std::vector<String>& filenames, const std::vector<String>& classNames = std::vector<String>() );
-    virtual ~LatentSvmDetector();
-
-    virtual void clear();
-    virtual bool empty() const;
-    bool load( const std::vector<String>& filenames, const std::vector<String>& classNames = std::vector<String>() );
-
-    virtual void detect( const Mat& image,
-                         std::vector<ObjectDetection>& objectDetections,
-                         float overlapThreshold = 0.5f,
-                         int numThreads = -1 );
-
-    const std::vector<String>& getClassNames() const;
-    size_t getClassCount() const;
-
-private:
-    std::vector<CvLatentSvmDetector*> detectors;
-    std::vector<String> classNames;
-};
-
 // class for grouping object candidates, detected by Cascade Classifier, HOG etc.
 // instance of the class is to be passed to cv::partition (see cxoperations.hpp)
 class CV_EXPORTS SimilarRects
@@ -353,15 +313,6 @@ public:
     void groupRectangles(std::vector<cv::Rect>& rectList, std::vector<double>& weights, int groupThreshold, double eps) const;
 };
 
-
-CV_EXPORTS_W void findDataMatrix(InputArray image,
-                                 CV_OUT std::vector<String>& codes,
-                                 OutputArray corners = noArray(),
-                                 OutputArrayOfArrays dmtx = noArray());
-
-CV_EXPORTS_W void drawDataMatrixCodes(InputOutputArray image,
-                                      const std::vector<String>& codes,
-                                      InputArray corners);
 }
 
 #include "opencv2/objdetect/linemod.hpp"
index 1d6fd2b..807efd7 100644 (file)
@@ -144,125 +144,6 @@ CVAPI(int) cvRunHaarClassifierCascade( const CvHaarClassifierCascade* cascade,
                                        CvPoint pt, int start_stage CV_DEFAULT(0));
 
 
-/****************************************************************************************\
-*                         Latent SVM Object Detection functions                          *
-\****************************************************************************************/
-
-// DataType: STRUCT position
-// Structure describes the position of the filter in the feature pyramid
-// l - level in the feature pyramid
-// (x, y) - coordinate in level l
-typedef struct CvLSVMFilterPosition
-{
-    int x;
-    int y;
-    int l;
-} CvLSVMFilterPosition;
-
-// DataType: STRUCT filterObject
-// Description of the filter, which corresponds to the part of the object
-// V               - ideal (penalty = 0) position of the partial filter
-//                   from the root filter position (V_i in the paper)
-// penaltyFunction - vector describes penalty function (d_i in the paper)
-//                   pf[0] * x + pf[1] * y + pf[2] * x^2 + pf[3] * y^2
-// FILTER DESCRIPTION
-//   Rectangular map (sizeX x sizeY),
-//   every cell stores feature vector (dimension = p)
-// H               - matrix of feature vectors
-//                   to set and get feature vectors (i,j)
-//                   used formula H[(j * sizeX + i) * p + k], where
-//                   k - component of feature vector in cell (i, j)
-// END OF FILTER DESCRIPTION
-typedef struct CvLSVMFilterObject{
-    CvLSVMFilterPosition V;
-    float fineFunction[4];
-    int sizeX;
-    int sizeY;
-    int numFeatures;
-    float *H;
-} CvLSVMFilterObject;
-
-// data type: STRUCT CvLatentSvmDetector
-// structure contains internal representation of trained Latent SVM detector
-// num_filters          - total number of filters (root plus part) in model
-// num_components       - number of components in model
-// num_part_filters     - array containing number of part filters for each component
-// filters              - root and part filters for all model components
-// b                    - biases for all model components
-// score_threshold      - confidence level threshold
-typedef struct CvLatentSvmDetector
-{
-    int num_filters;
-    int num_components;
-    int* num_part_filters;
-    CvLSVMFilterObject** filters;
-    float* b;
-    float score_threshold;
-} CvLatentSvmDetector;
-
-// data type: STRUCT CvObjectDetection
-// structure contains the bounding box and confidence level for detected object
-// rect                 - bounding box for a detected object
-// score                - confidence level
-typedef struct CvObjectDetection
-{
-    CvRect rect;
-    float score;
-} CvObjectDetection;
-
-//////////////// Object Detection using Latent SVM //////////////
-
-
-/*
-// load trained detector from a file
-//
-// API
-// CvLatentSvmDetector* cvLoadLatentSvmDetector(const char* filename);
-// INPUT
-// filename             - path to the file containing the parameters of
-                        - trained Latent SVM detector
-// OUTPUT
-// trained Latent SVM detector in internal representation
-*/
-CVAPI(CvLatentSvmDetector*) cvLoadLatentSvmDetector(const char* filename);
-
-/*
-// release memory allocated for CvLatentSvmDetector structure
-//
-// API
-// void cvReleaseLatentSvmDetector(CvLatentSvmDetector** detector);
-// INPUT
-// detector             - CvLatentSvmDetector structure to be released
-// OUTPUT
-*/
-CVAPI(void) cvReleaseLatentSvmDetector(CvLatentSvmDetector** detector);
-
-/*
-// find rectangular regions in the given image that are likely
-// to contain objects and corresponding confidence levels
-//
-// API
-// CvSeq* cvLatentSvmDetectObjects(const IplImage* image,
-//                                  CvLatentSvmDetector* detector,
-//                                  CvMemStorage* storage,
-//                                  float overlap_threshold = 0.5f,
-//                                  int numThreads = -1);
-// INPUT
-// image                - image to detect objects in
-// detector             - Latent SVM detector in internal representation
-// storage              - memory storage to store the resultant sequence
-//                          of the object candidate rectangles
-// overlap_threshold    - threshold for the non-maximum suppression algorithm
-                           = 0.5f [here will be the reference to original paper]
-// OUTPUT
-// sequence of detected objects (bounding boxes and confidence levels stored in CvObjectDetection structures)
-*/
-CVAPI(CvSeq*) cvLatentSvmDetectObjects(IplImage* image,
-                                CvLatentSvmDetector* detector,
-                                CvMemStorage* storage,
-                                float overlap_threshold CV_DEFAULT(0.5f),
-                                int numThreads CV_DEFAULT(-1));
-
 #ifdef __cplusplus
 }
 
@@ -274,16 +155,6 @@ CV_EXPORTS CvSeq* cvHaarDetectObjectsForROC( const CvArr* image,
                      CvSize min_size = cvSize(0, 0), CvSize max_size = cvSize(0, 0),
                      bool outputRejectLevels = false );
 
-struct CvDataMatrixCode
-{
-  char msg[4];
-  CvMat* original;
-  CvMat* corners;
-};
-
-CV_EXPORTS std::deque<CvDataMatrixCode> cvFindDataMatrix(CvMat *im);
-
 #endif
 
-
 #endif /* __OPENCV_OBJDETECT_C_H__ */
diff --git a/modules/objdetect/src/_latentsvm.h b/modules/objdetect/src/_latentsvm.h
deleted file mode 100644 (file)
index 757f1a8..0000000
+++ /dev/null
@@ -1,398 +0,0 @@
-/*****************************************************************************/
-/*                      Latent SVM prediction API                            */
-/*****************************************************************************/
-
-#ifndef _LATENTSVM_H_
-#define _LATENTSVM_H_
-
-#include <stdio.h>
-#include "_lsvm_types.h"
-#include "_lsvm_error.h"
-#include "_lsvm_routine.h"
-
-//////////////////////////////////////////////////////////////
-// Building feature pyramid
-// (pyramid constructed both contrast and non-contrast image)
-//////////////////////////////////////////////////////////////
-
-/*
-// Getting feature pyramid
-//
-// API
-// int getFeaturePyramid(IplImage * image, const filterObject **all_F,
-                      const int n_f,
-                      const int lambda, const int k,
-                      const int startX, const int startY,
-                      const int W, const int H, featurePyramid **maps);
-// INPUT
-// image             - image
-// lambda            - resize scale
-// k                 - size of cells
-// startX            - X coordinate of the image rectangle to search
-// startY            - Y coordinate of the image rectangle to search
-// W                 - width of the image rectangle to search
-// H                 - height of the image rectangle to search
-// OUTPUT
-// maps              - feature maps for all levels
-// RESULT
-// Error status
-*/
-int getFeaturePyramid(IplImage * image, CvLSVMFeaturePyramid **maps);
-
-/*
-// Getting feature map for the selected subimage
-//
-// API
-// int getFeatureMaps(const IplImage * image, const int k, featureMap **map);
-// INPUT
-// image             - selected subimage
-// k                 - size of cells
-// OUTPUT
-// map               - feature map
-// RESULT
-// Error status
-*/
-int getFeatureMaps(const IplImage * image, const int k, CvLSVMFeatureMap **map);
-
-
-/*
-// Feature map Normalization and Truncation
-//
-// API
-// int normalizationAndTruncationFeatureMaps(featureMap *map, const float alfa);
-// INPUT
-// map               - feature map
-// alfa              - truncation threshold
-// OUTPUT
-// map               - truncated and normalized feature map
-// RESULT
-// Error status
-*/
-int normalizeAndTruncate(CvLSVMFeatureMap *map, const float alfa);
-
-/*
-// Feature map reduction
-// In each cell we reduce dimension of the feature vector
-// according to original paper special procedure
-//
-// API
-// int PCAFeatureMaps(featureMap *map)
-// INPUT
-// map               - feature map
-// OUTPUT
-// map               - feature map
-// RESULT
-// Error status
-*/
-int PCAFeatureMaps(CvLSVMFeatureMap *map);
-
-//////////////////////////////////////////////////////////////
-// search object
-//////////////////////////////////////////////////////////////
-
-/*
-// Transformation filter displacement from the block space
-// to the space of pixels at the initial image
-//
-// API
-// int convertPoints(int countLevel, int lambda,
-                     int initialImageLevel,
-                     CvPoint *points, int *levels,
-                     CvPoint **partsDisplacement, int kPoints, int n,
-                     int maxXBorder,
-                     int maxYBorder);
-// INPUT
-// countLevel        - the number of levels in the feature pyramid
-// lambda            - method parameter
-// initialImageLevel - level of feature pyramid that contains feature map
-                       for initial image
-// points            - the set of root filter positions (in the block space)
-// levels            - the set of levels
-// partsDisplacement - displacement of part filters (in the block space)
-// kPoints           - number of root filter positions
-// n                 - number of part filters
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// OUTPUT
-// points            - the set of root filter positions (in the space of pixels)
-// partsDisplacement - displacement of part filters (in the space of pixels)
-// RESULT
-// Error status
-*/
-int convertPoints(int countLevel, int lambda,
-                  int initialImageLevel,
-                  CvPoint *points, int *levels,
-                  CvPoint **partsDisplacement, int kPoints, int n,
-                  int maxXBorder,
-                  int maxYBorder);
-
-/*
-// Elimination boxes that are outside the image boudaries
-//
-// API
-// int clippingBoxes(int width, int height,
-                     CvPoint *points, int kPoints);
-// INPUT
-// width             - image wediht
-// height            - image heigth
-// points            - a set of points (coordinates of top left or
-                       bottom right corners)
-// kPoints           - points number
-// OUTPUT
-// points            - updated points (if coordinates less than zero then
-                       set zero coordinate, if coordinates more than image
-                       size then set coordinates equal image size)
-// RESULT
-// Error status
-*/
-#ifdef __cplusplus
-extern "C"
-#endif
-int clippingBoxes(int width, int height,
-                  CvPoint *points, int kPoints);
-
-/*
-// Creation feature pyramid with nullable border
-//
-// API
-// featurePyramid* createFeaturePyramidWithBorder(const IplImage *image,
-                                                  int maxXBorder, int maxYBorder);
-
-// INPUT
-// image             - initial image
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// OUTPUT
-// RESULT
-// Feature pyramid with nullable border
-*/
-#ifdef __cplusplus
-extern "C"
-#endif
-CvLSVMFeaturePyramid* createFeaturePyramidWithBorder(IplImage *image,
-                                               int maxXBorder, int maxYBorder);
-
-/*
-// Computation of the root filter displacement and values of score function
-//
-// API
-// int searchObject(const featurePyramid *H, const filterObject **all_F, int n,
-                    float b,
-                    int maxXBorder,
-                    int maxYBorder,
-                    CvPoint **points, int **levels, int *kPoints, float *score,
-                    CvPoint ***partsDisplacement);
-// INPUT
-// H                 - feature pyramid
-// all_F             - the set of filters (the first element is root filter,
-                       other elements - part filters)
-// n                 - the number of part filters
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// OUTPUT
-// points            - positions (x, y) of the upper-left corner
-                       of root filter frame
-// levels            - levels that correspond to each position
-// kPoints           - number of positions
-// score             - value of the score function
-// partsDisplacement - part filters displacement for each position
-                       of the root filter
-// RESULT
-// Error status
-*/
-int searchObject(const CvLSVMFeaturePyramid *H, const CvLSVMFilterObject **all_F, int n,
-                 float b,
-                 int maxXBorder,
-                 int maxYBorder,
-                 CvPoint **points, int **levels, int *kPoints, float *score,
-                 CvPoint ***partsDisplacement);
-
-/*
-// Computation of the root filter displacement and values of score function
-//
-// API
-// int searchObjectThreshold(const featurePyramid *H,
-                             const filterObject **all_F, int n,
-                             float b,
-                             int maxXBorder, int maxYBorder,
-                             float scoreThreshold,
-                             CvPoint **points, int **levels, int *kPoints,
-                             float **score, CvPoint ***partsDisplacement);
-// INPUT
-// H                 - feature pyramid
-// all_F             - the set of filters (the first element is root filter,
-                       other elements - part filters)
-// n                 - the number of part filters
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// scoreThreshold    - score threshold
-// OUTPUT
-// points            - positions (x, y) of the upper-left corner
-                       of root filter frame
-// levels            - levels that correspond to each position
-// kPoints           - number of positions
-// score             - values of the score function
-// partsDisplacement - part filters displacement for each position
-                       of the root filter
-// RESULT
-// Error status
-*/
-int searchObjectThreshold(const CvLSVMFeaturePyramid *H,
-                          const CvLSVMFilterObject **all_F, int n,
-                          float b,
-                          int maxXBorder, int maxYBorder,
-                          float scoreThreshold,
-                          CvPoint **points, int **levels, int *kPoints,
-                          float **score, CvPoint ***partsDisplacement,
-                          int numThreads CV_DEFAULT(-1));
-
-/*
-// Computation root filters displacement and values of score function
-//
-// API
-// int searchObjectThresholdSomeComponents(const featurePyramid *H,
-                                           const filterObject **filters,
-                                           int kComponents, const int *kPartFilters,
-                                           const float *b, float scoreThreshold,
-                                           CvPoint **points, CvPoint **oppPoints,
-                                           float **score, int *kPoints);
-// INPUT
-// H                 - feature pyramid
-// filters           - filters (root filter then it's part filters, etc.)
-// kComponents       - root filters number
-// kPartFilters      - array of part filters number for each component
-// b                 - array of linear terms
-// scoreThreshold    - score threshold
-// OUTPUT
-// points            - root filters displacement (top left corners)
-// oppPoints         - root filters displacement (bottom right corners)
-// score             - array of score values
-// kPoints           - number of boxes
-// RESULT
-// Error status
-*/
-#ifdef __cplusplus
-extern "C"
-#endif
-int searchObjectThresholdSomeComponents(const CvLSVMFeaturePyramid *H,
-                                        const CvLSVMFilterObject **filters,
-                                        int kComponents, const int *kPartFilters,
-                                        const float *b, float scoreThreshold,
-                                        CvPoint **points, CvPoint **oppPoints,
-                                        float **score, int *kPoints, int numThreads);
-
-/*
-// Compute opposite point for filter box
-//
-// API
-// int getOppositePoint(CvPoint point,
-                        int sizeX, int sizeY,
-                        float step, int degree,
-                        CvPoint *oppositePoint);
-
-// INPUT
-// point             - coordinates of filter top left corner
-                       (in the space of pixels)
-// (sizeX, sizeY)    - filter dimension in the block space
-// step              - scaling factor
-// degree            - degree of the scaling factor
-// OUTPUT
-// oppositePoint     - coordinates of filter bottom corner
-                       (in the space of pixels)
-// RESULT
-// Error status
-*/
-int getOppositePoint(CvPoint point,
-                     int sizeX, int sizeY,
-                     float step, int degree,
-                     CvPoint *oppositePoint);
-
-/*
-// Drawing root filter boxes
-//
-// API
-// int showRootFilterBoxes(const IplImage *image,
-                           const filterObject *filter,
-                           CvPoint *points, int *levels, int kPoints,
-                           CvScalar color, int thickness,
-                           int line_type, int shift);
-// INPUT
-// image             - initial image
-// filter            - root filter object
-// points            - a set of points
-// levels            - levels of feature pyramid
-// kPoints           - number of points
-// color             - line color for each box
-// thickness         - line thickness
-// line_type         - line type
-// shift             - shift
-// OUTPUT
-// window contained initial image and filter boxes
-// RESULT
-// Error status
-*/
-int showRootFilterBoxes(IplImage *image,
-                        const CvLSVMFilterObject *filter,
-                        CvPoint *points, int *levels, int kPoints,
-                        CvScalar color, int thickness,
-                        int line_type, int shift);
-
-/*
-// Drawing part filter boxes
-//
-// API
-// int showPartFilterBoxes(const IplImage *image,
-                           const filterObject *filter,
-                           CvPoint *points, int *levels, int kPoints,
-                           CvScalar color, int thickness,
-                           int line_type, int shift);
-// INPUT
-// image             - initial image
-// filters           - a set of part filters
-// n                 - number of part filters
-// partsDisplacement - a set of points
-// levels            - levels of feature pyramid
-// kPoints           - number of foot filter positions
-// color             - line color for each box
-// thickness         - line thickness
-// line_type         - line type
-// shift             - shift
-// OUTPUT
-// window contained initial image and filter boxes
-// RESULT
-// Error status
-*/
-int showPartFilterBoxes(IplImage *image,
-                        const CvLSVMFilterObject **filters,
-                        int n, CvPoint **partsDisplacement,
-                        int *levels, int kPoints,
-                        CvScalar color, int thickness,
-                        int line_type, int shift);
-
-/*
-// Drawing boxes
-//
-// API
-// int showBoxes(const IplImage *img,
-                 const CvPoint *points, const CvPoint *oppositePoints, int kPoints,
-                 CvScalar color, int thickness, int line_type, int shift);
-// INPUT
-// img               - initial image
-// points            - top left corner coordinates
-// oppositePoints    - right bottom corner coordinates
-// kPoints           - points number
-// color             - line color for each box
-// thickness         - line thickness
-// line_type         - line type
-// shift             - shift
-// OUTPUT
-// RESULT
-// Error status
-*/
-int showBoxes(IplImage *img,
-              const CvPoint *points, const CvPoint *oppositePoints, int kPoints,
-              CvScalar color, int thickness, int line_type, int shift);
-
-#endif
diff --git a/modules/objdetect/src/_lsvm_distancetransform.h b/modules/objdetect/src/_lsvm_distancetransform.h
deleted file mode 100644 (file)
index 8554065..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-#ifndef _LSVM_DIST_TRANSFORM_H_
-#define _LSVM_DIST_TRANSFORM_H_
-
-#include "_lsvm_types.h"
-#include "_lsvm_error.h"
-
-/*
-// Computation the point of intersection functions
-// (parabolas on the variable y)
-//      a(y - q1) + b(q1 - y)(q1 - y) + f[q1]
-//      a(y - q2) + b(q2 - y)(q2 - y) + f[q2]
-//
-// API
-// int GetPointOfIntersection(const F_type *f,
-                              const F_type a, const F_type b,
-                              int q1, int q2, F_type *point);
-// INPUT
-// f                - function on the regular grid
-// a                - coefficient of the function
-// b                - coefficient of the function
-// q1               - parameter of the function
-// q2               - parameter of the function
-// OUTPUT
-// point            - point of intersection
-// RESULT
-// Error status
-*/
-int GetPointOfIntersection(const float *f,
-                           const float a, const float b,
-                           int q1, int q2, float *point);
-
-/*
-// Decision of one dimensional problem generalized distance transform
-// on the regular grid at all points
-//      min (a(y' - y) + b(y' - y)(y' - y) + f(y')) (on y')
-//
-// API
-// int DistanceTransformOneDimensionalProblem(const F_type *f, const int n,
-                                              const F_type a, const F_type b,
-                                              F_type *distanceTransform,
-                                              int *points);
-// INPUT
-// f                 - function on the regular grid
-// n                 - grid dimension
-// a                 - coefficient of optimizable function
-// b                 - coefficient of optimizable function
-// OUTPUT
-// distanceTransform - values of generalized distance transform
-// points            - arguments that corresponds to the optimal value of function
-// RESULT
-// Error status
-*/
-int DistanceTransformOneDimensionalProblem(const float *f, const int n,
-                                           const float a, const float b,
-                                           float *distanceTransform,
-                                           int *points);
-
-/*
-// Computation next cycle element
-//
-// API
-// int GetNextCycleElement(int k, int n, int q);
-// INPUT
-// k                 - index of the previous cycle element
-// n                 - number of matrix rows
-// q                 - parameter that equal (number_of_rows * number_of_columns - 1)
-// OUTPUT
-// None
-// RESULT
-// Next cycle element
-*/
-int GetNextCycleElement(int k, int n, int q);
-
-/*
-// Transposition of cycle elements
-//
-// API
-// void TransposeCycleElements(F_type *a, int *cycle, int cycle_len);
-// INPUT
-// a                 - initial matrix
-// cycle             - cycle
-// cycle_len         - cycle length
-// OUTPUT
-// a                 - matrix with transposed elements
-// RESULT
-// None
-*/
-void TransposeCycleElements(float *a, int *cycle, int cycle_len);
-
-/*
-// Getting transposed matrix
-//
-// API
-// void Transpose(F_type *a, int n, int m);
-// INPUT
-// a                 - initial matrix
-// n                 - number of rows
-// m                 - number of columns
-// OUTPUT
-// a                 - transposed matrix
-// RESULT
-// Error status
-*/
-void Transpose(float *a, int n, int m);
-
-/*
-// Decision of two dimensional problem generalized distance transform
-// on the regular grid at all points
-//      min{d2(y' - y) + d4(y' - y)(y' - y) +
-            min(d1(x' - x) + d3(x' - x)(x' - x) + f(x',y'))} (on x', y')
-//
-// API
-// int DistanceTransformTwoDimensionalProblem(const F_type *f,
-                                              const int n, const int m,
-                                              const F_type coeff[4],
-                                              F_type *distanceTransform,
-                                              int *pointsX, int *pointsY);
-// INPUT
-// f                 - function on the regular grid
-// n                 - number of rows
-// m                 - number of columns
-// coeff             - coefficients of optimizable function
-                       coeff[0] = d1, coeff[1] = d2,
-                       coeff[2] = d3, coeff[3] = d4
-// OUTPUT
-// distanceTransform - values of generalized distance transform
-// pointsX           - arguments x' that correspond to the optimal value
-// pointsY           - arguments y' that correspond to the optimal value
-// RESULT
-// Error status
-*/
-int DistanceTransformTwoDimensionalProblem(const float *f,
-                                           const int n, const int m,
-                                           const float coeff[4],
-                                           float *distanceTransform,
-                                           int *pointsX, int *pointsY);
-
-#endif
diff --git a/modules/objdetect/src/_lsvm_error.h b/modules/objdetect/src/_lsvm_error.h
deleted file mode 100644 (file)
index 76b6be7..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef LSVM_ERROR
-#define LSVM_ERROR
-
-#define LATENT_SVM_OK 0
-#define LATENT_SVM_MEM_NULL 2
-#define DISTANCE_TRANSFORM_OK 1
-#define DISTANCE_TRANSFORM_GET_INTERSECTION_ERROR -1
-#define DISTANCE_TRANSFORM_ERROR -2
-#define DISTANCE_TRANSFORM_EQUAL_POINTS -3
-#define LATENT_SVM_GET_FEATURE_PYRAMID_FAILED -4
-#define LATENT_SVM_SEARCH_OBJECT_FAILED -5
-#define LATENT_SVM_FAILED_SUPERPOSITION -6
-#define FILTER_OUT_OF_BOUNDARIES -7
-#define LATENT_SVM_TBB_SCHEDULE_CREATION_FAILED -8
-#define LATENT_SVM_TBB_NUMTHREADS_NOT_CORRECT -9
-#define FFT_OK 2
-#define FFT_ERROR -10
-#define LSVM_PARSER_FILE_NOT_FOUND -11
-
-#endif
diff --git a/modules/objdetect/src/_lsvm_fft.h b/modules/objdetect/src/_lsvm_fft.h
deleted file mode 100644 (file)
index 962f923..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef _LSVM_FFT_H_
-#define _LSVM_FFT_H_
-
-#include "_lsvm_types.h"
-#include "_lsvm_error.h"
-#include <math.h>
-
-/*
-// 1-dimensional FFT
-//
-// API
-// int fft(float *x_in, float *x_out, int n, int shift);
-// INPUT
-// x_in              - input signal
-// n                 - number of elements for searching Fourier image
-// shift             - shift between input elements
-// OUTPUT
-// x_out             - output signal (contains 2n elements in order
-                       Re(x_in[0]), Im(x_in[0]), Re(x_in[1]), Im(x_in[1]) and etc.)
-// RESULT
-// Error status
-*/
-int fft(float *x_in, float *x_out, int n, int shift);
-
-/*
-// Inverse 1-dimensional FFT
-//
-// API
-// int fftInverse(float *x_in, float *x_out, int n, int shift);
-// INPUT
-// x_in              - Fourier image of 1d input signal(contains 2n elements
-                       in order Re(x_in[0]), Im(x_in[0]),
-                       Re(x_in[1]), Im(x_in[1]) and etc.)
-// n                 - number of elements for searching counter FFT image
-// shift             - shift between input elements
-// OUTPUT
-// x_in              - input signal (contains n elements)
-// RESULT
-// Error status
-*/
-int fftInverse(float *x_in, float *x_out, int n, int shift);
-
-/*
-// 2-dimensional FFT
-//
-// API
-// int fft2d(float *x_in, float *x_out, int numRows, int numColls);
-// INPUT
-// x_in              - input signal (matrix, launched by rows)
-// numRows           - number of rows
-// numColls          - number of collumns
-// OUTPUT
-// x_out             - output signal (contains (2 * numRows * numColls) elements
-                       in order Re(x_in[0][0]), Im(x_in[0][0]),
-                       Re(x_in[0][1]), Im(x_in[0][1]) and etc.)
-// RESULT
-// Error status
-*/
-int fft2d(float *x_in, float *x_out, int numRows, int numColls);
-
-/*
-// Inverse 2-dimensional FFT
-//
-// API
-// int fftInverse2d(float *x_in, float *x_out, int numRows, int numColls);
-// INPUT
-// x_in              - Fourier image of matrix (contains (2 * numRows * numColls)
-                       elements in order Re(x_in[0][0]), Im(x_in[0][0]),
-                       Re(x_in[0][1]), Im(x_in[0][1]) and etc.)
-// numRows           - number of rows
-// numColls          - number of collumns
-// OUTPUT
-// x_out             - initial signal (matrix, launched by rows)
-// RESULT
-// Error status
-*/
-int fftInverse2d(float *x_in, float *x_out, int numRows, int numColls);
-
-#endif
diff --git a/modules/objdetect/src/_lsvm_matching.h b/modules/objdetect/src/_lsvm_matching.h
deleted file mode 100644 (file)
index ad1023b..0000000
+++ /dev/null
@@ -1,440 +0,0 @@
-/*****************************************************************************/
-/*                      Matching procedure API                               */
-/*****************************************************************************/
-//
-#ifndef _LSVM_MATCHING_H_
-#define _LSVM_MATCHING_H_
-
-#include "_latentsvm.h"
-#include "_lsvm_error.h"
-#include "_lsvm_distancetransform.h"
-#include "_lsvm_fft.h"
-#include "_lsvm_routine.h"
-
-#ifdef HAVE_TBB
-#include "_lsvm_tbbversion.h"
-#endif
-
-//extern "C" {
-/*
-// Function for convolution computation
-//
-// API
-// int convolution(const filterObject *Fi, const featureMap *map, float *f);
-// INPUT
-// Fi                - filter object
-// map               - feature map
-// OUTPUT
-// f                 - the convolution
-// RESULT
-// Error status
-*/
-int convolution(const CvLSVMFilterObject *Fi, const CvLSVMFeatureMap *map, float *f);
-
-/*
-// Computation multiplication of FFT images
-//
-// API
-// int fftImagesMulti(float *fftImage1, float *fftImage2, int numRows, int numColls,
-                      float *multi);
-// INPUT
-// fftImage1         - first fft image
-// fftImage2         - second fft image
-// (numRows, numColls) - image dimesions
-// OUTPUT
-// multi             - multiplication
-// RESULT
-// Error status
-*/
-int fftImagesMulti(float *fftImage1, float *fftImage2, int numRows, int numColls,
-                   float *multi);
-
-/*
-// Turnover filter matrix for the single feature
-//
-// API
-// int rot2PI(float *filter, int dimX, int dimY, float *rot2PIFilter,
-              int p, int shift);
-// INPUT
-// filter            - filter weight matrix
-// (dimX, dimY)      - dimension of filter matrix
-// p                 - number of features
-// shift             - number of feature (or channel)
-// OUTPUT
-// rot2PIFilter      - rotated matrix
-// RESULT
-// Error status
-*/
-int rot2PI(float *filter, int dimX, int dimY, float *rot2PIFilter,
-           int p, int shift);
-
-/*
-// Addition nullable bars to the dimension of feature map (single feature)
-//
-// API
-// int addNullableBars(float *rot2PIFilter, int dimX, int dimY,
-                       float *newFilter, int newDimX, int newDimY);
-// INPUT
-// rot2PIFilter      - filter matrix for the single feature that was rotated
-// (dimX, dimY)      - dimension rot2PIFilter
-// (newDimX, newDimY)- dimension of feature map for the single feature
-// OUTPUT
-// newFilter         - filter matrix with nullable bars
-// RESULT
-// Error status
-*/
-int addNullableBars(float *rot2PIFilter, int dimX, int dimY,
-                    float *newFilter, int newDimX, int newDimY);
-
-/*
-// Computation FFT image for filter object
-//
-// API
-// int getFFTImageFilterObject(const filterObject *filter,
-                               int mapDimX, int mapDimY,
-                               fftImage **image);
-// INPUT
-// filter        - filter object
-// (mapDimX, mapDimY)- dimension of feature map
-// OUTPUT
-// image         - fft image
-// RESULT
-// Error status
-*/
-int getFFTImageFilterObject(const CvLSVMFilterObject *filter,
-                            int mapDimX, int mapDimY,
-                            CvLSVMFftImage **image);
-
-/*
-// Computation FFT image for feature map
-//
-// API
-// int getFFTImageFeatureMap(const featureMap *map, fftImage **image);
-// INPUT
-// OUTPUT
-// RESULT
-// Error status
-*/
-int getFFTImageFeatureMap(const CvLSVMFeatureMap *map, CvLSVMFftImage **image);
-
-/*
-// Function for convolution computation using FFT
-//
-// API
-// int convFFTConv2d(const fftImage *featMapImage, const fftImage *filterImage,
-                     int filterDimX, int filterDimY, float **conv);
-// INPUT
-// featMapImage      - feature map image
-// filterImage       - filter image
-// (filterDimX,filterDimY) - filter dimension
-// OUTPUT
-// conv              - the convolution
-// RESULT
-// Error status
-*/
-int convFFTConv2d(const CvLSVMFftImage *featMapImage, const CvLSVMFftImage *filterImage,
-                  int filterDimX, int filterDimY, float **conv);
-
-/*
-// Computation objective function D according the original paper
-//
-// API
-// int filterDispositionLevel(const filterObject *Fi, const featureMap *pyramid,
-                              float **scoreFi,
-                              int **pointsX, int **pointsY);
-// INPUT
-// Fi                - filter object (weights and coefficients of penalty
-                       function that are used in this routine)
-// pyramid           - feature map
-// OUTPUT
-// scoreFi           - values of distance transform on the level at all positions
-// (pointsX, pointsY)- positions that correspond to the maximum value
-                       of distance transform at all grid nodes
-// RESULT
-// Error status
-*/
-int filterDispositionLevel(const CvLSVMFilterObject *Fi, const CvLSVMFeatureMap *pyramid,
-                           float **scoreFi,
-                           int **pointsX, int **pointsY);
-
-/*
-// Computation objective function D according the original paper using FFT
-//
-// API
-// int filterDispositionLevelFFT(const filterObject *Fi, const fftImage *featMapImage,
-                                 float **scoreFi,
-                                 int **pointsX, int **pointsY);
-// INPUT
-// Fi                - filter object (weights and coefficients of penalty
-                       function that are used in this routine)
-// featMapImage      - FFT image of feature map
-// OUTPUT
-// scoreFi           - values of distance transform on the level at all positions
-// (pointsX, pointsY)- positions that correspond to the maximum value
-                       of distance transform at all grid nodes
-// RESULT
-// Error status
-*/
-int filterDispositionLevelFFT(const CvLSVMFilterObject *Fi, const CvLSVMFftImage *featMapImage,
-                              float **scoreFi,
-                              int **pointsX, int **pointsY);
-
-/*
-// Computation border size for feature map
-//
-// API
-// int computeBorderSize(int maxXBorder, int maxYBorder, int *bx, int *by);
-// INPUT
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// OUTPUT
-// bx                - border size (X-direction)
-// by                - border size (Y-direction)
-// RESULT
-// Error status
-*/
-int computeBorderSize(int maxXBorder, int maxYBorder, int *bx, int *by);
-
-/*
-// Addition nullable border to the feature map
-//
-// API
-// int addNullableBorder(featureMap *map, int bx, int by);
-// INPUT
-// map               - feature map
-// bx                - border size (X-direction)
-// by                - border size (Y-direction)
-// OUTPUT
-// RESULT
-// Error status
-*/
-int addNullableBorder(CvLSVMFeatureMap *map, int bx, int by);
-
-/*
-// Computation the maximum of the score function at the level
-//
-// API
-// int maxFunctionalScoreFixedLevel(const filterObject **all_F, int n,
-                                    const featurePyramid *H,
-                                    int level, float b,
-                                    int maxXBorder, int maxYBorder,
-                                    float *score, CvPoint **points, int *kPoints,
-                                    CvPoint ***partsDisplacement);
-// INPUT
-// all_F             - the set of filters (the first element is root filter,
-                       the other - part filters)
-// n                 - the number of part filters
-// H                 - feature pyramid
-// level             - feature pyramid level for computation maximum score
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// OUTPUT
-// score             - the maximum of the score function at the level
-// points            - the set of root filter positions (in the block space)
-// levels            - the set of levels
-// kPoints           - number of root filter positions
-// partsDisplacement - displacement of part filters (in the block space)
-// RESULT
-// Error status
-*/
-int maxFunctionalScoreFixedLevel(const CvLSVMFilterObject **all_F, int n,
-                                 const CvLSVMFeaturePyramid *H,
-                                 int level, float b,
-                                 int maxXBorder, int maxYBorder,
-                                 float *score, CvPoint **points, int *kPoints,
-                                 CvPoint ***partsDisplacement);
-
-/*
-// Computation score function at the level that exceed threshold
-//
-// API
-// int thresholdFunctionalScoreFixedLevel(const filterObject **all_F, int n,
-                                          const featurePyramid *H,
-                                          int level, float b,
-                                          int maxXBorder, int maxYBorder,
-                                          float scoreThreshold,
-                                          float **score, CvPoint **points, int *kPoints,
-                                          CvPoint ***partsDisplacement);
-// INPUT
-// all_F             - the set of filters (the first element is root filter,
-                       the other - part filters)
-// n                 - the number of part filters
-// H                 - feature pyramid
-// level             - feature pyramid level for computation maximum score
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// scoreThreshold    - score threshold
-// OUTPUT
-// score             - score function at the level that exceed threshold
-// points            - the set of root filter positions (in the block space)
-// levels            - the set of levels
-// kPoints           - number of root filter positions
-// partsDisplacement - displacement of part filters (in the block space)
-// RESULT
-// Error status
-*/
-int thresholdFunctionalScoreFixedLevel(const CvLSVMFilterObject **all_F, int n,
-                                       const CvLSVMFeaturePyramid *H,
-                                       int level, float b,
-                                       int maxXBorder, int maxYBorder,
-                                       float scoreThreshold,
-                                       float **score, CvPoint **points, int *kPoints,
-                                       CvPoint ***partsDisplacement);
-
-/*
-// Computation the maximum of the score function
-//
-// API
-// int maxFunctionalScore(const filterObject **all_F, int n,
-                          const featurePyramid *H, float b,
-                          int maxXBorder, int maxYBorder,
-                          float *score,
-                          CvPoint **points, int **levels, int *kPoints,
-                          CvPoint ***partsDisplacement);
-// INPUT
-// all_F             - the set of filters (the first element is root filter,
-                       the other - part filters)
-// n                 - the number of part filters
-// H                 - feature pyramid
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// OUTPUT
-// score             - the maximum of the score function
-// points            - the set of root filter positions (in the block space)
-// levels            - the set of levels
-// kPoints           - number of root filter positions
-// partsDisplacement - displacement of part filters (in the block space)
-// RESULT
-// Error status
-*/
-int maxFunctionalScore(const CvLSVMFilterObject **all_F, int n,
-                       const CvLSVMFeaturePyramid *H, float b,
-                       int maxXBorder, int maxYBorder,
-                       float *score,
-                       CvPoint **points, int **levels, int *kPoints,
-                       CvPoint ***partsDisplacement);
-
-/*
-// Computation score function that exceed threshold
-//
-// API
-// int thresholdFunctionalScore(const filterObject **all_F, int n,
-                                const featurePyramid *H,
-                                float b,
-                                int maxXBorder, int maxYBorder,
-                                float scoreThreshold,
-                                float **score,
-                                CvPoint **points, int **levels, int *kPoints,
-                                CvPoint ***partsDisplacement);
-// INPUT
-// all_F             - the set of filters (the first element is root filter,
-                       the other - part filters)
-// n                 - the number of part filters
-// H                 - feature pyramid
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// scoreThreshold    - score threshold
-// OUTPUT
-// score             - score function values that exceed threshold
-// points            - the set of root filter positions (in the block space)
-// levels            - the set of levels
-// kPoints           - number of root filter positions
-// partsDisplacement - displacement of part filters (in the block space)
-// RESULT
-// Error status
-*/
-int thresholdFunctionalScore(const CvLSVMFilterObject **all_F, int n,
-                             const CvLSVMFeaturePyramid *H,
-                             float b,
-                             int maxXBorder, int maxYBorder,
-                             float scoreThreshold,
-                             float **score,
-                             CvPoint **points, int **levels, int *kPoints,
-                             CvPoint ***partsDisplacement);
-
-#ifdef HAVE_TBB
-/*
-// int tbbThresholdFunctionalScore(const CvLSVMFilterObject **all_F, int n,
-                                   const CvLSVMFeaturePyramid *H,
-                                   const float b,
-                                   const int maxXBorder, const int maxYBorder,
-                                   const float scoreThreshold,
-                                   const int threadsNum,
-                                   float **score,
-                                   CvPoint **points, int **levels, int *kPoints,
-                                   CvPoint ***partsDisplacement);
-// INPUT
-// all_F             - the set of filters (the first element is root filter,
-                       the other - part filters)
-// n                 - the number of part filters
-// H                 - feature pyramid
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// scoreThreshold    - score threshold
-// threadsNum        - number of threads that will be created using TBB version
-// OUTPUT
-// score             - score function values that exceed threshold
-// points            - the set of root filter positions (in the block space)
-// levels            - the set of levels
-// kPoints           - number of root filter positions
-// partsDisplacement - displacement of part filters (in the block space)
-// RESULT
-// Error status
-*/
-int tbbThresholdFunctionalScore(const CvLSVMFilterObject **all_F, int n,
-                                const CvLSVMFeaturePyramid *H,
-                                const float b,
-                                const int maxXBorder, const int maxYBorder,
-                                const float scoreThreshold,
-                                const int threadsNum,
-                                float **score,
-                                CvPoint **points, int **levels, int *kPoints,
-                                CvPoint ***partsDisplacement);
-#endif
-
-/*
-// Perform non-maximum suppression algorithm (described in original paper)
-// to remove "similar" bounding boxes
-//
-// API
-// int nonMaximumSuppression(int numBoxes, const CvPoint *points,
-                             const CvPoint *oppositePoints, const float *score,
-                             float overlapThreshold,
-                             int *numBoxesout, CvPoint **pointsOut,
-                             CvPoint **oppositePointsOut, float **scoreOut);
-// INPUT
-// numBoxes          - number of bounding boxes
-// points            - array of left top corner coordinates
-// oppositePoints    - array of right bottom corner coordinates
-// score             - array of detection scores
-// overlapThreshold  - threshold: bounding box is removed if overlap part
-                       is greater than passed value
-// OUTPUT
-// numBoxesOut       - the number of bounding boxes algorithm returns
-// pointsOut         - array of left top corner coordinates
-// oppositePointsOut - array of right bottom corner coordinates
-// scoreOut          - array of detection scores
-// RESULT
-// Error status
-*/
-#ifdef __cplusplus
-extern "C"
-#endif
-int nonMaximumSuppression(int numBoxes, const CvPoint *points,
-                          const CvPoint *oppositePoints, const float *score,
-                          float overlapThreshold,
-                          int *numBoxesOut, CvPoint **pointsOut,
-                          CvPoint **oppositePointsOut, float **scoreOut);
-#ifdef __cplusplus
-extern "C"
-#endif
-int getMaxFilterDims(const CvLSVMFilterObject **filters, int kComponents,
-                     const int *kPartFilters,
-                     unsigned int *maxXBorder, unsigned int *maxYBorder);
-//}
-#endif
diff --git a/modules/objdetect/src/_lsvm_resizeimg.h b/modules/objdetect/src/_lsvm_resizeimg.h
deleted file mode 100644 (file)
index c6ebc53..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _LSVM_RESIZEIMG_H_
-#define _LSVM_RESIZEIMG_H_
-
-#include "_lsvm_types.h"
-
-IplImage * resize_opencv (IplImage * img, float scale);
-IplImage * resize_article_dp1(IplImage * img, float scale, const int k);
-IplImage * resize_article_dp(IplImage * img, float scale, const int k);
-
-#endif
diff --git a/modules/objdetect/src/_lsvm_routine.h b/modules/objdetect/src/_lsvm_routine.h
deleted file mode 100644 (file)
index 5a95b68..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _LSVM_ROUTINE_H_
-#define _LSVM_ROUTINE_H_
-
-#include "opencv2/objdetect/objdetect_c.h"
-
-#include "_lsvm_types.h"
-#include "_lsvm_error.h"
-
-
-//////////////////////////////////////////////////////////////
-// Memory management routines
-// All paramaters names correspond to previous data structures description
-// All "alloc" functions return allocated memory for 1 object
-// with all fields including arrays
-// Error status is return value
-//////////////////////////////////////////////////////////////
-int allocFilterObject(CvLSVMFilterObject **obj, const int sizeX, const int sizeY,
-                      const int p);
-int freeFilterObject (CvLSVMFilterObject **obj);
-
-int allocFeatureMapObject(CvLSVMFeatureMap **obj, const int sizeX, const int sizeY,
-                          const int p);
-int freeFeatureMapObject (CvLSVMFeatureMap **obj);
-
-#ifdef __cplusplus
-extern "C"
-#endif
-int allocFeaturePyramidObject(CvLSVMFeaturePyramid **obj,
-                              const int countLevel);
-
-#ifdef __cplusplus
-extern "C"
-#endif
-int freeFeaturePyramidObject (CvLSVMFeaturePyramid **obj);
-int allocFFTImage(CvLSVMFftImage **image, int p, int dimX, int dimY);
-int freeFFTImage(CvLSVMFftImage **image);
-#endif
diff --git a/modules/objdetect/src/_lsvm_tbbversion.h b/modules/objdetect/src/_lsvm_tbbversion.h
deleted file mode 100644 (file)
index 8bfca1b..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef _LSVM_TBBVERSION_H
-#define _LSVM_TBBVERSION_H
-
-#include "_lsvm_matching.h"
-
-/*
-// Computation score function using TBB tasks
-//
-// API
-// int tbbTasksThresholdFunctionalScore(const CvLSVMFilterObject **filters, const int n,
-                                        const CvLSVMFeaturePyramid *H, const float b,
-                                        const int maxXBorder, const int maxYBorder,
-                                        const float scoreThreshold,
-                                        int *kLevels, int **procLevels,
-                                        const int threadsNum,
-                                        float **score, CvPoint ***points,
-                                        int *kPoints,
-                                        CvPoint ****partsDisplacement);
-// INPUT
-// filters           - the set of filters (the first element is root filter,
-                       the other - part filters)
-// n                 - the number of part filters
-// H                 - feature pyramid
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// scoreThreshold    - score threshold
-// kLevels           - array that contains number of levels processed
-                       by each thread
-// procLevels        - array that contains lists of levels processed
-                       by each thread
-// threadsNum        - the number of created threads
-// OUTPUT
-// score             - score function values that exceed threshold
-// points            - the set of root filter positions (in the block space)
-// kPoints           - number of root filter positions
-// partsDisplacement - displacement of part filters (in the block space)
-// RESULT
-//
-*/
-int tbbTasksThresholdFunctionalScore(const CvLSVMFilterObject **filters, const int n,
-                                     const CvLSVMFeaturePyramid *H, const float b,
-                                     const int maxXBorder, const int maxYBorder,
-                                     const float scoreThreshold,
-                                     int *kLevels, int **procLevels,
-                                     const int threadsNum,
-                                     float **score, CvPoint ***points,
-                                     int *kPoints,
-                                     CvPoint ****partsDisplacement);
-
-#endif
diff --git a/modules/objdetect/src/_lsvm_types.h b/modules/objdetect/src/_lsvm_types.h
deleted file mode 100644 (file)
index efb750a..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifndef SVM_TYPE
-#define SVM_TYPE
-
-#include "float.h"
-
-//#define FFT_CONV
-
-#define PI    CV_PI
-
-#define EPS 0.000001
-
-#define F_MAX FLT_MAX
-#define F_MIN -FLT_MAX
-
-// The number of elements in bin
-// The number of sectors in gradient histogram building
-#define NUM_SECTOR 9
-
-// The number of levels in image resize procedure
-// We need Lambda levels to resize image twice
-#define LAMBDA 10
-
-// Block size. Used in feature pyramid building procedure
-#define SIDE_LENGTH 8
-
-#define VAL_OF_TRUNCATE 0.2f
-
-//////////////////////////////////////////////////////////////
-// main data structures                                     //
-//////////////////////////////////////////////////////////////
-
-// DataType: STRUCT featureMap
-// FEATURE MAP DESCRIPTION
-//   Rectangular map (sizeX x sizeY),
-//   every cell stores feature vector (dimension = numFeatures)
-// map             - matrix of feature vectors
-//                   to set and get feature vectors (i,j)
-//                   used formula map[(j * sizeX + i) * p + k], where
-//                   k - component of feature vector in cell (i, j)
-typedef struct{
-    int sizeX;
-    int sizeY;
-    int numFeatures;
-    float *map;
-} CvLSVMFeatureMap;
-
-// DataType: STRUCT featurePyramid
-//
-// numLevels    - number of levels in the feature pyramid
-// pyramid      - array of pointers to feature map at different levels
-typedef struct{
-    int numLevels;
-    CvLSVMFeatureMap **pyramid;
-} CvLSVMFeaturePyramid;
-
-// DataType: STRUCT filterDisposition
-// The structure stores preliminary results in optimization process
-// with objective function D
-//
-// x            - array with X coordinates of optimization problems solutions
-// y            - array with Y coordinates of optimization problems solutions
-// score        - array with optimal objective values
-typedef struct{
-    float *score;
-    int *x;
-    int *y;
-} CvLSVMFilterDisposition;
-
-// DataType: STRUCT fftImage
-// The structure stores FFT image
-//
-// numFeatures  - number of channels
-// x            - array of FFT images for 2d signals
-// n            - number of rows
-// m            - number of collums
-typedef struct{
-    int numFeatures;
-    int dimX;
-    int dimY;
-    float **channels;
-} CvLSVMFftImage;
-
-#endif
diff --git a/modules/objdetect/src/_lsvmparser.h b/modules/objdetect/src/_lsvmparser.h
deleted file mode 100644 (file)
index 0c34ede..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#ifndef LSVM_PARSER
-#define LSVM_PARSER
-#include "opencv2/objdetect/objdetect_c.h"
-
-#include "_lsvm_types.h"
-
-#define MODEL    1
-#define P        2
-#define COMP     3
-#define SCORE    4
-#define RFILTER  100
-#define PFILTERs 101
-#define PFILTER  200
-#define SIZEX    150
-#define SIZEY    151
-#define WEIGHTS  152
-#define TAGV     300
-#define Vx       350
-#define Vy       351
-#define TAGD     400
-#define Dx       451
-#define Dy       452
-#define Dxx      453
-#define Dyy      454
-#define BTAG     500
-
-#define STEP_END 1000
-
-#define EMODEL    (STEP_END + MODEL)
-#define EP        (STEP_END + P)
-#define ECOMP     (STEP_END + COMP)
-#define ESCORE    (STEP_END + SCORE)
-#define ERFILTER  (STEP_END + RFILTER)
-#define EPFILTERs (STEP_END + PFILTERs)
-#define EPFILTER  (STEP_END + PFILTER)
-#define ESIZEX    (STEP_END + SIZEX)
-#define ESIZEY    (STEP_END + SIZEY)
-#define EWEIGHTS  (STEP_END + WEIGHTS)
-#define ETAGV     (STEP_END + TAGV)
-#define EVx       (STEP_END + Vx)
-#define EVy       (STEP_END + Vy)
-#define ETAGD     (STEP_END + TAGD)
-#define EDx       (STEP_END + Dx)
-#define EDy       (STEP_END + Dy)
-#define EDxx      (STEP_END + Dxx)
-#define EDyy      (STEP_END + Dyy)
-#define EBTAG     (STEP_END + BTAG)
-
-//extern "C" {
-    int LSVMparser(const char * filename, CvLSVMFilterObject *** model, int *last, int *max,
-                   int **comp, float **b, int *count, float * score);
-#ifdef __cplusplus
-extern "C"
-#endif
-    int loadModel(
-
-              const char *modelPath,
-
-              CvLSVMFilterObject ***filters,
-              int *kFilters,
-              int *kComponents,
-              int **kPartFilters,
-              float **b,
-              float *scoreThreshold);
-//};
-#endif
diff --git a/modules/objdetect/src/datamatrix.cpp b/modules/objdetect/src/datamatrix.cpp
deleted file mode 100644 (file)
index 754dd11..0000000
+++ /dev/null
@@ -1,567 +0,0 @@
-#include "precomp.hpp"
-#include "opencv2/imgproc/imgproc_c.h"
-#include "opencv2/objdetect/objdetect_c.h"
-
-#include <algorithm>
-
-class Sampler {
-public:
-  CvMat *im;
-  CvPoint o;
-  CvPoint c, cc;
-  CvMat *perim;
-  CvPoint fcoord(float fx, float fy);
-  CvPoint coord(int ix, int iy);
-  Sampler(CvMat *_im, CvPoint _o, CvPoint _c, CvPoint _cc);
-  uchar getpixel(int ix, int iy);
-  int isinside(int x, int y);
-  int overlap(Sampler &other);
-  int hasbars();
-  void timing();
-  CvMat *extract();
-  Sampler():im(0),perim(0){}
-  ~Sampler(){}
-};
-
-class code {    // used in this file only
-public:
-  char msg[4];
-  CvMat *original;
-  Sampler sa;
-};
-
-unsigned char cblk[256] = { 34,19,36,36,51,19,51,51,66,19,36,36,66,19,66,66,49,19,36,36,51,19,51,51,49,19,36,36,
-    49,19,49,49,32,19,36,36,51,19,51,51,66,19,36,36,66,19,66,66,32,19,36,36,51,19,51,51,32,19,36,36,32,19,32,32,
-    17,19,36,36,51,19,51,51,66,19,36,36,66,19,66,66,49,19,36,36,51,19,51,51,49,19,36,36,49,19,49,49,17,19,36,36,
-    51,19,51,51,66,19,36,36,66,19,66,66,17,19,36,36,51,19,51,51,17,19,36,36,17,19,17,17,2,19,2,36,2,19,2,51,2,19,
-    2,36,2,19,2,66,2,19,2,36,2,19,2,51,2,19,2,36,2,19,2,49,2,19,2,36,2,19,2,51,2,19,2,36,2,19,2,66,2,19,2,36,2,19,
-    2,51,2,19,2,36,2,19,2,32,2,19,2,36,2,19,2,51,2,19,2,36,2,19,2,66,2,19,2,36,2,19,2,51,2,19,2,36,2,19,2,49,2,19,
-    2,36,2,19,2,51,2,19,2,36,2,19,2,66,2,19,2,36,2,19,2,51,2,19,2,36,2,19,2,34 };
-unsigned char ccblk[256] = { 34,17,2,17,19,19,2,17,36,36,2,36,19,19,2,17,51,51,2,51,19,19,2,51,36,36,2,36,19,19,2,17,
-    66,66,2,66,19,19,2,66,36,36,2,36,19,19,2,66,51,51,2,51,19,19,2,51,36,36,2,36,19,19,2,17,49,49,2,49,19,19,2,49,36,
-    36,2,36,19,19,2,49,51,51,2,51,19,19,2,51,36,36,2,36,19,19,2,49,66,66,2,66,19,19,2,66,36,36,2,36,19,19,2,66,51,51,
-    2,51,19,19,2,51,36,36,2,36,19,19,2,17,32,32,2,32,19,19,2,32,36,36,2,36,19,19,2,32,51,51,2,51,19,19,2,51,36,36,2,
-    36,19,19,2,32,66,66,2,66,19,19,2,66,36,36,2,36,19,19,2,66,51,51,2,51,19,19,2,51,36,36,2,36,19,19,2,32,49,49,2,49,
-    19,19,2,49,36,36,2,36,19,19,2,49,51,51,2,51,19,19,2,51,36,36,2,36,19,19,2,49,66,66,2,66,19,19,2,66,36,36,2,36,19,
-    19,2,66,51,51,2,51,19,19,2,51,36,36,2,36,19,19,2,34 };
-static const int pickup[64][2] = { {7,6},{8,6},{7,5},{8,5},{1,5},{7,4},{8,4},{1,4},{1,8},{2,8},{1,7},{2,7},{3,7},
-    {1,6},{2,6},{3,6},{3,2},{4,2},{3,1},{4,1},{5,1},{3,8},{4,8},{5,8},{6,1},{7,1},{6,8},{7,8},{8,8},{6,7},{7,7},{8,7},
-    {4,7},{5,7},{4,6},{5,6},{6,6},{4,5},{5,5},{6,5},{2,5},{3,5},{2,4},{3,4},{4,4},{2,3},{3,3},{4,3},{8,3},{1,3},{8,2},
-    {1,2},{2,2},{8,1},{1,1},{2,1},{5,4},{6,4},{5,3},{6,3},{7,3},{5,2},{6,2},{7,2} };
-static const uchar Alog[256] = { 1,2,4,8,16,32,64,128,45,90,180,69,138,57,114,228,229,231,227,235,251,219,155,27,
-    54,108,216,157,23,46,92,184,93,186,89,178,73,146,9,18,36,72,144,13,26,52,104,208,141,55,110,220,149,7,14,28,
-    56,112,224,237,247,195,171,123,246,193,175,115,230,225,239,243,203,187,91,182,65,130,41,82,164,101,202,185,95,
-    190,81,162,105,210,137,63,126,252,213,135,35,70,140,53,106,212,133,39,78,156,21,42,84,168,125,250,217,159,19,
-    38,76,152,29,58,116,232,253,215,131,43,86,172,117,234,249,223,147,11,22,44,88,176,77,154,25,50,100,200,189,87,
-    174,113,226,233,255,211,139,59,118,236,245,199,163,107,214,129,47,94,188,85,170,121,242,201,191,83,166,97,194,
-    169,127,254,209,143,51,102,204,181,71,142,49,98,196,165,103,206,177,79,158,17,34,68,136,61,122,244,197,167,99,
-    198,161,111,222,145,15,30,60,120,240,205,183,67,134,33,66,132,37,74,148,5,10,20,40,80,160,109,218,153,31,62,
-    124,248,221,151,3,6,12,24,48,96,192,173,119,238,241,207,179,75,150,1 };
-static const uchar Log[256] = { (uchar)-255,255,1,240,2,225,241,53,3,38,226,133,242,43,54,210,4,195,39,
-    114,227,106,134,28,243,140,44,23,55,118,211,234,5,219,196,96,40,222,115,103,228,78,107,125,
-    135,8,29,162,244,186,141,180,45,99,24,49,56,13,119,153,212,199,235,91,6,76,220,217,197,11,97,
-    184,41,36,223,253,116,138,104,193,229,86,79,171,108,165,126,145,136,34,9,74,30,32,163,84,245,
-    173,187,204,142,81,181,190,46,88,100,159,25,231,50,207,57,147,14,67,120,128,154,248,213,167,
-    200,63,236,110,92,176,7,161,77,124,221,102,218,95,198,90,12,152,98,48,185,179,42,209,37,132,
-    224,52,254,239,117,233,139,22,105,27,194,113,230,206,87,158,80,189,172,203,109,175,166,62,127,
-    247,146,66,137,192,35,252,10,183,75,216,31,83,33,73,164,144,85,170,246,65,174,61,188,202,205,
-    157,143,169,82,72,182,215,191,251,47,178,89,151,101,94,160,123,26,112,232,21,51,238,208,131,
-    58,69,148,18,15,16,68,17,121,149,129,19,155,59,249,70,214,250,168,71,201,156,64,60,237,130,
-    111,20,93,122,177,150 };
-
-#define dethresh 0.92f
-#define eincO    (2 * dethresh)         // e increment orthogonal
-#define eincD    (1.414f * dethresh)     // e increment diagonal
-
-static const float eincs[] = {
-  eincO, eincD,
-  eincO, eincD,
-  eincO, eincD,
-  eincO, eincD,
-  999 };
-
-#define Ki(x) _mm_set_epi32((x),(x),(x),(x))
-#define Kf(x) _mm_set_ps((x),(x),(x),(x))
-
-static const int CV_DECL_ALIGNED(16) absmask[] = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff};
-#define _mm_abs_ps(x) _mm_and_ps((x), *(const __m128*)absmask)
-
-static void writexy(CvMat *m, int r, CvPoint p)
-{
-  int *pdst = (int*)cvPtr2D(m, r, 0);
-  pdst[0] = p.x;
-  pdst[1] = p.y;
-}
-
-Sampler::Sampler(CvMat *_im, CvPoint _o, CvPoint _c, CvPoint _cc)
-{
-  im = _im;
-  o = _o;
-  c = _c;
-  cc = _cc;
-  perim = cvCreateMat(4, 1, CV_32SC2);
-  writexy(perim, 0, fcoord(-.2f,-.2f));
-  writexy(perim, 1, fcoord(-.2f,1.2f));
-  writexy(perim, 2, fcoord(1.2f,1.2f));
-  writexy(perim, 3, fcoord(1.2f,-.2f));
-  // printf("Sampler %d,%d %d,%d %d,%d\n", o.x, o.y, c.x, c.y, cc.x, cc.y);
-}
-
-CvPoint Sampler::fcoord(float fx, float fy)
-{
-  CvPoint r;
-  r.x = (int)(o.x + fx * (cc.x - o.x) + fy * (c.x - o.x));
-  r.y = (int)(o.y + fx * (cc.y - o.y) + fy * (c.y - o.y));
-  return r;
-}
-
-CvPoint Sampler::coord(int ix, int iy)
-{
-  return fcoord(0.05f + 0.1f * ix, 0.05f + 0.1f * iy);
-}
-
-uchar Sampler::getpixel(int ix, int iy)
-{
-  CvPoint pt = coord(ix, iy);
-  if ((0 <= pt.x) && (pt.x < im->cols) && (0 <= pt.y) && (pt.y < im->rows))
-    return *cvPtr2D(im, pt.y, pt.x);
-  else
-    return 0;
-}
-
-int Sampler::isinside(int x, int y)
-{
-  CvPoint2D32f pt;
-  pt.x = (float)x;
-  pt.y = (float)y;
-  if ((0 <= pt.x) && (pt.x < im->cols) && (0 <= pt.y) && (pt.y < im->rows))
-    return cvPointPolygonTest(perim, pt, 0) < 0;
-  else
-    return 0;
-}
-
-int Sampler::overlap(Sampler &other)
-{
-  for (int i = 0; i < 4; i++) {
-    CvScalar p;
-    p = cvGet2D(other.perim, i, 0);
-    if (isinside((int)p.val[0], (int)p.val[1]))
-      return 1;
-    p = cvGet2D(perim, i, 0);
-    if (other.isinside((int)p.val[0], (int)p.val[1]))
-      return 1;
-  }
-  return 0;
-}
-
-int Sampler::hasbars()
-{
-  return getpixel(9, 1) > getpixel(9, 0);
-}
-
-void Sampler::timing()
-{
-  /*uchar light, dark = getpixel(9, 0);
-  for (int i = 1; i < 3; i += 2) {
-    light = getpixel(9, i);
-    // if (light <= dark)
-    //  goto endo;
-    dark = getpixel(9, i + 1);
-    // if (up <= down)
-    //  goto endo;
-  }*/
-}
-
-CvMat *Sampler::extract()
-{
-  // return a 10x10 CvMat for the current contents, 0 is black, 255 is white
-  // Sampler has (0,0) at bottom left, so invert Y
-  CvMat *r = cvCreateMat(10, 10, CV_8UC1);
-  for (int x = 0; x < 10; x++)
-    for (int y = 0; y < 10; y++)
-      *cvPtr2D(r, 9 - y, x) = (getpixel(x, y) < 128) ? 0 : 255;
-  return r;
-}
-
-#if CV_SSE2
-static void apron(CvMat *v)
-{
-  int r = v->rows;
-  int c = v->cols;
-  memset(cvPtr2D(v, 0, 0), 0x22, c);
-  memset(cvPtr2D(v, 1, 0), 0x22, c);
-  memset(cvPtr2D(v, r - 2, 0), 0x22, c);
-  memset(cvPtr2D(v, r - 1, 0), 0x22, c);
-  int y;
-  for (y = 2; y < r - 2; y++) {
-    uchar *lp = cvPtr2D(v, y, 0);
-    lp[0] = 0x22;
-    lp[1] = 0x22;
-    lp[c-2] = 0x22;
-    lp[c-1] = 0x22;
-  }
-}
-
-static void cfollow(CvMat *src, CvMat *dst)
-{
-  int sx, sy;
-  uchar *vpd = cvPtr2D(src, 0, 0);
-  for (sy = 0; sy < src->rows; sy++) {
-    short *wr = (short*)cvPtr2D(dst, sy, 0);
-    for (sx = 0; sx < src->cols; sx++) {
-      int x = sx;
-      int y = sy;
-      float e = 0;
-      int ontrack = true;
-      int dir;
-
-      while (ontrack) {
-        dir = vpd[y * src->step + x];
-        int xd = ((dir & 0xf) - 2);
-        int yd = ((dir >> 4) - 2);
-        e += (dir == 0x22) ? 999 : ((dir & 1) ? eincD : eincO);
-        x += xd;
-        y += yd;
-        if (e > 10.) {
-          float d = (float)(((x - sx) * (x - sx)) + ((y - sy) * (y - sy)));
-          ontrack = d > (e * e);
-        }
-      }
-      if ((24 <= e) && (e < 999)) {
-        // printf("sx=%d, sy=%d, x=%d, y=%d\n", sx, sy, x, y);
-        *wr++ = (short)(x - sx);
-        *wr++ = (short)(y - sy);
-      } else {
-        *wr++ = 0;
-        *wr++ = 0;
-      }
-    }
-  }
-}
-
-static uchar gf256mul(uchar a, uchar b)
-{
-    return Alog[(Log[a] + Log[b]) % 255];
-}
-
-static int decode(Sampler &sa, code &cc)
-{
-  uchar binary[8] = {0,0,0,0,0,0,0,0};
-  uchar b = 0;
-  int sum;
-
-  sum = 0;
-
-  for (int i = 0; i < 64; i++)
-    sum += sa.getpixel(1 + (i & 7), 1 + (i >> 3));
-  uchar mean = (uchar)(sum / 64);
-  for (int i = 0; i < 64; i++) {
-    b = (b << 1) + (sa.getpixel(pickup[i][0], pickup[i][1]) <= mean);
-    if ((i & 7) == 7) {
-      binary[i >> 3] = b;
-      b = 0;
-    }
-  }
-
-  // Compute the 5 RS codewords for the 3 datawords
-
-  uchar c[5] = {0,0,0,0,0};
-  {
-    uchar a[5] = {228, 48, 15, 111, 62};
-    int k = 5;
-    for (int i = 0; i < 3; i++) {
-      uchar t = binary[i] ^ c[4];
-      for (int j = k - 1; j != -1; j--) {
-        if (t == 0)
-            c[j] = 0;
-        else
-            c[j] = gf256mul(t, a[j]);
-        if (j > 0)
-            c[j] = c[j - 1] ^ c[j];
-      }
-    }
-  }
-
-  if ((c[4] == binary[3]) &&
-      (c[3] == binary[4]) &&
-      (c[2] == binary[5]) &&
-      (c[1] == binary[6]) &&
-      (c[0] == binary[7])) {
-    uchar x = 0xff & (binary[0] - 1);
-    uchar y = 0xff & (binary[1] - 1);
-    uchar z = 0xff & (binary[2] - 1);
-    cc.msg[0] = x;
-    cc.msg[1] = y;
-    cc.msg[2] = z;
-    cc.msg[3] = 0;
-    cc.sa = sa;
-    cc.original = sa.extract();
-    return 1;
-  } else {
-    return 0;
-  }
-}
-
-static std::deque<CvPoint> trailto(CvMat *v, int x, int y, CvMat *terminal)
-{
-  CvPoint np;
-  /* Return the last 10th of the trail of points following v from (x,y)
-   * to terminal
-   */
-
-  int ex = x + ((short*)cvPtr2D(terminal, y, x))[0];
-  int ey = y + ((short*)cvPtr2D(terminal, y, x))[1];
-  std::deque<CvPoint> r;
-  while ((x != ex) || (y != ey)) {
-    np.x = x;
-    np.y = y;
-    r.push_back(np);
-    int dir = *cvPtr2D(v, y, x);
-    int xd = ((dir & 0xf) - 2);
-    int yd = ((dir >> 4) - 2);
-    x += xd;
-    y += yd;
-  }
-
-  int l = (int)(r.size() * 9 / 10);
-  while (l--)
-    r.pop_front();
-  return r;
-}
-#endif
-
-std::deque <CvDataMatrixCode> cvFindDataMatrix(CvMat *im)
-{
-#if CV_SSE2
-  int r = im->rows;
-  int c = im->cols;
-
-#define SAMESIZE(nm, ty) CvMat *nm = cvCreateMat(r, c, ty);
-
-  SAMESIZE(thresh, CV_8UC1)
-  SAMESIZE(vecpic, CV_8UC1)
-  SAMESIZE(vc, CV_8UC1)
-  SAMESIZE(vcc, CV_8UC1)
-  SAMESIZE(cxy, CV_16SC2)
-  SAMESIZE(ccxy, CV_16SC2)
-
-  cvAdaptiveThreshold(im, thresh, 255.0, CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY, 13);
-  {
-    int x, y;
-    int sstride = thresh->step;
-    int sw = thresh->cols; // source width
-    for (y = 2; y < thresh->rows - 2; y++) {
-      uchar *ps = cvPtr2D(thresh, y, 0);
-      uchar *pd = cvPtr2D(vecpic, y, 0);
-      uchar *pvc = cvPtr2D(vc, y, 0);
-      uchar *pvcc = cvPtr2D(vcc, y, 0);
-      for (x = 0; x < sw; x++) {
-        uchar v =
-            (0x01 & ps[-2 * sstride]) |
-            (0x02 & ps[-sstride + 1]) |
-            (0x04 & ps[2]) |
-            (0x08 & ps[sstride + 1]) |
-            (0x10 & ps[2 * sstride]) |
-            (0x20 & ps[sstride - 1]) |
-            (0x40 & ps[-2]) |
-            (0x80 & ps[-sstride -1]);
-        *pd++ = v;
-        *pvc++ = cblk[v];
-        *pvcc++ = ccblk[v];
-        ps++;
-      }
-    }
-    apron(vc);
-    apron(vcc);
-  }
-
-  cfollow(vc, cxy);
-  cfollow(vcc, ccxy);
-
-  std::deque <CvPoint> candidates;
-  {
-    int x, y;
-    int rows = cxy->rows;
-    int cols = cxy->cols;
-    for (y = 0; y < rows; y++) {
-      const short *cd = (const short*)cvPtr2D(cxy, y, 0);
-      const short *ccd = (const short*)cvPtr2D(ccxy, y, 0);
-      for (x = 0; x < cols; x += 4, cd += 8, ccd += 8) {
-        __m128i v = _mm_loadu_si128((const __m128i*)cd);
-        __m128 cyxyxA = _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(v, v), 16));
-        __m128 cyxyxB = _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpackhi_epi16(v, v), 16));
-        __m128 cx = _mm_shuffle_ps(cyxyxA, cyxyxB, _MM_SHUFFLE(2, 0, 2, 0));
-        __m128 cy = _mm_shuffle_ps(cyxyxA, cyxyxB, _MM_SHUFFLE(3, 1, 3, 1));
-        __m128 cmag = _mm_sqrt_ps(_mm_add_ps(_mm_mul_ps(cx, cx), _mm_mul_ps(cy, cy)));
-        __m128 crmag = _mm_rcp_ps(cmag);
-        __m128 ncx = _mm_mul_ps(cx, crmag);
-        __m128 ncy = _mm_mul_ps(cy, crmag);
-
-        v = _mm_loadu_si128((const __m128i*)ccd);
-        __m128 ccyxyxA = _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(v, v), 16));
-        __m128 ccyxyxB = _mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpackhi_epi16(v, v), 16));
-        __m128 ccx = _mm_shuffle_ps(ccyxyxA, ccyxyxB, _MM_SHUFFLE(2, 0, 2, 0));
-        __m128 ccy = _mm_shuffle_ps(ccyxyxA, ccyxyxB, _MM_SHUFFLE(3, 1, 3, 1));
-        __m128 ccmag = _mm_sqrt_ps(_mm_add_ps(_mm_mul_ps(ccx, ccx), _mm_mul_ps(ccy, ccy)));
-        __m128 ccrmag = _mm_rcp_ps(ccmag);
-        __m128 nccx = _mm_mul_ps(ccx, ccrmag);
-        __m128 nccy = _mm_mul_ps(ccy, ccrmag);
-
-        __m128 dot = _mm_mul_ps(_mm_mul_ps(ncx, nccx), _mm_mul_ps(ncy, nccy));
-        // iscand = (cmag > 30) & (ccmag > 30) & (numpy.minimum(cmag, ccmag) * 1.1 > numpy.maximum(cmag, ccmag)) & (abs(dot) < 0.25)
-        __m128 iscand = _mm_and_ps(_mm_cmpgt_ps(cmag, Kf(30)), _mm_cmpgt_ps(ccmag, Kf(30)));
-
-        iscand = _mm_and_ps(iscand, _mm_cmpgt_ps(_mm_mul_ps(_mm_min_ps(cmag, ccmag), Kf(1.1f)), _mm_max_ps(cmag, ccmag)));
-        iscand = _mm_and_ps(iscand, _mm_cmplt_ps(_mm_abs_ps(dot),  Kf(0.25f)));
-
-        unsigned int CV_DECL_ALIGNED(16) result[4];
-        _mm_store_ps((float*)result, iscand);
-        int ix;
-        CvPoint np;
-        for (ix = 0; ix < 4; ix++) {
-          if (result[ix]) {
-            np.x = x + ix;
-            np.y = y;
-            candidates.push_back(np);
-          }
-        }
-      }
-    }
-  }
-
-  std::deque <code> codes;
-  size_t i, j, k;
-  while (!candidates.empty()) {
-    CvPoint o = candidates.front();
-    candidates.pop_front();
-    std::deque<CvPoint> ptc = trailto(vc, o.x, o.y, cxy);
-    std::deque<CvPoint> ptcc = trailto(vcc, o.x, o.y, ccxy);
-    for (j = 0; j < ptc.size(); j++) {
-      for (k = 0; k < ptcc.size(); k++) {
-        code cc;
-        Sampler sa(im, o, ptc[j], ptcc[k]);
-        for (i = 0; i < codes.size(); i++) {
-          if (sa.overlap(codes[i].sa))
-          {
-            cvReleaseMat(&sa.perim);
-            goto endo;
-          }
-        }
-        if (codes.size() > 0) {
-          //printf("searching for more\n");
-        }
-        if (decode(sa, cc)) {
-          codes.push_back(cc);
-          goto endo;
-        }
-
-        cvReleaseMat(&sa.perim);
-      }
-    }
-endo: ; // end search for this o
-  }
-
-  cvReleaseMat(&thresh);
-  cvReleaseMat(&vecpic);
-  cvReleaseMat(&vc);
-  cvReleaseMat(&vcc);
-  cvReleaseMat(&cxy);
-  cvReleaseMat(&ccxy);
-
-  std::deque <CvDataMatrixCode> rc;
-  for (i = 0; i < codes.size(); i++) {
-    CvDataMatrixCode cc;
-    strcpy(cc.msg, codes[i].msg);
-    cc.original = codes[i].original;
-    cc.corners = codes[i].sa.perim;
-    rc.push_back(cc);
-  }
-  return rc;
-#else
-  (void)im;
-  std::deque <CvDataMatrixCode> rc;
-  return rc;
-#endif
-}
-
-#include <opencv2/imgproc.hpp>
-
-namespace cv
-{
-
-void findDataMatrix(InputArray _image,
-                    std::vector<String>& codes,
-                    OutputArray _corners,
-                    OutputArrayOfArrays _dmtx)
-{
-    Mat image = _image.getMat();
-    CvMat m(image);
-    std::deque <CvDataMatrixCode> rc = cvFindDataMatrix(&m);
-    int i, n = (int)rc.size();
-    Mat corners;
-
-    if( _corners.needed() )
-    {
-        _corners.create(n, 4, CV_32SC2);
-        corners = _corners.getMat();
-    }
-
-    if( _dmtx.needed() )
-        _dmtx.create(n, 1, CV_8U);
-
-    codes.resize(n);
-
-    for( i = 0; i < n; i++ )
-    {
-        CvDataMatrixCode& rc_i = rc[i];
-        codes[i] = String(rc_i.msg);
-
-        if( corners.data )
-        {
-            const Point* srcpt = (Point*)rc_i.corners->data.ptr;
-            Point* dstpt = (Point*)corners.ptr(i);
-            for( int k = 0; k < 4; k++ )
-                dstpt[k] = srcpt[k];
-        }
-        cvReleaseMat(&rc_i.corners);
-
-        if( _dmtx.needed() )
-        {
-            _dmtx.create(rc_i.original->rows, rc_i.original->cols, rc_i.original->type, i);
-            Mat dst = _dmtx.getMat(i);
-            cv::cvarrToMat(rc_i.original).copyTo(dst);
-        }
-        cvReleaseMat(&rc_i.original);
-    }
-}
-
-void drawDataMatrixCodes(InputOutputArray _image,
-                         const std::vector<String>& codes,
-                         InputArray _corners)
-{
-    Mat image = _image.getMat();
-    Mat corners = _corners.getMat();
-    int i, n = corners.rows;
-
-    if( n > 0 )
-    {
-        CV_Assert( corners.depth() == CV_32S &&
-                  corners.cols*corners.channels() == 8 &&
-                  n == (int)codes.size() );
-    }
-
-    for( i = 0; i < n; i++ )
-    {
-        Scalar c(0, 255, 0);
-        Scalar c2(255, 0,0);
-        const Point* pt = (const Point*)corners.ptr(i);
-
-        for( int k = 0; k < 4; k++ )
-            line(image, pt[k], pt[(k+1)%4], c);
-        //int baseline = 0;
-        //Size sz = getTextSize(code_text, CV_FONT_HERSHEY_SIMPLEX, 1, 1, &baseline);
-        putText(image, codes[i], pt[0], CV_FONT_HERSHEY_SIMPLEX, 0.8, c2, 1, CV_AA, false);
-    }
-}
-
-}
diff --git a/modules/objdetect/src/distancetransform.cpp b/modules/objdetect/src/distancetransform.cpp
deleted file mode 100644 (file)
index 4fe27c6..0000000
+++ /dev/null
@@ -1,383 +0,0 @@
-#include "precomp.hpp"
-#include "_lsvm_distancetransform.h"
-
-/*
-// Computation the point of intersection functions
-// (parabolas on the variable y)
-//      a(y - q1) + b(q1 - y)(q1 - y) + f[q1]
-//      a(y - q2) + b(q2 - y)(q2 - y) + f[q2]
-//
-//
-// API
-// int GetPointOfIntersection(const float *f,
-                              const float a, const float b,
-                              int q1, int q2, float *point);
-// INPUT
-// f                - function on the regular grid
-// a                - coefficient of the function
-// b                - coefficient of the function
-// q1               - parameter of the function
-// q2               - parameter of the function
-// OUTPUT
-// point            - point of intersection
-// RESULT
-// Error status
-*/
-int GetPointOfIntersection(const float *f,
-                           const float a, const float b,
-                           int q1, int q2, float *point)
-{
-    if (q1 == q2)
-    {
-        return DISTANCE_TRANSFORM_EQUAL_POINTS;
-    } /* if (q1 == q2) */
-    (*point) = ( (f[q2] - a * q2 + b *q2 * q2) -
-                 (f[q1] - a * q1 + b * q1 * q1) ) / (2 * b * (q2 - q1));
-    return DISTANCE_TRANSFORM_OK;
-}
-
-/*
-// Decision of one dimensional problem generalized distance transform
-// on the regular grid at all points
-//      min (a(y' - y) + b(y' - y)(y' - y) + f(y')) (on y')
-//
-// API
-// int DistanceTransformOneDimensionalProblem(const float *f, const int n,
-                                              const float a, const float b,
-                                              float *distanceTransform,
-                                              int *points);
-// INPUT
-// f                 - function on the regular grid
-// n                 - grid dimension
-// a                 - coefficient of optimizable function
-// b                 - coefficient of optimizable function
-// OUTPUT
-// distanceTransform - values of generalized distance transform
-// points            - arguments that corresponds to the optimal value of function
-// RESULT
-// Error status
-*/
-int DistanceTransformOneDimensionalProblem(const float *f, const int n,
-                                           const float a, const float b,
-                                           float *distanceTransform,
-                                           int *points)
-{
-    int i, k;
-    int tmp;
-    int diff;
-    float pointIntersection;
-    int *v;
-    float *z;
-    k = 0;
-
-    // Allocation memory (must be free in this function)
-    v = (int *)malloc (sizeof(int) * n);
-    z = (float *)malloc (sizeof(float) * (n + 1));
-
-    v[0] = 0;
-    z[0] = (float)F_MIN; // left border of envelope
-    z[1] = (float)F_MAX; // right border of envelope
-
-    for (i = 1; i < n; i++)
-    {
-        tmp = GetPointOfIntersection(f, a, b, v[k], i, &pointIntersection);
-        if (tmp != DISTANCE_TRANSFORM_OK)
-        {
-            free(v);
-            free(z);
-            return DISTANCE_TRANSFORM_GET_INTERSECTION_ERROR;
-        } /* if (tmp != DISTANCE_TRANSFORM_OK) */
-        if (pointIntersection <= z[k])
-        {
-            // Envelope doesn't contain current parabola
-            do
-            {
-                k--;
-                tmp = GetPointOfIntersection(f, a, b, v[k], i, &pointIntersection);
-                if (tmp != DISTANCE_TRANSFORM_OK)
-                {
-                    free(v);
-                    free(z);
-                    return DISTANCE_TRANSFORM_GET_INTERSECTION_ERROR;
-                } /* if (tmp != DISTANCE_TRANSFORM_OK) */
-            }while (pointIntersection <= z[k]);
-            // Addition parabola to the envelope
-            k++;
-            v[k] = i;
-            z[k] = pointIntersection;
-            z[k + 1] = (float)F_MAX;
-        }
-        else
-        {
-            // Addition parabola to the envelope
-            k++;
-            v[k] = i;
-            z[k] = pointIntersection;
-            z[k + 1] = (float)F_MAX;
-        } /* if (pointIntersection <= z[k]) */
-    }
-
-    // Computation values of generalized distance transform at all grid points
-    k = 0;
-    for (i = 0; i < n; i++)
-    {
-        while (z[k + 1] < i)
-        {
-            k++;
-        }
-        points[i] = v[k];
-        diff = i - v[k];
-        distanceTransform[i] = a * diff + b * diff * diff + f[v[k]];
-    }
-
-    // Release allocated memory
-    free(v);
-    free(z);
-    return DISTANCE_TRANSFORM_OK;
-}
-
-/*
-// Computation next cycle element
-//
-// API
-// int GetNextCycleElement(int k, int n, int q);
-// INPUT
-// k                 - index of the previous cycle element
-// n                 - number of matrix rows
-// q                 - parameter that equal
-                       (number_of_rows * number_of_columns - 1)
-// OUTPUT
-// None
-// RESULT
-// Next cycle element
-*/
-int GetNextCycleElement(int k, int n, int q)
-{
-    return ((k * n) % q);
-}
-
-/*
-// Transpose cycle elements
-//
-// API
-// void TransposeCycleElements(float *a, int *cycle, int cycle_len)
-// INPUT
-// a                 - initial matrix
-// cycle             - indeces array of cycle
-// cycle_len         - number of elements in the cycle
-// OUTPUT
-// a                 - matrix with transposed elements
-// RESULT
-// Error status
-*/
-void TransposeCycleElements(float *a, int *cycle, int cycle_len)
-{
-    int i;
-    float buf;
-    for (i = cycle_len - 1; i > 0 ; i--)
-    {
-        buf = a[ cycle[i] ];
-        a[ cycle[i] ] = a[ cycle[i - 1] ];
-        a[ cycle[i - 1] ] = buf;
-    }
-}
-
-/*
-// Transpose cycle elements
-//
-// API
-// void TransposeCycleElements(int *a, int *cycle, int cycle_len)
-// INPUT
-// a                 - initial matrix
-// cycle             - indeces array of cycle
-// cycle_len         - number of elements in the cycle
-// OUTPUT
-// a                 - matrix with transposed elements
-// RESULT
-// Error status
-*/
-static void TransposeCycleElements_int(int *a, int *cycle, int cycle_len)
-{
-    int i;
-    int buf;
-    for (i = cycle_len - 1; i > 0 ; i--)
-    {
-        buf = a[ cycle[i] ];
-        a[ cycle[i] ] = a[ cycle[i - 1] ];
-        a[ cycle[i - 1] ] = buf;
-    }
-}
-
-/*
-// Getting transposed matrix
-//
-// API
-// void Transpose(float *a, int n, int m);
-// INPUT
-// a                 - initial matrix
-// n                 - number of rows
-// m                 - number of columns
-// OUTPUT
-// a                 - transposed matrix
-// RESULT
-// None
-*/
-void Transpose(float *a, int n, int m)
-{
-    int *cycle;
-    int i, k, q, cycle_len;
-    int max_cycle_len;
-
-    max_cycle_len = n * m;
-
-    // Allocation memory  (must be free in this function)
-    cycle = (int *)malloc(sizeof(int) * max_cycle_len);
-
-    cycle_len = 0;
-    q = n * m - 1;
-    for (i = 1; i < q; i++)
-    {
-        k = GetNextCycleElement(i, n, q);
-        cycle[cycle_len] = i;
-        cycle_len++;
-
-        while (k > i)
-        {
-            cycle[cycle_len] = k;
-            cycle_len++;
-            k = GetNextCycleElement(k, n, q);
-        }
-        if (k == i)
-        {
-            TransposeCycleElements(a, cycle, cycle_len);
-        } /* if (k == i) */
-        cycle_len = 0;
-    }
-
-    // Release allocated memory
-    free(cycle);
-}
-
-/*
-// Getting transposed matrix
-//
-// API
-// void Transpose_int(int *a, int n, int m);
-// INPUT
-// a                 - initial matrix
-// n                 - number of rows
-// m                 - number of columns
-// OUTPUT
-// a                 - transposed matrix
-// RESULT
-// None
-*/
-static void Transpose_int(int *a, int n, int m)
-{
-    int *cycle;
-    int i, k, q, cycle_len;
-    int max_cycle_len;
-
-    max_cycle_len = n * m;
-
-    // Allocation memory  (must be free in this function)
-    cycle = (int *)malloc(sizeof(int) * max_cycle_len);
-
-    cycle_len = 0;
-    q = n * m - 1;
-    for (i = 1; i < q; i++)
-    {
-        k = GetNextCycleElement(i, n, q);
-        cycle[cycle_len] = i;
-        cycle_len++;
-
-        while (k > i)
-        {
-            cycle[cycle_len] = k;
-            cycle_len++;
-            k = GetNextCycleElement(k, n, q);
-        }
-        if (k == i)
-        {
-            TransposeCycleElements_int(a, cycle, cycle_len);
-        } /* if (k == i) */
-        cycle_len = 0;
-    }
-
-    // Release allocated memory
-    free(cycle);
-}
-
-/*
-// Decision of two dimensional problem generalized distance transform
-// on the regular grid at all points
-//      min{d2(y' - y) + d4(y' - y)(y' - y) +
-            min(d1(x' - x) + d3(x' - x)(x' - x) + f(x',y'))} (on x', y')
-//
-// API
-// int DistanceTransformTwoDimensionalProblem(const float *f,
-                                              const int n, const int m,
-                                              const float coeff[4],
-                                              float *distanceTransform,
-                                              int *pointsX, int *pointsY);
-// INPUT
-// f                 - function on the regular grid
-// n                 - number of rows
-// m                 - number of columns
-// coeff             - coefficients of optimizable function
-                       coeff[0] = d1, coeff[1] = d2,
-                       coeff[2] = d3, coeff[3] = d4
-// OUTPUT
-// distanceTransform - values of generalized distance transform
-// pointsX           - arguments x' that correspond to the optimal value
-// pointsY           - arguments y' that correspond to the optimal value
-// RESULT
-// Error status
-*/
-int DistanceTransformTwoDimensionalProblem(const float *f,
-                                           const int n, const int m,
-                                           const float coeff[4],
-                                           float *distanceTransform,
-                                           int *pointsX, int *pointsY)
-{
-    int i, j, tmp;
-    int resOneDimProblem;
-    int size = n * m;
-    std::vector<float> internalDistTrans(size);
-    std::vector<int> internalPointsX(size);
-
-    for (i = 0; i < n; i++)
-    {
-        resOneDimProblem = DistanceTransformOneDimensionalProblem(
-                                    f + i * m, m,
-                                    coeff[0], coeff[2],
-                                    &internalDistTrans[i * m],
-                                    &internalPointsX[i * m]);
-        if (resOneDimProblem != DISTANCE_TRANSFORM_OK)
-            return DISTANCE_TRANSFORM_ERROR;
-    }
-    Transpose(&internalDistTrans[0], n, m);
-    for (j = 0; j < m; j++)
-    {
-        resOneDimProblem = DistanceTransformOneDimensionalProblem(
-                                    &internalDistTrans[j * n], n,
-                                    coeff[1], coeff[3],
-                                    distanceTransform + j * n,
-                                    pointsY + j * n);
-        if (resOneDimProblem != DISTANCE_TRANSFORM_OK)
-            return DISTANCE_TRANSFORM_ERROR;
-    }
-    Transpose(distanceTransform, m, n);
-    Transpose_int(pointsY, m, n);
-
-    for (i = 0; i < n; i++)
-    {
-        for (j = 0; j < m; j++)
-        {
-            tmp = pointsY[i * m + j];
-            pointsX[i * m + j] = internalPointsX[tmp * m + j];
-        }
-    }
-
-    return DISTANCE_TRANSFORM_OK;
-}
diff --git a/modules/objdetect/src/featurepyramid.cpp b/modules/objdetect/src/featurepyramid.cpp
deleted file mode 100644 (file)
index 35cda95..0000000
+++ /dev/null
@@ -1,515 +0,0 @@
-#include "precomp.hpp"
-#include "opencv2/imgproc/imgproc_c.h"
-#include "_latentsvm.h"
-#include "_lsvm_resizeimg.h"
-
-#ifndef max
-#define max(a,b)            (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef min
-#define min(a,b)            (((a) < (b)) ? (a) : (b))
-#endif
-
-/*
-// Getting feature map for the selected subimage
-//
-// API
-// int getFeatureMaps(const IplImage * image, const int k, featureMap **map);
-// INPUT
-// image             - selected subimage
-// k                 - size of cells
-// OUTPUT
-// map               - feature map
-// RESULT
-// Error status
-*/
-int getFeatureMaps(const IplImage* image, const int k, CvLSVMFeatureMap **map)
-{
-    int sizeX, sizeY;
-    int p, px, stringSize;
-    int height, width, numChannels;
-    int i, j, kk, c, ii, jj, d;
-    float  * datadx, * datady;
-
-    int   ch;
-    float magnitude, x, y, tx, ty;
-
-    IplImage * dx, * dy;
-    int *nearest;
-    float *w, a_x, b_x;
-
-    float kernel[3] = {-1.f, 0.f, 1.f};
-    CvMat kernel_dx = cvMat(1, 3, CV_32F, kernel);
-    CvMat kernel_dy = cvMat(3, 1, CV_32F, kernel);
-
-    float * r;
-    int   * alfa;
-
-    float boundary_x[NUM_SECTOR + 1];
-    float boundary_y[NUM_SECTOR + 1];
-    float max, dotProd;
-    int   maxi;
-
-    height = image->height;
-    width  = image->width ;
-
-    numChannels = image->nChannels;
-
-    dx    = cvCreateImage(cvSize(image->width, image->height),
-                          IPL_DEPTH_32F, 3);
-    dy    = cvCreateImage(cvSize(image->width, image->height),
-                          IPL_DEPTH_32F, 3);
-
-    sizeX = width  / k;
-    sizeY = height / k;
-    px    = 3 * NUM_SECTOR;
-    p     = px;
-    stringSize = sizeX * p;
-    allocFeatureMapObject(map, sizeX, sizeY, p);
-
-    cvFilter2D(image, dx, &kernel_dx, cvPoint(-1, 0));
-    cvFilter2D(image, dy, &kernel_dy, cvPoint(0, -1));
-
-    float arg_vector;
-    for(i = 0; i <= NUM_SECTOR; i++)
-    {
-        arg_vector    = ( (float) i ) * ( (float)(PI) / (float)(NUM_SECTOR) );
-        boundary_x[i] = cosf(arg_vector);
-        boundary_y[i] = sinf(arg_vector);
-    }/*for(i = 0; i <= NUM_SECTOR; i++) */
-
-    r    = (float *)malloc( sizeof(float) * (width * height));
-    alfa = (int   *)malloc( sizeof(int  ) * (width * height * 2));
-
-    for(j = 1; j < height - 1; j++)
-    {
-        datadx = (float*)(dx->imageData + dx->widthStep * j);
-        datady = (float*)(dy->imageData + dy->widthStep * j);
-        for(i = 1; i < width - 1; i++)
-        {
-            c = 0;
-            x = (datadx[i * numChannels + c]);
-            y = (datady[i * numChannels + c]);
-
-            r[j * width + i] =sqrtf(x * x + y * y);
-            for(ch = 1; ch < numChannels; ch++)
-            {
-                tx = (datadx[i * numChannels + ch]);
-                ty = (datady[i * numChannels + ch]);
-                magnitude = sqrtf(tx * tx + ty * ty);
-                if(magnitude > r[j * width + i])
-                {
-                    r[j * width + i] = magnitude;
-                    c = ch;
-                    x = tx;
-                    y = ty;
-                }
-            }/*for(ch = 1; ch < numChannels; ch++)*/
-
-            max  = boundary_x[0] * x + boundary_y[0] * y;
-            maxi = 0;
-            for (kk = 0; kk < NUM_SECTOR; kk++)
-            {
-                dotProd = boundary_x[kk] * x + boundary_y[kk] * y;
-                if (dotProd > max)
-                {
-                    max  = dotProd;
-                    maxi = kk;
-                }
-                else
-                {
-                    if (-dotProd > max)
-                    {
-                        max  = -dotProd;
-                        maxi = kk + NUM_SECTOR;
-                    }
-                }
-            }
-            alfa[j * width * 2 + i * 2    ] = maxi % NUM_SECTOR;
-            alfa[j * width * 2 + i * 2 + 1] = maxi;
-        }/*for(i = 0; i < width; i++)*/
-    }/*for(j = 0; j < height; j++)*/
-
-    nearest = (int  *)malloc(sizeof(int  ) *  k);
-    w       = (float*)malloc(sizeof(float) * (k * 2));
-
-    for(i = 0; i < k / 2; i++)
-    {
-        nearest[i] = -1;
-    }/*for(i = 0; i < k / 2; i++)*/
-    for(i = k / 2; i < k; i++)
-    {
-        nearest[i] = 1;
-    }/*for(i = k / 2; i < k; i++)*/
-
-    for(j = 0; j < k / 2; j++)
-    {
-        b_x = k / 2 + j + 0.5f;
-        a_x = k / 2 - j - 0.5f;
-        w[j * 2    ] = 1.0f/a_x * ((a_x * b_x) / ( a_x + b_x));
-        w[j * 2 + 1] = 1.0f/b_x * ((a_x * b_x) / ( a_x + b_x));
-    }/*for(j = 0; j < k / 2; j++)*/
-    for(j = k / 2; j < k; j++)
-    {
-        a_x = j - k / 2 + 0.5f;
-        b_x =-j + k / 2 - 0.5f + k;
-        w[j * 2    ] = 1.0f/a_x * ((a_x * b_x) / ( a_x + b_x));
-        w[j * 2 + 1] = 1.0f/b_x * ((a_x * b_x) / ( a_x + b_x));
-    }/*for(j = k / 2; j < k; j++)*/
-
-
-    for(i = 0; i < sizeY; i++)
-    {
-      for(j = 0; j < sizeX; j++)
-      {
-        for(ii = 0; ii < k; ii++)
-        {
-          for(jj = 0; jj < k; jj++)
-          {
-            if ((i * k + ii > 0) &&
-                (i * k + ii < height - 1) &&
-                (j * k + jj > 0) &&
-                (j * k + jj < width  - 1))
-            {
-              d = (k * i + ii) * width + (j * k + jj);
-              (*map)->map[ i * stringSize + j * (*map)->numFeatures + alfa[d * 2    ]] +=
-                  r[d] * w[ii * 2] * w[jj * 2];
-              (*map)->map[ i * stringSize + j * (*map)->numFeatures + alfa[d * 2 + 1] + NUM_SECTOR] +=
-                  r[d] * w[ii * 2] * w[jj * 2];
-              if ((i + nearest[ii] >= 0) &&
-                  (i + nearest[ii] <= sizeY - 1))
-              {
-                (*map)->map[(i + nearest[ii]) * stringSize + j * (*map)->numFeatures + alfa[d * 2    ]             ] +=
-                  r[d] * w[ii * 2 + 1] * w[jj * 2 ];
-                (*map)->map[(i + nearest[ii]) * stringSize + j * (*map)->numFeatures + alfa[d * 2 + 1] + NUM_SECTOR] +=
-                  r[d] * w[ii * 2 + 1] * w[jj * 2 ];
-              }
-              if ((j + nearest[jj] >= 0) &&
-                  (j + nearest[jj] <= sizeX - 1))
-              {
-                (*map)->map[i * stringSize + (j + nearest[jj]) * (*map)->numFeatures + alfa[d * 2    ]             ] +=
-                  r[d] * w[ii * 2] * w[jj * 2 + 1];
-                (*map)->map[i * stringSize + (j + nearest[jj]) * (*map)->numFeatures + alfa[d * 2 + 1] + NUM_SECTOR] +=
-                  r[d] * w[ii * 2] * w[jj * 2 + 1];
-              }
-              if ((i + nearest[ii] >= 0) &&
-                  (i + nearest[ii] <= sizeY - 1) &&
-                  (j + nearest[jj] >= 0) &&
-                  (j + nearest[jj] <= sizeX - 1))
-              {
-                (*map)->map[(i + nearest[ii]) * stringSize + (j + nearest[jj]) * (*map)->numFeatures + alfa[d * 2    ]             ] +=
-                  r[d] * w[ii * 2 + 1] * w[jj * 2 + 1];
-                (*map)->map[(i + nearest[ii]) * stringSize + (j + nearest[jj]) * (*map)->numFeatures + alfa[d * 2 + 1] + NUM_SECTOR] +=
-                  r[d] * w[ii * 2 + 1] * w[jj * 2 + 1];
-              }
-            }
-          }/*for(jj = 0; jj < k; jj++)*/
-        }/*for(ii = 0; ii < k; ii++)*/
-      }/*for(j = 1; j < sizeX - 1; j++)*/
-    }/*for(i = 1; i < sizeY - 1; i++)*/
-
-    cvReleaseImage(&dx);
-    cvReleaseImage(&dy);
-
-
-    free(w);
-    free(nearest);
-
-    free(r);
-    free(alfa);
-
-    return LATENT_SVM_OK;
-}
-
-/*
-// Feature map Normalization and Truncation
-//
-// API
-// int normalizeAndTruncate(featureMap *map, const float alfa);
-// INPUT
-// map               - feature map
-// alfa              - truncation threshold
-// OUTPUT
-// map               - truncated and normalized feature map
-// RESULT
-// Error status
-*/
-int normalizeAndTruncate(CvLSVMFeatureMap *map, const float alfa)
-{
-    int i,j, ii;
-    int sizeX, sizeY, p, pos, pp, xp, pos1, pos2;
-    float * partOfNorm; // norm of C(i, j)
-    float * newData;
-    float   valOfNorm;
-
-    sizeX     = map->sizeX;
-    sizeY     = map->sizeY;
-    partOfNorm = (float *)malloc (sizeof(float) * (sizeX * sizeY));
-
-    p  = NUM_SECTOR;
-    xp = NUM_SECTOR * 3;
-    pp = NUM_SECTOR * 12;
-
-    for(i = 0; i < sizeX * sizeY; i++)
-    {
-        valOfNorm = 0.0f;
-        pos = i * map->numFeatures;
-        for(j = 0; j < p; j++)
-        {
-            valOfNorm += map->map[pos + j] * map->map[pos + j];
-        }/*for(j = 0; j < p; j++)*/
-        partOfNorm[i] = valOfNorm;
-    }/*for(i = 0; i < sizeX * sizeY; i++)*/
-
-    sizeX -= 2;
-    sizeY -= 2;
-
-    newData = (float *)malloc (sizeof(float) * (sizeX * sizeY * pp));
-    //normalization
-    for(i = 1; i <= sizeY; i++)
-    {
-        for(j = 1; j <= sizeX; j++)
-        {
-            valOfNorm = sqrtf(
-                partOfNorm[(i    )*(sizeX + 2) + (j    )] +
-                partOfNorm[(i    )*(sizeX + 2) + (j + 1)] +
-                partOfNorm[(i + 1)*(sizeX + 2) + (j    )] +
-                partOfNorm[(i + 1)*(sizeX + 2) + (j + 1)]) + FLT_EPSILON;
-            pos1 = (i  ) * (sizeX + 2) * xp + (j  ) * xp;
-            pos2 = (i-1) * (sizeX    ) * pp + (j-1) * pp;
-            for(ii = 0; ii < p; ii++)
-            {
-                newData[pos2 + ii        ] = map->map[pos1 + ii    ] / valOfNorm;
-            }/*for(ii = 0; ii < p; ii++)*/
-            for(ii = 0; ii < 2 * p; ii++)
-            {
-                newData[pos2 + ii + p * 4] = map->map[pos1 + ii + p] / valOfNorm;
-            }/*for(ii = 0; ii < 2 * p; ii++)*/
-            valOfNorm = sqrtf(
-                partOfNorm[(i    )*(sizeX + 2) + (j    )] +
-                partOfNorm[(i    )*(sizeX + 2) + (j + 1)] +
-                partOfNorm[(i - 1)*(sizeX + 2) + (j    )] +
-                partOfNorm[(i - 1)*(sizeX + 2) + (j + 1)]) + FLT_EPSILON;
-            for(ii = 0; ii < p; ii++)
-            {
-                newData[pos2 + ii + p    ] = map->map[pos1 + ii    ] / valOfNorm;
-            }/*for(ii = 0; ii < p; ii++)*/
-            for(ii = 0; ii < 2 * p; ii++)
-            {
-                newData[pos2 + ii + p * 6] = map->map[pos1 + ii + p] / valOfNorm;
-            }/*for(ii = 0; ii < 2 * p; ii++)*/
-            valOfNorm = sqrtf(
-                partOfNorm[(i    )*(sizeX + 2) + (j    )] +
-                partOfNorm[(i    )*(sizeX + 2) + (j - 1)] +
-                partOfNorm[(i + 1)*(sizeX + 2) + (j    )] +
-                partOfNorm[(i + 1)*(sizeX + 2) + (j - 1)]) + FLT_EPSILON;
-            for(ii = 0; ii < p; ii++)
-            {
-                newData[pos2 + ii + p * 2] = map->map[pos1 + ii    ] / valOfNorm;
-            }/*for(ii = 0; ii < p; ii++)*/
-            for(ii = 0; ii < 2 * p; ii++)
-            {
-                newData[pos2 + ii + p * 8] = map->map[pos1 + ii + p] / valOfNorm;
-            }/*for(ii = 0; ii < 2 * p; ii++)*/
-            valOfNorm = sqrtf(
-                partOfNorm[(i    )*(sizeX + 2) + (j    )] +
-                partOfNorm[(i    )*(sizeX + 2) + (j - 1)] +
-                partOfNorm[(i - 1)*(sizeX + 2) + (j    )] +
-                partOfNorm[(i - 1)*(sizeX + 2) + (j - 1)]) + FLT_EPSILON;
-            for(ii = 0; ii < p; ii++)
-            {
-                newData[pos2 + ii + p * 3 ] = map->map[pos1 + ii    ] / valOfNorm;
-            }/*for(ii = 0; ii < p; ii++)*/
-            for(ii = 0; ii < 2 * p; ii++)
-            {
-                newData[pos2 + ii + p * 10] = map->map[pos1 + ii + p] / valOfNorm;
-            }/*for(ii = 0; ii < 2 * p; ii++)*/
-        }/*for(j = 1; j <= sizeX; j++)*/
-    }/*for(i = 1; i <= sizeY; i++)*/
-    //truncation
-    for(i = 0; i < sizeX * sizeY * pp; i++)
-    {
-        if(newData [i] > alfa) newData [i] = alfa;
-    }/*for(i = 0; i < sizeX * sizeY * pp; i++)*/
-    //swap data
-
-    map->numFeatures  = pp;
-    map->sizeX = sizeX;
-    map->sizeY = sizeY;
-
-    free (map->map);
-    free (partOfNorm);
-
-    map->map = newData;
-
-    return LATENT_SVM_OK;
-}
-
-/*
-// Feature map reduction
-// In each cell we reduce dimension of the feature vector
-// according to original paper special procedure
-//
-// API
-// int PCAFeatureMaps(featureMap *map)
-// INPUT
-// map               - feature map
-// OUTPUT
-// map               - feature map
-// RESULT
-// Error status
-*/
-int PCAFeatureMaps(CvLSVMFeatureMap *map)
-{
-    int i,j, ii, jj, k;
-    int sizeX, sizeY, p,  pp, xp, yp, pos1, pos2;
-    float * newData;
-    float val;
-    float nx, ny;
-
-    sizeX = map->sizeX;
-    sizeY = map->sizeY;
-    p     = map->numFeatures;
-    pp    = NUM_SECTOR * 3 + 4;
-    yp    = 4;
-    xp    = NUM_SECTOR;
-
-    nx    = 1.0f / sqrtf((float)(xp * 2));
-    ny    = 1.0f / sqrtf((float)(yp    ));
-
-    newData = (float *)malloc (sizeof(float) * (sizeX * sizeY * pp));
-
-    for(i = 0; i < sizeY; i++)
-    {
-        for(j = 0; j < sizeX; j++)
-        {
-            pos1 = ((i)*sizeX + j)*p;
-            pos2 = ((i)*sizeX + j)*pp;
-            k = 0;
-            for(jj = 0; jj < xp * 2; jj++)
-            {
-                val = 0;
-                for(ii = 0; ii < yp; ii++)
-                {
-                    val += map->map[pos1 + yp * xp + ii * xp * 2 + jj];
-                }/*for(ii = 0; ii < yp; ii++)*/
-                newData[pos2 + k] = val * ny;
-                k++;
-            }/*for(jj = 0; jj < xp * 2; jj++)*/
-            for(jj = 0; jj < xp; jj++)
-            {
-                val = 0;
-                for(ii = 0; ii < yp; ii++)
-                {
-                    val += map->map[pos1 + ii * xp + jj];
-                }/*for(ii = 0; ii < yp; ii++)*/
-                newData[pos2 + k] = val * ny;
-                k++;
-            }/*for(jj = 0; jj < xp; jj++)*/
-            for(ii = 0; ii < yp; ii++)
-            {
-                val = 0;
-                for(jj = 0; jj < 2 * xp; jj++)
-                {
-                    val += map->map[pos1 + yp * xp + ii * xp * 2 + jj];
-                }/*for(jj = 0; jj < xp; jj++)*/
-                newData[pos2 + k] = val * nx;
-                k++;
-            } /*for(ii = 0; ii < yp; ii++)*/
-        }/*for(j = 0; j < sizeX; j++)*/
-    }/*for(i = 0; i < sizeY; i++)*/
-    //swap data
-
-    map->numFeatures = pp;
-
-    free (map->map);
-
-    map->map = newData;
-
-    return LATENT_SVM_OK;
-}
-
-
-static int getPathOfFeaturePyramid(IplImage * image,
-                            float step, int numStep, int startIndex,
-                            int sideLength, CvLSVMFeaturePyramid **maps)
-{
-    CvLSVMFeatureMap *map;
-    IplImage *scaleTmp;
-    float scale;
-    int   i;
-
-    for(i = 0; i < numStep; i++)
-    {
-        scale = 1.0f / powf(step, (float)i);
-        scaleTmp = resize_opencv (image, scale);
-        getFeatureMaps(scaleTmp, sideLength, &map);
-        normalizeAndTruncate(map, VAL_OF_TRUNCATE);
-        PCAFeatureMaps(map);
-        (*maps)->pyramid[startIndex + i] = map;
-        cvReleaseImage(&scaleTmp);
-    }/*for(i = 0; i < numStep; i++)*/
-    return LATENT_SVM_OK;
-}
-
-/*
-// Getting feature pyramid
-//
-// API
-// int getFeaturePyramid(IplImage * image, const filterObject **all_F,
-                      const int n_f,
-                      const int lambda, const int k,
-                      const int startX, const int startY,
-                      const int W, const int H, featurePyramid **maps);
-// INPUT
-// image             - image
-// OUTPUT
-// maps              - feature maps for all levels
-// RESULT
-// Error status
-*/
-int getFeaturePyramid(IplImage * image, CvLSVMFeaturePyramid **maps)
-{
-    IplImage *imgResize;
-    float step;
-    int   numStep;
-    int   maxNumCells;
-    int   W, H;
-
-    if(image->depth == IPL_DEPTH_32F)
-    {
-        imgResize = image;
-    }
-    else
-    {
-        imgResize = cvCreateImage(cvSize(image->width , image->height) ,
-                                  IPL_DEPTH_32F , 3);
-        cvConvert(image, imgResize);
-    }
-
-    W = imgResize->width;
-    H = imgResize->height;
-
-    step = powf(2.0f, 1.0f / ((float)LAMBDA));
-    maxNumCells = W / SIDE_LENGTH;
-    if( maxNumCells > H / SIDE_LENGTH )
-    {
-        maxNumCells = H / SIDE_LENGTH;
-    }
-    numStep = (int)(logf((float) maxNumCells / (5.0f)) / logf( step )) + 1;
-
-    allocFeaturePyramidObject(maps, numStep + LAMBDA);
-
-    getPathOfFeaturePyramid(imgResize, step   , LAMBDA, 0,
-                            SIDE_LENGTH / 2, maps);
-    getPathOfFeaturePyramid(imgResize, step, numStep, LAMBDA,
-                            SIDE_LENGTH    , maps);
-
-    if(image->depth != IPL_DEPTH_32F)
-    {
-        cvReleaseImage(&imgResize);
-    }
-
-    return LATENT_SVM_OK;
-}
diff --git a/modules/objdetect/src/fft.cpp b/modules/objdetect/src/fft.cpp
deleted file mode 100644 (file)
index 5c5902f..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-#include "precomp.hpp"
-#include "_lsvm_fft.h"
-
-// static int getEntireRes(int number, int divisor, int *entire, int *res)
-// {
-//     *entire = number / divisor;
-//     *res = number % divisor;
-//     return FFT_OK;
-// }
-
-static int getMultipliers(int n, int *n1, int *n2)
-{
-    int multiplier, i;
-    if (n == 1)
-    {
-        *n1 = 1;
-        *n2 = 1;
-        return FFT_ERROR; // n = 1
-    }
-    multiplier = n / 2;
-    for (i = multiplier; i >= 2; i--)
-    {
-        if (n % i == 0)
-        {
-            *n1 = i;
-            *n2 = n / i;
-            return FFT_OK; // n = n1 * n2
-        }
-    }
-    *n1 = 1;
-    *n2 = n;
-    return FFT_ERROR; // n - prime number
-}
-
-/*
-// 1-dimensional FFT
-//
-// API
-// int fft(float *x_in, float *x_out, int n, int shift);
-// INPUT
-// x_in              - input signal
-// n                 - number of elements for searching Fourier image
-// shift             - shift between input elements
-// OUTPUT
-// x_out             - output signal (contains 2n elements in order
-                       Re(x_in[0]), Im(x_in[0]), Re(x_in[1]), Im(x_in[1]) and etc.)
-// RESULT
-// Error status
-*/
-int fft(float *x_in, float *x_out, int n, int shift)
-{
-    int n1, n2, res, k1, k2, m1, m2, index, idx;
-    float alpha, beta, gamma, angle, cosAngle, sinAngle;
-    float tmpGamma, tmpAlpha, tmpBeta;
-    float tmpRe, tmpIm, phaseRe, phaseIm;
-    res = getMultipliers(n, &n1, &n2);
-    if (res == FFT_OK)
-    {
-        fft(x_in, x_out, n1, shift);
-        fft(x_in, x_out, n2, shift);
-    }
-    alpha = (float)(2.0 * PI / ((float)n));
-    beta = (float)(2.0 * PI / ((float)n1));
-    gamma = (float)(2.0 * PI / ((float)n2));
-    for (k1 = 0; k1 < n1; k1++)
-    {
-        tmpBeta = beta * k1;
-        for (k2 = 0; k2 < n2; k2++)
-        {
-            idx = shift * (n2 * k1 + k2);
-            x_out[idx] = 0.0;
-            x_out[idx + 1] = 0.0;
-            tmpGamma = gamma * k2;
-            tmpAlpha = alpha * k2;
-            for (m1 = 0; m1 < n1; m1++)
-            {
-                tmpRe = 0.0;
-                tmpIm = 0.0;
-                for (m2 = 0; m2 < n2; m2++)
-                {
-                    angle = tmpGamma * m2;
-                    index = shift * (n1 * m2 + m1);
-                    cosAngle = cosf(angle);
-                    sinAngle = sinf(angle);
-                    tmpRe += x_in[index] * cosAngle + x_in[index + 1] * sinAngle;
-                    tmpIm += x_in[index + 1] * cosAngle - x_in[index] * sinAngle;
-                }
-                angle = tmpAlpha * m1;
-                cosAngle = cosf(angle);
-                sinAngle = sinf(angle);
-                phaseRe = cosAngle * tmpRe + sinAngle * tmpIm;
-                phaseIm = cosAngle * tmpIm - sinAngle * tmpRe;
-                angle = tmpBeta * m1;
-                cosAngle = cosf(angle);
-                sinAngle = sinf(angle);
-                x_out[idx] += (cosAngle * phaseRe + sinAngle * phaseIm);
-                x_out[idx + 1] += (cosAngle * phaseIm - sinAngle * phaseRe);
-            }
-        }
-    }
-    return FFT_OK;
-}
-
-/*
-// Inverse 1-dimensional FFT
-//
-// API
-// int fftInverse(float *x_in, float *x_out, int n, int shift);
-// INPUT
-// x_in              - Fourier image of 1d input signal(contains 2n elements
-                       in order Re(x_in[0]), Im(x_in[0]),
-                       Re(x_in[1]), Im(x_in[1]) and etc.)
-// n                 - number of elements for searching counter FFT image
-// shift             - shift between input elements
-// OUTPUT
-// x_in              - input signal (contains n elements)
-// RESULT
-// Error status
-*/
-int fftInverse(float *x_in, float *x_out, int n, int shift)
-{
-    int n1, n2, res, k1, k2, m1, m2, index, idx;
-    float alpha, beta, gamma, angle, cosAngle, sinAngle;
-    float tmpRe, tmpIm, phaseRe, phaseIm;
-    res = getMultipliers(n, &n1, &n2);
-    if (res == FFT_OK)
-    {
-        fftInverse(x_in, x_out, n1, shift);
-        fftInverse(x_in, x_out, n2, shift);
-    }
-    alpha = (float)(2.0f * PI / ((float)n));
-    beta = (float)(2.0f * PI / ((float)n1));
-    gamma = (float)(2.0f * PI / ((float)n2));
-    for (m1 = 0; m1 < n1; m1++)
-    {
-        for (m2 = 0; m2 < n2; m2++)
-        {
-            idx = (n1 * m2 + m1) * shift;
-            x_out[idx] = 0.0;
-            x_out[idx + 1] = 0.0;
-            for (k2 = 0; k2 < n2; k2++)
-            {
-                tmpRe = 0.0;
-                tmpIm = 0.0;
-                for (k1 = 0; k1 < n1; k1++)
-                {
-                    angle = beta * k1 * m1;
-                    index = shift *(n2 * k1 + k2);
-                    sinAngle = sinf(angle);
-                    cosAngle = cosf(angle);
-                    tmpRe += x_in[index] * cosAngle - x_in[index + 1] * sinAngle;
-                    tmpIm += x_in[index] * sinAngle + x_in[index + 1] * cosAngle;
-                }
-                angle = alpha * m1 * k2;
-                sinAngle = sinf(angle);
-                cosAngle = cosf(angle);
-                phaseRe = cosAngle * tmpRe - sinAngle * tmpIm;
-                phaseIm = cosAngle * tmpIm + sinAngle * tmpRe;
-                angle = gamma * k2 * m2;
-                sinAngle = sinf(angle);
-                cosAngle = cosf(angle);
-                x_out[idx] += cosAngle * phaseRe - sinAngle * phaseIm;
-                x_out[idx + 1] += cosAngle * phaseIm + sinAngle * phaseRe;
-            }
-            x_out[idx] /= n;
-            x_out[idx + 1] /= n;
-        }
-    }
-    return FFT_OK;
-}
-
-/*
-// 2-dimensional FFT
-//
-// API
-// int fft2d(float *x_in, float *x_out, int numRows, int numColls);
-// INPUT
-// x_in              - input signal (matrix, launched by rows)
-// numRows           - number of rows
-// numColls          - number of collumns
-// OUTPUT
-// x_out             - output signal (contains (2 * numRows * numColls) elements
-                       in order Re(x_in[0][0]), Im(x_in[0][0]),
-                       Re(x_in[0][1]), Im(x_in[0][1]) and etc.)
-// RESULT
-// Error status
-*/
-int fft2d(float *x_in, float *x_out, int numRows, int numColls)
-{
-    int i, size;
-    float *x_outTmp;
-    size = numRows * numColls;
-    x_outTmp = (float *)malloc(sizeof(float) * (2 * size));
-    for (i = 0; i < numRows; i++)
-    {
-        fft(x_in + i * 2 * numColls,
-            x_outTmp + i * 2 * numColls,
-            numColls, 2);
-    }
-    for (i = 0; i < numColls; i++)
-    {
-        fft(x_outTmp + 2 * i,
-            x_out + 2 * i,
-            numRows, 2 * numColls);
-    }
-    free(x_outTmp);
-    return FFT_OK;
-}
-
-/*
-// Inverse 2-dimensional FFT
-//
-// API
-// int fftInverse2d(float *x_in, float *x_out, int numRows, int numColls);
-// INPUT
-// x_in              - Fourier image of matrix (contains (2 * numRows * numColls)
-                       elements in order Re(x_in[0][0]), Im(x_in[0][0]),
-                       Re(x_in[0][1]), Im(x_in[0][1]) and etc.)
-// numRows           - number of rows
-// numColls          - number of collumns
-// OUTPUT
-// x_out             - initial signal (matrix, launched by rows)
-// RESULT
-// Error status
-*/
-int fftInverse2d(float *x_in, float *x_out, int numRows, int numColls)
-{
-    int i, size;
-    float *x_outTmp;
-    size = numRows * numColls;
-    x_outTmp = (float *)malloc(sizeof(float) * (2 * size));
-    for (i = 0; i < numRows; i++)
-    {
-        fftInverse(x_in + i * 2 * numColls,
-            x_outTmp + i * 2 * numColls,
-            numColls, 2);
-    }
-    for (i = 0; i < numColls; i++)
-    {
-        fftInverse(x_outTmp + 2 * i,
-            x_out + 2 * i,
-            numRows, 2 * numColls);
-    }
-    free(x_outTmp);
-    return FFT_OK;
-}
diff --git a/modules/objdetect/src/latentsvm.cpp b/modules/objdetect/src/latentsvm.cpp
deleted file mode 100644 (file)
index 613da1c..0000000
+++ /dev/null
@@ -1,644 +0,0 @@
-#include "precomp.hpp"
-#include "_latentsvm.h"
-#include "_lsvm_matching.h"
-
-/*
-// Transformation filter displacement from the block space
-// to the space of pixels at the initial image
-//
-// API
-// int convertPoints(int countLevel, CvPoint *points, int *levels,
-                  CvPoint **partsDisplacement, int kPoints, int n);
-// INPUT
-// countLevel        - the number of levels in the feature pyramid
-// points            - the set of root filter positions (in the block space)
-// levels            - the set of levels
-// partsDisplacement - displacement of part filters (in the block space)
-// kPoints           - number of root filter positions
-// n                 - number of part filters
-// initialImageLevel - level that contains features for initial image
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// OUTPUT
-// points            - the set of root filter positions (in the space of pixels)
-// partsDisplacement - displacement of part filters (in the space of pixels)
-// RESULT
-// Error status
-*/
-int convertPoints(int /*countLevel*/, int lambda,
-                  int initialImageLevel,
-                  CvPoint *points, int *levels,
-                  CvPoint **partsDisplacement, int kPoints, int n,
-                  int maxXBorder,
-                  int maxYBorder)
-{
-    int i, j, bx, by;
-    float step, scale;
-    step = powf( 2.0f, 1.0f / ((float)lambda) );
-
-    computeBorderSize(maxXBorder, maxYBorder, &bx, &by);
-
-    for (i = 0; i < kPoints; i++)
-    {
-        // scaling factor for root filter
-        scale = SIDE_LENGTH * powf(step, (float)(levels[i] - initialImageLevel));
-        points[i].x = (int)((points[i].x - bx + 1) * scale);
-        points[i].y = (int)((points[i].y - by + 1) * scale);
-
-        // scaling factor for part filters
-        scale = SIDE_LENGTH * powf(step, (float)(levels[i] - lambda - initialImageLevel));
-        for (j = 0; j < n; j++)
-        {
-            partsDisplacement[i][j].x = (int)((partsDisplacement[i][j].x -
-                                               2 * bx + 1) * scale);
-            partsDisplacement[i][j].y = (int)((partsDisplacement[i][j].y -
-                                               2 * by + 1) * scale);
-        }
-    }
-    return LATENT_SVM_OK;
-}
-
-/*
-// Elimination boxes that are outside the image boudaries
-//
-// API
-// int clippingBoxes(int width, int height,
-                     CvPoint *points, int kPoints);
-// INPUT
-// width             - image wediht
-// height            - image heigth
-// points            - a set of points (coordinates of top left or
-                       bottom right corners)
-// kPoints           - points number
-// OUTPUT
-// points            - updated points (if coordinates less than zero then
-                       set zero coordinate, if coordinates more than image
-                       size then set coordinates equal image size)
-// RESULT
-// Error status
-*/
-int clippingBoxes(int width, int height,
-                  CvPoint *points, int kPoints)
-{
-    int i;
-    for (i = 0; i < kPoints; i++)
-    {
-        if (points[i].x > width - 1)
-        {
-            points[i].x = width - 1;
-        }
-        if (points[i].x < 0)
-        {
-            points[i].x = 0;
-        }
-        if (points[i].y > height - 1)
-        {
-            points[i].y = height - 1;
-        }
-        if (points[i].y < 0)
-        {
-            points[i].y = 0;
-        }
-    }
-    return LATENT_SVM_OK;
-}
-
-/*
-// Creation feature pyramid with nullable border
-//
-// API
-// featurePyramid* createFeaturePyramidWithBorder(const IplImage *image,
-                                                  int maxXBorder, int maxYBorder);
-
-// INPUT
-// image             - initial image
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// OUTPUT
-// RESULT
-// Feature pyramid with nullable border
-*/
-CvLSVMFeaturePyramid* createFeaturePyramidWithBorder(IplImage *image,
-                                               int maxXBorder, int maxYBorder)
-{
-    int opResult;
-    int bx, by;
-    int level;
-    CvLSVMFeaturePyramid *H;
-
-    // Obtaining feature pyramid
-    opResult = getFeaturePyramid(image, &H);
-
-    if (opResult != LATENT_SVM_OK)
-    {
-        freeFeaturePyramidObject(&H);
-        return NULL;
-    } /* if (opResult != LATENT_SVM_OK) */
-
-    // Addition nullable border for each feature map
-    // the size of the border for root filters
-    computeBorderSize(maxXBorder, maxYBorder, &bx, &by);
-    for (level = 0; level < H->numLevels; level++)
-    {
-        addNullableBorder(H->pyramid[level], bx, by);
-    }
-    return H;
-}
-
-/*
-// Computation of the root filter displacement and values of score function
-//
-// API
-// int searchObject(const featurePyramid *H, const filterObject **all_F, int n,
-                    float b,
-                    int maxXBorder,
-                     int maxYBorder,
-                     CvPoint **points, int **levels, int *kPoints, float *score,
-                     CvPoint ***partsDisplacement);
-// INPUT
-// image             - initial image for searhing object
-// all_F             - the set of filters (the first element is root filter,
-                       other elements - part filters)
-// n                 - the number of part filters
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// OUTPUT
-// points            - positions (x, y) of the upper-left corner
-                       of root filter frame
-// levels            - levels that correspond to each position
-// kPoints           - number of positions
-// score             - value of the score function
-// partsDisplacement - part filters displacement for each position
-                       of the root filter
-// RESULT
-// Error status
-*/
-int searchObject(const CvLSVMFeaturePyramid *H, const CvLSVMFilterObject **all_F,
-                 int n, float b,
-                 int maxXBorder,
-                 int maxYBorder,
-                 CvPoint **points, int **levels, int *kPoints, float *score,
-                 CvPoint ***partsDisplacement)
-{
-    int opResult;
-
-    // Matching
-    opResult = maxFunctionalScore(all_F, n, H, b, maxXBorder, maxYBorder,
-                                  score, points, levels,
-                                  kPoints, partsDisplacement);
-    if (opResult != LATENT_SVM_OK)
-    {
-        return LATENT_SVM_SEARCH_OBJECT_FAILED;
-    }
-
-    // Transformation filter displacement from the block space
-    // to the space of pixels at the initial image
-    // that settles at the level number LAMBDA
-    convertPoints(H->numLevels, LAMBDA, LAMBDA, (*points),
-                  (*levels), (*partsDisplacement), (*kPoints), n,
-                  maxXBorder, maxYBorder);
-
-    return LATENT_SVM_OK;
-}
-
-/*
-// Computation right bottom corners coordinates of bounding boxes
-//
-// API
-// int estimateBoxes(CvPoint *points, int *levels, int kPoints,
-                     int sizeX, int sizeY, CvPoint **oppositePoints);
-// INPUT
-// points            - left top corners coordinates of bounding boxes
-// levels            - levels of feature pyramid where points were found
-// (sizeX, sizeY)    - size of root filter
-// OUTPUT
-// oppositePoins     - right bottom corners coordinates of bounding boxes
-// RESULT
-// Error status
-*/
-static int estimateBoxes(CvPoint *points, int *levels, int kPoints,
-                  int sizeX, int sizeY, CvPoint **oppositePoints)
-{
-    int i;
-    float step;
-
-    step = powf( 2.0f, 1.0f / ((float)(LAMBDA)));
-
-    *oppositePoints = (CvPoint *)malloc(sizeof(CvPoint) * kPoints);
-    for (i = 0; i < kPoints; i++)
-    {
-        getOppositePoint(points[i], sizeX, sizeY, step, levels[i] - LAMBDA, &((*oppositePoints)[i]));
-    }
-    return LATENT_SVM_OK;
-}
-
-/*
-// Computation of the root filter displacement and values of score function
-//
-// API
-// int searchObjectThreshold(const featurePyramid *H,
-                             const filterObject **all_F, int n,
-                             float b,
-                             int maxXBorder, int maxYBorder,
-                             float scoreThreshold,
-                             CvPoint **points, int **levels, int *kPoints,
-                             float **score, CvPoint ***partsDisplacement);
-// INPUT
-// H                 - feature pyramid
-// all_F             - the set of filters (the first element is root filter,
-                       other elements - part filters)
-// n                 - the number of part filters
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// scoreThreshold    - score threshold
-// OUTPUT
-// points            - positions (x, y) of the upper-left corner
-                       of root filter frame
-// levels            - levels that correspond to each position
-// kPoints           - number of positions
-// score             - values of the score function
-// partsDisplacement - part filters displacement for each position
-                       of the root filter
-// RESULT
-// Error status
-*/
-int searchObjectThreshold(const CvLSVMFeaturePyramid *H,
-                          const CvLSVMFilterObject **all_F, int n,
-                          float b,
-                          int maxXBorder, int maxYBorder,
-                          float scoreThreshold,
-                          CvPoint **points, int **levels, int *kPoints,
-                          float **score, CvPoint ***partsDisplacement,
-                          int numThreads)
-{
-    int opResult;
-
-
-    // Matching
-#ifdef HAVE_TBB
-    if (numThreads <= 0)
-    {
-        opResult = LATENT_SVM_TBB_NUMTHREADS_NOT_CORRECT;
-        return opResult;
-    }
-    opResult = tbbThresholdFunctionalScore(all_F, n, H, b, maxXBorder, maxYBorder,
-                                           scoreThreshold, numThreads, score,
-                                           points, levels, kPoints,
-                                           partsDisplacement);
-#else
-    opResult = thresholdFunctionalScore(all_F, n, H, b,
-                                        maxXBorder, maxYBorder,
-                                        scoreThreshold,
-                                        score, points, levels,
-                                        kPoints, partsDisplacement);
-
-  (void)numThreads;
-#endif
-    if (opResult != LATENT_SVM_OK)
-    {
-        return LATENT_SVM_SEARCH_OBJECT_FAILED;
-    }
-
-    // Transformation filter displacement from the block space
-    // to the space of pixels at the initial image
-    // that settles at the level number LAMBDA
-    convertPoints(H->numLevels, LAMBDA, LAMBDA, (*points),
-                  (*levels), (*partsDisplacement), (*kPoints), n,
-                  maxXBorder, maxYBorder);
-
-    return LATENT_SVM_OK;
-}
-
-/*
-// Compute opposite point for filter box
-//
-// API
-// int getOppositePoint(CvPoint point,
-                        int sizeX, int sizeY,
-                        float step, int degree,
-                        CvPoint *oppositePoint);
-
-// INPUT
-// point             - coordinates of filter top left corner
-                       (in the space of pixels)
-// (sizeX, sizeY)    - filter dimension in the block space
-// step              - scaling factor
-// degree            - degree of the scaling factor
-// OUTPUT
-// oppositePoint     - coordinates of filter bottom corner
-                       (in the space of pixels)
-// RESULT
-// Error status
-*/
-int getOppositePoint(CvPoint point,
-                     int sizeX, int sizeY,
-                     float step, int degree,
-                     CvPoint *oppositePoint)
-{
-    float scale;
-    scale = SIDE_LENGTH * powf(step, (float)degree);
-    oppositePoint->x = (int)(point.x + sizeX * scale);
-    oppositePoint->y = (int)(point.y + sizeY * scale);
-    return LATENT_SVM_OK;
-}
-
-
-/*
-// Drawing root filter boxes
-//
-// API
-// int showRootFilterBoxes(const IplImage *image,
-                           const filterObject *filter,
-                           CvPoint *points, int *levels, int kPoints,
-                           CvScalar color, int thickness,
-                           int line_type, int shift);
-// INPUT
-// image             - initial image
-// filter            - root filter object
-// points            - a set of points
-// levels            - levels of feature pyramid
-// kPoints           - number of points
-// color             - line color for each box
-// thickness         - line thickness
-// line_type         - line type
-// shift             - shift
-// OUTPUT
-// window contained initial image and filter boxes
-// RESULT
-// Error status
-*/
-int showRootFilterBoxes(IplImage *image,
-                        const CvLSVMFilterObject *filter,
-                        CvPoint *points, int *levels, int kPoints,
-                        CvScalar color, int thickness,
-                        int line_type, int shift)
-{
-    int i;
-    float step;
-    CvPoint oppositePoint;
-    step = powf( 2.0f, 1.0f / ((float)LAMBDA));
-
-    for (i = 0; i < kPoints; i++)
-    {
-        // Drawing rectangle for filter
-        getOppositePoint(points[i], filter->sizeX, filter->sizeY,
-                         step, levels[i] - LAMBDA, &oppositePoint);
-        cvRectangle(image, points[i], oppositePoint,
-                    color, thickness, line_type, shift);
-    }
-#ifdef HAVE_OPENCV_HIGHGUI
-    cv::imshow("Initial image", cv::cvarrToMat(image));
-#endif
-    return LATENT_SVM_OK;
-}
-
-/*
-// Drawing part filter boxes
-//
-// API
-// int showPartFilterBoxes(const IplImage *image,
-                           const filterObject *filter,
-                           CvPoint *points, int *levels, int kPoints,
-                           CvScalar color, int thickness,
-                           int line_type, int shift);
-// INPUT
-// image             - initial image
-// filters           - a set of part filters
-// n                 - number of part filters
-// partsDisplacement - a set of points
-// levels            - levels of feature pyramid
-// kPoints           - number of foot filter positions
-// color             - line color for each box
-// thickness         - line thickness
-// line_type         - line type
-// shift             - shift
-// OUTPUT
-// window contained initial image and filter boxes
-// RESULT
-// Error status
-*/
-int showPartFilterBoxes(IplImage *image,
-                        const CvLSVMFilterObject **filters,
-                        int n, CvPoint **partsDisplacement,
-                        int *levels, int kPoints,
-                        CvScalar color, int thickness,
-                        int line_type, int shift)
-{
-    int i, j;
-    float step;
-    CvPoint oppositePoint;
-
-    step = powf( 2.0f, 1.0f / ((float)LAMBDA));
-
-    for (i = 0; i < kPoints; i++)
-    {
-        for (j = 0; j < n; j++)
-        {
-            // Drawing rectangles for part filters
-            getOppositePoint(partsDisplacement[i][j],
-                             filters[j + 1]->sizeX, filters[j + 1]->sizeY,
-                             step, levels[i] - 2 * LAMBDA, &oppositePoint);
-            cvRectangle(image, partsDisplacement[i][j], oppositePoint,
-                        color, thickness, line_type, shift);
-        }
-    }
-#ifdef HAVE_OPENCV_HIGHGUI
-    cv::imshow("Initial image", cv::cvarrToMat(image));
-#endif
-    return LATENT_SVM_OK;
-}
-
-/*
-// Drawing boxes
-//
-// API
-// int showBoxes(const IplImage *img,
-                 const CvPoint *points, const CvPoint *oppositePoints, int kPoints,
-                 CvScalar color, int thickness, int line_type, int shift);
-// INPUT
-// img               - initial image
-// points            - top left corner coordinates
-// oppositePoints    - right bottom corner coordinates
-// kPoints           - points number
-// color             - line color for each box
-// thickness         - line thickness
-// line_type         - line type
-// shift             - shift
-// OUTPUT
-// RESULT
-// Error status
-*/
-int showBoxes(IplImage *img,
-              const CvPoint *points, const CvPoint *oppositePoints, int kPoints,
-              CvScalar color, int thickness, int line_type, int shift)
-{
-    int i;
-    for (i = 0; i < kPoints; i++)
-    {
-        cvRectangle(img, points[i], oppositePoints[i],
-                    color, thickness, line_type, shift);
-    }
-#ifdef HAVE_OPENCV_HIGHGUI
-    cv::imshow("Initial image", cv::cvarrToMat(img));
-#endif
-    return LATENT_SVM_OK;
-}
-
-/*
-// Computation maximum filter size for each dimension
-//
-// API
-// int getMaxFilterDims(const filterObject **filters, int kComponents,
-                        const int *kPartFilters,
-                        unsigned int *maxXBorder, unsigned int *maxYBorder);
-// INPUT
-// filters           - a set of filters (at first root filter, then part filters
-                       and etc. for all components)
-// kComponents       - number of components
-// kPartFilters      - number of part filters for each component
-// OUTPUT
-// maxXBorder        - maximum of filter size at the horizontal dimension
-// maxYBorder        - maximum of filter size at the vertical dimension
-// RESULT
-// Error status
-*/
-int getMaxFilterDims(const CvLSVMFilterObject **filters, int kComponents,
-                     const int *kPartFilters,
-                     unsigned int *maxXBorder, unsigned int *maxYBorder)
-{
-    int i, componentIndex;
-    *maxXBorder = filters[0]->sizeX;
-    *maxYBorder = filters[0]->sizeY;
-    componentIndex = kPartFilters[0] + 1;
-    for (i = 1; i < kComponents; i++)
-    {
-        if ((unsigned)filters[componentIndex]->sizeX > *maxXBorder)
-        {
-            *maxXBorder = filters[componentIndex]->sizeX;
-        }
-        if ((unsigned)filters[componentIndex]->sizeY > *maxYBorder)
-        {
-            *maxYBorder = filters[componentIndex]->sizeY;
-        }
-        componentIndex += (kPartFilters[i] + 1);
-    }
-    return LATENT_SVM_OK;
-}
-
-/*
-// Computation root filters displacement and values of score function
-//
-// API
-// int searchObjectThresholdSomeComponents(const featurePyramid *H,
-                                           const filterObject **filters,
-                                           int kComponents, const int *kPartFilters,
-                                           const float *b, float scoreThreshold,
-                                           CvPoint **points, CvPoint **oppPoints,
-                                           float **score, int *kPoints);
-// INPUT
-// H                 - feature pyramid
-// filters           - filters (root filter then it's part filters, etc.)
-// kComponents       - root filters number
-// kPartFilters      - array of part filters number for each component
-// b                 - array of linear terms
-// scoreThreshold    - score threshold
-// OUTPUT
-// points            - root filters displacement (top left corners)
-// oppPoints         - root filters displacement (bottom right corners)
-// score             - array of score values
-// kPoints           - number of boxes
-// RESULT
-// Error status
-*/
-int searchObjectThresholdSomeComponents(const CvLSVMFeaturePyramid *H,
-                                        const CvLSVMFilterObject **filters,
-                                        int kComponents, const int *kPartFilters,
-                                        const float *b, float scoreThreshold,
-                                        CvPoint **points, CvPoint **oppPoints,
-                                        float **score, int *kPoints,
-                                        int numThreads)
-{
-    //int error = 0;
-    int i, j, s, f, componentIndex;
-    unsigned int maxXBorder, maxYBorder;
-    CvPoint **pointsArr, **oppPointsArr, ***partsDisplacementArr;
-    float **scoreArr;
-    int *kPointsArr, **levelsArr;
-
-    // Allocation memory
-    pointsArr = (CvPoint **)malloc(sizeof(CvPoint *) * kComponents);
-    oppPointsArr = (CvPoint **)malloc(sizeof(CvPoint *) * kComponents);
-    scoreArr = (float **)malloc(sizeof(float *) * kComponents);
-    kPointsArr = (int *)malloc(sizeof(int) * kComponents);
-    levelsArr = (int **)malloc(sizeof(int *) * kComponents);
-    partsDisplacementArr = (CvPoint ***)malloc(sizeof(CvPoint **) * kComponents);
-
-    // Getting maximum filter dimensions
-    /*error = */getMaxFilterDims(filters, kComponents, kPartFilters, &maxXBorder, &maxYBorder);
-    componentIndex = 0;
-    *kPoints = 0;
-    // For each component perform searching
-    for (i = 0; i < kComponents; i++)
-    {
-        int error = searchObjectThreshold(H, &(filters[componentIndex]), kPartFilters[i],
-            b[i], maxXBorder, maxYBorder, scoreThreshold,
-            &(pointsArr[i]), &(levelsArr[i]), &(kPointsArr[i]),
-            &(scoreArr[i]), &(partsDisplacementArr[i]), numThreads);
-        if (error != LATENT_SVM_OK)
-        {
-            // Release allocated memory
-            free(pointsArr);
-            free(oppPointsArr);
-            free(scoreArr);
-            free(kPointsArr);
-            free(levelsArr);
-            free(partsDisplacementArr);
-            return LATENT_SVM_SEARCH_OBJECT_FAILED;
-        }
-        estimateBoxes(pointsArr[i], levelsArr[i], kPointsArr[i],
-            filters[componentIndex]->sizeX, filters[componentIndex]->sizeY, &(oppPointsArr[i]));
-        componentIndex += (kPartFilters[i] + 1);
-        *kPoints += kPointsArr[i];
-    }
-
-    *points = (CvPoint *)malloc(sizeof(CvPoint) * (*kPoints));
-    *oppPoints = (CvPoint *)malloc(sizeof(CvPoint) * (*kPoints));
-    *score = (float *)malloc(sizeof(float) * (*kPoints));
-    s = 0;
-    for (i = 0; i < kComponents; i++)
-    {
-        f = s + kPointsArr[i];
-        for (j = s; j < f; j++)
-        {
-            (*points)[j].x = pointsArr[i][j - s].x;
-            (*points)[j].y = pointsArr[i][j - s].y;
-            (*oppPoints)[j].x = oppPointsArr[i][j - s].x;
-            (*oppPoints)[j].y = oppPointsArr[i][j - s].y;
-            (*score)[j] = scoreArr[i][j - s];
-        }
-        s = f;
-    }
-
-    // Release allocated memory
-    for (i = 0; i < kComponents; i++)
-    {
-        free(pointsArr[i]);
-        free(oppPointsArr[i]);
-        free(scoreArr[i]);
-        free(levelsArr[i]);
-        for (j = 0; j < kPointsArr[i]; j++)
-        {
-            free(partsDisplacementArr[i][j]);
-        }
-        free(partsDisplacementArr[i]);
-    }
-    free(pointsArr);
-    free(oppPointsArr);
-    free(scoreArr);
-    free(kPointsArr);
-    free(levelsArr);
-    free(partsDisplacementArr);
-    return LATENT_SVM_OK;
-}
diff --git a/modules/objdetect/src/latentsvmdetector.cpp b/modules/objdetect/src/latentsvmdetector.cpp
deleted file mode 100644 (file)
index 8f7fcb4..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-#include "precomp.hpp"
-#include "opencv2/imgproc/imgproc_c.h"
-#include "opencv2/objdetect/objdetect_c.h"
-#include "_lsvmparser.h"
-#include "_lsvm_matching.h"
-
-/*
-// load trained detector from a file
-//
-// API
-// CvLatentSvmDetector* cvLoadLatentSvmDetector(const char* filename);
-// INPUT
-// filename             - path to the file containing the parameters of
-//                      - trained Latent SVM detector
-// OUTPUT
-// trained Latent SVM detector in internal representation
-*/
-CvLatentSvmDetector* cvLoadLatentSvmDetector(const char* filename)
-{
-    CvLatentSvmDetector* detector = 0;
-    CvLSVMFilterObject** filters = 0;
-    int kFilters = 0;
-    int kComponents = 0;
-    int* kPartFilters = 0;
-    float* b = 0;
-    float scoreThreshold = 0.f;
-    int err_code = 0;
-
-    err_code = loadModel(filename, &filters, &kFilters, &kComponents, &kPartFilters, &b, &scoreThreshold);
-    if (err_code != LATENT_SVM_OK) return 0;
-
-    detector = (CvLatentSvmDetector*)malloc(sizeof(CvLatentSvmDetector));
-    detector->filters = filters;
-    detector->b = b;
-    detector->num_components = kComponents;
-    detector->num_filters = kFilters;
-    detector->num_part_filters = kPartFilters;
-    detector->score_threshold = scoreThreshold;
-
-    return detector;
-}
-
-/*
-// release memory allocated for CvLatentSvmDetector structure
-//
-// API
-// void cvReleaseLatentSvmDetector(CvLatentSvmDetector** detector);
-// INPUT
-// detector             - CvLatentSvmDetector structure to be released
-// OUTPUT
-*/
-void cvReleaseLatentSvmDetector(CvLatentSvmDetector** detector)
-{
-    free((*detector)->b);
-    free((*detector)->num_part_filters);
-    for (int i = 0; i < (*detector)->num_filters; i++)
-    {
-        free((*detector)->filters[i]->H);
-        free((*detector)->filters[i]);
-    }
-    free((*detector)->filters);
-    free((*detector));
-    *detector = 0;
-}
-
-/*
-// find rectangular regions in the given image that are likely
-// to contain objects and corresponding confidence levels
-//
-// API
-// CvSeq* cvLatentSvmDetectObjects(const IplImage* image,
-//                                  CvLatentSvmDetector* detector,
-//                                  CvMemStorage* storage,
-//                                  float overlap_threshold = 0.5f,
-                                    int numThreads = -1);
-// INPUT
-// image                - image to detect objects in
-// detector             - Latent SVM detector in internal representation
-// storage              - memory storage to store the resultant sequence
-//                          of the object candidate rectangles
-// overlap_threshold    - threshold for the non-maximum suppression algorithm [here will be the reference to original paper]
-// OUTPUT
-// sequence of detected objects (bounding boxes and confidence levels stored in CvObjectDetection structures)
-*/
-CvSeq* cvLatentSvmDetectObjects(IplImage* image,
-                                CvLatentSvmDetector* detector,
-                                CvMemStorage* storage,
-                                float overlap_threshold, int numThreads)
-{
-    CvLSVMFeaturePyramid *H = 0;
-    CvPoint *points = 0, *oppPoints = 0;
-    int kPoints = 0;
-    float *score = 0;
-    unsigned int maxXBorder = 0, maxYBorder = 0;
-    int numBoxesOut = 0;
-    CvPoint *pointsOut = 0;
-    CvPoint *oppPointsOut = 0;
-    float *scoreOut = 0;
-    CvSeq* result_seq = 0;
-    int error = 0;
-
-    if(image->nChannels == 3)
-        cvCvtColor(image, image, CV_BGR2RGB);
-
-    // Getting maximum filter dimensions
-    getMaxFilterDims((const CvLSVMFilterObject**)(detector->filters), detector->num_components,
-                     detector->num_part_filters, &maxXBorder, &maxYBorder);
-    // Create feature pyramid with nullable border
-    H = createFeaturePyramidWithBorder(image, maxXBorder, maxYBorder);
-    // Search object
-    error = searchObjectThresholdSomeComponents(H, (const CvLSVMFilterObject**)(detector->filters),
-        detector->num_components, detector->num_part_filters, detector->b, detector->score_threshold,
-        &points, &oppPoints, &score, &kPoints, numThreads);
-    if (error != LATENT_SVM_OK)
-    {
-        return NULL;
-    }
-    // Clipping boxes
-    clippingBoxes(image->width, image->height, points, kPoints);
-    clippingBoxes(image->width, image->height, oppPoints, kPoints);
-    // NMS procedure
-    nonMaximumSuppression(kPoints, points, oppPoints, score, overlap_threshold,
-                &numBoxesOut, &pointsOut, &oppPointsOut, &scoreOut);
-
-    result_seq = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvObjectDetection), storage );
-
-    for (int i = 0; i < numBoxesOut; i++)
-    {
-        CvObjectDetection detection = {CvRect(), 0};
-        detection.score = scoreOut[i];
-        CvRect bounding_box;
-        bounding_box.x = pointsOut[i].x;
-        bounding_box.y = pointsOut[i].y;
-        bounding_box.width = oppPointsOut[i].x - pointsOut[i].x;
-        bounding_box.height = oppPointsOut[i].y - pointsOut[i].y;
-        detection.rect = bounding_box;
-        cvSeqPush(result_seq, &detection);
-    }
-
-    if(image->nChannels == 3)
-        cvCvtColor(image, image, CV_RGB2BGR);
-
-    freeFeaturePyramidObject(&H);
-    free(points);
-    free(oppPoints);
-    free(score);
-    free(scoreOut);
-
-    return result_seq;
-}
-
-namespace cv
-{
-LatentSvmDetector::ObjectDetection::ObjectDetection() : score(0.f), classID(-1)
-{}
-
-LatentSvmDetector::ObjectDetection::ObjectDetection( const Rect& _rect, float _score, int _classID ) :
-    rect(_rect), score(_score), classID(_classID)
-{}
-
-LatentSvmDetector::LatentSvmDetector()
-{}
-
-LatentSvmDetector::LatentSvmDetector( const std::vector<String>& filenames, const std::vector<String>& _classNames )
-{
-    load( filenames, _classNames );
-}
-
-LatentSvmDetector::~LatentSvmDetector()
-{
-    clear();
-}
-
-void LatentSvmDetector::clear()
-{
-    for( size_t i = 0; i < detectors.size(); i++ )
-        cvReleaseLatentSvmDetector( &detectors[i] );
-    detectors.clear();
-
-    classNames.clear();
-}
-
-bool LatentSvmDetector::empty() const
-{
-    return detectors.empty();
-}
-
-const std::vector<String>& LatentSvmDetector::getClassNames() const
-{
-    return classNames;
-}
-
-size_t LatentSvmDetector::getClassCount() const
-{
-    return classNames.size();
-}
-
-static String extractModelName( const String& filename )
-{
-    size_t startPos = filename.rfind('/');
-    if( startPos == String::npos )
-        startPos = filename.rfind('\\');
-
-    if( startPos == String::npos )
-        startPos = 0;
-    else
-        startPos++;
-
-    const int extentionSize = 4; //.xml
-
-    int substrLength = (int)(filename.size() - startPos - extentionSize);
-
-    return filename.substr(startPos, substrLength);
-}
-
-bool LatentSvmDetector::load( const std::vector<String>& filenames, const std::vector<String>& _classNames )
-{
-    clear();
-
-    CV_Assert( _classNames.empty() || _classNames.size() == filenames.size() );
-
-    for( size_t i = 0; i < filenames.size(); i++ )
-    {
-        const String filename = filenames[i];
-        if( filename.length() < 5 || filename.substr(filename.length()-4, 4) != ".xml" )
-            continue;
-
-        CvLatentSvmDetector* detector = cvLoadLatentSvmDetector( filename.c_str() );
-        if( detector )
-        {
-            detectors.push_back( detector );
-            if( _classNames.empty() )
-            {
-                classNames.push_back( extractModelName(filenames[i]) );
-            }
-            else
-                classNames.push_back( _classNames[i] );
-        }
-    }
-
-    return !empty();
-}
-
-void LatentSvmDetector::detect( const Mat& image,
-                                std::vector<ObjectDetection>& objectDetections,
-                                float overlapThreshold,
-                                int numThreads )
-{
-    objectDetections.clear();
-    if( numThreads <= 0 )
-        numThreads = 1;
-
-    for( size_t classID = 0; classID < detectors.size(); classID++ )
-    {
-        IplImage image_ipl = image;
-        CvMemStorage* storage = cvCreateMemStorage(0);
-        CvSeq* detections = cvLatentSvmDetectObjects( &image_ipl, detectors[classID], storage, overlapThreshold, numThreads );
-
-        // convert results
-        objectDetections.reserve( objectDetections.size() + detections->total );
-        for( int detectionIdx = 0; detectionIdx < detections->total; detectionIdx++ )
-        {
-            CvObjectDetection detection = *(CvObjectDetection*)cvGetSeqElem( detections, detectionIdx );
-            objectDetections.push_back( ObjectDetection(Rect(detection.rect), detection.score, (int)classID) );
-        }
-
-        cvReleaseMemStorage( &storage );
-    }
-}
-
-} // namespace cv
diff --git a/modules/objdetect/src/lsvmparser.cpp b/modules/objdetect/src/lsvmparser.cpp
deleted file mode 100644 (file)
index 52c4d82..0000000
+++ /dev/null
@@ -1,817 +0,0 @@
-#include "precomp.hpp"
-#include <stdio.h>
-#include "string.h"
-#include "_lsvmparser.h"
-#include "_lsvm_error.h"
-
-namespace
-{
-int isMODEL    (char *str){
-    char stag [] = "<Model>";
-    char etag [] = "</Model>";
-    if(strcmp(stag, str) == 0)return  MODEL;
-    if(strcmp(etag, str) == 0)return EMODEL;
-    return 0;
-}
-int isP        (char *str){
-    char stag [] = "<P>";
-    char etag [] = "</P>";
-    if(strcmp(stag, str) == 0)return  P;
-    if(strcmp(etag, str) == 0)return EP;
-    return 0;
-}
-int isSCORE        (char *str){
-    char stag [] = "<ScoreThreshold>";
-    char etag [] = "</ScoreThreshold>";
-    if(strcmp(stag, str) == 0)return  SCORE;
-    if(strcmp(etag, str) == 0)return ESCORE;
-    return 0;
-}
-int isCOMP     (char *str){
-    char stag [] = "<Component>";
-    char etag [] = "</Component>";
-    if(strcmp(stag, str) == 0)return  COMP;
-    if(strcmp(etag, str) == 0)return ECOMP;
-    return 0;
-}
-int isRFILTER  (char *str){
-    char stag [] = "<RootFilter>";
-    char etag [] = "</RootFilter>";
-    if(strcmp(stag, str) == 0)return  RFILTER;
-    if(strcmp(etag, str) == 0)return ERFILTER;
-    return 0;
-}
-int isPFILTERs (char *str){
-    char stag [] = "<PartFilters>";
-    char etag [] = "</PartFilters>";
-    if(strcmp(stag, str) == 0)return  PFILTERs;
-    if(strcmp(etag, str) == 0)return EPFILTERs;
-    return 0;
-}
-int isPFILTER  (char *str){
-    char stag [] = "<PartFilter>";
-    char etag [] = "</PartFilter>";
-    if(strcmp(stag, str) == 0)return  PFILTER;
-    if(strcmp(etag, str) == 0)return EPFILTER;
-    return 0;
-}
-int isSIZEX    (char *str){
-    char stag [] = "<sizeX>";
-    char etag [] = "</sizeX>";
-    if(strcmp(stag, str) == 0)return  SIZEX;
-    if(strcmp(etag, str) == 0)return ESIZEX;
-    return 0;
-}
-int isSIZEY    (char *str){
-    char stag [] = "<sizeY>";
-    char etag [] = "</sizeY>";
-    if(strcmp(stag, str) == 0)return  SIZEY;
-    if(strcmp(etag, str) == 0)return ESIZEY;
-    return 0;
-}
-int isWEIGHTS  (char *str){
-    char stag [] = "<Weights>";
-    char etag [] = "</Weights>";
-    if(strcmp(stag, str) == 0)return  WEIGHTS;
-    if(strcmp(etag, str) == 0)return EWEIGHTS;
-    return 0;
-}
-int isV        (char *str){
-    char stag [] = "<V>";
-    char etag [] = "</V>";
-    if(strcmp(stag, str) == 0)return  TAGV;
-    if(strcmp(etag, str) == 0)return ETAGV;
-    return 0;
-}
-int isVx       (char *str){
-    char stag [] = "<Vx>";
-    char etag [] = "</Vx>";
-    if(strcmp(stag, str) == 0)return  Vx;
-    if(strcmp(etag, str) == 0)return EVx;
-    return 0;
-}
-int isVy       (char *str){
-    char stag [] = "<Vy>";
-    char etag [] = "</Vy>";
-    if(strcmp(stag, str) == 0)return  Vy;
-    if(strcmp(etag, str) == 0)return EVy;
-    return 0;
-}
-int isD        (char *str){
-    char stag [] = "<Penalty>";
-    char etag [] = "</Penalty>";
-    if(strcmp(stag, str) == 0)return  TAGD;
-    if(strcmp(etag, str) == 0)return ETAGD;
-    return 0;
-}
-int isDx       (char *str){
-    char stag [] = "<dx>";
-    char etag [] = "</dx>";
-    if(strcmp(stag, str) == 0)return  Dx;
-    if(strcmp(etag, str) == 0)return EDx;
-    return 0;
-}
-int isDy       (char *str){
-    char stag [] = "<dy>";
-    char etag [] = "</dy>";
-    if(strcmp(stag, str) == 0)return  Dy;
-    if(strcmp(etag, str) == 0)return EDy;
-    return 0;
-}
-int isDxx      (char *str){
-    char stag [] = "<dxx>";
-    char etag [] = "</dxx>";
-    if(strcmp(stag, str) == 0)return  Dxx;
-    if(strcmp(etag, str) == 0)return EDxx;
-    return 0;
-}
-int isDyy      (char *str){
-    char stag [] = "<dyy>";
-    char etag [] = "</dyy>";
-    if(strcmp(stag, str) == 0)return  Dyy;
-    if(strcmp(etag, str) == 0)return EDyy;
-    return 0;
-}
-int isB      (char *str){
-    char stag [] = "<LinearTerm>";
-    char etag [] = "</LinearTerm>";
-    if(strcmp(stag, str) == 0)return  BTAG;
-    if(strcmp(etag, str) == 0)return EBTAG;
-    return 0;
-}
-
-int getTeg(char *str){
-    int sum = 0;
-    sum = isMODEL (str)+
-    isP        (str)+
-    isSCORE    (str)+
-    isCOMP     (str)+
-    isRFILTER  (str)+
-    isPFILTERs (str)+
-    isPFILTER  (str)+
-    isSIZEX    (str)+
-    isSIZEY    (str)+
-    isWEIGHTS  (str)+
-    isV        (str)+
-    isVx       (str)+
-    isVy       (str)+
-    isD        (str)+
-    isDx       (str)+
-    isDy       (str)+
-    isDxx      (str)+
-    isDyy      (str)+
-    isB        (str);
-
-    return sum;
-}
-
-void addFilter(CvLSVMFilterObject *** model, int *last, int *max){
-    CvLSVMFilterObject ** nmodel;
-    int i;
-    (*last) ++;
-    if((*last) >= (*max)){
-        (*max) += 10;
-        nmodel = (CvLSVMFilterObject **)malloc(sizeof(CvLSVMFilterObject *) * (*max));
-        for(i = 0; i < *last; i++){
-            nmodel[i] = (* model)[i];
-        }
-        free(* model);
-        (*model) = nmodel;
-    }
-    (*model) [(*last)] = (CvLSVMFilterObject *)malloc(sizeof(CvLSVMFilterObject));
-}
-
-void parserRFilter  (FILE * xmlf, int p, CvLSVMFilterObject * model, float *b){
-    int st = 0;
-    int sizeX=0, sizeY=0;
-    int tag;
-    int tagVal;
-    char ch;
-    int i,j,ii;
-    char buf[1024];
-    char tagBuf[1024];
-    double *data;
-    //printf("<RootFilter>\n");
-
-    model->V.x = 0;
-    model->V.y = 0;
-    model->V.l = 0;
-    model->fineFunction[0] = 0.0;
-    model->fineFunction[1] = 0.0;
-    model->fineFunction[2] = 0.0;
-    model->fineFunction[3] = 0.0;
-
-    i   = 0;
-    j   = 0;
-    st  = 0;
-    tag = 0;
-    while(!feof(xmlf)){
-        ch = (char)fgetc( xmlf );
-        if(ch == '<'){
-            tag = 1;
-            j   = 1;
-            tagBuf[j - 1] = ch;
-        }else {
-            if(ch == '>'){
-                tagBuf[j    ] = ch;
-                tagBuf[j + 1] = '\0';
-
-                tagVal = getTeg(tagBuf);
-
-                if(tagVal == ERFILTER){
-                    //printf("</RootFilter>\n");
-                    return;
-                }
-                if(tagVal == SIZEX){
-                    st = 1;
-                    i = 0;
-                }
-                if(tagVal == ESIZEX){
-                    st = 0;
-                    buf[i] = '\0';
-                    sizeX = atoi(buf);
-                    model->sizeX = sizeX;
-                    //printf("<sizeX>%d</sizeX>\n", sizeX);
-                }
-                if(tagVal == SIZEY){
-                    st = 1;
-                    i = 0;
-                }
-                if(tagVal == ESIZEY){
-                    st = 0;
-                    buf[i] = '\0';
-                    sizeY = atoi(buf);
-                    model->sizeY = sizeY;
-                    //printf("<sizeY>%d</sizeY>\n", sizeY);
-                }
-                if(tagVal == WEIGHTS){
-                    data = (double *)malloc( sizeof(double) * p * sizeX * sizeY);
-                    size_t elements_read = fread(data, sizeof(double), p * sizeX * sizeY, xmlf);
-                    CV_Assert(elements_read == (size_t)(p * sizeX * sizeY));
-                    model->H = (float *)malloc(sizeof(float)* p * sizeX * sizeY);
-                    for(ii = 0; ii < p * sizeX * sizeY; ii++){
-                        model->H[ii] = (float)data[ii];
-                    }
-                    free(data);
-                }
-                if(tagVal == EWEIGHTS){
-                    //printf("WEIGHTS OK\n");
-                }
-                if(tagVal == BTAG){
-                    st = 1;
-                    i = 0;
-                }
-                if(tagVal == EBTAG){
-                    st = 0;
-                    buf[i] = '\0';
-                    *b =(float) atof(buf);
-                    //printf("<B>%f</B>\n", *b);
-                }
-
-                tag = 0;
-                i   = 0;
-            }else{
-                if((tag == 0)&& (st == 1)){
-                    buf[i] = ch; i++;
-                }else{
-                    tagBuf[j] = ch; j++;
-                }
-            }
-        }
-    }
-}
-
-void parserV  (FILE * xmlf, int /*p*/, CvLSVMFilterObject * model){
-    int st = 0;
-    int tag;
-    int tagVal;
-    char ch;
-    int i,j;
-    char buf[1024];
-    char tagBuf[1024];
-    //printf("    <V>\n");
-
-    i   = 0;
-    j   = 0;
-    st  = 0;
-    tag = 0;
-    while(!feof(xmlf)){
-        ch = (char)fgetc( xmlf );
-        if(ch == '<'){
-            tag = 1;
-            j   = 1;
-            tagBuf[j - 1] = ch;
-        }else {
-            if(ch == '>'){
-                tagBuf[j    ] = ch;
-                tagBuf[j + 1] = '\0';
-
-                tagVal = getTeg(tagBuf);
-
-                if(tagVal == ETAGV){
-                    //printf("    </V>\n");
-                    return;
-                }
-                if(tagVal == Vx){
-                    st = 1;
-                    i = 0;
-                }
-                if(tagVal == EVx){
-                    st = 0;
-                    buf[i] = '\0';
-                    model->V.x = atoi(buf);
-                    //printf("        <Vx>%d</Vx>\n", model->V.x);
-                }
-                if(tagVal == Vy){
-                    st = 1;
-                    i = 0;
-                }
-                if(tagVal == EVy){
-                    st = 0;
-                    buf[i] = '\0';
-                    model->V.y = atoi(buf);
-                    //printf("        <Vy>%d</Vy>\n", model->V.y);
-                }
-                tag = 0;
-                i   = 0;
-            }else{
-                if((tag == 0)&& (st == 1)){
-                    buf[i] = ch; i++;
-                }else{
-                    tagBuf[j] = ch; j++;
-                }
-            }
-        }
-    }
-}
-void parserD  (FILE * xmlf, int /*p*/, CvLSVMFilterObject * model){
-    int st = 0;
-    int tag;
-    int tagVal;
-    char ch;
-    int i,j;
-    char buf[1024];
-    char tagBuf[1024];
-    //printf("    <D>\n");
-
-    i   = 0;
-    j   = 0;
-    st  = 0;
-    tag = 0;
-    while(!feof(xmlf)){
-        ch = (char)fgetc( xmlf );
-        if(ch == '<'){
-            tag = 1;
-            j   = 1;
-            tagBuf[j - 1] = ch;
-        }else {
-            if(ch == '>'){
-                tagBuf[j    ] = ch;
-                tagBuf[j + 1] = '\0';
-
-                tagVal = getTeg(tagBuf);
-
-                if(tagVal == ETAGD){
-                    //printf("    </D>\n");
-                    return;
-                }
-                if(tagVal == Dx){
-                    st = 1;
-                    i = 0;
-                }
-                if(tagVal == EDx){
-                    st = 0;
-                    buf[i] = '\0';
-
-                    model->fineFunction[0] = (float)atof(buf);
-                    //printf("        <Dx>%f</Dx>\n", model->fineFunction[0]);
-                }
-                if(tagVal == Dy){
-                    st = 1;
-                    i = 0;
-                }
-                if(tagVal == EDy){
-                    st = 0;
-                    buf[i] = '\0';
-
-                    model->fineFunction[1] = (float)atof(buf);
-                    //printf("        <Dy>%f</Dy>\n", model->fineFunction[1]);
-                }
-                if(tagVal == Dxx){
-                    st = 1;
-                    i = 0;
-                }
-                if(tagVal == EDxx){
-                    st = 0;
-                    buf[i] = '\0';
-
-                    model->fineFunction[2] = (float)atof(buf);
-                    //printf("        <Dxx>%f</Dxx>\n", model->fineFunction[2]);
-                }
-                if(tagVal == Dyy){
-                    st = 1;
-                    i = 0;
-                }
-                if(tagVal == EDyy){
-                    st = 0;
-                    buf[i] = '\0';
-
-                    model->fineFunction[3] = (float)atof(buf);
-                    //printf("        <Dyy>%f</Dyy>\n", model->fineFunction[3]);
-                }
-
-                tag = 0;
-                i   = 0;
-            }else{
-                if((tag == 0)&& (st == 1)){
-                    buf[i] = ch; i++;
-                }else{
-                    tagBuf[j] = ch; j++;
-                }
-            }
-        }
-    }
-}
-
-void parserPFilter  (FILE * xmlf, int p, int /*N_path*/, CvLSVMFilterObject * model){
-    int st = 0;
-    int sizeX=0, sizeY=0;
-    int tag;
-    int tagVal;
-    char ch;
-    int i,j, ii;
-    char buf[1024];
-    char tagBuf[1024];
-    double *data;
-    //printf("<PathFilter> (%d)\n", N_path);
-
-    model->V.x = 0;
-    model->V.y = 0;
-    model->V.l = 0;
-    model->fineFunction[0] = 0.0f;
-    model->fineFunction[1] = 0.0f;
-    model->fineFunction[2] = 0.0f;
-    model->fineFunction[3] = 0.0f;
-
-    i   = 0;
-    j   = 0;
-    st  = 0;
-    tag = 0;
-    while(!feof(xmlf)){
-        ch = (char)fgetc( xmlf );
-        if(ch == '<'){
-            tag = 1;
-            j   = 1;
-            tagBuf[j - 1] = ch;
-        }else {
-            if(ch == '>'){
-                tagBuf[j    ] = ch;
-                tagBuf[j + 1] = '\0';
-
-                tagVal = getTeg(tagBuf);
-
-                if(tagVal == EPFILTER){
-                    //printf("</PathFilter>\n");
-                    return;
-                }
-
-                if(tagVal == TAGV){
-                    parserV(xmlf, p, model);
-                }
-                if(tagVal == TAGD){
-                    parserD(xmlf, p, model);
-                }
-                if(tagVal == SIZEX){
-                    st = 1;
-                    i = 0;
-                }
-                if(tagVal == ESIZEX){
-                    st = 0;
-                    buf[i] = '\0';
-                    sizeX = atoi(buf);
-                    model->sizeX = sizeX;
-                    //printf("<sizeX>%d</sizeX>\n", sizeX);
-                }
-                if(tagVal == SIZEY){
-                    st = 1;
-                    i = 0;
-                }
-                if(tagVal == ESIZEY){
-                    st = 0;
-                    buf[i] = '\0';
-                    sizeY = atoi(buf);
-                    model->sizeY = sizeY;
-                    //printf("<sizeY>%d</sizeY>\n", sizeY);
-                }
-                if(tagVal == WEIGHTS){
-                    data = (double *)malloc( sizeof(double) * p * sizeX * sizeY);
-                    size_t elements_read = fread(data, sizeof(double), p * sizeX * sizeY, xmlf);
-                    CV_Assert(elements_read == (size_t)(p * sizeX * sizeY));
-                    model->H = (float *)malloc(sizeof(float)* p * sizeX * sizeY);
-                    for(ii = 0; ii < p * sizeX * sizeY; ii++){
-                        model->H[ii] = (float)data[ii];
-                    }
-                    free(data);
-                }
-                if(tagVal == EWEIGHTS){
-                    //printf("WEIGHTS OK\n");
-                }
-                tag = 0;
-                i   = 0;
-            }else{
-                if((tag == 0)&& (st == 1)){
-                    buf[i] = ch; i++;
-                }else{
-                    tagBuf[j] = ch; j++;
-                }
-            }
-        }
-    }
-}
-void parserPFilterS (FILE * xmlf, int p, CvLSVMFilterObject *** model, int *last, int *max){
-    int st = 0;
-    int N_path = 0;
-    int tag;
-    int tagVal;
-    char ch;
-    int /*i,*/j;
-    //char buf[1024];
-    char tagBuf[1024];
-    //printf("<PartFilters>\n");
-
-    //i   = 0;
-    j   = 0;
-    st  = 0;
-    tag = 0;
-    while(!feof(xmlf)){
-        ch = (char)fgetc( xmlf );
-        if(ch == '<'){
-            tag = 1;
-            j   = 1;
-            tagBuf[j - 1] = ch;
-        }else {
-            if(ch == '>'){
-                tagBuf[j    ] = ch;
-                tagBuf[j + 1] = '\0';
-
-                tagVal = getTeg(tagBuf);
-
-                if(tagVal == EPFILTERs){
-                    //printf("</PartFilters>\n");
-                    return;
-                }
-                if(tagVal == PFILTER){
-                    addFilter(model, last, max);
-                    parserPFilter  (xmlf, p, N_path, (*model)[*last]);
-                    N_path++;
-                }
-                tag = 0;
-                //i   = 0;
-            }else{
-                if((tag == 0)&& (st == 1)){
-                    //buf[i] = ch; i++;
-                }else{
-                    tagBuf[j] = ch; j++;
-                }
-            }
-        }
-    }
-}
-void parserComp (FILE * xmlf, int p, int *N_comp, CvLSVMFilterObject *** model, float *b, int *last, int *max){
-    int st = 0;
-    int tag;
-    int tagVal;
-    char ch;
-    int /*i,*/j;
-    //char buf[1024];
-    char tagBuf[1024];
-    //printf("<Component> %d\n", *N_comp);
-
-    //i   = 0;
-    j   = 0;
-    st  = 0;
-    tag = 0;
-    while(!feof(xmlf)){
-        ch = (char)fgetc( xmlf );
-        if(ch == '<'){
-            tag = 1;
-            j   = 1;
-            tagBuf[j - 1] = ch;
-        }else {
-            if(ch == '>'){
-                tagBuf[j    ] = ch;
-                tagBuf[j + 1] = '\0';
-
-                tagVal = getTeg(tagBuf);
-
-                if(tagVal == ECOMP){
-                    (*N_comp) ++;
-                    return;
-                }
-                if(tagVal == RFILTER){
-                    addFilter(model, last, max);
-                    parserRFilter   (xmlf, p, (*model)[*last],b);
-                }
-                if(tagVal == PFILTERs){
-                    parserPFilterS  (xmlf, p, model, last, max);
-                }
-                tag = 0;
-                //i   = 0;
-            }else{
-                if((tag == 0)&& (st == 1)){
-                    //buf[i] = ch; i++;
-                }else{
-                    tagBuf[j] = ch; j++;
-                }
-            }
-        }
-    }
-}
-void parserModel(FILE * xmlf, CvLSVMFilterObject *** model, int *last, int *max, int **comp, float **b, int *count, float * score){
-    int p = 0;
-    int N_comp = 0;
-    int * cmp;
-    float *bb;
-    int st = 0;
-    int tag;
-    int tagVal;
-    char ch;
-    int i,j, ii = 0;
-    char buf[1024];
-    char tagBuf[1024];
-
-    //printf("<Model>\n");
-
-    i   = 0;
-    j   = 0;
-    st  = 0;
-    tag = 0;
-    while(!feof(xmlf)){
-        ch = (char)fgetc( xmlf );
-        if(ch == '<'){
-            tag = 1;
-            j   = 1;
-            tagBuf[j - 1] = ch;
-        }else {
-            if(ch == '>'){
-                tagBuf[j    ] = ch;
-                tagBuf[j + 1] = '\0';
-
-                tagVal = getTeg(tagBuf);
-
-                if(tagVal == EMODEL){
-                    //printf("</Model>\n");
-                    for(ii = 0; ii <= *last; ii++){
-                        (*model)[ii]->numFeatures = p;
-                    }
-                    * count = N_comp;
-                    return;
-                }
-                if(tagVal == COMP){
-                    if(N_comp == 0){
-                        cmp = (int    *)malloc(sizeof(int));
-                        bb  = (float *)malloc(sizeof(float));
-                        * comp = cmp;
-                        * b    = bb;
-                        * count = N_comp + 1;
-                    } else {
-                        cmp = (int   *)malloc(sizeof(int)   * (N_comp + 1));
-                        bb  = (float *)malloc(sizeof(float) * (N_comp + 1));
-                        for(ii = 0; ii < N_comp; ii++){
-                            cmp[ii] = (* comp)[ii];
-                            bb [ii] = (* b   )[ii];
-                        }
-                        free(* comp);
-                        free(* b   );
-                        * comp = cmp;
-                        * b    = bb;
-                        * count = N_comp + 1;
-                    }
-                    parserComp(xmlf, p, &N_comp, model, &((*b)[N_comp]), last, max);
-                    cmp[N_comp - 1] = *last;
-                }
-                if(tagVal == P){
-                    st = 1;
-                    i = 0;
-                }
-                if(tagVal == EP){
-                    st = 0;
-                    buf[i] = '\0';
-                    p = atoi(buf);
-                    //printf("<P>%d</P>\n", p);
-                }
-                if(tagVal == SCORE){
-                    st = 1;
-                    i = 0;
-                }
-                if(tagVal == ESCORE){
-                    st = 0;
-                    buf[i] = '\0';
-                    *score = (float)atof(buf);
-                    //printf("<ScoreThreshold>%f</ScoreThreshold>\n", score);
-                }
-                tag = 0;
-                i   = 0;
-            }else{
-                if((tag == 0)&& (st == 1)){
-                    buf[i] = ch; i++;
-                }else{
-                    tagBuf[j] = ch; j++;
-                }
-            }
-        }
-    }
-}
-
-}//namespace
-
-int LSVMparser(const char * filename, CvLSVMFilterObject *** model, int *last, int *max, int **comp, float **b, int *count, float * score){
-    //int st = 0;
-    int tag;
-    char ch;
-    int /*i,*/j;
-    FILE *xmlf;
-    //char buf[1024];
-    char tagBuf[1024];
-
-    (*max) = 10;
-    (*last) = -1;
-    (*model) = (CvLSVMFilterObject ** )malloc((sizeof(CvLSVMFilterObject * )) * (*max));
-
-    //printf("parse : %s\n", filename);
-
-    xmlf = fopen(filename, "rb");
-    if(xmlf == NULL) {
-        free(*model);
-        *model = NULL;
-        return LSVM_PARSER_FILE_NOT_FOUND;
-    }
-
-    //i   = 0;
-    j   = 0;
-    //st  = 0;
-    tag = 0;
-    while(!feof(xmlf)){
-        ch = (char)fgetc( xmlf );
-        if(ch == '<'){
-            tag = 1;
-            j   = 1;
-            tagBuf[j - 1] = ch;
-        }else {
-            if(ch == '>'){
-                tag = 0;
-                //i   = 0;
-                tagBuf[j    ] = ch;
-                tagBuf[j + 1] = '\0';
-                if(getTeg(tagBuf) == MODEL){
-                    parserModel(xmlf, model, last, max, comp, b, count, score);
-                }
-            }else{
-                if(tag == 0){
-                    //buf[i] = ch; i++;
-                }else{
-                    tagBuf[j] = ch; j++;
-                }
-            }
-        }
-    }
-
-    fclose(xmlf);
-    return LATENT_SVM_OK;
-}
-
-int loadModel(
-              const char *modelPath,
-              CvLSVMFilterObject ***filters,
-              int *kFilters,
-              int *kComponents,
-              int **kPartFilters,
-              float **b,
-              float *scoreThreshold){
-    int last;
-    int max;
-    int *comp = NULL;
-    int count;
-    int i;
-    int err;
-    float score;
-    //printf("start_parse\n\n");
-
-    err = LSVMparser(modelPath, filters, &last, &max, &comp, b, &count, &score);
-    if(err != LATENT_SVM_OK){
-        return err;
-    }
-    (*kFilters)       = last + 1;
-    (*kComponents)    = count;
-    (*scoreThreshold) = (float) score;
-
-    (*kPartFilters) = (int *)malloc(sizeof(int) * count);
-
-    for(i = 1; i < count;i++){
-        (*kPartFilters)[i] = (comp[i] - comp[i - 1]) - 1;
-    }
-    (*kPartFilters)[0] = comp[0];
-    free(comp);
-
-    return 0;
-}
diff --git a/modules/objdetect/src/lsvmtbbversion.cpp b/modules/objdetect/src/lsvmtbbversion.cpp
deleted file mode 100644 (file)
index 26e85bd..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-#include "precomp.hpp"
-
-#ifdef HAVE_TBB
-#include "_lsvm_tbbversion.h"
-
-/*
-// Task class
-*/
-class ScoreComputation : public tbb::task
-{
-private:
-    const CvLSVMFilterObject **filters;
-    const int n;
-    const CvLSVMFeaturePyramid *H;
-    const float b;
-    const int maxXBorder;
-    const int maxYBorder;
-    const float scoreThreshold;
-    const int kLevels;
-    const int *procLevels;
-public:
-    float **score;
-    CvPoint ***points;
-    CvPoint ****partsDisplacement;
-    int *kPoints;
-public:
-    ScoreComputation(const CvLSVMFilterObject **_filters, int _n,
-                     const CvLSVMFeaturePyramid *_H,
-                     float _b, int _maxXBorder, int _maxYBorder,
-                     float _scoreThreshold, int _kLevels, const int *_procLevels,
-                     float **_score, CvPoint ***_points, int *_kPoints,
-                     CvPoint ****_partsDisplacement) :
-    n(_n), b(_b), maxXBorder(_maxXBorder),
-        maxYBorder(_maxYBorder), scoreThreshold(_scoreThreshold),
-        kLevels(_kLevels), score(_score), points(_points),
-        partsDisplacement(_partsDisplacement), kPoints(_kPoints)
-    {
-        filters = _filters;
-        H = _H;
-        procLevels = _procLevels;
-    };
-
-    task* execute()
-    {
-        int i, level, partsLevel, res;
-        for (i = 0; i < kLevels; i++)
-        {
-            level = procLevels[i];
-            partsLevel = level - LAMBDA;//H->lambda;
-            res = thresholdFunctionalScoreFixedLevel(
-                filters, n, H, level, b,
-                maxXBorder, maxYBorder, scoreThreshold, &(score[partsLevel]),
-                points[partsLevel], &(kPoints[partsLevel]),
-                partsDisplacement[partsLevel]);
-            if (res != LATENT_SVM_OK)
-            {
-                continue;
-            }
-        }
-        return NULL;
-    }
-};
-
-/*
-// Computation score function using TBB tasks
-//
-// API
-// int tbbTasksThresholdFunctionalScore(const CvLSVMFilterObject **filters, const int n,
-                                        const CvLSVMFeatureMap *H, const float b,
-                                        const int maxXBorder, const int maxYBorder,
-                                        const float scoreThreshold,
-                                        int *kLevels, int **procLevels,
-                                        const int threadsNum,
-                                        float **score, CvPoint ***points,
-                                        int *kPoints,
-                                        CvPoint ****partsDisplacement);
-// INPUT
-// filters           - the set of filters (the first element is root filter,
-                       the other - part filters)
-// n                 - the number of part filters
-// H                 - feature pyramid
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// scoreThreshold    - score threshold
-// kLevels           - array that contains number of levels processed
-                       by each thread
-// procLevels        - array that contains lists of levels processed
-                       by each thread
-// threadsNum        - the number of created threads
-// OUTPUT
-// score             - score function values that exceed threshold
-// points            - the set of root filter positions (in the block space)
-// kPoints           - number of root filter positions
-// partsDisplacement - displacement of part filters (in the block space)
-// RESULT
-//
-*/
-int tbbTasksThresholdFunctionalScore(const CvLSVMFilterObject **filters, const int n,
-                                     const CvLSVMFeaturePyramid *H, const float b,
-                                     const int maxXBorder, const int maxYBorder,
-                                     const float scoreThreshold,
-                                     int *kLevels, int **procLevels,
-                                     const int threadsNum,
-                                     float **score, CvPoint ***points,
-                                     int *kPoints,
-                                     CvPoint ****partsDisplacement)
-{
-    tbb::task_list tasks;
-    int i;
-    for (i = 0; i < threadsNum; i++)
-    {
-        ScoreComputation& sc =
-            *new(tbb::task::allocate_root()) ScoreComputation(filters, n, H, b,
-            maxXBorder, maxYBorder, scoreThreshold, kLevels[i], procLevels[i],
-            score, points, kPoints, partsDisplacement);
-        tasks.push_back(sc);
-    }
-    tbb::task::spawn_root_and_wait(tasks);
-    return LATENT_SVM_OK;
-};
-#endif
diff --git a/modules/objdetect/src/matching.cpp b/modules/objdetect/src/matching.cpp
deleted file mode 100644 (file)
index 871c9e6..0000000
+++ /dev/null
@@ -1,1800 +0,0 @@
-#include "precomp.hpp"
-#include "opencv2/objdetect/objdetect_c.h"
-#include "_lsvm_matching.h"
-#include <stdio.h>
-
-#ifndef max
-#define max(a,b)            (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef min
-#define min(a,b)            (((a) < (b)) ? (a) : (b))
-#endif
-
-/*
-// Function for convolution computation
-//
-// INPUT
-// Fi                - filter object
-// map               - feature map
-// OUTPUT
-// f                 - the convolution
-// RESULT
-// Error status
-*/
-int convolution(const CvLSVMFilterObject *Fi, const CvLSVMFeatureMap *map, float *f)
-{
-    int n1, m1, n2, m2, p, /*size,*/ diff1, diff2;
-    int i1, i2, j1, j2, k;
-    float tmp_f1, tmp_f2, tmp_f3, tmp_f4;
-    float *pMap = NULL;
-    float *pH = NULL;
-
-    n1 = map->sizeY;
-    m1 = map->sizeX;
-    n2 = Fi->sizeY;
-    m2 = Fi->sizeX;
-    p = map->numFeatures;
-
-    diff1 = n1 - n2 + 1;
-    diff2 = m1 - m2 + 1;
-    //size = diff1 * diff2;
-    for (j1 = diff2 - 1; j1 >= 0; j1--)
-    {
-
-        for (i1 = diff1 - 1; i1 >= 0; i1--)
-        {
-            tmp_f1 = 0.0f;
-            tmp_f2 = 0.0f;
-            tmp_f3 = 0.0f;
-            tmp_f4 = 0.0f;
-            for (i2 = 0; i2 < n2; i2++)
-            {
-                for (j2 = 0; j2 < m2; j2++)
-                {
-                    pMap = map->map + (i1 + i2) * m1 * p + (j1 + j2) * p;//sm2
-                    pH = Fi->H + (i2 * m2 + j2) * p;//sm2
-                    for (k = 0; k < p/4; k++)
-                    {
-
-                        tmp_f1 += pMap[4*k]*pH[4*k];//sm2
-                        tmp_f2 += pMap[4*k+1]*pH[4*k+1];
-                        tmp_f3 += pMap[4*k+2]*pH[4*k+2];
-                        tmp_f4 += pMap[4*k+3]*pH[4*k+3];
-                    }
-
-                    if (p%4==1)
-                    {
-                        tmp_f1 += pH[p-1]*pMap[p-1];
-                    }
-                    else
-                    {
-                        if (p%4==2)
-                        {
-                            tmp_f1 += pH[p-2]*pMap[p-2] + pH[p-1]*pMap[p-1];
-                        }
-                        else
-                        {
-                            if (p%4==3)
-                            {
-                                tmp_f1 += pH[p-3]*pMap[p-3] + pH[p-2]*pMap[p-2] + pH[p-1]*pMap[p-1];
-                            }
-                        }
-                    }
-
-                }
-            }
-            f[i1 * diff2 + j1] = tmp_f1 + tmp_f2 + tmp_f3 + tmp_f4;//sm1
-        }
-    }
-    return LATENT_SVM_OK;
-}
-
-/*
-// Computation multiplication of FFT images
-//
-// API
-// int fftImagesMulti(float *fftImage1, float *fftImage2, int numRows, int numColls,
-                      float *multi);
-// INPUT
-// fftImage1         - first fft image
-// fftImage2         - second fft image
-// (numRows, numColls) - image dimesions
-// OUTPUT
-// multi             - multiplication
-// RESULT
-// Error status
-*/
-int fftImagesMulti(float *fftImage1, float *fftImage2, int numRows, int numColls,
-                   float *multi)
-{
-    int i, index, size;
-    size = numRows * numColls;
-    for (i = 0; i < size; i++)
-    {
-        index = 2 * i;
-        multi[index] = fftImage1[index] * fftImage2[index] -
-                       fftImage1[index + 1] * fftImage2[index + 1];
-        multi[index + 1] = fftImage1[index] * fftImage2[index + 1] +
-                           fftImage1[index + 1] * fftImage2[index];
-    }
-    return LATENT_SVM_OK;
-}
-
-/*
-// Turnover filter matrix for the single feature
-//
-// API
-// int rot2PI(float *filter, int dimX, int dimY, float *rot2PIFilter,
-              int p, int shift);
-// INPUT
-// filter            - filter weight matrix
-// (dimX, dimY)      - dimension of filter matrix
-// p                 - number of features
-// shift             - number of feature (or channel)
-// OUTPUT
-// rot2PIFilter      - rotated matrix
-// RESULT
-// Error status
-*/
-int rot2PI(float *filter, int dimX, int dimY, float *rot2PIFilter,
-           int p, int shift)
-{
-    int i, size;
-    size = dimX * dimY;
-    for (i = 0; i < size; i++)
-    {
-        rot2PIFilter[i] = filter[(size - i - 1) * p + shift];
-    }
-    return LATENT_SVM_OK;
-}
-
-/*
-// Addition nullable bars to the dimension of feature map (single feature)
-//
-// API
-// int addNullableBars(float *rot2PIFilter, int dimX, int dimY,
-                       float *newFilter, int newDimX, int newDimY);
-// INPUT
-// rot2PIFilter      - filter matrix for the single feature that was rotated
-// (dimX, dimY)      - dimension rot2PIFilter
-// (newDimX, newDimY)- dimension of feature map for the single feature
-// OUTPUT
-// newFilter         - filter matrix with nullable bars
-// RESULT
-// Error status
-*/
-int addNullableBars(float *rot2PIFilter, int dimX, int dimY,
-                    float *newFilter, int newDimX, int newDimY)
-{
-    int size, i, j;
-    size = newDimX * newDimY;
-    for (i = 0; i < size; i++)
-    {
-        newFilter[2 * i] = 0.0;
-        newFilter[2 * i + 1] = 0.0;
-    }
-    for (i = 0; i < dimY; i++)
-    {
-        for (j = 0; j < dimX; j++)
-        {
-            newFilter[2 * (i * newDimX + j)] = rot2PIFilter[i * dimX + j];
-        }
-    }
-    return LATENT_SVM_OK;
-}
-
-/*
-// Computation FFT image for filter object
-//
-// API
-// int getFFTImageFilterObject(const CvLSVMFilterObject *filter,
-                               int mapDimX, int mapDimY,
-                               fftImage **image);
-// INPUT
-// filter        - filter object
-// (mapDimX, mapDimY)- dimension of feature map
-// OUTPUT
-// image         - fft image
-// RESULT
-// Error status
-*/
-int getFFTImageFilterObject(const CvLSVMFilterObject *filter,
-                            int mapDimX, int mapDimY,
-                            CvLSVMFftImage **image)
-{
-    int i, mapSize, filterSize, res;
-    float *newFilter, *rot2PIFilter;
-
-    filterSize = filter->sizeX * filter->sizeY;
-    mapSize = mapDimX * mapDimY;
-
-    res = allocFFTImage(image, filter->numFeatures, mapDimX, mapDimY);
-    if (res != LATENT_SVM_OK)
-        return res;
-
-    newFilter = (float *)malloc(sizeof(float) * (2 * mapSize));
-    rot2PIFilter = (float *)malloc(sizeof(float) * filterSize);
-    for (i = 0; i < filter->numFeatures; i++)
-    {
-        rot2PI(filter->H, filter->sizeX, filter->sizeY, rot2PIFilter, filter->numFeatures, i);
-        addNullableBars(rot2PIFilter, filter->sizeX, filter->sizeY,
-                        newFilter, mapDimX, mapDimY);
-        fft2d(newFilter, (*image)->channels[i], mapDimY, mapDimX);
-    }
-    free(newFilter);
-    free(rot2PIFilter);
-    return LATENT_SVM_OK;
-}
-
-/*
-// Computation FFT image for feature map
-//
-// API
-// int getFFTImageFeatureMap(const featureMap *map, fftImage **image);
-// INPUT
-// OUTPUT
-// RESULT
-// Error status
-*/
-int getFFTImageFeatureMap(const CvLSVMFeatureMap *map, CvLSVMFftImage **image)
-{
-    int i, j, size;
-    float *buf;
-    allocFFTImage(image, map->numFeatures, map->sizeX, map->sizeY);
-    size = map->sizeX * map->sizeY;
-    buf = (float *)malloc(sizeof(float) * (2 * size));
-    for (i = 0; i < map->numFeatures; i++)
-    {
-        for (j = 0; j < size; j++)
-        {
-            buf[2 * j] = map->map[j * map->numFeatures + i];
-            buf[2 * j + 1] = 0.0;
-        }
-        fft2d(buf, (*image)->channels[i], map->sizeY, map->sizeX);
-    }
-    free(buf);
-    return LATENT_SVM_OK;
-}
-
-/*
-// Function for convolution computation using FFT
-//
-// API
-// int convFFTConv2d(const fftImage *featMapImage, const fftImage *filterImage,
-                     int filterDimX, int filterDimY, float **conv);
-// INPUT
-// featMapImage      - feature map image
-// filterImage       - filter image
-// (filterDimX,filterDimY) - filter dimension
-// OUTPUT
-// conv              - the convolution
-// RESULT
-// Error status
-*/
-int convFFTConv2d(const CvLSVMFftImage *featMapImage, const CvLSVMFftImage *filterImage,
-                  int filterDimX, int filterDimY, float **conv)
-{
-    int i, j, size, diffX, diffY, index;
-    float *imagesMult, *imagesMultRes, *fconv;
-    size = 2 * featMapImage->dimX * featMapImage->dimY;
-    imagesMult = (float *)malloc(sizeof(float) * size);
-    imagesMultRes = (float *)malloc(sizeof(float) * size);
-    fftImagesMulti(featMapImage->channels[0], filterImage->channels[0],
-            featMapImage->dimY, featMapImage->dimX, imagesMultRes);
-    for (i = 1; (i < (int)featMapImage->numFeatures) && (i < (int)filterImage->numFeatures); i++)
-    {
-        fftImagesMulti(featMapImage->channels[i],filterImage->channels[i],
-            featMapImage->dimY, featMapImage->dimX, imagesMult);
-        for (j = 0; j < size; j++)
-        {
-            imagesMultRes[j] += imagesMult[j];
-        }
-    }
-    fconv = (float *)malloc(sizeof(float) * size);
-    fftInverse2d(imagesMultRes, fconv, featMapImage->dimY, featMapImage->dimX);
-    diffX = featMapImage->dimX - filterDimX + 1;
-    diffY = featMapImage->dimY - filterDimY + 1;
-    *conv = (float *)malloc(sizeof(float) * (diffX * diffY));
-    for (i = 0; i < diffY; i++)
-    {
-        for (j = 0; j < diffX; j++)
-        {
-            index = (i + filterDimY - 1) * featMapImage->dimX +
-                    (j + filterDimX - 1);
-            (*conv)[i * diffX + j] = fconv[2 * index];
-        }
-    }
-    free(imagesMult);
-    free(imagesMultRes);
-    free(fconv);
-    return LATENT_SVM_OK;
-}
-
-/*
-// Computation objective function D according the original paper
-//
-// API
-// int filterDispositionLevel(const CvLSVMFilterObject *Fi, const featurePyramid *H,
-                              int level, float **scoreFi,
-                              int **pointsX, int **pointsY);
-// INPUT
-// Fi                - filter object (weights and coefficients of penalty
-                       function that are used in this routine)
-// H                 - feature pyramid
-// level             - level number
-// OUTPUT
-// scoreFi           - values of distance transform on the level at all positions
-// (pointsX, pointsY)- positions that correspond to the maximum value
-                       of distance transform at all grid nodes
-// RESULT
-// Error status
-*/
-int filterDispositionLevel(const CvLSVMFilterObject *Fi, const CvLSVMFeatureMap *pyramid,
-                           float **scoreFi,
-                           int **pointsX, int **pointsY)
-{
-    int n1, m1, n2, m2, /*p,*/ size, diff1, diff2;
-    float *f;
-    int i1, j1;
-    int res;
-
-    n1 = pyramid->sizeY;
-    m1 = pyramid->sizeX;
-    n2 = Fi->sizeY;
-    m2 = Fi->sizeX;
-    //p = pyramid->numFeatures;
-    (*scoreFi) = NULL;
-    (*pointsX) = NULL;
-    (*pointsY) = NULL;
-
-    // Processing the situation when part filter goes
-    // beyond the boundaries of the block set
-    if (n1 < n2 || m1 < m2)
-    {
-        return FILTER_OUT_OF_BOUNDARIES;
-    } /* if (n1 < n2 || m1 < m2) */
-
-    // Computation number of positions for the filter
-    diff1 = n1 - n2 + 1;
-    diff2 = m1 - m2 + 1;
-    size = diff1 * diff2;
-
-    // Allocation memory for additional array (must be free in this function)
-    f = (float *)malloc(sizeof(float) * size);
-    // Allocation memory for arrays for saving decisions
-    (*scoreFi) = (float *)malloc(sizeof(float) * size);
-    (*pointsX) = (int *)malloc(sizeof(int) * size);
-    (*pointsY) = (int *)malloc(sizeof(int) * size);
-
-    // Consruction values of the array f
-    // (a dot product vectors of feature map and weights of the filter)
-    res = convolution(Fi, pyramid, f);
-    if (res != LATENT_SVM_OK)
-    {
-        free(f);
-        free(*scoreFi);
-        free(*pointsX);
-        free(*pointsY);
-        return res;
-    }
-
-    // TODO: necessary to change
-    for (i1 = 0; i1 < diff1; i1++)
-    {
-         for (j1 = 0; j1 < diff2; j1++)
-         {
-             f[i1 * diff2 + j1] *= (-1);
-         }
-    }
-
-    // Decision of the general distance transform task
-    DistanceTransformTwoDimensionalProblem(f, diff1, diff2, Fi->fineFunction,
-                                          (*scoreFi), (*pointsX), (*pointsY));
-
-    // Release allocated memory
-    free(f);
-    return LATENT_SVM_OK;
-}
-
-/*
-// Computation objective function D according the original paper using FFT
-//
-// API
-// int filterDispositionLevelFFT(const CvLSVMFilterObject *Fi, const fftImage *featMapImage,
-                                 float **scoreFi,
-                                 int **pointsX, int **pointsY);
-// INPUT
-// Fi                - filter object (weights and coefficients of penalty
-                       function that are used in this routine)
-// featMapImage      - FFT image of feature map
-// OUTPUT
-// scoreFi           - values of distance transform on the level at all positions
-// (pointsX, pointsY)- positions that correspond to the maximum value
-                       of distance transform at all grid nodes
-// RESULT
-// Error status
-*/
-int filterDispositionLevelFFT(const CvLSVMFilterObject *Fi, const CvLSVMFftImage *featMapImage,
-                              float **scoreFi,
-                              int **pointsX, int **pointsY)
-{
-    int n1, m1, n2, m2, /*p,*/ size, diff1, diff2;
-    float *f;
-    int i1, j1;
-    int res;
-    CvLSVMFftImage *filterImage;
-
-    n1 = featMapImage->dimY;
-    m1 = featMapImage->dimX;
-    n2 = Fi->sizeY;
-    m2 = Fi->sizeX;
-    //p = featMapImage->numFeatures;
-    (*scoreFi) = NULL;
-    (*pointsX) = NULL;
-    (*pointsY) = NULL;
-
-    // Processing the situation when part filter goes
-    // beyond the boundaries of the block set
-    if (n1 < n2 || m1 < m2)
-    {
-        return FILTER_OUT_OF_BOUNDARIES;
-    } /* if (n1 < n2 || m1 < m2) */
-
-    // Computation number of positions for the filter
-    diff1 = n1 - n2 + 1;
-    diff2 = m1 - m2 + 1;
-    size = diff1 * diff2;
-
-    // Allocation memory for arrays for saving decisions
-    (*scoreFi) = (float *)malloc(sizeof(float) * size);
-    (*pointsX) = (int *)malloc(sizeof(int) * size);
-    (*pointsY) = (int *)malloc(sizeof(int) * size);
-
-    // create filter image
-    getFFTImageFilterObject(Fi, featMapImage->dimX, featMapImage->dimY, &filterImage);
-
-    // Consruction values of the array f
-    // (a dot product vectors of feature map and weights of the filter)
-    res = convFFTConv2d(featMapImage, filterImage, Fi->sizeX, Fi->sizeY, &f);
-    if (res != LATENT_SVM_OK)
-    {
-        free(f);
-        free(*scoreFi);
-        free(*pointsX);
-        free(*pointsY);
-        return res;
-    }
-
-    // TODO: necessary to change
-    for (i1 = 0; i1 < diff1; i1++)
-    {
-         for (j1 = 0; j1 < diff2; j1++)
-         {
-             f[i1 * diff2 + j1] *= (-1);
-         }
-    }
-
-    // Decision of the general distance transform task
-    DistanceTransformTwoDimensionalProblem(f, diff1, diff2, Fi->fineFunction,
-                                          (*scoreFi), (*pointsX), (*pointsY));
-
-    // Release allocated memory
-    free(f);
-    freeFFTImage(&filterImage);
-    return LATENT_SVM_OK;
-}
-
-/*
-// Computation border size for feature map
-//
-// API
-// int computeBorderSize(int maxXBorder, int maxYBorder, int *bx, int *by);
-// INPUT
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// OUTPUT
-// bx                - border size (X-direction)
-// by                - border size (Y-direction)
-// RESULT
-// Error status
-*/
-int computeBorderSize(int maxXBorder, int maxYBorder, int *bx, int *by)
-{
-    *bx = (int)ceilf(((float) maxXBorder) / 2.0f + 1.0f);
-    *by = (int)ceilf(((float) maxYBorder) / 2.0f + 1.0f);
-    return LATENT_SVM_OK;
-}
-
-/*
-// Addition nullable border to the feature map
-//
-// API
-// int addNullableBorder(featureMap *map, int bx, int by);
-// INPUT
-// map               - feature map
-// bx                - border size (X-direction)
-// by                - border size (Y-direction)
-// OUTPUT
-// RESULT
-// Error status
-*/
-int addNullableBorder(CvLSVMFeatureMap *map, int bx, int by)
-{
-    int sizeX, sizeY, i, j, k;
-    float *new_map;
-    sizeX = map->sizeX + 2 * bx;
-    sizeY = map->sizeY + 2 * by;
-    // fix for Windows Phone 8 ARM compiler
-    size_t size = sizeof(float) * sizeX * sizeY * map->numFeatures;
-    new_map = (float *)malloc(size);
-    for (i = 0; i < sizeX * sizeY * map->numFeatures; i++)
-    {
-        new_map[i] = 0.0;
-    }
-    for (i = by; i < map->sizeY + by; i++)
-    {
-        for (j = bx; j < map->sizeX + bx; j++)
-        {
-            for (k = 0; k < map->numFeatures; k++)
-            {
-                new_map[(i * sizeX + j) * map->numFeatures + k] =
-                    map->map[((i - by) * map->sizeX + j - bx) * map->numFeatures + k];
-            }
-        }
-    }
-    map->sizeX = sizeX;
-    map->sizeY = sizeY;
-    free(map->map);
-    map->map = new_map;
-    return LATENT_SVM_OK;
-}
-
-static CvLSVMFeatureMap* featureMapBorderPartFilter(CvLSVMFeatureMap *map,
-                                       int maxXBorder, int maxYBorder)
-{
-    int bx, by;
-    int sizeX, sizeY, i, j, k;
-    CvLSVMFeatureMap *new_map;
-
-    computeBorderSize(maxXBorder, maxYBorder, &bx, &by);
-    sizeX = map->sizeX + 2 * bx;
-    sizeY = map->sizeY + 2 * by;
-    allocFeatureMapObject(&new_map, sizeX, sizeY, map->numFeatures);
-    for (i = 0; i < sizeX * sizeY * map->numFeatures; i++)
-    {
-        new_map->map[i] = 0.0f;
-    }
-    for (i = by; i < map->sizeY + by; i++)
-    {
-        for (j = bx; j < map->sizeX + bx; j++)
-        {
-            for (k = 0; k < map->numFeatures; k++)
-            {
-                new_map->map[(i * sizeX + j) * map->numFeatures + k] =
-                    map->map[((i - by) * map->sizeX + j - bx) * map->numFeatures + k];
-            }
-        }
-    }
-    return new_map;
-}
-
-/*
-// Computation the maximum of the score function at the level
-//
-// API
-// int maxFunctionalScoreFixedLevel(const CvLSVMFilterObject **all_F, int n,
-                                    const featurePyramid *H,
-                                    int level, float b,
-                                    int maxXBorder, int maxYBorder,
-                                    float *score, CvPoint **points, int *kPoints,
-                                    CvPoint ***partsDisplacement);
-// INPUT
-// all_F             - the set of filters (the first element is root filter,
-                       the other - part filters)
-// n                 - the number of part filters
-// H                 - feature pyramid
-// level             - feature pyramid level for computation maximum score
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// OUTPUT
-// score             - the maximum of the score function at the level
-// points            - the set of root filter positions (in the block space)
-// levels            - the set of levels
-// kPoints           - number of root filter positions
-// partsDisplacement - displacement of part filters (in the block space)
-// RESULT
-// Error status
-*/
-int maxFunctionalScoreFixedLevel(const CvLSVMFilterObject **all_F, int n,
-                                 const CvLSVMFeaturePyramid *H,
-                                 int level, float b,
-                                 int maxXBorder, int maxYBorder,
-                                 float *score, CvPoint **points,
-                                 int *kPoints, CvPoint ***partsDisplacement)
-{
-    int i, j, k, dimX, dimY, nF0, mF0/*, p*/;
-    int diff1, diff2, index, last, partsLevel;
-    CvLSVMFilterDisposition **disposition;
-    float *f;
-    float *scores;
-    float sumScorePartDisposition, maxScore;
-    int res;
-    CvLSVMFeatureMap *map;
-#ifdef FFT_CONV
-    CvLSVMFftImage *rootFilterImage, *mapImage;
-#else
-#endif
-
-    /*
-    // DEBUG variables
-    FILE *file;
-    char *tmp;
-    char buf[40] = "..\\Data\\score\\score", buf1[10] = ".csv";
-    tmp = (char *)malloc(sizeof(char) * 80);
-    itoa(level, tmp, 10);
-    strcat(tmp, buf1);
-    //*/
-
-    // Feature map matrix dimension on the level
-    dimX = H->pyramid[level]->sizeX;
-    dimY = H->pyramid[level]->sizeY;
-
-    // Number of features
-    //p = H->pyramid[level]->numFeatures;
-
-    // Getting dimension of root filter
-    nF0 = all_F[0]->sizeY;
-    mF0 = all_F[0]->sizeX;
-    // Processing the situation when root filter goes
-    // beyond the boundaries of the block set
-    if (nF0 > dimY || mF0 > dimX)
-    {
-        return LATENT_SVM_FAILED_SUPERPOSITION;
-    }
-
-    diff1 = dimY - nF0 + 1;
-    diff2 = dimX - mF0 + 1;
-
-    // Allocation memory for saving values of function D
-    // on the level for each part filter
-    disposition = (CvLSVMFilterDisposition **)malloc(sizeof(CvLSVMFilterDisposition *) * n);
-    for (i = 0; i < n; i++)
-    {
-        disposition[i] = (CvLSVMFilterDisposition *)malloc(sizeof(CvLSVMFilterDisposition));
-    }
-
-    // Allocation memory for values of score function for each block on the level
-    scores = (float *)malloc(sizeof(float) * (diff1 * diff2));
-
-    // A dot product vectors of feature map and weights of root filter
-#ifdef FFT_CONV
-    getFFTImageFeatureMap(H->pyramid[level], &mapImage);
-    getFFTImageFilterObject(all_F[0], H->pyramid[level]->sizeX, H->pyramid[level]->sizeY, &rootFilterImage);
-    res = convFFTConv2d(mapImage, rootFilterImage, all_F[0]->sizeX, all_F[0]->sizeY, &f);
-    freeFFTImage(&mapImage);
-    freeFFTImage(&rootFilterImage);
-#else
-    // Allocation memory for saving a dot product vectors of feature map and
-    // weights of root filter
-    f = (float *)malloc(sizeof(float) * (diff1 * diff2));
-    // A dot product vectors of feature map and weights of root filter
-    res = convolution(all_F[0], H->pyramid[level], f);
-#endif
-    if (res != LATENT_SVM_OK)
-    {
-        free(f);
-        free(scores);
-        for (i = 0; i < n; i++)
-        {
-            free(disposition[i]);
-        }
-        free(disposition);
-        return res;
-    }
-
-    // Computation values of function D for each part filter
-    // on the level (level - LAMBDA)
-    partsLevel = level - LAMBDA;
-    // For feature map at the level 'partsLevel' add nullable border
-    map = featureMapBorderPartFilter(H->pyramid[partsLevel],
-                                     maxXBorder, maxYBorder);
-
-    // Computation the maximum of score function
-    sumScorePartDisposition = 0.0;
-#ifdef FFT_CONV
-    getFFTImageFeatureMap(map, &mapImage);
-    for (k = 1; k <= n; k++)
-    {
-        filterDispositionLevelFFT(all_F[k], mapImage,
-                               &(disposition[k - 1]->score),
-                               &(disposition[k - 1]->x),
-                               &(disposition[k - 1]->y));
-    }
-    freeFFTImage(&mapImage);
-#else
-    for (k = 1; k <= n; k++)
-    {
-        filterDispositionLevel(all_F[k], map,
-                               &(disposition[k - 1]->score),
-                               &(disposition[k - 1]->x),
-                               &(disposition[k - 1]->y));
-    }
-#endif
-    scores[0] = f[0] - sumScorePartDisposition + b;
-    maxScore = scores[0];
-    (*kPoints) = 0;
-    for (i = 0; i < diff1; i++)
-    {
-        for (j = 0; j < diff2; j++)
-        {
-            sumScorePartDisposition = 0.0;
-            for (k = 1; k <= n; k++)
-            {
-                // This condition takes on a value true
-                // when filter goes beyond the boundaries of block set
-                if ((2 * i + all_F[k]->V.y <
-                            map->sizeY - all_F[k]->sizeY + 1) &&
-                    (2 * j + all_F[k]->V.x <
-                            map->sizeX - all_F[k]->sizeX + 1))
-                {
-                    index = (2 * i + all_F[k]->V.y) *
-                                (map->sizeX - all_F[k]->sizeX + 1) +
-                            (2 * j + all_F[k]->V.x);
-                    sumScorePartDisposition += disposition[k - 1]->score[index];
-                }
-            }
-            scores[i * diff2 + j] = f[i * diff2 + j] - sumScorePartDisposition + b;
-            if (maxScore < scores[i * diff2 + j])
-            {
-                maxScore = scores[i * diff2 + j];
-                (*kPoints) = 1;
-            }
-            else if ((scores[i * diff2 + j] - maxScore) *
-                     (scores[i * diff2 + j] - maxScore) <= EPS)
-            {
-                (*kPoints)++;
-            } /* if (maxScore < scores[i * diff2 + j]) */
-        }
-    }
-
-    // Allocation memory for saving positions of root filter and part filters
-    (*points) = (CvPoint *)malloc(sizeof(CvPoint) * (*kPoints));
-    (*partsDisplacement) = (CvPoint **)malloc(sizeof(CvPoint *) * (*kPoints));
-    for (i = 0; i < (*kPoints); i++)
-    {
-        (*partsDisplacement)[i] = (CvPoint *)malloc(sizeof(CvPoint) * n);
-    }
-
-    /*// DEBUG
-    strcat(buf, tmp);
-    file = fopen(buf, "w+");
-    //*/
-    // Construction of the set of positions for root filter
-    // that correspond the maximum of score function on the level
-    (*score) = maxScore;
-    last = 0;
-    for (i = 0; i < diff1; i++)
-    {
-        for (j = 0; j < diff2; j++)
-        {
-            if ((scores[i * diff2 + j] - maxScore) *
-                (scores[i * diff2 + j] - maxScore) <= EPS)
-            {
-                (*points)[last].y = i;
-                (*points)[last].x = j;
-                for (k = 1; k <= n; k++)
-                {
-                    if ((2 * i + all_F[k]->V.y <
-                            map->sizeY - all_F[k]->sizeY + 1) &&
-                        (2 * j + all_F[k]->V.x <
-                            map->sizeX - all_F[k]->sizeX + 1))
-                    {
-                        index = (2 * i + all_F[k]->V.y) *
-                                   (map->sizeX - all_F[k]->sizeX + 1) +
-                                (2 * j + all_F[k]->V.x);
-                        (*partsDisplacement)[last][k - 1].x =
-                                              disposition[k - 1]->x[index];
-                        (*partsDisplacement)[last][k - 1].y =
-                                              disposition[k - 1]->y[index];
-                    }
-                }
-                last++;
-            } /* if ((scores[i * diff2 + j] - maxScore) *
-                     (scores[i * diff2 + j] - maxScore) <= EPS) */
-            //fprintf(file, "%lf;", scores[i * diff2 + j]);
-        }
-        //fprintf(file, "\n");
-    }
-    //fclose(file);
-    //free(tmp);
-
-    // Release allocated memory
-    for (i = 0; i < n ; i++)
-    {
-        free(disposition[i]->score);
-        free(disposition[i]->x);
-        free(disposition[i]->y);
-        free(disposition[i]);
-    }
-    free(disposition);
-    free(f);
-    free(scores);
-    freeFeatureMapObject(&map);
-    return LATENT_SVM_OK;
-}
-
-/*
-// Computation score function at the level that exceed threshold
-//
-// API
-// int thresholdFunctionalScoreFixedLevel(const CvLSVMFilterObject **all_F, int n,
-                                          const featurePyramid *H,
-                                          int level, float b,
-                                          int maxXBorder, int maxYBorder,
-                                          float scoreThreshold,
-                                          float **score, CvPoint **points, int *kPoints,
-                                          CvPoint ***partsDisplacement);
-// INPUT
-// all_F             - the set of filters (the first element is root filter,
-                       the other - part filters)
-// n                 - the number of part filters
-// H                 - feature pyramid
-// level             - feature pyramid level for computation maximum score
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// scoreThreshold    - score threshold
-// OUTPUT
-// score             - score function at the level that exceed threshold
-// points            - the set of root filter positions (in the block space)
-// levels            - the set of levels
-// kPoints           - number of root filter positions
-// partsDisplacement - displacement of part filters (in the block space)
-// RESULT
-// Error status
-*/
-int thresholdFunctionalScoreFixedLevel(const CvLSVMFilterObject **all_F, int n,
-                                       const CvLSVMFeaturePyramid *H,
-                                       int level, float b,
-                                       int maxXBorder, int maxYBorder,
-                                       float scoreThreshold,
-                                       float **score, CvPoint **points, int *kPoints,
-                                       CvPoint ***partsDisplacement)
-{
-    int i, j, k, dimX, dimY, nF0, mF0/*, p*/;
-    int diff1, diff2, index, last, partsLevel;
-    CvLSVMFilterDisposition **disposition;
-    float *f;
-    float *scores;
-    float sumScorePartDisposition;
-    int res;
-    CvLSVMFeatureMap *map;
-#ifdef FFT_CONV
-    CvLSVMFftImage *rootFilterImage, *mapImage;
-#else
-#endif
-    /*
-    // DEBUG variables
-    FILE *file;
-    char *tmp;
-    char buf[40] = "..\\Data\\score\\score", buf1[10] = ".csv";
-    tmp = (char *)malloc(sizeof(char) * 80);
-    itoa(level, tmp, 10);
-    strcat(tmp, buf1);
-    //*/
-
-    // Feature map matrix dimension on the level
-    dimX = H->pyramid[level]->sizeX;
-    dimY = H->pyramid[level]->sizeY;
-
-    // Number of features
-    //p = H->pyramid[level]->numFeatures;
-
-    // Getting dimension of root filter
-    nF0 = all_F[0]->sizeY;
-    mF0 = all_F[0]->sizeX;
-    // Processing the situation when root filter goes
-    // beyond the boundaries of the block set
-    if (nF0 > dimY || mF0 > dimX)
-    {
-        return LATENT_SVM_FAILED_SUPERPOSITION;
-    }
-
-    diff1 = dimY - nF0 + 1;
-    diff2 = dimX - mF0 + 1;
-
-    // Allocation memory for saving values of function D
-    // on the level for each part filter
-    disposition = (CvLSVMFilterDisposition **)malloc(sizeof(CvLSVMFilterDisposition *) * n);
-    for (i = 0; i < n; i++)
-    {
-        disposition[i] = (CvLSVMFilterDisposition *)malloc(sizeof(CvLSVMFilterDisposition));
-    }
-
-    // Allocation memory for values of score function for each block on the level
-    scores = (float *)malloc(sizeof(float) * (diff1 * diff2));
-    // A dot product vectors of feature map and weights of root filter
-#ifdef FFT_CONV
-    getFFTImageFeatureMap(H->pyramid[level], &mapImage);
-    getFFTImageFilterObject(all_F[0], H->pyramid[level]->sizeX, H->pyramid[level]->sizeY, &rootFilterImage);
-    res = convFFTConv2d(mapImage, rootFilterImage, all_F[0]->sizeX, all_F[0]->sizeY, &f);
-    freeFFTImage(&mapImage);
-    freeFFTImage(&rootFilterImage);
-#else
-    // Allocation memory for saving a dot product vectors of feature map and
-    // weights of root filter
-    f = (float *)malloc(sizeof(float) * (diff1 * diff2));
-    res = convolution(all_F[0], H->pyramid[level], f);
-#endif
-    if (res != LATENT_SVM_OK)
-    {
-        free(f);
-        free(scores);
-        for (i = 0; i < n; i++)
-        {
-            free(disposition[i]);
-        }
-        free(disposition);
-        return res;
-    }
-
-    // Computation values of function D for each part filter
-    // on the level (level - LAMBDA)
-    partsLevel = level - LAMBDA;
-    // For feature map at the level 'partsLevel' add nullable border
-    map = featureMapBorderPartFilter(H->pyramid[partsLevel],
-                                     maxXBorder, maxYBorder);
-
-    // Computation the maximum of score function
-    sumScorePartDisposition = 0.0;
-#ifdef FFT_CONV
-    getFFTImageFeatureMap(map, &mapImage);
-    for (k = 1; k <= n; k++)
-    {
-        filterDispositionLevelFFT(all_F[k], mapImage,
-                               &(disposition[k - 1]->score),
-                               &(disposition[k - 1]->x),
-                               &(disposition[k - 1]->y));
-    }
-    freeFFTImage(&mapImage);
-#else
-    for (k = 1; k <= n; k++)
-    {
-        filterDispositionLevel(all_F[k], map,
-                               &(disposition[k - 1]->score),
-                               &(disposition[k - 1]->x),
-                               &(disposition[k - 1]->y));
-    }
-#endif
-    (*kPoints) = 0;
-    for (i = 0; i < diff1; i++)
-    {
-        for (j = 0; j < diff2; j++)
-        {
-            sumScorePartDisposition = 0.0;
-            for (k = 1; k <= n; k++)
-            {
-                // This condition takes on a value true
-                // when filter goes beyond the boundaries of block set
-                if ((2 * i + all_F[k]->V.y <
-                            map->sizeY - all_F[k]->sizeY + 1) &&
-                    (2 * j + all_F[k]->V.x <
-                            map->sizeX - all_F[k]->sizeX + 1))
-                {
-                    index = (2 * i + all_F[k]->V.y) *
-                                (map->sizeX - all_F[k]->sizeX + 1) +
-                            (2 * j + all_F[k]->V.x);
-                    sumScorePartDisposition += disposition[k - 1]->score[index];
-                }
-            }
-            scores[i * diff2 + j] = f[i * diff2 + j] - sumScorePartDisposition + b;
-            if (scores[i * diff2 + j] > scoreThreshold)
-            {
-                (*kPoints)++;
-            }
-        }
-    }
-
-    // Allocation memory for saving positions of root filter and part filters
-    (*points) = (CvPoint *)malloc(sizeof(CvPoint) * (*kPoints));
-    (*partsDisplacement) = (CvPoint **)malloc(sizeof(CvPoint *) * (*kPoints));
-    for (i = 0; i < (*kPoints); i++)
-    {
-        (*partsDisplacement)[i] = (CvPoint *)malloc(sizeof(CvPoint) * n);
-    }
-
-    /*// DEBUG
-    strcat(buf, tmp);
-    file = fopen(buf, "w+");
-    //*/
-    // Construction of the set of positions for root filter
-    // that correspond score function on the level that exceed threshold
-    (*score) = (float *)malloc(sizeof(float) * (*kPoints));
-    last = 0;
-    for (i = 0; i < diff1; i++)
-    {
-        for (j = 0; j < diff2; j++)
-        {
-            if (scores[i * diff2 + j] > scoreThreshold)
-            {
-                (*score)[last] = scores[i * diff2 + j];
-                (*points)[last].y = i;
-                (*points)[last].x = j;
-                for (k = 1; k <= n; k++)
-                {
-                    if ((2 * i + all_F[k]->V.y <
-                            map->sizeY - all_F[k]->sizeY + 1) &&
-                        (2 * j + all_F[k]->V.x <
-                            map->sizeX - all_F[k]->sizeX + 1))
-                    {
-                        index = (2 * i + all_F[k]->V.y) *
-                                   (map->sizeX - all_F[k]->sizeX + 1) +
-                                (2 * j + all_F[k]->V.x);
-                        (*partsDisplacement)[last][k - 1].x =
-                                              disposition[k - 1]->x[index];
-                        (*partsDisplacement)[last][k - 1].y =
-                                              disposition[k - 1]->y[index];
-                    }
-                }
-                last++;
-            }
-            //fprintf(file, "%lf;", scores[i * diff2 + j]);
-        }
-        //fprintf(file, "\n");
-    }
-    //fclose(file);
-    //free(tmp);
-
-    // Release allocated memory
-    for (i = 0; i < n ; i++)
-    {
-        free(disposition[i]->score);
-        free(disposition[i]->x);
-        free(disposition[i]->y);
-        free(disposition[i]);
-    }
-    free(disposition);
-    free(f);
-    free(scores);
-    freeFeatureMapObject(&map);
-    return LATENT_SVM_OK;
-}
-
-/*
-// Computation the maximum of the score function
-//
-// API
-// int maxFunctionalScore(const CvLSVMFilterObject **all_F, int n,
-                          const featurePyramid *H, float b,
-                          int maxXBorder, int maxYBorder,
-                          float *score,
-                          CvPoint **points, int **levels, int *kPoints,
-                          CvPoint ***partsDisplacement);
-// INPUT
-// all_F             - the set of filters (the first element is root filter,
-                       the other - part filters)
-// n                 - the number of part filters
-// H                 - feature pyramid
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// OUTPUT
-// score             - the maximum of the score function
-// points            - the set of root filter positions (in the block space)
-// levels            - the set of levels
-// kPoints           - number of root filter positions
-// partsDisplacement - displacement of part filters (in the block space)
-// RESULT
-// Error status
-*/
-int maxFunctionalScore(const CvLSVMFilterObject **all_F, int n,
-                       const CvLSVMFeaturePyramid *H, float b,
-                       int maxXBorder, int maxYBorder,
-                       float *score,
-                       CvPoint **points, int **levels, int *kPoints,
-                       CvPoint ***partsDisplacement)
-{
-    int l, i, j, k, s, f, level, numLevels;
-    float *tmpScore;
-    CvPoint ***tmpPoints;
-    CvPoint ****tmpPartsDisplacement;
-    int *tmpKPoints;
-    float maxScore;
-    int res;
-
-    /* DEBUG
-    FILE *file;
-    //*/
-
-    // Computation the number of levels for seaching object,
-    // first lambda-levels are used for computation values
-    // of score function for each position of root filter
-    numLevels = H->numLevels - LAMBDA;
-
-    // Allocation memory for maximum value of score function for each level
-    tmpScore = (float *)malloc(sizeof(float) * numLevels);
-    // Allocation memory for the set of points that corresponds
-    // to the maximum of score function
-    tmpPoints = (CvPoint ***)malloc(sizeof(CvPoint **) * numLevels);
-    for (i = 0; i < numLevels; i++)
-    {
-        tmpPoints[i] = (CvPoint **)malloc(sizeof(CvPoint *));
-    }
-    // Allocation memory for memory for saving parts displacement on each level
-    tmpPartsDisplacement = (CvPoint ****)malloc(sizeof(CvPoint ***) * numLevels);
-    for (i = 0; i < numLevels; i++)
-    {
-        tmpPartsDisplacement[i] = (CvPoint ***)malloc(sizeof(CvPoint **));
-    }
-    // Number of points that corresponds to the maximum
-    // of score function on each level
-    tmpKPoints = (int *)malloc(sizeof(int) * numLevels);
-    for (i = 0; i < numLevels; i++)
-    {
-        tmpKPoints[i] = 0;
-    }
-
-    // Set current value of the maximum of score function
-    res = maxFunctionalScoreFixedLevel(all_F, n, H, LAMBDA, b,
-            maxXBorder, maxYBorder,
-            &(tmpScore[0]),
-            tmpPoints[0],
-            &(tmpKPoints[0]),
-            tmpPartsDisplacement[0]);
-    maxScore = tmpScore[0];
-    (*kPoints) = tmpKPoints[0];
-
-    // Computation maxima of score function on each level
-    // and getting the maximum on all levels
-    /* DEBUG: maxScore
-    file = fopen("maxScore.csv", "w+");
-    fprintf(file, "%i;%lf;\n", H->lambda, tmpScore[0]);
-    //*/
-    for (l = LAMBDA + 1; l < H->numLevels; l++)
-    {
-        k = l - LAMBDA;
-        res = maxFunctionalScoreFixedLevel(all_F, n, H, l, b,
-                                           maxXBorder, maxYBorder,
-                                           &(tmpScore[k]),
-                                           tmpPoints[k],
-                                           &(tmpKPoints[k]),
-                                           tmpPartsDisplacement[k]);
-        //fprintf(file, "%i;%lf;\n", l, tmpScore[k]);
-        if (res != LATENT_SVM_OK)
-        {
-            continue;
-        }
-        if (maxScore < tmpScore[k])
-        {
-            maxScore = tmpScore[k];
-            (*kPoints) = tmpKPoints[k];
-        }
-        else if ((maxScore - tmpScore[k]) * (maxScore - tmpScore[k]) <= EPS)
-        {
-            (*kPoints) += tmpKPoints[k];
-        } /* if (maxScore < tmpScore[k]) else if (...)*/
-    }
-    //fclose(file);
-
-    // Allocation memory for levels
-    (*levels) = (int *)malloc(sizeof(int) * (*kPoints));
-    // Allocation memory for the set of points
-    (*points) = (CvPoint *)malloc(sizeof(CvPoint) * (*kPoints));
-    // Allocation memory for parts displacement
-    (*partsDisplacement) = (CvPoint **)malloc(sizeof(CvPoint *) * (*kPoints));
-
-    // Filling the set of points, levels and parts displacement
-    s = 0;
-    f = 0;
-    for (i = 0; i < numLevels; i++)
-    {
-        if ((tmpScore[i] - maxScore) * (tmpScore[i] - maxScore) <= EPS)
-        {
-            // Computation the number of level
-            level = i + LAMBDA;
-
-            // Addition a set of points
-            f += tmpKPoints[i];
-            for (j = s; j < f; j++)
-            {
-                (*levels)[j] = level;
-                (*points)[j] = (*tmpPoints[i])[j - s];
-                (*partsDisplacement)[j] = (*(tmpPartsDisplacement[i]))[j - s];
-            }
-            s = f;
-        } /* if ((tmpScore[i] - maxScore) * (tmpScore[i] - maxScore) <= EPS) */
-    }
-    (*score) = maxScore;
-
-    // Release allocated memory
-    for (i = 0; i < numLevels; i++)
-    {
-        free(tmpPoints[i]);
-        free(tmpPartsDisplacement[i]);
-    }
-    free(tmpPoints);
-    free(tmpPartsDisplacement);
-    free(tmpScore);
-    free(tmpKPoints);
-
-    return LATENT_SVM_OK;
-}
-
-/*
-// Computation score function that exceed threshold
-//
-// API
-// int thresholdFunctionalScore(const CvLSVMFilterObject **all_F, int n,
-                                const featurePyramid *H,
-                                float b,
-                                int maxXBorder, int maxYBorder,
-                                float scoreThreshold,
-                                float **score,
-                                CvPoint **points, int **levels, int *kPoints,
-                                CvPoint ***partsDisplacement);
-// INPUT
-// all_F             - the set of filters (the first element is root filter,
-                       the other - part filters)
-// n                 - the number of part filters
-// H                 - feature pyramid
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// scoreThreshold    - score threshold
-// OUTPUT
-// score             - score function values that exceed threshold
-// points            - the set of root filter positions (in the block space)
-// levels            - the set of levels
-// kPoints           - number of root filter positions
-// partsDisplacement - displacement of part filters (in the block space)
-// RESULT
-// Error status
-*/
-int thresholdFunctionalScore(const CvLSVMFilterObject **all_F, int n,
-                             const CvLSVMFeaturePyramid *H,
-                             float b,
-                             int maxXBorder, int maxYBorder,
-                             float scoreThreshold,
-                             float **score,
-                             CvPoint **points, int **levels, int *kPoints,
-                             CvPoint ***partsDisplacement)
-{
-    int l, i, j, k, s, f, level, numLevels;
-    float **tmpScore;
-    CvPoint ***tmpPoints;
-    CvPoint ****tmpPartsDisplacement;
-    int *tmpKPoints;
-    int res;
-
-    /* DEBUG
-    FILE *file;
-    //*/
-
-    // Computation the number of levels for seaching object,
-    // first lambda-levels are used for computation values
-    // of score function for each position of root filter
-    numLevels = H->numLevels - LAMBDA;
-
-    // Allocation memory for values of score function for each level
-    // that exceed threshold
-    tmpScore = (float **)malloc(sizeof(float*) * numLevels);
-    // Allocation memory for the set of points that corresponds
-    // to the maximum of score function
-    tmpPoints = (CvPoint ***)malloc(sizeof(CvPoint **) * numLevels);
-    for (i = 0; i < numLevels; i++)
-    {
-        tmpPoints[i] = (CvPoint **)malloc(sizeof(CvPoint *));
-    }
-    // Allocation memory for memory for saving parts displacement on each level
-    tmpPartsDisplacement = (CvPoint ****)malloc(sizeof(CvPoint ***) * numLevels);
-    for (i = 0; i < numLevels; i++)
-    {
-        tmpPartsDisplacement[i] = (CvPoint ***)malloc(sizeof(CvPoint **));
-    }
-    // Number of points that corresponds to the maximum
-    // of score function on each level
-    tmpKPoints = (int *)malloc(sizeof(int) * numLevels);
-    for (i = 0; i < numLevels; i++)
-    {
-        tmpKPoints[i] = 0;
-    }
-
-    // Computation maxima of score function on each level
-    // and getting the maximum on all levels
-    /* DEBUG: maxScore
-    file = fopen("maxScore.csv", "w+");
-    fprintf(file, "%i;%lf;\n", H->lambda, tmpScore[0]);
-    //*/
-    (*kPoints) = 0;
-    for (l = LAMBDA; l < H->numLevels; l++)
-    {
-        k = l - LAMBDA;
-        //printf("Score at the level %i\n", l);
-        res = thresholdFunctionalScoreFixedLevel(all_F, n, H, l, b,
-            maxXBorder, maxYBorder, scoreThreshold,
-            &(tmpScore[k]),
-            tmpPoints[k],
-            &(tmpKPoints[k]),
-            tmpPartsDisplacement[k]);
-        //fprintf(file, "%i;%lf;\n", l, tmpScore[k]);
-        if (res != LATENT_SVM_OK)
-        {
-            continue;
-        }
-        (*kPoints) += tmpKPoints[k];
-    }
-    //fclose(file);
-
-    // Allocation memory for levels
-    (*levels) = (int *)malloc(sizeof(int) * (*kPoints));
-    // Allocation memory for the set of points
-    (*points) = (CvPoint *)malloc(sizeof(CvPoint) * (*kPoints));
-    // Allocation memory for parts displacement
-    (*partsDisplacement) = (CvPoint **)malloc(sizeof(CvPoint *) * (*kPoints));
-    // Allocation memory for score function values
-    (*score) = (float *)malloc(sizeof(float) * (*kPoints));
-
-    // Filling the set of points, levels and parts displacement
-    s = 0;
-    f = 0;
-    for (i = 0; i < numLevels; i++)
-    {
-        // Computation the number of level
-        level = i + LAMBDA;
-
-        // Addition a set of points
-        f += tmpKPoints[i];
-        for (j = s; j < f; j++)
-        {
-            (*levels)[j] = level;
-            (*points)[j] = (*tmpPoints[i])[j - s];
-            (*score)[j] = tmpScore[i][j - s];
-            (*partsDisplacement)[j] = (*(tmpPartsDisplacement[i]))[j - s];
-        }
-        s = f;
-    }
-
-    // Release allocated memory
-    for (i = 0; i < numLevels; i++)
-    {
-        free(tmpPoints[i]);
-        free(tmpPartsDisplacement[i]);
-    }
-    free(tmpPoints);
-    free(tmpScore);
-    free(tmpKPoints);
-    free(tmpPartsDisplacement);
-
-    return LATENT_SVM_OK;
-}
-
-#ifdef HAVE_TBB
-/*
-// Creating schedule of pyramid levels processing
-//
-// API
-// int createSchedule(const featurePyramid *H, const filterObject **all_F,
-                      const int n, const int bx, const int by,
-                      const int threadsNum, int *kLevels,
-                      int **processingLevels)
-// INPUT
-// H                 - feature pyramid
-// all_F             - the set of filters (the first element is root filter,
-                       the other - part filters)
-// n                 - the number of part filters
-// bx                - size of nullable border (X direction)
-// by                - size of nullable border (Y direction)
-// threadsNum        - number of threads that will be created in TBB version
-// OUTPUT
-// kLevels           - array that contains number of levels processed
-                       by each thread
-// processingLevels  - array that contains lists of levels processed
-                       by each thread
-// RESULT
-// Error status
-*/
-static int createSchedule(const CvLSVMFeaturePyramid *H, const CvLSVMFilterObject **all_F,
-                   const int n, const int bx, const int by,
-                   const int threadsNum, int *kLevels, int **processingLevels)
-{
-    int rootFilterDim, sumPartFiltersDim, i, numLevels, dbx, dby;
-    int j, minValue, argMin, lambda, maxValue, k;
-    int *dotProd, *weights, *disp;
-    if (H == NULL || all_F == NULL)
-    {
-        return LATENT_SVM_TBB_SCHEDULE_CREATION_FAILED;
-    }
-    // Number of feature vectors in root filter
-    rootFilterDim = all_F[0]->sizeX * all_F[0]->sizeY;
-    // Number of feature vectors in all part filters
-    sumPartFiltersDim = 0;
-    for (i = 1; i <= n; i++)
-    {
-        sumPartFiltersDim += all_F[i]->sizeX * all_F[i]->sizeY;
-    }
-    // Number of levels which are used for computation of score function
-    numLevels = H->numLevels - LAMBDA;
-    // Allocation memory for saving number of dot products that will be
-    // computed for each level of feature pyramid
-    dotProd = (int *)malloc(sizeof(int) * numLevels);
-    // Size of nullable border that's used in computing convolution
-    // of feature map with part filter
-    dbx = 2 * bx;
-    dby = 2 * by;
-    lambda = LAMBDA;
-    for (i = 0; i < numLevels; i++)
-    {
-        dotProd[i] = H->pyramid[i + lambda]->sizeX *
-                     H->pyramid[i + lambda]->sizeY * rootFilterDim +
-                     (H->pyramid[i]->sizeX + dbx) *
-                     (H->pyramid[i]->sizeY + dby) * sumPartFiltersDim;
-    }
-    // Allocation memory for saving dot product number performed by each thread
-    weights = (int *)malloc(sizeof(int) * threadsNum);
-    // Allocation memory for saving dispertion
-    disp = (int *)malloc(sizeof(int) * threadsNum);
-    // At the first step we think of first threadsNum levels will be processed
-    // by different threads
-    for (i = 0; i < threadsNum; i++)
-    {
-        kLevels[i] = 1;
-        weights[i] = dotProd[i];
-        disp[i] = 0;
-    }
-    // Computation number of levels that will be processed by each thread
-    for (i = threadsNum; i < numLevels; i++)
-    {
-        // Search number of thread that will process level number i
-        for (j = 0; j < threadsNum; j++)
-        {
-            weights[j] += dotProd[i];
-            minValue = weights[0];
-            maxValue = weights[0];
-            for (k = 1; k < threadsNum; k++)
-            {
-                minValue = min(minValue, weights[k]);
-                maxValue = max(maxValue, weights[k]);
-            }
-            disp[j] = maxValue - minValue;
-            weights[j] -= dotProd[i];
-        }
-        minValue = disp[0];
-        argMin = 0;
-        for (j = 1; j < threadsNum; j++)
-        {
-            if (disp[j] < minValue)
-            {
-                minValue = disp[j];
-                argMin = j;
-            }
-        }
-        // Addition new level
-        kLevels[argMin]++;
-        weights[argMin] += dotProd[i];
-    }
-    for (i = 0; i < threadsNum; i++)
-    {
-        // Allocation memory for saving list of levels for each level
-        processingLevels[i] = (int *)malloc(sizeof(int) * kLevels[i]);
-        // At the first step we think of first threadsNum levels will be processed
-        // by different threads
-        processingLevels[i][0] = lambda + i;
-        kLevels[i] = 1;
-        weights[i] = dotProd[i];
-    }
-    // Creating list of levels
-    for (i = threadsNum; i < numLevels; i++)
-    {
-        for (j = 0; j < threadsNum; j++)
-        {
-            weights[j] += dotProd[i];
-            minValue = weights[0];
-            maxValue = weights[0];
-            for (k = 1; k < threadsNum; k++)
-            {
-                minValue = min(minValue, weights[k]);
-                maxValue = max(maxValue, weights[k]);
-            }
-            disp[j] = maxValue - minValue;
-            weights[j] -= dotProd[i];
-        }
-        minValue = disp[0];
-        argMin = 0;
-        for (j = 1; j < threadsNum; j++)
-        {
-            if (disp[j] < minValue)
-            {
-                minValue = disp[j];
-                argMin = j;
-            }
-        }
-        processingLevels[argMin][kLevels[argMin]] = lambda + i;
-        kLevels[argMin]++;
-        weights[argMin] += dotProd[i];
-    }
-    // Release allocated memory
-    free(weights);
-    free(dotProd);
-    free(disp);
-    return LATENT_SVM_OK;
-}
-
-/*
-// int tbbThresholdFunctionalScore(const CvLSVMFilterObject **all_F, int n,
-                                   const CvLSVMFeaturePyramid *H,
-                                   const float b,
-                                   const int maxXBorder, const int maxYBorder,
-                                   const float scoreThreshold,
-                                   const int threadsNum,
-                                   float **score,
-                                   CvPoint **points, int **levels, int *kPoints,
-                                   CvPoint ***partsDisplacement);
-// INPUT
-// all_F             - the set of filters (the first element is root filter,
-                       the other - part filters)
-// n                 - the number of part filters
-// H                 - feature pyramid
-// b                 - linear term of the score function
-// maxXBorder        - the largest root filter size (X-direction)
-// maxYBorder        - the largest root filter size (Y-direction)
-// scoreThreshold    - score threshold
-// threadsNum        - number of threads that will be created using TBB version
-// OUTPUT
-// score             - score function values that exceed threshold
-// points            - the set of root filter positions (in the block space)
-// levels            - the set of levels
-// kPoints           - number of root filter positions
-// partsDisplacement - displacement of part filters (in the block space)
-// RESULT
-// Error status
-*/
-int tbbThresholdFunctionalScore(const CvLSVMFilterObject **all_F, int n,
-                                const CvLSVMFeaturePyramid *H,
-                                const float b,
-                                const int maxXBorder, const int maxYBorder,
-                                const float scoreThreshold,
-                                const int threadsNum,
-                                float **score,
-                                CvPoint **points, int **levels, int *kPoints,
-                                CvPoint ***partsDisplacement)
-{
-    int i, j, s, f, level, numLevels;
-    float **tmpScore;
-    CvPoint ***tmpPoints;
-    CvPoint ****tmpPartsDisplacement;
-    int *tmpKPoints;
-    int res;
-
-    int *kLevels, **procLevels;
-    int bx, by;
-
-    // Computation the number of levels for seaching object,
-    // first lambda-levels are used for computation values
-    // of score function for each position of root filter
-    numLevels = H->numLevels - LAMBDA;
-    kLevels = (int *)malloc(sizeof(int) * threadsNum);
-    procLevels = (int **)malloc(sizeof(int*) * threadsNum);
-    computeBorderSize(maxXBorder, maxYBorder, &bx, &by);
-    res = createSchedule(H, all_F, n, bx, by, threadsNum, kLevels, procLevels);
-    if (res != LATENT_SVM_OK)
-    {
-        for (i = 0; i < threadsNum; i++)
-        {
-            if (procLevels[i] != NULL)
-            {
-                free(procLevels[i]);
-            }
-        }
-        free(procLevels);
-        free(kLevels);
-        return res;
-    }
-
-    // Allocation memory for values of score function for each level
-    // that exceed threshold
-    tmpScore = (float **)malloc(sizeof(float*) * numLevels);
-    // Allocation memory for the set of points that corresponds
-    // to the maximum of score function
-    tmpPoints = (CvPoint ***)malloc(sizeof(CvPoint **) * numLevels);
-    for (i = 0; i < numLevels; i++)
-    {
-        tmpPoints[i] = (CvPoint **)malloc(sizeof(CvPoint *));
-    }
-    // Allocation memory for memory for saving parts displacement on each level
-    tmpPartsDisplacement = (CvPoint ****)malloc(sizeof(CvPoint ***) * numLevels);
-    for (i = 0; i < numLevels; i++)
-    {
-        tmpPartsDisplacement[i] = (CvPoint ***)malloc(sizeof(CvPoint **));
-    }
-    // Number of points that corresponds to the maximum
-    // of score function on each level
-    tmpKPoints = (int *)malloc(sizeof(int) * numLevels);
-    for (i = 0; i < numLevels; i++)
-    {
-        tmpKPoints[i] = 0;
-    }
-
-    // Computation maxima of score function on each level
-    // and getting the maximum on all levels using TBB tasks
-    tbbTasksThresholdFunctionalScore(all_F, n, H, b, maxXBorder, maxYBorder,
-        scoreThreshold, kLevels, procLevels,
-        threadsNum, tmpScore, tmpPoints,
-        tmpKPoints, tmpPartsDisplacement);
-    (*kPoints) = 0;
-    for (i = 0; i < numLevels; i++)
-    {
-        (*kPoints) += tmpKPoints[i];
-    }
-
-    // Allocation memory for levels
-    (*levels) = (int *)malloc(sizeof(int) * (*kPoints));
-    // Allocation memory for the set of points
-    (*points) = (CvPoint *)malloc(sizeof(CvPoint) * (*kPoints));
-    // Allocation memory for parts displacement
-    (*partsDisplacement) = (CvPoint **)malloc(sizeof(CvPoint *) * (*kPoints));
-    // Allocation memory for score function values
-    (*score) = (float *)malloc(sizeof(float) * (*kPoints));
-
-    // Filling the set of points, levels and parts displacement
-    s = 0;
-    f = 0;
-    for (i = 0; i < numLevels; i++)
-    {
-        // Computation the number of level
-        level = i + LAMBDA;//H->lambda;
-
-        // Addition a set of points
-        f += tmpKPoints[i];
-        for (j = s; j < f; j++)
-        {
-            (*levels)[j] = level;
-            (*points)[j] = (*tmpPoints[i])[j - s];
-            (*score)[j] = tmpScore[i][j - s];
-            (*partsDisplacement)[j] = (*(tmpPartsDisplacement[i]))[j - s];
-        }
-        s = f;
-    }
-
-    // Release allocated memory
-    for (i = 0; i < numLevels; i++)
-    {
-        free(tmpPoints[i]);
-        free(tmpPartsDisplacement[i]);
-    }
-    for (i = 0; i < threadsNum; i++)
-    {
-        free(procLevels[i]);
-    }
-    free(procLevels);
-    free(kLevels);
-    free(tmpPoints);
-    free(tmpScore);
-    free(tmpKPoints);
-    free(tmpPartsDisplacement);
-
-    return LATENT_SVM_OK;
-}
-#endif
-
-static void sort(int n, const float* x, int* indices)
-{
-    int i, j;
-    for (i = 0; i < n; i++)
-        for (j = i + 1; j < n; j++)
-        {
-            if (x[indices[j]] > x[indices[i]])
-            {
-                //float x_tmp = x[i];
-                int index_tmp = indices[i];
-                //x[i] = x[j];
-                indices[i] = indices[j];
-                //x[j] = x_tmp;
-                indices[j] = index_tmp;
-            }
-        }
-}
-
-/*
-// Perform non-maximum suppression algorithm (described in original paper)
-// to remove "similar" bounding boxes
-//
-// API
-// int nonMaximumSuppression(int numBoxes, const CvPoint *points,
-                             const CvPoint *oppositePoints, const float *score,
-                             float overlapThreshold,
-                             int *numBoxesOut, CvPoint **pointsOut,
-                             CvPoint **oppositePointsOut, float **scoreOut);
-// INPUT
-// numBoxes          - number of bounding boxes
-// points            - array of left top corner coordinates
-// oppositePoints    - array of right bottom corner coordinates
-// score             - array of detection scores
-// overlapThreshold  - threshold: bounding box is removed if overlap part
-                       is greater than passed value
-// OUTPUT
-// numBoxesOut       - the number of bounding boxes algorithm returns
-// pointsOut         - array of left top corner coordinates
-// oppositePointsOut - array of right bottom corner coordinates
-// scoreOut          - array of detection scores
-// RESULT
-// Error status
-*/
-int nonMaximumSuppression(int numBoxes, const CvPoint *points,
-                          const CvPoint *oppositePoints, const float *score,
-                          float overlapThreshold,
-                          int *numBoxesOut, CvPoint **pointsOut,
-                          CvPoint **oppositePointsOut, float **scoreOut)
-{
-    int i, j, index;
-    float* box_area = (float*)malloc(numBoxes * sizeof(float));
-    int* indices = (int*)malloc(numBoxes * sizeof(int));
-    int* is_suppressed = (int*)malloc(numBoxes * sizeof(int));
-
-    for (i = 0; i < numBoxes; i++)
-    {
-        indices[i] = i;
-        is_suppressed[i] = 0;
-        box_area[i] = (float)( (oppositePoints[i].x - points[i].x + 1) *
-                                (oppositePoints[i].y - points[i].y + 1));
-    }
-
-    sort(numBoxes, score, indices);
-    for (i = 0; i < numBoxes; i++)
-    {
-        if (!is_suppressed[indices[i]])
-        {
-            for (j = i + 1; j < numBoxes; j++)
-            {
-                if (!is_suppressed[indices[j]])
-                {
-                    int x1max = max(points[indices[i]].x, points[indices[j]].x);
-                    int x2min = min(oppositePoints[indices[i]].x, oppositePoints[indices[j]].x);
-                    int y1max = max(points[indices[i]].y, points[indices[j]].y);
-                    int y2min = min(oppositePoints[indices[i]].y, oppositePoints[indices[j]].y);
-                    int overlapWidth = x2min - x1max + 1;
-                    int overlapHeight = y2min - y1max + 1;
-                    if (overlapWidth > 0 && overlapHeight > 0)
-                    {
-                        float overlapPart = (overlapWidth * overlapHeight) / box_area[indices[j]];
-                        if (overlapPart > overlapThreshold)
-                        {
-                            is_suppressed[indices[j]] = 1;
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    *numBoxesOut = 0;
-    for (i = 0; i < numBoxes; i++)
-    {
-        if (!is_suppressed[i]) (*numBoxesOut)++;
-    }
-
-    *pointsOut = (CvPoint *)malloc((*numBoxesOut) * sizeof(CvPoint));
-    *oppositePointsOut = (CvPoint *)malloc((*numBoxesOut) * sizeof(CvPoint));
-    *scoreOut = (float *)malloc((*numBoxesOut) * sizeof(float));
-    index = 0;
-    for (i = 0; i < numBoxes; i++)
-    {
-        if (!is_suppressed[indices[i]])
-        {
-            (*pointsOut)[index].x = points[indices[i]].x;
-            (*pointsOut)[index].y = points[indices[i]].y;
-            (*oppositePointsOut)[index].x = oppositePoints[indices[i]].x;
-            (*oppositePointsOut)[index].y = oppositePoints[indices[i]].y;
-            (*scoreOut)[index] = score[indices[i]];
-            index++;
-        }
-
-    }
-
-    free(indices);
-    free(box_area);
-    free(is_suppressed);
-
-    return LATENT_SVM_OK;
-}
diff --git a/modules/objdetect/src/resizeimg.cpp b/modules/objdetect/src/resizeimg.cpp
deleted file mode 100644 (file)
index d999d12..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-#include "precomp.hpp"
-#include "opencv2/imgproc/imgproc_c.h"
-#include "_lsvm_resizeimg.h"
-#include <stdio.h>
-#include <assert.h>
-#include <math.h>
-
-IplImage* resize_opencv(IplImage* img, float scale)
-{
-    IplImage* imgTmp;
-
-    int W, H, tW, tH;
-
-    W = img->width;
-    H = img->height;
-
-    tW = (int)(((float)W) * scale + 0.5);
-    tH = (int)(((float)H) * scale + 0.5);
-
-    imgTmp = cvCreateImage(cvSize(tW , tH), img->depth, img->nChannels);
-    cvResize(img, imgTmp, CV_INTER_AREA);
-
-    return imgTmp;
-}
-
-//
-///*
-// * Fast image subsampling.
-// * This is used to construct the feature pyramid.
-// */
-//
-//// struct used for caching interpolation values
-//typedef struct  {
-//  int si, di;
-//  float alpha;
-//}alphainfo;
-//
-//// copy src into dst using pre-computed interpolation values
-//void alphacopy(float *src, float *dst, alphainfo *ofs, int n) {
-//    int i;
-//    for(i = 0; i < n; i++){
-//        dst[ofs[i].di] += ofs[i].alpha * src[ofs[i].si];
-//    }
-//}
-//
-//int round(float val){
-//    return (int)(val + 0.5);
-//}
-//void bzero(float * arr, int cnt){
-//    int i;
-//    for(i = 0; i < cnt; i++){
-//        arr[i] = 0.0f;
-//    }
-//}
-//// resize along each column
-//// result is transposed, so we can apply it twice for a complete resize
-//void resize1dtran(float *src, int sheight, float *dst, int dheight,
-//               int width, int chan) {
-//  alphainfo *ofs;
-//  float scale = (float)dheight/(float)sheight;
-//  float invscale = (float)sheight/(float)dheight;
-//
-//  // we cache the interpolation values since they can be
-//  // shared among different columns
-//  int len = (int)ceilf(dheight*invscale) + 2*dheight;
-//  int k = 0;
-//  int dy;
-//  float fsy1;
-//  float fsy2;
-//  int sy1;
-//  int sy2;
-//  int sy;
-//  int c, x;
-//  float *s, *d;
-//
-//  ofs = (alphainfo *) malloc (sizeof(alphainfo) * len);
-//  for (dy = 0; dy < dheight; dy++) {
-//    fsy1 = dy * invscale;
-//    fsy2 = fsy1 + invscale;
-//    sy1 = (int)ceilf(fsy1);
-//    sy2 = (int)floorf(fsy2);
-//
-//    if (sy1 - fsy1 > 1e-3) {
-//      assert(k < len);
-//      assert(sy1 - 1 >= 0);
-//      ofs[k].di = dy*width;
-//      ofs[k].si = sy1-1;
-//      ofs[k++].alpha = (sy1 - fsy1) * scale;
-//    }
-//
-//    for (sy = sy1; sy < sy2; sy++) {
-//      assert(k < len);
-//      assert(sy < sheight);
-//      ofs[k].di = dy*width;
-//      ofs[k].si = sy;
-//      ofs[k++].alpha = scale;
-//    }
-//
-//    if (fsy2 - sy2 > 1e-3) {
-//      assert(k < len);
-//      assert(sy2 < sheight);
-//      ofs[k].di = dy*width;
-//      ofs[k].si = sy2;
-//      ofs[k++].alpha = (fsy2 - sy2) * scale;
-//    }
-//  }
-//
-//  // resize each column of each color channel
-//  bzero(dst, chan*width*dheight);
-//  for (c = 0; c < chan; c++) {
-//    for (x = 0; x < width; x++) {
-//      s = src + c*width*sheight + x*sheight;
-//      d = dst + c*width*dheight + x;
-//      alphacopy(s, d, ofs, k);
-//    }
-//  }
-//  free(ofs);
-//}
-//
-//IplImage * resize_article_dp(IplImage * img, float scale, const int k){
-//    IplImage * imgTmp;
-//    float W, H;
-//    unsigned  char   *dataSrc;
-//    float * dataf;
-//    float *src, *dst, *tmp;
-//    int i, j, kk, channels;
-//     int index;
-//    int widthStep;
-//    int tW, tH;
-//
-//    W = (float)img->width;
-//    H = (float)img->height;
-//    channels  = img->nChannels;
-//     widthStep = img->widthStep;
-//
-//    tW = (int)(((float)W) * scale + 0.5f);
-//    tH = (int)(((float)H) * scale + 0.5f);
-//
-//    src = (float *)malloc(sizeof(float) * (int)(W * H * 3));
-//
-//    dataSrc = (unsigned char*)(img->imageData);
-//     index = 0;
-//     for (kk = 0; kk < channels; kk++)
-//     {
-//             for (i = 0; i < W; i++)
-//             {
-//                     for (j = 0; j < H; j++)
-//                     {
-//                             src[index++] = (float)dataSrc[j * widthStep + i * channels + kk];
-//                     }
-//             }
-//     }
-//
-//    imgTmp = cvCreateImage(cvSize(tW , tH), IPL_DEPTH_32F, channels);
-//
-//    dst = (float *)malloc(sizeof(float) * (int)(tH * tW) * channels);
-//    tmp = (float *)malloc(sizeof(float) * (int)(tH *  W) * channels);
-//
-//    resize1dtran(src, (int)H, tmp, (int)tH, (int)W , 3);
-//
-//    resize1dtran(tmp, (int)W, dst, (int)tW, (int)tH, 3);
-//
-//     index = 0;
-//     //dataf = (float*)imgTmp->imageData;
-//     for (kk = 0; kk < channels; kk++)
-//     {
-//             for (i = 0; i < tW; i++)
-//             {
-//                     for (j = 0; j < tH; j++)
-//                     {
-//                dataf = (float*)(imgTmp->imageData + j * imgTmp->widthStep);
-//                             dataf[ i * channels + kk] = dst[index++];
-//                     }
-//             }
-//     }
-//
-//    free(src);
-//    free(dst);
-//    free(tmp);
-//    return imgTmp;
-//}
-//
-//IplImage * resize_article_dp1(IplImage * img, float scale, const int k){
-//    IplImage * imgTmp;
-//    float W, H;
-//    float * dataf;
-//    float *src, *dst, *tmp;
-//    int i, j, kk, channels;
-//     int index;
-//     int widthStep;
-//    int tW, tH;
-//
-//    W = (float)img->width;
-//    H = (float)img->height;
-//    channels  = img->nChannels;
-//     widthStep = img->widthStep;
-//
-//    tW = (int)(((float)W) * scale + 0.5f);
-//    tH = (int)(((float)H) * scale + 0.5f);
-//
-//    src = (float *)malloc(sizeof(float) * (int)(W * H) * 3);
-//
-//     index = 0;
-//     for (kk = 0; kk < channels; kk++)
-//     {
-//             for (i = 0; i < W; i++)
-//             {
-//                     for (j = 0; j < H; j++)
-//                     {
-//                             src[index++] = (float)(*( (float *)(img->imageData + j * widthStep) + i * channels + kk));
-//                     }
-//             }
-//     }
-//
-//    imgTmp = cvCreateImage(cvSize(tW , tH), IPL_DEPTH_32F, channels);
-//
-//    dst = (float *)malloc(sizeof(float) * (int)(tH * tW) * channels);
-//    tmp = (float *)malloc(sizeof(float) * (int)(tH *  W) * channels);
-//
-//    resize1dtran(src, (int)H, tmp, (int)tH, (int)W , 3);
-//
-//    resize1dtran(tmp, (int)W, dst, (int)tW, (int)tH, 3);
-//
-//     index = 0;
-//     for (kk = 0; kk < channels; kk++)
-//     {
-//             for (i = 0; i < tW; i++)
-//             {
-//                     for (j = 0; j < tH; j++)
-//                     {
-//                dataf = (float *)(imgTmp->imageData + j * imgTmp->widthStep);
-//                             dataf[ i * channels + kk] = dst[index++];
-//                     }
-//             }
-//     }
-//
-//    free(src);
-//    free(dst);
-//    free(tmp);
-//    return imgTmp;
-//}
-//
diff --git a/modules/objdetect/src/routine.cpp b/modules/objdetect/src/routine.cpp
deleted file mode 100644 (file)
index a834e45..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-#include "precomp.hpp"
-#include "_lsvm_routine.h"
-
-int allocFilterObject(CvLSVMFilterObject **obj, const int sizeX,
-                      const int sizeY, const int numFeatures)
-{
-    int i;
-    (*obj) = (CvLSVMFilterObject *)malloc(sizeof(CvLSVMFilterObject));
-    (*obj)->sizeX           = sizeX;
-    (*obj)->sizeY           = sizeY;
-    (*obj)->numFeatures     = numFeatures;
-    (*obj)->fineFunction[0] = 0.0f;
-    (*obj)->fineFunction[1] = 0.0f;
-    (*obj)->fineFunction[2] = 0.0f;
-    (*obj)->fineFunction[3] = 0.0f;
-    (*obj)->V.x         = 0;
-    (*obj)->V.y         = 0;
-    (*obj)->V.l         = 0;
-    (*obj)->H = (float *) malloc(sizeof (float) *
-                                (sizeX * sizeY  * numFeatures));
-    for(i = 0; i < sizeX * sizeY * numFeatures; i++)
-    {
-        (*obj)->H[i] = 0.0f;
-    }
-    return LATENT_SVM_OK;
-}
-int freeFilterObject (CvLSVMFilterObject **obj)
-{
-    if(*obj == NULL) return LATENT_SVM_MEM_NULL;
-    free((*obj)->H);
-    free(*obj);
-    (*obj) = NULL;
-    return LATENT_SVM_OK;
-}
-
-int allocFeatureMapObject(CvLSVMFeatureMap **obj, const int sizeX,
-                          const int sizeY, const int numFeatures)
-{
-    int i;
-    (*obj) = (CvLSVMFeatureMap *)malloc(sizeof(CvLSVMFeatureMap));
-    (*obj)->sizeX       = sizeX;
-    (*obj)->sizeY       = sizeY;
-    (*obj)->numFeatures = numFeatures;
-    (*obj)->map = (float *) malloc(sizeof (float) *
-                                  (sizeX * sizeY  * numFeatures));
-    for(i = 0; i < sizeX * sizeY * numFeatures; i++)
-    {
-        (*obj)->map[i] = 0.0f;
-    }
-    return LATENT_SVM_OK;
-}
-int freeFeatureMapObject (CvLSVMFeatureMap **obj)
-{
-    if(*obj == NULL) return LATENT_SVM_MEM_NULL;
-    free((*obj)->map);
-    free(*obj);
-    (*obj) = NULL;
-    return LATENT_SVM_OK;
-}
-
-int allocFeaturePyramidObject(CvLSVMFeaturePyramid **obj,
-                              const int numLevels)
-{
-    (*obj) = (CvLSVMFeaturePyramid *)malloc(sizeof(CvLSVMFeaturePyramid));
-    (*obj)->numLevels = numLevels;
-    (*obj)->pyramid    = (CvLSVMFeatureMap **)malloc(
-                         sizeof(CvLSVMFeatureMap *) * numLevels);
-    return LATENT_SVM_OK;
-}
-
-int freeFeaturePyramidObject (CvLSVMFeaturePyramid **obj)
-{
-    int i;
-    if(*obj == NULL) return LATENT_SVM_MEM_NULL;
-    for(i = 0; i < (*obj)->numLevels; i++)
-    {
-        freeFeatureMapObject(&((*obj)->pyramid[i]));
-    }
-    free((*obj)->pyramid);
-    free(*obj);
-    (*obj) = NULL;
-    return LATENT_SVM_OK;
-}
-
-int allocFFTImage(CvLSVMFftImage **image, int numFeatures, int dimX, int dimY)
-{
-    int i, j, size;
-    *image = (CvLSVMFftImage *)malloc(sizeof(CvLSVMFftImage));
-    (*image)->numFeatures = numFeatures;
-    (*image)->dimX         = dimX;
-    (*image)->dimY         = dimY;
-    (*image)->channels     = (float **)malloc(sizeof(float *) * numFeatures);
-    size = 2 * dimX * dimY;
-    for (i = 0; i < numFeatures; i++)
-    {
-        (*image)->channels[i] = (float *)malloc(sizeof(float) * size);
-        for (j = 0; j < size; j++)
-        {
-            (*image)->channels[i][j] = 0.0f;
-        }
-    }
-    return LATENT_SVM_OK;
-}
-
-int freeFFTImage(CvLSVMFftImage **image)
-{
-    int i;
-    if (*image == NULL) return LATENT_SVM_OK;
-    for (i = 0; i < (*image)->numFeatures; i++)
-    {
-        free((*image)->channels[i]);
-        (*image)->channels[i] = NULL;
-    }
-    free((*image)->channels);
-    (*image)->channels = NULL;
-    return LATENT_SVM_OK;
-}
diff --git a/modules/objdetect/test/test_latentsvmdetector.cpp b/modules/objdetect/test/test_latentsvmdetector.cpp
deleted file mode 100644 (file)
index 30ab157..0000000
+++ /dev/null
@@ -1,307 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-#include "opencv2/objdetect/objdetect_c.h"
-#include <string>
-
-#ifdef HAVE_TBB
-#include "tbb/task_scheduler_init.h"
-#endif
-
-using namespace std;
-using namespace cv;
-
-const int num_detections = 3;
-const float true_scores[3] = {-0.383931f, -0.825876f, -0.959934f};
-const float score_thr = 0.05f;
-const CvRect true_bounding_boxes[3] = {cvRect(0, 45, 362, 452), cvRect(304, 0, 64, 80), cvRect(236, 0, 108, 59)};
-
-class CV_LatentSVMDetectorTest : public cvtest::BaseTest
-{
-protected:
-    void run(int);
-    bool isEqual(CvRect r1, CvRect r2, int eps);
-};
-
-bool CV_LatentSVMDetectorTest::isEqual(CvRect r1, CvRect r2, int eps)
-{
-    return (std::abs(r1.x - r2.x) <= eps
-            && std::abs(r1.y - r2.y) <= eps
-            && std::abs(r1.width - r2.width) <= eps
-            && std::abs(r1.height - r2.height) <= eps);
-}
-
-void CV_LatentSVMDetectorTest::run( int /* start_from */)
-{
-    string img_path = string(ts->get_data_path()) + "latentsvmdetector/cat.png";
-    string model_path = string(ts->get_data_path()) + "latentsvmdetector/models_VOC2007/cat.xml";
-    int numThreads = -1;
-
-#ifdef HAVE_TBB
-    numThreads = 2;
-    tbb::task_scheduler_init init(tbb::task_scheduler_init::deferred);
-    init.initialize(numThreads);
-#endif
-
-    Mat image2 = cv::imread(img_path.c_str());
-    IplImage image = image2;
-    if (image2.empty())
-    {
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );
-        return;
-    }
-
-    CvLatentSvmDetector* detector = cvLoadLatentSvmDetector(model_path.c_str());
-    if (!detector)
-    {
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );
-        return;
-    }
-
-    CvMemStorage* storage = cvCreateMemStorage(0);
-    CvSeq* detections = 0;
-    detections = cvLatentSvmDetectObjects(&image, detector, storage, 0.5f, numThreads);
-    if (detections->total != num_detections)
-    {
-        ts->set_failed_test_info( cvtest::TS::FAIL_MISMATCH );
-    }
-    else
-    {
-        ts->set_failed_test_info(cvtest::TS::OK);
-        for (int i = 0; i < detections->total; i++)
-        {
-            CvObjectDetection detection = *(CvObjectDetection*)cvGetSeqElem( detections, i );
-            CvRect bounding_box = detection.rect;
-            float score = detection.score;
-            if ((!isEqual(bounding_box, true_bounding_boxes[i], 1)) || (fabs(score - true_scores[i]) > score_thr))
-            {
-                ts->set_failed_test_info( cvtest::TS::FAIL_MISMATCH );
-                break;
-            }
-        }
-    }
-#ifdef HAVE_TBB
-    init.terminate();
-#endif
-    cvReleaseMemStorage( &storage );
-    cvReleaseLatentSvmDetector( &detector );
-}
-
-// Test for c++ version of Latent SVM
-
-class LatentSVMDetectorTest : public cvtest::BaseTest
-{
-protected:
-    void run(int);
-};
-
-static void writeDetections( FileStorage& fs, const string& nodeName, const vector<LatentSvmDetector::ObjectDetection>& detections )
-{
-    fs << nodeName << "[";
-    for( size_t i = 0; i < detections.size(); i++ )
-    {
-        const LatentSvmDetector::ObjectDetection& d = detections[i];
-        fs << d.rect.x << d.rect.y << d.rect.width << d.rect.height
-           << d.score << d.classID;
-    }
-    fs << "]";
-}
-
-static void readDetections( FileStorage fs, const string& nodeName, vector<LatentSvmDetector::ObjectDetection>& detections )
-{
-    detections.clear();
-
-    FileNode fn = fs.root()[nodeName];
-    FileNodeIterator fni = fn.begin();
-    while( fni != fn.end() )
-    {
-        LatentSvmDetector::ObjectDetection d;
-        fni >> d.rect.x >> d.rect.y >> d.rect.width >> d.rect.height
-            >> d.score >> d.classID;
-        detections.push_back( d );
-    }
-}
-
-static inline bool isEqual( const LatentSvmDetector::ObjectDetection& d1, const LatentSvmDetector::ObjectDetection& d2, int eps, float threshold)
-{
-    return (
-           std::abs(d1.rect.x - d2.rect.x) <= eps
-           && std::abs(d1.rect.y - d2.rect.y) <= eps
-           && std::abs(d1.rect.width - d2.rect.width) <= eps
-           && std::abs(d1.rect.height - d2.rect.height) <= eps
-           && (d1.classID == d2.classID)
-           && std::abs(d1.score - d2.score) <= threshold
-           );
-}
-
-std::ostream& operator << (std::ostream& os, const CvRect& r)
-{
-    return (os << "[x=" << r.x << ", y=" << r.y << ", w=" << r.width << ", h=" << r.height << "]");
-}
-
-bool compareResults( const vector<LatentSvmDetector::ObjectDetection>& calc, const vector<LatentSvmDetector::ObjectDetection>& valid, int eps, float threshold)
-{
-    if( calc.size() != valid.size() )
-        return false;
-
-    for( size_t i = 0; i < calc.size(); i++ )
-    {
-        const LatentSvmDetector::ObjectDetection& c = calc[i];
-        const LatentSvmDetector::ObjectDetection& v = valid[i];
-        if( !isEqual(c, v, eps, threshold) )
-        {
-            std::cerr << "Expected: " << v.rect << " class=" << v.classID << " score=" << v.score << std::endl;
-            std::cerr << "Actual:   " << c.rect << " class=" << c.classID << " score=" << c.score << std::endl;
-            return false;
-        }
-    }
-    return true;
-}
-
-void LatentSVMDetectorTest::run( int /* start_from */)
-{
-    string img_path_cat = string(ts->get_data_path()) + "latentsvmdetector/cat.png";
-    string img_path_cars = string(ts->get_data_path()) + "latentsvmdetector/cars.png";
-
-    string model_path_cat = string(ts->get_data_path()) + "latentsvmdetector/models_VOC2007/cat.xml";
-    string model_path_car = string(ts->get_data_path()) + "latentsvmdetector/models_VOC2007/car.xml";
-
-    string true_res_path = string(ts->get_data_path()) + "latentsvmdetector/results.xml";
-
-    int numThreads = 1;
-
-#ifdef HAVE_TBB
-    numThreads = 2;
-#endif
-
-    Mat image_cat = imread( img_path_cat );
-    Mat image_cars = imread( img_path_cars );
-    if( image_cat.empty() || image_cars.empty() )
-    {
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );
-        return;
-    }
-
-    // We will test 2 cases:
-    // detector1 - to test case of one class 'cat'
-    // detector12 - to test case of two (several) classes 'cat' and car
-
-    // Load detectors
-    LatentSvmDetector detector1( vector<String>(1,model_path_cat) );
-
-    vector<String> models_pathes(2);
-    models_pathes[0] = model_path_cat;
-    models_pathes[1] = model_path_car;
-    LatentSvmDetector detector12( models_pathes );
-
-    if( detector1.empty() || detector12.empty() || detector12.getClassCount() != 2 )
-    {
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA );
-        return;
-    }
-
-    // 1. Test method detect
-    // Run detectors
-    vector<LatentSvmDetector::ObjectDetection> detections1_cat, detections12_cat, detections12_cars;
-    detector1.detect( image_cat, detections1_cat, 0.5, numThreads );
-    detector12.detect( image_cat, detections12_cat, 0.5, numThreads );
-    detector12.detect( image_cars, detections12_cars, 0.5, numThreads );
-
-    // Load true results
-    FileStorage fs( true_res_path, FileStorage::READ );
-    if( fs.isOpened() )
-    {
-        vector<LatentSvmDetector::ObjectDetection> true_detections1_cat, true_detections12_cat, true_detections12_cars;
-        readDetections( fs, "detections1_cat", true_detections1_cat );
-        readDetections( fs, "detections12_cat", true_detections12_cat );
-        readDetections( fs, "detections12_cars", true_detections12_cars );
-
-
-        if( !compareResults(detections1_cat, true_detections1_cat, 1, score_thr) )
-        {
-            std::cerr << "Results of detector1 are invalid on image cat.png" << std::endl;
-            ts->set_failed_test_info( cvtest::TS::FAIL_MISMATCH );
-        }
-        if( !compareResults(detections12_cat, true_detections12_cat, 1, score_thr) )
-        {
-            std::cerr << "Results of detector12 are invalid on image cat.png" << std::endl;
-            ts->set_failed_test_info( cvtest::TS::FAIL_MISMATCH );
-        }
-        if( !compareResults(detections12_cars, true_detections12_cars, 1, score_thr) )
-        {
-            std::cerr << "Results of detector12 are invalid on image cars.png" << std::endl;
-            ts->set_failed_test_info( cvtest::TS::FAIL_MISMATCH );
-        }
-    }
-    else
-    {
-        fs.open( true_res_path, FileStorage::WRITE );
-        if( fs.isOpened() )
-        {
-            writeDetections( fs, "detections1_cat", detections1_cat );
-            writeDetections( fs, "detections12_cat", detections12_cat );
-            writeDetections( fs, "detections12_cars", detections12_cars );
-        }
-        else
-            std::cerr << "File " << true_res_path << " cann't be opened to save test results" << std::endl;
-    }
-
-    // 2. Simple tests of other methods
-    if( detector1.getClassCount() != 1 || detector1.getClassNames()[0] != "cat" )
-    {
-        std::cerr << "Incorrect result of method getClassNames() or getClassCount()" << std::endl;
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT);
-    }
-
-    detector1.clear();
-    if( !detector1.empty() )
-    {
-        std::cerr << "There is a bug in method clear() or empty()" << std::endl;
-        ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT);
-    }
-
-    ts->set_failed_test_info( cvtest::TS::OK);
-}
-
-TEST(Objdetect_LatentSVMDetector_c, DISABLED_regression) { CV_LatentSVMDetectorTest test; test.safe_run(); }
-TEST(Objdetect_LatentSVMDetector_cpp, DISABLED_regression) { LatentSVMDetectorTest test; test.safe_run(); }
index f796a97..a50e372 100644 (file)
@@ -11,7 +11,7 @@ if(ANDROID OR IOS OR NOT PYTHONLIBS_FOUND OR NOT PYTHON_NUMPY_INCLUDE_DIRS)
 endif()
 
 set(the_description "The python bindings")
-ocv_add_module(python BINDINGS opencv_core opencv_flann opencv_imgproc opencv_video opencv_ml opencv_features2d opencv_highgui opencv_calib3d opencv_photo opencv_objdetect opencv_contrib opencv_legacy opencv_softcascade OPTIONAL opencv_nonfree)
+ocv_add_module(python BINDINGS opencv_core opencv_flann opencv_imgproc opencv_video opencv_ml opencv_features2d opencv_highgui opencv_calib3d opencv_photo opencv_objdetect OPTIONAL opencv_nonfree)
 
 ocv_module_include_directories(
     "${PYTHON_INCLUDE_PATH}"
@@ -36,8 +36,7 @@ set(opencv_hdrs
     "${OPENCV_MODULE_opencv_features2d_LOCATION}/include/opencv2/features2d.hpp"
     "${OPENCV_MODULE_opencv_calib3d_LOCATION}/include/opencv2/calib3d.hpp"
     "${OPENCV_MODULE_opencv_objdetect_LOCATION}/include/opencv2/objdetect.hpp"
-    "${OPENCV_MODULE_opencv_softcascade_LOCATION}/include/opencv2/softcascade.hpp"
-    "${OPENCV_MODULE_opencv_contrib_LOCATION}/include/opencv2/contrib.hpp")
+    )
 
 if(HAVE_opencv_nonfree)
   list(APPEND opencv_hdrs     "${OPENCV_MODULE_opencv_nonfree_LOCATION}/include/opencv2/nonfree/features2d.hpp"
index 340242f..622d24e 100644 (file)
@@ -84,7 +84,6 @@ catch (const cv::Exception &e) \
 using namespace cv;
 using cv::flann::IndexParams;
 using cv::flann::SearchParams;
-using cv::softcascade::ChannelFeatureBuilder;
 
 typedef std::vector<uchar> vector_uchar;
 typedef std::vector<char> vector_char;
@@ -111,8 +110,6 @@ typedef std::vector<std::vector<Point2f> > vector_vector_Point2f;
 typedef std::vector<std::vector<Point3f> > vector_vector_Point3f;
 typedef std::vector<std::vector<DMatch> > vector_vector_DMatch;
 
-typedef cv::softcascade::ChannelFeatureBuilder softcascade_ChannelFeatureBuilder;
-
 typedef SimpleBlobDetector::Params SimpleBlobDetector_Params;
 
 typedef cvflann::flann_distance_t cvflann_flann_distance_t;
index 78981ed..e2bab9e 100755 (executable)
@@ -15,7 +15,6 @@ opencv_hdr_list = [
 "../../video/include/opencv2/video/tracking.hpp",
 "../../video/include/opencv2/video/background_segm.hpp",
 "../../objdetect/include/opencv2/objdetect.hpp",
-"../../contrib/include/opencv2/contrib.hpp",
 "../../highgui/include/opencv2/highgui.hpp"
 ]
 
diff --git a/modules/softcascade/CMakeLists.txt b/modules/softcascade/CMakeLists.txt
deleted file mode 100644 (file)
index 84d098d..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-set(the_description "Soft Cascade detection and training")
-ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4310 -Wundef -Wmissing-declarations -Wmissing-prototypes)
-ocv_define_module(softcascade opencv_core opencv_imgproc opencv_ml)
diff --git a/modules/softcascade/doc/softcascade.rst b/modules/softcascade/doc/softcascade.rst
deleted file mode 100644 (file)
index 4b3a44a..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-********************************************************
-softcascade. Soft Cascade object detection and training.
-********************************************************
-
-.. highlight:: cpp
-
-.. toctree::
-    :maxdepth: 2
-
-    softcascade_detector
-    softcascade_training
-    softcascade_cuda
diff --git a/modules/softcascade/doc/softcascade_cuda.rst b/modules/softcascade/doc/softcascade_cuda.rst
deleted file mode 100644 (file)
index 32abb8c..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-CUDA version of Soft Cascade Classifier
-========================================
-
-softcascade::SCascade
------------------------------------------------
-.. ocv:class:: softcascade::SCascade : public Algorithm
-
-Implementation of soft (stageless) cascaded detector. ::
-
-    class CV_EXPORTS SCascade : public Algorithm
-    {
-        struct CV_EXPORTS Detection
-        {
-              ushort x;
-              ushort y;
-              ushort w;
-              ushort h;
-              float confidence;
-              int kind;
-
-              enum {PEDESTRIAN = 0};
-        };
-
-        SCascade(const double minScale = 0.4, const double maxScale = 5., const int scales = 55, const int rejfactor = 1);
-        virtual ~SCascade();
-        virtual bool load(const FileNode& fn);
-        virtual void detect(InputArray image, InputArray rois, OutputArray objects, Stream& stream = Stream::Null()) const;
-        virtual void genRoi(InputArray roi, OutputArray mask, Stream& stream = Stream::Null()) const;
-    };
-
-
-softcascade::SCascade::~SCascade
----------------------------------
-Destructor for SCascade.
-
-.. ocv:function:: softcascade::SCascade::~SCascade()
-
-
-
-softcascade::SCascade::load
-----------------------------
-Load cascade from FileNode.
-
-.. ocv:function:: bool softcascade::SCascade::load(const FileNode& fn)
-
-    :param fn: File node from which the soft cascade are read.
-
-
-
-softcascade::SCascade::detect
-------------------------------
-Apply cascade to an input frame and return the vector of Decection objcts.
-
-.. ocv:function:: void softcascade::SCascade::detect(InputArray image, InputArray rois, OutputArray objects, cv::cuda::Stream& stream = cv::cuda::Stream::Null()) const
-
-    :param image: a frame on which detector will be applied.
-
-    :param rois: a regions of interests mask generated by genRoi. Only the objects that fall into one of the regions will be returned.
-
-    :param objects: an output array of Detections represented as GpuMat of detections (SCascade::Detection). The first element of the matrix is  actually a count of detections.
-
-    :param stream: a high-level CUDA stream abstraction used for asynchronous execution.
diff --git a/modules/softcascade/doc/softcascade_detector.rst b/modules/softcascade/doc/softcascade_detector.rst
deleted file mode 100644 (file)
index 49d1ab0..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-Soft Cascade Classifier
-=======================
-
-.. highlight:: cpp
-
-Soft Cascade Classifier for Object Detection
---------------------------------------------
-
-Cascade detectors have been shown to operate extremely rapidly, with high accuracy, and have important applications in different spheres. The initial goal for this cascade implementation was the fast and accurate pedestrian detector but it also useful in general. Soft cascade is trained with AdaBoost. But instead of training sequence of stages, the soft cascade is trained as a one long stage of T weak classifiers. Soft cascade is formulated as follows:
-
-.. math::
-    \texttt{H}(x) = \sum _{\texttt{t}=1..\texttt{T}} {\texttt{s}_t(x)}
-
-where :math:`\texttt{s}_t(x) = \alpha_t\texttt{h}_t(x)` are the set of thresholded weak classifiers selected during AdaBoost training scaled by the associated weights. Let
-
-.. math::
-    \texttt{H}_t(x) = \sum _{\texttt{i}=1..\texttt{t}} {\texttt{s}_i(x)}
-
-be the partial sum of sample responses before :math:`t`-the weak classifier will be applied. The function :math:`\texttt{H}_t(x)` of :math:`t` for sample :math:`x` named *sample trace*.
-After each weak classifier evaluation, the sample trace at the point :math:`t` is compared with the rejection threshold :math:`r_t`. The sequence of :math:`r_t` named *rejection trace*.
-
-The sample has been rejected if it fall rejection threshold. So stageless cascade allows to reject not-object sample as soon as possible. Another meaning of the sample trace is a confidence with that sample recognized as desired object. At each :math:`t` that confidence depend on all previous weak classifier. This feature of soft cascade is resulted in more accurate detection. The original formulation of soft cascade can be found in [BJ05]_.
-
-.. [BJ05] Lubomir Bourdev and Jonathan Brandt. tRobust Object Detection Via Soft Cascade. IEEE CVPR, 2005.
-.. [BMTG12] Rodrigo Benenson, Markus Mathias, Radu Timofte and Luc Van Gool. Pedestrian detection at 100 frames per second. IEEE CVPR, 2012.
-
-
-softcascade::Detector
----------------------
-.. ocv:class:: softcascade::Detector : public Algorithm
-
-Implementation of soft (stageless) cascaded detector. ::
-
-    class Detector : public Algorithm
-    {
-    public:
-
-        enum { NO_REJECT = 1, DOLLAR = 2, /*PASCAL = 4,*/ DEFAULT = NO_REJECT};
-
-        Detector(double minScale = 0.4, double maxScale = 5., int scales = 55, int rejCriteria = 1);
-        virtual ~Detector();
-        cv::AlgorithmInfo* info() const;
-        virtual bool load(const FileNode& fileNode);
-        virtual void read(const FileNode& fileNode);
-        virtual void detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const;
-        virtual void detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const;
-
-    }
-
-
-
-softcascade::Detector::Detector
-----------------------------------------
-An empty cascade will be created.
-
-.. ocv:function:: softcascade::Detector::Detector( double minScale=0.4, double maxScale=5., int scales=55, int rejCriteria=1 )
-
-.. ocv:pyfunction:: cv2.softcascade_Detector([minScale[, maxScale[, scales[, rejCriteria]]]]) -> <softcascade_Detector object>
-
-    :param minScale: a minimum scale relative to the original size of the image on which cascade will be applied.
-
-    :param maxScale: a maximum scale relative to the original size of the image on which cascade will be applied.
-
-    :param scales: a number of scales from minScale to maxScale.
-
-    :param rejCriteria: algorithm used for non maximum suppression.
-
-
-
-softcascade::Detector::~Detector
------------------------------------------
-Destructor for Detector.
-
-.. ocv:function:: softcascade::Detector::~Detector()
-
-
-
-softcascade::Detector::load
----------------------------
-Load cascade from FileNode.
-
-.. ocv:function:: bool softcascade::Detector::load(const FileNode& fileNode)
-
-.. ocv:pyfunction:: cv2.softcascade_Detector.load(fileNode) -> retval
-
-    :param fileNode: File node from which the soft cascade are read.
-
-
-
-softcascade::Detector::detect
------------------------------
-Apply cascade to an input frame and return the vector of Detection objects.
-
-.. ocv:function:: void softcascade::Detector::detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const
-
-.. ocv:function:: void softcascade::Detector::detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const
-
-.. ocv:pyfunction:: cv2.softcascade_Detector.detect(image, rois[, rects[, confs]]) -> rects, confs
-
-    :param image: a frame on which detector will be applied.
-
-    :param rois: a vector of regions of interest. Only the objects that fall into one of the regions will be returned.
-
-    :param objects: an output array of Detections.
-
-    :param rects: an output array of bounding rectangles for detected objects.
-
-    :param confs: an output array of confidence for detected objects. i-th bounding rectangle corresponds i-th confidence.
-
-
-softcascade::ChannelFeatureBuilder
-----------------------------------
-.. ocv:class:: softcascade::ChannelFeatureBuilder : public Algorithm
-
-Public interface for of soft (stageless) cascaded detector. ::
-
-    class ChannelFeatureBuilder : public Algorithm
-    {
-    public:
-        virtual ~ChannelFeatureBuilder();
-
-        virtual void operator()(InputArray src, OutputArray channels) const = 0;
-
-        static cv::Ptr<ChannelFeatureBuilder> create();
-    };
-
-
-softcascade::ChannelFeatureBuilder:~ChannelFeatureBuilder
----------------------------------------------------------
-Destructor for ChannelFeatureBuilder.
-
-.. ocv:function:: softcascade::ChannelFeatureBuilder::~ChannelFeatureBuilder()
-
-.. ocv:pyfunction:: cv2.softcascade_ChannelFeatureBuilder_create(featureType) -> retval
-
-
-softcascade::ChannelFeatureBuilder::operator()
-----------------------------------------------
-Create channel feature integrals for input image.
-
-.. ocv:function:: void softcascade::ChannelFeatureBuilder::operator()(InputArray src, OutputArray channels) const
-
-.. ocv:pyfunction:: cv2.softcascade_ChannelFeatureBuilder.compute(src, channels) -> None
-
-    :param src source frame
-
-    :param channels in OutputArray of computed channels
diff --git a/modules/softcascade/doc/softcascade_training.rst b/modules/softcascade/doc/softcascade_training.rst
deleted file mode 100644 (file)
index cc83b38..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-Soft Cascade Training
-=======================
-
-.. highlight:: cpp
-
-Soft Cascade Detector Training
---------------------------------------------
-
-
-softcascade::Octave
--------------------
-.. ocv:class:: softcascade::Octave : public Algorithm
-
-Public interface for soft cascade training algorithm. ::
-
-    class Octave : public Algorithm
-    {
-    public:
-
-        enum {
-            // Direct backward pruning. (Cha Zhang and Paul Viola)
-            DBP = 1,
-            // Multiple instance pruning. (Cha Zhang and Paul Viola)
-            MIP = 2,
-            // Originally proposed by L. Bourdev and J. Brandt
-            HEURISTIC = 4 };
-
-        virtual ~Octave();
-        static cv::Ptr<Octave> create(cv::Rect boundingBox, int npositives, int nnegatives, int logScale, int shrinkage);
-
-        virtual bool train(const Dataset* dataset, const FeaturePool* pool, int weaks, int treeDepth) = 0;
-        virtual void setRejectThresholds(OutputArray thresholds) = 0;
-        virtual void write( cv::FileStorage &fs, const FeaturePool* pool, InputArray thresholds) const = 0;
-        virtual void write( CvFileStorage* fs, String name) const = 0;
-
-    };
-
-
-
-softcascade::Octave::~Octave
----------------------------------------
-Destructor for Octave.
-
-.. ocv:function:: softcascade::Octave::~Octave()
-
-
-softcascade::Octave::train
---------------------------
-
-.. ocv:function:: bool softcascade::Octave::train(const Dataset* dataset, const FeaturePool* pool, int weaks, int treeDepth)
-
-    :param dataset an object that allows communicate for training set.
-
-    :param pool an object that presents feature pool.
-
-    :param weaks a number of weak trees should be trained.
-
-    :param treeDepth a depth of resulting weak trees.
-
-
-
-softcascade::Octave::setRejectThresholds
-----------------------------------------
-
-.. ocv:function:: void softcascade::Octave::setRejectThresholds(OutputArray thresholds)
-
-    :param thresholds an output array of resulted rejection vector. Have same size as number of trained stages.
-
-
-softcascade::Octave::write
---------------------------
-
-.. ocv:function:: void softcascade::Octave::train(cv::FileStorage &fs, const FeaturePool* pool, InputArray thresholds) const
-.. ocv:function:: void softcascade::Octave::train( CvFileStorage* fs, String name) const
-
-    :param fs an output file storage to store trained detector.
-
-    :param pool an object that presents feature pool.
-
-    :param dataset a rejection vector that should be included in detector xml file.
-
-    :param name a name of root node for trained detector.
-
-
-softcascade::FeaturePool
-------------------------
-.. ocv:class:: softcascade::FeaturePool
-
-Public interface for feature pool. This is a hight level abstraction for training random feature pool. ::
-
-    class FeaturePool
-    {
-    public:
-
-        virtual int size() const = 0;
-        virtual float apply(int fi, int si, const Mat& channels) const = 0;
-        virtual void write( cv::FileStorage& fs, int index) const = 0;
-        virtual ~FeaturePool();
-
-    };
-
-softcascade::FeaturePool::size
-------------------------------
-
-Returns size of feature pool.
-
-.. ocv:function:: int softcascade::FeaturePool::size() const
-
-
-
-softcascade::FeaturePool::~FeaturePool
---------------------------------------
-
-FeaturePool destructor.
-
-.. ocv:function:: softcascade::FeaturePool::~FeaturePool()
-
-
-
-softcascade::FeaturePool::write
--------------------------------
-
-Write specified feature from feature pool to file storage.
-
-.. ocv:function:: void softcascade::FeaturePool::write( cv::FileStorage& fs, int index) const
-
-    :param fs an output file storage to store feature.
-
-    :param index an index of feature that should be stored.
-
-
-softcascade::FeaturePool::apply
--------------------------------
-
-Compute feature on integral channel image.
-
-.. ocv:function:: float softcascade::FeaturePool::apply(int fi, int si, const Mat& channels) const
-
-    :param fi an index of feature that should be computed.
-
-    :param si an index of sample.
-
-    :param fs a channel matrix.
diff --git a/modules/softcascade/include/opencv2/softcascade.hpp b/modules/softcascade/include/opencv2/softcascade.hpp
deleted file mode 100644 (file)
index 3b3a5f5..0000000
+++ /dev/null
@@ -1,300 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_SOFTCASCADE_HPP__
-#define __OPENCV_SOFTCASCADE_HPP__
-
-#include <iosfwd>
-
-#include "opencv2/core.hpp"
-#include "opencv2/core/cuda.hpp"
-
-namespace cv { namespace softcascade {
-
-// Representation of detectors result.
-// We assume that image is less then 2^16x2^16.
-struct CV_EXPORTS Detection
-{
-    // Creates Detection from an object bounding box and confidence.
-    // Param b is a bounding box
-    // Param c is a confidence that object belongs to class k
-    // Param k is an object class
-    Detection(const cv::Rect& b, const float c, int k = PEDESTRIAN);
-    cv::Rect bb() const;
-    enum {PEDESTRIAN = 1};
-
-    ushort x;
-    ushort y;
-    ushort w;
-    ushort h;
-    float confidence;
-    int kind;
-};
-
-class CV_EXPORTS Dataset
-{
-public:
-    typedef enum {POSITIVE = 1, NEGATIVE = 2} SampleType;
-
-    virtual cv::Mat get(SampleType type, int idx) const = 0;
-    virtual int available(SampleType type) const = 0;
-    virtual ~Dataset();
-};
-
-// ========================================================================== //
-//                       Public interface feature pool.
-// ========================================================================== //
-
-class CV_EXPORTS FeaturePool
-{
-public:
-
-    virtual int size() const = 0;
-    virtual float apply(int fi, int si, const Mat& channels) const = 0;
-    virtual void write( cv::FileStorage& fs, int index) const = 0;
-    virtual ~FeaturePool();
-
-    static cv::Ptr<FeaturePool> create(const cv::Size& model, int nfeatures, int nchannels );
-};
-
-// ========================================================================== //
-//                         First order channel feature.
-// ========================================================================== //
-
-class CV_EXPORTS ChannelFeature
-{
-public:
-    ChannelFeature(int x, int y, int w, int h, int ch);
-    ~ChannelFeature();
-
-    bool operator ==(ChannelFeature b);
-    bool operator !=(ChannelFeature b);
-
-    float operator() (const cv::Mat& integrals, const cv::Size& model) const;
-
-    friend void write(cv::FileStorage& fs, const String&, const ChannelFeature& f);
-    friend std::ostream& operator<<(std::ostream& out, const ChannelFeature& f);
-
-private:
-    cv::Rect bb;
-    int channel;
-};
-
-void write(cv::FileStorage& fs, const String&, const ChannelFeature& f);
-std::ostream& operator<<(std::ostream& out, const ChannelFeature& m);
-
-// ========================================================================== //
-//             Public Interface for Integral Channel Feature.
-// ========================================================================== //
-
-class CV_EXPORTS_W ChannelFeatureBuilder : public cv::Algorithm
-{
-public:
-    virtual ~ChannelFeatureBuilder();
-
-    // apply channels to source frame
-    CV_WRAP_AS(compute) virtual void operator()(InputArray src, OutputArray channels, cv::Size channelsSize = cv::Size()) const = 0;
-
-    CV_WRAP virtual int totalChannels() const = 0;
-    virtual cv::AlgorithmInfo* info() const = 0;
-
-    CV_WRAP static cv::Ptr<ChannelFeatureBuilder> create(const String& featureType);
-};
-
-// ========================================================================== //
-//             Implementation of soft (stageless) cascaded detector.
-// ========================================================================== //
-class CV_EXPORTS_W Detector : public cv::Algorithm
-{
-public:
-
-    enum { NO_REJECT = 1, DOLLAR = 2, /*PASCAL = 4,*/ DEFAULT = NO_REJECT};
-
-    // An empty cascade will be created.
-    // Param minScale is a minimum scale relative to the original size of the image on which cascade will be applied.
-    // Param minScale is a maximum scale relative to the original size of the image on which cascade will be applied.
-    // Param scales is a number of scales from minScale to maxScale.
-    // Param rejCriteria is used for NMS.
-    CV_WRAP Detector(double minScale = 0.4, double maxScale = 5., int scales = 55, int rejCriteria = 1);
-
-    CV_WRAP virtual ~Detector();
-
-    cv::AlgorithmInfo* info() const;
-
-    // Load soft cascade from FileNode.
-    // Param fileNode is a root node for cascade.
-    CV_WRAP virtual bool load(const FileNode& fileNode);
-
-    // Load soft cascade config.
-    CV_WRAP virtual void read(const FileNode& fileNode);
-
-    // Return the vector of Detection objects.
-    // Param image is a frame on which detector will be applied.
-    // Param rois is a vector of regions of interest. Only the objects that fall into one of the regions will be returned.
-    // Param objects is an output array of Detections
-    virtual void detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const;
-
-    // Param rects is an output array of bounding rectangles for detected objects.
-    // Param confs is an output array of confidence for detected objects. i-th bounding rectangle corresponds i-th confidence.
-    CV_WRAP virtual void detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const;
-
-private:
-    void detectNoRoi(const Mat& image, std::vector<Detection>& objects) const;
-
-    struct Fields;
-    Fields* fields;
-
-    double minScale;
-    double maxScale;
-
-    int   scales;
-    int   rejCriteria;
-};
-
-// ========================================================================== //
-//     Public Interface for singe soft (stageless) cascade octave training.
-// ========================================================================== //
-class CV_EXPORTS Octave : public cv::Algorithm
-{
-public:
-    enum
-    {
-        // Direct backward pruning. (Cha Zhang and Paul Viola)
-        DBP = 1,
-        // Multiple instance pruning. (Cha Zhang and Paul Viola)
-        MIP = 2,
-        // Originally proposed by L. Bourdev and J. Brandt
-        HEURISTIC = 4
-    };
-
-    virtual ~Octave();
-    static cv::Ptr<Octave> create(cv::Rect boundingBox, int npositives, int nnegatives,
-        int logScale, int shrinkage, cv::Ptr<ChannelFeatureBuilder> builder);
-
-    virtual bool train(const Dataset* dataset, const FeaturePool* pool, int weaks, int treeDepth) = 0;
-    virtual void setRejectThresholds(OutputArray thresholds) = 0;
-    virtual void write( cv::FileStorage &fs, const FeaturePool* pool, InputArray thresholds) const = 0;
-    virtual void write( CvFileStorage* fs, String name) const = 0;
-};
-
-CV_EXPORTS bool initModule_softcascade(void);
-
-// ======================== CUDA version for soft cascade ===================== //
-
-class CV_EXPORTS ChannelsProcessor
-{
-public:
-    enum
-    {
-        // GENERIC   = 1 << 4, does not supported
-        SEPARABLE = 2 << 4
-    };
-
-    // Appends specified number of HOG first-order features integrals into given vector.
-    // Param frame is an input 3-channel bgr image.
-    // Param channels is a GPU matrix of optionally shrinked channels
-    // Param stream is stream is a high-level CUDA stream abstraction used for asynchronous execution.
-    virtual void apply(InputArray frame, OutputArray channels, cv::cuda::Stream& stream = cv::cuda::Stream::Null()) = 0;
-
-    // Creates a specific preprocessor implementation.
-    // Param shrinkage is a resizing factor. Resize is applied before the computing integral sum
-    // Param bins is a number of HOG-like channels.
-    // Param flags is a channel computing extra flags.
-    static cv::Ptr<ChannelsProcessor> create(const int shrinkage, const int bins, const int flags = SEPARABLE);
-
-    virtual ~ChannelsProcessor();
-
-protected:
-    ChannelsProcessor();
-};
-
-// Implementation of soft (stage-less) cascaded detector.
-class CV_EXPORTS SCascade : public cv::Algorithm
-{
-public:
-
-    enum { NO_REJECT = 1, DOLLAR = 2, /*PASCAL = 4,*/ DEFAULT = NO_REJECT, NMS_MASK = 0xF};
-
-    // An empty cascade will be created.
-    // Param minScale is a minimum scale relative to the original size of the image on which cascade will be applied.
-    // Param minScale is a maximum scale relative to the original size of the image on which cascade will be applied.
-    // Param scales is a number of scales from minScale to maxScale.
-    // Param flags is an extra tuning flags.
-    SCascade(const double minScale = 0.4, const double maxScale = 5., const int scales = 55,
-        const int flags = NO_REJECT | ChannelsProcessor::SEPARABLE);
-
-    virtual ~SCascade();
-
-    cv::AlgorithmInfo* info() const;
-
-    // Load cascade from FileNode.
-    // Param fn is a root node for cascade. Should be <cascade>.
-    virtual bool load(const FileNode& fn);
-
-    // Load cascade config.
-    virtual void read(const FileNode& fn);
-
-    // Return the matrix of of detected objects.
-    // Param image is a frame on which detector will be applied.
-    // Param rois is a regions of interests mask generated by genRoi.
-    //    Only the objects that fall into one of the regions will be returned.
-    // Param objects is an output array of Detections represented as GpuMat of detections (SCascade::Detection)
-    //    The first element of the matrix is  actually a count of detections.
-    // Param stream is stream is a high-level CUDA stream abstraction used for asynchronous execution
-    virtual void detect(InputArray image, InputArray rois, OutputArray objects, cv::cuda::Stream& stream = cv::cuda::Stream::Null()) const;
-
-private:
-
-    struct Fields;
-    Fields* fields;
-
-    double minScale;
-    double maxScale;
-    int scales;
-
-    int flags;
-};
-
-
-}} // namespace cv { namespace softcascade {
-
-#endif
diff --git a/modules/softcascade/misc/detections2negatives.py b/modules/softcascade/misc/detections2negatives.py
deleted file mode 100755 (executable)
index 33ccb5f..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/usr/bin/env python
-
-import sys, os, os.path, glob, math, cv2, string, random
-from datetime import datetime
-from optparse import OptionParser
-import re
-import numpy as np
-from xml.dom import minidom
-
-def resize(image, d_w, d_h):
-    if (d_h < image.shape[0]) or (d_w < image.shape[1]):
-        ratio = min(d_h / float(image.shape[0]), d_w / float(image.shape[1]))
-
-        kernel_size = int( 5 / (2 * ratio))
-        sigma = 0.5 / ratio
-        image_to_resize = cv2.filter2D(image, cv2.CV_8UC3, cv2.getGaussianKernel(kernel_size, sigma))
-        interpolation_type = cv2.INTER_AREA
-    else:
-        image_to_resize = image
-        interpolation_type = cv2.INTER_CUBIC
-
-    return cv2.resize(image_to_resize,(d_w, d_h), None, 0, 0, interpolation_type)
-
-def det2negative(xmldoc, opath):
-    samples = xmldoc.getElementsByTagName('sample')
-    for sample in samples:
-        detections = sample.getElementsByTagName('detections')
-        detections = minidom.parseString(detections[0].toxml())
-        detections = detections.getElementsByTagName("_")
-        if len(detections) is not 0:
-            path = sample.getElementsByTagName("path")
-            path = path[0].firstChild.nodeValue
-            mat = cv2.imread(path)
-            mat_h, mat_w, _ = mat.shape
-
-            for detection in detections:
-                detection = detection.childNodes
-                for each in detection:
-                    rect = eval(re.sub( r"\b\s\b", ",", re.sub(r"\n", "[", each.nodeValue )) + "]")
-                    print rect
-
-                    ratio = 64.0 / rect[3]
-
-                    print rect, ratio
-                    mat = resize(mat, int(round(mat_w * ratio)), int(round(mat_h * ratio)))
-
-                    rect[0] = int(round(ratio * rect[0])) - 10
-                    rect[1] = int(round(ratio * rect[1])) - 10
-                    rect[2] = rect[0] + 32 + 20
-                    rect[3] = rect[1] + 64 + 20
-                    try:
-                        cropped = mat[rect[1]:(rect[3]), rect[0]:(rect[2]), :]
-                        img = os.path.join(opath, ''.join(random.choice(string.lowercase) for i in range(8)) + ".png")
-                        cr_h, cr_w, _ = cropped.shape
-                        if cr_h is 84 and cr_w is 52:
-                            cv2.imwrite(img, cropped)
-                    except:
-                        pass
-
-if __name__ == "__main__":
-
-    parser = OptionParser()
-    parser.add_option("-i", "--input", dest="input", metavar="DIRECTORY", type="string",
-                       help="Path to the xml collection folder.")
-
-    parser.add_option("-d", "--output-dir", dest="output", metavar="DIRECTORY", type="string",
-                       help="Path to store data", default=".")
-
-    (options, args) = parser.parse_args()
-
-    if not options.input:
-        parser.error("Input folder is required.")
-
-    opath = os.path.join(options.output, datetime.now().strftime("negatives" + "-%Y-%m-%d-%H-%M-%S"))
-    os.mkdir(opath)
-
-    gl = glob.iglob( os.path.join(options.input, "set[0][0]_V0[0][5].seq.xml"))
-    for f in gl:
-        print f
-        xmldoc = minidom.parse(f)
-        det2negative(xmldoc, opath)
diff --git a/modules/softcascade/misc/roc_caltech.py b/modules/softcascade/misc/roc_caltech.py
deleted file mode 100755 (executable)
index c949823..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/env python
-
-import argparse
-import sft
-
-import sys, os, os.path, glob, math, cv2, re
-from datetime import datetime
-import numpy
-
-if __name__ == "__main__":
-    path = "/home/kellan/datasets/caltech/set00/V000.txt"
-    # open annotation file
-    f = open(path)
-    annotations = sft.parse_caltech(f)
-
-    for each in annotations:
-        print each
diff --git a/modules/softcascade/misc/roc_test.py b/modules/softcascade/misc/roc_test.py
deleted file mode 100755 (executable)
index 30361f2..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/usr/bin/env python
-
-import argparse
-import sft
-
-import sys, os, os.path, glob, math, cv2
-from datetime import datetime
-import numpy
-
-plot_colors = ['b', 'c', 'r', 'g', 'm']
-
-#       "key"   : (  b,   g,   r)
-bgr = { "red"   : (  0,   0, 255),
-        "green" : (  0, 255,   0),
-        "blue"  : (255,   0 ,  0)}
-
-def range(s):
-    try:
-        lb, rb = map(int, s.split(','))
-        return lb, rb
-    except:
-        raise argparse.ArgumentTypeError("Must be lb, rb")
-
-def call_parser(f, a):
-    return eval( "sft.parse_" + f + "('" + a + "')")
-
-if __name__ == "__main__":
-    parser = argparse.ArgumentParser(description = 'Plot ROC curve using Caltech method of per image detection performance estimation.')
-
-    # positional
-    parser.add_argument("cascade",     help = "Path to the tested detector.",  nargs='+')
-    parser.add_argument("input",       help = "Image sequence pattern.")
-    parser.add_argument("annotations", help = "Path to the annotations.")
-
-    # optional
-    parser.add_argument("-m", "--min_scale", dest = "min_scale", type = float, metavar= "fl",   help = "Minimum scale to be tested.",               default = 0.4)
-    parser.add_argument("-M", "--max_scale", dest = "max_scale", type = float, metavar= "fl",   help = "Maximum scale to be tested.",               default = 5.0)
-    parser.add_argument("-o", "--output",    dest = "output",    type = str,   metavar= "path", help = "Path to store resulting image.",           default = "./roc.png")
-    parser.add_argument("-n", "--nscales",   dest = "nscales",   type = int,   metavar= "n",    help = "Preferred count of scales from min to max.", default = 55)
-
-    parser.add_argument("-r", "--scale-range",          dest = "scale_range", type = range,  default = (128 * 0.4, 128 * 2.4))
-    parser.add_argument("-e", "--extended-range-ratio", dest = "ext_ratio",   type = float,  default = 1.25)
-    parser.add_argument("-t", "--title",                dest = "title",       type = str,    default = "ROC curve Bahnhof")
-
-    # required
-    parser.add_argument("-f", "--anttn-format", dest = "anttn_format", choices = ['inria', 'caltech', "idl"], help = "Annotation file for test sequence.", required = True)
-    parser.add_argument("-l", "--labels", dest = "labels" ,required=True,     help = "Plot labels for legend.",       nargs='+')
-
-    args = parser.parse_args()
-
-    print args.scale_range
-
-    print args.cascade
-    # parse annotations
-    sft.initPlot(args.title)
-    samples = call_parser(args.anttn_format, args.annotations)
-    for idx, each in enumerate(args.cascade):
-        print each
-        cascade = sft.cascade(args.min_scale, args.max_scale, args.nscales, each)
-        pattern = args.input
-        camera =  cv2.VideoCapture(pattern)
-
-        # for plotting over dataset
-        nannotated  = 0
-        nframes     = 0
-
-        confidenses = []
-        tp          = []
-        ignored     = []
-
-        while True:
-            ret, img = camera.read()
-            if not ret:
-                break;
-
-            name = pattern % (nframes,)
-            _, tail = os.path.split(name)
-
-            boxes = sft.filter_for_range(samples[tail], args.scale_range, args.ext_ratio)
-
-            nannotated = nannotated + len(boxes)
-            nframes = nframes + 1
-            rects, confs = cascade.detect(img, rois = None)
-
-            if confs is None:
-                continue
-
-            dts = sft.convert2detections(rects, confs)
-
-            confs = confs.tolist()[0]
-            confs.sort(lambda x, y : -1  if (x - y) > 0 else 1)
-            confidenses = confidenses + confs
-
-            matched, skip_list = sft.match(boxes, dts)
-            tp = tp + matched
-            ignored = ignored + skip_list
-
-            print nframes, nannotated
-
-        fppi, miss_rate = sft.computeROC(confidenses, tp, nannotated, nframes, ignored)
-        sft.plotLogLog(fppi, miss_rate, plot_colors[idx])
-
-    sft.showPlot(args.output, args.labels)
diff --git a/modules/softcascade/misc/scale_caltech.py b/modules/softcascade/misc/scale_caltech.py
deleted file mode 100755 (executable)
index 07e7d06..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-#!/usr/bin/env python
-
-import sys, os, os.path, glob, math, cv2, sft
-from datetime import datetime
-from optparse import OptionParser
-import re
-import numpy as np
-
-def extractPositive(f, path, opath, octave, min_possible):
-    newobj = re.compile("^lbl=\'(\w+)\'\s+str=(\d+)\s+end=(\d+)\s+hide=0$")
-    pos    = re.compile("^pos\s=(\[[((\d+\.+\d*)|\s+|\;)]*\])$")
-    occl   = re.compile("^occl\s*=(\[[0-1|\s]*\])$")
-
-    whole_mod_w = int(64  * octave) + 2 * int(20 * octave)
-    whole_mod_h = int(128 * octave) + 2 * int(20 * octave)
-
-    goNext = 0
-    start  = 0
-    end    = 0
-
-    person_id = -1;
-
-    boxes = []
-    occls = []
-
-    for l in f:
-        m = newobj.match(l)
-        if m is not None:
-            if m.group(1) == "person":
-                goNext = 1
-                start = int(m.group(2))
-                end   = int(m.group(3))
-                person_id = person_id + 1
-                print m.group(1), person_id, start, end
-            else:
-                goNext = 0
-        else:
-            m = pos.match(l)
-            if m is not None:
-                if not goNext:
-                    continue
-                strarr = re.sub(r"\s", ", ", re.sub(r"\;\s+(?=\])", "]", re.sub(r"\;\s+(?!\])", "],[", re.sub(r"(\[)(\d)", "\\1[\\2", m.group(1)))))
-                boxes = eval(strarr)
-            else:
-                m = occl.match(l)
-                if m is not None:
-                    occls = eval(re.sub(r"\s+(?!\])", ",", m.group(1)))
-
-                    if len(boxes) > 0 and len(boxes) == len(occls):
-                        for idx, box in enumerate(boxes):
-                            if occls[idx] == 1:
-                                continue
-
-                            x = box[0]
-                            y = box[1]
-                            w = box[2]
-                            h = box[3]
-
-                            id = int(start) - 1 + idx
-                            file = os.path.join(path, "I0%04d.jpg" % id)
-
-                            if (start + id) >= end or w < 10 or h < min_possible:
-                                continue
-
-                            mat = cv2.imread(file)
-                            mat_h, mat_w, _ = mat.shape
-
-                            # let default height of person be 96.
-                            scale = h / float(96)
-                            rel_scale = scale / octave
-
-                            d_w = whole_mod_w * rel_scale
-                            d_h = whole_mod_h * rel_scale
-
-                            tb = (d_h - h) / 2.0
-                            lr = (d_w - w) / 2.0
-
-                            x = int(round(x - lr))
-                            y = int(round(y - tb))
-
-                            w = int(round(w + lr * 2.0))
-                            h = int(round(h + tb * 2.0))
-
-                            inner = [max(5, x), max(5, y), min(mat_w - 5, x + w), min(mat_h - 5, y + h) ]
-                            cropped = mat[inner[1]:inner[3], inner[0]:inner[2], :]
-
-                            top     = int(max(0, 0 - y))
-                            bottom  = int(max(0, y + h - mat_h))
-                            left    = int(max(0, 0 - x))
-                            right   = int(max(0, x + w - mat_w))
-
-                            if top < -d_h / 4.0 or bottom > d_h / 4.0 or left < -d_w / 4.0 or right > d_w / 4.0:
-                                continue
-
-                            cropped = cv2.copyMakeBorder(cropped, top, bottom, left, right, cv2.BORDER_REPLICATE)
-                            resized = sft.resize_sample(cropped, whole_mod_w, whole_mod_h)
-                            flipped = cv2.flip(resized, 1)
-
-                            cv2.imshow("resized", resized)
-
-                            c = cv2.waitKey(20)
-                            if c == 27:
-                                exit(0)
-
-                            fname = re.sub(r"^.*\/(set[0-1]\d)\/(V0\d\d)\.(seq)/(I\d+).jpg$", "\\1_\\2_\\4", file)
-                            fname = os.path.join(opath, fname + "_%04d." % person_id + "png")
-                            fname_fl = os.path.join(opath, fname + "_mirror_%04d." % person_id + "png")
-                            try:
-                                cv2.imwrite(fname, resized)
-                                cv2.imwrite(fname_fl, flipped)
-                            except:
-                                print "something wrong... go next."
-                                pass
-
-if __name__ == "__main__":
-    parser = OptionParser()
-    parser.add_option("-i", "--input", dest="input", metavar="DIRECTORY", type="string",
-                       help="Path to the Caltech dataset folder.")
-
-    parser.add_option("-d", "--output-dir", dest="output", metavar="DIRECTORY", type="string",
-                       help="Path to store data", default=".")
-
-    parser.add_option("-o", "--octave", dest="octave", type="float",
-                       help="Octave for a dataset to be scaled", default="0.5")
-
-    parser.add_option("-m", "--min-possible", dest="min_possible", type="int",
-                       help="Minimum possible height for positive.", default="64")
-
-    (options, args) = parser.parse_args()
-
-    if not options.input:
-        parser.error("Caltech dataset folder is required.")
-
-    opath = os.path.join(options.output, datetime.now().strftime("raw_ge64_cr_mirr_ts" + "-%Y-%m-%d-%H-%M-%S"))
-    os.mkdir(opath)
-
-    gl = glob.iglob( os.path.join(options.input, "set[0][0]/V0[0-9][0-9].txt"))
-    for each in gl:
-        path, ext = os.path.splitext(each)
-        path = path + ".seq"
-        print path
-        extractPositive(open(each), path, opath, options.octave, options.min_possible)
diff --git a/modules/softcascade/misc/scale_inria.py b/modules/softcascade/misc/scale_inria.py
deleted file mode 100755 (executable)
index ebfc6f3..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-#!/usr/bin/env python
-
-import sys, os, os.path, glob, math, cv2
-from datetime import datetime
-from optparse import OptionParser
-
-def parse(ipath, f):
-    bbs = []
-    path = None
-    for l in f:
-        box = None
-        if l.startswith("Bounding box"):
-            b = [x.strip() for x in l.split(":")[1].split("-")]
-            c = [x[1:-1].split(",") for x in b]
-            d = [int(x) for x in sum(c, [])]
-            bbs.append(d)
-
-        if l.startswith("Image filename"):
-            path = os.path.join(os.path.join(ipath, ".."), l.split('"')[-2])
-
-    return (path, bbs)
-
-def adjust(box, tb, lr):
-
-    mix = int(round(box[0] - lr))
-    miy = int(round(box[1] - tb))
-
-    max = int(round(box[2] + lr))
-    may = int(round(box[3] + tb))
-
-    return [mix, miy, max, may]
-
-if __name__ == "__main__":
-    parser = OptionParser()
-    parser.add_option("-i", "--input", dest="input", metavar="DIRECTORY", type="string",
-                       help="path to Inria train data folder")
-
-    parser.add_option("-o", "--output", dest="output", metavar="DIRECTORY", type="string",
-                       help="path to store data", default=".")
-
-    parser.add_option("-t", "--target", dest="target", type="string", help="should be train or test", default="train")
-
-    (options, args) = parser.parse_args()
-    if not options.input:
-        parser.error("Inria data folder required")
-
-    if options.target not in ["train", "test"]:
-        parser.error("dataset should contain train or test data")
-
-    octaves = [-1, 0, 1, 2]
-
-    path = os.path.join(options.output, datetime.now().strftime("rescaled-" + options.target + "-%Y-%m-%d-%H-%M-%S"))
-    os.mkdir(path)
-
-    neg_path = os.path.join(path, "neg")
-    os.mkdir(neg_path)
-
-    pos_path = os.path.join(path, "pos")
-    os.mkdir(pos_path)
-
-    print "rescaled Inria training data stored into", path, "\nprocessing",
-    for each in octaves:
-        octave = 2**each
-
-        whole_mod_w = int(64 * octave) + 2 * int(20 * octave)
-        whole_mod_h = int(128 * octave) + 2 * int(20 * octave)
-
-        cpos_path = os.path.join(pos_path, "octave_%d" % each)
-        os.mkdir(cpos_path)
-        idx = 0
-
-        gl = glob.iglob(os.path.join(options.input, "annotations/*.txt"))
-        for image, boxes in [parse(options.input, open(__p)) for __p in gl]:
-            for box in boxes:
-                height = box[3] - box[1]
-                scale = height / float(96)
-
-                mat = cv2.imread(image)
-                mat_h, mat_w, _ = mat.shape
-
-                rel_scale = scale / octave
-
-                d_w = whole_mod_w * rel_scale
-                d_h = whole_mod_h * rel_scale
-
-                top_bottom_border = (d_h - (box[3] - box[1])) / 2.0
-                left_right_border = (d_w - (box[2] - box[0])) / 2.0
-
-                box = adjust(box, top_bottom_border, left_right_border)
-                inner = [max(0, box[0]), max(0, box[1]), min(mat_w, box[2]), min(mat_h, box[3]) ]
-
-                cropped = mat[inner[1]:inner[3], inner[0]:inner[2], :]
-
-                top     = int(max(0, 0 - box[1]))
-                bottom  = int(max(0, box[3] - mat_h))
-                left    = int(max(0, 0 - box[0]))
-                right   = int(max(0, box[2] - mat_w))
-                cropped = cv2.copyMakeBorder(cropped, top, bottom, left, right, cv2.BORDER_REPLICATE)
-                resized = sft.resize_sample(cropped, whole_mod_w, whole_mod_h)
-
-                out_name = ".png"
-                if round(math.log(scale)/math.log(2)) < each:
-                    out_name = "_upscaled" + out_name
-
-                cv2.imwrite(os.path.join(cpos_path, "sample_%d" % idx + out_name), resized)
-
-                flipped = cv2.flip(resized, 1)
-                cv2.imwrite(os.path.join(cpos_path, "sample_%d" % idx + "_mirror" + out_name), flipped)
-                idx = idx + 1
-                print "." ,
-                sys.stdout.flush()
-
-        idx = 0
-        cneg_path = os.path.join(neg_path, "octave_%d" % each)
-        os.mkdir(cneg_path)
-
-        for each in [__n for __n in glob.iglob(os.path.join(options.input, "neg/*.*"))]:
-            img = cv2.imread(each)
-            min_shape = (1.5 * whole_mod_h, 1.5 * whole_mod_w)
-
-            if (img.shape[1] <= min_shape[1]) or (img.shape[0] <= min_shape[0]):
-                out_name = "negative_sample_%i_resized.png" % idx
-
-                ratio = float(img.shape[1]) / img.shape[0]
-
-                if (img.shape[1] <= min_shape[1]):
-                    resized_size = (int(min_shape[1]), int(min_shape[1] / ratio))
-
-                if (img.shape[0] <= min_shape[0]):
-                    resized_size = (int(min_shape[0] * ratio), int(min_shape[0]))
-
-                img = sft.resize_sample(img, resized_size[0], resized_size[1])
-            else:
-                out_name = "negative_sample_%i.png" % idx
-
-            cv2.imwrite(os.path.join(cneg_path, out_name), img)
-            idx = idx + 1
-            print "." ,
-            sys.stdout.flush()
diff --git a/modules/softcascade/misc/sft.py b/modules/softcascade/misc/sft.py
deleted file mode 100644 (file)
index 6c82d71..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-#!/usr/bin/env python
-
-import cv2, re, glob
-import numpy             as np
-import matplotlib.pyplot as plt
-from itertools import izip
-
-""" Convert numPy matrices with rectangles and confidences to sorted list of detections."""
-def convert2detections(rects, confs, crop_factor = 0.125):
-    if rects is None:
-        return []
-
-    dts = zip(*[rects.tolist(), confs.tolist()])
-    dts = zip(dts[0][0], dts[0][1])
-    dts = [Detection(r,c) for r, c in dts]
-
-    dts.sort(lambda x, y : -1  if (x.conf - y.conf) > 0 else 1)
-
-    for dt in dts:
-        dt.crop(crop_factor)
-
-    return dts
-
-""" Create new instance of soft cascade."""
-def cascade(min_scale, max_scale, nscales, f):
-    # where we use nms cv::SoftCascadeDetector::DOLLAR == 2
-    c = cv2.softcascade_Detector(min_scale, max_scale, nscales, 2)
-    xml = cv2.FileStorage(f, 0)
-    dom = xml.getFirstTopLevelNode()
-    assert c.load(dom)
-    return c
-
-""" Compute prefix sum for en array."""
-def cumsum(n):
-    cum = []
-    y = 0
-    for i in n:
-        y += i
-        cum.append(y)
-    return cum
-
-""" Compute x and y arrays for ROC plot."""
-def computeROC(confidenses, tp, nannotated, nframes, ignored):
-    confidenses, tp, ignored = zip(*sorted(zip(confidenses, tp, ignored), reverse = True))
-
-    fp = [(1 - x) for x in tp]
-    fp = [(x - y) for x, y in izip(fp, ignored)]
-
-    fp = cumsum(fp)
-    tp = cumsum(tp)
-    miss_rate = [(1 - x / (nannotated + 0.000001)) for x in tp]
-    fppi = [x / float(nframes) for x in fp]
-
-    return fppi, miss_rate
-
-""" Crop rectangle by factor."""
-def crop_rect(rect, factor):
-    val_x = factor * float(rect[2])
-    val_y = factor * float(rect[3])
-    x = [int(rect[0] + val_x), int(rect[1] + val_y), int(rect[2] - 2.0 * val_x), int(rect[3] - 2.0 * val_y)]
-    return x
-
-""" Initialize plot axises."""
-def initPlot(name):
-    plt.xlabel("fppi")
-    plt.ylabel("miss rate")
-    plt.title(name)
-    plt.grid(True)
-    plt.xscale('log')
-    plt.yscale('log')
-
-""" Draw plot."""
-def plotLogLog(fppi, miss_rate, c):
-    plt.loglog(fppi, miss_rate, color = c, linewidth = 2)
-
-""" Show resulted plot."""
-def showPlot(file_name, labels):
-    plt.axis((pow(10, -3), pow(10, 1), .035, 1))
-    plt.yticks( [0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.64, 0.8, 1], ['.05', '.10', '.20', '.30', '.40', '.50', '.64', '.80', '1'] )
-    plt.legend(labels, loc = "lower left")
-    plt.savefig(file_name)
-    plt.show()
-
-""" Filter true positives and ignored detections for cascade detector output."""
-def match(gts, dts):
-    matches_gt     = [0]*len(gts)
-    matches_dt     = [0]*len(dts)
-    matches_ignore = [0]*len(dts)
-
-    if len(gts) == 0:
-        return matches_dt, matches_ignore
-
-    # Cartesian product for each detection BB_dt with each BB_gt
-    overlaps = [[dt.overlap(gt) for gt in gts]for dt in dts]
-
-    for idx, row in enumerate(overlaps):
-        imax = row.index(max(row))
-
-        # try to match ground truth
-        if (matches_gt[imax] == 0 and row[imax] > 0.5):
-            matches_gt[imax] = 1
-            matches_dt[idx]  = 1
-
-    for idx, dt in enumerate(dts):
-        # try to math ignored
-        if matches_dt[idx] == 0:
-            row = gts
-            row = [i for i in row if (i[3] - i[1]) < 53 or (i[3] - i[1]) >  256]
-            for each in row:
-                if dts[idx].overlapIgnored(each) > 0.5:
-                    matches_ignore[idx] = 1
-    return matches_dt, matches_ignore
-
-
-""" Draw detections or ground truth on image."""
-def draw_rects(img, rects, color, l = lambda x, y : x + y):
-    if rects is not None:
-        for x1, y1, x2, y2 in rects:
-            cv2.rectangle(img, (x1, y1), (l(x1, x2), l(y1, y2)), color, 2)
-
-
-def draw_dt(img, dts, color, l = lambda x, y : x + y):
-    if dts is not None:
-        for dt in dts:
-            bb = dt.bb
-            x1, y1, x2, y2 = dt.bb[0], dt.bb[1], dt.bb[2], dt.bb[3]
-
-            cv2.rectangle(img, (x1, y1), (l(x1, x2), l(y1, y2)), color, 2)
-
-class Detection:
-    def __init__(self, bb, conf):
-        self.bb = bb
-        self.conf = conf
-        self.matched = False
-
-    def crop(self, factor):
-        self.bb = crop_rect(self.bb, factor)
-
-    # we use rect-style for dt and box style for gt. ToDo: fix it
-    def overlap(self, b):
-
-        a = self.bb
-        w = min( a[0] + a[2], b[2]) - max(a[0], b[0]);
-        h = min( a[1] + a[3], b[3]) - max(a[1], b[1]);
-
-        cross_area = 0.0 if (w < 0 or h < 0) else float(w * h)
-        union_area = (a[2] * a[3]) + ((b[2] - b[0]) * (b[3] - b[1])) - cross_area;
-
-        return cross_area / union_area
-
-        # we use rect-style for dt and box style for gt. ToDo: fix it
-    def overlapIgnored(self, b):
-
-        a = self.bb
-        w = min( a[0] + a[2], b[2]) - max(a[0], b[0]);
-        h = min( a[1] + a[3], b[3]) - max(a[1], b[1]);
-
-        cross_area = 0.0 if (w < 0 or h < 0) else float(w * h)
-        self_area = (a[2] * a[3]);
-
-        return cross_area / self_area
-
-    def mark_matched(self):
-        self.matched = True
-
-"""Parse INPIA annotation format"""
-def parse_inria(ipath, f):
-    bbs = []
-    path = None
-    for l in f:
-        box = None
-        if l.startswith("Bounding box"):
-            b = [x.strip() for x in l.split(":")[1].split("-")]
-            c = [x[1:-1].split(",") for x in b]
-            d = [int(x) for x in sum(c, [])]
-            bbs.append(d)
-
-        if l.startswith("Image filename"):
-            path = l.split('"')[-2]
-
-    return Sample(path, bbs)
-
-
-def glob_set(pattern):
-    return [__n for __n in glob.iglob(pattern)]
-
-""" Parse ETH idl file. """
-def parse_idl(f):
-    map = {}
-    for l in open(f):
-        l = re.sub(r"^\"left\/", "{\"", l)
-        l = re.sub(r"\:", ":[", l)
-        l = re.sub(r"(\;|\.)$", "]}", l)
-        map.update(eval(l))
-    return map
-
-""" Normalize detection box to unified aspect ration."""
-def norm_box(box, ratio):
-    middle = float(box[0] + box[2]) / 2.0
-    new_half_width = float(box[3] - box[1]) * ratio / 2.0
-    return (int(round(middle - new_half_width)), box[1], int(round(middle + new_half_width)), box[3])
-
-""" Process array of boxes."""
-def norm_acpect_ratio(boxes, ratio):
-    return [ norm_box(box, ratio)  for box in boxes]
-
-""" Filter detections out of extended range. """
-def filter_for_range(boxes, scale_range, ext_ratio):
-    boxes = norm_acpect_ratio(boxes, 0.5)
-    boxes = [b for b in boxes if (b[3] - b[1]) > scale_range[0] / ext_ratio]
-    boxes = [b for b in boxes if (b[3] - b[1]) < scale_range[1] * ext_ratio]
-    return boxes
-
-""" Resize sample for training."""
-def resize_sample(image, d_w, d_h):
-    h, w, _ = image.shape
-    if (d_h < h) or (d_w < w):
-        ratio = min(d_h / float(h), d_w / float(w))
-
-        kernel_size = int( 5 / (2 * ratio))
-        sigma = 0.5 / ratio
-        image_to_resize = cv2.filter2D(image, cv2.CV_8UC3, cv2.getGaussianKernel(kernel_size, sigma))
-        interpolation_type = cv2.INTER_AREA
-    else:
-        image_to_resize = image
-        interpolation_type = cv2.INTER_CUBIC
-
-    return cv2.resize(image_to_resize,(d_w, d_h), None, 0, 0, interpolation_type)
-
-newobj = re.compile("^lbl=\'(\w+)\'\s+str=(\d+)\s+end=(\d+)\s+hide=0$")
-
-class caltech:
-    @staticmethod
-    def extract_objects(f):
-        objects = []
-        tmp = []
-        for l in f:
-            if newobj.match(l) is not None:
-                objects.append(tmp)
-                tmp = []
-            tmp.append(l)
-        return objects[1:]
-
-    @staticmethod
-    def parse_header(f):
-        _    = f.readline() # skip first line (version string)
-        head = f.readline()
-        (nFrame, nSample) = re.search(r'nFrame=(\d+) n=(\d+)', head).groups()
-        return (int(nFrame), int(nSample))
-
-    @staticmethod
-    def parse_pos(l):
-        pos = re.match(r'^posv?\s*=(\[[\d\s\.\;]+\])$', l).group(1)
-        pos = re.sub(r"(\[)(\d)", "\\1[\\2", pos)
-        pos = re.sub(r"\s", ", ", re.sub(r"\;\s+(?=\])", "]", re.sub(r"\;\s+(?!\])", "],[", pos)))
-        return eval(pos)
-
-    @staticmethod
-    def parse_occl(l):
-        occl = re.match(r'^occl\s*=(\[[\d\s\.\;]+\])$', l).group(1)
-        occl = re.sub(r"\s(?!\])", ",", occl)
-        return eval(occl)
-
-def parse_caltech(f):
-    (nFrame, nSample) = caltech.parse_header(f)
-    objects = caltech.extract_objects(f)
-
-    annotations = [[] for i in range(nFrame)]
-    for obj in objects:
-        (type, start, end) = re.search(r'^lbl=\'(\w+)\'\s+str=(\d+)\s+end=(\d+)\s+hide=0$', obj[0]).groups()
-        print type, start, end
-        start = int(start) -1
-        end   = int(end)
-        pos   = caltech.parse_pos(obj[1])
-        posv  = caltech.parse_pos(obj[2])
-        occl  = caltech.parse_occl(obj[3])
-
-        for idx, (p, pv, oc) in enumerate(zip(*[pos, posv, occl])):
-            annotations[start + idx].append((type, p, oc, pv))
-
-    return annotations
diff --git a/modules/softcascade/perf/perf_cuda_softcascade.cpp b/modules/softcascade/perf/perf_cuda_softcascade.cpp
deleted file mode 100644 (file)
index a5a12f7..0000000
+++ /dev/null
@@ -1,236 +0,0 @@
-#include "perf_precomp.hpp"
-
-using std::tr1::get;
-
-#define SC_PERF_TEST_P(fixture, name, params)  \
-    class fixture##_##name : public fixture {\
-     public:\
-      fixture##_##name() {}\
-     protected:\
-        virtual void __cpu();\
-        virtual void __gpu();\
-      virtual void PerfTestBody();\
-    };\
-    TEST_P(fixture##_##name, name /*perf*/){ RunPerfTestBody(); }\
-    INSTANTIATE_TEST_CASE_P(/*none*/, fixture##_##name, params);\
-    void fixture##_##name::PerfTestBody() { if (PERF_RUN_CUDA()) __gpu(); else __cpu(); }
-
-#define RUN_CPU(fixture, name)\
-    void fixture##_##name::__cpu()
-
-#define RUN_CUDA(fixture, name)\
-    void fixture##_##name::__gpu()
-
-#define NO_CPU(fixture, name)\
-void fixture##_##name::__cpu() { FAIL() << "No such CPU implementation analogy";}
-
-namespace {
-    struct DetectionLess
-    {
-        bool operator()(const cv::softcascade::Detection& a,
-            const cv::softcascade::Detection& b) const
-        {
-            if (a.x != b.x)      return a.x < b.x;
-            else if (a.y != b.y) return a.y < b.y;
-            else if (a.w != b.w) return a.w < b.w;
-            else return a.h < b.h;
-        }
-    };
-
-    cv::Mat sortDetections(cv::cuda::GpuMat& objects)
-    {
-        cv::Mat detections(objects);
-
-        typedef cv::softcascade::Detection Detection;
-        Detection* begin = (Detection*)(detections.ptr<char>(0));
-        Detection* end = (Detection*)(detections.ptr<char>(0) + detections.cols);
-        std::sort(begin, end, DetectionLess());
-
-        return detections;
-    }
-}
-
-
-typedef std::tr1::tuple<std::string, std::string> fixture_t;
-typedef perf::TestBaseWithParam<fixture_t> SCascadeTest;
-
-SC_PERF_TEST_P(SCascadeTest, detect,
-    testing::Combine(
-        testing::Values(std::string("cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml"),
-                        std::string("cv/cascadeandhog/cascades/sc_cvpr_2012_to_opencv_new_format.xml")),
-        testing::Values(std::string("cv/cascadeandhog/images/image_00000000_0.png"))))
-
-RUN_CUDA(SCascadeTest, detect)
-{
-    cv::Mat cpu = cv::imread(getDataPath(get<1>(GetParam())));;
-    ASSERT_FALSE(cpu.empty());
-    cv::cuda::GpuMat colored(cpu);
-
-    cv::softcascade::SCascade cascade;
-
-    cv::FileStorage fs(getDataPath(get<0>(GetParam())), cv::FileStorage::READ);
-    ASSERT_TRUE(fs.isOpened());
-
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-
-    cv::cuda::GpuMat objectBoxes(1, 10000 * sizeof(cv::softcascade::Detection), CV_8UC1), rois(colored.size(), CV_8UC1);
-    rois.setTo(1);
-
-    cascade.detect(colored, rois, objectBoxes);
-
-    TEST_CYCLE()
-    {
-        cascade.detect(colored, rois, objectBoxes);
-    }
-
-    SANITY_CHECK(sortDetections(objectBoxes));
-}
-
-NO_CPU(SCascadeTest, detect)
-
-static cv::Rect getFromTable(int idx)
-{
-    static const cv::Rect rois[] =
-    {
-        cv::Rect( 65 * 4,  20 * 4,  35 * 4, 80 * 4),
-        cv::Rect( 95 * 4,  35 * 4,  45 * 4, 40 * 4),
-        cv::Rect( 45 * 4,  35 * 4,  45 * 4, 40 * 4),
-        cv::Rect( 25 * 4,  27 * 4,  50 * 4, 45 * 4),
-        cv::Rect(100 * 4,  50 * 4,  45 * 4, 40 * 4),
-
-        cv::Rect( 60 * 4,  30 * 4,  45 * 4, 40 * 4),
-        cv::Rect( 40 * 4,  55 * 4,  50 * 4, 40 * 4),
-        cv::Rect( 48 * 4,  37 * 4,  72 * 4, 80 * 4),
-        cv::Rect( 48 * 4,  32 * 4,  85 * 4, 58 * 4),
-        cv::Rect( 48 * 4,   0 * 4,  32 * 4, 27 * 4)
-    };
-
-    return rois[idx];
-}
-
-typedef std::tr1::tuple<std::string, std::string, int> roi_fixture_t;
-typedef perf::TestBaseWithParam<roi_fixture_t> SCascadeTestRoi;
-
-SC_PERF_TEST_P(SCascadeTestRoi, detectInRoi,
-    testing::Combine(
-        testing::Values(std::string("cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml"),
-                        std::string("cv/cascadeandhog/cascades/sc_cvpr_2012_to_opencv_new_format.xml")),
-        testing::Values(std::string("cv/cascadeandhog/images/image_00000000_0.png")),
-        testing::Range(0, 5)))
-
-RUN_CUDA(SCascadeTestRoi, detectInRoi)
-{
-    cv::Mat cpu = cv::imread(getDataPath(get<1>(GetParam())));
-    ASSERT_FALSE(cpu.empty());
-    cv::cuda::GpuMat colored(cpu);
-
-    cv::softcascade::SCascade cascade;
-
-    cv::FileStorage fs(getDataPath(get<0>(GetParam())), cv::FileStorage::READ);
-    ASSERT_TRUE(fs.isOpened());
-
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-
-    cv::cuda::GpuMat objectBoxes(1, 16384 * 20, CV_8UC1), rois(colored.size(), CV_8UC1);
-    rois.setTo(0);
-
-    int nroi = get<2>(GetParam());
-    cv::RNG rng;
-    for (int i = 0; i < nroi; ++i)
-    {
-        cv::Rect r = getFromTable(rng(10));
-        cv::cuda::GpuMat sub(rois, r);
-        sub.setTo(1);
-    }
-
-    cascade.detect(colored, rois, objectBoxes);
-
-    TEST_CYCLE()
-    {
-        cascade.detect(colored, rois, objectBoxes);
-    }
-
-    SANITY_CHECK(sortDetections(objectBoxes));
-}
-
-NO_CPU(SCascadeTestRoi, detectInRoi)
-
-
-SC_PERF_TEST_P(SCascadeTestRoi, detectEachRoi,
-    testing::Combine(
-        testing::Values(std::string("cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml"),
-                        std::string("cv/cascadeandhog/cascades/sc_cvpr_2012_to_opencv_new_format.xml")),
-        testing::Values(std::string("cv/cascadeandhog/images/image_00000000_0.png")),
-        testing::Range(0, 10)))
-
-RUN_CUDA(SCascadeTestRoi, detectEachRoi)
-{
-    cv::Mat cpu = cv::imread(getDataPath(get<1>(GetParam())));
-    ASSERT_FALSE(cpu.empty());
-    cv::cuda::GpuMat colored(cpu);
-
-    cv::softcascade::SCascade cascade;
-
-    cv::FileStorage fs(getDataPath(get<0>(GetParam())), cv::FileStorage::READ);
-    ASSERT_TRUE(fs.isOpened());
-
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-
-    cv::cuda::GpuMat objectBoxes(1, 16384 * 20, CV_8UC1), rois(colored.size(), CV_8UC1);
-    rois.setTo(0);
-
-    int idx = get<2>(GetParam());
-    cv::Rect r = getFromTable(idx);
-    cv::cuda::GpuMat sub(rois, r);
-    sub.setTo(1);
-
-    cascade.detect(colored, rois, objectBoxes);
-
-    TEST_CYCLE()
-    {
-        cascade.detect(colored, rois, objectBoxes);
-    }
-
-    SANITY_CHECK(sortDetections(objectBoxes));
-}
-
-NO_CPU(SCascadeTestRoi, detectEachRoi)
-
-SC_PERF_TEST_P(SCascadeTest, detectStream,
-    testing::Combine(
-        testing::Values(std::string("cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml"),
-                        std::string("cv/cascadeandhog/cascades/sc_cvpr_2012_to_opencv_new_format.xml")),
-        testing::Values(std::string("cv/cascadeandhog/images/image_00000000_0.png"))))
-
-RUN_CUDA(SCascadeTest, detectStream)
-{
-    cv::Mat cpu = cv::imread(getDataPath(get<1>(GetParam())));
-    ASSERT_FALSE(cpu.empty());
-    cv::cuda::GpuMat colored(cpu);
-
-    cv::softcascade::SCascade cascade;
-
-    cv::FileStorage fs(getDataPath(get<0>(GetParam())), cv::FileStorage::READ);
-    ASSERT_TRUE(fs.isOpened());
-
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-
-    cv::cuda::GpuMat objectBoxes(1, 10000 * sizeof(cv::softcascade::Detection), CV_8UC1), rois(colored.size(), CV_8UC1);
-    rois.setTo(1);
-
-    cv::cuda::Stream s;
-
-    cascade.detect(colored, rois, objectBoxes, s);
-
-    TEST_CYCLE()
-    {
-        cascade.detect(colored, rois, objectBoxes, s);
-    }
-
-    s.waitForCompletion();
-    SANITY_CHECK(sortDetections(objectBoxes));
-}
-
-NO_CPU(SCascadeTest, detectStream)
-
-#undef SC_PERF_TEST_P
diff --git a/modules/softcascade/perf/perf_main.cpp b/modules/softcascade/perf/perf_main.cpp
deleted file mode 100644 (file)
index 7a259b2..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "perf_precomp.hpp"
-#include "opencv2/ts/cuda_perf.hpp"
-
-static const char * impls[] = {
-#ifdef HAVE_CUDA
-    "cuda",
-#endif
-    "plain"
-};
-
-CV_PERF_TEST_MAIN_WITH_IMPLS(softcascade, impls, perf::printCudaInfo())
diff --git a/modules/softcascade/perf/perf_precomp.hpp b/modules/softcascade/perf/perf_precomp.hpp
deleted file mode 100644 (file)
index 667e30a..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifdef __GNUC__
-#  pragma GCC diagnostic ignored "-Wmissing-declarations"
-#  if defined __clang__ || defined __APPLE__
-#    pragma GCC diagnostic ignored "-Wmissing-prototypes"
-#    pragma GCC diagnostic ignored "-Wextra"
-#  endif
-#endif
-
-#ifndef __OPENCV_PERF_PRECOMP_HPP__
-#define __OPENCV_PERF_PRECOMP_HPP__
-
-# include "opencv2/ts.hpp"
-# include "opencv2/softcascade.hpp"
-# include "opencv2/highgui.hpp"
-
-#ifdef GTEST_CREATE_SHARED_LIBRARY
-# error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
-#endif
-
-#endif
diff --git a/modules/softcascade/perf/perf_softcascade.cpp b/modules/softcascade/perf/perf_softcascade.cpp
deleted file mode 100644 (file)
index 8165bd9..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "perf_precomp.hpp"
-#include <opencv2/imgproc.hpp>
-
-using cv::Rect;
-using std::tr1::get;
-
-
-using namespace cv::softcascade;
-
-typedef std::tr1::tuple<std::string, std::string> fixture;
-typedef perf::TestBaseWithParam<fixture> detect;
-
-
-namespace {
-
-void extractRacts(std::vector<Detection> objectBoxes, std::vector<Rect>& rects)
-{
-    rects.clear();
-    for (int i = 0; i < (int)objectBoxes.size(); ++i)
-        rects.push_back(objectBoxes[i].bb());
-}
-
-}
-
-PERF_TEST_P(detect, SoftCascadeDetector,
-    testing::Combine(testing::Values(std::string("cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml")),
-    testing::Values(std::string("cv/cascadeandhog/images/image_00000000_0.png"))))
-{
-    cv::Mat colored = cv::imread(getDataPath(get<1>(GetParam())));
-    ASSERT_FALSE(colored.empty());
-
-    Detector cascade;
-    cv::FileStorage fs(getDataPath(get<0>(GetParam())), cv::FileStorage::READ);
-    ASSERT_TRUE(fs.isOpened());
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-
-    std::vector<Detection> objectBoxes;
-    TEST_CYCLE()
-    {
-        cascade.detect(colored, cv::noArray(), objectBoxes);
-    }
-
-    std::vector<Rect> rects;
-    extractRacts(objectBoxes, rects);
-    std::sort(rects.begin(), rects.end(), perf::comparators::RectLess());
-    SANITY_CHECK(rects);
-}
diff --git a/modules/softcascade/src/cuda/channels.cu b/modules/softcascade/src/cuda/channels.cu
deleted file mode 100644 (file)
index 894b15b..0000000
+++ /dev/null
@@ -1,507 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "opencv2/core/cuda_types.hpp"
-#include "opencv2/core/cuda/common.hpp"
-
-namespace cv { namespace softcascade { namespace cudev
-{
-    typedef unsigned int uint;
-    typedef unsigned short ushort;
-
-    // Utility function to extract unsigned chars from an unsigned integer
-    __device__ uchar4 int_to_uchar4(unsigned int in)
-    {
-        uchar4 bytes;
-        bytes.x = (in & 0x000000ff) >>  0;
-        bytes.y = (in & 0x0000ff00) >>  8;
-        bytes.z = (in & 0x00ff0000) >> 16;
-        bytes.w = (in & 0xff000000) >> 24;
-        return bytes;
-    }
-
-    __global__ void shfl_integral_horizontal(const cv::cuda::PtrStep<uint4> img, cv::cuda::PtrStep<uint4> integral)
-    {
-    #if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 300)
-        __shared__ int sums[128];
-
-        const int id = threadIdx.x;
-        const int lane_id = id % warpSize;
-        const int warp_id = id / warpSize;
-
-        const uint4 data = img(blockIdx.x, id);
-
-        const uchar4 a = int_to_uchar4(data.x);
-        const uchar4 b = int_to_uchar4(data.y);
-        const uchar4 c = int_to_uchar4(data.z);
-        const uchar4 d = int_to_uchar4(data.w);
-
-        int result[16];
-
-        result[0]  =              a.x;
-        result[1]  = result[0]  + a.y;
-        result[2]  = result[1]  + a.z;
-        result[3]  = result[2]  + a.w;
-
-        result[4]  = result[3]  + b.x;
-        result[5]  = result[4]  + b.y;
-        result[6]  = result[5]  + b.z;
-        result[7]  = result[6]  + b.w;
-
-        result[8]  = result[7]  + c.x;
-        result[9]  = result[8]  + c.y;
-        result[10] = result[9]  + c.z;
-        result[11] = result[10] + c.w;
-
-        result[12] = result[11] + d.x;
-        result[13] = result[12] + d.y;
-        result[14] = result[13] + d.z;
-        result[15] = result[14] + d.w;
-
-        int sum = result[15];
-
-        // the prefix sum for each thread's 16 value is computed,
-        // now the final sums (result[15]) need to be shared
-        // with the other threads and add.  To do this,
-        // the __shfl_up() instruction is used and a shuffle scan
-        // operation is performed to distribute the sums to the correct
-        // threads
-        #pragma unroll
-        for (int i = 1; i < 32; i *= 2)
-        {
-            const int n = __shfl_up(sum, i, 32);
-
-            if (lane_id >= i)
-            {
-                #pragma unroll
-                for (int i = 0; i < 16; ++i)
-                    result[i] += n;
-
-                sum += n;
-            }
-        }
-
-        // Now the final sum for the warp must be shared
-        // between warps.  This is done by each warp
-        // having a thread store to shared memory, then
-        // having some other warp load the values and
-        // compute a prefix sum, again by using __shfl_up.
-        // The results are uniformly added back to the warps.
-        // last thread in the warp holding sum of the warp
-        // places that in shared
-        if (threadIdx.x % warpSize == warpSize - 1)
-            sums[warp_id] = result[15];
-
-        __syncthreads();
-
-        if (warp_id == 0)
-        {
-            int warp_sum = sums[lane_id];
-
-            #pragma unroll
-            for (int i = 1; i <= 32; i *= 2)
-            {
-                const int n = __shfl_up(warp_sum, i, 32);
-
-                if (lane_id >= i)
-                    warp_sum += n;
-            }
-
-            sums[lane_id] = warp_sum;
-        }
-
-        __syncthreads();
-
-        int blockSum = 0;
-
-        // fold in unused warp
-        if (warp_id > 0)
-        {
-            blockSum = sums[warp_id - 1];
-
-            #pragma unroll
-            for (int i = 0; i < 16; ++i)
-                result[i] += blockSum;
-        }
-
-        // assemble result
-        // Each thread has 16 values to write, which are
-        // now integer data (to avoid overflow).  Instead of
-        // each thread writing consecutive uint4s, the
-        // approach shown here experiments using
-        // the shuffle command to reformat the data
-        // inside the registers so that each thread holds
-        // consecutive data to be written so larger contiguous
-        // segments can be assembled for writing.
-
-        /*
-            For example data that needs to be written as
-
-            GMEM[16] <- x0 x1 x2 x3 y0 y1 y2 y3 z0 z1 z2 z3 w0 w1 w2 w3
-            but is stored in registers (r0..r3), in four threads (0..3) as:
-
-            threadId   0  1  2  3
-              r0      x0 y0 z0 w0
-              r1      x1 y1 z1 w1
-              r2      x2 y2 z2 w2
-              r3      x3 y3 z3 w3
-
-              after apply __shfl_xor operations to move data between registers r1..r3:
-
-            threadId  00 01 10 11
-                      x0 y0 z0 w0
-             xor(01)->y1 x1 w1 z1
-             xor(10)->z2 w2 x2 y2
-             xor(11)->w3 z3 y3 x3
-
-             and now x0..x3, and z0..z3 can be written out in order by all threads.
-
-             In the current code, each register above is actually representing
-             four integers to be written as uint4's to GMEM.
-        */
-
-        result[4]  = __shfl_xor(result[4] , 1, 32);
-        result[5]  = __shfl_xor(result[5] , 1, 32);
-        result[6]  = __shfl_xor(result[6] , 1, 32);
-        result[7]  = __shfl_xor(result[7] , 1, 32);
-
-        result[8]  = __shfl_xor(result[8] , 2, 32);
-        result[9]  = __shfl_xor(result[9] , 2, 32);
-        result[10] = __shfl_xor(result[10], 2, 32);
-        result[11] = __shfl_xor(result[11], 2, 32);
-
-        result[12] = __shfl_xor(result[12], 3, 32);
-        result[13] = __shfl_xor(result[13], 3, 32);
-        result[14] = __shfl_xor(result[14], 3, 32);
-        result[15] = __shfl_xor(result[15], 3, 32);
-
-        uint4* integral_row = integral.ptr(blockIdx.x);
-        uint4 output;
-
-        ///////
-
-        if (threadIdx.x % 4 == 0)
-            output = make_uint4(result[0], result[1], result[2], result[3]);
-
-        if (threadIdx.x % 4 == 1)
-            output = make_uint4(result[4], result[5], result[6], result[7]);
-
-        if (threadIdx.x % 4 == 2)
-            output = make_uint4(result[8], result[9], result[10], result[11]);
-
-        if (threadIdx.x % 4 == 3)
-            output = make_uint4(result[12], result[13], result[14], result[15]);
-
-        integral_row[threadIdx.x % 4 + (threadIdx.x / 4) * 16] = output;
-
-        ///////
-
-        if (threadIdx.x % 4 == 2)
-            output = make_uint4(result[0], result[1], result[2], result[3]);
-
-        if (threadIdx.x % 4 == 3)
-            output = make_uint4(result[4], result[5], result[6], result[7]);
-
-        if (threadIdx.x % 4 == 0)
-            output = make_uint4(result[8], result[9], result[10], result[11]);
-
-        if (threadIdx.x % 4 == 1)
-            output = make_uint4(result[12], result[13], result[14], result[15]);
-
-        integral_row[(threadIdx.x + 2) % 4 + (threadIdx.x / 4) * 16 + 8] = output;
-
-        // continuning from the above example,
-        // this use of __shfl_xor() places the y0..y3 and w0..w3 data
-        // in order.
-
-        #pragma unroll
-        for (int i = 0; i < 16; ++i)
-            result[i] = __shfl_xor(result[i], 1, 32);
-
-        if (threadIdx.x % 4 == 0)
-            output = make_uint4(result[0], result[1], result[2], result[3]);
-
-        if (threadIdx.x % 4 == 1)
-            output = make_uint4(result[4], result[5], result[6], result[7]);
-
-        if (threadIdx.x % 4 == 2)
-            output = make_uint4(result[8], result[9], result[10], result[11]);
-
-        if (threadIdx.x % 4 == 3)
-            output = make_uint4(result[12], result[13], result[14], result[15]);
-
-        integral_row[threadIdx.x % 4 + (threadIdx.x / 4) * 16 + 4] = output;
-
-        ///////
-
-        if (threadIdx.x % 4 == 2)
-            output = make_uint4(result[0], result[1], result[2], result[3]);
-
-        if (threadIdx.x % 4 == 3)
-            output = make_uint4(result[4], result[5], result[6], result[7]);
-
-        if (threadIdx.x % 4 == 0)
-            output = make_uint4(result[8], result[9], result[10], result[11]);
-
-        if (threadIdx.x % 4 == 1)
-            output = make_uint4(result[12], result[13], result[14], result[15]);
-
-        integral_row[(threadIdx.x + 2) % 4 + (threadIdx.x / 4) * 16 + 12] = output;
-    #endif
-    }
-
-    // This kernel computes columnwise prefix sums.  When the data input is
-    // the row sums from above, this completes the integral image.
-    // The approach here is to have each block compute a local set of sums.
-    // First , the data covered by the block is loaded into shared memory,
-    // then instead of performing a sum in shared memory using __syncthreads
-    // between stages, the data is reformatted so that the necessary sums
-    // occur inside warps and the shuffle scan operation is used.
-    // The final set of sums from the block is then propgated, with the block
-    // computing "down" the image and adding the running sum to the local
-    // block sums.
-    __global__ void shfl_integral_vertical(cv::cuda::PtrStepSz<unsigned int> integral)
-    {
-    #if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 300)
-        __shared__ unsigned int sums[32][9];
-
-        const int tidx = blockIdx.x * blockDim.x + threadIdx.x;
-        const int lane_id = tidx % 8;
-
-        if (tidx >= integral.cols)
-            return;
-
-        sums[threadIdx.x][threadIdx.y] = 0;
-        __syncthreads();
-
-        unsigned int stepSum = 0;
-
-        for (int y = threadIdx.y; y < integral.rows; y += blockDim.y)
-        {
-            unsigned int* p = integral.ptr(y) + tidx;
-
-            unsigned int sum = *p;
-
-            sums[threadIdx.x][threadIdx.y] = sum;
-            __syncthreads();
-
-            // place into SMEM
-            // shfl scan reduce the SMEM, reformating so the column
-            // sums are computed in a warp
-            // then read out properly
-            const int j = threadIdx.x % 8;
-            const int k = threadIdx.x / 8 + threadIdx.y * 4;
-
-            int partial_sum = sums[k][j];
-
-            for (int i = 1; i <= 8; i *= 2)
-            {
-                int n = __shfl_up(partial_sum, i, 32);
-
-                if (lane_id >= i)
-                    partial_sum += n;
-            }
-
-            sums[k][j] = partial_sum;
-            __syncthreads();
-
-            if (threadIdx.y > 0)
-                sum += sums[threadIdx.x][threadIdx.y - 1];
-
-            sum += stepSum;
-            stepSum += sums[threadIdx.x][blockDim.y - 1];
-
-            __syncthreads();
-
-            *p = sum;
-        }
-    #endif
-    }
-
-    void shfl_integral(const cv::cuda::PtrStepSzb& img, cv::cuda::PtrStepSz<unsigned int> integral, cudaStream_t stream)
-    {
-        {
-            // each thread handles 16 values, use 1 block/row
-            // save, becouse step is actually can't be less 512 bytes
-            int block = integral.cols / 16;
-
-            // launch 1 block / row
-            const int grid = img.rows;
-
-            cudaSafeCall( cudaFuncSetCacheConfig(shfl_integral_horizontal, cudaFuncCachePreferL1) );
-
-            shfl_integral_horizontal<<<grid, block, 0, stream>>>((const cv::cuda::PtrStepSz<uint4>) img, (cv::cuda::PtrStepSz<uint4>) integral);
-            cudaSafeCall( cudaGetLastError() );
-        }
-
-        {
-            const dim3 block(32, 8);
-            const dim3 grid(cv::cuda::device::divUp(integral.cols, block.x), 1);
-
-            shfl_integral_vertical<<<grid, block, 0, stream>>>(integral);
-            cudaSafeCall( cudaGetLastError() );
-        }
-
-        if (stream == 0)
-            cudaSafeCall( cudaDeviceSynchronize() );
-    }
-
-    __global__ void shfl_integral_vertical(cv::cuda::PtrStepSz<unsigned int> buffer, cv::cuda::PtrStepSz<unsigned int> integral)
-    {
-    #if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 300)
-        __shared__ unsigned int sums[32][9];
-
-        const int tidx = blockIdx.x * blockDim.x + threadIdx.x;
-        const int lane_id = tidx % 8;
-
-        if (tidx >= integral.cols)
-            return;
-
-        sums[threadIdx.x][threadIdx.y] = 0;
-        __syncthreads();
-
-        unsigned int stepSum = 0;
-
-        for (int y = threadIdx.y; y < integral.rows; y += blockDim.y)
-        {
-            unsigned int* p = buffer.ptr(y) + tidx;
-            unsigned int* dst = integral.ptr(y + 1) + tidx + 1;
-
-            unsigned int sum = *p;
-
-            sums[threadIdx.x][threadIdx.y] = sum;
-            __syncthreads();
-
-            // place into SMEM
-            // shfl scan reduce the SMEM, reformating so the column
-            // sums are computed in a warp
-            // then read out properly
-            const int j = threadIdx.x % 8;
-            const int k = threadIdx.x / 8 + threadIdx.y * 4;
-
-            int partial_sum = sums[k][j];
-
-            for (int i = 1; i <= 8; i *= 2)
-            {
-                int n = __shfl_up(partial_sum, i, 32);
-
-                if (lane_id >= i)
-                    partial_sum += n;
-            }
-
-            sums[k][j] = partial_sum;
-            __syncthreads();
-
-            if (threadIdx.y > 0)
-                sum += sums[threadIdx.x][threadIdx.y - 1];
-
-            sum += stepSum;
-            stepSum += sums[threadIdx.x][blockDim.y - 1];
-
-            __syncthreads();
-
-            *dst = sum;
-        }
-    #endif
-    }
-
-    // used for frame preprocessing before Soft Cascade evaluation: no synchronization needed
-    void shfl_integral_gpu_buffered(cv::cuda::PtrStepSzb img, cv::cuda::PtrStepSz<uint4> buffer, cv::cuda::PtrStepSz<unsigned int> integral,
-        int blockStep, cudaStream_t stream)
-    {
-        {
-            const int block = blockStep;
-            const int grid = img.rows;
-
-            cudaSafeCall( cudaFuncSetCacheConfig(shfl_integral_horizontal, cudaFuncCachePreferL1) );
-
-            shfl_integral_horizontal<<<grid, block, 0, stream>>>((cv::cuda::PtrStepSz<uint4>) img, buffer);
-            cudaSafeCall( cudaGetLastError() );
-        }
-
-        {
-            const dim3 block(32, 8);
-            const dim3 grid(cv::cuda::device::divUp(integral.cols, block.x), 1);
-
-            shfl_integral_vertical<<<grid, block, 0, stream>>>((cv::cuda::PtrStepSz<unsigned int>)buffer, integral);
-            cudaSafeCall( cudaGetLastError() );
-        }
-    }
-    // 0
-#define CV_DESCALE(x, n) (((x) + (1 << ((n)-1))) >> (n))
-
-    enum
-    {
-        yuv_shift  = 14,
-        xyz_shift  = 12,
-        R2Y        = 4899,
-        G2Y        = 9617,
-        B2Y        = 1868
-    };
-
-    template <int bidx> static __device__ __forceinline__ unsigned char RGB2GrayConvert(unsigned char b, unsigned char g, unsigned char r)
-    {
-        // uint b = 0xffu & (src >> (bidx * 8));
-        // uint g = 0xffu & (src >> 8);
-        // uint r = 0xffu & (src >> ((bidx ^ 2) * 8));
-        return CV_DESCALE((unsigned int)(b * B2Y + g * G2Y + r * R2Y), yuv_shift);
-    }
-
-    __global__ void device_transform(const cv::cuda::PtrStepSz<uchar3> bgr, cv::cuda::PtrStepSzb gray)
-    {
-        const int y = blockIdx.y * blockDim.y + threadIdx.y;
-        const int x = blockIdx.x * blockDim.x + threadIdx.x;
-
-        const uchar3 colored = (uchar3)(bgr.ptr(y))[x];
-
-        gray.ptr(y)[x] = RGB2GrayConvert<0>(colored.x, colored.y, colored.z);
-    }
-
-    ///////
-    void transform(const cv::cuda::PtrStepSz<uchar3>& bgr, cv::cuda::PtrStepSzb gray)
-    {
-        const dim3 block(32, 8);
-        const dim3 grid(cv::cuda::device::divUp(bgr.cols, block.x), cv::cuda::device::divUp(bgr.rows, block.y));
-        device_transform<<<grid, block>>>(bgr, gray);
-        cudaSafeCall(cudaDeviceSynchronize());
-    }
-}}}
diff --git a/modules/softcascade/src/cuda/icf-sc.cu b/modules/softcascade/src/cuda/icf-sc.cu
deleted file mode 100644 (file)
index 8781734..0000000
+++ /dev/null
@@ -1,566 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include <cuda_invoker.hpp>
-#include <float.h>
-#include <stdio.h>
-#include "opencv2/core/cuda/common.hpp"
-
-namespace cv { namespace softcascade { namespace cudev {
-
-typedef unsigned char uchar;
-
-    template <int FACTOR>
-    __device__ __forceinline__ uchar shrink(const uchar* ptr, const int pitch, const int y, const int x)
-    {
-        int out = 0;
-#pragma unroll
-        for(int dy = 0; dy < FACTOR; ++dy)
-#pragma unroll
-            for(int dx = 0; dx < FACTOR; ++dx)
-            {
-                out += ptr[dy * pitch + dx];
-            }
-
-        return static_cast<uchar>(out / (FACTOR * FACTOR));
-    }
-
-    template<int FACTOR>
-    __global__ void shrink(const uchar* __restrict__ hogluv, const size_t inPitch,
-                                 uchar* __restrict__ shrank, const size_t outPitch )
-    {
-        const int y = blockIdx.y * blockDim.y + threadIdx.y;
-        const int x = blockIdx.x * blockDim.x + threadIdx.x;
-
-        const uchar* ptr = hogluv + (FACTOR * y) * inPitch + (FACTOR * x);
-
-        shrank[ y * outPitch + x] = shrink<FACTOR>(ptr, inPitch, y, x);
-    }
-
-    void shrink(const cv::cuda::PtrStepSzb& channels, cv::cuda::PtrStepSzb shrunk)
-    {
-        dim3 block(32, 8);
-        dim3 grid(shrunk.cols / 32, shrunk.rows / 8);
-        shrink<4><<<grid, block>>>((uchar*)channels.ptr(), channels.step, (uchar*)shrunk.ptr(), shrunk.step);
-        cudaSafeCall(cudaDeviceSynchronize());
-    }
-
-    __device__ __forceinline__ void luv(const float& b, const float& g, const float& r, uchar& __l, uchar& __u, uchar& __v)
-    {
-        // rgb -> XYZ
-        float x = 0.412453f * r + 0.357580f * g + 0.180423f * b;
-        float y = 0.212671f * r + 0.715160f * g + 0.072169f * b;
-        float z = 0.019334f * r + 0.119193f * g + 0.950227f * b;
-
-        // computed for D65
-        const float _ur = 0.19783303699678276f;
-        const float _vr = 0.46833047435252234f;
-
-        const float divisor = fmax((x + 15.f * y + 3.f * z), FLT_EPSILON);
-        const float _u = __fdividef(4.f * x, divisor);
-        const float _v = __fdividef(9.f * y, divisor);
-
-        float hack = static_cast<float>(__float2int_rn(y * 2047)) / 2047;
-        const float L = fmax(0.f, ((116.f * cbrtf(hack)) - 16.f));
-        const float U = 13.f * L * (_u - _ur);
-        const float V = 13.f * L * (_v - _vr);
-
-        // L in [0, 100], u in [-134, 220], v in [-140, 122]
-        __l = static_cast<uchar>( L * (255.f / 100.f));
-        __u = static_cast<uchar>((U + 134.f) * (255.f / (220.f + 134.f )));
-        __v = static_cast<uchar>((V + 140.f) * (255.f / (122.f + 140.f )));
-    }
-
-    __global__ void bgr2Luv_d(const uchar* rgb, const size_t rgbPitch, uchar* luvg, const size_t luvgPitch)
-    {
-        const int y = blockIdx.y * blockDim.y + threadIdx.y;
-        const int x = blockIdx.x * blockDim.x + threadIdx.x;
-
-        uchar3 color = ((uchar3*)(rgb + rgbPitch * y))[x];
-        uchar l, u, v;
-        luv(color.x / 255.f, color.y / 255.f, color.z / 255.f, l, u, v);
-
-        luvg[luvgPitch *  y + x] = l;
-        luvg[luvgPitch * (y + 480) + x] = u;
-        luvg[luvgPitch * (y + 2 * 480) + x] = v;
-    }
-
-    void bgr2Luv(const cv::cuda::PtrStepSzb& bgr, cv::cuda::PtrStepSzb luv)
-    {
-        dim3 block(32, 8);
-        dim3 grid(bgr.cols / 32, bgr.rows / 8);
-
-        bgr2Luv_d<<<grid, block>>>((const uchar*)bgr.ptr(0), bgr.step, (uchar*)luv.ptr(0), luv.step);
-
-        cudaSafeCall(cudaDeviceSynchronize());
-    }
-
-    template<bool isDefaultNum>
-    __device__ __forceinline__ int fast_angle_bin(const float& dx, const float& dy)
-    {
-        const float angle_quantum = CV_PI_F / 6.f;
-        float angle = atan2(dx, dy) + (angle_quantum / 2.f);
-
-        if (angle < 0) angle += CV_PI_F;
-
-        const float angle_scaling = 1.f / angle_quantum;
-        return static_cast<int>(angle * angle_scaling) % 6;
-    }
-
-    template<>
-    __device__ __forceinline__ int fast_angle_bin<true>(const float& dy, const float& dx)
-    {
-        int index = 0;
-
-        float max_dot = fabs(dx);
-
-        {
-            const float dot_product = fabs(dx * 0.8660254037844386f + dy * 0.5f);
-
-            if(dot_product > max_dot)
-            {
-                max_dot = dot_product;
-                index = 1;
-            }
-        }
-        {
-            const float dot_product = fabs(dy * 0.8660254037844386f + dx * 0.5f);
-
-            if(dot_product > max_dot)
-            {
-                max_dot = dot_product;
-                index = 2;
-            }
-        }
-        {
-            int i = 3;
-            float2 bin_vector_i;
-            bin_vector_i.x = ::cos(i * (CV_PI_F / 6.f));
-            bin_vector_i.y = ::sin(i * (CV_PI_F / 6.f));
-
-            const float dot_product = fabs(dx * bin_vector_i.x + dy * bin_vector_i.y);
-            if(dot_product > max_dot)
-            {
-                max_dot = dot_product;
-                index = i;
-            }
-        }
-        {
-            const float dot_product = fabs(dx * (-0.4999999999999998f) + dy * 0.8660254037844387f);
-            if(dot_product > max_dot)
-            {
-                max_dot = dot_product;
-                index = 4;
-            }
-        }
-        {
-            const float dot_product = fabs(dx * (-0.8660254037844387f) + dy * 0.49999999999999994f);
-            if(dot_product > max_dot)
-            {
-                max_dot = dot_product;
-                index = 5;
-            }
-        }
-        return index;
-    }
-
-    texture<uchar,  cudaTextureType2D, cudaReadModeElementType> tgray;
-
-    template<bool isDefaultNum>
-    __global__ void gray2hog(cv::cuda::PtrStepSzb mag)
-    {
-        const int x = blockIdx.x * blockDim.x + threadIdx.x;
-        const int y = blockIdx.y * blockDim.y + threadIdx.y;
-
-        const float dx = tex2D(tgray, x + 1, y + 0) - tex2D(tgray, x - 1, y - 0);
-        const float dy = tex2D(tgray, x + 0, y + 1) - tex2D(tgray, x - 0, y - 1);
-
-        const float magnitude = sqrtf((dx * dx) + (dy * dy)) * (1.0f / sqrtf(2));
-        const uchar cmag = static_cast<uchar>(magnitude);
-
-        mag( 480 * 6 + y, x) = cmag;
-        mag( 480 * fast_angle_bin<isDefaultNum>(dy, dx) + y, x) = cmag;
-    }
-
-    void gray2hog(const cv::cuda::PtrStepSzb& gray, cv::cuda::PtrStepSzb mag, const int bins)
-    {
-        dim3 block(32, 8);
-        dim3 grid(gray.cols / 32, gray.rows / 8);
-
-        cudaChannelFormatDesc desc = cudaCreateChannelDesc<uchar>();
-        cudaSafeCall( cudaBindTexture2D(0, tgray, gray.data, desc, gray.cols, gray.rows, gray.step) );
-
-        if (bins == 6)
-            gray2hog<true><<<grid, block>>>(mag);
-        else
-            gray2hog<false><<<grid, block>>>(mag);
-
-        cudaSafeCall(cudaDeviceSynchronize());
-    }
-
-    // ToDo: use textures or uncached load instruction.
-    __global__ void magToHist(const uchar* __restrict__ mag,
-                              const float* __restrict__ angle, const size_t angPitch,
-                                    uchar* __restrict__ hog,   const size_t hogPitch, const int fh)
-    {
-        const int y = blockIdx.y * blockDim.y + threadIdx.y;
-        const int x = blockIdx.x * blockDim.x + threadIdx.x;
-
-        const int bin = (int)(angle[y * angPitch + x]);
-        const uchar val = mag[y * hogPitch + x];
-        hog[((fh * bin) + y) * hogPitch + x] = val;
-    }
-
-    void fillBins(cv::cuda::PtrStepSzb hogluv, const cv::cuda::PtrStepSzf& nangle,
-                  const int fw,  const int fh, const int bins, cudaStream_t stream )
-    {
-        const uchar* mag = (const uchar*)hogluv.ptr(fh * bins);
-        uchar* hog = (uchar*)hogluv.ptr();
-        const float* angle = (const float*)nangle.ptr();
-
-        dim3 block(32, 8);
-        dim3 grid(fw / 32, fh / 8);
-
-        magToHist<<<grid, block, 0, stream>>>(mag, angle, nangle.step / sizeof(float), hog, hogluv.step, fh);
-        if (!stream)
-        {
-            cudaSafeCall( cudaGetLastError() );
-            cudaSafeCall( cudaDeviceSynchronize() );
-        }
-    }
-
-    __device__ __forceinline__ float overlapArea(const Detection &a, const Detection &b)
-    {
-        int w = ::min(a.x + a.w, b.x + b.w) - ::max(a.x, b.x);
-        int h = ::min(a.y + a.h, b.y + b.h) - ::max(a.y, b.y);
-
-        return (w < 0 || h < 0)? 0.f : (float)(w * h);
-    }
-
-    texture<uint4,  cudaTextureType2D, cudaReadModeElementType> tdetections;
-
-    __global__ void overlap(const uint* n, uchar* overlaps)
-    {
-        const int idx = threadIdx.x;
-        const int total = *n;
-
-        for (int i = idx + 1; i < total; i += 192)
-        {
-            const uint4 _a = tex2D(tdetections, i, 0);
-            const Detection& a = *((Detection*)(&_a));
-            bool excluded = false;
-
-            for (int j = i + 1; j < total; ++j)
-            {
-                const uint4 _b = tex2D(tdetections, j, 0);
-                const Detection& b = *((Detection*)(&_b));
-                float ovl = overlapArea(a, b) / ::min(a.w * a.h, b.w * b.h);
-
-                if (ovl > 0.65f)
-                {
-                    int suppessed = (a.confidence > b.confidence)? j : i;
-                    overlaps[suppessed] = 1;
-                    excluded = excluded || (suppessed == i);
-                }
-
-            #if defined __CUDA_ARCH__ && (__CUDA_ARCH__ >= 120)
-                if (__all(excluded)) break;
-            #endif
-            }
-        }
-    }
-
-    __global__ void collect(const uint* n, uchar* overlaps, uint* ctr, uint4* suppressed)
-    {
-        const int idx = threadIdx.x;
-        const int total = *n;
-
-        for (int i = idx; i < total; i += 192)
-        {
-            if (!overlaps[i])
-            {
-                int oidx = atomicInc(ctr, 50);
-                suppressed[oidx] = tex2D(tdetections, i + 1, 0);
-            }
-        }
-    }
-
-    void suppress(const cv::cuda::PtrStepSzb& objects, cv::cuda::PtrStepSzb overlaps, cv::cuda::PtrStepSzi ndetections,
-        cv::cuda::PtrStepSzb suppressed, cudaStream_t stream)
-    {
-        int block = 192;
-        int grid = 1;
-
-        cudaChannelFormatDesc desc = cudaCreateChannelDesc<uint4>();
-        size_t offset;
-        cudaSafeCall( cudaBindTexture2D(&offset, tdetections, objects.data, desc, objects.cols / sizeof(uint4), objects.rows, objects.step));
-
-        overlap<<<grid, block>>>((uint*)ndetections.ptr(0), (uchar*)overlaps.ptr(0));
-        collect<<<grid, block>>>((uint*)ndetections.ptr(0), (uchar*)overlaps.ptr(0), (uint*)suppressed.ptr(0), ((uint4*)suppressed.ptr(0)) + 1);
-
-        if (!stream)
-        {
-            cudaSafeCall( cudaGetLastError());
-            cudaSafeCall( cudaDeviceSynchronize());
-        }
-    }
-
-    template<typename Policy>
-    struct PrefixSum
-    {
-    __device_inline__ static void apply(float& impact)
-        {
-    #if defined __CUDA_ARCH__ && __CUDA_ARCH__ >= 300
-    #pragma unroll
-            // scan on shuffle functions
-            for (int i = 1; i < Policy::WARP; i *= 2)
-            {
-                const float n = __shfl_up(impact, i, Policy::WARP);
-
-                if (threadIdx.x >= i)
-                    impact += n;
-            }
-    #else
-            __shared__ volatile float ptr[Policy::STA_X * Policy::STA_Y];
-
-            const int idx = threadIdx.y * Policy::STA_X + threadIdx.x;
-
-            ptr[idx] = impact;
-
-            if ( threadIdx.x >=  1) ptr [idx ] = (ptr [idx -  1] + ptr [idx]);
-            if ( threadIdx.x >=  2) ptr [idx ] = (ptr [idx -  2] + ptr [idx]);
-            if ( threadIdx.x >=  4) ptr [idx ] = (ptr [idx -  4] + ptr [idx]);
-            if ( threadIdx.x >=  8) ptr [idx ] = (ptr [idx -  8] + ptr [idx]);
-            if ( threadIdx.x >= 16) ptr [idx ] = (ptr [idx - 16] + ptr [idx]);
-
-            impact = ptr[idx];
-    #endif
-        }
-    };
-
-    texture<int,  cudaTextureType2D, cudaReadModeElementType> thogluv;
-
-    template<bool isUp>
-    __device__ __forceinline__ float rescale(const Level& level, Node& node)
-    {
-        uchar4& scaledRect = node.rect;
-        float relScale = level.relScale;
-        float farea = (scaledRect.z - scaledRect.x) * (scaledRect.w - scaledRect.y);
-
-        // rescale
-        scaledRect.x = __float2int_rn(relScale * scaledRect.x);
-        scaledRect.y = __float2int_rn(relScale * scaledRect.y);
-        scaledRect.z = __float2int_rn(relScale * scaledRect.z);
-        scaledRect.w = __float2int_rn(relScale * scaledRect.w);
-
-        float sarea = (scaledRect.z - scaledRect.x) * (scaledRect.w - scaledRect.y);
-
-        const float expected_new_area = farea * relScale * relScale;
-        float approx = (sarea == 0)? 1: __fdividef(sarea, expected_new_area);
-
-        float rootThreshold = (node.threshold & 0x0FFFFFFFU) * approx * level.scaling[(node.threshold >> 28) > 6];
-
-        return rootThreshold;
-    }
-
-    template<>
-    __device__ __forceinline__ float rescale<true>(const Level& level, Node& node)
-    {
-        uchar4& scaledRect = node.rect;
-        float relScale = level.relScale;
-        float farea = scaledRect.z * scaledRect.w;
-
-        // rescale
-        scaledRect.x = __float2int_rn(relScale * scaledRect.x);
-        scaledRect.y = __float2int_rn(relScale * scaledRect.y);
-        scaledRect.z = __float2int_rn(relScale * scaledRect.z);
-        scaledRect.w = __float2int_rn(relScale * scaledRect.w);
-
-        float sarea = scaledRect.z * scaledRect.w;
-
-        const float expected_new_area = farea * relScale * relScale;
-        float approx = __fdividef(sarea, expected_new_area);
-
-        float rootThreshold = (node.threshold & 0x0FFFFFFFU) * approx * level.scaling[(node.threshold >> 28) > 6];
-
-        return rootThreshold;
-    }
-
-    template<bool isUp>
-    __device__ __forceinline__ int get(int x, int y, uchar4 area)
-    {
-        int a = tex2D(thogluv, x + area.x, y + area.y);
-        int b = tex2D(thogluv, x + area.z, y + area.y);
-        int c = tex2D(thogluv, x + area.z, y + area.w);
-        int d = tex2D(thogluv, x + area.x, y + area.w);
-
-        return (a - b + c - d);
-    }
-
-    template<>
-    __device__ __forceinline__ int get<true>(int x, int y, uchar4 area)
-    {
-        x += area.x;
-        y += area.y;
-
-        int a = tex2D(thogluv, x, y);
-        int b = tex2D(thogluv, x + area.z, y);
-        int c = tex2D(thogluv, x + area.z, y + area.w);
-        int d = tex2D(thogluv, x, y + area.w);
-
-        return (a - b + c - d);
-    }
-
-    texture<float2,  cudaTextureType2D, cudaReadModeElementType> troi;
-
-template<typename Policy>
-template<bool isUp>
-__device_inline__ void CascadeInvoker<Policy>::detect(Detection* objects, const uint ndetections, uint* ctr, const int downscales) const
-{
-    const int y = blockIdx.y * blockDim.y + threadIdx.y;
-    const int x = blockIdx.x;
-
-    // load Level
-    __shared__ Level level;
-
-    // check POI
-    __shared__ volatile char roiCache[Policy::STA_Y];
-
-    if (!threadIdx.y && !threadIdx.x)
-        ((float2*)roiCache)[threadIdx.x] = tex2D(troi, blockIdx.y, x);
-
-    __syncthreads();
-
-    if (!roiCache[threadIdx.y]) return;
-
-    if (!threadIdx.x)
-        level = levels[downscales + blockIdx.z];
-
-    if(x >= level.workRect.x || y >= level.workRect.y) return;
-
-    int st = level.octave * level.step;
-    const int stEnd = st + level.step;
-
-    const int hogluvStep = gridDim.y * Policy::STA_Y;
-    float confidence = 0.f;
-    for(; st < stEnd; st += Policy::WARP)
-    {
-        const int nId = (st + threadIdx.x) * 3;
-
-        Node node = nodes[nId];
-
-        float threshold = rescale<isUp>(level, node);
-        int sum = get<isUp>(x, y + (node.threshold >> 28) * hogluvStep, node.rect);
-
-        int next = 1 + (int)(sum >= threshold);
-
-        node = nodes[nId + next];
-        threshold = rescale<isUp>(level, node);
-        sum = get<isUp>(x, y + (node.threshold >> 28) * hogluvStep, node.rect);
-
-        const int lShift = (next - 1) * 2 + (int)(sum >= threshold);
-        float impact = leaves[(st + threadIdx.x) * 4 + lShift];
-
-        PrefixSum<Policy>::apply(impact);
-
-    #if __CUDA_ARCH__ >= 120
-        if(__any((confidence + impact <= stages[(st + threadIdx.x)]))) st += 2048;
-    #endif
-    #if __CUDA_ARCH__ >= 300
-        impact = __shfl(impact, 31);
-    #endif
-
-        confidence += impact;
-    }
-
-    if(!threadIdx.x && st == stEnd &&  ((confidence - FLT_EPSILON) >= 0))
-    {
-        int idx = atomicInc(ctr, ndetections);
-        objects[idx] = Detection(__float2int_rn(x * Policy::SHRINKAGE),
-            __float2int_rn(y * Policy::SHRINKAGE), level.objSize.x, level.objSize.y, confidence);
-    }
-}
-
-template<typename Policy, bool isUp>
-__global__ void soft_cascade(const CascadeInvoker<Policy> invoker, Detection* objects, const uint n, uint* ctr, const int downs)
-{
-    invoker.template detect<isUp>(objects, n, ctr, downs);
-}
-
-template<typename Policy>
-void CascadeInvoker<Policy>::operator()(const cv::cuda::PtrStepSzb& roi, const cv::cuda::PtrStepSzi& hogluv,
-    cv::cuda::PtrStepSz<uchar4> objects, const int downscales, const cudaStream_t& stream) const
-{
-    int fw = roi.rows;
-    int fh = roi.cols;
-
-    dim3 grid(fw, fh / Policy::STA_Y, downscales);
-
-    uint* ctr = (uint*)(objects.ptr(0));
-    Detection* det = ((Detection*)objects.ptr(0)) + 1;
-    uint max_det = objects.cols / sizeof(Detection);
-
-    cudaChannelFormatDesc desc = cudaCreateChannelDesc<int>();
-    cudaSafeCall( cudaBindTexture2D(0, thogluv, hogluv.data, desc, hogluv.cols, hogluv.rows, hogluv.step));
-
-    cudaChannelFormatDesc desc_roi = cudaCreateChannelDesc<typename Policy::roi_type>();
-    cudaSafeCall( cudaBindTexture2D(0, troi, roi.data, desc_roi, roi.cols / Policy::STA_Y, roi.rows, roi.step));
-
-    const CascadeInvoker<Policy> inv = *this;
-
-    soft_cascade<Policy, false><<<grid, Policy::block(), 0, stream>>>(inv, det, max_det, ctr, 0);
-    cudaSafeCall( cudaGetLastError());
-
-    grid = dim3(fw, fh / Policy::STA_Y, min(38, scales) - downscales);
-    soft_cascade<Policy, true><<<grid, Policy::block(), 0, stream>>>(inv, det, max_det, ctr, downscales);
-
-    if (!stream)
-    {
-        cudaSafeCall( cudaGetLastError());
-        cudaSafeCall( cudaDeviceSynchronize());
-    }
-}
-
-template void CascadeInvoker<GK107PolicyX4>::operator()(const cv::cuda::PtrStepSzb& roi, const cv::cuda::PtrStepSzi& hogluv,
-    cv::cuda::PtrStepSz<uchar4> objects, const int downscales, const cudaStream_t& stream) const;
-
-}}}
diff --git a/modules/softcascade/src/cuda_invoker.hpp b/modules/softcascade/src/cuda_invoker.hpp
deleted file mode 100644 (file)
index 81229df..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-//M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M
-
-
-#ifndef __OPENCV_ICF_HPP__
-#define __OPENCV_ICF_HPP__
-
-#include "opencv2/core/cuda_types.hpp"
-#include "cuda_runtime_api.h"
-
-#if defined __CUDACC__
-# define __device_inline__ __device__ __forceinline__
-#else
-# define __device_inline__
-#endif
-
-
-namespace cv { namespace softcascade { namespace cudev {
-
-typedef unsigned char uchar;
-typedef unsigned int uint;
-typedef unsigned short ushort;
-
-struct Octave
-{
-    float scale;
-    ushort2 size;
-    ushort index;
-    ushort stages;
-    ushort shrinkage;
-
-    Octave(const ushort i, const ushort s, const ushort sh, const ushort2 sz, const float sc)
-    : scale(sc), size(sz), index(i), stages(s), shrinkage(sh) {}
-};
-
-struct Level
-{
-    int octave;
-    int step;
-
-    float relScale;
-    float scaling[2];// calculated according to Dollar paper
-
-    uchar2 workRect;
-    uchar2 objSize;
-
-    Level(int idx, const Octave& oct, const float scale, const int w, const int h);
-    __device_inline__ Level(){}
-};
-
-struct Node
-{
-    uchar4 rect;
-    // ushort channel;
-    unsigned int threshold;
-
-    enum { THRESHOLD_MASK = 0x0FFFFFFF };
-
-    Node(const uchar4 r, const unsigned int ch, const unsigned int t) : rect(r), threshold(t + (ch << 28)) {}
-};
-
-struct Detection
-{
-    ushort x;
-    ushort y;
-    ushort w;
-    ushort h;
-
-    float confidence;
-    int kind;
-
-    Detection(){}
-    __device_inline__ Detection(int _x, int _y, uchar _w, uchar _h, float c)
-    : x(static_cast<ushort>(_x)), y(static_cast<ushort>(_y)), w(_w), h(_h), confidence(c), kind(0) {}
-};
-
-struct GK107PolicyX4
-{
-    enum {WARP = 32, STA_X = WARP, STA_Y = 8, SHRINKAGE = 4};
-    typedef float2 roi_type;
-    static const dim3 block()
-    {
-        return dim3(STA_X, STA_Y);
-    }
-};
-
-template<typename Policy>
-struct CascadeInvoker
-{
-    CascadeInvoker(): levels(0), stages(0), nodes(0), leaves(0), scales(0) {}
-
-    CascadeInvoker(const cv::cuda::PtrStepSzb& _levels, const cv::cuda::PtrStepSzf& _stages,
-                   const cv::cuda::PtrStepSzb& _nodes,  const cv::cuda::PtrStepSzf& _leaves)
-    : levels((const Level*)_levels.ptr()),
-      stages((const float*)_stages.ptr()),
-      nodes((const Node*)_nodes.ptr()), leaves((const float*)_leaves.ptr()),
-      scales(_levels.cols / sizeof(Level))
-    {}
-
-    const Level*  levels;
-    const float*  stages;
-
-    const Node*   nodes;
-    const float*  leaves;
-
-    int scales;
-
-    void operator()(const cv::cuda::PtrStepSzb& roi, const cv::cuda::PtrStepSzi& hogluv, cv::cuda::PtrStepSz<uchar4> objects,
-        const int downscales, const cudaStream_t& stream = 0) const;
-
-    template<bool isUp>
-    __device_inline__ void detect(Detection* objects, const unsigned int ndetections, unsigned int* ctr, const int downscales) const;
-};
-
-}}}
-
-#endif
diff --git a/modules/softcascade/src/detector.cpp b/modules/softcascade/src/detector.cpp
deleted file mode 100644 (file)
index ad74614..0000000
+++ /dev/null
@@ -1,596 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-cv::softcascade::Detection::Detection(const cv::Rect& b, const float c, int k)
-: x(static_cast<ushort>(b.x)), y(static_cast<ushort>(b.y)),
-  w(static_cast<ushort>(b.width)), h(static_cast<ushort>(b.height)), confidence(c), kind(k) {}
-
-cv::Rect cv::softcascade::Detection::bb() const
-{
-    return cv::Rect(x, y, w, h);
-}
-
-namespace {
-
-struct SOctave
-{
-    SOctave(const int i, const cv::Size& origObjSize, const cv::FileNode& fn)
-    : index(i), weaks((int)fn[SC_OCT_WEAKS]), scale((float)std::pow(2,(float)fn[SC_OCT_SCALE])),
-      size(cvRound(origObjSize.width * scale), cvRound(origObjSize.height * scale)) {}
-
-    int   index;
-    int   weaks;
-
-    float scale;
-
-    cv::Size size;
-
-    static const char *const SC_OCT_SCALE;
-    static const char *const SC_OCT_WEAKS;
-    static const char *const SC_OCT_SHRINKAGE;
-};
-
-
-struct Weak
-{
-    Weak(){}
-    Weak(const cv::FileNode& fn) : threshold((float)fn[SC_WEAK_THRESHOLD]) {}
-
-    float threshold;
-
-    static const char *const SC_WEAK_THRESHOLD;
-};
-
-
-struct Node
-{
-    Node(){}
-    Node(const int offset, cv::FileNodeIterator& fIt)
-    : feature((int)(*(fIt +=2)++) + offset), threshold((float)(*(fIt++))) {}
-
-    int   feature;
-    float threshold;
-};
-
-struct Feature
-{
-    Feature() {}
-    Feature(const cv::FileNode& fn, bool useBoxes = false) : channel((int)fn[SC_F_CHANNEL])
-    {
-        cv::FileNode rn = fn[SC_F_RECT];
-        cv::FileNodeIterator r_it = rn.begin();
-
-        int x = *r_it++;
-        int y = *r_it++;
-        int w = *r_it++;
-        int h = *r_it++;
-
-        // ToDo: fix me
-        if (useBoxes)
-            rect = cv::Rect(x, y, w, h);
-        else
-            rect = cv::Rect(x, y, w + x, h + y);
-
-        // 1 / area
-        rarea = 1.f / ((rect.width - rect.x) * (rect.height - rect.y));
-    }
-
-    int channel;
-    cv::Rect rect;
-    float rarea;
-
-    static const char *const SC_F_CHANNEL;
-    static const char *const SC_F_RECT;
-};
-
-const char *const SOctave::SC_OCT_SCALE      = "scale";
-const char *const SOctave::SC_OCT_WEAKS      = "weaks";
-const char *const SOctave::SC_OCT_SHRINKAGE  = "shrinkingFactor";
-const char *const Weak::SC_WEAK_THRESHOLD   = "treeThreshold";
-const char *const Feature::SC_F_CHANNEL     = "channel";
-const char *const Feature::SC_F_RECT        = "rect";
-
-struct Level
-{
-    const SOctave* octave;
-
-    float origScale;
-    float relScale;
-    int scaleshift;
-
-    cv::Size workRect;
-    cv::Size objSize;
-
-    float scaling[2]; // 0-th for channels <= 6, 1-st otherwise
-
-    Level(const SOctave& oct, const float scale, const int shrinkage, const int w, const int h)
-    :  octave(&oct), origScale(scale), relScale(scale / oct.scale),
-       workRect(cv::Size(cvRound(w / (float)shrinkage),cvRound(h / (float)shrinkage))),
-       objSize(cv::Size(cvRound(oct.size.width * relScale), cvRound(oct.size.height * relScale)))
-    {
-        scaling[0] = ((relScale >= 1.f)? 1.f : (0.89f * std::pow(relScale, 1.099f / std::log(2.f)))) / (relScale * relScale);
-        scaling[1] = 1.f;
-        scaleshift = static_cast<int>(relScale * (1 << 16));
-    }
-
-    void addDetection(const int x, const int y, float confidence, std::vector<cv::softcascade::Detection>& detections) const
-    {
-        // fix me
-        int shrinkage = 4;//(*octave).shrinkage;
-        cv::Rect rect(cvRound(x * shrinkage), cvRound(y * shrinkage), objSize.width, objSize.height);
-
-        detections.push_back(cv::softcascade::Detection(rect, confidence));
-    }
-
-    float rescale(cv::Rect& scaledRect, const float threshold, int idx) const
-    {
-#define SSHIFT(a) ((a) + (1 << 15)) >> 16
-        // rescale
-        scaledRect.x      = SSHIFT(scaleshift * scaledRect.x);
-        scaledRect.y      = SSHIFT(scaleshift * scaledRect.y);
-        scaledRect.width  = SSHIFT(scaleshift * scaledRect.width);
-        scaledRect.height = SSHIFT(scaleshift * scaledRect.height);
-#undef SSHIFT
-        float sarea = static_cast<float>((scaledRect.width - scaledRect.x) * (scaledRect.height - scaledRect.y));
-
-        // compensation areas rounding
-        return (sarea == 0.0f)? threshold : (threshold * scaling[idx] * sarea);
-    }
-};
-struct ChannelStorage
-{
-    cv::Mat hog;
-    int shrinkage;
-    int offset;
-    size_t step;
-    int model_height;
-
-    cv::Ptr<cv::softcascade::ChannelFeatureBuilder> builder;
-
-    enum {HOG_BINS = 6, HOG_LUV_BINS = 10};
-
-    ChannelStorage(const cv::Mat& colored, int shr, cv::String featureTypeStr) : shrinkage(shr)
-    {
-        model_height = cvRound(colored.rows / (float)shrinkage);
-        if (featureTypeStr == "ICF") featureTypeStr = "HOG6MagLuv";
-
-        builder = cv::softcascade::ChannelFeatureBuilder::create(featureTypeStr);
-        (*builder)(colored, hog, cv::Size(cvRound(colored.cols / (float)shrinkage), model_height));
-
-        step = hog.step1();
-    }
-
-    float get(const int channel, const cv::Rect& area) const
-    {
-        const int *ptr = hog.ptr<const int>(0) + model_height * channel * step + offset;
-
-        int a = ptr[area.y      * step + area.x];
-        int b = ptr[area.y      * step + area.width];
-        int c = ptr[area.height * step + area.width];
-        int d = ptr[area.height * step + area.x];
-
-        return static_cast<float>(a - b + c - d);
-    }
-};
-
-}
-
-struct cv::softcascade::Detector::Fields
-{
-    float minScale;
-    float maxScale;
-    int scales;
-
-    int origObjWidth;
-    int origObjHeight;
-
-    int shrinkage;
-
-    std::vector<SOctave> octaves;
-    std::vector<Weak>    weaks;
-    std::vector<Node>    nodes;
-    std::vector<float>   leaves;
-    std::vector<Feature> features;
-
-    std::vector<Level> levels;
-
-    cv::Size frameSize;
-
-    typedef std::vector<SOctave>::iterator  octIt_t;
-    typedef std::vector<Detection> dvector;
-
-    String featureTypeStr;
-
-    void detectAt(const int dx, const int dy, const Level& level, const ChannelStorage& storage, dvector& detections) const
-    {
-        float detectionScore = 0.f;
-
-        const SOctave& octave = *(level.octave);
-
-        int stBegin = octave.index * octave.weaks, stEnd = stBegin + octave.weaks;
-
-        for(int st = stBegin; st < stEnd; ++st)
-        {
-            const Weak& weak = weaks[st];
-
-            int nId = st * 3;
-
-            // work with root node
-            const Node& node = nodes[nId];
-            const Feature& feature = features[node.feature];
-
-            cv::Rect scaledRect(feature.rect);
-
-            float threshold = level.rescale(scaledRect, node.threshold, (int)(feature.channel > 6)) * feature.rarea;
-            float sum = storage.get(feature.channel, scaledRect);
-            int next = (sum >= threshold)? 2 : 1;
-
-            // leaves
-            const Node& leaf = nodes[nId + next];
-            const Feature& fLeaf = features[leaf.feature];
-
-            scaledRect = fLeaf.rect;
-            threshold = level.rescale(scaledRect, leaf.threshold, (int)(fLeaf.channel > 6)) * fLeaf.rarea;
-            sum = storage.get(fLeaf.channel, scaledRect);
-
-            int lShift = (next - 1) * 2 + ((sum >= threshold) ? 1 : 0);
-            float impact = leaves[(st * 4) + lShift];
-
-            detectionScore += impact;
-
-            if (detectionScore <= weak.threshold) return;
-        }
-
-        if (detectionScore > 0)
-            level.addDetection(dx, dy, detectionScore, detections);
-    }
-
-    octIt_t fitOctave(const float& logFactor)
-    {
-        float minAbsLog = FLT_MAX;
-        octIt_t res =  octaves.begin();
-        for (octIt_t oct = octaves.begin(); oct < octaves.end(); ++oct)
-        {
-            const SOctave& octave =*oct;
-            float logOctave = std::log(octave.scale);
-            float logAbsScale = fabs(logFactor - logOctave);
-
-            if(logAbsScale < minAbsLog)
-            {
-                res = oct;
-                minAbsLog = logAbsScale;
-            }
-        }
-        return res;
-    }
-
-    // compute levels of full pyramid
-    void calcLevels(const cv::Size& curr, float mins, float maxs, int total)
-    {
-        if (frameSize == curr && maxs == maxScale && mins == minScale && total == scales) return;
-
-        frameSize = curr;
-        maxScale = maxs; minScale = mins; scales = total;
-        CV_Assert(scales > 1);
-
-        levels.clear();
-        float logFactor = (std::log(maxScale) - std::log(minScale)) / (scales -1);
-
-        float scale = minScale;
-        for (int sc = 0; sc < scales; ++sc)
-        {
-            int width  = static_cast<int>(std::max(0.0f, frameSize.width  - (origObjWidth  * scale)));
-            int height = static_cast<int>(std::max(0.0f, frameSize.height - (origObjHeight * scale)));
-
-            float logScale = std::log(scale);
-            octIt_t fit = fitOctave(logScale);
-
-
-            Level level(*fit, scale, shrinkage, width, height);
-
-            if (!width || !height)
-                break;
-            else
-                levels.push_back(level);
-
-            if (fabs(scale - maxScale) < FLT_EPSILON) break;
-            scale = std::min(maxScale, expf(std::log(scale) + logFactor));
-        }
-    }
-
-    bool fill(const FileNode &root)
-    {
-        // cascade properties
-        static const char *const SC_STAGE_TYPE       = "stageType";
-        static const char *const SC_BOOST            = "BOOST";
-
-        static const char *const SC_FEATURE_TYPE     = "featureType";
-        static const char *const SC_HOG6_MAG_LUV     = "HOG6MagLuv";
-        static const char *const SC_ICF              = "ICF";
-
-        static const char *const SC_ORIG_W           = "width";
-        static const char *const SC_ORIG_H           = "height";
-
-        static const char *const SC_OCTAVES          = "octaves";
-        static const char *const SC_TREES            = "trees";
-        static const char *const SC_FEATURES         = "features";
-
-        static const char *const SC_INTERNAL         = "internalNodes";
-        static const char *const SC_LEAF             = "leafValues";
-
-        static const char *const SC_SHRINKAGE        = "shrinkage";
-
-        static const char *const FEATURE_FORMAT      = "featureFormat";
-
-        // only Ada Boost supported
-        String stageTypeStr = (String)root[SC_STAGE_TYPE];
-        CV_Assert(stageTypeStr == SC_BOOST);
-
-        String fformat = (String)root[FEATURE_FORMAT];
-        bool useBoxes = (fformat == "BOX");
-
-        // only HOG-like integral channel features supported
-        featureTypeStr = (String)root[SC_FEATURE_TYPE];
-        CV_Assert(featureTypeStr == SC_ICF || featureTypeStr == SC_HOG6_MAG_LUV);
-
-        origObjWidth  = (int)root[SC_ORIG_W];
-        origObjHeight = (int)root[SC_ORIG_H];
-
-        shrinkage = (int)root[SC_SHRINKAGE];
-
-        FileNode fn = root[SC_OCTAVES];
-        if (fn.empty()) return false;
-
-        // for each octave
-        FileNodeIterator it = fn.begin(), it_end = fn.end();
-        for (int octIndex = 0; it != it_end; ++it, ++octIndex)
-        {
-            FileNode fns = *it;
-            SOctave octave(octIndex, cv::Size(origObjWidth, origObjHeight), fns);
-            CV_Assert(octave.weaks > 0);
-            octaves.push_back(octave);
-
-            FileNode ffs = fns[SC_FEATURES];
-            if (ffs.empty()) return false;
-
-            fns = fns[SC_TREES];
-            if (fn.empty()) return false;
-
-            FileNodeIterator st = fns.begin(), st_end = fns.end();
-            for (; st != st_end; ++st )
-            {
-                weaks.push_back(Weak(*st));
-
-                fns = (*st)[SC_INTERNAL];
-                FileNodeIterator inIt = fns.begin(), inIt_end = fns.end();
-                for (; inIt != inIt_end;)
-                    nodes.push_back(Node((int)features.size(), inIt));
-
-                fns = (*st)[SC_LEAF];
-                inIt = fns.begin(), inIt_end = fns.end();
-
-                for (; inIt != inIt_end; ++inIt)
-                    leaves.push_back((float)(*inIt));
-            }
-
-            st = ffs.begin(), st_end = ffs.end();
-            for (; st != st_end; ++st )
-                features.push_back(Feature(*st, useBoxes));
-        }
-
-        return true;
-    }
-};
-
-cv::softcascade::Detector::Detector(const double mins, const double maxs, const int nsc, const int rej)
-: fields(0), minScale(mins), maxScale(maxs), scales(nsc), rejCriteria(rej) {}
-
-cv::softcascade::Detector::~Detector() { delete fields;}
-
-void cv::softcascade::Detector::read(const cv::FileNode& fn)
-{
-    Algorithm::read(fn);
-}
-
-bool cv::softcascade::Detector::load(const cv::FileNode& fn)
-{
-    if (fields) delete fields;
-
-    fields = new Fields;
-    return fields->fill(fn);
-}
-
-namespace {
-
-using cv::softcascade::Detection;
-typedef std::vector<Detection>  dvector;
-
-
-struct ConfidenceGt
-{
-    bool operator()(const Detection& a, const Detection& b) const
-    {
-        return a.confidence > b.confidence;
-    }
-};
-
-static float overlap(const cv::Rect &a, const cv::Rect &b)
-{
-    int w = std::min(a.x + a.width,  b.x + b.width)  - std::max(a.x, b.x);
-    int h = std::min(a.y + a.height, b.y + b.height) - std::max(a.y, b.y);
-
-    return (w < 0 || h < 0)? 0.f : (float)(w * h);
-}
-
-void DollarNMS(dvector& objects)
-{
-    static const float DollarThreshold = 0.65f;
-    std::sort(objects.begin(), objects.end(), ConfidenceGt());
-
-    for (dvector::iterator dIt = objects.begin(); dIt != objects.end(); ++dIt)
-    {
-        const Detection &a = *dIt;
-        for (dvector::iterator next = dIt + 1; next != objects.end(); )
-        {
-            const Detection &b = *next;
-
-            const float ovl =  overlap(a.bb(), b.bb()) / std::min(a.bb().area(), b.bb().area());
-
-            if (ovl > DollarThreshold)
-                next = objects.erase(next);
-            else
-                ++next;
-        }
-    }
-}
-
-static void suppress(int type, std::vector<Detection>& objects)
-{
-    CV_Assert(type == cv::softcascade::Detector::DOLLAR);
-    DollarNMS(objects);
-}
-
-}
-
-void cv::softcascade::Detector::detectNoRoi(const cv::Mat& image, std::vector<Detection>& objects) const
-{
-    Fields& fld = *fields;
-    // create integrals
-    ChannelStorage storage(image, fld.shrinkage, fld.featureTypeStr);
-
-    typedef std::vector<Level>::const_iterator lIt;
-    for (lIt it = fld.levels.begin(); it != fld.levels.end(); ++it)
-    {
-        const Level& level = *it;
-
-        // we train only 3 scales.
-        if (level.origScale > 2.5) break;
-
-        for (int dy = 0; dy < level.workRect.height; ++dy)
-        {
-            for (int dx = 0; dx < level.workRect.width; ++dx)
-            {
-                storage.offset = (int)(dy * storage.step + dx);
-                fld.detectAt(dx, dy, level, storage, objects);
-            }
-        }
-    }
-
-    if (rejCriteria != NO_REJECT) suppress(rejCriteria, objects);
-}
-
-void cv::softcascade::Detector::detect(cv::InputArray _image, cv::InputArray _rois, std::vector<Detection>& objects) const
-{
-    // only color images are suppered
-    cv::Mat image = _image.getMat();
-    CV_Assert(image.type() == CV_8UC3);
-
-    Fields& fld = *fields;
-    fld.calcLevels(image.size(),(float) minScale, (float)maxScale, scales);
-
-    objects.clear();
-
-    if (_rois.empty())
-        return detectNoRoi(image, objects);
-
-    int shr = fld.shrinkage;
-
-    cv::Mat roi = _rois.getMat();
-    cv::Mat mask(image.rows / shr, image.cols / shr, CV_8UC1);
-
-    mask.setTo(cv::Scalar::all(0));
-    cv::Rect* r = roi.ptr<cv::Rect>(0);
-    for (int i = 0; i < (int)roi.cols; ++i)
-        cv::Mat(mask, cv::Rect(r[i].x / shr, r[i].y / shr, r[i].width / shr , r[i].height / shr)).setTo(cv::Scalar::all(1));
-
-    // create integrals
-    ChannelStorage storage(image, shr, fld.featureTypeStr);
-
-    typedef std::vector<Level>::const_iterator lIt;
-    for (lIt it = fld.levels.begin(); it != fld.levels.end(); ++it)
-    {
-         const Level& level = *it;
-
-        // we train only 3 scales.
-        if (level.origScale > 2.5) break;
-
-         for (int dy = 0; dy < level.workRect.height; ++dy)
-         {
-             uchar* m  = mask.ptr<uchar>(dy);
-             for (int dx = 0; dx < level.workRect.width; ++dx)
-             {
-                 if (m[dx])
-                 {
-                     storage.offset = (int)(dy * storage.step + dx);
-                     fld.detectAt(dx, dy, level, storage, objects);
-                 }
-             }
-         }
-    }
-
-    if (rejCriteria != NO_REJECT) suppress(rejCriteria, objects);
-}
-
-void cv::softcascade::Detector::detect(InputArray _image, InputArray _rois,  OutputArray _rects, OutputArray _confs) const
-{
-    std::vector<Detection> objects;
-    detect( _image, _rois, objects);
-
-    _rects.create(1, (int)objects.size(), CV_32SC4);
-    cv::Mat_<cv::Rect> rects = (cv::Mat_<cv::Rect>)_rects.getMat();
-    cv::Rect* rectPtr = rects.ptr<cv::Rect>(0);
-
-    _confs.create(1, (int)objects.size(), CV_32F);
-    cv::Mat confs = _confs.getMat();
-    float* confPtr = confs.ptr<float>(0);
-
-    typedef std::vector<Detection>::const_iterator IDet;
-
-    int i = 0;
-    for (IDet it = objects.begin(); it != objects.end(); ++it, ++i)
-    {
-        rectPtr[i] = (*it).bb();
-        confPtr[i] = (*it).confidence;
-    }
-}
diff --git a/modules/softcascade/src/detector_cuda.cpp b/modules/softcascade/src/detector_cuda.cpp
deleted file mode 100644 (file)
index 328b7d4..0000000
+++ /dev/null
@@ -1,603 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-#if !defined (HAVE_CUDA)
-
-cv::softcascade::SCascade::SCascade(const double, const double, const int, const int) { throw_no_cuda(); }
-
-cv::softcascade::SCascade::~SCascade() { throw_no_cuda(); }
-
-bool cv::softcascade::SCascade::load(const FileNode&) { throw_no_cuda(); return false;}
-
-void cv::softcascade::SCascade::detect(InputArray, InputArray, OutputArray, cv::cuda::Stream&) const { throw_no_cuda(); }
-
-void cv::softcascade::SCascade::read(const FileNode& fn) { Algorithm::read(fn); }
-
-cv::softcascade::ChannelsProcessor::ChannelsProcessor() { throw_no_cuda(); }
- cv::softcascade::ChannelsProcessor::~ChannelsProcessor() { throw_no_cuda(); }
-
-cv::Ptr<cv::softcascade::ChannelsProcessor> cv::softcascade::ChannelsProcessor::create(const int, const int, const int)
-{ throw_no_cuda(); return cv::Ptr<cv::softcascade::ChannelsProcessor>(); }
-
-#else
-
-# include "cuda_invoker.hpp"
-
-cv::softcascade::cudev::Level::Level(int idx, const Octave& oct, const float scale, const int w, const int h)
-:  octave(idx), step(oct.stages), relScale(scale / oct.scale)
-{
-    workRect.x = (unsigned char)cvRound(w / (float)oct.shrinkage);
-    workRect.y = (unsigned char)cvRound(h / (float)oct.shrinkage);
-
-    objSize.x  = cv::saturate_cast<uchar>(oct.size.x * relScale);
-    objSize.y  = cv::saturate_cast<uchar>(oct.size.y * relScale);
-
-    // according to R. Benenson, M. Mathias, R. Timofte and L. Van Gool's and Dallal's papers
-    if (fabs(relScale - 1.f) < FLT_EPSILON)
-        scaling[0] = scaling[1] = 1.f;
-    else
-    {
-        scaling[0] = (relScale < 1.f) ? 0.89f * ::pow(relScale, 1.099f / ::log(2.0f)) : 1.f;
-        scaling[1] = relScale * relScale;
-    }
-}
-
-namespace cv { namespace softcascade { namespace cudev {
-
-    void fillBins(cv::cuda::PtrStepSzb hogluv, const cv::cuda::PtrStepSzf& nangle,
-        const int fw, const int fh, const int bins, cudaStream_t stream);
-
-    void suppress(const cv::cuda::PtrStepSzb& objects, cv::cuda::PtrStepSzb overlaps, cv::cuda::PtrStepSzi ndetections,
-        cv::cuda::PtrStepSzb suppressed, cudaStream_t stream);
-
-    void bgr2Luv(const cv::cuda::PtrStepSzb& bgr, cv::cuda::PtrStepSzb luv);
-    void transform(const cv::cuda::PtrStepSz<uchar3>& bgr, cv::cuda::PtrStepSzb gray);
-    void gray2hog(const cv::cuda::PtrStepSzb& gray, cv::cuda::PtrStepSzb mag, const int bins);
-    void shrink(const cv::cuda::PtrStepSzb& channels, cv::cuda::PtrStepSzb shrunk);
-
-    void shfl_integral(const cv::cuda::PtrStepSzb& img, cv::cuda::PtrStepSz<unsigned int> integral, cudaStream_t stream);
-}}}
-
-struct cv::softcascade::SCascade::Fields
-{
-    static Fields* parseCascade(const FileNode &root, const float mins, const float maxs, const int totals, const int method)
-    {
-        static const char *const SC_STAGE_TYPE          = "stageType";
-        static const char *const SC_BOOST               = "BOOST";
-        static const char *const SC_FEATURE_TYPE        = "featureType";
-        static const char *const SC_ICF                 = "ICF";
-        static const char *const SC_ORIG_W              = "width";
-        static const char *const SC_ORIG_H              = "height";
-        static const char *const SC_FEATURE_FORMAT      = "featureFormat";
-        static const char *const SC_SHRINKAGE           = "shrinkage";
-        static const char *const SC_OCTAVES             = "octaves";
-        static const char *const SC_OCT_SCALE           = "scale";
-        static const char *const SC_OCT_WEAKS           = "weaks";
-        static const char *const SC_TREES               = "trees";
-        static const char *const SC_WEAK_THRESHOLD      = "treeThreshold";
-        static const char *const SC_FEATURES            = "features";
-        static const char *const SC_INTERNAL            = "internalNodes";
-        static const char *const SC_LEAF                = "leafValues";
-        static const char *const SC_F_CHANNEL           = "channel";
-        static const char *const SC_F_RECT              = "rect";
-
-        // only Ada Boost supported
-        String stageTypeStr = (String)root[SC_STAGE_TYPE];
-        CV_Assert(stageTypeStr == SC_BOOST);
-
-        // only HOG-like integral channel features supported
-        String featureTypeStr = (String)root[SC_FEATURE_TYPE];
-        CV_Assert(featureTypeStr == SC_ICF);
-
-        int origWidth  = (int)root[SC_ORIG_W];
-        int origHeight = (int)root[SC_ORIG_H];
-
-        String fformat = (String)root[SC_FEATURE_FORMAT];
-        bool useBoxes = (fformat == "BOX");
-        ushort shrinkage = cv::saturate_cast<ushort>((int)root[SC_SHRINKAGE]);
-
-        FileNode fn = root[SC_OCTAVES];
-        if (fn.empty()) return 0;
-
-        std::vector<cudev::Octave>  voctaves;
-        std::vector<float>   vstages;
-        std::vector<cudev::Node>    vnodes;
-        std::vector<float>   vleaves;
-
-        FileNodeIterator it = fn.begin(), it_end = fn.end();
-        for (ushort octIndex = 0; it != it_end; ++it, ++octIndex)
-        {
-            FileNode fns = *it;
-            float scale = powf(2.f,saturate_cast<float>((int)fns[SC_OCT_SCALE]));
-            bool isUPOctave = scale >= 1;
-
-            ushort nweaks = saturate_cast<ushort>((int)fns[SC_OCT_WEAKS]);
-
-            ushort2 size;
-            size.x = (unsigned short)cvRound(origWidth * scale);
-            size.y = (unsigned short)cvRound(origHeight * scale);
-
-            cudev::Octave octave(octIndex, nweaks, shrinkage, size, scale);
-            CV_Assert(octave.stages > 0);
-            voctaves.push_back(octave);
-
-            FileNode ffs = fns[SC_FEATURES];
-            if (ffs.empty()) return 0;
-
-            std::vector<cv::Rect> feature_rects;
-            std::vector<int> feature_channels;
-
-            FileNodeIterator ftrs = ffs.begin(), ftrs_end = ffs.end();
-            int feature_offset = 0;
-            for (; ftrs != ftrs_end; ++ftrs, ++feature_offset )
-            {
-                cv::FileNode ftn = (*ftrs)[SC_F_RECT];
-                cv::FileNodeIterator r_it = ftn.begin();
-                int x = (int)*(r_it++);
-                int y = (int)*(r_it++);
-                int w = (int)*(r_it++);
-                int h = (int)*(r_it++);
-
-                if (useBoxes)
-                {
-                    if (isUPOctave)
-                    {
-                        w -= x;
-                        h -= y;
-                    }
-                }
-                else
-                {
-                    if (!isUPOctave)
-                    {
-                        w += x;
-                        h += y;
-                    }
-                }
-                feature_rects.push_back(cv::Rect(x, y, w, h));
-                feature_channels.push_back((int)(*ftrs)[SC_F_CHANNEL]);
-            }
-
-            fns = fns[SC_TREES];
-            if (fn.empty()) return 0;
-
-            // for each stage (~ decision tree with H = 2)
-            FileNodeIterator st = fns.begin(), st_end = fns.end();
-            for (; st != st_end; ++st )
-            {
-                FileNode octfn = *st;
-                float threshold = (float)octfn[SC_WEAK_THRESHOLD];
-                vstages.push_back(threshold);
-
-                FileNode intfns = octfn[SC_INTERNAL];
-                FileNodeIterator inIt = intfns.begin(), inIt_end = intfns.end();
-                for (; inIt != inIt_end;)
-                {
-                    inIt +=2;
-                    int featureIdx = (int)(*(inIt++));
-
-                    float orig_threshold = (float)(*(inIt++));
-                    unsigned int th = saturate_cast<unsigned int>((int)orig_threshold);
-                    cv::Rect& r = feature_rects[featureIdx];
-                    uchar4 rect;
-                    rect.x = saturate_cast<uchar>(r.x);
-                    rect.y = saturate_cast<uchar>(r.y);
-                    rect.z = saturate_cast<uchar>(r.width);
-                    rect.w = saturate_cast<uchar>(r.height);
-
-                    unsigned int channel = saturate_cast<unsigned int>(feature_channels[featureIdx]);
-                    vnodes.push_back(cudev::Node(rect, channel, th));
-                }
-
-                intfns = octfn[SC_LEAF];
-                inIt = intfns.begin(), inIt_end = intfns.end();
-                for (; inIt != inIt_end; ++inIt)
-                {
-                    vleaves.push_back((float)(*inIt));
-                }
-            }
-        }
-
-        cv::Mat hoctaves(1, (int) (voctaves.size() * sizeof(cudev::Octave)), CV_8UC1, (uchar*)&(voctaves[0]));
-        CV_Assert(!hoctaves.empty());
-
-        cv::Mat hstages(cv::Mat(vstages).reshape(1,1));
-        CV_Assert(!hstages.empty());
-
-        cv::Mat hnodes(1, (int) (vnodes.size() * sizeof(cudev::Node)), CV_8UC1, (uchar*)&(vnodes[0]) );
-        CV_Assert(!hnodes.empty());
-
-        cv::Mat hleaves(cv::Mat(vleaves).reshape(1,1));
-        CV_Assert(!hleaves.empty());
-
-        Fields* fields = new Fields(mins, maxs, totals, origWidth, origHeight, shrinkage, 0,
-            hoctaves, hstages, hnodes, hleaves, method);
-        fields->voctaves = voctaves;
-        fields->createLevels(DEFAULT_FRAME_HEIGHT, DEFAULT_FRAME_WIDTH);
-
-        return fields;
-    }
-
-    bool check(float mins,float  maxs, int scales)
-    {
-        bool updated = ((minScale == mins) || (maxScale == maxs) || (totals == scales));
-
-        minScale = mins;
-        maxScale = maxScale;
-        totals   = scales;
-
-        return updated;
-    }
-
-    int createLevels(const int fh, const int fw)
-    {
-        std::vector<cudev::Level> vlevels;
-        float logFactor = (::log(maxScale) - ::log(minScale)) / (totals -1);
-
-        float scale = minScale;
-        int dcs = 0;
-        for (int sc = 0; sc < totals; ++sc)
-        {
-            int width  = (int)::std::max(0.0f, fw - (origObjWidth  * scale));
-            int height = (int)::std::max(0.0f, fh - (origObjHeight * scale));
-
-            float logScale = ::log(scale);
-            int fit = fitOctave(voctaves, logScale);
-
-            cudev::Level level(fit, voctaves[fit], scale, width, height);
-
-            if (!width || !height)
-                break;
-            else
-            {
-                vlevels.push_back(level);
-                if (voctaves[fit].scale < 1) ++dcs;
-            }
-
-            if (::fabs(scale - maxScale) < FLT_EPSILON) break;
-            scale = ::std::min(maxScale, ::expf(::log(scale) + logFactor));
-        }
-
-        cv::Mat hlevels = cv::Mat(1, (int) (vlevels.size() * sizeof(cudev::Level)), CV_8UC1, (uchar*)&(vlevels[0]) );
-        CV_Assert(!hlevels.empty());
-        levels.upload(hlevels);
-        downscales = dcs;
-        return dcs;
-    }
-
-    bool update(int fh, int fw, int shr)
-    {
-        shrunk.create(fh / shr * HOG_LUV_BINS, fw / shr, CV_8UC1);
-        integralBuffer.create(shrunk.rows, shrunk.cols, CV_32SC1);
-
-        hogluv.create((fh / shr) * HOG_LUV_BINS + 1, fw / shr + 1, CV_32SC1);
-        hogluv.setTo(cv::Scalar::all(0));
-
-        overlaps.create(1, 5000, CV_8UC1);
-        suppressed.create(1, sizeof(Detection) * 51, CV_8UC1);
-
-        return true;
-    }
-
-    Fields( const float mins, const float maxs, const int tts, const int ow, const int oh, const int shr, const int ds,
-        cv::Mat hoctaves, cv::Mat hstages, cv::Mat hnodes, cv::Mat hleaves, int method)
-    : minScale(mins), maxScale(maxs), totals(tts), origObjWidth(ow), origObjHeight(oh), shrinkage(shr), downscales(ds)
-    {
-        update(DEFAULT_FRAME_HEIGHT, DEFAULT_FRAME_WIDTH, shr);
-        octaves.upload(hoctaves);
-        stages.upload(hstages);
-        nodes.upload(hnodes);
-        leaves.upload(hleaves);
-
-        preprocessor = ChannelsProcessor::create(shrinkage, 6, method);
-    }
-
-    void detect(cv::cuda::GpuMat& objects, cv::cuda::Stream& s) const
-    {
-        objects.setTo(Scalar::all(0), s);
-
-        cudaSafeCall( cudaGetLastError());
-
-        cudev::CascadeInvoker<cudev::GK107PolicyX4> invoker
-        = cudev::CascadeInvoker<cudev::GK107PolicyX4>(levels, stages, nodes, leaves);
-
-        cudaStream_t stream = cv::cuda::StreamAccessor::getStream(s);
-        invoker(mask, hogluv, objects, downscales, stream);
-    }
-
-    void suppress(cv::cuda::GpuMat& objects, cv::cuda::Stream& s)
-    {
-        cv::cuda::GpuMat ndetections = cv::cuda::GpuMat(objects, cv::Rect(0, 0, sizeof(Detection), 1));
-        ensureSizeIsEnough(objects.rows, objects.cols, CV_8UC1, overlaps);
-
-        overlaps.setTo(0, s);
-        suppressed.setTo(0, s);
-
-        cudaStream_t stream = cv::cuda::StreamAccessor::getStream(s);
-        cudev::suppress(objects, overlaps, ndetections, suppressed, stream);
-    }
-
-private:
-
-    typedef std::vector<cudev::Octave>::const_iterator  octIt_t;
-    static int fitOctave(const std::vector<cudev::Octave>& octs, const float& logFactor)
-    {
-        float minAbsLog = FLT_MAX;
-        int res =  0;
-        for (int oct = 0; oct < (int)octs.size(); ++oct)
-        {
-            const cudev::Octave& octave =octs[oct];
-            float logOctave = ::log(octave.scale);
-            float logAbsScale = ::fabs(logFactor - logOctave);
-
-            if(logAbsScale < minAbsLog)
-            {
-                res = oct;
-                minAbsLog = logAbsScale;
-            }
-        }
-        return res;
-    }
-
-public:
-
-    cv::Ptr<ChannelsProcessor> preprocessor;
-
-    // scales range
-    float minScale;
-    float maxScale;
-
-    int totals;
-
-    int origObjWidth;
-    int origObjHeight;
-
-    const int shrinkage;
-    int downscales;
-
-
-    // 160x120x10
-    cv::cuda::GpuMat shrunk;
-
-    // temporal mat for integral
-    cv::cuda::GpuMat integralBuffer;
-
-    // 161x121x10
-    cv::cuda::GpuMat hogluv;
-
-
-    // used for suppression
-    cv::cuda::GpuMat suppressed;
-    // used for area overlap computing during
-    cv::cuda::GpuMat overlaps;
-
-
-    // Cascade from xml
-    cv::cuda::GpuMat octaves;
-    cv::cuda::GpuMat stages;
-    cv::cuda::GpuMat nodes;
-    cv::cuda::GpuMat leaves;
-    cv::cuda::GpuMat levels;
-
-
-    // For ROI
-    cv::cuda::GpuMat mask;
-    cv::cuda::GpuMat genRoiTmp;
-
-//     cv::cuda::GpuMat collected;
-
-
-    std::vector<cudev::Octave> voctaves;
-
-//     DeviceInfo info;
-
-    enum { BOOST = 0 };
-    enum
-    {
-        DEFAULT_FRAME_WIDTH        = 640,
-        DEFAULT_FRAME_HEIGHT       = 480,
-        HOG_LUV_BINS               = 10
-    };
-
-private:
-    cv::softcascade::SCascade::Fields& operator=( const cv::softcascade::SCascade::Fields & );
-};
-
-cv::softcascade::SCascade::SCascade(const double mins, const double maxs, const int sc, const int fl)
-: fields(0),  minScale(mins), maxScale(maxs), scales(sc), flags(fl) {}
-
-cv::softcascade::SCascade::~SCascade() { delete fields; }
-
-bool cv::softcascade::SCascade::load(const FileNode& fn)
-{
-    if (fields) delete fields;
-    fields = Fields::parseCascade(fn, (float)minScale, (float)maxScale, scales, flags);
-    return fields != 0;
-}
-
-namespace {
-
-void integral(const cv::cuda::GpuMat& src, cv::cuda::GpuMat& sum, cv::cuda::GpuMat& buffer, cv::cuda::Stream& s)
-{
-    CV_Assert(src.type() == CV_8UC1);
-
-    cudaStream_t stream = cv::cuda::StreamAccessor::getStream(s);
-
-    cv::Size whole;
-    cv::Point offset;
-
-    src.locateROI(whole, offset);
-
-    if (cv::cuda::deviceSupports(cv::cuda::WARP_SHUFFLE_FUNCTIONS) && src.cols <= 2048
-        && offset.x % 16 == 0 && ((src.cols + 63) / 64) * 64 <= (static_cast<int>(src.step) - offset.x))
-    {
-        ensureSizeIsEnough(((src.rows + 7) / 8) * 8, ((src.cols + 63) / 64) * 64, CV_32SC1, buffer);
-
-        cv::softcascade::cudev::shfl_integral(src, buffer, stream);
-
-        sum.create(src.rows + 1, src.cols + 1, CV_32SC1);
-        sum.setTo(cv::Scalar::all(0), s);
-
-        cv::cuda::GpuMat inner = sum(cv::Rect(1, 1, src.cols, src.rows));
-        cv::cuda::GpuMat res = buffer(cv::Rect(0, 0, src.cols, src.rows));
-
-        res.copyTo(inner, s);
-    }
-    else {CV_Error(cv::Error::GpuNotSupported, ": CC 3.x required.");}
-}
-
-}
-
-void cv::softcascade::SCascade::detect(InputArray _image, InputArray _rois, OutputArray _objects, cv::cuda::Stream& s) const
-{
-    CV_Assert(fields);
-
-    // only color images and precomputed integrals are supported
-    int type = _image.type();
-    CV_Assert(type == CV_8UC3 || type == CV_32SC1 || (!_rois.empty()));
-
-    const cv::cuda::GpuMat image = _image.getGpuMat();
-
-    if (_objects.empty()) _objects.create(1, 4096 * sizeof(Detection), CV_8UC1);
-
-    cv::cuda::GpuMat rois = _rois.getGpuMat(), objects = _objects.getGpuMat();
-
-    /// roi
-    Fields& flds = *fields;
-    int shr = flds.shrinkage;
-
-    flds.mask.create( rois.cols / shr, rois.rows / shr, rois.type());
-
-    cudev::shrink(rois, flds.mask);
-    //cv::cuda::transpose(flds.genRoiTmp, flds.mask, s);
-
-    if (type == CV_8UC3)
-    {
-        flds.update(image.rows, image.cols, flds.shrinkage);
-
-        if (flds.check((float)minScale, (float)maxScale, scales))
-            flds.createLevels(image.rows, image.cols);
-
-        flds.preprocessor->apply(image, flds.shrunk);
-        ::integral(flds.shrunk, flds.hogluv, flds.integralBuffer, s);
-    }
-    else
-    {
-        image.copyTo(flds.hogluv, s);
-    }
-
-    flds.detect(objects, s);
-
-    if ( (flags && NMS_MASK) != NO_REJECT)
-    {
-        cv::cuda::GpuMat spr(objects, cv::Rect(0, 0, flds.suppressed.cols, flds.suppressed.rows));
-        flds.suppress(objects, s);
-        flds.suppressed.copyTo(spr);
-    }
-}
-
-void cv::softcascade::SCascade::read(const FileNode& fn)
-{
-    Algorithm::read(fn);
-}
-
-namespace {
-
-using cv::InputArray;
-using cv::OutputArray;
-using cv::cuda::Stream;
-using cv::cuda::GpuMat;
-
-inline void setZero(cv::cuda::GpuMat& m, cv::cuda::Stream& s)
-{
-    m.setTo(0, s);
-}
-
-struct SeparablePreprocessor : public cv::softcascade::ChannelsProcessor
-{
-    SeparablePreprocessor(const int s, const int b) : cv::softcascade::ChannelsProcessor(), shrinkage(s), bins(b) {}
-    virtual ~SeparablePreprocessor() {}
-
-    virtual void apply(InputArray _frame, OutputArray _shrunk, cv::cuda::Stream& s = cv::cuda::Stream::Null())
-    {
-        bgr = _frame.getGpuMat();
-        //cv::cuda::GaussianBlur(frame, bgr, cv::Size(3, 3), -1.0);
-
-        _shrunk.create(bgr.rows * (4 + bins) / shrinkage, bgr.cols / shrinkage, CV_8UC1);
-        cv::cuda::GpuMat shrunk = _shrunk.getGpuMat();
-
-        channels.create(bgr.rows * (4 + bins), bgr.cols, CV_8UC1);
-        setZero(channels, s);
-
-        gray.create(bgr.size(), CV_8UC1);
-        cv::softcascade::cudev::transform(bgr, gray); //cv::cuda::cvtColor(bgr, gray, CV_BGR2GRAY);
-        cv::softcascade::cudev::gray2hog(gray, channels(cv::Rect(0, 0, bgr.cols, bgr.rows * (bins + 1))), bins);
-
-        cv::cuda::GpuMat luv(channels, cv::Rect(0, bgr.rows * (bins + 1), bgr.cols, bgr.rows * 3));
-        cv::softcascade::cudev::bgr2Luv(bgr, luv);
-        cv::softcascade::cudev::shrink(channels, shrunk);
-    }
-
-private:
-    const int shrinkage;
-    const int bins;
-
-    cv::cuda::GpuMat bgr;
-    cv::cuda::GpuMat gray;
-    cv::cuda::GpuMat channels;
-    SeparablePreprocessor& operator=( const SeparablePreprocessor& );
-};
-
-}
-
-cv::Ptr<cv::softcascade::ChannelsProcessor> cv::softcascade::ChannelsProcessor::create(const int s, const int b, const int m)
-{
-    CV_Assert((m && SEPARABLE));
-    return makePtr<SeparablePreprocessor>(s, b);
-}
-
-cv::softcascade::ChannelsProcessor::ChannelsProcessor() { }
-cv::softcascade::ChannelsProcessor::~ChannelsProcessor() { }
-
-#endif
diff --git a/modules/softcascade/src/integral_channel_builder.cpp b/modules/softcascade/src/integral_channel_builder.cpp
deleted file mode 100644 (file)
index 540005b..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-namespace {
-
-using namespace cv::softcascade;
-
-class HOG6MagLuv : public ChannelFeatureBuilder
-{
-    enum {N_CHANNELS = 10};
-public:
-    virtual ~HOG6MagLuv() {}
-    virtual cv::AlgorithmInfo* info() const;
-
-    virtual int totalChannels() const {return N_CHANNELS; }
-
-    virtual void operator()(cv::InputArray _frame, cv::OutputArray _integrals, cv::Size channelsSize) const
-    {
-        CV_Assert(_frame.type() == CV_8UC3);
-
-        cv::Mat frame      = _frame.getMat();
-        int h = frame.rows;
-        int w = frame.cols;
-
-        if (channelsSize != cv::Size())
-            _integrals.create(channelsSize.height * N_CHANNELS + 1, channelsSize.width + 1, CV_32SC1);
-
-        if(_integrals.empty())
-            _integrals.create(frame.rows * N_CHANNELS + 1, frame.cols + 1, CV_32SC1);
-
-        cv::Mat& integrals = _integrals.getMatRef();
-
-        cv::Mat channels, gray;
-
-        channels.create(h * N_CHANNELS, w, CV_8UC1);
-        channels.setTo(0);
-
-        cvtColor(frame, gray, cv::COLOR_BGR2GRAY);
-
-        cv::Mat df_dx, df_dy, mag, angle;
-        cv::Sobel(gray, df_dx, CV_32F, 1, 0);
-        cv::Sobel(gray, df_dy, CV_32F, 0, 1);
-
-        cv::cartToPolar(df_dx, df_dy, mag, angle, true);
-        mag *= (1.f / (8 * sqrt(2.f)));
-
-        cv::Mat nmag = channels(cv::Rect(0, h * (N_CHANNELS - 4), w, h));
-        mag.convertTo(nmag, CV_8UC1);
-
-        angle *=  6 / 360.f;
-
-        for (int y = 0; y < h; ++y)
-        {
-            uchar* magnitude = nmag.ptr<uchar>(y);
-            float* ang = angle.ptr<float>(y);
-
-            for (int x = 0; x < w; ++x)
-            {
-                channels.ptr<uchar>(y + (h * (int)ang[x]))[x] = magnitude[x];
-            }
-        }
-
-        cv::Mat luv, shrunk;
-        cv::cvtColor(frame, luv, cv::COLOR_BGR2Luv);
-
-        std::vector<cv::Mat> splited;
-        for (int i = 0; i < 3; ++i)
-            splited.push_back(channels(cv::Rect(0, h * (7 + i), w, h)));
-        split(luv, splited);
-        cv::resize(channels, shrunk, cv::Size(integrals.cols - 1, integrals.rows - 1), -1 , -1, cv::INTER_AREA);
-        cv::integral(shrunk, integrals, cv::noArray(), CV_32S);
-    }
-};
-
-}
-
-using cv::softcascade::ChannelFeatureBuilder;
-using cv::softcascade::ChannelFeature;
-
-CV_INIT_ALGORITHM(HOG6MagLuv,  "ChannelFeatureBuilder.HOG6MagLuv", )
-
-ChannelFeatureBuilder::~ChannelFeatureBuilder() {}
-
-cv::Ptr<ChannelFeatureBuilder> ChannelFeatureBuilder::create(const cv::String& featureType)
-{
-    return Algorithm::create<ChannelFeatureBuilder>("ChannelFeatureBuilder." + featureType);
-}
-
-ChannelFeature::ChannelFeature(int x, int y, int w, int h, int ch)
-: bb(cv::Rect(x, y, w, h)), channel(ch) {}
-
-bool ChannelFeature::operator ==(ChannelFeature b)
-{
-    return bb == b.bb && channel == b.channel;
-}
-
-bool ChannelFeature::operator !=(ChannelFeature b)
-{
-    return bb != b.bb || channel != b.channel;
-}
-
-
-float ChannelFeature::operator() (const cv::Mat& integrals, const cv::Size& model) const
-{
-    int step = model.width + 1;
-
-    const int* ptr = integrals.ptr<int>(0) + (model.height * channel + bb.y) * step + bb.x;
-
-    int a = ptr[0];
-    int b = ptr[bb.width];
-
-    ptr += bb.height * step;
-
-    int c = ptr[bb.width];
-    int d = ptr[0];
-
-    return (float)(a - b + c - d);
-}
-
-void cv::softcascade::write(cv::FileStorage& fs, const cv::String&, const ChannelFeature& f)
-{
-    fs << "{" << "channel" << f.channel << "rect" << f.bb << "}";
-}
-
-std::ostream& cv::softcascade::operator<<(std::ostream& out, const ChannelFeature& m)
-{
-    return out << m.channel << " " << "[" << m.bb.width << " x " << m.bb.height << " from (" << m.bb.x << ", " << m.bb.y << ")]";
-}
-
-ChannelFeature::~ChannelFeature(){}
-
-namespace {
-
-using namespace cv::softcascade;
-
-class ChannelFeaturePool : public FeaturePool
-{
-public:
-    ChannelFeaturePool(cv::Size m, int n, int ch) : FeaturePool(), model(m), N_CHANNELS(ch)
-    {
-        CV_Assert(m != cv::Size() && n > 0 && (ch == 10 || ch == 8));
-        fill(n);
-    }
-
-    virtual int size() const { return (int)pool.size(); }
-    virtual float apply(int fi, int si, const cv::Mat& integrals) const;
-    virtual void write( cv::FileStorage& fs, int index) const;
-
-    virtual ~ChannelFeaturePool() {}
-
-private:
-
-    void fill(int desired);
-
-    cv::Size model;
-    std::vector<ChannelFeature> pool;
-    int N_CHANNELS;
-};
-
-float ChannelFeaturePool::apply(int fi, int si, const cv::Mat& integrals) const
-{
-    return pool[fi](integrals.row(si), model);
-}
-
-void ChannelFeaturePool::write( cv::FileStorage& fs, int index) const
-{
-
-    CV_Assert((index >= 0) && (index < (int)pool.size()));
-    fs << pool[index];
-}
-
-void ChannelFeaturePool::fill(int desired)
-{
-    using namespace cv::softcascade::internal;
-    int mw = model.width;
-    int mh = model.height;
-
-    int maxPoolSize = (mw -1) * mw / 2 * (mh - 1) * mh / 2 * N_CHANNELS;
-
-    int nfeatures = std::min(desired, maxPoolSize);
-    pool.reserve(nfeatures);
-
-    Random::engine eng((Random::seed_type)FEATURE_RECT_SEED);
-    Random::engine eng_ch(DCHANNELS_SEED);
-
-    Random::uniform chRand(0, N_CHANNELS - 1);
-
-    Random::uniform xRand(0, model.width  - 2);
-    Random::uniform yRand(0, model.height - 2);
-
-    Random::uniform wRand(1, model.width  - 1);
-    Random::uniform hRand(1, model.height - 1);
-
-    while (pool.size() < size_t(nfeatures))
-    {
-        int x = xRand(eng);
-        int y = yRand(eng);
-
-        int w = 1 + wRand(eng, model.width  - x - 1);
-        int h = 1 + hRand(eng, model.height - y - 1);
-
-        CV_Assert(w > 0);
-        CV_Assert(h > 0);
-
-        CV_Assert(w + x < model.width);
-        CV_Assert(h + y < model.height);
-
-        int ch = chRand(eng_ch);
-
-        ChannelFeature f(x, y, w, h, ch);
-
-        if (std::find(pool.begin(), pool.end(),f) == pool.end())
-        {
-            pool.push_back(f);
-        }
-    }
-}
-
-}
-
-cv::Ptr<FeaturePool> FeaturePool::create(const cv::Size& model, int nfeatures, int nchannels )
-{
-    cv::Ptr<FeaturePool> pool(new ChannelFeaturePool(model, nfeatures, nchannels));
-    return pool;
-}
diff --git a/modules/softcascade/src/octave.cpp b/modules/softcascade/src/octave.cpp
deleted file mode 100644 (file)
index 96b8c61..0000000
+++ /dev/null
@@ -1,458 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-#include "opencv2/ml.hpp"
-#include <queue>
-
-using cv::InputArray;
-using cv::OutputArray;
-using cv::Mat;
-
-using cv::softcascade::Octave;
-using cv::softcascade::FeaturePool;
-using cv::softcascade::Dataset;
-using cv::softcascade::ChannelFeatureBuilder;
-
-FeaturePool::~FeaturePool(){}
-Dataset::~Dataset(){}
-
-namespace {
-
-class BoostedSoftCascadeOctave : public cv::Boost, public Octave
-{
-public:
-
-    BoostedSoftCascadeOctave(cv::Rect boundingBox = cv::Rect(), int npositives = 0, int nnegatives = 0, int logScale = 0,
-        int shrinkage = 1, cv::Ptr<ChannelFeatureBuilder> builder = ChannelFeatureBuilder::create("HOG6MagLuv"));
-    virtual ~BoostedSoftCascadeOctave();
-    virtual cv::AlgorithmInfo* info() const;
-    virtual bool train(const Dataset* dataset, const FeaturePool* pool, int weaks, int treeDepth);
-    virtual void setRejectThresholds(OutputArray thresholds);
-    virtual void write( cv::FileStorage &fs, const FeaturePool* pool, InputArray thresholds) const;
-    virtual void write( CvFileStorage* fs, cv::String name) const;
-protected:
-    virtual float predict( InputArray _sample, InputArray _votes, bool raw_mode, bool return_sum ) const;
-    virtual bool train( const cv::Mat& trainData, const cv::Mat& responses, const cv::Mat& varIdx=cv::Mat(),
-       const cv::Mat& sampleIdx=cv::Mat(), const cv::Mat& varType=cv::Mat(), const cv::Mat& missingDataMask=cv::Mat());
-
-    void processPositives(const Dataset* dataset);
-    void generateNegatives(const Dataset* dataset);
-
-    float predict( const Mat& _sample, const cv::Range range) const;
-private:
-    void traverse(const CvBoostTree* tree, cv::FileStorage& fs, int& nfeatures, int* used, const double* th) const;
-    virtual void initialize_weights(double (&p)[2]);
-
-    int logScale;
-    cv::Rect boundingBox;
-
-    int npositives;
-    int nnegatives;
-
-    int shrinkage;
-
-    Mat integrals;
-    Mat responses;
-
-    CvBoostParams params;
-
-    Mat trainData;
-
-    cv::Ptr<ChannelFeatureBuilder> builder;
-};
-
-BoostedSoftCascadeOctave::BoostedSoftCascadeOctave(cv::Rect bb, int np, int nn, int ls, int shr,
-    cv::Ptr<ChannelFeatureBuilder> _builder)
-: logScale(ls), boundingBox(bb), npositives(np), nnegatives(nn), shrinkage(shr)
-{
-    int maxSample = npositives + nnegatives;
-    responses.create(maxSample, 1, CV_32FC1);
-
-    CvBoostParams _params;
-    {
-        // tree params
-        _params.max_categories       = 10;
-        _params.max_depth            = 2;
-        _params.cv_folds             = 0;
-        _params.truncate_pruned_tree = false;
-        _params.use_surrogates       = false;
-        _params.use_1se_rule         = false;
-        _params.regression_accuracy  = 0;
-
-        // boost params
-        _params.boost_type           = CvBoost::GENTLE;
-        _params.split_criteria       = CvBoost::SQERR;
-        _params.weight_trim_rate     = 0.95;
-
-        // simple defaults
-        _params.min_sample_count     = 0;
-        _params.weak_count           = 1;
-    }
-
-    params = _params;
-
-    builder = _builder;
-
-    int w = boundingBox.width;
-    int h = boundingBox.height;
-
-    integrals.create(npositives + nnegatives, (w / shrinkage + 1) * (h / shrinkage * builder->totalChannels() + 1), CV_32SC1);
-}
-
-BoostedSoftCascadeOctave::~BoostedSoftCascadeOctave(){}
-
-bool BoostedSoftCascadeOctave::train( const cv::Mat& _trainData, const cv::Mat& _responses, const cv::Mat& varIdx,
-       const cv::Mat& sampleIdx, const cv::Mat& varType, const cv::Mat& missingDataMask)
-{
-    bool update = false;
-    return cv::Boost::train(_trainData, CV_COL_SAMPLE, _responses, varIdx, sampleIdx, varType, missingDataMask, params,
-    update);
-}
-
-void BoostedSoftCascadeOctave::setRejectThresholds(cv::OutputArray _thresholds)
-{
-    // labels decided by classifier
-    cv::Mat desisions(responses.cols, responses.rows, responses.type());
-    float* dptr = desisions.ptr<float>(0);
-
-    // mask of samples satisfying the condition
-    cv::Mat ppmask(responses.cols, responses.rows, CV_8UC1);
-    uchar* mptr = ppmask.ptr<uchar>(0);
-
-    int nsamples = npositives + nnegatives;
-
-    cv::Mat stab;
-
-    for (int si = 0; si < nsamples; ++si)
-    {
-        float decision = dptr[si] = predict(trainData.col(si), stab, false, false);
-        mptr[si] = cv::saturate_cast<uchar>((unsigned int)( (responses.ptr<float>(si)[0] == 1.f) && (decision == 1.f)));
-    }
-
-    int weaks = weak->total;
-    _thresholds.create(1, weaks, CV_64FC1);
-    cv::Mat& thresholds = _thresholds.getMatRef();
-    double* thptr = thresholds.ptr<double>(0);
-
-    cv::Mat traces(weaks, nsamples, CV_64FC1, cv::Scalar::all(FLT_MAX));
-
-    for (int w = 0; w < weaks; ++w)
-    {
-        double* rptr = traces.ptr<double>(w);
-        for (int si = 0; si < nsamples; ++si)
-        {
-            cv::Range curr(0, w + 1);
-            if (mptr[si])
-            {
-                float trace = predict(trainData.col(si), curr);
-                rptr[si] = trace;
-            }
-        }
-        double mintrace = 0.;
-        cv::minMaxLoc(traces.row(w), &mintrace);
-        thptr[w] = mintrace;
-    }
-}
-
-void BoostedSoftCascadeOctave::processPositives(const Dataset* dataset)
-{
-    int h = boundingBox.height;
-
-    ChannelFeatureBuilder& _builder = *builder;
-
-    int total = 0;
-    for (int curr = 0; curr < dataset->available( Dataset::POSITIVE); ++curr)
-    {
-        cv::Mat sample = dataset->get( Dataset::POSITIVE, curr);
-
-        cv::Mat channels = integrals.row(total).reshape(0, h / shrinkage * builder->totalChannels() + 1);
-        sample = sample(boundingBox);
-
-        _builder(sample, channels);
-        responses.ptr<float>(total)[0] = 1.f;
-
-        if (++total >= npositives) break;
-    }
-    npositives  = total;
-    nnegatives = cvRound(nnegatives * total / (double)npositives);
-}
-
-void BoostedSoftCascadeOctave::generateNegatives(const Dataset* dataset)
-{
-    using namespace cv::softcascade::internal;
-    // ToDo: set seed, use offsets
-    Random::engine eng(DX_DY_SEED);
-    Random::engine idxEng((Random::seed_type)INDEX_ENGINE_SEED);
-
-    int h = boundingBox.height;
-
-    int nimages = dataset->available(Dataset::NEGATIVE);
-    Random::uniform iRand(0, nimages - 1);
-
-    int total = 0;
-    Mat sum;
-
-    ChannelFeatureBuilder& _builder = *builder;
-    for (int i = npositives; i < nnegatives + npositives; ++total)
-    {
-        int curr = iRand(idxEng);
-
-        Mat frame = dataset->get(Dataset::NEGATIVE, curr);
-
-        int maxW = frame.cols - 2 * boundingBox.x - boundingBox.width;
-        int maxH = frame.rows - 2 * boundingBox.y - boundingBox.height;
-
-        Random::uniform wRand(0, maxW -1);
-        Random::uniform hRand(0, maxH -1);
-
-        int dx = wRand(eng);
-        int dy = hRand(eng);
-
-        frame = frame(cv::Rect(dx, dy, boundingBox.width, boundingBox.height));
-
-        cv::Mat channels = integrals.row(i).reshape(0, h / shrinkage * builder->totalChannels() + 1);
-        _builder(frame, channels);
-
-        // // if (predict(sum))
-        {
-            responses.ptr<float>(i)[0] = 0.f;
-            ++i;
-        }
-    }
-}
-
-
-template <typename T> int sgn(T val) {
-    return (T(0) < val) - (val < T(0));
-}
-
-void BoostedSoftCascadeOctave::traverse(const CvBoostTree* tree, cv::FileStorage& fs, int& nfeatures, int* used, const double* th) const
-{
-    std::queue<const CvDTreeNode*> nodes;
-    nodes.push( tree->get_root());
-    const CvDTreeNode* tempNode;
-    int leafValIdx = 0;
-    int internalNodeIdx = 1;
-    float* leafs = new float[(int)pow(2.f, get_params().max_depth)];
-
-    fs << "{";
-    fs << "treeThreshold" << *th;
-    fs << "internalNodes" << "[";
-    while (!nodes.empty())
-    {
-        tempNode = nodes.front();
-        CV_Assert( tempNode->left );
-        if ( !tempNode->left->left && !tempNode->left->right)
-        {
-            leafs[-leafValIdx] = (float)tempNode->left->value;
-            fs << leafValIdx-- ;
-        }
-        else
-        {
-            nodes.push( tempNode->left );
-            fs << internalNodeIdx++;
-        }
-        CV_Assert( tempNode->right );
-        if ( !tempNode->right->left && !tempNode->right->right)
-        {
-            leafs[-leafValIdx] = (float)tempNode->right->value;
-            fs << leafValIdx--;
-        }
-        else
-        {
-            nodes.push( tempNode->right );
-            fs << internalNodeIdx++;
-        }
-
-        int fidx = tempNode->split->var_idx;
-        fs << nfeatures;
-        used[nfeatures++] = fidx;
-
-        fs << tempNode->split->ord.c;
-
-        nodes.pop();
-    }
-    fs << "]";
-
-    fs << "leafValues" << "[";
-    for (int ni = 0; ni < -leafValIdx; ni++)
-        fs << leafs[ni];
-    fs << "]";
-
-
-    fs << "}";
-
-    delete [] leafs;
-}
-
-void BoostedSoftCascadeOctave::write( cv::FileStorage &fso, const FeaturePool* pool, InputArray _thresholds) const
-{
-    CV_Assert(!_thresholds.empty());
-    cv::Mat used( 1, weak->total * ( (int)pow(2.f, params.max_depth) - 1), CV_32SC1);
-    int* usedPtr = used.ptr<int>(0);
-    int nfeatures = 0;
-    cv::Mat thresholds = _thresholds.getMat();
-    fso << "{"
-        << "scale" << logScale
-        << "weaks" << weak->total
-        << "trees" << "[";
-        // should be replaced with the H.L. one
-        CvSeqReader reader;
-        cvStartReadSeq( weak, &reader);
-
-        for(int i = 0; i < weak->total; i++ )
-        {
-            CvBoostTree* tree;
-            CV_READ_SEQ_ELEM( tree, reader );
-
-            traverse(tree, fso, nfeatures, usedPtr, thresholds.ptr<double>(0) + i);
-        }
-    fso << "]";
-    // features
-
-    fso << "features" << "[";
-    for (int i = 0; i < nfeatures; ++i)
-        pool->write(fso, usedPtr[i]);
-    fso << "]"
-        << "}";
-}
-
-void BoostedSoftCascadeOctave::initialize_weights(double (&p)[2])
-{
-    double n = data->sample_count;
-    p[0] =  n / (2. * (double)(nnegatives));
-    p[1] =  n / (2. * (double)(npositives));
-}
-
-bool BoostedSoftCascadeOctave::train(const Dataset* dataset, const FeaturePool* pool, int weaks, int treeDepth)
-{
-    CV_Assert(treeDepth == 2);
-    CV_Assert(weaks > 0);
-
-    params.max_depth  = treeDepth;
-    params.weak_count = weaks;
-
-    // 1. fill integrals and classes
-    processPositives(dataset);
-    generateNegatives(dataset);
-
-    // 2. only simple case (all features used)
-    int nfeatures = pool->size();
-    cv::Mat varIdx(1, nfeatures, CV_32SC1);
-    int* ptr = varIdx.ptr<int>(0);
-
-    for (int x = 0; x < nfeatures; ++x)
-        ptr[x] = x;
-
-    // 3. only simple case (all samples used)
-    int nsamples = npositives + nnegatives;
-    cv::Mat sampleIdx(1, nsamples, CV_32SC1);
-    ptr = sampleIdx.ptr<int>(0);
-
-    for (int x = 0; x < nsamples; ++x)
-        ptr[x] = x;
-
-    // 4. ICF has an ordered response.
-    cv::Mat varType(1, nfeatures + 1, CV_8UC1);
-    uchar* uptr = varType.ptr<uchar>(0);
-    for (int x = 0; x < nfeatures; ++x)
-        uptr[x] = CV_VAR_ORDERED;
-    uptr[nfeatures] = CV_VAR_CATEGORICAL;
-
-    trainData.create(nfeatures, nsamples, CV_32FC1);
-    for (int fi = 0; fi < nfeatures; ++fi)
-    {
-        float* dptr = trainData.ptr<float>(fi);
-        for (int si = 0; si < nsamples; ++si)
-        {
-            dptr[si] = pool->apply(fi, si, integrals);
-        }
-    }
-
-    cv::Mat missingMask;
-
-    bool ok = train(trainData, responses, varIdx, sampleIdx, varType, missingMask);
-    if (!ok)
-        CV_Error(CV_StsInternal, "ERROR: tree can not be trained");
-    return ok;
-
-}
-
-float BoostedSoftCascadeOctave::predict( cv::InputArray _sample, cv::InputArray _votes, bool raw_mode, bool return_sum ) const
-{
-    cv::Mat sample = _sample.getMat();
-    CvMat csample = sample;
-    if (_votes.empty())
-        return CvBoost::predict(&csample, 0, 0, CV_WHOLE_SEQ, raw_mode, return_sum);
-    else
-    {
-        cv::Mat votes = _votes.getMat();
-        CvMat cvotes = votes;
-        return CvBoost::predict(&csample, 0, &cvotes, CV_WHOLE_SEQ, raw_mode, return_sum);
-    }
-}
-
-float BoostedSoftCascadeOctave::predict( const Mat& _sample, const cv::Range range) const
-{
-    CvMat sample = _sample;
-    return CvBoost::predict(&sample, 0, 0, range, false, true);
-}
-
-void BoostedSoftCascadeOctave::write( CvFileStorage* fs, cv::String _name) const
-{
-    CvBoost::write(fs, _name.c_str());
-}
-
-}
-
-CV_INIT_ALGORITHM(BoostedSoftCascadeOctave, "Octave.BoostedSoftCascadeOctave", )
-
-Octave::~Octave(){}
-
-cv::Ptr<Octave> Octave::create(cv::Rect boundingBox, int npositives, int nnegatives,
-        int logScale, int shrinkage, cv::Ptr<ChannelFeatureBuilder> builder)
-{
-    cv::Ptr<Octave> octave(
-        new BoostedSoftCascadeOctave(boundingBox, npositives, nnegatives, logScale, shrinkage, builder));
-    return octave;
-}
diff --git a/modules/softcascade/src/precomp.hpp b/modules/softcascade/src/precomp.hpp
deleted file mode 100644 (file)
index ec5011b..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_PRECOMP_H__
-#define __OPENCV_PRECOMP_H__
-
-#include <iostream>
-
-#include "opencv2/softcascade.hpp"
-#include "opencv2/imgproc.hpp"
-
-#include "opencv2/core/private.hpp"
-#include "opencv2/core/private.cuda.hpp"
-
-namespace cv { namespace softcascade { namespace internal
-{
-
-namespace rnd {
-
-typedef cv::RNG_MT19937 engine;
-
-template<typename T>
-struct uniform_int
-{
-    uniform_int(const int _min, const int _max) : min(_min), max(_max) {}
-    T operator() (engine& eng, const int bound) const
-    {
-        return (T)eng.uniform(min, bound);
-    }
-
-    T operator() (engine& eng) const
-    {
-        return (T)eng.uniform(min, max);
-    }
-
-private:
-    int min;
-    int max;
-};
-
-}
-
-struct Random
-{
-    typedef rnd::engine engine;
-    typedef uint64 seed_type;
-    typedef rnd::uniform_int<int> uniform;
-};
-
-}}}
-
-#define FEATURE_RECT_SEED      88543422U
-#define INDEX_ENGINE_SEED      76422434U
-#define DCHANNELS_SEED         314152314U
-#define DX_DY_SEED             65633343U
-
-#endif
diff --git a/modules/softcascade/src/softcascade_init.cpp b/modules/softcascade/src/softcascade_init.cpp
deleted file mode 100644 (file)
index 59a33f8..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "precomp.hpp"
-
-namespace cv { namespace softcascade
-{
-
-CV_INIT_ALGORITHM(Detector, "SoftCascade.Detector",
-                  obj.info()->addParam(obj, "minScale",    obj.minScale);
-                  obj.info()->addParam(obj, "maxScale",    obj.maxScale);
-                  obj.info()->addParam(obj, "scales",      obj.scales);
-                  obj.info()->addParam(obj, "rejCriteria", obj.rejCriteria))
-
-CV_INIT_ALGORITHM(SCascade, "CascadeDetector.SCascade",
-                  obj.info()->addParam(obj, "minScale", obj.minScale);
-                  obj.info()->addParam(obj, "maxScale", obj.maxScale);
-                  obj.info()->addParam(obj, "scales",   obj.scales))
-
-bool initModule_softcascade(void)
-{
-    Ptr<Algorithm> sc = createSCascade_ptr_hidden();
-    Ptr<Algorithm> sc1 = createDetector_ptr_hidden();
-    return (sc1->info() != 0) && (sc->info() != 0);
-}
-
-} }
diff --git a/modules/softcascade/test/test_channel_features.cpp b/modules/softcascade/test/test_channel_features.cpp
deleted file mode 100644 (file)
index 07b8957..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-using namespace cv::softcascade;
-
-TEST(ChannelFeatureBuilderTest, info)
-{
-    cv::Ptr<ChannelFeatureBuilder> builder = ChannelFeatureBuilder::create("HOG6MagLuv");
-    ASSERT_TRUE(builder->info() != 0);
-}
-
-TEST(ChannelFeatureBuilderTest, compute)
-{
-    cv::Ptr<ChannelFeatureBuilder> builder = ChannelFeatureBuilder::create("HOG6MagLuv");
-
-    cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path()  + "cascadeandhog/images/image_00000000_0.png");
-    cv::Mat ints;
-    (*builder)(colored, ints);
-
-    ASSERT_FALSE(ints.empty());
-}
diff --git a/modules/softcascade/test/test_cuda_softcascade.cpp b/modules/softcascade/test/test_cuda_softcascade.cpp
deleted file mode 100644 (file)
index 9aa5f8a..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-#include "opencv2/core/cuda.hpp"
-
-
-#ifdef HAVE_CUDA
-using std::tr1::get;
-
-// show detection results on input image with cv::imshow
-//#define SHOW_DETECTIONS
-
-#if defined SHOW_DETECTIONS
-# define SHOW(res)           \
-    cv::imshow(#res, res);   \
-    cv::waitKey(0);
-#else
-# define SHOW(res)
-#endif
-
-static std::string path(std::string relative)
-{
-    return cvtest::TS::ptr()->get_data_path() + "cascadeandhog/" + relative;
-}
-
-TEST(SCascadeTest, readCascade)
-{
-    std::string xml = path("cascades/inria_caltech-17.01.2013.xml");
-    cv::FileStorage fs(xml, cv::FileStorage::READ);
-
-    cv::softcascade::SCascade cascade;
-
-    ASSERT_TRUE(fs.isOpened());
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-}
-
-namespace
-{
-    typedef cv::softcascade::Detection Detection;
-
-    cv::Rect getFromTable(int idx)
-    {
-        static const cv::Rect rois[] =
-        {
-            cv::Rect( 65 * 4,  20 * 4,  35 * 4, 80 * 4),
-            cv::Rect( 95 * 4,  35 * 4,  45 * 4, 40 * 4),
-            cv::Rect( 45 * 4,  35 * 4,  45 * 4, 40 * 4),
-            cv::Rect( 25 * 4,  27 * 4,  50 * 4, 45 * 4),
-            cv::Rect(100 * 4,  50 * 4,  45 * 4, 40 * 4),
-
-            cv::Rect( 60 * 4,  30 * 4,  45 * 4, 40 * 4),
-            cv::Rect( 40 * 4,  55 * 4,  50 * 4, 40 * 4),
-            cv::Rect( 48 * 4,  37 * 4,  72 * 4, 80 * 4),
-            cv::Rect( 48 * 4,  32 * 4,  85 * 4, 58 * 4),
-            cv::Rect( 48 * 4,   0 * 4,  32 * 4, 27 * 4)
-        };
-
-        return rois[idx];
-    }
-
-    void print(std::ostream &out, const Detection& d)
-    {
-    #if defined SHOW_DETECTIONS
-        out << "\x1b[32m[ detection]\x1b[0m ("
-            << std::setw(4)  << d.x
-            << " "
-            << std::setw(4)  << d.y
-            << ") ("
-            << std::setw(4)  << d.w
-            << " "
-            << std::setw(4)  << d.h
-            << ") "
-            << std::setw(12) << d.confidence
-            <<  std::endl;
-    #else
-        (void)out; (void)d;
-    #endif
-    }
-
-    void printTotal(std::ostream &out, int detbytes)
-    {
-    #if defined SHOW_DETECTIONS
-        out << "\x1b[32m[          ]\x1b[0m Total detections " << (detbytes / sizeof(Detection)) << std::endl;
-    #else
-        (void)out; (void)detbytes;
-    #endif
-    }
-
-    std::string itoa(long i)
-    {
-        static char s[65];
-        sprintf(s, "%ld", i);
-        return std::string(s);
-    }
-
-#if defined SHOW_DETECTIONS
-    std::string getImageName(int level)
-    {
-        time_t rawtime;
-        struct tm * timeinfo;
-        char buffer [80];
-
-        time ( &rawtime );
-        timeinfo = localtime ( &rawtime );
-
-        strftime (buffer,80,"%Y-%m-%d--%H-%M-%S",timeinfo);
-        return "gpu_rec_level_" + itoa(level)+ "_" + std::string(buffer) + ".png";
-    }
-
-    void writeResult(const cv::Mat& result, const int level)
-    {
-        std::string path = cv::tempfile(getImageName(level).c_str());
-        cv::imwrite(path, result);
-        std::cout << "\x1b[32m" << "[          ]" << std::endl << "[ stored in]"<< "\x1b[0m" << path << std::endl;
-    }
-#endif
-}
-
-class SCascadeTestRoi : public ::testing::TestWithParam<std::tr1::tuple<cv::cuda::DeviceInfo, std::string, std::string, int> >
-{
-    virtual void SetUp()
-    {
-        cv::cuda::setDevice(get<0>(GetParam()).deviceID());
-    }
-};
-
-TEST_P(SCascadeTestRoi, Detect)
-{
-    cv::Mat coloredCpu = cv::imread(path(get<2>(GetParam())));
-    ASSERT_FALSE(coloredCpu.empty());
-
-    cv::softcascade::SCascade cascade;
-
-    cv::FileStorage fs(path(get<1>(GetParam())), cv::FileStorage::READ);
-    ASSERT_TRUE(fs.isOpened());
-
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-
-    cv::cuda::GpuMat colored(coloredCpu), objectBoxes(1, 16384, CV_8UC1), rois(colored.size(), CV_8UC1);
-    rois.setTo(0);
-
-    int nroi = get<3>(GetParam());
-    cv::Mat result(coloredCpu);
-    cv::RNG rng;
-    for (int i = 0; i < nroi; ++i)
-    {
-        cv::Rect r = getFromTable(rng(10));
-        cv::cuda::GpuMat sub(rois, r);
-        sub.setTo(1);
-        cv::rectangle(result, r, cv::Scalar(0, 0, 255, 255), 1);
-    }
-    objectBoxes.setTo(0);
-
-    cascade.detect(colored, rois, objectBoxes);
-
-    cv::Mat dt(objectBoxes);
-    typedef cv::softcascade::Detection Detection;
-
-    Detection* dts = ((Detection*)dt.data) + 1;
-    int* count = dt.ptr<int>(0);
-
-    printTotal(std::cout, *count);
-
-    for (int i = 0; i  < *count; ++i)
-    {
-        Detection d = dts[i];
-        print(std::cout, d);
-        cv::rectangle(result, cv::Rect(d.x, d.y, d.w, d.h), cv::Scalar(255, 0, 0, 255), 1);
-    }
-
-    SHOW(result);
-}
-
-INSTANTIATE_TEST_CASE_P(cuda_accelerated, SCascadeTestRoi, testing::Combine(
-    ALL_DEVICES,
-    testing::Values(std::string("cascades/inria_caltech-17.01.2013.xml"),
-                    std::string("cascades/sc_cvpr_2012_to_opencv_new_format.xml")),
-    testing::Values(std::string("images/image_00000000_0.png")),
-    testing::Range(0, 5)));
-
-namespace {
-
-struct Fixture
-{
-    std::string path;
-    int expected;
-
-    Fixture(){}
-    Fixture(std::string p, int e): path(p), expected(e) {}
-};
-}
-
-typedef std::tr1::tuple<cv::cuda::DeviceInfo, Fixture> SCascadeTestAllFixture;
-class SCascadeTestAll : public ::testing::TestWithParam<SCascadeTestAllFixture>
-{
-protected:
-    std::string xml;
-    int expected;
-
-    virtual void SetUp()
-    {
-        cv::cuda::setDevice(get<0>(GetParam()).deviceID());
-        xml = path(get<1>(GetParam()).path);
-        expected = get<1>(GetParam()).expected;
-    }
-};
-
-TEST_P(SCascadeTestAll, detect)
-{
-    cv::softcascade::SCascade cascade;
-
-    cv::FileStorage fs(xml, cv::FileStorage::READ);
-    ASSERT_TRUE(fs.isOpened());
-
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-
-    cv::Mat coloredCpu = cv::imread(path("images/image_00000000_0.png"));
-    ASSERT_FALSE(coloredCpu.empty());
-
-    cv::cuda::GpuMat colored(coloredCpu), objectBoxes, rois(colored.size(), CV_8UC1);
-    rois.setTo(1);
-
-    cascade.detect(colored, rois, objectBoxes);
-
-    typedef cv::softcascade::Detection Detection;
-    cv::Mat dt(objectBoxes);
-
-
-    Detection* dts = ((Detection*)dt.data) + 1;
-    int* count = dt.ptr<int>(0);
-
-    printTotal(std::cout, *count);
-
-    for (int i = 0; i  < *count; ++i)
-    {
-        Detection d = dts[i];
-        print(std::cout, d);
-        cv::rectangle(coloredCpu, cv::Rect(d.x, d.y, d.w, d.h), cv::Scalar(255, 0, 0, 255), 1);
-    }
-
-    SHOW(coloredCpu);
-    ASSERT_EQ(*count, expected);
-}
-
-TEST_P(SCascadeTestAll, detectStream)
-{
-    cv::softcascade::SCascade cascade;
-
-    cv::FileStorage fs(xml, cv::FileStorage::READ);
-    ASSERT_TRUE(fs.isOpened());
-
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-
-    cv::Mat coloredCpu = cv::imread(path("images/image_00000000_0.png"));
-    ASSERT_FALSE(coloredCpu.empty());
-
-    cv::cuda::GpuMat colored(coloredCpu), objectBoxes(1, 100000, CV_8UC1), rois(colored.size(), CV_8UC1);
-    rois.setTo(cv::Scalar::all(1));
-
-    cv::cuda::Stream s;
-
-    objectBoxes.setTo(0);
-    cascade.detect(colored, rois, objectBoxes, s);
-    s.waitForCompletion();
-
-    typedef cv::softcascade::Detection Detection;
-    cv::Mat detections(objectBoxes);
-    int a = *(detections.ptr<int>(0));
-    ASSERT_EQ(a, expected);
-}
-
-INSTANTIATE_TEST_CASE_P(cuda_accelerated, SCascadeTestAll, testing::Combine( ALL_DEVICES,
-                    testing::Values(Fixture("cascades/inria_caltech-17.01.2013.xml", 7),
-                                    Fixture("cascades/sc_cvpr_2012_to_opencv_new_format.xml", 1291))));
-
-#endif
diff --git a/modules/softcascade/test/test_main.cpp b/modules/softcascade/test/test_main.cpp
deleted file mode 100644 (file)
index d3999d4..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-CV_TEST_MAIN("cv")
diff --git a/modules/softcascade/test/test_precomp.hpp b/modules/softcascade/test/test_precomp.hpp
deleted file mode 100644 (file)
index 4a39744..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifdef __GNUC__
-#  pragma GCC diagnostic ignored "-Wmissing-declarations"
-#  if defined __clang__ || defined __APPLE__
-#    pragma GCC diagnostic ignored "-Wmissing-prototypes"
-#    pragma GCC diagnostic ignored "-Wextra"
-#  endif
-#endif
-
-#ifndef __OPENCV_TEST_PRECOMP_HPP__
-#define __OPENCV_TEST_PRECOMP_HPP__
-
-#include "opencv2/ts.hpp"
-#include "opencv2/softcascade.hpp"
-#include "opencv2/imgproc.hpp"
-#include "opencv2/highgui.hpp"
-#include "cvconfig.h"
-#include "utility.hpp"
-
-#endif
diff --git a/modules/softcascade/test/test_softcascade.cpp b/modules/softcascade/test/test_softcascade.cpp
deleted file mode 100644 (file)
index 59d5c3c..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include <string>
-#include <fstream>
-
-#include "test_precomp.hpp"
-
-using namespace cv::softcascade;
-
-TEST(SoftCascadeDetector, readCascade)
-{
-    std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
-     Detector cascade;
-    cv::FileStorage fs(xml, cv::FileStorage::READ);
-    ASSERT_TRUE(fs.isOpened());
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-}
-
-TEST(SoftCascadeDetector, detect)
-{
-    std::string xml =  cvtest::TS::ptr()->get_data_path()+ "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
-    Detector cascade;
-    cv::FileStorage fs(xml, cv::FileStorage::READ);
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-
-    cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path()  + "cascadeandhog/images/image_00000000_0.png");
-    ASSERT_FALSE(colored.empty());
-
-    std::vector<Detection> objects;
-    cascade.detect(colored, cv::noArray(), objects);
-
-    ASSERT_EQ(719, (int)objects.size());
-}
-
-TEST(SoftCascadeDetector, detectSeparate)
-{
-    std::string xml =  cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
-    Detector cascade;
-    cv::FileStorage fs(xml, cv::FileStorage::READ);
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-
-    cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/images/image_00000000_0.png");
-    ASSERT_FALSE(colored.empty());
-
-    cv::Mat rects, confs;
-
-    cascade.detect(colored, cv::noArray(), rects, confs);
-    ASSERT_EQ(719, confs.cols);
-}
-
-TEST(SoftCascadeDetector, detectRoi)
-{
-    std::string xml =  cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
-    Detector cascade;
-    cv::FileStorage fs(xml, cv::FileStorage::READ);
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-
-    cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/images/image_00000000_0.png");
-    ASSERT_FALSE(colored.empty());
-
-    std::vector<Detection> objects;
-    std::vector<cv::Rect> rois;
-    rois.push_back(cv::Rect(0, 0, 640, 480));
-
-    cascade.detect(colored, rois, objects);
-    ASSERT_EQ(719, (int)objects.size());
-}
-
-TEST(SoftCascadeDetector, detectNoRoi)
-{
-    std::string xml =  cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
-    Detector cascade;
-    cv::FileStorage fs(xml, cv::FileStorage::READ);
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-
-    cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/images/image_00000000_0.png");
-    ASSERT_FALSE(colored.empty());
-
-    std::vector<Detection> objects;
-    std::vector<cv::Rect> rois;
-
-    cascade.detect(colored, rois, objects);
-
-    ASSERT_EQ(719, (int)objects.size());
-}
-
-TEST(SoftCascadeDetector, detectEmptyRoi)
-{
-    std::string xml =  cvtest::TS::ptr()->get_data_path() + "cascadeandhog/cascades/inria_caltech-17.01.2013.xml";
-    Detector cascade;
-    cv::FileStorage fs(xml, cv::FileStorage::READ);
-    ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
-
-    cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/images/image_00000000_0.png");
-    ASSERT_FALSE(colored.empty());
-
-    std::vector<Detection> objects;
-    cascade.detect(colored, cv::Mat::zeros(colored.size(), CV_8UC1), objects);
-
-    ASSERT_EQ(0, (int)objects.size());
-}
diff --git a/modules/softcascade/test/test_training.cpp b/modules/softcascade/test/test_training.cpp
deleted file mode 100644 (file)
index 5ade816..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                           License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
-// Copyright (C) 2008-2013, Willow Garage Inc., all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and / or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#if !defined(ANDROID)
-
-#include <test_precomp.hpp>
-#include <string>
-#include <fstream>
-#include <vector>
-
-using namespace std;
-
-namespace {
-
-using namespace cv::softcascade;
-
-typedef vector<cv::String> svector;
-class ScaledDataset : public Dataset
-{
-public:
-    ScaledDataset(const string& path, const int octave);
-
-    virtual cv::Mat get(SampleType type, int idx) const;
-    virtual int available(SampleType type) const;
-    virtual ~ScaledDataset();
-
-private:
-    svector pos;
-    svector neg;
-};
-
-ScaledDataset::ScaledDataset(const string& path, const int oct)
-{
-    cv::glob(path + cv::format("/octave_%d/*.png", oct), pos);
-    cv::glob(path + "/*.png", neg);
-
-    // Check: files not empty
-    CV_Assert(pos.size() != size_t(0));
-    CV_Assert(neg.size() != size_t(0));
-}
-
-cv::Mat ScaledDataset::get(SampleType type, int idx) const
-{
-    const std::string& src = (type == POSITIVE)? pos[idx]: neg[idx];
-    return cv::imread(src);
-}
-
-int ScaledDataset::available(SampleType type) const
-{
-    return (int)((type == POSITIVE)? pos.size():neg.size());
-}
-
-ScaledDataset::~ScaledDataset(){}
-
-}
-
-TEST(SoftCascade, training)
-{
-    // // 2. check and open output file
-    string outXmlPath = cv::tempfile(".xml");
-    cv::FileStorage fso(outXmlPath, cv::FileStorage::WRITE);
-
-    ASSERT_TRUE(fso.isOpened());
-
-    std::vector<int> octaves;
-    {
-        octaves.push_back(-1);
-        octaves.push_back(0);
-    }
-
-    fso << "regression-cascade"
-        << "{"
-        << "stageType"   << "BOOST"
-        << "featureType" << "ICF"
-        << "octavesNum"  << 2
-        << "width"       << 64
-        << "height"      << 128
-        << "shrinkage"   << 4
-        << "octaves"     << "[";
-
-    for (std::vector<int>::const_iterator it = octaves.begin(); it != octaves.end(); ++it)
-    {
-        int nfeatures  = 100;
-        int shrinkage = 4;
-        float octave = powf(2.f, (float)(*it));
-        cv::Size model = cv::Size( cvRound(64 * octave) / shrinkage, cvRound(128 * octave) / shrinkage );
-
-        cv::Ptr<FeaturePool> pool = FeaturePool::create(model, nfeatures, 10);
-        nfeatures = pool->size();
-        int npositives = 10;
-        int nnegatives = 20;
-
-        cv::Rect boundingBox = cv::Rect( cvRound(20 * octave), cvRound(20  * octave),
-                                         cvRound(64 * octave), cvRound(128 * octave));
-
-        cv::Ptr<ChannelFeatureBuilder> builder = ChannelFeatureBuilder::create("HOG6MagLuv");
-        cv::Ptr<Octave> boost = Octave::create(boundingBox, npositives, nnegatives, *it, shrinkage, builder);
-
-        std::string path = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/sample_training_set";
-        ScaledDataset dataset(path, *it);
-
-        if (boost->train(&dataset, pool, 3, 2))
-        {
-            cv::Mat thresholds;
-            boost->setRejectThresholds(thresholds);
-            boost->write(fso, pool, thresholds);
-        }
-    }
-
-    fso << "]" << "}";
-    fso.release();
-
-
-    cv::FileStorage actual(outXmlPath, cv::FileStorage::READ);
-    cv::FileNode root = actual.getFirstTopLevelNode();
-
-    cv::FileNode fn = root["octaves"];
-    ASSERT_FALSE(fn.empty());
-}
-
-#endif
diff --git a/modules/softcascade/test/utility.cpp b/modules/softcascade/test/utility.cpp
deleted file mode 100644 (file)
index b4e17a9..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "test_precomp.hpp"
-
-#ifdef HAVE_CUDA
-
-
-using namespace std;
-using namespace cv;
-using namespace cv::cuda;
-using namespace cvtest;
-using namespace testing;
-using namespace testing::internal;
-
-//////////////////////////////////////////////////////////////////////
-// Gpu devices
-
-bool supportFeature(const DeviceInfo& info, FeatureSet feature)
-{
-    return TargetArchs::builtWith(feature) && info.supports(feature);
-}
-
-DeviceManager& DeviceManager::instance()
-{
-    static DeviceManager obj;
-    return obj;
-}
-
-void DeviceManager::load(int i)
-{
-    devices_.clear();
-    devices_.reserve(1);
-
-    std::ostringstream msg;
-
-    if (i < 0 || i >= getCudaEnabledDeviceCount())
-    {
-        msg << "Incorrect device number - " << i;
-        CV_Error(cv::Error::StsBadArg, msg.str());
-    }
-
-    DeviceInfo info(i);
-
-    if (!info.isCompatible())
-    {
-        msg << "Device " << i << " [" << info.name() << "] is NOT compatible with current CUDA module build";
-        CV_Error(cv::Error::StsBadArg, msg.str());
-    }
-
-    devices_.push_back(info);
-}
-
-void DeviceManager::loadAll()
-{
-    int deviceCount = getCudaEnabledDeviceCount();
-
-    devices_.clear();
-    devices_.reserve(deviceCount);
-
-    for (int i = 0; i < deviceCount; ++i)
-    {
-        DeviceInfo info(i);
-        if (info.isCompatible())
-        {
-            devices_.push_back(info);
-        }
-    }
-}
-
-#endif // HAVE_CUDA
diff --git a/modules/softcascade/test/utility.hpp b/modules/softcascade/test/utility.hpp
deleted file mode 100644 (file)
index 81b937f..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef __OPENCV_SOFTCASCADE_TEST_UTILITY_HPP__
-#define __OPENCV_SOFTCASCADE_TEST_UTILITY_HPP__
-
-#include "opencv2/core.hpp"
-#include "opencv2/core/cuda.hpp"
-#include "opencv2/ts.hpp"
-
-//////////////////////////////////////////////////////////////////////
-// Gpu devices
-//! return true if device supports specified feature and gpu module was built with support the feature.
-bool supportFeature(const cv::cuda::DeviceInfo& info, cv::cuda::FeatureSet feature);
-
-
-#if defined(HAVE_CUDA)
-class DeviceManager
-{
-public:
-    static DeviceManager& instance();
-
-    void load(int i);
-    void loadAll();
-
-    const std::vector<cv::cuda::DeviceInfo>& values() const { return devices_; }
-
-private:
-    std::vector<cv::cuda::DeviceInfo> devices_;
-    DeviceManager() {loadAll();}
-};
-# define ALL_DEVICES testing::ValuesIn(DeviceManager::instance().values())
-#else
-# define ALL_DEVICES testing::ValuesIn(std::vector<cv::cuda::DeviceInfo>())
-#endif
-
-#endif // __OPENCV_CUDA_TEST_UTILITY_HPP__
index 36b68d2..e1021de 100644 (file)
@@ -10,7 +10,6 @@ if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
 #
 # ----------------------------------------------------------------------------
 
-add_subdirectory(c)
 add_subdirectory(cpp)
 add_subdirectory(gpu)
 add_subdirectory(tapi)
@@ -60,7 +59,6 @@ if(MSVC)
   endif()
 endif()
 
-add_subdirectory(c)
 add_subdirectory(cpp)
 # FIXIT: can't use cvconfig.h in samples: add_subdirectory(gpu)
 
diff --git a/samples/c/CMakeLists.txt b/samples/c/CMakeLists.txt
deleted file mode 100644 (file)
index 260f6f6..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-# ----------------------------------------------------------------------------
-#  CMake file for C samples. See root CMakeLists.txt
-#
-# ----------------------------------------------------------------------------
-
-SET(OPENCV_C_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc
-    opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo opencv_nonfree
-    opencv_features2d opencv_calib3d opencv_legacy opencv_contrib)
-
-ocv_check_dependencies(${OPENCV_C_SAMPLES_REQUIRED_DEPS})
-
-if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
-  project(c_samples)
-
-  if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
-  endif()
-
-  ocv_include_modules(${OPENCV_C_SAMPLES_REQUIRED_DEPS})
-
-  # ---------------------------------------------
-  #      Define executable targets
-  # ---------------------------------------------
-  MACRO(OPENCV_DEFINE_C_EXAMPLE name srcs)
-    set(the_target "example_${name}")
-    add_executable(${the_target} ${srcs})
-    target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_C_SAMPLES_REQUIRED_DEPS})
-
-    set_target_properties(${the_target} PROPERTIES
-      OUTPUT_NAME "c-example-${name}"
-      PROJECT_LABEL "(EXAMPLE) ${name}")
-
-    if(ENABLE_SOLUTION_FOLDERS)
-      set_target_properties(${the_target} PROPERTIES FOLDER "samples//c")
-    endif()
-
-    if(WIN32)
-      if(MSVC AND NOT BUILD_SHARED_LIBS)
-        set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
-      endif()
-      install(TARGETS ${the_target}
-              RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/c" COMPONENT samples)
-    endif()
-  ENDMACRO()
-
-  file(GLOB cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.c)
-
-  foreach(sample_filename ${cpp_samples})
-    get_filename_component(sample ${sample_filename} NAME_WE)
-    OPENCV_DEFINE_C_EXAMPLE(${sample} ${sample_filename})
-  endforeach()
-endif()
-
-if(INSTALL_C_EXAMPLES AND NOT WIN32)
-  file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
-  install(FILES ${C_SAMPLES}
-          DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/c
-          PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
-endif ()
diff --git a/samples/c/JCB.png b/samples/c/JCB.png
deleted file mode 100644 (file)
index 243602a..0000000
Binary files a/samples/c/JCB.png and /dev/null differ
diff --git a/samples/c/adaptiveskindetector.cpp b/samples/c/adaptiveskindetector.cpp
deleted file mode 100644 (file)
index ac9057d..0000000
+++ /dev/null
@@ -1,415 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install, copy or use the software.
-//
-// Copyright (C) 2009, Farhad Dadgostar
-// Intel Corporation and third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include <iostream>
-#include <cstdio>
-#include <cstring>
-#include <ctime>
-#include "opencv2/contrib/compat.hpp"
-#include "opencv2/highgui/highgui_c.h"
-
-#ifndef _CRT_SECURE_NO_WARNINGS
-# define _CRT_SECURE_NO_WARNINGS
-#endif
-
-static void help(char **argv)
-{
-    std::cout << "\nThis program demonstrates the contributed flesh detector CvAdaptiveSkinDetector which can be found in contrib.cpp\n"
-            << "Usage: " << std::endl <<
-        argv[0] << " fileMask firstFrame lastFrame" << std::endl << std::endl <<
-        "Example: " << std::endl <<
-        argv[0] << " C:\\VideoSequences\\sample1\\right_view\\temp_%05d.jpg  0  1000" << std::endl <<
-        "   iterates through temp_00000.jpg  to  temp_01000.jpg" << std::endl << std::endl <<
-        "If no parameter specified, this application will try to capture from the default Webcam." << std::endl <<
-        "Please note: Background should not contain large surfaces with skin tone." <<
-        "\n\n ESC will stop\n"
-        "Using OpenCV version %s\n" << CV_VERSION << "\n"
-        << std::endl;
-}
-
-class ASDFrameHolder
-{
-private:
-    IplImage *image;
-    double timeStamp;
-
-public:
-    ASDFrameHolder();
-    virtual ~ASDFrameHolder();
-    virtual void assignFrame(IplImage *sourceImage, double frameTime);
-    inline IplImage *getImage();
-    inline double getTimeStamp();
-    virtual void setImage(IplImage *sourceImage);
-};
-
-class ASDFrameSequencer
-{
-public:
-    virtual ~ASDFrameSequencer();
-    virtual IplImage *getNextImage();
-    virtual void close();
-    virtual bool isOpen();
-    virtual void getFrameCaption(char *caption);
-};
-
-class ASDCVFrameSequencer : public ASDFrameSequencer
-{
-protected:
-    CvCapture *capture;
-
-public:
-    virtual IplImage *getNextImage();
-    virtual void close();
-    virtual bool isOpen();
-};
-
-class ASDFrameSequencerWebCam : public ASDCVFrameSequencer
-{
-public:
-    virtual bool open(int cameraIndex);
-};
-
-class ASDFrameSequencerVideoFile : public ASDCVFrameSequencer
-{
-public:
-    virtual bool open(const char *fileName);
-};
-
-class ASDFrameSequencerImageFile : public ASDFrameSequencer {
-private:
-    char sFileNameMask[2048];
-    int nCurrentIndex, nStartIndex, nEndIndex;
-
-public:
-    virtual void open(const char *fileNameMask, int startIndex, int endIndex);
-    virtual void getFrameCaption(char *caption);
-    virtual IplImage *getNextImage();
-    virtual void close();
-    virtual bool isOpen();
-};
-
-//-------------------- ASDFrameHolder -----------------------//
-ASDFrameHolder::ASDFrameHolder( )
-{
-    image = NULL;
-    timeStamp = 0;
-}
-
-ASDFrameHolder::~ASDFrameHolder( )
-{
-    cvReleaseImage(&image);
-}
-
-void ASDFrameHolder::assignFrame(IplImage *sourceImage, double frameTime)
-{
-    if (image != NULL)
-    {
-        cvReleaseImage(&image);
-        image = NULL;
-    }
-
-    image = cvCloneImage(sourceImage);
-    timeStamp = frameTime;
-}
-
-IplImage *ASDFrameHolder::getImage()
-{
-    return image;
-}
-
-double ASDFrameHolder::getTimeStamp()
-{
-    return timeStamp;
-}
-
-void ASDFrameHolder::setImage(IplImage *sourceImage)
-{
-    image = sourceImage;
-}
-
-
-//-------------------- ASDFrameSequencer -----------------------//
-
-ASDFrameSequencer::~ASDFrameSequencer()
-{
-    close();
-}
-
-IplImage *ASDFrameSequencer::getNextImage()
-{
-    return NULL;
-}
-
-void ASDFrameSequencer::close()
-{
-
-}
-
-bool ASDFrameSequencer::isOpen()
-{
-    return false;
-}
-
-void ASDFrameSequencer::getFrameCaption(char* /*caption*/) {
-    return;
-}
-
-IplImage* ASDCVFrameSequencer::getNextImage()
-{
-    IplImage *image;
-
-    image = cvQueryFrame(capture);
-
-    if (image != NULL)
-    {
-        return cvCloneImage(image);
-    }
-    else
-    {
-        return NULL;
-    }
-}
-
-void ASDCVFrameSequencer::close()
-{
-    if (capture != NULL)
-    {
-        cvReleaseCapture(&capture);
-    }
-}
-
-bool ASDCVFrameSequencer::isOpen()
-{
-    return (capture != NULL);
-}
-
-
-//-------------------- ASDFrameSequencerWebCam -----------------------//
-
-bool ASDFrameSequencerWebCam::open(int cameraIndex)
-{
-    close();
-
-    capture = cvCaptureFromCAM(cameraIndex);
-
-    if (!capture)
-    {
-        return false;
-    }
-    else
-    {
-        return true;
-    }
-}
-
-
-//-------------------- ASDFrameSequencerVideoFile -----------------------//
-
-bool ASDFrameSequencerVideoFile::open(const char *fileName)
-{
-    close();
-
-    capture = cvCaptureFromFile(fileName);
-    if (!capture)
-    {
-        return false;
-    }
-    else
-    {
-        return true;
-    }
-}
-
-
-//-------------------- ASDFrameSequencerImageFile -----------------------//
-
-void ASDFrameSequencerImageFile::open(const char *fileNameMask, int startIndex, int endIndex)
-{
-    nCurrentIndex = startIndex-1;
-    nStartIndex = startIndex;
-    nEndIndex = endIndex;
-
-    std::sprintf(sFileNameMask, "%s", fileNameMask);
-}
-
-void ASDFrameSequencerImageFile::getFrameCaption(char *caption) {
-    std::sprintf(caption, sFileNameMask, nCurrentIndex);
-}
-
-IplImage* ASDFrameSequencerImageFile::getNextImage()
-{
-    char fileName[2048];
-
-    nCurrentIndex++;
-
-    if (nCurrentIndex > nEndIndex)
-        return NULL;
-
-    std::sprintf(fileName, sFileNameMask, nCurrentIndex);
-
-    IplImage* img = cvLoadImage(fileName);
-
-    return img;
-}
-
-void ASDFrameSequencerImageFile::close()
-{
-    nCurrentIndex = nEndIndex+1;
-}
-
-bool ASDFrameSequencerImageFile::isOpen()
-{
-    return (nCurrentIndex <= nEndIndex);
-}
-
-static void putTextWithShadow(IplImage *img, const char *str, CvPoint point, CvFont *font, CvScalar color = CV_RGB(255, 255, 128))
-{
-    cvPutText(img, str, cvPoint(point.x-1,point.y-1), font, CV_RGB(0, 0, 0));
-    cvPutText(img, str, point, font, color);
-}
-
-#define ASD_RGB_SET_PIXEL(pointer, r, g, b) { (*pointer) = (unsigned char)b; (*(pointer+1)) = (unsigned char)g; (*(pointer+2)) = (unsigned char)r; }
-
-#define ASD_RGB_GET_PIXEL(pointer, r, g, b) {b = (unsigned char)(*(pointer)); g = (unsigned char)(*(pointer+1)); r = (unsigned char)(*(pointer+2));}
-
-static void displayBuffer(IplImage *rgbDestImage, IplImage *buffer, int rValue, int gValue, int bValue)
-{
-    int x, y, nWidth, nHeight;
-    double destX, destY, dx, dy;
-    uchar c;
-    unsigned char *pSrc;
-
-    nWidth = buffer->width;
-    nHeight = buffer->height;
-
-    dx = double(rgbDestImage->width)/double(nWidth);
-    dy = double(rgbDestImage->height)/double(nHeight);
-
-    destX = 0;
-    for (x = 0; x < nWidth; x++)
-    {
-        destY = 0;
-        for (y = 0; y < nHeight; y++)
-        {
-            c = ((uchar*)(buffer->imageData + buffer->widthStep*y))[x];
-
-            if (c)
-            {
-                pSrc = (unsigned char *)rgbDestImage->imageData + rgbDestImage->widthStep*int(destY) + (int(destX)*rgbDestImage->nChannels);
-                ASD_RGB_SET_PIXEL(pSrc, rValue, gValue, bValue);
-            }
-            destY += dy;
-        }
-        destY = 0;
-        destX += dx;
-    }
-}
-
-int main(int argc, char** argv )
-{
-    IplImage *img, *filterMask = NULL;
-    CvAdaptiveSkinDetector filter(1, CvAdaptiveSkinDetector::MORPHING_METHOD_ERODE_DILATE);
-    ASDFrameSequencer *sequencer;
-    CvFont base_font;
-    char caption[2048], s[256], windowName[256];
-    long int clockTotal = 0, numFrames = 0;
-    std::clock_t clock;
-
-    if (argc < 4)
-    {
-        help(argv);
-        sequencer = new ASDFrameSequencerWebCam();
-        (dynamic_cast<ASDFrameSequencerWebCam*>(sequencer))->open(-1);
-
-        if (! sequencer->isOpen())
-        {
-            std::cout << std::endl << "Error: Cannot initialize the default Webcam" << std::endl << std::endl;
-        }
-    }
-    else
-    {
-        sequencer = new ASDFrameSequencerImageFile();
-        (dynamic_cast<ASDFrameSequencerImageFile*>(sequencer))->open(argv[1], std::atoi(argv[2]), std::atoi(argv[3]) ); // A sequence of images captured from video source, is stored here
-
-    }
-    std::sprintf(windowName, "%s", "Adaptive Skin Detection Algorithm for Video Sequences");
-
-    cvNamedWindow(windowName, CV_WINDOW_AUTOSIZE);
-    cvInitFont( &base_font, CV_FONT_VECTOR0, 0.5, 0.5);
-
-    // Usage:
-    //      c:\>CvASDSample "C:\VideoSequences\sample1\right_view\temp_%05d.jpg" 0 1000
-
-    std::cout << "Press ESC to stop." << std::endl << std::endl;
-    while ((img = sequencer->getNextImage()) != 0)
-    {
-        numFrames++;
-
-        if (filterMask == NULL)
-        {
-            filterMask = cvCreateImage( cvSize(img->width, img->height), IPL_DEPTH_8U, 1);
-        }
-        clock = std::clock();
-        filter.process(img, filterMask);    // DETECT SKIN
-        clockTotal += (std::clock() - clock);
-
-        displayBuffer(img, filterMask, 0, 255, 0);
-
-        sequencer->getFrameCaption(caption);
-        std::sprintf(s, "%s - %d x %d", caption, img->width, img->height);
-        putTextWithShadow(img, s, cvPoint(10, img->height-35), &base_font);
-
-        std::sprintf(s, "Average processing time per frame: %5.2fms", (double(clockTotal*1000/CLOCKS_PER_SEC))/numFrames);
-        putTextWithShadow(img, s, cvPoint(10, img->height-15), &base_font);
-
-        cvShowImage (windowName, img);
-        cvReleaseImage(&img);
-
-        if (cvWaitKey(1) == 27)
-            break;
-    }
-
-    sequencer->close();
-    delete sequencer;
-
-    cvReleaseImage(&filterMask);
-
-    cvDestroyWindow(windowName);
-
-    std::cout << "Finished, " << numFrames << " frames processed." << std::endl;
-
-    return 0;
-}
diff --git a/samples/c/baboon.jpg b/samples/c/baboon.jpg
deleted file mode 100644 (file)
index 2f98d83..0000000
Binary files a/samples/c/baboon.jpg and /dev/null differ
diff --git a/samples/c/bgfg_codebook.cpp b/samples/c/bgfg_codebook.cpp
deleted file mode 100644 (file)
index eba0b71..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-// Background average sample code done with averages and done with codebooks
-// (adapted from the OpenCV book sample)
-//
-// NOTE: To get the keyboard to work, you *have* to have one of the video windows be active
-//       and NOT the consule window.
-//
-// Gary Bradski Oct 3, 2008.
-//
-/* *************** License:**************************
-   Oct. 3, 2008
-   Right to use this code in any way you want without warrenty, support or any guarentee of it working.
-
-   BOOK: It would be nice if you cited it:
-   Learning OpenCV: Computer Vision with the OpenCV Library
-     by Gary Bradski and Adrian Kaehler
-     Published by O'Reilly Media, October 3, 2008
-
-   AVAILABLE AT:
-     http://www.amazon.com/Learning-OpenCV-Computer-Vision-Library/dp/0596516134
-     Or: http://oreilly.com/catalog/9780596516130/
-     ISBN-10: 0596516134 or: ISBN-13: 978-0596516130
-************************************************** */
-#include "opencv2/core.hpp"
-#include "opencv2/core/utility.hpp"
-#include "opencv2/video/background_segm.hpp"
-#include "opencv2/imgproc/imgproc_c.h"
-#include "opencv2/highgui/highgui_c.h"
-#include "opencv2/legacy.hpp"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-using namespace std;
-using namespace cv;
-
-//VARIABLES for CODEBOOK METHOD:
-CvBGCodeBookModel* model = 0;
-const int NCHANNELS = 3;
-bool ch[NCHANNELS]={true,true,true}; // This sets what channels should be adjusted for background bounds
-
-static void help()
-{
-    printf("\nLearn background and find foreground using simple average and average difference learning method:\n"
-            "Originally from the book: Learning OpenCV by O'Reilly press\n"
-        "\nUSAGE:\n"
-        "   bgfg_codebook [--nframes(-nf)=300] [--movie_filename(-mf)=tree.avi] [--camera(-c), use camera or not]\n"
-        "***Keep the focus on the video windows, NOT the consol***\n\n"
-        "INTERACTIVE PARAMETERS:\n"
-        "\tESC,q,Q  - quit the program\n"
-        "\th    - print this help\n"
-        "\tp    - pause toggle\n"
-        "\ts    - single step\n"
-        "\tr    - run mode (single step off)\n"
-        "=== AVG PARAMS ===\n"
-        "\t-    - bump high threshold UP by 0.25\n"
-        "\t=    - bump high threshold DOWN by 0.25\n"
-        "\t[    - bump low threshold UP by 0.25\n"
-        "\t]    - bump low threshold DOWN by 0.25\n"
-        "=== CODEBOOK PARAMS ===\n"
-        "\ty,u,v- only adjust channel 0(y) or 1(u) or 2(v) respectively\n"
-        "\ta    - adjust all 3 channels at once\n"
-        "\tb    - adjust both 2 and 3 at once\n"
-        "\ti,o  - bump upper threshold up,down by 1\n"
-        "\tk,l  - bump lower threshold up,down by 1\n"
-        "\tSPACE - reset the model\n"
-        );
-}
-
-//
-//USAGE:  ch9_background startFrameCollection# endFrameCollection# [movie filename, else from camera]
-//If from AVI, then optionally add HighAvg, LowAvg, HighCB_Y LowCB_Y HighCB_U LowCB_U HighCB_V LowCB_V
-//
-const char *keys =
-{
-    "{nf nframes   |300        |frames number}"
-    "{c  camera    |false      |use the camera or not}"
-    "{mf movie_file|tree.avi   |used movie video file}"
-};
-int main(int argc, const char** argv)
-{
-    help();
-
-    CommandLineParser parser(argc, argv, keys);
-    int nframesToLearnBG = parser.get<int>("nf");
-    bool useCamera = parser.has("c");
-    string filename = parser.get<string>("mf");
-    IplImage* rawImage = 0, *yuvImage = 0; //yuvImage is for codebook method
-    IplImage *ImaskCodeBook = 0,*ImaskCodeBookCC = 0;
-    CvCapture* capture = 0;
-
-    int c, n, nframes = 0;
-
-    model = cvCreateBGCodeBookModel();
-
-    //Set color thresholds to default values
-    model->modMin[0] = 3;
-    model->modMin[1] = model->modMin[2] = 3;
-    model->modMax[0] = 10;
-    model->modMax[1] = model->modMax[2] = 10;
-    model->cbBounds[0] = model->cbBounds[1] = model->cbBounds[2] = 10;
-
-    bool pause = false;
-    bool singlestep = false;
-
-    if( useCamera )
-    {
-        printf("Capture from camera\n");
-        capture = cvCaptureFromCAM( 0 );
-    }
-    else
-    {
-        printf("Capture from file %s\n",filename.c_str());
-        capture = cvCreateFileCapture( filename.c_str() );
-    }
-
-    if( !capture )
-    {
-        printf( "Can not initialize video capturing\n\n" );
-        help();
-        return -1;
-    }
-
-    //MAIN PROCESSING LOOP:
-    for(;;)
-    {
-        if( !pause )
-        {
-            rawImage = cvQueryFrame( capture );
-            ++nframes;
-            if(!rawImage)
-                break;
-        }
-        if( singlestep )
-            pause = true;
-
-        //First time:
-        if( nframes == 1 && rawImage )
-        {
-            // CODEBOOK METHOD ALLOCATION
-            yuvImage = cvCloneImage(rawImage);
-            ImaskCodeBook = cvCreateImage( cvGetSize(rawImage), IPL_DEPTH_8U, 1 );
-            ImaskCodeBookCC = cvCreateImage( cvGetSize(rawImage), IPL_DEPTH_8U, 1 );
-            cvSet(ImaskCodeBook,cvScalar(255));
-
-            cvNamedWindow( "Raw", 1 );
-            cvNamedWindow( "ForegroundCodeBook",1);
-            cvNamedWindow( "CodeBook_ConnectComp",1);
-        }
-
-        // If we've got an rawImage and are good to go:
-        if( rawImage )
-        {
-            cvCvtColor( rawImage, yuvImage, CV_BGR2YCrCb );//YUV For codebook method
-            //This is where we build our background model
-            if( !pause && nframes-1 < nframesToLearnBG  )
-                cvBGCodeBookUpdate( model, yuvImage );
-
-            if( nframes-1 == nframesToLearnBG  )
-                cvBGCodeBookClearStale( model, model->t/2 );
-
-            //Find the foreground if any
-            if( nframes-1 >= nframesToLearnBG  )
-            {
-                // Find foreground by codebook method
-                cvBGCodeBookDiff( model, yuvImage, ImaskCodeBook );
-                // This part just to visualize bounding boxes and centers if desired
-                cvCopy(ImaskCodeBook,ImaskCodeBookCC);
-                cvSegmentFGMask( ImaskCodeBookCC );
-            }
-            //Display
-            cvShowImage( "Raw", rawImage );
-            cvShowImage( "ForegroundCodeBook",ImaskCodeBook);
-            cvShowImage( "CodeBook_ConnectComp",ImaskCodeBookCC);
-        }
-
-        // User input:
-        c = cvWaitKey(10)&0xFF;
-        c = tolower(c);
-        // End processing on ESC, q or Q
-        if(c == 27 || c == 'q')
-            break;
-        //Else check for user input
-        switch( c )
-        {
-        case 'h':
-            help();
-            break;
-        case 'p':
-            pause = !pause;
-            break;
-        case 's':
-            singlestep = !singlestep;
-            pause = false;
-            break;
-        case 'r':
-            pause = false;
-            singlestep = false;
-            break;
-        case ' ':
-            cvBGCodeBookClearStale( model, 0 );
-            nframes = 0;
-            break;
-            //CODEBOOK PARAMS
-        case 'y': case '0':
-        case 'u': case '1':
-        case 'v': case '2':
-        case 'a': case '3':
-        case 'b':
-            ch[0] = c == 'y' || c == '0' || c == 'a' || c == '3';
-            ch[1] = c == 'u' || c == '1' || c == 'a' || c == '3' || c == 'b';
-            ch[2] = c == 'v' || c == '2' || c == 'a' || c == '3' || c == 'b';
-            printf("CodeBook YUV Channels active: %d, %d, %d\n", ch[0], ch[1], ch[2] );
-            break;
-        case 'i': //modify max classification bounds (max bound goes higher)
-        case 'o': //modify max classification bounds (max bound goes lower)
-        case 'k': //modify min classification bounds (min bound goes lower)
-        case 'l': //modify min classification bounds (min bound goes higher)
-            {
-            uchar* ptr = c == 'i' || c == 'o' ? model->modMax : model->modMin;
-            for(n=0; n<NCHANNELS; n++)
-            {
-                if( ch[n] )
-                {
-                    int v = ptr[n] + (c == 'i' || c == 'l' ? 1 : -1);
-                    ptr[n] = cv::saturate_cast<uchar>(v);
-                }
-                printf("%d,", ptr[n]);
-            }
-            printf(" CodeBook %s Side\n", c == 'i' || c == 'o' ? "High" : "Low" );
-            }
-            break;
-        }
-    }
-
-    cvReleaseCapture( &capture );
-    cvDestroyWindow( "Raw" );
-    cvDestroyWindow( "ForegroundCodeBook");
-    cvDestroyWindow( "CodeBook_ConnectComp");
-    return 0;
-}
diff --git a/samples/c/blobtrack_sample.cpp b/samples/c/blobtrack_sample.cpp
deleted file mode 100644 (file)
index 90f670d..0000000
+++ /dev/null
@@ -1,755 +0,0 @@
-#include "opencv2/video/background_segm.hpp"
-#include "opencv2/legacy/blobtrack.hpp"
-#include "opencv2/legacy/legacy.hpp"
-#include <opencv2/highgui/highgui_c.h>
-#include <opencv2/imgproc/imgproc_c.h>
-
-#include <stdio.h>
-
-/* Select appropriate case insensitive string comparison function: */
-#if defined WIN32 || defined _MSC_VER
-# define MY_STRNICMP _strnicmp
-# define MY_STRICMP _stricmp
-# define MY_STRDUP _strdup
-#else
-# define MY_STRNICMP strncasecmp
-# define MY_STRICMP strcasecmp
-# define MY_STRDUP strdup
-#endif
-
-/* List of foreground (FG) DETECTION modules: */
-static CvFGDetector* cvCreateFGDetector0      () { return cvCreateFGDetectorBase(CV_BG_MODEL_FGD,        NULL); }
-static CvFGDetector* cvCreateFGDetector0Simple() { return cvCreateFGDetectorBase(CV_BG_MODEL_FGD_SIMPLE, NULL); }
-static CvFGDetector* cvCreateFGDetector1      () { return cvCreateFGDetectorBase(CV_BG_MODEL_MOG,        NULL); }
-
-typedef struct DefModule_FGDetector
-{
-    CvFGDetector* (*create)();
-    const char* nickname;
-    const char* description;
-} DefModule_FGDetector;
-
-DefModule_FGDetector FGDetector_Modules[] =
-{
-    {cvCreateFGDetector0,"FG_0","Foreground Object Detection from Videos Containing Complex Background. ACM MM2003."},
-    {cvCreateFGDetector0Simple,"FG_0S","Simplified version of FG_0"},
-    {cvCreateFGDetector1,"FG_1","Adaptive background mixture models for real-time tracking. CVPR1999"},
-    {NULL,NULL,NULL}
-};
-
-/* List of BLOB DETECTION modules: */
-typedef struct DefModule_BlobDetector
-{
-    CvBlobDetector* (*create)();
-    const char* nickname;
-    const char* description;
-} DefModule_BlobDetector;
-
-DefModule_BlobDetector BlobDetector_Modules[] =
-{
-    {cvCreateBlobDetectorCC,"BD_CC","Detect new blob by tracking CC of FG mask"},
-    {cvCreateBlobDetectorSimple,"BD_Simple","Detect new blob by uniform moving of connected components of FG mask"},
-    {NULL,NULL,NULL}
-};
-
-/* List of BLOB TRACKING modules: */
-typedef struct DefModule_BlobTracker
-{
-    CvBlobTracker* (*create)();
-    const char* nickname;
-    const char* description;
-} DefModule_BlobTracker;
-
-DefModule_BlobTracker BlobTracker_Modules[] =
-{
-    {cvCreateBlobTrackerCCMSPF,"CCMSPF","connected component tracking and MSPF resolver for collision"},
-    {cvCreateBlobTrackerCC,"CC","Simple connected component tracking"},
-    {cvCreateBlobTrackerMS,"MS","Mean shift algorithm "},
-    {cvCreateBlobTrackerMSFG,"MSFG","Mean shift algorithm with FG mask using"},
-    {cvCreateBlobTrackerMSPF,"MSPF","Particle filtering based on MS weight"},
-    {NULL,NULL,NULL}
-};
-
-/* List of BLOB TRAJECTORY GENERATION modules: */
-typedef struct DefModule_BlobTrackGen
-{
-    CvBlobTrackGen* (*create)();
-    const char* nickname;
-    const char* description;
-} DefModule_BlobTrackGen;
-
-DefModule_BlobTrackGen BlobTrackGen_Modules[] =
-{
-    {cvCreateModuleBlobTrackGenYML,"YML","Generate track record in YML format as synthetic video data"},
-    {cvCreateModuleBlobTrackGen1,"RawTracks","Generate raw track record (x,y,sx,sy),()... in each line"},
-    {NULL,NULL,NULL}
-};
-
-/* List of BLOB TRAJECTORY POST PROCESSING modules: */
-typedef struct DefModule_BlobTrackPostProc
-{
-    CvBlobTrackPostProc* (*create)();
-    const char* nickname;
-    const char* description;
-} DefModule_BlobTrackPostProc;
-
-DefModule_BlobTrackPostProc BlobTrackPostProc_Modules[] =
-{
-    {cvCreateModuleBlobTrackPostProcKalman,"Kalman","Kalman filtering of blob position and size"},
-    {NULL,"None","No post processing filter"},
-//    {cvCreateModuleBlobTrackPostProcTimeAverRect,"TimeAverRect","Average by time using rectangle window"},
-//    {cvCreateModuleBlobTrackPostProcTimeAverExp,"TimeAverExp","Average by time using exponential window"},
-    {NULL,NULL,NULL}
-};
-
-/* List of BLOB TRAJECTORY ANALYSIS modules: */
-CvBlobTrackAnalysis* cvCreateModuleBlobTrackAnalysisDetector();
-
-typedef struct DefModule_BlobTrackAnalysis
-{
-    CvBlobTrackAnalysis* (*create)();
-    const char* nickname;
-    const char* description;
-} DefModule_BlobTrackAnalysis;
-
-DefModule_BlobTrackAnalysis BlobTrackAnalysis_Modules[] =
-{
-    {cvCreateModuleBlobTrackAnalysisHistPVS,"HistPVS","Histogram of 5D feature vector analysis (x,y,vx,vy,state)"},
-    {NULL,"None","No trajectory analiser"},
-    {cvCreateModuleBlobTrackAnalysisHistP,"HistP","Histogram of 2D feature vector analysis (x,y)"},
-    {cvCreateModuleBlobTrackAnalysisHistPV,"HistPV","Histogram of 4D feature vector analysis (x,y,vx,vy)"},
-    {cvCreateModuleBlobTrackAnalysisHistSS,"HistSS","Histogram of 4D feature vector analysis (startpos,endpos)"},
-    {cvCreateModuleBlobTrackAnalysisTrackDist,"TrackDist","Compare tracks directly"},
-    {cvCreateModuleBlobTrackAnalysisIOR,"IOR","Integrator (by OR operation) of several analysers "},
-    {NULL,NULL,NULL}
-};
-
-/* List of Blob Trajectory ANALYSIS modules: */
-/*================= END MODULES DECRIPTION ===================================*/
-
-/* Run pipeline on all frames: */
-static int RunBlobTrackingAuto( CvCapture* pCap, CvBlobTrackerAuto* pTracker,char* fgavi_name = NULL, char* btavi_name = NULL )
-{
-    int                     OneFrameProcess = 0;
-    int                     key;
-    int                     FrameNum = 0;
-    CvVideoWriter*          pFGAvi = NULL;
-    CvVideoWriter*          pBTAvi = NULL;
-
-    //cvNamedWindow( "FG", 0 );
-
-    /* Main loop: */
-    for( FrameNum=0; pCap && (key=cvWaitKey(OneFrameProcess?0:1))!=27;
-         FrameNum++)
-    {   /* Main loop: */
-        IplImage*   pImg  = NULL;
-        IplImage*   pMask = NULL;
-
-        if(key!=-1)
-        {
-            OneFrameProcess = 1;
-            if(key=='r')OneFrameProcess = 0;
-        }
-
-        pImg = cvQueryFrame(pCap);
-        if(pImg == NULL) break;
-
-
-        /* Process: */
-        pTracker->Process(pImg, pMask);
-
-        if(fgavi_name)
-        if(pTracker->GetFGMask())
-        {   /* Debug FG: */
-            IplImage*           pFG = pTracker->GetFGMask();
-            CvSize              S = cvSize(pFG->width,pFG->height);
-            static IplImage*    pI = NULL;
-
-            if(pI==NULL)pI = cvCreateImage(S,pFG->depth,3);
-            cvCvtColor( pFG, pI, CV_GRAY2BGR );
-
-            if(fgavi_name)
-            {   /* Save fg to avi file: */
-                if(pFGAvi==NULL)
-                {
-                    pFGAvi=cvCreateVideoWriter(
-                        fgavi_name,
-                        CV_FOURCC('x','v','i','d'),
-                        25,
-                        S );
-                }
-                cvWriteFrame( pFGAvi, pI );
-            }
-
-            if(pTracker->GetBlobNum()>0)
-            {   /* Draw detected blobs: */
-                int i;
-                for(i=pTracker->GetBlobNum();i>0;i--)
-                {
-                    CvBlob* pB = pTracker->GetBlob(i-1);
-                    CvPoint p = cvPointFrom32f(CV_BLOB_CENTER(pB));
-                    CvSize  s = cvSize(MAX(1,cvRound(CV_BLOB_RX(pB))), MAX(1,cvRound(CV_BLOB_RY(pB))));
-                    int c = cvRound(255*pTracker->GetState(CV_BLOB_ID(pB)));
-                    cvEllipse( pI,
-                        p,
-                        s,
-                        0, 0, 360,
-                        CV_RGB(c,255-c,0), cvRound(1+(3*c)/255) );
-                }   /* Next blob: */;
-            }
-
-            cvNamedWindow( "FG",0);
-            cvShowImage( "FG",pI);
-        }   /* Debug FG. */
-
-
-        /* Draw debug info: */
-        if(pImg)
-        {   /* Draw all information about test sequence: */
-            char        str[1024];
-            int         line_type = CV_AA;   // Change it to 8 to see non-antialiased graphics.
-            CvFont      font;
-            int         i;
-            IplImage*   pI = cvCloneImage(pImg);
-
-            cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, 0.7, 0.7, 0, 1, line_type );
-
-            for(i=pTracker->GetBlobNum(); i>0; i--)
-            {
-                CvSize  TextSize;
-                CvBlob* pB = pTracker->GetBlob(i-1);
-                CvPoint p = cvPoint(cvRound(pB->x*256),cvRound(pB->y*256));
-                CvSize  s = cvSize(MAX(1,cvRound(CV_BLOB_RX(pB)*256)), MAX(1,cvRound(CV_BLOB_RY(pB)*256)));
-                int c = cvRound(255*pTracker->GetState(CV_BLOB_ID(pB)));
-
-                cvEllipse( pI,
-                    p,
-                    s,
-                    0, 0, 360,
-                    CV_RGB(c,255-c,0), cvRound(1+(3*0)/255), CV_AA, 8 );
-
-                p.x >>= 8;
-                p.y >>= 8;
-                s.width >>= 8;
-                s.height >>= 8;
-                sprintf(str,"%03d",CV_BLOB_ID(pB));
-                cvGetTextSize( str, &font, &TextSize, NULL );
-                p.y -= s.height;
-                cvPutText( pI, str, p, &font, CV_RGB(0,255,255));
-                {
-                    const char* pS = pTracker->GetStateDesc(CV_BLOB_ID(pB));
-
-                    if(pS)
-                    {
-                        char* pStr = MY_STRDUP(pS);
-                        char* pStrFree = pStr;
-
-                        while (pStr && strlen(pStr) > 0)
-                        {
-                            char* str_next = strchr(pStr,'\n');
-
-                            if(str_next)
-                            {
-                                str_next[0] = 0;
-                                str_next++;
-                            }
-
-                            p.y += TextSize.height+1;
-                            cvPutText( pI, pStr, p, &font, CV_RGB(0,255,255));
-                            pStr = str_next;
-                        }
-                        free(pStrFree);
-                    }
-                }
-
-            }   /* Next blob. */;
-
-            cvNamedWindow( "Tracking", 0);
-            cvShowImage( "Tracking",pI );
-
-            if(btavi_name && pI)
-            {   /* Save to avi file: */
-                CvSize      S = cvSize(pI->width,pI->height);
-                if(pBTAvi==NULL)
-                {
-                    pBTAvi=cvCreateVideoWriter(
-                        btavi_name,
-                        CV_FOURCC('x','v','i','d'),
-                        25,
-                        S );
-                }
-                cvWriteFrame( pBTAvi, pI );
-            }
-
-            cvReleaseImage(&pI);
-        }   /* Draw all information about test sequence. */
-    }   /*  Main loop. */
-
-    if(pFGAvi)cvReleaseVideoWriter( &pFGAvi );
-    if(pBTAvi)cvReleaseVideoWriter( &pBTAvi );
-    return 0;
-}   /* RunBlobTrackingAuto */
-
-/* Read parameters from command line
- * and transfer to specified module:
- */
-static void set_params(int argc, char* argv[], CvVSModule* pM, const char* prefix, const char* module)
-{
-    int prefix_len = (int)strlen(prefix);
-    int i;
-    for(i=0; i<argc; ++i)
-    {
-        int j;
-        char* ptr_eq = NULL;
-        int   cmd_param_len=0;
-        char* cmd = argv[i];
-        if(MY_STRNICMP(prefix,cmd,prefix_len)!=0) continue;
-        cmd += prefix_len;
-        if(cmd[0]!=':')continue;
-        cmd++;
-
-        ptr_eq = strchr(cmd,'=');
-        if(ptr_eq)
-            cmd_param_len = (int)(ptr_eq-cmd);
-
-        for(j=0; ; ++j)
-        {
-            int     param_len;
-            const char*   param = pM->GetParamName(j);
-            if(param==NULL) break;
-            param_len = (int)strlen(param);
-            if(cmd_param_len!=param_len) continue;
-            if(MY_STRNICMP(param,cmd,param_len)!=0) continue;
-            cmd+=param_len;
-            if(cmd[0]!='=')continue;
-            cmd++;
-            pM->SetParamStr(param,cmd);
-            printf("%s:%s param set to %g\n",module,param,pM->GetParam(param));
-        }
-    }
-
-    pM->ParamUpdate();
-
-}   /* set_params */
-
-/* Print all parameter values for given module: */
-static void print_params(CvVSModule* pM, const char* module, const char* log_name)
-{
-    FILE* log = log_name?fopen(log_name,"at"):NULL;
-    int i;
-    if(pM->GetParamName(0) == NULL ) return;
-
-
-    printf("%s(%s) module parameters:\n",module,pM->GetNickName());
-    if(log)
-        fprintf(log,"%s(%s) module parameters:\n",module,pM->GetNickName());
-
-    for (i=0; ; ++i)
-    {
-        const char*   param = pM->GetParamName(i);
-        const char*   str = param?pM->GetParamStr(param):NULL;
-        if(param == NULL)break;
-        if(str)
-        {
-            printf("  %s: %s\n",param,str);
-            if(log)
-                fprintf(log,"  %s: %s\n",param,str);
-        }
-        else
-        {
-            printf("  %s: %g\n",param,pM->GetParam(param));
-            if(log)
-                fprintf(log,"  %s: %g\n",param,pM->GetParam(param));
-        }
-    }
-
-    if(log) fclose(log);
-
-}   /* print_params */
-
-int main(int argc, char* argv[])
-{   /* Main function: */
-    CvCapture*                  pCap = NULL;
-    CvBlobTrackerAutoParam1     param = {0,0,0,0,0,0,0,0};
-    CvBlobTrackerAuto*          pTracker = NULL;
-
-    //float       scale = 1;
-    const char* scale_name = NULL;
-    char*       yml_name = NULL;
-    char**      yml_video_names = NULL;
-    int         yml_video_num = 0;
-    char*       avi_name = NULL;
-    const char* fg_name = NULL;
-    char*       fgavi_name = NULL;
-    char*       btavi_name = NULL;
-    const char* bd_name = NULL;
-    const char* bt_name = NULL;
-    const char* btgen_name = NULL;
-    const char* btpp_name = NULL;
-    const char* bta_name = NULL;
-    char*       bta_data_name = NULL;
-    char*       track_name = NULL;
-    //char*       comment_name = NULL;
-    char*       FGTrainFrames = NULL;
-    char*       log_name = NULL;
-    char*       savestate_name = NULL;
-    char*       loadstate_name = NULL;
-    const char* bt_corr = NULL;
-    DefModule_FGDetector*           pFGModule = NULL;
-    DefModule_BlobDetector*         pBDModule = NULL;
-    DefModule_BlobTracker*          pBTModule = NULL;
-    DefModule_BlobTrackPostProc*    pBTPostProcModule = NULL;
-    DefModule_BlobTrackGen*         pBTGenModule = NULL;
-    DefModule_BlobTrackAnalysis*    pBTAnalysisModule = NULL;
-
-    cvInitSystem(argc, argv);
-
-    if(argc < 2)
-    {   /* Print help: */
-        int i;
-        printf("blobtrack [fg=<fg_name>] [bd=<bd_name>]\n"
-            "          [bt=<bt_name>] [btpp=<btpp_name>]\n"
-            "          [bta=<bta_name>\n"
-            "          [bta_data=<bta_data_name>\n"
-            "          [bt_corr=<bt_corr_way>]\n"
-            "          [btgen=<btgen_name>]\n"
-            "          [track=<track_file_name>]\n"
-            "          [scale=<scale val>] [noise=<noise_name>] [IVar=<IVar_name>]\n"
-            "          [FGTrainFrames=<FGTrainFrames>]\n"
-            "          [btavi=<avi output>] [fgavi=<avi output on FG>]\n"
-            "          <avi_file>\n");
-
-        printf("  <bt_corr_way> is the method of blob position correction for the \"Blob Tracking\" module\n"
-            "     <bt_corr_way>=none,PostProcRes\n"
-            "  <FGTrainFrames> is number of frames for FG training\n"
-            "  <track_file_name> is file name for save tracked trajectories\n"
-            "  <bta_data> is file name for data base of trajectory analysis module\n"
-            "  <avi_file> is file name of avi to process by BlobTrackerAuto\n");
-
-        puts("\nModules:");
-#define PR(_name,_m,_mt)\
-        printf("<%s> is \"%s\" module name and can be:\n",_name,_mt);\
-        for(i=0; _m[i].nickname; ++i)\
-        {\
-            printf("  %d. %s",i+1,_m[i].nickname);\
-            if(_m[i].description)printf(" - %s",_m[i].description);\
-            printf("\n");\
-        }
-
-        PR("fg_name",FGDetector_Modules,"FG/BG Detection");
-        PR("bd_name",BlobDetector_Modules,"Blob Entrance Detection");
-        PR("bt_name",BlobTracker_Modules,"Blob Tracking");
-        PR("btpp_name",BlobTrackPostProc_Modules, "Blob Trajectory Post Processing");
-        PR("btgen_name",BlobTrackGen_Modules, "Blob Trajectory Generation");
-        PR("bta_name",BlobTrackAnalysis_Modules, "Blob Trajectory Analysis");
-#undef PR
-        return 0;
-    }   /* Print help. */
-
-    {   /* Parse arguments: */
-        int i;
-        for(i=1; i<argc; ++i)
-        {
-            int bParsed = 0;
-            size_t len = strlen(argv[i]);
-#define RO(_n1,_n2) if(strncmp(argv[i],_n1,strlen(_n1))==0) {_n2 = argv[i]+strlen(_n1);bParsed=1;};
-            RO("fg=",fg_name);
-            RO("fgavi=",fgavi_name);
-            RO("btavi=",btavi_name);
-            RO("bd=",bd_name);
-            RO("bt=",bt_name);
-            RO("bt_corr=",bt_corr);
-            RO("btpp=",btpp_name);
-            RO("bta=",bta_name);
-            RO("bta_data=",bta_data_name);
-            RO("btgen=",btgen_name);
-            RO("track=",track_name);
-            //RO("comment=",comment_name);
-            RO("FGTrainFrames=",FGTrainFrames);
-            RO("log=",log_name);
-            RO("savestate=",savestate_name);
-            RO("loadstate=",loadstate_name);
-#undef RO
-            {
-                char* ext = argv[i] + len-4;
-                if( strrchr(argv[i],'=') == NULL &&
-                    !bParsed &&
-                    (len>3 && (MY_STRICMP(ext,".avi") == 0 )))
-                {
-                    avi_name = argv[i];
-                    break;
-                }
-            }   /* Next argument. */
-        }
-    }   /* Parse arguments. */
-
-    if(track_name)
-    {   /* Set Trajectory Generator module: */
-        int i;
-        if(!btgen_name)btgen_name=BlobTrackGen_Modules[0].nickname;
-
-        for(i=0; BlobTrackGen_Modules[i].nickname; ++i)
-        {
-            if(MY_STRICMP(BlobTrackGen_Modules[i].nickname,btgen_name)==0)
-                pBTGenModule = BlobTrackGen_Modules + i;
-        }
-    }   /* Set Trajectory Generato module. */
-
-    /* Initialize postprocessing module if tracker
-     * correction by postprocessing is required.
-     */
-    if(bt_corr && MY_STRICMP(bt_corr,"PostProcRes")!=0 && !btpp_name)
-    {
-        btpp_name = bt_corr;
-        if(MY_STRICMP(btpp_name,"none")!=0)bt_corr = "PostProcRes";
-    }
-
-    {   /* Set default parameters for one processing: */
-        if(!bt_corr) bt_corr = "none";
-        if(!fg_name) fg_name = FGDetector_Modules[0].nickname;
-        if(!bd_name) bd_name = BlobDetector_Modules[0].nickname;
-        if(!bt_name) bt_name = BlobTracker_Modules[0].nickname;
-        if(!btpp_name) btpp_name = BlobTrackPostProc_Modules[0].nickname;
-        if(!bta_name) bta_name = BlobTrackAnalysis_Modules[0].nickname;
-        if(!scale_name) scale_name = "1";
-    }
-
-//    if(scale_name)
-  //      scale = (float)atof(scale_name);
-
-    for(pFGModule=FGDetector_Modules; pFGModule->nickname; ++pFGModule)
-        if( fg_name && MY_STRICMP(fg_name,pFGModule->nickname)==0 ) break;
-
-    for(pBDModule=BlobDetector_Modules; pBDModule->nickname; ++pBDModule)
-        if( bd_name && MY_STRICMP(bd_name,pBDModule->nickname)==0 ) break;
-
-    for(pBTModule=BlobTracker_Modules; pBTModule->nickname; ++pBTModule)
-        if( bt_name && MY_STRICMP(bt_name,pBTModule->nickname)==0 ) break;
-
-    for(pBTPostProcModule=BlobTrackPostProc_Modules; pBTPostProcModule->nickname; ++pBTPostProcModule)
-        if( btpp_name && MY_STRICMP(btpp_name,pBTPostProcModule->nickname)==0 ) break;
-
-    for(pBTAnalysisModule=BlobTrackAnalysis_Modules; pBTAnalysisModule->nickname; ++pBTAnalysisModule)
-        if( bta_name && MY_STRICMP(bta_name,pBTAnalysisModule->nickname)==0 ) break;
-
-    /* Create source video: */
-    if(avi_name)
-        pCap = cvCaptureFromFile(avi_name);
-
-    if(pCap==NULL)
-    {
-        printf("Can't open %s file\n",avi_name);
-        return -1;
-    }
-
-
-    {   /* Display parameters: */
-        int i;
-        FILE* log = log_name?fopen(log_name,"at"):NULL;
-        if(log)
-        {   /* Print to log file: */
-            fprintf(log,"\n=== Blob Tracking pipline in processing mode===\n");
-            if(avi_name)
-            {
-                fprintf(log,"AVIFile: %s\n",avi_name);
-            }
-            fprintf(log,"FGDetector:   %s\n", pFGModule->nickname);
-            fprintf(log,"BlobDetector: %s\n", pBDModule->nickname);
-            fprintf(log,"BlobTracker:  %s\n", pBTModule->nickname);
-            fprintf(log,"BlobTrackPostProc:  %s\n", pBTPostProcModule->nickname);
-            fprintf(log,"BlobCorrection:  %s\n", bt_corr);
-
-            fprintf(log,"Blob Trajectory Generator:  %s (%s)\n",
-                pBTGenModule?pBTGenModule->nickname:"None",
-                track_name?track_name:"none");
-
-            fprintf(log,"BlobTrackAnalysis:  %s\n", pBTAnalysisModule->nickname);
-            fclose(log);
-        }
-
-        printf("\n=== Blob Tracking pipline in %s mode===\n","processing");
-        if(yml_name)
-        {
-            printf("ConfigFile: %s\n",yml_name);
-            printf("BG: %s\n",yml_video_names[0]);
-            printf("FG: ");
-            for(i=1;i<(yml_video_num);++i){printf("%s",yml_video_names[i]);if((i+1)<yml_video_num)printf("|");};
-            printf("\n");
-        }
-        if(avi_name)
-        {
-            printf("AVIFile: %s\n",avi_name);
-        }
-        printf("FGDetector:   %s\n", pFGModule->nickname);
-        printf("BlobDetector: %s\n", pBDModule->nickname);
-        printf("BlobTracker:  %s\n", pBTModule->nickname);
-        printf("BlobTrackPostProc:  %s\n", pBTPostProcModule->nickname);
-        printf("BlobCorrection:  %s\n", bt_corr);
-
-        printf("Blob Trajectory Generator:  %s (%s)\n",
-            pBTGenModule?pBTGenModule->nickname:"None",
-            track_name?track_name:"none");
-
-        printf("BlobTrackAnalysis:  %s\n", pBTAnalysisModule->nickname);
-
-    }   /* Display parameters. */
-
-    {   /* Create autotracker module and its components: */
-        param.FGTrainFrames = FGTrainFrames?atoi(FGTrainFrames):0;
-
-        /* Create FG Detection module: */
-        param.pFG = pFGModule->create();
-        if(!param.pFG)
-            puts("Can not create FGDetector module");
-        param.pFG->SetNickName(pFGModule->nickname);
-        set_params(argc, argv, param.pFG, "fg", pFGModule->nickname);
-
-        /* Create Blob Entrance Detection module: */
-        param.pBD = pBDModule->create();
-        if(!param.pBD)
-            puts("Can not create BlobDetector module");
-        param.pBD->SetNickName(pBDModule->nickname);
-        set_params(argc, argv, param.pBD, "bd", pBDModule->nickname);
-
-        /* Create blob tracker module: */
-        param.pBT = pBTModule->create();
-        if(!param.pBT)
-            puts("Can not create BlobTracker module");
-        param.pBT->SetNickName(pBTModule->nickname);
-        set_params(argc, argv, param.pBT, "bt", pBTModule->nickname);
-
-        /* Create blob trajectory generation module: */
-        param.pBTGen = NULL;
-        if(pBTGenModule && track_name && pBTGenModule->create)
-        {
-            param.pBTGen = pBTGenModule->create();
-            param.pBTGen->SetFileName(track_name);
-        }
-        if(param.pBTGen)
-        {
-            param.pBTGen->SetNickName(pBTGenModule->nickname);
-            set_params(argc, argv, param.pBTGen, "btgen", pBTGenModule->nickname);
-        }
-
-        /* Create blob trajectory post processing module: */
-        param.pBTPP = NULL;
-        if(pBTPostProcModule && pBTPostProcModule->create)
-        {
-            param.pBTPP = pBTPostProcModule->create();
-        }
-        if(param.pBTPP)
-        {
-            param.pBTPP->SetNickName(pBTPostProcModule->nickname);
-            set_params(argc, argv, param.pBTPP, "btpp", pBTPostProcModule->nickname);
-        }
-
-        param.UsePPData = (bt_corr && MY_STRICMP(bt_corr,"PostProcRes")==0);
-
-        /* Create blob trajectory analysis module: */
-        param.pBTA = NULL;
-        if(pBTAnalysisModule && pBTAnalysisModule->create)
-        {
-            param.pBTA = pBTAnalysisModule->create();
-            param.pBTA->SetFileName(bta_data_name);
-        }
-        if(param.pBTA)
-        {
-            param.pBTA->SetNickName(pBTAnalysisModule->nickname);
-            set_params(argc, argv, param.pBTA, "bta", pBTAnalysisModule->nickname);
-        }
-
-        /* Create whole pipline: */
-        pTracker = cvCreateBlobTrackerAuto1(&param);
-        if(!pTracker)
-            puts("Can not create BlobTrackerAuto");
-    }
-
-    {   /* Load states of each module from state file: */
-        CvFileStorage* fs = NULL;
-        if(loadstate_name)
-            fs=cvOpenFileStorage(loadstate_name,NULL,CV_STORAGE_READ);
-        if(fs)
-        {
-            printf("Load states for modules...\n");
-            if(param.pBT)
-            {
-                CvFileNode* fn = cvGetFileNodeByName(fs,NULL,"BlobTracker");
-                param.pBT->LoadState(fs,fn);
-            }
-
-            if(param.pBTA)
-            {
-                CvFileNode* fn = cvGetFileNodeByName(fs,NULL,"BlobTrackAnalyser");
-                param.pBTA->LoadState(fs,fn);
-            }
-
-            if(pTracker)
-            {
-                CvFileNode* fn = cvGetFileNodeByName(fs,NULL,"BlobTrackerAuto");
-                pTracker->LoadState(fs,fn);
-            }
-
-            cvReleaseFileStorage(&fs);
-            printf("... Modules states loaded\n");
-        }
-    }   /* Load states of each module. */
-
-    {   /* Print module parameters: */
-        struct DefMMM
-        {
-            CvVSModule* pM;
-            const char* name;
-        } Modules[] = {
-            {(CvVSModule*)param.pFG,"FGdetector"},
-            {(CvVSModule*)param.pBD,"BlobDetector"},
-            {(CvVSModule*)param.pBT,"BlobTracker"},
-            {(CvVSModule*)param.pBTGen,"TrackGen"},
-            {(CvVSModule*)param.pBTPP,"PostProcessing"},
-            {(CvVSModule*)param.pBTA,"TrackAnalysis"},
-            {NULL,NULL}
-        };
-        int     i;
-        for(i=0; Modules[i].name; ++i)
-        {
-            if(Modules[i].pM)
-                print_params(Modules[i].pM,Modules[i].name,log_name);
-        }
-    }   /* Print module parameters. */
-
-    /* Run pipeline: */
-    RunBlobTrackingAuto( pCap, pTracker, fgavi_name, btavi_name );
-
-    {   /* Save state and release modules: */
-        CvFileStorage* fs = NULL;
-        if(savestate_name)
-        {
-            fs=cvOpenFileStorage(savestate_name,NULL,CV_STORAGE_WRITE);
-        }
-        if(fs)
-        {
-            cvStartWriteStruct(fs,"BlobTracker",CV_NODE_MAP);
-            if(param.pBT)param.pBT->SaveState(fs);
-            cvEndWriteStruct(fs);
-            cvStartWriteStruct(fs,"BlobTrackerAuto",CV_NODE_MAP);
-            if(pTracker)pTracker->SaveState(fs);
-            cvEndWriteStruct(fs);
-            cvStartWriteStruct(fs,"BlobTrackAnalyser",CV_NODE_MAP);
-            if(param.pBTA)param.pBTA->SaveState(fs);
-            cvEndWriteStruct(fs);
-            cvReleaseFileStorage(&fs);
-        }
-        if(param.pBT)cvReleaseBlobTracker(&param.pBT);
-        if(param.pBD)cvReleaseBlobDetector(&param.pBD);
-        if(param.pBTGen)cvReleaseBlobTrackGen(&param.pBTGen);
-        if(param.pBTA)cvReleaseBlobTrackAnalysis(&param.pBTA);
-        if(param.pFG)cvReleaseFGDetector(&param.pFG);
-        if(pTracker)cvReleaseBlobTrackerAuto(&pTracker);
-
-    }   /* Save state and release modules. */
-
-    if(pCap)
-        cvReleaseCapture(&pCap);
-
-    return 0;
-
-}   /* main() */
diff --git a/samples/c/build_all.sh b/samples/c/build_all.sh
deleted file mode 100755 (executable)
index 94a5a05..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-if [ $# -gt 0 ] ; then
-    base=`basename $1 .c`
-    echo "compiling $base"
-    gcc -ggdb `pkg-config opencv --cflags --libs` $base.c -o $base
-else
-    for i in *.c; do
-        echo "compiling $i"
-        gcc -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv`;
-    done
-    for i in *.cpp; do
-        echo "compiling $i"
-        g++ -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv`;
-    done
-fi
diff --git a/samples/c/calonder_params.xml b/samples/c/calonder_params.xml
deleted file mode 100644 (file)
index f2294ca..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0"?>
-<opencv_storage>
-    <numTrees>20</numTrees>
-    <depth>7</depth>
-    <views>1000</views>
-    <patchSize>20</patchSize>
-    <reducedNumDim>30</reducedNumDim>
-    <numQuantBits>4</numQuantBits>
-    <printStatus>1</printStatus>
-</opencv_storage>
diff --git a/samples/c/cat.jpg b/samples/c/cat.jpg
deleted file mode 100644 (file)
index df4a907..0000000
Binary files a/samples/c/cat.jpg and /dev/null differ
diff --git a/samples/c/cat.xml b/samples/c/cat.xml
deleted file mode 100644 (file)
index 85fcf09..0000000
Binary files a/samples/c/cat.xml and /dev/null differ
diff --git a/samples/c/contours.c b/samples/c/contours.c
deleted file mode 100644 (file)
index 58939e4..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-#include "opencv2/imgproc/imgproc_c.h"
-#include "opencv2/highgui/highgui_c.h"
-#include <stdio.h>
-
-static void help(void)
-{
-    printf("\nThis program creates an image to demonstrate the use of the \"c\" contour\n"
-            "functions: cvFindContours() and cvApproxPoly() along with the storage\n"
-            "functions cvCreateMemStorage() and cvDrawContours().\n"
-            "It also shows the use of a trackbar to control contour retrieval.\n"
-            "\n"
-            "Usage :\n"
-            "./contours\n");
-}
-
-#define w 500
-int levels = 3;
-CvSeq* contours = 0;
-
-static void on_trackbar(int pos)
-{
-    IplImage* cnt_img = cvCreateImage( cvSize(w,w), 8, 3 );
-    CvSeq* _contours = contours;
-    int _levels = levels - 3;
-    (void)pos;
-
-    if( _levels <= 0 ) // get to the nearest face to make it look more funny
-        _contours = _contours->h_next->h_next->h_next;
-    cvZero( cnt_img );
-    cvDrawContours( cnt_img, _contours, CV_RGB(255,0,0), CV_RGB(0,255,0), _levels, 3, CV_AA, cvPoint(0,0) );
-    cvShowImage( "contours", cnt_img );
-    cvReleaseImage( &cnt_img );
-}
-
-static void findCComp( IplImage* img )
-{
-    int x, y, cidx = 1;
-    IplImage* mask = cvCreateImage( cvSize(img->width+2, img->height+2), 8, 1 );
-    cvZero(mask);
-    cvRectangle( mask, cvPoint(0, 0), cvPoint(mask->width-1, mask->height-1),
-                 cvScalarAll(1), 1, 8, 0 );
-
-    for( y = 0; y < img->height; y++ )
-        for( x = 0; x < img->width; x++ )
-        {
-            if( CV_IMAGE_ELEM(mask, uchar, y+1, x+1) != 0 )
-                continue;
-            cvFloodFill(img, cvPoint(x,y), cvScalarAll(cidx),
-                        cvScalarAll(0), cvScalarAll(0), 0, 4, mask);
-            cidx++;
-        }
-}
-
-
-int main(int argc, char* argv[])
-{
-    int i, j;
-    CvMemStorage* storage = cvCreateMemStorage(0);
-    IplImage* img = cvCreateImage( cvSize(w,w), 8, 1 );
-    IplImage* img32f = cvCreateImage( cvSize(w,w), IPL_DEPTH_32F, 1 );
-    IplImage* img32s = cvCreateImage( cvSize(w,w), IPL_DEPTH_32S, 1 );
-    IplImage* img3 = cvCreateImage( cvSize(w,w), 8, 3 );
-    (void)argc; (void)argv;
-
-    help();
-    cvZero( img );
-
-    for( i=0; i < 6; i++ )
-    {
-        int dx = (i%2)*250 - 30;
-        int dy = (i/2)*150;
-        CvScalar white = cvRealScalar(255);
-        CvScalar black = cvRealScalar(0);
-
-        if( i == 0 )
-        {
-            for( j = 0; j <= 10; j++ )
-            {
-                double angle = (j+5)*CV_PI/21;
-                cvLine(img, cvPoint(cvRound(dx+100+j*10-80*cos(angle)),
-                    cvRound(dy+100-90*sin(angle))),
-                    cvPoint(cvRound(dx+100+j*10-30*cos(angle)),
-                    cvRound(dy+100-30*sin(angle))), white, 3, 8, 0);
-            }
-        }
-
-        cvEllipse( img, cvPoint(dx+150, dy+100), cvSize(100,70), 0, 0, 360, white, -1, 8, 0 );
-        cvEllipse( img, cvPoint(dx+115, dy+70), cvSize(30,20), 0, 0, 360, black, -1, 8, 0 );
-        cvEllipse( img, cvPoint(dx+185, dy+70), cvSize(30,20), 0, 0, 360, black, -1, 8, 0 );
-        cvEllipse( img, cvPoint(dx+115, dy+70), cvSize(15,15), 0, 0, 360, white, -1, 8, 0 );
-        cvEllipse( img, cvPoint(dx+185, dy+70), cvSize(15,15), 0, 0, 360, white, -1, 8, 0 );
-        cvEllipse( img, cvPoint(dx+115, dy+70), cvSize(5,5), 0, 0, 360, black, -1, 8, 0 );
-        cvEllipse( img, cvPoint(dx+185, dy+70), cvSize(5,5), 0, 0, 360, black, -1, 8, 0 );
-        cvEllipse( img, cvPoint(dx+150, dy+100), cvSize(10,5), 0, 0, 360, black, -1, 8, 0 );
-        cvEllipse( img, cvPoint(dx+150, dy+150), cvSize(40,10), 0, 0, 360, black, -1, 8, 0 );
-        cvEllipse( img, cvPoint(dx+27, dy+100), cvSize(20,35), 0, 0, 360, white, -1, 8, 0 );
-        cvEllipse( img, cvPoint(dx+273, dy+100), cvSize(20,35), 0, 0, 360, white, -1, 8, 0 );
-    }
-
-    cvNamedWindow( "image", 1 );
-    cvShowImage( "image", img );
-    cvConvert( img, img32f );
-    findCComp( img32f );
-    cvConvert( img32f, img32s );
-
-    cvFindContours( img32s, storage, &contours, sizeof(CvContour),
-                    CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0) );
-
-    //cvFindContours( img, storage, &contours, sizeof(CvContour),
-    //                CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0) );
-
-
-    {
-    const char* attrs[] = {"recursive", "1", 0};
-    cvSave("contours.xml", contours, 0, 0, cvAttrList(attrs, 0));
-    contours = (CvSeq*)cvLoad("contours.xml", storage, 0, 0);
-    }
-
-    // comment this out if you do not want approximation
-    contours = cvApproxPoly( contours, sizeof(CvContour), storage, CV_POLY_APPROX_DP, 3, 1 );
-
-    cvNamedWindow( "contours", 1 );
-    cvCreateTrackbar( "levels+3", "contours", &levels, 7, on_trackbar );
-
-    {
-        CvRNG rng = cvRNG(-1);
-
-        CvSeq* tcontours = contours;
-        cvCvtColor( img, img3, CV_GRAY2BGR );
-        while( tcontours->h_next )
-            tcontours = tcontours->h_next;
-
-        for( ; tcontours != 0; tcontours = tcontours->h_prev )
-        {
-            CvScalar color;
-            color.val[0] = cvRandInt(&rng) % 256;
-            color.val[1] = cvRandInt(&rng) % 256;
-            color.val[2] = cvRandInt(&rng) % 256;
-            color.val[3] = cvRandInt(&rng) % 256;
-            cvDrawContours(img3, tcontours, color, color, 0, -1, 8, cvPoint(0,0));
-            if( tcontours->v_next )
-            {
-                color.val[0] = cvRandInt(&rng) % 256;
-                color.val[1] = cvRandInt(&rng) % 256;
-                color.val[2] = cvRandInt(&rng) % 256;
-                color.val[3] = cvRandInt(&rng) % 256;
-                cvDrawContours(img3, tcontours->v_next, color, color, 1, -1, 8, cvPoint(0,0));
-            }
-        }
-
-    }
-
-    cvShowImage( "colored", img3 );
-    on_trackbar(0);
-    cvWaitKey(0);
-    cvReleaseMemStorage( &storage );
-    cvReleaseImage( &img );
-    cvReleaseImage( &img32f );
-    cvReleaseImage( &img32s );
-    cvReleaseImage( &img3 );
-
-    return 0;
-}
-
-#ifdef _EiC
-main(1,"");
-#endif
diff --git a/samples/c/convert_cascade.c b/samples/c/convert_cascade.c
deleted file mode 100644 (file)
index 4337e35..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "opencv2/objdetect/objdetect_c.h"
-#include "opencv2/highgui/highgui_c.h"
-
-#include <ctype.h>
-#include <stdio.h>
-
-static void help(void)
-{
-    printf("\n This sample demonstrates cascade's convertation \n"
-    "Usage:\n"
-    "./convert_cascade --size=\"<width>x<height>\"<convertation size> \n"
-    "                   input_cascade_path \n"
-    "                   output_cascade_filename\n"
-    "Example: \n"
-    "./convert_cascade --size=640x480 ../../opencv/data/haarcascades/haarcascade_eye.xml ../../opencv/data/haarcascades/test_cascade.xml \n"
-    );
-}
-
-int main( int argc, char** argv )
-{
-    const char* size_opt = "--size=";
-    char comment[1024];
-    CvHaarClassifierCascade* cascade = 0;
-    CvSize size;
-
-    help();
-
-    if( argc != 4 || strncmp( argv[1], size_opt, strlen(size_opt) ) != 0 )
-    {
-        help();
-        return -1;
-    }
-
-    sscanf( argv[1], "--size=%ux%u", &size.width, &size.height );
-    cascade = cvLoadHaarClassifierCascade( argv[2], size );
-
-    if( !cascade )
-    {
-        fprintf( stderr, "Input cascade could not be found/opened\n" );
-        return -1;
-    }
-
-    sprintf( comment, "Automatically converted from %s, window size = %dx%d", argv[2], size.width, size.height );
-    cvSave( argv[3], cascade, 0, comment, cvAttrList(0,0) );
-    return 0;
-}
-
-#ifdef _EiC
-main(1,"facedetect.c");
-#endif
diff --git a/samples/c/cvsample.dsp b/samples/c/cvsample.dsp
deleted file mode 100644 (file)
index 71fcf28..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-# Microsoft Developer Studio Project File - Name="cvsample" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=cvsample - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE 
-!MESSAGE NMAKE /f "cvsample.mak".
-!MESSAGE 
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "cvsample.mak" CFG="cvsample - Win32 Release"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "cvsample - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "cvsample - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE 
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "cvsample - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "..\..\_temp\cvsample_Release"
-# PROP Intermediate_Dir "..\..\_temp\cvsample_Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-F90=df.exe
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /Gm /GX /Zi /O2 /I "../../cxcore/include" /I "../../cv/include" /I "../../otherlibs/highgui" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cxcore.lib cv.lib highgui.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libmmd.lib" /out:".\cvsample.exe" /libpath:"../../lib"
-
-!ELSEIF  "$(CFG)" == "cvsample - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "..\..\_temp\cvsample_Debug"
-# PROP Intermediate_Dir "..\..\_temp\cvsample_Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-F90=df.exe
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W4 /Gm /GX /Zi /Od /I "../../cxcore/include" /I "../../cv/include" /I "../../otherlibs/highgui" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cxcored.lib cvd.lib highguid.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libmmdd.lib" /out:".\cvsampled.exe" /pdbtype:sept /libpath:"../../lib"
-
-!ENDIF 
-
-# Begin Target
-
-# Name "cvsample - Win32 Release"
-# Name "cvsample - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\squares.c
-# End Source File
-# End Target
-# End Project
diff --git a/samples/c/cvsample.vs2005.vcproj b/samples/c/cvsample.vs2005.vcproj
deleted file mode 100644 (file)
index 18d2f06..0000000
+++ /dev/null
@@ -1,413 +0,0 @@
-<?xml version="1.0" encoding="windows-1251"?>
-<VisualStudioProject
-       ProjectType="Visual C++"
-       Version="8,00"
-       Name="cvsample"
-       ProjectGUID="{2820F96A-13D2-4EFE-BC9F-A9AF482026AE}"
-       RootNamespace="cvsample"
-       >
-       <Platforms>
-               <Platform
-                       Name="Win32"
-               />
-               <Platform
-                       Name="x64"
-               />
-       </Platforms>
-       <ToolFiles>
-       </ToolFiles>
-       <Configurations>
-               <Configuration
-                       Name="Debug|Win32"
-                       OutputDirectory="$(TEMP)\opencv.build\$(ProjectName)_$(ConfigurationName).$(PlatformName)"
-                       IntermediateDirectory="$(OutDir)"
-                       ConfigurationType="1"
-                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-                       UseOfMFC="0"
-                       ATLMinimizesCRunTimeLibraryUsage="false"
-                       CharacterSet="2"
-                       >
-                       <Tool
-                               Name="VCPreBuildEventTool"
-                       />
-                       <Tool
-                               Name="VCCustomBuildTool"
-                       />
-                       <Tool
-                               Name="VCXMLDataGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCWebServiceProxyGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCMIDLTool"
-                               TypeLibraryName=".\..\..\_temp\cvsample_Dbg/cvsample.tlb"
-                               HeaderFileName=""
-                       />
-                       <Tool
-                               Name="VCCLCompilerTool"
-                               Optimization="0"
-                               AdditionalIncludeDirectories="../../cxcore/include,../../cv/include,../../otherlibs/highgui"
-                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
-                               MinimalRebuild="true"
-                               BasicRuntimeChecks="3"
-                               RuntimeLibrary="3"
-                               PrecompiledHeaderFile=".\..\..\_temp\cvsample_Dbg/cvsample.pch"
-                               AssemblerListingLocation="$(IntDir)\"
-                               ObjectFile="$(IntDir)\"
-                               ProgramDataBaseFileName="$(IntDir)\"
-                               WarningLevel="4"
-                               SuppressStartupBanner="true"
-                               DebugInformationFormat="3"
-                       />
-                       <Tool
-                               Name="VCManagedResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCResourceCompilerTool"
-                               PreprocessorDefinitions="_DEBUG"
-                               Culture="1033"
-                       />
-                       <Tool
-                               Name="VCPreLinkEventTool"
-                       />
-                       <Tool
-                               Name="VCLinkerTool"
-                               AdditionalDependencies="odbc32.lib odbccp32.lib cxcored.lib cvd.lib highguid.lib"
-                               OutputFile=".\cvsampled.exe"
-                               LinkIncremental="2"
-                               SuppressStartupBanner="true"
-                               AdditionalLibraryDirectories="../../lib"
-                               IgnoreDefaultLibraryNames="libmmdd.lib"
-                               GenerateDebugInformation="true"
-                               ProgramDatabaseFile="$(IntDir)/$(ProjectName)d.pdb"
-                               SubSystem="1"
-                               TargetMachine="1"
-                       />
-                       <Tool
-                               Name="VCALinkTool"
-                       />
-                       <Tool
-                               Name="VCManifestTool"
-                       />
-                       <Tool
-                               Name="VCXDCMakeTool"
-                       />
-                       <Tool
-                               Name="VCBscMakeTool"
-                               SuppressStartupBanner="true"
-                               OutputFile="$(IntDir)\$(ProjectName).bsc"
-                       />
-                       <Tool
-                               Name="VCFxCopTool"
-                       />
-                       <Tool
-                               Name="VCAppVerifierTool"
-                       />
-                       <Tool
-                               Name="VCWebDeploymentTool"
-                       />
-                       <Tool
-                               Name="VCPostBuildEventTool"
-                       />
-               </Configuration>
-               <Configuration
-                       Name="Debug|x64"
-                       OutputDirectory="$(TEMP)\opencv.build\$(ProjectName)_$(ConfigurationName).$(PlatformName)"
-                       IntermediateDirectory="$(OutDir)"
-                       ConfigurationType="1"
-                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-                       UseOfMFC="0"
-                       ATLMinimizesCRunTimeLibraryUsage="false"
-                       CharacterSet="2"
-                       >
-                       <Tool
-                               Name="VCPreBuildEventTool"
-                       />
-                       <Tool
-                               Name="VCCustomBuildTool"
-                       />
-                       <Tool
-                               Name="VCXMLDataGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCWebServiceProxyGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCMIDLTool"
-                               TargetEnvironment="3"
-                               TypeLibraryName=".\..\..\_temp\cvsample_Dbg64/cvsample.tlb"
-                               HeaderFileName=""
-                       />
-                       <Tool
-                               Name="VCCLCompilerTool"
-                               Optimization="0"
-                               AdditionalIncludeDirectories="../../cxcore/include,../../cv/include,../../otherlibs/highgui"
-                               PreprocessorDefinitions="WIN32;WIN64;EM64T;_DEBUG;_CONSOLE"
-                               MinimalRebuild="true"
-                               BasicRuntimeChecks="3"
-                               RuntimeLibrary="3"
-                               PrecompiledHeaderFile=".\..\..\_temp\cvsample_Dbg64/cvsample.pch"
-                               AssemblerListingLocation="$(IntDir)\"
-                               ObjectFile="$(IntDir)\"
-                               ProgramDataBaseFileName="$(IntDir)\"
-                               WarningLevel="4"
-                               SuppressStartupBanner="true"
-                               DebugInformationFormat="3"
-                       />
-                       <Tool
-                               Name="VCManagedResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCResourceCompilerTool"
-                               PreprocessorDefinitions="_DEBUG"
-                               Culture="1033"
-                       />
-                       <Tool
-                               Name="VCPreLinkEventTool"
-                       />
-                       <Tool
-                               Name="VCLinkerTool"
-                               AdditionalDependencies="odbc32.lib odbccp32.lib cxcored_64.lib cvd_64.lib highguid_64.lib"
-                               OutputFile=".\cvsampled_64.exe"
-                               LinkIncremental="2"
-                               SuppressStartupBanner="true"
-                               AdditionalLibraryDirectories="../../lib"
-                               IgnoreDefaultLibraryNames="libmmdd.lib"
-                               GenerateDebugInformation="true"
-                               ProgramDatabaseFile="$(IntDir)/$(ProjectName)d_64.pdb"
-                               SubSystem="1"
-                               TargetMachine="17"
-                       />
-                       <Tool
-                               Name="VCALinkTool"
-                       />
-                       <Tool
-                               Name="VCManifestTool"
-                       />
-                       <Tool
-                               Name="VCXDCMakeTool"
-                       />
-                       <Tool
-                               Name="VCBscMakeTool"
-                               SuppressStartupBanner="true"
-                               OutputFile="$(IntDir)\$(ProjectName).bsc"
-                       />
-                       <Tool
-                               Name="VCFxCopTool"
-                       />
-                       <Tool
-                               Name="VCAppVerifierTool"
-                       />
-                       <Tool
-                               Name="VCWebDeploymentTool"
-                       />
-                       <Tool
-                               Name="VCPostBuildEventTool"
-                       />
-               </Configuration>
-               <Configuration
-                       Name="Release|Win32"
-                       OutputDirectory="$(TEMP)\opencv.build\$(ProjectName)_$(ConfigurationName).$(PlatformName)"
-                       IntermediateDirectory="$(OutDir)"
-                       ConfigurationType="1"
-                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-                       UseOfMFC="0"
-                       ATLMinimizesCRunTimeLibraryUsage="false"
-                       CharacterSet="2"
-                       >
-                       <Tool
-                               Name="VCPreBuildEventTool"
-                       />
-                       <Tool
-                               Name="VCCustomBuildTool"
-                       />
-                       <Tool
-                               Name="VCXMLDataGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCWebServiceProxyGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCMIDLTool"
-                               TypeLibraryName=".\..\..\_temp\cvsample_Rls/cvsample.tlb"
-                               HeaderFileName=""
-                       />
-                       <Tool
-                               Name="VCCLCompilerTool"
-                               Optimization="2"
-                               InlineFunctionExpansion="1"
-                               AdditionalIncludeDirectories="../../cxcore/include,../../cv/include,../../otherlibs/highgui"
-                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
-                               StringPooling="true"
-                               MinimalRebuild="true"
-                               RuntimeLibrary="2"
-                               EnableFunctionLevelLinking="true"
-                               PrecompiledHeaderFile=".\..\..\_temp\cvsample_Rls/cvsample.pch"
-                               AssemblerListingLocation="$(IntDir)\"
-                               ObjectFile="$(IntDir)\"
-                               ProgramDataBaseFileName="$(IntDir)\"
-                               WarningLevel="4"
-                               SuppressStartupBanner="true"
-                               DebugInformationFormat="3"
-                       />
-                       <Tool
-                               Name="VCManagedResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCResourceCompilerTool"
-                               PreprocessorDefinitions="NDEBUG"
-                               Culture="1033"
-                       />
-                       <Tool
-                               Name="VCPreLinkEventTool"
-                       />
-                       <Tool
-                               Name="VCLinkerTool"
-                               AdditionalDependencies="odbc32.lib odbccp32.lib cxcore.lib cv.lib highgui.lib"
-                               OutputFile=".\cvsample.exe"
-                               LinkIncremental="1"
-                               SuppressStartupBanner="true"
-                               AdditionalLibraryDirectories="../../lib"
-                               IgnoreDefaultLibraryNames="libmmd.lib"
-                               GenerateDebugInformation="true"
-                               ProgramDatabaseFile="$(IntDir)/$(ProjectName).pdb"
-                               SubSystem="1"
-                               TargetMachine="1"
-                       />
-                       <Tool
-                               Name="VCALinkTool"
-                       />
-                       <Tool
-                               Name="VCManifestTool"
-                       />
-                       <Tool
-                               Name="VCXDCMakeTool"
-                       />
-                       <Tool
-                               Name="VCBscMakeTool"
-                               SuppressStartupBanner="true"
-                               OutputFile="$(IntDir)\$(ProjectName).bsc"
-                       />
-                       <Tool
-                               Name="VCFxCopTool"
-                       />
-                       <Tool
-                               Name="VCAppVerifierTool"
-                       />
-                       <Tool
-                               Name="VCWebDeploymentTool"
-                       />
-                       <Tool
-                               Name="VCPostBuildEventTool"
-                       />
-               </Configuration>
-               <Configuration
-                       Name="Release|x64"
-                       OutputDirectory="$(TEMP)\opencv.build\$(ProjectName)_$(ConfigurationName).$(PlatformName)"
-                       IntermediateDirectory="$(OutDir)"
-                       ConfigurationType="1"
-                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
-                       UseOfMFC="0"
-                       ATLMinimizesCRunTimeLibraryUsage="false"
-                       CharacterSet="2"
-                       >
-                       <Tool
-                               Name="VCPreBuildEventTool"
-                       />
-                       <Tool
-                               Name="VCCustomBuildTool"
-                       />
-                       <Tool
-                               Name="VCXMLDataGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCWebServiceProxyGeneratorTool"
-                       />
-                       <Tool
-                               Name="VCMIDLTool"
-                               TargetEnvironment="3"
-                               TypeLibraryName=".\..\..\_temp\cvsample_Rls64/cvsample.tlb"
-                               HeaderFileName=""
-                       />
-                       <Tool
-                               Name="VCCLCompilerTool"
-                               Optimization="2"
-                               InlineFunctionExpansion="1"
-                               AdditionalIncludeDirectories="../../cxcore/include,../../cv/include,../../otherlibs/highgui"
-                               PreprocessorDefinitions="WIN32;WIN64;EM64T;NDEBUG;_CONSOLE"
-                               StringPooling="true"
-                               MinimalRebuild="true"
-                               RuntimeLibrary="2"
-                               EnableFunctionLevelLinking="true"
-                               PrecompiledHeaderFile=".\..\..\_temp\cvsample_Rls64/cvsample.pch"
-                               AssemblerListingLocation="$(IntDir)\"
-                               ObjectFile="$(IntDir)\"
-                               ProgramDataBaseFileName="$(IntDir)\"
-                               WarningLevel="4"
-                               SuppressStartupBanner="true"
-                               DebugInformationFormat="3"
-                       />
-                       <Tool
-                               Name="VCManagedResourceCompilerTool"
-                       />
-                       <Tool
-                               Name="VCResourceCompilerTool"
-                               PreprocessorDefinitions="NDEBUG"
-                               Culture="1033"
-                       />
-                       <Tool
-                               Name="VCPreLinkEventTool"
-                       />
-                       <Tool
-                               Name="VCLinkerTool"
-                               AdditionalDependencies="odbc32.lib odbccp32.lib cxcore_64.lib cv_64.lib highgui_64.lib"
-                               OutputFile=".\cvsample_64.exe"
-                               LinkIncremental="1"
-                               SuppressStartupBanner="true"
-                               AdditionalLibraryDirectories="../../lib"
-                               IgnoreDefaultLibraryNames="libmmd.lib"
-                               GenerateDebugInformation="true"
-                               ProgramDatabaseFile="$(IntDir)/$(ProjectName)_64.pdb"
-                               SubSystem="1"
-                               TargetMachine="17"
-                       />
-                       <Tool
-                               Name="VCALinkTool"
-                       />
-                       <Tool
-                               Name="VCManifestTool"
-                       />
-                       <Tool
-                               Name="VCXDCMakeTool"
-                       />
-                       <Tool
-                               Name="VCBscMakeTool"
-                               SuppressStartupBanner="true"
-                               OutputFile="$(IntDir)\$(ProjectName).bsc"
-                       />
-                       <Tool
-                               Name="VCFxCopTool"
-                       />
-                       <Tool
-                               Name="VCAppVerifierTool"
-                       />
-                       <Tool
-                               Name="VCWebDeploymentTool"
-                       />
-                       <Tool
-                               Name="VCPostBuildEventTool"
-                       />
-               </Configuration>
-       </Configurations>
-       <References>
-       </References>
-       <Files>
-               <File
-                       RelativePath=".\stereo_calib.cpp"
-                       >
-               </File>
-       </Files>
-       <Globals>
-       </Globals>
-</VisualStudioProject>
diff --git a/samples/c/delaunay.c b/samples/c/delaunay.c
deleted file mode 100644 (file)
index 1f09efe..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-#include <opencv2/imgproc/imgproc_c.h>
-#include <opencv2/highgui/highgui_c.h>
-#include <opencv2/legacy.hpp>
-
-#include <stdio.h>
-static void help( void )
-{
-    printf("\nThis program demostrates iterative construction of\n"
-            "delaunay triangulation and voronoi tesselation.\n"
-            "It draws a random set of points in an image and then delaunay triangulates them.\n"
-            "Usage: \n"
-            "./delaunay \n"
-            "\nThis program builds the traingulation interactively, you may stop this process by\n"
-            "hitting any key.\n");
-}
-
-static CvSubdiv2D* init_delaunay( CvMemStorage* storage,
-                           CvRect rect )
-{
-    CvSubdiv2D* subdiv;
-
-    subdiv = cvCreateSubdiv2D( CV_SEQ_KIND_SUBDIV2D, sizeof(*subdiv),
-                               sizeof(CvSubdiv2DPoint),
-                               sizeof(CvQuadEdge2D),
-                               storage );
-    cvInitSubdivDelaunay2D( subdiv, rect );
-
-    return subdiv;
-}
-
-
-static void draw_subdiv_point( IplImage* img, CvPoint2D32f fp, CvScalar color )
-{
-    cvCircle( img, cvPoint(cvRound(fp.x), cvRound(fp.y)), 3, color, CV_FILLED, 8, 0 );
-}
-
-
-static void draw_subdiv_edge( IplImage* img, CvSubdiv2DEdge edge, CvScalar color )
-{
-    CvSubdiv2DPoint* org_pt;
-    CvSubdiv2DPoint* dst_pt;
-    CvPoint2D32f org;
-    CvPoint2D32f dst;
-    CvPoint iorg, idst;
-
-    org_pt = cvSubdiv2DEdgeOrg(edge);
-    dst_pt = cvSubdiv2DEdgeDst(edge);
-
-    if( org_pt && dst_pt )
-    {
-        org = org_pt->pt;
-        dst = dst_pt->pt;
-
-        iorg = cvPoint( cvRound( org.x ), cvRound( org.y ));
-        idst = cvPoint( cvRound( dst.x ), cvRound( dst.y ));
-
-        cvLine( img, iorg, idst, color, 1, CV_AA, 0 );
-    }
-}
-
-
-static void draw_subdiv( IplImage* img, CvSubdiv2D* subdiv,
-                  CvScalar delaunay_color, CvScalar voronoi_color )
-{
-    CvSeqReader  reader;
-    int i, total = subdiv->edges->total;
-    int elem_size = subdiv->edges->elem_size;
-
-    cvStartReadSeq( (CvSeq*)(subdiv->edges), &reader, 0 );
-
-    for( i = 0; i < total; i++ )
-    {
-        CvQuadEdge2D* edge = (CvQuadEdge2D*)(reader.ptr);
-
-        if( CV_IS_SET_ELEM( edge ))
-        {
-            draw_subdiv_edge( img, (CvSubdiv2DEdge)edge + 1, voronoi_color );
-            draw_subdiv_edge( img, (CvSubdiv2DEdge)edge, delaunay_color );
-        }
-
-        CV_NEXT_SEQ_ELEM( elem_size, reader );
-    }
-}
-
-
-static void locate_point( CvSubdiv2D* subdiv, CvPoint2D32f fp, IplImage* img,
-                   CvScalar active_color )
-{
-    CvSubdiv2DEdge e;
-    CvSubdiv2DEdge e0 = 0;
-    CvSubdiv2DPoint* p = 0;
-
-    cvSubdiv2DLocate( subdiv, fp, &e0, &p );
-
-    if( e0 )
-    {
-        e = e0;
-        do
-        {
-            draw_subdiv_edge( img, e, active_color );
-            e = cvSubdiv2DGetEdge(e,CV_NEXT_AROUND_LEFT);
-        }
-        while( e != e0 );
-    }
-
-    draw_subdiv_point( img, fp, active_color );
-}
-
-
-static void draw_subdiv_facet( IplImage* img, CvSubdiv2DEdge edge )
-{
-    CvSubdiv2DEdge t = edge;
-    int i, count = 0;
-    CvPoint* buf = 0;
-
-    // count number of edges in facet
-    do
-    {
-        count++;
-        t = cvSubdiv2DGetEdge( t, CV_NEXT_AROUND_LEFT );
-    } while (t != edge );
-
-    buf = (CvPoint*)malloc( count * sizeof(buf[0]));
-
-    // gather points
-    t = edge;
-    for( i = 0; i < count; i++ )
-    {
-        CvSubdiv2DPoint* pt = cvSubdiv2DEdgeOrg( t );
-        if( !pt ) break;
-        buf[i] = cvPoint( cvRound(pt->pt.x), cvRound(pt->pt.y));
-        t = cvSubdiv2DGetEdge( t, CV_NEXT_AROUND_LEFT );
-    }
-
-    if( i == count )
-    {
-        CvSubdiv2DPoint* pt = cvSubdiv2DEdgeDst( cvSubdiv2DRotateEdge( edge, 1 ));
-        cvFillConvexPoly( img, buf, count, CV_RGB(rand()&255,rand()&255,rand()&255), CV_AA, 0 );
-        cvPolyLine( img, &buf, &count, 1, 1, CV_RGB(0,0,0), 1, CV_AA, 0);
-        draw_subdiv_point( img, pt->pt, CV_RGB(0,0,0));
-    }
-    free( buf );
-}
-
-static void paint_voronoi( CvSubdiv2D* subdiv, IplImage* img )
-{
-    CvSeqReader  reader;
-    int i, total = subdiv->edges->total;
-    int elem_size = subdiv->edges->elem_size;
-
-    cvCalcSubdivVoronoi2D( subdiv );
-
-    cvStartReadSeq( (CvSeq*)(subdiv->edges), &reader, 0 );
-
-    for( i = 0; i < total; i++ )
-    {
-        CvQuadEdge2D* edge = (CvQuadEdge2D*)(reader.ptr);
-
-        if( CV_IS_SET_ELEM( edge ))
-        {
-            CvSubdiv2DEdge e = (CvSubdiv2DEdge)edge;
-            // left
-            draw_subdiv_facet( img, cvSubdiv2DRotateEdge( e, 1 ));
-
-            // right
-            draw_subdiv_facet( img, cvSubdiv2DRotateEdge( e, 3 ));
-        }
-
-        CV_NEXT_SEQ_ELEM( elem_size, reader );
-    }
-}
-
-
-static void run(void)
-{
-    char win[] = "source";
-    int i;
-    CvRect rect = { 0, 0, 600, 600 };
-    CvMemStorage* storage;
-    CvSubdiv2D* subdiv;
-    IplImage* img;
-    CvScalar active_facet_color, delaunay_color, voronoi_color, bkgnd_color;
-
-    active_facet_color = CV_RGB( 255, 0, 0 );
-    delaunay_color  = CV_RGB( 0,0,0);
-    voronoi_color = CV_RGB(0, 180, 0);
-    bkgnd_color = CV_RGB(255,255,255);
-
-    img = cvCreateImage( cvSize(rect.width,rect.height), 8, 3 );
-    cvSet( img, bkgnd_color, 0 );
-
-    cvNamedWindow( win, 1 );
-
-    storage = cvCreateMemStorage(0);
-    subdiv = init_delaunay( storage, rect );
-
-    printf("Delaunay triangulation will be build now interactively.\n"
-           "To stop the process, press any key\n\n");
-
-    for( i = 0; i < 200; i++ )
-    {
-        CvPoint2D32f fp = cvPoint2D32f( (float)(rand()%(rect.width-10)+5),
-                                        (float)(rand()%(rect.height-10)+5));
-
-        locate_point( subdiv, fp, img, active_facet_color );
-        cvShowImage( win, img );
-
-        if( cvWaitKey( 100 ) >= 0 )
-            break;
-
-        cvSubdivDelaunay2DInsert( subdiv, fp );
-        cvCalcSubdivVoronoi2D( subdiv );
-        cvSet( img, bkgnd_color, 0 );
-        draw_subdiv( img, subdiv, delaunay_color, voronoi_color );
-        cvShowImage( win, img );
-
-        if( cvWaitKey( 100 ) >= 0 )
-            break;
-    }
-
-    cvSet( img, bkgnd_color, 0 );
-    paint_voronoi( subdiv, img );
-    cvShowImage( win, img );
-
-    cvWaitKey(0);
-
-    cvReleaseMemStorage( &storage );
-    cvReleaseImage(&img);
-    cvDestroyWindow( win );
-}
-
-int main( int argc, char** argv )
-{
-    (void)argc; (void)argv;
-    help();
-    run();
-    return 0;
-}
-
-#ifdef _EiC
-main( 1, "delaunay.c" );
-#endif
diff --git a/samples/c/example_cmake/CMakeLists.txt b/samples/c/example_cmake/CMakeLists.txt
deleted file mode 100644 (file)
index 475677a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-PROJECT(opencv_example)
-
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-if(COMMAND cmake_policy)
-      cmake_policy(SET CMP0003 NEW)
-endif(COMMAND cmake_policy)
-
-FIND_PACKAGE( OpenCV REQUIRED )
-
-# Declare the target (an executable)
-ADD_EXECUTABLE(opencv_example  minarea.c)
-
-TARGET_LINK_LIBRARIES(opencv_example ${OpenCV_LIBS})
-
-#MESSAGE(STATUS "OpenCV_LIBS: ${OpenCV_LIBS}")
diff --git a/samples/c/example_cmake/README.txt b/samples/c/example_cmake/README.txt
deleted file mode 100644 (file)
index 7d573e3..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-Example for CMake build system.
-
-Compile OpenCV with cmake, preferently in an off-tree build, for example:
-
- $ mkdir opencv-release
- $ cd opencv-release
- $ cmake <OPENCV_SRC_PATH>
- $ make
-
-And, *only optionally*, install it with.
- $ sudo make install
-
-Then create the binary directory for the example with:
- $ mkdir example-release
- $ cd example-release
-
-Then, if "make install" have been executed, directly running
- $ cmake <OPENCV_SRC_PATH>/samples/c/example_cmake/
-
-will detect the "OpenCVConfig.cmake" file and the project is ready to compile.
-
-If "make install" has not been executed, you'll have to manually pick the opencv
-binary directory (Under Windows CMake may remember the correct directory). Open
-the CMake gui with:
- $ cmake-gui <OPENCV_SRC_PATH>/samples/c/example_cmake/
-
-And pick the correct value for OpenCV_DIR.
diff --git a/samples/c/example_cmake/minarea.c b/samples/c/example_cmake/minarea.c
deleted file mode 100644 (file)
index c6e0cf3..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-#ifdef _CH_
-#pragma package <opencv>
-#endif
-
-#ifndef _EiC
-#include "cv.h"
-#include "highgui.h"
-#include <stdio.h>
-#include <stdlib.h>
-#endif
-
-#define ARRAY  1
-
-void help()
-{
-    printf("\nThis program demonstrates finding the minimum enclosing box or circle of a set\n"
-        "of points using functions: minAreaRect() minEnclosingCircle().\n"
-        "Random points are generated and then enclosed.\n"
-        "Call:\n"
-        "./minarea\n");
-}
-
-int main( int argc, char** argv )
-{
-    IplImage* img = cvCreateImage( cvSize( 500, 500 ), 8, 3 );
-#if !ARRAY
-    CvMemStorage* storage = cvCreateMemStorage(0);
-#endif
-    help();
-    cvNamedWindow( "rect & circle", 1 );
-
-    for(;;)
-    {
-        char key;
-        int i, count = rand()%100 + 1;
-        CvPoint pt0, pt;
-        CvBox2D box;
-        CvPoint2D32f box_vtx[4];
-        CvPoint2D32f center;
-        CvPoint icenter;
-        float radius;
-#if !ARRAY
-        CvSeq* ptseq = cvCreateSeq( CV_SEQ_KIND_GENERIC|CV_32SC2, sizeof(CvContour),
-                                     sizeof(CvPoint), storage );
-        for( i = 0; i < count; i++ )
-        {
-            pt0.x = rand() % (img->width/2) + img->width/4;
-            pt0.y = rand() % (img->height/2) + img->height/4;
-            cvSeqPush( ptseq, &pt0 );
-        }
-#ifndef _EiC /* unfortunately, here EiC crashes */
-        box = cvMinAreaRect2( ptseq, 0 );
-#endif
-        cvMinEnclosingCircle( ptseq, &center, &radius );
-#else
-        CvPoint* points = (CvPoint*)malloc( count * sizeof(points[0]));
-        CvMat pointMat = cvMat( 1, count, CV_32SC2, points );
-
-        for( i = 0; i < count; i++ )
-        {
-            pt0.x = rand() % (img->width/2) + img->width/4;
-            pt0.y = rand() % (img->height/2) + img->height/4;
-            points[i] = pt0;
-        }
-#ifndef _EiC
-        box = cvMinAreaRect2( &pointMat, 0 );
-#endif
-        cvMinEnclosingCircle( &pointMat, &center, &radius );
-#endif
-        cvBoxPoints( box, box_vtx );
-        cvZero( img );
-        for( i = 0; i < count; i++ )
-        {
-#if !ARRAY
-            pt0 = *CV_GET_SEQ_ELEM( CvPoint, ptseq, i );
-#else
-            pt0 = points[i];
-#endif
-            cvCircle( img, pt0, 2, CV_RGB( 255, 0, 0 ), CV_FILLED, CV_AA, 0 );
-        }
-
-#ifndef _EiC
-        pt0.x = cvRound(box_vtx[3].x);
-        pt0.y = cvRound(box_vtx[3].y);
-        for( i = 0; i < 4; i++ )
-        {
-            pt.x = cvRound(box_vtx[i].x);
-            pt.y = cvRound(box_vtx[i].y);
-            cvLine(img, pt0, pt, CV_RGB(0, 255, 0), 1, CV_AA, 0);
-            pt0 = pt;
-        }
-#endif
-        icenter.x = cvRound(center.x);
-        icenter.y = cvRound(center.y);
-        cvCircle( img, icenter, cvRound(radius), CV_RGB(255, 255, 0), 1, CV_AA, 0 );
-
-        cvShowImage( "rect & circle", img );
-
-        key = (char) cvWaitKey(0);
-        if( key == 27 || key == 'q' || key == 'Q' ) // 'ESC'
-            break;
-
-#if !ARRAY
-        cvClearMemStorage( storage );
-#else
-        free( points );
-#endif
-    }
-
-    cvDestroyWindow( "rect & circle" );
-    return 0;
-}
-
-#ifdef _EiC
-main(1,"convexhull.c");
-#endif
diff --git a/samples/c/facedetect.cmd b/samples/c/facedetect.cmd
deleted file mode 100644 (file)
index c5dcef3..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-REM an example of using haar cascade recognition for face and eye detection.
-facedetect --cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3 %1
diff --git a/samples/c/fback_c.c b/samples/c/fback_c.c
deleted file mode 100644 (file)
index e0317a4..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-#include "opencv2/video/tracking_c.h"
-#include "opencv2/highgui/highgui_c.h"
-#include "opencv2/imgproc/imgproc_c.h"
-#include <stdio.h>
-
-static void help(void)
-{
-    printf(
-            "\n This program demonstrate dense \"Farneback\n optical flow\n"
-            "It read from camera 0, and shows how to use and display dense Franeback optical flow\n"
-            "Usage: \n"
-            "./fback_c \n");
-
-}
-
-static void drawOptFlowMap(const CvMat* flow, CvMat* cflowmap, int step,
-                    double scale, CvScalar color)
-{
-    int x, y;
-    (void)scale;
-    for( y = 0; y < cflowmap->rows; y += step)
-        for( x = 0; x < cflowmap->cols; x += step)
-        {
-            CvPoint2D32f fxy = CV_MAT_ELEM(*flow, CvPoint2D32f, y, x);
-            cvLine(cflowmap, cvPoint(x,y), cvPoint(cvRound(x+fxy.x), cvRound(y+fxy.y)),
-                 color, 1, 8, 0);
-            cvCircle(cflowmap, cvPoint(x,y), 2, color, -1, 8, 0);
-        }
-}
-
-int main( int argc, char** argv )
-{
-    CvCapture* capture = cvCreateCameraCapture(0);
-    CvMat* prevgray = 0, *gray = 0, *flow = 0, *cflow = 0;
-    (void)argc; (void)argv;
-
-    help();
-
-    if( !capture )
-        return -1;
-
-    cvNamedWindow("flow", 1);
-
-    for(;;)
-    {
-        int firstFrame = gray == 0;
-        IplImage* frame = cvQueryFrame(capture);
-        if(!frame)
-            break;
-        if(!gray)
-        {
-            gray = cvCreateMat(frame->height, frame->width, CV_8UC1);
-            prevgray = cvCreateMat(gray->rows, gray->cols, gray->type);
-            flow = cvCreateMat(gray->rows, gray->cols, CV_32FC2);
-            cflow = cvCreateMat(gray->rows, gray->cols, CV_8UC3);
-        }
-        cvCvtColor(frame, gray, CV_BGR2GRAY);
-
-        if( !firstFrame )
-        {
-            cvCalcOpticalFlowFarneback(prevgray, gray, flow, 0.5, 3, 15, 3, 5, 1.2, 0);
-            cvCvtColor(prevgray, cflow, CV_GRAY2BGR);
-            drawOptFlowMap(flow, cflow, 16, 1.5, CV_RGB(0, 255, 0));
-            cvShowImage("flow", cflow);
-        }
-        if(cvWaitKey(30)>=0)
-            break;
-        {
-        CvMat* temp;
-        CV_SWAP(prevgray, gray, temp);
-        }
-    }
-    cvReleaseCapture(&capture);
-    return 0;
-}
diff --git a/samples/c/find_obj.cpp b/samples/c/find_obj.cpp
deleted file mode 100644 (file)
index 651f439..0000000
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * A Demo to OpenCV Implementation of SURF
- * Further Information Refer to "SURF: Speed-Up Robust Feature"
- * Author: Liu Liu
- * liuliu.1987+opencv@gmail.com
- */
-#include "opencv2/objdetect/objdetect.hpp"
-#include "opencv2/features2d/features2d.hpp"
-#include "opencv2/calib3d/calib3d.hpp"
-#include "opencv2/nonfree/nonfree.hpp"
-#include "opencv2/imgproc/imgproc_c.h"
-#include "opencv2/highgui/highgui_c.h"
-#include "opencv2/legacy/legacy.hpp"
-#include "opencv2/legacy/compat.hpp"
-
-#include <iostream>
-#include <vector>
-#include <stdio.h>
-
-using namespace std;
-static void help()
-{
-    printf(
-        "This program demonstrated the use of the SURF Detector and Descriptor using\n"
-        "either FLANN (fast approx nearst neighbor classification) or brute force matching\n"
-        "on planar objects.\n"
-        "Usage:\n"
-        "./find_obj <object_filename> <scene_filename>, default is box.png  and box_in_scene.png\n\n");
-    return;
-}
-
-// define whether to use approximate nearest-neighbor search
-#define USE_FLANN
-
-#ifdef USE_FLANN
-static void
-flannFindPairs( const CvSeq*, const CvSeq* objectDescriptors,
-           const CvSeq*, const CvSeq* imageDescriptors, vector<int>& ptpairs )
-{
-    int length = (int)(objectDescriptors->elem_size/sizeof(float));
-
-    cv::Mat m_object(objectDescriptors->total, length, CV_32F);
-    cv::Mat m_image(imageDescriptors->total, length, CV_32F);
-
-
-    // copy descriptors
-    CvSeqReader obj_reader;
-    float* obj_ptr = m_object.ptr<float>(0);
-    cvStartReadSeq( objectDescriptors, &obj_reader );
-    for(int i = 0; i < objectDescriptors->total; i++ )
-    {
-        const float* descriptor = (const float*)obj_reader.ptr;
-        CV_NEXT_SEQ_ELEM( obj_reader.seq->elem_size, obj_reader );
-        memcpy(obj_ptr, descriptor, length*sizeof(float));
-        obj_ptr += length;
-    }
-    CvSeqReader img_reader;
-    float* img_ptr = m_image.ptr<float>(0);
-    cvStartReadSeq( imageDescriptors, &img_reader );
-    for(int i = 0; i < imageDescriptors->total; i++ )
-    {
-        const float* descriptor = (const float*)img_reader.ptr;
-        CV_NEXT_SEQ_ELEM( img_reader.seq->elem_size, img_reader );
-        memcpy(img_ptr, descriptor, length*sizeof(float));
-        img_ptr += length;
-    }
-
-    // find nearest neighbors using FLANN
-    cv::Mat m_indices(objectDescriptors->total, 2, CV_32S);
-    cv::Mat m_dists(objectDescriptors->total, 2, CV_32F);
-    cv::flann::Index flann_index(m_image, cv::flann::KDTreeIndexParams(4));  // using 4 randomized kdtrees
-    flann_index.knnSearch(m_object, m_indices, m_dists, 2, cv::flann::SearchParams(64) ); // maximum number of leafs checked
-
-    int* indices_ptr = m_indices.ptr<int>(0);
-    float* dists_ptr = m_dists.ptr<float>(0);
-    for (int i=0;i<m_indices.rows;++i) {
-        if (dists_ptr[2*i]<0.6*dists_ptr[2*i+1]) {
-            ptpairs.push_back(i);
-            ptpairs.push_back(indices_ptr[2*i]);
-        }
-    }
-}
-#else
-
-static double
-compareSURFDescriptors( const float* d1, const float* d2, double best, int length )
-{
-    double total_cost = 0;
-    assert( length % 4 == 0 );
-    for( int i = 0; i < length; i += 4 )
-    {
-        double t0 = d1[i  ] - d2[i  ];
-        double t1 = d1[i+1] - d2[i+1];
-        double t2 = d1[i+2] - d2[i+2];
-        double t3 = d1[i+3] - d2[i+3];
-        total_cost += t0*t0 + t1*t1 + t2*t2 + t3*t3;
-        if( total_cost > best )
-            break;
-    }
-    return total_cost;
-}
-
-static int
-naiveNearestNeighbor( const float* vec, int laplacian,
-                      const CvSeq* model_keypoints,
-                      const CvSeq* model_descriptors )
-{
-    int length = (int)(model_descriptors->elem_size/sizeof(float));
-    int i, neighbor = -1;
-    double d, dist1 = 1e6, dist2 = 1e6;
-    CvSeqReader reader, kreader;
-    cvStartReadSeq( model_keypoints, &kreader, 0 );
-    cvStartReadSeq( model_descriptors, &reader, 0 );
-
-    for( i = 0; i < model_descriptors->total; i++ )
-    {
-        const CvSURFPoint* kp = (const CvSURFPoint*)kreader.ptr;
-        const float* mvec = (const float*)reader.ptr;
-        CV_NEXT_SEQ_ELEM( kreader.seq->elem_size, kreader );
-        CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader );
-        if( laplacian != kp->laplacian )
-            continue;
-        d = compareSURFDescriptors( vec, mvec, dist2, length );
-        if( d < dist1 )
-        {
-            dist2 = dist1;
-            dist1 = d;
-            neighbor = i;
-        }
-        else if ( d < dist2 )
-            dist2 = d;
-    }
-    if ( dist1 < 0.6*dist2 )
-        return neighbor;
-    return -1;
-}
-
-static void
-findPairs( const CvSeq* objectKeypoints, const CvSeq* objectDescriptors,
-           const CvSeq* imageKeypoints, const CvSeq* imageDescriptors, vector<int>& ptpairs )
-{
-    int i;
-    CvSeqReader reader, kreader;
-    cvStartReadSeq( objectKeypoints, &kreader );
-    cvStartReadSeq( objectDescriptors, &reader );
-    ptpairs.clear();
-
-    for( i = 0; i < objectDescriptors->total; i++ )
-    {
-        const CvSURFPoint* kp = (const CvSURFPoint*)kreader.ptr;
-        const float* descriptor = (const float*)reader.ptr;
-        CV_NEXT_SEQ_ELEM( kreader.seq->elem_size, kreader );
-        CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader );
-        int nearest_neighbor = naiveNearestNeighbor( descriptor, kp->laplacian, imageKeypoints, imageDescriptors );
-        if( nearest_neighbor >= 0 )
-        {
-            ptpairs.push_back(i);
-            ptpairs.push_back(nearest_neighbor);
-        }
-    }
-}
-#endif
-
-/* a rough implementation for object location */
-static int
-locatePlanarObject( const CvSeq* objectKeypoints, const CvSeq* objectDescriptors,
-                    const CvSeq* imageKeypoints, const CvSeq* imageDescriptors,
-                    const CvPoint src_corners[4], CvPoint dst_corners[4] )
-{
-    double h[9];
-    CvMat _h = cvMat(3, 3, CV_64F, h);
-    vector<int> ptpairs;
-    vector<CvPoint2D32f> pt1, pt2;
-    CvMat _pt1, _pt2;
-    int i, n;
-
-#ifdef USE_FLANN
-    flannFindPairs( objectKeypoints, objectDescriptors, imageKeypoints, imageDescriptors, ptpairs );
-#else
-    findPairs( objectKeypoints, objectDescriptors, imageKeypoints, imageDescriptors, ptpairs );
-#endif
-
-    n = (int)(ptpairs.size()/2);
-    if( n < 4 )
-        return 0;
-
-    pt1.resize(n);
-    pt2.resize(n);
-    for( i = 0; i < n; i++ )
-    {
-        pt1[i] = ((CvSURFPoint*)cvGetSeqElem(objectKeypoints,ptpairs[i*2]))->pt;
-        pt2[i] = ((CvSURFPoint*)cvGetSeqElem(imageKeypoints,ptpairs[i*2+1]))->pt;
-    }
-
-    _pt1 = cvMat(1, n, CV_32FC2, &pt1[0] );
-    _pt2 = cvMat(1, n, CV_32FC2, &pt2[0] );
-    if( !cvFindHomography( &_pt1, &_pt2, &_h, CV_RANSAC, 5 ))
-        return 0;
-
-    for( i = 0; i < 4; i++ )
-    {
-        double x = src_corners[i].x, y = src_corners[i].y;
-        double Z = 1./(h[6]*x + h[7]*y + h[8]);
-        double X = (h[0]*x + h[1]*y + h[2])*Z;
-        double Y = (h[3]*x + h[4]*y + h[5])*Z;
-        dst_corners[i] = cvPoint(cvRound(X), cvRound(Y));
-    }
-
-    return 1;
-}
-
-int main(int argc, char** argv)
-{
-    const char* object_filename = argc == 3 ? argv[1] : "box.png";
-    const char* scene_filename = argc == 3 ? argv[2] : "box_in_scene.png";
-
-    cv::initModule_nonfree();
-    help();
-
-    IplImage* object = cvLoadImage( object_filename, CV_LOAD_IMAGE_GRAYSCALE );
-    IplImage* image = cvLoadImage( scene_filename, CV_LOAD_IMAGE_GRAYSCALE );
-    if( !object || !image )
-    {
-        fprintf( stderr, "Can not load %s and/or %s\n",
-            object_filename, scene_filename );
-        exit(-1);
-    }
-
-    CvMemStorage* storage = cvCreateMemStorage(0);
-
-    cvNamedWindow("Object", 1);
-    cvNamedWindow("Object Correspond", 1);
-
-    static cv::Scalar colors[] =
-    {
-        cv::Scalar(0,0,255),
-        cv::Scalar(0,128,255),
-        cv::Scalar(0,255,255),
-        cv::Scalar(0,255,0),
-        cv::Scalar(255,128,0),
-        cv::Scalar(255,255,0),
-        cv::Scalar(255,0,0),
-        cv::Scalar(255,0,255),
-        cv::Scalar(255,255,255)
-    };
-
-    IplImage* object_color = cvCreateImage(cvGetSize(object), 8, 3);
-    cvCvtColor( object, object_color, CV_GRAY2BGR );
-
-    CvSeq* objectKeypoints = 0, *objectDescriptors = 0;
-    CvSeq* imageKeypoints = 0, *imageDescriptors = 0;
-    int i;
-    CvSURFParams params = cvSURFParams(500, 1);
-
-    double tt = (double)cvGetTickCount();
-    cvExtractSURF( object, 0, &objectKeypoints, &objectDescriptors, storage, params );
-    printf("Object Descriptors: %d\n", objectDescriptors->total);
-
-    cvExtractSURF( image, 0, &imageKeypoints, &imageDescriptors, storage, params );
-    printf("Image Descriptors: %d\n", imageDescriptors->total);
-    tt = (double)cvGetTickCount() - tt;
-
-    printf( "Extraction time = %gms\n", tt/(cvGetTickFrequency()*1000.));
-
-    CvPoint src_corners[4] = {CvPoint(0,0), CvPoint(object->width,0), CvPoint(object->width, object->height), CvPoint(0, object->height)};
-    CvPoint dst_corners[4];
-    IplImage* correspond = cvCreateImage( cvSize(image->width, object->height+image->height), 8, 1 );
-    cvSetImageROI( correspond, cvRect( 0, 0, object->width, object->height ) );
-    cvCopy( object, correspond );
-    cvSetImageROI( correspond, cvRect( 0, object->height, correspond->width, correspond->height ) );
-    cvCopy( image, correspond );
-    cvResetImageROI( correspond );
-
-#ifdef USE_FLANN
-    printf("Using approximate nearest neighbor search\n");
-#endif
-
-    if( locatePlanarObject( objectKeypoints, objectDescriptors, imageKeypoints,
-        imageDescriptors, src_corners, dst_corners ))
-    {
-        for( i = 0; i < 4; i++ )
-        {
-            CvPoint r1 = dst_corners[i%4];
-            CvPoint r2 = dst_corners[(i+1)%4];
-            cvLine( correspond, cvPoint(r1.x, r1.y+object->height ),
-                cvPoint(r2.x, r2.y+object->height ), colors[8] );
-        }
-    }
-    vector<int> ptpairs;
-#ifdef USE_FLANN
-    flannFindPairs( objectKeypoints, objectDescriptors, imageKeypoints, imageDescriptors, ptpairs );
-#else
-    findPairs( objectKeypoints, objectDescriptors, imageKeypoints, imageDescriptors, ptpairs );
-#endif
-    for( i = 0; i < (int)ptpairs.size(); i += 2 )
-    {
-        CvSURFPoint* r1 = (CvSURFPoint*)cvGetSeqElem( objectKeypoints, ptpairs[i] );
-        CvSURFPoint* r2 = (CvSURFPoint*)cvGetSeqElem( imageKeypoints, ptpairs[i+1] );
-        cvLine( correspond, cvPointFrom32f(r1->pt),
-            cvPoint(cvRound(r2->pt.x), cvRound(r2->pt.y+object->height)), colors[8] );
-    }
-
-    cvShowImage( "Object Correspond", correspond );
-    for( i = 0; i < objectKeypoints->total; i++ )
-    {
-        CvSURFPoint* r = (CvSURFPoint*)cvGetSeqElem( objectKeypoints, i );
-        CvPoint center;
-        int radius;
-        center.x = cvRound(r->pt.x);
-        center.y = cvRound(r->pt.y);
-        radius = cvRound(r->size*1.2/9.*2);
-        cvCircle( object_color, center, radius, colors[0], 1, 8, 0 );
-    }
-    cvShowImage( "Object", object_color );
-
-    cvWaitKey(0);
-
-    cvDestroyWindow("Object");
-    cvDestroyWindow("Object Correspond");
-
-    return 0;
-}
diff --git a/samples/c/find_obj_calonder.cpp b/samples/c/find_obj_calonder.cpp
deleted file mode 100644 (file)
index a7b01c8..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-#include "opencv2/highgui/highgui.hpp"
-#include "opencv2/core/core.hpp"
-#include "opencv2/imgproc/imgproc.hpp"
-#include "opencv2/features2d/features2d.hpp"
-#include "opencv2/nonfree/nonfree.hpp"
-#include "opencv2/legacy/legacy.hpp"
-
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-using namespace cv;
-
-static void help()
-{
-    cout << "This program shows the use of the Calonder point descriptor classifier"
-            "SURF is used to detect interest points, Calonder is used to describe/match these points\n"
-            "Format:" << endl <<
-            "   classifier_file(to write) test_image file_with_train_images_filenames(txt)" <<
-            "   or" << endl <<
-            "   classifier_file(to read) test_image" << "\n" << endl <<
-            "Using OpenCV version " << CV_VERSION << "\n" << endl;
-
-    return;
-}
-
-
-/*
- * Generates random perspective transform of image
- */
-static void warpPerspectiveRand( const Mat& src, Mat& dst, Mat& H, RNG& rng )
-{
-    H.create(3, 3, CV_32FC1);
-    H.at<float>(0,0) = rng.uniform( 0.8f, 1.2f);
-    H.at<float>(0,1) = rng.uniform(-0.1f, 0.1f);
-    H.at<float>(0,2) = rng.uniform(-0.1f, 0.1f)*src.cols;
-    H.at<float>(1,0) = rng.uniform(-0.1f, 0.1f);
-    H.at<float>(1,1) = rng.uniform( 0.8f, 1.2f);
-    H.at<float>(1,2) = rng.uniform(-0.1f, 0.1f)*src.rows;
-    H.at<float>(2,0) = rng.uniform( -1e-4f, 1e-4f);
-    H.at<float>(2,1) = rng.uniform( -1e-4f, 1e-4f);
-    H.at<float>(2,2) = rng.uniform( 0.8f, 1.2f);
-
-    warpPerspective( src, dst, H, src.size() );
-}
-
-/*
- * Trains Calonder classifier and writes trained classifier in file:
- *      imgFilename - name of .txt file which contains list of full filenames of train images,
- *      classifierFilename - name of binary file in which classifier will be written.
- *
- * To train Calonder classifier RTreeClassifier class need to be used.
- */
-static void trainCalonderClassifier( const string& classifierFilename, const string& imgFilename )
-{
-    // Reads train images
-    ifstream is( imgFilename.c_str(), ifstream::in );
-    vector<Mat> trainImgs;
-    while( !is.eof() )
-    {
-        string str;
-        getline( is, str );
-        if (str.empty()) break;
-        Mat img = imread( str, IMREAD_GRAYSCALE );
-        if( !img.empty() )
-            trainImgs.push_back( img );
-    }
-    if( trainImgs.empty() )
-    {
-        cout << "All train images can not be read." << endl;
-        exit(-1);
-    }
-    cout << trainImgs.size() << " train images were read." << endl;
-
-    // Extracts keypoints from train images
-    SurfFeatureDetector detector;
-    vector<BaseKeypoint> trainPoints;
-    vector<IplImage> iplTrainImgs(trainImgs.size());
-    for( size_t imgIdx = 0; imgIdx < trainImgs.size(); imgIdx++ )
-    {
-        iplTrainImgs[imgIdx] = trainImgs[imgIdx];
-        vector<KeyPoint> kps; detector.detect( trainImgs[imgIdx], kps );
-
-        for( size_t pointIdx = 0; pointIdx < kps.size(); pointIdx++ )
-        {
-            Point2f p = kps[pointIdx].pt;
-            trainPoints.push_back( BaseKeypoint(cvRound(p.x), cvRound(p.y), &iplTrainImgs[imgIdx]) );
-        }
-    }
-
-    // Trains Calonder classifier on extracted points
-    RTreeClassifier classifier;
-    classifier.train( trainPoints, theRNG(), 48, 9, 100 );
-    // Writes classifier
-    classifier.write( classifierFilename.c_str() );
-}
-
-/*
- * Test Calonder classifier to match keypoints on given image:
- *      classifierFilename - name of file from which classifier will be read,
- *      imgFilename - test image filename.
- *
- * To calculate keypoint descriptors you may use RTreeClassifier class (as to train),
- * but it is convenient to use CalonderDescriptorExtractor class which is wrapper of
- * RTreeClassifier.
- */
-static void testCalonderClassifier( const string& classifierFilename, const string& imgFilename )
-{
-    Mat img1 = imread( imgFilename, IMREAD_GRAYSCALE ), img2, H12;
-    if( img1.empty() )
-    {
-        cout << "Test image can not be read." << endl;
-        exit(-1);
-    }
-    warpPerspectiveRand( img1, img2, H12, theRNG() );
-
-    // Exstract keypoints from test images
-    SurfFeatureDetector detector;
-    vector<KeyPoint> keypoints1; detector.detect( img1, keypoints1 );
-    vector<KeyPoint> keypoints2; detector.detect( img2, keypoints2 );
-
-    // Compute descriptors
-    CalonderDescriptorExtractor<float> de( classifierFilename );
-    Mat descriptors1;  de.compute( img1, keypoints1, descriptors1 );
-    Mat descriptors2;  de.compute( img2, keypoints2, descriptors2 );
-
-    // Match descriptors
-    BFMatcher matcher(de.defaultNorm());
-    vector<DMatch> matches;
-    matcher.match( descriptors1, descriptors2, matches );
-
-    // Prepare inlier mask
-    vector<char> matchesMask( matches.size(), 0 );
-    vector<Point2f> points1; KeyPoint::convert( keypoints1, points1 );
-    vector<Point2f> points2; KeyPoint::convert( keypoints2, points2 );
-    Mat points1t; perspectiveTransform(Mat(points1), points1t, H12);
-    for( size_t mi = 0; mi < matches.size(); mi++ )
-    {
-        if( norm(points2[matches[mi].trainIdx] - points1t.at<Point2f>((int)mi,0)) < 4 ) // inlier
-            matchesMask[mi] = 1;
-    }
-
-    // Draw
-    Mat drawImg;
-    drawMatches( img1, keypoints1, img2, keypoints2, matches, drawImg, CV_RGB(0, 255, 0), CV_RGB(0, 0, 255), matchesMask );
-    string winName = "Matches";
-    namedWindow( winName, WINDOW_AUTOSIZE );
-    imshow( winName, drawImg );
-    waitKey();
-}
-
-int main( int argc, char **argv )
-{
-    if( argc != 4 && argc != 3 )
-    {
-        help();
-        return -1;
-    }
-
-    if( argc == 4 )
-        trainCalonderClassifier( argv[1], argv[3] );
-
-    testCalonderClassifier( argv[1], argv[2] );
-
-    return 0;
-}
diff --git a/samples/c/find_obj_ferns.cpp b/samples/c/find_obj_ferns.cpp
deleted file mode 100644 (file)
index cd48684..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-#include "opencv2/core/utility.hpp"
-#include "opencv2/highgui.hpp"
-#include "opencv2/imgproc.hpp"
-#include "opencv2/features2d.hpp"
-#include "opencv2/objdetect.hpp"
-#include "opencv2/legacy.hpp"
-
-#include <algorithm>
-#include <iostream>
-#include <vector>
-#include <stdio.h>
-
-using namespace std;
-using namespace cv;
-
-static void help()
-{
-    printf( "This program shows the use of the \"fern\" plannar PlanarObjectDetector point\n"
-            "descriptor classifier\n"
-            "Usage:\n"
-            "./find_obj_ferns <object_filename> <scene_filename>, default: box.png and box_in_scene.png\n\n");
-    return;
-}
-
-
-int main(int argc, char** argv)
-{
-    int i;
-
-    const char* object_filename = argc > 1 ? argv[1] : "box.png";
-    const char* scene_filename = argc > 2 ? argv[2] : "box_in_scene.png";
-
-    help();
-
-    Mat object = imread( object_filename, IMREAD_GRAYSCALE );
-    Mat scene = imread( scene_filename, IMREAD_GRAYSCALE );
-
-    if( !object.data || !scene.data )
-    {
-        fprintf( stderr, "Can not load %s and/or %s\n",
-                object_filename, scene_filename );
-        exit(-1);
-    }
-
-    double imgscale = 1;
-    Mat image;
-
-    resize(scene, image, Size(), 1./imgscale, 1./imgscale, INTER_CUBIC);
-
-    namedWindow("Object", 1);
-    namedWindow("Image", 1);
-    namedWindow("Object Correspondence", 1);
-
-    Size patchSize(32, 32);
-    LDetector ldetector(7, 20, 2, 2000, patchSize.width, 2);
-    ldetector.setVerbose(true);
-    PlanarObjectDetector detector;
-
-    vector<Mat> objpyr, imgpyr;
-    int blurKSize = 3;
-    double sigma = 0;
-    GaussianBlur(object, object, Size(blurKSize, blurKSize), sigma, sigma);
-    GaussianBlur(image, image, Size(blurKSize, blurKSize), sigma, sigma);
-    buildPyramid(object, objpyr, ldetector.nOctaves-1);
-    buildPyramid(image, imgpyr, ldetector.nOctaves-1);
-
-    vector<KeyPoint> objKeypoints, imgKeypoints;
-    PatchGenerator gen(0,256,5,true,0.8,1.2,-CV_PI/2,CV_PI/2,-CV_PI/2,CV_PI/2);
-
-    string model_filename = format("%s_model.xml.gz", object_filename);
-    printf("Trying to load %s ...\n", model_filename.c_str());
-    FileStorage fs(model_filename, FileStorage::READ);
-    if( fs.isOpened() )
-    {
-        detector.read(fs.getFirstTopLevelNode());
-        printf("Successfully loaded %s.\n", model_filename.c_str());
-    }
-    else
-    {
-        printf("The file not found and can not be read. Let's train the model.\n");
-        printf("Step 1. Finding the robust keypoints ...\n");
-        ldetector.setVerbose(true);
-        ldetector.getMostStable2D(object, objKeypoints, 100, gen);
-        printf("Done.\nStep 2. Training ferns-based planar object detector ...\n");
-        detector.setVerbose(true);
-
-        detector.train(objpyr, objKeypoints, patchSize.width, 100, 11, 10000, ldetector, gen);
-        printf("Done.\nStep 3. Saving the model to %s ...\n", model_filename.c_str());
-        if( fs.open(model_filename, FileStorage::WRITE) )
-            detector.write(fs, "ferns_model");
-    }
-    printf("Now find the keypoints in the image, try recognize them and compute the homography matrix\n");
-    fs.release();
-
-    vector<Point2f> dst_corners;
-    Mat correspond( object.rows + image.rows, std::max(object.cols, image.cols), CV_8UC3);
-    correspond = Scalar(0.);
-    Mat part(correspond, Rect(0, 0, object.cols, object.rows));
-    cvtColor(object, part, CV_GRAY2BGR);
-    part = Mat(correspond, Rect(0, object.rows, image.cols, image.rows));
-    cvtColor(image, part, CV_GRAY2BGR);
-
-    vector<int> pairs;
-    Mat H;
-
-    double t = (double)getTickCount();
-    objKeypoints = detector.getModelPoints();
-    ldetector(imgpyr, imgKeypoints, 300);
-
-    std::cout << "Object keypoints: " << objKeypoints.size() << "\n";
-    std::cout << "Image keypoints: " << imgKeypoints.size() << "\n";
-    bool found = detector(imgpyr, imgKeypoints, H, dst_corners, &pairs);
-    t = (double)getTickCount() - t;
-    printf("%gms\n", t*1000/getTickFrequency());
-
-    if( found )
-    {
-        for( i = 0; i < 4; i++ )
-        {
-            Point r1 = dst_corners[i%4];
-            Point r2 = dst_corners[(i+1)%4];
-            line( correspond, Point(r1.x, r1.y+object.rows),
-                 Point(r2.x, r2.y+object.rows), Scalar(0,0,255) );
-        }
-    }
-
-    for( i = 0; i < (int)pairs.size(); i += 2 )
-    {
-        line( correspond, objKeypoints[pairs[i]].pt,
-             imgKeypoints[pairs[i+1]].pt + Point2f(0,(float)object.rows),
-             Scalar(0,255,0) );
-    }
-
-    imshow( "Object Correspondence", correspond );
-    Mat objectColor;
-    cvtColor(object, objectColor, CV_GRAY2BGR);
-    for( i = 0; i < (int)objKeypoints.size(); i++ )
-    {
-        circle( objectColor, objKeypoints[i].pt, 2, Scalar(0,0,255), -1 );
-        circle( objectColor, objKeypoints[i].pt, (1 << objKeypoints[i].octave)*15, Scalar(0,255,0), 1 );
-    }
-    Mat imageColor;
-    cvtColor(image, imageColor, CV_GRAY2BGR);
-    for( i = 0; i < (int)imgKeypoints.size(); i++ )
-    {
-        circle( imageColor, imgKeypoints[i].pt, 2, Scalar(0,0,255), -1 );
-        circle( imageColor, imgKeypoints[i].pt, (1 << imgKeypoints[i].octave)*15, Scalar(0,255,0), 1 );
-    }
-
-    imwrite("correspond.png", correspond );
-    imshow( "Object", objectColor );
-    imshow( "Image", imageColor );
-
-    waitKey(0);
-
-    return 0;
-}
diff --git a/samples/c/fruits.jpg b/samples/c/fruits.jpg
deleted file mode 100644 (file)
index a89b84a..0000000
Binary files a/samples/c/fruits.jpg and /dev/null differ
diff --git a/samples/c/latentsvmdetect.cpp b/samples/c/latentsvmdetect.cpp
deleted file mode 100644 (file)
index 83a078e..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "opencv2/objdetect/objdetect_c.h"
-#include "opencv2/highgui/highgui_c.h"
-#include "opencv2/core/utility.hpp"
-#include <stdio.h>
-
-using namespace cv;
-
-static void help()
-{
-    printf( "This program demonstrated the use of the latentSVM detector.\n"
-            "It reads in a trained object model and then uses that to detect the object in an image\n"
-            "Call:\n"
-            "./latentsvmdetect [<image_filename> <model_filename> [<threads_number>]]\n"
-            "  The defaults for image_filename and model_filename are cat.jpg and cat.xml respectively\n"
-            "  Press any key to quit.\n");
-}
-
-const char* model_filename = "cat.xml";
-const char* image_filename = "cat.jpg";
-int   tbbNumThreads = -1;
-
-static void detect_and_draw_objects( IplImage* image, CvLatentSvmDetector* detector, int numThreads = -1)
-{
-    CvMemStorage* storage = cvCreateMemStorage(0);
-    CvSeq* detections = 0;
-    int i = 0;
-    int64 start = 0, finish = 0;
-
-    setNumThreads(numThreads);
-    numThreads = getNumThreads();
-    printf("Number of threads %i\n", numThreads);
-
-    start = cvGetTickCount();
-    detections = cvLatentSvmDetectObjects(image, detector, storage, 0.5f, numThreads);
-    finish = cvGetTickCount();
-    printf("detection time = %.3f\n", (float)(finish - start) / (float)(cvGetTickFrequency() * 1000000.0));
-    setNumThreads(-1);
-
-    for( i = 0; i < detections->total; i++ )
-    {
-        CvObjectDetection detection = *(CvObjectDetection*)cvGetSeqElem( detections, i );
-        float score         = detection.score;
-        CvRect bounding_box = detection.rect;
-        cvRectangle( image, cvPoint(bounding_box.x, bounding_box.y),
-                     cvPoint(bounding_box.x + bounding_box.width,
-                            bounding_box.y + bounding_box.height),
-                     CV_RGB(cvRound(255.0f*score),0,0), 3 );
-    }
-    cvReleaseMemStorage( &storage );
-}
-
-int main(int argc, char* argv[])
-{
-    help();
-    if (argc > 2)
-    {
-        image_filename = argv[1];
-        model_filename = argv[2];
-        if (argc > 3)
-        {
-            tbbNumThreads = atoi(argv[3]);
-        }
-    }
-    IplImage* image = cvLoadImage(image_filename);
-    if (!image)
-    {
-        printf( "Unable to load the image\n"
-                "Pass it as the first parameter: latentsvmdetect <path to cat.jpg> <path to cat.xml>\n" );
-        return -1;
-    }
-    CvLatentSvmDetector* detector = cvLoadLatentSvmDetector(model_filename);
-    if (!detector)
-    {
-        printf( "Unable to load the model\n"
-                "Pass it as the second parameter: latentsvmdetect <path to cat.jpg> <path to cat.xml>\n" );
-        cvReleaseImage( &image );
-        return -1;
-    }
-    detect_and_draw_objects( image, detector, tbbNumThreads );
-    cvNamedWindow( "test", 0 );
-    cvShowImage( "test", image );
-    cvWaitKey(0);
-    cvReleaseLatentSvmDetector( &detector );
-    cvReleaseImage( &image );
-    cvDestroyAllWindows();
-
-    return 0;
-}
diff --git a/samples/c/lena.jpg b/samples/c/lena.jpg
deleted file mode 100644 (file)
index f06aa74..0000000
Binary files a/samples/c/lena.jpg and /dev/null differ
diff --git a/samples/c/morphology.c b/samples/c/morphology.c
deleted file mode 100644 (file)
index fc2e2f1..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-#include "opencv2/highgui/highgui_c.h"
-#include "opencv2/imgproc/imgproc_c.h"
-
-#include <stdio.h>
-
-IplImage* src = 0;
-IplImage* dst = 0;
-
-IplConvKernel* element = 0;
-int element_shape = CV_SHAPE_RECT;
-
-//the address of variable which receives trackbar position update
-int max_iters = 10;
-int open_close_pos = 0;
-int erode_dilate_pos = 0;
-
-// callback function for open/close trackbar
-static void OpenClose(int pos)
-{
-    int n = open_close_pos - max_iters;
-    int an = n > 0 ? n : -n;
-    (void)pos;
-
-    element = cvCreateStructuringElementEx( an*2+1, an*2+1, an, an, element_shape, 0 );
-    if( n < 0 )
-    {
-        cvErode(src,dst,element,1);
-        cvDilate(dst,dst,element,1);
-    }
-    else
-    {
-        cvDilate(src,dst,element,1);
-        cvErode(dst,dst,element,1);
-    }
-    cvReleaseStructuringElement(&element);
-    cvShowImage("Open/Close",dst);
-}
-
-// callback function for erode/dilate trackbar
-static void ErodeDilate(int pos)
-{
-    int n = erode_dilate_pos - max_iters;
-    int an = n > 0 ? n : -n;
-    (void)pos;
-
-    element = cvCreateStructuringElementEx( an*2+1, an*2+1, an, an, element_shape, 0 );
-    if( n < 0 )
-    {
-        cvErode(src,dst,element,1);
-    }
-    else
-    {
-        cvDilate(src,dst,element,1);
-    }
-    cvReleaseStructuringElement(&element);
-    cvShowImage("Erode/Dilate",dst);
-}
-
-static void help(void)
-{
-    printf( "This program demonstrated the use of the morphology operator, especially open, close, erode, dilate operations\n"
-            "Morphology operators are built on max (close) and min (open) operators as measured by pixels covered by small structuring elements.\n"
-            "These operators are very efficient.\n"
-            "This program also allows you to play with elliptical, rectangluar and cross structure elements\n"
-            "Usage: \n"
-            "./morphologyc [image_name -- Default baboon.jpg]\n"
-            "\nHot keys: \n"
-                "\tESC - quit the program\n"
-                "\tr - use rectangle structuring element\n"
-                "\te - use elliptic structuring element\n"
-                "\tc - use cross-shaped structuring element\n"
-                "\tSPACE - loop through all the options\n" );
-}
-
-int main( int argc, char** argv )
-{
-    char* filename = 0;
-
-    help();
-
-    filename = argc == 2 ? argv[1] : (char*)"baboon.jpg";
-    if( (src = cvLoadImage(filename,1)) == 0 )
-    {
-        printf("Cannot load file image %s\n", filename);
-        help();
-        return -1;
-    }
-
-
-
-    dst = cvCloneImage(src);
-
-    //create windows for output images
-    cvNamedWindow("Open/Close",1);
-    cvNamedWindow("Erode/Dilate",1);
-
-    open_close_pos = erode_dilate_pos = max_iters;
-    cvCreateTrackbar("iterations", "Open/Close",&open_close_pos,max_iters*2+1,OpenClose);
-    cvCreateTrackbar("iterations", "Erode/Dilate",&erode_dilate_pos,max_iters*2+1,ErodeDilate);
-
-    for(;;)
-    {
-        int c;
-
-        OpenClose(open_close_pos);
-        ErodeDilate(erode_dilate_pos);
-        c = cvWaitKey(0);
-
-        if( (char)c == 27 )
-            break;
-        if( (char)c == 'e' )
-            element_shape = CV_SHAPE_ELLIPSE;
-        else if( (char)c == 'r' )
-            element_shape = CV_SHAPE_RECT;
-        else if( (char)c == 'c' )
-            element_shape = CV_SHAPE_CROSS;
-        else if( (char)c == ' ' )
-            element_shape = (element_shape + 1) % 3;
-    }
-
-    //release images
-    cvReleaseImage(&src);
-    cvReleaseImage(&dst);
-
-    //destroy windows
-    cvDestroyWindow("Open/Close");
-    cvDestroyWindow("Erode/Dilate");
-
-    return 0;
-}
diff --git a/samples/c/mser_sample.cpp b/samples/c/mser_sample.cpp
deleted file mode 100644 (file)
index b6b96c3..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* This sample code was originally provided by Liu Liu
- * Copyright (C) 2009, Liu Liu All rights reserved.
- */
-
-#include <opencv2/core/utility.hpp>
-#include "opencv2/highgui.hpp"
-#include "opencv2/features2d.hpp"
-#include "opencv2/imgproc.hpp"
-
-#include <iostream>
-#include <stdio.h>
-
-using namespace cv;
-using namespace std;
-
-static void help()
-{
-    cout << "\nThis program demonstrates the Maximal Extremal Region interest point detector.\n"
-    "It finds the most stable (in size) dark and white regions as a threshold is increased.\n"
-    "\nCall:\n"
-    "./mser_sample <path_and_image_filename, Default is 'puzzle.png'>\n\n";
-}
-
-static const Vec3b bcolors[] =
-{
-    Vec3b(0,0,255),
-    Vec3b(0,128,255),
-    Vec3b(0,255,255),
-    Vec3b(0,255,0),
-    Vec3b(255,128,0),
-    Vec3b(255,255,0),
-    Vec3b(255,0,0),
-    Vec3b(255,0,255),
-    Vec3b(255,255,255)
-};
-
-int main( int argc, char** argv )
-{
-    string path;
-    Mat img0, img, yuv, gray, ellipses;
-    help();
-
-    img0 = imread( argc != 2 ? "puzzle.png" : argv[1], 1 );
-    if( img0.empty() )
-    {
-        if( argc != 2 )
-            cout << "\nUsage: mser_sample <path_to_image>\n";
-        else
-            cout << "Unable to load image " << argv[1] << endl;
-        return 0;
-    }
-
-    cvtColor(img0, yuv, COLOR_BGR2YCrCb);
-    cvtColor(img0, gray, COLOR_BGR2GRAY);
-    cvtColor(gray, img, COLOR_GRAY2BGR);
-    img.copyTo(ellipses);
-
-    vector<vector<Point> > contours;
-    double t = (double)getTickCount();
-    MSER()(yuv, contours);
-    t = (double)getTickCount() - t;
-    printf( "MSER extracted %d contours in %g ms.\n", (int)contours.size(),
-           t*1000./getTickFrequency() );
-
-    // draw mser's with different colors
-    for( int i = (int)contours.size()-1; i >= 0; i-- )
-    {
-        const vector<Point>& r = contours[i];
-        for ( int j = 0; j < (int)r.size(); j++ )
-        {
-            Point pt = r[j];
-            img.at<Vec3b>(pt) = bcolors[i%9];
-        }
-
-        // find ellipse (it seems cvfitellipse2 have error or sth?)
-        RotatedRect box = fitEllipse( r );
-
-        box.angle=(float)CV_PI/2-box.angle;
-        ellipse( ellipses, box, Scalar(196,255,255), 2 );
-    }
-
-    imshow( "original", img0 );
-    imshow( "response", img );
-    imshow( "ellipses", ellipses );
-
-    waitKey(0);
-}
diff --git a/samples/c/one_way_sample.cpp b/samples/c/one_way_sample.cpp
deleted file mode 100644 (file)
index d2ca7f4..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- *  one_way_sample.cpp
- *  outlet_detection
- *
- *  Created by Victor  Eruhimov on 8/5/09.
- *  Copyright 2009 Argus Corp. All rights reserved.
- *
- */
-
-#include "opencv2/imgproc/imgproc.hpp"
-#include "opencv2/features2d/features2d.hpp"
-#include "opencv2/highgui/highgui.hpp"
-#include "opencv2/imgproc/imgproc_c.h"
-#include "opencv2/nonfree/nonfree.hpp"
-#include "opencv2/legacy/legacy.hpp"
-#include "opencv2/legacy/compat.hpp"
-
-#include <string>
-#include <stdio.h>
-
-static void help()
-{
-    printf("\nThis program demonstrates the one way interest point descriptor found in features2d.hpp\n"
-            "Correspondences are drawn\n");
-    printf("Format: \n./one_way_sample <path_to_samples> <image1> <image2>\n");
-    printf("For example: ./one_way_sample . ../c/scene_l.bmp ../c/scene_r.bmp\n");
-}
-
-using namespace std;
-using namespace cv;
-
-Mat DrawCorrespondences(const Mat& img1, const vector<KeyPoint>& features1, const Mat& img2,
-                        const vector<KeyPoint>& features2, const vector<int>& desc_idx);
-
-int main(int argc, char** argv)
-{
-    const char images_list[] = "one_way_train_images.txt";
-    const CvSize patch_size = cvSize(24, 24);
-    const int pose_count = 50;
-
-    if (argc != 4)
-    {
-        help();
-        return 0;
-    }
-
-    std::string path_name = argv[1];
-    std::string img1_name = path_name + "/" + std::string(argv[2]);
-    std::string img2_name = path_name + "/" + std::string(argv[3]);
-
-    printf("Reading the images...\n");
-    Mat img1 = imread(img1_name, IMREAD_GRAYSCALE);
-    Mat img2 = imread(img2_name, IMREAD_GRAYSCALE);
-
-    // extract keypoints from the first image
-    SURF surf_extractor(5.0e3);
-    vector<KeyPoint> keypoints1;
-
-    // printf("Extracting keypoints\n");
-    surf_extractor(img1, Mat(), keypoints1);
-
-    printf("Extracted %d keypoints...\n", (int)keypoints1.size());
-
-    printf("Training one way descriptors... \n");
-    // create descriptors
-    OneWayDescriptorBase descriptors(patch_size, pose_count, OneWayDescriptorBase::GetPCAFilename(), path_name,
-                                     images_list);
-    IplImage img1_c = img1;
-    IplImage img2_c = img2;
-    descriptors.CreateDescriptorsFromImage(&img1_c, keypoints1);
-    printf("done\n");
-
-    // extract keypoints from the second image
-    vector<KeyPoint> keypoints2;
-    surf_extractor(img2, Mat(), keypoints2);
-    printf("Extracted %d keypoints from the second image...\n", (int)keypoints2.size());
-
-    printf("Finding nearest neighbors...");
-    // find NN for each of keypoints2 in keypoints1
-    vector<int> desc_idx;
-    desc_idx.resize(keypoints2.size());
-    for (size_t i = 0; i < keypoints2.size(); i++)
-    {
-        int pose_idx = 0;
-        float distance = 0;
-        descriptors.FindDescriptor(&img2_c, keypoints2[i].pt, desc_idx[i], pose_idx, distance);
-    }
-    printf("done\n");
-
-    Mat img_corr = DrawCorrespondences(img1, keypoints1, img2, keypoints2, desc_idx);
-
-    imshow("correspondences", img_corr);
-    waitKey(0);
-}
-
-Mat DrawCorrespondences(const Mat& img1, const vector<KeyPoint>& features1, const Mat& img2,
-                        const vector<KeyPoint>& features2, const vector<int>& desc_idx)
-{
-    Mat part, img_corr(Size(img1.cols + img2.cols, MAX(img1.rows, img2.rows)), CV_8UC3);
-    img_corr = Scalar::all(0);
-    part = img_corr(Rect(0, 0, img1.cols, img1.rows));
-    cvtColor(img1, part, COLOR_GRAY2RGB);
-    part = img_corr(Rect(img1.cols, 0, img2.cols, img2.rows));
-    cvtColor(img1, part, COLOR_GRAY2RGB);
-
-    for (size_t i = 0; i < features1.size(); i++)
-    {
-        circle(img_corr, features1[i].pt, 3, CV_RGB(255, 0, 0));
-    }
-
-    for (size_t i = 0; i < features2.size(); i++)
-    {
-        Point pt((int)features2[i].pt.x + img1.cols, (int)features2[i].pt.y);
-        circle(img_corr, pt, 3, Scalar(0, 0, 255));
-        line(img_corr, features1[desc_idx[i]].pt, pt, Scalar(0, 255, 0));
-    }
-
-    return img_corr;
-}
diff --git a/samples/c/one_way_train_0000.jpg b/samples/c/one_way_train_0000.jpg
deleted file mode 100644 (file)
index 457820e..0000000
Binary files a/samples/c/one_way_train_0000.jpg and /dev/null differ
diff --git a/samples/c/one_way_train_0001.jpg b/samples/c/one_way_train_0001.jpg
deleted file mode 100644 (file)
index 7f3990f..0000000
Binary files a/samples/c/one_way_train_0001.jpg and /dev/null differ
diff --git a/samples/c/one_way_train_images.txt b/samples/c/one_way_train_images.txt
deleted file mode 100644 (file)
index eefa571..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-one_way_train_0000.jpg
-one_way_train_0001.jpg
diff --git a/samples/c/pyramid_segmentation.c b/samples/c/pyramid_segmentation.c
deleted file mode 100644 (file)
index c15c7cd..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-#include "opencv2/imgproc/imgproc_c.h"
-#include "opencv2/highgui/highgui_c.h"
-#include "opencv2/legacy.hpp"
-#include <stdio.h>
-
-static void help(void)
-{
-    printf("\nThis program demonstrated color pyramid segmentation cvcvPyrSegmentation() which is controlled\n"
-            "by two trhesholds which can be manipulated by a trackbar. It can take an image file name or defaults to 'fruits.jpg'\n"
-            "Usage :\n"
-            "./pyaramid_segmentation [image_path_filename -- Defaults to fruits.jpg]\n\n"
-            );
-}
-
-IplImage*  image[2] = { 0, 0 }, *image0 = 0, *image1 = 0;
-CvSize size;
-
-int  w0, h0,i;
-int  threshold1, threshold2;
-int  l,level = 4;
-int sthreshold1, sthreshold2;
-int  l_comp;
-int block_size = 1000;
-float  parameter;
-double threshold;
-double rezult, min_rezult;
-int filter = CV_GAUSSIAN_5x5;
-CvConnectedComp *cur_comp, min_comp;
-CvSeq *comp;
-CvMemStorage *storage;
-
-CvPoint pt1, pt2;
-
-static void ON_SEGMENT(int a)
-{
-    (void)a;
-    cvPyrSegmentation(image0, image1, storage, &comp,
-                      level, threshold1+1, threshold2+1);
-
-    cvShowImage("Segmentation", image1);
-}
-
-
-int main( int argc, char** argv )
-{
-    char* filename;
-
-    help();
-
-    filename = argc == 2 ? argv[1] : (char*)"fruits.jpg";
-
-    if( (image[0] = cvLoadImage( filename, 1)) == 0 )
-    {
-        help();
-        printf("Cannot load fileimage - %s\n", filename);
-        return -1;
-    }
-
-    cvNamedWindow("Source", 0);
-    cvShowImage("Source", image[0]);
-
-    cvNamedWindow("Segmentation", 0);
-
-    storage = cvCreateMemStorage ( block_size );
-
-    image[0]->width &= -(1<<level);
-    image[0]->height &= -(1<<level);
-
-    image0 = cvCloneImage( image[0] );
-    image1 = cvCloneImage( image[0] );
-    // segmentation of the color image
-    l = 1;
-    threshold1 =255;
-    threshold2 =30;
-
-    ON_SEGMENT(1);
-
-    sthreshold1 = cvCreateTrackbar("Threshold1", "Segmentation", &threshold1, 255, ON_SEGMENT);
-    sthreshold2 = cvCreateTrackbar("Threshold2", "Segmentation",  &threshold2, 255, ON_SEGMENT);
-
-    cvShowImage("Segmentation", image1);
-    cvWaitKey(0);
-
-    cvDestroyWindow("Segmentation");
-    cvDestroyWindow("Source");
-
-    cvReleaseMemStorage(&storage );
-
-    cvReleaseImage(&image[0]);
-    cvReleaseImage(&image0);
-    cvReleaseImage(&image1);
-
-    return 0;
-}
-
-#ifdef _EiC
-main(1,"pyramid_segmentation.c");
-#endif
diff --git a/samples/c/stuff.jpg b/samples/c/stuff.jpg
deleted file mode 100644 (file)
index 720d341..0000000
Binary files a/samples/c/stuff.jpg and /dev/null differ
index 5b92b5e..e597c0c 100644 (file)
@@ -3,9 +3,9 @@
 #
 # ----------------------------------------------------------------------------
 
-SET(OPENCV_CPP_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc
-    opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo opencv_nonfree opencv_softcascade
-    opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_stitching opencv_videostab opencv_shape)
+SET(OPENCV_CPP_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_flann
+    opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo opencv_nonfree
+    opencv_features2d opencv_calib3d opencv_stitching opencv_videostab opencv_shape)
 
 ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
 
diff --git a/samples/cpp/Qt_sample/CMakeLists.txt b/samples/cpp/Qt_sample/CMakeLists.txt
deleted file mode 100644 (file)
index f465947..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#http://www.cmake.org/cmake/help/cmake2.6docs.html
-cmake_minimum_required (VERSION 2.6)
-project (OpenGL_Qt_Binding)
-
-
-FIND_PACKAGE( OpenCV REQUIRED )
-find_package (OpenGL REQUIRED)
-
-
-ADD_EXECUTABLE(OpenGL_Qt_Binding qt_opengl.cpp)
-TARGET_LINK_LIBRARIES(OpenGL_Qt_Binding ${OpenCV_LIBS} ${OPENGL_LIBRARIES} )
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cube4.avi ${CMAKE_CURRENT_BINARY_DIR}/cube4.avi COPYONLY)
diff --git a/samples/cpp/Qt_sample/cube4.avi b/samples/cpp/Qt_sample/cube4.avi
deleted file mode 100644 (file)
index 70ec42b..0000000
Binary files a/samples/cpp/Qt_sample/cube4.avi and /dev/null differ
diff --git a/samples/cpp/Qt_sample/qt_opengl.cpp b/samples/cpp/Qt_sample/qt_opengl.cpp
deleted file mode 100644 (file)
index ff4a0b0..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-// Yannick Verdie 2010
-// --- Please read help() below: ---
-
-#include <iostream>
-#include <vector>
-
-#include <opencv2/calib3d/calib3d.hpp>
-#include <opencv2/calib3d/calib3d_c.h>
-#include <opencv2/core/core.hpp>
-#include <opencv2/highgui/highgui.hpp>
-#include <opencv2/imgproc/imgproc.hpp>
-#include <opencv2/legacy/compat.hpp>
-
-#ifdef __APPLE__
-#include <OpenGL/gl.h>
-#else
-#include <GL/gl.h>
-#endif
-
-using namespace std;
-using namespace cv;
-
-static void help()
-{
-    cout << "This demo demonstrates the use of the Qt enhanced version of the highgui GUI interface\n"
-            "and dang if it doesn't throw in the use of of the POSIT 3D tracking algorithm too\n"
-            "It works off of the video: cube4.avi\n"
-            "Using OpenCV version " << CV_VERSION << "\n\n"
-
-            " 1) This demo is mainly based on work from Javier Barandiaran Martirena\n"
-            "    See this page http://code.opencv.org/projects/opencv/wiki/Posit.\n"
-            " 2) This is a demo to illustrate how to use **OpenGL Callback**.\n"
-            " 3) You need Qt binding to compile this sample with OpenGL support enabled.\n"
-            " 4) The features' detection is very basic and could highly be improved\n"
-            "    (basic thresholding tuned for the specific video) but 2).\n"
-            " 5) Thanks to Google Summer of Code 2010 for supporting this work!\n" << endl;
-}
-
-#define FOCAL_LENGTH 600
-#define CUBE_SIZE 0.5
-
-static void renderCube(float size)
-{
-    glBegin(GL_QUADS);
-    // Front Face
-    glNormal3f( 0.0f, 0.0f, 1.0f);
-    glVertex3f( 0.0f,  0.0f,  0.0f);
-    glVertex3f( size,  0.0f,  0.0f);
-    glVertex3f( size,  size,  0.0f);
-    glVertex3f( 0.0f,  size,  0.0f);
-    // Back Face
-    glNormal3f( 0.0f, 0.0f,-1.0f);
-    glVertex3f( 0.0f,  0.0f, size);
-    glVertex3f( 0.0f,  size, size);
-    glVertex3f( size,  size, size);
-    glVertex3f( size,  0.0f, size);
-    // Top Face
-    glNormal3f( 0.0f, 1.0f, 0.0f);
-    glVertex3f( 0.0f,  size,  0.0f);
-    glVertex3f( size,  size,  0.0f);
-    glVertex3f( size,  size, size);
-    glVertex3f( 0.0f,  size, size);
-    // Bottom Face
-    glNormal3f( 0.0f,-1.0f, 0.0f);
-    glVertex3f( 0.0f,  0.0f,  0.0f);
-    glVertex3f( 0.0f,  0.0f, size);
-    glVertex3f( size,  0.0f, size);
-    glVertex3f( size,  0.0f,  0.0f);
-    // Right face
-    glNormal3f( 1.0f, 0.0f, 0.0f);
-    glVertex3f( size,  0.0f, 0.0f);
-    glVertex3f( size,  0.0f, size);
-    glVertex3f( size,  size, size);
-    glVertex3f( size,  size, 0.0f);
-    // Left Face
-    glNormal3f(-1.0f, 0.0f, 0.0f);
-    glVertex3f( 0.0f,  0.0f, 0.0f);
-    glVertex3f( 0.0f,  size, 0.0f);
-    glVertex3f( 0.0f,  size, size);
-    glVertex3f( 0.0f,  0.0f, size);
-    glEnd();
-}
-
-static void on_opengl(void* param)
-{
-    //Draw the object with the estimated pose
-    glLoadIdentity();
-    glScalef( 1.0f, 1.0f, -1.0f);
-    glMultMatrixf( (float*)param );
-    glEnable( GL_LIGHTING );
-    glEnable( GL_LIGHT0 );
-    glEnable( GL_BLEND );
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-    renderCube( CUBE_SIZE );
-    glDisable(GL_BLEND);
-    glDisable( GL_LIGHTING );
-}
-
-static void initPOSIT(std::vector<CvPoint3D32f> * modelPoints)
-{
-    // Create the model pointss
-    modelPoints->push_back(cvPoint3D32f(0.0f, 0.0f, 0.0f)); // The first must be (0, 0, 0)
-    modelPoints->push_back(cvPoint3D32f(0.0f, 0.0f, CUBE_SIZE));
-    modelPoints->push_back(cvPoint3D32f(CUBE_SIZE, 0.0f, 0.0f));
-    modelPoints->push_back(cvPoint3D32f(0.0f, CUBE_SIZE, 0.0f));
-}
-
-static void foundCorners(vector<CvPoint2D32f> * srcImagePoints, const Mat & source, Mat & grayImage)
-{
-    cvtColor(source, grayImage, COLOR_RGB2GRAY);
-    GaussianBlur(grayImage, grayImage, Size(11, 11), 0, 0);
-    normalize(grayImage, grayImage, 0, 255, NORM_MINMAX);
-    threshold(grayImage, grayImage, 26, 255, THRESH_BINARY_INV); //25
-
-    Mat MgrayImage = grayImage;
-    vector<vector<Point> > contours;
-    vector<Vec4i> hierarchy;
-    findContours(MgrayImage, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
-
-    Point p;
-    vector<CvPoint2D32f> srcImagePoints_temp(4, cvPoint2D32f(0, 0));
-
-    if (contours.size() == srcImagePoints_temp.size())
-    {
-        for (size_t i = 0; i < contours.size(); i++ )
-        {
-            p.x = p.y = 0;
-
-            for (size_t j = 0 ; j < contours[i].size(); j++)
-                p += contours[i][j];
-
-            srcImagePoints_temp.at(i) = cvPoint2D32f(float(p.x) / contours[i].size(), float(p.y) / contours[i].size());
-        }
-
-        // Need to keep the same order
-        // > y = 0
-        // > x = 1
-        // < x = 2
-        // < y = 3
-
-        // get point 0;
-        size_t index = 0;
-        for (size_t i = 1 ; i<srcImagePoints_temp.size(); i++)
-            if (srcImagePoints_temp.at(i).y > srcImagePoints_temp.at(index).y)
-                index = i;
-        srcImagePoints->at(0) = srcImagePoints_temp.at(index);
-
-        // get point 1;
-        index = 0;
-        for (size_t i = 1 ; i<srcImagePoints_temp.size(); i++)
-            if (srcImagePoints_temp.at(i).x > srcImagePoints_temp.at(index).x)
-                index = i;
-        srcImagePoints->at(1) = srcImagePoints_temp.at(index);
-
-        // get point 2;
-        index = 0;
-        for (size_t i = 1 ; i<srcImagePoints_temp.size(); i++)
-            if (srcImagePoints_temp.at(i).x < srcImagePoints_temp.at(index).x)
-                index = i;
-        srcImagePoints->at(2) = srcImagePoints_temp.at(index);
-
-        // get point 3;
-        index = 0;
-        for (size_t i = 1 ; i<srcImagePoints_temp.size(); i++ )
-            if (srcImagePoints_temp.at(i).y < srcImagePoints_temp.at(index).y)
-                index = i;
-        srcImagePoints->at(3) = srcImagePoints_temp.at(index);
-
-        Mat Msource = source;
-        stringstream ss;
-        for (size_t i = 0; i<srcImagePoints_temp.size(); i++ )
-        {
-            ss << i;
-            circle(Msource, srcImagePoints->at(i), 5, Scalar(0, 0, 255));
-            putText(Msource, ss.str(), srcImagePoints->at(i), FONT_HERSHEY_SIMPLEX, 1, Scalar(0, 0, 255));
-            ss.str("");
-
-            // new coordinate system in the middle of the frame and reversed (camera coordinate system)
-            srcImagePoints->at(i) = cvPoint2D32f(srcImagePoints_temp.at(i).x - source.cols / 2,
-                                                 source.rows / 2 - srcImagePoints_temp.at(i).y);
-        }
-    }
-}
-
-static void createOpenGLMatrixFrom(float * posePOSIT, const CvMatr32f & rotationMatrix,
-                                   const CvVect32f & translationVector)
-{
-    // coordinate system returned is relative to the first 3D input point
-    for (int f = 0; f < 3; f++)
-        for (int c = 0; c < 3; c++)
-            posePOSIT[c * 4 + f] = rotationMatrix[f * 3 + c]; // transposed
-
-    posePOSIT[3] = translationVector[0];
-    posePOSIT[7] = translationVector[1];
-    posePOSIT[11] = translationVector[2];
-    posePOSIT[12] = 0.0f;
-    posePOSIT[13] = 0.0f;
-    posePOSIT[14] = 0.0f;
-    posePOSIT[15] = 1.0f;
-}
-
-int main(void)
-{
-    help();
-
-    string fileName = "cube4.avi";
-    VideoCapture video(fileName);
-    if (!video.isOpened())
-    {
-        cerr << "Video file " << fileName << " could not be opened" << endl;
-        return EXIT_FAILURE;
-    }
-
-    Mat source, grayImage;
-    video >> source;
-
-    namedWindow("Original", WINDOW_AUTOSIZE | WINDOW_FREERATIO);
-    namedWindow("POSIT", WINDOW_OPENGL | WINDOW_FREERATIO);
-    resizeWindow("POSIT", source.cols, source.rows);
-
-    displayOverlay("POSIT", "We lost the 4 corners' detection quite often (the red circles disappear).\n"
-                   "This demo is only to illustrate how to use OpenGL callback.\n"
-                   " -- Press ESC to exit.", 10000);
-
-    float OpenGLMatrix[] = { 0, 0, 0, 0,
-                             0, 0, 0, 0,
-                             0, 0, 0, 0,
-                             0, 0, 0, 0 };
-    setOpenGlContext("POSIT");
-    setOpenGlDrawCallback("POSIT", on_opengl, OpenGLMatrix);
-
-    vector<CvPoint3D32f> modelPoints;
-    initPOSIT(&modelPoints);
-
-    // Create the POSIT object with the model points
-    CvPOSITObject* positObject = cvCreatePOSITObject( &modelPoints[0], (int)modelPoints.size());
-
-    CvMatr32f rotation_matrix = new float[9];
-    CvVect32f translation_vector = new float[3];
-    CvTermCriteria criteria = cvTermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 100, 1e-4f);
-    vector<CvPoint2D32f> srcImagePoints(4, cvPoint2D32f(0, 0));
-
-    while (waitKey(33) != 27)
-    {
-        video >> source;
-        if (source.empty())
-            break;
-
-        imshow("Original", source);
-
-        foundCorners(&srcImagePoints, source, grayImage);
-        cvPOSIT(positObject, &srcImagePoints[0], FOCAL_LENGTH, criteria, rotation_matrix, translation_vector);
-        createOpenGLMatrixFrom(OpenGLMatrix, rotation_matrix, translation_vector);
-
-        updateWindow("POSIT");
-
-        if (video.get(CAP_PROP_POS_AVI_RATIO) > 0.99)
-            video.set(CAP_PROP_POS_AVI_RATIO, 0);
-    }
-
-    setOpenGlDrawCallback("POSIT", NULL, NULL);
-    destroyAllWindows();
-    cvReleasePOSITObject(&positObject);
-
-    delete[]rotation_matrix;
-    delete[]translation_vector;
-
-    return EXIT_SUCCESS;
-}
index c9d289e..5601aa5 100644 (file)
@@ -4,10 +4,6 @@
 #include "opencv2/features2d/features2d.hpp"
 #include "opencv2/nonfree/nonfree.hpp"
 #include "opencv2/ml/ml.hpp"
-#ifdef HAVE_OPENCV_OCL
-#define _OCL_SVM_ 1 //select whether using ocl::svm method or not, default is using
-#include "opencv2/ocl/ocl.hpp"
-#endif
 
 #include <fstream>
 #include <iostream>
@@ -2378,15 +2374,9 @@ static void setSVMTrainAutoParams( CvParamGrid& c_grid, CvParamGrid& gamma_grid,
     degree_grid.step = 0;
 }
 
-#if defined HAVE_OPENCV_OCL && _OCL_SVM_
-static void trainSVMClassifier( cv::ocl::CvSVM_OCL& svm, const SVMTrainParamsExt& svmParamsExt, const string& objClassName, VocData& vocData,
-                               Ptr<BOWImgDescriptorExtractor>& bowExtractor, const Ptr<FeatureDetector>& fdetector,
-                               const string& resPath )
-#else
 static void trainSVMClassifier( CvSVM& svm, const SVMTrainParamsExt& svmParamsExt, const string& objClassName, VocData& vocData,
                          Ptr<BOWImgDescriptorExtractor>& bowExtractor, const Ptr<FeatureDetector>& fdetector,
                          const string& resPath )
-#endif
 {
     /* first check if a previously trained svm for the current class has been saved to file */
     string svmFilename = resPath + svmsDir + "/" + objClassName + ".xml.gz";
@@ -2459,15 +2449,9 @@ static void trainSVMClassifier( CvSVM& svm, const SVMTrainParamsExt& svmParamsEx
     }
 }
 
-#if defined HAVE_OPENCV_OCL && _OCL_SVM_
-static void computeConfidences( cv::ocl::CvSVM_OCL& svm, const string& objClassName, VocData& vocData,
-                               Ptr<BOWImgDescriptorExtractor>& bowExtractor, const Ptr<FeatureDetector>& fdetector,
-                               const string& resPath )
-#else
 static void computeConfidences( CvSVM& svm, const string& objClassName, VocData& vocData,
                          Ptr<BOWImgDescriptorExtractor>& bowExtractor, const Ptr<FeatureDetector>& fdetector,
                          const string& resPath )
-#endif
 {
     cout << "*** CALCULATING CONFIDENCES FOR CLASS " << objClassName << " ***" << endl;
     cout << "CALCULATING BOW VECTORS FOR TEST SET OF " << objClassName << "..." << endl;
@@ -2606,11 +2590,7 @@ int main(int argc, char** argv)
     for( size_t classIdx = 0; classIdx < objClasses.size(); ++classIdx )
     {
         // Train a classifier on train dataset
-#if defined HAVE_OPENCV_OCL && _OCL_SVM_
-        cv::ocl::CvSVM_OCL svm;
-#else
         CvSVM svm;
-#endif
         trainSVMClassifier( svm, svmTrainParamsExt, objClasses[classIdx], vocData,
                             bowExtractor, featureDetector, resPath );
 
similarity index 100%
rename from samples/c/box.png
rename to samples/cpp/box.png
diff --git a/samples/cpp/brief_match_test.cpp b/samples/cpp/brief_match_test.cpp
deleted file mode 100644 (file)
index bf99ec7..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * matching_test.cpp
- *
- *  Created on: Oct 17, 2010
- *      Author: ethan
- */
-#include "opencv2/core.hpp"
-#include <opencv2/core/utility.hpp>
-#include "opencv2/calib3d.hpp"
-#include "opencv2/features2d.hpp"
-#include "opencv2/imgproc.hpp"
-#include "opencv2/highgui.hpp"
-#include <vector>
-#include <iostream>
-
-using namespace cv;
-using namespace std;
-
-//Copy (x,y) location of descriptor matches found from KeyPoint data structures into Point2f vectors
-static void matches2points(const vector<DMatch>& matches, const vector<KeyPoint>& kpts_train,
-                    const vector<KeyPoint>& kpts_query, vector<Point2f>& pts_train, vector<Point2f>& pts_query)
-{
-  pts_train.clear();
-  pts_query.clear();
-  pts_train.reserve(matches.size());
-  pts_query.reserve(matches.size());
-  for (size_t i = 0; i < matches.size(); i++)
-  {
-    const DMatch& match = matches[i];
-    pts_query.push_back(kpts_query[match.queryIdx].pt);
-    pts_train.push_back(kpts_train[match.trainIdx].pt);
-  }
-
-}
-
-static double match(const vector<KeyPoint>& /*kpts_train*/, const vector<KeyPoint>& /*kpts_query*/, DescriptorMatcher& matcher,
-            const Mat& train, const Mat& query, vector<DMatch>& matches)
-{
-
-  double t = (double)getTickCount();
-  matcher.match(query, train, matches); //Using features2d
-  return ((double)getTickCount() - t) / getTickFrequency();
-}
-
-static void help()
-{
-       cout << "This program shows how to use BRIEF descriptor to match points in features2d" << endl <<
-               "It takes in two images, finds keypoints and matches them displaying matches and final homography warped results" << endl <<
-                "Usage: " << endl <<
-                    "image1 image2 " << endl <<
-                "Example: " << endl <<
-                    "box.png box_in_scene.png " << endl;
-}
-
-const char* keys =
-{
-    "{@first_image  | box.png          | the first image}"
-    "{@second_image | box_in_scene.png | the second image}"
-};
-
-int main(int argc, const char ** argv)
-{
-
-  help();
-  CommandLineParser parser(argc, argv, keys);
-  string im1_name = parser.get<string>(0);
-  string im2_name = parser.get<string>(1);
-
-  Mat im1 = imread(im1_name, IMREAD_GRAYSCALE);
-  Mat im2 = imread(im2_name, IMREAD_GRAYSCALE);
-
-  if (im1.empty() || im2.empty())
-  {
-    cout << "could not open one of the images..." << endl;
-    cout << "the cmd parameters have next current value: " << endl;
-    parser.printMessage();
-    return 1;
-  }
-
-  double t = (double)getTickCount();
-
-  FastFeatureDetector detector(50);
-  BriefDescriptorExtractor extractor(32); //this is really 32 x 8 matches since they are binary matches packed into bytes
-
-  vector<KeyPoint> kpts_1, kpts_2;
-  detector.detect(im1, kpts_1);
-  detector.detect(im2, kpts_2);
-
-  t = ((double)getTickCount() - t) / getTickFrequency();
-
-  cout << "found " << kpts_1.size() << " keypoints in " << im1_name << endl << "fount " << kpts_2.size()
-      << " keypoints in " << im2_name << endl << "took " << t << " seconds." << endl;
-
-  Mat desc_1, desc_2;
-
-  cout << "computing descriptors..." << endl;
-
-  t = (double)getTickCount();
-
-  extractor.compute(im1, kpts_1, desc_1);
-  extractor.compute(im2, kpts_2, desc_2);
-
-  t = ((double)getTickCount() - t) / getTickFrequency();
-
-  cout << "done computing descriptors... took " << t << " seconds" << endl;
-
-  //Do matching using features2d
-  cout << "matching with BruteForceMatcher<Hamming>" << endl;
-  BFMatcher matcher_popcount(extractor.defaultNorm());
-  vector<DMatch> matches_popcount;
-  double pop_time = match(kpts_1, kpts_2, matcher_popcount, desc_1, desc_2, matches_popcount);
-  cout << "done BruteForceMatcher<Hamming> matching. took " << pop_time << " seconds" << endl;
-
-  vector<Point2f> mpts_1, mpts_2;
-  matches2points(matches_popcount, kpts_1, kpts_2, mpts_1, mpts_2); //Extract a list of the (x,y) location of the matches
-  vector<char> outlier_mask;
-  Mat H = findHomography(mpts_2, mpts_1, RANSAC, 1, outlier_mask);
-
-  Mat outimg;
-  drawMatches(im2, kpts_2, im1, kpts_1, matches_popcount, outimg, Scalar::all(-1), Scalar::all(-1), outlier_mask);
-  imshow("matches - popcount - outliers removed", outimg);
-
-  Mat warped;
-  Mat diff;
-  warpPerspective(im2, warped, H, im1.size());
-  imshow("warped", warped);
-  absdiff(im1,warped,diff);
-  imshow("diff", diff);
-  waitKey();
-  return 0;
-}
diff --git a/samples/cpp/build3dmodel.cpp b/samples/cpp/build3dmodel.cpp
deleted file mode 100644 (file)
index 5c4d79b..0000000
+++ /dev/null
@@ -1,778 +0,0 @@
-#include "opencv2/core.hpp"
-#include <opencv2/core/utility.hpp>
-#include "opencv2/imgproc.hpp"
-#include "opencv2/calib3d.hpp"
-#include "opencv2/features2d.hpp"
-#include "opencv2/highgui.hpp"
-
-#include <map>
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-using namespace cv;
-using namespace std;
-
-static void help()
-{
-    printf("\nSigh: This program is not complete/will be replaced. \n"
-           "So:   Use this just to see hints of how to use things like Rodrigues\n"
-           "      conversions, finding the fundamental matrix, using descriptor\n"
-           "      finding and matching in features2d and using camera parameters\n"
-           "Usage: build3dmodel -i <intrinsics_filename>\n"
-           "\t[-d <detector>] [-de <descriptor_extractor>] -m <model_name>\n\n");
-    return;
-}
-
-
-static bool readCameraMatrix(const string& filename,
-                             Mat& cameraMatrix, Mat& distCoeffs,
-                             Size& calibratedImageSize )
-{
-    FileStorage fs(filename, FileStorage::READ);
-    fs["image_width"] >> calibratedImageSize.width;
-    fs["image_height"] >> calibratedImageSize.height;
-    fs["distortion_coefficients"] >> distCoeffs;
-    fs["camera_matrix"] >> cameraMatrix;
-
-    if( distCoeffs.type() != CV_64F )
-        distCoeffs = Mat_<double>(distCoeffs);
-    if( cameraMatrix.type() != CV_64F )
-        cameraMatrix = Mat_<double>(cameraMatrix);
-
-    return true;
-}
-
-static bool readModelViews( const string& filename, vector<Point3f>& box,
-                           vector<string>& imagelist,
-                           vector<Rect>& roiList, vector<Vec6f>& poseList )
-{
-    imagelist.resize(0);
-    roiList.resize(0);
-    poseList.resize(0);
-    box.resize(0);
-
-    FileStorage fs(filename, FileStorage::READ);
-    if( !fs.isOpened() )
-        return false;
-    fs["box"] >> box;
-
-    FileNode all = fs["views"];
-    if( all.type() != FileNode::SEQ )
-        return false;
-    FileNodeIterator it = all.begin(), it_end = all.end();
-
-    for(; it != it_end; ++it)
-    {
-        FileNode n = *it;
-        imagelist.push_back((string)n["image"]);
-        FileNode nr = n["roi"];
-        roiList.push_back(Rect((int)nr[0], (int)nr[1], (int)nr[2], (int)nr[3]));
-        FileNode np = n["pose"];
-        poseList.push_back(Vec6f((float)np[0], (float)np[1], (float)np[2],
-                                 (float)np[3], (float)np[4], (float)np[5]));
-    }
-
-    return true;
-}
-
-
-struct PointModel
-{
-    vector<Point3f> points;
-    vector<vector<int> > didx;
-    Mat descriptors;
-    string name;
-};
-
-
-static void writeModel(const string& modelFileName, const string& modelname,
-                       const PointModel& model)
-{
-    FileStorage fs(modelFileName, FileStorage::WRITE);
-
-    fs << modelname << "{" <<
-        "points" << "[:" << model.points << "]" <<
-        "idx" << "[:";
-
-    for( size_t i = 0; i < model.didx.size(); i++ )
-        fs << "[:" << model.didx[i] << "]";
-    fs << "]" << "descriptors" << model.descriptors;
-}
-
-
-static void unpackPose(const Vec6f& pose, Mat& R, Mat& t)
-{
-    Mat rvec = (Mat_<double>(3,1) << pose[0], pose[1], pose[2]);
-    t = (Mat_<double>(3,1) << pose[3], pose[4], pose[5]);
-    Rodrigues(rvec, R);
-}
-
-
-static Mat getFundamentalMat( const Mat& R1, const Mat& t1,
-                              const Mat& R2, const Mat& t2,
-                              const Mat& cameraMatrix )
-{
-    Mat_<double> R = R2*R1.t(), t = t2 - R*t1;
-    double tx = t.at<double>(0,0), ty = t.at<double>(1,0), tz = t.at<double>(2,0);
-    Mat E = (Mat_<double>(3,3) << 0, -tz, ty, tz, 0, -tx, -ty, tx, 0)*R;
-    Mat iK = cameraMatrix.inv();
-    Mat F = iK.t()*E*iK;
-
-#if 0
-    static bool checked = false;
-    if(!checked)
-    {
-        vector<Point3f> objpoints(100);
-        Mat O(objpoints);
-        randu(O, Scalar::all(-10), Scalar::all(10));
-        vector<Point2f> imgpoints1, imgpoints2;
-        projectPoints(Mat(objpoints), R1, t1, cameraMatrix, Mat(), imgpoints1);
-        projectPoints(Mat(objpoints), R2, t2, cameraMatrix, Mat(), imgpoints2);
-        double* f = (double*)F.data;
-        for( size_t i = 0; i < objpoints.size(); i++ )
-        {
-            Point2f p1 = imgpoints1[i], p2 = imgpoints2[i];
-            double diff = p2.x*(f[0]*p1.x + f[1]*p1.y + f[2]) +
-                 p2.y*(f[3]*p1.x + f[4]*p1.y + f[5]) +
-                f[6]*p1.x + f[7]*p1.y + f[8];
-            CV_Assert(fabs(diff) < 1e-3);
-        }
-        checked = true;
-    }
-#endif
-    return F;
-}
-
-
-static void findConstrainedCorrespondences(const Mat& _F,
-                const vector<KeyPoint>& keypoints1,
-                const vector<KeyPoint>& keypoints2,
-                const Mat& descriptors1,
-                const Mat& descriptors2,
-                vector<Vec2i>& matches,
-                double eps, double ratio)
-{
-    float F[9]={0};
-    int dsize = descriptors1.cols;
-
-    Mat Fhdr = Mat(3, 3, CV_32F, F);
-    _F.convertTo(Fhdr, CV_32F);
-    matches.clear();
-
-    for( int i = 0; i < (int)keypoints1.size(); i++ )
-    {
-        Point2f p1 = keypoints1[i].pt;
-        double bestDist1 = DBL_MAX, bestDist2 = DBL_MAX;
-        int bestIdx1 = -1;//, bestIdx2 = -1;
-        const float* d1 = descriptors1.ptr<float>(i);
-
-        for( int j = 0; j < (int)keypoints2.size(); j++ )
-        {
-            Point2f p2 = keypoints2[j].pt;
-            double e = p2.x*(F[0]*p1.x + F[1]*p1.y + F[2]) +
-                       p2.y*(F[3]*p1.x + F[4]*p1.y + F[5]) +
-                       F[6]*p1.x + F[7]*p1.y + F[8];
-            if( fabs(e) > eps )
-                continue;
-            const float* d2 = descriptors2.ptr<float>(j);
-            double dist = 0;
-            int k = 0;
-
-            for( ; k <= dsize - 8; k += 8 )
-            {
-                float t0 = d1[k] - d2[k], t1 = d1[k+1] - d2[k+1];
-                float t2 = d1[k+2] - d2[k+2], t3 = d1[k+3] - d2[k+3];
-                float t4 = d1[k+4] - d2[k+4], t5 = d1[k+5] - d2[k+5];
-                float t6 = d1[k+6] - d2[k+6], t7 = d1[k+7] - d2[k+7];
-                dist += t0*t0 + t1*t1 + t2*t2 + t3*t3 +
-                        t4*t4 + t5*t5 + t6*t6 + t7*t7;
-
-                if( dist >= bestDist2 )
-                    break;
-            }
-
-            if( dist < bestDist2 )
-            {
-                for( ; k < dsize; k++ )
-                {
-                    float t = d1[k] - d2[k];
-                    dist += t*t;
-                }
-
-                if( dist < bestDist1 )
-                {
-                    bestDist2 = bestDist1;
-                    //bestIdx2 = bestIdx1;
-                    bestDist1 = dist;
-                    bestIdx1 = (int)j;
-                }
-                else if( dist < bestDist2 )
-                {
-                    bestDist2 = dist;
-                    //bestIdx2 = (int)j;
-                }
-            }
-        }
-
-        if( bestIdx1 >= 0 && bestDist1 < bestDist2*ratio )
-        {
-            Point2f p2 = keypoints1[bestIdx1].pt;
-            double e = p2.x*(F[0]*p1.x + F[1]*p1.y + F[2]) +
-                        p2.y*(F[3]*p1.x + F[4]*p1.y + F[5]) +
-                        F[6]*p1.x + F[7]*p1.y + F[8];
-            if( e > eps*0.25 )
-                continue;
-            double threshold = bestDist1/ratio;
-            const float* d22 = descriptors2.ptr<float>(bestIdx1);
-            int i1 = 0;
-            for( ; i1 < (int)keypoints1.size(); i1++ )
-            {
-                if( i1 == i )
-                    continue;
-                Point2f pt1 = keypoints1[i1].pt;
-                const float* d11 = descriptors1.ptr<float>(i1);
-                double dist = 0;
-
-                e = p2.x*(F[0]*pt1.x + F[1]*pt1.y + F[2]) +
-                    p2.y*(F[3]*pt1.x + F[4]*pt1.y + F[5]) +
-                    F[6]*pt1.x + F[7]*pt1.y + F[8];
-                if( fabs(e) > eps )
-                    continue;
-
-                for( int k = 0; k < dsize; k++ )
-                {
-                    float t = d11[k] - d22[k];
-                    dist += t*t;
-                    if( dist >= threshold )
-                        break;
-                }
-
-                if( dist < threshold )
-                    break;
-            }
-            if( i1 == (int)keypoints1.size() )
-                matches.push_back(Vec2i(i,bestIdx1));
-        }
-    }
-}
-
-
-static Point3f findRayIntersection(Point3f k1, Point3f b1, Point3f k2, Point3f b2)
-{
-    float a[4], b[2], x[2];
-    a[0] = k1.dot(k1);
-    a[1] = a[2] = -k1.dot(k2);
-    a[3] = k2.dot(k2);
-    b[0] = k1.dot(b2 - b1);
-    b[1] = k2.dot(b1 - b2);
-    Mat_<float> A(2, 2, a), B(2, 1, b), X(2, 1, x);
-    solve(A, B, X);
-
-    float s1 = X.at<float>(0, 0);
-    float s2 = X.at<float>(1, 0);
-    return (k1*s1 + b1 + k2*s2 + b2)*0.5f;
-}
-
-
-static Point3f triangulatePoint(const vector<Point2f>& ps,
-                                const vector<Mat>& Rs,
-                                const vector<Mat>& ts,
-                                const Mat& cameraMatrix)
-{
-    Mat_<double> K(cameraMatrix);
-
-    /*if( ps.size() > 2 )
-    {
-        Mat_<double> L(ps.size()*3, 4), U, evalues;
-        Mat_<double> P(3,4), Rt(3,4), Rt_part1=Rt.colRange(0,3), Rt_part2=Rt.colRange(3,4);
-
-        for( size_t i = 0; i < ps.size(); i++ )
-        {
-            double x = ps[i].x, y = ps[i].y;
-            Rs[i].convertTo(Rt_part1, Rt_part1.type());
-            ts[i].convertTo(Rt_part2, Rt_part2.type());
-            P = K*Rt;
-
-            for( int k = 0; k < 4; k++ )
-            {
-                L(i*3, k) = x*P(2,k) - P(0,k);
-                L(i*3+1, k) = y*P(2,k) - P(1,k);
-                L(i*3+2, k) = x*P(1,k) - y*P(0,k);
-            }
-        }
-
-        eigen(L.t()*L, evalues, U);
-        CV_Assert(evalues(0,0) >= evalues(3,0));
-
-        double W = fabs(U(3,3)) > FLT_EPSILON ? 1./U(3,3) : 0;
-        return Point3f((float)(U(3,0)*W), (float)(U(3,1)*W), (float)(U(3,2)*W));
-    }
-    else*/
-    {
-        Mat_<float> iK = K.inv();
-        Mat_<float> R1t = Mat_<float>(Rs[0]).t();
-        Mat_<float> R2t = Mat_<float>(Rs[1]).t();
-        Mat_<float> m1 = (Mat_<float>(3,1) << ps[0].x, ps[0].y, 1);
-        Mat_<float> m2 = (Mat_<float>(3,1) << ps[1].x, ps[1].y, 1);
-        Mat_<float> K1 = R1t*(iK*m1), K2 = R2t*(iK*m2);
-        Mat_<float> B1 = -R1t*Mat_<float>(ts[0]);
-        Mat_<float> B2 = -R2t*Mat_<float>(ts[1]);
-        return findRayIntersection(*K1.ptr<Point3f>(), *B1.ptr<Point3f>(),
-                                   *K2.ptr<Point3f>(), *B2.ptr<Point3f>());
-    }
-}
-
-
-static void triangulatePoint_test(void)
-{
-    int i, n = 100;
-    vector<Point3f> objpt(n), delta1(n), delta2(n);
-    Mat rvec1(3,1,CV_32F), tvec1(3,1,CV_64F);
-    Mat rvec2(3,1,CV_32F), tvec2(3,1,CV_64F);
-    Mat objptmat(objpt), deltamat1(delta1), deltamat2(delta2);
-    randu(rvec1, Scalar::all(-10), Scalar::all(10));
-    randu(tvec1, Scalar::all(-10), Scalar::all(10));
-    randu(rvec2, Scalar::all(-10), Scalar::all(10));
-    randu(tvec2, Scalar::all(-10), Scalar::all(10));
-
-    randu(objptmat, Scalar::all(-10), Scalar::all(10));
-    double eps = 1e-2;
-    randu(deltamat1, Scalar::all(-eps), Scalar::all(eps));
-    randu(deltamat2, Scalar::all(-eps), Scalar::all(eps));
-    vector<Point2f> imgpt1, imgpt2;
-    Mat_<float> cameraMatrix(3,3);
-    double fx = 1000., fy = 1010., cx = 400.5, cy = 300.5;
-    cameraMatrix << fx, 0, cx, 0, fy, cy, 0, 0, 1;
-
-    projectPoints(Mat(objpt)+Mat(delta1), rvec1, tvec1, cameraMatrix, Mat(), imgpt1);
-    projectPoints(Mat(objpt)+Mat(delta2), rvec2, tvec2, cameraMatrix, Mat(), imgpt2);
-
-    vector<Point3f> objptt(n);
-    vector<Point2f> pts(2);
-    vector<Mat> Rv(2), tv(2);
-    Rodrigues(rvec1, Rv[0]);
-    Rodrigues(rvec2, Rv[1]);
-    tv[0] = tvec1; tv[1] = tvec2;
-    for( i = 0; i < n; i++ )
-    {
-        pts[0] = imgpt1[i]; pts[1] = imgpt2[i];
-        objptt[i] = triangulatePoint(pts, Rv, tv, cameraMatrix);
-    }
-    double err = norm(Mat(objpt), Mat(objptt), NORM_INF);
-    CV_Assert(err < 1e-1);
-}
-
-typedef pair<int, int> Pair2i;
-typedef map<Pair2i, int> Set2i;
-
-struct EqKeypoints
-{
-    EqKeypoints(const vector<int>* _dstart, const Set2i* _pairs)
-    : dstart(_dstart), pairs(_pairs) {}
-
-    bool operator()(const Pair2i& a, const Pair2i& b) const
-    {
-        return pairs->find(Pair2i(dstart->at(a.first) + a.second,
-                                  dstart->at(b.first) + b.second)) != pairs->end();
-    }
-
-    const vector<int>* dstart;
-    const Set2i* pairs;
-};
-
-template<typename _Tp, class _EqPredicate> static
-int partition( const std::vector<_Tp>& _vec, std::vector<int>& labels,
-           _EqPredicate predicate=_EqPredicate())
-{
-    int i, j, N = (int)_vec.size();
-    const _Tp* vec = &_vec[0];
-
-    const int PARENT=0;
-    const int RANK=1;
-
-    std::vector<int> _nodes(N*2);
-    int (*nodes)[2] = (int(*)[2])&_nodes[0];
-
-    // The first O(N) pass: create N single-vertex trees
-    for(i = 0; i < N; i++)
-    {
-        nodes[i][PARENT]=-1;
-        nodes[i][RANK] = 0;
-    }
-
-    // The main O(N^2) pass: merge connected components
-    for( i = 0; i < N; i++ )
-    {
-        int root = i;
-
-        // find root
-        while( nodes[root][PARENT] >= 0 )
-            root = nodes[root][PARENT];
-
-        for( j = 0; j < N; j++ )
-        {
-            if( i == j || !predicate(vec[i], vec[j]))
-                continue;
-            int root2 = j;
-
-            while( nodes[root2][PARENT] >= 0 )
-                root2 = nodes[root2][PARENT];
-
-            if( root2 != root )
-            {
-                // unite both trees
-                int rank = nodes[root][RANK], rank2 = nodes[root2][RANK];
-                if( rank > rank2 )
-                    nodes[root2][PARENT] = root;
-                else
-                {
-                    nodes[root][PARENT] = root2;
-                    nodes[root2][RANK] += rank == rank2;
-                    root = root2;
-                }
-                CV_Assert( nodes[root][PARENT] < 0 );
-
-                int k = j, parent;
-
-                // compress the path from node2 to root
-                while( (parent = nodes[k][PARENT]) >= 0 )
-                {
-                    nodes[k][PARENT] = root;
-                    k = parent;
-                }
-
-                // compress the path from node to root
-                k = i;
-                while( (parent = nodes[k][PARENT]) >= 0 )
-                {
-                    nodes[k][PARENT] = root;
-                    k = parent;
-                }
-            }
-        }
-    }
-
-    // Final O(N) pass: enumerate classes
-    labels.resize(N);
-    int nclasses = 0;
-
-    for( i = 0; i < N; i++ )
-    {
-        int root = i;
-        while( nodes[root][PARENT] >= 0 )
-            root = nodes[root][PARENT];
-        // re-use the rank as the class label
-        if( nodes[root][RANK] >= 0 )
-            nodes[root][RANK] = ~nclasses++;
-        labels[i] = ~nodes[root][RANK];
-    }
-
-    return nclasses;
-}
-
-static void build3dmodel( const Ptr<FeatureDetector>& detector,
-                          const Ptr<DescriptorExtractor>& descriptorExtractor,
-                          const vector<Point3f>& /*modelBox*/,
-                          const vector<string>& imageList,
-                          const vector<Rect>& roiList,
-                          const vector<Vec6f>& poseList,
-                          const Mat& cameraMatrix,
-                          PointModel& model )
-{
-    int progressBarSize = 10;
-
-    const double Feps = 5;
-    const double DescriptorRatio = 0.7;
-
-    vector<vector<KeyPoint> > allkeypoints;
-    vector<int> dstart;
-    vector<float> alldescriptorsVec;
-    vector<Vec2i> pairwiseMatches;
-    vector<Mat> Rs, ts;
-    int descriptorSize = 0;
-    Mat descriptorbuf;
-    Set2i pairs, keypointsIdxMap;
-
-    model.points.clear();
-    model.didx.clear();
-
-    dstart.push_back(0);
-
-    size_t nimages = imageList.size();
-    size_t nimagePairs = (nimages - 1)*nimages/2 - nimages;
-
-    printf("\nComputing descriptors ");
-
-    // 1. find all the keypoints and all the descriptors
-    for( size_t i = 0; i < nimages; i++ )
-    {
-        Mat img = imread(imageList[i], 1), gray;
-        cvtColor(img, gray, COLOR_BGR2GRAY);
-
-        vector<KeyPoint> keypoints;
-        detector->detect(gray, keypoints);
-        descriptorExtractor->compute(gray, keypoints, descriptorbuf);
-        Point2f roiofs = roiList[i].tl();
-        for( size_t k = 0; k < keypoints.size(); k++ )
-            keypoints[k].pt += roiofs;
-        allkeypoints.push_back(keypoints);
-
-        Mat buf = descriptorbuf;
-        if( !buf.isContinuous() || buf.type() != CV_32F )
-        {
-            buf.release();
-            descriptorbuf.convertTo(buf, CV_32F);
-        }
-        descriptorSize = buf.cols;
-
-        size_t prev = alldescriptorsVec.size();
-        size_t delta = buf.rows*buf.cols;
-        alldescriptorsVec.resize(prev + delta);
-        std::copy(buf.ptr<float>(), buf.ptr<float>() + delta,
-                  alldescriptorsVec.begin() + prev);
-        dstart.push_back(dstart.back() + (int)keypoints.size());
-
-        Mat R, t;
-        unpackPose(poseList[i], R, t);
-        Rs.push_back(R);
-        ts.push_back(t);
-
-        if( (i+1)*progressBarSize/nimages > i*progressBarSize/nimages )
-        {
-            putchar('.');
-            fflush(stdout);
-        }
-    }
-
-    Mat alldescriptors((int)alldescriptorsVec.size()/descriptorSize, descriptorSize, CV_32F,
-                       &alldescriptorsVec[0]);
-
-    printf("\nOk. total images = %d. total keypoints = %d\n",
-           (int)nimages, alldescriptors.rows);
-
-    printf("\nFinding correspondences ");
-
-    int pairsFound = 0;
-
-    vector<Point2f> pts_k(2);
-    vector<Mat> Rs_k(2), ts_k(2);
-    //namedWindow("img1", 1);
-    //namedWindow("img2", 1);
-
-    // 2. find pairwise correspondences
-    for( size_t i = 0; i < nimages; i++ )
-        for( size_t j = i+1; j < nimages; j++ )
-        {
-            const vector<KeyPoint>& keypoints1 = allkeypoints[i];
-            const vector<KeyPoint>& keypoints2 = allkeypoints[j];
-            Mat descriptors1 = alldescriptors.rowRange(dstart[i], dstart[i+1]);
-            Mat descriptors2 = alldescriptors.rowRange(dstart[j], dstart[j+1]);
-
-            Mat F = getFundamentalMat(Rs[i], ts[i], Rs[j], ts[j], cameraMatrix);
-
-            findConstrainedCorrespondences( F, keypoints1, keypoints2,
-                                            descriptors1, descriptors2,
-                                            pairwiseMatches, Feps, DescriptorRatio );
-
-            //pairsFound += (int)pairwiseMatches.size();
-
-            //Mat img1 = imread(format("%s/frame%04d.jpg", model.name.c_str(), (int)i), 1);
-            //Mat img2 = imread(format("%s/frame%04d.jpg", model.name.c_str(), (int)j), 1);
-
-            //double avg_err = 0;
-            for( size_t k = 0; k < pairwiseMatches.size(); k++ )
-            {
-                int i1 = pairwiseMatches[k][0], i2 = pairwiseMatches[k][1];
-
-                pts_k[0] = keypoints1[i1].pt;
-                pts_k[1] = keypoints2[i2].pt;
-                Rs_k[0] = Rs[i]; Rs_k[1] = Rs[j];
-                ts_k[0] = ts[i]; ts_k[1] = ts[j];
-                Point3f objpt = triangulatePoint(pts_k, Rs_k, ts_k, cameraMatrix);
-
-                vector<Point3f> objpts;
-                objpts.push_back(objpt);
-                vector<Point2f> imgpts1, imgpts2;
-                projectPoints(Mat(objpts), Rs_k[0], ts_k[0], cameraMatrix, Mat(), imgpts1);
-                projectPoints(Mat(objpts), Rs_k[1], ts_k[1], cameraMatrix, Mat(), imgpts2);
-
-                double e1 = norm(imgpts1[0] - keypoints1[i1].pt);
-                double e2 = norm(imgpts2[0] - keypoints2[i2].pt);
-                if( e1 + e2 > 5 )
-                    continue;
-
-                pairsFound++;
-
-                //model.points.push_back(objpt);
-                pairs[Pair2i(i1+dstart[i], i2+dstart[j])] = 1;
-                pairs[Pair2i(i2+dstart[j], i1+dstart[i])] = 1;
-                keypointsIdxMap[Pair2i((int)i,i1)] = 1;
-                keypointsIdxMap[Pair2i((int)j,i2)] = 1;
-                //CV_Assert(e1 < 5 && e2 < 5);
-                //Scalar color(rand()%256,rand()%256, rand()%256);
-                //circle(img1, keypoints1[i1].pt, 2, color, -1, CV_AA);
-                //circle(img2, keypoints2[i2].pt, 2, color, -1, CV_AA);
-            }
-            //printf("avg err = %g\n", pairwiseMatches.size() ? avg_err/(2*pairwiseMatches.size()) : 0.);
-            //imshow("img1", img1);
-            //imshow("img2", img2);
-            //waitKey();
-
-            if( (i+1)*progressBarSize/nimagePairs > i*progressBarSize/nimagePairs )
-            {
-                putchar('.');
-                fflush(stdout);
-            }
-        }
-
-    printf("\nOk. Total pairs = %d\n", pairsFound );
-
-    // 3. build the keypoint clusters
-    vector<Pair2i> keypointsIdx;
-    Set2i::iterator kpidx_it = keypointsIdxMap.begin(), kpidx_end = keypointsIdxMap.end();
-
-    for( ; kpidx_it != kpidx_end; ++kpidx_it )
-        keypointsIdx.push_back(kpidx_it->first);
-
-    printf("\nClustering correspondences ");
-
-    vector<int> labels;
-    int nclasses = partition( keypointsIdx, labels, EqKeypoints(&dstart, &pairs) );
-
-    printf("\nOk. Total classes (i.e. 3d points) = %d\n", nclasses );
-
-    model.descriptors.create((int)keypointsIdx.size(), descriptorSize, CV_32F);
-    model.didx.resize(nclasses);
-    model.points.resize(nclasses);
-
-    vector<vector<Pair2i> > clusters(nclasses);
-    for( size_t i = 0; i < keypointsIdx.size(); i++ )
-        clusters[labels[i]].push_back(keypointsIdx[i]);
-
-    // 4. now compute 3D points corresponding to each cluster and fill in the model data
-    printf("\nComputing 3D coordinates ");
-
-    int globalDIdx = 0;
-    for( int k = 0; k < nclasses; k++ )
-    {
-        int i, n = (int)clusters[k].size();
-        pts_k.resize(n);
-        Rs_k.resize(n);
-        ts_k.resize(n);
-        model.didx[k].resize(n);
-        for( i = 0; i < n; i++ )
-        {
-            int imgidx = clusters[k][i].first, ptidx = clusters[k][i].second;
-            Mat dstrow = model.descriptors.row(globalDIdx);
-            alldescriptors.row(dstart[imgidx] + ptidx).copyTo(dstrow);
-
-            model.didx[k][i] = globalDIdx++;
-            pts_k[i] = allkeypoints[imgidx][ptidx].pt;
-            Rs_k[i] = Rs[imgidx];
-            ts_k[i] = ts[imgidx];
-        }
-        Point3f objpt = triangulatePoint(pts_k, Rs_k, ts_k, cameraMatrix);
-        model.points[k] = objpt;
-
-        if( (i+1)*progressBarSize/nclasses > i*progressBarSize/nclasses )
-        {
-            putchar('.');
-            fflush(stdout);
-        }
-    }
-
-    Mat img(768, 1024, CV_8UC3);
-    vector<Point2f> imagePoints;
-    namedWindow("Test", 1);
-
-    // visualize the cloud
-    for( size_t i = 0; i < nimages; i++ )
-    {
-        img = imread(format("%s/frame%04d.jpg", model.name.c_str(), (int)i), 1);
-        projectPoints(Mat(model.points), Rs[i], ts[i], cameraMatrix, Mat(), imagePoints);
-
-        for( int k = 0; k < (int)imagePoints.size(); k++ )
-            circle(img, imagePoints[k], 2, Scalar(0,255,0), -1, LINE_AA, 0);
-
-        imshow("Test", img);
-        int c = waitKey();
-        if( c == 'q' || c == 'Q' )
-            break;
-    }
-}
-
-
-int main(int argc, char** argv)
-{
-    const char* intrinsicsFilename = 0;
-    const char* modelName = 0;
-    const char* detectorName = "SURF";
-    const char* descriptorExtractorName = "SURF";
-
-    vector<Point3f> modelBox;
-    vector<string>  imageList;
-    vector<Rect>    roiList;
-    vector<Vec6f>   poseList;
-
-    if(argc < 3)
-    {
-        help();
-        return -1;
-    }
-
-    for( int i = 1; i < argc; i++ )
-    {
-        if( strcmp(argv[i], "-i") == 0 )
-            intrinsicsFilename = argv[++i];
-        else if( strcmp(argv[i], "-m") == 0 )
-            modelName = argv[++i];
-        else if( strcmp(argv[i], "-d") == 0 )
-            detectorName = argv[++i];
-        else if( strcmp(argv[i], "-de") == 0 )
-            descriptorExtractorName = argv[++i];
-        else
-        {
-            help();
-            printf("Incorrect option\n");
-            return -1;
-        }
-    }
-
-    if( !intrinsicsFilename || !modelName )
-    {
-        printf("Some of the required parameters are missing\n");
-        help();
-        return -1;
-    }
-
-    triangulatePoint_test();
-
-    Mat cameraMatrix, distCoeffs;
-    Size calibratedImageSize;
-    readCameraMatrix(intrinsicsFilename, cameraMatrix, distCoeffs, calibratedImageSize);
-
-    Ptr<FeatureDetector> detector = FeatureDetector::create(detectorName);
-    Ptr<DescriptorExtractor> descriptorExtractor = DescriptorExtractor::create(descriptorExtractorName);
-
-    string modelIndexFilename = format("%s_segm/frame_index.yml", modelName);
-    if(!readModelViews( modelIndexFilename, modelBox, imageList, roiList, poseList))
-    {
-        printf("Can not read the model. Check the parameters and the working directory\n");
-        help();
-        return -1;
-    }
-
-    PointModel model;
-    model.name = modelName;
-    build3dmodel( detector, descriptorExtractor, modelBox,
-                  imageList, roiList, poseList, cameraMatrix, model );
-    string outputModelName = format("%s_model.yml.gz", modelName);
-
-
-    printf("\nDone! Now saving the model ...\n");
-    writeModel(outputModelName, modelName, model);
-
-    return 0;
-}
diff --git a/samples/cpp/calibration_artificial.cpp b/samples/cpp/calibration_artificial.cpp
deleted file mode 100644 (file)
index 478cd05..0000000
+++ /dev/null
@@ -1,334 +0,0 @@
-#include "opencv2/calib3d/calib3d.hpp"
-#include "opencv2/imgproc/imgproc.hpp"
-#include "opencv2/highgui/highgui.hpp"
-
-#include <iostream>
-#include <vector>
-#include <algorithm>
-#include <iterator>
-#include <stdio.h>
-
-using namespace cv;
-using namespace std;
-
-static void help()
-{
-    printf( "\nThis code generates an artificial camera and artificial chessboard images,\n"
-            "and then calibrates. It is basically test code for calibration that shows\n"
-            "how to package calibration points and then calibrate the camera.\n"
-            "Usage:\n"
-            "./calibration_artificial\n\n");
-}
-namespace cv
-{
-
-/* copy of class defines int tests/cv/chessboardgenerator.h */
-class ChessBoardGenerator
-{
-public:
-    double sensorWidth;
-    double sensorHeight;
-    size_t squareEdgePointsNum;
-    double min_cos;
-    mutable double cov;
-    Size patternSize;
-    int rendererResolutionMultiplier;
-
-    ChessBoardGenerator(const Size& patternSize = Size(8, 6));
-    Mat operator()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, vector<Point2f>& corners) const;
-    Size cornersSize() const;
-private:
-    void generateEdge(const Point3f& p1, const Point3f& p2, vector<Point3f>& out) const;
-    Mat generageChessBoard(const Mat& bg, const Mat& camMat, const Mat& distCoeffs,
-        const Point3f& zero, const Point3f& pb1, const Point3f& pb2,
-        float sqWidth, float sqHeight, const vector<Point3f>& whole, vector<Point2f>& corners) const;
-    void generateBasis(Point3f& pb1, Point3f& pb2) const;
-    Point3f generateChessBoardCenter(const Mat& camMat, const Size& imgSize) const;
-    Mat rvec, tvec;
-};
-}
-
-
-
-const Size imgSize(800, 600);
-const Size brdSize(8, 7);
-const size_t brds_num = 20;
-
-template<class T> ostream& operator<<(ostream& out, const Mat_<T>& mat)
-{
-    for(int j = 0; j < mat.rows; ++j)
-        for(int i = 0; i < mat.cols; ++i)
-            out << mat(j, i) << " ";
-    return out;
-}
-
-
-
-int main()
-{
-    help();
-    cout << "Initializing background...";
-    Mat background(imgSize, CV_8UC3);
-    randu(background, Scalar::all(32), Scalar::all(255));
-    GaussianBlur(background, background, Size(5, 5), 2);
-    cout << "Done" << endl;
-
-    cout << "Initializing chess board generator...";
-    ChessBoardGenerator cbg(brdSize);
-    cbg.rendererResolutionMultiplier = 4;
-    cout << "Done" << endl;
-
-    /* camera params */
-    Mat_<double> camMat(3, 3);
-    camMat << 300., 0., background.cols/2., 0, 300., background.rows/2., 0., 0., 1.;
-
-    Mat_<double> distCoeffs(1, 5);
-    distCoeffs << 1.2, 0.2, 0., 0., 0.;
-
-    cout << "Generating chessboards...";
-    vector<Mat> boards(brds_num);
-    vector<Point2f> tmp;
-    for(size_t i = 0; i < brds_num; ++i)
-        cout << (boards[i] = cbg(background, camMat, distCoeffs, tmp), i) << " ";
-    cout << "Done" << endl;
-
-    vector<Point3f> chessboard3D;
-    for(int j = 0; j < cbg.cornersSize().height; ++j)
-        for(int i = 0; i < cbg.cornersSize().width; ++i)
-            chessboard3D.push_back(Point3i(i, j, 0));
-
-    /* init points */
-    vector< vector<Point3f> > objectPoints;
-    vector< vector<Point2f> > imagePoints;
-
-    cout << endl << "Finding chessboards' corners...";
-    for(size_t i = 0; i < brds_num; ++i)
-    {
-        cout << i;
-        namedWindow("Current chessboard"); imshow("Current chessboard", boards[i]); waitKey(100);
-        bool found = findChessboardCorners(boards[i], cbg.cornersSize(), tmp);
-        if (found)
-        {
-            imagePoints.push_back(tmp);
-            objectPoints.push_back(chessboard3D);
-            cout<< "-found ";
-        }
-        else
-            cout<< "-not-found ";
-
-        drawChessboardCorners(boards[i], cbg.cornersSize(), Mat(tmp), found);
-        imshow("Current chessboard", boards[i]); waitKey(1000);
-    }
-    cout << "Done" << endl;
-    destroyAllWindows();
-
-    Mat camMat_est;
-    Mat distCoeffs_est;
-    vector<Mat> rvecs, tvecs;
-
-    cout << "Calibrating...";
-    double rep_err = calibrateCamera(objectPoints, imagePoints, imgSize, camMat_est, distCoeffs_est, rvecs, tvecs);
-    cout << "Done" << endl;
-
-    cout << endl << "Average Reprojection error: " << rep_err/brds_num/cbg.cornersSize().area() << endl;
-    cout << "==================================" << endl;
-    cout << "Original camera matrix:\n" << camMat << endl;
-    cout << "Original distCoeffs:\n" << distCoeffs << endl;
-    cout << "==================================" << endl;
-    cout << "Estimated camera matrix:\n" << (Mat_<double>&)camMat_est << endl;
-    cout << "Estimated distCoeffs:\n" << (Mat_<double>&)distCoeffs_est << endl;
-
-    return 0;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-// Copy of  tests/cv/src/chessboardgenerator code. Just do not want to add dependency.
-
-
-ChessBoardGenerator::ChessBoardGenerator(const Size& _patternSize) : sensorWidth(32), sensorHeight(24),
-    squareEdgePointsNum(200), min_cos(std::sqrt(2.f)*0.5f), cov(0.5),
-    patternSize(_patternSize), rendererResolutionMultiplier(4), tvec(Mat::zeros(1, 3, CV_32F))
-{
-    Rodrigues(Mat::eye(3, 3, CV_32F), rvec);
-}
-
-void cv::ChessBoardGenerator::generateEdge(const Point3f& p1, const Point3f& p2, vector<Point3f>& out) const
-{
-    Point3f step = (p2 - p1) * (1.f/squareEdgePointsNum);
-    for(size_t n = 0; n < squareEdgePointsNum; ++n)
-        out.push_back( p1 + step * (float)n);
-}
-
-Size cv::ChessBoardGenerator::cornersSize() const
-{
-    return Size(patternSize.width-1, patternSize.height-1);
-}
-
-struct Mult
-{
-    float m;
-    Mult(int mult) : m((float)mult) {}
-    Point2f operator()(const Point2f& p)const { return p * m; }
-};
-
-void cv::ChessBoardGenerator::generateBasis(Point3f& pb1, Point3f& pb2) const
-{
-    RNG& rng = theRNG();
-
-    Vec3f n;
-    for(;;)
-    {
-        n[0] = rng.uniform(-1.f, 1.f);
-        n[1] = rng.uniform(-1.f, 1.f);
-        n[2] = rng.uniform(-1.f, 1.f);
-        float len = (float)norm(n);
-        n[0]/=len;
-        n[1]/=len;
-        n[2]/=len;
-
-        if (fabs(n[2]) > min_cos)
-            break;
-    }
-
-    Vec3f n_temp = n; n_temp[0] += 100;
-    Vec3f b1 = n.cross(n_temp);
-    Vec3f b2 = n.cross(b1);
-    float len_b1 = (float)norm(b1);
-    float len_b2 = (float)norm(b2);
-
-    pb1 = Point3f(b1[0]/len_b1, b1[1]/len_b1, b1[2]/len_b1);
-    pb2 = Point3f(b2[0]/len_b1, b2[1]/len_b2, b2[2]/len_b2);
-}
-
-Mat cv::ChessBoardGenerator::generageChessBoard(const Mat& bg, const Mat& camMat, const Mat& distCoeffs,
-                                                const Point3f& zero, const Point3f& pb1, const Point3f& pb2,
-                                                float sqWidth, float sqHeight, const vector<Point3f>& whole,
-                                                vector<Point2f>& corners) const
-{
-    vector< vector<Point> > squares_black;
-    for(int i = 0; i < patternSize.width; ++i)
-        for(int j = 0; j < patternSize.height; ++j)
-            if ( (i % 2 == 0 && j % 2 == 0) || (i % 2 != 0 && j % 2 != 0) )
-            {
-                vector<Point3f> pts_square3d;
-                vector<Point2f> pts_square2d;
-
-                Point3f p1 = zero + (i + 0) * sqWidth * pb1 + (j + 0) * sqHeight * pb2;
-                Point3f p2 = zero + (i + 1) * sqWidth * pb1 + (j + 0) * sqHeight * pb2;
-                Point3f p3 = zero + (i + 1) * sqWidth * pb1 + (j + 1) * sqHeight * pb2;
-                Point3f p4 = zero + (i + 0) * sqWidth * pb1 + (j + 1) * sqHeight * pb2;
-                generateEdge(p1, p2, pts_square3d);
-                generateEdge(p2, p3, pts_square3d);
-                generateEdge(p3, p4, pts_square3d);
-                generateEdge(p4, p1, pts_square3d);
-
-                projectPoints( Mat(pts_square3d), rvec, tvec, camMat, distCoeffs, pts_square2d);
-                squares_black.resize(squares_black.size() + 1);
-                vector<Point2f> temp;
-                approxPolyDP(Mat(pts_square2d), temp, 1.0, true);
-                transform(temp.begin(), temp.end(), back_inserter(squares_black.back()), Mult(rendererResolutionMultiplier));
-            }
-
-    /* calculate corners */
-    vector<Point3f> corners3d;
-    for(int j = 0; j < patternSize.height - 1; ++j)
-        for(int i = 0; i < patternSize.width - 1; ++i)
-            corners3d.push_back(zero + (i + 1) * sqWidth * pb1 + (j + 1) * sqHeight * pb2);
-    corners.clear();
-    projectPoints( Mat(corners3d), rvec, tvec, camMat, distCoeffs, corners);
-
-    vector<Point3f> whole3d;
-    vector<Point2f> whole2d;
-    generateEdge(whole[0], whole[1], whole3d);
-    generateEdge(whole[1], whole[2], whole3d);
-    generateEdge(whole[2], whole[3], whole3d);
-    generateEdge(whole[3], whole[0], whole3d);
-    projectPoints( Mat(whole3d), rvec, tvec, camMat, distCoeffs, whole2d);
-    vector<Point2f> temp_whole2d;
-    approxPolyDP(Mat(whole2d), temp_whole2d, 1.0, true);
-
-    vector< vector<Point > > whole_contour(1);
-    transform(temp_whole2d.begin(), temp_whole2d.end(),
-        back_inserter(whole_contour.front()), Mult(rendererResolutionMultiplier));
-
-    Mat result;
-    if (rendererResolutionMultiplier == 1)
-    {
-        result = bg.clone();
-        drawContours(result, whole_contour, -1, Scalar::all(255), FILLED, LINE_AA);
-        drawContours(result, squares_black, -1, Scalar::all(0), FILLED, LINE_AA);
-    }
-    else
-    {
-        Mat tmp;
-        resize(bg, tmp, bg.size() * rendererResolutionMultiplier);
-        drawContours(tmp, whole_contour, -1, Scalar::all(255), FILLED, LINE_AA);
-        drawContours(tmp, squares_black, -1, Scalar::all(0), FILLED, LINE_AA);
-        resize(tmp, result, bg.size(), 0, 0, INTER_AREA);
-    }
-    return result;
-}
-
-Mat cv::ChessBoardGenerator::operator ()(const Mat& bg, const Mat& camMat, const Mat& distCoeffs, vector<Point2f>& corners) const
-{
-    cov = std::min(cov, 0.8);
-    double fovx, fovy, focalLen;
-    Point2d principalPoint;
-    double aspect;
-    calibrationMatrixValues( camMat, bg.size(), sensorWidth, sensorHeight,
-        fovx, fovy, focalLen, principalPoint, aspect);
-
-    RNG& rng = theRNG();
-
-    float d1 = static_cast<float>(rng.uniform(0.1, 10.0));
-    float ah = static_cast<float>(rng.uniform(-fovx/2 * cov, fovx/2 * cov) * CV_PI / 180);
-    float av = static_cast<float>(rng.uniform(-fovy/2 * cov, fovy/2 * cov) * CV_PI / 180);
-
-    Point3f p;
-    p.z = cos(ah) * d1;
-    p.x = sin(ah) * d1;
-    p.y = p.z * tan(av);
-
-    Point3f pb1, pb2;
-    generateBasis(pb1, pb2);
-
-    float cbHalfWidth = static_cast<float>(norm(p) * sin( std::min(fovx, fovy) * 0.5 * CV_PI / 180));
-    float cbHalfHeight = cbHalfWidth * patternSize.height / patternSize.width;
-
-    vector<Point3f> pts3d(4);
-    vector<Point2f> pts2d(4);
-    for(;;)
-    {
-        pts3d[0] = p + pb1 * cbHalfWidth + cbHalfHeight * pb2;
-        pts3d[1] = p + pb1 * cbHalfWidth - cbHalfHeight * pb2;
-        pts3d[2] = p - pb1 * cbHalfWidth - cbHalfHeight * pb2;
-        pts3d[3] = p - pb1 * cbHalfWidth + cbHalfHeight * pb2;
-
-        /* can remake with better perf */
-        projectPoints( Mat(pts3d), rvec, tvec, camMat, distCoeffs, pts2d);
-
-        bool inrect1 = pts2d[0].x < bg.cols && pts2d[0].y < bg.rows && pts2d[0].x > 0 && pts2d[0].y > 0;
-        bool inrect2 = pts2d[1].x < bg.cols && pts2d[1].y < bg.rows && pts2d[1].x > 0 && pts2d[1].y > 0;
-        bool inrect3 = pts2d[2].x < bg.cols && pts2d[2].y < bg.rows && pts2d[2].x > 0 && pts2d[2].y > 0;
-        bool inrect4 = pts2d[3].x < bg.cols && pts2d[3].y < bg.rows && pts2d[3].x > 0 && pts2d[3].y > 0;
-
-        if ( inrect1 && inrect2 && inrect3 && inrect4)
-            break;
-
-        cbHalfWidth*=0.8f;
-        cbHalfHeight = cbHalfWidth * patternSize.height / patternSize.width;
-    }
-
-    cbHalfWidth  *= static_cast<float>(patternSize.width)/(patternSize.width + 1);
-    cbHalfHeight *= static_cast<float>(patternSize.height)/(patternSize.height + 1);
-
-    Point3f zero = p - pb1 * cbHalfWidth - cbHalfHeight * pb2;
-    float sqWidth  = 2 * cbHalfWidth/patternSize.width;
-    float sqHeight = 2 * cbHalfHeight/patternSize.height;
-
-    return generageChessBoard(bg, camMat, distCoeffs, zero, pb1, pb2, sqWidth, sqHeight,  pts3d, corners);
-}
diff --git a/samples/cpp/chamfer.cpp b/samples/cpp/chamfer.cpp
deleted file mode 100644 (file)
index ab211f3..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-#include <opencv2/core/utility.hpp>
-#include "opencv2/imgproc.hpp"
-#include "opencv2/highgui.hpp"
-#include "opencv2/contrib.hpp"
-
-#include <iostream>
-
-using namespace cv;
-using namespace std;
-
-static void help()
-{
-
-   cout << "\nThis program demonstrates Chamfer matching -- computing a distance between an \n"
-            "edge template and a query edge image.\n"
-            "Usage: \n"
-            "./chamfer <image edge map> <template edge map>,"
-            " By default the inputs are logo_in_clutter.png logo.png\n";
-}
-
-const char* keys =
-{
-    "{@logo1 |logo_in_clutter.png  |image edge map    }"
-    "{@logo2 |logo.png             |template edge map}"
-};
-
-int main( int argc, const char** argv )
-{
-
-    help();
-    CommandLineParser parser(argc, argv, keys);
-
-    string image = parser.get<string>(0);
-    string templ = parser.get<string>(1);
-    Mat img = imread(image.c_str(), 0);
-    Mat tpl = imread(templ.c_str(), 0);
-
-    if (img.empty() || tpl.empty())
-    {
-        cout << "Could not read image file " << image << " or " << templ << "." << endl;
-        return -1;
-    }
-    Mat cimg;
-    cvtColor(img, cimg, COLOR_GRAY2BGR);
-
-    // if the image and the template are not edge maps but normal grayscale images,
-    // you might want to uncomment the lines below to produce the maps. You can also
-    // run Sobel instead of Canny.
-
-    // Canny(img, img, 5, 50, 3);
-    // Canny(tpl, tpl, 5, 50, 3);
-
-    vector<vector<Point> > results;
-    vector<float> costs;
-    int best = chamerMatching( img, tpl, results, costs );
-    if( best < 0 )
-    {
-        cout << "matching not found" << endl;
-        return -1;
-    }
-
-    size_t i, n = results[best].size();
-    for( i = 0; i < n; i++ )
-    {
-        Point pt = results[best][i];
-        if( pt.inside(Rect(0, 0, cimg.cols, cimg.rows)) )
-           cimg.at<Vec3b>(pt) = Vec3b(0, 255, 0);
-    }
-
-    imshow("result", cimg);
-
-    waitKey();
-
-    return 0;
-}
diff --git a/samples/cpp/dbt_face_detection.cpp b/samples/cpp/dbt_face_detection.cpp
deleted file mode 100644 (file)
index 651eaff..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(ANDROID)
-
-#include <opencv2/imgproc/imgproc.hpp>  // Gaussian Blur
-#include <opencv2/core/core.hpp>        // Basic OpenCV structures (cv::Mat, Scalar)
-#include <opencv2/highgui/highgui.hpp>  // OpenCV window I/O
-#include <opencv2/features2d/features2d.hpp>
-#include <opencv2/contrib/detection_based_tracker.hpp>
-
-#include <stdio.h>
-#include <string>
-#include <vector>
-
-using namespace std;
-using namespace cv;
-
-const string WindowName = "Face Detection example";
-
-class CascadeDetectorAdapter: public DetectionBasedTracker::IDetector
-{
-    public:
-        CascadeDetectorAdapter(cv::Ptr<cv::CascadeClassifier> detector):
-            IDetector(),
-            Detector(detector)
-        {
-            CV_Assert(detector);
-        }
-
-        void detect(const cv::Mat &Image, std::vector<cv::Rect> &objects)
-        {
-            Detector->detectMultiScale(Image, objects, scaleFactor, minNeighbours, 0, minObjSize, maxObjSize);
-        }
-
-        virtual ~CascadeDetectorAdapter()
-        {}
-
-    private:
-        CascadeDetectorAdapter();
-        cv::Ptr<cv::CascadeClassifier> Detector;
- };
-
-int main(int , char** )
-{
-    namedWindow(WindowName);
-
-    VideoCapture VideoStream(0);
-
-    if (!VideoStream.isOpened())
-    {
-        printf("Error: Cannot open video stream from camera\n");
-        return 1;
-    }
-
-    std::string cascadeFrontalfilename = "../../data/lbpcascades/lbpcascade_frontalface.xml";
-    cv::Ptr<cv::CascadeClassifier> cascade = makePtr<cv::CascadeClassifier>(cascadeFrontalfilename);
-    cv::Ptr<DetectionBasedTracker::IDetector> MainDetector = makePtr<CascadeDetectorAdapter>(cascade);
-
-    cascade = makePtr<cv::CascadeClassifier>(cascadeFrontalfilename);
-    cv::Ptr<DetectionBasedTracker::IDetector> TrackingDetector = makePtr<CascadeDetectorAdapter>(cascade);
-
-    DetectionBasedTracker::Parameters params;
-    DetectionBasedTracker Detector(MainDetector, TrackingDetector, params);
-
-    if (!Detector.run())
-    {
-        printf("Error: Detector initialization failed\n");
-        return 2;
-    }
-
-    Mat ReferenceFrame;
-    Mat GrayFrame;
-    vector<Rect> Faces;
-
-    while(true)
-    {
-        VideoStream >> ReferenceFrame;
-        cvtColor(ReferenceFrame, GrayFrame, COLOR_RGB2GRAY);
-        Detector.process(GrayFrame);
-        Detector.getObjects(Faces);
-
-        for (size_t i = 0; i < Faces.size(); i++)
-        {
-            rectangle(ReferenceFrame, Faces[i], Scalar(0,255,0));
-        }
-
-        imshow(WindowName, ReferenceFrame);
-
-        if (waitKey(30) >= 0) break;
-    }
-
-    Detector.stop();
-
-    return 0;
-}
-
-#else
-
-#include <stdio.h>
-int main()
-{
-    printf("This sample works for UNIX or ANDROID only\n");
-    return 0;
-}
-
-#endif
diff --git a/samples/cpp/detection_based_tracker_sample.cpp b/samples/cpp/detection_based_tracker_sample.cpp
deleted file mode 100644 (file)
index 81afa78..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(ANDROID)
-
-#include <opencv2/core.hpp>
-#include <opencv2/core/utility.hpp>
-#include <opencv2/imgproc.hpp>
-#include <opencv2/highgui.hpp>
-#include <opencv2/objdetect.hpp>
-#include "opencv2/contrib/detection_based_tracker.hpp"
-
-#include <vector>
-#include <iostream>
-#include <stdio.h>
-
-#define DEBUGLOGS 1
-
-
-#ifdef ANDROID
-#include <android/log.h>
-#define LOG_TAG "DETECTIONBASEDTRACKER__TEST_APPLICAT"
-#define LOGD0(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
-#define LOGI0(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
-#define LOGW0(...) ((void)__android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
-#define LOGE0(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
-#else
-
-#include <stdio.h>
-
-#define LOGD0(_str, ...) do{printf(_str , ## __VA_ARGS__); printf("\n");fflush(stdout);} while(0)
-#define LOGI0(_str, ...) do{printf(_str , ## __VA_ARGS__); printf("\n");fflush(stdout);} while(0)
-#define LOGW0(_str, ...) do{printf(_str , ## __VA_ARGS__); printf("\n");fflush(stdout);} while(0)
-#define LOGE0(_str, ...) do{printf(_str , ## __VA_ARGS__); printf("\n");fflush(stdout);} while(0)
-#endif
-
-#if DEBUGLOGS
-#define LOGD(_str, ...) LOGD0(_str , ## __VA_ARGS__)
-#define LOGI(_str, ...) LOGI0(_str , ## __VA_ARGS__)
-#define LOGW(_str, ...) LOGW0(_str , ## __VA_ARGS__)
-#define LOGE(_str, ...) LOGE0(_str , ## __VA_ARGS__)
-#else
-#define LOGD(...) do{} while(0)
-#define LOGI(...) do{} while(0)
-#define LOGW(...) do{} while(0)
-#define LOGE(...) do{} while(0)
-#endif
-
-using namespace cv;
-using namespace std;
-
-#define ORIGINAL 0
-#define SHOULD_USE_EXTERNAL_BUFFERS 1
-
-static void usage()
-{
-    LOGE0("usage: filepattern outfilepattern cascadefile");
-    LOGE0("\t where ");
-    LOGE0("\t filepattern --- pattern for the paths to the source images");
-    LOGE0("\t       (e.g.\"./Videos/FACESJPG2/Faces2_%%08d.jpg\" ");
-    LOGE0("\t outfilepattern --- pattern for the paths for images which will be generated");
-    LOGE0("\t       (e.g.\"./resFaces2_%%08d.jpg\" ");
-    LOGE0("\t cascadefile --- path to the cascade file");
-    LOGE0("\t       (e.g.\"opencv/data/lbpcascades/lbpcascade_frontalface.xml\" ");
-}
-
-class CascadeDetectorAdapter: public DetectionBasedTracker::IDetector
-{
-    public:
-        CascadeDetectorAdapter(cv::Ptr<cv::CascadeClassifier> detector):
-            Detector(detector)
-        {
-            CV_Assert(detector);
-        }
-
-        void detect(const cv::Mat &Image, std::vector<cv::Rect> &objects)
-        {
-            Detector->detectMultiScale(Image, objects, 1.1, 3, 0, minObjSize, maxObjSize);
-        }
-        virtual ~CascadeDetectorAdapter()
-        {}
-
-    private:
-        CascadeDetectorAdapter();
-        cv::Ptr<cv::CascadeClassifier> Detector;
- };
-
-static int test_FaceDetector(int argc, char *argv[])
-{
-    if (argc < 4)
-    {
-        usage();
-        return -1;
-    }
-
-    const char* filepattern=argv[1];
-    const char* outfilepattern=argv[2];
-    const char* cascadefile=argv[3];
-    LOGD0("filepattern='%s'", filepattern);
-    LOGD0("outfilepattern='%s'", outfilepattern);
-    LOGD0("cascadefile='%s'", cascadefile);
-
-    vector<Mat> images;
-    {
-        char filename[256];
-        for(int n=1; ; n++)
-        {
-            snprintf(filename, sizeof(filename), filepattern, n);
-            LOGD("filename='%s'", filename);
-            Mat m0;
-            m0=imread(filename);
-            if (m0.empty())
-            {
-                LOGI0("Cannot read the file --- break");
-                break;
-            }
-            images.push_back(m0);
-        }
-        LOGD("read %d images", (int)images.size());
-    }
-
-    std::string cascadeFrontalfilename=cascadefile;
-    cv::Ptr<cv::CascadeClassifier> cascade = makePtr<cv::CascadeClassifier>(cascadeFrontalfilename);
-    cv::Ptr<DetectionBasedTracker::IDetector> MainDetector = makePtr<CascadeDetectorAdapter>(cascade);
-
-    cascade = makePtr<cv::CascadeClassifier>(cascadeFrontalfilename);
-    cv::Ptr<DetectionBasedTracker::IDetector> TrackingDetector = makePtr<CascadeDetectorAdapter>(cascade);
-
-    DetectionBasedTracker::Parameters params;
-    DetectionBasedTracker fd(MainDetector, TrackingDetector, params);
-
-    fd.run();
-
-    Mat gray;
-    Mat m;
-
-    int64 tprev=getTickCount();
-    double freq=getTickFrequency();
-
-    int num_images=images.size();
-    for(int n=1; n <= num_images; n++)
-    {
-        int64 tcur=getTickCount();
-        int64 dt=tcur-tprev;
-        tprev=tcur;
-        double t_ms=((double)dt)/freq * 1000.0;
-        LOGD("\n\nSTEP n=%d        from prev step %f ms\n", n, t_ms);
-        m=images[n-1];
-        CV_Assert(! m.empty());
-        cvtColor(m, gray, COLOR_BGR2GRAY);
-
-        fd.process(gray);
-
-        vector<Rect> result;
-        fd.getObjects(result);
-
-        for(size_t i=0; i < result.size(); i++)
-        {
-            Rect r=result[i];
-            CV_Assert(r.area() > 0);
-            Point tl=r.tl();
-            Point br=r.br();
-            Scalar color=Scalar(0, 250, 0);
-            rectangle(m, tl, br, color, 3);
-        }
-    }
-
-    char outfilename[256];
-    for(int n=1; n <= num_images; n++)
-    {
-        snprintf(outfilename, sizeof(outfilename), outfilepattern, n);
-        LOGD("outfilename='%s'", outfilename);
-        m=images[n-1];
-        imwrite(outfilename, m);
-    }
-
-    fd.stop();
-
-    return 0;
-}
-
-int main(int argc, char *argv[])
-{
-    return test_FaceDetector(argc, argv);
-}
-
-#else // #if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(ANDROID)
-
-#include <stdio.h>
-int main()
-{
-    printf("This sample works for UNIX or ANDROID only\n");
-    return 0;
-}
-
-#endif
diff --git a/samples/cpp/detector_descriptor_evaluation.cpp b/samples/cpp/detector_descriptor_evaluation.cpp
deleted file mode 100644 (file)
index ccb8979..0000000
+++ /dev/null
@@ -1,983 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "opencv2/imgproc.hpp"
-#include "opencv2/highgui.hpp"
-#include "opencv2/features2d.hpp"
-#include "opencv2/legacy.hpp"
-
-#include <limits>
-#include <cstdio>
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-using namespace cv;
-
-
-string data_path;
-/****************************************************************************************\
-*           Functions to evaluate affine covariant detectors and descriptors.            *
-\****************************************************************************************/
-
-static inline Point2f applyHomography( const Mat_<double>& H, const Point2f& pt )
-{
-    double z = H(2,0)*pt.x + H(2,1)*pt.y + H(2,2);
-    if( z )
-    {
-        double w = 1./z;
-        return Point2f( (float)((H(0,0)*pt.x + H(0,1)*pt.y + H(0,2))*w),
-                                                (float)((H(1,0)*pt.x + H(1,1)*pt.y + H(1,2))*w) );
-    }
-    return Point2f( numeric_limits<float>::max(), numeric_limits<float>::max() );
-}
-
-static inline void linearizeHomographyAt( const Mat_<double>& H, const Point2f& pt, Mat_<double>& A )
-{
-    A.create(2,2);
-    double p1 = H(0,0)*pt.x + H(0,1)*pt.y + H(0,2),
-           p2 = H(1,0)*pt.x + H(1,1)*pt.y + H(1,2),
-           p3 = H(2,0)*pt.x + H(2,1)*pt.y + H(2,2),
-           p3_2 = p3*p3;
-    if( p3 )
-    {
-        A(0,0) = H(0,0)/p3 - p1*H(2,0)/p3_2; // fxdx
-        A(0,1) = H(0,1)/p3 - p1*H(2,1)/p3_2; // fxdy
-
-        A(1,0) = H(1,0)/p3 - p2*H(2,0)/p3_2; // fydx
-        A(1,1) = H(1,1)/p3 - p2*H(2,1)/p3_2; // fydx
-    }
-    else
-        A.setTo(Scalar::all(numeric_limits<double>::max()));
-}
-
-static void calcKeyPointProjections( const vector<KeyPoint>& src, const Mat_<double>& H, vector<KeyPoint>& dst )
-{
-    if(  !src.empty() )
-    {
-        CV_Assert( !H.empty() && H.cols == 3 && H.rows == 3);
-        dst.resize(src.size());
-        vector<KeyPoint>::const_iterator srcIt = src.begin();
-        vector<KeyPoint>::iterator       dstIt = dst.begin();
-        for( ; srcIt != src.end(); ++srcIt, ++dstIt )
-        {
-            Point2f dstPt = applyHomography(H, srcIt->pt);
-
-            float srcSize2 = srcIt->size * srcIt->size;
-            Mat_<double> M(2, 2);
-            M(0,0) = M(1,1) = 1./srcSize2;
-            M(1,0) = M(0,1) = 0;
-            Mat_<double> invM; invert(M, invM);
-            Mat_<double> Aff; linearizeHomographyAt(H, srcIt->pt, Aff);
-            Mat_<double> dstM; invert(Aff*invM*Aff.t(), dstM);
-            Mat_<double> eval; eigen( dstM, eval );
-            CV_Assert( eval(0,0) && eval(1,0) );
-            float dstSize = (float)pow(1./(eval(0,0)*eval(1,0)), 0.25);
-
-            // TODO: check angle projection
-            float srcAngleRad = (float)(srcIt->angle*CV_PI/180);
-            Point2f vec1(cos(srcAngleRad), sin(srcAngleRad)), vec2;
-            vec2.x = (float)(Aff(0,0)*vec1.x + Aff(0,1)*vec1.y);
-            vec2.y = (float)(Aff(1,0)*vec1.x + Aff(0,1)*vec1.y);
-            float dstAngleGrad = fastAtan2(vec2.y, vec2.x);
-
-            *dstIt = KeyPoint( dstPt, dstSize, dstAngleGrad, srcIt->response, srcIt->octave, srcIt->class_id );
-        }
-    }
-}
-
-static void filterKeyPointsByImageSize( vector<KeyPoint>& keypoints, const Size& imgSize )
-{
-    if( !keypoints.empty() )
-    {
-        vector<KeyPoint> filtered;
-        filtered.reserve(keypoints.size());
-        Rect r(0, 0, imgSize.width, imgSize.height);
-        vector<KeyPoint>::const_iterator it = keypoints.begin();
-        for( int i = 0; it != keypoints.end(); ++it, i++ )
-            if( r.contains(it->pt) )
-                filtered.push_back(*it);
-        keypoints.assign(filtered.begin(), filtered.end());
-    }
-}
-
-/****************************************************************************************\
-*                                  Detectors evaluation                                 *
-\****************************************************************************************/
-const int DATASETS_COUNT = 8;
-const int TEST_CASE_COUNT = 5;
-
-const string IMAGE_DATASETS_DIR = "detectors_descriptors_evaluation/images_datasets/";
-const string DETECTORS_DIR = "detectors_descriptors_evaluation/detectors/";
-const string DESCRIPTORS_DIR = "detectors_descriptors_evaluation/descriptors/";
-const string KEYPOINTS_DIR = "detectors_descriptors_evaluation/keypoints_datasets/";
-
-const string PARAMS_POSTFIX = "_params.xml";
-const string RES_POSTFIX = "_res.xml";
-
-const string REPEAT = "repeatability";
-const string CORRESP_COUNT = "correspondence_count";
-
-string DATASET_NAMES[DATASETS_COUNT] = { "bark", "bikes", "boat", "graf", "leuven", "trees", "ubc", "wall"};
-
-string DEFAULT_PARAMS = "default";
-
-string IS_ACTIVE_PARAMS = "isActiveParams";
-string IS_SAVE_KEYPOINTS = "isSaveKeypoints";
-
-
-class BaseQualityEvaluator
-{
-public:
-    BaseQualityEvaluator( const char* _algName, const char* _testName ) : algName(_algName), testName(_testName)
-    {
-        //TODO: change this
-        isWriteGraphicsData = true;
-    }
-
-    void run();
-
-    virtual ~BaseQualityEvaluator(){}
-
-protected:
-    virtual string getRunParamsFilename() const = 0;
-    virtual string getResultsFilename() const = 0;
-    virtual string getPlotPath() const = 0;
-
-    virtual void calcQualityClear( int datasetIdx ) = 0;
-    virtual bool isCalcQualityEmpty( int datasetIdx ) const = 0;
-
-    void readAllDatasetsRunParams();
-    virtual void readDatasetRunParams( FileNode& fn, int datasetIdx ) = 0;
-    void writeAllDatasetsRunParams() const;
-    virtual void writeDatasetRunParams( FileStorage& fs, int datasetIdx ) const = 0;
-    void setDefaultAllDatasetsRunParams();
-    virtual void setDefaultDatasetRunParams( int datasetIdx ) = 0;
-    virtual void readDefaultRunParams( FileNode& /*fn*/ ) {}
-    virtual void writeDefaultRunParams( FileStorage& /*fs*/ ) const {}
-
-    bool readDataset( const string& datasetName, vector<Mat>& Hs, vector<Mat>& imgs );
-
-    virtual void readAlgorithm() {}
-    virtual void processRunParamsFile() {}
-    virtual void runDatasetTest( const vector<Mat>& /*imgs*/, const vector<Mat>& /*Hs*/, int /*di*/, int& /*progress*/ ) {}
-
-    virtual void processResults( int datasetIdx );
-    virtual void processResults();
-    virtual void writePlotData( int /*datasetIdx*/ ) const {}
-
-    string algName, testName;
-    bool isWriteParams, isWriteGraphicsData;
-};
-
-void BaseQualityEvaluator::readAllDatasetsRunParams()
-{
-    string filename = getRunParamsFilename();
-    FileStorage fs( filename, FileStorage::READ );
-    if( !fs.isOpened() )
-    {
-        isWriteParams = true;
-        setDefaultAllDatasetsRunParams();
-        printf("All runParams are default.\n");
-    }
-    else
-    {
-        isWriteParams = false;
-        FileNode topfn = fs.getFirstTopLevelNode();
-
-        FileNode pfn = topfn[DEFAULT_PARAMS];
-        readDefaultRunParams(pfn);
-
-        for( int i = 0; i < DATASETS_COUNT; i++ )
-        {
-            FileNode fn = topfn[DATASET_NAMES[i]];
-            if( fn.empty() )
-            {
-                printf( "%d-runParams is default.\n", i);
-                setDefaultDatasetRunParams(i);
-            }
-            else
-                readDatasetRunParams(fn, i);
-        }
-    }
-}
-
-void BaseQualityEvaluator::writeAllDatasetsRunParams() const
-{
-    string filename = getRunParamsFilename();
-    FileStorage fs( filename, FileStorage::WRITE );
-    if( fs.isOpened() )
-    {
-        fs << "run_params" << "{"; // top file node
-        fs << DEFAULT_PARAMS << "{";
-        writeDefaultRunParams(fs);
-        fs << "}";
-        for( int i = 0; i < DATASETS_COUNT; i++ )
-        {
-            fs << DATASET_NAMES[i] << "{";
-            writeDatasetRunParams(fs, i);
-            fs << "}";
-        }
-        fs << "}";
-    }
-    else
-        printf( "File %s for writing run params can not be opened.\n", filename.c_str() );
-}
-
-void BaseQualityEvaluator::setDefaultAllDatasetsRunParams()
-{
-    for( int i = 0; i < DATASETS_COUNT; i++ )
-        setDefaultDatasetRunParams(i);
-}
-
-bool BaseQualityEvaluator::readDataset( const string& datasetName, vector<Mat>& Hs, vector<Mat>& imgs )
-{
-    Hs.resize( TEST_CASE_COUNT );
-    imgs.resize( TEST_CASE_COUNT+1 );
-    string dirname = data_path + IMAGE_DATASETS_DIR + datasetName + "/";
-    for( int i = 0; i < (int)Hs.size(); i++ )
-    {
-        stringstream filename; filename << "H1to" << i+2 << "p.xml";
-        FileStorage fs( dirname + filename.str(), FileStorage::READ );
-        if( !fs.isOpened() )
-        {
-            cout << "filename " << dirname + filename.str() << endl;
-            FileStorage fs2( dirname + filename.str(), FileStorage::READ );
-            return false;
-        }
-        fs.getFirstTopLevelNode() >> Hs[i];
-    }
-
-    for( int i = 0; i < (int)imgs.size(); i++ )
-    {
-        stringstream filename; filename << "img" << i+1 << ".png";
-        imgs[i] = imread( dirname + filename.str(), 0 );
-        if( imgs[i].empty() )
-        {
-            cout << "filename " << filename.str() << endl;
-            return false;
-        }
-    }
-    return true;
-}
-
-void BaseQualityEvaluator::processResults( int datasetIdx )
-{
-    if( isWriteGraphicsData )
-        writePlotData( datasetIdx );
-}
-
-void BaseQualityEvaluator::processResults()
-{
-    if( isWriteParams )
-        writeAllDatasetsRunParams();
-}
-
-void BaseQualityEvaluator::run()
-{
-    readAlgorithm ();
-    processRunParamsFile ();
-
-    int notReadDatasets = 0;
-    int progress = 0;
-
-    FileStorage runParamsFS( getRunParamsFilename(), FileStorage::READ );
-    isWriteParams = (! runParamsFS.isOpened());
-    FileNode topfn = runParamsFS.getFirstTopLevelNode();
-    FileNode defaultParams = topfn[DEFAULT_PARAMS];
-    readDefaultRunParams (defaultParams);
-
-    cout << testName << endl;
-    for(int di = 0; di < DATASETS_COUNT; di++ )
-    {
-        cout << "Dataset " << di << " [" << DATASET_NAMES[di] << "] " << flush;
-        vector<Mat> imgs, Hs;
-        if( !readDataset( DATASET_NAMES[di], Hs, imgs ) )
-        {
-            calcQualityClear (di);
-            printf( "Images or homography matrices of dataset named %s can not be read\n",
-                        DATASET_NAMES[di].c_str());
-            notReadDatasets++;
-            continue;
-        }
-
-        FileNode fn = topfn[DATASET_NAMES[di]];
-        readDatasetRunParams(fn, di);
-
-        runDatasetTest (imgs, Hs, di, progress);
-        processResults( di );
-        cout << endl;
-    }
-    if( notReadDatasets == DATASETS_COUNT )
-    {
-        printf( "All datasets were not be read\n");
-        exit(-1);
-    }
-    else
-        processResults();
-    runParamsFS.release();
-}
-
-
-
-class DetectorQualityEvaluator : public BaseQualityEvaluator
-{
-public:
-    DetectorQualityEvaluator( const char* _detectorName, const char* _testName ) : BaseQualityEvaluator( _detectorName, _testName )
-    {
-        calcQuality.resize(DATASETS_COUNT);
-        isSaveKeypoints.resize(DATASETS_COUNT);
-        isActiveParams.resize(DATASETS_COUNT);
-
-        isSaveKeypointsDefault = false;
-        isActiveParamsDefault = false;
-    }
-
-protected:
-    virtual string getRunParamsFilename() const;
-    virtual string getResultsFilename() const;
-    virtual string getPlotPath() const;
-
-    virtual void calcQualityClear( int datasetIdx );
-    virtual bool isCalcQualityEmpty( int datasetIdx ) const;
-
-    virtual void readDatasetRunParams( FileNode& fn, int datasetIdx );
-    virtual void writeDatasetRunParams( FileStorage& fs, int datasetIdx ) const;
-    virtual void setDefaultDatasetRunParams( int datasetIdx );
-    virtual void readDefaultRunParams( FileNode &fn );
-    virtual void writeDefaultRunParams( FileStorage &fs ) const;
-
-    virtual void writePlotData( int di ) const;
-
-    void openToWriteKeypointsFile( FileStorage& fs, int datasetIdx );
-
-    virtual void readAlgorithm();
-    virtual void processRunParamsFile() {}
-    virtual void runDatasetTest( const vector<Mat> &imgs, const vector<Mat> &Hs, int di, int &progress );
-
-    Ptr<FeatureDetector> specificDetector;
-    Ptr<FeatureDetector> defaultDetector;
-
-    struct Quality
-    {
-        float repeatability;
-        int correspondenceCount;
-    };
-    vector<vector<Quality> > calcQuality;
-
-    vector<bool> isSaveKeypoints;
-    vector<bool> isActiveParams;
-
-    bool isSaveKeypointsDefault;
-    bool isActiveParamsDefault;
-};
-
-string DetectorQualityEvaluator::getRunParamsFilename() const
-{
-     return data_path + DETECTORS_DIR + algName + PARAMS_POSTFIX;
-}
-
-string DetectorQualityEvaluator::getResultsFilename() const
-{
-    return data_path + DETECTORS_DIR + algName + RES_POSTFIX;
-}
-
-string DetectorQualityEvaluator::getPlotPath() const
-{
-    return data_path + DETECTORS_DIR + "plots/";
-}
-
-void DetectorQualityEvaluator::calcQualityClear( int datasetIdx )
-{
-    calcQuality[datasetIdx].clear();
-}
-
-bool DetectorQualityEvaluator::isCalcQualityEmpty( int datasetIdx ) const
-{
-    return calcQuality[datasetIdx].empty();
-}
-
-void DetectorQualityEvaluator::readDefaultRunParams (FileNode &fn)
-{
-    if (! fn.empty() )
-    {
-        isSaveKeypointsDefault = (int)fn[IS_SAVE_KEYPOINTS] != 0;
-        defaultDetector->read (fn);
-    }
-}
-
-void DetectorQualityEvaluator::writeDefaultRunParams (FileStorage &fs) const
-{
-    fs << IS_SAVE_KEYPOINTS << isSaveKeypointsDefault;
-    defaultDetector->write (fs);
-}
-
-void DetectorQualityEvaluator::readDatasetRunParams( FileNode& fn, int datasetIdx )
-{
-    isActiveParams[datasetIdx] = (int)fn[IS_ACTIVE_PARAMS] != 0;
-    if (isActiveParams[datasetIdx])
-    {
-        isSaveKeypoints[datasetIdx] = (int)fn[IS_SAVE_KEYPOINTS] != 0;
-        specificDetector->read (fn);
-    }
-    else
-    {
-        setDefaultDatasetRunParams(datasetIdx);
-    }
-}
-
-void DetectorQualityEvaluator::writeDatasetRunParams( FileStorage& fs, int datasetIdx ) const
-{
-    fs << IS_ACTIVE_PARAMS << isActiveParams[datasetIdx];
-    fs << IS_SAVE_KEYPOINTS << isSaveKeypoints[datasetIdx];
-    defaultDetector->write (fs);
-}
-
-void DetectorQualityEvaluator::setDefaultDatasetRunParams( int datasetIdx )
-{
-    isSaveKeypoints[datasetIdx] = isSaveKeypointsDefault;
-    isActiveParams[datasetIdx] = isActiveParamsDefault;
-}
-
-void DetectorQualityEvaluator::writePlotData(int di ) const
-{
-    int imgXVals[] = { 2, 3, 4, 5, 6 }; // if scale, blur or light changes
-    int viewpointXVals[] = { 20, 30, 40, 50, 60 }; // if viewpoint changes
-    int jpegXVals[] = { 60, 80, 90, 95, 98 }; // if jpeg compression
-
-    int* xVals = 0;
-    if( !DATASET_NAMES[di].compare("ubc") )
-    {
-        xVals = jpegXVals;
-    }
-    else if( !DATASET_NAMES[di].compare("graf") || !DATASET_NAMES[di].compare("wall") )
-    {
-        xVals = viewpointXVals;
-    }
-    else
-        xVals = imgXVals;
-
-    stringstream rFilename, cFilename;
-    rFilename << getPlotPath() << algName << "_" << DATASET_NAMES[di]  << "_repeatability.csv";
-    cFilename << getPlotPath() << algName << "_" << DATASET_NAMES[di]  << "_correspondenceCount.csv";
-    ofstream rfile(rFilename.str().c_str()), cfile(cFilename.str().c_str());
-    for( int ci = 0; ci < TEST_CASE_COUNT; ci++ )
-    {
-        rfile << xVals[ci] << ", " << calcQuality[di][ci].repeatability << endl;
-        cfile << xVals[ci] << ", " << calcQuality[di][ci].correspondenceCount << endl;
-    }
-}
-
-void DetectorQualityEvaluator::openToWriteKeypointsFile( FileStorage& fs, int datasetIdx )
-{
-    string filename = data_path + KEYPOINTS_DIR + algName + "_"+ DATASET_NAMES[datasetIdx] + ".xml.gz" ;
-
-    fs.open(filename, FileStorage::WRITE);
-    if( !fs.isOpened() )
-        printf( "keypoints can not be written in file %s because this file can not be opened\n", filename.c_str() );
-}
-
-inline void writeKeypoints( FileStorage& fs, const vector<KeyPoint>& keypoints, int imgIdx )
-{
-    if( fs.isOpened() )
-    {
-        stringstream imgName; imgName << "img" << imgIdx;
-        write( fs, imgName.str(), keypoints );
-    }
-}
-
-inline void readKeypoints( FileStorage& fs, vector<KeyPoint>& keypoints, int imgIdx )
-{
-    CV_Assert( fs.isOpened() );
-    stringstream imgName; imgName << "img" << imgIdx;
-    read( fs[imgName.str()], keypoints);
-}
-
-void DetectorQualityEvaluator::readAlgorithm ()
-{
-    defaultDetector = FeatureDetector::create( algName );
-    specificDetector = FeatureDetector::create( algName );
-    if( !defaultDetector )
-    {
-        printf( "Algorithm can not be read\n" );
-        exit(-1);
-    }
-}
-
-static int update_progress( const string& /*name*/, int progress, int test_case_idx, int count, double dt )
-{
-    int width = 60 /*- (int)name.length()*/;
-    if( count > 0 )
-    {
-        int t = cvRound( ((double)test_case_idx * width)/count );
-        if( t > progress )
-        {
-            cout << "." << flush;
-            progress = t;
-        }
-    }
-    else if( cvRound(dt) > progress )
-    {
-        cout << "." << flush;
-        progress = cvRound(dt);
-    }
-
-    return progress;
-}
-
-void DetectorQualityEvaluator::runDatasetTest (const vector<Mat> &imgs, const vector<Mat> &Hs, int di, int &progress)
-{
-    Ptr<FeatureDetector> detector = isActiveParams[di] ? specificDetector : defaultDetector;
-    FileStorage keypontsFS;
-    if( isSaveKeypoints[di] )
-        openToWriteKeypointsFile( keypontsFS, di );
-
-    calcQuality[di].resize(TEST_CASE_COUNT);
-
-    vector<KeyPoint> keypoints1;
-    detector->detect( imgs[0], keypoints1 );
-    writeKeypoints( keypontsFS, keypoints1, 0);
-    int progressCount = DATASETS_COUNT*TEST_CASE_COUNT;
-
-    for( int ci = 0; ci < TEST_CASE_COUNT; ci++ )
-    {
-        progress = update_progress( testName, progress, di*TEST_CASE_COUNT + ci + 1, progressCount, 0 );
-        vector<KeyPoint> keypoints2;
-        float rep;
-        evaluateFeatureDetector( imgs[0], imgs[ci+1], Hs[ci], &keypoints1, &keypoints2,
-                                 rep, calcQuality[di][ci].correspondenceCount,
-                                 detector );
-        calcQuality[di][ci].repeatability = rep == -1 ? rep : 100.f*rep;
-        writeKeypoints( keypontsFS, keypoints2, ci+1);
-    }
-}
-
-// static void testLog( bool isBadAccuracy )
-// {
-//     if( isBadAccuracy )
-//         printf(" bad accuracy\n");
-//     else
-//         printf("\n");
-// }
-
-/****************************************************************************************\
-*                                  Descriptors evaluation                                 *
-\****************************************************************************************/
-
-const string RECALL = "recall";
-const string PRECISION = "precision";
-
-const string KEYPOINTS_FILENAME = "keypointsFilename";
-const string PROJECT_KEYPOINTS_FROM_1IMAGE = "projectKeypointsFrom1Image";
-const string MATCH_FILTER = "matchFilter";
-const string RUN_PARAMS_IS_IDENTICAL = "runParamsIsIdentical";
-
-const string ONE_WAY_TRAIN_DIR = "detectors_descriptors_evaluation/one_way_train_images/";
-const string ONE_WAY_IMAGES_LIST = "one_way_train_images.txt";
-
-class DescriptorQualityEvaluator : public BaseQualityEvaluator
-{
-public:
-    enum{ NO_MATCH_FILTER = 0 };
-    DescriptorQualityEvaluator( const char* _descriptorName, const char* _testName, const char* _matcherName = 0 ) :
-            BaseQualityEvaluator( _descriptorName, _testName )
-    {
-        calcQuality.resize(DATASETS_COUNT);
-        calcDatasetQuality.resize(DATASETS_COUNT);
-        commRunParams.resize(DATASETS_COUNT);
-
-        commRunParamsDefault.projectKeypointsFrom1Image = true;
-        commRunParamsDefault.matchFilter = NO_MATCH_FILTER;
-        commRunParamsDefault.isActiveParams = false;
-
-        if( _matcherName )
-            matcherName = _matcherName;
-    }
-
-protected:
-    virtual string getRunParamsFilename() const;
-    virtual string getResultsFilename() const;
-    virtual string getPlotPath() const;
-
-    virtual void calcQualityClear( int datasetIdx );
-    virtual bool isCalcQualityEmpty( int datasetIdx ) const;
-
-    virtual void readDatasetRunParams( FileNode& fn, int datasetIdx ); //
-    virtual void writeDatasetRunParams( FileStorage& fs, int datasetIdx ) const;
-    virtual void setDefaultDatasetRunParams( int datasetIdx );
-    virtual void readDefaultRunParams( FileNode &fn );
-    virtual void writeDefaultRunParams( FileStorage &fs ) const;
-
-    virtual void readAlgorithm();
-    virtual void processRunParamsFile() {}
-    virtual void runDatasetTest( const vector<Mat> &imgs, const vector<Mat> &Hs, int di, int &progress );
-
-    virtual void writePlotData( int di ) const;
-    void calculatePlotData( vector<vector<DMatch> > &allMatches, vector<vector<uchar> > &allCorrectMatchesMask, int di );
-
-    struct Quality
-    {
-        float recall;
-        float precision;
-    };
-    vector<vector<Quality> > calcQuality;
-    vector<vector<Quality> > calcDatasetQuality;
-
-    struct CommonRunParams
-    {
-        string keypontsFilename;
-        bool projectKeypointsFrom1Image;
-        int matchFilter; // not used now
-        bool isActiveParams;
-    };
-    vector<CommonRunParams> commRunParams;
-
-    Ptr<GenericDescriptorMatch> specificDescMatcher;
-    Ptr<GenericDescriptorMatch> defaultDescMatcher;
-
-    CommonRunParams commRunParamsDefault;
-    string matcherName;
-};
-
-string DescriptorQualityEvaluator::getRunParamsFilename() const
-{
-    return data_path + DESCRIPTORS_DIR + algName + PARAMS_POSTFIX;
-}
-
-string DescriptorQualityEvaluator::getResultsFilename() const
-{
-    return data_path + DESCRIPTORS_DIR + algName + RES_POSTFIX;
-}
-
-string DescriptorQualityEvaluator::getPlotPath() const
-{
-    return data_path + DESCRIPTORS_DIR + "plots/";
-}
-
-void DescriptorQualityEvaluator::calcQualityClear( int datasetIdx )
-{
-    calcQuality[datasetIdx].clear();
-}
-
-bool DescriptorQualityEvaluator::isCalcQualityEmpty( int datasetIdx ) const
-{
-    return calcQuality[datasetIdx].empty();
-}
-
-void DescriptorQualityEvaluator::readDefaultRunParams (FileNode &fn)
-{
-    if (! fn.empty() )
-    {
-        commRunParamsDefault.projectKeypointsFrom1Image = (int)fn[PROJECT_KEYPOINTS_FROM_1IMAGE] != 0;
-        commRunParamsDefault.matchFilter = (int)fn[MATCH_FILTER];
-        defaultDescMatcher->read (fn);
-    }
-}
-
-void DescriptorQualityEvaluator::writeDefaultRunParams (FileStorage &fs) const
-{
-    fs << PROJECT_KEYPOINTS_FROM_1IMAGE << commRunParamsDefault.projectKeypointsFrom1Image;
-    fs << MATCH_FILTER << commRunParamsDefault.matchFilter;
-    defaultDescMatcher->write (fs);
-}
-
-void DescriptorQualityEvaluator::readDatasetRunParams( FileNode& fn, int datasetIdx )
-{
-    commRunParams[datasetIdx].isActiveParams = (int)fn[IS_ACTIVE_PARAMS] != 0;
-    if (commRunParams[datasetIdx].isActiveParams)
-    {
-        commRunParams[datasetIdx].keypontsFilename = (string)fn[KEYPOINTS_FILENAME];
-        commRunParams[datasetIdx].projectKeypointsFrom1Image = (int)fn[PROJECT_KEYPOINTS_FROM_1IMAGE] != 0;
-        commRunParams[datasetIdx].matchFilter = (int)fn[MATCH_FILTER];
-        specificDescMatcher->read (fn);
-    }
-    else
-    {
-        setDefaultDatasetRunParams(datasetIdx);
-    }
-}
-
-void DescriptorQualityEvaluator::writeDatasetRunParams( FileStorage& fs, int datasetIdx ) const
-{
-    fs << IS_ACTIVE_PARAMS << commRunParams[datasetIdx].isActiveParams;
-    fs << KEYPOINTS_FILENAME << commRunParams[datasetIdx].keypontsFilename;
-    fs << PROJECT_KEYPOINTS_FROM_1IMAGE << commRunParams[datasetIdx].projectKeypointsFrom1Image;
-    fs << MATCH_FILTER << commRunParams[datasetIdx].matchFilter;
-
-    defaultDescMatcher->write (fs);
-}
-
-void DescriptorQualityEvaluator::setDefaultDatasetRunParams( int datasetIdx )
-{
-    commRunParams[datasetIdx] = commRunParamsDefault;
-    commRunParams[datasetIdx].keypontsFilename = "SURF_" + DATASET_NAMES[datasetIdx] + ".xml.gz";
-}
-
-void DescriptorQualityEvaluator::writePlotData( int di ) const
-{
-    stringstream filename;
-    filename << getPlotPath() << algName << "_" << DATASET_NAMES[di] << ".csv";
-    FILE *file = fopen (filename.str().c_str(), "w");
-    size_t size = calcDatasetQuality[di].size();
-    for (size_t i=0;i<size;i++)
-    {
-        fprintf( file, "%f, %f\n", 1 - calcDatasetQuality[di][i].precision, calcDatasetQuality[di][i].recall);
-    }
-    fclose( file );
-}
-
-void DescriptorQualityEvaluator::readAlgorithm( )
-{
-    defaultDescMatcher = GenericDescriptorMatcher::create( algName );
-    specificDescMatcher = GenericDescriptorMatcher::create( algName );
-
-    if( !defaultDescMatcher )
-    {
-        Ptr<DescriptorExtractor> extractor = DescriptorExtractor::create( algName );
-        Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create( matcherName );
-        defaultDescMatcher = makePtr<VectorDescriptorMatch>( extractor, matcher );
-        specificDescMatcher = makePtr<VectorDescriptorMatch>( extractor, matcher );
-
-        if( !extractor || !matcher )
-        {
-            printf("Algorithm can not be read\n");
-            exit(-1);
-        }
-    }
-}
-
-void DescriptorQualityEvaluator::calculatePlotData( vector<vector<DMatch> > &allMatches, vector<vector<uchar> > &allCorrectMatchesMask, int di )
-{
-    vector<Point2f> recallPrecisionCurve;
-    computeRecallPrecisionCurve( allMatches, allCorrectMatchesMask, recallPrecisionCurve );
-
-    calcDatasetQuality[di].clear();
-    const float resultPrecision = 0.5;
-    bool isResultCalculated = false;
-    const double eps = 1e-2;
-
-    Quality initQuality;
-    initQuality.recall = 0;
-    initQuality.precision = 0;
-    calcDatasetQuality[di].push_back( initQuality );
-
-    for( size_t i=0;i<recallPrecisionCurve.size();i++ )
-    {
-        Quality quality;
-        quality.recall = recallPrecisionCurve[i].y;
-        quality.precision = 1 - recallPrecisionCurve[i].x;
-        Quality back = calcDatasetQuality[di].back();
-
-        if( fabs( quality.recall - back.recall ) < eps && fabs( quality.precision - back.precision ) < eps )
-            continue;
-
-        calcDatasetQuality[di].push_back( quality );
-
-        if( !isResultCalculated && quality.precision < resultPrecision )
-        {
-            for(int ci=0;ci<TEST_CASE_COUNT;ci++)
-            {
-                calcQuality[di][ci].recall = quality.recall;
-                calcQuality[di][ci].precision = quality.precision;
-            }
-            isResultCalculated = true;
-        }
-    }
-}
-
-void DescriptorQualityEvaluator::runDatasetTest (const vector<Mat> &imgs, const vector<Mat> &Hs, int di, int &progress)
-{
-    FileStorage keypontsFS( data_path + KEYPOINTS_DIR + commRunParams[di].keypontsFilename, FileStorage::READ );
-    if( !keypontsFS.isOpened())
-    {
-       calcQuality[di].clear();
-       printf( "keypoints from file %s can not be read\n", commRunParams[di].keypontsFilename.c_str() );
-       return;
-    }
-
-    Ptr<GenericDescriptorMatcher> descMatch = commRunParams[di].isActiveParams ? specificDescMatcher : defaultDescMatcher;
-    calcQuality[di].resize(TEST_CASE_COUNT);
-
-    vector<KeyPoint> keypoints1;
-    readKeypoints( keypontsFS, keypoints1, 0);
-
-    int progressCount = DATASETS_COUNT*TEST_CASE_COUNT;
-
-    vector<vector<DMatch> > allMatches1to2;
-    vector<vector<uchar> > allCorrectMatchesMask;
-    for( int ci = 0; ci < TEST_CASE_COUNT; ci++ )
-    {
-        progress = update_progress( testName, progress, di*TEST_CASE_COUNT + ci + 1, progressCount, 0 );
-
-        vector<KeyPoint> keypoints2;
-        if( commRunParams[di].projectKeypointsFrom1Image )
-        {
-            // TODO need to test function calcKeyPointProjections
-            calcKeyPointProjections( keypoints1, Hs[ci], keypoints2 );
-            filterKeyPointsByImageSize( keypoints2,  imgs[ci+1].size() );
-        }
-        else
-            readKeypoints( keypontsFS, keypoints2, ci+1 );
-        // TODO if( commRunParams[di].matchFilter )
-
-        vector<vector<DMatch> > matches1to2;
-        vector<vector<uchar> > correctMatchesMask;
-        vector<Point2f> recallPrecisionCurve; // not used because we need recallPrecisionCurve for
-                                              // all images in dataset
-        evaluateGenericDescriptorMatcher( imgs[0], imgs[ci+1], Hs[ci], keypoints1, keypoints2,
-                                          &matches1to2, &correctMatchesMask, recallPrecisionCurve,
-                                          descMatch );
-        allMatches1to2.insert( allMatches1to2.end(), matches1to2.begin(), matches1to2.end() );
-        allCorrectMatchesMask.insert( allCorrectMatchesMask.end(), correctMatchesMask.begin(), correctMatchesMask.end() );
-    }
-
-    calculatePlotData( allMatches1to2, allCorrectMatchesMask, di );
-}
-
-//--------------------------------- Calonder descriptor test --------------------------------------------
-class CalonderDescriptorQualityEvaluator : public DescriptorQualityEvaluator
-{
-public:
-    CalonderDescriptorQualityEvaluator() :
-            DescriptorQualityEvaluator( "Calonder", "quality-descriptor-calonder") {}
-    virtual void readAlgorithm( )
-    {
-        string classifierFile = data_path + "/features2d/calonder_classifier.rtc";
-        Ptr<DescriptorExtractor> extractor = makePtr<CalonderDescriptorExtractor<float> >( classifierFile );
-        defaultDescMatcher = makePtr<VectorDescriptorMatch>(
-            extractor,
-            makePtr<BFMatcher>(extractor->defaultNorm()));
-        specificDescMatcher = defaultDescMatcher;
-    }
-};
-
-//--------------------------------- One Way descriptor test --------------------------------------------
-class OneWayDescriptorQualityTest : public DescriptorQualityEvaluator
-{
-public:
-    OneWayDescriptorQualityTest() :
-        DescriptorQualityEvaluator("ONEWAY", "quality-descriptor-one-way")
-    {
-    }
-protected:
-    virtual void processRunParamsFile ();
-    virtual void writeDatasetRunParams( FileStorage& fs, int datasetIdx ) const;
-};
-
-void OneWayDescriptorQualityTest::processRunParamsFile ()
-{
-    string filename = getRunParamsFilename();
-    FileStorage fs = FileStorage (filename, FileStorage::READ);
-    FileNode fn = fs.getFirstTopLevelNode();
-    fn = fn[DEFAULT_PARAMS];
-
-    string pcaFilename = data_path + (string)fn["pcaFilename"];
-    string trainPath = data_path + (string)fn["trainPath"];
-    string trainImagesList = (string)fn["trainImagesList"];
-    int patch_width = fn["patchWidth"];
-    int patch_height = fn["patchHeight"];
-    Size patchSize = cvSize (patch_width, patch_height);
-    int poseCount = fn["poseCount"];
-
-    if (trainImagesList.length () == 0 )
-        return;
-
-    fs.release ();
-
-    readAllDatasetsRunParams();
-
-    Ptr<OneWayDescriptorBase> base(
-        new OneWayDescriptorBase(patchSize, poseCount, pcaFilename,
-                                 trainPath, trainImagesList));
-
-    Ptr<OneWayDescriptorMatch> match = makePtr<OneWayDescriptorMatch>();
-    match->initialize( OneWayDescriptorMatch::Params (), base );
-    defaultDescMatcher = match;
-    writeAllDatasetsRunParams();
-}
-
-void OneWayDescriptorQualityTest::writeDatasetRunParams( FileStorage& fs, int datasetIdx ) const
-{
-    fs << IS_ACTIVE_PARAMS << commRunParams[datasetIdx].isActiveParams;
-    fs << KEYPOINTS_FILENAME << commRunParams[datasetIdx].keypontsFilename;
-    fs << PROJECT_KEYPOINTS_FROM_1IMAGE << commRunParams[datasetIdx].projectKeypointsFrom1Image;
-    fs << MATCH_FILTER << commRunParams[datasetIdx].matchFilter;
-}
-
-int main( int argc, char** argv )
-{
-    if( argc != 2 )
-    {
-        cout << "Format: " << argv[0] << " testdata path (path to testdata/cv)" << endl;
-        return -1;
-    }
-
-    data_path = argv[1];
-#ifdef WIN32
-    if( *data_path.rbegin() != '\\' )
-        data_path = data_path + "\\";
-#else
-    if( *data_path.rbegin() != '/' )
-        data_path = data_path + "/";
-#endif
-
-    Ptr<BaseQualityEvaluator> evals[] =
-    {
-        makePtr<DetectorQualityEvaluator>( "FAST", "quality-detector-fast" ),
-        makePtr<DetectorQualityEvaluator>( "GFTT", "quality-detector-gftt" ),
-        makePtr<DetectorQualityEvaluator>( "HARRIS", "quality-detector-harris" ),
-        makePtr<DetectorQualityEvaluator>( "MSER", "quality-detector-mser" ),
-        makePtr<DetectorQualityEvaluator>( "STAR", "quality-detector-star" ),
-        makePtr<DetectorQualityEvaluator>( "SIFT", "quality-detector-sift" ),
-        makePtr<DetectorQualityEvaluator>( "SURF", "quality-detector-surf" ),
-
-        makePtr<DescriptorQualityEvaluator>( "SIFT", "quality-descriptor-sift", "BruteForce" ),
-        makePtr<DescriptorQualityEvaluator>( "SURF", "quality-descriptor-surf", "BruteForce" ),
-        makePtr<DescriptorQualityEvaluator>( "FERN", "quality-descriptor-fern"),
-        makePtr<CalonderDescriptorQualityEvaluator>()
-    };
-
-    for( size_t i = 0; i < sizeof(evals)/sizeof(evals[0]); i++ )
-    {
-        evals[i]->run();
-        cout << endl;
-    }
-}
diff --git a/samples/cpp/detector_descriptor_matcher_evaluation.cpp b/samples/cpp/detector_descriptor_matcher_evaluation.cpp
deleted file mode 100644 (file)
index 194cddf..0000000
+++ /dev/null
@@ -1,346 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
-//                        Intel License Agreement
-//                For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of Intel Corporation may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "opencv2/core/utility.hpp"
-#include "opencv2/imgproc.hpp"
-#include "opencv2/highgui.hpp"
-#include "opencv2/features2d.hpp"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/stat.h>
-
-#include <limits>
-#include <cstdio>
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-using namespace cv;
-
-/*
-The algorithm:
-
-for each tested combination of detector+descriptor+matcher:
-
-    create detector, descriptor and matcher,
-    load their params if they are there, otherwise use the default ones and save them
-
-    for each dataset:
-
-        load reference image
-        detect keypoints in it, compute descriptors
-
-        for each transformed image:
-            load the image
-            load the transformation matrix
-            detect keypoints in it too, compute descriptors
-
-            find matches
-            transform keypoints from the first image using the ground-truth matrix
-
-            compute the number of matched keypoints, i.e. for each pair (i,j) found by a matcher compare
-            j-th keypoint from the second image with the transformed i-th keypoint. If they are close, +1.
-
-            so, we have:
-               N - number of keypoints in the first image that are also visible
-               (after transformation) on the second image
-
-               N1 - number of keypoints in the first image that have been matched.
-
-               n - number of the correct matches found by the matcher
-
-               n/N1 - precision
-               n/N - recall (?)
-
-            we store (N, n/N1, n/N) (where N is stored primarily for tuning the detector's thresholds,
-                                     in order to semi-equalize their keypoints counts)
-
-*/
-
-typedef Vec3f TVec; // (N, n/N1, n/N) - see above
-
-static void saveloadDDM( const string& params_filename,
-                         Ptr<FeatureDetector>& detector,
-                         Ptr<DescriptorExtractor>& descriptor,
-                         Ptr<DescriptorMatcher>& matcher )
-{
-    FileStorage fs(params_filename, FileStorage::READ);
-    if( fs.isOpened() )
-    {
-        detector->read(fs["detector"]);
-        descriptor->read(fs["descriptor"]);
-        matcher->read(fs["matcher"]);
-    }
-    else
-    {
-        fs.open(params_filename, FileStorage::WRITE);
-        fs << "detector" << "{";
-        detector->write(fs);
-        fs << "}" << "descriptor" << "{";
-        descriptor->write(fs);
-        fs << "}" << "matcher" << "{";
-        matcher->write(fs);
-        fs << "}";
-    }
-}
-
-static Mat loadMat(const string& fsname)
-{
-    FileStorage fs(fsname, FileStorage::READ);
-    Mat m;
-    fs.getFirstTopLevelNode() >> m;
-    return m;
-}
-
-static void transformKeypoints( const vector<KeyPoint>& kp,
-                                vector<vector<Point2f> >& contours,
-                                const Mat& H )
-{
-    const float scale = 256.f;
-    size_t i, n = kp.size();
-    contours.resize(n);
-    vector<Point> temp;
-
-    for( i = 0; i < n; i++ )
-    {
-        ellipse2Poly(Point2f(kp[i].pt.x*scale, kp[i].pt.y*scale),
-                     Size2f(kp[i].size*scale, kp[i].size*scale),
-                     0, 0, 360, 12, temp);
-        Mat(temp).convertTo(contours[i], CV_32F, 1./scale);
-        perspectiveTransform(contours[i], contours[i], H);
-    }
-}
-
-
-static TVec proccessMatches( Size imgsize,
-                             const vector<DMatch>& matches,
-                             const vector<vector<Point2f> >& kp1t_contours,
-                             const vector<vector<Point2f> >& kp_contours,
-                             double overlapThreshold )
-{
-    const double visibilityThreshold = 0.6;
-
-    // 1. [preprocessing] find bounding rect for each element of kp1t_contours and kp_contours.
-    // 2. [cross-check] for each DMatch (iK, i1)
-    //        update best_match[i1] using DMatch::distance.
-    // 3. [compute overlapping] for each i1 (keypoint from the first image) do:
-    //        if i1-th keypoint is outside of image, skip it
-    //        increment N
-    //        if best_match[i1] is initialized, increment N1
-    //        if kp_contours[best_match[i1]] and kp1t_contours[i1] overlap by overlapThreshold*100%,
-    //        increment n. Use bounding rects to speedup this step
-
-    int i, size1 = (int)kp1t_contours.size(), size = (int)kp_contours.size(), msize = (int)matches.size();
-    vector<DMatch> best_match(size1);
-    vector<Rect> rects1(size1), rects(size);
-
-    // proprocess
-    for( i = 0; i < size1; i++ )
-        rects1[i] = boundingRect(kp1t_contours[i]);
-
-    for( i = 0; i < size; i++ )
-        rects[i] = boundingRect(kp_contours[i]);
-
-    // cross-check
-    for( i = 0; i < msize; i++ )
-    {
-        DMatch m = matches[i];
-        int i1 = m.trainIdx, iK = m.queryIdx;
-        CV_Assert( 0 <= i1 && i1 < size1 && 0 <= iK && iK < size );
-        if( best_match[i1].trainIdx < 0 || best_match[i1].distance > m.distance )
-            best_match[i1] = m;
-    }
-
-    int N = 0, N1 = 0, n = 0;
-
-    // overlapping
-    for( i = 0; i < size1; i++ )
-    {
-        int i1 = i, iK = best_match[i].queryIdx;
-        if( iK >= 0 )
-            N1++;
-
-        Rect r = rects1[i] & Rect(0, 0, imgsize.width, imgsize.height);
-        if( r.area() < visibilityThreshold*rects1[i].area() )
-            continue;
-        N++;
-
-        if( iK < 0 || (rects1[i1] & rects[iK]).area() == 0 )
-            continue;
-
-        double n_area = intersectConvexConvex(kp1t_contours[i1], kp_contours[iK], noArray(), true);
-        if( n_area == 0 )
-            continue;
-
-        double area1 = contourArea(kp1t_contours[i1], false);
-        double area = contourArea(kp_contours[iK], false);
-
-        double ratio = n_area/(area1 + area - n_area);
-        n += ratio >= overlapThreshold;
-    }
-
-    return TVec((float)N, (float)n/std::max(N1, 1), (float)n/std::max(N, 1));
-}
-
-
-static void saveResults(const string& dir, const string& name, const string& dsname,
-                        const vector<TVec>& results, const int* xvals)
-{
-    string fname1 = format("%s%s_%s_precision.csv", dir.c_str(), name.c_str(), dsname.c_str());
-    string fname2 = format("%s%s_%s_recall.csv", dir.c_str(), name.c_str(), dsname.c_str());
-    FILE* f1 = fopen(fname1.c_str(), "wt");
-    FILE* f2 = fopen(fname2.c_str(), "wt");
-
-    for( size_t i = 0; i < results.size(); i++ )
-    {
-        fprintf(f1, "%d, %.1f\n", xvals[i], results[i][1]*100);
-        fprintf(f2, "%d, %.1f\n", xvals[i], results[i][2]*100);
-    }
-    fclose(f1);
-    fclose(f2);
-}
-
-
-int main(int argc, char** argv)
-{
-    static const char* ddms[] =
-    {
-        "ORBX_BF", "ORB", "ORB", "BruteForce-Hamming",
-        //"ORB_BF", "ORB", "ORB", "BruteForce-Hamming",
-        //"ORB3_BF", "ORB", "ORB", "BruteForce-Hamming(2)",
-        //"ORB4_BF", "ORB", "ORB", "BruteForce-Hamming(2)",
-        //"ORB_LSH", "ORB", "ORB", "LSH"
-        //"SURF_BF", "SURF", "SURF", "BruteForce",
-        0
-    };
-
-    static const char* datasets[] =
-    {
-        "bark", "bikes", "boat", "graf", "leuven", "trees", "ubc", "wall", 0
-    };
-
-    static const int imgXVals[] = { 2, 3, 4, 5, 6 }; // if scale, blur or light changes
-    static const int viewpointXVals[] = { 20, 30, 40, 50, 60 }; // if viewpoint changes
-    static const int jpegXVals[] = { 60, 80, 90, 95, 98 }; // if jpeg compression
-
-    const double overlapThreshold = 0.6;
-
-    vector<vector<vector<TVec> > > results; // indexed as results[ddm][dataset][testcase]
-
-    string dataset_dir = string(getenv("OPENCV_TEST_DATA_PATH")) +
-        "/cv/detectors_descriptors_evaluation/images_datasets";
-
-    string dir=argc > 1 ? argv[1] : ".";
-
-    if( dir[dir.size()-1] != '\\' && dir[dir.size()-1] != '/' )
-        dir += "/";
-
-    int result = system(("mkdir " + dir).c_str());
-    CV_Assert(result == 0);
-
-    for( int i = 0; ddms[i*4] != 0; i++ )
-    {
-        const char* name = ddms[i*4];
-        const char* detector_name = ddms[i*4+1];
-        const char* descriptor_name = ddms[i*4+2];
-        const char* matcher_name = ddms[i*4+3];
-        string params_filename = dir + string(name) + "_params.yml";
-
-        cout << "Testing " << name << endl;
-
-        Ptr<FeatureDetector> detector = FeatureDetector::create(detector_name);
-        Ptr<DescriptorExtractor> descriptor = DescriptorExtractor::create(descriptor_name);
-        Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create(matcher_name);
-
-        saveloadDDM( params_filename, detector, descriptor, matcher );
-
-        results.push_back(vector<vector<TVec> >());
-
-        for( int j = 0; datasets[j] != 0; j++ )
-        {
-            const char* dsname = datasets[j];
-
-            cout << "\ton " << dsname << " ";
-            cout.flush();
-
-            const int* xvals = strcmp(dsname, "ubc") == 0 ? jpegXVals :
-                strcmp(dsname, "graf") == 0 || strcmp(dsname, "wall") == 0 ? viewpointXVals : imgXVals;
-
-            vector<KeyPoint> kp1, kp;
-            vector<DMatch> matches;
-            vector<vector<Point2f> > kp1t_contours, kp_contours;
-            Mat desc1, desc;
-
-            Mat img1 = imread(format("%s/%s/img1.png", dataset_dir.c_str(), dsname), 0);
-            CV_Assert( !img1.empty() );
-
-            detector->detect(img1, kp1);
-            descriptor->compute(img1, kp1, desc1);
-
-            results[i].push_back(vector<TVec>());
-
-            for( int k = 2; ; k++ )
-            {
-                cout << ".";
-                cout.flush();
-                Mat imgK = imread(format("%s/%s/img%d.png", dataset_dir.c_str(), dsname, k), 0);
-                if( imgK.empty() )
-                    break;
-
-                detector->detect(imgK, kp);
-                descriptor->compute(imgK, kp, desc);
-                matcher->match( desc, desc1, matches );
-
-                Mat H = loadMat(format("%s/%s/H1to%dp.xml", dataset_dir.c_str(), dsname, k));
-
-                transformKeypoints( kp1, kp1t_contours, H );
-                transformKeypoints( kp, kp_contours, Mat::eye(3, 3, CV_64F));
-
-                TVec r = proccessMatches( imgK.size(), matches, kp1t_contours, kp_contours, overlapThreshold );
-                results[i][j].push_back(r);
-            }
-
-            saveResults(dir, name, dsname, results[i][j], xvals);
-            cout << endl;
-        }
-    }
-}
index cdba5fe..a078588 100644 (file)
@@ -1,5 +1,5 @@
 #include "opencv2/highgui.hpp"
-#include "opencv2/legacy.hpp"
+#include "opencv2/ml.hpp"
 
 using namespace cv;
 
@@ -19,8 +19,6 @@ int main( int /*argc*/, char** /*argv*/ )
     Mat labels;
     Mat img = Mat::zeros( Size( 500, 500 ), CV_8UC3 );
     Mat sample( 1, 2, CV_32FC1 );
-    CvEM em_model;
-    CvEMParams params;
 
     samples = samples.reshape(2, 0);
     for( i = 0; i < N; i++ )
@@ -35,37 +33,10 @@ int main( int /*argc*/, char** /*argv*/ )
     }
     samples = samples.reshape(1, 0);
 
-    // initialize model parameters
-    params.covs      = NULL;
-    params.means     = NULL;
-    params.weights   = NULL;
-    params.probs     = NULL;
-    params.nclusters = N;
-    params.cov_mat_type       = CvEM::COV_MAT_SPHERICAL;
-    params.start_step         = CvEM::START_AUTO_STEP;
-    params.term_crit.max_iter = 300;
-    params.term_crit.epsilon  = 0.1;
-    params.term_crit.type     = TermCriteria::COUNT|TermCriteria::EPS;
-
     // cluster the data
-    em_model.train( samples, Mat(), params, &labels );
-
-#if 0
-    // the piece of code shows how to repeatedly optimize the model
-    // with less-constrained parameters
-    //(COV_MAT_DIAGONAL instead of COV_MAT_SPHERICAL)
-    // when the output of the first stage is used as input for the second one.
-    CvEM em_model2;
-    params.cov_mat_type = CvEM::COV_MAT_DIAGONAL;
-    params.start_step = CvEM::START_E_STEP;
-    params.means = em_model.get_means();
-    params.covs = em_model.get_covs();
-    params.weights = em_model.get_weights();
+    EM em_model(N, EM::COV_MAT_SPHERICAL, TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 300, 0.1));
+    em_model.train( samples, noArray(), labels, noArray() );
 
-    em_model2.train( samples, Mat(), params, &labels );
-    // to use em_model2, replace em_model.predict()
-    // with em_model2.predict() below
-#endif
     // classify every image pixel
     for( i = 0; i < img.rows; i++ )
     {
@@ -73,7 +44,7 @@ int main( int /*argc*/, char** /*argv*/ )
         {
             sample.at<float>(0) = (float)j;
             sample.at<float>(1) = (float)i;
-            int response = cvRound(em_model.predict( sample ));
+            int response = cvRound(em_model.predict( sample )[1]);
             Scalar c = colors[response];
 
             circle( img, Point(j, i), 1, c*0.75, FILLED );
diff --git a/samples/cpp/fabmap/stlucia_test_small0000.jpeg b/samples/cpp/fabmap/stlucia_test_small0000.jpeg
deleted file mode 100755 (executable)
index cc4d54e..0000000
Binary files a/samples/cpp/fabmap/stlucia_test_small0000.jpeg and /dev/null differ
diff --git a/samples/cpp/fabmap/stlucia_test_small0001.jpeg b/samples/cpp/fabmap/stlucia_test_small0001.jpeg
deleted file mode 100755 (executable)
index e849f49..0000000
Binary files a/samples/cpp/fabmap/stlucia_test_small0001.jpeg and /dev/null differ
diff --git a/samples/cpp/fabmap/stlucia_test_small0002.jpeg b/samples/cpp/fabmap/stlucia_test_small0002.jpeg
deleted file mode 100755 (executable)
index 1823ac1..0000000
Binary files a/samples/cpp/fabmap/stlucia_test_small0002.jpeg and /dev/null differ
diff --git a/samples/cpp/fabmap/stlucia_test_small0003.jpeg b/samples/cpp/fabmap/stlucia_test_small0003.jpeg
deleted file mode 100755 (executable)
index f7858dc..0000000
Binary files a/samples/cpp/fabmap/stlucia_test_small0003.jpeg and /dev/null differ
diff --git a/samples/cpp/fabmap/stlucia_test_small0004.jpeg b/samples/cpp/fabmap/stlucia_test_small0004.jpeg
deleted file mode 100755 (executable)
index d28d718..0000000
Binary files a/samples/cpp/fabmap/stlucia_test_small0004.jpeg and /dev/null differ
diff --git a/samples/cpp/fabmap/stlucia_test_small0005.jpeg b/samples/cpp/fabmap/stlucia_test_small0005.jpeg
deleted file mode 100755 (executable)
index 32a3c4e..0000000
Binary files a/samples/cpp/fabmap/stlucia_test_small0005.jpeg and /dev/null differ
diff --git a/samples/cpp/fabmap/stlucia_test_small0006.jpeg b/samples/cpp/fabmap/stlucia_test_small0006.jpeg
deleted file mode 100755 (executable)
index 4ea53c0..0000000
Binary files a/samples/cpp/fabmap/stlucia_test_small0006.jpeg and /dev/null differ
diff --git a/samples/cpp/fabmap/stlucia_test_small0007.jpeg b/samples/cpp/fabmap/stlucia_test_small0007.jpeg
deleted file mode 100755 (executable)
index 443f1ff..0000000
Binary files a/samples/cpp/fabmap/stlucia_test_small0007.jpeg and /dev/null differ
diff --git a/samples/cpp/fabmap/stlucia_test_small0008.jpeg b/samples/cpp/fabmap/stlucia_test_small0008.jpeg
deleted file mode 100755 (executable)
index ca163a2..0000000
Binary files a/samples/cpp/fabmap/stlucia_test_small0008.jpeg and /dev/null differ
diff --git a/samples/cpp/fabmap/stlucia_test_small0009.jpeg b/samples/cpp/fabmap/stlucia_test_small0009.jpeg
deleted file mode 100755 (executable)
index ce51ea3..0000000
Binary files a/samples/cpp/fabmap/stlucia_test_small0009.jpeg and /dev/null differ
diff --git a/samples/cpp/fabmap/train_data_small.yml b/samples/cpp/fabmap/train_data_small.yml
deleted file mode 100644 (file)
index 956cb95..0000000
+++ /dev/null
@@ -1,9197 +0,0 @@
-%YAML:1.0
-BOWImageDescs: !!opencv-matrix
-   rows: 162
-   cols: 545
-   dt: f
-   data: [ 1.27388537e-002, 0., 1.27388537e-002, 3.82165611e-002,
-       1.91082805e-002, 0., 0., 6.36942685e-003, 0., 1.27388537e-002, 0.,
-       0., 6.36942685e-003, 1.27388537e-002, 6.36942685e-003,
-       6.36942685e-003, 0., 1.27388537e-002, 2.54777074e-002,
-       1.91082805e-002, 0., 1.91082805e-002, 1.91082805e-002, 0., 0., 0.,
-       1.27388537e-002, 0., 0., 1.27388537e-002, 6.36942685e-003,
-       2.54777074e-002, 0., 6.36942685e-003, 0., 6.36942685e-003, 0., 0.,
-       1.27388537e-002, 1.27388537e-002, 6.36942685e-003, 0.,
-       6.36942685e-003, 0., 0., 6.36942685e-003, 0., 6.36942685e-003,
-       2.54777074e-002, 6.36942685e-003, 0., 0., 6.36942685e-003,
-       6.36942685e-003, 6.36942685e-003, 6.36942685e-003,
-       6.36942685e-003, 0., 6.36942685e-003, 6.36942685e-003, 0., 0., 0.,
-       6.36942685e-003, 1.91082805e-002, 0., 0., 0., 6.36942685e-003, 0.,
-       1.27388537e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.36942685e-003, 0., 0., 0., 6.36942685e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.27388537e-002, 6.36942685e-003, 0., 0., 0., 0., 0.,
-       6.36942685e-003, 2.54777074e-002, 0., 0., 0., 1.27388537e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.36942685e-003,
-       1.27388537e-002, 0., 6.36942685e-003, 0., 0., 6.36942685e-003, 0.,
-       0., 0., 6.36942685e-003, 0., 0., 0., 0., 6.36942685e-003, 0.,
-       6.36942685e-003, 0., 0., 0., 6.36942685e-003, 0., 0., 0.,
-       6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.27388537e-002, 0., 0., 0., 6.36942685e-003,
-       0., 0., 0., 0., 0., 6.36942685e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.36942685e-003, 0., 6.36942685e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.36942685e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.27388537e-002, 0., 0., 0., 0., 0.,
-       1.27388537e-002, 0., 0., 0., 0., 6.36942685e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.27388537e-002, 6.36942685e-003, 0., 0., 0.,
-       0., 0., 0., 6.36942685e-003, 0., 0., 0., 0., 0., 0.,
-       6.36942685e-003, 0., 0., 6.36942685e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.27388537e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.36942685e-003, 0., 0., 0., 0.,
-       1.27388537e-002, 6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.36942685e-003, 0.,
-       0., 0., 0., 0., 0., 0., 6.36942685e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.36942685e-003, 0., 1.27388537e-002, 0.,
-       6.36942685e-003, 0., 0., 0., 6.36942685e-003, 0., 0., 0.,
-       1.27388537e-002, 0., 1.91082805e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.36942685e-003, 0., 0., 0., 0.,
-       6.36942685e-003, 0., 0., 0., 0., 0., 6.36942685e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.36942685e-003,
-       0., 0., 0., 0., 0., 1.27388537e-002, 0., 0., 0., 0.,
-       6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.36942685e-003, 0., 0., 0., 0., 6.36942685e-003, 0., 0., 0., 0.,
-       0., 1.27388537e-002, 0., 0., 0., 0., 0., 6.36942685e-003,
-       6.36942685e-003, 0., 1.27388537e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.36942685e-003, 0., 6.36942685e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.36942685e-003, 6.36942685e-003, 6.36942685e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.36942685e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.27388537e-002, 0., 6.36942685e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 2.24719103e-002,
-       2.24719103e-002, 5.61797759e-003, 2.80898884e-002,
-       5.61797759e-003, 1.68539323e-002, 0., 0., 5.61797759e-003, 0.,
-       1.12359552e-002, 0., 1.68539323e-002, 0., 1.12359552e-002, 0., 0.,
-       5.61797759e-003, 5.61797759e-003, 5.61797759e-003,
-       5.61797759e-003, 1.12359552e-002, 2.24719103e-002, 0., 0.,
-       5.61797759e-003, 3.37078646e-002, 0., 5.61797759e-003,
-       1.68539323e-002, 5.61797759e-003, 0., 0., 1.12359552e-002,
-       1.12359552e-002, 1.12359552e-002, 0., 5.61797759e-003,
-       3.37078646e-002, 0., 0., 0., 0., 0., 5.61797759e-003,
-       5.61797759e-003, 5.61797759e-003, 0., 5.61797759e-003, 0., 0.,
-       1.68539323e-002, 0., 0., 0., 5.61797759e-003, 0., 0., 0.,
-       1.12359552e-002, 0., 0., 0., 0., 5.61797759e-003, 5.61797759e-003,
-       0., 0., 5.61797759e-003, 0., 5.61797759e-003, 0., 5.61797759e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 1.12359552e-002, 0., 0., 0., 0.,
-       1.68539323e-002, 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0.,
-       0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 5.61797759e-003,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 1.68539323e-002, 0., 0.,
-       5.61797759e-003, 1.12359552e-002, 5.61797759e-003, 0., 0., 0., 0.,
-       5.61797759e-003, 0., 1.68539323e-002, 0., 0., 0., 0.,
-       1.12359552e-002, 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 0., 5.61797759e-003,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       5.61797759e-003, 0., 0., 0., 1.12359552e-002, 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       0., 2.24719103e-002, 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.61797759e-003, 0., 1.12359552e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.12359552e-002, 0.,
-       0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.61797759e-003, 0., 0., 0., 0., 0., 1.68539323e-002,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 0., 5.61797759e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       1.12359552e-002, 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       1.12359552e-002, 0., 0., 0., 0., 0., 5.61797759e-003,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.12359552e-002, 5.61797759e-003, 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       0., 5.61797759e-003, 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 3.37078646e-002, 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 1.12359552e-002, 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.12359552e-002, 0., 0., 5.61797759e-003, 0., 1.68539323e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       5.61797759e-003, 0., 0., 0., 5.61797759e-003, 0., 0., 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.18343197e-002, 5.91715984e-003, 0., 3.55029590e-002,
-       1.18343197e-002, 1.18343197e-002, 0., 0., 1.18343197e-002, 0., 0.,
-       5.91715984e-003, 5.91715984e-003, 1.18343197e-002, 0., 0.,
-       5.91715984e-003, 1.77514795e-002, 5.91715984e-003, 0.,
-       5.91715984e-003, 5.91715984e-003, 1.77514795e-002, 0.,
-       5.91715984e-003, 5.91715984e-003, 5.91715984e-003, 0.,
-       5.91715984e-003, 0., 5.91715984e-003, 0., 0., 1.18343197e-002,
-       5.91715984e-003, 5.91715984e-003, 0., 0., 1.18343197e-002, 0., 0.,
-       5.91715984e-003, 0., 0., 0., 2.36686394e-002, 5.91715984e-003,
-       5.91715984e-003, 1.18343197e-002, 0., 0., 5.91715984e-003, 0., 0.,
-       5.91715984e-003, 1.77514795e-002, 0., 5.91715984e-003, 0., 0., 0.,
-       0., 5.91715984e-003, 0., 0., 0., 0., 0., 5.91715984e-003, 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.18343197e-002, 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0.,
-       5.91715984e-003, 5.91715984e-003, 0., 5.91715984e-003,
-       5.91715984e-003, 0., 0., 0., 1.18343197e-002, 0., 5.91715984e-003,
-       0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.77514795e-002, 0., 0., 5.91715984e-003, 0., 0., 1.18343197e-002,
-       0., 5.91715984e-003, 5.91715984e-003, 0., 0., 0., 0.,
-       3.55029590e-002, 0., 0., 5.91715984e-003, 2.95857992e-002, 0., 0.,
-       0., 0., 5.91715984e-003, 0., 0., 5.91715984e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0.,
-       5.91715984e-003, 5.91715984e-003, 0., 5.91715984e-003, 0., 0., 0.,
-       0., 5.91715984e-003, 0., 1.77514795e-002, 0., 0., 0., 0., 0., 0.,
-       0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0.,
-       1.18343197e-002, 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.18343197e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 5.91715984e-003, 5.91715984e-003, 0.,
-       5.91715984e-003, 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0.,
-       1.77514795e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 2.95857992e-002, 0., 0., 5.91715984e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.18343197e-002, 0., 0., 0., 5.91715984e-003, 0., 5.91715984e-003,
-       0., 0., 0., 0., 0., 0., 0., 1.77514795e-002, 0., 0.,
-       2.36686394e-002, 0., 5.91715984e-003, 0., 0., 0., 5.91715984e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 1.18343197e-002, 0., 0., 5.91715984e-003,
-       0., 0., 0., 5.91715984e-003, 5.91715984e-003, 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.18343197e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.91715984e-003, 1.18343197e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.18343197e-002, 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003,
-       0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.91715984e-003, 0., 0., 5.91715984e-003, 0., 0.,
-       5.91715984e-003, 0., 5.91715984e-003, 0., 1.18343197e-002, 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003,
-       0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.10497242e-002, 0., 5.52486209e-003, 5.52486209e-003, 0., 0., 0.,
-       5.52486209e-003, 1.10497242e-002, 0., 0., 0., 1.10497242e-002,
-       1.10497242e-002, 0., 5.52486209e-003, 0., 5.52486209e-003,
-       1.10497242e-002, 0., 0., 5.52486209e-003, 1.65745858e-002,
-       5.52486209e-003, 0., 0., 5.52486209e-003, 0., 5.52486209e-003,
-       2.20994484e-002, 5.52486209e-003, 0., 0., 0., 1.10497242e-002,
-       1.10497242e-002, 0., 5.52486209e-003, 1.10497242e-002,
-       1.65745858e-002, 0., 0., 0., 5.52486209e-003, 0., 1.10497242e-002,
-       5.52486209e-003, 0., 1.10497242e-002, 1.65745858e-002, 0.,
-       1.10497242e-002, 0., 0., 5.52486209e-003, 1.65745858e-002, 0., 0.,
-       5.52486209e-003, 2.76243109e-002, 5.52486209e-003, 0., 0., 0., 0.,
-       0., 0., 0., 1.10497242e-002, 0., 0., 0., 1.10497242e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0.,
-       0., 0., 5.52486209e-003, 1.65745858e-002, 0., 1.10497242e-002, 0.,
-       0., 0., 0., 0., 5.52486209e-003, 5.52486209e-003, 0., 0.,
-       5.52486209e-003, 5.52486209e-003, 0., 0., 0., 5.52486209e-003,
-       1.10497242e-002, 0., 0., 0., 0., 5.52486209e-003, 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0.,
-       0., 2.20994484e-002, 5.52486209e-003, 0., 5.52486209e-003, 0.,
-       5.52486209e-003, 1.10497242e-002, 0., 1.10497242e-002, 0., 0., 0.,
-       0., 0., 5.52486209e-003, 0., 5.52486209e-003, 0., 0.,
-       5.52486209e-003, 1.10497242e-002, 0., 0., 0., 5.52486209e-003, 0.,
-       0., 0., 0., 1.10497242e-002, 0., 0., 0., 0., 1.10497242e-002,
-       1.10497242e-002, 0., 0., 0., 1.10497242e-002, 0., 0.,
-       1.10497242e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.52486209e-003, 0., 0., 5.52486209e-003, 1.10497242e-002,
-       0., 0., 5.52486209e-003, 0., 5.52486209e-003, 0., 5.52486209e-003,
-       1.10497242e-002, 0., 0., 1.10497242e-002, 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 5.52486209e-003, 0., 0., 0.,
-       5.52486209e-003, 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0.,
-       0., 5.52486209e-003, 0., 0., 5.52486209e-003, 0., 1.65745858e-002,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0.,
-       1.10497242e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 5.52486209e-003, 0., 5.52486209e-003, 0., 0.,
-       0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.10497242e-002, 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0.,
-       5.52486209e-003, 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0.,
-       0., 5.52486209e-003, 0., 0., 0., 0., 5.52486209e-003, 0., 0., 0.,
-       0., 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 5.52486209e-003,
-       5.52486209e-003, 0., 0., 5.52486209e-003, 0., 5.52486209e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0., 0.,
-       1.10497242e-002, 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 5.52486209e-003, 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 5.52486209e-003,
-       1.10497242e-002, 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 5.52486209e-003, 0., 5.52486209e-003, 0., 0.,
-       0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0.,
-       5.52486209e-003, 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 5.52486209e-003, 1.10497242e-002,
-       0., 0., 0., 0., 0., 5.52486209e-003, 0., 5.52486209e-003, 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.92307699e-002, 9.61538497e-003, 0., 9.61538497e-003, 0.,
-       1.92307699e-002, 9.61538497e-003, 0., 1.92307699e-002, 0., 0., 0.,
-       0., 1.92307699e-002, 1.92307699e-002, 1.92307699e-002,
-       9.61538497e-003, 0., 1.92307699e-002, 0., 9.61538497e-003, 0.,
-       1.92307699e-002, 0., 1.92307699e-002, 0., 9.61538497e-003, 0., 0.,
-       9.61538497e-003, 0., 0., 1.92307699e-002, 0., 0., 0.,
-       9.61538497e-003, 9.61538497e-003, 0., 0., 0., 0., 0.,
-       1.92307699e-002, 0., 0., 2.88461559e-002, 0., 0., 9.61538497e-003,
-       0., 9.61538497e-003, 0., 0., 0., 9.61538497e-003, 9.61538497e-003,
-       0., 0., 0., 9.61538497e-003, 0., 9.61538497e-003, 0., 0., 0., 0.,
-       9.61538497e-003, 0., 0., 0., 0., 0., 0., 0., 9.61538497e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.61538497e-003, 0., 0., 0., 0., 1.92307699e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.61538497e-003, 0.,
-       9.61538497e-003, 9.61538497e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 3.84615399e-002, 9.61538497e-003, 0., 9.61538497e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.92307699e-002,
-       9.61538497e-003, 0., 0., 9.61538497e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.61538497e-003, 0., 0., 0., 0., 0., 0.,
-       9.61538497e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.61538497e-003, 0., 0., 0., 0., 0., 0.,
-       9.61538497e-003, 0., 0., 0., 9.61538497e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 4.80769239e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.61538497e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.61538497e-003, 0., 9.61538497e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.92307699e-002, 2.88461559e-002, 9.61538497e-003,
-       0., 0., 0., 9.61538497e-003, 9.61538497e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.61538497e-003, 0., 0., 0.,
-       1.92307699e-002, 0., 0., 0., 9.61538497e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.92307699e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.61538497e-003, 0., 1.92307699e-002, 0., 0.,
-       9.61538497e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.61538497e-003, 0.,
-       0., 0., 0., 9.61538497e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.92307699e-002, 9.61538497e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.61538497e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.61538497e-003, 0., 0., 2.88461559e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.61538497e-003, 0., 0., 0., 0., 0., 0., 9.61538497e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 9.61538497e-003, 0., 0., 0.,
-       9.61538497e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.61538497e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.39860138e-002, 6.99300691e-003, 6.99300691e-003, 0.,
-       6.99300691e-003, 6.99300691e-003, 0., 1.39860138e-002,
-       6.99300691e-003, 0., 6.99300691e-003, 6.99300691e-003,
-       1.39860138e-002, 6.99300691e-003, 0., 0., 0., 1.39860138e-002, 0.,
-       6.99300691e-003, 6.99300691e-003, 0., 6.99300691e-003,
-       6.99300691e-003, 6.99300691e-003, 6.99300691e-003,
-       2.79720277e-002, 0., 0., 2.09790207e-002, 0., 6.99300691e-003, 0.,
-       6.99300691e-003, 0., 6.99300691e-003, 0., 0., 3.49650346e-002, 0.,
-       0., 0., 0., 0., 0., 2.09790207e-002, 1.39860138e-002,
-       6.99300691e-003, 6.99300691e-003, 0., 0., 1.39860138e-002, 0., 0.,
-       0., 0., 0., 0., 0., 1.39860138e-002, 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 6.99300691e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.99300691e-003, 0., 0., 0., 6.99300691e-003,
-       6.99300691e-003, 1.39860138e-002, 0., 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 1.39860138e-002, 0., 0., 0.,
-       6.99300691e-003, 0., 6.99300691e-003, 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 2.79720277e-002, 0., 0., 0., 2.09790207e-002, 0.,
-       0., 6.99300691e-003, 6.99300691e-003, 0., 0., 0., 6.99300691e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.99300691e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.99300691e-003, 0.,
-       6.99300691e-003, 0., 0., 6.99300691e-003, 0., 6.99300691e-003, 0.,
-       0., 6.99300691e-003, 0., 0., 6.99300691e-003, 0., 0., 0.,
-       6.99300691e-003, 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.99300691e-003, 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 6.99300691e-003, 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 6.99300691e-003, 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 2.09790207e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.99300691e-003, 0.,
-       0., 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 0., 6.99300691e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.99300691e-003, 0.,
-       6.99300691e-003, 0., 0., 0., 0., 1.39860138e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.99300691e-003, 0.,
-       0., 1.39860138e-002, 0., 0., 0., 0., 0., 0., 6.99300691e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.39860138e-002, 6.99300691e-003, 0., 0., 1.39860138e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.99300691e-003, 0., 0., 0., 0.,
-       6.99300691e-003, 0., 1.39860138e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.99300691e-003, 0., 2.79720277e-002, 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.99300691e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.39860138e-002, 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 2.09790207e-002, 0.,
-       0., 6.99300691e-003, 0., 0., 0., 0., 1.39860138e-002,
-       6.99300691e-003, 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 2.09790207e-002,
-       0., 0., 0., 0., 0., 0., 6.99300691e-003, 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 6.99300691e-003, 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0.,
-       7.29927002e-003, 7.29927002e-003, 0., 7.29927002e-003, 0.,
-       1.45985400e-002, 0., 7.29927002e-003, 1.45985400e-002, 0.,
-       1.45985400e-002, 7.29927002e-003, 1.45985400e-002,
-       7.29927002e-003, 0., 0., 0., 2.18978096e-002, 0., 2.91970801e-002,
-       7.29927002e-003, 0., 7.29927002e-003, 0., 0., 0., 1.45985400e-002,
-       0., 0., 4.37956192e-002, 0., 7.29927002e-003, 0., 1.45985400e-002,
-       0., 0., 0., 0., 0., 7.29927002e-003, 0., 0., 7.29927002e-003,
-       1.45985400e-002, 0., 7.29927002e-003, 2.18978096e-002,
-       2.18978096e-002, 0., 0., 7.29927002e-003, 0., 0., 0.,
-       1.45985400e-002, 7.29927002e-003, 0., 0., 7.29927002e-003, 0., 0.,
-       0., 7.29927002e-003, 0., 0., 0., 0., 7.29927002e-003,
-       2.91970801e-002, 0., 0., 0., 7.29927002e-003, 0., 0., 0.,
-       7.29927002e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.29927002e-003, 0., 0., 0., 7.29927002e-003, 0., 7.29927002e-003,
-       0., 0., 0., 1.45985400e-002, 1.45985400e-002, 0., 0., 0.,
-       7.29927002e-003, 0., 0., 0., 7.29927002e-003, 0., 0., 0.,
-       1.45985400e-002, 0., 0., 0., 0., 1.45985400e-002, 0., 0., 0., 0.,
-       7.29927002e-003, 0., 0., 0., 7.29927002e-003, 0., 0., 0.,
-       2.91970801e-002, 0., 0., 0., 7.29927002e-003, 0., 0., 0., 0., 0.,
-       0., 7.29927002e-003, 0., 0., 0., 0., 0., 0., 0., 1.45985400e-002,
-       0., 0., 7.29927002e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.45985400e-002, 0., 1.45985400e-002, 0., 2.18978096e-002,
-       0., 0., 0., 0., 7.29927002e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.29927002e-003, 0., 0., 0., 0., 0., 0., 1.45985400e-002, 0.,
-       0., 7.29927002e-003, 0., 0., 7.29927002e-003, 0., 7.29927002e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.29927002e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.29927002e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.29927002e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.29927002e-003, 0., 0., 0., 0.,
-       7.29927002e-003, 0., 0., 1.45985400e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.29927002e-003, 0., 0., 0., 0.,
-       1.45985400e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.29927002e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.45985400e-002, 0., 0., 0., 7.29927002e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.29927002e-003, 0., 0., 0., 0., 0.,
-       1.45985400e-002, 0., 0., 0., 0., 0., 0., 0., 0., 7.29927002e-003,
-       7.29927002e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.29927002e-003, 0., 0., 0., 0., 0., 0., 7.29927002e-003, 0., 0.,
-       0., 0., 0., 7.29927002e-003, 0., 0., 0., 7.29927002e-003,
-       7.29927002e-003, 0., 1.45985400e-002, 0., 7.29927002e-003, 0., 0.,
-       0., 0., 7.29927002e-003, 0., 0., 0., 0., 0., 7.29927002e-003, 0.,
-       0., 7.29927002e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.29927002e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.29927002e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.29927002e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.29927002e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.29927002e-003, 0., 7.29927002e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.29927002e-003, 0., 0., 0., 0., 0., 0., 0., 7.29927002e-003, 0.,
-       0., 0., 7.29927002e-003, 0., 0., 0., 7.29927002e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.29927002e-003, 0., 0., 0., 0.,
-       6.41025649e-003, 6.41025649e-003, 1.92307699e-002,
-       6.41025649e-003, 0., 1.28205130e-002, 0., 0., 0., 6.41025649e-003,
-       1.28205130e-002, 1.28205130e-002, 0., 0., 6.41025649e-003, 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 6.41025649e-003, 0., 0.,
-       6.41025649e-003, 6.41025649e-003, 6.41025649e-003, 0., 0., 0.,
-       6.41025649e-003, 0., 0., 6.41025649e-003, 6.41025649e-003, 0.,
-       6.41025649e-003, 6.41025649e-003, 0., 0., 1.92307699e-002,
-       6.41025649e-003, 6.41025649e-003, 1.28205130e-002,
-       6.41025649e-003, 0., 6.41025649e-003, 0., 0., 6.41025649e-003,
-       1.92307699e-002, 0., 0., 0., 0., 0., 0., 0., 0., 1.28205130e-002,
-       0., 0., 6.41025649e-003, 1.28205130e-002, 0., 1.28205130e-002, 0.,
-       6.41025649e-003, 6.41025649e-003, 0., 6.41025649e-003, 0., 0., 0.,
-       0., 0., 0., 6.41025649e-003, 0., 6.41025649e-003, 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 6.41025649e-003, 0.,
-       6.41025649e-003, 0., 0., 0., 1.28205130e-002, 0., 0., 0.,
-       1.28205130e-002, 6.41025649e-003, 0., 0., 0., 6.41025649e-003,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 6.41025649e-003, 0.,
-       6.41025649e-003, 1.28205130e-002, 0., 0., 0., 6.41025649e-003, 0.,
-       1.92307699e-002, 0., 0., 1.28205130e-002, 3.20512839e-002, 0., 0.,
-       0., 0., 0., 1.28205130e-002, 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 1.92307699e-002, 0., 0., 0.,
-       6.41025649e-003, 6.41025649e-003, 0., 0., 6.41025649e-003, 0.,
-       1.28205130e-002, 0., 1.28205130e-002, 0., 0., 0., 1.28205130e-002,
-       0., 3.20512839e-002, 0., 0., 0., 0., 6.41025649e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 6.41025649e-003,
-       0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 6.41025649e-003, 0.,
-       0., 6.41025649e-003, 0., 0., 0., 0., 6.41025649e-003, 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 6.41025649e-003, 0.,
-       6.41025649e-003, 0., 0., 0., 1.28205130e-002, 6.41025649e-003, 0.,
-       6.41025649e-003, 0., 6.41025649e-003, 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.41025649e-003, 0., 0.,
-       6.41025649e-003, 0., 6.41025649e-003, 0., 6.41025649e-003,
-       1.28205130e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.41025649e-003, 0., 6.41025649e-003, 6.41025649e-003, 0.,
-       1.92307699e-002, 0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.41025649e-003, 0., 6.41025649e-003, 0.,
-       0., 0., 0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.41025649e-003, 0., 6.41025649e-003, 0., 0., 0.,
-       0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 1.28205130e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.28205130e-002, 0., 0., 0., 0., 0., 6.41025649e-003,
-       0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.41025649e-003, 0., 0., 6.41025649e-003,
-       0., 0., 2.56410260e-002, 0., 0., 0., 0., 0., 1.28205130e-002, 0.,
-       0., 0., 0., 1.28205130e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.41025649e-003, 0.,
-       0., 0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 6.41025649e-003, 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.61290318e-002,
-       2.15053763e-002, 0., 5.37634408e-003, 2.68817209e-002, 0.,
-       1.07526882e-002, 1.61290318e-002, 0., 0., 5.37634408e-003,
-       5.37634408e-003, 0., 1.07526882e-002, 0., 0., 0., 0., 0., 0., 0.,
-       1.07526882e-002, 1.07526882e-002, 5.37634408e-003,
-       1.07526882e-002, 5.37634408e-003, 5.37634408e-003, 0.,
-       5.37634408e-003, 0., 5.37634408e-003, 5.37634408e-003,
-       5.37634408e-003, 0., 0., 0., 0., 2.15053763e-002, 0.,
-       5.37634408e-003, 0., 0., 0., 0., 2.15053763e-002, 1.61290318e-002,
-       2.68817209e-002, 0., 0., 0., 0., 0., 0., 0., 2.15053763e-002, 0.,
-       1.07526882e-002, 0., 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.37634408e-003, 0., 5.37634408e-003, 5.37634408e-003,
-       5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.37634408e-003, 0., 5.37634408e-003,
-       1.07526882e-002, 0., 5.37634408e-003, 0., 5.37634408e-003, 0.,
-       5.37634408e-003, 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.07526882e-002, 0., 5.37634408e-003, 5.37634408e-003, 0.,
-       5.37634408e-003, 0., 5.37634408e-003, 5.37634408e-003,
-       5.37634408e-003, 0., 0., 0., 5.37634408e-003, 0., 3.22580636e-002,
-       0., 0., 5.37634408e-003, 1.61290318e-002, 5.37634408e-003, 0.,
-       5.37634408e-003, 0., 1.07526882e-002, 5.37634408e-003, 0.,
-       5.37634408e-003, 0., 0., 0., 0., 0., 5.37634408e-003,
-       5.37634408e-003, 1.07526882e-002, 5.37634408e-003, 0.,
-       2.68817209e-002, 0., 0., 0., 0., 0., 0., 0., 5.37634408e-003, 0.,
-       1.07526882e-002, 0., 0., 0., 0., 5.37634408e-003, 1.61290318e-002,
-       0., 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.37634408e-003, 5.37634408e-003, 5.37634408e-003, 0., 0.,
-       1.07526882e-002, 0., 0., 0., 0., 0., 1.07526882e-002, 0., 0., 0.,
-       0., 0., 1.61290318e-002, 0., 1.07526882e-002, 0., 5.37634408e-003,
-       0., 0., 0., 0., 0., 0., 0., 5.37634408e-003, 1.07526882e-002,
-       5.37634408e-003, 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.37634408e-003, 0., 0., 0., 0., 0., 0.,
-       5.37634408e-003, 0., 5.37634408e-003, 1.07526882e-002, 0., 0., 0.,
-       0., 5.37634408e-003, 5.37634408e-003, 0., 0., 0., 0., 0., 0.,
-       5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.07526882e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.37634408e-003, 0., 5.37634408e-003, 0., 0., 0., 0., 0.,
-       5.37634408e-003, 0., 5.37634408e-003, 0., 5.37634408e-003, 0., 0.,
-       0., 1.07526882e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.37634408e-003, 5.37634408e-003, 0., 5.37634408e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.61290318e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.37634408e-003, 0., 5.37634408e-003, 0.,
-       5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 5.37634408e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.37634408e-003, 0., 0., 0.,
-       5.37634408e-003, 0., 0., 0., 0., 0., 5.37634408e-003,
-       5.37634408e-003, 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.37634408e-003, 0., 1.07526882e-002, 0., 0., 5.37634408e-003, 0.,
-       0., 5.37634408e-003, 0., 0., 0., 0., 0., 1.61290318e-002, 0., 0.,
-       0., 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.37634408e-003, 0., 0., 0., 0., 5.37634408e-003,
-       0., 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.37634408e-003,
-       5.37634408e-003, 0., 0., 0., 5.37634408e-003, 0., 0., 0., 0.,
-       5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.37634408e-003, 0., 0., 0., 0.,
-       5.37634408e-003, 0., 0., 5.37634408e-003, 0., 0., 5.37634408e-003,
-       0., 1.01522841e-002, 0., 2.03045681e-002, 5.07614203e-003, 0.,
-       2.53807101e-002, 0., 5.07614203e-003, 0., 0., 5.07614203e-003,
-       5.07614203e-003, 1.01522841e-002, 5.07614203e-003, 0., 0., 0., 0.,
-       1.01522841e-002, 1.52284261e-002, 5.07614203e-003, 0.,
-       5.07614203e-003, 0., 5.07614203e-003, 5.07614203e-003, 0.,
-       1.01522841e-002, 0., 1.52284261e-002, 0., 0., 0., 1.01522841e-002,
-       0., 0., 5.07614203e-003, 5.07614203e-003, 1.01522841e-002,
-       1.01522841e-002, 5.07614203e-003, 0., 5.07614203e-003, 0., 0.,
-       1.01522841e-002, 5.07614203e-003, 0., 2.03045681e-002,
-       1.52284261e-002, 0., 1.01522841e-002, 0., 5.07614203e-003,
-       5.07614203e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.01522841e-002, 0., 0., 0., 5.07614203e-003, 0., 1.01522841e-002,
-       0., 0., 5.07614203e-003, 0., 0., 0., 0., 0., 5.07614203e-003, 0.,
-       0., 2.03045681e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.07614203e-003, 5.07614203e-003, 0., 5.07614203e-003, 0., 0., 0.,
-       5.07614203e-003, 0., 1.52284261e-002, 0., 5.07614203e-003,
-       5.07614203e-003, 0., 0., 0., 1.01522841e-002, 0., 0., 0., 0., 0.,
-       5.07614203e-003, 0., 0., 0., 5.07614203e-003, 0., 5.07614203e-003,
-       0., 5.07614203e-003, 0., 0., 0., 1.52284261e-002, 0.,
-       5.07614203e-003, 5.07614203e-003, 5.07614203e-003, 0., 0., 0., 0.,
-       0., 5.07614203e-003, 0., 1.52284261e-002, 0., 5.07614203e-003, 0.,
-       0., 5.07614203e-003, 5.07614203e-003, 5.07614203e-003,
-       5.07614203e-003, 0., 0., 5.07614203e-003, 5.07614203e-003, 0.,
-       5.07614203e-003, 0., 0., 0., 5.07614203e-003, 5.07614203e-003, 0.,
-       2.03045681e-002, 5.07614203e-003, 0., 0., 0., 0., 1.52284261e-002,
-       0., 2.53807101e-002, 0., 5.07614203e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.07614203e-003, 0., 1.01522841e-002, 0., 0., 5.07614203e-003, 0.,
-       0., 0., 0., 5.07614203e-003, 0., 0., 1.52284261e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.07614203e-003, 0., 0.,
-       1.01522841e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.07614203e-003, 0., 0., 1.01522841e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.07614203e-003,
-       0., 5.07614203e-003, 0., 5.07614203e-003, 0., 0., 0., 0., 0.,
-       5.07614203e-003, 0., 0., 0., 0., 0., 5.07614203e-003, 0., 0., 0.,
-       0., 0., 0., 5.07614203e-003, 0., 0., 0., 0., 1.01522841e-002, 0.,
-       5.07614203e-003, 2.53807101e-002, 0., 0., 0., 0., 0.,
-       5.07614203e-003, 0., 5.07614203e-003, 0., 0., 0., 0., 0.,
-       5.07614203e-003, 0., 2.03045681e-002, 0., 0., 5.07614203e-003, 0.,
-       0., 0., 0., 0., 0., 1.01522841e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.07614203e-003, 0., 0., 5.07614203e-003, 0., 0., 0.,
-       0., 5.07614203e-003, 0., 0., 0., 5.07614203e-003, 5.07614203e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.07614203e-003, 0.,
-       2.03045681e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.07614203e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.07614203e-003, 0., 0., 0., 0., 0., 0., 0., 5.07614203e-003,
-       5.07614203e-003, 0., 0., 0., 0., 0., 0., 5.07614203e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.07614203e-003, 0., 0., 0.,
-       5.07614203e-003, 0., 0., 0., 0., 0., 5.07614203e-003, 0., 0.,
-       5.07614203e-003, 0., 0., 0., 0., 0., 0., 0., 5.07614203e-003, 0.,
-       0., 0., 5.07614203e-003, 5.07614203e-003, 0., 0., 0., 0., 0., 0.,
-       0., 5.07614203e-003, 0., 0., 0., 0., 0., 0., 5.07614203e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.07614203e-003, 0., 1.01522841e-002, 0., 0., 0., 0.,
-       1.01522841e-002, 0., 0., 0., 0., 5.07614203e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.01522841e-002, 5.07614203e-003, 0., 0.,
-       5.07614203e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.07614203e-003, 0., 0., 0., 0., 0., 5.07614203e-003, 0., 0.,
-       0., 0., 0., 0., 5.07614203e-003, 5.07614203e-003, 0.,
-       5.07614203e-003, 0., 5.07614203e-003, 0., 5.07614203e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.07614203e-003, 0., 0., 0., 0., 0., 5.07614203e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 2.13903747e-002, 0., 0.,
-       5.34759369e-003, 5.34759369e-003, 1.06951874e-002,
-       5.34759369e-003, 5.34759369e-003, 1.06951874e-002,
-       5.34759369e-003, 5.34759369e-003, 0., 0., 1.06951874e-002, 0.,
-       5.34759369e-003, 0., 5.34759369e-003, 0., 0., 0., 0.,
-       5.34759369e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.60427801e-002, 5.34759369e-003, 5.34759369e-003, 0., 0., 0., 0.,
-       2.13903747e-002, 2.13903747e-002, 0., 3.20855603e-002, 0., 0., 0.,
-       5.34759369e-003, 1.06951874e-002, 0., 1.60427801e-002,
-       5.34759369e-003, 5.34759369e-003, 0., 0., 0., 0., 1.06951874e-002,
-       1.06951874e-002, 0., 0., 0., 0., 0., 0., 0., 0., 1.60427801e-002,
-       5.34759369e-003, 0., 0., 0., 0., 5.34759369e-003, 0., 0., 0., 0.,
-       5.34759369e-003, 0., 0., 0., 5.34759369e-003, 0., 0., 0., 0.,
-       5.34759369e-003, 5.34759369e-003, 0., 5.34759369e-003, 0., 0., 0.,
-       0., 1.06951874e-002, 0., 0., 0., 1.06951874e-002, 0., 0., 0.,
-       5.34759369e-003, 0., 0., 5.34759369e-003, 5.34759369e-003,
-       5.34759369e-003, 0., 0., 5.34759369e-003, 1.06951874e-002,
-       5.34759369e-003, 5.34759369e-003, 0., 5.34759369e-003, 0., 0., 0.,
-       5.34759369e-003, 1.60427801e-002, 5.34759369e-003,
-       5.34759369e-003, 0., 2.13903747e-002, 0., 0., 0., 0., 0., 0., 0.,
-       5.34759369e-003, 0., 0., 0., 0., 1.06951874e-002, 5.34759369e-003,
-       0., 0., 0., 0., 1.60427801e-002, 0., 0., 0., 5.34759369e-003, 0.,
-       0., 0., 0., 0., 2.13903747e-002, 0., 0., 0., 0., 1.06951874e-002,
-       2.13903747e-002, 0., 5.88235296e-002, 0., 0., 0., 0.,
-       5.34759369e-003, 0., 0., 0., 0., 0., 5.34759369e-003, 0.,
-       5.34759369e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.34759369e-003, 0., 0., 5.34759369e-003, 0., 5.34759369e-003,
-       0., 0., 0., 0., 0., 0., 5.34759369e-003, 5.34759369e-003,
-       5.34759369e-003, 0., 0., 0., 0., 0., 0., 5.34759369e-003, 0.,
-       5.34759369e-003, 5.34759369e-003, 0., 0., 0., 5.34759369e-003, 0.,
-       0., 1.06951874e-002, 0., 0., 0., 5.34759369e-003, 0., 0., 0.,
-       5.34759369e-003, 1.60427801e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.06951874e-002, 0., 0., 0., 0., 0., 0.,
-       0., 5.34759369e-003, 0., 5.34759369e-003, 0., 0., 0., 0., 0., 0.,
-       0., 2.13903747e-002, 0., 0., 0., 0., 0., 5.34759369e-003, 0., 0.,
-       5.34759369e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.34759369e-003,
-       5.34759369e-003, 0., 0., 0., 0., 0., 5.34759369e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.34759369e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.34759369e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.34759369e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.06951874e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.34759369e-003, 0., 0.,
-       5.34759369e-003, 0., 0., 0., 0., 0., 0., 5.34759369e-003,
-       5.34759369e-003, 1.60427801e-002, 0., 0., 0., 0., 5.34759369e-003,
-       0., 0., 0., 0., 0., 0., 0., 5.34759369e-003, 5.34759369e-003, 0.,
-       1.06951874e-002, 0., 0., 0., 0., 1.06951874e-002, 0.,
-       5.34759369e-003, 5.34759369e-003, 0., 5.34759369e-003, 0.,
-       5.34759369e-003, 5.34759369e-003, 0., 0., 0., 5.34759369e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.34759369e-003,
-       5.34759369e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.34759369e-003, 0., 0., 0., 0., 1.06951874e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.34759369e-003, 0., 0., 0.,
-       5.34759369e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.34759369e-003, 0., 1.06951874e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.34759369e-003, 0., 0., 0.,
-       5.34759369e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.34759369e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.34759369e-003, 0., 0.,
-       5.34759369e-003, 0., 0., 0., 0., 5.34759369e-003, 0., 0., 0., 0.,
-       0., 0., 0., 6.62251655e-003, 6.62251655e-003, 6.62251655e-003, 0.,
-       1.32450331e-002, 0., 0., 6.62251655e-003, 6.62251655e-003, 0.,
-       6.62251655e-003, 0., 1.98675506e-002, 6.62251655e-003,
-       6.62251655e-003, 0., 6.62251655e-003, 1.98675506e-002,
-       6.62251655e-003, 6.62251655e-003, 0., 0., 6.62251655e-003, 0., 0.,
-       0., 3.31125818e-002, 0., 6.62251655e-003, 1.32450331e-002, 0.,
-       1.32450331e-002, 6.62251655e-003, 0., 0., 0., 0., 0., 0.,
-       1.98675506e-002, 0., 0., 0., 0., 0., 0., 0., 1.32450331e-002,
-       3.97351012e-002, 0., 6.62251655e-003, 6.62251655e-003, 0., 0., 0.,
-       1.98675506e-002, 0., 0., 0., 0., 0., 0., 6.62251655e-003, 0., 0.,
-       0., 0., 0., 0., 0., 1.32450331e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 2.64900662e-002, 0., 0., 0., 0., 0., 0.,
-       6.62251655e-003, 0., 0., 1.98675506e-002, 0., 6.62251655e-003,
-       1.98675506e-002, 0., 0., 0., 0., 0., 0., 6.62251655e-003,
-       6.62251655e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.62251655e-003, 0., 6.62251655e-003, 0., 1.32450331e-002,
-       0., 0., 0., 1.32450331e-002, 0., 0., 6.62251655e-003,
-       6.62251655e-003, 0., 0., 6.62251655e-003, 0., 0., 0., 0.,
-       1.98675506e-002, 0., 0., 0., 0., 0., 0., 1.32450331e-002, 0., 0.,
-       0., 2.64900662e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.62251655e-003, 0., 0., 0., 0., 0., 3.31125818e-002, 0.,
-       6.62251655e-003, 0., 0., 0., 0., 6.62251655e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.62251655e-003,
-       6.62251655e-003, 0., 0., 0., 6.62251655e-003, 0., 0., 0., 0., 0.,
-       1.32450331e-002, 0., 0., 0., 0., 0., 0., 1.32450331e-002, 0., 0.,
-       0., 6.62251655e-003, 0., 6.62251655e-003, 0., 0., 0., 0., 0., 0.,
-       6.62251655e-003, 0., 0., 0., 0., 0., 0., 0., 1.32450331e-002, 0.,
-       0., 0., 0., 0., 0., 0., 6.62251655e-003, 1.32450331e-002, 0.,
-       6.62251655e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.62251655e-003, 6.62251655e-003, 0., 6.62251655e-003, 0., 0., 0.,
-       0., 0., 0., 6.62251655e-003, 0., 0., 0., 0., 6.62251655e-003, 0.,
-       6.62251655e-003, 1.98675506e-002, 0., 6.62251655e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.62251655e-003, 0., 0., 0.,
-       1.32450331e-002, 0., 0., 0., 0., 0., 6.62251655e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.62251655e-003, 0., 0., 0., 0.,
-       0., 0., 0., 6.62251655e-003, 0., 0., 0., 6.62251655e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.62251655e-003, 0., 0., 0.,
-       6.62251655e-003, 0., 6.62251655e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.62251655e-003, 6.62251655e-003, 0., 0., 6.62251655e-003,
-       0., 0., 0., 0., 0., 0., 6.62251655e-003, 0., 0., 0., 0., 0., 0.,
-       0., 1.98675506e-002, 0., 0., 0., 0., 0., 1.32450331e-002, 0., 0.,
-       0., 0., 0., 0., 6.62251655e-003, 0., 6.62251655e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.62251655e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.62251655e-003, 0., 0., 0., 0., 1.32450331e-002, 0., 0.,
-       1.98675506e-002, 0., 0., 0., 6.62251655e-003, 0., 0., 0.,
-       6.62251655e-003, 0., 6.62251655e-003, 0., 0., 6.62251655e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.62251655e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.62251655e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.62251655e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.42857144e-002, 2.14285720e-002, 7.14285718e-003,
-       3.57142873e-002, 0., 0., 7.14285718e-003, 7.14285718e-003, 0., 0.,
-       7.14285718e-003, 7.14285718e-003, 0., 7.14285718e-003,
-       7.14285718e-003, 1.42857144e-002, 7.14285718e-003,
-       2.85714287e-002, 0., 0., 7.14285718e-003, 0., 0., 0.,
-       2.85714287e-002, 0., 4.28571440e-002, 7.14285718e-003, 0., 0., 0.,
-       7.14285718e-003, 0., 0., 0., 0., 5.71428575e-002, 7.14285718e-003,
-       0., 0., 7.14285718e-003, 1.42857144e-002, 7.14285718e-003,
-       7.14285718e-003, 7.14285718e-003, 7.14285718e-003,
-       5.71428575e-002, 0., 0., 0., 7.14285718e-003, 7.14285718e-003, 0.,
-       7.14285718e-003, 0., 0., 7.14285718e-003, 0., 0., 0., 0.,
-       7.14285718e-003, 7.14285718e-003, 0., 0., 7.14285718e-003,
-       7.14285718e-003, 7.14285718e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.42857144e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.14285718e-003, 7.14285718e-003,
-       0., 0., 7.14285718e-003, 0., 0., 0., 0., 0., 7.14285718e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.42857144e-002, 0., 0.,
-       7.14285718e-003, 0., 0., 0., 4.28571440e-002, 0., 7.14285718e-003,
-       7.14285718e-003, 2.14285720e-002, 0., 0., 0., 7.14285718e-003, 0.,
-       0., 0., 7.14285718e-003, 0., 0., 0., 0., 7.14285718e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.14285718e-003, 0., 0., 0., 7.14285718e-003, 7.14285718e-003,
-       1.42857144e-002, 0., 0., 0., 0., 7.14285718e-003, 0., 0., 0.,
-       7.14285718e-003, 0., 0., 0., 0., 7.14285718e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.14285718e-003, 0., 7.14285718e-003, 0.,
-       0., 0., 7.14285718e-003, 0., 0., 0., 0., 7.14285718e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.42857144e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.85714287e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.42857144e-002, 0., 0., 0., 7.14285718e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.14285718e-003, 0., 0., 0.,
-       1.42857144e-002, 0., 0., 0., 0., 7.14285718e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.14285718e-003, 0., 0., 0., 0.,
-       0., 0., 7.14285718e-003, 7.14285718e-003, 0., 0., 0., 0.,
-       7.14285718e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.14285718e-003, 0., 7.14285718e-003,
-       0., 1.42857144e-002, 0., 0., 0., 7.14285718e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.14285718e-003, 0., 0., 0.,
-       0., 0., 0., 7.14285718e-003, 0., 7.14285718e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.14285718e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.14285718e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.14285718e-003,
-       7.14285718e-003, 0., 7.14285718e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.14285718e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.14285718e-003,
-       0., 7.14285718e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.14285718e-003,
-       0., 0., 0., 0., 7.14285718e-003, 0., 0., 0., 0., 0.,
-       2.34375000e-002, 7.81250000e-003, 0., 7.81250000e-003,
-       7.81250000e-003, 1.56250000e-002, 0., 1.56250000e-002,
-       7.81250000e-003, 0., 7.81250000e-003, 7.81250000e-003, 0.,
-       2.34375000e-002, 0., 7.81250000e-003, 0., 0., 1.56250000e-002,
-       7.81250000e-003, 0., 0., 0., 0., 7.81250000e-003, 0.,
-       7.81250000e-003, 0., 7.81250000e-003, 7.81250000e-003, 0.,
-       7.81250000e-003, 0., 7.81250000e-003, 0., 0., 0., 0.,
-       1.56250000e-002, 0., 0., 0., 7.81250000e-003, 0., 0., 0.,
-       2.34375000e-002, 7.81250000e-003, 1.56250000e-002, 0.,
-       7.81250000e-003, 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.81250000e-003, 7.81250000e-003, 0., 0., 0., 0.,
-       7.81250000e-003, 7.81250000e-003, 0., 0., 7.81250000e-003, 0., 0.,
-       0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.81250000e-003, 2.34375000e-002, 0., 0.,
-       0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.81250000e-003, 7.81250000e-003, 0., 0.,
-       0., 7.81250000e-003, 0., 0., 7.81250000e-003, 3.90625000e-002, 0.,
-       0., 0., 2.34375000e-002, 1.56250000e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 7.81250000e-003,
-       7.81250000e-003, 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0.,
-       0., 7.81250000e-003, 0., 7.81250000e-003, 0., 7.81250000e-003,
-       7.81250000e-003, 0., 0., 0., 0., 7.81250000e-003, 7.81250000e-003,
-       0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 7.81250000e-003, 0.,
-       0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 7.81250000e-003, 0.,
-       0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.56250000e-002, 7.81250000e-003, 0., 0., 0., 7.81250000e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0.,
-       1.56250000e-002, 0., 1.56250000e-002, 7.81250000e-003, 0., 0., 0.,
-       7.81250000e-003, 0., 7.81250000e-003, 0., 0., 0., 7.81250000e-003,
-       0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 7.81250000e-003,
-       0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0.,
-       7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.56250000e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 2.34375000e-002, 0., 7.81250000e-003, 0., 0., 0.,
-       7.81250000e-003, 0., 0., 0., 1.56250000e-002, 0., 7.81250000e-003,
-       0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.56250000e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.81250000e-003,
-       7.81250000e-003, 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0.,
-       7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 7.81250000e-003,
-       0., 0., 7.81250000e-003, 0., 0., 0., 0., 7.81250000e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.56250000e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 7.81250000e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.81250000e-003, 7.81250000e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0.,
-       0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0.,
-       0., 7.81250000e-003, 0., 0., 0., 7.81250000e-003, 0.,
-       5.15463902e-003, 5.15463902e-003, 0., 1.54639166e-002, 0.,
-       3.60824727e-002, 0., 0., 1.03092780e-002, 5.15463902e-003,
-       1.03092780e-002, 0., 0., 1.54639166e-002, 5.15463902e-003,
-       5.15463902e-003, 0., 5.15463902e-003, 5.15463902e-003,
-       2.06185561e-002, 0., 5.15463902e-003, 1.54639166e-002, 0., 0.,
-       5.15463902e-003, 1.03092780e-002, 0., 5.15463902e-003,
-       1.54639166e-002, 5.15463902e-003, 5.15463902e-003,
-       5.15463902e-003, 5.15463902e-003, 1.03092780e-002, 0.,
-       5.15463902e-003, 0., 2.57731955e-002, 5.15463902e-003, 0., 0., 0.,
-       1.03092780e-002, 5.15463902e-003, 5.15463902e-003, 0.,
-       5.15463902e-003, 2.06185561e-002, 0., 0., 0., 0., 0., 0.,
-       1.03092780e-002, 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003,
-       2.06185561e-002, 0., 0., 0., 0., 0., 5.15463902e-003, 0.,
-       1.03092780e-002, 0., 0., 0., 0., 5.15463902e-003, 1.03092780e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0.,
-       5.15463902e-003, 0., 5.15463902e-003, 5.15463902e-003,
-       5.15463902e-003, 0., 0., 5.15463902e-003, 0., 1.03092780e-002, 0.,
-       0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 5.15463902e-003, 0.,
-       0., 0., 0., 5.15463902e-003, 3.09278332e-002, 2.06185561e-002,
-       5.15463902e-003, 1.03092780e-002, 0., 0., 0., 0., 0.,
-       2.57731955e-002, 0., 0., 0., 4.12371121e-002, 0., 0., 0., 0.,
-       1.03092780e-002, 0., 0., 0., 0., 0., 1.03092780e-002, 0., 0., 0.,
-       0., 5.15463902e-003, 0., 0., 5.15463902e-003, 0., 0., 0.,
-       5.15463902e-003, 0., 0., 0., 5.15463902e-003, 0., 1.03092780e-002,
-       0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 0., 5.15463902e-003, 5.15463902e-003, 0.,
-       0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.03092780e-002, 0., 5.15463902e-003, 5.15463902e-003, 0., 0., 0.,
-       0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 5.15463902e-003, 0.,
-       1.03092780e-002, 0., 0., 5.15463902e-003, 5.15463902e-003,
-       5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 5.15463902e-003, 5.15463902e-003, 0., 0.,
-       0., 5.15463902e-003, 0., 0., 5.15463902e-003, 1.03092780e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003,
-       5.15463902e-003, 5.15463902e-003, 0., 5.15463902e-003,
-       1.54639166e-002, 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.03092780e-002, 0.,
-       5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.15463902e-003, 0., 1.03092780e-002, 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 2.06185561e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0.,
-       1.03092780e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.54639166e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0.,
-       0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 5.15463902e-003, 0., 5.15463902e-003, 0.,
-       5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003,
-       0., 0., 1.03092780e-002, 0., 5.15463902e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 1.03092780e-002, 0., 0., 0., 0., 5.15463902e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0.,
-       0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003,
-       0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.24637695e-003, 7.24637695e-003, 1.44927539e-002,
-       1.44927539e-002, 0., 7.24637695e-003, 0., 0., 1.44927539e-002, 0.,
-       7.24637695e-003, 0., 1.44927539e-002, 1.44927539e-002, 0., 0., 0.,
-       7.24637695e-003, 7.24637695e-003, 1.44927539e-002, 0., 0.,
-       2.17391308e-002, 0., 0., 0., 3.62318829e-002, 7.24637695e-003,
-       7.24637695e-003, 5.07246405e-002, 7.24637695e-003,
-       1.44927539e-002, 0., 1.44927539e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.24637695e-003, 0., 2.17391308e-002, 0., 0.,
-       0., 7.24637695e-003, 0., 0., 7.24637695e-003, 0., 7.24637695e-003,
-       0., 0., 0., 0., 0., 7.24637695e-003, 0., 7.24637695e-003, 0., 0.,
-       7.24637695e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.24637695e-003, 0., 0., 0., 7.24637695e-003, 1.44927539e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.24637695e-003, 0., 0., 0.,
-       7.24637695e-003, 3.62318829e-002, 2.17391308e-002, 0.,
-       7.24637695e-003, 0., 0., 7.24637695e-003, 0., 7.24637695e-003,
-       1.44927539e-002, 0., 0., 0., 6.52173907e-002, 7.24637695e-003, 0.,
-       0., 1.44927539e-002, 7.24637695e-003, 0., 0., 0., 0., 0., 0., 0.,
-       7.24637695e-003, 0., 0., 0., 0., 0., 1.44927539e-002, 0., 0., 0.,
-       0., 0., 0., 0., 7.24637695e-003, 0., 0., 0., 7.24637695e-003,
-       7.24637695e-003, 0., 0., 1.44927539e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.44927539e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.24637695e-003, 7.24637695e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.24637695e-003,
-       0., 1.44927539e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.44927539e-002, 0., 0., 0., 0., 0., 1.44927539e-002, 0., 0., 0.,
-       0., 0., 0., 0., 7.24637695e-003, 0., 0., 0., 0., 0., 0.,
-       1.44927539e-002, 0., 7.24637695e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.24637695e-003, 2.17391308e-002, 0., 0., 7.24637695e-003, 0.,
-       0., 2.17391308e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.24637695e-003, 7.24637695e-003,
-       7.24637695e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.44927539e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.24637695e-003, 0.,
-       0., 0., 0., 0., 7.24637695e-003, 7.24637695e-003, 7.24637695e-003,
-       0., 2.17391308e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.44927539e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.24637695e-003,
-       7.24637695e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.24637695e-003, 0., 0., 0., 0., 0., 0., 7.24637695e-003, 0., 0.,
-       7.24637695e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.44927539e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.24637695e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.24637695e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.24637695e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.24637695e-003, 0., 0., 0., 5.78034669e-003, 2.31213868e-002, 0.,
-       2.31213868e-002, 0., 1.73410401e-002, 5.78034669e-003,
-       5.78034669e-003, 5.78034669e-003, 0., 0., 1.15606934e-002, 0., 0.,
-       5.78034669e-003, 1.15606934e-002, 0., 1.15606934e-002, 0., 0.,
-       5.78034669e-003, 0., 0., 0., 1.15606934e-002, 0., 5.78034669e-003,
-       1.73410401e-002, 0., 1.15606934e-002, 0., 0., 0., 5.78034669e-003,
-       0., 0., 2.31213868e-002, 5.78034669e-003, 0., 0., 0., 0., 0.,
-       5.78034669e-003, 5.78034669e-003, 0., 1.15606934e-002, 0., 0.,
-       5.78034669e-003, 0., 0., 0., 1.73410401e-002, 0., 0., 0.,
-       2.31213868e-002, 0., 0., 5.78034669e-003, 0., 0., 5.78034669e-003,
-       0., 0., 0., 5.78034669e-003, 2.31213868e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0.,
-       0., 5.78034669e-003, 5.78034669e-003, 0., 0., 0., 0.,
-       1.15606934e-002, 0., 5.78034669e-003, 5.78034669e-003, 0., 0., 0.,
-       0., 5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003,
-       0., 0., 0., 5.78034669e-003, 1.15606934e-002, 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 5.78034669e-003, 4.62427735e-002, 0.,
-       0., 5.78034669e-003, 2.31213868e-002, 5.78034669e-003, 0., 0., 0.,
-       1.15606934e-002, 1.15606934e-002, 0., 0., 5.78034669e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003,
-       5.78034669e-003, 5.78034669e-003, 0., 1.73410401e-002, 0.,
-       1.15606934e-002, 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.78034669e-003, 0., 0., 0., 0., 5.78034669e-003, 0.,
-       0., 0., 0., 0., 0., 1.15606934e-002, 0., 1.15606934e-002, 0., 0.,
-       0., 0., 5.78034669e-003, 0., 0., 0., 5.78034669e-003, 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.20231202e-002, 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.78034669e-003, 0., 0., 5.78034669e-003, 0., 0., 0.,
-       0., 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 2.89017335e-002, 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0.,
-       0., 1.15606934e-002, 0., 1.15606934e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.15606934e-002, 0., 0., 0., 0., 5.78034669e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.78034669e-003, 0., 0., 0., 5.78034669e-003,
-       5.78034669e-003, 0., 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.78034669e-003, 5.78034669e-003,
-       1.15606934e-002, 0., 0., 5.78034669e-003, 0., 0., 5.78034669e-003,
-       0., 0., 0., 5.78034669e-003, 0., 5.78034669e-003, 0., 0., 0., 0.,
-       1.15606934e-002, 0., 0., 0., 0., 5.78034669e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.78034669e-003, 0., 0., 5.78034669e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0.,
-       1.15606934e-002, 0., 0., 5.78034669e-003, 0., 0., 0.,
-       1.73410401e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.78034669e-003, 0., 0., 5.78034669e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.78034669e-003, 0., 0., 0., 5.78034669e-003, 5.78034669e-003,
-       0., 0., 0., 0., 0., 0., 7.57575780e-003, 7.57575780e-003, 0.,
-       1.51515156e-002, 7.57575780e-003, 0., 2.27272734e-002, 0., 0.,
-       1.51515156e-002, 0., 0., 0., 2.27272734e-002, 0., 0., 0., 0.,
-       7.57575780e-003, 0., 0., 7.57575780e-003, 7.57575780e-003, 0., 0.,
-       2.27272734e-002, 0., 1.51515156e-002, 1.51515156e-002, 0., 0., 0.,
-       7.57575780e-003, 0., 0., 0., 7.57575780e-003, 0., 7.57575780e-003,
-       0., 0., 7.57575780e-003, 1.51515156e-002, 0., 0., 7.57575780e-003,
-       1.51515156e-002, 3.03030312e-002, 0., 0., 7.57575780e-003,
-       7.57575780e-003, 0., 0., 0., 0., 7.57575780e-003, 0.,
-       3.78787890e-002, 0., 0., 7.57575780e-003, 7.57575780e-003,
-       7.57575780e-003, 0., 0., 0., 2.27272734e-002, 0., 1.51515156e-002,
-       0., 0., 0., 0., 0., 0., 0., 7.57575780e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.57575780e-003, 0., 0.,
-       1.51515156e-002, 0., 0., 7.57575780e-003, 0., 7.57575780e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.51515156e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       4.54545468e-002, 0., 7.57575780e-003, 0., 3.03030312e-002, 0., 0.,
-       0., 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.57575780e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.57575780e-003, 0., 0., 0.,
-       1.51515156e-002, 0., 0., 0., 0., 0., 0., 0., 0., 7.57575780e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.57575780e-003, 0., 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0.,
-       1.51515156e-002, 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.57575780e-003, 0., 7.57575780e-003,
-       0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       4.54545468e-002, 0., 0., 0., 0., 7.57575780e-003, 0., 0., 0.,
-       7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.51515156e-002, 0., 0., 7.57575780e-003, 0., 0., 0.,
-       7.57575780e-003, 0., 0., 0., 0., 0., 7.57575780e-003, 0., 0., 0.,
-       0., 0., 7.57575780e-003, 0., 0., 0., 0., 0., 1.51515156e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.57575780e-003, 0., 0., 7.57575780e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.51515156e-002, 0., 0., 0., 0., 0.,
-       1.51515156e-002, 0., 0., 0., 0., 0., 7.57575780e-003,
-       7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 7.57575780e-003, 0.,
-       0., 0., 7.57575780e-003, 0., 0., 7.57575780e-003, 7.57575780e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.51515156e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.57575780e-003, 0.,
-       7.57575780e-003, 0., 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0.,
-       0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.51515156e-002, 0., 0., 0., 0., 0., 0., 0., 0., 7.57575780e-003,
-       0., 7.57575780e-003, 0., 0., 7.57575780e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.57575780e-003, 7.57575780e-003, 0.,
-       7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.57575780e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.40845068e-002, 1.40845068e-002, 7.04225339e-003,
-       2.11267602e-002, 0., 0., 7.04225339e-003, 0., 7.04225339e-003, 0.,
-       7.04225339e-003, 0., 7.04225339e-003, 0., 0., 0., 1.40845068e-002,
-       7.04225339e-003, 0., 7.04225339e-003, 7.04225339e-003, 0., 0., 0.,
-       1.40845068e-002, 7.04225339e-003, 7.04225339e-003,
-       1.40845068e-002, 0., 1.40845068e-002, 0., 7.04225339e-003, 0., 0.,
-       0., 0., 2.11267602e-002, 7.04225339e-003, 0., 0., 0., 0.,
-       7.04225339e-003, 0., 7.04225339e-003, 2.11267602e-002,
-       7.04225339e-003, 0., 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0.,
-       7.04225339e-003, 0., 0., 0., 1.40845068e-002, 0., 2.11267602e-002,
-       7.04225339e-003, 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0.,
-       0., 7.04225339e-003, 0., 7.04225339e-003, 0., 0., 0., 0., 0.,
-       7.04225339e-003, 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0., 0.,
-       7.04225339e-003, 7.04225339e-003, 7.04225339e-003, 0., 0., 0.,
-       7.04225339e-003, 0., 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003,
-       0., 7.04225339e-003, 0., 0., 0., 0., 0., 7.04225339e-003, 0., 0.,
-       7.04225339e-003, 0., 0., 0., 0., 0., 1.40845068e-002, 0., 0., 0.,
-       1.40845068e-002, 7.04225339e-003, 0., 7.04225339e-003,
-       7.04225339e-003, 1.40845068e-002, 7.04225339e-003, 0.,
-       1.40845068e-002, 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0.,
-       0., 7.04225339e-003, 7.04225339e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.04225339e-003, 0., 0., 7.04225339e-003, 0., 0.,
-       1.40845068e-002, 0., 0., 0., 0., 7.04225339e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.40845068e-002, 0.,
-       0., 0., 7.04225339e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.04225339e-003, 7.04225339e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 2.81690136e-002, 7.04225339e-003, 0.,
-       0., 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.40845068e-002, 0., 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003,
-       7.04225339e-003, 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0., 0.,
-       7.04225339e-003, 0., 0., 0., 0., 1.40845068e-002, 0., 0., 0., 0.,
-       7.04225339e-003, 0., 0., 0., 0., 2.11267602e-002, 0.,
-       7.04225339e-003, 0., 7.04225339e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.40845068e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.04225339e-003, 0., 7.04225339e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0.,
-       7.04225339e-003, 0., 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0.,
-       2.11267602e-002, 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0., 0.,
-       0., 0., 0., 0., 1.40845068e-002, 7.04225339e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0., 0., 0.,
-       7.04225339e-003, 7.04225339e-003, 0., 0., 7.04225339e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.04225339e-003, 0., 0., 0., 0., 0., 7.04225339e-003, 0., 0., 0.,
-       0., 0., 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0., 0., 0.,
-       7.04225339e-003, 0., 7.04225339e-003, 0., 0., 0., 2.11267602e-002,
-       0., 0., 0., 7.04225339e-003, 0., 0., 0., 7.04225339e-003, 0., 0.,
-       0., 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0., 0.,
-       7.04225339e-003, 0., 7.04225339e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 7.04225339e-003, 7.04225339e-003, 0., 0., 0.,
-       7.04225339e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.40845068e-002, 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.45161280e-003, 2.58064512e-002, 0., 1.93548389e-002,
-       1.93548389e-002, 0., 0., 0., 0., 6.45161280e-003, 0., 0.,
-       1.29032256e-002, 6.45161280e-003, 6.45161280e-003,
-       1.29032256e-002, 6.45161280e-003, 6.45161280e-003,
-       1.93548389e-002, 0., 0., 1.29032256e-002, 0., 6.45161280e-003, 0.,
-       1.29032256e-002, 0., 0., 1.93548389e-002, 1.93548389e-002,
-       6.45161280e-003, 0., 0., 0., 0., 0., 0., 6.45161280e-003, 0., 0.,
-       0., 6.45161280e-003, 0., 6.45161280e-003, 6.45161280e-003,
-       1.93548389e-002, 6.45161280e-003, 1.29032256e-002, 0., 0.,
-       6.45161280e-003, 0., 0., 0., 6.45161280e-003, 0., 0., 0., 0., 0.,
-       0., 6.45161280e-003, 6.45161280e-003, 0., 0., 0., 0.,
-       1.93548389e-002, 0., 6.45161280e-003, 0., 0., 6.45161280e-003, 0.,
-       0., 0., 0., 1.29032256e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.45161280e-003, 6.45161280e-003, 0., 0.,
-       0., 0., 6.45161280e-003, 6.45161280e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.45161280e-003, 0.,
-       6.45161280e-003, 0., 0., 6.45161280e-003, 0., 0., 0., 0.,
-       1.29032256e-002, 0., 0., 0., 2.58064512e-002, 6.45161280e-003, 0.,
-       0., 0., 0., 0., 0., 1.93548389e-002, 0., 0., 0., 0.,
-       6.45161280e-003, 0., 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.45161280e-003, 0., 0., 1.29032256e-002,
-       6.45161280e-003, 6.45161280e-003, 0., 0., 2.58064512e-002, 0.,
-       1.29032256e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.29032256e-002,
-       0., 0., 0., 0., 0., 0., 0., 6.45161280e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.29032256e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.45161280e-003, 0., 0., 6.45161280e-003, 0., 0.,
-       0., 2.58064512e-002, 0., 0., 1.29032256e-002, 0., 0.,
-       1.29032256e-002, 0., 1.29032256e-002, 0., 6.45161280e-003,
-       1.93548389e-002, 0., 0., 0., 6.45161280e-003, 0., 6.45161280e-003,
-       0., 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0., 3.22580636e-002,
-       0., 0., 1.93548389e-002, 0., 0., 0., 0., 0., 6.45161280e-003,
-       6.45161280e-003, 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.45161280e-003, 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.45161280e-003, 0., 0., 0., 0., 0., 1.29032256e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.45161280e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.29032256e-002, 0., 0., 0., 0., 0.,
-       6.45161280e-003, 6.45161280e-003, 0., 6.45161280e-003, 0., 0.,
-       6.45161280e-003, 0., 0., 6.45161280e-003, 0., 6.45161280e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.45161280e-003, 0., 0.,
-       6.45161280e-003, 0., 0., 0., 0., 0., 6.45161280e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.45161280e-003, 0., 0., 0., 0., 0., 0., 0., 0., 1.29032256e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.45161280e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.45161280e-003, 0.,
-       0., 0., 0., 0., 6.45161280e-003, 6.45161280e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.45161280e-003, 0., 0., 0., 0., 6.45161280e-003, 0., 0., 0., 0.,
-       6.45161280e-003, 0., 6.45161280e-003, 0., 0., 6.45161280e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.65289249e-002, 0., 2.47933865e-002,
-       8.26446246e-003, 4.13223132e-002, 0., 8.26446246e-003,
-       8.26446246e-003, 8.26446246e-003, 0., 0., 1.65289249e-002,
-       2.47933865e-002, 0., 8.26446246e-003, 8.26446246e-003,
-       1.65289249e-002, 8.26446246e-003, 0., 0., 0., 8.26446246e-003, 0.,
-       0., 0., 0., 0., 0., 1.65289249e-002, 0., 0., 0., 1.65289249e-002,
-       0., 0., 0., 0., 8.26446246e-003, 8.26446246e-003, 0., 0., 0., 0.,
-       0., 8.26446246e-003, 8.26446246e-003, 0., 2.47933865e-002, 0., 0.,
-       8.26446246e-003, 0., 0., 0., 8.26446246e-003, 0., 1.65289249e-002,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.26446246e-003, 0., 8.26446246e-003, 0., 0., 1.65289249e-002, 0.,
-       0., 0., 8.26446246e-003, 0., 0., 0., 0., 0., 8.26446246e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.26446246e-003, 1.65289249e-002, 8.26446246e-003,
-       0., 0., 8.26446246e-003, 8.26446246e-003, 0., 0., 0.,
-       1.65289249e-002, 0., 0., 0., 2.47933865e-002, 8.26446246e-003, 0.,
-       0., 0., 0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0., 0.,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.26446246e-003, 0., 8.26446246e-003, 0., 0.,
-       1.65289249e-002, 0., 0., 0., 0., 0., 0., 0., 0., 8.26446246e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 2.47933865e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0., 0.,
-       8.26446246e-003, 0., 1.65289249e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.26446246e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 8.26446246e-003,
-       0., 0., 8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.26446246e-003, 0., 0., 0., 1.65289249e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.26446246e-003, 0., 8.26446246e-003, 0., 0.,
-       8.26446246e-003, 0., 0., 0., 0., 8.26446246e-003, 0., 0.,
-       8.26446246e-003, 8.26446246e-003, 0., 0., 0., 8.26446246e-003, 0.,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.26446246e-003, 0., 0., 0., 8.26446246e-003, 0.,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 8.26446246e-003, 0.,
-       0., 0., 0., 0., 1.65289249e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0., 0., 0.,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.26446246e-003, 8.26446246e-003, 0., 0., 0., 8.26446246e-003,
-       8.26446246e-003, 0., 0., 0., 0., 8.26446246e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3.30578499e-002,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 8.26446246e-003,
-       0., 0., 0., 8.26446246e-003, 0., 8.26446246e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.26446246e-003, 8.26446246e-003, 0., 0., 0., 0.,
-       1.65289249e-002, 0., 0., 0., 0., 0., 0., 8.26446246e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.35294120e-003, 7.35294120e-003,
-       2.20588241e-002, 0., 0., 1.47058824e-002, 1.47058824e-002, 0.,
-       1.47058824e-002, 7.35294120e-003, 0., 7.35294120e-003, 0.,
-       1.47058824e-002, 0., 1.47058824e-002, 7.35294120e-003,
-       2.20588241e-002, 0., 0., 2.20588241e-002, 1.47058824e-002,
-       7.35294120e-003, 0., 7.35294120e-003, 0., 0., 7.35294120e-003,
-       1.47058824e-002, 7.35294120e-003, 0., 1.47058824e-002, 0., 0.,
-       7.35294120e-003, 0., 7.35294120e-003, 0., 0., 7.35294120e-003, 0.,
-       0., 0., 0., 0., 7.35294120e-003, 7.35294120e-003, 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 0., 1.47058824e-002,
-       7.35294120e-003, 0., 0., 0., 0., 7.35294120e-003, 0., 0., 0., 0.,
-       7.35294120e-003, 0., 7.35294120e-003, 0., 0., 0., 0.,
-       7.35294120e-003, 7.35294120e-003, 0., 0., 0., 0., 0.,
-       7.35294120e-003, 7.35294120e-003, 7.35294120e-003, 0.,
-       7.35294120e-003, 0., 0., 0., 7.35294120e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.47058824e-002, 0., 0., 7.35294120e-003, 2.94117648e-002, 0.,
-       0., 0., 7.35294120e-003, 7.35294120e-003, 0., 0., 7.35294120e-003,
-       0., 0., 0., 7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.47058824e-002, 0., 0., 0., 7.35294120e-003,
-       0., 0., 0., 7.35294120e-003, 0., 7.35294120e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.35294120e-003, 0., 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 7.35294120e-003, 0.,
-       7.35294120e-003, 7.35294120e-003, 0., 0., 0., 2.94117648e-002, 0.,
-       0., 0., 0., 1.47058824e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 7.35294120e-003, 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.35294120e-003, 0., 2.20588241e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.35294120e-003, 7.35294120e-003, 0., 0., 1.47058824e-002, 0.,
-       7.35294120e-003, 7.35294120e-003, 7.35294120e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.47058824e-002, 0., 0.,
-       1.47058824e-002, 0., 7.35294120e-003, 7.35294120e-003, 0.,
-       7.35294120e-003, 0., 7.35294120e-003, 0., 0., 0., 0., 0., 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 7.35294120e-003, 7.35294120e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.35294120e-003, 0., 0., 0., 0.,
-       0., 7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 2.20588241e-002, 0., 1.47058824e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.47058824e-002, 0., 0., 0., 0., 0.,
-       0., 7.35294120e-003, 0., 0., 0., 0., 7.35294120e-003, 0., 0., 0.,
-       0., 7.35294120e-003, 0., 0., 0., 0., 7.35294120e-003,
-       7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.35294120e-003, 0., 0.,
-       0., 0., 0., 7.35294120e-003, 0., 7.35294120e-003, 7.35294120e-003,
-       0., 0., 7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.35294120e-003, 0., 0., 0.,
-       0., 7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 7.35294120e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.35294120e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 7.35294120e-003, 0., 0., 7.35294120e-003, 0.,
-       1.11731840e-002, 0., 5.58659201e-003, 1.11731840e-002, 0.,
-       4.46927361e-002, 0., 1.11731840e-002, 0., 0., 5.58659201e-003,
-       1.11731840e-002, 0., 1.67597756e-002, 0., 5.58659201e-003,
-       1.11731840e-002, 1.67597756e-002, 1.67597756e-002,
-       2.23463681e-002, 0., 0., 2.23463681e-002, 1.11731840e-002, 0., 0.,
-       1.67597756e-002, 0., 0., 1.11731840e-002, 1.11731840e-002, 0., 0.,
-       5.58659201e-003, 5.58659201e-003, 0., 0., 0., 5.58659201e-003, 0.,
-       0., 0., 0., 5.58659201e-003, 0., 0., 0., 5.58659201e-003,
-       5.58659201e-003, 1.11731840e-002, 0., 5.58659201e-003, 0., 0., 0.,
-       5.58659201e-003, 0., 0., 5.58659201e-003, 0., 0., 0.,
-       1.11731840e-002, 0., 0., 0., 0., 0., 2.79329605e-002,
-       5.58659201e-003, 5.58659201e-003, 0., 5.58659201e-003, 0., 0., 0.,
-       0., 0., 5.58659201e-003, 0., 0., 0., 1.11731840e-002, 0., 0., 0.,
-       5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 5.58659201e-003, 0.,
-       5.58659201e-003, 0., 0., 5.58659201e-003, 0., 0., 0.,
-       1.11731840e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.11731840e-002, 2.23463681e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.23463681e-002, 0., 5.58659201e-003, 0., 5.58659211e-002,
-       1.11731840e-002, 0., 1.11731840e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.58659201e-003, 5.58659201e-003, 5.58659201e-003, 0., 0.,
-       5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.58659201e-003, 5.58659201e-003, 0., 0., 5.58659201e-003,
-       5.58659201e-003, 5.58659201e-003, 0., 1.11731840e-002, 0., 0., 0.,
-       0., 5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.11731840e-002, 1.11731840e-002, 5.58659201e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.58659201e-003, 0., 0., 0., 0., 0., 5.58659201e-003, 0.,
-       0., 0., 0., 0., 0., 0., 5.58659201e-003, 0., 1.67597756e-002, 0.,
-       0., 5.58659201e-003, 5.58659201e-003, 0., 0., 0., 0.,
-       1.67597756e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.58659201e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.58659201e-003, 0., 5.58659201e-003,
-       0., 5.58659201e-003, 1.67597756e-002, 0., 0., 0., 0., 0.,
-       5.58659201e-003, 0., 5.58659201e-003, 0., 0., 0., 0., 0.,
-       5.58659201e-003, 0., 1.11731840e-002, 0., 0., 0., 1.11731840e-002,
-       0., 0., 0., 1.11731840e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.58659201e-003, 0., 0., 5.58659201e-003, 0., 0., 0., 0.,
-       0., 5.58659201e-003, 0., 0., 5.58659201e-003, 0., 0., 0., 0., 0.,
-       0., 0., 5.58659201e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.58659201e-003, 0., 0., 0., 1.11731840e-002, 0., 0., 0.,
-       5.58659201e-003, 0., 1.67597756e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 2.79329605e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.58659201e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.58659201e-003, 0., 0., 0., 5.58659201e-003,
-       5.58659201e-003, 0., 0., 1.11731840e-002, 0., 0., 5.58659201e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.58659201e-003, 5.58659201e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.58659201e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 5.58659201e-003,
-       0., 0., 0., 0., 5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.58659201e-003,
-       0., 1.05820103e-002, 5.29100513e-003, 0., 1.05820103e-002, 0.,
-       5.29100513e-003, 0., 1.58730149e-002, 0., 5.29100513e-003,
-       1.58730149e-002, 5.29100513e-003, 5.29100513e-003,
-       1.05820103e-002, 5.29100513e-003, 1.05820103e-002,
-       1.58730149e-002, 2.64550261e-002, 1.05820103e-002,
-       1.05820103e-002, 0., 0., 5.29100513e-003, 1.05820103e-002,
-       5.29100513e-003, 5.29100513e-003, 0., 5.29100513e-003, 0., 0.,
-       5.29100513e-003, 0., 5.29100513e-003, 1.05820103e-002, 0.,
-       1.05820103e-002, 0., 0., 1.58730149e-002, 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 2.11640205e-002, 1.05820103e-002, 0., 0.,
-       5.29100513e-003, 5.29100513e-003, 0., 5.29100513e-003,
-       1.58730149e-002, 0., 0., 5.29100513e-003, 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 5.29100513e-003, 0., 5.29100513e-003,
-       5.29100513e-003, 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 5.29100513e-003, 0., 0., 5.29100513e-003,
-       0., 0., 0., 0., 0., 0., 0., 5.29100513e-003, 0., 0., 0., 0.,
-       5.29100513e-003, 1.05820103e-002, 0., 0., 0., 1.05820103e-002, 0.,
-       0., 0., 5.29100513e-003, 0., 0., 0., 0., 5.29100513e-003,
-       5.29100513e-003, 0., 0., 5.29100513e-003, 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 5.29100513e-003, 2.64550261e-002,
-       0., 0., 0., 3.70370373e-002, 5.29100513e-003, 0., 5.29100513e-003,
-       0., 5.29100513e-003, 0., 0., 2.11640205e-002, 0., 0., 0., 0., 0.,
-       0., 0., 5.29100513e-003, 5.29100513e-003, 0., 5.29100513e-003,
-       5.29100513e-003, 0., 1.05820103e-002, 0., 5.29100513e-003, 0., 0.,
-       0., 0., 1.05820103e-002, 5.29100513e-003, 5.29100513e-003, 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.11640205e-002, 0., 0., 1.05820103e-002, 0., 0., 0.,
-       5.29100513e-003, 5.29100513e-003, 5.29100513e-003, 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 5.29100513e-003, 0., 0.,
-       1.05820103e-002, 5.29100513e-003, 1.05820103e-002,
-       5.29100513e-003, 0., 0., 5.29100513e-003, 0., 0., 0., 0.,
-       1.05820103e-002, 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 5.29100513e-003, 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 5.29100513e-003, 0., 0.,
-       0., 0., 0., 0., 5.29100513e-003, 0., 5.29100513e-003, 0., 0., 0.,
-       0., 0., 0., 0., 1.05820103e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 5.29100513e-003, 0., 0., 0.,
-       5.29100513e-003, 0., 5.29100513e-003, 0., 0., 1.05820103e-002,
-       5.29100513e-003, 1.05820103e-002, 0., 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 1.05820103e-002, 0., 0., 0.,
-       0., 0., 1.58730149e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.29100513e-003, 0., 0., 0., 0., 0., 0., 5.29100513e-003, 0.,
-       0., 0., 5.29100513e-003, 0., 0., 0., 0., 1.05820103e-002,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 5.29100513e-003, 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 5.29100513e-003, 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.29100513e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 5.29100513e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.29100513e-003, 0., 0.,
-       0., 0., 1.05820103e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 1.05820103e-002, 0., 0., 5.29100513e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.29100513e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.05820103e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 1.05820103e-002,
-       1.05820103e-002, 0., 0., 0., 0., 0., 0., 0., 0., 5.29100513e-003,
-       1.75438598e-002, 0., 1.16959065e-002, 1.16959065e-002,
-       5.84795326e-003, 3.50877196e-002, 0., 0., 5.84795326e-003, 0.,
-       5.84795326e-003, 0., 1.16959065e-002, 5.84795326e-003,
-       5.84795326e-003, 0., 0., 0., 0., 1.75438598e-002, 0.,
-       1.16959065e-002, 1.75438598e-002, 0., 0., 0., 0., 0., 0.,
-       2.33918130e-002, 1.16959065e-002, 0., 0., 5.84795326e-003,
-       5.84795326e-003, 5.84795326e-003, 0., 0., 1.16959065e-002,
-       5.84795326e-003, 0., 0., 0., 0., 0., 5.84795326e-003,
-       5.84795326e-003, 5.84795326e-003, 1.16959065e-002, 0., 0.,
-       1.16959065e-002, 0., 5.84795326e-003, 5.84795326e-003,
-       5.84795326e-003, 0., 0., 5.84795326e-003, 0., 0., 0.,
-       1.75438598e-002, 0., 0., 0., 5.84795326e-003, 0., 5.84795326e-003,
-       0., 2.33918130e-002, 0., 0., 5.84795326e-003, 0., 5.84795326e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 1.16959065e-002,
-       0., 0., 0., 0., 5.84795326e-003, 0., 1.16959065e-002,
-       1.16959065e-002, 0., 0., 0., 0., 0., 1.75438598e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0.,
-       0., 0., 0., 0., 0., 5.84795326e-003, 0., 5.84795326e-003, 0., 0.,
-       1.75438598e-002, 0., 0., 0., 4.09356728e-002, 5.84795326e-003, 0.,
-       0., 0., 1.16959065e-002, 5.84795326e-003, 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 5.84795326e-003, 5.84795326e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 5.84795326e-003, 5.84795326e-003,
-       0., 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.84795326e-003, 0., 0., 0., 0., 5.84795326e-003, 0.,
-       0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 2.33918130e-002, 0.,
-       5.84795326e-003, 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.84795326e-003, 5.84795326e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 5.84795326e-003,
-       0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 5.84795326e-003,
-       5.84795326e-003, 0., 0., 5.84795326e-003, 5.84795326e-003,
-       1.75438598e-002, 0., 0., 1.16959065e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 5.84795326e-003,
-       0., 5.84795326e-003, 5.84795326e-003, 0., 5.84795326e-003, 0., 0.,
-       5.84795326e-003, 1.16959065e-002, 0., 0., 5.84795326e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.16959065e-002, 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0.,
-       0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.16959065e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.16959065e-002, 0., 0., 0., 1.16959065e-002,
-       0., 1.16959065e-002, 0., 5.84795326e-003, 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0., 5.84795326e-003,
-       0., 0., 0., 0., 0., 0., 5.84795326e-003, 5.84795326e-003, 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 1.75438598e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.16959065e-002, 0., 0.,
-       5.84795326e-003, 0., 1.75438598e-002, 0., 0., 0., 5.84795326e-003,
-       0., 0., 0., 0., 5.84795326e-003, 0., 2.11640205e-002,
-       5.29100513e-003, 2.11640205e-002, 0., 1.05820103e-002,
-       5.29100513e-003, 0., 1.05820103e-002, 1.05820103e-002,
-       5.29100513e-003, 0., 0., 1.05820103e-002, 5.29100513e-003,
-       5.29100513e-003, 0., 0., 1.05820103e-002, 0., 1.05820103e-002,
-       5.29100513e-003, 5.29100513e-003, 5.29100513e-003,
-       1.05820103e-002, 0., 5.29100513e-003, 1.58730149e-002,
-       1.05820103e-002, 1.05820103e-002, 1.05820103e-002, 0., 0., 0.,
-       1.05820103e-002, 5.29100513e-003, 0., 0., 0., 5.29100513e-003,
-       1.58730149e-002, 0., 0., 0., 5.29100513e-003, 0., 5.29100513e-003,
-       5.29100513e-003, 1.58730149e-002, 3.70370373e-002,
-       5.29100513e-003, 0., 0., 1.05820103e-002, 0., 5.29100513e-003,
-       5.29100513e-003, 0., 0., 1.05820103e-002, 5.29100513e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.58730149e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.05820103e-002, 0., 5.29100513e-003, 5.29100513e-003, 0.,
-       5.29100513e-003, 0., 5.29100513e-003, 0., 5.29100513e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.05820103e-002, 0., 0.,
-       0., 5.29100513e-003, 5.29100513e-003, 1.05820103e-002, 0.,
-       1.58730149e-002, 0., 0., 0., 5.29100513e-003, 0., 1.05820103e-002,
-       0., 5.29100513e-003, 1.05820103e-002, 2.11640205e-002, 0., 0., 0.,
-       0., 0., 0., 0., 2.11640205e-002, 0., 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 5.29100513e-003, 0.,
-       0., 0., 0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.05820103e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 5.29100513e-003, 0., 0., 0.,
-       5.29100513e-003, 5.29100513e-003, 0., 5.29100513e-003, 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 1.05820103e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.29100513e-003, 0., 0., 0.,
-       5.29100513e-003, 0., 5.29100513e-003, 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.29100513e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.29100513e-003, 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 1.05820103e-002, 0., 5.29100513e-003, 0.,
-       0., 1.58730149e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.05820103e-002, 1.58730149e-002, 0.,
-       0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.29100513e-003, 0., 5.29100513e-003, 5.29100513e-003,
-       5.29100513e-003, 0., 0., 1.05820103e-002, 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0.,
-       0., 0., 2.11640205e-002, 0., 1.05820103e-002, 0., 0., 0., 0., 0.,
-       0., 5.29100513e-003, 0., 0., 1.05820103e-002, 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 5.29100513e-003, 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 1.58730149e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.05820103e-002, 0.,
-       1.05820103e-002, 0., 5.29100513e-003, 5.29100513e-003, 0., 0., 0.,
-       1.05820103e-002, 0., 5.29100513e-003, 0., 0., 5.29100513e-003, 0.,
-       0., 5.29100513e-003, 0., 0., 0., 0., 1.58730149e-002,
-       5.29100513e-003, 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 5.29100513e-003, 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 5.29100513e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.29100513e-003, 0.,
-       0., 0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.29100513e-003, 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0., 6.06060587e-003,
-       6.06060587e-003, 2.42424235e-002, 3.03030293e-002, 0.,
-       6.06060587e-003, 0., 0., 6.06060587e-003, 0., 6.06060587e-003,
-       1.21212117e-002, 0., 1.81818176e-002, 6.06060587e-003,
-       6.06060587e-003, 0., 3.63636352e-002, 0., 6.06060587e-003,
-       1.21212117e-002, 6.06060587e-003, 0., 0., 1.81818176e-002, 0.,
-       6.06060587e-003, 3.03030293e-002, 6.06060587e-003, 0., 0.,
-       1.21212117e-002, 1.21212117e-002, 0., 0., 0., 3.03030293e-002,
-       6.06060587e-003, 0., 6.06060587e-003, 0., 0., 0., 0., 0.,
-       6.06060587e-003, 3.63636352e-002, 0., 0., 6.06060587e-003, 0., 0.,
-       0., 6.06060587e-003, 0., 1.21212117e-002, 0., 1.21212117e-002, 0.,
-       0., 6.06060587e-003, 6.06060587e-003, 1.81818176e-002, 0., 0., 0.,
-       6.06060587e-003, 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 1.21212117e-002, 0., 6.06060587e-003, 0.,
-       0., 0., 0., 6.06060587e-003, 0., 1.81818176e-002, 6.06060587e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.21212117e-002,
-       0., 0., 6.06060587e-003, 0., 0., 0., 0., 0., 1.21212117e-002, 0.,
-       0., 0., 3.03030293e-002, 0., 0., 0., 0., 6.06060587e-003, 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 6.06060587e-003, 6.06060587e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 1.81818176e-002, 6.06060587e-003, 0., 0., 0., 0.,
-       6.06060587e-003, 0., 1.21212117e-002, 0., 1.21212117e-002, 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 1.21212117e-002,
-       6.06060587e-003, 0., 6.06060587e-003, 0., 0., 0., 0.,
-       6.06060587e-003, 6.06060587e-003, 6.06060587e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.06060587e-003,
-       0., 0., 0., 0., 0., 0., 1.81818176e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.21212117e-002, 0., 0., 0., 6.06060587e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.21212117e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.06060587e-003, 0., 0., 0.,
-       1.81818176e-002, 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.06060587e-003,
-       1.81818176e-002, 0., 0., 0., 0., 0., 6.06060587e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 1.21212117e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.06060587e-003, 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 6.06060587e-003,
-       1.21212117e-002, 0., 1.21212117e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.06060587e-003, 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.06060587e-003, 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 1.21212117e-002, 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.06060587e-003, 6.06060587e-003, 0., 0., 0.,
-       6.06060587e-003, 0., 0., 6.06060587e-003, 0., 0., 0., 0.,
-       6.06060587e-003, 1.81818176e-002, 0., 0., 8.77192989e-003, 0.,
-       1.75438598e-002, 0., 0., 0., 8.77192989e-003, 0., 0., 0.,
-       1.75438598e-002, 0., 1.75438598e-002, 0., 0., 8.77192989e-003, 0.,
-       0., 0., 1.75438598e-002, 8.77192989e-003, 2.63157897e-002, 0., 0.,
-       0., 8.77192989e-003, 8.77192989e-003, 0., 4.38596494e-002,
-       8.77192989e-003, 0., 0., 2.63157897e-002, 0., 0., 0., 0.,
-       1.75438598e-002, 0., 0., 0., 8.77192989e-003, 0., 8.77192989e-003,
-       8.77192989e-003, 1.75438598e-002, 8.77192989e-003,
-       4.38596494e-002, 0., 0., 0., 0., 8.77192989e-003, 0.,
-       8.77192989e-003, 0., 3.50877196e-002, 0., 8.77192989e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.77192989e-003, 0., 0., 8.77192989e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.75438598e-002,
-       8.77192989e-003, 0., 0., 0., 0., 8.77192989e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.77192989e-003, 0., 0., 0., 0.,
-       1.75438598e-002, 8.77192989e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.75438598e-002, 0., 0., 8.77192989e-003, 3.50877196e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.77192989e-003,
-       8.77192989e-003, 0., 8.77192989e-003, 8.77192989e-003,
-       8.77192989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.77192989e-003, 0., 0., 0., 0., 0., 0., 8.77192989e-003,
-       1.75438598e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.77192989e-003, 0., 0., 0., 8.77192989e-003, 0., 0., 0.,
-       0., 0., 0., 1.75438598e-002, 0., 0., 0., 0., 0., 8.77192989e-003,
-       0., 0., 0., 0., 8.77192989e-003, 0., 0., 0., 8.77192989e-003, 0.,
-       0., 8.77192989e-003, 8.77192989e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.63157897e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.77192989e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.77192989e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.75438598e-002, 0., 0., 0., 0., 0.,
-       8.77192989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.77192989e-003, 0., 0., 4.38596494e-002, 0., 0., 0., 0.,
-       8.77192989e-003, 0., 1.75438598e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.77192989e-003,
-       8.77192989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.75438598e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.77192989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.77192989e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.77192989e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.77192989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.77192989e-003, 0., 0., 0., 0., 0., 1.75438598e-002,
-       0., 0., 0., 0., 0., 0., 0., 8.77192989e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.77192989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.77192989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.77192989e-003, 0., 0., 0., 0., 0., 8.77192989e-003,
-       0., 0., 1.89873427e-002, 6.32911408e-003, 6.32911408e-003,
-       1.26582282e-002, 1.89873427e-002, 0., 6.32911408e-003, 0.,
-       6.32911408e-003, 6.32911408e-003, 6.32911408e-003,
-       6.32911408e-003, 6.32911408e-003, 0., 6.32911408e-003, 0.,
-       6.32911408e-003, 0., 1.26582282e-002, 1.26582282e-002, 0.,
-       3.16455700e-002, 0., 0., 0., 1.89873427e-002, 0., 1.26582282e-002,
-       6.32911408e-003, 0., 6.32911408e-003, 0., 0., 6.32911408e-003, 0.,
-       0., 0., 1.26582282e-002, 0., 0., 0., 0., 6.32911408e-003,
-       6.32911408e-003, 6.32911408e-003, 6.32911408e-003,
-       6.32911408e-003, 6.32911408e-003, 0., 6.32911408e-003,
-       6.32911408e-003, 6.32911408e-003, 0., 0., 0., 0., 6.32911408e-003,
-       0., 6.32911408e-003, 0., 0., 1.26582282e-002, 0., 0.,
-       6.32911408e-003, 0., 0., 6.32911408e-003, 6.32911408e-003,
-       6.32911408e-003, 0., 0., 0., 0., 0., 0., 0., 6.32911408e-003, 0.,
-       0., 0., 6.32911408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.32911408e-003, 0., 1.26582282e-002, 0., 0., 0., 1.26582282e-002,
-       6.32911408e-003, 0., 0., 6.32911408e-003, 6.32911408e-003, 0., 0.,
-       0., 0., 0., 0., 0., 1.89873427e-002, 0., 0., 0., 0., 0.,
-       6.32911408e-003, 6.32911408e-003, 0., 6.32911408e-003, 0., 0., 0.,
-       0., 1.26582282e-002, 0., 0., 0., 4.43037972e-002, 0., 0., 0., 0.,
-       6.32911408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.32911408e-003, 0., 0., 0., 0., 0., 0., 0., 6.32911408e-003, 0.,
-       0., 6.32911408e-003, 0., 0., 0., 6.32911408e-003, 0., 0.,
-       6.32911408e-003, 0., 6.32911408e-003, 6.32911408e-003, 0., 0., 0.,
-       0., 6.32911408e-003, 0., 6.32911408e-003, 0., 0., 0., 0., 0., 0.,
-       1.26582282e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.26582282e-002, 0., 0., 1.89873427e-002, 0., 0., 0., 0., 0., 0.,
-       6.32911408e-003, 0., 0., 0., 0., 0., 0., 0., 6.32911408e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.32911408e-003,
-       0., 1.26582282e-002, 0., 0., 0., 0., 6.32911408e-003, 0., 0., 0.,
-       6.32911408e-003, 0., 0., 0., 0., 0., 6.32911408e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.32911408e-003, 0., 0., 0.,
-       6.32911408e-003, 6.32911408e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.32911408e-003, 0., 0., 1.26582282e-002, 0., 0., 0.,
-       6.32911408e-003, 6.32911408e-003, 0., 0., 0., 0., 0., 0.,
-       1.89873427e-002, 0., 0., 6.32911408e-003, 0., 6.32911408e-003, 0.,
-       0., 0., 6.32911408e-003, 6.32911408e-003, 1.26582282e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.32911408e-003, 1.26582282e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.26582282e-002, 6.32911408e-003,
-       0., 0., 6.32911408e-003, 0., 0., 0., 0., 0., 0., 6.32911408e-003,
-       0., 0., 0., 0., 0., 1.89873427e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.26582282e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.32911408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.32911408e-003, 0., 0., 0., 0.,
-       2.53164563e-002, 0., 0., 0., 0., 0., 0., 0., 6.32911408e-003, 0.,
-       0., 0., 6.32911408e-003, 0., 0., 0., 0., 1.26582282e-002, 0.,
-       6.32911408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.32911408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.89873427e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.32911408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.32911408e-003, 6.32911408e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.32911408e-003, 0., 0., 0.,
-       0., 6.32911408e-003, 0., 6.32911408e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.32911408e-003, 0., 0., 0., 0., 0.,
-       6.32911408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.32911408e-003, 0., 0., 0.,
-       0., 0., 1.58730168e-002, 0., 0., 0., 0., 0., 0., 2.38095261e-002,
-       0., 0., 0., 7.93650839e-003, 0., 7.93650839e-003, 0.,
-       7.93650839e-003, 0., 7.93650839e-003, 0., 1.58730168e-002, 0.,
-       7.93650839e-003, 3.96825410e-002, 0., 0., 7.93650839e-003,
-       2.38095261e-002, 0., 7.93650839e-003, 7.93650839e-003,
-       7.93650839e-003, 7.93650839e-003, 0., 1.58730168e-002,
-       1.58730168e-002, 0., 0., 0., 2.38095261e-002, 0., 0., 0.,
-       1.58730168e-002, 0., 0., 1.58730168e-002, 7.93650839e-003, 0.,
-       1.58730168e-002, 0., 0., 0., 7.93650839e-003, 0., 0.,
-       7.93650839e-003, 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0.,
-       2.38095261e-002, 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0.,
-       7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.38095261e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.93650839e-003, 7.93650839e-003, 0., 0., 0., 7.93650839e-003,
-       7.93650839e-003, 0., 7.93650839e-003, 1.58730168e-002, 0., 0., 0.,
-       0., 0., 0., 1.58730168e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.93650839e-003, 0., 0., 0., 0., 2.38095261e-002, 0.,
-       7.93650839e-003, 0., 3.96825410e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0.,
-       7.93650839e-003, 0., 0., 0., 2.38095261e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0., 0., 0., 0.,
-       0., 0., 7.93650839e-003, 0., 7.93650839e-003, 0., 7.93650839e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0.,
-       0., 0., 0., 0., 7.93650839e-003, 7.93650839e-003, 0., 0., 0., 0.,
-       0., 0., 7.93650839e-003, 0., 1.58730168e-002, 0., 0., 0., 0., 0.,
-       7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.93650839e-003, 0., 0., 0., 0., 7.93650839e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0.,
-       7.93650839e-003, 7.93650839e-003, 0., 0., 0., 0., 0.,
-       7.93650839e-003, 0., 0., 0., 7.93650839e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.58730168e-002, 0., 0., 0.,
-       1.58730168e-002, 1.58730168e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.93650839e-003, 0., 0., 0., 0., 7.93650839e-003, 0.,
-       0., 0., 0., 0., 0., 1.58730168e-002, 0., 0., 0., 0., 0.,
-       7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 0., 7.93650839e-003,
-       0., 7.93650839e-003, 0., 0., 0., 7.93650839e-003, 7.93650839e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 1.58730168e-002, 0.,
-       0., 7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 0., 7.93650839e-003,
-       0., 0., 0., 0., 0., 2.38095261e-002, 0., 0., 7.93650839e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0., 1.58730168e-002,
-       0., 1.19047621e-002, 0., 0., 5.95238106e-003, 1.19047621e-002,
-       1.78571437e-002, 0., 1.78571437e-002, 0., 5.95238106e-003,
-       5.95238106e-003, 5.95238106e-003, 5.95238106e-003,
-       1.78571437e-002, 0., 0., 0., 0., 5.95238106e-003, 1.19047621e-002,
-       5.95238106e-003, 0., 4.16666679e-002, 0., 0., 0., 1.78571437e-002,
-       0., 2.38095243e-002, 2.38095243e-002, 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 5.95238106e-003, 1.19047621e-002, 0.,
-       0., 0., 5.95238106e-003, 5.95238106e-003, 0., 1.19047621e-002,
-       1.19047621e-002, 3.57142873e-002, 0., 0., 5.95238106e-003, 0., 0.,
-       0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 1.19047621e-002,
-       5.95238106e-003, 1.78571437e-002, 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 1.19047621e-002, 0., 0., 5.95238106e-003, 0.,
-       0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 5.95238106e-003, 5.95238106e-003, 0., 0.,
-       0., 0., 0., 5.95238106e-003, 0., 0., 1.19047621e-002,
-       1.19047621e-002, 0., 0., 0., 0., 0., 0., 5.95238106e-003,
-       2.38095243e-002, 0., 5.95238106e-003, 0., 0., 0., 0., 0.,
-       1.19047621e-002, 0., 0., 0., 0., 0., 1.19047621e-002, 0., 0., 0.,
-       2.97619049e-002, 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0.,
-       0., 0., 0., 5.95238106e-003, 5.95238106e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 1.19047621e-002, 0., 1.19047621e-002, 0.,
-       1.19047621e-002, 0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003,
-       0., 0., 0., 5.95238106e-003, 0., 0., 0., 5.95238106e-003,
-       5.95238106e-003, 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.95238106e-003, 0., 0., 0., 5.95238106e-003, 0., 0.,
-       0., 0., 0., 0., 5.95238106e-003, 5.95238106e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.78571437e-002, 0., 0., 0.,
-       1.78571437e-002, 0., 0., 0., 0., 1.19047621e-002, 0., 0., 0., 0.,
-       0., 0., 0., 1.19047621e-002, 5.95238106e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.19047621e-002, 0., 0., 0., 5.95238106e-003,
-       0., 0., 0., 0., 1.19047621e-002, 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 1.19047621e-002, 0., 0.,
-       1.19047621e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.19047621e-002, 0., 0., 0., 1.19047621e-002, 1.78571437e-002, 0.,
-       0., 0., 0., 0., 1.19047621e-002, 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0.,
-       0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.19047621e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.78571437e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.95238106e-003, 0., 0., 0., 5.95238106e-003, 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.95238106e-003, 0., 0., 0., 5.95238106e-003, 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.95238106e-003, 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 1.08695654e-002, 1.63043477e-002,
-       5.43478271e-003, 1.08695654e-002, 1.08695654e-002, 0., 0.,
-       5.43478271e-003, 1.08695654e-002, 0., 0., 0., 5.43478271e-003,
-       5.43478271e-003, 5.43478271e-003, 0., 1.08695654e-002,
-       1.08695654e-002, 1.63043477e-002, 1.08695654e-002, 0., 0.,
-       1.63043477e-002, 5.43478271e-003, 0., 0., 0., 5.43478271e-003,
-       2.17391308e-002, 1.08695654e-002, 0., 5.43478271e-003,
-       5.43478271e-003, 1.08695654e-002, 5.43478271e-003, 0., 0.,
-       5.43478271e-003, 3.80434804e-002, 5.43478271e-003, 0., 0.,
-       1.08695654e-002, 5.43478271e-003, 0., 1.08695654e-002,
-       5.43478271e-003, 0., 2.17391308e-002, 0., 0., 5.43478271e-003,
-       5.43478271e-003, 0., 1.63043477e-002, 5.43478271e-003, 0., 0., 0.,
-       5.43478271e-003, 0., 0., 2.17391308e-002, 0., 5.43478271e-003, 0.,
-       0., 0., 5.43478271e-003, 5.43478271e-003, 0., 0., 5.43478271e-003,
-       0., 5.43478271e-003, 0., 0., 0., 0., 1.08695654e-002, 0., 0.,
-       5.43478271e-003, 0., 5.43478271e-003, 0., 0., 0., 0., 0.,
-       5.43478271e-003, 5.43478271e-003, 5.43478271e-003, 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 5.43478271e-003, 5.43478271e-003,
-       0., 5.43478271e-003, 0., 0., 0., 5.43478271e-003, 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0.,
-       5.43478271e-003, 0., 0., 0., 5.43478271e-003, 0., 1.63043477e-002,
-       5.43478271e-003, 0., 0., 2.71739140e-002, 5.43478271e-003, 0., 0.,
-       0., 0., 1.08695654e-002, 0., 0., 0., 0., 0., 0., 1.08695654e-002,
-       0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 5.43478271e-003, 0., 0., 0.,
-       5.43478271e-003, 0., 0., 5.43478271e-003, 5.43478271e-003, 0.,
-       5.43478271e-003, 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0.,
-       0., 0., 5.43478271e-003, 0., 0., 0., 5.43478271e-003, 0., 0.,
-       5.43478271e-003, 5.43478271e-003, 0., 1.08695654e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.63043477e-002, 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0.,
-       0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.43478271e-003, 0., 0., 0., 0., 5.43478271e-003, 0.,
-       5.43478271e-003, 1.08695654e-002, 0., 1.08695654e-002,
-       5.43478271e-003, 5.43478271e-003, 0., 5.43478271e-003, 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 5.43478271e-003, 0., 0., 1.08695654e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 5.43478271e-003, 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 5.43478271e-003,
-       1.08695654e-002, 0., 0., 5.43478271e-003, 5.43478271e-003, 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.08695654e-002, 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.43478271e-003, 0., 0., 5.43478271e-003, 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.08695654e-002, 0., 0., 0., 0., 5.43478271e-003, 5.43478271e-003,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003,
-       5.43478271e-003, 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0.,
-       5.43478271e-003, 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0.,
-       5.43478271e-003, 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0.,
-       0., 5.43478271e-003, 0., 0., 0., 0., 0., 5.43478271e-003, 0.,
-       5.43478271e-003, 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.43478271e-003, 5.43478271e-003, 0., 1.08695654e-002,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0.,
-       0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.36986300e-002, 0., 0., 6.84931502e-003, 6.84931502e-003, 0., 0.,
-       0., 2.73972601e-002, 6.84931502e-003, 6.84931502e-003, 0.,
-       1.36986300e-002, 6.84931502e-003, 0., 0., 0., 6.84931502e-003,
-       6.84931502e-003, 6.84931502e-003, 0., 0., 6.84931502e-003, 0., 0.,
-       0., 2.05479451e-002, 0., 6.84931502e-003, 1.36986300e-002, 0.,
-       1.36986300e-002, 0., 1.36986300e-002, 0., 0., 6.84931502e-003,
-       6.84931502e-003, 1.36986300e-002, 6.84931502e-003, 0., 0.,
-       6.84931502e-003, 1.36986300e-002, 0., 1.36986300e-002,
-       1.36986300e-002, 1.36986300e-002, 4.10958901e-002,
-       6.84931502e-003, 0., 6.84931502e-003, 0., 0., 0., 6.84931502e-003,
-       0., 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       3.42465751e-002, 0., 0., 0., 6.84931502e-003, 6.84931502e-003, 0.,
-       0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.84931502e-003, 0., 1.36986300e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0.,
-       1.36986300e-002, 1.36986300e-002, 0., 0., 0., 0., 1.36986300e-002,
-       6.84931502e-003, 0., 0., 0., 6.84931502e-003, 0., 0.,
-       1.36986300e-002, 1.36986300e-002, 0., 0., 0., 2.73972601e-002, 0.,
-       0., 0., 0., 0., 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0.,
-       2.05479451e-002, 0., 1.36986300e-002, 0., 0., 0., 0., 0., 0., 0.,
-       6.84931502e-003, 0., 6.84931502e-003, 6.84931502e-003, 0., 0., 0.,
-       1.36986300e-002, 0., 0., 0., 1.36986300e-002, 0., 6.84931502e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.84931502e-003, 0., 0., 0., 0., 6.84931502e-003, 0., 0., 0., 0.,
-       6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.84931502e-003, 0., 0., 6.84931502e-003, 2.05479451e-002, 0.,
-       0., 0., 0., 0., 0., 0., 1.36986300e-002, 0., 0., 0., 0., 0., 0.,
-       6.84931502e-003, 6.84931502e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.84931502e-003, 0.,
-       0., 6.84931502e-003, 0., 0., 6.84931502e-003, 0., 0.,
-       6.84931502e-003, 0., 0., 6.84931502e-003, 0., 0., 6.84931502e-003,
-       0., 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.36986300e-002, 0., 0., 0., 0., 6.84931502e-003, 0., 0., 0., 0.,
-       0., 6.84931502e-003, 0., 0., 0., 0., 0., 1.36986300e-002, 0.,
-       6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.05479451e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.84931502e-003, 0., 0., 0., 0., 0., 6.84931502e-003, 0., 0., 0.,
-       0., 0., 0., 0., 1.36986300e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.36986300e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.84931502e-003, 0., 0., 0., 6.84931502e-003,
-       0., 0., 0., 0., 0., 6.84931502e-003, 0., 0., 0., 0.,
-       6.84931502e-003, 0., 0., 0., 0., 0., 0., 6.84931502e-003, 0., 0.,
-       0., 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.84931502e-003,
-       1.36986300e-002, 0., 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.36986300e-002, 0.,
-       1.69491526e-002, 8.47457629e-003, 0., 0., 2.54237279e-002, 0., 0.,
-       0., 0., 8.47457629e-003, 0., 0., 2.54237279e-002, 0.,
-       8.47457629e-003, 8.47457629e-003, 8.47457629e-003,
-       2.54237279e-002, 8.47457629e-003, 1.69491526e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.47457629e-003, 8.47457629e-003, 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 8.47457629e-003, 0.,
-       8.47457629e-003, 0., 0., 1.69491526e-002, 0., 0., 8.47457629e-003,
-       1.69491526e-002, 1.69491526e-002, 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 8.47457629e-003, 8.47457629e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.69491526e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003,
-       8.47457629e-003, 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.47457629e-003, 8.47457629e-003, 0.,
-       8.47457629e-003, 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.47457629e-003, 8.47457629e-003, 0., 8.47457629e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003,
-       6.77966103e-002, 0., 0., 1.69491526e-002, 0., 0., 2.54237279e-002,
-       0., 1.69491526e-002, 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0.,
-       8.47457629e-003, 8.47457629e-003, 0., 0., 0., 0., 4.23728824e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0.,
-       0., 0., 1.69491526e-002, 8.47457629e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0.,
-       0., 0., 0., 0., 0., 0., 8.47457629e-003, 1.69491526e-002, 0., 0.,
-       0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.69491526e-002, 0., 0., 0., 8.47457629e-003, 0., 0., 0.,
-       8.47457629e-003, 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0.,
-       8.47457629e-003, 0., 8.47457629e-003, 0., 0., 0., 8.47457629e-003,
-       8.47457629e-003, 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 2.54237279e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.69491526e-002,
-       0., 1.69491526e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.47457629e-003, 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 8.47457629e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.69491526e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.80272095e-003, 6.80272095e-003,
-       6.80272095e-003, 2.04081628e-002, 1.36054419e-002,
-       4.08163257e-002, 0., 6.80272095e-003, 6.80272095e-003, 0., 0.,
-       6.80272095e-003, 6.80272095e-003, 0., 0., 1.36054419e-002, 0.,
-       6.80272095e-003, 0., 6.80272095e-003, 6.80272095e-003,
-       6.80272095e-003, 4.76190448e-002, 0., 6.80272095e-003, 0.,
-       1.36054419e-002, 0., 6.80272095e-003, 2.04081628e-002, 0.,
-       6.80272095e-003, 0., 6.80272095e-003, 0., 1.36054419e-002, 0., 0.,
-       2.04081628e-002, 2.04081628e-002, 0., 0., 6.80272095e-003, 0., 0.,
-       1.36054419e-002, 1.36054419e-002, 1.36054419e-002,
-       2.04081628e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.80272095e-003, 0., 6.80272095e-003, 0., 0., 6.80272095e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 0., 1.36054419e-002, 0., 0.,
-       1.36054419e-002, 2.04081628e-002, 0., 0., 0., 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 0., 6.80272095e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 2.72108838e-002, 6.80272095e-003,
-       0., 0., 0., 0., 0., 0., 2.72108838e-002, 0., 0., 0., 0.,
-       6.80272095e-003, 0., 6.80272095e-003, 6.80272095e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 0., 6.80272095e-003,
-       0., 6.80272095e-003, 0., 6.80272095e-003, 0., 2.72108838e-002, 0.,
-       6.80272095e-003, 0., 0., 0., 0., 6.80272095e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.80272095e-003, 0., 6.80272095e-003, 6.80272095e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.36054419e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.80272095e-003, 0., 0., 0., 0., 0.,
-       6.80272095e-003, 6.80272095e-003, 0., 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 1.36054419e-002, 0., 6.80272095e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.80272095e-003, 0., 0., 1.36054419e-002, 0., 0.,
-       6.80272095e-003, 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.80272095e-003, 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 0., 6.80272095e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.36054419e-002, 0., 0., 0.,
-       0., 0., 0., 6.80272095e-003, 0., 0., 6.80272095e-003,
-       6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 1.36054419e-002,
-       0., 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0., 0.,
-       6.80272095e-003, 0., 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.80272095e-003, 0., 0., 1.36054419e-002,
-       6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 2.04081628e-002, 0.,
-       0., 6.80272095e-003, 0., 0., 0., 0., 6.80272095e-003, 0.,
-       6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.36054419e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.80272095e-003, 0., 6.80272095e-003, 0., 1.36054419e-002,
-       0., 0., 0., 0., 6.80272095e-003, 0., 5.81395347e-003,
-       5.81395347e-003, 1.74418613e-002, 4.06976752e-002,
-       5.81395347e-003, 0., 5.81395347e-003, 5.81395347e-003,
-       5.81395347e-003, 1.16279069e-002, 0., 1.16279069e-002,
-       5.81395347e-003, 0., 0., 5.81395347e-003, 1.74418613e-002, 0.,
-       2.32558139e-002, 1.16279069e-002, 1.16279069e-002,
-       1.16279069e-002, 0., 5.81395347e-003, 0., 2.32558139e-002, 0.,
-       5.81395347e-003, 1.74418613e-002, 0., 0., 0., 5.81395347e-003, 0.,
-       0., 0., 0., 1.16279069e-002, 1.16279069e-002, 0., 0., 0.,
-       1.74418613e-002, 0., 1.16279069e-002, 0., 0., 1.16279069e-002, 0.,
-       5.81395347e-003, 0., 0., 5.81395347e-003, 5.81395347e-003,
-       1.16279069e-002, 0., 0., 5.81395347e-003, 0., 0., 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 5.81395347e-003,
-       5.81395347e-003, 1.16279069e-002, 0., 1.16279069e-002, 0., 0., 0.,
-       5.81395347e-003, 0., 0., 5.81395347e-003, 0., 0., 0., 0.,
-       5.81395347e-003, 0., 0., 1.16279069e-002, 0., 0., 0., 0., 0., 0.,
-       0., 5.81395347e-003, 0., 0., 0., 0., 1.16279069e-002, 0., 0., 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.81395347e-003, 5.81395347e-003, 0., 0., 0.,
-       2.32558139e-002, 0., 0., 0., 3.48837227e-002, 0., 0., 0., 0., 0.,
-       0., 0., 1.16279069e-002, 0., 0., 5.81395347e-003, 0.,
-       1.16279069e-002, 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.74418613e-002, 0., 5.81395347e-003, 0., 0.,
-       0., 0., 1.74418613e-002, 0., 0., 0., 0., 0., 0., 1.16279069e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0.,
-       5.81395347e-003, 0., 1.16279069e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.16279069e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.16279069e-002, 0., 0., 0., 0., 0., 0., 5.81395347e-003,
-       1.16279069e-002, 0., 0., 0., 0., 0., 1.74418613e-002, 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 5.81395347e-003,
-       5.81395347e-003, 5.81395347e-003, 0., 5.81395347e-003,
-       1.74418613e-002, 5.81395347e-003, 0., 0., 0., 0., 5.81395347e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.16279069e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.16279069e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0.,
-       1.16279069e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.16279069e-002, 0., 1.74418613e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.81395347e-003, 0., 0., 0., 5.81395347e-003, 0., 0.,
-       1.16279069e-002, 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.16279069e-002, 5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0.,
-       2.32558139e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.74418613e-002, 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0.,
-       0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0.,
-       5.81395347e-003, 0., 0., 0., 0., 1.16279069e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.12359552e-002, 0.,
-       1.68539323e-002, 2.24719103e-002, 1.12359552e-002, 0.,
-       1.12359552e-002, 5.61797759e-003, 0., 1.12359552e-002,
-       5.61797759e-003, 5.61797759e-003, 1.12359552e-002,
-       5.61797759e-003, 5.61797759e-003, 0., 1.12359552e-002,
-       1.12359552e-002, 2.80898884e-002, 0., 5.61797759e-003,
-       1.68539323e-002, 0., 0., 0., 1.12359552e-002, 0., 5.61797759e-003,
-       1.12359552e-002, 5.61797759e-003, 5.61797759e-003, 0., 0.,
-       3.37078646e-002, 0., 0., 5.61797759e-003, 1.68539323e-002,
-       1.12359552e-002, 0., 5.61797759e-003, 0., 1.12359552e-002,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 1.68539323e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0.,
-       1.12359552e-002, 0., 0., 0., 0., 5.61797759e-003, 5.61797759e-003,
-       0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 5.61797759e-003, 0.,
-       0., 1.12359552e-002, 0., 0., 0., 5.61797759e-003, 5.61797759e-003,
-       0., 0., 0., 0., 5.61797759e-003, 5.61797759e-003, 0.,
-       5.61797759e-003, 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       1.68539323e-002, 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0., 0.,
-       1.68539323e-002, 0., 5.61797759e-003, 0., 3.93258445e-002, 0., 0.,
-       0., 0., 0., 0., 0., 1.68539323e-002, 0., 0., 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 5.61797759e-003, 0., 0.,
-       0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 5.61797759e-003,
-       0., 0., 0., 5.61797759e-003, 5.61797759e-003, 2.24719103e-002, 0.,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 0., 5.61797759e-003, 0.,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0.,
-       1.12359552e-002, 0., 0., 5.61797759e-003, 0., 0., 0.,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 1.12359552e-002, 0., 0.,
-       0., 0., 0., 0., 5.61797759e-003, 5.61797759e-003, 5.61797759e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.61797759e-003, 0., 0., 5.61797759e-003, 0.,
-       1.12359552e-002, 0., 5.61797759e-003, 1.12359552e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 1.12359552e-002, 5.61797759e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 5.61797759e-003, 5.61797759e-003,
-       0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.12359552e-002, 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0.,
-       0., 5.61797759e-003, 0., 5.61797759e-003, 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       5.61797759e-003, 0., 0., 1.12359552e-002, 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       5.61797759e-003, 0., 0., 0., 1.68539323e-002, 0., 0., 0., 0., 0.,
-       1.12359552e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.61797759e-003, 0., 1.69491526e-002, 0., 8.47457629e-003,
-       2.54237279e-002, 1.69491526e-002, 0., 0., 1.69491526e-002, 0., 0.,
-       0., 0., 8.47457629e-003, 1.69491526e-002, 0., 8.47457629e-003,
-       8.47457629e-003, 8.47457629e-003, 0., 8.47457629e-003, 0.,
-       1.69491526e-002, 1.69491526e-002, 0., 1.69491526e-002, 0.,
-       1.69491526e-002, 0., 8.47457629e-003, 8.47457629e-003, 0.,
-       8.47457629e-003, 0., 0., 0., 8.47457629e-003, 0., 0.,
-       3.38983051e-002, 8.47457629e-003, 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 8.47457629e-003, 1.69491526e-002, 0., 0., 0.,
-       0., 0., 8.47457629e-003, 0., 0., 0., 0., 8.47457629e-003, 0., 0.,
-       0., 0., 2.54237279e-002, 0., 0., 0., 1.69491526e-002, 0.,
-       8.47457629e-003, 0., 0., 0., 8.47457629e-003, 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.69491526e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 8.47457629e-003,
-       8.47457629e-003, 0., 0., 0., 0., 0., 8.47457629e-003, 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 2.54237279e-002, 0., 0., 0.,
-       4.23728824e-002, 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0.,
-       0., 0., 0., 1.69491526e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 8.47457629e-003,
-       0., 1.69491526e-002, 2.54237279e-002, 0., 0., 0., 0., 0.,
-       8.47457629e-003, 8.47457629e-003, 0., 0., 8.47457629e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 1.69491526e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.69491526e-002, 8.47457629e-003, 0., 0., 0.,
-       0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 8.47457629e-003,
-       0., 0., 1.69491526e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 1.69491526e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 2.54237279e-002, 0., 8.47457629e-003,
-       0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0.,
-       0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 8.47457629e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.47457629e-003, 3.38983051e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003,
-       0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0.,
-       8.47457629e-003, 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.69491526e-002, 8.47457629e-003, 0., 0., 0., 0., 8.47457629e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0.,
-       7.40740728e-003, 0., 7.40740728e-003, 7.40740728e-003,
-       2.22222209e-002, 0., 7.40740728e-003, 7.40740728e-003, 0., 0., 0.,
-       0., 0., 0., 7.40740728e-003, 0., 0., 7.40740728e-003,
-       1.48148146e-002, 7.40740728e-003, 0., 7.40740728e-003, 0., 0., 0.,
-       2.22222209e-002, 0., 7.40740728e-003, 1.48148146e-002,
-       7.40740728e-003, 7.40740728e-003, 0., 7.40740728e-003,
-       7.40740728e-003, 0., 0., 0., 7.40740728e-003, 7.40740728e-003,
-       7.40740728e-003, 0., 7.40740728e-003, 0., 7.40740728e-003,
-       1.48148146e-002, 0., 7.40740728e-003, 1.48148146e-002,
-       7.40740728e-003, 0., 0., 1.48148146e-002, 0., 0., 1.48148146e-002,
-       0., 0., 0., 1.48148146e-002, 0., 0., 7.40740728e-003, 0.,
-       1.48148146e-002, 7.40740728e-003, 0., 0., 1.48148146e-002, 0.,
-       7.40740728e-003, 0., 7.40740728e-003, 0., 0., 0., 0., 0.,
-       7.40740728e-003, 0., 0., 0., 0., 0., 1.48148146e-002, 0., 0., 0.,
-       0., 0., 0., 0., 7.40740728e-003, 0., 0., 0., 0., 0., 0.,
-       1.48148146e-002, 0., 7.40740728e-003, 0., 7.40740728e-003,
-       1.48148146e-002, 0., 0., 0., 0., 0., 0., 0., 7.40740728e-003, 0.,
-       0., 7.40740728e-003, 0., 7.40740728e-003, 1.48148146e-002, 0.,
-       1.48148146e-002, 0., 0., 0., 0., 0., 7.40740728e-003, 0., 0., 0.,
-       5.18518500e-002, 7.40740728e-003, 0., 0., 0., 1.48148146e-002, 0.,
-       0., 0., 0., 0., 0., 0., 7.40740728e-003, 7.40740728e-003, 0., 0.,
-       0., 0., 0., 1.48148146e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.48148146e-002, 0., 0., 0., 0., 0., 0.,
-       1.48148146e-002, 0., 7.40740728e-003, 0., 0., 0., 0., 0.,
-       7.40740728e-003, 7.40740728e-003, 1.48148146e-002, 0., 0.,
-       7.40740728e-003, 0., 0., 0., 0., 0., 7.40740728e-003, 0., 0., 0.,
-       0., 0., 0., 0., 7.40740728e-003, 0., 0., 0., 0., 0., 0.,
-       7.40740728e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.40740728e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.48148146e-002, 7.40740728e-003, 0., 0.,
-       7.40740728e-003, 0., 0., 0., 0., 7.40740728e-003, 0., 0., 0., 0.,
-       7.40740728e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.40740728e-003, 0., 0., 0., 7.40740728e-003, 0., 0.,
-       7.40740728e-003, 0., 0., 7.40740728e-003, 7.40740728e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.40740728e-003, 0., 0., 0.,
-       0., 7.40740728e-003, 0., 0., 0., 0., 0., 7.40740728e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.40740728e-003, 0., 0., 0., 0., 0., 0., 7.40740728e-003, 0., 0.,
-       1.48148146e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.40740728e-003, 0., 7.40740728e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.40740728e-003, 0., 0., 0., 0., 0.,
-       7.40740728e-003, 0., 0., 0., 0., 0., 0., 0., 7.40740728e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.40740728e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.40740728e-003, 0., 0., 0., 0.,
-       7.40740728e-003, 0., 0., 0., 0., 0., 0., 0., 0., 7.40740728e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.40740728e-003, 0., 0.,
-       0., 0., 0., 7.40740728e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.48148146e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.40740728e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.48148146e-002, 0., 0.,
-       7.40740728e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.40740728e-003, 0., 0., 0., 0., 0., 0., 7.40740728e-003, 0., 0.,
-       0., 0., 0., 0., 0., 7.40740728e-003, 0., 0., 0., 0., 0.,
-       1.48148146e-002, 0., 0., 8.54700897e-003, 8.54700897e-003, 0., 0.,
-       2.56410278e-002, 0., 8.54700897e-003, 0., 0., 0., 0.,
-       2.56410278e-002, 8.54700897e-003, 0., 8.54700897e-003, 0., 0., 0.,
-       3.41880359e-002, 0., 8.54700897e-003, 8.54700897e-003, 0., 0., 0.,
-       4.27350439e-002, 0., 0., 8.54700897e-003, 1.70940179e-002, 0., 0.,
-       8.54700897e-003, 1.70940179e-002, 0., 0., 0., 4.27350439e-002,
-       8.54700897e-003, 0., 0., 0., 0., 0., 0., 0., 8.54700897e-003,
-       3.41880359e-002, 0., 0., 0., 0., 0., 8.54700897e-003,
-       8.54700897e-003, 0., 8.54700897e-003, 0., 1.70940179e-002, 0.,
-       8.54700897e-003, 0., 0., 1.70940179e-002, 0., 0., 0.,
-       8.54700897e-003, 0., 8.54700897e-003, 0., 0., 0., 0.,
-       1.70940179e-002, 0., 8.54700897e-003, 0., 0., 0., 0., 0., 0.,
-       8.54700897e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.54700897e-003, 0.,
-       8.54700897e-003, 8.54700897e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 2.56410278e-002, 0., 0., 0.,
-       7.69230798e-002, 0., 0., 0., 8.54700897e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.54700897e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.54700897e-003, 0., 0., 0., 0., 0., 0., 0.,
-       8.54700897e-003, 0., 0., 0., 8.54700897e-003, 0., 0., 0.,
-       8.54700897e-003, 0., 0., 0., 0., 0., 0., 0., 0., 8.54700897e-003,
-       0., 0., 0., 8.54700897e-003, 0., 0., 8.54700897e-003, 0.,
-       8.54700897e-003, 8.54700897e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.54700897e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.54700897e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.70940179e-002,
-       0., 0., 0., 0., 0., 0., 8.54700897e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.54700897e-003, 0., 0., 1.70940179e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 2.56410278e-002, 0.,
-       8.54700897e-003, 0., 0., 8.54700897e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.54700897e-003, 0., 0., 0.,
-       0., 2.56410278e-002, 0., 0., 0., 8.54700897e-003, 8.54700897e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.54700897e-003,
-       8.54700897e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.54700897e-003, 0., 8.54700897e-003, 0., 8.54700897e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.54700897e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.70940179e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.54700897e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.54700897e-003, 0., 0., 0., 0., 0.,
-       0., 0., 8.54700897e-003, 0., 8.54700897e-003, 0., 0., 0.,
-       8.54700897e-003, 0., 8.54700897e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.54700897e-003,
-       0., 0., 8.54700897e-003, 0., 8.54700897e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.54700897e-003, 0., 8.54700897e-003, 0., 0., 0., 0., 0.,
-       1.68067235e-002, 0., 0., 1.68067235e-002, 2.52100863e-002,
-       2.52100863e-002, 0., 0., 8.40336177e-003, 8.40336177e-003,
-       1.68067235e-002, 1.68067235e-002, 8.40336177e-003, 0., 0., 0., 0.,
-       1.68067235e-002, 0., 0., 0., 0., 8.40336177e-003, 0.,
-       8.40336177e-003, 0., 2.52100863e-002, 0., 0., 8.40336177e-003, 0.,
-       1.68067235e-002, 0., 1.68067235e-002, 0., 0., 0., 0.,
-       1.68067235e-002, 1.68067235e-002, 0., 0., 0., 8.40336177e-003, 0.,
-       1.68067235e-002, 1.68067235e-002, 1.68067235e-002,
-       3.36134471e-002, 0., 8.40336177e-003, 0., 8.40336177e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.40336177e-003, 0., 8.40336177e-003,
-       0., 0., 0., 0., 0., 0., 8.40336177e-003, 8.40336177e-003, 0., 0.,
-       0., 0., 8.40336177e-003, 0., 8.40336177e-003, 0., 8.40336177e-003,
-       0., 8.40336177e-003, 8.40336177e-003, 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 8.40336177e-003, 0., 0.,
-       2.52100863e-002, 0., 0., 0., 1.68067235e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 8.40336177e-003, 0., 0., 0., 8.40336177e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 1.68067235e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.40336177e-003, 0.,
-       1.68067235e-002, 0., 0., 0., 0., 0., 0., 0., 8.40336177e-003, 0.,
-       0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.68067235e-002, 0., 8.40336177e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.40336177e-003,
-       0., 0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 8.40336177e-003, 0., 0., 0., 0.,
-       0., 0., 8.40336177e-003, 0., 0., 0., 2.52100863e-002,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.68067235e-002, 0., 0.,
-       8.40336177e-003, 2.52100863e-002, 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.40336177e-003, 0., 0., 8.40336177e-003, 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 0., 8.40336177e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 2.52100863e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.40336177e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.68067235e-002,
-       1.68067235e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.68067235e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.68067235e-002, 0.,
-       8.40336177e-003, 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.39860138e-002, 0., 6.99300691e-003, 2.09790207e-002,
-       1.39860138e-002, 1.39860138e-002, 0., 0., 0., 0., 6.99300691e-003,
-       6.99300691e-003, 6.99300691e-003, 6.99300691e-003, 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 2.09790207e-002, 6.99300691e-003,
-       6.99300691e-003, 0., 2.79720277e-002, 0., 2.09790207e-002,
-       1.39860138e-002, 0., 6.99300691e-003, 0., 6.99300691e-003, 0., 0.,
-       0., 0., 2.79720277e-002, 1.39860138e-002, 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 4.89510484e-002, 6.99300691e-003, 0.,
-       0., 6.99300691e-003, 0., 0., 6.99300691e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.99300691e-003, 0., 0., 0., 0.,
-       1.39860138e-002, 0., 0., 6.99300691e-003, 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 6.99300691e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.39860138e-002, 0., 0.,
-       0., 0., 1.39860138e-002, 0., 0., 0., 0., 0., 6.99300691e-003, 0.,
-       4.89510484e-002, 6.99300691e-003, 0., 0., 1.39860138e-002, 0., 0.,
-       0., 0., 6.99300691e-003, 0., 0., 6.99300691e-003, 0., 0., 0., 0.,
-       2.79720277e-002, 6.99300691e-003, 0., 0., 6.99300691e-003, 0.,
-       1.39860138e-002, 0., 0., 0., 0., 6.99300691e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.99300691e-003, 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 6.99300691e-003,
-       0., 0., 6.99300691e-003, 0., 6.99300691e-003, 0., 0., 0., 0.,
-       6.99300691e-003, 6.99300691e-003, 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 6.99300691e-003, 6.99300691e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.99300691e-003, 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 6.99300691e-003, 0., 0.,
-       1.39860138e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 6.99300691e-003, 0., 0., 0., 0., 6.99300691e-003,
-       0., 0., 0., 0., 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 6.99300691e-003, 0., 0., 6.99300691e-003,
-       0., 1.39860138e-002, 0., 1.39860138e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.99300691e-003, 0., 6.99300691e-003, 0., 6.99300691e-003,
-       0., 0., 6.99300691e-003, 0., 0., 6.99300691e-003, 0., 0., 0.,
-       2.09790207e-002, 0., 0., 0., 0., 0., 0., 6.99300691e-003, 0., 0.,
-       0., 0., 0., 2.09790207e-002, 0., 0., 0., 0., 0., 6.99300691e-003,
-       0., 0., 0., 6.99300691e-003, 0., 6.99300691e-003, 0., 0., 0., 0.,
-       0., 0., 1.39860138e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 6.99300691e-003, 6.99300691e-003, 0., 0., 0.,
-       0., 0., 6.99300691e-003, 0., 0., 0., 0., 0., 1.39860138e-002, 0.,
-       0., 0., 0., 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.99300691e-003, 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 6.99300691e-003, 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.99300691e-003, 0., 0., 0., 0., 0., 6.99300691e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.99300691e-003, 0.,
-       0., 0., 0., 6.99300691e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.12820529e-003, 5.12820529e-003, 0.,
-       5.12820529e-003, 0., 2.05128212e-002, 0., 1.02564106e-002, 0., 0.,
-       5.12820529e-003, 0., 5.12820529e-003, 0., 5.12820529e-003,
-       5.12820529e-003, 0., 5.12820529e-003, 1.02564106e-002,
-       5.12820529e-003, 0., 0., 2.05128212e-002, 0., 0., 0.,
-       2.56410260e-002, 0., 0., 1.53846163e-002, 5.12820529e-003,
-       5.12820529e-003, 0., 5.12820529e-003, 0., 1.02564106e-002, 0.,
-       5.12820529e-003, 2.56410260e-002, 5.12820529e-003,
-       5.12820529e-003, 0., 5.12820529e-003, 5.12820529e-003, 0.,
-       1.02564106e-002, 0., 5.12820529e-003, 2.56410260e-002, 0., 0.,
-       1.02564106e-002, 0., 0., 0., 5.12820529e-003, 0., 1.02564106e-002,
-       0., 1.02564106e-002, 5.12820529e-003, 0., 5.12820529e-003, 0., 0.,
-       0., 0., 0., 1.02564106e-002, 0., 1.02564106e-002, 0.,
-       5.12820529e-003, 5.12820529e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.12820529e-003, 0., 0., 0.,
-       5.12820529e-003, 5.12820529e-003, 5.12820529e-003,
-       1.02564106e-002, 1.02564106e-002, 0., 0., 1.02564106e-002, 0.,
-       5.12820529e-003, 0., 5.12820529e-003, 5.12820529e-003, 0., 0.,
-       5.12820529e-003, 0., 5.12820529e-003, 0., 5.12820529e-003,
-       5.12820529e-003, 0., 5.12820529e-003, 0., 5.12820529e-003,
-       1.02564106e-002, 0., 0., 0., 0., 0., 0., 5.12820529e-003,
-       5.12820529e-003, 5.12820529e-003, 0., 0., 0., 1.53846163e-002, 0.,
-       5.12820529e-003, 0., 5.12820529e-003, 5.12820529e-003, 0., 0.,
-       5.12820529e-003, 0., 0., 0., 0., 2.05128212e-002, 5.12820529e-003,
-       5.12820529e-003, 5.12820529e-003, 0., 0., 0., 5.12820529e-003, 0.,
-       0., 0., 0., 0., 0., 5.12820529e-003, 0., 0., 0., 0., 0.,
-       5.12820529e-003, 5.12820529e-003, 1.02564106e-002, 0., 0., 0.,
-       5.12820529e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.12820529e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.12820529e-003,
-       0., 0., 0., 0., 5.12820529e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.02564106e-002, 0., 5.12820529e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.12820529e-003, 0., 0., 1.02564106e-002, 0., 0., 0.,
-       0., 5.12820529e-003, 0., 5.12820529e-003, 0., 0., 0., 0., 0., 0.,
-       5.12820529e-003, 0., 1.02564106e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.02564106e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.12820529e-003, 0., 5.12820529e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.12820529e-003, 0., 0., 0., 0., 5.12820529e-003,
-       0., 0., 5.12820529e-003, 0., 5.12820529e-003, 0., 5.12820529e-003,
-       0., 1.02564106e-002, 0., 0., 5.12820529e-003, 1.53846163e-002, 0.,
-       0., 1.02564106e-002, 0., 0., 0., 0., 0., 0., 5.12820529e-003, 0.,
-       0., 0., 0., 0., 1.02564106e-002, 5.12820529e-003, 0., 0., 0., 0.,
-       1.02564106e-002, 1.02564106e-002, 0., 5.12820529e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.12820529e-003, 0., 0., 0., 1.02564106e-002, 0., 0., 0., 0., 0.,
-       0., 1.02564106e-002, 0., 0., 0., 0., 0., 5.12820529e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.02564106e-002, 0., 5.12820529e-003,
-       0., 0., 0., 0., 5.12820529e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.12820529e-003, 0.,
-       0., 5.12820529e-003, 0., 0., 0., 5.12820529e-003, 0., 0., 0., 0.,
-       0., 5.12820529e-003, 0., 0., 5.12820529e-003, 0., 0., 0., 0., 0.,
-       2.05128212e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.12820529e-003, 0., 0., 0., 0., 0., 0., 5.12820529e-003,
-       5.12820529e-003, 0., 0., 0., 1.02564106e-002, 0., 0.,
-       5.12820529e-003, 0., 5.12820529e-003, 0., 0., 0., 5.12820529e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.12820529e-003, 0., 0., 0., 0.,
-       0., 0., 5.12820529e-003, 0., 0., 1.02564106e-002, 0.,
-       5.12820529e-003, 0., 0., 5.12820529e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.12820529e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.02564106e-002, 0.,
-       5.12820529e-003, 0., 5.12820529e-003, 0., 0., 0., 5.12820529e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.12820529e-003, 0.,
-       5.12820529e-003, 0., 5.12820529e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.12820529e-003, 0., 0., 0., 0., 1.68539323e-002, 0.,
-       1.12359552e-002, 5.61797759e-003, 1.12359552e-002,
-       1.12359552e-002, 0., 1.12359552e-002, 5.61797759e-003, 0., 0., 0.,
-       5.61797759e-003, 0., 1.68539323e-002, 0., 0., 1.12359552e-002,
-       5.61797759e-003, 0., 0., 0., 5.61797759e-003, 0., 0.,
-       5.61797759e-003, 1.68539323e-002, 0., 0., 5.61797759e-003, 0., 0.,
-       0., 0., 5.61797759e-003, 1.68539323e-002, 0., 0., 5.61797759e-003,
-       5.61797759e-003, 5.61797759e-003, 5.61797759e-003, 0.,
-       5.61797759e-003, 0., 1.68539323e-002, 0., 5.61797759e-003,
-       1.68539323e-002, 0., 5.61797759e-003, 5.61797759e-003,
-       5.61797759e-003, 5.61797759e-003, 5.61797759e-003,
-       1.12359552e-002, 0., 5.61797759e-003, 5.61797759e-003,
-       5.61797759e-003, 0., 0., 0., 5.61797759e-003, 5.61797759e-003, 0.,
-       0., 0., 5.61797759e-003, 5.61797759e-003, 0., 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 1.12359552e-002,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0., 5.61797759e-003,
-       0., 0., 5.61797759e-003, 0., 0., 5.61797759e-003, 0.,
-       5.61797759e-003, 5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0.,
-       0., 1.12359552e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0.,
-       0., 1.68539323e-002, 0., 0., 5.61797759e-003, 2.24719103e-002, 0.,
-       0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 5.61797759e-003,
-       0., 0., 1.12359552e-002, 1.68539323e-002, 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 1.12359552e-002,
-       5.61797759e-003, 0., 0., 0., 5.61797759e-003, 1.68539323e-002,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.12359552e-002, 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 5.61797759e-003, 0., 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 5.61797759e-003,
-       5.61797759e-003, 1.12359552e-002, 5.61797759e-003, 0., 0., 0., 0.,
-       1.12359552e-002, 0., 0., 1.12359552e-002, 0., 0., 0., 0.,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.12359552e-002, 0., 0., 0., 0.,
-       2.24719103e-002, 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       1.12359552e-002, 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.61797759e-003, 0., 0., 0., 1.12359552e-002, 0.,
-       1.12359552e-002, 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 0., 0., 1.12359552e-002,
-       0., 0., 5.61797759e-003, 0., 0., 1.12359552e-002, 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       0., 0., 0., 0., 0., 2.24719103e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.61797759e-003, 1.12359552e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.12359552e-002,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 1.12359552e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 5.61797759e-003, 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 1.68539323e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.40540554e-003, 1.62162166e-002,
-       5.40540554e-003, 0., 5.40540554e-003, 2.70270277e-002, 0.,
-       1.62162166e-002, 5.40540554e-003, 1.62162166e-002,
-       1.62162166e-002, 5.40540554e-003, 5.40540554e-003, 0., 0., 0.,
-       5.40540554e-003, 1.62162166e-002, 1.08108111e-002, 0., 0., 0.,
-       5.40540554e-003, 0., 0., 0., 1.08108111e-002, 5.40540554e-003, 0.,
-       5.40540554e-003, 1.62162166e-002, 5.40540554e-003, 0.,
-       1.08108111e-002, 5.40540554e-003, 5.40540554e-003, 0., 0.,
-       1.08108111e-002, 0., 5.40540554e-003, 0., 5.40540554e-003,
-       1.08108111e-002, 0., 5.40540554e-003, 5.40540554e-003,
-       1.08108111e-002, 2.16216221e-002, 5.40540554e-003, 0., 0., 0., 0.,
-       5.40540554e-003, 1.08108111e-002, 0., 1.08108111e-002, 0., 0., 0.,
-       0., 0., 5.40540554e-003, 1.08108111e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.40540554e-003, 0., 5.40540554e-003,
-       5.40540554e-003, 0., 0., 0., 5.40540554e-003, 0., 0., 0.,
-       1.08108111e-002, 0., 0., 0., 5.40540554e-003, 0., 5.40540554e-003,
-       0., 5.40540554e-003, 5.40540554e-003, 0., 1.08108111e-002, 0., 0.,
-       0., 0., 0., 5.40540554e-003, 0., 1.08108111e-002, 0., 0., 0.,
-       1.08108111e-002, 5.40540554e-003, 5.40540554e-003,
-       1.08108111e-002, 5.94594628e-002, 5.40540554e-003, 0., 0., 0., 0.,
-       5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 5.40540554e-003,
-       1.08108111e-002, 0., 0., 0., 5.40540554e-003, 5.40540554e-003, 0.,
-       5.40540554e-003, 0., 0., 0., 0., 5.40540554e-003, 5.40540554e-003,
-       0., 5.40540554e-003, 0., 0., 0., 5.40540554e-003, 5.40540554e-003,
-       0., 5.40540554e-003, 0., 5.40540554e-003, 0., 0., 5.40540554e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.40540554e-003, 0., 0., 0., 5.40540554e-003, 0., 0.,
-       5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 5.40540554e-003, 0.,
-       1.08108111e-002, 0., 0., 0., 0., 0., 0., 5.40540554e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.40540554e-003, 0., 0., 3.24324332e-002, 1.62162166e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.40540554e-003, 0., 0., 0.,
-       5.40540554e-003, 0., 5.40540554e-003, 0., 5.40540554e-003, 0.,
-       5.40540554e-003, 0., 5.40540554e-003, 5.40540554e-003,
-       5.40540554e-003, 0., 0., 0., 0., 0., 0., 5.40540554e-003, 0., 0.,
-       0., 0., 0., 5.40540554e-003, 0., 0., 0., 5.40540554e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 5.40540554e-003,
-       5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.08108111e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.62162166e-002, 0., 0., 0., 0.,
-       5.40540554e-003, 0., 0., 0., 0., 0., 5.40540554e-003, 0., 0.,
-       5.40540554e-003, 0., 0., 0., 0., 0., 5.40540554e-003, 0., 0., 0.,
-       0., 0., 5.40540554e-003, 0., 5.40540554e-003, 5.40540554e-003, 0.,
-       0., 0., 0., 0., 0., 0., 5.40540554e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.40540554e-003, 5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.40540554e-003, 0., 0., 5.40540554e-003, 0., 5.40540554e-003,
-       5.40540554e-003, 0., 5.40540554e-003, 5.40540554e-003, 0., 0., 0.,
-       1.08108111e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.40540554e-003, 0., 0., 0., 5.40540554e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.40540554e-003, 0., 0., 0., 5.40540554e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.08108111e-002, 0., 0.,
-       1.08108111e-002, 0., 0., 5.40540554e-003, 1.08108111e-002, 0., 0.,
-       0., 0., 0., 0., 1.08108111e-002, 5.40540554e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0.,
-       5.78034669e-003, 0., 1.15606934e-002, 0., 1.15606934e-002,
-       5.78034669e-003, 0., 1.15606934e-002, 0., 1.73410401e-002,
-       1.15606934e-002, 5.78034669e-003, 1.15606934e-002,
-       1.15606934e-002, 0., 0., 0., 4.62427735e-002, 5.78034669e-003, 0.,
-       5.78034669e-003, 2.31213868e-002, 0., 5.78034669e-003,
-       1.15606934e-002, 1.15606934e-002, 5.78034669e-003,
-       5.78034669e-003, 1.73410401e-002, 5.78034669e-003, 0., 0., 0.,
-       1.15606934e-002, 1.73410401e-002, 5.78034669e-003, 0., 0.,
-       5.78034669e-003, 0., 1.15606934e-002, 1.15606934e-002,
-       5.78034669e-003, 1.15606934e-002, 1.15606934e-002, 0., 0., 0., 0.,
-       0., 5.78034669e-003, 0., 0., 0., 1.15606934e-002, 0., 0., 0., 0.,
-       1.15606934e-002, 0., 5.78034669e-003, 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 5.78034669e-003, 0.,
-       5.78034669e-003, 0., 0., 5.78034669e-003, 0., 5.78034669e-003, 0.,
-       1.15606934e-002, 0., 0., 5.78034669e-003, 0., 0., 0.,
-       5.78034669e-003, 1.15606934e-002, 0., 0., 0., 0., 1.15606934e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0.,
-       0., 0., 0., 1.15606934e-002, 5.78034669e-003, 5.78034669e-003, 0.,
-       0., 0., 0., 0., 0., 0., 1.15606934e-002, 0., 0., 0.,
-       1.73410401e-002, 1.15606934e-002, 0., 0., 0., 5.78034669e-003, 0.,
-       0., 1.15606934e-002, 0., 0., 5.78034669e-003, 0., 1.15606934e-002,
-       0., 0., 5.78034669e-003, 0., 0., 5.78034669e-003, 0., 0., 0., 0.,
-       5.78034669e-003, 5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.15606934e-002, 5.78034669e-003, 1.15606934e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.15606934e-002, 0., 5.78034669e-003, 0., 0.,
-       5.78034669e-003, 0., 0., 5.78034669e-003, 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.78034669e-003, 0., 0., 0., 5.78034669e-003, 0.,
-       5.78034669e-003, 0., 0., 1.15606934e-002, 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 1.15606934e-002, 0., 0., 5.78034669e-003,
-       0., 0., 0., 1.15606934e-002, 0., 0., 0., 5.78034669e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 5.78034669e-003, 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 5.78034669e-003, 0., 0., 0.,
-       1.15606934e-002, 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.15606934e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0., 5.78034669e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003,
-       0., 1.15606934e-002, 0., 1.15606934e-002, 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.78034669e-003, 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.78034669e-003, 0., 0., 5.78034669e-003, 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 5.78034669e-003, 5.78034669e-003,
-       1.15606934e-002, 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.15606934e-002, 0., 0., 0., 1.73410401e-002, 0., 0., 0., 0., 0.,
-       0., 1.15606934e-002, 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0.,
-       0., 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0., 0., 0.,
-       1.15606934e-002, 0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003,
-       0., 5.49450563e-003, 0., 0., 0., 1.09890113e-002, 5.49450563e-003,
-       0., 1.64835174e-002, 0., 5.49450563e-003, 5.49450563e-003, 0.,
-       2.19780225e-002, 1.09890113e-002, 1.09890113e-002,
-       5.49450563e-003, 5.49450563e-003, 0., 5.49450563e-003,
-       2.19780225e-002, 0., 1.64835174e-002, 2.19780225e-002, 0., 0., 0.,
-       4.94505502e-002, 0., 2.19780225e-002, 5.49450563e-003,
-       1.64835174e-002, 1.09890113e-002, 0., 1.09890113e-002,
-       1.09890113e-002, 0., 0., 0., 1.64835174e-002, 0., 0., 0., 0., 0.,
-       1.09890113e-002, 0., 0., 1.09890113e-002, 1.09890113e-002, 0., 0.,
-       1.09890113e-002, 5.49450563e-003, 5.49450563e-003,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 2.19780225e-002, 0.,
-       0., 0., 0., 0., 5.49450563e-003, 5.49450563e-003, 0., 0., 0.,
-       5.49450563e-003, 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 5.49450563e-003, 0., 0., 0., 5.49450563e-003,
-       0., 0., 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0.,
-       5.49450563e-003, 1.09890113e-002, 0., 0., 1.09890113e-002, 0., 0.,
-       0., 0., 5.49450563e-003, 0., 0., 5.49450563e-003, 5.49450563e-003,
-       5.49450563e-003, 0., 0., 0., 5.49450563e-003, 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 2.19780225e-002, 0., 0.,
-       1.09890113e-002, 5.49450563e-003, 0., 0., 0., 5.49450563e-003,
-       5.49450563e-003, 0., 0., 5.49450563e-003, 0., 0., 0.,
-       5.49450563e-003, 0., 0., 5.49450563e-003, 0., 5.49450563e-003, 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 5.49450563e-003, 0., 0.,
-       1.64835174e-002, 0., 5.49450563e-003, 0., 0., 1.09890113e-002,
-       1.09890113e-002, 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0.,
-       5.49450563e-003, 5.49450563e-003, 5.49450563e-003, 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 5.49450563e-003, 0.,
-       0., 0., 5.49450563e-003, 5.49450563e-003, 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 5.49450563e-003, 0.,
-       0., 0., 1.09890113e-002, 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 2.19780225e-002,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.09890113e-002,
-       0., 5.49450563e-003, 0., 0., 0., 1.09890113e-002, 1.09890113e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.09890113e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.49450563e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 2.19780225e-002, 0., 0., 0.,
-       0., 5.49450563e-003, 0., 0., 0., 0., 0., 1.09890113e-002, 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.49450563e-003,
-       0., 0., 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.49450563e-003,
-       0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.09890113e-002, 0., 5.49450563e-003, 1.09890113e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.49450563e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.49450563e-003, 0., 0., 0.,
-       0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       5.49450563e-003, 1.64835174e-002, 0., 0., 0., 1.09890113e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 5.49450563e-003, 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 5.49450563e-003, 0., 0.,
-       0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.08695654e-002, 0., 5.43478271e-003, 5.43478271e-003,
-       5.43478271e-003, 0., 5.43478271e-003, 3.26086953e-002,
-       5.43478271e-003, 0., 1.08695654e-002, 0., 1.08695654e-002,
-       5.43478271e-003, 1.08695654e-002, 5.43478271e-003, 0.,
-       1.08695654e-002, 1.08695654e-002, 5.43478271e-003, 0., 0.,
-       1.63043477e-002, 1.08695654e-002, 0., 0., 3.26086953e-002,
-       5.43478271e-003, 5.43478271e-003, 2.17391308e-002,
-       1.08695654e-002, 0., 0., 0., 5.43478271e-003, 0., 0.,
-       5.43478271e-003, 5.43478271e-003, 5.43478271e-003, 0.,
-       5.43478271e-003, 0., 0., 0., 1.08695654e-002, 5.43478271e-003,
-       1.63043477e-002, 5.43478271e-003, 1.08695654e-002, 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 1.08695654e-002,
-       1.08695654e-002, 5.43478271e-003, 0., 0., 0., 0., 1.08695654e-002,
-       1.08695654e-002, 0., 2.17391308e-002, 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0.,
-       0., 0., 1.08695654e-002, 5.43478271e-003, 0., 0., 2.17391308e-002,
-       0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 5.43478271e-003,
-       1.08695654e-002, 0., 0., 0., 0., 5.43478271e-003, 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 3.26086953e-002, 0., 0.,
-       5.43478271e-003, 2.17391308e-002, 0., 0., 5.43478271e-003,
-       5.43478271e-003, 5.43478271e-003, 0., 0., 1.08695654e-002, 0.,
-       5.43478271e-003, 0., 0., 0., 0., 1.63043477e-002, 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0.,
-       2.17391308e-002, 5.43478271e-003, 0., 0., 5.43478271e-003, 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.43478271e-003, 0., 0., 5.43478271e-003, 0.,
-       5.43478271e-003, 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0.,
-       5.43478271e-003, 5.43478271e-003, 0., 5.43478271e-003, 0., 0., 0.,
-       0., 0., 0., 5.43478271e-003, 0., 1.63043477e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003,
-       0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.08695654e-002, 0., 0., 5.43478271e-003, 0.,
-       1.08695654e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.43478271e-003, 0., 0., 0., 1.08695654e-002, 0., 0.,
-       0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0.,
-       1.08695654e-002, 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0.,
-       0., 5.43478271e-003, 0., 0., 0., 0., 0., 1.08695654e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0.,
-       0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 5.43478271e-003,
-       5.43478271e-003, 0., 0., 0., 5.43478271e-003, 0., 0.,
-       5.43478271e-003, 0., 5.43478271e-003, 0., 5.43478271e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.43478271e-003, 5.43478271e-003, 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0.,
-       1.08695654e-002, 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0.,
-       0., 0., 0., 0., 0., 5.43478271e-003, 0., 5.43478271e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 1.08695654e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.17391308e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 4.99999989e-003, 9.99999978e-003, 4.99999989e-003,
-       1.49999997e-002, 9.99999978e-003, 4.99999989e-003, 0., 0.,
-       4.99999989e-003, 9.99999978e-003, 9.99999978e-003,
-       4.99999989e-003, 1.99999996e-002, 0., 1.49999997e-002,
-       4.99999989e-003, 0., 9.99999978e-003, 9.99999978e-003,
-       9.99999978e-003, 0., 4.99999989e-003, 1.49999997e-002, 0., 0., 0.,
-       4.99999989e-003, 0., 9.99999978e-003, 0., 0., 1.49999997e-002, 0.,
-       0., 1.99999996e-002, 0., 0., 4.99999989e-003, 4.99999989e-003,
-       9.99999978e-003, 0., 9.99999978e-003, 0., 1.49999997e-002, 0.,
-       4.99999989e-003, 0., 4.99999989e-003, 3.50000001e-002, 0., 0.,
-       4.99999989e-003, 0., 0., 0., 0., 0., 0., 4.99999989e-003, 0., 0.,
-       0., 4.99999989e-003, 0., 9.99999978e-003, 0., 0., 0., 0., 0., 0.,
-       0., 4.99999989e-003, 4.99999989e-003, 0., 4.99999989e-003, 0., 0.,
-       0., 0., 0., 0., 9.99999978e-003, 0., 4.99999989e-003, 0., 0.,
-       4.99999989e-003, 4.99999989e-003, 0., 0., 0., 0., 4.99999989e-003,
-       0., 0., 0., 0., 0., 9.99999978e-003, 0., 9.99999978e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 4.99999989e-003, 1.49999997e-002,
-       9.99999978e-003, 0., 0., 0., 0., 0., 0., 9.99999978e-003,
-       9.99999978e-003, 0., 0., 0., 0., 1.49999997e-002, 4.99999989e-003,
-       0., 4.99999989e-003, 3.50000001e-002, 0., 0., 0., 0., 0.,
-       4.99999989e-003, 0., 9.99999978e-003, 0., 0., 4.99999989e-003, 0.,
-       4.99999989e-003, 0., 2.99999993e-002, 0., 0., 0., 4.99999989e-003,
-       0., 0., 4.99999989e-003, 0., 4.99999989e-003, 0., 0., 0., 0., 0.,
-       4.99999989e-003, 0., 0., 4.99999989e-003, 4.99999989e-003,
-       4.99999989e-003, 4.99999989e-003, 4.99999989e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       4.99999989e-003, 0., 4.99999989e-003, 0., 0., 4.99999989e-003, 0.,
-       4.99999989e-003, 0., 0., 4.99999989e-003, 0., 0., 4.99999989e-003,
-       4.99999989e-003, 9.99999978e-003, 0., 0., 0., 0., 0., 0.,
-       4.99999989e-003, 0., 0., 0., 0., 0., 4.99999989e-003,
-       4.99999989e-003, 0., 0., 4.99999989e-003, 0., 0., 0., 0., 0.,
-       4.99999989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 9.99999978e-003,
-       4.99999989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 4.99999989e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 4.99999989e-003, 0., 0., 4.99999989e-003, 9.99999978e-003,
-       4.99999989e-003, 0., 0., 0., 0., 0., 0., 0., 4.99999989e-003, 0.,
-       4.99999989e-003, 0., 4.99999989e-003, 0., 4.99999989e-003,
-       4.99999989e-003, 0., 0., 0., 0., 9.99999978e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       4.99999989e-003, 4.99999989e-003, 0., 0., 4.99999989e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 4.99999989e-003, 0., 0., 0., 0.,
-       4.99999989e-003, 4.99999989e-003, 0., 4.99999989e-003, 0., 0., 0.,
-       0., 0., 0., 0., 1.49999997e-002, 0., 9.99999978e-003, 0.,
-       4.99999989e-003, 0., 0., 0., 0., 0., 9.99999978e-003, 0., 0., 0.,
-       0., 0., 4.99999989e-003, 4.99999989e-003, 4.99999989e-003, 0., 0.,
-       0., 0., 0., 0., 4.99999989e-003, 0., 0., 0., 9.99999978e-003, 0.,
-       0., 4.99999989e-003, 0., 0., 0., 9.99999978e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 4.99999989e-003, 0., 0., 0., 9.99999978e-003, 0.,
-       0., 0., 0., 4.99999989e-003, 0., 0., 9.99999978e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 4.99999989e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.99999978e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 4.99999989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       4.99999989e-003, 0., 0., 9.99999978e-003, 0., 4.99999989e-003,
-       9.99999978e-003, 0., 0., 0., 4.99999989e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 4.99999989e-003, 0., 4.99999989e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 4.99999989e-003, 0.,
-       0., 0., 0., 0., 0., 4.99999989e-003, 0., 4.99999989e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       4.99999989e-003, 0., 0., 0., 0., 0., 4.99999989e-003, 0., 0., 0.,
-       0., 5.81395347e-003, 1.16279069e-002, 0., 0., 0., 5.81395347e-003,
-       0., 0., 1.16279069e-002, 2.90697664e-002, 1.16279069e-002, 0., 0.,
-       0., 5.81395347e-003, 0., 0., 5.81395347e-003, 0., 1.16279069e-002,
-       5.81395347e-003, 1.16279069e-002, 5.81395347e-003, 0.,
-       5.81395347e-003, 0., 5.81395347e-003, 0., 0., 2.32558139e-002,
-       5.81395347e-003, 2.90697664e-002, 0., 5.81395347e-003, 0., 0., 0.,
-       0., 2.90697664e-002, 5.81395347e-003, 5.81395347e-003, 0.,
-       5.81395347e-003, 5.81395347e-003, 0., 0., 0., 5.81395347e-003,
-       4.06976752e-002, 0., 0., 5.81395347e-003, 5.81395347e-003, 0., 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.81395347e-003,
-       5.81395347e-003, 0., 0., 0., 0., 5.81395347e-003, 0.,
-       5.81395347e-003, 5.81395347e-003, 5.81395347e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0.,
-       5.81395347e-003, 0., 0., 0., 1.16279069e-002, 0., 0., 0., 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.81395347e-003, 0., 5.81395347e-003, 0., 0., 0.,
-       1.16279069e-002, 0., 0., 0., 0., 0., 4.06976752e-002,
-       5.81395347e-003, 0., 5.81395347e-003, 8.13953504e-002,
-       1.16279069e-002, 0., 0., 0., 5.81395347e-003, 0., 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 5.81395347e-003,
-       5.81395347e-003, 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0.,
-       5.81395328e-002, 0., 1.74418613e-002, 0., 5.81395347e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 5.81395347e-003,
-       0., 0., 5.81395347e-003, 0., 0., 5.81395347e-003, 0.,
-       5.81395347e-003, 0., 5.81395347e-003, 5.81395347e-003, 0., 0., 0.,
-       0., 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.81395347e-003,
-       0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0.,
-       0., 0., 0., 0., 1.74418613e-002, 0., 5.81395347e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0.,
-       5.81395347e-003, 0., 5.81395347e-003, 0., 0., 0., 5.81395347e-003,
-       1.74418613e-002, 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.81395347e-003, 0., 1.16279069e-002, 0., 0., 0., 0.,
-       0., 5.81395347e-003, 0., 0., 5.81395347e-003, 0., 0., 0.,
-       1.16279069e-002, 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0.,
-       0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 5.81395347e-003,
-       0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 1.16279069e-002,
-       0., 0., 0., 0., 0., 0., 0., 1.74418613e-002, 5.81395347e-003,
-       5.81395347e-003, 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.16279069e-002, 0., 0.,
-       0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.16279069e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.16279069e-002, 0., 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.16279069e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.19047621e-002, 5.95238106e-003, 0.,
-       0., 5.95238106e-003, 0., 0., 0., 1.19047621e-002, 1.19047621e-002,
-       0., 5.95238106e-003, 5.95238106e-003, 1.19047621e-002,
-       5.95238106e-003, 5.95238106e-003, 0., 5.95238106e-003,
-       1.19047621e-002, 0., 0., 5.95238106e-003, 0., 0., 1.19047621e-002,
-       5.95238106e-003, 5.95238106e-003, 1.78571437e-002, 0.,
-       5.95238106e-003, 1.78571437e-002, 0., 1.19047621e-002, 0.,
-       5.95238106e-003, 0., 0., 5.95238106e-003, 1.19047621e-002, 0., 0.,
-       0., 0., 0., 1.19047621e-002, 0., 0., 2.38095243e-002,
-       5.95238106e-003, 0., 0., 0., 5.95238106e-003, 0., 0., 0.,
-       5.95238106e-003, 5.95238106e-003, 0., 0., 0., 5.95238106e-003,
-       1.19047621e-002, 1.78571437e-002, 0., 0., 0., 0., 0.,
-       1.19047621e-002, 0., 0., 0., 5.95238106e-003, 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 5.95238106e-003, 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 1.78571437e-002, 5.95238106e-003,
-       1.19047621e-002, 5.95238106e-003, 5.95238106e-003, 0.,
-       5.95238106e-003, 0., 0., 5.95238106e-003, 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 1.19047621e-002, 0., 0., 0.,
-       0., 1.19047621e-002, 5.95238106e-003, 5.95238106e-003,
-       5.95238106e-003, 0., 0., 5.95238106e-003, 0., 0., 0.,
-       5.95238106e-003, 0., 2.38095243e-002, 0., 0., 0., 1.78571437e-002,
-       1.19047621e-002, 0., 5.95238106e-003, 0., 1.19047621e-002, 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 5.95238106e-003, 5.95238106e-003,
-       0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0.,
-       1.19047621e-002, 5.95238106e-003, 0., 1.19047621e-002, 0., 0., 0.,
-       0., 5.95238106e-003, 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0.,
-       0., 0., 5.95238106e-003, 0., 1.19047621e-002, 0., 0.,
-       5.95238106e-003, 0., 0., 0., 2.38095243e-002, 5.95238106e-003,
-       1.19047621e-002, 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.95238106e-003, 5.95238106e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0.,
-       5.95238106e-003, 0., 0., 0., 5.95238106e-003, 0., 5.95238106e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.19047621e-002,
-       1.19047621e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 5.95238106e-003,
-       0., 0., 0., 5.95238106e-003, 0., 5.95238106e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.78571437e-002, 0., 0., 0., 5.95238106e-003,
-       0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0.,
-       0., 5.95238106e-003, 0., 0., 0., 0., 0., 5.95238106e-003, 0.,
-       1.19047621e-002, 0., 5.95238106e-003, 0., 0., 0., 0.,
-       1.19047621e-002, 0., 5.95238106e-003, 0., 5.95238106e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003,
-       0., 5.95238106e-003, 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.95238106e-003, 0., 0., 0., 1.19047621e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0.,
-       5.95238106e-003, 5.95238106e-003, 5.95238106e-003, 0., 0., 0., 0.,
-       0., 0., 0., 5.95238106e-003, 0., 0., 0., 5.95238106e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.19047621e-002, 0.,
-       5.95238106e-003, 0., 5.95238106e-003, 0., 0., 5.95238106e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003,
-       0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 5.95238106e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.63043477e-002, 1.08695654e-002,
-       0., 5.43478271e-003, 0., 2.17391308e-002, 0., 0., 0.,
-       1.63043477e-002, 0., 0., 1.08695654e-002, 5.43478271e-003,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 2.17391308e-002,
-       5.43478271e-003, 0., 5.43478271e-003, 5.43478271e-003, 0.,
-       1.08695654e-002, 5.43478271e-003, 0., 1.08695654e-002, 0.,
-       1.08695654e-002, 0., 5.43478271e-003, 0., 5.43478271e-003, 0.,
-       5.43478271e-003, 5.43478271e-003, 0., 5.43478271e-003, 0.,
-       1.08695654e-002, 5.43478271e-003, 0., 1.08695654e-002,
-       2.17391308e-002, 0., 0., 0., 0., 0., 0., 1.63043477e-002, 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 1.63043477e-002, 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 5.43478271e-003, 0.,
-       5.43478271e-003, 0., 0., 5.43478271e-003, 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 2.17391308e-002, 0., 0., 5.43478271e-003,
-       0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.71739140e-002, 0., 5.43478271e-003, 5.43478271e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0.,
-       2.71739140e-002, 0., 0., 0., 6.52173907e-002, 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 1.08695654e-002,
-       5.43478271e-003, 0., 0., 0., 0., 5.43478271e-003, 5.43478271e-003,
-       0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 1.63043477e-002, 0.,
-       0., 0., 0., 0., 1.63043477e-002, 0., 5.43478271e-003, 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.08695654e-002, 0., 0.,
-       0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 1.08695654e-002,
-       0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 3.80434804e-002, 0., 5.43478271e-003, 5.43478271e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003,
-       0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 5.43478271e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.43478271e-003, 0., 0., 5.43478271e-003, 0., 1.63043477e-002,
-       0., 5.43478271e-003, 5.43478271e-003, 0., 0., 1.08695654e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003,
-       0., 0., 0., 1.08695654e-002, 1.63043477e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.08695654e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.08695654e-002, 0., 1.08695654e-002, 0., 0., 0.,
-       0., 5.43478271e-003, 0., 0., 1.08695654e-002, 0., 0.,
-       5.43478271e-003, 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 5.43478271e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.08695654e-002, 0., 0.,
-       0., 1.08695654e-002, 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003,
-       0., 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 1.08695654e-002,
-       0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 5.43478271e-003, 0., 0.,
-       5.43478271e-003, 1.63043477e-002, 5.43478271e-003, 0., 0.,
-       5.43478271e-003, 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0.,
-       0., 5.43478271e-003, 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 5.43478271e-003, 0., 1.08695654e-002, 0.,
-       0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0.,
-       0., 2.38095243e-002, 0., 5.95238106e-003, 0., 0., 5.95238106e-003,
-       0., 0., 5.95238106e-003, 1.19047621e-002, 0., 0., 1.19047621e-002,
-       0., 1.19047621e-002, 0., 0., 3.57142873e-002, 0., 0., 0.,
-       1.19047621e-002, 5.95238106e-003, 5.95238106e-003, 0., 0.,
-       3.57142873e-002, 0., 1.19047621e-002, 1.78571437e-002,
-       5.95238106e-003, 2.38095243e-002, 0., 0., 5.95238106e-003, 0., 0.,
-       5.95238106e-003, 0., 2.38095243e-002, 0., 0., 0., 0., 0.,
-       5.95238106e-003, 5.95238106e-003, 5.95238106e-003,
-       5.95238106e-003, 0., 0., 0., 0., 5.95238106e-003, 0.,
-       5.95238106e-003, 0., 0., 1.19047621e-002, 0., 0., 0.,
-       1.78571437e-002, 0., 5.95238106e-003, 0., 0., 5.95238106e-003,
-       5.95238106e-003, 5.95238106e-003, 0., 0., 0., 0., 5.95238106e-003,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 1.19047621e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003,
-       5.95238106e-003, 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.19047621e-002, 0.,
-       0., 0., 2.97619049e-002, 0., 0., 0., 5.95238106e-003, 0.,
-       2.38095243e-002, 0., 0., 0., 1.19047621e-002, 0., 0., 0., 0., 0.,
-       0., 0., 1.19047621e-002, 0., 0., 1.19047621e-002, 0.,
-       1.19047621e-002, 0., 0., 0., 0., 0., 1.78571437e-002, 0., 0., 0.,
-       0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0.,
-       4.16666679e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003,
-       0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0.,
-       5.95238106e-003, 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.95238106e-003, 0., 0., 0., 0., 0., 5.95238106e-003,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.95238106e-003, 0., 0., 5.95238106e-003, 0., 0., 0.,
-       5.95238106e-003, 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003,
-       0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 1.19047621e-002, 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.95238106e-003, 5.95238106e-003, 0., 0.,
-       1.19047621e-002, 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.19047621e-002, 0., 5.95238106e-003, 0., 0.,
-       0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 1.19047621e-002, 0., 5.95238106e-003,
-       1.19047621e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0.,
-       0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 5.95238106e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.19047621e-002, 0., 0., 5.95238106e-003, 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0.,
-       1.78571437e-002, 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 2.97619049e-002, 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.95238106e-003, 1.78571437e-002, 5.95238106e-003, 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0.,
-       0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 5.95238106e-003, 0.,
-       1.75438598e-002, 5.84795326e-003, 5.84795326e-003, 0.,
-       5.84795326e-003, 5.84795326e-003, 0., 5.84795326e-003,
-       1.16959065e-002, 5.84795326e-003, 5.84795326e-003,
-       5.84795326e-003, 5.84795326e-003, 5.84795326e-003, 0.,
-       5.84795326e-003, 0., 1.16959065e-002, 0., 5.84795326e-003, 0., 0.,
-       0., 0., 0., 0., 1.16959065e-002, 0., 5.84795326e-003, 0., 0.,
-       5.26315793e-002, 0., 5.84795326e-003, 0., 0., 0., 0., 0.,
-       1.75438598e-002, 0., 0., 5.84795326e-003, 0., 5.84795326e-003,
-       1.75438598e-002, 0., 0., 1.75438598e-002, 5.84795326e-003, 0., 0.,
-       0., 0., 5.84795326e-003, 1.16959065e-002, 0., 1.75438598e-002, 0.,
-       0., 0., 0., 5.84795326e-003, 0., 1.16959065e-002, 5.84795326e-003,
-       0., 0., 1.16959065e-002, 0., 0., 0., 5.84795326e-003, 0., 0., 0.,
-       1.16959065e-002, 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.84795326e-003, 0., 0., 1.75438598e-002, 0.,
-       1.16959065e-002, 5.84795326e-003, 0., 0., 0., 5.84795326e-003,
-       5.84795326e-003, 0., 5.84795326e-003, 1.16959065e-002, 0., 0., 0.,
-       0., 5.84795326e-003, 0., 0., 1.16959065e-002, 5.84795326e-003, 0.,
-       0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 1.75438598e-002, 0., 0., 0., 3.50877196e-002, 0.,
-       0., 5.84795326e-003, 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0.,
-       0., 5.84795326e-003, 5.84795326e-003, 0., 0., 0., 0.,
-       5.84795326e-003, 5.84795326e-003, 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 1.75438598e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 5.84795326e-003,
-       1.16959065e-002, 0., 0., 0., 0., 1.16959065e-002, 0., 0.,
-       5.84795326e-003, 0., 0., 5.84795326e-003, 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 5.84795326e-003, 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.16959065e-002, 0., 0., 0., 0., 1.16959065e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 0.,
-       5.84795326e-003, 0., 0., 5.84795326e-003, 0., 5.84795326e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 2.33918130e-002,
-       0., 1.16959065e-002, 1.75438598e-002, 0., 0., 0., 0.,
-       5.84795326e-003, 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.16959065e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.16959065e-002, 0., 0., 0., 0.,
-       1.75438598e-002, 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.16959065e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.16959065e-002, 0., 0., 0., 2.92397663e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 5.84795326e-003, 2.33918130e-002,
-       5.84795326e-003, 5.84795326e-003, 1.16959065e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 5.84795326e-003, 0.,
-       0., 1.16959065e-002, 0., 5.84795326e-003, 0., 0., 5.84795326e-003,
-       0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.16959065e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 5.84795326e-003,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 2.06185561e-002, 0., 5.15463902e-003, 0.,
-       5.15463902e-003, 1.54639166e-002, 1.54639166e-002, 0.,
-       5.15463902e-003, 0., 0., 0., 1.03092780e-002, 1.54639166e-002,
-       1.54639166e-002, 1.03092780e-002, 1.54639166e-002,
-       5.15463902e-003, 5.15463902e-003, 0., 0., 5.15463902e-003, 0.,
-       3.09278332e-002, 0., 1.03092780e-002, 1.54639166e-002,
-       1.03092780e-002, 0., 0., 5.15463902e-003, 5.15463902e-003, 0.,
-       1.03092780e-002, 0., 1.03092780e-002, 2.06185561e-002, 0., 0.,
-       5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.54639166e-002, 0., 2.57731955e-002, 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 0., 5.15463902e-003, 0., 0., 0., 1.03092780e-002,
-       0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.03092780e-002, 0., 5.15463902e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 5.15463902e-003, 0.,
-       5.15463902e-003, 1.03092780e-002, 2.57731955e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 1.03092780e-002, 0.,
-       0., 0., 5.15463902e-003, 0., 0., 0., 0., 3.09278332e-002, 0., 0.,
-       0., 2.06185561e-002, 0., 0., 1.03092780e-002, 0., 0., 0., 0.,
-       2.06185561e-002, 0., 0., 5.15463902e-003, 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 5.15463902e-003, 5.15463902e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0.,
-       3.09278332e-002, 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.15463902e-003, 0., 0., 1.03092780e-002,
-       5.15463902e-003, 0., 5.15463902e-003, 0., 5.15463902e-003,
-       5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.15463902e-003, 0., 5.15463902e-003, 5.15463902e-003, 0.,
-       1.03092780e-002, 0., 5.15463902e-003, 0., 0., 0., 1.03092780e-002,
-       0., 0., 0., 0., 3.09278332e-002, 0., 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 5.15463902e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 2.06185561e-002,
-       0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 0., 5.15463902e-003, 5.15463902e-003, 0., 0.,
-       1.03092780e-002, 0., 5.15463902e-003, 0., 0., 5.15463902e-003,
-       2.57731955e-002, 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 1.03092780e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.15463902e-003, 0., 5.15463902e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0.,
-       5.15463902e-003, 0., 5.15463902e-003, 0., 0., 5.15463902e-003, 0.,
-       0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 1.03092780e-002,
-       0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 1.54639166e-002, 0., 0., 5.15463902e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0.,
-       0., 1.03092780e-002, 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003,
-       5.15463902e-003, 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.03092780e-002,
-       0., 0., 0., 5.15463902e-003, 0., 0., 0., 5.15463902e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.03092780e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0.,
-       0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0.,
-       1.63934417e-002, 8.19672085e-003, 8.19672085e-003,
-       8.19672085e-003, 0., 0., 0., 3.27868834e-002, 2.45901626e-002,
-       8.19672085e-003, 0., 1.63934417e-002, 0., 8.19672085e-003, 0., 0.,
-       3.27868834e-002, 8.19672085e-003, 0., 1.63934417e-002, 0., 0., 0.,
-       0., 8.19672085e-003, 1.63934417e-002, 0., 2.45901626e-002, 0., 0.,
-       8.19672085e-003, 0., 8.19672085e-003, 0., 0., 0., 0., 0.,
-       8.19672085e-003, 0., 0., 0., 0., 8.19672085e-003, 0., 0.,
-       8.19672085e-003, 1.63934417e-002, 0., 0., 0., 0., 0., 0.,
-       8.19672085e-003, 0., 0., 8.19672085e-003, 0., 0., 0.,
-       8.19672085e-003, 0., 0., 0., 0., 0., 8.19672085e-003,
-       8.19672085e-003, 8.19672085e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.19672085e-003, 0., 0., 0., 0., 0.,
-       8.19672085e-003, 0., 2.45901626e-002, 0., 0., 8.19672085e-003, 0.,
-       0., 0., 0., 0., 0., 0., 8.19672085e-003, 8.19672085e-003, 0., 0.,
-       0., 0., 0., 0., 0., 1.63934417e-002, 0., 8.19672085e-003, 0., 0.,
-       0., 8.19672085e-003, 0., 0., 1.63934417e-002, 0., 0., 0., 0.,
-       1.63934417e-002, 0., 0., 8.19672085e-003, 1.63934417e-002, 0., 0.,
-       0., 0., 0., 8.19672085e-003, 0., 0., 0., 0., 2.45901626e-002, 0.,
-       0., 8.19672085e-003, 8.19672085e-003, 0., 0., 0., 8.19672085e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       3.27868834e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.63934417e-002, 0., 0., 0., 0., 0., 0., 0., 0., 8.19672085e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.19672085e-003,
-       8.19672085e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.19672085e-003, 0., 0., 0., 8.19672085e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.19672085e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.19672085e-003,
-       8.19672085e-003, 0., 0., 0., 0., 0., 8.19672085e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.19672085e-003, 0., 8.19672085e-003,
-       0., 0., 0., 8.19672085e-003, 1.63934417e-002, 0., 0., 0.,
-       1.63934417e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.19672085e-003, 0., 0., 0., 0., 0., 8.19672085e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.19672085e-003, 0.,
-       1.63934417e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.19672085e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.19672085e-003, 0., 0., 8.19672085e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.19672085e-003, 0., 0., 0.,
-       0., 0., 8.19672085e-003, 0., 8.19672085e-003, 0., 0.,
-       8.19672085e-003, 0., 8.19672085e-003, 8.19672085e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 2.45901626e-002, 0., 0.,
-       1.63934417e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.19672085e-003, 0., 0., 0., 0., 8.19672085e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.19672085e-003, 0., 1.63934417e-002,
-       1.63934417e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.19672085e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.63934417e-002, 8.19672085e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.63934417e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.61290318e-002, 8.06451589e-003, 0., 0., 0., 0., 0.,
-       0., 1.61290318e-002, 8.06451589e-003, 2.41935477e-002, 0.,
-       8.06451589e-003, 0., 0., 8.06451589e-003, 0., 0., 8.06451589e-003,
-       8.06451589e-003, 0., 8.06451589e-003, 2.41935477e-002,
-       8.06451589e-003, 0., 8.06451589e-003, 2.41935477e-002,
-       1.61290318e-002, 1.61290318e-002, 2.41935477e-002,
-       8.06451589e-003, 1.61290318e-002, 0., 8.06451589e-003, 0.,
-       8.06451589e-003, 0., 0., 8.06451589e-003, 0., 0., 0., 0.,
-       1.61290318e-002, 8.06451589e-003, 8.06451589e-003,
-       8.06451589e-003, 8.06451589e-003, 2.41935477e-002, 0., 0.,
-       1.61290318e-002, 0., 0., 8.06451589e-003, 0., 0., 0., 0., 0., 0.,
-       0., 8.06451589e-003, 0., 0., 0., 0., 8.06451589e-003,
-       8.06451589e-003, 0., 8.06451589e-003, 0., 0., 0., 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.06451589e-003, 0., 0., 0., 8.06451589e-003, 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 1.61290318e-002, 0., 0., 0., 0., 0.,
-       0., 0., 8.06451589e-003, 8.06451589e-003, 0., 0., 8.06451589e-003,
-       1.61290318e-002, 0., 0., 8.06451589e-003, 8.06451589e-003, 0., 0.,
-       0., 0., 8.06451589e-003, 0., 0., 8.06451589e-003, 2.41935477e-002,
-       8.06451589e-003, 0., 8.06451589e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.06451589e-003, 0., 8.06451589e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0.,
-       8.06451589e-003, 5.64516112e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.06451589e-003, 0., 8.06451589e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       3.22580636e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.06451589e-003, 8.06451589e-003, 0., 0., 0.,
-       8.06451589e-003, 0., 8.06451589e-003, 0., 0., 0., 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 8.06451589e-003, 0., 0.,
-       8.06451589e-003, 0., 0., 0., 8.06451589e-003, 0., 8.06451589e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.06451589e-003, 0., 0., 8.06451589e-003, 0., 0., 0.,
-       1.61290318e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.06451589e-003, 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 8.06451589e-003,
-       1.61290318e-002, 0., 0., 0., 0., 0., 0., 0., 0., 8.06451589e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 1.61290318e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.61797759e-003, 1.12359552e-002, 0., 0., 0.,
-       0., 0., 5.61797759e-003, 2.24719103e-002, 0., 1.68539323e-002,
-       5.61797759e-003, 1.12359552e-002, 0., 5.61797759e-003,
-       5.61797759e-003, 5.61797759e-003, 1.12359552e-002, 0., 0., 0., 0.,
-       1.12359552e-002, 5.61797759e-003, 5.61797759e-003,
-       5.61797759e-003, 2.24719103e-002, 5.61797759e-003,
-       5.61797759e-003, 5.61797759e-003, 1.12359552e-002,
-       1.12359552e-002, 0., 0., 1.12359552e-002, 5.61797759e-003, 0., 0.,
-       1.12359552e-002, 1.12359552e-002, 0., 0., 0., 0., 5.61797759e-003,
-       2.24719103e-002, 0., 1.68539323e-002, 2.24719103e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.12359552e-002, 5.61797759e-003, 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 1.12359552e-002, 0.,
-       0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.61797759e-003, 0., 0., 5.61797759e-003, 5.61797759e-003,
-       1.68539323e-002, 0., 0., 1.12359552e-002, 1.12359552e-002, 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       0., 1.12359552e-002, 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 1.12359552e-002,
-       5.61797759e-003, 0., 1.12359552e-002, 0., 1.68539323e-002, 0., 0.,
-       0., 2.24719103e-002, 0., 0., 5.61797759e-003, 0., 5.61797759e-003,
-       5.61797759e-003, 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 0., 1.12359552e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.68539323e-002, 0., 5.61797759e-003, 0., 0., 0., 0.,
-       1.12359552e-002, 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       1.12359552e-002, 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       0., 5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 5.61797759e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       5.61797759e-003, 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0.,
-       0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.61797759e-003, 5.61797759e-003, 0., 0., 0.,
-       5.61797759e-003, 1.68539323e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 1.12359552e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 2.24719103e-002, 0., 5.61797759e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 0., 0., 5.61797759e-003,
-       0., 0., 0., 5.61797759e-003, 0., 5.61797759e-003, 0., 0., 0., 0.,
-       0., 0., 2.24719103e-002, 0., 0., 5.61797759e-003, 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 5.61797759e-003,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       1.12359552e-002, 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0.,
-       0., 0., 5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       1.12359552e-002, 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       0., 0., 5.61797759e-003, 0., 5.61797759e-003, 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 5.61797759e-003, 0., 0.,
-       0., 5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       1.12359552e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.23560215e-003, 5.23560215e-003, 5.23560215e-003, 0., 0., 0., 0.,
-       0., 1.57068074e-002, 1.04712043e-002, 0., 1.57068074e-002,
-       1.04712043e-002, 0., 5.23560215e-003, 0., 1.04712043e-002, 0.,
-       5.23560215e-003, 0., 5.23560215e-003, 1.57068074e-002,
-       5.23560215e-003, 0., 0., 5.23560215e-003, 5.23560215e-003,
-       1.04712043e-002, 5.23560215e-003, 5.23560215e-003,
-       5.23560215e-003, 0., 0., 0., 0., 0., 5.23560215e-003,
-       2.09424086e-002, 1.57068074e-002, 0., 0., 1.04712043e-002, 0., 0.,
-       2.61780098e-002, 0., 0., 1.57068074e-002, 0., 0., 0., 0., 0.,
-       1.04712043e-002, 3.66492160e-002, 0., 5.23560215e-003,
-       5.23560215e-003, 5.23560215e-003, 0., 0., 1.04712043e-002,
-       1.04712043e-002, 0., 0., 0., 0., 0., 1.57068074e-002, 0., 0., 0.,
-       5.23560215e-003, 0., 5.23560215e-003, 0., 0., 5.23560215e-003,
-       5.23560215e-003, 0., 0., 0., 0., 1.57068074e-002, 0.,
-       1.04712043e-002, 0., 0., 0., 0., 0., 0., 0., 5.23560215e-003,
-       5.23560215e-003, 5.23560215e-003, 0., 0., 0., 5.23560215e-003, 0.,
-       0., 0., 5.23560215e-003, 0., 0., 0., 0., 5.23560215e-003, 0.,
-       5.23560215e-003, 5.23560215e-003, 0., 0., 0., 0., 0.,
-       5.23560215e-003, 1.57068074e-002, 0., 0., 0., 0., 5.23560215e-003,
-       0., 1.04712043e-002, 0., 0., 0., 2.09424086e-002, 5.23560215e-003,
-       0., 5.23560215e-003, 0., 0., 0., 5.23560215e-003, 5.23560215e-003,
-       0., 0., 0., 0., 5.23560215e-003, 1.57068074e-002, 0., 0., 0., 0.,
-       5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.23560215e-003, 5.23560215e-003, 0., 0., 5.23560215e-003, 0.,
-       1.57068074e-002, 0., 0., 0., 1.57068074e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.23560215e-003, 1.04712043e-002, 0.,
-       5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 1.04712043e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.23560215e-003, 5.23560215e-003,
-       0., 0., 0., 0., 0., 0., 5.23560215e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.23560215e-003, 0., 0., 0., 0., 5.23560215e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.23560215e-003, 0., 0., 0., 0., 0.,
-       5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.23560215e-003, 5.23560215e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.23560215e-003, 0., 0., 1.04712043e-002, 0.,
-       1.04712043e-002, 0., 5.23560215e-003, 1.57068074e-002, 0.,
-       5.23560215e-003, 5.23560215e-003, 1.04712043e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.23560215e-003, 0., 0., 0., 0., 0.,
-       5.23560215e-003, 5.23560215e-003, 0., 0., 0., 5.23560215e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.23560215e-003, 0., 0., 0.,
-       5.23560215e-003, 0., 5.23560215e-003, 0., 5.23560215e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.04712043e-002, 0., 5.23560215e-003, 0., 0., 0., 0., 0., 0.,
-       0., 5.23560215e-003, 0., 0., 0., 5.23560215e-003, 5.23560215e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.23560215e-003, 0.,
-       0., 0., 5.23560215e-003, 0., 0., 0., 0., 0., 0., 0.,
-       2.09424086e-002, 0., 0., 0., 0., 1.04712043e-002, 0.,
-       5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.23560215e-003, 0., 0., 5.23560215e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.04712043e-002, 0., 0.,
-       5.23560215e-003, 0., 5.23560215e-003, 0., 0., 5.23560215e-003, 0.,
-       0., 5.23560215e-003, 0., 0., 0., 0., 0., 1.04712043e-002, 0., 0.,
-       0., 0., 0., 0., 0., 5.23560215e-003, 5.23560215e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.23560215e-003, 0., 0., 0., 5.23560215e-003,
-       0., 0., 0., 5.23560215e-003, 0., 5.23560215e-003, 0., 0., 0., 0.,
-       0., 0., 0., 5.23560215e-003, 0., 0., 5.23560215e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.23560215e-003, 0., 0., 0., 0., 0., 0.,
-       5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.57068074e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.23560215e-003, 1.04712043e-002, 0., 0.,
-       0., 0., 0., 0., 1.81818176e-002, 6.06060587e-003, 6.06060587e-003,
-       0., 6.06060587e-003, 6.06060587e-003, 0., 0., 6.06060587e-003,
-       6.06060587e-003, 0., 1.21212117e-002, 1.21212117e-002,
-       6.06060587e-003, 0., 0., 6.06060587e-003, 1.81818176e-002, 0., 0.,
-       6.06060587e-003, 1.21212117e-002, 1.81818176e-002, 0.,
-       6.06060587e-003, 6.06060587e-003, 6.06060587e-003, 0.,
-       1.81818176e-002, 1.21212117e-002, 1.21212117e-002,
-       1.21212117e-002, 0., 0., 6.06060587e-003, 6.06060587e-003,
-       6.06060587e-003, 0., 1.81818176e-002, 0., 0., 0., 0.,
-       6.06060587e-003, 0., 6.06060587e-003, 0., 0., 3.03030293e-002,
-       6.06060587e-003, 0., 1.21212117e-002, 6.06060587e-003,
-       6.06060587e-003, 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0.,
-       1.21212117e-002, 0., 0., 6.06060587e-003, 0., 0., 0.,
-       6.06060587e-003, 6.06060587e-003, 0., 0., 6.06060587e-003, 0., 0.,
-       6.06060587e-003, 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.81818176e-002, 0., 0., 1.21212117e-002,
-       0., 0., 0., 1.21212117e-002, 0., 1.21212117e-002, 0.,
-       6.06060587e-003, 0., 6.06060587e-003, 0., 0., 6.06060587e-003, 0.,
-       0., 0., 6.06060587e-003, 0., 0., 6.06060587e-003, 6.06060587e-003,
-       6.06060587e-003, 6.06060587e-003, 0., 6.06060587e-003, 0., 0., 0.,
-       0., 0., 2.42424235e-002, 0., 0., 6.06060587e-003, 6.06060587e-003,
-       1.21212117e-002, 0., 0., 0., 0., 6.06060587e-003, 0.,
-       6.06060587e-003, 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.06060587e-003, 0.,
-       6.06060587e-003, 0., 0., 0., 1.81818176e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 6.06060587e-003, 0.,
-       6.06060587e-003, 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0.,
-       1.21212117e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.21212117e-002, 0., 0., 3.63636352e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 6.06060587e-003, 0.,
-       6.06060587e-003, 0., 6.06060587e-003, 0., 0., 6.06060587e-003, 0.,
-       0., 0., 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0.,
-       1.21212117e-002, 6.06060587e-003, 0., 0., 0., 6.06060587e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 6.06060587e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.81818176e-002,
-       0., 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 6.06060587e-003,
-       0., 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.06060587e-003, 6.06060587e-003, 0., 6.06060587e-003,
-       6.06060587e-003, 1.21212117e-002, 0., 0., 0., 0., 6.06060587e-003,
-       0., 6.06060587e-003, 0., 0., 0., 1.21212117e-002, 0., 0., 0., 0.,
-       1.21212117e-002, 0., 0., 0., 0., 0., 0., 0., 6.06060587e-003, 0.,
-       0., 0., 0., 0., 6.06060587e-003, 0., 6.06060587e-003, 0., 0., 0.,
-       0., 0., 1.21212117e-002, 0., 0., 6.06060587e-003, 0., 0., 0., 0.,
-       0., 0., 0., 6.06060587e-003, 0., 0., 0., 0., 6.06060587e-003, 0.,
-       0., 0., 0., 1.81818176e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 6.06060587e-003,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 6.06060587e-003, 6.06060587e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.87401572e-003, 7.87401572e-003,
-       7.87401572e-003, 0., 7.87401572e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.87401572e-003, 7.87401572e-003, 0., 0., 0., 0., 0.,
-       7.87401572e-003, 7.87401572e-003, 7.87401572e-003, 0., 0.,
-       1.57480314e-002, 7.87401572e-003, 7.87401572e-003, 0.,
-       7.87401572e-003, 0., 0., 7.87401572e-003, 0., 0., 0., 0.,
-       7.87401572e-003, 0., 0., 0., 0., 7.87401572e-003, 0.,
-       7.87401572e-003, 0., 1.57480314e-002, 4.72440943e-002, 0., 0., 0.,
-       0., 0., 1.57480314e-002, 3.14960629e-002, 0., 7.87401572e-003,
-       7.87401572e-003, 0., 0., 0., 7.87401572e-003, 0., 7.87401572e-003,
-       0., 0., 0., 0., 7.87401572e-003, 7.87401572e-003, 0., 0.,
-       7.87401572e-003, 0., 0., 0., 0., 0., 0., 0., 0., 7.87401572e-003,
-       0., 1.57480314e-002, 0., 7.87401572e-003, 0., 0., 7.87401572e-003,
-       7.87401572e-003, 0., 0., 0., 0., 2.36220472e-002, 0., 0., 0., 0.,
-       1.57480314e-002, 0., 0., 0., 7.87401572e-003, 0., 0., 0., 0.,
-       7.87401572e-003, 0., 0., 0., 0., 7.87401572e-003, 0., 0., 0., 0.,
-       7.87401572e-003, 0., 0., 0., 7.87401572e-003, 0., 0.,
-       2.36220472e-002, 0., 0., 0., 4.72440943e-002, 7.87401572e-003, 0.,
-       0., 0., 7.87401572e-003, 7.87401572e-003, 0., 0., 0., 0., 0., 0.,
-       0., 1.57480314e-002, 0., 0., 0., 0., 7.87401572e-003, 0., 0., 0.,
-       0., 0., 7.87401572e-003, 0., 0., 0., 1.57480314e-002,
-       1.57480314e-002, 0., 0., 0., 7.87401572e-003, 1.57480314e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.87401572e-003, 0.,
-       0., 0., 0., 0., 7.87401572e-003, 0., 0., 0., 7.87401572e-003, 0.,
-       0., 0., 1.57480314e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 7.87401572e-003, 0., 7.87401572e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 2.36220472e-002, 0., 0., 0., 7.87401572e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.87401572e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.87401572e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.87401572e-003, 0., 0., 0., 0., 0.,
-       7.87401572e-003, 2.36220472e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.87401572e-003, 0., 0., 0., 0., 7.87401572e-003, 0., 0.,
-       1.57480314e-002, 0., 0., 0., 7.87401572e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 2.36220472e-002, 0., 7.87401572e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.57480314e-002, 0., 0., 0., 1.57480314e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.57480314e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.87401572e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.87401572e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.57480314e-002, 0., 7.87401572e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.87401572e-003, 0., 0., 0., 7.87401572e-003, 0., 0., 0.,
-       0., 0., 7.87401572e-003, 0., 0., 0., 7.87401572e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.87401572e-003, 0., 0., 0., 1.57480314e-002, 0.,
-       7.87401572e-003, 0., 0., 0., 0., 0., 0., 0., 7.87401572e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.87401572e-003, 0., 0., 7.87401572e-003, 0., 0., 0., 0.,
-       3.17460299e-002, 1.58730149e-002, 5.29100513e-003,
-       1.05820103e-002, 0., 5.29100513e-003, 0., 5.29100513e-003,
-       1.05820103e-002, 1.05820103e-002, 0., 5.29100513e-003, 0., 0., 0.,
-       2.11640205e-002, 1.05820103e-002, 0., 0., 0., 0., 1.58730149e-002,
-       5.29100513e-003, 0., 0., 0., 1.58730149e-002, 0., 1.58730149e-002,
-       5.29100513e-003, 0., 1.58730149e-002, 0., 0., 0., 0., 0.,
-       1.05820103e-002, 5.29100513e-003, 5.29100513e-003, 0., 0.,
-       5.29100513e-003, 1.58730149e-002, 0., 5.29100513e-003, 0.,
-       2.11640205e-002, 1.05820103e-002, 0., 0., 5.29100513e-003, 0.,
-       5.29100513e-003, 5.29100513e-003, 0., 0., 5.29100513e-003, 0., 0.,
-       0., 0., 5.29100513e-003, 5.29100513e-003, 0., 0., 0., 0., 0.,
-       5.29100513e-003, 5.29100513e-003, 0., 0., 0., 0., 5.29100513e-003,
-       0., 0., 0., 0., 0., 0., 5.29100513e-003, 0., 5.29100513e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.29100513e-003, 1.58730149e-002, 0.,
-       0., 0., 0., 5.29100513e-003, 1.05820103e-002, 5.29100513e-003, 0.,
-       5.29100513e-003, 0., 0., 0., 5.29100513e-003, 0., 5.29100513e-003,
-       0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 5.29100513e-003, 0., 3.17460299e-002,
-       0., 5.29100513e-003, 0., 4.76190448e-002, 0., 0., 5.29100513e-003,
-       0., 0., 0., 0., 1.05820103e-002, 0., 0., 0., 0., 5.29100513e-003,
-       0., 0., 5.29100513e-003, 0., 0., 5.29100513e-003, 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.05820103e-002, 5.29100513e-003, 5.29100513e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 1.05820103e-002, 5.29100513e-003, 0., 0., 0., 0.,
-       0., 5.29100513e-003, 0., 0., 5.29100513e-003, 5.29100513e-003,
-       5.29100513e-003, 0., 0., 5.29100513e-003, 0., 5.29100513e-003, 0.,
-       0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 5.29100513e-003, 0.,
-       1.05820103e-002, 0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 3.17460299e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.05820103e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.29100513e-003, 0.,
-       0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 5.29100513e-003, 1.58730149e-002,
-       5.29100513e-003, 0., 5.29100513e-003, 1.05820103e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.58730149e-002, 0., 0., 0., 0., 5.29100513e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.29100513e-003, 5.29100513e-003, 0.,
-       0., 0., 0., 5.29100513e-003, 0., 0., 5.29100513e-003, 0., 0., 0.,
-       0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 5.29100513e-003,
-       0., 5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 1.05820103e-002, 0., 5.29100513e-003, 0., 0.,
-       0., 0., 5.29100513e-003, 0., 5.29100513e-003, 1.05820103e-002, 0.,
-       0., 5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.58730149e-002, 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.05820103e-002, 0., 5.29100513e-003, 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 5.29100513e-003,
-       2.11640205e-002, 0., 5.29100513e-003, 0., 0., 0., 0.,
-       5.29100513e-003, 5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.29100513e-003, 0.,
-       0., 0., 0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 1.05820103e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.29100513e-003, 0., 5.29100513e-003, 0., 0.,
-       0., 0., 5.29100513e-003, 0., 0., 0., 5.29100513e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.29100513e-003, 0., 0., 0., 0., 0.,
-       5.29100513e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 1.19047621e-002, 1.78571437e-002,
-       5.95238106e-003, 0., 1.19047621e-002, 0., 5.95238106e-003,
-       1.78571437e-002, 0., 1.78571437e-002, 0., 2.97619049e-002, 0., 0.,
-       5.95238106e-003, 0., 2.38095243e-002, 5.95238106e-003,
-       5.95238106e-003, 0., 0., 1.19047621e-002, 5.95238106e-003, 0.,
-       5.95238106e-003, 1.78571437e-002, 0., 5.95238106e-003,
-       5.95238106e-003, 0., 2.38095243e-002, 5.95238106e-003, 0.,
-       1.19047621e-002, 0., 0., 0., 0., 1.78571437e-002, 0., 0.,
-       5.95238106e-003, 0., 0., 2.38095243e-002, 0., 5.95238106e-003,
-       2.38095243e-002, 5.95238106e-003, 0., 0., 5.95238106e-003, 0.,
-       5.95238106e-003, 1.19047621e-002, 0., 0., 0., 0., 0., 0.,
-       1.19047621e-002, 0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0.,
-       0., 1.78571437e-002, 0., 0., 0., 0., 5.95238106e-003,
-       5.95238106e-003, 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0.,
-       5.95238106e-003, 5.95238106e-003, 0., 0., 5.95238106e-003, 0.,
-       1.78571437e-002, 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0.,
-       0., 0., 0., 5.95238106e-003, 0., 5.95238106e-003, 0.,
-       5.95238106e-003, 5.95238106e-003, 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 1.19047621e-002, 0., 0., 0.,
-       1.19047621e-002, 0., 0., 0., 0., 0., 5.95238106e-003, 0.,
-       1.78571437e-002, 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0.,
-       5.95238106e-003, 0., 0., 5.95238106e-003, 0., 0., 0.,
-       5.95238106e-003, 0., 1.19047621e-002, 0., 0., 1.19047621e-002, 0.,
-       0., 0., 0., 5.95238106e-003, 5.95238106e-003, 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.95238106e-003, 0., 0., 5.95238106e-003,
-       5.95238106e-003, 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0.,
-       0., 5.95238106e-003, 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.19047621e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0.,
-       1.19047621e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.19047621e-002,
-       0., 0., 0., 0., 0., 0., 0., 1.19047621e-002, 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.19047621e-002, 0., 0., 0., 1.19047621e-002, 0., 0.,
-       0., 5.95238106e-003, 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.19047621e-002, 0., 0., 0., 0., 0., 5.95238106e-003,
-       0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.95238106e-003, 0., 5.95238106e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.95238106e-003, 0., 0., 0., 0.,
-       5.95238106e-003, 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.19047621e-002, 0., 0., 0., 0., 5.95238106e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.95238106e-003, 1.19047621e-002, 0.,
-       0., 0., 1.78571437e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.95238106e-003, 5.95238106e-003, 0.,
-       5.95238106e-003, 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 5.95238106e-003, 0., 0., 0., 0., 0., 0.,
-       1.19047621e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.19047621e-002, 0., 0., 5.95238106e-003, 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.95238106e-003, 0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 0.,
-       0., 5.95238106e-003, 0., 0., 0., 0., 0., 1.19047621e-002, 0., 0.,
-       0., 0., 0., 5.95238106e-003, 0., 0., 0., 5.95238106e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.95238106e-003, 0., 5.95238106e-003,
-       1.03092780e-002, 1.03092780e-002, 5.15463902e-003,
-       1.03092780e-002, 0., 5.15463902e-003, 0., 1.03092780e-002,
-       5.15463902e-003, 1.03092780e-002, 5.15463902e-003,
-       1.03092780e-002, 1.03092780e-002, 0., 5.15463902e-003,
-       1.54639166e-002, 0., 1.54639166e-002, 1.03092780e-002, 0.,
-       1.03092780e-002, 5.15463902e-003, 5.15463902e-003,
-       5.15463902e-003, 0., 0., 1.54639166e-002, 0., 0., 0.,
-       5.15463902e-003, 5.15463902e-003, 0., 1.54639166e-002,
-       5.15463902e-003, 5.15463902e-003, 0., 0., 0., 5.15463902e-003,
-       1.03092780e-002, 0., 0., 0., 0., 5.15463902e-003, 0.,
-       1.03092780e-002, 5.15463902e-003, 1.03092780e-002, 0., 0., 0., 0.,
-       1.03092780e-002, 5.15463902e-003, 0., 0., 5.15463902e-003, 0.,
-       5.15463902e-003, 0., 1.54639166e-002, 0., 5.15463902e-003, 0., 0.,
-       0., 5.15463902e-003, 0., 5.15463902e-003, 0., 5.15463902e-003,
-       1.03092780e-002, 0., 0., 0., 5.15463902e-003, 5.15463902e-003,
-       1.03092780e-002, 0., 0., 0., 0., 2.06185561e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.15463902e-003, 0., 5.15463902e-003, 0.,
-       5.15463902e-003, 0., 5.15463902e-003, 5.15463902e-003, 0., 0., 0.,
-       0., 0., 0., 5.15463902e-003, 0., 0., 0., 5.15463902e-003,
-       1.03092780e-002, 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0.,
-       0., 0., 0., 2.57731955e-002, 5.15463902e-003, 5.15463902e-003,
-       5.15463902e-003, 2.57731955e-002, 0., 0., 5.15463902e-003, 0.,
-       1.03092780e-002, 1.03092780e-002, 0., 5.15463902e-003, 0., 0.,
-       1.03092780e-002, 0., 0., 1.03092780e-002, 0., 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.03092780e-002, 0., 0., 0., 1.54639166e-002, 5.15463902e-003, 0.,
-       0., 1.03092780e-002, 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.03092780e-002, 0., 0., 0., 0., 0., 1.03092780e-002,
-       5.15463902e-003, 0., 0., 0., 5.15463902e-003, 0., 5.15463902e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0.,
-       0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003,
-       5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003,
-       5.15463902e-003, 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.15463902e-003, 5.15463902e-003, 0., 0., 0.,
-       1.03092780e-002, 0., 0., 0., 0., 5.15463902e-003, 5.15463902e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0.,
-       5.15463902e-003, 0., 5.15463902e-003, 0., 0., 5.15463902e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.03092780e-002, 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 1.03092780e-002, 0., 0., 0., 0., 0., 0.,
-       5.15463902e-003, 0., 1.03092780e-002, 0., 0., 0., 0., 0., 0., 0.,
-       1.03092780e-002, 0., 0., 2.57731955e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.15463902e-003, 0., 0., 5.15463902e-003, 0., 0., 0., 0.,
-       5.15463902e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.15463902e-003, 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0.,
-       5.15463902e-003, 0., 0., 0., 1.03092780e-002, 0., 0.,
-       1.03092780e-002, 0., 5.15463902e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.03092780e-002, 0., 0., 5.15463902e-003,
-       1.03092780e-002, 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0.,
-       5.15463902e-003, 1.03092780e-002, 0., 0., 0., 5.15463902e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.15463902e-003, 0., 0.,
-       1.03092780e-002, 0., 0., 0., 0., 0., 0., 0., 0., 1.03092780e-002,
-       0., 0., 5.15463902e-003, 0., 0., 0., 5.15463902e-003, 0., 0.,
-       1.03092780e-002, 0., 0., 0., 5.15463902e-003, 0., 0., 0., 0., 0.,
-       0., 5.15463902e-003, 0., 0., 0., 1.73913036e-002, 0.,
-       8.69565178e-003, 0., 0., 8.69565178e-003, 0., 0., 0.,
-       8.69565178e-003, 8.69565178e-003, 0., 1.73913036e-002, 0., 0.,
-       8.69565178e-003, 8.69565178e-003, 8.69565178e-003, 0.,
-       3.47826071e-002, 8.69565178e-003, 8.69565178e-003, 0., 0., 0., 0.,
-       8.69565178e-003, 0., 1.73913036e-002, 0., 8.69565178e-003, 0., 0.,
-       5.21739125e-002, 0., 8.69565178e-003, 0., 0., 0., 1.73913036e-002,
-       0., 0., 0., 8.69565178e-003, 0., 0., 0., 1.73913036e-002,
-       1.73913036e-002, 0., 8.69565178e-003, 8.69565178e-003, 0., 0.,
-       8.69565178e-003, 8.69565178e-003, 0., 0., 8.69565178e-003, 0., 0.,
-       0., 1.73913036e-002, 0., 8.69565178e-003, 0., 0., 8.69565178e-003,
-       1.73913036e-002, 0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0.,
-       0., 8.69565178e-003, 0., 0., 8.69565178e-003, 0., 0., 0., 0.,
-       8.69565178e-003, 0., 0., 0., 8.69565178e-003, 0., 0., 0., 0., 0.,
-       0., 8.69565178e-003, 0., 8.69565178e-003, 8.69565178e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.73913036e-002, 0., 8.69565178e-003, 0., 0., 0., 0., 0.,
-       8.69565178e-003, 0., 8.69565178e-003, 0., 8.69565178e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 0., 0., 8.69565178e-003,
-       1.73913036e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.73913036e-002, 0., 0., 0., 0., 0., 0., 0., 2.60869563e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 0.,
-       0., 0., 0., 1.73913036e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.69565178e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 0.,
-       1.73913036e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.73913036e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.73913036e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 0., 0.,
-       0., 0., 0., 8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.60869563e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 2.60869563e-002, 0., 0., 0., 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 0., 1.73913036e-002,
-       0., 0., 0., 8.69565178e-003, 0., 8.69565178e-003, 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.60869563e-002, 0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0.,
-       0., 0., 0., 1.73913036e-002, 0., 0., 0., 0., 0., 0., 0.,
-       1.73913036e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 0., 1.73913036e-002,
-       0., 0., 8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.52380989e-003, 0., 0., 9.52380989e-003, 2.85714306e-002,
-       0., 1.90476198e-002, 0., 0., 9.52380989e-003, 0., 0.,
-       2.85714306e-002, 0., 9.52380989e-003, 0., 9.52380989e-003, 0.,
-       1.90476198e-002, 0., 0., 0., 1.90476198e-002, 0., 9.52380989e-003,
-       1.90476198e-002, 0., 1.90476198e-002, 0., 9.52380989e-003,
-       9.52380989e-003, 0., 9.52380989e-003, 0., 0., 0., 0., 0.,
-       2.85714306e-002, 0., 0., 0., 0., 0., 0., 1.90476198e-002,
-       9.52380989e-003, 2.85714306e-002, 0., 0., 0., 0., 0., 0.,
-       9.52380989e-003, 0., 0., 0., 0., 0., 0., 9.52380989e-003, 0., 0.,
-       0., 0., 0., 1.90476198e-002, 9.52380989e-003, 9.52380989e-003, 0.,
-       0., 0., 0., 0., 0., 0., 9.52380989e-003, 0., 0., 0.,
-       1.90476198e-002, 0., 0., 0., 9.52380989e-003, 0., 0., 0., 0., 0.,
-       2.85714306e-002, 0., 0., 0., 0., 0., 0., 0., 0., 9.52380989e-003,
-       0., 0., 1.90476198e-002, 0., 0., 9.52380989e-003, 0.,
-       9.52380989e-003, 0., 0., 9.52380989e-003, 9.52380989e-003, 0., 0.,
-       0., 0., 0., 0., 0., 9.52380989e-003, 0., 0., 0., 0.,
-       1.90476198e-002, 0., 0., 0., 3.80952395e-002, 0., 0., 0., 0., 0.,
-       0., 0., 1.90476198e-002, 0., 9.52380989e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.52380989e-003, 2.85714306e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.52380989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.52380989e-003, 0., 0., 1.90476198e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.52380989e-003, 0., 0., 0., 0., 0., 9.52380989e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.52380989e-003, 9.52380989e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.52380989e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.52380989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.52380989e-003, 0.,
-       0., 1.90476198e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.52380989e-003, 0., 0., 0., 0., 0., 9.52380989e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.52380989e-003, 0., 0., 9.52380989e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.52380989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.90476198e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.90476198e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.52380989e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.52380989e-003, 0., 0., 0.,
-       9.52380989e-003, 0., 0., 0., 0., 9.52380989e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.52380989e-003, 0., 9.52380989e-003, 0., 0., 0., 0., 0.,
-       0., 0., 1.90476198e-002, 0., 0., 0., 0., 0., 0., 9.52380989e-003,
-       0., 0., 0., 9.52380989e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 9.52380989e-003, 0., 0.,
-       1.90476198e-002, 0., 0., 0., 9.52380989e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.52380989e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 9.43396240e-003, 0., 0., 9.43396240e-003,
-       1.88679248e-002, 0., 0., 0., 1.88679248e-002, 9.43396240e-003, 0.,
-       0., 0., 3.77358496e-002, 9.43396240e-003, 0., 0., 0.,
-       9.43396240e-003, 0., 9.43396240e-003, 0., 0., 0., 9.43396240e-003,
-       3.77358496e-002, 9.43396240e-003, 9.43396240e-003, 0.,
-       3.77358496e-002, 1.88679248e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.43396240e-003, 1.88679248e-002, 9.43396240e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003,
-       0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       9.43396240e-003, 9.43396240e-003, 0., 0., 9.43396240e-003,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0.,
-       1.88679248e-002, 0., 0., 9.43396240e-003, 9.43396240e-003, 0., 0.,
-       0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 9.43396240e-003, 0., 0., 0., 1.88679248e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.88679248e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 1.88679248e-002,
-       0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 9.43396240e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 9.43396240e-003,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0.,
-       0., 0., 9.43396240e-003, 0., 0., 0., 4.71698120e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.43396240e-003, 0., 9.43396240e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0.,
-       1.88679248e-002, 9.43396240e-003, 0., 0., 0., 0., 1.88679248e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.88679248e-002, 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 2.83018872e-002, 0., 0.,
-       1.88679248e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.43396240e-003, 0., 0., 9.43396240e-003, 0.,
-       1.88679248e-002, 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0.,
-       9.43396240e-003, 9.43396240e-003, 9.43396240e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0.,
-       2.54237279e-002, 0., 0., 0., 0., 2.54237279e-002, 8.47457629e-003,
-       8.47457629e-003, 0., 1.69491526e-002, 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 8.47457629e-003, 0., 8.47457629e-003, 0.,
-       8.47457629e-003, 0., 2.54237279e-002, 0., 1.69491526e-002,
-       1.69491526e-002, 0., 1.69491526e-002, 0., 8.47457629e-003,
-       8.47457629e-003, 0., 0., 0., 8.47457629e-003, 8.47457629e-003, 0.,
-       0., 0., 8.47457629e-003, 0., 8.47457629e-003, 0., 0.,
-       2.54237279e-002, 1.69491526e-002, 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 1.69491526e-002, 0., 0.,
-       0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.69491526e-002, 0., 0., 8.47457629e-003, 8.47457629e-003,
-       8.47457629e-003, 0., 0., 0., 8.47457629e-003, 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 8.47457629e-003, 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0.,
-       1.69491526e-002, 8.47457629e-003, 0., 0., 0., 0., 1.69491526e-002,
-       0., 0., 0., 3.38983051e-002, 0., 0., 0., 8.47457629e-003, 0.,
-       8.47457629e-003, 0., 8.47457629e-003, 0., 0., 8.47457629e-003, 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0.,
-       8.47457629e-003, 0., 8.47457629e-003, 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0.,
-       0., 0., 8.47457629e-003, 0., 0., 0., 8.47457629e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.47457629e-003, 0., 8.47457629e-003, 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.69491526e-002, 2.54237279e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.69491526e-002, 0., 8.47457629e-003,
-       0., 0., 0., 0., 0., 0., 8.47457629e-003, 1.69491526e-002, 0.,
-       1.69491526e-002, 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0.,
-       0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003,
-       0., 1.69491526e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0.,
-       0., 0., 0., 0., 1.69491526e-002, 0., 8.47457629e-003, 0., 0.,
-       1.69491526e-002, 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.91715984e-003, 0., 1.18343197e-002, 0., 2.36686394e-002, 0.,
-       0., 1.18343197e-002, 2.95857992e-002, 1.18343197e-002,
-       5.91715984e-003, 5.91715984e-003, 5.91715984e-003,
-       2.36686394e-002, 1.18343197e-002, 0., 5.91715984e-003, 0.,
-       5.91715984e-003, 1.77514795e-002, 0., 0., 0., 5.91715984e-003, 0.,
-       5.91715984e-003, 0., 0., 4.14201170e-002, 5.91715984e-003,
-       5.91715984e-003, 0., 5.91715984e-003, 0., 5.91715984e-003, 0., 0.,
-       5.91715984e-003, 1.18343197e-002, 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 5.91715984e-003, 2.95857992e-002, 0., 0., 0., 0.,
-       0., 0., 2.95857992e-002, 0., 5.91715984e-003, 0., 0., 0.,
-       5.91715984e-003, 5.91715984e-003, 0., 5.91715984e-003, 0., 0.,
-       5.91715984e-003, 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0.,
-       0., 5.91715984e-003, 0., 0., 5.91715984e-003, 0., 5.91715984e-003,
-       0., 5.91715984e-003, 0., 0., 0., 0., 5.91715984e-003, 0., 0.,
-       5.91715984e-003, 5.91715984e-003, 5.91715984e-003, 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0.,
-       5.91715984e-003, 5.91715984e-003, 0., 0., 5.91715984e-003, 0., 0.,
-       0., 0., 1.18343197e-002, 0., 0., 5.91715984e-003, 0., 0., 0., 0.,
-       0., 2.36686394e-002, 0., 0., 0., 2.95857992e-002, 1.18343197e-002,
-       0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0.,
-       0., 5.91715984e-003, 5.91715984e-003, 0., 0., 5.91715984e-003, 0.,
-       1.18343197e-002, 0., 5.91715984e-003, 0., 1.77514795e-002, 0., 0.,
-       0., 0., 5.91715984e-003, 5.91715984e-003, 0., 0., 5.91715984e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0.,
-       5.91715984e-003, 0., 5.91715984e-003, 0., 0., 0., 5.91715984e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.18343197e-002, 0., 0., 0.,
-       0., 0., 0., 5.91715984e-003, 0., 5.91715984e-003, 0., 0., 0., 0.,
-       0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003,
-       0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0.,
-       5.91715984e-003, 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.91715984e-003, 5.91715984e-003, 0., 0., 0., 0.,
-       2.95857992e-002, 5.91715984e-003, 0., 0., 0., 0., 5.91715984e-003,
-       0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 5.91715984e-003, 5.91715984e-003,
-       5.91715984e-003, 0., 0., 5.91715984e-003, 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.18343197e-002, 0.,
-       1.77514795e-002, 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.18343197e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.91715984e-003, 0., 0., 0., 5.91715984e-003,
-       1.18343197e-002, 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0.,
-       0., 0., 1.18343197e-002, 0., 0., 0., 0., 5.91715984e-003, 0., 0.,
-       0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 5.91715984e-003, 0.,
-       0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 1.77514795e-002, 0., 0.,
-       0., 0., 5.91715984e-003, 0., 0., 0., 5.91715984e-003, 0., 0., 0.,
-       0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.14942528e-002,
-       1.14942528e-002, 5.74712642e-003, 5.74712642e-003, 0., 0., 0.,
-       5.74712642e-003, 1.72413792e-002, 0., 1.14942528e-002, 0.,
-       1.14942528e-002, 1.14942528e-002, 1.14942528e-002, 0.,
-       5.74712642e-003, 1.14942528e-002, 0., 5.74712642e-003, 0.,
-       5.74712642e-003, 0., 0., 0., 0., 1.72413792e-002, 0.,
-       5.74712642e-003, 1.72413792e-002, 5.74712642e-003,
-       1.14942528e-002, 0., 1.14942528e-002, 5.74712642e-003, 0., 0., 0.,
-       5.74712642e-003, 5.74712642e-003, 5.74712642e-003, 0., 0., 0., 0.,
-       1.14942528e-002, 5.74712642e-003, 1.72413792e-002, 0.,
-       5.74712642e-003, 0., 0., 0., 5.74712642e-003, 5.74712642e-003, 0.,
-       0., 0., 0., 0., 0., 0., 1.14942528e-002, 0., 1.14942528e-002, 0.,
-       0., 0., 5.74712642e-003, 0., 1.14942528e-002, 0., 0., 0., 0.,
-       1.14942528e-002, 0., 0., 0., 0., 0., 0., 1.72413792e-002, 0., 0.,
-       0., 0., 0., 0., 5.74712642e-003, 5.74712642e-003, 0.,
-       5.74712642e-003, 0., 1.72413792e-002, 5.74712642e-003, 0., 0., 0.,
-       5.74712642e-003, 1.72413792e-002, 1.14942528e-002, 0., 0., 0., 0.,
-       0., 5.74712642e-003, 1.14942528e-002, 5.74712642e-003, 0., 0.,
-       5.74712642e-003, 0., 5.74712642e-003, 0., 0., 0., 0., 0.,
-       5.74712642e-003, 0., 0., 0., 0., 0., 1.72413792e-002,
-       5.74712642e-003, 0., 0., 5.74712642e-003, 0., 0., 1.14942528e-002,
-       0., 0., 0., 0., 5.74712642e-003, 0., 0., 5.74712642e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.74712642e-003, 0., 0., 0.,
-       1.14942528e-002, 0., 0., 5.74712642e-003, 0., 0., 5.74712642e-003,
-       0., 0., 0., 5.74712642e-003, 5.74712642e-003, 0., 1.14942528e-002,
-       0., 0., 0., 0., 5.74712642e-003, 0., 0., 0., 0., 0.,
-       5.74712642e-003, 0., 0., 5.74712642e-003, 0., 0., 0., 0., 0.,
-       5.74712642e-003, 0., 0., 0., 1.72413792e-002, 5.74712642e-003, 0.,
-       0., 0., 0., 0., 5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.74712642e-003, 1.14942528e-002, 0.,
-       0., 5.74712642e-003, 0., 0., 0., 0., 5.74712642e-003, 0., 0., 0.,
-       0., 0., 5.74712642e-003, 0., 0., 0., 0., 5.74712642e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.74712642e-003, 0.,
-       0., 0., 0., 0., 0., 5.74712642e-003, 0., 0., 5.74712642e-003, 0.,
-       0., 0., 0., 0., 0., 5.74712642e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.14942528e-002,
-       5.74712642e-003, 0., 0., 0., 5.74712642e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.74712642e-003, 0., 0., 1.72413792e-002,
-       0., 5.74712642e-003, 0., 0., 0., 5.74712642e-003, 5.74712642e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.74712642e-003, 0.,
-       5.74712642e-003, 0., 0., 1.14942528e-002, 5.74712642e-003, 0., 0.,
-       0., 5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.14942528e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.74712642e-003, 0., 0., 0., 5.74712642e-003, 0., 0., 0.,
-       0., 0., 0., 5.74712642e-003, 1.14942528e-002, 0., 0., 0., 0.,
-       5.74712642e-003, 5.74712642e-003, 5.74712642e-003, 0., 0., 0., 0.,
-       0., 0., 0., 5.74712642e-003, 0., 5.74712642e-003, 5.74712642e-003,
-       0., 0., 0., 5.74712642e-003, 0., 0., 0., 5.74712642e-003, 0.,
-       5.74712642e-003, 0., 0., 0., 0., 0., 5.74712642e-003, 0., 0.,
-       1.72413792e-002, 5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.74712642e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.74712642e-003, 0., 0., 1.72413792e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.74712642e-003, 0., 0., 0.,
-       0., 5.74712642e-003, 0., 0., 5.74712642e-003, 0., 5.74712642e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 5.74712642e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.14942528e-002, 0.,
-       5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.74712642e-003, 0., 0., 0., 0., 0., 5.78034669e-003,
-       5.78034669e-003, 0., 0., 3.46820801e-002, 0., 0., 0.,
-       1.15606934e-002, 5.78034669e-003, 5.78034669e-003,
-       5.78034669e-003, 0., 0., 0., 0., 5.78034669e-003, 5.78034669e-003,
-       1.15606934e-002, 1.15606934e-002, 0., 1.15606934e-002, 0., 0., 0.,
-       2.89017335e-002, 0., 0., 1.15606934e-002, 0., 5.78034669e-003, 0.,
-       2.31213868e-002, 5.78034669e-003, 0., 5.78034669e-003,
-       5.78034669e-003, 1.15606934e-002, 0., 0., 0., 0., 5.78034669e-003,
-       0., 5.78034669e-003, 1.15606934e-002, 1.15606934e-002,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 1.73410401e-002, 0.,
-       1.15606934e-002, 0., 0., 0., 5.78034669e-003, 0., 5.78034669e-003,
-       5.78034669e-003, 0., 0., 5.78034669e-003, 5.78034669e-003, 0., 0.,
-       0., 0., 0., 0., 0., 5.78034669e-003, 0., 0., 0., 0., 0.,
-       1.73410401e-002, 0., 0., 0., 0., 0., 0., 5.78034669e-003,
-       5.78034669e-003, 0., 0., 0., 1.15606934e-002, 1.15606934e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 1.15606934e-002, 1.15606934e-002, 0.,
-       5.78034669e-003, 5.78034669e-003, 5.78034669e-003, 0., 0., 0., 0.,
-       1.73410401e-002, 0., 0., 0., 1.15606934e-002, 5.78034669e-003, 0.,
-       0., 0., 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 1.15606934e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.78034669e-003, 0., 0., 0., 0., 0.,
-       5.78034669e-003, 1.15606934e-002, 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 5.78034669e-003, 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 5.78034669e-003, 0., 0., 0., 1.15606934e-002, 0.,
-       0., 0., 0., 0., 1.15606934e-002, 0., 0., 5.78034669e-003, 0., 0.,
-       0., 0., 0., 0., 5.78034669e-003, 0., 0., 0., 5.78034669e-003,
-       1.15606934e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 1.73410401e-002, 0.,
-       1.15606934e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.15606934e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.15606934e-002, 0., 0., 5.78034669e-003, 0., 0., 0., 0.,
-       5.78034669e-003, 5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.15606934e-002, 0., 0., 0., 0., 5.78034669e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003,
-       5.78034669e-003, 0., 5.78034669e-003, 0., 0., 5.78034669e-003, 0.,
-       5.78034669e-003, 0., 0., 0., 0., 5.78034669e-003, 5.78034669e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 5.78034669e-003, 0., 0., 5.78034669e-003, 0.,
-       0., 2.31213868e-002, 0., 0., 0., 1.15606934e-002, 0., 0., 0., 0.,
-       0., 0., 5.78034669e-003, 5.78034669e-003, 0., 0., 5.78034669e-003,
-       0., 5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 5.78034669e-003,
-       5.78034669e-003, 0., 5.78034669e-003, 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.15606934e-002, 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 5.78034669e-003, 5.78034669e-003,
-       5.78034669e-003, 0., 0., 0., 0., 0., 1.73410401e-002, 0., 0., 0.,
-       0., 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003,
-       0., 5.78034669e-003, 5.78034669e-003, 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.78034669e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.78034669e-003, 5.78034669e-003,
-       5.78034669e-003, 0., 0., 0., 0., 5.78034669e-003, 0., 0., 0., 0.,
-       0., 5.78034669e-003, 5.78034669e-003, 0., 0., 0., 0., 0.,
-       5.78034669e-003, 0., 0., 0., 5.78034669e-003, 0., 0., 0.,
-       5.78034669e-003, 0., 0., 5.78034669e-003, 0., 0., 0., 0., 0., 0.,
-       0., 1.86335407e-002, 0., 0., 0., 0., 1.86335407e-002, 0., 0., 0.,
-       1.24223605e-002, 0., 0., 6.21118024e-003, 1.24223605e-002,
-       6.21118024e-003, 1.24223605e-002, 0., 6.21118024e-003,
-       1.24223605e-002, 0., 6.21118024e-003, 6.21118024e-003,
-       6.21118024e-003, 6.21118024e-003, 0., 6.21118024e-003,
-       2.48447210e-002, 6.21118024e-003, 3.72670814e-002,
-       2.48447210e-002, 0., 6.21118024e-003, 0., 0., 6.21118024e-003, 0.,
-       0., 6.21118024e-003, 0., 6.21118024e-003, 0., 0., 0.,
-       6.21118024e-003, 0., 6.21118024e-003, 6.21118024e-003,
-       2.48447210e-002, 3.10559012e-002, 0., 0., 1.24223605e-002, 0.,
-       1.24223605e-002, 0., 6.21118024e-003, 0., 0., 0., 0., 0., 0.,
-       1.24223605e-002, 0., 6.21118024e-003, 6.21118024e-003, 0., 0.,
-       6.21118024e-003, 0., 0., 0., 6.21118024e-003, 0., 0., 0.,
-       6.21118024e-003, 0., 0., 0., 0., 0., 6.21118024e-003, 0.,
-       1.24223605e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.21118024e-003, 1.24223605e-002, 0., 0., 0., 0.,
-       6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 1.24223605e-002, 0.,
-       0., 6.21118024e-003, 6.21118024e-003, 6.21118024e-003,
-       2.48447210e-002, 0., 0., 0., 0., 0., 0., 0., 3.10559012e-002,
-       6.21118024e-003, 0., 0., 4.34782617e-002, 0., 0., 0., 0., 0., 0.,
-       0., 1.24223605e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 6.21118024e-003, 0.,
-       0., 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0., 1.24223605e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.21118024e-003,
-       6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.24223605e-002, 0., 6.21118024e-003, 6.21118024e-003, 0.,
-       6.21118024e-003, 0., 0., 0., 0., 6.21118024e-003, 0., 0.,
-       6.21118024e-003, 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0., 0.,
-       0., 6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.86335407e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.21118024e-003,
-       6.21118024e-003, 0., 0., 0., 0., 1.24223605e-002, 0., 0.,
-       6.21118024e-003, 6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 3.10559012e-002, 0., 0., 0., 0., 0., 1.24223605e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.24223605e-002, 0., 0., 0., 0., 0.,
-       0., 0., 6.21118024e-003, 0., 6.21118024e-003, 0., 1.86335407e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.21118024e-003, 0., 6.21118024e-003, 6.21118024e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.21118024e-003, 6.21118024e-003,
-       6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 1.24223605e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.21118024e-003, 0.,
-       6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0., 6.21118024e-003,
-       0., 0., 0., 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0., 0., 0.,
-       1.86335407e-002, 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0., 0.,
-       0., 6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.21118024e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0., 0., 0.,
-       1.10497242e-002, 1.10497242e-002, 0., 5.52486209e-003, 0., 0.,
-       5.52486209e-003, 5.52486209e-003, 5.52486209e-003,
-       5.52486209e-003, 1.10497242e-002, 0., 1.10497242e-002, 0.,
-       5.52486209e-003, 5.52486209e-003, 0., 0., 5.52486209e-003, 0.,
-       5.52486209e-003, 1.10497242e-002, 1.10497242e-002,
-       5.52486209e-003, 0., 0., 4.41988967e-002, 0., 1.65745858e-002,
-       2.20994484e-002, 1.65745858e-002, 0., 0., 5.52486209e-003, 0., 0.,
-       0., 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0.,
-       1.10497242e-002, 1.65745858e-002, 2.20994484e-002, 0., 0., 0.,
-       5.52486209e-003, 0., 0., 5.52486209e-003, 0., 5.52486209e-003, 0.,
-       0., 0., 0., 5.52486209e-003, 0., 1.10497242e-002, 0., 0., 0., 0.,
-       0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 5.52486209e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 5.52486209e-003, 5.52486209e-003,
-       0., 5.52486209e-003, 0., 5.52486209e-003, 2.20994484e-002, 0., 0.,
-       0., 0., 0., 0., 5.52486209e-003, 1.65745858e-002, 0.,
-       5.52486209e-003, 0., 0., 0., 5.52486209e-003, 0., 1.10497242e-002,
-       0., 0., 0., 0., 0., 3.31491716e-002, 0., 0., 0., 3.31491716e-002,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0.,
-       0., 0., 0., 5.52486209e-003, 0., 5.52486209e-003, 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0.,
-       0., 0., 5.52486209e-003, 0., 0., 0., 5.52486209e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.10497242e-002, 1.10497242e-002, 0.,
-       5.52486209e-003, 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.65745858e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 5.52486209e-003, 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0.,
-       0., 0., 0., 0., 5.52486209e-003, 5.52486209e-003, 0., 0.,
-       5.52486209e-003, 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0.,
-       2.76243109e-002, 5.52486209e-003, 5.52486209e-003, 0., 0., 0.,
-       1.10497242e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 2.20994484e-002, 0.,
-       0., 0., 0., 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.52486209e-003, 0., 5.52486209e-003, 0., 0., 0., 0., 0.,
-       0., 0., 5.52486209e-003, 0., 3.31491716e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 1.10497242e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.52486209e-003,
-       0., 5.52486209e-003, 5.52486209e-003, 0., 0., 0., 0.,
-       5.52486209e-003, 1.10497242e-002, 0., 0., 0., 1.10497242e-002, 0.,
-       5.52486209e-003, 0., 0., 5.52486209e-003, 5.52486209e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.10497242e-002, 0., 0., 0., 0., 0.,
-       1.10497242e-002, 0., 5.52486209e-003, 0., 5.52486209e-003, 0.,
-       1.10497242e-002, 0., 0., 5.52486209e-003, 0., 0., 0., 0.,
-       2.20994484e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.10497242e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.52486209e-003, 5.52486209e-003, 0., 5.52486209e-003,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.10497242e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.24223605e-002, 6.21118024e-003, 0.,
-       1.24223605e-002, 0., 0., 0., 6.21118024e-003, 0., 1.24223605e-002,
-       6.21118024e-003, 0., 0., 0., 0., 0., 2.48447210e-002, 0., 0.,
-       1.24223605e-002, 0., 0., 0., 0., 0., 3.10559012e-002, 0.,
-       6.21118024e-003, 3.10559012e-002, 6.21118024e-003,
-       1.86335407e-002, 0., 1.24223605e-002, 0., 0., 0., 0.,
-       1.24223605e-002, 0., 0., 0., 6.21118024e-003, 0., 0., 0.,
-       1.24223605e-002, 0., 4.34782617e-002, 6.21118024e-003,
-       6.21118024e-003, 0., 0., 6.21118024e-003, 0., 1.24223605e-002, 0.,
-       0., 0., 0., 0., 6.21118024e-003, 0., 0., 6.21118024e-003,
-       6.21118024e-003, 0., 0., 0., 0., 0., 0., 6.21118024e-003, 0.,
-       6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.21118024e-003, 6.21118024e-003,
-       1.24223605e-002, 0., 0., 0., 1.24223605e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.21118024e-003,
-       1.24223605e-002, 0., 1.24223605e-002, 0., 0., 6.21118024e-003, 0.,
-       0., 1.86335407e-002, 0., 6.21118024e-003, 0., 3.72670814e-002, 0.,
-       0., 0., 0., 0., 0., 0., 1.24223605e-002, 0., 0., 0., 0., 0.,
-       6.21118024e-003, 0., 6.21118024e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.24223605e-002, 0., 1.24223605e-002,
-       6.21118024e-003, 0., 6.21118024e-003, 0., 3.72670814e-002, 0.,
-       6.21118024e-003, 0., 0., 0., 6.21118024e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0., 0., 0.,
-       6.21118024e-003, 6.21118024e-003, 0., 0., 0., 0., 0.,
-       6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.21118024e-003, 6.21118024e-003, 0., 0., 0., 6.21118024e-003, 0.,
-       0., 0., 0., 0., 6.21118024e-003, 0., 0., 6.21118024e-003, 0.,
-       6.21118024e-003, 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0., 0.,
-       0., 0., 1.24223605e-002, 6.21118024e-003, 0., 0., 0., 0.,
-       6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 2.48447210e-002, 0., 6.21118024e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.24223605e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.21118024e-003, 0., 0.,
-       6.21118024e-003, 0., 0., 6.21118024e-003, 0., 0., 0., 0.,
-       6.21118024e-003, 0., 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0.,
-       0., 6.21118024e-003, 0., 0., 0., 0., 1.24223605e-002, 0.,
-       3.10559012e-002, 6.21118024e-003, 0., 0., 0., 0., 0., 0.,
-       6.21118024e-003, 0., 0., 0., 6.21118024e-003, 0., 0., 0., 0., 0.,
-       0., 6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.21118024e-003, 6.21118024e-003, 0., 6.21118024e-003, 0., 0., 0.,
-       0., 0., 6.21118024e-003, 0., 0., 0., 6.21118024e-003, 0., 0., 0.,
-       0., 1.86335407e-002, 0., 0., 0., 6.21118024e-003, 0., 0., 0.,
-       6.21118024e-003, 0., 0., 0., 6.21118024e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.24223605e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.24223605e-002, 0., 0.,
-       1.24223605e-002, 6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.21118024e-003, 0., 1.24223605e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.21118024e-003, 0., 0., 0., 6.21118024e-003,
-       0., 1.24223605e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.21118024e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.21118024e-003, 0.,
-       1.16959065e-002, 0., 0., 1.16959065e-002, 0., 0., 0., 0.,
-       1.75438598e-002, 0., 5.84795326e-003, 0., 5.84795326e-003, 0., 0.,
-       5.84795326e-003, 5.84795326e-003, 0., 5.84795326e-003, 0.,
-       5.84795326e-003, 0., 2.33918130e-002, 0., 0., 1.16959065e-002, 0.,
-       5.84795326e-003, 5.84795326e-003, 2.92397663e-002, 0.,
-       5.84795326e-003, 0., 5.84795326e-003, 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 5.84795326e-003, 0., 0., 0., 0.,
-       5.84795326e-003, 4.09356728e-002, 1.16959065e-002, 0.,
-       5.84795326e-003, 0., 0., 0., 5.84795326e-003, 0., 0., 0.,
-       1.16959065e-002, 0., 0., 5.84795326e-003, 5.84795326e-003, 0., 0.,
-       0., 5.84795326e-003, 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 1.75438598e-002, 0., 0., 0.,
-       5.84795326e-003, 1.75438598e-002, 0., 0., 0., 1.16959065e-002, 0.,
-       0., 0., 0., 5.84795326e-003, 0., 5.84795326e-003, 0.,
-       5.84795326e-003, 0., 0., 0., 5.84795326e-003, 0., 5.84795326e-003,
-       5.84795326e-003, 0., 0., 0., 0., 5.84795326e-003, 4.09356728e-002,
-       0., 0., 0., 2.92397663e-002, 5.84795326e-003, 0., 5.84795326e-003,
-       0., 0., 5.84795326e-003, 0., 5.84795326e-003, 0., 0., 0., 0.,
-       5.84795326e-003, 5.84795326e-003, 5.84795326e-003, 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.16959065e-002, 0., 5.84795326e-003, 0., 0., 5.84795326e-003,
-       2.33918130e-002, 0., 5.84795326e-003, 0., 5.84795326e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.84795326e-003, 0., 0., 0., 0., 5.84795326e-003, 0., 0.,
-       1.16959065e-002, 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0.,
-       5.84795326e-003, 5.84795326e-003, 0., 5.84795326e-003,
-       5.84795326e-003, 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.75438598e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.84795326e-003, 0., 5.84795326e-003, 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.84795326e-003, 0., 0., 1.16959065e-002, 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 1.16959065e-002, 0., 0., 0.,
-       0., 2.33918130e-002, 0., 0., 0., 0., 0., 5.84795326e-003,
-       5.84795326e-003, 5.84795326e-003, 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 1.16959065e-002, 0., 0., 0., 0., 0., 0.,
-       0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 2.92397663e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.16959065e-002, 0., 1.16959065e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.16959065e-002, 0., 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0.,
-       0., 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0., 1.16959065e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003,
-       5.84795326e-003, 0., 0., 5.84795326e-003, 0., 0., 0.,
-       5.84795326e-003, 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 1.16959065e-002,
-       0., 0., 1.16959065e-002, 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.84795326e-003, 0., 0., 0., 5.84795326e-003, 0., 0.,
-       5.84795326e-003, 0., 0., 1.16959065e-002, 0., 5.84795326e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 1.16959065e-002, 0.,
-       5.84795326e-003, 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0.,
-       0., 0., 5.84795326e-003, 0., 0., 0., 0., 0., 5.84795326e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 5.88235306e-003, 0.,
-       5.88235306e-003, 0., 1.17647061e-002, 0., 5.88235306e-003,
-       1.17647061e-002, 5.88235306e-003, 0., 0., 1.17647061e-002,
-       5.88235306e-003, 0., 5.88235306e-003, 0., 1.17647061e-002, 0., 0.,
-       1.76470596e-002, 0., 1.17647061e-002, 1.17647061e-002, 0., 0.,
-       2.35294122e-002, 0., 1.17647061e-002, 1.76470596e-002,
-       5.88235306e-003, 5.88235306e-003, 0., 5.88235306e-003, 0., 0., 0.,
-       0., 5.88235306e-003, 1.17647061e-002, 0., 0., 5.88235306e-003,
-       1.17647061e-002, 0., 5.88235306e-003, 5.88235306e-003,
-       1.17647061e-002, 1.76470596e-002, 0., 0., 5.88235306e-003, 0., 0.,
-       5.88235306e-003, 5.88235306e-003, 0., 0., 5.88235306e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.88235306e-003, 5.88235306e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.17647061e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.88235306e-003, 5.88235306e-003, 0.,
-       0., 0., 0., 0., 0., 0., 1.17647061e-002, 0., 0., 0.,
-       5.88235306e-003, 0., 0., 0., 0., 5.88235306e-003, 0., 0.,
-       5.88235306e-003, 0., 0., 0., 0., 5.88235306e-003, 5.88235306e-003,
-       0., 0., 0., 0., 0., 0., 5.88235306e-003, 2.94117648e-002, 0.,
-       5.88235306e-003, 0., 2.35294122e-002, 5.88235306e-003, 0.,
-       5.88235306e-003, 0., 0., 0., 0., 5.88235306e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.88235306e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.88235306e-003, 5.88235306e-003, 0., 0.,
-       3.52941193e-002, 0., 0., 0., 5.88235306e-003, 0., 0., 0., 0.,
-       5.88235306e-003, 0., 0., 0., 0., 0., 0., 5.88235306e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.88235306e-003, 0.,
-       5.88235306e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.88235306e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.88235306e-003, 0., 0., 0., 5.88235306e-003, 0., 0., 0.,
-       5.88235306e-003, 0., 0., 0., 0., 0., 5.88235306e-003,
-       5.88235306e-003, 0., 1.76470596e-002, 0., 5.88235306e-003, 0.,
-       1.17647061e-002, 0., 5.88235306e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.17647061e-002, 0., 0., 0., 5.88235306e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.88235306e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.88235306e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.88235306e-003, 0., 0., 0., 0., 0., 0., 0., 5.88235306e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.88235306e-003, 5.88235306e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.17647061e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.88235306e-003, 0., 0., 0., 0., 0.,
-       1.76470596e-002, 0., 5.88235306e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.17647061e-002, 0., 2.94117648e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.17647061e-002, 0., 0., 0., 0., 5.88235306e-003, 0., 0.,
-       0., 5.88235306e-003, 0., 0., 0., 0., 0., 2.35294122e-002,
-       1.17647061e-002, 5.88235306e-003, 0., 0., 0., 0., 0., 0.,
-       5.88235306e-003, 0., 0., 5.88235306e-003, 0., 0., 0.,
-       5.88235306e-003, 0., 0., 0., 0., 0., 1.17647061e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.88235306e-003, 0.,
-       5.88235306e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.88235306e-003, 0., 0., 0., 5.88235306e-003,
-       5.88235306e-003, 0., 0., 5.88235306e-003, 0., 0., 1.17647061e-002,
-       5.88235306e-003, 0., 0., 0., 0., 0., 0., 5.88235306e-003, 0., 0.,
-       0., 0., 0., 1.17647061e-002, 0., 5.88235306e-003, 0.,
-       5.88235306e-003, 0., 0., 0., 0., 0., 0., 1.17647061e-002, 0., 0.,
-       5.88235306e-003, 0., 0., 5.88235306e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.88235306e-003, 0., 0., 0.,
-       5.88235306e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.88235306e-003, 0., 0., 0., 0., 5.88235306e-003, 0.,
-       5.88235306e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.17647061e-002, 0.,
-       0., 5.88235306e-003, 0., 0., 5.88235306e-003, 0., 5.81395347e-003,
-       0., 0., 0., 0., 0., 5.81395347e-003, 0., 5.81395347e-003, 0., 0.,
-       0., 5.81395347e-003, 5.81395347e-003, 5.81395347e-003,
-       5.81395347e-003, 0., 2.90697664e-002, 5.81395347e-003, 0.,
-       5.81395347e-003, 0., 2.90697664e-002, 0., 0., 0., 2.32558139e-002,
-       0., 1.16279069e-002, 2.90697664e-002, 0., 0., 0., 5.81395347e-003,
-       5.81395347e-003, 0., 0., 0., 0., 1.16279069e-002, 0., 0., 0., 0.,
-       5.81395347e-003, 1.16279069e-002, 0., 2.32558139e-002,
-       1.74418613e-002, 0., 5.81395347e-003, 5.81395347e-003, 0., 0., 0.,
-       1.74418613e-002, 0., 0., 0., 1.16279069e-002, 0., 0.,
-       5.81395347e-003, 0., 2.90697664e-002, 5.81395347e-003, 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0.,
-       5.81395347e-003, 5.81395347e-003, 0., 5.81395347e-003, 0.,
-       5.81395347e-003, 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0.,
-       1.16279069e-002, 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0.,
-       0., 1.74418613e-002, 0., 0., 0., 0., 0., 2.32558139e-002,
-       5.81395347e-003, 0., 0., 2.32558139e-002, 5.81395347e-003, 0.,
-       5.81395347e-003, 0., 2.32558139e-002, 0., 0., 0., 0., 0.,
-       5.81395347e-003, 5.81395347e-003, 5.81395347e-003,
-       5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.81395347e-003, 0., 1.16279069e-002, 0., 0., 0., 0., 0.,
-       3.48837227e-002, 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0.,
-       0., 0., 0., 1.16279069e-002, 0., 0., 5.81395347e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 5.81395347e-003,
-       0., 0., 0., 5.81395347e-003, 0., 0., 5.81395347e-003,
-       5.81395347e-003, 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 2.90697664e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.16279069e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.16279069e-002, 5.81395347e-003, 0., 0.,
-       0., 0., 5.81395347e-003, 0., 0., 0., 0., 5.81395347e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.81395347e-003,
-       0., 5.81395347e-003, 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.81395347e-003, 0., 1.74418613e-002, 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.16279069e-002, 0., 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0.,
-       0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0.,
-       5.81395347e-003, 0., 0., 5.81395347e-003, 0., 0., 5.81395347e-003,
-       0., 0., 0., 0., 1.16279069e-002, 0., 0., 1.16279069e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.16279069e-002, 0., 0., 0.,
-       5.81395347e-003, 0., 0., 5.81395347e-003, 5.81395347e-003, 0., 0.,
-       0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.74418613e-002, 0., 0., 0., 5.81395347e-003, 0., 0., 0.,
-       5.81395347e-003, 0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.81395347e-003,
-       0., 0., 0., 0., 5.81395347e-003, 5.81395347e-003, 0.,
-       5.81395347e-003, 0., 5.81395347e-003, 0., 0., 0., 5.81395347e-003,
-       0., 0., 5.81395347e-003, 0., 5.81395347e-003, 0., 0., 0., 0., 0.,
-       0., 0., 5.81395347e-003, 0., 0., 0., 0., 0., 0., 1.16279069e-002,
-       0., 0., 0., 0., 0., 5.81395347e-003, 0., 0., 0., 0., 0.,
-       9.70873795e-003, 0., 0., 0., 0., 9.70873795e-003, 0., 0.,
-       1.94174759e-002, 0., 0., 0., 0., 1.94174759e-002, 0.,
-       9.70873795e-003, 1.94174759e-002, 0., 1.94174759e-002, 0., 0.,
-       9.70873795e-003, 9.70873795e-003, 0., 9.70873795e-003,
-       9.70873795e-003, 0., 1.94174759e-002, 0., 1.94174759e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.70873795e-003, 0., 0.,
-       9.70873795e-003, 0., 0., 1.94174759e-002, 0., 0., 0.,
-       9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.70873795e-003, 0., 0., 0.,
-       0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 9.70873795e-003,
-       9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.94174759e-002, 0., 9.70873795e-003, 0., 0.,
-       0., 0., 0., 2.91262139e-002, 0., 0., 9.70873795e-003,
-       2.91262139e-002, 9.70873795e-003, 0., 9.70873795e-003, 0.,
-       1.94174759e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.94174759e-002, 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.79611638e-002, 0., 9.70873795e-003,
-       0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.94174759e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.70873795e-003, 0., 0., 0., 0., 0., 0.,
-       2.91262139e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.70873795e-003, 0.,
-       0., 0., 0., 0., 0., 9.70873795e-003, 0., 0., 0., 0., 0., 0.,
-       9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.82524277e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 2.91262139e-002, 0., 0., 0., 9.70873795e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.94174759e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.70873795e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.70873795e-003, 0.,
-       9.70873795e-003, 0., 0., 0., 0., 0., 0., 9.70873795e-003,
-       9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.70873795e-003, 0., 0., 0., 0.,
-       0., 0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.70873795e-003,
-       1.94174759e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.94174759e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.94174759e-002, 0., 0., 9.70873795e-003, 0., 0., 0., 0.,
-       9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.70873795e-003, 0., 0., 0.,
-       9.70873795e-003, 0., 0., 1.94174759e-002, 0., 0., 0., 0.,
-       9.70873795e-003, 9.70873795e-003, 0., 9.70873795e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.70873795e-003, 0., 9.70873795e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 2.42424235e-002, 6.06060587e-003, 0., 0., 0.,
-       6.06060587e-003, 0., 0., 2.42424235e-002, 6.06060587e-003, 0.,
-       1.21212117e-002, 0., 0., 0., 0., 6.06060587e-003, 0.,
-       6.06060587e-003, 0., 6.06060587e-003, 0., 1.81818176e-002,
-       6.06060587e-003, 0., 0., 0., 0., 0., 6.06060587e-003,
-       6.06060587e-003, 6.06060587e-003, 0., 0., 6.06060587e-003, 0., 0.,
-       0., 6.06060587e-003, 6.06060587e-003, 0., 0., 0., 6.06060587e-003,
-       6.06060587e-003, 1.21212117e-002, 0., 1.21212117e-002,
-       1.81818176e-002, 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.06060587e-003, 0., 6.06060587e-003, 0., 1.21212117e-002,
-       2.42424235e-002, 6.06060587e-003, 0., 6.06060587e-003,
-       6.06060587e-003, 0., 6.06060587e-003, 0., 1.81818176e-002, 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 1.21212117e-002,
-       0., 0., 0., 0., 0., 6.06060587e-003, 0., 0., 1.21212117e-002, 0.,
-       6.06060587e-003, 0., 0., 0., 1.21212117e-002, 6.06060587e-003,
-       1.21212117e-002, 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.06060587e-003, 6.06060587e-003,
-       6.06060587e-003, 0., 0., 0., 0., 0., 1.21212117e-002, 0.,
-       6.06060587e-003, 6.06060587e-003, 3.63636352e-002,
-       6.06060587e-003, 0., 1.21212117e-002, 0., 6.06060587e-003, 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 6.06060587e-003, 1.21212117e-002,
-       1.81818176e-002, 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.21212117e-002, 6.06060587e-003, 6.06060587e-003,
-       0., 0., 0., 1.21212117e-002, 0., 0., 0., 0., 6.06060587e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.06060587e-003, 0., 0., 0., 0.,
-       0., 0., 6.06060587e-003, 0., 0., 0., 6.06060587e-003,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 6.06060587e-003,
-       6.06060587e-003, 0., 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.21212117e-002, 0., 0., 6.06060587e-003,
-       1.21212117e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 6.06060587e-003, 0., 6.06060587e-003, 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.21212117e-002, 0., 0., 0.,
-       6.06060587e-003, 0., 0., 1.81818176e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.06060587e-003, 0.,
-       1.81818176e-002, 0., 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0.,
-       0., 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 1.21212117e-002, 0., 6.06060587e-003, 0.,
-       1.21212117e-002, 6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.21212117e-002, 0., 0., 0.,
-       6.06060587e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0.,
-       1.21212117e-002, 0., 0., 0., 0., 0., 6.06060587e-003, 0., 0.,
-       1.21212117e-002, 0., 0., 0., 0., 0., 1.21212117e-002, 0., 0., 0.,
-       0., 0., 0., 1.21212117e-002, 0., 0., 6.06060587e-003, 0., 0., 0.,
-       0., 0., 0., 0., 6.06060587e-003, 0., 0., 0., 6.06060587e-003,
-       6.06060587e-003, 0., 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.21212117e-002, 0., 0., 0., 0., 0., 0., 6.06060587e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.81818176e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.06060587e-003, 0., 0., 0.,
-       0., 0., 0., 0., 6.06060587e-003, 0., 0., 0., 0., 0., 0.,
-       6.06060587e-003, 0., 1.21212117e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.06060587e-003, 0., 0., 6.06060587e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.06060587e-003, 0., 0.,
-       0., 0., 0., 0., 1.21951215e-002, 6.09756075e-003, 0., 0., 0., 0.,
-       0., 6.09756075e-003, 1.21951215e-002, 0., 2.43902430e-002, 0., 0.,
-       0., 0., 1.21951215e-002, 6.09756075e-003, 1.21951215e-002,
-       1.21951215e-002, 6.09756075e-003, 6.09756075e-003, 0., 0.,
-       1.21951215e-002, 1.82926822e-002, 0., 6.09756075e-003, 0.,
-       6.09756075e-003, 0., 0., 1.21951215e-002, 0., 0., 0.,
-       6.09756075e-003, 0., 0., 1.21951215e-002, 0., 0., 6.09756075e-003,
-       6.09756075e-003, 0., 0., 0., 1.21951215e-002, 6.09756075e-003,
-       1.21951215e-002, 0., 1.21951215e-002, 6.09756075e-003,
-       6.09756075e-003, 0., 1.21951215e-002, 6.09756075e-003, 0., 0.,
-       6.09756075e-003, 0., 0., 0., 6.09756075e-003, 6.09756075e-003,
-       6.09756075e-003, 6.09756075e-003, 0., 6.09756075e-003, 0., 0.,
-       1.21951215e-002, 0., 0., 0., 0., 6.09756075e-003, 0., 0.,
-       6.09756075e-003, 6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.09756075e-003, 1.21951215e-002, 0., 0., 0.,
-       6.09756075e-003, 6.09756075e-003, 6.09756075e-003,
-       6.09756075e-003, 0., 0., 0., 6.09756075e-003, 0., 6.09756075e-003,
-       0., 1.21951215e-002, 0., 0., 1.82926822e-002, 0., 6.09756075e-003,
-       0., 0., 0., 6.09756075e-003, 0., 6.09756075e-003, 0., 0., 0., 0.,
-       0., 1.21951215e-002, 0., 0., 0., 2.43902430e-002, 0., 0.,
-       6.09756075e-003, 0., 0., 0., 0., 2.43902430e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.09756075e-003, 1.21951215e-002, 0.,
-       6.09756075e-003, 6.09756075e-003, 6.09756075e-003, 0., 0.,
-       1.21951215e-002, 0., 0., 1.21951215e-002, 0., 0., 0.,
-       6.09756075e-003, 2.43902430e-002, 0., 0., 0., 0., 0., 0.,
-       6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003, 6.09756075e-003,
-       0., 0., 0., 0., 0., 6.09756075e-003, 0., 0., 6.09756075e-003, 0.,
-       6.09756075e-003, 0., 0., 0., 0., 0., 6.09756075e-003, 0., 0., 0.,
-       0., 0., 0., 6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.21951215e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.09756075e-003, 0., 0., 0., 0., 0., 6.09756075e-003,
-       6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003, 0.,
-       6.09756075e-003, 0., 0., 6.09756075e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.09756075e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.09756075e-003, 6.09756075e-003, 6.09756075e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.09756075e-003, 6.09756075e-003, 0., 0., 0., 0.,
-       0., 6.09756075e-003, 0., 0., 0., 0., 0., 2.43902430e-002, 0., 0.,
-       0., 0., 0., 0., 6.09756075e-003, 0., 0., 0., 0., 0.,
-       6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003,
-       0., 0., 6.09756075e-003, 0., 6.09756075e-003, 0., 0., 0.,
-       1.21951215e-002, 0., 0., 6.09756075e-003, 0., 0., 0., 0.,
-       1.21951215e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.09756075e-003, 0., 0., 0., 6.09756075e-003, 0., 0.,
-       0., 0., 0., 0., 0., 6.09756075e-003, 0., 0., 0., 0., 0., 0.,
-       1.21951215e-002, 0., 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003,
-       0., 0., 0., 6.09756075e-003, 0., 1.21951215e-002, 0.,
-       6.09756075e-003, 6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.09756075e-003, 0., 0., 6.09756075e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003, 0., 0., 0.,
-       6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003,
-       1.21951215e-002, 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003, 0.,
-       0., 0., 0., 6.09756075e-003, 6.09756075e-003, 0., 0., 0., 0.,
-       6.09756075e-003, 6.09756075e-003, 0., 0., 0., 0., 0., 0.,
-       6.09756075e-003, 6.09756075e-003, 0., 0., 0., 6.09756075e-003, 0.,
-       0., 0., 5.61797759e-003, 1.68539323e-002, 1.12359552e-002, 0., 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 5.61797759e-003,
-       1.12359552e-002, 5.61797759e-003, 5.61797759e-003,
-       1.12359552e-002, 1.68539323e-002, 0., 0., 1.12359552e-002, 0., 0.,
-       1.12359552e-002, 0., 1.12359552e-002, 5.61797759e-003, 0.,
-       5.61797759e-003, 5.61797759e-003, 0., 1.68539323e-002, 0.,
-       5.61797759e-003, 1.12359552e-002, 0., 5.61797759e-003,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 1.12359552e-002, 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 1.12359552e-002, 0.,
-       0., 1.12359552e-002, 0., 0., 1.12359552e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.68539323e-002, 5.61797759e-003,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 5.61797759e-003, 0.,
-       5.61797759e-003, 0., 0., 0., 0., 5.61797759e-003, 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 1.12359552e-002,
-       5.61797759e-003, 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       1.68539323e-002, 0., 5.61797759e-003, 1.12359552e-002, 0., 0.,
-       5.61797759e-003, 5.61797759e-003, 0., 5.61797759e-003, 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 5.61797759e-003, 0., 0.,
-       0., 1.12359552e-002, 5.61797759e-003, 0., 0., 0., 0., 0.,
-       5.61797759e-003, 5.61797759e-003, 1.12359552e-002, 0., 0., 0.,
-       5.61797759e-003, 0., 5.05617969e-002, 0., 0., 0., 2.24719103e-002,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       0., 0., 0., 0., 5.61797759e-003, 5.61797759e-003, 5.61797759e-003,
-       0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 3.93258445e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.61797759e-003, 0., 0., 5.61797759e-003,
-       1.12359552e-002, 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.12359552e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 5.61797759e-003, 5.61797759e-003,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 5.61797759e-003, 0., 0.,
-       1.12359552e-002, 0., 0., 5.61797759e-003, 5.61797759e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.61797759e-003, 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 0., 5.61797759e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 5.61797759e-003, 5.61797759e-003, 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.12359552e-002, 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 1.12359552e-002, 5.61797759e-003, 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 5.61797759e-003, 0., 0., 0.,
-       1.68539323e-002, 5.61797759e-003, 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 1.12359552e-002, 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       0., 0., 5.61797759e-003, 0., 5.61797759e-003, 0., 0., 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.35294120e-003, 7.35294120e-003, 7.35294120e-003, 0.,
-       7.35294120e-003, 7.35294120e-003, 0., 7.35294120e-003,
-       2.94117648e-002, 2.20588241e-002, 0., 1.47058824e-002,
-       7.35294120e-003, 0., 0., 7.35294120e-003, 0., 0., 0., 0.,
-       1.47058824e-002, 0., 2.20588241e-002, 7.35294120e-003, 0., 0.,
-       1.47058824e-002, 0., 1.47058824e-002, 1.47058824e-002, 0., 0., 0.,
-       1.47058824e-002, 1.47058824e-002, 7.35294120e-003, 0., 0., 0.,
-       1.47058824e-002, 0., 0., 0., 7.35294120e-003, 0., 0., 0., 0.,
-       1.47058824e-002, 0., 0., 0., 0., 0., 7.35294120e-003,
-       7.35294120e-003, 0., 1.47058824e-002, 0., 0., 7.35294120e-003, 0.,
-       0., 0., 1.47058824e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.35294120e-003, 7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.35294120e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.35294120e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.35294120e-003, 7.35294120e-003, 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 0., 3.67647074e-002, 0.,
-       7.35294120e-003, 0., 2.20588241e-002, 0., 0., 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.35294120e-003, 0., 0., 0., 1.47058824e-002, 0., 0., 0., 0.,
-       7.35294120e-003, 0., 0., 1.47058824e-002, 0., 7.35294120e-003,
-       7.35294120e-003, 0., 0., 7.35294120e-003, 0., 7.35294120e-003, 0.,
-       0., 0., 1.47058824e-002, 0., 0., 0., 0., 0., 7.35294120e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.35294120e-003, 0., 0.,
-       0., 2.20588241e-002, 0., 0., 0., 0., 0., 0., 7.35294120e-003, 0.,
-       0., 0., 1.47058824e-002, 0., 0., 0., 0., 7.35294120e-003, 0., 0.,
-       0., 0., 7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.47058824e-002, 0., 0., 0., 0., 0., 7.35294120e-003,
-       7.35294120e-003, 0., 0., 7.35294120e-003, 0., 7.35294120e-003, 0.,
-       0., 7.35294120e-003, 0., 0., 1.47058824e-002, 0., 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 2.94117648e-002, 0., 0., 0., 0., 7.35294120e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.35294120e-003, 0., 0., 0., 0., 0., 0., 7.35294120e-003, 0., 0.,
-       0., 0., 0., 0., 7.35294120e-003, 0., 0., 0., 0., 0.,
-       1.47058824e-002, 0., 7.35294120e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.35294120e-003, 0., 0., 0., 0., 0., 2.20588241e-002, 0.,
-       0., 0., 0., 0., 0., 0., 7.35294120e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.35294120e-003, 0., 0., 0.,
-       0., 0., 0., 7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.35294120e-003,
-       0., 0., 0., 0., 0., 1.47058824e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.35294120e-003,
-       0., 7.35294120e-003, 0., 0., 7.35294120e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.35294120e-003, 0.,
-       0., 0., 7.35294120e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.35294120e-003, 0., 0., 0., 0., 7.35294120e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.47058824e-002, 2.94117648e-002, 0., 0.,
-       0., 1.47058824e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.35294120e-003, 0., 7.35294120e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.35294120e-003, 0., 0.,
-       2.01342292e-002, 2.68456377e-002, 1.34228189e-002,
-       1.34228189e-002, 0., 4.69798669e-002, 0., 0., 0., 6.71140943e-003,
-       0., 6.71140943e-003, 1.34228189e-002, 1.34228189e-002, 0.,
-       1.34228189e-002, 6.71140943e-003, 1.34228189e-002, 0.,
-       1.34228189e-002, 0., 0., 2.01342292e-002, 1.34228189e-002, 0., 0.,
-       6.71140943e-003, 0., 6.71140943e-003, 0., 1.34228189e-002,
-       1.34228189e-002, 0., 0., 0., 0., 0., 0., 6.71140943e-003,
-       2.01342292e-002, 0., 0., 0., 6.71140943e-003, 6.71140943e-003,
-       6.71140943e-003, 6.71140943e-003, 1.34228189e-002,
-       1.34228189e-002, 0., 0., 1.34228189e-002, 0., 0., 0.,
-       1.34228189e-002, 0., 6.71140943e-003, 0., 6.71140943e-003, 0., 0.,
-       0., 0., 6.71140943e-003, 6.71140943e-003, 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 0., 6.71140943e-003, 6.71140943e-003,
-       6.71140943e-003, 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.71140943e-003, 0., 2.01342292e-002,
-       6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 2.01342292e-002, 0., 0., 0., 6.71140943e-003, 0., 0., 0.,
-       0., 4.02684584e-002, 0., 0., 0., 1.34228189e-002, 0., 0.,
-       6.71140943e-003, 0., 0., 0., 0., 6.71140943e-003, 0., 0., 0., 0.,
-       6.71140943e-003, 6.71140943e-003, 0., 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0., 6.71140943e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.71140943e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.71140943e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.71140943e-003, 6.71140943e-003,
-       0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.71140943e-003, 6.71140943e-003, 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 2.01342292e-002, 0., 0., 1.34228189e-002,
-       0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.34228189e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.71140943e-003,
-       6.71140943e-003, 0., 0., 6.71140943e-003, 6.71140943e-003, 0., 0.,
-       0., 0., 0., 0., 0., 1.34228189e-002, 0., 0., 0., 6.71140943e-003,
-       0., 6.71140943e-003, 0., 0., 0., 0., 0., 1.34228189e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.71140943e-003, 1.34228189e-002, 0., 6.71140943e-003, 0.,
-       6.71140943e-003, 6.71140943e-003, 0., 0., 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 0., 0., 6.71140943e-003, 0., 0., 0., 0.,
-       0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 0., 6.71140943e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.34228189e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0.,
-       0., 6.71140943e-003, 0., 0., 1.34228189e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.71140943e-003, 0., 6.71140943e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.71140943e-003, 0., 0.,
-       1.80180185e-002, 0., 0., 9.00900923e-003, 9.00900923e-003, 0., 0.,
-       0., 9.00900923e-003, 0., 9.00900923e-003, 0., 9.00900923e-003, 0.,
-       9.00900923e-003, 0., 2.70270277e-002, 0., 0., 0., 0.,
-       9.00900923e-003, 0., 9.00900923e-003, 0., 0., 0., 9.00900923e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 2.70270277e-002,
-       1.80180185e-002, 0., 0., 0., 9.00900923e-003, 0., 9.00900923e-003,
-       0., 0., 9.00900923e-003, 9.00900923e-003, 0., 0., 0., 0.,
-       1.80180185e-002, 0., 0., 0., 0., 0., 0., 0., 9.00900923e-003, 0.,
-       9.00900923e-003, 0., 0., 9.00900923e-003, 9.00900923e-003, 0.,
-       9.00900923e-003, 0., 9.00900923e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.80180185e-002, 0., 0.,
-       0., 0., 0., 9.00900923e-003, 0., 0., 0., 9.00900923e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 2.70270277e-002, 0., 9.00900923e-003,
-       9.00900923e-003, 0., 9.00900923e-003, 0., 0., 0., 0., 0.,
-       9.00900923e-003, 0., 0., 0., 0., 0., 3.60360369e-002, 0., 0., 0.,
-       9.00900923e-003, 0., 0., 0., 0., 0., 0., 0., 9.00900923e-003, 0.,
-       0., 0., 0., 1.80180185e-002, 0., 9.00900923e-003, 0., 0., 0., 0.,
-       9.00900923e-003, 0., 0., 0., 0., 9.00900923e-003, 0.,
-       9.00900923e-003, 0., 9.00900923e-003, 9.00900923e-003, 0., 0., 0.,
-       0., 1.80180185e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.00900923e-003, 0., 0., 0., 0., 0., 0.,
-       1.80180185e-002, 0., 0., 9.00900923e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.00900923e-003,
-       0., 0., 0., 0., 0., 9.00900923e-003, 0., 0., 0., 0., 0., 0., 0.,
-       9.00900923e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.00900923e-003, 0., 9.00900923e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.00900923e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.00900923e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.00900923e-003, 0., 0., 0., 0., 0., 0.,
-       9.00900923e-003, 9.00900923e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.00900923e-003, 0.,
-       9.00900923e-003, 1.80180185e-002, 0., 0., 0., 9.00900923e-003,
-       9.00900923e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.00900923e-003, 0., 0., 9.00900923e-003, 0., 0., 0., 0.,
-       0., 1.80180185e-002, 9.00900923e-003, 0., 0., 0., 0., 0.,
-       1.80180185e-002, 0., 0., 0., 0., 9.00900923e-003, 1.80180185e-002,
-       0., 9.00900923e-003, 0., 0., 0., 0., 0., 0., 0., 9.00900923e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.00900923e-003, 0., 0., 0., 0., 0., 0., 9.00900923e-003, 0., 0.,
-       0., 0., 0., 1.80180185e-002, 0., 0., 0., 0., 0., 0.,
-       1.80180185e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.00900923e-003, 0., 0., 0., 0., 9.00900923e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 9.00900923e-003, 0., 0., 0., 0., 9.00900923e-003, 0., 0., 0.,
-       9.00900923e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.00900923e-003, 0., 0., 0., 0., 9.00900923e-003, 0., 0.,
-       9.00900923e-003, 0., 0., 9.00900923e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.80180185e-002, 0., 0.,
-       0., 9.00900923e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.00900923e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 9.00900923e-003, 0., 0., 9.00900923e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.68539323e-002, 2.24719103e-002, 1.12359552e-002,
-       1.68539323e-002, 1.12359552e-002, 1.12359552e-002, 0.,
-       5.61797759e-003, 0., 0., 0., 1.12359552e-002, 0., 0.,
-       5.61797759e-003, 1.12359552e-002, 5.61797759e-003,
-       1.12359552e-002, 5.61797759e-003, 0., 0., 5.61797759e-003,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 0., 0.,
-       1.12359552e-002, 5.61797759e-003, 0., 1.12359552e-002,
-       2.24719103e-002, 0., 1.12359552e-002, 5.61797759e-003,
-       1.12359552e-002, 2.80898884e-002, 1.12359552e-002,
-       5.61797759e-003, 0., 0., 0., 1.68539323e-002, 5.61797759e-003,
-       5.61797759e-003, 5.61797759e-003, 5.61797759e-003,
-       1.12359552e-002, 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       1.12359552e-002, 0., 0., 0., 1.12359552e-002, 5.61797759e-003, 0.,
-       0., 0., 0., 5.61797759e-003, 0., 1.12359552e-002, 0., 0., 0.,
-       1.68539323e-002, 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       0., 5.61797759e-003, 0., 0., 0., 0., 5.61797759e-003,
-       5.61797759e-003, 5.61797759e-003, 0., 1.12359552e-002, 0., 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 5.61797759e-003,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       5.61797759e-003, 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0.,
-       2.80898884e-002, 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       1.12359552e-002, 0., 0., 5.61797759e-003, 0., 0., 5.61797759e-003,
-       1.12359552e-002, 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       0., 0., 5.61797759e-003, 0., 5.61797759e-003, 0., 1.12359552e-002,
-       0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 5.61797759e-003, 0.,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0.,
-       0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0.,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       5.61797759e-003, 0., 5.61797759e-003, 5.61797759e-003,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       1.12359552e-002, 5.61797759e-003, 0., 5.61797759e-003,
-       5.61797759e-003, 1.12359552e-002, 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.68539323e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.61797759e-003, 0., 0., 5.61797759e-003, 0., 0., 5.61797759e-003,
-       0., 0., 0., 0., 0., 1.12359552e-002, 0., 0., 5.61797759e-003, 0.,
-       0., 0., 0., 0., 5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0.,
-       5.61797759e-003, 0., 5.61797759e-003, 0., 0., 0., 0., 0.,
-       5.61797759e-003, 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 5.61797759e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0.,
-       0., 0., 0., 1.12359552e-002, 0., 5.61797759e-003, 0., 0., 0., 0.,
-       0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0.,
-       0., 0., 1.12359552e-002, 0., 0., 5.61797759e-003, 0., 0.,
-       1.68539323e-002, 0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.61797759e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.61797759e-003,
-       5.61797759e-003, 0., 0., 0., 0., 1.12359552e-002, 0., 0.,
-       5.61797759e-003, 0., 0., 0., 0., 0., 5.61797759e-003, 0.,
-       6.41025649e-003, 1.92307699e-002, 0., 0., 1.28205130e-002,
-       1.28205130e-002, 0., 6.41025649e-003, 1.28205130e-002,
-       6.41025649e-003, 0., 0., 0., 6.41025649e-003, 0., 0.,
-       6.41025649e-003, 6.41025649e-003, 0., 1.28205130e-002,
-       6.41025649e-003, 0., 0., 1.92307699e-002, 0., 0., 6.41025649e-003,
-       0., 1.28205130e-002, 0., 1.28205130e-002, 6.41025649e-003, 0.,
-       6.41025649e-003, 1.92307699e-002, 0., 0., 0., 0., 1.28205130e-002,
-       0., 0., 0., 0., 0., 0., 0., 6.41025649e-003, 6.41025649e-003, 0.,
-       0., 1.28205130e-002, 0., 0., 1.28205130e-002, 1.28205130e-002, 0.,
-       6.41025649e-003, 0., 0., 1.28205130e-002, 0., 0., 6.41025649e-003,
-       0., 6.41025649e-003, 0., 6.41025649e-003, 0., 6.41025649e-003,
-       1.92307699e-002, 0., 0., 6.41025649e-003, 0., 6.41025649e-003, 0.,
-       0., 6.41025649e-003, 0., 0., 0., 1.28205130e-002, 0., 0., 0., 0.,
-       0., 0., 0., 6.41025649e-003, 0., 0., 6.41025649e-003, 0.,
-       6.41025649e-003, 0., 0., 0., 2.56410260e-002, 0., 6.41025649e-003,
-       0., 1.28205130e-002, 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 6.41025649e-003,
-       0., 0., 0., 1.28205130e-002, 6.41025649e-003, 6.41025649e-003, 0.,
-       0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 6.41025649e-003,
-       5.12820520e-002, 0., 0., 0., 1.28205130e-002, 6.41025649e-003, 0.,
-       0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 6.41025649e-003, 0., 0.,
-       0., 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 6.41025649e-003,
-       0., 0., 6.41025649e-003, 0., 6.41025649e-003, 0., 0.,
-       6.41025649e-003, 0., 6.41025649e-003, 6.41025649e-003, 0.,
-       6.41025649e-003, 0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 6.41025649e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.28205130e-002, 0., 0., 6.41025649e-003, 0., 6.41025649e-003, 0.,
-       0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 1.28205130e-002,
-       6.41025649e-003, 0., 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.28205130e-002, 0., 0., 6.41025649e-003,
-       0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 1.28205130e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.28205130e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 1.28205130e-002, 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 6.41025649e-003, 6.41025649e-003, 0.,
-       1.92307699e-002, 0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 0.,
-       6.41025649e-003, 6.41025649e-003, 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 6.41025649e-003, 0.,
-       0., 0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 6.41025649e-003,
-       0., 0., 0., 0., 0., 6.41025649e-003, 0., 1.28205130e-002, 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 6.41025649e-003, 0.,
-       0., 0., 0., 0., 0., 6.41025649e-003, 0., 6.41025649e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.41025649e-003, 0., 0., 0., 6.41025649e-003, 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 6.41025649e-003, 0., 0., 0., 6.41025649e-003,
-       0., 0., 5.68181835e-003, 1.13636367e-002, 0., 5.68181835e-003,
-       5.68181835e-003, 5.68181835e-003, 0., 0., 1.70454551e-002, 0., 0.,
-       0., 5.68181835e-003, 0., 0., 5.68181835e-003, 5.68181835e-003,
-       1.13636367e-002, 1.70454551e-002, 5.68181835e-003, 0., 0.,
-       5.68181835e-003, 5.68181835e-003, 0., 0., 1.70454551e-002, 0.,
-       1.13636367e-002, 0., 1.13636367e-002, 0., 0., 0., 1.13636367e-002,
-       0., 0., 5.68181835e-003, 5.68181835e-003, 1.70454551e-002, 0.,
-       5.68181835e-003, 0., 0., 0., 0., 0., 5.68181835e-003, 0.,
-       5.68181835e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.68181835e-003, 0., 0., 0., 5.68181835e-003, 0., 0.,
-       5.68181835e-003, 0., 0., 0., 0., 0., 0., 0., 5.68181835e-003, 0.,
-       5.68181835e-003, 0., 0., 0., 0., 0., 0., 5.68181835e-003, 0.,
-       5.68181835e-003, 0., 0., 5.68181835e-003, 0., 0., 0.,
-       5.68181835e-003, 0., 5.68181835e-003, 5.68181835e-003, 0.,
-       5.68181835e-003, 5.11363670e-002, 0., 0., 0., 0., 0.,
-       5.68181835e-003, 0., 5.68181835e-003, 0., 0., 0., 1.70454551e-002,
-       0., 5.68181835e-003, 0., 0., 0., 0., 5.68181835e-003, 0.,
-       5.68181835e-003, 0., 0., 0., 0., 0., 1.13636367e-002, 0.,
-       5.68181835e-003, 0., 1.13636367e-002, 5.68181835e-003, 0.,
-       1.13636367e-002, 0., 0., 5.68181835e-003, 0., 2.27272734e-002, 0.,
-       0., 5.68181835e-003, 0., 5.68181835e-003, 0., 1.13636367e-002, 0.,
-       5.68181835e-003, 0., 0., 0., 0., 5.68181835e-003, 0., 0., 0., 0.,
-       5.68181835e-003, 0., 5.68181835e-003, 0., 1.13636367e-002, 0.,
-       5.68181835e-003, 0., 1.13636367e-002, 0., 5.68181835e-003, 0., 0.,
-       0., 0., 5.68181835e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.13636367e-002, 0., 0., 0., 0., 0., 0., 0., 5.68181835e-003, 0.,
-       0., 5.68181835e-003, 5.68181835e-003, 5.68181835e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.68181835e-003, 0., 0., 0., 5.68181835e-003, 0.,
-       0., 5.68181835e-003, 0., 0., 0., 0., 5.68181835e-003, 0., 0.,
-       5.68181835e-003, 0., 0., 0., 0., 0., 5.68181835e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.68181835e-003, 5.68181835e-003, 0.,
-       5.68181835e-003, 5.68181835e-003, 0., 0., 0., 5.68181835e-003, 0.,
-       0., 0., 0., 0., 0., 0., 5.68181835e-003, 0., 0., 0., 0., 0., 0.,
-       5.68181835e-003, 0., 0., 0., 0., 0., 0., 0., 5.68181835e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.68181835e-003, 0.,
-       0., 5.68181835e-003, 0., 1.13636367e-002, 0., 0., 5.68181835e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.68181835e-003, 0.,
-       0., 5.68181835e-003, 0., 0., 0., 0., 1.13636367e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.13636367e-002, 0., 0., 0., 1.13636367e-002, 1.70454551e-002,
-       5.68181835e-003, 0., 5.68181835e-003, 0., 0., 0., 5.68181835e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.68181835e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.68181835e-003, 0., 0.,
-       1.13636367e-002, 0., 0., 5.68181835e-003, 0., 0., 0., 0., 0., 0.,
-       0., 5.68181835e-003, 0., 0., 0., 1.70454551e-002, 0., 0., 0.,
-       1.13636367e-002, 0., 0., 0., 0., 0., 5.68181835e-003, 0.,
-       3.40909101e-002, 0., 0., 0., 0., 1.13636367e-002, 0., 0., 0.,
-       5.68181835e-003, 5.68181835e-003, 0., 0., 0., 0., 0.,
-       5.68181835e-003, 5.68181835e-003, 0., 0., 5.68181835e-003, 0., 0.,
-       0., 5.68181835e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.68181835e-003, 0., 0., 5.68181835e-003, 0., 5.68181835e-003, 0.,
-       0., 5.68181835e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.68181835e-003, 0., 5.68181835e-003, 5.68181835e-003, 0.,
-       0., 0., 1.13636367e-002, 5.68181835e-003, 0., 5.68181835e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.68181835e-003, 0.,
-       0., 0., 5.68181835e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.13636367e-002, 1.13636367e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 2.39520967e-002,
-       1.19760484e-002, 0., 0., 0., 0., 0., 0., 5.98802418e-003, 0., 0.,
-       1.19760484e-002, 1.79640725e-002, 0., 1.19760484e-002,
-       5.98802418e-003, 0., 2.39520967e-002, 5.98802418e-003, 0.,
-       1.79640725e-002, 2.39520967e-002, 5.98802418e-003, 0.,
-       1.19760484e-002, 0., 1.79640725e-002, 0., 5.98802418e-003, 0.,
-       1.19760484e-002, 0., 0., 1.19760484e-002, 5.98802418e-003, 0., 0.,
-       5.98802418e-003, 2.99401209e-002, 0., 5.98802418e-003, 0., 0., 0.,
-       0., 4.79041934e-002, 5.98802418e-003, 0., 0., 1.19760484e-002,
-       5.98802418e-003, 0., 0., 0., 1.19760484e-002, 2.99401209e-002, 0.,
-       0., 1.19760484e-002, 0., 0., 0., 1.19760484e-002, 0., 0., 0., 0.,
-       0., 0., 0., 5.98802418e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.19760484e-002, 0., 0., 0., 0., 0., 0.,
-       5.98802418e-003, 1.79640725e-002, 0., 0., 1.19760484e-002, 0., 0.,
-       0., 0., 0., 5.98802418e-003, 0., 5.98802418e-003, 5.98802418e-003,
-       0., 0., 0., 0., 5.98802418e-003, 0., 5.98802418e-003, 0., 0., 0.,
-       0., 0., 5.98802418e-003, 5.98802418e-003, 0., 0., 0., 0., 0., 0.,
-       0., 1.19760484e-002, 0., 0., 0., 4.19161692e-002, 0., 0.,
-       5.98802418e-003, 0., 5.98802418e-003, 1.19760484e-002, 0.,
-       5.98802418e-003, 0., 0., 0., 0., 1.19760484e-002, 1.19760484e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.19760484e-002, 1.19760484e-002, 0., 0., 5.98802418e-003,
-       5.98802418e-003, 2.39520967e-002, 0., 1.19760484e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0., 0.,
-       0., 0., 0., 5.98802418e-003, 0., 0., 0., 5.98802418e-003, 0., 0.,
-       5.98802418e-003, 0., 0., 0., 0., 5.98802418e-003, 0., 0.,
-       5.98802418e-003, 0., 5.98802418e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.98802418e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.98802418e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0., 0., 0.,
-       0., 1.19760484e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.98802418e-003, 5.98802418e-003, 0., 0.,
-       5.98802418e-003, 5.98802418e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0.,
-       5.98802418e-003, 0., 5.98802418e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.98802418e-003, 0., 0., 5.98802418e-003, 0., 0., 0.,
-       0., 1.19760484e-002, 0., 0., 0., 1.19760484e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.98802418e-003, 5.98802418e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.98802418e-003,
-       5.98802418e-003, 5.98802418e-003, 0., 5.98802418e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0.,
-       5.98802418e-003, 0., 0., 0., 5.98802418e-003, 0., 0., 0.,
-       5.98802418e-003, 0., 0., 0., 5.98802418e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.98802418e-003, 0., 5.98802418e-003, 5.98802418e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.98802418e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.98802418e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.19760484e-002,
-       5.98802418e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.19760484e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.98802418e-003, 0., 0., 0., 5.98802418e-003, 0., 0., 0., 0., 0.,
-       0., 5.98802418e-003, 0., 0., 0., 2.19780225e-002, 1.09890113e-002,
-       1.64835174e-002, 0., 5.49450563e-003, 4.39560451e-002, 0., 0.,
-       1.64835174e-002, 5.49450563e-003, 5.49450563e-003,
-       1.64835174e-002, 0., 5.49450563e-003, 0., 0., 0., 1.09890113e-002,
-       0., 0., 0., 1.09890113e-002, 0., 0., 5.49450563e-003, 0.,
-       1.09890113e-002, 0., 1.64835174e-002, 5.49450563e-003,
-       5.49450563e-003, 1.09890113e-002, 0., 1.09890113e-002,
-       1.09890113e-002, 5.49450563e-003, 1.09890113e-002,
-       5.49450563e-003, 5.49450563e-003, 5.49450563e-003,
-       5.49450563e-003, 0., 0., 0., 0., 1.64835174e-002, 1.09890113e-002,
-       1.09890113e-002, 2.19780225e-002, 0., 0., 0., 0., 5.49450563e-003,
-       5.49450563e-003, 1.09890113e-002, 0., 0., 5.49450563e-003, 0., 0.,
-       0., 5.49450563e-003, 0., 5.49450563e-003, 0., 0., 0.,
-       5.49450563e-003, 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.49450563e-003, 0., 5.49450563e-003, 0.,
-       1.09890113e-002, 0., 0., 0., 0., 5.49450563e-003, 5.49450563e-003,
-       0., 5.49450563e-003, 1.09890113e-002, 0., 0., 0., 1.09890113e-002,
-       5.49450563e-003, 5.49450563e-003, 0., 0., 5.49450563e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.09890113e-002, 0., 0., 5.49450563e-003,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 1.09890113e-002, 0.,
-       0., 1.09890113e-002, 0., 5.49450563e-003, 0., 0., 1.09890113e-002,
-       0., 0., 0., 0., 0., 0., 0., 1.09890113e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.49450563e-003, 5.49450563e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.49450563e-003, 0., 5.49450563e-003, 0., 0.,
-       5.49450563e-003, 0., 0., 5.49450563e-003, 0., 0., 1.09890113e-002,
-       0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.49450563e-003, 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.09890113e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 5.49450563e-003, 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 5.49450563e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.49450563e-003, 0., 0., 1.09890113e-002, 0., 0.,
-       0., 1.09890113e-002, 0., 0., 0., 1.09890113e-002, 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 5.49450563e-003, 5.49450563e-003, 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 5.49450563e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.09890113e-002, 0., 5.49450563e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       0., 5.49450563e-003, 5.49450563e-003, 5.49450563e-003, 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 1.09890113e-002, 0.,
-       1.64835174e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.09890113e-002, 5.49450563e-003, 0., 5.49450563e-003, 0., 0.,
-       5.49450563e-003, 0., 0., 1.09890113e-002, 0., 0., 0., 0., 0., 0.,
-       0., 5.49450563e-003, 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0.,
-       0., 1.09890113e-002, 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       0., 0., 5.49450563e-003, 0., 0., 5.49450563e-003, 5.49450563e-003,
-       0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 5.49450563e-003,
-       0., 0., 5.49450563e-003, 0., 0., 0., 5.49450563e-003, 0.,
-       5.49450563e-003, 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.64835174e-002, 0., 5.49450563e-003, 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 5.49450563e-003, 5.49450563e-003, 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 5.49450563e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.49450563e-003, 0., 0., 0., 0., 1.11111114e-002,
-       5.55555569e-003, 1.11111114e-002, 1.66666675e-002,
-       1.11111114e-002, 1.11111114e-002, 0., 5.55555569e-003,
-       5.55555569e-003, 0., 5.55555569e-003, 0., 0., 5.55555569e-003, 0.,
-       0., 5.55555569e-003, 5.55555569e-003, 5.55555569e-003,
-       5.55555569e-003, 0., 5.55555569e-003, 0., 0., 1.11111114e-002,
-       5.55555569e-003, 1.66666675e-002, 5.55555569e-003,
-       5.55555569e-003, 2.77777780e-002, 0., 0., 0., 5.55555569e-003,
-       5.55555569e-003, 5.55555569e-003, 0., 0., 1.66666675e-002, 0., 0.,
-       0., 5.55555569e-003, 5.55555569e-003, 0., 5.55555569e-003, 0.,
-       1.11111114e-002, 2.22222228e-002, 1.11111114e-002, 0.,
-       1.11111114e-002, 0., 0., 0., 1.11111114e-002, 0., 5.55555569e-003,
-       0., 0., 0., 0., 0., 2.22222228e-002, 0., 0., 0., 0.,
-       5.55555569e-003, 0., 1.11111114e-002, 0., 0., 0., 5.55555569e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.66666675e-002, 0., 0.,
-       5.55555569e-003, 5.55555569e-003, 0., 5.55555569e-003, 0.,
-       1.11111114e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.55555569e-003, 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003,
-       2.77777780e-002, 5.55555569e-003, 0., 0., 1.11111114e-002, 0., 0.,
-       5.55555569e-003, 0., 0., 0., 0., 1.66666675e-002, 0., 0., 0., 0.,
-       0., 0., 0., 1.11111114e-002, 0., 0., 5.55555569e-003, 0.,
-       5.55555569e-003, 0., 0., 5.55555569e-003, 5.55555569e-003, 0., 0.,
-       0., 1.11111114e-002, 1.11111114e-002, 0., 0., 0., 1.11111114e-002,
-       1.11111114e-002, 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.55555569e-003, 5.55555569e-003, 0., 0., 1.11111114e-002,
-       0., 5.55555569e-003, 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003,
-       0., 5.55555569e-003, 0., 0., 1.11111114e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.55555569e-003, 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003, 0.,
-       0., 0., 0., 0., 0., 0., 5.55555569e-003, 0., 0., 0.,
-       5.55555569e-003, 0., 0., 0., 0., 5.55555569e-003, 0.,
-       5.55555569e-003, 2.22222228e-002, 0., 0., 5.55555569e-003,
-       5.55555569e-003, 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003, 0.,
-       1.11111114e-002, 0., 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0.,
-       0., 5.55555569e-003, 0., 0., 5.55555569e-003, 0., 0., 0., 0., 0.,
-       0., 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.55555569e-003, 0., 0., 0., 0., 0., 5.55555569e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.11111114e-002, 0., 2.22222228e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003,
-       5.55555569e-003, 0., 0., 0., 1.11111114e-002, 0., 0.,
-       5.55555569e-003, 0., 0., 1.11111114e-002, 0., 0., 5.55555569e-003,
-       0., 5.55555569e-003, 0., 0., 0., 5.55555569e-003, 0., 0.,
-       5.55555569e-003, 5.55555569e-003, 0., 5.55555569e-003, 0., 0.,
-       5.55555569e-003, 0., 0., 5.55555569e-003, 0., 0., 0., 0.,
-       5.55555569e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.55555569e-003, 0., 0., 0., 5.55555569e-003, 0., 0., 0., 0., 0.,
-       5.55555569e-003, 0., 0., 0., 0., 1.66666675e-002, 5.55555569e-003,
-       0., 0., 0., 0., 0., 5.55555569e-003, 0., 0., 0., 1.11111114e-002,
-       0., 0., 0., 5.55555569e-003, 0., 0., 5.55555569e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003, 0.,
-       0., 0., 5.55555569e-003, 0., 0., 0., 5.55555569e-003, 0., 0., 0.,
-       0., 0., 5.55555569e-003, 0., 5.55555569e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.55555569e-003, 0., 5.55555569e-003,
-       0., 0., 0., 0., 0., 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.58659201e-003, 1.67597756e-002,
-       5.58659201e-003, 0., 0., 0., 0., 0., 1.67597756e-002,
-       5.58659201e-003, 0., 0., 1.67597756e-002, 1.67597756e-002,
-       5.58659201e-003, 0., 0., 5.58659201e-003, 1.11731840e-002,
-       5.58659201e-003, 5.58659201e-003, 1.11731840e-002, 0.,
-       1.11731840e-002, 1.11731840e-002, 0., 0., 5.58659201e-003, 0.,
-       1.67597756e-002, 0., 0., 0., 0., 5.58659201e-003, 5.58659201e-003,
-       0., 5.58659201e-003, 0., 2.23463681e-002, 5.58659201e-003, 0., 0.,
-       1.11731840e-002, 5.58659201e-003, 1.11731840e-002, 0.,
-       2.23463681e-002, 3.35195512e-002, 1.67597756e-002, 0., 0., 0., 0.,
-       1.67597756e-002, 5.58659201e-003, 0., 0., 5.58659201e-003,
-       5.58659201e-003, 5.58659201e-003, 0., 0., 0., 5.58659201e-003, 0.,
-       0., 5.58659201e-003, 5.58659201e-003, 0., 5.58659201e-003,
-       5.58659201e-003, 5.58659201e-003, 0., 1.11731840e-002, 0., 0.,
-       5.58659201e-003, 0., 0., 0., 0., 5.58659201e-003, 5.58659201e-003,
-       5.58659201e-003, 0., 0., 0., 0., 5.58659201e-003, 0., 0., 0., 0.,
-       5.58659201e-003, 2.23463681e-002, 0., 0., 5.58659201e-003,
-       1.11731840e-002, 2.23463681e-002, 0., 5.58659201e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.58659201e-003, 5.58659201e-003,
-       0., 0., 0., 0., 0., 5.58659201e-003, 0., 0., 0., 0.,
-       1.67597756e-002, 0., 5.58659201e-003, 5.58659201e-003,
-       1.67597756e-002, 0., 0., 5.58659201e-003, 0., 0., 0., 0., 0., 0.,
-       0., 1.11731840e-002, 5.58659201e-003, 0., 0., 0., 0.,
-       5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.58659201e-003, 1.67597756e-002, 0., 0., 5.58659201e-003, 0.,
-       2.79329605e-002, 0., 0., 0., 0., 0., 0., 5.58659201e-003, 0., 0.,
-       0., 5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.58659201e-003, 0., 0., 5.58659201e-003,
-       0., 0., 5.58659201e-003, 5.58659201e-003, 0., 0., 5.58659201e-003,
-       0., 5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.58659201e-003, 0., 0., 0., 5.58659201e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.11731840e-002, 0., 5.58659201e-003,
-       5.58659201e-003, 0., 5.58659201e-003, 0., 0., 0., 5.58659201e-003,
-       0., 0., 5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.58659201e-003, 0., 0., 0., 0., 0., 5.58659201e-003,
-       5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 5.58659201e-003,
-       5.58659201e-003, 0., 5.58659201e-003, 0., 0., 5.58659201e-003,
-       1.11731840e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.58659201e-003, 0., 0., 1.67597756e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.58659201e-003, 5.58659201e-003, 0.,
-       5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.11731840e-002, 0., 1.11731840e-002, 0., 0., 0., 0., 0., 0.,
-       5.58659201e-003, 0., 0., 0., 5.58659201e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.67597756e-002, 0., 0., 5.58659201e-003, 0., 0., 0.,
-       0., 5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.58659201e-003, 0., 0., 0., 0., 5.58659201e-003, 0., 0.,
-       5.58659201e-003, 0., 0., 0., 5.58659201e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.58659201e-003, 1.11731840e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.58659201e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.58659201e-003, 0., 0., 5.58659201e-003, 0., 0., 0.,
-       5.58659201e-003, 0., 0., 0., 5.58659201e-003, 0., 0., 0.,
-       5.58659201e-003, 0., 0., 5.58659201e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.58659201e-003, 0., 0., 0.,
-       0., 6.13496918e-003, 0., 6.13496918e-003, 1.22699384e-002,
-       6.13496918e-003, 6.13496918e-003, 0., 0., 6.13496918e-003,
-       6.13496918e-003, 1.22699384e-002, 0., 1.84049085e-002,
-       1.22699384e-002, 6.13496918e-003, 0., 0., 1.22699384e-002, 0.,
-       6.13496918e-003, 1.22699384e-002, 0., 1.22699384e-002,
-       6.13496918e-003, 6.13496918e-003, 6.13496918e-003, 0., 0.,
-       6.13496918e-003, 6.13496918e-003, 6.13496918e-003,
-       1.22699384e-002, 0., 1.22699384e-002, 6.13496918e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0.,
-       2.45398767e-002, 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0.,
-       0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0.,
-       6.13496918e-003, 6.13496918e-003, 0., 6.13496918e-003,
-       6.13496918e-003, 0., 0., 6.13496918e-003, 2.45398767e-002,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0.,
-       0., 0., 0., 0., 0., 0., 1.22699384e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.13496918e-003, 0., 6.13496918e-003, 6.13496918e-003,
-       6.13496918e-003, 1.84049085e-002, 0., 1.22699384e-002, 0., 0.,
-       6.13496918e-003, 0., 0., 0., 6.13496918e-003, 0., 6.13496918e-003,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0.,
-       6.13496918e-003, 0., 0., 0., 6.13496918e-003, 0., 0.,
-       1.22699384e-002, 6.13496918e-003, 0., 0., 0., 1.22699384e-002,
-       1.84049085e-002, 1.22699384e-002, 6.13496918e-003, 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0.,
-       1.22699384e-002, 0., 0., 0., 0., 6.13496918e-003, 0.,
-       6.13496918e-003, 6.13496918e-003, 0., 6.13496918e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 1.22699384e-002, 0., 0., 0.,
-       1.22699384e-002, 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 6.13496918e-003,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.22699384e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.22699384e-002, 0., 0., 0., 0., 6.13496918e-003,
-       0., 0., 0., 1.22699384e-002, 6.13496918e-003, 6.13496918e-003, 0.,
-       0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 6.13496918e-003, 0.,
-       0., 0., 6.13496918e-003, 6.13496918e-003, 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0.,
-       0., 1.22699384e-002, 0., 6.13496918e-003, 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0.,
-       0., 0., 0., 6.13496918e-003, 0., 0., 6.13496918e-003, 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0.,
-       6.13496918e-003, 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 1.22699384e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.22699384e-002, 0., 0., 0.,
-       1.22699384e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003,
-       0., 0., 1.84049085e-002, 0., 6.13496918e-003, 0., 0.,
-       6.13496918e-003, 0., 0., 6.13496918e-003, 6.13496918e-003, 0.,
-       6.13496918e-003, 0., 0., 6.13496918e-003, 1.22699384e-002, 0., 0.,
-       0., 0., 0., 0., 6.13496918e-003, 0., 6.13496918e-003, 0., 0., 0.,
-       0., 0., 6.13496918e-003, 0., 6.13496918e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0.,
-       0., 0., 1.22699384e-002, 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 6.13496918e-003, 0., 6.13496918e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0.,
-       0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 1.19760484e-002,
-       1.79640725e-002, 0., 0., 0., 2.39520967e-002, 0., 0.,
-       1.19760484e-002, 1.19760484e-002, 5.98802418e-003,
-       5.98802418e-003, 0., 5.98802418e-003, 0., 0., 0., 1.19760484e-002,
-       0., 0., 0., 0., 5.98802418e-003, 0., 5.98802418e-003, 0.,
-       5.98802418e-003, 5.98802418e-003, 5.98802418e-003,
-       5.98802418e-003, 5.98802418e-003, 5.98802418e-003, 0.,
-       1.79640725e-002, 1.19760484e-002, 0., 0., 1.19760484e-002,
-       1.19760484e-002, 5.98802418e-003, 0., 0., 0., 0., 5.98802418e-003,
-       5.98802418e-003, 0., 1.19760484e-002, 5.98802418e-003,
-       5.98802418e-003, 0., 0., 0., 0., 0., 1.19760484e-002, 0., 0., 0.,
-       0., 0., 0., 5.98802418e-003, 1.19760484e-002, 1.19760484e-002, 0.,
-       0., 0., 5.98802418e-003, 0., 0., 0., 0., 0., 0., 1.79640725e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.19760484e-002, 0., 0., 1.19760484e-002, 0., 0., 5.98802418e-003,
-       0., 0., 5.98802418e-003, 0., 1.19760484e-002, 0., 0.,
-       1.19760484e-002, 0., 0., 5.98802418e-003, 5.98802418e-003,
-       5.98802418e-003, 0., 1.19760484e-002, 0., 0., 0., 0., 0.,
-       5.98802418e-003, 0., 0., 5.98802418e-003, 1.19760484e-002, 0., 0.,
-       0., 5.98802418e-003, 4.79041934e-002, 0., 5.98802418e-003,
-       5.98802418e-003, 2.39520967e-002, 0., 0., 0., 0., 0., 0., 0.,
-       1.19760484e-002, 0., 0., 1.19760484e-002, 0., 0., 0., 0., 0.,
-       1.19760484e-002, 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0., 0.,
-       0., 5.98802418e-003, 5.98802418e-003, 0., 0., 0., 0.,
-       5.98802418e-003, 1.79640725e-002, 0., 5.98802418e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.19760484e-002, 0., 0., 5.98802418e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.98802418e-003, 5.98802418e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.98802418e-003, 0.,
-       0., 1.19760484e-002, 0., 0., 0., 5.98802418e-003, 0., 0., 0., 0.,
-       5.98802418e-003, 0., 0., 0., 5.98802418e-003, 5.98802418e-003,
-       5.98802418e-003, 0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0.,
-       0., 0., 0., 5.98802418e-003, 5.98802418e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.98802418e-003, 5.98802418e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.98802418e-003, 0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0.,
-       0., 5.98802418e-003, 0., 0., 0., 5.98802418e-003, 0.,
-       5.98802418e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.98802418e-003, 0.,
-       0., 5.98802418e-003, 0., 0., 0., 0., 0., 5.98802418e-003, 0., 0.,
-       0., 5.98802418e-003, 0., 0., 0., 5.98802418e-003, 5.98802418e-003,
-       0., 0., 0., 5.98802418e-003, 5.98802418e-003, 0., 5.98802418e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.19760484e-002, 0., 0., 0.,
-       5.98802418e-003, 0., 5.98802418e-003, 5.98802418e-003, 0.,
-       5.98802418e-003, 5.98802418e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.98802418e-003, 0., 0., 0., 0., 0., 0., 0., 5.98802418e-003, 0.,
-       0., 0., 0., 0., 0., 5.98802418e-003, 0., 5.98802418e-003, 0., 0.,
-       1.79640725e-002, 0., 1.19760484e-002, 0., 0., 0., 0., 0., 0.,
-       1.19760484e-002, 0., 0., 0., 0., 0., 0., 0., 0., 5.98802418e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.19760484e-002,
-       0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.98802418e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.98802418e-003, 0., 0., 5.98802418e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.79640725e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.98802418e-003, 0., 0., 0.,
-       5.98802418e-003, 0., 5.98802418e-003, 0., 0., 0., 3.44827585e-002,
-       8.62068962e-003, 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0.,
-       8.62068962e-003, 8.62068962e-003, 1.72413792e-002,
-       1.72413792e-002, 0., 8.62068962e-003, 0., 2.58620679e-002, 0., 0.,
-       0., 8.62068962e-003, 1.72413792e-002, 0., 0., 8.62068962e-003, 0.,
-       8.62068962e-003, 1.72413792e-002, 1.72413792e-002, 0., 0., 0.,
-       1.72413792e-002, 0., 0., 0., 8.62068962e-003, 8.62068962e-003, 0.,
-       0., 0., 0., 0., 0., 0., 2.58620679e-002, 1.72413792e-002, 0., 0.,
-       0., 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0., 8.62068962e-003,
-       0., 8.62068962e-003, 0., 8.62068962e-003, 0., 0., 0.,
-       1.72413792e-002, 0., 8.62068962e-003, 0., 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0.,
-       0., 0., 0., 0., 0., 3.44827585e-002, 0., 0., 0., 0.,
-       1.72413792e-002, 0., 0., 0., 0., 0., 0., 8.62068962e-003,
-       8.62068962e-003, 0., 0., 0., 0., 0., 1.72413792e-002, 0.,
-       8.62068962e-003, 8.62068962e-003, 0., 0., 0., 0., 8.62068962e-003,
-       0., 0., 0., 5.17241359e-002, 0., 0., 8.62068962e-003, 0., 0., 0.,
-       0., 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0.,
-       0., 0., 2.58620679e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 1.72413792e-002, 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 1.72413792e-002, 0., 0., 0., 8.62068962e-003, 0.,
-       8.62068962e-003, 0., 0., 8.62068962e-003, 8.62068962e-003,
-       8.62068962e-003, 0., 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003,
-       0., 0., 8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 8.62068962e-003,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0.,
-       8.62068962e-003, 0., 8.62068962e-003, 0., 0., 0., 8.62068962e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.72413792e-002, 0., 8.62068962e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 8.62068962e-003, 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 8.62068962e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.72413792e-002, 0., 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003,
-       0., 0., 8.62068962e-003, 0., 0., 0., 0., 8.62068962e-003,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 3.36134471e-002, 8.40336177e-003, 0., 0., 8.40336177e-003, 0.,
-       0., 8.40336177e-003, 0., 0., 8.40336177e-003, 0., 8.40336177e-003,
-       0., 0., 0., 8.40336177e-003, 0., 8.40336177e-003, 0., 0.,
-       8.40336177e-003, 8.40336177e-003, 8.40336177e-003, 0., 0.,
-       1.68067235e-002, 0., 8.40336177e-003, 8.40336177e-003,
-       1.68067235e-002, 8.40336177e-003, 0., 8.40336177e-003,
-       8.40336177e-003, 8.40336177e-003, 8.40336177e-003, 0.,
-       8.40336177e-003, 2.52100863e-002, 0., 8.40336177e-003, 0., 0., 0.,
-       8.40336177e-003, 0., 0., 1.68067235e-002, 0., 0., 8.40336177e-003,
-       0., 0., 8.40336177e-003, 2.52100863e-002, 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 1.68067235e-002, 0., 8.40336177e-003, 0., 0., 0.,
-       0., 0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 1.68067235e-002,
-       0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.40336177e-003, 0., 0., 0., 8.40336177e-003,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 2.52100863e-002, 0., 1.68067235e-002,
-       8.40336177e-003, 0., 0., 0., 0., 8.40336177e-003, 0., 0., 0.,
-       2.52100863e-002, 1.68067235e-002, 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 8.40336177e-003, 0., 0., 0., 0.,
-       0., 0., 8.40336177e-003, 0., 8.40336177e-003, 0., 8.40336177e-003,
-       0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.68067235e-002, 0.,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.68067235e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.40336177e-003, 0.,
-       0., 0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.40336177e-003, 0., 0., 0.,
-       8.40336177e-003, 8.40336177e-003, 0., 0., 8.40336177e-003, 0., 0.,
-       0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.40336177e-003, 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 8.40336177e-003, 0., 8.40336177e-003, 0., 0.,
-       0., 0., 8.40336177e-003, 0., 8.40336177e-003, 0., 0., 0., 0., 0.,
-       0., 8.40336177e-003, 0., 0., 0., 0., 0., 8.40336177e-003, 0., 0.,
-       0., 0., 0., 8.40336177e-003, 0., 0., 2.52100863e-002, 0., 0., 0.,
-       0., 0., 8.40336177e-003, 0., 8.40336177e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.40336177e-003, 0.,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 8.40336177e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.40336177e-003, 0., 0., 0., 0.,
-       8.40336177e-003, 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 8.40336177e-003, 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 1.68067235e-002, 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.40336177e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.40336177e-003, 0., 0., 0., 0., 0., 0., 8.40336177e-003, 0.,
-       7.93650839e-003, 0., 7.93650839e-003, 0., 0., 1.58730168e-002, 0.,
-       2.38095261e-002, 1.58730168e-002, 0., 7.93650839e-003,
-       7.93650839e-003, 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0.,
-       0., 1.58730168e-002, 7.93650839e-003, 0., 0., 3.17460336e-002, 0.,
-       0., 1.58730168e-002, 7.93650839e-003, 7.93650839e-003, 0., 0.,
-       7.93650839e-003, 0., 0., 0., 7.93650839e-003, 1.58730168e-002, 0.,
-       0., 0., 0., 0., 1.58730168e-002, 7.93650839e-003, 0.,
-       3.96825410e-002, 7.93650839e-003, 0., 7.93650839e-003, 0., 0., 0.,
-       7.93650839e-003, 0., 0., 0., 7.93650839e-003, 0., 0.,
-       7.93650839e-003, 0., 7.93650839e-003, 0., 0., 0., 7.93650839e-003,
-       0., 0., 0., 7.93650839e-003, 0., 7.93650839e-003, 7.93650839e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.58730168e-002, 7.93650839e-003,
-       7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 1.58730168e-002, 0.,
-       0., 0., 0., 0., 0., 0., 1.58730168e-002, 0., 0., 1.58730168e-002,
-       0., 0., 0., 0., 0., 3.17460336e-002, 0., 0., 7.93650839e-003,
-       2.38095261e-002, 0., 0., 0., 0., 3.17460336e-002, 0., 0.,
-       7.93650839e-003, 0., 0., 0., 0., 7.93650839e-003, 7.93650839e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0., 0.,
-       0., 1.58730168e-002, 7.93650839e-003, 0., 0., 0., 7.93650839e-003,
-       7.93650839e-003, 0., 3.17460336e-002, 0., 0., 7.93650839e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.93650839e-003, 0., 0., 0., 0., 0., 1.58730168e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.93650839e-003, 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       3.96825410e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.93650839e-003,
-       0., 0., 0., 0., 0., 0., 0., 7.93650839e-003, 7.93650839e-003, 0.,
-       1.58730168e-002, 0., 7.93650839e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0., 0., 0.,
-       1.58730168e-002, 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.93650839e-003,
-       0., 7.93650839e-003, 0., 0., 7.93650839e-003, 0., 0., 0., 0., 0.,
-       0., 0., 7.93650839e-003, 0., 0., 0., 0., 7.93650839e-003, 0., 0.,
-       0., 7.93650839e-003, 0., 0., 0., 0., 7.93650839e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0., 0.,
-       0., 7.93650839e-003, 0., 0., 7.93650839e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.93650839e-003, 0., 0., 0., 0., 0., 7.93650839e-003, 0.,
-       0., 0., 7.93650839e-003, 0., 0., 1.58730168e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0., 0., 0., 0.,
-       7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 7.93650839e-003, 0.,
-       0., 7.93650839e-003, 0., 0., 0., 0., 0., 0., 0., 2.09424086e-002,
-       1.04712043e-002, 0., 0., 0., 5.23560215e-003, 0., 0.,
-       5.23560215e-003, 1.57068074e-002, 5.23560215e-003, 0.,
-       1.57068074e-002, 1.04712043e-002, 0., 0., 5.23560215e-003,
-       5.23560215e-003, 1.04712043e-002, 0., 0., 5.23560215e-003,
-       5.23560215e-003, 0., 5.23560215e-003, 5.23560215e-003,
-       5.23560215e-003, 1.04712043e-002, 5.23560215e-003,
-       5.23560215e-003, 0., 1.04712043e-002, 0., 0., 5.23560215e-003, 0.,
-       0., 5.23560215e-003, 5.23560215e-003, 1.04712043e-002, 0., 0., 0.,
-       0., 0., 2.09424086e-002, 5.23560215e-003, 1.04712043e-002,
-       2.09424086e-002, 1.57068074e-002, 0., 1.04712043e-002, 0., 0.,
-       5.23560215e-003, 5.23560215e-003, 0., 5.23560215e-003,
-       1.57068074e-002, 1.04712043e-002, 5.23560215e-003, 0.,
-       5.23560215e-003, 5.23560215e-003, 5.23560215e-003, 0., 0., 0.,
-       5.23560215e-003, 5.23560215e-003, 5.23560215e-003, 0.,
-       2.09424086e-002, 0., 0., 0., 0., 5.23560215e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.23560215e-003, 0., 0., 0., 0., 0.,
-       5.23560215e-003, 1.04712043e-002, 1.04712043e-002,
-       5.23560215e-003, 0., 0., 0., 0., 5.23560215e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.23560215e-003, 0., 0., 1.04712043e-002,
-       0., 0., 5.23560215e-003, 0., 5.23560215e-003, 1.04712043e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.57068074e-002, 1.04712043e-002,
-       0., 0., 0., 0., 5.23560215e-003, 0., 2.09424086e-002, 0., 0.,
-       1.04712043e-002, 0., 0., 5.23560215e-003, 0., 5.23560215e-003,
-       5.23560215e-003, 0., 0., 0., 0., 0., 0., 5.23560215e-003, 0., 0.,
-       5.23560215e-003, 0., 0., 0., 0., 0., 5.23560215e-003,
-       5.23560215e-003, 1.04712043e-002, 5.23560215e-003,
-       5.23560215e-003, 0., 1.04712043e-002, 0., 0., 0., 0., 0., 0.,
-       5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.23560215e-003, 0., 1.04712043e-002, 0., 5.23560215e-003,
-       1.57068074e-002, 0., 5.23560215e-003, 0., 0., 0., 5.23560215e-003,
-       0., 0., 5.23560215e-003, 0., 0., 5.23560215e-003, 0., 0.,
-       1.04712043e-002, 0., 5.23560215e-003, 5.23560215e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.23560215e-003, 0., 1.04712043e-002,
-       5.23560215e-003, 5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.04712043e-002, 0., 0., 0.,
-       5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.23560215e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.23560215e-003, 0., 0., 5.23560215e-003, 5.23560215e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.04712043e-002, 0., 0., 0., 0., 1.04712043e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.23560215e-003, 0., 0., 0., 0.,
-       5.23560215e-003, 0., 0., 0., 0., 0., 0., 5.23560215e-003, 0., 0.,
-       0., 0., 0., 0., 1.04712043e-002, 0., 0., 0., 0., 0.,
-       2.09424086e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.23560215e-003, 0., 0., 0., 0., 0., 5.23560215e-003,
-       5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.23560215e-003, 5.23560215e-003, 0., 5.23560215e-003, 0., 0., 0.,
-       0., 0., 5.23560215e-003, 5.23560215e-003, 2.09424086e-002,
-       5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.23560215e-003,
-       0., 0., 0., 0., 0., 0., 1.04712043e-002, 0., 0., 1.04712043e-002,
-       0., 0., 0., 0., 1.04712043e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.23560215e-003, 0., 0., 5.23560215e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.23560215e-003, 0.,
-       5.23560215e-003, 0., 0., 0., 0., 0., 5.23560215e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.23560215e-003, 5.23560215e-003,
-       5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.23560215e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.04712043e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.23560215e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.23560215e-003, 0., 0., 5.23560215e-003, 0., 0., 0., 0., 0.,
-       0., 0., 6.02409616e-003, 0., 0., 6.02409616e-003, 6.02409616e-003,
-       0., 0., 1.80722885e-002, 1.20481923e-002, 0., 0., 6.02409616e-003,
-       6.02409616e-003, 6.02409616e-003, 0., 6.02409616e-003,
-       6.02409616e-003, 6.02409616e-003, 6.02409616e-003, 0., 0.,
-       6.02409616e-003, 1.80722885e-002, 0., 6.02409616e-003, 0.,
-       6.02409616e-003, 1.20481923e-002, 0., 3.01204808e-002, 0., 0., 0.,
-       6.02409616e-003, 0., 0., 6.02409616e-003, 0., 0., 0.,
-       1.20481923e-002, 6.02409616e-003, 0., 0., 0., 0., 6.02409616e-003,
-       0., 6.02409616e-003, 1.80722885e-002, 0., 0., 0., 6.02409616e-003,
-       6.02409616e-003, 1.20481923e-002, 0., 6.02409616e-003,
-       6.02409616e-003, 0., 0., 0., 6.02409616e-003, 0., 6.02409616e-003,
-       0., 0., 0., 6.02409616e-003, 6.02409616e-003, 1.20481923e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.02409616e-003, 0., 0., 0., 0.,
-       6.02409616e-003, 0., 0., 0., 0., 6.02409616e-003, 0.,
-       6.02409616e-003, 0., 0., 6.02409616e-003, 0., 6.02409616e-003, 0.,
-       6.02409616e-003, 6.02409616e-003, 0., 1.20481923e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.80722885e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.02409616e-003, 0., 0., 0., 0., 1.20481923e-002, 0.,
-       0., 0., 2.40963846e-002, 1.80722885e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.20481923e-002, 1.20481923e-002, 6.02409616e-003,
-       6.02409616e-003, 1.20481923e-002, 6.02409616e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.80722885e-002, 6.02409616e-003,
-       0., 0., 0., 0., 6.02409616e-003, 0., 3.01204808e-002, 0.,
-       1.20481923e-002, 0., 0., 0., 0., 0., 0., 6.02409616e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.20481923e-002, 0., 0.,
-       0., 0., 1.80722885e-002, 0., 0., 0., 0., 0., 1.20481923e-002,
-       6.02409616e-003, 0., 0., 0., 0., 0., 6.02409616e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.02409616e-003, 0., 0.,
-       6.02409616e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       3.01204808e-002, 6.02409616e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.02409616e-003, 0., 0., 0., 0.,
-       6.02409616e-003, 6.02409616e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.02409616e-003, 0., 0., 1.20481923e-002, 0., 0., 0., 0., 0., 0.,
-       0., 6.02409616e-003, 0., 0., 0., 0., 0., 0., 0., 6.02409616e-003,
-       0., 0., 0., 6.02409616e-003, 0., 0., 0., 0., 1.20481923e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.02409616e-003, 1.20481923e-002, 1.20481923e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.02409616e-003, 0., 0.,
-       6.02409616e-003, 0., 0., 1.20481923e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.02409616e-003, 0., 0.,
-       6.02409616e-003, 0., 0., 0., 0., 6.02409616e-003, 6.02409616e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.02409616e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.80722885e-002, 0., 0., 0., 0.,
-       6.02409616e-003, 6.02409616e-003, 0., 0., 0., 0., 0.,
-       6.02409616e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.02409616e-003, 0., 0., 0., 0., 6.02409616e-003, 0., 0.,
-       6.02409616e-003, 1.20481923e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.02409616e-003, 6.02409616e-003, 0., 6.02409616e-003,
-       6.02409616e-003, 0., 0., 0., 6.02409616e-003, 0., 0., 0.,
-       6.02409616e-003, 0., 0., 6.02409616e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.02409616e-003, 0., 0., 0., 0., 0., 0.,
-       6.02409616e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.02409616e-003, 0., 0., 0.,
-       6.02409616e-003, 6.02409616e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.02409616e-003, 0., 6.02409616e-003, 0., 0., 0., 0., 0., 0.,
-       6.02409616e-003, 0., 0., 0., 0., 0., 0., 0., 0., 6.02409616e-003,
-       0., 0., 0., 0., 6.02409616e-003, 0., 0., 0., 6.02409616e-003,
-       2.27272734e-002, 0., 2.27272734e-002, 7.57575780e-003, 0.,
-       1.51515156e-002, 0., 0., 1.51515156e-002, 7.57575780e-003, 0., 0.,
-       2.27272734e-002, 7.57575780e-003, 0., 0., 7.57575780e-003,
-       1.51515156e-002, 7.57575780e-003, 0., 0., 7.57575780e-003, 0.,
-       7.57575780e-003, 0., 7.57575780e-003, 7.57575780e-003,
-       7.57575780e-003, 0., 7.57575780e-003, 0., 0., 0., 0., 0.,
-       7.57575780e-003, 0., 0., 0., 7.57575780e-003, 0., 0., 0.,
-       1.51515156e-002, 0., 0., 0., 7.57575780e-003, 1.51515156e-002, 0.,
-       0., 7.57575780e-003, 0., 0., 0., 1.51515156e-002, 0.,
-       7.57575780e-003, 0., 0., 0., 0., 2.27272734e-002, 0., 0.,
-       7.57575780e-003, 0., 0., 0., 7.57575780e-003, 0., 0., 0., 0.,
-       7.57575780e-003, 7.57575780e-003, 0., 0., 0., 7.57575780e-003, 0.,
-       0., 7.57575780e-003, 7.57575780e-003, 0., 0., 0., 0., 0.,
-       7.57575780e-003, 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.57575780e-003, 7.57575780e-003, 0., 0., 0., 0., 0., 0.,
-       7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.57575780e-003, 0., 1.51515156e-002, 2.27272734e-002, 0., 0.,
-       7.57575780e-003, 0., 7.57575780e-003, 7.57575780e-003, 0.,
-       2.27272734e-002, 3.78787890e-002, 0., 0., 7.57575780e-003, 0.,
-       7.57575780e-003, 7.57575780e-003, 7.57575780e-003, 0., 0.,
-       7.57575780e-003, 7.57575780e-003, 7.57575780e-003, 0.,
-       7.57575780e-003, 7.57575780e-003, 0., 0., 0., 7.57575780e-003,
-       7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.57575780e-003, 0., 0., 0., 2.27272734e-002, 0., 1.51515156e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.57575780e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 2.27272734e-002, 0., 0., 0.,
-       7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.57575780e-003, 0., 0., 0., 0.,
-       1.51515156e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.27272734e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.57575780e-003, 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 7.57575780e-003,
-       0., 0., 2.27272734e-002, 0., 7.57575780e-003, 0., 0., 0.,
-       7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.57575780e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.57575780e-003, 0., 0., 7.57575780e-003, 0.,
-       0., 0., 0., 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0.,
-       7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.51515156e-002, 0., 0., 0., 0., 1.51515156e-002, 0., 0., 0., 0.,
-       0., 0., 2.27272734e-002, 7.57575780e-003, 0., 0., 0., 0., 0., 0.,
-       0., 7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.57575780e-003, 0., 7.57575780e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.51515156e-002, 0., 0., 0., 0., 0., 0., 0., 0., 7.57575780e-003,
-       7.57575780e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 7.57575780e-003, 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 9.43396240e-003, 0., 9.43396240e-003, 0.,
-       9.43396240e-003, 1.88679248e-002, 0., 0., 9.43396240e-003,
-       9.43396240e-003, 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0.,
-       1.88679248e-002, 0., 9.43396240e-003, 9.43396240e-003,
-       1.88679248e-002, 0., 9.43396240e-003, 0., 1.88679248e-002,
-       9.43396240e-003, 0., 0., 9.43396240e-003, 0., 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 9.43396240e-003, 0., 1.88679248e-002,
-       9.43396240e-003, 1.88679248e-002, 1.88679248e-002, 0., 0., 0., 0.,
-       0., 9.43396240e-003, 1.88679248e-002, 0., 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 9.43396240e-003, 0., 0., 9.43396240e-003, 0., 0.,
-       0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.88679248e-002,
-       1.88679248e-002, 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.88679248e-002, 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       2.83018872e-002, 0., 0., 0., 3.77358496e-002, 0., 0., 0., 0.,
-       1.88679248e-002, 0., 0., 9.43396240e-003, 0., 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0.,
-       0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 9.43396240e-003, 0., 9.43396240e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 9.43396240e-003, 0.,
-       0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 9.43396240e-003,
-       0., 1.88679248e-002, 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 9.43396240e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0.,
-       0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0.,
-       0., 9.43396240e-003, 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003,
-       0., 0., 0., 0., 0., 9.43396240e-003, 9.43396240e-003, 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0.,
-       9.43396240e-003, 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       1.88679248e-002, 0., 0., 0., 1.88679248e-002, 0., 0., 0., 0., 0.,
-       0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 9.43396240e-003,
-       9.43396240e-003, 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       1.72413792e-002, 8.62068962e-003, 0., 0., 8.62068962e-003, 0., 0.,
-       0., 8.62068962e-003, 0., 0., 0., 0., 0., 1.72413792e-002,
-       8.62068962e-003, 0., 0., 1.72413792e-002, 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 8.62068962e-003, 8.62068962e-003,
-       8.62068962e-003, 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0.,
-       8.62068962e-003, 0., 8.62068962e-003, 0., 1.72413792e-002,
-       8.62068962e-003, 0., 0., 0., 2.58620679e-002, 4.31034490e-002, 0.,
-       0., 0., 0., 0., 8.62068962e-003, 8.62068962e-003, 0., 0., 0., 0.,
-       0., 0., 0., 2.58620679e-002, 1.72413792e-002, 0., 0., 0.,
-       8.62068962e-003, 8.62068962e-003, 0., 0., 8.62068962e-003, 0., 0.,
-       1.72413792e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 1.72413792e-002, 8.62068962e-003, 0., 0., 0., 0.,
-       0., 0., 8.62068962e-003, 0., 0., 1.72413792e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0.,
-       4.31034490e-002, 0., 0., 1.72413792e-002, 2.58620679e-002,
-       8.62068962e-003, 0., 0., 0., 2.58620679e-002, 8.62068962e-003, 0.,
-       8.62068962e-003, 0., 0., 0., 0., 1.72413792e-002, 8.62068962e-003,
-       0., 8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.72413792e-002, 8.62068962e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0.,
-       1.72413792e-002, 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 2.58620679e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 8.62068962e-003, 8.62068962e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.72413792e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 8.62068962e-003, 0., 0., 0., 0., 0.,
-       8.62068962e-003, 8.62068962e-003, 0., 8.62068962e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 1.72413792e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.62068962e-003, 0., 0., 0., 0., 8.62068962e-003, 0., 0.,
-       0., 0., 0., 0., 0., 8.62068962e-003, 0., 8.62068962e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003,
-       8.62068962e-003, 8.62068962e-003, 0., 0., 0., 0., 8.62068962e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003,
-       0., 0., 0., 8.06451589e-003, 8.06451589e-003, 8.06451589e-003, 0.,
-       0., 0., 0., 0., 0., 1.61290318e-002, 0., 8.06451589e-003, 0., 0.,
-       1.61290318e-002, 0., 0., 0., 8.06451589e-003, 0., 0.,
-       8.06451589e-003, 0., 0., 0., 3.22580636e-002, 0., 1.61290318e-002,
-       0., 0., 8.06451589e-003, 8.06451589e-003, 0., 8.06451589e-003, 0.,
-       0., 0., 8.06451589e-003, 1.61290318e-002, 0., 0., 0., 0., 0.,
-       2.41935477e-002, 0., 0., 1.61290318e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.06451589e-003, 0., 8.06451589e-003, 0., 0., 0.,
-       1.61290318e-002, 8.06451589e-003, 1.61290318e-002, 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 8.06451589e-003,
-       8.06451589e-003, 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0., 0.,
-       0., 0., 8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.06451589e-003, 0., 0., 0., 0., 8.06451589e-003,
-       0., 0., 8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.64516112e-002, 0., 8.06451589e-003, 0., 8.06451589e-003,
-       8.06451589e-003, 0., 0., 0., 3.22580636e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.06451589e-003, 8.06451589e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.06451589e-003, 0., 0., 0., 8.06451589e-003,
-       8.06451589e-003, 0., 0., 0., 8.06451589e-003, 2.41935477e-002, 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 2.41935477e-002, 0.,
-       0., 0., 0., 0., 0., 0., 1.61290318e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.06451589e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0.,
-       0., 0., 2.41935477e-002, 0., 0., 8.06451589e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0., 0., 0., 0.,
-       1.61290318e-002, 0., 0., 0., 0., 0., 0., 0., 8.06451589e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.61290318e-002, 0., 0.,
-       8.06451589e-003, 0., 0., 8.06451589e-003, 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 8.06451589e-003, 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.06451589e-003, 0., 8.06451589e-003, 0., 0.,
-       8.06451589e-003, 8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 8.06451589e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.61290318e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.06451589e-003, 8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.61290318e-002, 0., 0., 8.06451589e-003, 8.06451589e-003, 0., 0.,
-       0., 0., 0., 0., 0., 8.06451589e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.06451589e-003,
-       1.61290318e-002, 8.06451589e-003, 0., 8.06451589e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.06451589e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.06451589e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.06451589e-003, 0., 0., 8.06451589e-003, 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.06451589e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.06451589e-003, 8.06451589e-003, 0., 0., 0.,
-       8.06451589e-003, 0., 0., 0., 0., 8.06451589e-003, 8.06451589e-003,
-       0., 6.71140943e-003, 1.34228189e-002, 6.71140943e-003, 0., 0., 0.,
-       0., 0., 0., 6.71140943e-003, 2.68456377e-002, 0., 0., 0., 0., 0.,
-       0., 6.71140943e-003, 6.71140943e-003, 6.71140943e-003, 0.,
-       1.34228189e-002, 1.34228189e-002, 1.34228189e-002, 0., 0., 0., 0.,
-       1.34228189e-002, 2.01342292e-002, 0., 6.71140943e-003, 0.,
-       2.01342292e-002, 0., 0., 0., 2.01342292e-002, 6.71140943e-003,
-       6.71140943e-003, 6.71140943e-003, 0., 0., 6.71140943e-003, 0., 0.,
-       0., 6.71140943e-003, 6.71140943e-003, 0., 0., 0., 0., 0., 0.,
-       2.01342292e-002, 0., 0., 0., 6.71140943e-003, 0., 0.,
-       2.68456377e-002, 1.34228189e-002, 0., 0., 0., 0., 6.71140943e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.71140943e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.71140943e-003,
-       0., 0., 0., 6.71140943e-003, 6.71140943e-003, 6.71140943e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.34228189e-002, 0., 0.,
-       0., 6.71140943e-003, 0., 6.71140943e-003, 0., 6.71140943e-003,
-       6.71140943e-003, 0., 0., 0., 0., 1.34228189e-002, 0., 0., 0.,
-       1.34228189e-002, 2.01342292e-002, 0., 6.71140943e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.34228189e-002, 6.71140943e-003, 0.,
-       0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.34228189e-002, 0., 0., 0., 0., 1.34228189e-002, 1.34228189e-002,
-       0., 6.71140943e-003, 0., 1.34228189e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.71140943e-003, 0., 6.71140943e-003, 0., 0., 0., 0.,
-       6.71140943e-003, 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.71140943e-003, 6.71140943e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.34228189e-002, 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 2.01342292e-002, 0., 0., 0., 0., 0.,
-       6.71140943e-003, 6.71140943e-003, 0., 0., 6.71140943e-003,
-       6.71140943e-003, 0., 0., 6.71140943e-003, 6.71140943e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.34228189e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.71140943e-003, 0., 0., 0., 6.71140943e-003,
-       6.71140943e-003, 1.34228189e-002, 0., 0., 0., 6.71140943e-003,
-       6.71140943e-003, 0., 0., 0., 0., 1.34228189e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.71140943e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.71140943e-003, 0., 0.,
-       6.71140943e-003, 0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.34228189e-002, 1.34228189e-002, 0., 0.,
-       0., 0., 0., 1.34228189e-002, 0., 0., 6.71140943e-003, 0., 0., 0.,
-       0., 0., 6.71140943e-003, 1.34228189e-002, 0., 6.71140943e-003,
-       1.34228189e-002, 0., 0., 0., 0., 1.34228189e-002, 1.34228189e-002,
-       0., 0., 0., 0., 0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.71140943e-003, 0., 0.,
-       0., 0., 0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.34228189e-002, 0., 0.,
-       0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0.,
-       0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 6.71140943e-003, 0.,
-       0., 0., 0., 0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 2.01342292e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.71140943e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.71140943e-003, 0., 0., 0., 0., 0., 0., 6.71140943e-003, 0., 0.,
-       0., 0., 6.71140943e-003, 0., 0., 0., 1.03626940e-002,
-       5.18134702e-003, 0., 0., 2.07253881e-002, 0., 0., 0.,
-       1.03626940e-002, 5.18134702e-003, 1.03626940e-002,
-       1.03626940e-002, 0., 1.03626940e-002, 0., 0., 5.18134702e-003, 0.,
-       0., 0., 1.03626940e-002, 2.59067342e-002, 1.03626940e-002,
-       5.18134702e-003, 5.18134702e-003, 5.18134702e-003,
-       5.18134702e-003, 1.55440411e-002, 5.18134702e-003, 0.,
-       1.55440411e-002, 0., 5.18134702e-003, 1.03626940e-002,
-       5.18134702e-003, 0., 0., 5.18134702e-003, 0., 0., 0., 0.,
-       1.03626940e-002, 0., 1.55440411e-002, 0., 1.03626940e-002,
-       2.59067342e-002, 5.18134702e-003, 0., 5.18134702e-003,
-       5.18134702e-003, 0., 0., 1.03626940e-002, 0., 5.18134702e-003,
-       5.18134702e-003, 5.18134702e-003, 0., 0., 1.03626940e-002,
-       5.18134702e-003, 0., 5.18134702e-003, 0., 5.18134702e-003, 0., 0.,
-       0., 0., 0., 1.55440411e-002, 5.18134702e-003, 1.03626940e-002, 0.,
-       0., 0., 5.18134702e-003, 0., 0., 0., 0., 5.18134702e-003, 0., 0.,
-       0., 0., 0., 5.18134702e-003, 0., 0., 1.55440411e-002,
-       5.18134702e-003, 1.55440411e-002, 0., 0., 5.18134702e-003,
-       1.03626940e-002, 1.03626940e-002, 0., 5.18134702e-003, 0., 0.,
-       5.18134702e-003, 0., 0., 0., 0., 0., 2.07253881e-002,
-       5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 5.18134702e-003,
-       5.18134702e-003, 0., 0., 0., 0., 2.07253881e-002, 0., 0.,
-       5.18134702e-003, 5.69948182e-002, 5.18134702e-003, 0.,
-       5.18134702e-003, 0., 5.18134702e-003, 0., 0., 0., 0., 0.,
-       5.18134702e-003, 0., 5.18134702e-003, 5.18134702e-003, 0., 0.,
-       5.18134702e-003, 0., 1.03626940e-002, 0., 0., 5.18134702e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.18134702e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.18134702e-003, 0., 1.03626940e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.18134702e-003, 0., 0.,
-       5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.18134702e-003, 0., 0., 0., 5.18134702e-003, 1.03626940e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.07253881e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.18134702e-003, 0., 0., 0., 0., 5.18134702e-003, 0., 0.,
-       0., 5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 5.18134702e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.03626940e-002, 0., 0., 1.03626940e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.18134702e-003, 0., 0., 0.,
-       5.18134702e-003, 0., 0., 0., 0., 2.07253881e-002, 0., 0., 0., 0.,
-       1.03626940e-002, 0., 0., 0., 0., 0., 0., 5.18134702e-003, 0., 0.,
-       0., 1.03626940e-002, 0., 0., 0., 0., 0., 0., 0., 5.18134702e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.03626940e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.18134702e-003, 5.18134702e-003, 0., 0., 0.,
-       0., 0., 5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.18134702e-003, 0., 0., 0., 0., 5.18134702e-003, 0.,
-       5.18134702e-003, 0., 0., 5.18134702e-003, 0., 0., 0.,
-       5.18134702e-003, 0., 0., 5.18134702e-003, 0., 0., 1.55440411e-002,
-       5.18134702e-003, 0., 0., 0., 5.18134702e-003, 0., 0., 0., 0., 0.,
-       5.18134702e-003, 5.18134702e-003, 0., 0., 0., 0., 5.18134702e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.03626940e-002, 0., 0.,
-       0., 1.03626940e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.18134702e-003, 0., 5.18134702e-003, 0., 5.18134702e-003,
-       5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.18134702e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.18134702e-003, 5.18134702e-003, 0., 5.18134702e-003, 0., 0., 0.,
-       0., 5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.18134702e-003, 0., 0., 0., 5.18134702e-003, 0., 0., 0., 0., 0.,
-       0., 1.91082805e-002, 3.18471342e-002, 1.27388537e-002,
-       6.36942685e-003, 6.36942685e-003, 6.36942685e-003, 0.,
-       1.27388537e-002, 6.36942685e-003, 0., 6.36942685e-003, 0.,
-       6.36942685e-003, 6.36942685e-003, 6.36942685e-003, 0., 0.,
-       6.36942685e-003, 0., 0., 0., 6.36942685e-003, 6.36942685e-003, 0.,
-       6.36942685e-003, 0., 6.36942685e-003, 0., 1.27388537e-002,
-       6.36942685e-003, 0., 6.36942685e-003, 6.36942685e-003,
-       6.36942685e-003, 0., 0., 0., 6.36942685e-003, 0., 0.,
-       6.36942685e-003, 0., 0., 0., 0., 6.36942685e-003, 6.36942685e-003,
-       6.36942685e-003, 1.27388537e-002, 1.27388537e-002, 0.,
-       1.27388537e-002, 0., 0., 0., 6.36942685e-003, 0., 0., 0.,
-       1.27388537e-002, 0., 0., 1.27388537e-002, 0., 6.36942685e-003,
-       6.36942685e-003, 0., 0., 1.27388537e-002, 1.27388537e-002, 0.,
-       6.36942685e-003, 0., 0., 1.27388537e-002, 6.36942685e-003, 0.,
-       6.36942685e-003, 0., 0., 0., 0., 6.36942685e-003, 6.36942685e-003,
-       1.27388537e-002, 0., 0., 0., 0., 6.36942685e-003, 6.36942685e-003,
-       0., 6.36942685e-003, 0., 0., 6.36942685e-003, 0., 0., 0.,
-       1.27388537e-002, 0., 0., 0., 0., 0., 0., 0., 0., 1.91082805e-002,
-       1.27388537e-002, 0., 0., 0., 0., 0., 0., 0., 1.27388537e-002,
-       6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 4.45859879e-002, 0.,
-       0., 0., 3.18471342e-002, 0., 0., 0., 0., 6.36942685e-003,
-       6.36942685e-003, 0., 1.91082805e-002, 0., 6.36942685e-003, 0., 0.,
-       0., 0., 6.36942685e-003, 0., 0., 0., 6.36942685e-003,
-       6.36942685e-003, 0., 6.36942685e-003, 0., 1.27388537e-002,
-       6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 6.36942685e-003,
-       6.36942685e-003, 0., 0., 0., 0., 0., 6.36942685e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.36942685e-003, 0., 6.36942685e-003, 0., 0., 6.36942685e-003, 0.,
-       0., 0., 0., 0., 0., 6.36942685e-003, 0., 0., 0., 0.,
-       6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 0., 1.91082805e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 2.54777074e-002, 0., 0., 0., 0., 0., 6.36942685e-003, 0.,
-       0., 0., 0., 0., 6.36942685e-003, 0., 0., 6.36942685e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.36942685e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.36942685e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.36942685e-003, 0., 0., 0., 0., 6.36942685e-003, 0.,
-       0., 6.36942685e-003, 6.36942685e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 1.91082805e-002,
-       0., 0., 0., 0., 6.36942685e-003, 0., 0., 0., 6.36942685e-003, 0.,
-       0., 0., 0., 6.36942685e-003, 0., 0., 6.36942685e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 6.36942685e-003, 0.,
-       0., 0., 6.36942685e-003, 0., 0., 0., 0., 6.36942685e-003, 0., 0.,
-       6.36942685e-003, 6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.36942685e-003, 0., 0., 0., 0., 6.36942685e-003, 0.,
-       1.27388537e-002, 1.91082805e-002, 0., 6.36942685e-003, 0., 0., 0.,
-       1.27388537e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.36942685e-003, 0., 0., 0., 0., 0., 0., 0., 6.36942685e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.36942685e-003, 0., 0., 0.,
-       0., 0., 6.36942685e-003, 0., 6.36942685e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.85185187e-002,
-       1.23456791e-002, 0., 1.23456791e-002, 0., 1.23456791e-002, 0.,
-       6.17283955e-003, 1.23456791e-002, 0., 1.23456791e-002,
-       6.17283955e-003, 6.17283955e-003, 1.23456791e-002, 0., 0.,
-       6.17283955e-003, 6.17283955e-003, 6.17283955e-003, 0., 0.,
-       6.17283955e-003, 1.85185187e-002, 6.17283955e-003, 0.,
-       6.17283955e-003, 0., 0., 1.23456791e-002, 0., 0., 6.17283955e-003,
-       0., 6.17283955e-003, 6.17283955e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.17283955e-003, 0., 1.23456791e-002, 6.17283955e-003,
-       6.17283955e-003, 0., 6.17283955e-003, 1.85185187e-002, 0., 0.,
-       6.17283955e-003, 3.08641978e-002, 0., 0., 6.17283955e-003, 0.,
-       1.23456791e-002, 0., 1.23456791e-002, 0., 0., 6.17283955e-003, 0.,
-       0., 0., 0., 0., 0., 0., 6.17283955e-003, 0., 0., 0.,
-       6.17283955e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.17283955e-003, 0., 1.23456791e-002, 0., 0., 0.,
-       1.23456791e-002, 6.17283955e-003, 0., 0., 0., 0., 0., 0.,
-       6.17283955e-003, 0., 0., 0., 1.23456791e-002, 0., 0., 0., 0., 0.,
-       0., 0., 6.17283955e-003, 0., 0., 0., 0., 6.17283955e-003, 0., 0.,
-       0., 0., 6.17283955e-003, 4.32098769e-002, 1.85185187e-002, 0.,
-       2.46913582e-002, 0., 0., 0., 0., 6.17283955e-003, 0., 0., 0., 0.,
-       0., 6.17283955e-003, 6.17283955e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.85185187e-002, 0., 6.17283955e-003, 6.17283955e-003, 0.,
-       1.23456791e-002, 6.17283955e-003, 0., 0., 0., 0., 0.,
-       6.17283955e-003, 0., 0., 0., 0., 0., 0., 6.17283955e-003, 0., 0.,
-       0., 0., 0., 0., 0., 6.17283955e-003, 6.17283955e-003, 0., 0., 0.,
-       0., 0., 0., 6.17283955e-003, 0., 1.23456791e-002, 6.17283955e-003,
-       0., 0., 0., 0., 1.23456791e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.17283955e-003, 0., 0., 0., 0., 6.17283955e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.17283955e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.85185187e-002, 0., 3.08641978e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.85185187e-002, 0., 0.,
-       0., 0., 0., 1.23456791e-002, 0., 0., 0., 0., 0., 0., 0.,
-       6.17283955e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.17283955e-003, 0., 1.85185187e-002, 0., 0.,
-       6.17283955e-003, 0., 0., 0., 0., 0., 6.17283955e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.85185187e-002, 0., 0.,
-       6.17283955e-003, 0., 6.17283955e-003, 6.17283955e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.23456791e-002, 0.,
-       6.17283955e-003, 0., 6.17283955e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.17283955e-003, 0., 0., 0., 0., 0., 0., 0., 0., 6.17283955e-003,
-       0., 0., 0., 0., 1.23456791e-002, 0., 0., 0., 0., 0., 0., 0.,
-       6.17283955e-003, 6.17283955e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.23456791e-002,
-       6.17283955e-003, 0., 0., 0., 0., 0., 6.17283955e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.17283955e-003, 0., 0., 6.17283955e-003, 0., 0., 0., 0.,
-       6.17283955e-003, 0., 0., 0., 0., 0., 0., 0., 6.17283955e-003,
-       6.17283955e-003, 0., 0., 0., 0., 6.17283955e-003, 0., 0., 0.,
-       6.17283955e-003, 0., 0., 0., 0., 0., 0., 6.17283955e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.17283955e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.17283955e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.23456791e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.17283955e-003, 0., 0., 0., 0., 0.,
-       6.17283955e-003, 0., 0., 6.17283955e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.17283955e-003, 6.17283955e-003, 0., 0., 0.,
-       2.74725277e-002, 5.49450563e-003, 5.49450563e-003, 0.,
-       2.74725277e-002, 0., 0., 1.64835174e-002, 0., 0., 0., 0.,
-       5.49450563e-003, 0., 5.49450563e-003, 0., 1.09890113e-002,
-       5.49450563e-003, 5.49450563e-003, 0., 1.64835174e-002,
-       1.09890113e-002, 5.49450563e-003, 5.49450563e-003, 0.,
-       5.49450563e-003, 0., 1.64835174e-002, 5.49450563e-003,
-       5.49450563e-003, 0., 0., 0., 1.64835174e-002, 0., 0.,
-       5.49450563e-003, 5.49450563e-003, 0., 0., 0., 0., 5.49450563e-003,
-       0., 0., 0., 5.49450563e-003, 5.49450563e-003, 0., 0.,
-       1.64835174e-002, 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 5.49450563e-003, 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 5.49450563e-003, 0., 0., 0., 5.49450563e-003,
-       0., 5.49450563e-003, 4.94505502e-002, 1.09890113e-002,
-       5.49450563e-003, 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 1.09890113e-002,
-       5.49450563e-003, 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       2.19780225e-002, 0., 0., 5.49450563e-003, 1.09890113e-002, 0., 0.,
-       0., 0., 0., 0., 0., 5.49450563e-003, 0., 5.49450563e-003, 0., 0.,
-       0., 0., 5.49450563e-003, 1.09890113e-002, 0., 0., 5.49450563e-003,
-       0., 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 1.64835174e-002,
-       0., 0., 5.49450563e-003, 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 5.49450563e-003, 0.,
-       0., 0., 0., 0., 0., 0., 5.49450563e-003, 5.49450563e-003, 0.,
-       5.49450563e-003, 0., 0., 0., 0., 1.09890113e-002, 0., 0., 0., 0.,
-       0., 5.49450563e-003, 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0.,
-       0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 5.49450563e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 2.74725277e-002, 5.49450563e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 5.49450563e-003, 0., 0.,
-       5.49450563e-003, 5.49450563e-003, 0., 5.49450563e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.49450563e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.49450563e-003, 0., 1.09890113e-002,
-       0., 0., 0., 0., 0., 0., 0., 5.49450563e-003, 5.49450563e-003, 0.,
-       5.49450563e-003, 0., 5.49450563e-003, 5.49450563e-003, 0., 0.,
-       5.49450563e-003, 0., 0., 0., 1.09890113e-002, 5.49450563e-003, 0.,
-       0., 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 1.09890113e-002, 0., 0., 1.09890113e-002,
-       0., 1.09890113e-002, 0., 1.09890113e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0.,
-       3.29670347e-002, 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.49450563e-003, 0., 0., 0., 0., 0., 5.49450563e-003,
-       5.49450563e-003, 0., 0., 0., 5.49450563e-003, 0., 5.49450563e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.49450563e-003, 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 5.49450563e-003, 0., 0.,
-       5.49450563e-003, 0., 0., 5.49450563e-003, 0., 0., 0.,
-       5.49450563e-003, 0., 5.49450563e-003, 5.49450563e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.49450563e-003, 5.49450563e-003, 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.49450563e-003, 0., 0., 0., 5.49450563e-003, 0., 0., 0.,
-       0., 5.49450563e-003, 5.49450563e-003, 0., 0., 5.49450563e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.49450563e-003, 0., 0.,
-       5.49450563e-003, 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 5.49450563e-003, 0., 0., 0., 0.,
-       5.49450563e-003, 0., 5.49450563e-003, 1.09890113e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.09890113e-002, 5.49450563e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0.,
-       9.09090880e-003, 9.09090880e-003, 0., 0., 0., 0., 9.09090880e-003,
-       0., 0., 0., 0., 2.72727273e-002, 9.09090880e-003, 0., 0.,
-       2.72727273e-002, 0., 1.81818176e-002, 9.09090880e-003, 0.,
-       1.81818176e-002, 0., 0., 0., 1.81818176e-002, 0., 0.,
-       1.81818176e-002, 0., 0., 0., 9.09090880e-003, 0., 0., 0.,
-       9.09090880e-003, 1.81818176e-002, 9.09090880e-003, 0., 0., 0.,
-       9.09090880e-003, 0., 9.09090880e-003, 9.09090880e-003,
-       1.81818176e-002, 9.09090880e-003, 0., 0., 9.09090880e-003, 0., 0.,
-       0., 1.81818176e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.09090880e-003, 0., 0., 0., 9.09090880e-003, 0., 0., 0., 0.,
-       9.09090880e-003, 9.09090880e-003, 9.09090880e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.09090880e-003, 9.09090880e-003, 0., 0., 0., 0., 0., 0.,
-       9.09090880e-003, 0., 0., 9.09090880e-003, 0., 0., 0.,
-       9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       3.63636352e-002, 0., 2.72727273e-002, 9.09090880e-003, 0., 0., 0.,
-       0., 9.09090880e-003, 0., 0., 0., 5.45454547e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.09090880e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.09090880e-003, 0., 0., 0., 1.81818176e-002, 0., 0., 0.,
-       9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 9.09090880e-003, 0.,
-       0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.81818176e-002, 0., 0., 0., 0.,
-       9.09090880e-003, 0., 0., 0., 0., 9.09090880e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.09090880e-003, 0., 0., 0., 0., 1.81818176e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 9.09090880e-003, 0., 9.09090880e-003, 0., 0., 0., 0., 0.,
-       9.09090880e-003, 0., 0., 0., 9.09090880e-003, 0., 0., 0., 0., 0.,
-       2.72727273e-002, 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.09090880e-003, 0., 0., 1.81818176e-002,
-       0., 0., 0., 0., 0., 1.81818176e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.09090880e-003, 0., 0., 0.,
-       1.81818176e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 9.09090880e-003, 0., 1.81818176e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.09090880e-003,
-       0., 0., 0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.09090880e-003, 0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.09090880e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.09090880e-003, 0., 0., 1.81818176e-002, 0., 0.,
-       0., 0., 9.09090880e-003, 0., 0., 0., 0., 9.09090880e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.09090880e-003, 0., 9.09090880e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.09090880e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.09090880e-003, 0., 0., 9.17431153e-003, 9.17431153e-003, 0., 0.,
-       0., 0., 0., 9.17431153e-003, 0., 9.17431153e-003, 9.17431153e-003,
-       9.17431153e-003, 1.83486231e-002, 1.83486231e-002, 0., 0.,
-       9.17431153e-003, 0., 0., 0., 0., 9.17431153e-003, 9.17431153e-003,
-       0., 9.17431153e-003, 3.66972461e-002, 0., 9.17431153e-003,
-       9.17431153e-003, 9.17431153e-003, 9.17431153e-003,
-       9.17431153e-003, 0., 0., 0., 0., 0., 9.17431153e-003,
-       2.75229346e-002, 0., 0., 0., 0., 0., 0., 0., 9.17431153e-003, 0.,
-       0., 0., 9.17431153e-003, 0., 0., 0., 1.83486231e-002, 0., 0., 0.,
-       0., 0., 0., 1.83486231e-002, 0., 2.75229346e-002, 0., 0., 0., 0.,
-       0., 9.17431153e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.17431153e-003, 0., 0., 0., 9.17431153e-003, 0., 0., 0., 0., 0.,
-       0., 9.17431153e-003, 0., 0., 0., 0., 2.75229346e-002,
-       9.17431153e-003, 0., 0., 0., 0., 9.17431153e-003, 0., 0.,
-       9.17431153e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.17431153e-003, 0., 0., 1.83486231e-002, 1.83486231e-002, 0., 0.,
-       0., 0., 9.17431153e-003, 0., 0., 0., 9.17431153e-003,
-       9.17431153e-003, 0., 0., 9.17431153e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.17431153e-003, 1.83486231e-002, 0., 0., 0., 0., 0.,
-       9.17431153e-003, 0., 0., 0., 0., 9.17431153e-003, 0., 0., 0., 0.,
-       9.17431153e-003, 0., 9.17431153e-003, 0., 0., 9.17431153e-003, 0.,
-       1.83486231e-002, 0., 9.17431153e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.17431153e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.17431153e-003, 9.17431153e-003, 0., 0., 0., 0., 0.,
-       1.83486231e-002, 0., 0., 1.83486231e-002, 9.17431153e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.17431153e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.17431153e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.17431153e-003, 0., 0., 0., 0., 0.,
-       9.17431153e-003, 0., 0., 0., 1.83486231e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.83486231e-002, 9.17431153e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.17431153e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.83486231e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.17431153e-003,
-       0., 0., 0., 0., 0., 0., 9.17431153e-003, 9.17431153e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.17431153e-003, 0., 0., 0.,
-       0., 0., 0., 9.17431153e-003, 9.17431153e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.17431153e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.83486231e-002, 0., 0.,
-       9.17431153e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 9.17431153e-003, 0., 0., 0., 0., 0., 0., 0., 9.17431153e-003,
-       0., 0., 0., 0., 0., 9.17431153e-003, 0., 9.17431153e-003, 0., 0.,
-       9.17431153e-003, 0., 0., 1.83486231e-002, 0., 0., 9.17431153e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.17431153e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.17431153e-003, 0., 0., 0., 0., 0., 0., 0., 0., 9.17431153e-003,
-       0., 0., 0., 9.17431153e-003, 9.17431153e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.81250000e-003, 0., 0., 2.34375000e-002, 0., 0.,
-       7.81250000e-003, 7.81250000e-003, 7.81250000e-003, 0., 0.,
-       7.81250000e-003, 1.56250000e-002, 0., 0., 7.81250000e-003, 0.,
-       7.81250000e-003, 7.81250000e-003, 0., 2.34375000e-002, 0., 0., 0.,
-       2.34375000e-002, 0., 2.34375000e-002, 1.56250000e-002,
-       1.56250000e-002, 0., 0., 0., 1.56250000e-002, 7.81250000e-003, 0.,
-       0., 3.12500000e-002, 7.81250000e-003, 0., 0., 0., 2.34375000e-002,
-       0., 0., 0., 7.81250000e-003, 0., 0., 0., 7.81250000e-003, 0., 0.,
-       0., 3.90625000e-002, 0., 0., 0., 0., 0., 0., 0., 7.81250000e-003,
-       0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.56250000e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.56250000e-002, 7.81250000e-003,
-       0., 0., 0., 0., 0., 0., 0., 1.56250000e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.56250000e-002, 0., 0., 0., 1.56250000e-002,
-       7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 1.56250000e-002, 0.,
-       0., 0., 5.46875000e-002, 0., 0., 0., 0., 7.81250000e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.81250000e-003, 7.81250000e-003, 0., 0.,
-       7.81250000e-003, 0., 7.81250000e-003, 0., 2.34375000e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.81250000e-003, 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0.,
-       1.56250000e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.81250000e-003, 7.81250000e-003, 0., 0., 0.,
-       7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.56250000e-002, 0., 0., 0., 0., 1.56250000e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.56250000e-002, 7.81250000e-003, 0., 0.,
-       0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.56250000e-002, 0., 0., 0., 0., 0., 7.81250000e-003, 0.,
-       0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0.,
-       7.81250000e-003, 0., 0., 7.81250000e-003, 0., 0., 0., 0.,
-       3.12500000e-002, 0., 0., 0., 1.56250000e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 7.81250000e-003, 0., 1.56250000e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.81250000e-003, 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.81250000e-003, 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.81250000e-003, 0., 0., 1.56250000e-002, 0., 0., 0.,
-       0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.81250000e-003, 0., 7.81250000e-003, 0., 0., 0., 0.,
-       7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.81250000e-003, 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.75675692e-003, 1.35135138e-002, 6.75675692e-003, 0.,
-       6.75675692e-003, 1.35135138e-002, 0., 0., 1.35135138e-002, 0., 0.,
-       0., 0., 2.70270277e-002, 0., 6.75675692e-003, 6.75675692e-003,
-       2.02702712e-002, 0., 1.35135138e-002, 0., 6.75675692e-003,
-       6.75675692e-003, 0., 0., 0., 2.02702712e-002, 0., 6.75675692e-003,
-       3.37837860e-002, 0., 0., 0., 0., 6.75675692e-003, 0., 0., 0.,
-       2.02702712e-002, 6.75675692e-003, 0., 0., 0., 0., 0., 0.,
-       1.35135138e-002, 0., 1.35135138e-002, 0., 6.75675692e-003, 0.,
-       1.35135138e-002, 0., 0., 1.35135138e-002, 0., 0., 1.35135138e-002,
-       0., 0., 0., 6.75675692e-003, 0., 6.75675692e-003, 6.75675692e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.75675692e-003, 0.,
-       0., 0., 6.75675692e-003, 6.75675692e-003, 0., 0., 6.75675692e-003,
-       0., 0., 0., 0., 0., 0., 0., 6.75675692e-003, 0., 2.02702712e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.75675692e-003, 0., 0., 0., 0.,
-       0., 0., 1.35135138e-002, 1.35135138e-002, 0., 0., 0.,
-       6.75675692e-003, 6.75675692e-003, 6.75675692e-003, 0., 0.,
-       6.75675692e-003, 0., 6.75675692e-003, 0., 0., 0., 0., 0., 0.,
-       4.05405425e-002, 0., 0., 0., 0., 6.75675692e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.35135138e-002, 6.75675692e-003, 0., 0., 0.,
-       6.75675692e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.75675692e-003, 0., 0., 0., 0.,
-       6.75675692e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.35135138e-002, 0., 0.,
-       6.75675692e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.75675692e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.75675692e-003, 0., 0., 0., 6.75675692e-003, 0., 0., 0.,
-       6.75675692e-003, 0., 0., 0., 0., 2.02702712e-002, 0., 0., 0., 0.,
-       0., 6.75675692e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.35135138e-002, 0., 0., 6.75675692e-003, 0., 6.75675692e-003,
-       6.75675692e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.35135138e-002, 0., 0., 6.75675692e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.75675692e-003, 0., 6.75675692e-003, 0.,
-       6.75675692e-003, 2.70270277e-002, 0., 6.75675692e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.75675692e-003,
-       6.75675692e-003, 0., 0., 6.75675692e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.75675692e-003, 0., 0., 0.,
-       2.02702712e-002, 0., 0., 0., 0., 0., 0., 6.75675692e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.75675692e-003, 0., 0., 0., 0.,
-       0., 6.75675692e-003, 0., 0., 0., 0., 0., 6.75675692e-003, 0., 0.,
-       0., 6.75675692e-003, 0., 2.02702712e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.75675692e-003, 0., 0., 0., 0., 0., 6.75675692e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.75675692e-003, 0., 0.,
-       0., 0., 0., 0., 6.75675692e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.75675692e-003, 0., 0., 0., 6.75675692e-003, 0., 0., 0., 0., 0.,
-       6.75675692e-003, 0., 0., 0., 0., 0., 6.75675692e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.75675692e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 2.70270277e-002, 0.,
-       6.75675692e-003, 0., 6.75675692e-003, 0., 0., 0., 0., 0.,
-       6.75675692e-003, 0., 0., 0., 6.75675692e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.75675692e-003, 0., 0., 0., 0., 0.,
-       6.75675692e-003, 0., 0., 0., 0., 6.75675692e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.75675692e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.75675692e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.35135138e-002, 0., 0., 0., 0., 0., 0., 0., 6.75675692e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.66666675e-002,
-       8.33333377e-003, 0., 0., 8.33333377e-003, 0., 0., 0.,
-       3.33333351e-002, 1.66666675e-002, 0., 0., 8.33333377e-003, 0.,
-       8.33333377e-003, 0., 0., 8.33333377e-003, 0., 8.33333377e-003,
-       8.33333377e-003, 0., 2.50000022e-002, 0., 0., 0., 3.33333351e-002,
-       0., 1.66666675e-002, 1.66666675e-002, 0., 2.50000022e-002, 0.,
-       8.33333377e-003, 8.33333377e-003, 0., 0., 0., 1.66666675e-002,
-       8.33333377e-003, 0., 0., 0., 0., 8.33333377e-003, 0., 0.,
-       1.66666675e-002, 1.66666675e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 0., 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0.,
-       0., 1.66666675e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.33333377e-003, 0., 0., 0., 8.33333377e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.66666675e-002, 0., 0., 0., 2.50000022e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.33333377e-003, 0.,
-       1.66666675e-002, 0., 0., 0., 8.33333377e-003, 8.33333377e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 3.33333351e-002, 0., 0., 0.,
-       8.33333377e-003, 0., 8.33333377e-003, 8.33333377e-003, 0.,
-       1.66666675e-002, 8.33333377e-003, 0., 1.66666675e-002, 0., 0.,
-       8.33333377e-003, 0., 0., 0., 8.33333377e-003, 0., 0., 0., 0.,
-       1.66666675e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.33333377e-003, 2.50000022e-002, 0., 0., 0., 1.66666675e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0.,
-       8.33333377e-003, 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0., 0.,
-       0., 0., 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 0., 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0.,
-       0., 0., 0., 0., 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0., 0.,
-       0., 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.33333377e-003, 0., 0., 0., 8.33333377e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.33333377e-003,
-       0., 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0., 8.33333377e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 0., 0., 1.66666675e-002, 1.66666675e-002,
-       1.66666675e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.66666675e-002, 0., 0., 0., 0., 0., 0., 0., 8.33333377e-003,
-       8.33333377e-003, 0., 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0., 0.,
-       1.66666675e-002, 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.66666675e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.33333377e-003,
-       8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0., 0.,
-       8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 0., 8.33333377e-003, 8.33333377e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 2.45398767e-002, 1.22699384e-002, 0.,
-       6.13496918e-003, 3.06748450e-002, 6.13496918e-003, 0., 0.,
-       1.22699384e-002, 1.22699384e-002, 6.13496918e-003,
-       6.13496918e-003, 1.22699384e-002, 0., 0., 6.13496918e-003, 0.,
-       2.45398767e-002, 6.13496918e-003, 0., 1.22699384e-002, 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0.,
-       0., 6.13496918e-003, 6.13496918e-003, 6.13496918e-003, 0., 0.,
-       1.84049085e-002, 1.22699384e-002, 0., 0., 0., 0., 0.,
-       1.22699384e-002, 6.13496918e-003, 0., 6.13496918e-003, 0., 0., 0.,
-       0., 6.13496918e-003, 6.13496918e-003, 1.22699384e-002, 0.,
-       1.22699384e-002, 0., 6.13496918e-003, 0., 0., 1.22699384e-002,
-       1.84049085e-002, 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 6.13496918e-003,
-       1.22699384e-002, 0., 0., 1.22699384e-002, 0., 6.13496918e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 6.13496918e-003,
-       0., 0., 0., 1.84049085e-002, 0., 0., 0., 0., 1.84049085e-002, 0.,
-       0., 6.13496918e-003, 0., 6.13496918e-003, 0., 0., 1.22699384e-002,
-       6.13496918e-003, 0., 0., 0., 0., 6.13496918e-003, 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0.,
-       1.22699384e-002, 1.22699384e-002, 0., 6.13496918e-003, 0., 0.,
-       1.84049085e-002, 0., 0., 0., 0., 0., 0., 1.84049085e-002, 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 6.13496918e-003, 0., 0., 0., 0., 0.,
-       1.84049085e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.13496918e-003, 6.13496918e-003, 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0.,
-       0., 0., 0., 0., 0., 1.22699384e-002, 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0.,
-       6.13496918e-003, 6.13496918e-003, 0., 6.13496918e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0.,
-       0., 0., 0., 1.22699384e-002, 0., 0., 0., 0., 6.13496918e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.22699384e-002, 6.13496918e-003, 1.84049085e-002, 0., 0., 0., 0.,
-       1.22699384e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.22699384e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.84049085e-002, 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0.,
-       1.22699384e-002, 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0.,
-       2.45398767e-002, 6.13496918e-003, 6.13496918e-003, 0., 0.,
-       6.13496918e-003, 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0.,
-       0., 0., 1.84049085e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 2.45398767e-002,
-       0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0.,
-       6.13496918e-003, 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003,
-       0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 6.13496918e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0.,
-       0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.22699384e-002, 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.18343197e-002, 5.91715984e-003,
-       5.91715984e-003, 0., 0., 2.95857992e-002, 0., 0., 0., 0., 0., 0.,
-       1.18343197e-002, 1.77514795e-002, 5.91715984e-003, 0., 0.,
-       1.18343197e-002, 0., 0., 0., 0., 5.91715984e-003, 1.18343197e-002,
-       0., 0., 1.18343197e-002, 5.91715984e-003, 5.91715984e-003, 0., 0.,
-       1.77514795e-002, 0., 1.18343197e-002, 0., 0., 0., 0.,
-       1.18343197e-002, 1.77514795e-002, 5.91715984e-003, 0., 0., 0., 0.,
-       1.18343197e-002, 0., 1.18343197e-002, 1.77514795e-002,
-       5.91715984e-003, 0., 5.91715984e-003, 0., 0., 5.91715984e-003, 0.,
-       0., 1.18343197e-002, 0., 0., 0., 0., 0., 5.91715984e-003,
-       5.91715984e-003, 1.18343197e-002, 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 1.18343197e-002, 0., 0., 1.18343197e-002,
-       0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 5.91715984e-003, 0., 0., 1.18343197e-002, 0., 0.,
-       0., 0., 0., 0., 1.18343197e-002, 0., 0., 0., 0., 1.18343197e-002,
-       5.91715984e-003, 1.77514795e-002, 5.91715984e-003, 0.,
-       5.91715984e-003, 0., 0., 0., 0., 1.18343197e-002, 5.91715984e-003,
-       0., 5.91715984e-003, 3.55029590e-002, 0., 0., 1.18343197e-002, 0.,
-       1.18343197e-002, 0., 0., 1.18343197e-002, 0., 0., 0., 0., 0., 0.,
-       1.77514795e-002, 0., 0., 5.91715984e-003, 5.91715984e-003,
-       5.91715984e-003, 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 2.36686394e-002, 0.,
-       1.18343197e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0.,
-       0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 5.91715984e-003,
-       0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.18343197e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.91715984e-003, 0., 5.91715984e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003,
-       5.91715984e-003, 0., 1.18343197e-002, 0., 0., 0., 5.91715984e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0.,
-       5.91715984e-003, 1.18343197e-002, 0., 0., 0., 0., 1.18343197e-002,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0.,
-       5.91715984e-003, 5.91715984e-003, 0., 0., 5.91715984e-003, 0., 0.,
-       0., 5.91715984e-003, 1.77514795e-002, 0., 0., 0., 5.91715984e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.18343197e-002, 0., 0., 0., 0.,
-       5.91715984e-003, 5.91715984e-003, 0., 0., 0., 0., 0., 0.,
-       1.18343197e-002, 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0.,
-       1.77514795e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003,
-       0., 0., 0., 0., 0., 1.77514795e-002, 0., 0., 0., 0., 0.,
-       1.18343197e-002, 0., 1.18343197e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003,
-       0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.91715984e-003, 0., 5.91715984e-003, 5.91715984e-003, 0., 0.,
-       0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 5.91715984e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.92307699e-002,
-       6.41025649e-003, 1.28205130e-002, 1.28205130e-002, 0.,
-       6.41025649e-003, 0., 0., 6.41025649e-003, 3.20512839e-002, 0., 0.,
-       1.28205130e-002, 6.41025649e-003, 6.41025649e-003, 0.,
-       6.41025649e-003, 0., 0., 0., 0., 6.41025649e-003, 1.28205130e-002,
-       0., 0., 6.41025649e-003, 0., 0., 1.92307699e-002, 2.56410260e-002,
-       6.41025649e-003, 6.41025649e-003, 6.41025649e-003,
-       6.41025649e-003, 0., 0., 0., 0., 1.92307699e-002, 2.56410260e-002,
-       6.41025649e-003, 6.41025649e-003, 0., 6.41025649e-003, 0.,
-       6.41025649e-003, 0., 6.41025649e-003, 3.20512839e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0.,
-       0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 6.41025649e-003, 0., 0., 1.92307699e-002,
-       0., 0., 0., 6.41025649e-003, 0., 0., 6.41025649e-003, 0.,
-       6.41025649e-003, 0., 6.41025649e-003, 6.41025649e-003, 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 6.41025649e-003,
-       1.28205130e-002, 6.41025649e-003, 6.41025649e-003,
-       1.28205130e-002, 0., 0., 0., 0., 1.92307699e-002, 0., 0., 0.,
-       1.92307699e-002, 6.41025649e-003, 0., 6.41025649e-003, 0., 0.,
-       6.41025649e-003, 0., 6.41025649e-003, 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 6.41025649e-003, 0., 6.41025649e-003,
-       0., 1.92307699e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 1.92307699e-002, 0., 0.,
-       0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 6.41025649e-003, 0.,
-       0., 0., 0., 0., 6.41025649e-003, 0., 0., 6.41025649e-003, 0., 0.,
-       0., 0., 1.28205130e-002, 6.41025649e-003, 0., 0., 0., 0., 0., 0.,
-       0., 1.28205130e-002, 6.41025649e-003, 6.41025649e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.28205130e-002, 0., 0., 0., 0.,
-       0., 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.41025649e-003, 6.41025649e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.41025649e-003, 0., 6.41025649e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.28205130e-002, 1.92307699e-002, 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 3.20512839e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.41025649e-003, 0., 6.41025649e-003, 0., 6.41025649e-003,
-       0., 0., 6.41025649e-003, 0., 0., 6.41025649e-003, 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 6.41025649e-003, 0., 0.,
-       1.28205130e-002, 0., 0., 0., 0., 0., 0., 0., 1.92307699e-002,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 6.41025649e-003, 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 1.28205130e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.41025649e-003, 0., 0., 0., 0., 6.41025649e-003, 0., 0., 0.,
-       0., 0., 1.92307699e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.41025649e-003, 0., 0., 0., 0., 6.41025649e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.41025649e-003, 0.,
-       0., 0., 0., 0., 6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.41025649e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.01010101e-002, 1.01010101e-002, 5.05050505e-003, 0., 0.,
-       1.01010101e-002, 1.01010101e-002, 0., 1.51515156e-002,
-       1.01010101e-002, 1.01010101e-002, 5.05050505e-003,
-       5.05050505e-003, 1.01010101e-002, 3.03030312e-002,
-       5.05050505e-003, 0., 5.05050505e-003, 5.05050505e-003, 0.,
-       1.01010101e-002, 5.05050505e-003, 1.01010101e-002, 0., 0.,
-       5.05050505e-003, 0., 1.01010101e-002, 5.05050505e-003, 0.,
-       1.01010101e-002, 0., 0., 5.05050505e-003, 0., 1.51515156e-002,
-       5.05050505e-003, 0., 0., 0., 0., 0., 1.51515156e-002, 0., 0.,
-       3.03030312e-002, 5.05050505e-003, 0., 5.05050505e-003, 0.,
-       1.01010101e-002, 1.01010101e-002, 5.05050505e-003, 0.,
-       5.05050505e-003, 5.05050505e-003, 5.05050505e-003, 0., 0.,
-       5.05050505e-003, 5.05050505e-003, 1.01010101e-002, 0., 0., 0.,
-       5.05050505e-003, 1.01010101e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.05050505e-003, 1.01010101e-002, 5.05050505e-003, 0., 0.,
-       1.01010101e-002, 5.05050505e-003, 5.05050505e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.05050505e-003, 0., 0.,
-       1.01010101e-002, 0., 5.05050505e-003, 0., 1.01010101e-002,
-       5.05050505e-003, 0., 0., 5.05050505e-003, 0., 4.54545468e-002, 0.,
-       5.05050505e-003, 0., 4.04040404e-002, 0., 0., 5.05050505e-003, 0.,
-       0., 0., 0., 2.52525248e-002, 0., 0., 0., 0., 5.05050505e-003,
-       5.05050505e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.05050505e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.05050505e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.01010101e-002, 0.,
-       1.01010101e-002, 5.05050505e-003, 0., 1.01010101e-002, 0., 0., 0.,
-       1.01010101e-002, 1.01010101e-002, 0., 0., 0., 0., 0., 0.,
-       1.01010101e-002, 0., 0., 0., 0., 0., 0., 0., 5.05050505e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.05050505e-003, 0., 0., 0., 0., 0.,
-       5.05050505e-003, 0., 0., 0., 0., 1.01010101e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.05050505e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.01010101e-002,
-       0., 0., 5.05050505e-003, 5.05050505e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.05050505e-003, 0.,
-       2.52525248e-002, 0., 0., 5.05050505e-003, 1.01010101e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.05050505e-003,
-       5.05050505e-003, 5.05050505e-003, 0., 0., 0., 0., 0., 0.,
-       5.05050505e-003, 5.05050505e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 2.02020202e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.05050505e-003, 0., 0., 1.01010101e-002, 0., 0., 5.05050505e-003,
-       0., 0., 0., 5.05050505e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.05050505e-003, 0., 0., 0., 0., 0., 5.05050505e-003, 0.,
-       1.51515156e-002, 0., 0., 0., 0., 0., 0., 5.05050505e-003,
-       5.05050505e-003, 5.05050505e-003, 0., 0., 0., 0., 5.05050505e-003,
-       5.05050505e-003, 0., 1.01010101e-002, 0., 0., 1.01010101e-002, 0.,
-       0., 0., 1.01010101e-002, 1.01010101e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.05050505e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.05050505e-003, 0., 0., 5.05050505e-003, 0.,
-       5.05050505e-003, 0., 0., 1.01010101e-002, 0., 0., 0., 0., 0., 0.,
-       5.05050505e-003, 0., 0., 5.05050505e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.05050505e-003, 0., 0., 0., 0., 1.01010101e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 2.02020202e-002, 0., 0.,
-       0., 0., 5.05050505e-003, 0., 0., 5.05050505e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.05050505e-003, 0., 0., 0., 0., 0.,
-       0., 5.05050505e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 5.49450563e-003, 5.49450563e-003,
-       1.09890113e-002, 0., 0., 0., 5.49450563e-003, 1.09890113e-002,
-       5.49450563e-003, 0., 5.49450563e-003, 0., 1.09890113e-002,
-       5.49450563e-003, 5.49450563e-003, 5.49450563e-003,
-       2.74725277e-002, 0., 5.49450563e-003, 0., 0., 1.09890113e-002, 0.,
-       1.09890113e-002, 5.49450563e-003, 5.49450563e-003, 0.,
-       1.64835174e-002, 0., 5.49450563e-003, 1.09890113e-002, 0., 0., 0.,
-       0., 0., 0., 5.49450563e-003, 1.09890113e-002, 0., 0.,
-       1.64835174e-002, 0., 0., 5.49450563e-003, 5.49450563e-003,
-       1.64835174e-002, 3.29670347e-002, 0., 0., 5.49450563e-003, 0., 0.,
-       0., 0., 0., 5.49450563e-003, 5.49450563e-003, 0., 0., 0.,
-       1.09890113e-002, 5.49450563e-003, 1.64835174e-002,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.09890113e-002, 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.49450563e-003,
-       5.49450563e-003, 0., 5.49450563e-003, 5.49450563e-003,
-       5.49450563e-003, 0., 0., 1.09890113e-002, 0., 0., 0., 0.,
-       5.49450563e-003, 5.49450563e-003, 0., 1.09890113e-002, 0., 0., 0.,
-       0., 0., 0., 5.49450563e-003, 5.49450563e-003, 0., 5.49450563e-003,
-       1.09890113e-002, 0., 0., 0., 2.19780225e-002, 5.49450563e-003, 0.,
-       0., 2.74725277e-002, 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.09890113e-002, 0., 0., 5.49450563e-003, 0., 0., 0.,
-       1.09890113e-002, 5.49450563e-003, 5.49450563e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.09890113e-002, 5.49450563e-003, 0.,
-       5.49450563e-003, 0., 2.19780225e-002, 0., 0., 0., 1.09890113e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.49450563e-003, 0., 5.49450563e-003, 0., 5.49450563e-003,
-       5.49450563e-003, 0., 1.09890113e-002, 0., 0., 0., 5.49450563e-003,
-       0., 0., 0., 0., 0., 0., 0., 1.09890113e-002, 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 5.49450563e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.09890113e-002, 0., 0., 0., 0., 0., 5.49450563e-003, 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.49450563e-003, 5.49450563e-003, 5.49450563e-003,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.09890113e-002, 0., 0., 1.09890113e-002, 0., 0., 0., 0.,
-       5.49450563e-003, 0., 5.49450563e-003, 5.49450563e-003, 0., 0., 0.,
-       0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.49450563e-003, 1.09890113e-002, 5.49450563e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.49450563e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 3.29670347e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.09890113e-002,
-       5.49450563e-003, 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 5.49450563e-003, 0., 1.64835174e-002, 0.,
-       0., 0., 0., 1.09890113e-002, 0., 0., 0., 5.49450563e-003, 0., 0.,
-       0., 0., 0., 0., 5.49450563e-003, 0., 0., 0., 2.74725277e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.49450563e-003, 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.09890113e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.49450563e-003, 0., 0., 1.09890113e-002, 0., 0.,
-       0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 5.49450563e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.49450563e-003, 0., 0., 0., 0., 5.49450563e-003, 0., 0.,
-       1.09890113e-002, 0., 0., 0., 0., 5.49450563e-003, 0., 0.,
-       5.20833349e-003, 5.20833349e-003, 0., 0., 5.20833349e-003, 0., 0.,
-       0., 0., 1.04166670e-002, 0., 5.20833349e-003, 1.04166670e-002, 0.,
-       5.20833349e-003, 0., 5.20833349e-003, 3.12500000e-002, 0., 0., 0.,
-       5.20833349e-003, 5.20833349e-003, 1.04166670e-002,
-       1.04166670e-002, 5.20833349e-003, 5.20833349e-003,
-       5.20833349e-003, 1.04166670e-002, 2.08333340e-002,
-       1.04166670e-002, 1.04166670e-002, 0., 0., 5.20833349e-003, 0., 0.,
-       0., 0., 2.60416679e-002, 0., 0., 0., 5.20833349e-003,
-       5.20833349e-003, 1.56250000e-002, 0., 1.56250000e-002,
-       1.56250000e-002, 5.20833349e-003, 5.20833349e-003,
-       5.20833349e-003, 0., 0., 0., 5.20833349e-003, 0., 0.,
-       5.20833349e-003, 0., 0., 0., 1.56250000e-002, 0., 0.,
-       1.04166670e-002, 0., 5.20833349e-003, 5.20833349e-003, 0., 0., 0.,
-       0., 0., 0., 1.04166670e-002, 0., 0., 0., 5.20833349e-003, 0., 0.,
-       0., 0., 5.20833349e-003, 5.20833349e-003, 0., 0., 0., 0., 0., 0.,
-       5.20833349e-003, 0., 0., 2.08333340e-002, 0., 0., 0.,
-       5.20833349e-003, 5.20833349e-003, 5.20833349e-003,
-       5.20833349e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.20833349e-003, 0., 0., 0., 0., 0., 0., 5.20833349e-003,
-       5.20833349e-003, 0., 5.20833349e-003, 0., 0., 1.56250000e-002, 0.,
-       5.20833349e-003, 5.20833349e-003, 1.56250000e-002,
-       5.20833349e-003, 0., 0., 0., 5.20833349e-003, 0., 0.,
-       5.20833349e-003, 0., 0., 0., 0., 5.20833349e-003, 0.,
-       5.20833349e-003, 5.20833349e-003, 0., 5.20833349e-003, 0.,
-       5.20833349e-003, 0., 0., 0., 5.20833349e-003, 0., 0.,
-       5.20833349e-003, 0., 0., 0., 0., 0., 0., 5.20833349e-003,
-       4.16666679e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.20833349e-003, 0., 0., 0.,
-       0., 1.56250000e-002, 0., 0., 0., 0., 1.04166670e-002, 0.,
-       5.20833349e-003, 0., 0., 5.20833349e-003, 0., 0., 0., 0., 0.,
-       5.20833349e-003, 0., 0., 0., 0., 0., 0., 5.20833349e-003, 0., 0.,
-       0., 0., 0., 0., 0., 5.20833349e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.20833349e-003, 0., 0., 0., 0., 0., 5.20833349e-003,
-       0., 0., 0., 0., 0., 0., 0., 5.20833349e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.20833349e-003, 0., 0., 0., 0.,
-       5.20833349e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.20833349e-003, 0., 0., 0., 5.20833349e-003,
-       0., 1.04166670e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.20833349e-003, 0., 0., 0., 0., 3.64583358e-002, 5.20833349e-003,
-       0., 0., 0., 1.04166670e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.04166670e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.56250000e-002, 0., 5.20833349e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.20833349e-003, 0., 5.20833349e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.04166670e-002, 0., 5.20833349e-003,
-       0., 0., 5.20833349e-003, 0., 0., 0., 5.20833349e-003, 0., 0., 0.,
-       0., 5.20833349e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.20833349e-003, 0., 0., 0., 5.20833349e-003, 0., 0., 0.,
-       0., 5.20833349e-003, 5.20833349e-003, 0., 5.20833349e-003, 0., 0.,
-       0., 5.20833349e-003, 0., 0., 1.04166670e-002, 0., 0., 0., 0., 0.,
-       0., 0., 5.20833349e-003, 0., 0., 0., 5.20833349e-003, 0., 0., 0.,
-       5.20833349e-003, 0., 1.04166670e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.20833349e-003,
-       1.04166670e-002, 5.20833349e-003, 1.04166670e-002, 0., 0.,
-       5.20833349e-003, 0., 0., 0., 2.08333340e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.20833349e-003,
-       0., 0., 5.20833349e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.20833349e-003, 0., 0., 0., 1.04166670e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.20833349e-003, 0., 0., 5.20833349e-003, 0., 5.20833349e-003,
-       5.20833349e-003, 0., 0., 0., 0., 0., 5.20833349e-003,
-       1.04166670e-002, 0., 0., 0., 0., 0., 0., 5.20833349e-003, 0., 0.,
-       0., 0., 0., 5.20833349e-003, 0., 1.08108111e-002, 5.40540554e-003,
-       1.62162166e-002, 0., 0., 0., 0., 0., 1.08108111e-002,
-       5.40540554e-003, 0., 0., 5.40540554e-003, 5.40540554e-003, 0., 0.,
-       5.40540554e-003, 5.40540554e-003, 5.40540554e-003, 0.,
-       1.08108111e-002, 1.08108111e-002, 1.08108111e-002,
-       5.40540554e-003, 0., 0., 5.40540554e-003, 5.40540554e-003,
-       5.40540554e-003, 0., 5.40540554e-003, 1.62162166e-002, 0., 0.,
-       1.08108111e-002, 0., 0., 0., 1.08108111e-002, 5.40540554e-003,
-       5.40540554e-003, 0., 5.40540554e-003, 0., 0., 5.40540554e-003, 0.,
-       1.62162166e-002, 1.62162166e-002, 0., 0., 0., 0., 0.,
-       5.40540554e-003, 1.62162166e-002, 5.40540554e-003, 0., 0., 0., 0.,
-       0., 1.08108111e-002, 5.40540554e-003, 0., 1.08108111e-002, 0.,
-       5.40540554e-003, 5.40540554e-003, 0., 0., 0., 0., 0.,
-       5.40540554e-003, 1.62162166e-002, 5.40540554e-003, 0., 0., 0., 0.,
-       0., 0., 0., 1.08108111e-002, 5.40540554e-003, 0., 0., 0., 0., 0.,
-       0., 1.08108111e-002, 0., 5.40540554e-003, 0., 0., 0., 0.,
-       2.16216221e-002, 5.40540554e-003, 0., 0., 5.40540554e-003, 0., 0.,
-       0., 0., 0., 0., 0., 5.40540554e-003, 5.40540554e-003,
-       1.62162166e-002, 5.40540554e-003, 0., 0., 5.40540554e-003,
-       1.08108111e-002, 0., 1.62162166e-002, 1.62162166e-002, 0., 0., 0.,
-       0., 1.08108111e-002, 5.40540554e-003, 0., 1.08108111e-002, 0.,
-       5.40540554e-003, 0., 1.08108111e-002, 0., 0., 0., 0.,
-       5.40540554e-003, 0., 0., 5.40540554e-003, 0., 0., 1.08108111e-002,
-       5.40540554e-003, 0., 0., 0., 5.40540554e-003, 0., 0., 0., 0.,
-       1.62162166e-002, 0., 0., 5.40540554e-003, 0., 0., 0., 0., 0., 0.,
-       0., 4.32432443e-002, 0., 0., 0., 0., 0., 0., 5.40540554e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.40540554e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.40540554e-003, 0., 0., 5.40540554e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.40540554e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.40540554e-003, 0., 0.,
-       5.40540554e-003, 0., 1.08108111e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.40540554e-003, 0., 0., 0., 0., 5.40540554e-003, 0.,
-       5.40540554e-003, 0., 0., 0., 0., 5.40540554e-003, 0.,
-       5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 2.16216221e-002, 5.40540554e-003, 0., 0., 0., 0.,
-       1.08108111e-002, 0., 0., 0., 0., 0., 0., 0., 0., 5.40540554e-003,
-       0., 0., 0., 5.40540554e-003, 1.08108111e-002, 5.40540554e-003,
-       5.40540554e-003, 0., 0., 0., 0., 0., 0., 5.40540554e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 2.16216221e-002, 0.,
-       5.40540554e-003, 0., 0., 5.40540554e-003, 0., 0., 0., 0., 0., 0.,
-       5.40540554e-003, 5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.40540554e-003, 0., 0., 0., 0., 1.62162166e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.08108111e-002, 0., 1.08108111e-002,
-       5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.40540554e-003, 5.40540554e-003, 0., 0., 0., 5.40540554e-003,
-       0., 0., 0., 5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.40540554e-003, 0., 0., 0.,
-       0., 5.40540554e-003, 0., 0., 5.40540554e-003, 5.40540554e-003,
-       5.40540554e-003, 0., 0., 5.40540554e-003, 0., 0., 1.08108111e-002,
-       0., 0., 0., 5.40540554e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0., 1.08108111e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.40540554e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.40540554e-003, 0., 0., 0., 5.40540554e-003, 0., 0.,
-       5.40540554e-003, 0., 0., 0., 0., 0., 0., 0., 5.40540554e-003, 0.,
-       0., 1.62162166e-002, 0., 5.40540554e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.89655170e-003, 0., 6.89655170e-003, 0., 6.89655170e-003, 0., 0.,
-       6.89655170e-003, 2.06896551e-002, 6.89655170e-003, 0.,
-       6.89655170e-003, 6.89655170e-003, 0., 0., 6.89655170e-003, 0.,
-       2.75862068e-002, 6.89655170e-003, 1.37931034e-002, 0., 0.,
-       1.37931034e-002, 0., 6.89655170e-003, 2.06896551e-002,
-       6.89655170e-003, 0., 1.37931034e-002, 6.89655170e-003, 0.,
-       6.89655170e-003, 0., 0., 0., 0., 0., 6.89655170e-003,
-       6.89655170e-003, 2.06896551e-002, 0., 0., 0., 0., 0.,
-       6.89655170e-003, 0., 0., 1.37931034e-002, 0., 0., 0., 0., 0.,
-       1.37931034e-002, 6.89655170e-003, 0., 0., 0., 0., 0., 0.,
-       6.89655170e-003, 0., 0., 1.37931034e-002, 0., 0., 0., 0.,
-       1.37931034e-002, 0., 0., 0., 0., 1.37931034e-002, 0., 0., 0., 0.,
-       0., 0., 6.89655170e-003, 0., 0., 0., 6.89655170e-003, 0., 0., 0.,
-       1.37931034e-002, 0., 0., 0., 0., 0., 6.89655170e-003, 0., 0.,
-       6.89655170e-003, 6.89655170e-003, 1.37931034e-002, 0., 0.,
-       1.37931034e-002, 0., 0., 0., 0., 0., 0., 6.89655170e-003, 0., 0.,
-       0., 0., 6.89655170e-003, 0., 6.89655170e-003, 6.89655170e-003,
-       6.89655170e-003, 0., 0., 0., 6.89655170e-003, 0., 0., 0.,
-       6.89655170e-003, 0., 2.75862068e-002, 6.89655170e-003, 0.,
-       1.37931034e-002, 0., 1.37931034e-002, 0., 0., 0., 0., 0.,
-       6.89655170e-003, 0., 0., 0., 6.89655170e-003, 0., 0., 0.,
-       6.89655170e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.89655170e-003, 6.89655170e-003, 0., 0., 0., 6.89655170e-003,
-       2.75862068e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.89655170e-003, 0., 0., 6.89655170e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.89655170e-003,
-       6.89655170e-003, 0., 0., 0., 0., 0., 6.89655170e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.37931034e-002, 0., 0., 0.,
-       0., 0., 6.89655170e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.89655170e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.89655170e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.89655170e-003, 6.89655170e-003, 0.,
-       0., 0., 2.06896551e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.89655170e-003,
-       6.89655170e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.89655170e-003, 0., 0., 0., 0., 0., 1.37931034e-002, 0.,
-       6.89655170e-003, 0., 0., 0., 0., 0., 0., 0., 6.89655170e-003, 0.,
-       6.89655170e-003, 2.06896551e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.89655170e-003, 0., 0., 0., 0., 6.89655170e-003, 0., 0., 0.,
-       1.37931034e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.89655170e-003, 0., 0., 0., 0., 0.,
-       1.37931034e-002, 0., 0., 0., 0., 2.06896551e-002, 0., 0., 0., 0.,
-       6.89655170e-003, 0., 0., 0., 0., 0., 0., 6.89655170e-003, 0., 0.,
-       6.89655170e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.89655170e-003, 0., 6.89655170e-003, 1.37931034e-002, 0., 0., 0.,
-       6.89655170e-003, 6.89655170e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.89655170e-003, 6.89655170e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.89655170e-003, 0., 0., 0., 0., 0., 0., 0., 2.06896551e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.37931034e-002, 0.,
-       0., 0., 6.89655170e-003, 0., 6.89655170e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.89655170e-003, 0., 6.89655170e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.89655170e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.89655170e-003, 0., 0., 0., 6.89655170e-003, 0., 0., 0.,
-       0., 0., 0., 0., 6.89655170e-003, 0., 0., 1.22699384e-002, 0., 0.,
-       0., 0., 6.13496918e-003, 0., 0., 0., 1.22699384e-002,
-       1.84049085e-002, 6.13496918e-003, 3.06748450e-002, 0., 0.,
-       1.22699384e-002, 0., 2.45398767e-002, 6.13496918e-003, 0., 0.,
-       6.13496918e-003, 1.22699384e-002, 0., 1.22699384e-002,
-       6.13496918e-003, 0., 0., 1.22699384e-002, 6.13496918e-003, 0.,
-       6.13496918e-003, 0., 1.22699384e-002, 1.22699384e-002,
-       1.22699384e-002, 0., 0., 6.13496918e-003, 1.22699384e-002, 0., 0.,
-       0., 0., 0., 3.06748450e-002, 0., 1.22699384e-002, 1.22699384e-002,
-       1.22699384e-002, 6.13496918e-003, 0., 0., 0., 6.13496918e-003, 0.,
-       0., 0., 6.13496918e-003, 0., 0., 0., 1.22699384e-002,
-       6.13496918e-003, 0., 0., 0., 0., 6.13496918e-003, 0.,
-       6.13496918e-003, 0., 6.13496918e-003, 0., 0., 6.13496918e-003, 0.,
-       0., 0., 0., 0., 0., 6.13496918e-003, 6.13496918e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.22699384e-002,
-       0., 6.13496918e-003, 0., 0., 6.13496918e-003, 0., 0., 0.,
-       1.22699384e-002, 1.22699384e-002, 0., 0., 0., 6.13496918e-003, 0.,
-       0., 0., 0., 6.13496918e-003, 0., 1.22699384e-002, 6.13496918e-003,
-       0., 0., 0., 0., 1.84049085e-002, 0., 6.13496918e-003, 0.,
-       4.29447852e-002, 0., 0., 0., 0., 0., 0., 0., 1.22699384e-002, 0.,
-       0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 1.22699384e-002,
-       6.13496918e-003, 0., 0., 0., 0., 1.22699384e-002, 0.,
-       6.13496918e-003, 0., 1.22699384e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.22699384e-002, 0., 0., 0.,
-       0., 1.22699384e-002, 0., 0., 6.13496918e-003, 0., 0.,
-       6.13496918e-003, 6.13496918e-003, 0., 0., 0., 6.13496918e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 1.22699384e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 1.22699384e-002, 0.,
-       0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 6.13496918e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 1.22699384e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.13496918e-003, 0., 0., 0., 6.13496918e-003, 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0.,
-       1.22699384e-002, 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0.,
-       1.22699384e-002, 0., 0., 0., 6.13496918e-003, 6.13496918e-003, 0.,
-       0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 6.13496918e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 6.13496918e-003, 0., 0., 0., 0., 0.,
-       1.22699384e-002, 0., 6.13496918e-003, 1.22699384e-002,
-       6.13496918e-003, 6.13496918e-003, 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 1.22699384e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.84049085e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 1.22699384e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 1.75438598e-002, 5.84795326e-003, 0., 0., 0., 0.,
-       0., 5.84795326e-003, 1.16959065e-002, 1.16959065e-002,
-       5.84795326e-003, 1.16959065e-002, 1.75438598e-002,
-       5.84795326e-003, 0., 5.84795326e-003, 5.84795326e-003, 0., 0., 0.,
-       0., 0., 5.84795326e-003, 0., 5.84795326e-003, 5.84795326e-003, 0.,
-       0., 3.50877196e-002, 0., 5.84795326e-003, 5.84795326e-003, 0.,
-       5.84795326e-003, 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0.,
-       0., 5.84795326e-003, 1.75438598e-002, 5.84795326e-003,
-       2.33918130e-002, 3.50877196e-002, 5.84795326e-003, 0., 0., 0., 0.,
-       5.84795326e-003, 1.75438598e-002, 0., 0., 5.84795326e-003,
-       5.84795326e-003, 0., 0., 0., 1.16959065e-002, 0., 0., 0., 0., 0.,
-       5.84795326e-003, 5.84795326e-003, 0., 0., 5.84795326e-003, 0.,
-       5.84795326e-003, 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0.,
-       5.84795326e-003, 1.16959065e-002, 1.16959065e-002, 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 5.84795326e-003, 0.,
-       5.84795326e-003, 1.16959065e-002, 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 1.75438598e-002, 5.84795326e-003, 0., 0.,
-       5.84795326e-003, 0., 1.16959065e-002, 0., 0., 0., 2.33918130e-002,
-       5.84795326e-003, 0., 5.84795326e-003, 0., 5.84795326e-003, 0.,
-       5.84795326e-003, 1.75438598e-002, 0., 0., 0., 0., 0., 0., 0.,
-       1.16959065e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.16959065e-002, 5.84795326e-003, 0., 0., 0., 5.84795326e-003,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0.,
-       5.84795326e-003, 5.84795326e-003, 2.33918130e-002, 0., 0., 0., 0.,
-       0., 0., 5.84795326e-003, 5.84795326e-003, 5.84795326e-003, 0., 0.,
-       0., 5.84795326e-003, 0., 5.84795326e-003, 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0.,
-       0., 1.16959065e-002, 5.84795326e-003, 0., 0., 5.84795326e-003, 0.,
-       0., 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 5.84795326e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0.,
-       0., 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 5.84795326e-003, 0., 0., 0., 5.84795326e-003,
-       5.84795326e-003, 1.16959065e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0.,
-       2.33918130e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003,
-       0., 0., 0., 0., 1.16959065e-002, 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 1.16959065e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 5.84795326e-003, 0., 0., 0.,
-       5.84795326e-003, 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 1.16959065e-002,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003,
-       5.84795326e-003, 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.84795326e-003, 0., 0., 5.84795326e-003, 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 5.84795326e-003, 0., 0., 0., 0.,
-       5.84795326e-003, 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003,
-       0., 0., 0., 0., 5.84795326e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.84795326e-003, 0., 1.16959065e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.16959065e-002, 0., 0., 0., 0., 0., 5.84795326e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.84795326e-003, 0., 0.,
-       0., 0., 0., 0., 0., 5.71428565e-003, 5.71428565e-003, 0., 0., 0.,
-       0., 0., 1.14285713e-002, 0., 5.71428565e-003, 5.71428565e-003,
-       5.71428565e-003, 1.14285713e-002, 1.14285713e-002, 0.,
-       5.71428565e-003, 0., 1.71428565e-002, 0., 1.14285713e-002,
-       5.71428565e-003, 1.14285713e-002, 0., 1.14285713e-002,
-       1.14285713e-002, 5.71428565e-003, 0., 0., 2.85714287e-002,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.14285713e-002, 5.71428565e-003, 0., 0., 0., 0., 1.14285713e-002,
-       0., 5.71428565e-003, 2.85714287e-002, 5.71428565e-003,
-       5.71428565e-003, 5.71428565e-003, 0., 0., 0., 5.71428565e-003, 0.,
-       0., 0., 5.71428565e-003, 0., 0., 5.71428565e-003, 0., 0., 0., 0.,
-       0., 0., 5.71428565e-003, 5.71428565e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.14285713e-002, 0., 5.71428565e-003, 0., 0.,
-       0., 0., 0., 0., 0., 5.71428565e-003, 0., 0., 1.14285713e-002, 0.,
-       0., 5.71428565e-003, 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0.,
-       0., 0., 1.71428565e-002, 0., 1.14285713e-002, 0., 0., 0., 0., 0.,
-       0., 0., 5.71428565e-003, 5.71428565e-003, 5.71428565e-003, 0., 0.,
-       1.14285713e-002, 0., 1.71428565e-002, 0., 0., 0., 3.42857130e-002,
-       0., 0., 1.14285713e-002, 0., 0., 5.71428565e-003, 0., 0., 0., 0.,
-       1.14285713e-002, 0., 5.71428565e-003, 1.71428565e-002,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 5.71428565e-003, 1.14285713e-002,
-       0., 0., 0., 0., 5.71428565e-003, 0., 1.14285713e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0.,
-       0., 5.71428565e-003, 0., 0., 0., 0., 0., 5.71428565e-003,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 0., 0., 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 2.28571426e-002, 0., 0., 5.71428565e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.71428565e-003, 0., 0., 0., 0., 1.14285713e-002,
-       5.71428565e-003, 0., 0., 0., 1.14285713e-002, 0., 1.14285713e-002,
-       5.71428565e-003, 0., 0., 1.14285713e-002, 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0.,
-       1.14285713e-002, 0., 0., 0., 0., 5.71428565e-003, 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.14285713e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 1.14285713e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.14285713e-002, 0., 0., 0., 0., 5.71428565e-003,
-       5.71428565e-003, 1.14285713e-002, 0., 0., 5.71428565e-003, 0., 0.,
-       0., 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.14285713e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.14285713e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 5.71428565e-003, 0., 0.,
-       0., 0., 1.71428565e-002, 0., 0., 5.71428565e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.14285713e-002, 0., 5.71428565e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0.,
-       5.71428565e-003, 0., 0., 0., 1.14285713e-002, 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 1.14285713e-002, 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 1.14285713e-002, 5.71428565e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.28571426e-002, 0., 0., 0., 5.71428565e-003, 5.71428565e-003, 0.,
-       5.71428565e-003, 5.71428565e-003, 1.14285713e-002, 0.,
-       1.14285713e-002, 0., 5.71428565e-003, 0., 5.71428565e-003,
-       1.14285713e-002, 5.71428565e-003, 5.71428565e-003,
-       5.71428565e-003, 5.71428565e-003, 5.71428565e-003,
-       5.71428565e-003, 5.71428565e-003, 0., 5.71428565e-003,
-       5.71428565e-003, 0., 0., 5.71428565e-003, 0., 5.71428565e-003, 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 5.71428565e-003,
-       1.14285713e-002, 5.71428565e-003, 1.14285713e-002, 0., 0., 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 1.14285713e-002,
-       2.28571426e-002, 0., 0., 5.71428565e-003, 0., 0., 0.,
-       1.14285713e-002, 0., 5.71428565e-003, 5.71428565e-003, 0., 0., 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 0., 0., 1.14285713e-002,
-       1.14285713e-002, 1.14285713e-002, 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 5.71428565e-003, 0.,
-       1.14285713e-002, 0., 0., 0., 5.71428565e-003, 0., 0., 0., 0.,
-       5.71428565e-003, 5.71428565e-003, 0., 0., 0., 0., 0.,
-       5.71428565e-003, 1.14285713e-002, 5.71428565e-003, 0.,
-       5.71428565e-003, 0., 0., 5.71428565e-003, 0., 0., 5.71428565e-003,
-       5.71428565e-003, 0., 0., 5.71428565e-003, 0., 1.14285713e-002,
-       5.71428565e-003, 0., 0., 1.71428565e-002, 5.71428565e-003, 0., 0.,
-       0., 5.71428565e-003, 1.14285713e-002, 0., 0., 0., 2.28571426e-002,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0.,
-       5.71428565e-003, 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 1.14285713e-002, 0., 0., 0., 0., 0.,
-       0., 0., 5.71428565e-003, 0., 5.71428565e-003, 5.71428565e-003, 0.,
-       0., 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 1.71428565e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.71428565e-003, 1.14285713e-002, 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 5.71428565e-003, 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 5.71428565e-003, 0., 0., 5.71428565e-003,
-       0., 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 5.71428565e-003, 0., 0., 5.71428565e-003, 0., 0.,
-       0., 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.71428565e-003, 0., 5.71428565e-003, 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 5.71428565e-003,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 1.14285713e-002, 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 1.71428565e-002, 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.14285713e-002, 0., 0., 0., 0., 1.14285713e-002, 1.14285713e-002,
-       0., 0., 5.71428565e-003, 0., 0., 1.14285713e-002, 0.,
-       5.71428565e-003, 5.71428565e-003, 0., 0., 1.14285713e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.71428565e-003, 5.71428565e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0.,
-       0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.71428565e-002, 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 1.71428565e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0., 5.71428565e-003,
-       0., 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0.,
-       5.71428565e-003, 0., 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.18134702e-003, 5.18134702e-003,
-       5.18134702e-003, 1.55440411e-002, 0., 5.18134702e-003, 0.,
-       1.03626940e-002, 0., 5.18134702e-003, 1.03626940e-002,
-       5.18134702e-003, 0., 1.03626940e-002, 0., 5.18134702e-003,
-       5.18134702e-003, 1.03626940e-002, 0., 0., 0., 0., 2.07253881e-002,
-       0., 1.03626940e-002, 0., 1.55440411e-002, 5.18134702e-003,
-       1.03626940e-002, 0., 5.18134702e-003, 1.03626940e-002, 0., 0., 0.,
-       1.03626940e-002, 0., 0., 5.18134702e-003, 2.59067342e-002, 0., 0.,
-       0., 5.18134702e-003, 0., 5.18134702e-003, 5.18134702e-003,
-       1.03626940e-002, 1.55440411e-002, 0., 5.18134702e-003, 0., 0., 0.,
-       0., 2.07253881e-002, 0., 0., 0., 1.03626940e-002, 0., 0., 0., 0.,
-       5.18134702e-003, 0., 0., 0., 5.18134702e-003, 0., 0., 0.,
-       5.18134702e-003, 0., 0., 0., 0., 0., 1.03626940e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.18134702e-003, 0., 0., 0., 0., 0., 0.,
-       1.03626940e-002, 0., 0., 0., 0., 1.03626940e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.03626940e-002, 0., 0., 0., 1.03626940e-002, 0.,
-       0., 5.18134702e-003, 5.18134702e-003, 0., 0., 5.18134702e-003, 0.,
-       0., 0., 0., 0., 3.10880821e-002, 0., 0., 5.18134702e-003,
-       4.66321222e-002, 0., 0., 1.03626940e-002, 0., 5.18134702e-003,
-       1.03626940e-002, 0., 2.07253881e-002, 0., 5.18134702e-003, 0., 0.,
-       0., 0., 1.55440411e-002, 0., 5.18134702e-003, 0., 1.03626940e-002,
-       0., 0., 5.18134702e-003, 0., 5.18134702e-003, 0., 0.,
-       5.18134702e-003, 0., 3.10880821e-002, 5.18134702e-003,
-       5.18134702e-003, 0., 5.18134702e-003, 5.18134702e-003,
-       5.18134702e-003, 5.18134702e-003, 1.55440411e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.18134702e-003, 0., 0., 0.,
-       0., 5.18134702e-003, 0., 0., 0., 0., 5.18134702e-003, 0., 0.,
-       5.18134702e-003, 0., 1.03626940e-002, 1.55440411e-002, 0., 0.,
-       5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 5.18134702e-003,
-       5.18134702e-003, 0., 0., 0., 5.18134702e-003, 0., 5.18134702e-003,
-       0., 5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.18134702e-003, 0., 0., 1.55440411e-002, 0., 0., 0., 0.,
-       0., 5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.18134702e-003,
-       0., 0., 2.59067342e-002, 0., 0., 0., 0., 0., 1.03626940e-002, 0.,
-       5.18134702e-003, 0., 0., 0., 5.18134702e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.18134702e-003, 0., 0., 0., 1.55440411e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.18134702e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.18134702e-003, 5.18134702e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.18134702e-003, 0., 5.18134702e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.18134702e-003, 0.,
-       5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.18134702e-003, 5.18134702e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.18134702e-003, 0., 0., 0., 0., 0., 0., 1.03626940e-002, 0., 0.,
-       0., 5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.18134702e-003, 0., 0., 5.18134702e-003, 0., 5.18134702e-003, 0.,
-       0., 0., 0., 0., 0., 5.18134702e-003, 0., 5.18134702e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.18134702e-003, 5.18134702e-003,
-       1.03626940e-002, 0., 5.18134702e-003, 0., 1.55440411e-002, 0., 0.,
-       0., 5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.03626940e-002, 0., 0., 0., 0., 0., 0., 0., 0., 5.18134702e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.18134702e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.18134702e-003, 0., 0., 5.18134702e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.18134702e-003, 0., 0., 0., 0., 0., 0., 0., 2.28571426e-002,
-       5.71428565e-003, 5.71428565e-003, 5.71428565e-003, 0.,
-       1.71428565e-002, 0., 0., 1.71428565e-002, 0., 5.71428565e-003,
-       1.14285713e-002, 0., 0., 5.71428565e-003, 0., 0., 5.71428565e-003,
-       1.14285713e-002, 0., 0., 0., 2.28571426e-002, 5.71428565e-003,
-       5.71428565e-003, 5.71428565e-003, 1.14285713e-002, 0.,
-       2.28571426e-002, 5.71428565e-003, 1.14285713e-002,
-       5.71428565e-003, 5.71428565e-003, 0., 0., 1.14285713e-002, 0.,
-       5.71428565e-003, 5.71428565e-003, 1.14285713e-002, 0., 0., 0.,
-       5.71428565e-003, 5.71428565e-003, 1.14285713e-002, 0., 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 1.14285713e-002, 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 5.71428565e-003, 0., 0.,
-       0., 0., 0., 0., 1.14285713e-002, 0., 0., 0., 5.71428565e-003,
-       5.71428565e-003, 5.71428565e-003, 0., 0., 0., 5.71428565e-003, 0.,
-       0., 0., 0., 0., 0., 0., 1.14285713e-002, 5.71428565e-003,
-       5.71428565e-003, 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.71428565e-003, 5.71428565e-003, 0., 0.,
-       1.71428565e-002, 0., 0., 0., 0., 1.14285713e-002, 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 1.14285713e-002, 0.,
-       0., 5.71428565e-003, 0., 2.28571426e-002, 0., 0., 5.71428565e-003,
-       3.42857130e-002, 0., 0., 5.71428565e-003, 0., 5.71428565e-003,
-       1.14285713e-002, 0., 0., 0., 0., 5.71428565e-003, 0.,
-       1.14285713e-002, 0., 5.71428565e-003, 0., 5.71428565e-003,
-       5.71428565e-003, 5.71428565e-003, 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 1.14285713e-002,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.71428565e-003, 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0.,
-       0., 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.71428565e-003, 0., 0., 0., 5.71428565e-003, 0.,
-       5.71428565e-003, 5.71428565e-003, 0., 5.71428565e-003, 0.,
-       5.71428565e-003, 0., 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0.,
-       0., 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 2.28571426e-002, 0., 5.71428565e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.14285713e-002, 5.71428565e-003, 0., 0., 5.71428565e-003,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.14285713e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 1.14285713e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0.,
-       0., 5.71428565e-003, 0., 0., 0., 5.71428565e-003, 0., 0., 0., 0.,
-       0., 0., 1.14285713e-002, 0., 5.71428565e-003, 0., 5.71428565e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0.,
-       1.14285713e-002, 0., 0., 0., 0., 0., 1.14285713e-002, 0., 0., 0.,
-       0., 5.71428565e-003, 1.14285713e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0.,
-       5.71428565e-003, 5.71428565e-003, 0., 0., 5.71428565e-003, 0.,
-       1.14285713e-002, 0., 5.71428565e-003, 5.71428565e-003, 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 5.71428565e-003, 0., 0., 0.,
-       1.14285713e-002, 0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.14285713e-002, 0., 5.71428565e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.14285713e-002, 0.,
-       5.71428565e-003, 0., 0., 0., 5.71428565e-003, 5.71428565e-003, 0.,
-       0., 0., 0., 0., 0., 5.71428565e-003, 0., 5.71428565e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.37634408e-003, 0., 1.07526882e-002, 0., 1.07526882e-002,
-       1.61290318e-002, 0., 5.37634408e-003, 0., 0., 0., 0.,
-       1.07526882e-002, 5.37634408e-003, 5.37634408e-003,
-       1.07526882e-002, 0., 4.30107526e-002, 1.07526882e-002,
-       5.37634408e-003, 0., 0., 2.15053763e-002, 5.37634408e-003,
-       1.07526882e-002, 5.37634408e-003, 5.37634408e-003, 0.,
-       2.15053763e-002, 5.37634408e-003, 0., 1.07526882e-002, 0., 0.,
-       1.07526882e-002, 0., 5.37634408e-003, 0., 1.07526882e-002,
-       2.15053763e-002, 0., 0., 0., 0., 0., 5.37634408e-003, 0.,
-       1.07526882e-002, 1.07526882e-002, 5.37634408e-003, 0.,
-       5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 5.37634408e-003, 0.,
-       0., 0., 1.07526882e-002, 5.37634408e-003, 0., 0., 0.,
-       5.37634408e-003, 0., 0., 5.37634408e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.37634408e-003, 0., 1.61290318e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.07526882e-002,
-       5.37634408e-003, 5.37634408e-003, 0., 0., 5.37634408e-003, 0., 0.,
-       5.37634408e-003, 0., 5.37634408e-003, 0., 5.37634408e-003,
-       1.61290318e-002, 0., 0., 0., 0., 0., 5.37634408e-003, 0.,
-       5.37634408e-003, 0., 0., 0., 0., 5.37634408e-003, 1.61290318e-002,
-       0., 0., 0., 2.68817209e-002, 0., 0., 0., 0., 0., 0., 0.,
-       1.61290318e-002, 0., 0., 0., 0., 0., 0., 5.37634408e-003,
-       5.37634408e-003, 0., 0., 1.07526882e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.61290318e-002, 5.37634408e-003, 0., 0., 0., 0.,
-       1.61290318e-002, 0., 0., 0., 5.37634408e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 2.15053763e-002, 0., 5.37634408e-003, 0.,
-       5.37634408e-003, 0., 0., 1.07526882e-002, 0., 0., 5.37634408e-003,
-       0., 0., 0., 0., 0., 0., 5.37634408e-003, 0., 0., 0., 0.,
-       5.37634408e-003, 0., 0., 0., 5.37634408e-003, 5.37634408e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.37634408e-003, 0., 0., 0., 0.,
-       0., 0., 0., 5.37634408e-003, 0., 0., 0., 0., 5.37634408e-003, 0.,
-       0., 0., 0., 0., 0., 5.37634408e-003, 0., 5.37634408e-003, 0., 0.,
-       1.07526882e-002, 0., 0., 0., 0., 0., 0., 0., 0., 5.37634408e-003,
-       0., 0., 0., 0., 0., 0., 0., 5.37634408e-003, 0., 0., 0., 0.,
-       5.37634408e-003, 5.37634408e-003, 0., 0., 0., 2.15053763e-002,
-       5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.37634408e-003, 5.37634408e-003, 5.37634408e-003, 0., 0., 0.,
-       1.61290318e-002, 0., 0., 0., 1.61290318e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.37634408e-003, 0., 0.,
-       5.37634408e-003, 0., 0., 0., 0., 0., 0., 5.37634408e-003, 0.,
-       1.07526882e-002, 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.07526882e-002, 0., 5.37634408e-003, 0., 5.37634408e-003,
-       1.61290318e-002, 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.37634408e-003, 5.37634408e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.37634408e-003, 0., 0., 0., 0., 5.37634408e-003,
-       1.07526882e-002, 0., 0., 1.07526882e-002, 0., 0., 0., 0.,
-       5.37634408e-003, 0., 5.37634408e-003, 5.37634408e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.37634408e-003, 5.37634408e-003, 0.,
-       5.37634408e-003, 0., 0., 0., 0., 0., 5.37634408e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.07526882e-002, 0., 0., 0., 0., 0.,
-       5.37634408e-003, 0., 0., 0., 0., 0., 1.07526882e-002,
-       5.37634408e-003, 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.37634408e-003,
-       0., 0., 5.37634408e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 2.05479451e-002, 0., 6.84931502e-003, 6.84931502e-003, 0.,
-       6.84931502e-003, 0., 6.84931502e-003, 6.84931502e-003,
-       6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 1.36986300e-002,
-       6.84931502e-003, 0., 6.84931502e-003, 1.36986300e-002,
-       2.05479451e-002, 6.84931502e-003, 0., 6.84931502e-003,
-       1.36986300e-002, 0., 2.05479451e-002, 0., 0., 6.84931502e-003, 0.,
-       6.84931502e-003, 0., 0., 0., 0., 6.84931502e-003, 1.36986300e-002,
-       0., 0., 0., 0., 0., 0., 2.05479451e-002, 0., 2.05479451e-002, 0.,
-       0., 0., 0., 0., 0., 6.84931502e-003, 0., 0., 0., 6.84931502e-003,
-       0., 0., 6.84931502e-003, 0., 6.84931502e-003, 6.84931502e-003, 0.,
-       0., 0., 6.84931502e-003, 6.84931502e-003, 0., 6.84931502e-003, 0.,
-       0., 6.84931502e-003, 6.84931502e-003, 0., 6.84931502e-003, 0., 0.,
-       0., 0., 0., 1.36986300e-002, 0., 0., 0., 0., 0., 6.84931502e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.84931502e-003, 0., 0.,
-       0., 0., 0., 0., 0., 6.84931502e-003, 0., 1.36986300e-002, 0.,
-       6.84931502e-003, 0., 0., 0., 0., 0., 0., 1.36986300e-002,
-       6.84931502e-003, 0., 0., 0., 0., 4.10958901e-002, 0., 0., 0.,
-       2.73972601e-002, 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.36986300e-002, 6.84931502e-003, 0., 0., 0., 0.,
-       6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 6.84931502e-003, 0.,
-       6.84931502e-003, 0., 0., 0., 0., 0., 1.36986300e-002, 0., 0., 0.,
-       1.36986300e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.84931502e-003, 0., 1.36986300e-002,
-       0., 0., 0., 0., 0., 6.84931502e-003, 0., 0., 6.84931502e-003,
-       6.84931502e-003, 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.36986300e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.84931502e-003, 0., 0., 0., 0.,
-       3.42465751e-002, 6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.84931502e-003, 0., 0., 0., 1.36986300e-002, 0., 0., 0., 0.,
-       0., 6.84931502e-003, 6.84931502e-003, 0., 6.84931502e-003, 0., 0.,
-       0., 0., 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 6.84931502e-003,
-       0., 6.84931502e-003, 0., 0., 0., 6.84931502e-003, 0.,
-       6.84931502e-003, 0., 6.84931502e-003, 0., 0., 0., 0., 0.,
-       6.84931502e-003, 0., 0., 0., 1.36986300e-002, 2.05479451e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.84931502e-003, 6.84931502e-003, 0., 0., 0., 0., 0.,
-       6.84931502e-003, 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.84931502e-003, 0., 0., 0.,
-       6.84931502e-003, 6.84931502e-003, 0., 0., 0., 0., 6.84931502e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.84931502e-003, 0., 0., 0.,
-       6.84931502e-003, 6.84931502e-003, 0., 6.84931502e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.36986300e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.36986300e-002,
-       6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.84931502e-003, 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.84931502e-003, 0., 0., 0., 6.84931502e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.84931502e-003, 1.36986300e-002, 0., 0., 0.,
-       0., 0., 0., 0., 6.84931502e-003, 0., 0., 0., 0., 6.84931502e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.84931502e-003, 0.,
-       0., 0., 0., 0., 0., 6.84931502e-003, 0., 0., 0., 0., 0., 0.,
-       6.84931502e-003, 0., 0., 6.84931502e-003, 0., 0., 0.,
-       6.84931502e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.10497242e-002, 1.10497242e-002, 0., 0.,
-       5.52486209e-003, 0., 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0.,
-       0., 1.10497242e-002, 0., 5.52486209e-003, 5.52486209e-003, 0.,
-       1.10497242e-002, 0., 2.20994484e-002, 0., 0., 0., 0.,
-       5.52486209e-003, 5.52486209e-003, 5.52486209e-003, 0.,
-       1.10497242e-002, 0., 0., 1.10497242e-002, 5.52486209e-003, 0.,
-       5.52486209e-003, 1.65745858e-002, 5.52486209e-003, 0.,
-       5.52486209e-003, 0., 1.10497242e-002, 0., 0., 0., 1.10497242e-002,
-       4.41988967e-002, 0., 0., 0., 0., 0., 5.52486209e-003,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 5.52486209e-003,
-       5.52486209e-003, 0., 0., 0., 5.52486209e-003, 0., 5.52486209e-003,
-       1.10497242e-002, 0., 5.52486209e-003, 1.10497242e-002, 0., 0.,
-       5.52486209e-003, 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.52486209e-003, 5.52486209e-003, 0.,
-       5.52486209e-003, 5.52486209e-003, 0., 0., 1.10497242e-002, 0., 0.,
-       0., 1.10497242e-002, 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 5.52486209e-003,
-       1.10497242e-002, 0., 0., 0., 5.52486209e-003, 2.20994484e-002, 0.,
-       0., 1.10497242e-002, 3.86740342e-002, 1.65745858e-002, 0., 0., 0.,
-       0., 0., 5.52486209e-003, 2.76243109e-002, 0., 0., 0., 0.,
-       5.52486209e-003, 1.10497242e-002, 0., 0., 0., 0., 0.,
-       1.65745858e-002, 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0.,
-       5.52486209e-003, 0., 0., 0., 0., 5.52486209e-003, 1.10497242e-002,
-       0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.52486209e-003, 1.10497242e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 5.52486209e-003, 0.,
-       0., 0., 0., 5.52486209e-003, 0., 0., 0., 5.52486209e-003, 0., 0.,
-       5.52486209e-003, 0., 0., 5.52486209e-003, 0., 0., 5.52486209e-003,
-       0., 5.52486209e-003, 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.52486209e-003, 5.52486209e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.10497242e-002, 0., 0., 0., 5.52486209e-003, 0., 0.,
-       0., 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 5.52486209e-003,
-       0., 0., 0., 0., 0., 0., 2.20994484e-002, 0., 0., 0., 0.,
-       1.10497242e-002, 5.52486209e-003, 5.52486209e-003, 0., 0., 0., 0.,
-       0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 1.10497242e-002,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 1.10497242e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.52486209e-003,
-       5.52486209e-003, 0., 0., 1.65745858e-002, 0., 5.52486209e-003, 0.,
-       0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0., 0., 0.,
-       5.52486209e-003, 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 1.10497242e-002, 1.10497242e-002, 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0.,
-       1.10497242e-002, 0., 0., 0., 1.65745858e-002, 0., 0., 0.,
-       5.52486209e-003, 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0.,
-       5.52486209e-003, 5.52486209e-003, 0., 5.52486209e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.52486209e-003, 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.10497242e-002, 0., 0., 0., 0., 1.65745858e-002, 0., 0., 0., 0.,
-       0., 0., 5.52486209e-003, 0., 0., 5.52486209e-003, 0., 0., 0., 0.,
-       0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.52486209e-003, 0., 0., 0., 0., 0., 0., 8.69565178e-003,
-       0., 0., 8.69565178e-003, 0., 0., 8.69565178e-003, 1.73913036e-002,
-       8.69565178e-003, 8.69565178e-003, 2.60869563e-002, 0., 0.,
-       8.69565178e-003, 0., 0., 1.73913036e-002, 2.60869563e-002, 0., 0.,
-       0., 8.69565178e-003, 0., 8.69565178e-003, 0., 2.60869563e-002,
-       1.73913036e-002, 0., 0., 8.69565178e-003, 0., 0., 0.,
-       2.60869563e-002, 0., 0., 0., 0., 0., 0., 0., 0., 8.69565178e-003,
-       0., 8.69565178e-003, 8.69565178e-003, 0., 0., 0., 0.,
-       8.69565178e-003, 0., 0., 8.69565178e-003, 0., 0., 8.69565178e-003,
-       0., 0., 1.73913036e-002, 8.69565178e-003, 0., 8.69565178e-003, 0.,
-       0., 8.69565178e-003, 0., 0., 8.69565178e-003, 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 8.69565178e-003, 0.,
-       0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 0., 8.69565178e-003,
-       0., 0., 0., 2.60869563e-002, 0., 0., 0., 8.69565178e-003,
-       8.69565178e-003, 8.69565178e-003, 0., 0., 0., 0., 0., 0., 0.,
-       8.69565178e-003, 0., 0., 8.69565178e-003, 0., 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 8.69565178e-003, 8.69565178e-003,
-       0., 0., 0., 5.21739125e-002, 0., 0., 0., 8.69565178e-003, 0., 0.,
-       0., 8.69565178e-003, 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 0., 4.34782580e-002, 0., 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.73913036e-002, 8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 3.47826071e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.69565178e-003, 0., 0., 0., 0., 0.,
-       1.73913036e-002, 0., 0., 0., 8.69565178e-003, 0., 8.69565178e-003,
-       0., 0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 8.69565178e-003, 8.69565178e-003,
-       0., 0., 0., 0., 8.69565178e-003, 0., 0., 0., 0., 1.73913036e-002,
-       0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 0., 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 0., 8.69565178e-003,
-       8.69565178e-003, 0., 0., 0., 8.69565178e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.69565178e-003, 0., 0., 0., 0., 0., 8.69565178e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 8.69565178e-003,
-       0., 8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 0., 0., 0., 0.,
-       0., 8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.69565178e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.69565178e-003, 8.69565178e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.69565178e-003,
-       0., 0., 0., 0., 0., 1.73913036e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.69565178e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.69565178e-003, 8.69565178e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.69565178e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 1.63043477e-002,
-       0., 0., 0., 1.08695654e-002, 0., 0., 5.43478271e-003,
-       1.08695654e-002, 5.43478271e-003, 1.08695654e-002,
-       1.63043477e-002, 5.43478271e-003, 5.43478271e-003,
-       1.08695654e-002, 0., 0., 5.43478271e-003, 5.43478271e-003, 0.,
-       1.08695654e-002, 1.08695654e-002, 1.08695654e-002, 0., 0.,
-       5.43478271e-003, 5.43478271e-003, 5.43478271e-003,
-       5.43478271e-003, 0., 5.43478271e-003, 0., 1.08695654e-002, 0.,
-       1.08695654e-002, 0., 0., 5.43478271e-003, 5.43478271e-003,
-       1.08695654e-002, 0., 0., 5.43478271e-003, 0., 5.43478271e-003,
-       1.08695654e-002, 1.63043477e-002, 2.71739140e-002, 0., 0.,
-       5.43478271e-003, 0., 5.43478271e-003, 0., 1.08695654e-002, 0., 0.,
-       0., 0., 0., 0., 5.43478271e-003, 0., 1.08695654e-002,
-       5.43478271e-003, 0., 0., 0., 5.43478271e-003, 5.43478271e-003, 0.,
-       0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 1.08695654e-002, 0.,
-       0., 0., 0., 0., 5.43478271e-003, 0., 0., 5.43478271e-003,
-       1.08695654e-002, 1.08695654e-002, 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 1.63043477e-002, 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.08695654e-002, 0., 0., 5.43478271e-003, 2.17391308e-002,
-       1.63043477e-002, 0., 0., 0., 1.08695654e-002, 5.43478271e-003, 0.,
-       0., 0., 0., 5.43478271e-003, 0., 5.43478271e-003, 1.08695654e-002,
-       0., 0., 5.43478271e-003, 0., 5.43478271e-003, 5.43478271e-003, 0.,
-       0., 0., 0., 0., 0., 5.43478271e-003, 0., 1.08695654e-002, 0.,
-       5.43478271e-003, 0., 0., 5.43478271e-003, 5.43478271e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0.,
-       5.43478271e-003, 0., 0., 1.08695654e-002, 0., 0., 5.43478271e-003,
-       0., 0., 5.43478271e-003, 5.43478271e-003, 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0.,
-       0., 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 5.43478271e-003,
-       0., 0., 0., 0., 0., 1.08695654e-002, 5.43478271e-003, 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.43478271e-003, 5.43478271e-003, 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0.,
-       0., 0., 0., 0., 5.43478271e-003, 0., 0., 1.08695654e-002, 0., 0.,
-       1.08695654e-002, 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0.,
-       5.43478271e-003, 0., 0., 1.08695654e-002, 0., 0., 1.08695654e-002,
-       0., 0., 0., 0., 5.43478271e-003, 1.63043477e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.43478271e-003, 0., 0., 5.43478271e-003, 0.,
-       5.43478271e-003, 0., 1.63043477e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.43478271e-003, 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.08695654e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 1.08695654e-002, 0., 0.,
-       1.08695654e-002, 0., 0., 0., 0., 5.43478271e-003, 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 5.43478271e-003,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0., 5.43478271e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0.,
-       1.08695654e-002, 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0.,
-       5.43478271e-003, 5.43478271e-003, 0., 0., 0., 5.43478271e-003,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.08695654e-002, 0., 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0.,
-       0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.43478271e-003, 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.43478271e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.43478271e-003, 0., 0., 0., 0., 0., 0., 5.43478271e-003, 0., 0.,
-       0., 0., 0., 5.43478271e-003, 0., 0., 5.91715984e-003,
-       1.18343197e-002, 0., 0., 0., 1.18343197e-002, 0., 0.,
-       5.91715984e-003, 0., 0., 0., 2.36686394e-002, 0., 0.,
-       5.91715984e-003, 0., 0., 5.91715984e-003, 5.91715984e-003,
-       5.91715984e-003, 1.18343197e-002, 4.14201170e-002,
-       1.77514795e-002, 5.91715984e-003, 5.91715984e-003, 0., 0.,
-       2.36686394e-002, 5.91715984e-003, 5.91715984e-003,
-       1.18343197e-002, 5.91715984e-003, 5.91715984e-003, 0., 0.,
-       5.91715984e-003, 5.91715984e-003, 0., 5.91715984e-003, 0., 0., 0.,
-       5.91715984e-003, 0., 1.18343197e-002, 0., 1.18343197e-002,
-       1.18343197e-002, 5.91715984e-003, 0., 1.77514795e-002, 0., 0.,
-       1.18343197e-002, 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.18343197e-002, 1.18343197e-002, 5.91715984e-003, 0., 0., 0., 0.,
-       1.18343197e-002, 0., 0., 0., 0., 5.91715984e-003, 0., 0.,
-       1.18343197e-002, 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.91715984e-003, 5.91715984e-003, 0., 1.18343197e-002,
-       0., 5.91715984e-003, 0., 0., 2.36686394e-002, 0., 1.77514795e-002,
-       0., 0., 5.91715984e-003, 0., 0., 0., 5.91715984e-003, 0., 0.,
-       5.91715984e-003, 0., 5.91715984e-003, 0., 5.91715984e-003, 0., 0.,
-       0., 5.91715984e-003, 1.77514795e-002, 0., 0., 0., 0., 0.,
-       2.36686394e-002, 0., 0., 0., 1.77514795e-002, 0., 0., 0., 0., 0.,
-       1.18343197e-002, 0., 5.91715984e-003, 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 1.18343197e-002, 0., 0., 5.91715984e-003, 0.,
-       5.91715984e-003, 0., 0., 0., 5.91715984e-003, 0., 5.91715984e-003,
-       0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 5.91715984e-003, 0., 5.91715984e-003,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 5.91715984e-003, 5.91715984e-003,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.95857992e-002, 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.91715984e-003, 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0.,
-       1.77514795e-002, 0., 5.91715984e-003, 5.91715984e-003, 0., 0., 0.,
-       0., 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.18343197e-002, 0., 0., 5.91715984e-003, 1.77514795e-002,
-       1.18343197e-002, 0., 0., 0., 1.77514795e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.91715984e-003, 5.91715984e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 5.91715984e-003, 5.91715984e-003, 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0.,
-       0., 5.91715984e-003, 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 1.18343197e-002, 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 5.91715984e-003, 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 5.91715984e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 5.91715984e-003, 0., 5.91715984e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.91715984e-003, 0., 0., 0., 5.91715984e-003, 0., 0., 0., 0., 0.,
-       0., 5.91715984e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       3.44827585e-002, 8.62068962e-003, 0., 8.62068962e-003, 0., 0., 0.,
-       8.62068962e-003, 8.62068962e-003, 8.62068962e-003, 0.,
-       8.62068962e-003, 8.62068962e-003, 0., 0., 2.58620679e-002, 0., 0.,
-       0., 0., 0., 0., 8.62068962e-003, 8.62068962e-003, 8.62068962e-003,
-       0., 8.62068962e-003, 0., 0., 0., 1.72413792e-002, 8.62068962e-003,
-       0., 8.62068962e-003, 8.62068962e-003, 8.62068962e-003, 0., 0.,
-       8.62068962e-003, 0., 1.72413792e-002, 0., 0., 8.62068962e-003, 0.,
-       0., 8.62068962e-003, 8.62068962e-003, 1.72413792e-002, 0., 0., 0.,
-       0., 0., 8.62068962e-003, 2.58620679e-002, 0., 0., 0.,
-       8.62068962e-003, 0., 0., 8.62068962e-003, 0., 8.62068962e-003,
-       8.62068962e-003, 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 8.62068962e-003,
-       0., 0., 0., 0., 0., 8.62068962e-003, 0., 8.62068962e-003, 0., 0.,
-       0., 0., 0., 0., 8.62068962e-003, 0., 8.62068962e-003, 0., 0.,
-       8.62068962e-003, 0., 0., 0., 8.62068962e-003, 0., 0.,
-       8.62068962e-003, 8.62068962e-003, 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 0., 8.62068962e-003, 0., 0., 0.,
-       8.62068962e-003, 3.44827585e-002, 0., 0., 0., 1.72413792e-002,
-       8.62068962e-003, 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 8.62068962e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 3.44827585e-002, 0., 0., 0., 8.62068962e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.62068962e-003, 0., 0., 1.72413792e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.72413792e-002, 0., 0.,
-       1.72413792e-002, 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 1.72413792e-002, 8.62068962e-003, 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.72413792e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 8.62068962e-003, 0., 0., 8.62068962e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0.,
-       8.62068962e-003, 0., 0., 8.62068962e-003, 0., 0., 1.72413792e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 8.62068962e-003, 0.,
-       1.72413792e-002, 0., 0., 8.62068962e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.72413792e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.62068962e-003, 0., 0., 0., 0.,
-       0., 0., 8.62068962e-003, 0., 0., 8.62068962e-003, 0., 0., 0., 0.,
-       0., 8.62068962e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.62068962e-003, 8.62068962e-003, 8.62068962e-003, 0., 0., 0., 0.,
-       7.19424477e-003, 7.19424477e-003, 1.43884895e-002,
-       2.15827338e-002, 7.19424477e-003, 1.43884895e-002, 0.,
-       7.19424477e-003, 1.43884895e-002, 1.43884895e-002,
-       1.43884895e-002, 0., 0., 7.19424477e-003, 0., 1.43884895e-002, 0.,
-       1.43884895e-002, 7.19424477e-003, 7.19424477e-003,
-       7.19424477e-003, 0., 7.19424477e-003, 0., 0., 0., 0., 0.,
-       1.43884895e-002, 0., 0., 2.15827338e-002, 0., 7.19424477e-003, 0.,
-       1.43884895e-002, 0., 7.19424477e-003, 7.19424477e-003, 0., 0., 0.,
-       0., 7.19424477e-003, 0., 7.19424477e-003, 0., 0., 2.87769791e-002,
-       7.19424477e-003, 0., 7.19424477e-003, 0., 0., 1.43884895e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.43884895e-002, 7.19424477e-003, 0.,
-       0., 0., 1.43884895e-002, 0., 1.43884895e-002, 0., 0., 0.,
-       7.19424477e-003, 0., 0., 7.19424477e-003, 7.19424477e-003, 0., 0.,
-       0., 7.19424477e-003, 0., 0., 0., 0., 0., 0., 0., 7.19424477e-003,
-       0., 0., 0., 7.19424477e-003, 0., 7.19424477e-003, 0.,
-       7.19424477e-003, 7.19424477e-003, 0., 0., 0., 0., 7.19424477e-003,
-       1.43884895e-002, 0., 7.19424477e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.19424477e-003, 0.,
-       2.87769791e-002, 0., 0., 0., 2.15827338e-002, 0., 0., 0., 0.,
-       7.19424477e-003, 0., 0., 7.19424477e-003, 0., 0., 0., 0., 0.,
-       7.19424477e-003, 0., 7.19424477e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.43884895e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.19424477e-003, 0., 0., 0., 0., 0., 0., 0., 7.19424477e-003, 0.,
-       7.19424477e-003, 0., 0., 7.19424477e-003, 0., 0., 0.,
-       7.19424477e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.19424477e-003, 0., 0., 0., 7.19424477e-003, 0., 0., 0., 0., 0.,
-       7.19424477e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.19424477e-003, 0., 0., 0., 0., 0., 0., 7.19424477e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.19424477e-003, 0., 0., 0., 0., 7.19424477e-003, 0.,
-       0., 0., 7.19424477e-003, 7.19424477e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.19424477e-003, 0., 0., 0., 0., 0., 0., 7.19424477e-003,
-       0., 0., 0., 0., 0., 0., 1.43884895e-002, 0., 0., 7.19424477e-003,
-       0., 0., 7.19424477e-003, 0., 0., 0., 0., 0., 7.19424477e-003, 0.,
-       0., 0., 7.19424477e-003, 0., 0., 0., 0., 7.19424477e-003, 0., 0.,
-       7.19424477e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.19424477e-003, 0., 0., 0., 0., 0., 0., 7.19424477e-003, 0., 0.,
-       7.19424477e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.19424477e-003, 0., 0., 1.43884895e-002, 0., 0., 7.19424477e-003,
-       0., 0., 0., 7.19424477e-003, 0., 1.43884895e-002, 0., 0.,
-       7.19424477e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.19424477e-003, 0., 7.19424477e-003, 0., 0., 0., 7.19424477e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.19424477e-003, 0., 0.,
-       0., 7.19424477e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.19424477e-003, 0., 0., 0., 0.,
-       0., 1.43884895e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.19424477e-003, 0., 0.,
-       0., 0., 0., 7.19424477e-003, 0., 7.19424477e-003, 0., 0., 0.,
-       7.19424477e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.19424477e-003, 0., 0., 0., 0., 0., 0., 0., 7.19424477e-003, 0.,
-       7.19424477e-003, 0., 7.19424477e-003, 0., 0., 0., 1.43884895e-002,
-       0., 7.19424477e-003, 0., 7.19424477e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.43884895e-002, 0., 0., 0., 7.19424477e-003, 0.,
-       7.19424477e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.00000038e-003, 0., 0., 8.00000038e-003,
-       8.00000038e-003, 0., 0., 8.00000038e-003, 0., 0., 0.,
-       8.00000038e-003, 2.40000002e-002, 0., 0., 1.60000008e-002, 0.,
-       1.60000008e-002, 0., 0., 1.60000008e-002, 0., 4.00000028e-002,
-       8.00000038e-003, 8.00000038e-003, 0., 1.60000008e-002, 0., 0.,
-       8.00000038e-003, 0., 2.40000002e-002, 0., 8.00000038e-003,
-       8.00000038e-003, 8.00000038e-003, 0., 0., 8.00000038e-003, 0., 0.,
-       0., 1.60000008e-002, 8.00000038e-003, 0., 0., 8.00000038e-003,
-       8.00000038e-003, 8.00000038e-003, 0., 0., 1.60000008e-002, 0.,
-       8.00000038e-003, 0., 8.00000038e-003, 0., 0., 0., 0., 0., 0.,
-       8.00000038e-003, 2.40000002e-002, 8.00000038e-003, 0., 0., 0., 0.,
-       8.00000038e-003, 1.60000008e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.00000038e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.00000038e-003,
-       8.00000038e-003, 0., 0., 0., 8.00000038e-003, 0., 0.,
-       8.00000038e-003, 0., 0., 0., 8.00000038e-003, 0., 1.60000008e-002,
-       0., 1.60000008e-002, 0., 0., 0., 8.00000038e-003, 0.,
-       4.80000004e-002, 0., 0., 0., 1.60000008e-002, 1.60000008e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.00000038e-003, 0.,
-       8.00000038e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.00000038e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.00000038e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.00000038e-003, 0., 0., 0., 0.,
-       8.00000038e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.00000038e-003, 0., 0., 0., 8.00000038e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 4.00000028e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.00000038e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.00000038e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.00000038e-003, 0., 0., 8.00000038e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.60000008e-002, 0., 0., 8.00000038e-003,
-       1.60000008e-002, 0., 0., 0., 8.00000038e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.60000008e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.00000038e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.00000038e-003, 0., 0., 0., 8.00000038e-003, 1.60000008e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.00000038e-003, 0., 8.00000038e-003, 0., 0., 8.00000038e-003,
-       8.00000038e-003, 0., 0., 0., 0., 8.00000038e-003, 0., 0., 0., 0.,
-       0., 0., 8.00000038e-003, 0., 8.00000038e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.00000038e-003, 0., 0., 0., 0., 0., 8.00000038e-003, 0.,
-       8.00000038e-003, 8.00000038e-003, 0., 0., 0., 0., 0., 0., 0.,
-       8.00000038e-003, 0., 0., 0., 0., 0., 0., 8.00000038e-003, 0., 0.,
-       0., 8.00000038e-003, 0., 0., 2.40000002e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.00000038e-003, 0., 0., 0., 0., 0., 0., 8.00000038e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.00000038e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.00000038e-003, 0., 0.,
-       8.00000038e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.00000038e-003, 0., 0., 8.00000038e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.00000038e-003, 0., 0., 0., 0., 0.,
-       8.19672085e-003, 2.45901626e-002, 8.19672085e-003,
-       8.19672085e-003, 0., 2.45901626e-002, 0., 0., 1.63934417e-002,
-       1.63934417e-002, 0., 0., 8.19672085e-003, 0., 0., 0., 0., 0., 0.,
-       0., 8.19672085e-003, 0., 0., 0., 0., 0., 1.63934417e-002, 0.,
-       2.45901626e-002, 0., 0., 8.19672085e-003, 0., 0., 0., 0., 0., 0.,
-       2.45901626e-002, 8.19672085e-003, 0., 0., 0., 0., 0.,
-       8.19672085e-003, 0., 1.63934417e-002, 1.63934417e-002, 0., 0., 0.,
-       0., 0., 8.19672085e-003, 0., 0., 8.19672085e-003, 0.,
-       8.19672085e-003, 8.19672085e-003, 0., 8.19672085e-003, 0.,
-       2.45901626e-002, 8.19672085e-003, 8.19672085e-003, 0., 0., 0.,
-       8.19672085e-003, 0., 8.19672085e-003, 0., 0., 0., 0.,
-       8.19672085e-003, 0., 8.19672085e-003, 0., 0., 8.19672085e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.63934417e-002, 0., 0., 0., 0.,
-       0., 0., 8.19672085e-003, 8.19672085e-003, 8.19672085e-003, 0., 0.,
-       8.19672085e-003, 0., 0., 0., 0., 8.19672085e-003, 0., 0., 0., 0.,
-       0., 0., 1.63934417e-002, 0., 1.63934417e-002, 0., 8.19672085e-003,
-       0., 0., 0., 0., 0., 2.45901626e-002, 0., 0., 8.19672085e-003,
-       8.19672085e-003, 0., 0., 0., 0., 1.63934417e-002, 8.19672085e-003,
-       0., 0., 0., 0., 0., 0., 0., 8.19672085e-003, 0., 0., 0., 0.,
-       3.27868834e-002, 0., 0., 8.19672085e-003, 0., 0., 0., 0., 0., 0.,
-       8.19672085e-003, 0., 0., 0., 8.19672085e-003, 1.63934417e-002,
-       8.19672085e-003, 0., 1.63934417e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.19672085e-003, 0., 0., 0., 0., 0., 0., 0., 8.19672085e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.19672085e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.19672085e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.19672085e-003,
-       1.63934417e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.19672085e-003, 0., 0., 0., 0., 0., 0., 8.19672085e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.19672085e-003, 0., 0., 0., 0., 0., 0., 8.19672085e-003, 0., 0.,
-       8.19672085e-003, 0., 8.19672085e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.19672085e-003, 0., 0., 8.19672085e-003, 0., 0., 0.,
-       8.19672085e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.19672085e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.63934417e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.19672085e-003, 0., 0., 0., 1.63934417e-002, 0., 0., 0., 0.,
-       8.19672085e-003, 8.19672085e-003, 8.19672085e-003,
-       8.19672085e-003, 0., 0., 8.19672085e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.19672085e-003, 0., 8.19672085e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.19672085e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.19672085e-003, 0., 0., 0., 0., 8.19672085e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.19672085e-003, 0., 0., 0., 0.,
-       0., 0., 0., 8.19672085e-003, 0., 8.19672085e-003, 8.19672085e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.19672085e-003, 0.,
-       8.19672085e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.63934417e-002, 0., 0., 8.19672085e-003, 0., 0., 0., 0.,
-       8.19672085e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.19672085e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.19672085e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.99999993e-002, 9.99999978e-003, 0., 0., 0., 9.99999978e-003, 0.,
-       0., 9.99999978e-003, 9.99999978e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.99999978e-003, 0., 0., 9.99999978e-003, 9.99999978e-003,
-       0., 9.99999978e-003, 0., 0., 0., 0., 0., 9.99999978e-003, 0., 0.,
-       9.99999978e-003, 0., 9.99999978e-003, 0., 0., 0., 9.99999978e-003,
-       0., 0., 0., 0., 1.99999996e-002, 0., 0., 9.99999978e-003, 0.,
-       1.99999996e-002, 9.99999978e-003, 3.99999991e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.99999996e-002, 0., 0., 0., 0., 0., 0., 0.,
-       1.99999996e-002, 0., 0., 0., 0., 9.99999978e-003, 0., 0., 0., 0.,
-       0., 0., 9.99999978e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.99999978e-003, 0., 9.99999978e-003, 0., 0., 0., 0., 0.,
-       9.99999978e-003, 0., 9.99999978e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.99999978e-003, 0., 1.99999996e-002,
-       9.99999978e-003, 9.99999978e-003, 0., 0., 0., 0., 0.,
-       2.99999993e-002, 0., 0., 0., 7.00000003e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.99999978e-003, 0., 0., 0., 0., 0.,
-       9.99999978e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 2.99999993e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.99999978e-003, 0., 0.,
-       9.99999978e-003, 0., 0., 0., 0., 9.99999978e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.99999978e-003, 0., 0., 0., 0., 0., 9.99999978e-003, 0.,
-       9.99999978e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.99999996e-002, 0., 0., 9.99999978e-003, 0., 9.99999978e-003,
-       1.99999996e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.99999978e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.99999978e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.99999978e-003, 9.99999978e-003,
-       0., 0., 9.99999978e-003, 1.99999996e-002, 9.99999978e-003, 0., 0.,
-       1.99999996e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.99999978e-003, 0., 0., 0., 0., 0., 1.99999996e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.99999996e-002,
-       9.99999978e-003, 9.99999978e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.99999978e-003, 9.99999978e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.99999996e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.99999978e-003, 0., 0., 0., 0., 0., 9.99999978e-003,
-       0., 0., 0., 0., 0., 0., 0., 9.99999978e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.99999978e-003, 0., 0., 0., 0., 0., 9.99999978e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.99999978e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.99999978e-003,
-       0., 9.99999978e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.99999978e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.99999996e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.99999978e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.09090880e-003, 9.09090880e-003, 9.09090880e-003, 0., 0., 0., 0.,
-       0., 1.81818176e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.09090880e-003, 9.09090880e-003, 9.09090880e-003, 0.,
-       2.72727273e-002, 0., 0., 0., 9.09090880e-003, 0., 0.,
-       9.09090880e-003, 0., 0., 0., 0., 9.09090880e-003, 0., 0.,
-       1.81818176e-002, 1.81818176e-002, 0., 0., 0., 1.81818176e-002, 0.,
-       0., 0., 0., 0., 9.09090880e-003, 0., 0., 0., 0., 9.09090880e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.09090880e-003, 9.09090880e-003,
-       1.81818176e-002, 0., 0., 0., 0., 0., 0., 0., 0., 9.09090880e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.81818176e-002, 0., 0., 0., 0., 0., 1.81818176e-002, 0.,
-       9.09090880e-003, 0., 9.09090880e-003, 0., 0., 9.09090880e-003, 0.,
-       0., 0., 9.09090880e-003, 0., 0., 0., 0., 9.09090880e-003,
-       9.09090880e-003, 9.09090880e-003, 0., 0., 1.81818176e-002, 0., 0.,
-       0., 0., 0., 9.09090880e-003, 0., 9.09090880e-003, 0., 0., 0., 0.,
-       1.81818176e-002, 0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.09090880e-003, 0., 9.09090880e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.09090880e-003, 0., 0., 0.,
-       0., 0., 9.09090880e-003, 9.09090880e-003, 9.09090880e-003,
-       1.81818176e-002, 0., 0., 0., 0., 0., 9.09090880e-003, 0.,
-       1.81818176e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.81818176e-002, 0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.81818176e-002, 0., 0.,
-       9.09090880e-003, 9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.09090880e-003,
-       9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.09090880e-003, 0., 9.09090880e-003, 0., 0., 0., 0., 0.,
-       1.81818176e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.09090880e-003, 0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.09090880e-003,
-       9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.81818176e-002, 0., 0., 0., 0.,
-       9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.81818176e-002, 0., 0., 0., 9.09090880e-003, 0., 0.,
-       9.09090880e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.09090880e-003, 0., 0., 0., 0., 1.81818176e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.81818176e-002, 0., 0.,
-       0., 0., 0., 0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.09090880e-003, 0., 0., 9.09090880e-003, 0., 0., 0.,
-       0., 9.09090880e-003, 0., 0., 0., 0., 0., 0., 1.81818176e-002, 0.,
-       9.09090880e-003, 0., 0., 0., 0., 0., 0., 1.81818176e-002, 0., 0.,
-       0., 9.09090880e-003, 0., 0., 0., 0., 0., 9.09090880e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.09090880e-003,
-       0., 0., 0., 0., 9.09090880e-003, 0., 0., 0., 9.09090880e-003, 0.,
-       9.09090880e-003, 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.09090880e-003, 0., 0., 0., 9.09090880e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.09090880e-003, 0., 9.09090880e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.09090880e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.09090880e-003, 3.70370373e-002, 9.25925933e-003,
-       1.85185187e-002, 9.25925933e-003, 9.25925933e-003,
-       1.85185187e-002, 0., 9.25925933e-003, 9.25925933e-003,
-       2.77777780e-002, 1.85185187e-002, 0., 0., 9.25925933e-003, 0., 0.,
-       0., 0., 0., 9.25925933e-003, 0., 0., 0., 0., 0., 9.25925933e-003,
-       2.77777780e-002, 0., 9.25925933e-003, 9.25925933e-003, 0., 0., 0.,
-       0., 0., 9.25925933e-003, 0., 0., 0., 1.85185187e-002, 0., 0., 0.,
-       0., 9.25925933e-003, 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0.,
-       0., 0., 0., 0., 9.25925933e-003, 0., 0., 0., 0., 1.85185187e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003,
-       9.25925933e-003, 9.25925933e-003, 0., 9.25925933e-003, 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.77777780e-002, 0., 0., 0., 0., 9.25925933e-003, 0., 0., 0.,
-       9.25925933e-003, 1.85185187e-002, 0., 0., 1.85185187e-002,
-       1.85185187e-002, 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0.,
-       9.25925933e-003, 0., 0., 9.25925933e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0.,
-       0., 0., 1.85185187e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 9.25925933e-003, 0., 0., 9.25925933e-003, 0.,
-       9.25925933e-003, 0., 9.25925933e-003, 0., 0., 0., 9.25925933e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0., 0.,
-       0., 0., 9.25925933e-003, 0., 0., 0., 0., 9.25925933e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0., 0., 0.,
-       0., 9.25925933e-003, 0., 9.25925933e-003, 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.25925933e-003, 0., 0., 9.25925933e-003, 0., 0., 0., 0.,
-       0., 0., 0., 9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 9.25925933e-003, 0., 0., 9.25925933e-003, 0., 0.,
-       0., 0., 0., 9.25925933e-003, 0., 0., 0., 9.25925933e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 2.77777780e-002, 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 9.25925933e-003, 0., 0., 0., 0.,
-       9.25925933e-003, 0., 9.25925933e-003, 0., 9.25925933e-003, 0., 0.,
-       9.25925933e-003, 0., 9.25925933e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0., 9.25925933e-003,
-       0., 0., 9.25925933e-003, 1.85185187e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0.,
-       0., 0., 0., 9.25925933e-003, 0., 0., 0., 0., 9.25925933e-003, 0.,
-       0., 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0., 0., 0., 0., 0.,
-       0., 9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 9.25925933e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0.,
-       4.23728824e-002, 0., 1.69491526e-002, 0., 0., 8.47457629e-003,
-       8.47457629e-003, 0., 8.47457629e-003, 0., 0., 8.47457629e-003,
-       1.69491526e-002, 1.69491526e-002, 0., 8.47457629e-003,
-       8.47457629e-003, 0., 8.47457629e-003, 1.69491526e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 2.54237279e-002, 0., 0., 0.,
-       8.47457629e-003, 2.54237279e-002, 8.47457629e-003, 0.,
-       8.47457629e-003, 0., 0., 0., 8.47457629e-003, 0., 0.,
-       3.38983051e-002, 0., 0., 0., 0., 0., 0., 1.69491526e-002, 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0.,
-       0., 0., 8.47457629e-003, 8.47457629e-003, 0., 0., 0.,
-       8.47457629e-003, 0., 8.47457629e-003, 0., 0., 0., 0.,
-       8.47457629e-003, 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 1.69491526e-002, 0., 0., 0., 0.,
-       4.23728824e-002, 0., 0., 0., 1.69491526e-002, 8.47457629e-003, 0.,
-       0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0.,
-       1.69491526e-002, 8.47457629e-003, 0., 0., 8.47457629e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 1.69491526e-002, 0., 0., 0., 0.,
-       2.54237279e-002, 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 1.69491526e-002, 0., 8.47457629e-003,
-       0., 8.47457629e-003, 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.47457629e-003, 0., 0., 8.47457629e-003, 0., 0., 0., 0.,
-       0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 1.69491526e-002, 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.69491526e-002, 0.,
-       8.47457629e-003, 0., 0., 0., 8.47457629e-003, 0., 0.,
-       8.47457629e-003, 2.54237279e-002, 0., 1.69491526e-002, 0., 0., 0.,
-       0., 0., 0., 0., 8.47457629e-003, 0., 3.38983051e-002, 0., 0., 0.,
-       0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.69491526e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.69491526e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0.,
-       0., 8.47457629e-003, 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.47457629e-003,
-       0., 0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.47457629e-003, 0., 0., 0., 0., 0., 0.,
-       8.47457629e-003, 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0.,
-       0., 3.70370373e-002, 0., 4.62962985e-002, 0., 9.25925933e-003, 0.,
-       0., 0., 0., 9.25925933e-003, 0., 0., 0., 9.25925933e-003,
-       2.77777780e-002, 0., 0., 1.85185187e-002, 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 9.25925933e-003, 9.25925933e-003, 0.,
-       9.25925933e-003, 0., 1.85185187e-002, 0., 0., 0., 0.,
-       4.62962985e-002, 9.25925933e-003, 0., 0., 0., 9.25925933e-003, 0.,
-       9.25925933e-003, 9.25925933e-003, 1.85185187e-002,
-       2.77777780e-002, 0., 0., 1.85185187e-002, 9.25925933e-003,
-       9.25925933e-003, 0., 0., 0., 9.25925933e-003, 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0.,
-       0., 0., 9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0., 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 0., 9.25925933e-003, 0., 0., 0., 0., 0.,
-       1.85185187e-002, 0., 1.85185187e-002, 0., 9.25925933e-003, 0., 0.,
-       1.85185187e-002, 3.70370373e-002, 0., 0., 0., 1.85185187e-002, 0.,
-       0., 0., 0., 0., 0., 9.25925933e-003, 9.25925933e-003, 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 9.25925933e-003, 9.25925933e-003, 0., 0., 0., 0.,
-       0., 9.25925933e-003, 0., 0., 0., 0., 9.25925933e-003, 0., 0., 0.,
-       0., 0., 0., 1.85185187e-002, 0., 0., 0., 0., 0., 0.,
-       1.85185187e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.85185187e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.85185187e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.25925933e-003, 9.25925933e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 2.77777780e-002, 0., 0., 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 1.85185187e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.25925933e-003, 0., 9.25925933e-003, 0., 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0.,
-       9.25925933e-003, 0., 0., 9.25925933e-003, 0., 0., 9.25925933e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.25925933e-003, 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.25925933e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.25925933e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.70873795e-003, 1.94174759e-002,
-       9.70873795e-003, 0., 3.88349518e-002, 0., 0., 0., 9.70873795e-003,
-       0., 0., 9.70873795e-003, 9.70873795e-003, 0., 0., 0.,
-       1.94174759e-002, 0., 1.94174759e-002, 0., 0., 2.91262139e-002, 0.,
-       0., 0., 1.94174759e-002, 0., 0., 0., 1.94174759e-002,
-       2.91262139e-002, 0., 9.70873795e-003, 9.70873795e-003, 0., 0.,
-       1.94174759e-002, 1.94174759e-002, 0., 0., 9.70873795e-003, 0., 0.,
-       0., 9.70873795e-003, 0., 9.70873795e-003, 9.70873795e-003, 0., 0.,
-       9.70873795e-003, 9.70873795e-003, 0., 9.70873795e-003, 0., 0., 0.,
-       0., 9.70873795e-003, 0., 0., 9.70873795e-003, 0., 0.,
-       9.70873795e-003, 0., 0., 1.94174759e-002, 0., 9.70873795e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.70873795e-003, 0., 0.,
-       9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.70873795e-003, 0., 0., 0., 1.94174759e-002, 0.,
-       0., 0., 0., 0., 0., 9.70873795e-003, 0., 9.70873795e-003, 0., 0.,
-       9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 3.88349518e-002,
-       0., 0., 0., 1.94174759e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.70873795e-003,
-       0., 0., 0., 1.94174759e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.94174759e-002, 0., 0., 0.,
-       0., 0., 0., 0., 9.70873795e-003, 0., 0., 9.70873795e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.70873795e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.70873795e-003, 0.,
-       0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 9.70873795e-003, 0.,
-       9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.70873795e-003, 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 9.70873795e-003, 0., 9.70873795e-003,
-       0., 0., 0., 0., 0., 0., 0., 9.70873795e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.94174759e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.70873795e-003, 0., 9.70873795e-003, 0., 0., 0., 0.,
-       0., 0., 0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.70873795e-003, 0., 0., 0., 0.,
-       9.70873795e-003, 0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 9.70873795e-003, 0., 0., 0., 0., 9.70873795e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 2.91262139e-002, 0., 9.70873795e-003, 0., 0., 0., 0., 0.,
-       9.70873795e-003, 0., 0., 0., 9.70873795e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.94174759e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.70873795e-003, 0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.70873795e-003, 0., 9.70873795e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.57480314e-002, 7.87401572e-003, 0., 0.,
-       3.14960629e-002, 0., 0., 7.87401572e-003, 0., 0., 0.,
-       7.87401572e-003, 0., 1.57480314e-002, 7.87401572e-003,
-       7.87401572e-003, 0., 7.87401572e-003, 0., 0., 7.87401572e-003,
-       1.57480314e-002, 7.87401572e-003, 7.87401572e-003,
-       7.87401572e-003, 7.87401572e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.87401572e-003, 7.87401572e-003, 0., 2.36220472e-002, 0.,
-       7.87401572e-003, 0., 7.87401572e-003, 0., 0., 7.87401572e-003, 0.,
-       0., 1.57480314e-002, 7.87401572e-003, 7.87401572e-003,
-       7.87401572e-003, 7.87401572e-003, 0., 7.87401572e-003,
-       1.57480314e-002, 0., 0., 7.87401572e-003, 0., 0., 0.,
-       1.57480314e-002, 7.87401572e-003, 7.87401572e-003, 0., 0., 0.,
-       7.87401572e-003, 0., 2.36220472e-002, 0., 0., 0., 7.87401572e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.87401572e-003, 0.,
-       7.87401572e-003, 0., 0., 0., 0., 0., 1.57480314e-002, 0.,
-       7.87401572e-003, 7.87401572e-003, 0., 0., 0., 0., 1.57480314e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.57480314e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 7.87401572e-003, 0., 0., 7.87401572e-003, 0., 0.,
-       7.87401572e-003, 0., 2.36220472e-002, 0., 0., 0., 0.,
-       7.87401572e-003, 0., 0., 7.87401572e-003, 0., 0., 0.,
-       1.57480314e-002, 0., 0., 0., 0., 7.87401572e-003, 7.87401572e-003,
-       0., 7.87401572e-003, 0., 0., 7.87401572e-003, 0., 0., 0., 0.,
-       2.36220472e-002, 7.87401572e-003, 0., 0., 7.87401572e-003,
-       1.57480314e-002, 0., 0., 0., 0., 7.87401572e-003, 1.57480314e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.87401572e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 7.87401572e-003, 0., 1.57480314e-002,
-       1.57480314e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.57480314e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.87401572e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.87401572e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.87401572e-003, 0., 0., 0., 0., 0., 0., 0., 0., 1.57480314e-002,
-       0., 0., 0., 0., 0., 0., 0., 3.14960629e-002, 0., 0., 0., 0., 0.,
-       7.87401572e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.87401572e-003, 0., 0., 0., 0., 0., 7.87401572e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.57480314e-002, 0., 0., 0.,
-       7.87401572e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.87401572e-003, 0., 0., 0., 7.87401572e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.87401572e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.57480314e-002,
-       7.87401572e-003, 0., 0., 7.87401572e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.87401572e-003,
-       0., 0., 0., 0., 7.87401572e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.87401572e-003, 0., 0., 0., 0., 0., 0., 0.,
-       7.87401572e-003, 0., 0., 0., 0., 7.87401572e-003, 0., 0.,
-       7.87401572e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.87401572e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.87401572e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.57480314e-002, 0., 7.87401572e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.87401572e-003,
-       0., 0., 0., 0., 0., 0., 0., 7.87401572e-003, 0., 7.87401572e-003,
-       0., 0., 7.87401572e-003, 0., 0., 1.29032256e-002, 6.45161280e-003,
-       6.45161280e-003, 0., 0., 1.29032256e-002, 0., 0., 6.45161280e-003,
-       6.45161280e-003, 6.45161280e-003, 0., 1.29032256e-002, 0.,
-       6.45161280e-003, 0., 1.29032256e-002, 0., 0., 1.29032256e-002, 0.,
-       0., 6.45161280e-003, 6.45161280e-003, 0., 1.29032256e-002, 0., 0.,
-       6.45161280e-003, 1.29032256e-002, 0., 6.45161280e-003, 0.,
-       6.45161280e-003, 6.45161280e-003, 6.45161280e-003, 0., 0.,
-       6.45161280e-003, 0., 6.45161280e-003, 0., 0., 6.45161280e-003, 0.,
-       1.29032256e-002, 1.29032256e-002, 6.45161280e-003,
-       6.45161280e-003, 0., 0., 1.93548389e-002, 6.45161280e-003, 0.,
-       6.45161280e-003, 1.29032256e-002, 0., 0., 0., 6.45161280e-003,
-       6.45161280e-003, 0., 1.29032256e-002, 6.45161280e-003,
-       1.93548389e-002, 0., 0., 0., 6.45161280e-003, 0., 0., 0., 0.,
-       6.45161280e-003, 0., 1.29032256e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.45161280e-003, 0., 0., 0., 0.,
-       0., 0., 0., 1.29032256e-002, 0., 0., 6.45161280e-003, 0., 0., 0.,
-       0., 0., 0., 6.45161280e-003, 0., 0., 0., 1.29032256e-002, 0., 0.,
-       0., 0., 0., 0., 6.45161280e-003, 1.29032256e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.93548389e-002, 0., 0., 0., 0., 0., 0., 0.,
-       6.45161280e-003, 0., 0., 6.45161280e-003, 0., 0., 6.45161280e-003,
-       0., 0., 0., 0., 6.45161280e-003, 6.45161280e-003, 0.,
-       1.93548389e-002, 0., 6.45161280e-003, 6.45161280e-003, 0., 0., 0.,
-       3.22580636e-002, 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.45161280e-003, 0., 0., 1.29032256e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.45161280e-003, 0., 0., 6.45161280e-003, 0., 0., 6.45161280e-003,
-       0., 0., 0., 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.45161280e-003, 0., 0., 6.45161280e-003, 0., 6.45161280e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.45161280e-003, 0., 0.,
-       6.45161280e-003, 0., 0., 0., 6.45161280e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.45161280e-003, 0., 0., 6.45161280e-003, 0.,
-       0., 0., 0., 0., 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.45161280e-003, 0., 0., 0., 6.45161280e-003, 0., 0., 0.,
-       0., 6.45161280e-003, 6.45161280e-003, 0., 0., 1.29032256e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.45161280e-003, 0., 1.29032256e-002, 0., 6.45161280e-003, 0.,
-       0., 0., 0., 0., 0., 0., 6.45161280e-003, 0., 6.45161280e-003, 0.,
-       0., 6.45161280e-003, 0., 0., 0., 0., 6.45161280e-003, 0., 0.,
-       6.45161280e-003, 0., 1.29032256e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.29032256e-002, 0., 6.45161280e-003, 0., 0., 0.,
-       0., 6.45161280e-003, 0., 1.29032256e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.45161280e-003, 0., 0., 0., 0., 0., 6.45161280e-003,
-       6.45161280e-003, 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.45161280e-003, 0., 0., 0., 0., 0., 6.45161280e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.45161280e-003, 0.,
-       1.29032256e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.45161280e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.45161280e-003, 0., 0., 0., 1.29032256e-002, 0., 0., 0., 0.,
-       0., 0., 6.45161280e-003, 6.45161280e-003, 6.45161280e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.29032256e-002, 0., 0.,
-       1.93548389e-002, 0., 0., 0., 0., 0., 0., 0., 6.45161280e-003, 0.,
-       0., 1.29032256e-002, 0., 0., 6.45161280e-003, 0., 0., 0., 0., 0.,
-       1.29032256e-002, 6.45161280e-003, 0., 0., 0., 0., 6.45161280e-003,
-       6.45161280e-003, 0., 0., 0., 0., 0., 0., 0., 0., 5.05050505e-003,
-       1.51515156e-002, 5.05050505e-003, 2.02020202e-002,
-       5.05050505e-003, 0., 0., 1.01010101e-002, 5.05050505e-003, 0., 0.,
-       5.05050505e-003, 2.52525248e-002, 0., 5.05050505e-003,
-       5.05050505e-003, 1.01010101e-002, 5.05050505e-003, 0., 0., 0., 0.,
-       1.01010101e-002, 0., 0., 0., 1.01010101e-002, 0., 5.05050505e-003,
-       2.02020202e-002, 0., 5.05050505e-003, 0., 1.01010101e-002, 0., 0.,
-       5.05050505e-003, 0., 5.05050505e-003, 5.05050505e-003, 0., 0.,
-       5.05050505e-003, 1.51515156e-002, 0., 2.02020202e-002, 0.,
-       1.51515156e-002, 5.05050505e-003, 0., 0., 5.05050505e-003,
-       5.05050505e-003, 5.05050505e-003, 5.05050505e-003,
-       5.05050505e-003, 0., 5.05050505e-003, 0., 0., 5.05050505e-003, 0.,
-       1.01010101e-002, 0., 0., 5.05050505e-003, 0., 5.05050505e-003,
-       1.01010101e-002, 0., 2.52525248e-002, 0., 5.05050505e-003, 0.,
-       5.05050505e-003, 5.05050505e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.05050505e-003, 0., 0., 5.05050505e-003, 0., 0., 0., 0., 0.,
-       5.05050505e-003, 5.05050505e-003, 1.01010101e-002, 0., 0., 0.,
-       1.51515156e-002, 1.01010101e-002, 5.05050505e-003, 0., 0.,
-       5.05050505e-003, 0., 0., 5.05050505e-003, 5.05050505e-003,
-       5.05050505e-003, 0., 5.05050505e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.05050505e-003, 0., 0., 5.05050505e-003,
-       5.05050505e-003, 0., 0., 4.54545468e-002, 0., 0., 0., 0., 0.,
-       5.05050505e-003, 0., 1.01010101e-002, 0., 0., 0., 0.,
-       5.05050505e-003, 5.05050505e-003, 5.05050505e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.05050505e-003, 0., 5.05050505e-003,
-       0., 1.01010101e-002, 0., 0., 5.05050505e-003, 5.05050505e-003, 0.,
-       0., 0., 1.01010101e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.05050505e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.01010101e-002, 0., 0., 0., 0., 0., 5.05050505e-003, 0.,
-       5.05050505e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.05050505e-003, 5.05050505e-003, 5.05050505e-003,
-       5.05050505e-003, 0., 0., 5.05050505e-003, 0., 0., 5.05050505e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 2.02020202e-002,
-       1.01010101e-002, 5.05050505e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.05050505e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.05050505e-003, 5.05050505e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.05050505e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.05050505e-003, 0., 2.52525248e-002, 0., 5.05050505e-003, 0., 0.,
-       0., 5.05050505e-003, 0., 0., 1.01010101e-002, 0., 0., 0., 0., 0.,
-       0., 5.05050505e-003, 0., 0., 1.01010101e-002, 5.05050505e-003,
-       5.05050505e-003, 0., 0., 0., 5.05050505e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.05050505e-003, 0., 0., 0.,
-       5.05050505e-003, 0., 5.05050505e-003, 0., 0., 5.05050505e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.05050505e-003, 0., 0.,
-       2.02020202e-002, 0., 5.05050505e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.01010101e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.05050505e-003, 0., 0., 0., 0., 0., 0., 5.05050505e-003, 0., 0.,
-       5.05050505e-003, 0., 0., 0., 0., 0., 0., 5.05050505e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.05050505e-003, 0., 0.,
-       5.05050505e-003, 0., 0., 5.05050505e-003, 0., 0., 0., 0., 0.,
-       1.01010101e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.05050505e-003, 0., 5.05050505e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.51515156e-002, 5.05050505e-003, 0.,
-       1.01010101e-002, 0., 0., 0., 0., 0., 0., 0., 1.01010101e-002, 0.,
-       0., 0., 0., 5.05050505e-003, 0., 5.05050505e-003, 5.05050505e-003,
-       0., 0., 0., 0., 0., 0., 5.05050505e-003, 0., 0., 5.05050505e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.05050505e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.01010101e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.05050505e-003, 0., 0., 0., 5.05050505e-003, 0.,
-       0., 0., 5.05050505e-003, 0., 0., 0., 0., 0., 5.05050505e-003, 0.,
-       0., 0., 0., 5.05050505e-003, 0., 0., 0., 0., 0., 5.05050505e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.65289249e-002, 0.,
-       8.26446246e-003, 1.65289249e-002, 0., 0., 0., 0., 0., 0.,
-       8.26446246e-003, 1.65289249e-002, 8.26446246e-003, 0., 0.,
-       8.26446246e-003, 0., 8.26446246e-003, 8.26446246e-003, 0.,
-       8.26446246e-003, 8.26446246e-003, 1.65289249e-002,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 1.65289249e-002,
-       1.65289249e-002, 0., 8.26446246e-003, 8.26446246e-003, 0., 0., 0.,
-       2.47933865e-002, 1.65289249e-002, 0., 0., 0., 2.47933865e-002, 0.,
-       8.26446246e-003, 0., 8.26446246e-003, 2.47933865e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 2.47933865e-002, 0., 0., 0.,
-       1.65289249e-002, 2.47933865e-002, 0., 0., 0., 8.26446246e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.26446246e-003, 0., 0.,
-       0., 0., 0., 0., 8.26446246e-003, 0., 0., 8.26446246e-003, 0., 0.,
-       0., 0., 0., 1.65289249e-002, 0., 0., 0., 0., 8.26446246e-003, 0.,
-       0., 0., 1.65289249e-002, 0., 1.65289249e-002, 0., 0., 0., 0., 0.,
-       3.30578499e-002, 0., 0., 0., 0., 0., 0., 8.26446246e-003, 0., 0.,
-       0., 0., 8.26446246e-003, 0., 0., 0., 0., 8.26446246e-003, 0.,
-       8.26446246e-003, 0., 0., 0., 1.65289249e-002, 0., 0., 0., 0., 0.,
-       0., 0., 8.26446246e-003, 0., 8.26446246e-003, 0., 0., 0., 0., 0.,
-       8.26446246e-003, 0., 8.26446246e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 1.65289249e-002, 0.,
-       0., 8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.26446246e-003, 0., 8.26446246e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.47933865e-002, 0., 0., 0., 0., 0., 0., 0., 0., 8.26446246e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 8.26446246e-003, 0.,
-       8.26446246e-003, 0., 8.26446246e-003, 0., 0., 0., 8.26446246e-003,
-       0., 0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.65289249e-002, 0., 0., 8.26446246e-003,
-       8.26446246e-003, 0., 0., 0., 0., 1.65289249e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 2.47933865e-002, 8.26446246e-003,
-       0., 0., 0., 0., 2.47933865e-002, 8.26446246e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.26446246e-003, 0., 0.,
-       0., 0., 0., 0., 0., 1.65289249e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.26446246e-003, 0., 0., 8.26446246e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.26446246e-003, 0., 2.47933865e-002, 0., 0.,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.26446246e-003, 0., 0., 0., 8.26446246e-003, 0., 8.26446246e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.26446246e-003, 0., 8.26446246e-003, 0., 0., 0., 0., 0.,
-       8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.26446246e-003, 0., 0., 0., 0., 0.,
-       1.71428565e-002, 0., 0., 5.71428565e-003, 5.71428565e-003,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 0., 0., 5.71428565e-003,
-       1.14285713e-002, 0., 0., 1.14285713e-002, 0., 1.71428565e-002, 0.,
-       0., 0., 5.71428565e-003, 1.71428565e-002, 1.14285713e-002,
-       5.71428565e-003, 0., 0., 1.71428565e-002, 1.71428565e-002, 0.,
-       5.71428565e-003, 0., 0., 1.71428565e-002, 1.71428565e-002,
-       5.71428565e-003, 0., 0., 1.14285713e-002, 0., 0., 0., 0.,
-       1.71428565e-002, 5.71428565e-003, 0., 5.71428565e-003, 0.,
-       2.85714287e-002, 0., 0., 0., 0., 0., 5.71428565e-003,
-       1.71428565e-002, 0., 1.14285713e-002, 5.71428565e-003, 0., 0., 0.,
-       0., 0., 5.71428565e-003, 0., 0., 0., 0., 0., 5.71428565e-003, 0.,
-       5.71428565e-003, 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.14285713e-002, 0., 0.,
-       5.71428565e-003, 5.71428565e-003, 0., 5.71428565e-003, 0.,
-       1.14285713e-002, 0., 0., 5.71428565e-003, 0., 0., 5.71428565e-003,
-       0., 0., 0., 0., 5.71428565e-003, 0., 5.71428565e-003, 0.,
-       1.14285713e-002, 0., 0., 0., 5.71428565e-003, 5.71428565e-003, 0.,
-       0., 1.14285713e-002, 0., 0., 0., 0., 2.28571426e-002, 0., 0., 0.,
-       5.71428575e-002, 0., 0., 1.71428565e-002, 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 1.14285713e-002, 0.,
-       1.14285713e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 5.71428565e-003, 1.71428565e-002,
-       1.14285713e-002, 0., 0., 0., 5.71428565e-003, 5.71428565e-003, 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0.,
-       0., 0., 5.71428565e-003, 5.71428565e-003, 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 1.14285713e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.71428565e-003, 5.71428565e-003, 0., 0.,
-       5.71428565e-003, 0., 0., 1.14285713e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 5.71428565e-003, 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0., 0.,
-       1.14285713e-002, 0., 5.71428565e-003, 1.14285713e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0.,
-       1.14285713e-002, 0., 0., 5.71428565e-003, 0., 5.71428565e-003, 0.,
-       0., 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.14285713e-002, 0., 0., 0.,
-       0., 5.71428565e-003, 0., 0., 0., 0., 0., 1.14285713e-002, 0., 0.,
-       0., 0., 0., 1.14285713e-002, 0., 5.71428565e-003, 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 1.14285713e-002, 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0., 0.,
-       0., 5.71428565e-003, 5.71428565e-003, 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.71428565e-003, 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003,
-       5.71428565e-003, 0., 5.71428565e-003, 5.71428565e-003, 0., 0., 0.,
-       0., 0., 0., 5.71428565e-003, 0., 0., 0., 5.71428565e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.71428565e-003, 0., 5.71428565e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.71428565e-003,
-       5.71428565e-003, 0., 0., 5.71428565e-003, 0., 5.71428565e-003, 0.,
-       0., 0., 0., 0., 0., 5.71428565e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.71428565e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.14942528e-002, 1.14942528e-002, 1.72413792e-002,
-       5.74712642e-003, 5.74712642e-003, 0., 0., 5.74712642e-003, 0., 0.,
-       5.74712642e-003, 0., 1.72413792e-002, 0., 0., 0., 0.,
-       5.74712642e-003, 5.74712642e-003, 0., 0., 0., 1.14942528e-002, 0.,
-       0., 5.74712642e-003, 5.74712642e-003, 5.74712642e-003,
-       1.14942528e-002, 1.14942528e-002, 5.74712642e-003,
-       5.74712642e-003, 0., 0., 0., 0., 0., 0., 1.72413792e-002,
-       5.74712642e-003, 0., 0., 0., 0., 5.74712642e-003, 1.72413792e-002,
-       5.74712642e-003, 1.14942528e-002, 1.14942528e-002, 0., 0., 0., 0.,
-       5.74712642e-003, 0., 5.74712642e-003, 0., 5.74712642e-003, 0.,
-       1.72413792e-002, 0., 0., 5.74712642e-003, 5.74712642e-003, 0., 0.,
-       0., 0., 5.74712642e-003, 5.74712642e-003, 5.74712642e-003, 0.,
-       5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.14942528e-002, 0., 0., 0., 0., 0., 0., 5.74712642e-003,
-       5.74712642e-003, 0., 5.74712642e-003, 5.74712642e-003,
-       5.74712642e-003, 0., 5.74712642e-003, 5.74712642e-003, 0., 0., 0.,
-       0., 5.74712642e-003, 0., 0., 0., 0., 5.74712642e-003, 0., 0.,
-       5.74712642e-003, 5.74712642e-003, 0., 0., 1.72413792e-002, 0.,
-       5.74712642e-003, 5.74712642e-003, 0., 0., 0., 0., 0.,
-       5.74712642e-003, 1.72413792e-002, 0., 0., 5.74712642e-003,
-       2.87356321e-002, 0., 0., 5.74712642e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.14942528e-002, 5.74712642e-003, 5.74712642e-003,
-       5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.74712642e-003, 0., 5.74712642e-003, 0., 0., 0., 0.,
-       5.74712642e-003, 0., 1.14942528e-002, 0., 0., 5.74712642e-003, 0.,
-       5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.74712642e-003, 0., 1.14942528e-002,
-       5.74712642e-003, 0., 0., 0., 0., 0., 0., 5.74712642e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.74712642e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.14942528e-002, 0., 0., 0., 0., 0., 0., 0.,
-       5.74712642e-003, 0., 0., 0., 0., 0., 5.74712642e-003, 0., 0., 0.,
-       0., 5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.14942528e-002, 0., 0., 5.74712642e-003, 0., 0., 5.74712642e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.74712642e-003, 0., 0., 0.,
-       0., 0., 5.74712642e-003, 0., 0., 0., 0., 0., 0., 1.14942528e-002,
-       0., 0., 5.74712642e-003, 0., 0., 0., 0., 5.74712642e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       2.87356321e-002, 0., 0., 0., 1.14942528e-002, 0., 0., 0., 0.,
-       1.14942528e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.74712642e-003, 5.74712642e-003, 0., 1.14942528e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.74712642e-003, 0.,
-       0., 0., 0., 0., 5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.14942528e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.74712642e-003, 0., 5.74712642e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 5.74712642e-003, 0., 5.74712642e-003,
-       1.14942528e-002, 0., 1.14942528e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.72413792e-002, 0.,
-       0., 5.74712642e-003, 0., 0., 0., 0., 0., 1.14942528e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.74712642e-003, 0., 0., 0., 0., 0.,
-       1.14942528e-002, 0., 0., 5.74712642e-003, 0., 0., 5.74712642e-003,
-       5.74712642e-003, 0., 5.74712642e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.74712642e-003, 5.74712642e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.74712642e-003, 0., 1.14942528e-002, 0., 0., 1.14942528e-002, 0.,
-       0., 0., 5.74712642e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.74712642e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.14942528e-002, 0., 0.,
-       5.74712642e-003, 0., 0., 0., 5.74712642e-003, 0., 5.74712642e-003,
-       0., 0., 0., 0., 0., 0., 5.74712642e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.14942528e-002, 0., 0., 0., 5.74712642e-003,
-       1.14942528e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.14942528e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.40845068e-002, 2.11267602e-002, 7.04225339e-003,
-       7.04225339e-003, 0., 1.40845068e-002, 0., 1.40845068e-002,
-       7.04225339e-003, 0., 0., 7.04225339e-003, 0., 0., 7.04225339e-003,
-       2.81690136e-002, 0., 0., 0., 7.04225339e-003, 0., 0.,
-       2.11267602e-002, 0., 0., 0., 7.04225339e-003, 0., 7.04225339e-003,
-       0., 7.04225339e-003, 0., 0., 2.11267602e-002, 7.04225339e-003, 0.,
-       0., 0., 2.11267602e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.40845068e-002, 0., 0., 0., 0., 0., 0., 1.40845068e-002,
-       7.04225339e-003, 0., 0., 0., 0., 0., 0., 2.11267602e-002, 0.,
-       7.04225339e-003, 0., 7.04225339e-003, 0., 0., 7.04225339e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0.,
-       2.11267602e-002, 0., 0., 7.04225339e-003, 7.04225339e-003, 0., 0.,
-       7.04225339e-003, 0., 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003,
-       7.04225339e-003, 7.04225339e-003, 0., 0., 7.04225339e-003,
-       7.04225339e-003, 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0.,
-       2.81690136e-002, 0., 7.04225339e-003, 0., 3.52112651e-002,
-       7.04225339e-003, 0., 7.04225339e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.04225339e-003, 1.40845068e-002, 7.04225339e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0.,
-       7.04225339e-003, 0., 0., 0., 1.40845068e-002, 0., 7.04225339e-003,
-       0., 7.04225339e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0.,
-       7.04225339e-003, 0., 0., 0., 7.04225339e-003, 0., 0., 0.,
-       1.40845068e-002, 0., 0., 0., 0., 1.40845068e-002, 0., 0., 0.,
-       7.04225339e-003, 0., 0., 0., 0., 0., 7.04225339e-003,
-       7.04225339e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 2.11267602e-002, 7.04225339e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.04225339e-003, 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003,
-       1.40845068e-002, 0., 0., 7.04225339e-003, 0., 0., 7.04225339e-003,
-       0., 0., 7.04225339e-003, 0., 0., 0., 7.04225339e-003, 0., 0.,
-       7.04225339e-003, 7.04225339e-003, 0., 7.04225339e-003, 0., 0., 0.,
-       7.04225339e-003, 0., 0., 0., 0., 7.04225339e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 7.04225339e-003, 0., 0., 7.04225339e-003, 0.,
-       0., 7.04225339e-003, 7.04225339e-003, 0., 0., 2.81690136e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.04225339e-003, 7.04225339e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0.,
-       7.04225339e-003, 0., 0., 7.04225339e-003, 0., 0., 0.,
-       1.40845068e-002, 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0., 0., 0., 0.,
-       7.04225339e-003, 0., 0., 0., 0., 0., 7.04225339e-003, 0., 0., 0.,
-       7.04225339e-003, 0., 0., 0., 0., 0., 7.04225339e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.04225339e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 2.11267602e-002, 0., 0., 0., 0., 0., 0.,
-       0., 7.04225339e-003, 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0.,
-       7.04225339e-003, 0., 7.04225339e-003, 0., 0., 0., 0., 0.,
-       7.04225339e-003, 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.04225339e-003, 0., 0., 0., 0., 0.,
-       1.40845068e-002, 0., 0., 0., 0., 0., 9.43396240e-003,
-       1.88679248e-002, 0., 0., 1.88679248e-002, 0., 9.43396240e-003, 0.,
-       0., 0., 0., 9.43396240e-003, 9.43396240e-003, 0., 9.43396240e-003,
-       0., 9.43396240e-003, 0., 0., 0., 0., 1.88679248e-002,
-       9.43396240e-003, 2.83018872e-002, 0., 1.88679248e-002, 0.,
-       9.43396240e-003, 0., 0., 0., 0., 9.43396240e-003, 9.43396240e-003,
-       9.43396240e-003, 0., 9.43396240e-003, 9.43396240e-003,
-       9.43396240e-003, 0., 0., 0., 1.88679248e-002, 0., 0.,
-       9.43396240e-003, 0., 0., 0., 9.43396240e-003, 9.43396240e-003, 0.,
-       9.43396240e-003, 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       9.43396240e-003, 9.43396240e-003, 9.43396240e-003, 0., 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 9.43396240e-003, 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0.,
-       0., 0., 9.43396240e-003, 0., 0., 0., 9.43396240e-003, 0.,
-       9.43396240e-003, 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 9.43396240e-003, 0.,
-       0., 0., 0., 0., 0., 6.60377368e-002, 0., 9.43396240e-003, 0.,
-       5.66037744e-002, 0., 0., 9.43396240e-003, 0., 9.43396240e-003, 0.,
-       0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 9.43396240e-003,
-       0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.88679248e-002, 0., 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 9.43396240e-003, 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003,
-       9.43396240e-003, 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.43396240e-003, 0., 1.88679248e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 0.,
-       0., 0., 1.88679248e-002, 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0.,
-       9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0.,
-       0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.88679248e-002, 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 9.43396240e-003, 0., 0., 1.88679248e-002, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.43396240e-003, 0., 0., 9.43396240e-003,
-       0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 1.88679248e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 9.43396240e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 9.43396240e-003, 9.43396240e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 9.43396240e-003, 0., 9.43396240e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0.,
-       8.92857183e-003, 0., 1.78571437e-002, 0., 0., 8.92857183e-003, 0.,
-       0., 8.92857183e-003, 0., 8.92857183e-003, 0., 0., 1.78571437e-002,
-       0., 0., 0., 8.92857183e-003, 0., 0., 0., 4.46428582e-002, 0.,
-       1.78571437e-002, 0., 0., 8.92857183e-003, 0., 2.67857164e-002,
-       1.78571437e-002, 0., 0., 8.92857183e-003, 8.92857183e-003, 0., 0.,
-       0., 0., 8.92857183e-003, 0., 1.78571437e-002, 0., 1.78571437e-002,
-       2.67857164e-002, 0., 1.78571437e-002, 0., 0., 0., 0.,
-       1.78571437e-002, 0., 0., 0., 8.92857183e-003, 0., 0., 0.,
-       8.92857183e-003, 1.78571437e-002, 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 8.92857183e-003, 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0.,
-       0., 0., 0., 8.92857183e-003, 0., 8.92857183e-003, 0., 0., 0., 0.,
-       0., 0., 0., 1.78571437e-002, 0., 0., 0., 3.57142873e-002, 0., 0.,
-       1.78571437e-002, 8.92857183e-003, 0., 1.78571437e-002, 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.92857183e-003, 0., 8.92857183e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.92857183e-003, 4.46428582e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 8.92857183e-003, 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.78571437e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.78571437e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.92857183e-003,
-       8.92857183e-003, 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 8.92857183e-003, 8.92857183e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.78571437e-002, 0., 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0.,
-       8.92857183e-003, 0., 1.78571437e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.92857183e-003, 0., 8.92857183e-003, 0.,
-       8.92857183e-003, 0., 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.92857183e-003, 0.,
-       8.92857183e-003, 0., 0., 8.92857183e-003, 0., 0., 0., 0.,
-       2.67857164e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 8.92857183e-003, 0., 0., 8.92857183e-003, 0., 0., 0., 0., 0.,
-       0., 0., 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.57894742e-003, 0.,
-       6.57894742e-003, 1.31578948e-002, 0., 6.57894742e-003, 0., 0.,
-       6.57894742e-003, 1.31578948e-002, 0., 0., 6.57894742e-003, 0.,
-       6.57894742e-003, 6.57894742e-003, 0., 6.57894742e-003, 0., 0.,
-       6.57894742e-003, 6.57894742e-003, 6.57894742e-003, 0., 0.,
-       6.57894742e-003, 0., 0., 0., 0., 0., 1.31578948e-002, 0.,
-       6.57894742e-003, 6.57894742e-003, 0., 0., 0., 6.57894742e-003, 0.,
-       0., 0., 0., 6.57894742e-003, 0., 0., 1.31578948e-002, 0.,
-       4.60526310e-002, 0., 0., 1.31578948e-002, 0., 0., 6.57894742e-003,
-       6.57894742e-003, 0., 1.31578948e-002, 1.31578948e-002,
-       1.31578948e-002, 0., 0., 6.57894742e-003, 1.31578948e-002, 0., 0.,
-       0., 0., 0., 0., 6.57894742e-003, 0., 6.57894742e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.57894742e-003, 0., 0., 0., 0.,
-       6.57894742e-003, 0., 0., 0., 6.57894742e-003, 0., 6.57894742e-003,
-       6.57894742e-003, 0., 0., 1.97368413e-002, 6.57894742e-003,
-       6.57894742e-003, 0., 0., 0., 6.57894742e-003, 0., 0., 0., 0., 0.,
-       0., 6.57894742e-003, 6.57894742e-003, 0., 0., 0., 6.57894742e-003,
-       6.57894742e-003, 6.57894742e-003, 0., 1.31578948e-002, 0., 0., 0.,
-       0., 2.63157897e-002, 0., 0., 0., 2.63157897e-002, 6.57894742e-003,
-       0., 0., 0., 0., 6.57894742e-003, 0., 0., 0., 0., 0., 0.,
-       6.57894742e-003, 6.57894742e-003, 6.57894742e-003, 0., 0., 0.,
-       1.31578948e-002, 6.57894742e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.57894742e-003, 0., 0., 1.31578948e-002, 1.97368413e-002,
-       6.57894742e-003, 0., 0., 0., 0., 0., 6.57894742e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.57894742e-003, 0.,
-       0., 0., 1.31578948e-002, 6.57894742e-003, 0., 6.57894742e-003,
-       6.57894742e-003, 0., 0., 0., 0., 6.57894742e-003, 0.,
-       6.57894742e-003, 0., 6.57894742e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.57894742e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.31578948e-002, 0.,
-       1.31578948e-002, 0., 1.31578948e-002, 0., 0., 0., 0.,
-       1.31578948e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.57894742e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.57894742e-003, 6.57894742e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.57894742e-003, 2.63157897e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.31578948e-002, 6.57894742e-003, 0., 6.57894742e-003, 0., 0.,
-       1.31578948e-002, 6.57894742e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.57894742e-003, 0., 0., 0., 6.57894742e-003, 0., 0.,
-       6.57894742e-003, 0., 0., 6.57894742e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.57894742e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.57894742e-003, 0., 0., 0., 0., 0., 0.,
-       6.57894742e-003, 6.57894742e-003, 0., 0., 0., 0., 0., 0.,
-       6.57894742e-003, 0., 0., 0., 0., 0., 0., 1.31578948e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.57894742e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.31578948e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 2.63157897e-002, 0., 0., 0., 0., 0., 6.57894742e-003, 0., 0.,
-       0., 0., 0., 0., 6.57894742e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.57894742e-003, 0., 0., 6.57894742e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.57894742e-003,
-       0., 6.57894742e-003, 0., 0., 0., 0., 1.31578948e-002, 0., 0., 0.,
-       0., 0., 0., 0., 6.57894742e-003, 0., 6.57894742e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.57894742e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.57894742e-003, 0., 0., 0., 0., 6.57894742e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 6.13496918e-003,
-       6.13496918e-003, 6.13496918e-003, 2.45398767e-002, 0.,
-       6.13496918e-003, 6.13496918e-003, 0., 0., 0., 1.22699384e-002, 0.,
-       0., 1.22699384e-002, 0., 0., 6.13496918e-003, 0., 1.22699384e-002,
-       0., 1.84049085e-002, 0., 0., 6.13496918e-003, 6.13496918e-003, 0.,
-       0., 0., 0., 0., 0., 1.22699384e-002, 1.22699384e-002,
-       1.22699384e-002, 0., 0., 1.84049085e-002, 0., 0., 0.,
-       6.13496918e-003, 1.84049085e-002, 0., 0., 0., 6.13496918e-003,
-       6.13496918e-003, 0., 0., 0., 0., 0., 6.13496918e-003,
-       6.13496918e-003, 0., 6.13496918e-003, 0., 6.13496918e-003, 0., 0.,
-       0., 1.22699384e-002, 6.13496918e-003, 0., 6.13496918e-003, 0., 0.,
-       0., 1.22699384e-002, 0., 0., 1.22699384e-002, 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 1.22699384e-002, 0.,
-       0., 0., 0., 3.06748450e-002, 0., 6.13496918e-003, 0., 0., 0., 0.,
-       0., 6.13496918e-003, 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 6.13496918e-003, 6.13496918e-003, 0.,
-       0., 0., 0., 1.84049085e-002, 6.13496918e-003, 0., 1.22699384e-002,
-       3.68098170e-002, 0., 0., 0., 6.13496918e-003, 1.84049085e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.84049085e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 1.84049085e-002,
-       6.13496918e-003, 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 2.45398767e-002, 0., 6.13496918e-003, 0., 0.,
-       6.13496918e-003, 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0.,
-       6.13496918e-003, 6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 2.45398767e-002, 0., 0.,
-       6.13496918e-003, 0., 6.13496918e-003, 0., 0., 0., 6.13496918e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0.,
-       0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 6.13496918e-003, 0., 6.13496918e-003,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 6.13496918e-003, 6.13496918e-003,
-       0., 0., 0., 1.22699384e-002, 0., 0., 6.13496918e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.22699384e-002, 0., 6.13496918e-003, 0., 0., 0., 6.13496918e-003,
-       0., 0., 0., 1.84049085e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 1.22699384e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.13496918e-003, 0., 0., 6.13496918e-003, 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 1.84049085e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.22699384e-002, 0., 0., 0., 0., 0., 0.,
-       0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 6.13496918e-003,
-       1.22699384e-002, 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.13496918e-003, 0., 0., 6.13496918e-003, 6.13496918e-003, 0.,
-       0., 0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0., 0.,
-       6.13496918e-003, 0., 0., 0., 0., 0., 0., 6.13496918e-003, 0.,
-       2.45398767e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.22699384e-002, 0., 6.13496918e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.13496918e-003, 0., 0., 0., 0., 6.13496918e-003,
-       0., 0., 0., 0., 0., 7.63358781e-003, 7.63358781e-003,
-       7.63358781e-003, 1.52671756e-002, 7.63358781e-003, 0., 0.,
-       7.63358781e-003, 7.63358781e-003, 0., 1.52671756e-002,
-       7.63358781e-003, 0., 7.63358781e-003, 0., 7.63358781e-003, 0., 0.,
-       0., 0., 0., 7.63358781e-003, 7.63358781e-003, 0., 0., 0.,
-       3.05343512e-002, 0., 2.29007639e-002, 1.52671756e-002, 0.,
-       7.63358781e-003, 0., 7.63358781e-003, 7.63358781e-003, 0.,
-       7.63358781e-003, 0., 7.63358781e-003, 0., 0., 0., 0.,
-       1.52671756e-002, 0., 0., 0., 2.29007639e-002, 0., 0., 0., 0.,
-       7.63358781e-003, 0., 0., 0., 0., 7.63358781e-003, 0.,
-       7.63358781e-003, 0., 0., 7.63358781e-003, 7.63358781e-003,
-       7.63358781e-003, 0., 7.63358781e-003, 0., 0., 0., 7.63358781e-003,
-       0., 7.63358781e-003, 0., 0., 0., 0., 0., 0., 7.63358781e-003, 0.,
-       0., 0., 0., 0., 7.63358781e-003, 0., 0., 0., 7.63358781e-003, 0.,
-       0., 0., 0., 7.63358781e-003, 7.63358781e-003, 0., 0., 0.,
-       7.63358781e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.63358781e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.63358781e-003, 7.63358781e-003, 0., 0., 0., 0., 3.81679386e-002,
-       7.63358781e-003, 7.63358781e-003, 0., 3.81679386e-002,
-       1.52671756e-002, 0., 0., 1.52671756e-002, 7.63358781e-003,
-       1.52671756e-002, 7.63358781e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 7.63358781e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.52671756e-002, 0., 0., 0., 0., 0., 0., 0., 7.63358781e-003, 0.,
-       1.52671756e-002, 0., 0., 0., 0., 0., 0., 7.63358781e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.63358781e-003, 0., 0., 0., 0., 0., 0., 1.52671756e-002, 0., 0.,
-       0., 0., 7.63358781e-003, 0., 0., 0., 0., 0., 0., 7.63358781e-003,
-       0., 0., 0., 0., 0., 0., 7.63358781e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 3.05343512e-002, 0., 0., 0.,
-       0., 7.63358781e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.63358781e-003, 0., 0., 7.63358781e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.63358781e-003, 0., 0., 7.63358781e-003, 0., 0., 0., 0.,
-       7.63358781e-003, 0., 0., 7.63358781e-003, 0., 0., 7.63358781e-003,
-       7.63358781e-003, 0., 0., 7.63358781e-003, 0., 0., 0., 0., 0.,
-       7.63358781e-003, 0., 0., 1.52671756e-002, 0., 0., 0., 0.,
-       7.63358781e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 7.63358781e-003, 7.63358781e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.52671756e-002, 0.,
-       0., 0., 0., 7.63358781e-003, 0., 0., 0., 0., 2.29007639e-002, 0.,
-       0., 0., 7.63358781e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.63358781e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.63358781e-003, 0., 0., 0., 0., 0., 0., 7.63358781e-003, 0., 0.,
-       0., 7.63358781e-003, 0., 0., 0., 0., 0., 0., 7.63358781e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 7.63358781e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 2.29007639e-002, 0., 0., 7.63358781e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.52671756e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 7.63358781e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 7.63358781e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.63358781e-003, 0., 0., 0., 7.63358781e-003, 0., 0., 0.,
-       7.63358781e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.63358781e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.63358781e-003, 0., 0., 0., 0., 0., 7.81250000e-003,
-       0., 1.56250000e-002, 1.56250000e-002, 7.81250000e-003,
-       3.12500000e-002, 0., 1.56250000e-002, 7.81250000e-003, 0.,
-       7.81250000e-003, 7.81250000e-003, 7.81250000e-003, 0., 0.,
-       7.81250000e-003, 7.81250000e-003, 7.81250000e-003,
-       7.81250000e-003, 7.81250000e-003, 7.81250000e-003,
-       7.81250000e-003, 0., 0., 0., 0., 7.81250000e-003, 0., 0.,
-       1.56250000e-002, 7.81250000e-003, 2.34375000e-002, 0., 0., 0., 0.,
-       0., 0., 2.34375000e-002, 0., 0., 7.81250000e-003, 0.,
-       7.81250000e-003, 0., 0., 7.81250000e-003, 0., 2.34375000e-002, 0.,
-       7.81250000e-003, 7.81250000e-003, 0., 0., 1.56250000e-002, 0., 0.,
-       0., 0., 0., 0., 0., 7.81250000e-003, 7.81250000e-003,
-       7.81250000e-003, 7.81250000e-003, 0., 0., 1.56250000e-002,
-       7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.56250000e-002, 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.56250000e-002, 7.81250000e-003, 0.,
-       0., 7.81250000e-003, 0., 1.56250000e-002, 0., 0., 0.,
-       7.81250000e-003, 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0.,
-       0., 7.81250000e-003, 7.81250000e-003, 0., 0., 0., 0.,
-       3.90625000e-002, 0., 0., 0., 2.34375000e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 7.81250000e-003,
-       0., 0., 0., 7.81250000e-003, 0., 0., 7.81250000e-003, 0., 0.,
-       7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.56250000e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.81250000e-003, 7.81250000e-003, 0., 0., 0., 0., 0.,
-       7.81250000e-003, 0., 0., 0., 0., 7.81250000e-003, 0.,
-       7.81250000e-003, 0., 0., 0., 7.81250000e-003, 0., 7.81250000e-003,
-       0., 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.81250000e-003, 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0.,
-       1.56250000e-002, 0., 0., 0., 0., 0., 0., 0., 0., 7.81250000e-003,
-       0., 0., 0., 2.34375000e-002, 0., 0., 0., 0., 0., 7.81250000e-003,
-       7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.81250000e-003,
-       7.81250000e-003, 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0.,
-       0., 7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.81250000e-003, 0., 0., 0., 0., 7.81250000e-003,
-       3.12500000e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 1.56250000e-002, 7.81250000e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0.,
-       0., 0., 0., 7.81250000e-003, 0., 0., 7.81250000e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 7.81250000e-003,
-       7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 7.81250000e-003, 0., 0., 7.81250000e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 7.81250000e-003, 0., 0., 0., 0.,
-       7.81250000e-003, 0., 0., 7.81250000e-003, 0., 0., 0.,
-       7.81250000e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.78571437e-002, 1.78571437e-002, 0., 8.92857183e-003, 0., 0.,
-       8.92857183e-003, 0., 0., 0., 8.92857183e-003, 8.92857183e-003, 0.,
-       0., 0., 0., 0., 8.92857183e-003, 8.92857183e-003, 0.,
-       8.92857183e-003, 0., 0., 0., 2.67857164e-002, 0., 0.,
-       2.67857164e-002, 0., 1.78571437e-002, 0., 2.67857164e-002, 0., 0.,
-       0., 0., 1.78571437e-002, 1.78571437e-002, 0., 0., 0., 0., 0., 0.,
-       3.57142873e-002, 0., 1.78571437e-002, 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 8.92857183e-003, 0., 0., 0., 0.,
-       8.92857183e-003, 0., 8.92857183e-003, 8.92857183e-003, 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.78571437e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 8.92857183e-003, 0., 0., 8.92857183e-003, 0., 0.,
-       0., 8.92857183e-003, 1.78571437e-002, 0., 0., 0., 8.92857183e-003,
-       8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.78571437e-002, 0., 0., 0., 0., 0., 8.92857183e-003, 0.,
-       1.78571437e-002, 0., 0., 0., 1.78571437e-002, 8.92857183e-003, 0.,
-       0., 0., 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.92857183e-003,
-       0., 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0.,
-       8.92857183e-003, 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.92857183e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 8.92857183e-003, 8.92857183e-003, 0., 0., 0.,
-       0., 0., 0., 1.78571437e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 5.35714328e-002, 0., 1.78571437e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0.,
-       1.78571437e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 0., 1.78571437e-002, 0., 0.,
-       0., 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0., 8.92857183e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 8.92857183e-003,
-       0., 0., 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 8.92857183e-003,
-       0., 0., 0., 0., 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.92857183e-003, 0., 0., 0., 0., 0.,
-       8.92857183e-003, 0., 0., 1.78571437e-002, 0., 0., 0., 0., 0., 0.,
-       0., 8.92857183e-003, 0., 0., 8.92857183e-003, 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.92857183e-003, 8.92857183e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.78571437e-002, 8.92857183e-003, 0., 0., 0.,
-       8.92857183e-003, 0., 0., 0., 0., 0., 6.80272095e-003, 0.,
-       6.80272095e-003, 0., 0., 4.08163257e-002, 0., 6.80272095e-003,
-       1.36054419e-002, 6.80272095e-003, 0., 0., 6.80272095e-003,
-       1.36054419e-002, 6.80272095e-003, 0., 6.80272095e-003, 0., 0., 0.,
-       0., 0., 6.80272095e-003, 0., 0., 6.80272095e-003, 2.04081628e-002,
-       0., 6.80272095e-003, 0., 0., 6.80272095e-003, 0., 2.04081628e-002,
-       6.80272095e-003, 0., 0., 0., 2.72108838e-002, 6.80272095e-003, 0.,
-       0., 0., 6.80272095e-003, 0., 0., 0., 0., 1.36054419e-002,
-       6.80272095e-003, 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0., 0.,
-       0., 0., 0., 0., 6.80272095e-003, 0., 6.80272095e-003, 0., 0., 0.,
-       0., 6.80272095e-003, 0., 1.36054419e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0.,
-       0., 6.80272095e-003, 0., 0., 0., 0., 0., 1.36054419e-002,
-       1.36054419e-002, 0., 0., 0., 6.80272095e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.80272095e-003, 0., 2.04081628e-002, 0.,
-       0., 0., 0., 0., 0., 0., 1.36054419e-002, 0., 0., 6.80272095e-003,
-       4.08163257e-002, 0., 0., 0., 0., 6.80272095e-003, 0., 0.,
-       2.04081628e-002, 0., 0., 0., 0., 6.80272095e-003, 1.36054419e-002,
-       0., 0., 6.80272095e-003, 0., 6.80272095e-003, 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 0., 0., 6.80272095e-003, 0.,
-       6.80272095e-003, 0., 0., 6.80272095e-003, 4.08163257e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003,
-       1.36054419e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       4.76190448e-002, 0., 0., 0., 6.80272095e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.36054419e-002, 0., 0.,
-       0., 0., 6.80272095e-003, 0., 1.36054419e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 6.80272095e-003, 0.,
-       0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.80272095e-003, 0., 6.80272095e-003, 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 0., 2.04081628e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0.,
-       2.04081628e-002, 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0.,
-       1.36054419e-002, 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0., 0.,
-       0., 6.80272095e-003, 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0.,
-       0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 2.04081628e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.36054419e-002, 0., 0., 0., 0., 0., 6.80272095e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 0.,
-       0., 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0., 1.36054419e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.36054419e-002, 0., 0.,
-       6.80272095e-003, 0., 6.80272095e-003, 0., 0., 6.80272095e-003, 0.,
-       0., 0., 0., 0., 1.36054419e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 6.80272095e-003, 0., 0., 0., 0., 6.80272095e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0.,
-       0., 0., 1.36054419e-002, 0., 6.80272095e-003, 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 0., 6.80272095e-003, 0., 6.80272095e-003,
-       0., 0., 1.36054419e-002, 0., 6.80272095e-003, 0., 0., 0., 0.,
-       1.36054419e-002, 1.36054419e-002, 1.36054419e-002,
-       6.80272095e-003, 6.80272095e-003, 0., 6.80272095e-003, 0., 0.,
-       6.80272095e-003, 6.80272095e-003, 6.80272095e-003, 0., 0., 0., 0.,
-       1.36054419e-002, 6.80272095e-003, 6.80272095e-003, 0., 0.,
-       6.80272095e-003, 0., 6.80272095e-003, 0., 6.80272095e-003,
-       6.80272095e-003, 0., 0., 6.80272095e-003, 6.80272095e-003,
-       6.80272095e-003, 0., 0., 0., 1.36054419e-002, 3.40136066e-002,
-       6.80272095e-003, 0., 0., 0., 1.36054419e-002, 6.80272095e-003,
-       6.80272095e-003, 6.80272095e-003, 0., 0., 6.80272095e-003, 0., 0.,
-       6.80272095e-003, 0., 6.80272095e-003, 0., 0., 6.80272095e-003,
-       6.80272095e-003, 0., 1.36054419e-002, 0., 0., 0., 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0., 0.,
-       0., 0., 0., 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003,
-       1.36054419e-002, 0., 0., 0., 0., 1.36054419e-002, 0., 0., 0.,
-       6.80272095e-003, 0., 0., 0., 6.80272095e-003, 0., 6.80272095e-003,
-       0., 6.80272095e-003, 0., 0., 0., 0., 6.80272095e-003, 0., 0., 0.,
-       6.80272095e-003, 0., 1.36054419e-002, 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0.,
-       2.04081628e-002, 2.04081628e-002, 0., 6.80272095e-003, 0.,
-       6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 1.36054419e-002, 0., 0.,
-       6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 0.,
-       1.36054419e-002, 0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003,
-       0., 0., 0., 0., 1.36054419e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 6.80272095e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003,
-       0., 0., 0., 6.80272095e-003, 6.80272095e-003, 6.80272095e-003, 0.,
-       6.80272095e-003, 0., 0., 6.80272095e-003, 6.80272095e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0.,
-       6.80272095e-003, 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0., 0., 0., 0.,
-       6.80272095e-003, 1.36054419e-002, 6.80272095e-003, 0.,
-       1.36054419e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.80272095e-003, 0., 0., 6.80272095e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.36054419e-002, 0., 2.04081628e-002, 0., 0.,
-       6.80272095e-003, 0., 0., 0., 0., 6.80272095e-003, 6.80272095e-003,
-       6.80272095e-003, 0., 0., 6.80272095e-003, 6.80272095e-003, 0.,
-       6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 0., 0., 6.80272095e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3.40136066e-002, 0., 0.,
-       6.80272095e-003, 0., 0., 0., 0., 6.80272095e-003, 0., 0.,
-       6.80272095e-003, 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 6.80272095e-003, 0., 0., 0.,
-       6.80272095e-003, 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.80272095e-003, 0., 0., 0., 6.80272095e-003, 0., 0., 0., 0.,
-       0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.80272095e-003, 0., 0., 6.80272095e-003, 0., 0., 0., 0.,
-       0., 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.80272095e-003,
-       0., 0., 0., 0., 6.80272095e-003, 6.80272095e-003, 0., 0., 0., 0.,
-       0., 0., 6.80272095e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.80272095e-003, 0., 0., 0., 6.80272095e-003, 0., 1.66666675e-002,
-       8.33333377e-003, 0., 0., 0., 8.33333377e-003, 0., 1.66666675e-002,
-       0., 8.33333377e-003, 8.33333377e-003, 0., 1.66666675e-002, 0.,
-       8.33333377e-003, 8.33333377e-003, 8.33333377e-003,
-       8.33333377e-003, 8.33333377e-003, 1.66666675e-002, 0., 0.,
-       1.66666675e-002, 8.33333377e-003, 8.33333377e-003, 0., 0., 0., 0.,
-       1.66666675e-002, 0., 0., 0., 8.33333377e-003, 0., 0.,
-       8.33333377e-003, 0., 0., 8.33333377e-003, 0., 8.33333377e-003, 0.,
-       8.33333377e-003, 0., 8.33333377e-003, 0., 8.33333377e-003,
-       1.66666675e-002, 0., 0., 1.66666675e-002, 0., 0., 0.,
-       8.33333377e-003, 0., 8.33333377e-003, 1.66666675e-002, 0., 0., 0.,
-       0., 0., 0., 8.33333377e-003, 0., 8.33333377e-003, 8.33333377e-003,
-       0., 8.33333377e-003, 0., 1.66666675e-002, 0., 0., 0., 0.,
-       8.33333377e-003, 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 0., 0., 0., 8.33333377e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.33333377e-003, 0., 0., 0., 1.66666675e-002, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.66666675e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0., 8.33333377e-003,
-       8.33333377e-003, 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.33333377e-003, 8.33333377e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.66666675e-002,
-       8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 8.33333377e-003, 8.33333377e-003, 0., 0.,
-       8.33333377e-003, 0., 0., 8.33333377e-003, 0., 0., 0., 0.,
-       8.33333377e-003, 0., 8.33333377e-003, 1.66666675e-002,
-       8.33333377e-003, 0., 0., 0., 8.33333377e-003, 0., 1.66666675e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 3.33333351e-002, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 8.33333377e-003, 1.66666675e-002, 0.,
-       0., 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 1.66666675e-002, 0.,
-       0., 0., 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 0., 0., 0., 0., 8.33333377e-003, 0., 0.,
-       8.33333377e-003, 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.33333377e-003, 0., 8.33333377e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 0., 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 1.66666675e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.66666675e-002, 8.33333377e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 8.33333377e-003, 0., 0., 0.,
-       1.66666675e-002, 0., 0., 0., 0., 0., 0., 0., 1.66666675e-002, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 0., 8.33333377e-003, 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0., 8.33333377e-003,
-       8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 8.33333377e-003, 0., 0., 0., 0., 0., 0.,
-       8.33333377e-003, 0., 0., 0., 0., 0., 0., 0., 5.10204071e-003, 0.,
-       0., 0., 1.53061226e-002, 1.02040814e-002, 0., 2.55102031e-002,
-       5.10204071e-003, 1.02040814e-002, 5.10204071e-003,
-       1.53061226e-002, 1.02040814e-002, 1.53061226e-002,
-       1.53061226e-002, 0., 5.10204071e-003, 0., 1.02040814e-002, 0., 0.,
-       5.10204071e-003, 0., 0., 1.02040814e-002, 5.10204071e-003,
-       5.10204071e-003, 0., 0., 0., 5.10204071e-003, 0., 5.10204071e-003,
-       2.04081628e-002, 5.10204071e-003, 2.04081628e-002,
-       5.10204071e-003, 0., 5.10204071e-003, 0., 1.02040814e-002, 0.,
-       5.10204071e-003, 1.02040814e-002, 1.02040814e-002, 0.,
-       1.53061226e-002, 0., 0., 5.10204071e-003, 0., 0., 0., 0.,
-       5.10204071e-003, 0., 0., 5.10204071e-003, 0., 0., 0., 0., 0.,
-       1.53061226e-002, 0., 5.10204071e-003, 0., 5.10204071e-003,
-       5.10204071e-003, 5.10204071e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.10204071e-003, 0., 0., 0., 0., 5.10204071e-003,
-       5.10204071e-003, 0., 0., 0., 0., 0., 0., 0., 5.10204071e-003,
-       1.53061226e-002, 5.10204071e-003, 0., 0., 0., 0., 1.02040814e-002,
-       0., 1.53061226e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.02040814e-002, 0., 0., 1.53061226e-002, 0., 0., 0., 0.,
-       1.02040814e-002, 0., 0., 0., 1.53061226e-002, 0., 0., 0., 0.,
-       5.10204071e-003, 1.53061226e-002, 0., 5.10204071e-003, 0., 0., 0.,
-       0., 5.10204071e-003, 0., 0., 0., 1.02040814e-002, 0., 0.,
-       5.10204071e-003, 0., 5.10204071e-003, 0., 0., 0., 5.10204071e-003,
-       5.10204071e-003, 0., 0., 5.10204071e-003, 1.02040814e-002, 0., 0.,
-       0., 5.10204071e-003, 1.02040814e-002, 0., 0., 5.10204071e-003, 0.,
-       0., 0., 0., 0., 5.10204071e-003, 0., 0., 0., 0., 5.10204071e-003,
-       5.10204071e-003, 0., 0., 0., 5.10204071e-003, 5.10204071e-003, 0.,
-       0., 0., 0., 5.10204071e-003, 5.10204071e-003, 0., 5.10204071e-003,
-       0., 0., 0., 5.10204071e-003, 0., 0., 0., 1.53061226e-002, 0., 0.,
-       0., 0., 0., 0., 0., 5.10204071e-003, 0., 0., 0., 0.,
-       5.10204071e-003, 0., 0., 0., 5.10204071e-003, 0., 0., 0.,
-       5.10204071e-003, 0., 1.53061226e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 1.02040814e-002, 5.10204071e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.10204071e-003, 0., 5.10204071e-003, 0., 0., 0.,
-       0., 0., 5.10204071e-003, 0., 0., 0., 0., 5.10204071e-003, 0., 0.,
-       0., 0., 0., 0., 0., 1.02040814e-002, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.10204071e-003, 5.10204071e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 5.10204071e-003, 2.04081628e-002, 0., 0., 0., 0.,
-       0., 0., 0., 1.02040814e-002, 5.10204071e-003, 0., 0., 0.,
-       5.10204071e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 5.10204071e-003, 0., 5.10204071e-003, 5.10204071e-003,
-       0., 5.10204071e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.53061226e-002, 0., 0., 0., 0.,
-       0., 5.10204071e-003, 0., 0., 0., 1.02040814e-002, 0.,
-       5.10204071e-003, 0., 0., 0., 0., 0., 0., 5.10204071e-003, 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.10204071e-003, 0., 0., 1.02040814e-002, 0., 0., 0., 0.,
-       0., 0., 0., 5.10204071e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.10204071e-003,
-       5.10204071e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.10204071e-003, 0., 0., 0., 0., 0., 0., 0., 0., 1.02040814e-002,
-       0., 0., 0., 1.02040814e-002, 5.10204071e-003, 5.10204071e-003, 0.,
-       0., 0., 0., 0., 0., 5.10204071e-003, 0., 0., 0., 0., 0., 0.,
-       5.10204071e-003, 0., 0., 5.10204071e-003, 0., 0., 5.10204071e-003,
-       0., 1.53061226e-002, 0., 0., 0., 0., 0., 5.10204071e-003, 0., 0.,
-       0., 0., 0., 0., 0., 5.10204071e-003, 0., 0., 5.10204071e-003, 0.,
-       0., 5.10204071e-003, 0., 0., 0., 0., 0., 0., 5.10204071e-003, 0.,
-       0., 5.10204071e-003, 0., 0., 0., 1.02040814e-002, 0., 0., 0., 0.,
-       0., 5.10204071e-003, 0., 0., 0., 0., 5.10204071e-003, 0., 0., 0.,
-       0., 1.02040814e-002, 0., 0., 0., 5.10204071e-003, 5.10204071e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 1.02040814e-002, 0., 0.,
-       1.82926822e-002, 1.21951215e-002, 1.82926822e-002,
-       1.21951215e-002, 2.43902430e-002, 0., 0., 1.21951215e-002,
-       6.09756075e-003, 6.09756075e-003, 0., 6.09756075e-003,
-       6.09756075e-003, 6.09756075e-003, 1.82926822e-002, 0.,
-       6.09756075e-003, 0., 1.82926822e-002, 0., 0., 1.21951215e-002,
-       6.09756075e-003, 0., 0., 0., 0., 0., 6.09756075e-003, 0., 0., 0.,
-       0., 0., 1.21951215e-002, 0., 6.09756075e-003, 1.21951215e-002,
-       1.82926822e-002, 6.09756075e-003, 6.09756075e-003, 0., 0., 0., 0.,
-       6.09756075e-003, 1.82926822e-002, 1.82926822e-002, 0., 0.,
-       6.09756075e-003, 0., 0., 0., 6.09756075e-003, 0., 0., 0.,
-       6.09756075e-003, 0., 6.09756075e-003, 0., 0., 0., 6.09756075e-003,
-       0., 0., 1.82926822e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.09756075e-003, 0., 0., 0., 0., 6.09756075e-003, 0.,
-       1.21951215e-002, 0., 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003,
-       6.09756075e-003, 6.09756075e-003, 1.21951215e-002, 0., 0.,
-       1.21951215e-002, 6.09756075e-003, 6.09756075e-003, 0., 0., 0., 0.,
-       0., 0., 0., 6.09756075e-003, 0., 6.09756075e-003, 0.,
-       6.09756075e-003, 6.09756075e-003, 0., 0., 0., 6.09756075e-003, 0.,
-       6.09756075e-003, 0., 0., 0., 0., 0., 1.21951215e-002, 0., 0.,
-       6.09756075e-003, 6.09756075e-003, 1.21951215e-002, 0., 0., 0.,
-       6.09756075e-003, 6.09756075e-003, 0., 6.09756075e-003, 0., 0., 0.,
-       6.09756075e-003, 0., 0., 0., 0., 0., 0., 6.09756075e-003, 0., 0.,
-       6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.21951215e-002, 1.21951215e-002, 0., 0., 6.09756075e-003, 0., 0.,
-       0., 0., 6.09756075e-003, 0., 6.09756075e-003, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.21951215e-002, 0., 1.21951215e-002, 0.,
-       0., 0., 0., 0., 0., 0., 6.09756075e-003, 0., 0., 6.09756075e-003,
-       0., 6.09756075e-003, 6.09756075e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 6.09756075e-003, 0., 0., 6.09756075e-003, 0., 0.,
-       0., 0., 6.09756075e-003, 0., 1.21951215e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003, 0., 0., 0.,
-       6.09756075e-003, 0., 0., 0., 1.21951215e-002, 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.09756075e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 6.09756075e-003, 0., 0., 0., 0.,
-       6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 6.09756075e-003, 0., 6.09756075e-003, 0., 0., 6.09756075e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.09756075e-003, 2.43902430e-002, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 2.43902430e-002, 0., 6.09756075e-003, 0., 0., 0., 0.,
-       6.09756075e-003, 0., 0., 6.09756075e-003, 0., 6.09756075e-003, 0.,
-       0., 0., 0., 6.09756075e-003, 6.09756075e-003, 6.09756075e-003, 0.,
-       6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003, 0., 0., 0.,
-       6.09756075e-003, 0., 0., 0., 0., 6.09756075e-003, 1.21951215e-002,
-       0., 0., 0., 0., 0., 6.09756075e-003, 0., 6.09756075e-003, 0., 0.,
-       6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.09756075e-003, 0., 0., 0., 0., 6.09756075e-003, 0., 0.,
-       0., 0., 6.09756075e-003, 0., 0., 0., 0., 6.09756075e-003, 0., 0.,
-       0., 0., 0., 1.21951215e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003, 0.,
-       0., 0., 0., 0., 0., 0., 6.09756075e-003, 0., 0., 6.09756075e-003,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003, 0.,
-       6.09756075e-003, 0., 0., 0., 0., 6.09756075e-003, 0., 0., 0.,
-       6.09756075e-003, 6.09756075e-003, 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 6.09756075e-003, 6.09756075e-003, 0., 0., 1.21951215e-002,
-       0., 0., 0., 0., 0., 0., 0., 0., 6.09756075e-003, 0.,
-       1.66666675e-002, 1.11111114e-002, 1.11111114e-002,
-       1.66666675e-002, 0., 0., 0., 0., 1.66666675e-002, 1.11111114e-002,
-       0., 0., 0., 1.11111114e-002, 0., 5.55555569e-003, 0., 0., 0., 0.,
-       0., 0., 2.77777780e-002, 0., 5.55555569e-003, 5.55555569e-003,
-       1.11111114e-002, 0., 5.55555569e-003, 1.11111114e-002,
-       5.55555569e-003, 1.11111114e-002, 0., 2.22222228e-002, 0., 0.,
-       5.55555569e-003, 0., 0., 5.55555569e-003, 5.55555569e-003,
-       5.55555569e-003, 0., 0., 0., 1.11111114e-002, 0., 5.55555569e-003,
-       3.33333351e-002, 0., 5.55555569e-003, 5.55555569e-003, 0.,
-       5.55555569e-003, 1.11111114e-002, 0., 0., 0., 0., 0., 0., 0.,
-       1.11111114e-002, 0., 0., 0., 0., 1.11111114e-002, 1.66666675e-002,
-       0., 0., 0., 0., 5.55555569e-003, 0., 0., 0., 0., 0.,
-       5.55555569e-003, 0., 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.11111114e-002, 1.11111114e-002, 0., 0., 0., 0.,
-       1.11111114e-002, 5.55555569e-003, 0., 0., 0., 5.55555569e-003, 0.,
-       0., 0., 0., 5.55555569e-003, 0., 0., 1.11111114e-002,
-       5.55555569e-003, 0., 0., 5.55555569e-003, 5.55555569e-003,
-       1.11111114e-002, 5.55555569e-003, 0., 5.55555569e-003, 0., 0.,
-       1.66666675e-002, 0., 1.11111114e-002, 0., 0., 0., 2.77777780e-002,
-       0., 0., 0., 0., 0., 5.55555569e-003, 5.55555569e-003, 0., 0.,
-       5.55555569e-003, 0., 0., 1.11111114e-002, 0., 0., 0.,
-       5.55555569e-003, 0., 0., 1.11111114e-002, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003, 0.,
-       1.11111114e-002, 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003, 0.,
-       0., 1.11111114e-002, 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.55555569e-003, 0., 0., 0., 0., 5.55555569e-003, 0., 0.,
-       0., 1.11111114e-002, 0., 0., 0., 5.55555569e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 1.11111114e-002, 0., 0., 0., 0., 0.,
-       5.55555569e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 4.44444455e-002, 0., 5.55555569e-003, 0., 0., 0.,
-       0., 5.55555569e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.55555569e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       1.66666675e-002, 5.55555569e-003, 5.55555569e-003,
-       5.55555569e-003, 0., 5.55555569e-003, 0., 0., 0., 0.,
-       1.11111114e-002, 0., 0., 0., 0., 0., 5.55555569e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.55555569e-003, 0., 0., 5.55555569e-003,
-       0., 5.55555569e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 1.11111114e-002, 0., 0., 0., 0., 5.55555569e-003, 0.,
-       0., 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 1.11111114e-002, 0., 0., 0., 0., 0., 0.,
-       5.55555569e-003, 0., 0., 1.66666675e-002, 0., 0., 5.55555569e-003,
-       5.55555569e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 5.55555569e-003, 5.55555569e-003, 0., 0., 0., 0., 0., 0., 0.,
-       5.55555569e-003, 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003, 0., 0.,
-       1.11111114e-002, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.55555569e-003, 0., 0., 5.55555569e-003, 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 1.11111114e-002, 0., 0., 0., 0.,
-       5.55555569e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       5.55555569e-003, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 5.55555569e-003, 5.55555569e-003, 0., 0.,
-       0., 5.55555569e-003, 0., 0., 0., 5.55555569e-003, 0., 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003, 0.,
-       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 5.55555569e-003, 0., 0.,
-       1.66666675e-002, 5.55555569e-003, 0., 5.55555569e-003, 0., 0., 0.,
-       0., 0., 0., 0., 0., 0., 0., 5.55555569e-003, 0., 0., 0., 0., 0.,
-       0., 5.55555569e-003, 5.55555569e-003, 0., 0. ]
diff --git a/samples/cpp/fabmap/vocab_small.yml b/samples/cpp/fabmap/vocab_small.yml
deleted file mode 100644 (file)
index b3745db..0000000
+++ /dev/null
@@ -1,11632 +0,0 @@
-%YAML:1.0
-Vocabulary: !!opencv-matrix
-   rows: 545
-   cols: 64
-   dt: f
-   data: [ -2.23840773e-003, -1.45805170e-004, 5.83372777e-003,
-       4.78582736e-003, -6.79995958e-003, -2.73266230e-002,
-       3.78876217e-002, 4.05635685e-002, 2.39772238e-002,
-       -2.35542655e-002, 4.16107289e-002, 3.84643264e-002,
-       4.04689985e-004, 3.61579529e-004, 4.87240031e-003,
-       4.31159278e-003, -4.20301110e-002, 3.01776617e-003,
-       5.38702793e-002, 3.66228931e-002, -1.40395328e-001,
-       -1.08054712e-001, 2.43867636e-001, 2.04767004e-001,
-       2.39047572e-001, -1.60057992e-001, 2.80289233e-001,
-       2.17854336e-001, 2.53522228e-002, -1.45573737e-002,
-       4.25381958e-002, 3.34862769e-002, -2.99079753e-002,
-       2.65644658e-002, 4.65271436e-002, 4.05995697e-002,
-       -2.59213448e-001, 2.83290684e-001, 3.11675638e-001,
-       3.22893202e-001, 1.31321296e-001, 1.04262643e-001,
-       2.19351202e-001, 2.08086759e-001, 3.54408175e-002,
-       -2.20329175e-003, 4.65276241e-002, 3.26152667e-002,
-       2.98278494e-004, -6.70515292e-005, 4.70742583e-003,
-       4.15264582e-003, -3.09823938e-002, 2.70887669e-002,
-       4.53752875e-002, 4.35089581e-002, -5.31507330e-003,
-       3.55863273e-002, 3.68984751e-002, 4.59275655e-002,
-       1.82320224e-003, 1.15874631e-003, 5.14107989e-003,
-       4.71368525e-003, -5.06616198e-004, 2.05147895e-003,
-       3.35898064e-003, 4.74551553e-003, 5.69651311e-004,
-       2.54006945e-002, 2.10890882e-002, 3.99157405e-002,
-       -5.01428777e-003, 2.40984391e-002, 2.27562878e-002,
-       3.87184992e-002, -5.42908034e-004, 1.05822028e-003,
-       3.28905950e-003, 4.05709771e-003, 2.12366469e-002,
-       2.64870450e-002, 3.21609490e-002, 3.91589403e-002,
-       7.07554519e-002, 2.95910597e-001, 1.54240519e-001,
-       3.35204840e-001, -1.39442146e-001, 2.84468114e-001,
-       2.11933002e-001, 3.30289334e-001, -3.15708704e-002,
-       1.98965147e-002, 4.04352359e-002, 3.58315334e-002,
-       2.42719781e-002, -1.79040283e-002, 3.41793112e-002,
-       3.60317230e-002, 7.41999894e-002, -2.11056530e-001,
-       1.61902398e-001, 2.87930667e-001, -1.50428280e-001,
-       -2.09661797e-001, 2.18079194e-001, 2.92788655e-001,
-       -3.38707343e-002, -1.30352816e-002, 4.28731889e-002,
-       3.46324556e-002, -1.73740380e-004, -2.19622650e-003,
-       3.61105334e-003, 5.24148811e-003, 1.59536241e-004,
-       -3.20830457e-002, 2.47771144e-002, 4.71860766e-002,
-       -6.94153551e-003, -2.99014747e-002, 2.62722224e-002,
-       4.53941263e-002, -7.28746003e-004, -1.15212682e-003,
-       3.75777180e-003, 4.47807414e-003, 6.39962265e-004,
-       -2.04029749e-003, 3.88975674e-003, 4.78605507e-003,
-       6.55037118e-003, -2.74506100e-002, 2.98325233e-002,
-       4.05248478e-002, 2.22890135e-002, -2.35787760e-002,
-       3.69363390e-002, 4.05068770e-002, 1.07901613e-003,
-       -1.34838119e-004, 4.41030273e-003, 4.72284202e-003,
-       -1.30135901e-002, -1.21046929e-002, 2.60815900e-002,
-       3.20601314e-002, -1.02646472e-002, -1.42910406e-001,
-       1.34074569e-001, 2.06852108e-001, 1.82671413e-001,
-       -1.93959147e-001, 2.28636637e-001, 2.56080598e-001,
-       3.26253287e-002, -2.24077180e-002, 4.24838476e-002,
-       4.17442918e-002, -1.28750447e-002, 3.41011286e-002,
-       2.84624826e-002, 4.71641980e-002, -2.17288490e-002,
-       2.98778594e-001, 1.50262862e-001, 3.59291553e-001,
-       1.49900407e-001, 3.13571513e-001, 2.10952431e-001,
-       3.86784673e-001, 3.11150756e-002, 2.89170723e-002,
-       4.11258191e-002, 4.89541627e-002, 1.84576958e-003,
-       2.62546749e-003, 4.46394598e-003, 5.50895790e-003,
-       6.29984960e-003, 3.28875147e-002, 2.99717803e-002,
-       4.70964052e-002, 1.09767662e-002, 3.03741340e-002,
-       2.85561457e-002, 4.38149162e-002, -5.61830275e-005,
-       1.74538593e-003, 3.51823610e-003, 4.46260767e-003,
-       4.64883233e-005, 5.40048059e-004, 4.64470731e-003,
-       5.49857737e-003, 2.72302646e-002, 4.69881259e-002,
-       4.20331582e-002, 7.07317963e-002, 2.14038026e-002,
-       7.64405429e-002, 4.31087725e-002, 9.58721861e-002,
-       1.43965997e-003, 6.74130674e-003, 5.44613181e-003,
-       1.04570836e-002, 4.93450686e-002, 4.58037257e-002,
-       6.49900213e-002, 5.80696575e-002, 3.06494772e-001,
-       4.06743616e-001, 3.47406060e-001, 4.39883322e-001,
-       -9.67812445e-003, 1.98782235e-001, 1.43346861e-001,
-       2.52882421e-001, -1.63476001e-002, 1.96603462e-002,
-       3.09653431e-002, 3.33330110e-002, 6.35472685e-002,
-       1.48298843e-002, 7.52776712e-002, 4.36739400e-002,
-       1.36095494e-001, -3.95558178e-002, 2.02910945e-001,
-       1.47791564e-001, -4.28706929e-002, -3.63306254e-002,
-       1.03769362e-001, 1.01320960e-001, -1.56269651e-002,
-       -1.76056765e-003, 2.60859337e-002, 1.93906520e-002,
-       3.98196001e-003, 8.07995966e-004, 7.30827404e-003,
-       5.61313983e-003, 1.69261470e-002, -1.98163912e-002,
-       3.23840007e-002, 3.54515836e-002, -7.70552433e-004,
-       -1.75696854e-002, 2.10676249e-002, 2.89358180e-002,
-       -5.75672602e-004, -6.54784264e-004, 3.29677900e-003,
-       3.34690255e-003, -4.47988306e-004, -3.96635907e-004,
-       3.71261546e-003, 3.28005594e-003, -1.52235792e-003,
-       -1.06495516e-002, 2.08811723e-002, 2.21505221e-002,
-       7.22342450e-003, -1.07294219e-002, 2.27845330e-002,
-       2.30260212e-002, 4.22174996e-003, 5.14141633e-004,
-       6.54624728e-003, 4.31627501e-003, -1.51944747e-002,
-       1.78262137e-003, 2.84746625e-002, 2.23664977e-002,
-       -2.93665081e-002, -3.15488577e-002, 1.06725529e-001,
-       1.03039920e-001, 9.37158242e-002, -5.16995462e-003,
-       1.49795786e-001, 1.24505728e-001, 5.87471463e-002,
-       2.70866472e-002, 6.83943555e-002, 4.35000397e-002,
-       -1.81138590e-002, 2.04075500e-002, 3.58537175e-002,
-       3.65797319e-002, -2.15239134e-002, 1.88728541e-001,
-       1.55168250e-001, 2.44728342e-001, 3.54996055e-001,
-       4.11725134e-001, 3.87277037e-001, 4.41488981e-001,
-       4.46619876e-002, 6.23290949e-002, 6.35662302e-002,
-       6.96495175e-002, 1.75462186e-003, 4.82114172e-003,
-       6.19291048e-003, 7.63208140e-003, 2.36442797e-002,
-       7.04132691e-002, 4.91044521e-002, 8.04637447e-002,
-       3.99896726e-002, 4.86416966e-002, 5.33663444e-002,
-       6.54476807e-002, -1.67146209e-003, -1.27220526e-003,
-       4.96597355e-003, 4.37750714e-003, 9.66227381e-004,
-       -2.96014850e-003, 3.18601844e-003, 5.04885847e-003,
-       2.96646322e-004, -2.80020218e-002, 1.99545678e-002,
-       3.93892080e-002, 5.53441758e-004, -2.60542482e-002,
-       2.06031390e-002, 3.82976718e-002, -1.04083400e-003,
-       -2.53630406e-003, 3.24764173e-003, 4.88804467e-003,
-       -1.12808356e-002, -3.83649841e-002, 2.16235816e-002,
-       4.97278422e-002, -3.02229282e-002, -3.14814776e-001,
-       1.10802069e-001, 3.65518302e-001, 3.99985053e-002,
-       -3.20346057e-001, 1.10861398e-001, 3.72951180e-001,
-       9.67699662e-003, -4.15788814e-002, 2.01666486e-002,
-       5.28978109e-002, -1.22842155e-002, 3.74811701e-002,
-       2.17446107e-002, 4.73767519e-002, -4.65767384e-002,
-       2.79764712e-001, 1.10101879e-001, 3.27185929e-001,
-       1.82031281e-002, 2.50788867e-001, 1.02298789e-001,
-       3.05724591e-001, 9.29293875e-003, 2.95719653e-002,
-       1.93833020e-002, 4.38007712e-002, 6.90613408e-004,
-       2.61855684e-003, 3.09589389e-003, 4.95227892e-003,
-       -3.72880558e-003, 2.91409306e-002, 2.12447308e-002,
-       4.11369316e-002, -1.88071921e-003, 3.17554809e-002,
-       2.25676186e-002, 4.30514589e-002, -7.30705215e-004,
-       3.46329086e-003, 3.33467242e-003, 5.61719900e-003,
-       1.11681614e-002, 2.10514311e-002, 1.97412595e-002,
-       2.70309132e-002, -1.32659357e-003, 2.65401840e-001,
-       3.01854145e-002, 3.12005579e-001, -4.93198261e-003,
-       2.63774425e-001, 2.30455119e-002, 3.17578882e-001,
-       -1.09588567e-004, 3.38784605e-002, 4.45968518e-003,
-       4.24446501e-002, 2.06787914e-001, 8.61708634e-003,
-       2.98929423e-001, 4.71966006e-002, 7.99639598e-002,
-       1.55997872e-001, 1.79967463e-001, 2.56197095e-001,
-       -1.64327305e-002, 1.79949984e-001, 9.07244906e-002,
-       2.57656306e-001, -1.10678775e-002, 3.07309907e-002,
-       2.03141756e-002, 4.18453403e-002, 2.13108167e-001,
-       1.10010048e-002, 2.95161486e-001, 3.54198962e-002,
-       6.90176785e-002, 9.03246645e-003, 1.62276179e-001,
-       8.97402018e-002, -1.30499443e-002, -3.17033217e-003,
-       7.09738731e-002, 6.09545149e-002, -7.68624758e-003,
-       5.85683156e-004, 1.48472330e-002, 1.20609803e-002,
-       2.52990015e-002, 2.77531939e-003, 3.68549712e-002,
-       6.02000300e-003, 9.83278546e-003, -3.72600765e-003,
-       2.36107055e-002, 1.33350240e-002, -3.34310881e-003,
-       -3.31213814e-003, 1.09420540e-002, 9.15892422e-003,
-       -4.93357307e-004, 5.88192306e-005, 1.88892102e-003,
-       1.35786890e-003, 1.41431275e-003, 2.34915479e-003,
-       4.66814078e-003, 5.41197229e-003, 3.40519659e-003,
-       5.19851930e-002, 3.02428156e-002, 7.31882676e-002,
-       -2.40552519e-003, 4.28700484e-002, 2.53108777e-002,
-       7.04635680e-002, 1.61312276e-003, 3.57554504e-003,
-       4.10544593e-003, 8.55881814e-003, 4.32288796e-002,
-       8.69551394e-003, 6.30870759e-002, 3.05743460e-002,
-       2.54263043e-001, 2.66059548e-001, 3.21135759e-001,
-       3.24895352e-001, -6.29717186e-002, 3.50725859e-001,
-       1.30241290e-001, 3.82445246e-001, -1.42178191e-002,
-       4.82835174e-002, 2.92357150e-002, 5.52612469e-002,
-       4.81977016e-002, 5.53501258e-003, 7.02330172e-002,
-       2.69483905e-002, 2.83668846e-001, -1.38835702e-002,
-       3.24899167e-001, 1.16578944e-001, -2.49049701e-002,
-       -1.33585492e-002, 8.30738246e-002, 7.70169944e-002,
-       -1.31388754e-002, 2.51764292e-003, 2.21927613e-002,
-       1.53826941e-002, 5.52905956e-003, 1.99346594e-003,
-       9.19964071e-003, 4.25843941e-003, 3.39125283e-002,
-       -8.39921273e-003, 4.28450070e-002, 2.24305950e-002,
-       -2.35332322e-004, -7.90562015e-003, 1.51584297e-002,
-       1.63971093e-002, -8.19770212e-004, -2.38286302e-004,
-       2.60267640e-003, 2.13386375e-003, 2.38834647e-003,
-       -7.50835810e-004, 5.67667419e-003, 3.93949216e-003,
-       3.46644372e-002, 2.24967487e-002, 4.52967361e-002,
-       3.63315865e-002, -1.59158220e-003, 2.49080583e-002,
-       2.77491845e-002, 3.58137079e-002, -1.14613364e-003,
-       8.03122937e-004, 4.14975081e-003, 4.02934523e-003,
-       3.35200913e-002, 4.02554730e-003, 4.85638604e-002,
-       2.57301405e-002, 3.14588130e-001, 9.01470110e-002,
-       3.49137962e-001, 1.81718394e-001, -9.10726637e-002,
-       4.52047847e-002, 1.62447721e-001, 1.48703501e-001,
-       -2.54023466e-002, -3.57903284e-003, 3.72706726e-002,
-       2.72013806e-002, 3.71433198e-002, -7.94685446e-003,
-       4.90551926e-002, 2.96646543e-002, 2.51118809e-001,
-       -2.23607764e-001, 3.05163950e-001, 2.90560633e-001,
-       -1.23846576e-001, -2.62217790e-001, 1.99007213e-001,
-       3.05309951e-001, -2.14355774e-002, -2.71279141e-002,
-       3.81317772e-002, 4.03598920e-002, 1.23749452e-003,
-       -1.42892252e-003, 4.18460835e-003, 4.50564548e-003,
-       1.11593055e-002, -4.12642173e-002, 3.16474959e-002,
-       5.63254654e-002, -3.94308614e-003, -4.13183756e-002,
-       2.99611446e-002, 5.87938353e-002, 8.41489644e-004,
-       -2.61648861e-003, 4.27282089e-003, 6.20577345e-003,
-       2.15210093e-004, 2.83295522e-004, 4.13683895e-003,
-       3.47144506e-003, 2.24962924e-002, 3.05757318e-002,
-       3.82054634e-002, 3.97322699e-002, -1.23539129e-002,
-       3.19534391e-002, 3.62576172e-002, 4.20490466e-002,
-       -2.24402105e-003, 2.73249403e-004, 5.04024280e-003,
-       4.01930790e-003, 2.34371834e-002, 1.74649209e-002,
-       3.88917923e-002, 2.94167884e-002, 2.59323210e-001,
-       1.88362703e-001, 2.96269447e-001, 2.28626758e-001,
-       -2.10341185e-001, 1.39805213e-001, 2.79310644e-001,
-       2.17759088e-001, -4.00440432e-002, 2.20531295e-003,
-       5.03280796e-002, 3.05585340e-002, 3.67639363e-002,
-       1.30418856e-002, 4.60822582e-002, 2.98898723e-002,
-       1.21892810e-001, -4.19994332e-002, 2.10125163e-001,
-       1.65723249e-001, -2.95721561e-001, -2.20592991e-001,
-       3.34229052e-001, 2.60094047e-001, -2.93739606e-002,
-       -1.51236355e-002, 4.31582890e-002, 3.08249854e-002,
-       2.64525320e-003, -6.36742101e-004, 5.07212384e-003,
-       4.04421845e-003, -7.38360966e-003, -2.99136601e-002,
-       3.33957970e-002, 3.87484021e-002, -3.64676863e-002,
-       -2.30928771e-002, 4.67360020e-002, 3.81140150e-002,
-       -3.60798673e-004, 4.20351309e-004, 4.12968360e-003,
-       3.57644469e-003, -1.32571859e-003, 6.54139463e-003,
-       5.13805589e-003, 9.62157920e-003, -9.01581533e-003,
-       6.79364651e-002, 3.23920920e-002, 8.56782421e-002,
-       -1.68991219e-002, 5.62760048e-002, 3.73047180e-002,
-       7.53489062e-002, -1.21674465e-003, 1.32728263e-003,
-       5.51139517e-003, 5.83564024e-003, 1.75790899e-002,
-       2.52142604e-002, 3.37456688e-002, 3.59918997e-002,
-       2.54755560e-002, 2.28996128e-001, 1.38745755e-001,
-       2.75865793e-001, -3.02511036e-001, 2.61498988e-001,
-       3.62901509e-001, 3.19231212e-001, -5.25892489e-002,
-       8.37134849e-003, 7.48365894e-002, 3.50196734e-002,
-       1.71684306e-002, -5.33423852e-004, 3.02696563e-002,
-       1.78647041e-002, 3.53834182e-002, -3.01275589e-002,
-       1.18871912e-001, 9.66245532e-002, -3.01264703e-001,
-       -3.26512456e-002, 3.65526855e-001, 1.26873955e-001,
-       -5.87003939e-002, 3.29473522e-003, 8.32590237e-002,
-       2.84877084e-002, 9.76657495e-004, -3.77851538e-004,
-       3.82327568e-003, 2.91927136e-003, 2.34231842e-003,
-       -1.27439164e-002, 2.14447062e-002, 2.30826959e-002,
-       -3.90316918e-002, -1.45740090e-002, 5.10261171e-002,
-       2.81349365e-002, -5.98082785e-003, 1.55485666e-003,
-       1.03986179e-002, 4.43816138e-003, 4.24821349e-003,
-       -9.65262123e-004, 1.10907229e-002, 3.79467849e-003,
-       2.48473436e-002, 1.57392081e-002, 4.22193334e-002,
-       2.61627845e-002, -3.95157821e-002, 1.04935765e-002,
-       5.26626520e-002, 2.66714115e-002, -4.14158311e-003,
-       -1.36935187e-003, 8.94255284e-003, 4.34175879e-003,
-       6.31721616e-002, 3.60284955e-003, 9.83192474e-002,
-       2.67235599e-002, 1.42045945e-001, 2.18820367e-002,
-       2.39691734e-001, 1.14417590e-001, -3.28066468e-001,
-       -4.71286662e-003, 3.94637257e-001, 1.29491761e-001,
-       -2.79057734e-002, -1.54427066e-003, 6.27084598e-002,
-       2.62700859e-002, 7.24681169e-002, 8.73946643e-004,
-       9.77867767e-002, 3.16545591e-002, 4.09985445e-002,
-       -1.38429254e-001, 2.23940581e-001, 2.13532299e-001,
-       -2.77560622e-001, -1.55617386e-001, 3.87452602e-001,
-       2.43753657e-001, -2.54227873e-002, -2.27912795e-003,
-       5.80889918e-002, 3.07432916e-002, 3.89012555e-003,
-       -2.66907248e-003, 9.42590367e-003, 6.70169247e-003,
-       -1.00736963e-002, -5.92664964e-002, 4.12332974e-002,
-       7.62227699e-002, -1.56080807e-002, -5.07808216e-002,
-       4.35443111e-002, 6.94676265e-002, -8.86105583e-004,
-       -1.44870055e-003, 5.81600470e-003, 5.83413290e-003,
-       -3.73573927e-003, 9.78440046e-004, 6.85504545e-003,
-       3.87491169e-003, -2.19224263e-002, -1.31376786e-002,
-       3.95316258e-002, 2.70377696e-002, 6.23588450e-003,
-       -1.48362331e-002, 3.08888741e-002, 2.64019929e-002,
-       2.77890521e-003, 2.45906354e-004, 5.71850827e-003,
-       3.83244804e-003, -3.75685766e-002, 9.56751686e-003,
-       5.19641526e-002, 2.76500080e-002, -2.36117184e-001,
-       -4.74616177e-002, 2.93891340e-001, 1.48707137e-001,
-       1.18473612e-001, -2.94311438e-002, 2.02028409e-001,
-       1.38572618e-001, 3.62572148e-002, 1.28303478e-002,
-       4.90970910e-002, 3.13159376e-002, -2.91657858e-002,
-       1.26565527e-002, 4.72497456e-002, 2.72762235e-002,
-       -3.18792224e-001, 1.28836066e-001, 3.76148909e-001,
-       2.01063469e-001, 2.76111782e-001, 2.03172594e-001,
-       3.19292009e-001, 2.48906136e-001, 2.48469692e-002,
-       2.77657490e-002, 4.67640758e-002, 3.99161391e-002,
-       -1.45657687e-003, -2.75623839e-004, 5.32443076e-003,
-       3.47040105e-003, -2.78863832e-002, 3.58197764e-002,
-       5.04815690e-002, 4.59184386e-002, 3.41350622e-002,
-       3.23147029e-002, 4.98251989e-002, 4.56066616e-002,
-       -3.50000919e-004, -1.01677484e-004, 5.13664400e-003,
-       4.28624591e-003, 9.89927212e-004, 4.41623124e-004,
-       3.43245221e-003, 3.06127290e-003, 1.89286843e-003,
-       1.23480093e-002, 1.81654338e-002, 2.24024504e-002,
-       -1.35236196e-002, 1.29921837e-002, 2.60058437e-002,
-       2.46718712e-002, -4.42694966e-003, -5.12551575e-004,
-       7.96458218e-003, 3.86605365e-003, 1.91252120e-002,
-       -8.60670640e-004, 2.99247131e-002, 2.14081239e-002,
-       3.09080184e-002, 3.07410993e-002, 9.96437967e-002,
-       1.02420814e-001, -1.20130114e-001, 2.41689216e-002,
-       1.75219774e-001, 1.20190367e-001, -5.40535562e-002,
-       -9.00703762e-003, 7.24968985e-002, 3.23046595e-002,
-       1.93666220e-002, -4.92816344e-002, 3.42974775e-002,
-       5.85045181e-002, 4.93223630e-002, -3.84806097e-001,
-       1.38155013e-001, 4.22717363e-001, -1.56576321e-001,
-       -3.81195784e-001, 2.26639539e-001, 4.23939347e-001,
-       -4.79634181e-002, -3.52039896e-002, 6.88419566e-002,
-       5.22088930e-002, -1.17197621e-003, -4.35381755e-003,
-       3.86297260e-003, 9.28013865e-003, 3.68626497e-005,
-       -4.19749916e-002, 2.21945141e-002, 7.20882490e-002,
-       -3.62213259e-003, -3.90844308e-002, 2.49903947e-002,
-       6.82056919e-002, 2.96633661e-005, -2.33535352e-003,
-       4.47170343e-003, 6.94447849e-003, 1.26071787e-003,
-       7.85933749e-004, 5.09115402e-003, 4.73064696e-003,
-       -3.12397424e-002, -2.21502539e-002, 4.69744205e-002,
-       4.32929769e-002, -1.43592255e-002, -3.46800610e-002,
-       4.09755073e-002, 4.52331826e-002, 3.37534957e-003,
-       -1.84589109e-004, 6.20780513e-003, 4.85807052e-003,
-       -2.21218057e-002, -3.14107873e-002, 4.37492281e-002,
-       4.66236174e-002, -2.38626227e-001, -2.71817803e-001,
-       2.90395647e-001, 3.23451370e-001, 1.04014061e-001,
-       -3.88676301e-002, 2.21614793e-001, 1.87451437e-001,
-       5.04132770e-002, 1.61463600e-002, 5.95637336e-002,
-       3.70900407e-002, -3.57033648e-002, -8.46630242e-003,
-       4.74362187e-002, 3.89632881e-002, -6.24761321e-002,
-       7.58465603e-002, 1.93312734e-001, 2.01685980e-001,
-       2.85420448e-001, 2.22651139e-001, 3.18631142e-001,
-       2.85730332e-001, 3.37439440e-002, 2.36872770e-002,
-       5.02690077e-002, 4.14218083e-002, -1.25837862e-003,
-       1.67496409e-003, 5.44222072e-003, 5.56924939e-003,
-       1.29806548e-002, 4.36843336e-002, 3.88843454e-002,
-       5.36862686e-002, 3.30824591e-002, 3.48556265e-002,
-       4.84384596e-002, 4.96730916e-002, -2.74709164e-004,
-       -2.17946261e-004, 4.82326187e-003, 4.55866661e-003,
-       1.10241421e-003, 1.05224561e-003, 4.70233988e-003,
-       4.51703928e-003, 1.61316730e-002, 4.48866114e-002,
-       3.96761335e-002, 5.65250367e-002, -1.83062181e-002,
-       3.84612568e-002, 3.75689715e-002, 5.42800836e-002,
-       5.89085219e-004, 9.13972210e-004, 4.46719211e-003,
-       5.28019760e-003, 3.84759195e-002, 2.15557851e-002,
-       5.16407378e-002, 3.62993367e-002, 2.48027727e-001,
-       2.17347875e-001, 3.10197592e-001, 2.71540523e-001,
-       -2.07228765e-001, 2.75205165e-001, 2.55649835e-001,
-       3.18704486e-001, -2.45770514e-002, 3.91682014e-002,
-       4.25577983e-002, 5.02727777e-002, 4.18820567e-002,
-       -3.83256422e-003, 5.23491018e-002, 3.44806537e-002,
-       1.82845876e-001, -1.91645190e-001, 2.38697797e-001,
-       2.52401084e-001, -4.09929715e-002, -1.15990236e-001,
-       1.51587695e-001, 1.93411648e-001, -2.86246035e-002,
-       4.94819274e-003, 3.90940048e-002, 3.27391028e-002,
-       1.23746169e-003, -5.26416115e-004, 4.78526950e-003,
-       4.65767365e-003, 1.77884400e-002, -2.61192042e-002,
-       3.51225324e-002, 4.27427478e-002, 1.02264890e-002,
-       -3.17160711e-002, 3.02369948e-002, 4.34940867e-002,
-       -6.91001944e-004, -2.04336853e-003, 4.19469038e-003,
-       4.91001084e-003, 3.36124445e-004, -1.24260364e-003,
-       4.62219771e-003, 4.72282479e-003, -3.42963054e-003,
-       -3.06325871e-002, 3.05556860e-002, 4.63433154e-002,
-       -1.23451324e-002, -4.16709110e-002, 3.45609896e-002,
-       5.59019335e-002, -5.33102371e-004, -3.85896605e-003,
-       5.10730967e-003, 6.59612054e-003, -3.57003286e-002,
-       -3.37480977e-002, 5.08378670e-002, 4.73210625e-002,
-       -1.23063542e-001, -3.55430156e-001, 2.40266591e-001,
-       3.97224247e-001, -3.25407684e-002, -3.04835200e-001,
-       2.13020399e-001, 3.57529998e-001, 3.71762775e-002,
-       -1.93175208e-002, 4.93055135e-002, 4.12396118e-002,
-       -4.39904034e-002, -1.56847090e-002, 5.47321849e-002,
-       3.82458642e-002, -6.79925680e-002, 2.84791994e-003,
-       1.90873414e-001, 1.84111685e-001, 1.20009258e-001,
-       1.45440593e-001, 2.03442812e-001, 2.19590873e-001,
-       3.40065658e-002, 1.89974885e-002, 4.81042899e-002,
-       3.89660895e-002, -2.71839928e-003, 1.80459610e-004,
-       5.80643490e-003, 5.00546210e-003, 5.18574705e-003,
-       2.34277472e-002, 3.22721824e-002, 3.71964872e-002,
-       1.98352113e-002, 1.80607196e-002, 3.81789580e-002,
-       3.82592008e-002, 6.61502359e-004, -6.48299756e-004,
-       5.40223625e-003, 5.16275968e-003, 2.19575968e-003,
-       -3.84818530e-003, 5.77654224e-003, 6.64186478e-003,
-       1.70572996e-002, -5.64606600e-002, 3.98038067e-002,
-       6.72801435e-002, 2.66474169e-002, -4.24297899e-002,
-       3.97436656e-002, 5.44223711e-002, 3.21891916e-004,
-       -3.72202863e-004, 3.54885217e-003, 3.39363096e-003,
-       -1.59808490e-002, -2.03988515e-002, 3.52561288e-002,
-       3.63372788e-002, -3.28741944e-003, -2.14131206e-001,
-       1.71873078e-001, 2.78277099e-001, 3.32195997e-001,
-       -3.07503015e-001, 3.73307794e-001, 3.51594985e-001,
-       4.04536650e-002, -2.35130750e-002, 5.24488837e-002,
-       3.56360041e-002, -1.49691273e-002, 1.18477421e-003,
-       3.05151269e-002, 2.42814738e-002, -3.28159817e-002,
-       4.47103567e-002, 1.37695044e-001, 1.36804298e-001,
-       2.38008112e-001, 1.35608558e-002, 2.87483454e-001,
-       1.48942739e-001, 5.52896149e-002, -1.46915931e-002,
-       6.55776858e-002, 3.28799784e-002, -1.80373565e-004,
-       7.38456947e-005, 3.86283174e-003, 3.41505697e-003,
-       -5.29089360e-004, 1.36495447e-002, 2.46098954e-002,
-       2.68652719e-002, 2.45620143e-002, 1.45513006e-002,
-       3.77722085e-002, 2.94708479e-002, 4.65047127e-003,
-       -1.31051755e-003, 7.13860476e-003, 4.50263685e-003,
-       -6.98138494e-004, -6.38988335e-004, 4.31709737e-003,
-       4.81814519e-003, -6.32832432e-003, -1.80236194e-002,
-       2.70679407e-002, 3.37262005e-002, 4.54956805e-003,
-       -1.73884388e-002, 2.77924761e-002, 3.19622569e-002,
-       1.56917039e-003, -3.17301630e-004, 4.84537426e-003,
-       4.42272751e-003, -2.64026150e-002, 4.33786772e-003,
-       3.96052785e-002, 3.77517752e-002, -5.51256314e-002,
-       -5.75430170e-002, 1.51520520e-001, 1.73935726e-001,
-       7.56346807e-002, -4.17034887e-002, 1.51487157e-001,
-       1.49002582e-001, 2.97785737e-002, 3.21124075e-003,
-       4.19798531e-002, 3.20670232e-002, -2.55699493e-002,
-       5.38893454e-002, 4.54515368e-002, 6.48109615e-002,
-       -1.27181083e-001, 4.16281521e-001, 2.47511879e-001,
-       4.62140173e-001, 3.91330458e-002, 2.79386729e-001,
-       2.24591926e-001, 3.39507073e-001, 3.22142653e-002,
-       2.84682550e-002, 4.72158976e-002, 4.48138118e-002,
-       1.80051115e-003, 9.84718325e-004, 4.72172815e-003,
-       5.11968276e-003, -1.18690720e-002, 2.95928717e-002,
-       3.16297673e-002, 4.78018112e-002, -1.17865587e-002,
-       4.62970138e-002, 3.82096656e-002, 5.96044734e-002,
-       -3.24207242e-004, 3.17007839e-003, 5.42911002e-003,
-       6.24179700e-003, -5.63234848e-004, 4.09285072e-003,
-       4.67640255e-003, 8.23435467e-003, -4.17124573e-003,
-       3.95206995e-002, 2.60561854e-002, 6.71207756e-002,
-       -2.89049838e-003, 2.93027963e-002, 2.31961012e-002,
-       5.93198128e-002, 1.04806735e-003, 1.85548724e-003,
-       3.89577844e-003, 7.21744169e-003, 3.74405496e-002,
-       3.83486599e-002, 5.58295324e-002, 5.34969345e-002,
-       5.13848811e-002, 3.77152205e-001, 1.79161489e-001,
-       4.21310931e-001, -9.38462466e-002, 4.26250219e-001,
-       1.80673182e-001, 4.61132646e-001, -2.76903715e-002,
-       5.42913079e-002, 4.59185615e-002, 6.53212368e-002,
-       3.80461365e-002, 4.67227353e-003, 5.38022555e-002,
-       2.78558210e-002, 6.52928501e-002, -1.81847271e-002,
-       1.30877972e-001, 1.01120085e-001, -4.55324352e-002,
-       -7.16318423e-003, 1.07543908e-001, 9.24111903e-002,
-       -2.86381412e-002, 8.35110433e-003, 4.15160768e-002,
-       2.56457347e-002, 2.66725570e-003, 5.66570088e-004,
-       5.77612128e-003, 3.40505037e-003, 8.67367722e-003,
-       -9.18610021e-003, 2.09087338e-002, 2.03439482e-002,
-       -4.21086559e-003, -8.37657321e-003, 1.71094947e-002,
-       1.83828566e-002, -1.89272780e-003, 1.30746994e-004,
-       4.35057702e-003, 2.81766360e-003, 5.03752381e-003,
-       -5.78335137e-004, 9.31086671e-003, 6.97596418e-003,
-       4.04164344e-002, 4.16810699e-002, 6.19139560e-002,
-       6.68606162e-002, 2.21190937e-002, 2.78675538e-002,
-       3.34197208e-002, 3.78318913e-002, -7.01271580e-004,
-       7.98847119e-004, 2.55434634e-003, 2.58044759e-003,
-       1.02754585e-001, 1.17558232e-002, 1.13603055e-001,
-       5.56210279e-002, 1.53082758e-001, 1.46154806e-001,
-       2.31830373e-001, 2.14475483e-001, 1.41976622e-003,
-       2.10046917e-002, 8.51256698e-002, 7.10659027e-002,
-       -1.28289526e-002, 5.96782993e-005, 2.05581840e-002,
-       1.14321727e-002, 6.67123124e-002, -5.43668233e-002,
-       8.49927366e-002, 6.90845847e-002, 3.73792082e-001,
-       -3.74246061e-001, 4.23202455e-001, 4.09823418e-001,
-       6.28216378e-003, -3.11804190e-002, 9.31044072e-002,
-       8.46788511e-002, -1.42851928e-002, -2.35565403e-003,
-       2.25322954e-002, 1.31483134e-002, -7.87994184e-004,
-       7.36919348e-004, 5.94646763e-003, 5.10097574e-003,
-       8.43485892e-002, -4.58313189e-002, 9.50149223e-002,
-       6.72127157e-002, 3.19486782e-002, -4.18054014e-002,
-       4.76678535e-002, 5.17576784e-002, -6.41179504e-004,
-       -1.64614292e-003, 3.74805019e-003, 3.61942523e-003,
-       6.58383535e-004, 1.18744955e-003, 3.97546357e-003,
-       3.80331930e-003, -6.24101982e-003, 2.38983333e-002,
-       2.67522056e-002, 3.45510505e-002, -3.65258381e-002,
-       2.11754758e-002, 4.97307479e-002, 3.74160856e-002,
-       -3.30050499e-003, -1.00034196e-003, 6.96389098e-003,
-       4.47908044e-003, 2.01375615e-002, -2.52593984e-003,
-       3.25143449e-002, 2.36946493e-002, 1.01427771e-002,
-       4.03900184e-002, 1.36013746e-001, 1.33404315e-001,
-       -3.30328941e-001, 5.18405624e-002, 3.79156023e-001,
-       1.85245275e-001, -3.84104662e-002, -3.23035987e-003,
-       5.69899604e-002, 2.88269054e-002, 1.84536688e-002,
-       -3.16967368e-002, 3.63216735e-002, 4.35001515e-002,
-       9.01609883e-002, -2.19776675e-001, 1.76763177e-001,
-       2.81991929e-001, -3.25162202e-001, -1.22363165e-001,
-       3.82728875e-001, 2.47789726e-001, -3.68449837e-002,
-       -1.87987881e-003, 5.63869402e-002, 2.89910119e-002,
-       -1.33167021e-003, -2.67478940e-003, 4.98381862e-003,
-       6.58852421e-003, 8.81632511e-003, -4.57292832e-002,
-       3.44046503e-002, 6.35011047e-002, -1.66392755e-002,
-       -4.71162312e-002, 4.21529151e-002, 6.23699278e-002,
-       -2.00917549e-003, -2.84930080e-004, 5.68251917e-003,
-       4.75370185e-003, 1.80544273e-003, -4.31471090e-005,
-       4.86758444e-003, 2.91459356e-003, 2.80092675e-002,
-       3.05272359e-002, 4.62446548e-002, 3.80837880e-002,
-       -3.45457494e-002, 3.04860473e-002, 4.68125977e-002,
-       3.93562466e-002, -5.64482471e-004, 2.04025084e-004,
-       4.28620446e-003, 3.34730628e-003, 2.40965299e-002,
-       3.61315673e-003, 3.98608856e-002, 1.84947737e-002,
-       3.31346989e-001, 8.23410749e-002, 3.72676909e-001,
-       1.52649879e-001, -2.86314726e-001, 1.60884365e-001,
-       3.26304823e-001, 2.00045675e-001, -2.53282264e-002,
-       1.71123948e-002, 4.27132063e-002, 2.88287010e-002,
-       2.81202495e-002, 5.76091977e-003, 4.26688828e-002,
-       1.92351285e-002, 3.00343603e-001, -3.14961411e-002,
-       3.36743325e-001, 1.19072802e-001, -1.67005897e-001,
-       -1.66400354e-002, 2.33381763e-001, 1.18663192e-001,
-       -3.68839502e-002, 1.16336532e-002, 4.93060723e-002,
-       2.66845077e-002, 3.04342783e-003, 9.19921033e-004,
-       5.58145763e-003, 2.89529050e-003, 3.07930037e-002,
-       -1.32069429e-002, 4.14950550e-002, 2.31444351e-002,
-       -1.24327969e-002, -1.46019198e-002, 3.19796540e-002,
-       2.37175506e-002, -3.52738844e-003, 5.51524281e-004,
-       5.91230812e-003, 3.33590480e-003, 1.37414376e-003,
-       -2.25896991e-004, 4.95774997e-003, 4.19051666e-003,
-       1.69149917e-002, 2.49563754e-002, 3.55922431e-002,
-       3.97829562e-002, -9.83540900e-003, 2.47731321e-002,
-       3.10027618e-002, 4.03111428e-002, -6.17250684e-004,
-       4.49854677e-004, 4.29366948e-003, 4.60455054e-003,
-       3.02225314e-002, 1.32084824e-002, 4.46053632e-002,
-       3.26861627e-002, 1.92729354e-001, 1.00732550e-001,
-       2.55306721e-001, 2.15500534e-001, -1.08658172e-001,
-       1.16004318e-001, 1.94621086e-001, 2.22346678e-001,
-       -2.88404003e-002, 1.07095484e-002, 4.17583510e-002,
-       3.58034335e-002, 3.70168984e-002, -7.18389405e-003,
-       4.71619964e-002, 3.74235623e-002, 8.39719456e-003,
-       -2.42681041e-001, 2.13923082e-001, 3.39251190e-001,
-       -5.01429923e-002, -3.69140714e-001, 1.87279329e-001,
-       4.12515074e-001, -2.78191399e-002, -3.32804285e-002,
-       4.05107811e-002, 4.79195490e-002, 5.36393374e-004,
-       -2.89842836e-003, 4.25136462e-003, 5.89225581e-003,
-       -1.11532211e-002, -3.07406280e-002, 2.90425643e-002,
-       4.93610948e-002, -1.61928707e-003, -1.74246170e-002,
-       2.26078443e-002, 4.07558121e-002, 6.98779768e-004,
-       -1.18141191e-003, 3.53922253e-003, 5.09616220e-003,
-       8.82607303e-004, -4.95884684e-004, 4.13070386e-003,
-       4.64667147e-003, -1.60062425e-002, -4.17196825e-002,
-       3.12348008e-002, 5.73412031e-002, 1.47182005e-003,
-       -5.11823744e-002, 3.15971933e-002, 6.47349209e-002,
-       -1.32723816e-003, -3.07547441e-003, 4.82989522e-003,
-       6.19664928e-003, -2.80217696e-002, -4.51532081e-002,
-       4.94651347e-002, 6.31105155e-002, -2.06022292e-001,
-       -2.72125453e-001, 2.92908639e-001, 4.49570090e-001,
-       1.07837409e-001, -2.24769861e-001, 2.14156285e-001,
-       3.51343840e-001, 1.98722556e-002, -3.18982117e-002,
-       3.96654233e-002, 4.88475747e-002, -3.08895539e-002,
-       -1.51829440e-002, 4.84469868e-002, 5.15550300e-002,
-       -9.20621678e-002, -5.02680466e-002, 1.96435809e-001,
-       2.54790872e-001, 5.53626679e-002, -4.89128530e-002,
-       1.52903080e-001, 1.94468543e-001, 2.39952896e-002,
-       -1.16555532e-002, 3.57371494e-002, 3.58544290e-002,
-       -1.70265825e-003, 2.08158192e-004, 5.40921651e-003,
-       5.92229934e-003, -1.04794027e-002, 1.84995327e-002,
-       3.10572367e-002, 3.93100083e-002, 2.65617343e-003,
-       1.81969460e-002, 2.62126662e-002, 3.58002633e-002,
-       1.27488864e-003, 7.31205335e-004, 4.46448429e-003,
-       4.93388344e-003, 1.42980239e-003, 2.54960760e-004,
-       4.61151032e-003, 4.36816551e-003, 1.36019299e-002,
-       2.29205396e-002, 3.62480693e-002, 4.47757244e-002,
-       -1.17766894e-002, 2.11010724e-002, 3.61599997e-002,
-       4.42413874e-002, -1.24310004e-003, 2.46367708e-004,
-       4.53805830e-003, 4.21015918e-003, 1.25484597e-002,
-       -7.30976462e-003, 3.57345790e-002, 2.91567445e-002,
-       1.69873387e-001, -1.24379210e-001, 2.72533834e-001,
-       2.89070249e-001, -9.57392901e-002, -2.25275289e-002,
-       2.89393932e-001, 2.48136163e-001, -1.73103735e-002,
-       -3.57852574e-003, 4.11753654e-002, 3.19498330e-002,
-       1.12949805e-002, 4.45119990e-003, 3.52766626e-002,
-       2.84482930e-002, 2.12300256e-001, 1.28947869e-001,
-       2.95956880e-001, 2.99868524e-001, -1.88016951e-001,
-       -2.21467130e-002, 3.35298449e-001, 2.68390566e-001,
-       -1.10384226e-002, -8.51244107e-003, 3.85704264e-002,
-       3.13261747e-002, 1.46122405e-003, -1.41291501e-004,
-       4.71794000e-003, 4.10273857e-003, 1.39183011e-002,
-       -2.55074315e-002, 3.81155536e-002, 4.40104976e-002,
-       -2.22028643e-002, -1.84843093e-002, 4.16928791e-002,
-       4.31742258e-002, 5.02285218e-007, 5.55108709e-004,
-       4.44004964e-003, 4.12418507e-003, 3.87760974e-003,
-       -7.58353621e-004, 6.67272089e-003, 4.07037139e-003,
-       4.31991257e-002, 2.79247928e-002, 5.56175113e-002,
-       4.17700931e-002, 2.79648416e-003, 2.59406716e-002,
-       2.67337002e-002, 3.61059569e-002, -1.49655752e-004,
-       1.43592618e-003, 3.36773088e-003, 3.67088104e-003,
-       4.02040482e-002, -2.41892692e-003, 5.51913828e-002,
-       2.30305381e-002, 3.68978232e-001, 7.17703030e-002,
-       4.09149617e-001, 1.56966045e-001, -4.06015068e-002,
-       5.83019070e-002, 1.03540055e-001, 9.90400463e-002,
-       -1.22829778e-002, 4.86336928e-003, 2.31508855e-002,
-       1.61370952e-002, 3.05507798e-002, -6.98052766e-003,
-       4.80294079e-002, 2.33587082e-002, 4.28223491e-001,
-       -1.41305268e-001, 4.60701704e-001, 1.99027866e-001,
-       -3.46333012e-002, -5.09534553e-002, 1.07162304e-001,
-       9.94921178e-002, -1.27677033e-002, -3.71547253e-003,
-       2.36987844e-002, 1.59694050e-002, 1.69674703e-003,
-       5.81638422e-004, 5.28557645e-003, 3.76073364e-003,
-       5.40124327e-002, -3.32987309e-002, 6.52195737e-002,
-       4.90081385e-002, 1.10864099e-002, -3.46896350e-002,
-       3.31475288e-002, 4.53536734e-002, -2.40949681e-004,
-       -1.79581181e-003, 3.57653922e-003, 4.09992691e-003,
-       4.50140331e-004, 1.62169209e-003, 5.26480749e-003,
-       5.15386648e-003, -1.25963881e-003, 2.88252644e-002,
-       3.38862613e-002, 4.58878353e-002, -9.84541979e-003,
-       2.26681978e-002, 2.91514210e-002, 4.04687300e-002,
-       -3.81247606e-004, 5.20769856e-004, 3.88591806e-003,
-       4.17396706e-003, 3.55546661e-002, 1.19367028e-002,
-       5.63235246e-002, 3.67497839e-002, -6.59136251e-002,
-       1.80359706e-001, 3.24767500e-001, 3.04279387e-001,
-       -1.36861622e-001, 9.75617990e-002, 2.50658244e-001,
-       2.48833686e-001, -1.89363007e-002, 9.13301110e-003,
-       3.70825306e-002, 2.92979572e-002, 3.22120376e-002,
-       -1.15756467e-002, 5.63854575e-002, 3.83141786e-002,
-       5.04945368e-002, -9.48792621e-002, 3.36740494e-001,
-       2.97641307e-001, -1.38091460e-001, 1.08720779e-001,
-       2.73554504e-001, 3.03473830e-001, -2.75880061e-002,
-       7.80153880e-003, 4.43335772e-002, 3.46074216e-002,
-       7.69617211e-004, -9.65687868e-005, 5.53147960e-003,
-       5.12566231e-003, 1.11859841e-002, -2.62650102e-002,
-       4.08181325e-002, 5.49963787e-002, -6.84863748e-003,
-       -3.72366831e-002, 3.78905535e-002, 5.93900569e-002,
-       -1.94035145e-003, -4.46942431e-004, 5.41484123e-003,
-       5.61271468e-003, -7.11588887e-004, -3.71292526e-006,
-       5.91454282e-003, 3.47895687e-003, -2.89339870e-002,
-       -2.75948737e-002, 5.01510464e-002, 3.72860245e-002,
-       4.70629185e-002, -2.51456369e-002, 6.01770431e-002,
-       3.63556966e-002, 2.06766208e-003, 1.09235034e-003,
-       5.72754769e-003, 3.20768752e-003, -2.97030061e-002,
-       -1.63633991e-002, 5.07555678e-002, 2.85181068e-002,
-       -2.00849205e-001, -1.11773700e-001, 2.77860969e-001,
-       1.66473165e-001, 3.98672014e-001, -8.38116407e-002,
-       4.37409759e-001, 1.54861093e-001, 2.80071758e-002,
-       -6.13273168e-003, 4.78500053e-002, 2.04337556e-002,
-       -4.07708324e-002, -9.69395321e-003, 5.41419275e-002,
-       2.53516044e-002, -8.41575041e-002, 2.64919680e-002,
-       1.94101855e-001, 1.13964006e-001, 3.12516749e-001,
-       2.55565941e-002, 3.59135628e-001, 1.25417560e-001,
-       3.74428034e-002, -9.46382061e-003, 5.48927598e-002,
-       2.32917257e-002, -3.83153837e-003, -4.90099366e-004,
-       6.56587211e-003, 3.34663247e-003, -3.37026082e-003,
-       1.32123567e-002, 2.96183750e-002, 2.28380691e-002,
-       3.41917798e-002, 1.33528411e-002, 4.62681875e-002,
-       2.45943312e-002, 3.78513872e-003, -1.24705641e-003,
-       6.96970895e-003, 3.63916019e-003, -8.29251774e-004,
-       -4.04625134e-005, 4.81630210e-003, 3.18062725e-003,
-       -1.02135567e-002, -1.66181289e-002, 3.16474214e-002,
-       2.67384537e-002, 2.71271653e-002, -1.46471905e-002,
-       4.35810387e-002, 2.78550945e-002, 6.96915109e-003,
-       2.25744653e-003, 9.14048124e-003, 4.54847701e-003,
-       -2.33637504e-002, -4.01911419e-003, 3.92615609e-002,
-       2.03737970e-002, -7.99917355e-002, -5.38458303e-002,
-       1.71351478e-001, 1.13179870e-001, 3.10916841e-001,
-       1.86353289e-002, 3.60559553e-001, 1.35549933e-001,
-       5.53980768e-002, 1.76782943e-002, 6.97571039e-002,
-       2.84575392e-002, -2.86954902e-002, -1.72395259e-004,
-       4.26688232e-002, 2.13792268e-002, -4.09252346e-002,
-       4.50119004e-002, 1.61574289e-001, 1.13632940e-001,
-       4.54430789e-001, 1.56103924e-001, 4.85478461e-001,
-       1.94303319e-001, 2.77564451e-002, 9.22238734e-003,
-       4.88271862e-002, 2.14804504e-002, -2.13092216e-003,
-       4.14742331e-004, 5.63488202e-003, 3.62746185e-003,
-       9.40661132e-003, 2.62817312e-002, 3.39161344e-002,
-       3.49426530e-002, 6.36723861e-002, 2.93633714e-002,
-       7.12636709e-002, 4.04762849e-002, 1.68982442e-004,
-       -1.23837695e-003, 5.12331771e-003, 3.25017353e-003,
-       -9.82108060e-004, -8.32006393e-004, 5.31202601e-003,
-       4.25132504e-003, -4.95227519e-003, -3.76701467e-002,
-       3.30872163e-002, 5.70167489e-002, -1.57988712e-003,
-       -3.66110504e-002, 2.51725968e-002, 6.20667487e-002,
-       -2.39295908e-003, -3.26834270e-003, 4.63009067e-003,
-       7.78701855e-003, -4.20058854e-002, -9.26621910e-003,
-       5.94654605e-002, 2.64846068e-002, -2.52715886e-001,
-       -2.79938251e-001, 3.20772082e-001, 3.29678088e-001,
-       3.83910760e-002, -3.28467786e-001, 1.19357876e-001,
-       3.71824503e-001, 1.07546290e-002, -3.98523398e-002,
-       2.51158513e-002, 4.92743105e-002, -4.72148247e-002,
-       -2.88923644e-003, 6.50699288e-002, 2.25365367e-002,
-       -2.87712514e-001, 3.66899930e-002, 3.36406261e-001,
-       1.24754377e-001, 2.50968412e-002, 3.06040179e-002,
-       9.43311378e-002, 1.06742918e-001, 1.20985629e-002,
-       -9.98504838e-005, 2.12908201e-002, 1.94367226e-002,
-       -5.59439510e-003, -1.24111550e-003, 8.62212386e-003,
-       3.42187169e-003, -3.35270353e-002, 1.04624778e-002,
-       4.62805815e-002, 2.42543593e-002, 5.96485857e-004,
-       1.17723020e-002, 1.84583366e-002, 2.28339192e-002,
-       4.63247270e-004, 6.79799065e-004, 2.84932810e-003,
-       3.00764199e-003, -2.94958637e-003, 1.65782997e-003,
-       7.47142080e-003, 3.14219785e-003, -4.29947935e-002,
-       -1.33065572e-002, 6.55312389e-002, 2.66569946e-002,
-       4.83469479e-003, -1.52406683e-002, 3.36950049e-002,
-       2.92297862e-002, 4.21821699e-003, 5.46025462e-004,
-       9.37048532e-003, 4.15355945e-003, -2.26233173e-002,
-       2.43523717e-003, 5.23093604e-002, 1.36700785e-002,
-       -3.55755150e-001, -2.71105599e-002, 4.77553844e-001,
-       1.03395432e-001, 2.72707306e-002, -3.52606736e-002,
-       1.84082508e-001, 1.10759221e-001, 5.81315942e-002,
-       1.53060525e-003, 8.88718963e-002, 2.63613556e-002,
-       -2.41119824e-002, -2.20160559e-003, 5.45895286e-002,
-       1.35779837e-002, -3.47375602e-001, 3.27776745e-002,
-       4.78795826e-001, 1.09530412e-001, 2.94232406e-002,
-       4.21646163e-002, 2.02073202e-001, 1.06839612e-001,
-       5.82773127e-002, 2.21337448e-003, 9.18661654e-002,
-       2.62792818e-002, -3.38289910e-003, -1.37207471e-003,
-       8.15750100e-003, 2.96857394e-003, -4.07727659e-002,
-       1.61374081e-002, 6.52055666e-002, 2.99411677e-002,
-       4.12037596e-003, 1.71990227e-002, 3.74386944e-002,
-       3.05993389e-002, 3.86472698e-003, -5.08413126e-004,
-       9.84979421e-003, 4.27141879e-003, 4.17772261e-003,
-       6.49777846e-003, 1.07172374e-002, 1.41086346e-002,
-       -9.92022082e-003, 8.94793496e-002, 4.03430611e-002,
-       1.52924463e-001, -3.84547806e-004, 6.83634430e-002,
-       3.00866831e-002, 1.32382378e-001, -1.57749199e-003,
-       4.52582538e-003, 7.94081017e-003, 1.31349359e-002,
-       1.18417867e-001, 2.14056820e-002, 1.82778001e-001,
-       5.03992476e-002, 4.28859815e-002, 2.71563351e-001,
-       2.06897676e-001, 3.43189627e-001, -7.18206391e-002,
-       3.33693832e-001, 1.77947834e-001, 4.05817181e-001,
-       -9.98187438e-002, 2.74093151e-002, 1.39393091e-001,
-       5.17537929e-002, 1.19557492e-001, 1.53188258e-002,
-       1.78525880e-001, 3.94865200e-002, 5.03927730e-002,
-       3.22342990e-003, 1.57122299e-001, 9.96723399e-002,
-       -1.00750685e-001, -1.99685916e-002, 1.76948622e-001,
-       1.10291354e-001, -9.87683833e-002, -3.55594303e-003,
-       1.44022048e-001, 3.20415720e-002, 1.05560618e-002,
-       2.48985249e-003, 1.73547808e-002, 4.89800656e-003,
-       4.99845017e-003, -5.92993898e-003, 2.44251397e-002,
-       1.72289107e-002, -1.75383259e-002, -7.31516909e-003,
-       2.86991596e-002, 2.14440189e-002, -9.94609948e-003,
-       1.94437546e-003, 1.59174390e-002, 5.56246378e-003,
-       -1.46691897e-003, 5.78336010e-004, 4.88652848e-003,
-       3.68005084e-003, -1.34024955e-003, -1.04918834e-002,
-       2.58407462e-002, 2.51803622e-002, 2.46862229e-002,
-       -9.49828140e-003, 4.20222990e-002, 2.77113840e-002,
-       5.45754610e-003, 2.19218084e-003, 8.69189389e-003,
-       4.98845568e-003, -2.50467248e-002, 1.22842919e-002,
-       4.15801182e-002, 3.06094289e-002, -5.18082194e-002,
-       3.37995552e-002, 1.65126160e-001, 1.53380916e-001,
-       2.43592232e-001, 3.36746909e-002, 3.43700320e-001,
-       1.66511580e-001, 5.29475138e-002, 1.68721117e-002,
-       7.13462532e-002, 3.44519690e-002, -2.49897540e-002,
-       3.02966461e-002, 4.57733050e-002, 4.51539829e-002,
-       -9.51977670e-002, 2.34089851e-001, 2.12499425e-001,
-       3.02036554e-001, 2.82479674e-001, 2.15039939e-001,
-       3.85761052e-001, 2.80138105e-001, 4.13482934e-002,
-       1.38863698e-002, 5.92885055e-002, 2.98719667e-002,
-       1.28221139e-003, 2.34964048e-003, 5.40695619e-003,
-       5.72700892e-003, -8.32718890e-003, 4.44055386e-002,
-       3.69981192e-002, 5.65049872e-002, 2.19191872e-002,
-       4.33674566e-002, 4.36836109e-002, 5.45167625e-002,
-       1.04896678e-003, -6.71892076e-006, 4.91152657e-003,
-       3.59626114e-003, -2.60246661e-003, 1.71481154e-003,
-       7.63114402e-003, 5.12429466e-003, -4.03376184e-002,
-       -1.66576020e-002, 5.68739399e-002, 4.07866687e-002,
-       -9.37322993e-003, -1.90691072e-002, 2.87755635e-002,
-       3.41233127e-002, 6.94859948e-004, -8.46471346e-004,
-       3.79526755e-003, 3.69578740e-003, -4.35023941e-002,
-       -9.62770078e-003, 6.63781092e-002, 3.57012190e-002,
-       -2.89529741e-001, -1.27961114e-001, 3.60951602e-001,
-       2.24728331e-001, 6.03925111e-003, -3.81611213e-002,
-       1.27240494e-001, 1.40888855e-001, 1.59262922e-002,
-       -8.77114071e-004, 2.75906045e-002, 2.22755056e-002,
-       -4.61787619e-002, 1.46949766e-002, 6.42802417e-002,
-       3.84527445e-002, -2.34910086e-001, 2.76701808e-001,
-       3.27686995e-001, 3.48263681e-001, -7.70635623e-003,
-       2.11402848e-001, 1.46402583e-001, 2.76571721e-001,
-       1.40228570e-002, 1.93870552e-002, 2.89932657e-002,
-       3.39106172e-002, -1.06857880e-003, 5.31880127e-004,
-       5.80959162e-003, 4.85768449e-003, -2.01628637e-002,
-       3.82937156e-002, 4.54273820e-002, 5.79514354e-002,
-       -1.78685207e-002, 4.16031182e-002, 3.77997570e-002,
-       6.00795336e-002, -1.39915559e-003, 3.40826157e-003,
-       4.83534625e-003, 6.62761787e-003, -1.40314351e-003,
-       1.34507252e-003, 7.76218623e-003, 5.51237119e-003,
-       -1.96583178e-002, -2.44641751e-002, 5.22860326e-002,
-       4.55261022e-002, 1.45317577e-002, -2.25955620e-002,
-       4.55775484e-002, 4.31148559e-002, 2.55248439e-003,
-       5.47986070e-004, 6.85400376e-003, 4.95699374e-003,
-       -4.19742651e-002, -1.21669024e-002, 7.05902576e-002,
-       4.16005142e-002, -1.32840037e-001, -8.94111693e-002,
-       3.49115759e-001, 2.54492581e-001, 1.37017131e-001,
-       -4.66351733e-002, 2.90170789e-001, 2.14515388e-001,
-       4.45895679e-002, 1.95438261e-004, 6.34036362e-002,
-       3.64510641e-002, -5.74061796e-002, -1.61165418e-003,
-       7.63359144e-002, 3.97692695e-002, 4.89251912e-002,
-       1.58067092e-001, 3.21902931e-001, 2.73245960e-001,
-       7.59716183e-002, 1.97337762e-001, 3.03884208e-001,
-       2.73392171e-001, 4.29517180e-002, 1.44712087e-002,
-       6.24329038e-002, 3.75150107e-002, -2.59948149e-003,
-       1.09397795e-003, 7.83136394e-003, 5.46408258e-003,
-       1.12996865e-002, 3.09248697e-002, 4.69215624e-002,
-       4.85606343e-002, 8.53968039e-003, 2.72372141e-002,
-       4.52250279e-002, 4.53648232e-002, 8.94372235e-004,
-       2.41726491e-004, 5.92491217e-003, 4.85244021e-003,
-       -1.40903576e-003, -8.90507692e-007, 4.89218952e-003,
-       4.26443666e-003, -1.77858546e-002, -2.20354758e-002,
-       3.41736898e-002, 3.88980322e-002, 9.76457726e-003,
-       -2.15768963e-002, 2.96735726e-002, 3.81731316e-002,
-       6.00321218e-004, -5.83299552e-004, 4.58148681e-003,
-       4.69760224e-003, -2.10971218e-002, -1.04310960e-002,
-       3.93711701e-002, 3.57526876e-002, -1.51606053e-001,
-       -2.12983470e-002, 2.33225867e-001, 2.13611633e-001,
-       9.24635828e-002, -2.10329816e-002, 1.87323734e-001,
-       2.06718698e-001, 1.61935445e-002, -8.37448612e-003,
-       3.52249816e-002, 3.61254774e-002, -1.87978204e-002,
-       2.04227283e-003, 3.57946120e-002, 6.89028278e-002,
-       -7.46450499e-002, 9.28569138e-002, 1.71603203e-001,
-       5.33014536e-001, 2.63063721e-002, 8.39180127e-002,
-       1.45311460e-001, 4.82435286e-001, 1.51303606e-002,
-       1.67642604e-003, 3.14138308e-002, 6.27509877e-002,
-       1.60100491e-004, 3.53178941e-003, 4.54883371e-003,
-       7.49536185e-003, -1.07583811e-003, 4.41251621e-002,
-       2.75762640e-002, 6.85375333e-002, -6.68003922e-003,
-       4.90951426e-002, 2.65841074e-002, 7.22953230e-002,
-       -1.16300117e-003, 5.17055765e-003, 4.63545322e-003,
-       8.87822174e-003, -1.16091559e-003, -1.32736168e-003,
-       5.26378723e-003, 6.80209929e-003, -1.28726782e-002,
-       -2.80939266e-002, 3.43248546e-002, 5.19997366e-002,
-       -1.09478564e-003, -2.84143761e-002, 3.27871256e-002,
-       5.09873442e-002, 3.68861511e-004, -1.60663889e-003,
-       4.65880614e-003, 6.42652577e-003, -3.20060141e-002,
-       4.21623513e-003, 4.64737490e-002, 5.35398461e-002,
-       -9.94165465e-002, -4.08936106e-002, 2.09142640e-001,
-       3.24193448e-001, 8.36718976e-002, 2.60369945e-002,
-       1.77627951e-001, 3.15471798e-001, 1.51287764e-002,
-       4.87353466e-003, 3.51394489e-002, 4.27329466e-002,
-       -2.21638903e-002, 3.46084535e-002, 4.32780795e-002,
-       5.26525155e-002, -2.94106960e-001, 1.50713429e-001,
-       3.69871944e-001, 3.27524900e-001, 1.26131311e-001,
-       -3.69696878e-002, 2.16174394e-001, 2.96077371e-001,
-       1.68672111e-002, 3.06555699e-003, 3.86780985e-002,
-       4.12441418e-002, -6.26371882e-004, -8.17050692e-004,
-       4.77662776e-003, 5.69377141e-003, -2.89926659e-002,
-       3.98196541e-002, 4.67030704e-002, 6.71586469e-002,
-       -2.19510635e-003, 5.69822676e-002, 3.76643538e-002,
-       7.52915666e-002, -2.66765303e-004, 2.85428343e-003,
-       5.69314696e-003, 7.52491131e-003, -9.18843783e-003,
-       2.63924641e-003, 1.20140668e-002, 4.82413592e-003,
-       -1.95528958e-002, -1.31726954e-002, 4.39164117e-002,
-       2.70254239e-002, 8.97742715e-003, -1.52177429e-002,
-       2.78257821e-002, 2.69922521e-002, 2.27250959e-004,
-       -2.92777491e-004, 4.23039682e-003, 3.47427744e-003,
-       -6.69676214e-002, 1.89819504e-002, 8.64558145e-002,
-       3.04277744e-002, -2.65465677e-001, -6.45449094e-004,
-       3.73301357e-001, 1.33107752e-001, 6.95367083e-002,
-       -5.77776693e-002, 1.36275843e-001, 1.14135765e-001,
-       1.77109614e-002, -4.25556069e-003, 3.18907984e-002,
-       2.11644918e-002, -3.28085795e-002, 9.68584511e-003,
-       6.28186241e-002, 2.28248965e-002, -4.46789771e-001,
-       1.44410163e-001, 5.27516484e-001, 1.89557865e-001,
-       7.12090582e-002, 3.13203931e-002, 1.43156335e-001,
-       1.06296346e-001, 2.02624835e-002, 1.92301569e-003,
-       3.33552696e-002, 2.17506960e-002, -5.39654691e-004,
-       -1.46354514e-003, 7.22942874e-003, 3.37538612e-003,
-       -7.07226172e-002, 2.55927667e-002, 8.55576098e-002,
-       3.72908413e-002, 1.70146232e-003, 1.86495110e-002,
-       3.10686603e-002, 3.02251074e-002, 1.27966423e-003,
-       3.97871336e-004, 4.41703759e-003, 3.77890421e-003,
-       5.72360866e-003, -1.63266133e-003, 8.24184436e-003,
-       4.28640144e-003, 1.05626984e-002, 7.54221249e-003,
-       2.18154937e-002, 1.79711934e-002, -1.05806638e-003,
-       6.48329221e-003, 1.28087271e-002, 1.39213940e-002,
-       -6.14859397e-004, 1.28077314e-004, 2.19311845e-003,
-       1.92590756e-003, 6.43069297e-002, -2.41935346e-002,
-       7.80989155e-002, 4.07582037e-002, 1.18673936e-001,
-       -1.08949132e-002, 1.74268886e-001, 1.06822729e-001,
-       -2.00369842e-002, 1.17094098e-002, 7.31786117e-002,
-       6.93155527e-002, -1.11003546e-002, -1.85148267e-003,
-       1.91142894e-002, 1.47923604e-002, 4.40617800e-002,
-       -4.04822379e-002, 6.27488717e-002, 5.25459424e-002,
-       2.74913102e-001, -4.00513232e-001, 3.25244904e-001,
-       4.34939593e-001, -2.81927027e-002, -3.07615012e-001,
-       1.39715835e-001, 3.47727358e-001, -1.14661511e-002,
-       -3.92788313e-002, 2.79398300e-002, 4.78677079e-002,
-       -5.19864943e-006, -1.22141629e-003, 4.14072024e-003,
-       4.85045416e-003, 1.66722517e-002, -4.18125503e-002,
-       3.35686542e-002, 6.25395104e-002, 1.01584597e-002,
-       -5.50983436e-002, 3.64643633e-002, 7.74607733e-002,
-       2.16501323e-003, -5.04283095e-003, 5.16946893e-003,
-       9.28667840e-003, 3.55724915e-004, 1.56175531e-003,
-       4.24759975e-003, 5.23077790e-003, 6.31232606e-003,
-       3.63167189e-002, 3.00651956e-002, 5.58400452e-002,
-       -9.15933773e-003, 3.52820307e-002, 3.18862088e-002,
-       5.64292111e-002, -5.08213299e-004, 9.78757977e-004,
-       4.13047336e-003, 5.11607807e-003, 2.68853251e-002,
-       6.81048585e-003, 4.14324850e-002, 3.53803635e-002,
-       1.75981089e-001, 1.07409544e-001, 2.54122764e-001,
-       3.54103595e-001, -2.03560248e-001, 1.09503455e-001,
-       3.05689454e-001, 3.89076114e-001, -2.63544675e-002,
-       7.24151824e-003, 4.23099697e-002, 3.93533371e-002,
-       2.45407224e-002, -1.96986017e-003, 4.08603176e-002,
-       2.74269879e-002, 1.75637275e-001, -4.21638228e-002,
-       2.50617921e-001, 1.88746929e-001, -1.86518833e-001,
-       -3.65162157e-002, 2.77257264e-001, 2.08560839e-001,
-       -2.68864725e-002, 6.82722253e-004, 4.27449793e-002,
-       3.13445143e-002, 1.79230445e-003, 4.13984299e-006,
-       4.94025694e-003, 3.92910698e-003, 1.61281265e-002,
-       -2.06321944e-002, 3.41071710e-002, 3.59256603e-002,
-       -1.85074452e-002, -2.12109983e-002, 3.72946262e-002,
-       3.71087492e-002, -1.78461976e-003, 1.97266825e-004,
-       5.07350359e-003, 4.33710730e-003, -2.82683503e-003,
-       -1.19359128e-003, 6.62868097e-003, 5.99570293e-003,
-       3.14087514e-003, -2.78334226e-002, 3.19014974e-002,
-       4.70953844e-002, 9.51705780e-003, -2.25657690e-002,
-       3.14052664e-002, 4.61520329e-002, -6.42713567e-004,
-       -1.36902626e-003, 4.89500165e-003, 5.97935729e-003,
-       -4.94960323e-002, 1.60539020e-002, 6.20331578e-002,
-       4.37189676e-002, -5.16156815e-002, -4.26899716e-002,
-       1.58083543e-001, 1.85904980e-001, 6.59719631e-002,
-       -1.16300061e-001, 1.40631273e-001, 2.20451578e-001,
-       1.59964077e-002, -1.07376324e-002, 3.11893504e-002,
-       3.68786380e-002, -6.57976568e-002, 6.31026104e-002,
-       8.42285678e-002, 7.75944665e-002, -2.09056288e-001,
-       3.22616488e-001, 2.76107848e-001, 4.08580899e-001,
-       6.72071874e-002, 2.36650810e-001, 1.65921494e-001,
-       3.26123953e-001, 2.13882718e-002, 3.37665044e-002,
-       3.99016738e-002, 5.22956401e-002, -2.36839376e-004,
-       3.40330950e-003, 7.25060888e-003, 9.96027049e-003,
-       -1.93952154e-002, 1.05671309e-001, 4.55407239e-002,
-       1.37151212e-001, -4.94999904e-003, 1.25414938e-001,
-       4.20850217e-002, 1.51789695e-001, -2.28748797e-003,
-       1.15029998e-002, 6.91376021e-003, 1.57425646e-002,
-       1.01292710e-004, 7.75000546e-004, 6.13448257e-003,
-       4.08252655e-003, 1.58378351e-002, 3.23358402e-002,
-       4.15963605e-002, 4.47639078e-002, -2.81866826e-002,
-       3.08029819e-002, 5.91036528e-002, 4.57183421e-002,
-       -4.89510363e-004, -4.88330552e-004, 5.17472159e-003,
-       4.00333293e-003, 2.51277462e-002, 6.02834811e-003,
-       5.26072085e-002, 2.39137616e-002, 9.37835053e-002,
-       7.77309984e-002, 3.26493591e-001, 1.70971930e-001,
-       -2.39648804e-001, 5.17886542e-002, 4.94340211e-001,
-       1.78267375e-001, -1.62629448e-002, 1.11845434e-002,
-       4.61893119e-002, 2.68542189e-002, 3.59777622e-002,
-       4.00343118e-003, 6.09206446e-002, 2.32155658e-002,
-       -5.67094088e-002, -3.24830413e-002, 4.06495154e-001,
-       1.43362358e-001, -4.12356183e-002, -9.68782324e-003,
-       3.40103000e-001, 1.64706782e-001, -3.36525142e-002,
-       1.27345305e-002, 5.54034449e-002, 3.01225875e-002,
-       3.14629218e-003, 2.33554485e-004, 7.67135667e-003,
-       3.80830793e-003, -9.58425738e-003, -1.62040088e-002,
-       5.56353740e-002, 3.23054418e-002, -4.65717539e-003,
-       -1.78196784e-002, 4.25983630e-002, 3.52242589e-002,
-       -2.80691520e-003, -1.92486899e-004, 6.48346310e-003,
-       4.52047959e-003, 1.24665094e-003, -3.37444908e-005,
-       5.06259222e-003, 2.51999847e-003, 2.27144193e-002,
-       1.35618877e-002, 4.17194143e-002, 2.52264012e-002,
-       -2.53066756e-002, 1.78256445e-002, 5.86067699e-002,
-       2.98717078e-002, -1.40612246e-003, -3.39382415e-004,
-       5.53003233e-003, 2.90397182e-003, 1.75282657e-002,
-       2.44915579e-003, 3.87448557e-002, 1.49052450e-002,
-       1.87096372e-001, 1.82819813e-002, 2.83652872e-001,
-       1.15578242e-001, -1.58099920e-001, 7.22708106e-002,
-       5.14822900e-001, 1.48862153e-001, -2.05490422e-002,
-       1.82561844e-003, 4.55027707e-002, 1.78512894e-002,
-       2.05973256e-002, 1.21212367e-003, 3.98578718e-002,
-       1.45431561e-002, 1.26497388e-001, -2.61046570e-002,
-       2.62088180e-001, 1.08118817e-001, -6.99524209e-002,
-       -4.35422771e-002, 5.21675229e-001, 1.33391872e-001,
-       -2.84821559e-002, 2.66567897e-003, 5.05591929e-002,
-       1.87074710e-002, 2.10965960e-003, 3.12293327e-004,
-       5.13789617e-003, 2.35026376e-003, 1.23891970e-002,
-       -9.37899575e-003, 3.64371166e-002, 2.03726515e-002,
-       -8.13251641e-003, -1.58545393e-002, 5.81441633e-002,
-       2.73617879e-002, -3.43430392e-003, 5.72711520e-004,
-       6.80775708e-003, 3.07082571e-003, -9.54177137e-003,
-       1.27386372e-003, 1.27402144e-002, 4.44702990e-003,
-       -1.88990291e-002, -1.44343041e-002, 3.82997319e-002,
-       2.60588694e-002, 3.99023294e-002, -1.74541641e-002,
-       6.01189882e-002, 3.11379880e-002, 1.09690977e-002,
-       3.46884783e-003, 2.11342834e-002, 6.52383314e-003,
-       -8.35700557e-002, 1.06626190e-002, 1.04226783e-001,
-       2.72677913e-002, -1.88338384e-001, -3.14152311e-003,
-       2.73256510e-001, 1.07427791e-001, 2.56466478e-001,
-       -4.84275185e-002, 3.75586987e-001, 1.24479160e-001,
-       1.33077264e-001, -1.71911716e-003, 1.97551519e-001,
-       3.69825289e-002, -7.15641454e-002, 6.95573352e-003,
-       9.85657573e-002, 2.50269659e-002, -2.48267427e-001,
-       6.08396269e-002, 3.27597201e-001, 1.19589448e-001,
-       1.73018396e-001, 1.06932512e-002, 3.09445024e-001,
-       1.07091010e-001, 1.52826846e-001, -1.88631490e-002,
-       2.13139310e-001, 4.12904918e-002, -6.46950910e-003,
-       -8.54161452e-004, 1.16918562e-002, 4.04640287e-003,
-       -4.00559679e-002, 1.62444171e-002, 5.61752245e-002,
-       2.90836766e-002, 1.68094765e-002, 1.27711864e-002,
-       4.27627303e-002, 2.57688463e-002, 1.55277997e-002,
-       -2.98985583e-003, 2.30497159e-002, 6.21123472e-003,
-       2.62268283e-003, 7.83565396e-004, 5.09114657e-003,
-       4.21787659e-003, -2.26900773e-003, 2.91970149e-002,
-       2.98764799e-002, 3.80678363e-002, -2.11513247e-002,
-       2.46979017e-002, 3.56316492e-002, 3.63162942e-002,
-       -7.18257565e-004, 1.72859145e-004, 4.06398019e-003,
-       3.69973108e-003, 4.03324738e-002, -1.28402896e-002,
-       4.83624898e-002, 3.22873630e-002, 1.27727032e-001,
-       8.37465748e-002, 2.20958903e-001, 1.94604769e-001,
-       -2.32852980e-001, 1.79212585e-001, 2.74806440e-001,
-       2.24685460e-001, -2.76726931e-002, 8.44205357e-003,
-       4.05019037e-002, 2.80209389e-002, 2.27456279e-002,
-       -2.11514644e-002, 3.82920206e-002, 3.21732573e-002,
-       3.29599679e-001, -2.17517018e-001, 3.58417213e-001,
-       2.56203949e-001, -2.14408293e-001, -8.92898664e-002,
-       2.71941453e-001, 1.89257994e-001, -3.39757130e-002,
-       -2.06033536e-003, 4.54764664e-002, 2.86364015e-002,
-       1.21602701e-004, 3.84825456e-004, 3.91394133e-003,
-       3.23355384e-003, 3.58550958e-002, -2.56310608e-002,
-       4.60496880e-002, 3.70559357e-002, -9.38699022e-003,
-       -3.05866040e-002, 3.72684486e-002, 4.01390716e-002,
-       -2.19259481e-003, -6.60316728e-005, 5.01982495e-003,
-       3.92271206e-003, 1.69397751e-003, 1.92131952e-003,
-       6.84812292e-003, 7.15827616e-003, 3.86785306e-002,
-       9.07425359e-002, 5.33939935e-002, 1.22309782e-001,
-       7.52597908e-003, 1.03035882e-001, 3.34443115e-002,
-       1.39795274e-001, 1.22735277e-004, 9.92296636e-003,
-       5.25453547e-003, 1.57190394e-002, 4.60208841e-002,
-       7.30598532e-003, 8.10112581e-002, 2.79394165e-002,
-       4.28355396e-001, 1.67501226e-001, 4.73816991e-001,
-       2.27511033e-001, -3.76131572e-002, 8.46083611e-002,
-       1.15576059e-001, 1.50661290e-001, -1.88525431e-002,
-       1.18515231e-002, 3.40956077e-002, 2.52493657e-002,
-       7.61251822e-002, 1.52429324e-002, 1.03591017e-001,
-       3.13384496e-002, 2.98198998e-001, 3.79915759e-002,
-       3.66490990e-001, 1.18047692e-001, -3.99042703e-002,
-       -7.59334117e-003, 9.72533226e-002, 6.83696195e-002,
-       -1.58719160e-002, 1.15384825e-003, 2.85790060e-002,
-       1.34379398e-002, 1.13253575e-002, 2.78079743e-003,
-       1.50677813e-002, 5.39503293e-003, 3.03690769e-002,
-       -7.06699071e-003, 4.48745377e-002, 2.09102444e-002,
-       -4.76954691e-003, -7.19787693e-003, 1.77053027e-002,
-       1.51757598e-002, -1.18896901e-003, -1.65145306e-004,
-       3.46992211e-003, 1.96957658e-003, -1.12952723e-003,
-       -4.67568985e-004, 4.64640372e-003, 3.31668509e-003,
-       -1.75885037e-002, -3.48075554e-002, 4.08908464e-002,
-       4.41984087e-002, 1.79482549e-002, -3.35605703e-002,
-       3.85457315e-002, 4.53580469e-002, 7.62137410e-004,
-       -7.82251533e-004, 4.80935862e-003, 4.17679362e-003,
-       -2.73774303e-002, -8.38513300e-003, 4.30194065e-002,
-       2.39167977e-002, -2.68101901e-001, -1.60783872e-001,
-       3.28703374e-001, 2.17175022e-001, 2.25667849e-001,
-       -1.84548229e-001, 2.81171292e-001, 2.40843371e-001,
-       3.00048348e-002, -1.15150195e-002, 4.53631245e-002,
-       3.04951966e-002, -3.17916162e-002, -6.56117545e-003,
-       4.65598591e-002, 2.27673780e-002, -2.57733077e-001,
-       1.17746321e-002, 3.16187948e-001, 1.30513504e-001,
-       2.45742515e-001, 6.05590269e-002, 2.89561421e-001,
-       1.43730402e-001, 3.03243678e-002, 4.19283868e-004,
-       4.71218564e-002, 2.59615090e-002, -3.61595862e-003,
-       -1.16245274e-003, 6.32426655e-003, 3.40484455e-003,
-       -2.24902425e-002, 1.23885125e-002, 4.15641367e-002,
-       2.48705484e-002, 2.87588667e-002, 1.29095251e-002,
-       4.08623703e-002, 2.57937126e-002, 2.09415564e-003,
-       -9.73700662e-004, 5.62020997e-003, 3.62803577e-003,
-       1.82777899e-003, 3.35287943e-004, 5.73225971e-003,
-       3.09680053e-003, 1.19816903e-002, 2.26839185e-002,
-       3.55720632e-002, 3.01396847e-002, -5.60194477e-002,
-       2.22157650e-002, 6.61498234e-002, 3.17218117e-002,
-       -1.49685540e-003, -9.64540639e-004, 5.00647211e-003,
-       3.06457584e-003, 2.96356361e-002, 4.59942548e-003,
-       4.51519340e-002, 1.91363785e-002, 1.16840176e-001,
-       5.16182519e-002, 1.84264690e-001, 1.03660516e-001,
-       -4.38472629e-001, 8.34785774e-002, 4.76708233e-001,
-       1.32442743e-001, -2.11176965e-002, 2.96303537e-003,
-       3.97652425e-002, 1.74964983e-002, 2.93119680e-002,
-       5.37677959e-004, 4.36871611e-002, 1.75168440e-002,
-       1.07176691e-001, -3.65292430e-002, 1.67659700e-001,
-       8.89495164e-002, -3.63938421e-001, 4.23904555e-003,
-       4.10424709e-001, 1.05458863e-001, -3.33030745e-002,
-       8.44096672e-003, 4.90718707e-002, 2.02178769e-002,
-       2.14610761e-003, -1.84569653e-005, 5.17759938e-003,
-       2.57589947e-003, 1.29876221e-002, -1.45941814e-002,
-       2.83449702e-002, 2.19956115e-002, -3.85970995e-002,
-       -1.19952532e-002, 5.15138432e-002, 2.32630782e-002,
-       -4.76643862e-003, 1.70734164e-003, 7.39020435e-003,
-       3.66471778e-003, 7.26971251e-004, 2.15545297e-003,
-       4.57167253e-003, 5.13185328e-003, -1.23596098e-002,
-       2.75571868e-002, 3.33885476e-002, 4.46263514e-002,
-       -1.51240628e-003, 1.55778332e-002, 2.76741143e-002,
-       3.67818326e-002, 4.50968597e-004, 9.61611629e-004,
-       4.26810095e-003, 4.61527612e-003, 3.62615474e-002,
-       4.91127092e-003, 4.86716218e-002, 3.49784419e-002,
-       -6.65372387e-002, 1.60774902e-001, 2.73390621e-001,
-       2.94778228e-001, 5.03430329e-003, 3.02051961e-001,
-       2.35672340e-001, 3.56049836e-001, -3.21634971e-002,
-       2.21902318e-002, 4.71734628e-002, 4.07049954e-002,
-       2.67027691e-002, -2.00254731e-002, 4.16458175e-002,
-       3.44990902e-002, 9.33364779e-002, -2.00409919e-001,
-       2.38255024e-001, 2.72387356e-001, 1.16895838e-002,
-       -1.67303205e-001, 2.70337343e-001, 2.74630874e-001,
-       -3.72102931e-002, -1.39367785e-002, 5.21427020e-002,
-       3.70821245e-002, 1.29474705e-004, -4.56788111e-004,
-       4.06568777e-003, 4.10553487e-003, 9.01050493e-003,
-       -2.05947943e-002, 3.02670486e-002, 3.77534032e-002,
-       8.25584633e-004, -2.57664621e-002, 3.32191847e-002,
-       4.32637855e-002, -5.52236394e-004, -9.53810173e-004,
-       4.79148841e-003, 4.82157944e-003, -2.57506873e-003,
-       -1.83840818e-003, 8.02148972e-003, 7.11557735e-003,
-       -5.90607151e-003, -8.42882246e-002, 4.51226681e-002,
-       1.13743573e-001, -3.97908222e-003, -9.45924744e-002,
-       3.38357240e-002, 1.27510950e-001, -1.99651555e-003,
-       -8.08174349e-003, 5.31815737e-003, 1.34033281e-002,
-       -5.44208512e-002, -4.94793616e-003, 7.67848492e-002,
-       3.18527892e-002, -2.78487593e-001, -1.28065512e-001,
-       3.55041772e-001, 2.81757414e-001, 5.66720963e-002,
-       -1.37184918e-001, 1.34886459e-001, 3.16654861e-001,
-       1.42935729e-002, -1.73984654e-002, 2.83187535e-002,
-       4.33334075e-002, -5.37524596e-002, 4.66604531e-003,
-       7.53754899e-002, 2.84372400e-002, -2.48834416e-001,
-       1.61181211e-001, 3.29113543e-001, 2.25671113e-001,
-       2.46867146e-002, 1.45939335e-001, 1.16228774e-001,
-       2.11345926e-001, 1.18129216e-002, 1.33849401e-002,
-       2.50243358e-002, 3.11401263e-002, -3.76529712e-003,
-       5.81882137e-004, 8.21573287e-003, 4.97254403e-003,
-       -1.99663732e-002, 4.47501168e-002, 4.42005880e-002,
-       6.27168566e-002, -6.01704884e-003, 4.74334210e-002,
-       2.77915020e-002, 6.55142367e-002, -4.38152289e-004,
-       4.65280516e-003, 4.10036463e-003, 7.91479647e-003,
-       -1.91111269e-003, -9.53427370e-005, 5.35262702e-003,
-       4.24561091e-003, -1.17292497e-002, -2.61886343e-002,
-       3.88232246e-002, 4.09875289e-002, 1.92790129e-003,
-       -2.77530756e-002, 3.02245487e-002, 4.37734500e-002,
-       -7.81893323e-004, -2.09684740e-003, 4.13836678e-003,
-       5.41985221e-003, -3.50134298e-002, -1.38832694e-002,
-       4.84971590e-002, 3.30356732e-002, -1.87234387e-001,
-       -1.60121366e-001, 2.64434636e-001, 2.22690970e-001,
-       2.85957139e-002, -1.86964050e-001, 1.39659926e-001,
-       2.50334203e-001, 1.64704341e-002, -1.60680898e-002,
-       2.85847019e-002, 3.73090506e-002, -3.75042781e-002,
-       4.54051560e-003, 4.83944379e-002, 3.52817290e-002,
-       -9.71777588e-002, 2.12434381e-001, 2.19442755e-001,
-       2.94010878e-001, 8.53681192e-002, 3.71140838e-001,
-       1.68792650e-001, 4.07280684e-001, 1.48737067e-002,
-       4.66606170e-002, 3.03776469e-002, 5.60498536e-002,
-       -1.30532193e-003, 2.18329299e-003, 5.14517585e-003,
-       5.03636571e-003, 1.05054416e-002, 3.76638137e-002,
-       3.47955897e-002, 5.03469966e-002, 9.91088711e-003,
-       2.75123287e-002, 3.04114819e-002, 4.64169532e-002,
-       -1.77237729e-003, 1.68881973e-003, 4.36157826e-003,
-       5.65992482e-003, -2.19124332e-002, 3.41106812e-003,
-       2.79062074e-002, 7.24234385e-003, -2.82213259e-002,
-       -1.30651901e-002, 4.72960770e-002, 2.92002447e-002,
-       2.43018679e-002, -1.17240679e-002, 3.43982838e-002,
-       2.57842951e-002, 2.22305302e-003, 4.93490894e-004,
-       6.35943608e-003, 3.86787392e-003, -1.98080733e-001,
-       9.15028714e-003, 2.39909247e-001, 3.83786298e-002,
-       -2.52312154e-001, 1.08923232e-002, 3.29173088e-001,
-       1.33940607e-001, 1.95703730e-001, -2.28059199e-002,
-       2.34189659e-001, 1.19789585e-001, 2.90271994e-002,
-       5.02924318e-004, 4.99406867e-002, 2.73566023e-002,
-       -1.82854444e-001, -6.90150401e-003, 2.21967623e-001,
-       4.59975116e-002, -2.47658834e-001, 1.09415933e-001,
-       3.44517708e-001, 2.17634141e-001, 1.52343184e-001,
-       8.36554840e-002, 2.15686709e-001, 1.65102407e-001,
-       3.27785015e-002, 2.38796184e-003, 5.40966056e-002,
-       3.31281759e-002, -1.20021086e-002, -7.25400983e-004,
-       1.97462030e-002, 7.92020373e-003, -4.17707786e-002,
-       5.04480414e-002, 6.95293099e-002, 7.33898357e-002,
-       8.32931232e-003, 3.91818210e-002, 3.97024229e-002,
-       5.46845496e-002, 2.96809897e-003, 1.80026982e-003,
-       7.05421064e-003, 6.25462504e-003, -1.65306177e-004,
-       -3.92519141e-004, 4.57852986e-003, 4.60482109e-003,
-       2.51011029e-002, 1.55348489e-002, 4.49424908e-002,
-       4.55734059e-002, 1.02032656e-002, 2.74443179e-002,
-       4.37169299e-002, 4.98711951e-002, -4.55340167e-004,
-       3.36962228e-004, 4.85617714e-003, 5.03661949e-003,
-       1.70926005e-002, 1.55665614e-002, 4.47047539e-002,
-       3.60126048e-002, 1.99847624e-001, 1.12172596e-001,
-       3.38170737e-001, 3.37872952e-001, -3.59039828e-002,
-       -1.95322223e-002, 2.59845138e-001, 2.56284773e-001,
-       -1.65826082e-002, 5.31114312e-003, 4.75918464e-002,
-       3.59595902e-002, 3.10448930e-002, -1.57764985e-003,
-       5.01003116e-002, 3.63513678e-002, -4.11987528e-002,
-       -1.38914302e-001, 2.97826260e-001, 2.89614797e-001,
-       1.52766287e-001, -6.66577667e-002, 3.24640125e-001,
-       2.51496524e-001, -2.11208872e-002, 5.51304023e-004,
-       4.78222556e-002, 3.37564908e-002, 8.11756123e-004,
-       -1.13514019e-003, 4.73579671e-003, 4.96924669e-003,
-       5.27022406e-003, -1.37087647e-002, 3.46499346e-002,
-       4.25632633e-002, 1.76256932e-002, -2.00950019e-002,
-       4.24684882e-002, 4.78123836e-002, -1.22557278e-004,
-       -1.42612564e-003, 5.37360134e-003, 5.57624409e-003,
-       -2.31040595e-003, -9.60370875e-004, 5.81289362e-003,
-       5.60552208e-003, 4.94613172e-003, -3.39954644e-002,
-       3.74880955e-002, 5.10010161e-002, 1.42092239e-002,
-       -2.12992970e-002, 3.66283990e-002, 4.54302803e-002,
-       -6.89296576e-004, -8.17949549e-005, 4.64251777e-003,
-       5.26814489e-003, -3.54702361e-002, 2.37988122e-002,
-       5.06955869e-002, 4.42867242e-002, -1.54898733e-001,
-       5.53877056e-002, 2.60765612e-001, 2.97452062e-001,
-       1.06513053e-001, -1.84277177e-001, 2.08500788e-001,
-       3.13605845e-001, 2.47807000e-002, -1.79763921e-002,
-       4.06998582e-002, 4.52198051e-002, -2.17165593e-002,
-       6.88338187e-003, 4.28397879e-002, 2.79972218e-002,
-       -2.53142864e-001, 8.51888955e-002, 3.56578559e-001,
-       2.06059128e-001, 8.88043642e-002, 2.31836036e-001,
-       2.40353301e-001, 2.88952500e-001, 2.61044875e-002,
-       2.58658882e-002, 4.35209461e-002, 4.31966782e-002,
-       -1.18849846e-003, -4.66435624e-004, 5.37846843e-003,
-       3.97032220e-003, -1.37377381e-002, 2.71601249e-002,
-       4.61064912e-002, 4.08176854e-002, 1.57107655e-002,
-       2.46434081e-002, 4.10664044e-002, 4.09042947e-002,
-       -2.31277663e-004, 9.36450204e-004, 5.21331979e-003,
-       4.66875779e-003, -7.36554386e-004, 1.05511898e-003,
-       6.81241369e-003, 3.92379984e-003, -6.09043837e-002,
-       -2.74536852e-002, 7.56991282e-002, 4.11264338e-002,
-       1.96198770e-003, -2.23520827e-002, 3.78208160e-002,
-       3.34035009e-002, 3.52805178e-003, 2.83308764e-004,
-       6.36398001e-003, 4.08650981e-003, -4.07525338e-002,
-       -1.91538595e-002, 6.55777529e-002, 3.38566601e-002,
-       -3.70056123e-001, -1.96215838e-001, 4.45056587e-001,
-       2.41488174e-001, 1.58089802e-001, -1.39968069e-002,
-       2.23763555e-001, 1.27894729e-001, 3.20874825e-002,
-       5.18741878e-003, 4.71558906e-002, 2.61661913e-002,
-       -6.34398088e-002, -1.22298943e-002, 7.90171176e-002,
-       3.52548659e-002, -2.06226498e-001, 5.93411103e-002,
-       2.99776196e-001, 1.70053512e-001, 2.00059041e-001,
-       7.88139701e-002, 2.48023868e-001, 1.47623941e-001,
-       2.41582841e-002, 4.85607423e-003, 4.24464270e-002,
-       2.54072417e-002, -6.33325893e-003, -1.49027526e-003,
-       9.49805789e-003, 4.90677962e-003, -1.65013727e-002,
-       1.90178584e-002, 4.10728380e-002, 3.36465538e-002,
-       2.18606722e-002, 2.12603342e-002, 4.00022864e-002,
-       3.28076966e-002, 1.05659629e-003, 1.06224128e-004,
-       5.17339585e-003, 3.97232920e-003, -7.10183382e-003,
-       5.57336061e-005, 1.21888788e-002, 6.90203765e-003,
-       -1.46903209e-002, -2.58391127e-002, 3.65981646e-002,
-       4.11959104e-002, 3.84653686e-003, -2.20312197e-002,
-       2.49643940e-002, 3.74040045e-002, 1.58012437e-003,
-       -1.59879608e-004, 4.98809479e-003, 5.24985977e-003,
-       -6.96644038e-002, 2.49346700e-002, 1.01480760e-001,
-       5.49240932e-002, -1.97840810e-001, 1.22910134e-001,
-       2.65590608e-001, 2.59955645e-001, 5.56140095e-002,
-       3.39354500e-002, 1.60945177e-001, 1.63870335e-001,
-       1.94912273e-002, -1.31509107e-004, 3.94036695e-002,
-       2.26848256e-002, -4.56740968e-002, -2.87897866e-002,
-       7.46989921e-002, 7.26806074e-002, -2.08579853e-001,
-       -6.80772886e-002, 3.07035893e-001, 3.86709780e-001,
-       4.87396419e-002, 2.01636180e-002, 1.90007403e-001,
-       2.87398905e-001, 1.94700416e-002, 5.10342559e-003,
-       3.22437473e-002, 4.04890589e-002, -2.54385383e-003,
-       7.89425243e-003, 8.88224784e-003, 1.56576149e-002,
-       5.46615617e-003, 1.55782789e-001, 5.29342405e-002,
-       1.88774630e-001, -1.13069098e-002, 1.51782408e-001,
-       4.28995527e-002, 1.78600565e-001, -1.81669532e-003,
-       1.14870556e-002, 5.02708834e-003, 1.43854348e-002,
-       -8.48111871e-004, 1.60250568e-003, 6.39591226e-003,
-       4.78400663e-003, -5.19748079e-004, 2.92234179e-002,
-       4.00849991e-002, 4.96516712e-002, 2.73517217e-003,
-       3.35701145e-002, 4.21382636e-002, 5.31656630e-002,
-       -2.24760221e-003, 8.29571625e-004, 5.70955174e-003,
-       5.17955888e-003, 2.15963367e-002, 1.06934067e-002,
-       5.68631776e-002, 2.78764591e-002, -3.13944519e-002,
-       1.51973262e-001, 3.19444299e-001, 2.37181172e-001,
-       -6.87080920e-002, 2.65863985e-002, 3.86785686e-001,
-       2.35572666e-001, -2.61794012e-002, -1.03098145e-002,
-       4.88233194e-002, 3.42737176e-002, 3.15629616e-002,
-       5.18447533e-003, 6.18327036e-002, 2.46517081e-002,
-       -6.52320832e-002, -7.60818599e-003, 3.36535424e-001,
-       1.38077691e-001, -2.13086739e-001, -5.90134859e-002,
-       4.50309157e-001, 1.61933467e-001, -9.76539217e-003,
-       -6.12434046e-003, 3.99014130e-002, 2.29132529e-002,
-       2.86078965e-003, -1.34604794e-004, 7.60102551e-003,
-       3.50237917e-003, -7.97159504e-003, -1.21011641e-002,
-       4.75000106e-002, 2.85885688e-002, -3.47996652e-002,
-       -8.89977813e-003, 6.01916201e-002, 2.93050036e-002,
-       -4.87120618e-004, 6.56316755e-004, 4.84638894e-003,
-       3.28093930e-003, 5.86336886e-004, -1.46308495e-003,
-       5.37910964e-003, 5.93220396e-003, -7.73199461e-003,
-       -4.65394035e-002, 3.96416299e-002, 6.36998788e-002,
-       2.39646132e-003, -5.61831519e-002, 4.07373123e-002,
-       6.95721731e-002, 2.08434090e-003, -2.50843819e-003,
-       5.57818357e-003, 6.41468214e-003, -3.16979103e-002,
-       -2.14253087e-002, 5.02939075e-002, 4.71803583e-002,
-       -9.86820534e-002, -1.94748625e-001, 2.54088491e-001,
-       3.04015756e-001, 1.74212843e-001, 2.09118612e-002,
-       2.59474814e-001, 3.10536653e-001, 4.21855971e-002,
-       1.64555181e-002, 5.39797544e-002, 4.96297218e-002,
-       -3.92721146e-002, -9.72342037e-004, 5.52383922e-002,
-       3.50826681e-002, -3.49682122e-002, 3.75173166e-002,
-       2.34874055e-001, 1.70737535e-001, 3.55231702e-001,
-       1.60024446e-002, 3.91961187e-001, 1.90092131e-001,
-       2.36670505e-002, 7.13682408e-003, 4.44928184e-002,
-       3.62026058e-002, -2.20839866e-003, -6.67733140e-004,
-       6.20428752e-003, 4.82847961e-003, -4.11335193e-003,
-       1.93616431e-002, 3.53347994e-002, 3.37011144e-002,
-       3.66289914e-002, 1.42978625e-002, 4.89954725e-002,
-       3.44458111e-002, 1.95812015e-003, -2.11857236e-003,
-       5.96937072e-003, 5.27717033e-003, -8.61863326e-003,
-       2.30891700e-003, 1.13929240e-002, 5.09342272e-003,
-       8.84655304e-003, -1.33910608e-002, 2.89479308e-002,
-       2.35108510e-002, 6.43765405e-002, -2.77465992e-002,
-       7.88133740e-002, 3.99612188e-002, -2.90343747e-003,
-       2.10012007e-003, 8.74952134e-003, 4.65406058e-003,
-       -1.15977995e-001, 4.17658389e-002, 1.26113445e-001,
-       4.89066951e-002, -4.16163006e-004, -4.30360530e-003,
-       2.13535190e-001, 1.20621867e-001, 3.09764206e-001,
-       -1.25833601e-001, 3.76895964e-001, 1.87226877e-001,
-       3.46875787e-002, -1.07441125e-002, 8.08798820e-002,
-       3.67636085e-002, -7.36448094e-002, 2.65580025e-002,
-       9.74181592e-002, 3.87173854e-002, -2.25177228e-001,
-       1.40709028e-001, 4.39784616e-001, 2.11102486e-001,
-       1.38709798e-001, 2.11543776e-002, 2.24876314e-001,
-       1.46166787e-001, 8.13937113e-002, -2.55152080e-002,
-       1.02271967e-001, 4.44186665e-002, -1.83690118e-003,
-       -4.33886744e-004, 9.00064316e-003, 3.89512000e-003,
-       -6.11469932e-002, 4.53346185e-002, 9.12907347e-002,
-       5.29268645e-002, 1.04350010e-002, 1.73166376e-002,
-       3.76003347e-002, 3.41104753e-002, 6.90125488e-003,
-       -1.65710086e-003, 1.00229075e-002, 5.41283237e-003,
-       1.50438267e-004, -1.55858893e-003, 4.30637226e-003,
-       6.94020744e-003, 8.79475474e-003, -1.50391143e-002,
-       2.87656579e-002, 5.94964400e-002, 3.49844503e-003,
-       -4.09506308e-003, 2.44225226e-002, 6.02105446e-002,
-       -9.27398505e-004, -6.87617518e-004, 4.26856475e-003,
-       8.00189003e-003, -2.77336799e-002, -1.28131500e-002,
-       3.91117483e-002, 4.94445749e-002, -4.12131734e-002,
-       -1.68297112e-001, 1.46367595e-001, 4.68811333e-001,
-       5.70503622e-002, -2.39916563e-001, 1.37036026e-001,
-       5.73962092e-001, 1.63566973e-002, -2.90565789e-002,
-       3.12745236e-002, 7.17171058e-002, -3.00697666e-002,
-       1.19415587e-002, 4.14903536e-002, 3.20039578e-002,
-       -3.80519368e-002, 1.17628522e-001, 1.29251942e-001,
-       1.95339337e-001, 3.91693227e-002, 1.55848429e-001,
-       1.15821965e-001, 2.28084400e-001, 1.79596338e-002,
-       2.24414673e-002, 2.98419762e-002, 4.05059457e-002,
-       -1.51313387e-003, 2.45591975e-003, 4.89379978e-003,
-       5.36922598e-003, 2.43183831e-003, 3.48025374e-002,
-       2.51340624e-002, 5.00458777e-002, 6.12320937e-003,
-       3.48792411e-002, 2.30998825e-002, 5.22557124e-002,
-       3.49409383e-004, 2.96899816e-003, 4.30125045e-003,
-       6.17266633e-003, 8.20905901e-003, -8.20665678e-004,
-       1.33831007e-002, 4.87024896e-003, 1.02105942e-002,
-       6.46910397e-003, 2.75989436e-002, 2.19608266e-002,
-       -2.11761724e-002, 7.73508800e-003, 4.01736349e-002,
-       2.24093758e-002, -9.69466940e-003, -1.11446378e-003,
-       1.54403877e-002, 5.51378494e-003, 8.67767707e-002,
-       -2.81824032e-003, 1.18808918e-001, 2.95438264e-002,
-       4.19924222e-002, -2.32304316e-002, 1.70611069e-001,
-       1.20178044e-001, -1.73099428e-001, -7.31522292e-002,
-       2.82943606e-001, 1.67059362e-001, -7.86331519e-002,
-       -6.36854488e-003, 1.23059846e-001, 3.44696231e-002,
-       8.04535821e-002, -2.36815177e-002, 1.06172867e-001,
-       4.91273589e-002, -3.53969336e-002, -3.19678396e-001,
-       2.32226163e-001, 3.80956948e-001, -3.97885144e-002,
-       -1.91384897e-001, 2.84696251e-001, 3.33316356e-001,
-       -8.08369145e-002, -7.52563728e-003, 1.22712024e-001,
-       3.99691910e-002, 1.52624154e-003, -6.03169436e-003,
-       7.53959036e-003, 1.10080922e-002, -2.23102327e-003,
-       -6.47798255e-002, 3.83900702e-002, 1.01883136e-001,
-       1.16505418e-002, -7.20591471e-002, 4.35554869e-002,
-       1.00853942e-001, -2.95078056e-003, -4.88383090e-003,
-       8.21291283e-003, 1.00437496e-002, 8.12370563e-004,
-       -3.52694158e-004, 4.45717340e-003, 3.37631139e-003,
-       3.16575170e-002, 2.11769883e-002, 4.45162095e-002,
-       3.36201824e-002, -2.56419331e-002, 2.25883853e-002,
-       4.37760241e-002, 3.48373242e-002, -1.81760057e-003,
-       -5.65489172e-004, 4.78350278e-003, 3.52326757e-003,
-       1.89714022e-002, 8.72360449e-003, 3.75165716e-002,
-       2.56621856e-002, 2.78562039e-001, 8.86186585e-002,
-       3.35062981e-001, 1.93071440e-001, -2.97520489e-001,
-       1.35635687e-002, 3.50203663e-001, 1.71108022e-001,
-       -1.98744964e-002, 2.06284760e-003, 3.63080390e-002,
-       2.45467834e-002, 3.10017355e-002, 2.42831558e-003,
-       4.38434929e-002, 3.48619260e-002, 1.27062008e-001,
-       -1.02708459e-001, 2.65736610e-001, 3.08699399e-001,
-       -2.05880851e-001, -8.21589381e-002, 2.77145177e-001,
-       2.25586236e-001, -2.36491598e-002, 3.33046936e-003,
-       3.75509784e-002, 2.76729744e-002, 1.04072131e-003,
-       -9.30539682e-004, 4.56303125e-003, 4.40640049e-003,
-       6.99423766e-003, -2.98039746e-002, 3.26230898e-002,
-       4.42988984e-002, -8.20128340e-003, -2.80531477e-002,
-       3.23732942e-002, 4.09515537e-002, -1.14590209e-003,
-       -7.01907557e-004, 4.28752182e-003, 4.00067819e-003,
-       -4.68697806e-004, 5.38673194e-004, 4.88681998e-003,
-       2.81818840e-003, -2.01711431e-002, -1.02868152e-003,
-       4.75773066e-002, 2.88336296e-002, 9.23425239e-003,
-       -1.52910664e-003, 3.79591025e-002, 2.96106078e-002,
-       2.88265030e-004, 7.33429973e-004, 5.46451425e-003,
-       3.66254081e-003, 7.46992882e-003, 3.65342782e-003,
-       4.21109498e-002, 1.80875268e-002, -1.99096888e-001,
-       6.16831370e-002, 4.10335690e-001, 1.63482875e-001,
-       1.26601219e-001, 7.38497674e-002, 3.18788737e-001,
-       1.66247413e-001, -5.18881995e-003, 7.18280021e-003,
-       4.55884039e-002, 2.41523422e-002, 6.16844837e-003,
-       -3.79724195e-003, 4.40365896e-002, 1.75872389e-002,
-       -1.96959615e-001, -8.10786113e-002, 4.23331648e-001,
-       1.57594338e-001, 1.73714027e-001, -3.81084569e-002,
-       3.66747350e-001, 1.47094861e-001, -1.05744964e-002,
-       -2.37544693e-004, 4.60216105e-002, 2.15822756e-002,
-       -9.91384150e-004, -5.02826821e-004, 5.73594496e-003,
-       2.87601608e-003, -1.76473856e-002, 2.69871176e-004,
-       4.68756706e-002, 2.67860163e-002, 1.96770951e-002,
-       2.91234523e-004, 4.52562347e-002, 2.67017968e-002,
-       -8.15299572e-004, -7.29915278e-004, 5.58733754e-003,
-       3.27909901e-003, 3.12386639e-003, -4.80906630e-004,
-       7.26101780e-003, 2.87472433e-003, -1.63509580e-003,
-       1.60254315e-002, 5.72704673e-002, 2.74047162e-002,
-       -2.37356462e-002, 1.18933870e-002, 4.46808040e-002,
-       2.45677009e-002, -2.01270124e-003, -3.17781814e-004,
-       4.81493725e-003, 2.83777853e-003, 3.02158538e-002,
-       -4.03238228e-003, 5.46368249e-002, 1.74508356e-002,
-       2.19738018e-002, 3.22319679e-002, 4.76854414e-001,
-       1.24777175e-001, -1.81658998e-001, 5.63228168e-002,
-       3.32694173e-001, 1.26034021e-001, -2.21070256e-002,
-       2.42534373e-003, 3.93956490e-002, 1.80969462e-002,
-       2.12713536e-002, -1.39483134e-003, 4.96425852e-002,
-       1.63682699e-002, 1.05042800e-001, -4.57462445e-002,
-       4.61783648e-001, 1.30350724e-001, -2.06591919e-001,
-       -9.18109808e-003, 3.43043149e-001, 1.26063332e-001,
-       -2.24714652e-002, 1.48726953e-003, 4.05132510e-002,
-       1.86391715e-002, 1.54308241e-003, 4.49942949e-004,
-       6.39701355e-003, 2.61314469e-003, 1.76221225e-002,
-       -1.34903789e-002, 5.67427464e-002, 2.56354995e-002,
-       -2.74428129e-002, -1.06082736e-002, 4.87003997e-002,
-       2.52725538e-002, -2.14840192e-003, 5.19111287e-004,
-       5.17898193e-003, 2.94149364e-003, -7.42218131e-003,
-       -1.07996631e-003, 1.31111443e-002, 6.32454222e-003,
-       3.68605508e-003, -4.29624356e-002, 4.15230989e-002,
-       7.15881437e-002, 6.18804188e-004, -3.81450094e-002,
-       3.03605553e-002, 7.47205541e-002, -1.74228312e-003,
-       -3.82792228e-003, 5.19199483e-003, 9.51539166e-003,
-       -1.22957416e-001, -8.85932427e-003, 1.52967185e-001,
-       3.50218341e-002, -1.21626146e-001, -2.78336555e-001,
-       2.32596993e-001, 3.29369664e-001, 3.47768664e-002,
-       -3.35771829e-001, 1.24847911e-001, 3.80204350e-001,
-       1.28995143e-002, -3.99384871e-002, 2.83349063e-002,
-       5.19114807e-002, -1.19486511e-001, -1.29910279e-003,
-       1.50498956e-001, 3.34297866e-002, -1.67115450e-001,
-       1.33943304e-001, 2.43118465e-001, 2.10039631e-001,
-       2.48973798e-002, 1.26970664e-001, 1.15697473e-001,
-       2.02308029e-001, 1.35558592e-002, 1.25084547e-002,
-       2.53159385e-002, 3.12567279e-002, -9.41064581e-003,
-       2.46220705e-004, 1.48342149e-002, 5.24144433e-003,
-       -1.17203649e-002, 3.72340344e-002, 4.17254753e-002,
-       5.46450950e-002, -8.34239880e-004, 4.21175435e-002,
-       2.86128074e-002, 5.88546954e-002, -1.48525243e-004,
-       4.29951586e-003, 4.05485602e-003, 7.39108771e-003,
-       -1.23966858e-003, 1.35402018e-002, 5.88599825e-003,
-       1.77884605e-002, -1.85484942e-002, 1.34000003e-001,
-       4.03550193e-002, 1.66864932e-001, -2.17707753e-002,
-       1.08471178e-001, 4.64142300e-002, 1.49730131e-001,
-       -1.54392468e-003, 2.53369333e-003, 7.90089555e-003,
-       1.23992069e-002, 2.13476960e-002, 2.19986797e-003,
-       3.47623453e-002, 3.60944942e-002, -1.48037053e-003,
-       1.04354635e-001, 1.20239571e-001, 1.94147542e-001,
-       -2.10740060e-001, 2.33036429e-001, 2.76267290e-001,
-       3.08905214e-001, -8.74499232e-002, 3.31678577e-002,
-       1.17241934e-001, 6.26994595e-002, 2.62651294e-002,
-       -4.88275215e-002, 4.91946898e-002, 6.42977208e-002,
-       1.42653286e-001, -2.44268268e-001, 2.04026029e-001,
-       2.98996150e-001, -1.07945718e-001, -1.06517874e-001,
-       2.00058788e-001, 2.05977380e-001, -9.52278227e-002,
-       1.04551313e-004, 1.19689398e-001, 4.63818945e-002,
-       -2.57298443e-003, -2.95171910e-003, 7.79771619e-003,
-       1.18626598e-002, 1.99654922e-002, -7.77061135e-002,
-       5.25462367e-002, 1.12864636e-001, 5.84073970e-003,
-       -9.47170630e-002, 4.76058275e-002, 1.17908254e-001,
-       -4.85184835e-003, -4.61698370e-003, 1.06288791e-002,
-       1.03105670e-002, -1.22219877e-004, 1.96291669e-003,
-       4.92525194e-003, 5.41333621e-003, -7.31364870e-003,
-       2.81141493e-002, 4.04719263e-002, 4.43377905e-002,
-       1.27881309e-002, 3.30714062e-002, 4.44729403e-002,
-       4.67408225e-002, -4.80944291e-003, 5.22675924e-004,
-       8.76400527e-003, 5.15973475e-003, 2.23703831e-002,
-       1.90925859e-002, 3.77053767e-002, 3.38410661e-002,
-       -6.47988245e-002, 1.92830443e-001, 2.16275424e-001,
-       2.46700078e-001, 1.72318462e-002, 1.02552548e-001,
-       2.76852041e-001, 2.01491937e-001, -7.33717829e-002,
-       -6.13174355e-003, 9.22469720e-002, 3.64419110e-002,
-       2.09725574e-002, -2.48798244e-002, 3.59432250e-002,
-       4.06844728e-002, -5.90579510e-002, -2.47625798e-001,
-       1.90312833e-001, 3.18223745e-001, -1.28796130e-001,
-       -2.95902342e-001, 2.90183842e-001, 3.68265271e-001,
-       -5.48656993e-002, -2.46359184e-002, 7.95982182e-002,
-       4.32383120e-002, -9.43829364e-004, -4.61890781e-003,
-       4.47807042e-003, 8.14849231e-003, -1.17613049e-002,
-       -4.26137224e-002, 3.12423445e-002, 6.50047064e-002,
-       -6.74507441e-003, -3.13584581e-002, 3.34230252e-002,
-       5.49074970e-002, -4.22068551e-004, -4.06497944e-004,
-       5.57367690e-003, 5.40800020e-003, -2.25375727e-004,
-       -5.47707547e-004, 4.09725448e-003, 3.79674183e-003,
-       4.24940996e-002, 2.45128516e-002, 5.26743345e-002,
-       4.15254235e-002, 2.65238229e-002, 3.35801654e-002,
-       3.79658975e-002, 4.16835919e-002, 1.62467870e-004,
-       1.81717973e-003, 3.04549700e-003, 3.68503202e-003,
-       3.43614817e-002, 3.64862904e-002, 4.78550158e-002,
-       4.73732613e-002, 2.92264581e-001, 3.14518809e-001,
-       3.20873231e-001, 3.39491606e-001, 9.84274689e-003,
-       8.72145221e-002, 1.17007799e-001, 1.44916520e-001,
-       -1.20558292e-002, 2.05024891e-003, 2.02210937e-002,
-       1.93098541e-002, 4.89435643e-002, -8.52141343e-003,
-       5.48078120e-002, 4.51418869e-002, 1.00437790e-001,
-       -2.59767562e-001, 1.79486290e-001, 3.24498922e-001,
-       -3.34164575e-002, -2.70093739e-001, 1.22753926e-001,
-       3.01640630e-001, -1.07165202e-002, -2.97360085e-002,
-       2.32902262e-002, 3.83230187e-002, 8.40469787e-004,
-       -2.77518854e-003, 3.67036392e-003, 6.41687959e-003,
-       2.56709196e-003, -3.57832424e-002, 2.51771566e-002,
-       5.87118492e-002, 7.06625916e-003, -3.59803662e-002,
-       2.64152884e-002, 5.94717599e-002, 1.56470540e-003,
-       -3.40360799e-003, 3.85449338e-003, 7.11641042e-003,
-       1.73329154e-003, 6.52334362e-004, 3.81806330e-003,
-       2.77954247e-003, 1.28515987e-002, 2.64937449e-002,
-       2.79382505e-002, 3.40290256e-002, -2.12242436e-002,
-       2.41335742e-002, 3.27010527e-002, 3.34456079e-002,
-       -1.44295802e-003, 2.91063945e-004, 3.67708760e-003,
-       2.83035380e-003, 2.37708539e-002, 2.56461278e-003,
-       3.54120545e-002, 1.98160242e-002, 1.36494324e-001,
-       3.08789480e-002, 2.23915830e-001, 1.59051180e-001,
-       -2.23135233e-001, 2.67338119e-002, 2.74716973e-001,
-       1.70270666e-001, -1.89142283e-002, 1.70867192e-003,
-       3.20278853e-002, 2.21597515e-002, 2.19427608e-002,
-       -1.63626997e-003, 3.60594615e-002, 2.49494389e-002,
-       2.72658229e-001, 9.25067216e-002, 3.16752464e-001,
-       2.86145836e-001, -2.86270857e-001, 1.72732517e-001,
-       3.32478255e-001, 3.32147658e-001, -2.40012873e-002,
-       1.15121370e-002, 3.92692648e-002, 3.05000953e-002,
-       1.68406370e-003, 3.59723112e-004, 4.37758025e-003,
-       3.34130297e-003, 2.99497098e-002, -2.79692151e-002,
-       4.23052572e-002, 4.25305218e-002, -2.27582324e-002,
-       -2.77322847e-002, 4.42707874e-002, 4.51701209e-002,
-       -2.64080404e-003, 4.52427514e-004, 5.16474945e-003,
-       4.28507617e-003, 9.22725711e-004, -2.49010348e-003,
-       3.96157103e-003, 5.52080479e-003, -1.67376117e-003,
-       -2.96682082e-002, 2.95223314e-002, 4.51510176e-002,
-       1.94146100e-003, -3.10791973e-002, 3.20025347e-002,
-       4.50976901e-002, 2.71594443e-004, -2.45912420e-003,
-       4.13131202e-003, 5.34946145e-003, -1.80860758e-002,
-       -2.61850823e-002, 3.03969458e-002, 4.44399342e-002,
-       -5.04124351e-002, -2.87478656e-001, 1.48474753e-001,
-       3.31518263e-001, 9.64880511e-002, -2.30922788e-001,
-       1.83244780e-001, 3.04624081e-001, 2.93813329e-002,
-       -8.22512340e-003, 3.98181528e-002, 4.24008481e-002,
-       -1.86209958e-002, 2.99344342e-002, 3.27226482e-002,
-       4.44576666e-002, -1.35509253e-001, 2.09930420e-001,
-       1.99663520e-001, 2.70251453e-001, 2.56678581e-001,
-       1.93267539e-001, 2.97200412e-001, 2.53559440e-001,
-       2.80964188e-002, 3.14830802e-002, 4.24908288e-002,
-       4.56007309e-002, 2.79808970e-004, 7.37117545e-004,
-       4.22278419e-003, 4.58082510e-003, -1.62153486e-002,
-       2.53302716e-002, 3.71671617e-002, 4.11295891e-002,
-       2.44651474e-002, 2.46007405e-002, 4.39370535e-002,
-       3.92880440e-002, 1.15885795e-003, -6.83638384e-004,
-       4.70872456e-003, 4.43171058e-003, -2.59128795e-003,
-       -5.77428285e-003, 6.90237479e-003, 1.06537221e-002,
-       -1.61563023e-003, -9.51967388e-002, 3.40222418e-002,
-       1.22856155e-001, -1.28205083e-002, -1.01016432e-001,
-       3.15336920e-002, 1.26722246e-001, -1.11505820e-003,
-       -8.12672917e-003, 4.12105769e-003, 1.18448194e-002,
-       -4.46803272e-002, 2.75374274e-003, 5.56591190e-002,
-       3.96266617e-002, -1.05079435e-001, -7.57556350e-004,
-       1.63487405e-001, 2.25484803e-001, 2.01506149e-002,
-       1.99133903e-002, 1.01632021e-001, 2.10599720e-001,
-       1.21266292e-002, 4.73676389e-003, 2.29355134e-002,
-       3.15547511e-002, -3.00290082e-002, 3.70905958e-002,
-       4.50101420e-002, 4.96930704e-002, -1.30851999e-001,
-       3.55257630e-001, 1.84218913e-001, 4.04320538e-001,
-       3.54435369e-002, 3.48093003e-001, 1.14981674e-001,
-       3.95181894e-001, 7.37102469e-003, 4.34654020e-002,
-       2.41966918e-002, 5.32058030e-002, 7.44609279e-004,
-       2.74971267e-003, 4.85625258e-003, 6.47388073e-003,
-       -3.72483511e-003, 4.41837497e-002, 2.47344784e-002,
-       6.60912320e-002, -2.30216677e-003, 4.68229391e-002,
-       2.38951370e-002, 7.13309050e-002, -2.22772616e-003,
-       5.17328223e-003, 4.80832718e-003, 9.34130792e-003,
-       2.51238840e-003, 1.88885932e-003, 6.79677725e-003,
-       5.87887364e-003, -2.13891380e-002, 5.66043109e-002,
-       5.31652011e-002, 6.66076094e-002, -4.87122387e-002,
-       3.61359343e-002, 6.03028871e-002, 5.53632304e-002,
-       1.64740172e-003, -9.78567870e-004, 4.26467694e-003,
-       4.64604190e-003, 4.84992117e-002, 7.54592707e-003,
-       6.12038262e-002, 3.40735540e-002, 7.52970874e-002,
-       1.22684002e-001, 1.91020042e-001, 1.81569323e-001,
-       -3.57159078e-001, 4.10335332e-001, 3.83024096e-001,
-       4.31458205e-001, -3.21299061e-002, 5.66559583e-002,
-       5.16338870e-002, 6.70729354e-002, 4.16055657e-002,
-       2.74202344e-003, 5.47250435e-002, 2.86765117e-002,
-       1.12020284e-001, -5.47982045e-002, 1.63653821e-001,
-       1.16146632e-001, -9.22978818e-002, -2.31483690e-002,
-       1.50954232e-001, 1.24802090e-001, -4.71594855e-002,
-       2.46463418e-002, 5.58595955e-002, 4.44860011e-002,
-       2.48214183e-003, 6.24834734e-004, 5.59437042e-003,
-       3.52689927e-003, 1.18135056e-002, -1.33146625e-002,
-       2.70369444e-002, 2.39794496e-002, -5.95018687e-003,
-       -1.47755118e-002, 2.41099969e-002, 2.50279643e-002,
-       -2.38196598e-003, 3.54772899e-004, 4.47601965e-003,
-       3.83197772e-003, 2.40692243e-004, 1.38347142e-003,
-       5.09824045e-003, 5.58520807e-003, -4.42042388e-003,
-       2.44814791e-002, 3.44778188e-002, 4.81973179e-002,
-       -5.44923823e-003, 1.84220020e-002, 3.11794411e-002,
-       4.45882790e-002, -9.30748356e-005, 8.45215574e-004,
-       4.15264117e-003, 5.01339743e-003, 2.21847091e-002,
-       9.20145959e-003, 4.65904027e-002, 3.89643572e-002,
-       -1.24568539e-002, 8.66978765e-002, 2.74910390e-001,
-       3.21889222e-001, 6.52902760e-003, 2.05787614e-001,
-       2.74224192e-001, 3.56812149e-001, -3.06353364e-002,
-       1.25580514e-002, 4.75036465e-002, 4.05169725e-002,
-       2.59647314e-002, 5.84103260e-003, 4.74147126e-002,
-       3.61741148e-002, 4.80577983e-002, 9.33291763e-002,
-       2.43000403e-001, 2.88781554e-001, -1.54893622e-001,
-       -1.27345636e-001, 2.98793286e-001, 2.98992515e-001,
-       -2.40622368e-002, -1.65438522e-002, 4.47592176e-002,
-       3.96565460e-002, 1.62371760e-003, -4.54376917e-004,
-       5.48681011e-003, 5.34112751e-003, -5.07376343e-003,
-       -2.92026233e-002, 3.59580480e-002, 4.95430082e-002,
-       -2.63428092e-002, -1.54181989e-002, 4.36801165e-002,
-       4.65812460e-002, -1.03992461e-004, 7.05042214e-004,
-       4.52256063e-003, 4.92217764e-003, 8.25293464e-005,
-       5.39758475e-003, 4.80862055e-003, 1.01635950e-002,
-       4.75146808e-003, 7.16937259e-002, 3.04609835e-002,
-       9.48473141e-002, 4.75895446e-004, 7.07235634e-002,
-       3.17955986e-002, 9.31262448e-002, -8.47499818e-004,
-       4.30717971e-003, 5.11938846e-003, 9.03934054e-003,
-       3.36437672e-002, 1.00488085e-002, 4.57433686e-002,
-       4.56756689e-002, 6.25655279e-002, 1.00696206e-001,
-       1.70984119e-001, 2.88986474e-001, -7.54981786e-002,
-       7.54051208e-002, 1.94156110e-001, 2.65768468e-001,
-       -3.52180339e-002, 1.07312510e-002, 4.98360395e-002,
-       3.99569720e-002, 2.89499275e-002, -4.49512340e-002,
-       4.40503620e-002, 6.13632798e-002, 1.25162378e-001,
-       -3.46517861e-001, 1.99500307e-001, 4.42625701e-001,
-       -2.45848466e-002, -2.07260668e-001, 1.75584897e-001,
-       3.15695822e-001, -3.01397610e-002, -1.38763608e-002,
-       4.44217026e-002, 3.91816013e-002, -1.23579870e-003,
-       3.73396142e-005, 4.55770455e-003, 7.21360417e-003,
-       1.13895154e-002, -2.06114221e-002, 3.00113149e-002,
-       6.12802804e-002, 1.21584460e-002, -4.18125503e-002,
-       3.22441384e-002, 7.14861527e-002, -1.47159255e-004,
-       -3.72003578e-003, 4.88744862e-003, 8.24165717e-003,
-       -1.79127941e-003, -1.69239589e-003, 5.77180879e-003,
-       4.76464583e-003, 1.38556585e-002, -4.26605083e-002,
-       5.04138246e-002, 5.41799366e-002, 1.47016952e-002,
-       -2.36049499e-002, 3.68036143e-002, 4.36294973e-002,
-       -1.98261975e-003, -1.16823951e-003, 4.67918580e-003,
-       5.08068921e-003, -4.01011743e-002, -1.14573045e-002,
-       5.56089543e-002, 3.39657664e-002, -8.33081976e-002,
-       -1.62704453e-001, 3.00144702e-001, 2.66339779e-001,
-       9.33380052e-002, -3.89790803e-001, 2.20962763e-001,
-       4.37648058e-001, 2.16205902e-002, -4.80655134e-002,
-       3.95926349e-002, 5.85443862e-002, -3.67467254e-002,
-       2.36811792e-003, 5.24227694e-002, 3.18726040e-002,
-       -1.25521392e-001, 1.20118216e-001, 2.50252277e-001,
-       2.08928704e-001, -3.67872156e-002, 1.11321568e-001,
-       1.91721708e-001, 1.89622715e-001, 2.59643011e-002,
-       2.20945873e-003, 3.79311889e-002, 3.19989324e-002,
-       -2.47121137e-003, -4.09981876e-004, 6.12672605e-003,
-       4.35566204e-003, -1.05434163e-002, 1.56244701e-002,
-       4.00401950e-002, 3.54572609e-002, -8.18431098e-003,
-       1.90653652e-002, 3.46494950e-002, 3.61684524e-002,
-       7.25696969e-004, 9.96676041e-004, 4.61134035e-003,
-       4.57612518e-003, 1.27702230e-003, -4.60632564e-003,
-       5.39319078e-003, 9.42065008e-003, 2.91906297e-003,
-       -6.83882684e-002, 3.65250260e-002, 9.19547006e-002,
-       4.04103566e-003, -6.55113384e-002, 3.87290567e-002,
-       8.92826319e-002, -2.98144034e-004, -3.89578682e-003,
-       5.54050598e-003, 8.98450334e-003, -2.15072930e-002,
-       -7.86609203e-003, 3.86300795e-002, 5.37806973e-002,
-       -8.68916735e-002, -7.11086914e-002, 1.99202240e-001,
-       4.09053028e-001, 1.42175496e-001, -7.84789473e-002,
-       2.44444668e-001, 4.46999103e-001, 3.44251171e-002,
-       -1.85878528e-003, 5.04217111e-002, 6.31169006e-002,
-       -2.11399905e-002, 8.57273303e-003, 3.76519635e-002,
-       3.90836373e-002, -6.69221058e-002, 8.11920688e-002,
-       1.84240609e-001, 2.44613990e-001, 1.64758429e-001,
-       1.24717668e-001, 2.40619138e-001, 2.49911740e-001,
-       3.36355343e-002, 1.35248294e-002, 4.95795310e-002,
-       4.32810672e-002, -3.79237579e-004, 1.66931935e-003,
-       5.01009496e-003, 5.87941287e-003, -1.72817803e-004,
-       3.65217291e-002, 3.24916430e-002, 5.27922846e-002,
-       1.70139540e-002, 3.41512822e-002, 3.68220061e-002,
-       5.18910810e-002, 1.22538069e-003, 9.96495597e-004,
-       5.39974682e-003, 5.78471739e-003, 2.33551284e-004,
-       -2.66932184e-004, 4.94427839e-003, 3.28407786e-003,
-       2.01862380e-002, 1.15599930e-002, 3.89787331e-002,
-       3.36964242e-002, -1.48410080e-002, 1.28960470e-002,
-       3.67284976e-002, 3.91592309e-002, -8.04729643e-004,
-       -4.37328184e-004, 4.30075917e-003, 4.37030196e-003,
-       2.70407624e-003, -3.45145771e-003, 3.87120657e-002,
-       2.21714377e-002, 1.55509084e-001, -6.53854460e-002,
-       3.10876131e-001, 1.91462636e-001, -2.00077727e-001,
-       -1.84413522e-001, 2.98247874e-001, 2.99244195e-001,
-       1.66050997e-003, -7.42121786e-003, 3.43614109e-002,
-       3.13543826e-002, 1.35483688e-005, 3.18663660e-003,
-       3.80790010e-002, 2.24238671e-002, 1.31838948e-001,
-       2.51484532e-002, 3.29770356e-001, 2.04069600e-001,
-       -9.81072113e-002, 2.19275773e-001, 2.54220814e-001,
-       3.40529084e-001, -5.94496634e-003, 1.77395456e-002,
-       3.88080478e-002, 3.63339223e-002, -5.81239510e-005,
-       1.47779996e-004, 4.99857543e-003, 3.12588573e-003,
-       2.01484486e-002, -8.29818100e-003, 4.42516766e-002,
-       3.81469503e-002, -2.69098533e-003, -1.57537777e-002,
-       3.58674861e-002, 4.32395563e-002, -1.57527055e-003,
-       -2.15714725e-004, 4.23743669e-003, 4.06650035e-003,
-       -7.03471061e-003, 1.31529511e-003, 1.09345736e-002,
-       3.67978727e-003, -2.18366124e-002, -1.81495324e-002,
-       5.79929724e-002, 3.33615988e-002, -4.73473374e-005,
-       -2.09696479e-002, 3.20975706e-002, 3.68513614e-002,
-       7.12880515e-004, -1.31089007e-003, 4.47757402e-003,
-       4.58666543e-003, -6.45989478e-002, 5.13581140e-003,
-       8.75046104e-002, 2.07393263e-002, -2.17008829e-001,
-       -6.04435876e-002, 4.29193795e-001, 1.50881752e-001,
-       7.10558146e-003, -4.47870605e-002, 1.56287342e-001,
-       1.54345363e-001, 1.82342511e-002, -3.23910685e-003,
-       3.16726677e-002, 2.57061664e-002, -6.62174672e-002,
-       -5.61509049e-004, 8.78204033e-002, 1.96117330e-002,
-       -1.53485641e-001, 8.83154273e-002, 5.05718172e-001,
-       1.74388304e-001, 5.00247031e-002, 2.38025323e-001,
-       1.84939206e-001, 2.89228916e-001, 1.45805059e-002,
-       2.98572592e-002, 3.30661051e-002, 4.12984081e-002,
-       -7.22136116e-003, -7.73749431e-004, 1.07722282e-002,
-       3.54368612e-003, 2.43392983e-003, 2.89728623e-002,
-       7.59452656e-002, 4.23004068e-002, 1.45970611e-002,
-       2.50877738e-002, 4.44883518e-002, 4.77143601e-002,
-       -1.58423150e-003, 1.53555535e-003, 5.49014891e-003,
-       5.79111790e-003, -4.66384721e-004, 5.49312332e-004,
-       4.04639076e-003, 4.35531698e-003, 1.81212146e-002,
-       2.78957505e-002, 3.58213373e-002, 4.44516093e-002,
-       2.76294001e-003, 4.22828868e-002, 3.53838801e-002,
-       5.39620593e-002, -2.46407883e-003, 1.20199879e-003,
-       5.34284580e-003, 5.41094039e-003, 2.24659033e-002,
-       2.58156992e-002, 3.87963131e-002, 3.96634154e-002,
-       1.56173646e-001, 2.28688434e-001, 2.37844720e-001,
-       2.93032736e-001, -1.77880645e-001, -3.43566909e-002,
-       2.77109712e-001, 2.82779485e-001, -3.50040421e-002,
-       -1.59302242e-002, 4.75749858e-002, 4.10158634e-002,
-       3.00995540e-002, 4.27642278e-003, 4.33635898e-002,
-       3.30078192e-002, 8.72076601e-002, -2.41398886e-002,
-       1.92041174e-001, 1.83807060e-001, -3.39364052e-001,
-       1.08773159e-002, 3.76702130e-001, 2.81266809e-001,
-       -2.12542154e-002, -1.34004606e-003, 3.98138463e-002,
-       3.66233066e-002, 1.47831521e-003, -4.99295478e-004,
-       4.69900900e-003, 4.59312974e-003, 2.96252733e-003,
-       -2.71509290e-002, 3.24783400e-002, 4.28748094e-002,
-       -3.18390988e-002, -2.35561579e-002, 4.60848212e-002,
-       4.75535467e-002, -1.48170837e-003, 9.73401417e-004,
-       5.09234611e-003, 5.08767972e-003, 1.15789613e-002,
-       1.62201412e-002, 2.40273885e-002, 2.26146933e-002,
-       -2.10904442e-002, 2.35465348e-001, 7.72660598e-002,
-       3.13180387e-001, 4.42176573e-002, 1.90889105e-001,
-       7.06328154e-002, 2.51980394e-001, -1.21593126e-003,
-       1.79134943e-002, 5.70499105e-003, 2.71156393e-002,
-       1.57662243e-001, -2.20622420e-002, 2.63532877e-001,
-       4.80095707e-002, 8.01456869e-002, 6.67961091e-002,
-       1.62772119e-001, 1.73188955e-001, 2.31185462e-002,
-       5.34867272e-002, 8.54807645e-002, 1.32009178e-001,
-       -1.98305883e-002, 1.95711162e-002, 3.21200937e-002,
-       2.42865346e-002, 1.64754957e-001, -3.94283794e-002,
-       2.93788046e-001, 6.67415559e-002, 1.61186770e-001,
-       -1.43687755e-001, 2.69048184e-001, 3.13817948e-001,
-       1.00524891e-002, -5.14715984e-002, 1.14133857e-001,
-       1.81085333e-001, -1.62142143e-002, -1.76348649e-002,
-       2.22028177e-002, 3.04187462e-002, 1.58622488e-002,
-       -2.85204570e-003, 2.92637050e-002, 1.44554153e-002,
-       4.40131128e-002, -3.96232158e-002, 6.65981770e-002,
-       1.05395161e-001, 3.51972505e-003, -7.47706741e-002,
-       3.15710828e-002, 1.16811000e-001, -8.91002361e-004,
-       -1.06527898e-002, 3.98510927e-003, 1.72128826e-002,
-       3.06298654e-003, 2.16686130e-002, 1.07673332e-002,
-       3.91326584e-002, 1.27473362e-002, 2.99600154e-001,
-       3.43754217e-002, 3.86584491e-001, -2.20081280e-003,
-       3.17402363e-001, 2.80651078e-002, 4.08931941e-001,
-       -1.12089154e-004, 3.63334790e-002, 5.75711532e-003,
-       4.98820879e-002, 1.06650829e-001, 7.01709390e-002,
-       1.34368777e-001, 9.69581008e-002, 1.13351360e-001,
-       1.62404299e-001, 1.89859301e-001, 3.34625006e-001,
-       -2.83815712e-002, 1.02266222e-001, 9.74304602e-002,
-       2.68778980e-001, -2.36423351e-002, 3.67669240e-002,
-       3.74047831e-002, 5.31625226e-002, 5.77210225e-002,
-       1.75216757e-002, 8.06177109e-002, 3.28934118e-002,
-       2.46247780e-002, 3.69451307e-002, 9.21278894e-002,
-       1.19079754e-001, -1.78840701e-002, 2.70853899e-002,
-       6.71056509e-002, 9.75957513e-002, -9.11568198e-003,
-       1.34793075e-003, 1.94973219e-002, 1.30273066e-002,
-       5.05332882e-003, 6.76018128e-004, 7.72095658e-003,
-       3.89315747e-003, 2.57974211e-003, -4.89369500e-003,
-       1.34949116e-002, 1.76596679e-002, -3.29486281e-003,
-       -5.24728326e-003, 7.46815465e-003, 1.47171216e-002,
-       -8.73528246e-004, -2.39803136e-004, 2.14184332e-003,
-       2.24888930e-003, -1.23082995e-004, -1.88729656e-003,
-       5.36931772e-003, 5.10155456e-003, 2.16921903e-002,
-       -3.40725817e-002, 4.88602854e-002, 5.03168330e-002,
-       4.95262817e-002, -1.84262656e-002, 6.53368980e-002,
-       5.64949960e-002, -4.49395389e-004, 4.89068567e-004,
-       5.56473667e-003, 6.00634515e-003, -1.36577766e-002,
-       -3.35089373e-003, 3.57576460e-002, 2.95374263e-002,
-       5.10752620e-003, -4.11100015e-002, 2.04582259e-001,
-       1.82358742e-001, 2.00281918e-001, -2.43340924e-001,
-       2.87278742e-001, 3.89808863e-001, 5.99900112e-002,
-       -1.27810845e-002, 7.33572096e-002, 6.25038594e-002,
-       -1.33543592e-002, -7.23744975e-004, 3.59366089e-002,
-       2.88454257e-002, -3.46996263e-002, -4.73970687e-003,
-       1.74184322e-001, 1.67772442e-001, 3.11880410e-001,
-       1.54878929e-001, 3.74529213e-001, 2.70005554e-001,
-       5.33408597e-002, 2.58619934e-002, 6.92637414e-002,
-       4.88884151e-002, -4.91514569e-004, 2.19039517e-004,
-       5.20196045e-003, 4.38722549e-003, 1.65933296e-002,
-       2.96493005e-002, 3.98706496e-002, 4.45215032e-002,
-       5.34379669e-002, 3.95455025e-002, 6.59420416e-002,
-       5.94261065e-002, 8.25498893e-004, -8.37619475e-004,
-       5.94672794e-003, 5.54657495e-003, 8.65527138e-004,
-       3.37905622e-005, 3.86980246e-003, 3.52465967e-003,
-       1.29830220e-003, 4.37972369e-003, 2.87536513e-002,
-       3.12169474e-002, -1.46992784e-002, 4.85270750e-003,
-       5.28677292e-002, 3.08932047e-002, 6.68344495e-004,
-       1.46230785e-004, 4.36576875e-003, 3.48658301e-003,
-       -2.94506026e-004, -1.51154948e-002, 3.20782438e-002,
-       3.32027748e-002, 5.56496009e-002, -1.28414318e-001,
-       2.14014113e-001, 2.42984548e-001, -6.30112514e-002,
-       -3.31884809e-002, 3.87725204e-001, 1.96937695e-001,
-       2.57746340e-003, -4.79576964e-004, 3.76079194e-002,
-       2.75245328e-002, 4.06019716e-003, -5.58988051e-003,
-       2.82953363e-002, 5.77558838e-002, 4.19354104e-002,
-       -3.39918844e-002, 1.61815584e-001, 4.76060480e-001,
-       -4.74359840e-003, -8.23315084e-002, 2.23791763e-001,
-       4.23615128e-001, -9.05321038e-004, -1.03577208e-002,
-       3.62869315e-002, 5.45922481e-002, -3.32591793e-004,
-       1.11220451e-003, 3.08939372e-003, 4.98199137e-003,
-       -2.65438762e-003, 4.25784383e-003, 2.23738942e-002,
-       4.33958732e-002, -2.57125916e-003, 2.42775623e-005,
-       3.30257192e-002, 4.22165804e-002, 1.04107929e-003,
-       2.62978516e-004, 3.65654426e-003, 5.11859218e-003,
-       1.28278590e-003, 7.48605467e-004, 3.67415627e-003,
-       3.61531135e-003, 6.73687086e-003, 2.63255890e-002,
-       2.71721184e-002, 3.83111723e-002, -5.26902732e-004,
-       2.57426463e-002, 2.46127900e-002, 4.04557884e-002,
-       4.72494779e-004, 1.89158355e-003, 3.58690531e-003,
-       4.87058470e-003, 2.54992023e-002, 2.48740870e-003,
-       3.55160423e-002, 2.52447315e-002, 2.31430292e-001,
-       1.61664680e-001, 2.80883461e-001, 2.60514081e-001,
-       -5.02783582e-002, 2.64979422e-001, 1.57515779e-001,
-       3.08018744e-001, -2.45036352e-002, 1.71629842e-002,
-       3.50713246e-002, 3.71713787e-002, 2.77987663e-002,
-       1.09124917e-003, 3.80379222e-002, 2.45521031e-002,
-       2.70439386e-001, -5.11925183e-002, 3.18299294e-001,
-       2.13705868e-001, -1.60070196e-001, -2.29550749e-001,
-       2.21577480e-001, 2.90852696e-001, -2.34394222e-002,
-       -2.85128839e-002, 3.72472294e-002, 4.14172783e-002,
-       2.13764561e-003, -4.49471816e-004, 4.47308691e-003,
-       3.76633345e-003, 9.80581250e-003, -3.55021209e-002,
-       3.44092697e-002, 4.56379168e-002, -1.81081425e-002,
-       -2.81487592e-002, 3.38815376e-002, 4.41234410e-002,
-       6.43402571e-004, -4.60845797e-004, 3.79992742e-003,
-       4.43805521e-003, 5.36228006e-004, -2.06610374e-003,
-       4.66774357e-003, 5.72758634e-003, 1.40961530e-002,
-       -3.37279513e-002, 3.64751779e-002, 5.37959673e-002,
-       4.72118892e-003, -3.78795005e-002, 3.54411379e-002,
-       5.64703308e-002, 3.17138364e-003, -2.87021254e-003,
-       7.61066563e-003, 7.55515322e-003, -1.25271603e-002,
-       -8.80690385e-003, 3.03172600e-002, 2.90365629e-002,
-       7.16134235e-002, -7.76727647e-002, 1.76459804e-001,
-       1.82456344e-001, 1.97169166e-002, -8.12171996e-002,
-       2.00149715e-001, 2.25194111e-001, 6.07882142e-002,
-       5.42068807e-003, 7.21572787e-002, 5.03230691e-002,
-       -1.99873224e-002, 2.78855972e-002, 3.96729484e-002,
-       5.11409715e-002, 2.43355967e-002, 1.28342688e-001,
-       1.72545999e-001, 3.19969654e-001, 2.19818413e-001,
-       2.09660694e-001, 3.05945277e-001, 3.58919680e-001,
-       7.31117949e-002, 7.24184141e-002, 9.43640321e-002,
-       9.20257792e-002, 3.09893186e-003, 1.52211748e-002,
-       8.38299096e-003, 1.88492816e-002, 7.75790215e-003,
-       1.72206119e-001, 4.78638895e-002, 1.93175182e-001,
-       2.98244338e-002, 1.62227467e-001, 6.08990788e-002,
-       1.81972951e-001, -1.51894812e-004, 7.00243376e-003,
-       9.41616297e-003, 1.39451856e-002, 1.16274669e-003,
-       1.62802244e-005, 5.26803965e-003, 5.02525875e-003,
-       1.32558541e-002, 2.77810078e-002, 3.87222320e-002,
-       5.78174703e-002, -1.75557435e-002, 3.02531794e-002,
-       3.51771824e-002, 6.32217154e-002, -1.51240127e-003,
-       -3.05958703e-004, 4.52109007e-003, 5.99159161e-003,
-       2.12252606e-002, 1.59332936e-003, 5.57250306e-002,
-       3.49039920e-002, 1.35828242e-001, -1.05803959e-001,
-       3.25697750e-001, 3.36189121e-001, -1.80865675e-001,
-       -1.40696973e-001, 2.77097493e-001, 3.56632620e-001,
-       -1.84258074e-002, -1.18503335e-003, 4.48247641e-002,
-       3.82076874e-002, 2.52767857e-002, -4.16713534e-003,
-       5.21950759e-002, 3.21496911e-002, -1.05310783e-001,
-       -1.06182478e-001, 3.21646810e-001, 2.40162507e-001,
-       -1.12358676e-002, -1.44657731e-001, 1.79866791e-001,
-       2.47413933e-001, -1.58104245e-002, -1.09452503e-002,
-       3.52567732e-002, 2.97921430e-002, 6.27911999e-004,
-       -1.78352685e-003, 5.03690960e-003, 4.90693096e-003,
-       -1.12684835e-002, -2.35388335e-002, 3.37046534e-002,
-       4.32895981e-002, -4.50920407e-003, -1.69486757e-002,
-       2.46122535e-002, 3.55487503e-002, 1.60759682e-005,
-       -1.46104011e-003, 3.22966021e-003, 4.12843004e-003,
-       -8.69608385e-008, 4.96440660e-003, 8.83160438e-003,
-       1.51689779e-002, 2.02326644e-002, 1.34684965e-001,
-       5.04313000e-002, 1.75326765e-001, 2.40011737e-002,
-       1.49524882e-001, 6.23297542e-002, 1.80546135e-001,
-       -2.97599589e-003, 7.38297123e-003, 1.25257205e-002,
-       1.65146850e-002, 8.43448788e-002, 5.51588014e-002,
-       1.06184378e-001, 9.04930905e-002, 1.51264817e-001,
-       3.08895916e-001, 2.38879949e-001, 3.67803991e-001,
-       -1.65365398e-001, 1.23536028e-001, 2.71949500e-001,
-       2.54337728e-001, -8.42671245e-002, -1.37754073e-002,
-       1.28227547e-001, 6.22237995e-002, 8.40069875e-002,
-       1.92504190e-002, 1.04891576e-001, 4.41971570e-002,
-       4.89748381e-002, 1.34232817e-002, 1.19695097e-001,
-       8.83360729e-002, -1.86844915e-001, 4.72807214e-002,
-       2.44394392e-001, 1.33087501e-001, -7.99883306e-002,
-       3.76729257e-002, 1.19183443e-001, 6.42249659e-002,
-       7.03541841e-003, 1.29510497e-003, 9.66657232e-003,
-       4.17915126e-003, 6.10502297e-003, -4.32496378e-003,
-       1.65778585e-002, 1.40455309e-002, -1.57807563e-002,
-       -3.26155825e-003, 2.56928466e-002, 1.51474960e-002,
-       -5.64011652e-003, 2.27094418e-003, 9.96483397e-003,
-       4.53894725e-003, 5.25174488e-004, -3.21016487e-005,
-       9.75013524e-003, 1.16321854e-002, 4.35950346e-002,
-       5.47326058e-002, 8.12636912e-002, 1.10627964e-001,
-       -3.58870402e-002, 1.00300841e-001, 6.34212717e-002,
-       1.23559244e-001, -1.52281398e-004, 6.46739453e-003,
-       1.03215761e-002, 1.31933531e-002, 1.30988769e-002,
-       7.28843957e-002, 8.31302479e-002, 1.07378773e-001,
-       3.43977332e-001, 2.38595635e-001, 3.95055383e-001,
-       3.07389349e-001, -1.99818864e-001, 1.26445949e-001,
-       2.43584096e-001, 2.14314416e-001, -7.91306235e-003,
-       4.68737595e-002, 6.70070276e-002, 6.55030534e-002,
-       3.38820294e-002, 2.00402271e-002, 4.90883216e-002,
-       4.52265851e-002, 2.54438818e-002, -1.88116115e-002,
-       9.91776884e-002, 1.45049199e-001, -4.03250344e-002,
-       -2.90267877e-002, 1.02910005e-001, 1.42897367e-001,
-       -1.76689010e-002, 7.42195128e-003, 3.61094810e-002,
-       3.31596397e-002, 2.48789933e-004, -1.02181723e-002,
-       5.79160452e-003, 1.86435021e-002, -1.51093276e-002,
-       -1.29900649e-001, 3.19201276e-002, 1.84772745e-001,
-       1.04245432e-002, -1.25262633e-001, 3.15998867e-002,
-       1.80173576e-001, 2.55646580e-003, -9.23236739e-003,
-       5.62068308e-003, 1.50679825e-002, 1.48978946e-003,
-       1.57248776e-003, 6.07189769e-003, 4.46584076e-003,
-       -1.28119309e-002, 2.50388868e-002, 4.78922017e-002,
-       4.01850678e-002, 7.70737696e-003, 2.69865263e-002,
-       6.75654039e-002, 3.86463292e-002, -1.86443632e-003,
-       3.68579131e-005, 5.54701686e-003, 3.56366672e-003,
-       4.20762561e-002, 6.37826370e-003, 5.77158220e-002,
-       2.68527549e-002, -7.84672424e-002, 1.96081042e-001,
-       2.90613800e-001, 2.55851746e-001, -1.61071476e-002,
-       1.61956370e-001, 5.41186154e-001, 2.36172259e-001,
-       -3.27235833e-002, 8.52079876e-003, 5.25726601e-002,
-       2.50693150e-002, 3.49153765e-002, -5.90604916e-003,
-       5.33541515e-002, 2.45472938e-002, 9.85565111e-002,
-       -5.89460433e-002, 2.15069667e-001, 1.58404887e-001,
-       -1.48929834e-001, -4.31929193e-002, 3.27090502e-001,
-       1.69235766e-001, -3.76356803e-002, 6.28451351e-003,
-       5.80177344e-002, 2.67149266e-002, 1.81665318e-003,
-       2.98342260e-004, 5.81195764e-003, 3.27071152e-003,
-       1.37078483e-002, -1.70746911e-002, 3.29508074e-002,
-       3.04770581e-002, -1.61918290e-002, -1.73851270e-002,
-       4.21899371e-002, 3.12943645e-002, -3.10294400e-003,
-       9.20502003e-004, 6.94482960e-003, 4.02118126e-003,
-       -3.40937893e-003, -8.17511056e-004, 7.26177823e-003,
-       5.89491148e-003, 1.31414470e-003, -4.26158458e-002,
-       4.36045267e-002, 5.94104156e-002, 2.46496126e-002,
-       -3.40857059e-002, 4.71704379e-002, 5.54718524e-002,
-       -5.84799447e-004, -1.77249240e-004, 5.52742789e-003,
-       5.41778328e-003, -4.37566377e-002, 1.33741396e-002,
-       6.28035739e-002, 3.94107029e-002, -1.17717609e-001,
-       3.76490653e-002, 2.78456479e-001, 2.43937790e-001,
-       1.55214235e-001, -1.44252107e-001, 3.22522610e-001,
-       2.89112091e-001, 2.32936144e-002, -2.01359596e-002,
-       5.10336459e-002, 4.40745354e-002, -3.01843807e-002,
-       6.73058163e-003, 5.80831431e-002, 3.52814421e-002,
-       -2.56830961e-001, -5.09573903e-004, 3.67746949e-001,
-       2.54436284e-001, 6.53493479e-002, -3.08709312e-002,
-       2.73755819e-001, 2.41604954e-001, 3.60095501e-002,
-       -7.19514769e-003, 5.70473373e-002, 4.03868556e-002,
-       -2.03352980e-003, -1.48077530e-003, 7.20995478e-003,
-       5.34721371e-003, -3.14975902e-002, 2.10409947e-002,
-       5.44213057e-002, 4.54206690e-002, 6.52502384e-003,
-       2.40915492e-002, 4.14997488e-002, 4.48031127e-002,
-       2.29175272e-003, -3.29906979e-005, 6.64252881e-003,
-       5.63611183e-003, -9.49059241e-003, 3.09647265e-004,
-       1.29010268e-002, 5.60804550e-003, 2.05616038e-002,
-       -3.31789590e-002, 5.88825606e-002, 5.34275472e-002,
-       -1.53242135e-002, -3.79350446e-002, 4.41093035e-002,
-       6.18371293e-002, -8.99274135e-004, -3.96916969e-003,
-       5.32312412e-003, 7.41007784e-003, -1.09724186e-001,
-       5.83832990e-003, 1.27667695e-001, 3.04135606e-002,
-       1.49719128e-002, -1.11102916e-001, 3.72743845e-001,
-       2.22970322e-001, -1.15995981e-001, -1.64539188e-001,
-       2.22285435e-001, 2.56501228e-001, 1.57296751e-002,
-       -1.44340005e-002, 2.96741333e-002, 3.36369723e-002,
-       -9.18495432e-002, 7.74337258e-003, 1.12030841e-001,
-       3.12025957e-002, -1.03255801e-001, 2.03962997e-001,
-       3.27785164e-001, 2.89341837e-001, -5.06281070e-002,
-       1.96293592e-001, 1.71748355e-001, 2.88943529e-001,
-       1.46105941e-002, 2.56536398e-002, 3.00942436e-002,
-       4.00821455e-002, -5.65932831e-003, 4.33929585e-004,
-       1.01944320e-002, 4.97881696e-003, -8.91146157e-003,
-       3.48469801e-002, 4.77048419e-002, 5.69624268e-002,
-       -2.68929312e-003, 3.76855619e-002, 3.54229994e-002,
-       6.21924475e-002, -6.42029569e-004, 3.96116544e-003,
-       4.92240442e-003, 7.97605235e-003, 1.07921602e-003,
-       6.20884355e-004, 4.87232395e-003, 4.06199787e-003,
-       9.20054782e-003, 1.93710383e-002, 3.32513154e-002,
-       3.49701978e-002, 1.72078405e-002, 2.68758759e-002,
-       3.98116075e-002, 3.96788791e-002, -2.69526313e-003,
-       1.20589032e-003, 6.35249447e-003, 4.86313831e-003,
-       3.36535312e-002, 5.71798952e-003, 4.63519096e-002,
-       2.81039849e-002, 7.93219656e-002, 1.75275460e-001,
-       2.46898860e-001, 2.39451632e-001, 8.47723782e-002,
-       9.96281430e-002, 2.98230320e-001, 2.20930740e-001,
-       -4.98853587e-002, -1.29031967e-002, 6.16726913e-002,
-       3.71467471e-002, 3.18180956e-002, -1.27326725e-002,
-       4.59976867e-002, 3.12258005e-002, 2.01633900e-001,
-       -1.16647512e-001, 3.00584406e-001, 2.53032297e-001,
-       -2.12415695e-001, -1.98646113e-001, 3.54038984e-001,
-       2.95596153e-001, -2.65893023e-002, -2.54449360e-002,
-       5.00257537e-002, 4.09210399e-002, 9.05830238e-004,
-       -5.45001880e-004, 4.74084029e-003, 4.38157935e-003,
-       1.62221268e-002, -3.40629593e-002, 3.82286794e-002,
-       4.88344803e-002, -2.27273088e-002, -3.20988670e-002,
-       4.42925170e-002, 4.86763753e-002, 4.54039546e-004,
-       3.56700708e-004, 5.01123210e-003, 4.47404338e-003,
-       -1.44134380e-003, 1.88235706e-003, 4.01732372e-003,
-       5.31598646e-003, 6.68788515e-003, 2.60233674e-002,
-       2.52397954e-002, 4.37321216e-002, 1.38338311e-002,
-       4.26588878e-002, 3.18344533e-002, 5.56590967e-002,
-       -1.26712854e-004, 3.86536005e-003, 5.21022175e-003,
-       6.55852025e-003, 1.87493730e-002, 4.67958301e-002,
-       3.46395895e-002, 5.46571948e-002, 1.06081672e-001,
-       3.93154114e-001, 1.91705614e-001, 4.17226493e-001,
-       -1.82305649e-002, 2.52133548e-001, 2.07446739e-001,
-       3.24790388e-001, -4.51705530e-002, 1.98860792e-003,
-       5.70125580e-002, 4.25158143e-002, 2.24714465e-002,
-       6.86257472e-003, 3.22759934e-002, 2.62765549e-002,
-       4.33130972e-002, -2.44772378e-002, 1.33596703e-001,
-       1.22791134e-001, -2.44677782e-001, -1.45542845e-001,
-       2.92755187e-001, 2.06158802e-001, -3.29289213e-002,
-       -2.35648323e-002, 5.50908484e-002, 4.26803082e-002,
-       9.43250488e-004, -7.40030548e-004, 3.78845935e-003,
-       3.44767072e-003, -3.80789186e-003, -2.11690050e-002,
-       2.72302795e-002, 3.15607786e-002, -3.78122218e-002,
-       -1.63077917e-002, 4.99034822e-002, 3.65065746e-002,
-       -9.25651926e-004, 1.71749911e-003, 6.08301349e-003,
-       4.85861860e-003, 1.13664637e-003, 2.77909148e-003,
-       5.55911567e-003, 6.44167094e-003, 1.50881708e-002,
-       5.95350154e-002, 3.64503935e-002, 7.80605897e-002,
-       9.18881595e-003, 7.24333674e-002, 3.91849801e-002,
-       8.81988928e-002, -2.30704411e-003, 4.52245260e-003,
-       6.89602131e-003, 8.24652798e-003, 5.28386496e-002,
-       9.72243771e-003, 7.14471191e-002, 3.45735177e-002,
-       2.25104585e-001, 2.50488430e-001, 2.91423202e-001,
-       3.03268313e-001, -8.18655118e-002, 1.67449832e-001,
-       2.43857399e-001, 2.37386405e-001, -5.95385320e-002,
-       4.44001565e-003, 7.78706968e-002, 3.63899134e-002,
-       5.17994054e-002, -2.42439844e-003, 7.59232342e-002,
-       2.90994551e-002, 2.96021163e-001, -2.56259590e-002,
-       3.48816484e-001, 1.51918352e-001, -1.70105815e-001,
-       1.27740074e-002, 2.65333563e-001, 1.36558011e-001,
-       -5.76588511e-002, 3.42574413e-003, 8.01081583e-002,
-       3.24811898e-002, 4.42119734e-003, 1.65348453e-003,
-       8.96701124e-003, 4.61452547e-003, 4.21528593e-002,
-       -1.38007635e-002, 5.22706285e-002, 3.04771606e-002,
-       -1.89469736e-002, -1.36360861e-002, 3.92872989e-002,
-       2.73522008e-002, -5.05761104e-003, 1.17507391e-003,
-       8.99556838e-003, 4.35906695e-003, 4.45711077e-004,
-       9.32626834e-004, 3.19248415e-003, 2.82241427e-003,
-       -8.57623818e-004, 1.76345389e-002, 2.11219545e-002,
-       2.58173309e-002, -3.63559760e-002, 1.90537274e-002,
-       4.79786098e-002, 3.38414684e-002, -5.84913231e-003,
-       -1.71454635e-003, 9.20489058e-003, 5.38843777e-003,
-       1.35097401e-002, 3.12438374e-003, 2.41273884e-002,
-       1.46969333e-002, 2.79993620e-002, 3.77453640e-002,
-       9.24753621e-002, 8.44339952e-002, -3.03173810e-001,
-       3.44906151e-002, 3.52640271e-001, 1.43438324e-001,
-       -5.38948365e-002, -7.05463113e-003, 7.13458285e-002,
-       3.30724940e-002, 1.43044172e-002, -5.83881512e-003,
-       2.51355842e-002, 1.79260392e-002, 3.79957771e-003,
-       -8.03274289e-002, 1.03681743e-001, 1.27281517e-001,
-       -4.31041062e-001, -2.61547446e-001, 4.62310612e-001,
-       2.91696072e-001, -3.00652608e-002, -1.51207866e-002,
-       5.37048914e-002, 3.32520753e-002, 1.11835725e-004,
-       -3.49408481e-003, 4.24271310e-003, 5.66141959e-003,
-       -2.10977495e-002, -4.74559292e-002, 3.72308269e-002,
-       5.82145713e-002, -5.58655299e-002, -3.84631008e-002,
-       6.72160685e-002, 5.73425591e-002, 3.71804315e-004,
-       7.72000581e-004, 5.10333758e-003, 4.49107029e-003,
-       7.39997486e-003, -4.18536511e-004, 1.15082031e-002,
-       4.47465107e-003, 1.55923842e-003, 1.71683896e-002,
-       3.30129303e-002, 2.82511152e-002, -4.33601663e-002,
-       1.78285912e-002, 5.82760721e-002, 4.01920564e-002,
-       -6.57038484e-003, -1.91310083e-003, 1.16106477e-002,
-       6.91739470e-003, 8.24109986e-002, -1.31531712e-002,
-       1.04092315e-001, 3.66929099e-002, 6.70612678e-002,
-       9.37914476e-003, 1.64912969e-001, 1.06242254e-001,
-       -2.42193863e-001, 1.08691975e-001, 3.13543290e-001,
-       1.89043745e-001, -8.64729062e-002, 4.75019775e-003,
-       1.09655425e-001, 4.93897870e-002, 7.07161799e-002,
-       -1.19842347e-002, 1.01394527e-001, 4.17526364e-002,
-       1.56859055e-001, -6.87215105e-002, 2.40000516e-001,
-       1.45255387e-001, -3.44056845e-001, -2.16367960e-001,
-       4.00603175e-001, 2.72822708e-001, -6.87216148e-002,
-       -2.41568405e-002, 9.96042117e-002, 5.55051751e-002,
-       4.73161601e-003, 3.55727680e-004, 1.18464939e-002,
-       5.27140871e-003, 1.48222493e-002, -3.01995445e-002,
-       4.96222228e-002, 4.27069850e-002, -7.18837976e-002,
-       -3.64939049e-002, 8.66823122e-002, 5.74083216e-002,
-       6.15082536e-005, 1.19818270e-003, 9.35305003e-003,
-       6.64891675e-003, 2.89341464e-004, 2.91441288e-003,
-       5.81410667e-003, 9.96389333e-003, -1.37929805e-003,
-       5.81978261e-002, 3.38372365e-002, 8.44084397e-002,
-       -1.03070755e-002, 5.70067465e-002, 3.72837186e-002,
-       8.52429271e-002, -1.50497700e-003, 2.44055619e-003,
-       6.06038701e-003, 8.55911896e-003, 3.34790982e-002,
-       9.12422966e-003, 5.07697389e-002, 5.29969893e-002,
-       8.65660831e-002, 8.42465833e-002, 1.96463093e-001,
-       3.35478097e-001, -8.32318440e-002, 1.69686124e-001,
-       1.99573323e-001, 3.05845290e-001, -4.68200222e-002,
-       2.44431030e-002, 6.15278669e-002, 5.04447408e-002,
-       3.47841121e-002, -1.09779919e-002, 5.31856194e-002,
-       5.66302501e-002, 1.12976700e-001, -3.05578578e-002,
-       1.97755367e-001, 3.65947813e-001, -1.19604617e-001,
-       -1.12572260e-001, 2.06580430e-001, 3.05857033e-001,
-       -4.63389792e-002, -2.27051247e-002, 6.30062297e-002,
-       5.11312298e-002, -4.01750876e-004, -1.00835841e-002,
-       5.34370914e-003, 1.69194508e-002, 4.94422857e-003,
-       -1.36332422e-001, 3.33788730e-002, 1.76555574e-001,
-       -5.80904214e-003, -1.26220256e-001, 3.48347686e-002,
-       1.64783567e-001, -9.14639677e-004, -8.28203280e-003,
-       6.34397566e-003, 1.50025943e-002, -2.28060433e-003,
-       4.23602964e-004, 6.72167446e-003, 2.74624489e-003,
-       -5.61005669e-003, -1.73921641e-002, 7.61997402e-002,
-       3.21001336e-002, 9.01705865e-003, -1.41513133e-002,
-       4.13631536e-002, 3.27320211e-002, 1.33506197e-003,
-       -5.20705886e-004, 5.32058394e-003, 3.63830337e-003,
-       -2.85401978e-002, -8.03705771e-003, 5.58048338e-002,
-       2.17450745e-002, -5.34177013e-002, -9.31477472e-002,
-       5.98729610e-001, 1.77922696e-001, 5.10586165e-002,
-       -1.10275194e-001, 2.32712567e-001, 1.90897092e-001,
-       2.71967053e-002, -4.64135874e-003, 4.09105308e-002,
-       2.90839300e-002, -3.92460078e-002, -6.78836228e-003,
-       5.80536835e-002, 2.70429030e-002, -7.18922913e-002,
-       4.39744852e-002, 3.42099339e-001, 1.97103307e-001,
-       1.66122511e-001, 1.09304354e-001, 2.42503718e-001,
-       2.20396116e-001, 2.10516118e-002, 1.38062201e-002,
-       3.86878178e-002, 3.27172540e-002, -3.78967472e-003,
-       -3.45965469e-004, 6.88717561e-003, 3.73282586e-003,
-       9.31892486e-004, 2.08256450e-002, 4.20116857e-002,
-       3.64932865e-002, 2.02465300e-002, 1.59274805e-002,
-       4.00486067e-002, 3.63475382e-002, 1.19747769e-004,
-       -5.69499563e-004, 4.90263477e-003, 4.58956137e-003,
-       -9.28676309e-005, 2.20248965e-003, 2.92798481e-003,
-       4.72699851e-003, 1.50132924e-003, 2.77782753e-002,
-       1.81654934e-002, 4.07214984e-002, -1.09689194e-004,
-       2.71780156e-002, 1.74754076e-002, 4.02889289e-002,
-       1.59636184e-004, 2.36715726e-003, 2.59951944e-003,
-       4.76571685e-003, 2.18348615e-002, 2.56390460e-002,
-       2.88818497e-002, 3.84213328e-002, 5.34553602e-002,
-       2.49024510e-001, 1.15123190e-001, 2.87934065e-001,
-       -4.00300734e-002, 2.53985375e-001, 1.05018593e-001,
-       2.89976329e-001, -1.87224522e-002, 2.81328894e-002,
-       2.54903547e-002, 3.89502831e-002, 2.02975366e-002,
-       -3.63492072e-002, 2.75469106e-002, 4.54293415e-002,
-       5.21606803e-002, -3.47772002e-001, 1.15415908e-001,
-       3.77471030e-001, -3.56716365e-002, -3.53269696e-001,
-       1.06108621e-001, 3.83693844e-001, -1.67498477e-002,
-       -3.91139016e-002, 2.48172525e-002, 4.79396395e-002,
-       -4.67530306e-004, -1.56367349e-003, 2.60419631e-003,
-       4.48991405e-003, -2.79195752e-004, -1.73735172e-002,
-       1.58364531e-002, 3.57004441e-002, 3.38498183e-004,
-       -1.68682747e-002, 1.51587008e-002, 3.57193574e-002,
-       6.65560074e-004, -1.75902620e-003, 2.46480480e-003,
-       4.64928057e-003, -3.61374510e-003, 1.06622872e-003,
-       8.71437043e-003, 4.65720193e-003, -2.96752546e-002,
-       -2.88943499e-002, 5.78083992e-002, 4.94448319e-002,
-       6.62464229e-003, -2.74689104e-002, 3.86888869e-002,
-       5.23482226e-002, -1.20145280e-003, -1.68223598e-003,
-       5.22239599e-003, 6.18878333e-003, -5.79075925e-002,
-       -6.67349435e-003, 8.22638199e-002, 3.13038267e-002,
-       -3.37060124e-001, -1.44177169e-001, 4.15860265e-001,
-       2.37207219e-001, 4.87453230e-002, -2.05545127e-001,
-       1.63114488e-001, 2.61529833e-001, 1.64549761e-002,
-       -2.41957232e-002, 3.30053456e-002, 3.71994451e-002,
-       -7.64987692e-002, -1.82128605e-002, 9.63686481e-002,
-       4.24055941e-002, -2.42750123e-001, 4.79172990e-002,
-       3.47129881e-001, 2.48744667e-001, -2.73161125e-003,
-       8.55695233e-002, 1.50161073e-001, 1.76264137e-001,
-       1.89458337e-002, 3.79054970e-003, 3.11407540e-002,
-       2.59976089e-002, -6.72530709e-003, -7.79882481e-004,
-       1.10866176e-002, 6.21424010e-003, -1.83734242e-002,
-       2.96540391e-002, 5.12338020e-002, 5.17326035e-002,
-       -1.22122411e-002, 2.68673133e-002, 3.57843414e-002,
-       4.42214534e-002, 3.97742173e-004, 1.57390721e-003,
-       4.16042516e-003, 4.90509206e-003, 4.77333844e-004,
-       5.37861197e-004, 5.33526018e-003, 4.41233441e-003,
-       -4.72834259e-002, -4.07388657e-002, 6.27048090e-002,
-       5.66129573e-002, -4.53496439e-004, -4.69041914e-002,
-       4.33743410e-002, 5.93196675e-002, -1.94337743e-004,
-       -1.93542382e-003, 5.31792361e-003, 5.86839067e-003,
-       -3.20390910e-002, -7.19967261e-002, 5.01963384e-002,
-       8.05111080e-002, -2.76129276e-001, -3.14482272e-001,
-       3.50102663e-001, 3.86542499e-001, 9.47851837e-002,
-       -1.45823747e-001, 1.88888043e-001, 2.49522462e-001,
-       1.48757510e-002, -2.91766133e-002, 3.13850865e-002,
-       4.44193445e-002, -2.67970376e-002, 1.66834556e-002,
-       4.11802977e-002, 5.23972660e-002, -4.45177220e-002,
-       2.28358597e-001, 1.66393980e-001, 2.84915060e-001,
-       -3.01972758e-002, 1.30291671e-001, 1.52350828e-001,
-       2.03037471e-001, 1.48848956e-002, 7.92065728e-003,
-       2.64247656e-002, 3.16285864e-002, 5.12239058e-004,
-       2.84170196e-003, 5.36591467e-003, 7.10428180e-003,
-       -1.51880495e-002, 3.18845101e-002, 3.73750478e-002,
-       5.12029715e-002, -1.57753304e-002, 3.23315337e-002,
-       3.47339660e-002, 4.65497151e-002, 2.40173285e-005,
-       2.53072963e-003, 4.30182647e-003, 5.60729019e-003,
-       1.38046918e-003, 1.69433159e-004, 5.02821757e-003,
-       4.31721378e-003, 1.89457703e-002, 2.10332330e-002,
-       3.41987312e-002, 3.99526507e-002, 8.01386021e-004,
-       2.70558838e-002, 2.93403249e-002, 4.42073867e-002,
-       -1.09663862e-003, 1.03883992e-003, 4.50252555e-003,
-       5.13152778e-003, 2.73763277e-002, 8.69454816e-003,
-       4.48965244e-002, 3.07965577e-002, 1.46554276e-001,
-       8.07897672e-002, 2.26644471e-001, 2.07127899e-001,
-       -5.41738644e-002, -3.12492102e-002, 1.83792740e-001,
-       2.45171994e-001, -2.74009537e-002, -7.67935487e-003,
-       4.23589200e-002, 3.85910384e-002, 3.04029677e-002,
-       -5.72041096e-003, 4.68938090e-002, 3.48830447e-002,
-       8.49509314e-002, -1.06957458e-001, 2.31050685e-001,
-       3.10427547e-001, -1.80965006e-001, -2.14841828e-001,
-       2.68586040e-001, 5.13728499e-001, -2.62678042e-002,
-       -3.76304798e-002, 4.55172285e-002, 6.31285906e-002,
-       5.74547157e-004, -3.44047905e-003, 4.71054204e-003,
-       7.08782487e-003, -9.33654141e-003, -5.42936139e-002,
-       3.48209478e-002, 7.67921880e-002, -1.12769920e-002,
-       -2.29724441e-002, 3.21924426e-002, 6.23474009e-002,
-       7.56548019e-004, 9.53452138e-004, 4.11686674e-003,
-       6.37877081e-003, -6.56859390e-003, 1.16427522e-003,
-       9.48857423e-003, 3.90681252e-003, -6.21081190e-003,
-       -1.18164560e-002, 2.64398307e-002, 2.74670385e-002,
-       2.07944005e-003, -1.20492559e-002, 2.10373458e-002,
-       2.48803739e-002, 1.24007475e-003, -2.42586451e-004,
-       3.69105744e-003, 3.30799934e-003, -7.43903890e-002,
-       9.20904055e-003, 8.93115029e-002, 2.87300646e-002,
-       -7.69404694e-002, -2.77620032e-002, 1.53614745e-001,
-       1.18803345e-001, 5.72572537e-002, -1.58297457e-002,
-       1.11093357e-001, 1.09468415e-001, 2.02685669e-002,
-       4.63121943e-003, 3.02225873e-002, 2.31662430e-002,
-       -6.60674796e-002, 3.25243846e-002, 8.31635222e-002,
-       4.58990186e-002, -8.70187134e-002, 3.84821087e-001,
-       1.84657261e-001, 4.17104602e-001, 8.67294595e-002,
-       4.10927862e-001, 1.44993916e-001, 4.47140455e-001,
-       1.96166560e-002, 5.15637286e-002, 3.45950648e-002,
-       6.02979399e-002, -1.23238642e-004, 2.05349526e-003,
-       6.08939072e-003, 5.49284881e-003, 3.38067627e-003,
-       4.13269177e-002, 2.62319483e-002, 5.88413216e-002,
-       4.02665790e-003, 3.63149494e-002, 2.25721635e-002,
-       5.63326553e-002, -1.92746019e-003, 3.13635659e-003,
-       4.33258619e-003, 6.90767262e-003, 5.69540534e-005,
-       -1.32416037e-003, 5.23107266e-003, 4.32833331e-003,
-       2.41326615e-002, -2.61927228e-002, 4.60466109e-002,
-       4.26998101e-002, 4.91339788e-002, -2.53106002e-002,
-       5.82773983e-002, 4.71544079e-002, 1.16992171e-003,
-       9.58128192e-004, 4.03501792e-003, 3.77317122e-003,
-       -1.67122278e-002, 2.41981907e-004, 4.13877517e-002,
-       2.77334154e-002, 1.20675385e-001, -3.94947492e-002,
-       2.83629745e-001, 1.75296485e-001, 2.60654479e-001,
-       -1.65144026e-001, 3.54824811e-001, 2.62782663e-001,
-       4.53326069e-002, -1.83963850e-002, 5.62965684e-002,
-       2.95720715e-002, -1.99248251e-002, 3.21196346e-003,
-       4.21055332e-002, 2.75120307e-002, 1.69415683e-001,
-       1.01008713e-001, 3.07571054e-001, 1.77535400e-001,
-       1.67430192e-001, 1.99380353e-001, 3.09215635e-001,
-       2.71475226e-001, 5.26377074e-002, 1.23349624e-002,
-       6.43677115e-002, 2.95671485e-002, 2.36357999e-004,
-       1.60414481e-003, 5.25568891e-003, 4.26283432e-003,
-       3.42482664e-002, 3.48388962e-002, 5.00035509e-002,
-       4.76845503e-002, 3.23145874e-002, 2.96686105e-002,
-       4.70607802e-002, 4.82110865e-002, 7.09447020e-004,
-       6.46352191e-006, 4.26503038e-003, 3.70703056e-003,
-       7.33548717e-004, -5.19235502e-004, 3.36975884e-003,
-       4.85880440e-003, 7.60770403e-003, 6.89786859e-003,
-       2.23930776e-002, 4.54504974e-002, -3.83415027e-003,
-       1.01942876e-002, 2.14913059e-002, 4.40303273e-002,
-       -9.42585175e-004, -1.42632751e-004, 3.25369858e-003,
-       4.64371033e-003, 7.46617652e-003, -6.27262564e-003,
-       2.62310412e-002, 3.72666344e-002, 6.67020231e-002,
-       -1.09661356e-001, 1.52526468e-001, 3.30811590e-001,
-       -5.45070581e-002, -1.47410125e-001, 1.50329813e-001,
-       3.61650944e-001, -9.54751018e-003, -1.19013358e-002,
-       2.61489265e-002, 3.87533680e-002, 6.61386037e-003,
-       4.63497918e-003, 2.68772542e-002, 5.40589839e-002,
-       4.68552597e-002, 7.27368668e-002, 1.41640216e-001,
-       5.05957365e-001, -5.06618805e-002, 8.74428377e-002,
-       1.42659619e-001, 4.42887008e-001, -8.40514526e-003,
-       6.62656408e-003, 2.51805410e-002, 4.62189540e-002,
-       3.50320479e-004, 1.02709957e-004, 3.11562745e-003,
-       5.45241358e-003, 2.58989749e-003, -4.06068284e-003,
-       2.13735942e-002, 4.76458743e-002, -1.61433429e-003,
-       -3.23452358e-003, 2.15710383e-002, 4.84894961e-002,
-       -6.23154570e-004, 6.13919983e-004, 3.10594286e-003,
-       5.20453975e-003, 3.73077899e-004, 1.87467784e-003,
-       5.98467700e-003, 6.15559332e-003, -3.20107141e-003,
-       1.83188710e-002, 2.70963106e-002, 4.67441715e-002,
-       -2.47014570e-003, 1.92007814e-002, 2.84967348e-002,
-       4.74859551e-002, -2.27301661e-003, 7.02468853e-004,
-       4.83502587e-003, 5.62064163e-003, 2.08965894e-002,
-       4.05742991e-004, 3.91561128e-002, 3.65858637e-002,
-       3.15222815e-002, 1.40836090e-002, 1.34923548e-001,
-       2.31604874e-001, -3.79269458e-002, 6.51878398e-003,
-       1.48719326e-001, 2.69068420e-001, -2.86001898e-002,
-       3.11259390e-003, 4.04234119e-002, 3.57692949e-002,
-       2.69355606e-002, 1.29530663e-002, 4.41374853e-002,
-       6.49582446e-002, 3.57707292e-002, 1.71601087e-001,
-       1.35424927e-001, 4.62578624e-001, -3.25986445e-002,
-       1.91871107e-001, 1.49705365e-001, 5.27283370e-001,
-       -3.48239020e-002, 2.26272885e-002, 4.60198410e-002,
-       6.56392500e-002, 2.61858164e-004, -8.97160918e-003,
-       4.07639425e-003, 1.50352782e-002, 1.46965333e-003,
-       -1.06860258e-001, 2.16802824e-002, 1.39215395e-001,
-       9.91490204e-004, -1.04308710e-001, 2.16919556e-002,
-       1.43536836e-001, 2.68023810e-004, -6.91173784e-003,
-       4.34115203e-003, 1.35962935e-002, 6.18679551e-005,
-       -1.82830496e-004, 4.01279470e-003, 5.51044103e-003,
-       7.97778647e-003, 2.01511849e-002, 2.77588014e-002,
-       4.84052226e-002, 3.97847005e-004, 3.29046100e-002,
-       2.42063310e-002, 5.52795306e-002, -6.61084894e-004,
-       1.78765506e-003, 3.82478163e-003, 5.95532078e-003,
-       2.46783700e-002, 2.04826314e-002, 4.06620875e-002,
-       4.23966758e-002, 7.21957758e-002, 1.16066173e-001,
-       2.37992972e-001, 3.69812280e-001, -9.42135602e-002,
-       -1.12558745e-001, 2.00838074e-001, 4.47144210e-001,
-       -1.82117820e-002, -7.60587025e-003, 3.41910087e-002,
-       4.37668785e-002, 2.36811098e-002, -1.20774545e-002,
-       3.95656638e-002, 3.85235660e-002, -1.62511710e-002,
-       -1.35408759e-001, 2.23580629e-001, 3.09028506e-001,
-       -6.16990998e-002, 3.71268317e-002, 1.87640548e-001,
-       3.78891945e-001, -1.69352982e-002, 1.59196393e-003,
-       3.16520110e-002, 4.26048860e-002, 7.39720199e-005,
-       -1.09189481e-003, 3.88931367e-003, 5.50676603e-003,
-       1.61955366e-003, -2.00329479e-002, 2.62168515e-002,
-       4.88102362e-002, -1.72095629e-003, -2.35741306e-002,
-       2.47166101e-002, 5.05742840e-002, -3.95942276e-004,
-       -1.20510941e-003, 3.57434433e-003, 5.32635208e-003,
-       1.91839773e-003, 4.57531773e-004, 5.25985099e-003,
-       4.09036549e-003, 8.74710921e-003, 2.49107890e-002,
-       3.45176086e-002, 3.76662947e-002, -2.44426467e-002,
-       1.82810277e-002, 4.06030118e-002, 3.74551229e-002,
-       2.62929552e-005, -3.24057735e-004, 4.41613747e-003,
-       4.48423717e-003, 3.56716849e-002, 4.31856170e-004,
-       4.87761609e-002, 2.88040880e-002, 1.01086266e-001,
-       7.26305842e-002, 2.42528647e-001, 1.84956759e-001,
-       -1.99511692e-001, 1.37431741e-001, 2.70613551e-001,
-       2.36852169e-001, -1.44600524e-002, 2.17300355e-002,
-       3.61289121e-002, 3.81431133e-002, 2.94107776e-002,
-       -1.40059991e-002, 4.58350703e-002, 3.42678912e-002,
-       1.15458213e-001, -2.16179654e-001, 2.76253641e-001,
-       3.31268430e-001, 1.14881131e-003, -1.25532985e-001,
-       2.26148307e-001, 4.60717857e-001, -3.04317195e-002,
-       -2.42346385e-003, 4.44327183e-002, 5.49968667e-002,
-       3.59341997e-004, -8.37984378e-004, 4.42245137e-003,
-       4.97831451e-003, 4.78376809e-004, -2.67613009e-002,
-       3.19371969e-002, 5.07990941e-002, 2.84169917e-003,
-       -3.16613838e-002, 2.89815329e-002, 5.82942590e-002,
-       3.96356372e-005, -2.81634089e-003, 4.37215297e-003,
-       7.06175715e-003, 2.81426730e-003, -3.30638315e-004,
-       5.42435516e-003, 3.25267715e-003, 2.27596015e-002,
-       2.12366655e-002, 4.08021808e-002, 3.19593586e-002,
-       -5.63460868e-003, 2.78968513e-002, 4.34862114e-002,
-       4.04409058e-002, -2.72316672e-003, 5.18569781e-004,
-       6.89155422e-003, 4.51510539e-003, 3.01335100e-002,
-       -3.25996801e-003, 4.35842015e-002, 1.94103736e-002,
-       2.75416493e-001, 6.41916171e-002, 3.42330754e-001,
-       1.54611662e-001, -1.96811967e-002, 1.39043331e-001,
-       3.11173856e-001, 2.06926599e-001, -5.19828051e-002,
-       8.87091924e-003, 6.87478632e-002, 3.15460786e-002,
-       2.72254646e-002, -2.07598973e-003, 4.19356339e-002,
-       1.90164037e-002, 3.51368695e-001, -2.56534163e-002,
-       4.00920630e-001, 1.67174906e-001, -8.85509402e-002,
-       -1.17264584e-001, 2.63362944e-001, 2.06337228e-001,
-       -4.59932722e-002, -5.45775052e-003, 6.53853193e-002,
-       3.18789780e-002, 2.39677192e-003, 6.48125657e-004,
-       5.42123290e-003, 3.42254993e-003, 3.21353972e-002,
-       -2.67191809e-002, 4.79292311e-002, 3.91239859e-002,
-       -1.38112605e-002, -3.06168031e-002, 4.03212570e-002,
-       4.40464914e-002, -1.39702554e-003, -4.31978406e-004,
-       6.41646981e-003, 4.77021793e-003, 3.12466430e-003,
-       -2.28975471e-002, 7.66196847e-003, 2.89713778e-002,
-       6.33611344e-003, -2.39555299e-001, 3.71616073e-002,
-       2.77512044e-001, -5.41646592e-003, -2.40187228e-001,
-       4.26309370e-002, 2.79004425e-001, -4.33657598e-003,
-       -2.34539453e-002, 9.75193083e-003, 3.02398074e-002,
-       -4.12821062e-002, -6.58996543e-003, 5.72507232e-002,
-       4.77848798e-002, -7.15928674e-002, -1.61514178e-001,
-       1.91557199e-001, 3.33098799e-001, 7.30017349e-002,
-       -1.21224083e-001, 1.68804094e-001, 3.19350928e-001,
-       1.84654705e-002, -1.47228558e-002, 3.82439680e-002,
-       4.87658903e-002, -5.30842915e-002, 1.94350607e-003,
-       6.63302615e-002, 3.51443142e-002, -1.28262728e-001,
-       -3.25834937e-002, 2.29937434e-001, 1.97367877e-001,
-       1.26699030e-001, -5.02422191e-002, 1.77830756e-001,
-       2.02469721e-001, 2.54471432e-002, -1.92714005e-003,
-       3.58501263e-002, 3.57589424e-002, -5.65284351e-003,
-       -2.31867773e-004, 8.83126818e-003, 5.27112978e-003,
-       -1.71663351e-002, 1.26550114e-002, 3.42237167e-002,
-       2.89255828e-002, 1.34525960e-002, 8.67335033e-003,
-       2.65099965e-002, 2.70900838e-002, 2.39379960e-003,
-       -3.88949498e-004, 4.75939037e-003, 4.90011647e-003,
-       -6.13736454e-004, -2.92004755e-004, 5.39444899e-003,
-       5.36379730e-003, -2.81786956e-002, -3.09203714e-002,
-       4.98314053e-002, 5.93405813e-002, -1.12266466e-002,
-       -3.24536189e-002, 3.79851833e-002, 5.59274070e-002,
-       -2.24416377e-004, -1.72029366e-003, 5.10276295e-003,
-       5.98944956e-003, -3.56481597e-002, -1.63817860e-003,
-       5.41838296e-002, 4.82429415e-002, -2.55131066e-001,
-       -1.09933458e-001, 3.44240397e-001, 4.12937194e-001,
-       4.48624231e-002, -1.13450691e-001, 1.65998623e-001,
-       2.45582357e-001, 1.88860856e-002, -7.97424745e-003,
-       3.58502083e-002, 3.30560878e-002, -3.13844383e-002,
-       1.98408752e-003, 5.31432033e-002, 3.45267169e-002,
-       -3.22585732e-001, 8.40642955e-003, 3.89903516e-001,
-       2.09805474e-001, 8.32365528e-002, 4.14517708e-002,
-       1.64400324e-001, 1.50986373e-001, 1.84640680e-002,
-       4.98420000e-003, 3.42278890e-002, 2.64226496e-002,
-       -3.27542704e-003, -1.41565164e-003, 7.43143214e-003,
-       4.94316453e-003, -3.47828455e-002, 1.91059876e-002,
-       5.22384308e-002, 3.87741663e-002, 7.03252247e-003,
-       1.66761745e-002, 3.08123510e-002, 3.27913947e-002,
-       5.67097275e-004, 6.58561362e-007, 4.78072697e-003,
-       4.05374402e-003, -2.01321527e-004, -1.18435419e-003,
-       3.48160113e-003, 3.41328001e-003, 9.63453762e-003,
-       -2.08370835e-002, 2.58495286e-002, 3.02494224e-002,
-       6.08110949e-002, -2.31621116e-002, 6.91817701e-002,
-       3.95062529e-002, 6.89319056e-003, 2.74352450e-003,
-       1.17317960e-002, 5.72071271e-003, -1.04950955e-002,
-       -1.19031302e-003, 2.41610836e-002, 1.72983967e-002,
-       1.49107911e-002, -3.12254261e-002, 1.15572385e-001,
-       1.04173429e-001, 4.04793084e-001, -1.02258146e-001,
-       4.37901706e-001, 1.69308394e-001, 9.02732164e-002,
-       -1.11598549e-002, 1.13972120e-001, 3.53254005e-002,
-       -1.05809318e-002, 2.02802904e-002, 2.67510302e-002,
-       3.12443040e-002, 9.52728558e-003, 1.69847757e-001,
-       1.28200665e-001, 2.13020340e-001, 2.77720273e-001,
-       1.34713680e-001, 3.34627628e-001, 2.27208853e-001,
-       1.04058497e-001, -8.78034532e-003, 1.23796709e-001,
-       4.04838547e-002, 1.81666506e-003, 6.16327580e-003,
-       5.35797561e-003, 1.02028633e-002, 9.79472417e-003,
-       7.45098814e-002, 3.76465097e-002, 9.57273841e-002,
-       2.08109654e-002, 7.48619586e-002, 4.64533977e-002,
-       9.56255570e-002, 5.26591204e-003, 4.06117353e-004,
-       9.84816160e-003, 8.08466133e-003, 1.71453448e-003,
-       5.75919228e-004, 5.01344353e-003, 3.78345768e-003,
-       8.16216506e-003, 1.81635804e-002, 3.06533836e-002,
-       3.65683064e-002, 1.13464370e-002, 2.04712190e-002,
-       4.33445536e-002, 4.37897034e-002, -9.66559339e-004,
-       5.94095793e-004, 6.89170230e-003, 4.78759175e-003,
-       3.00303418e-002, 4.43214923e-003, 4.87857535e-002,
-       2.27850415e-002, 7.71964714e-002, 7.76663348e-002,
-       2.24471122e-001, 1.85265824e-001, 1.57701507e-001,
-       1.60339788e-001, 4.08423662e-001, 2.45926961e-001,
-       -4.37496752e-002, 9.80627351e-003, 6.81254715e-002,
-       3.21070626e-002, 3.07010747e-002, -6.43588882e-003,
-       4.94124517e-002, 2.23643500e-002, 5.52364625e-002,
-       -1.15019105e-001, 2.35876769e-001, 1.96587592e-001,
-       1.86581567e-001, -1.90175712e-001, 4.19416487e-001,
-       2.66966313e-001, -4.42502126e-002, -1.04129110e-002,
-       6.68301359e-002, 3.23840454e-002, 1.83410093e-003,
-       -6.19308848e-004, 4.76668170e-003, 3.40204709e-003,
-       6.52513700e-003, -1.45020494e-002, 2.91067641e-002,
-       3.43834907e-002, 1.17684118e-002, -2.13846881e-002,
-       4.04844321e-002, 4.23832312e-002, -1.07075530e-003,
-       -1.72811968e-003, 6.49946183e-003, 4.80324402e-003,
-       9.20474122e-004, 1.27918058e-004, 4.90651606e-003,
-       4.16024914e-003, 1.43593643e-002, 2.35797167e-002,
-       3.78634408e-002, 4.74189036e-002, -7.64353620e-003,
-       2.45216060e-002, 3.60984467e-002, 5.33401407e-002,
-       9.23751912e-004, 2.57440872e-004, 5.01757162e-003,
-       5.44496393e-003, 1.07974280e-002, 8.72202776e-003,
-       4.19123657e-002, 3.17334235e-002, 2.21872315e-001,
-       3.73384962e-003, 3.26943815e-001, 2.75918782e-001,
-       -4.26727422e-002, 9.89571884e-002, 2.65677214e-001,
-       3.33519071e-001, -1.82207078e-002, 2.05792040e-002,
-       4.71296944e-002, 4.43636104e-002, 2.71830894e-002,
-       1.23542212e-002, 5.16881272e-002, 3.69923487e-002,
-       5.22292741e-002, 1.27249360e-001, 2.88938433e-001,
-       3.26171517e-001, 6.22039177e-002, -3.60567868e-002,
-       2.57878631e-001, 3.03057164e-001, -1.99615154e-002,
-       5.91387157e-004, 4.59620580e-002, 4.01826799e-002,
-       2.92548258e-003, -3.11809679e-004, 5.89012774e-003,
-       5.33019612e-003, 9.43231047e-004, -2.70790253e-002,
-       3.92526872e-002, 5.50332703e-002, -1.48342084e-003,
-       -2.21039634e-002, 3.79055701e-002, 5.50907031e-002,
-       1.28618150e-004, -1.44833454e-003, 4.94491262e-003,
-       6.00678241e-003, 1.81224430e-003, -1.05697196e-002,
-       6.16982765e-003, 1.46749429e-002, 9.54157673e-003,
-       -1.27110168e-001, 4.06619199e-002, 1.50962636e-001,
-       -8.38937517e-003, -1.31518394e-001, 4.38847467e-002,
-       1.58133179e-001, -3.61305242e-003, -1.16220703e-002,
-       7.74174416e-003, 1.60133690e-002, -1.70947332e-002,
-       -2.36188415e-002, 2.96801161e-002, 4.13464233e-002,
-       -4.21366505e-002, -1.62019759e-001, 1.22083075e-001,
-       2.59747416e-001, 2.18571108e-002, -1.66411489e-001,
-       1.21662855e-001, 2.80145884e-001, 1.75116323e-002,
-       -1.64970849e-002, 3.42777818e-002, 4.23091613e-002,
-       -1.31019661e-002, 3.31670418e-002, 2.78341174e-002,
-       4.82943319e-002, -1.87809858e-002, 2.96601087e-001,
-       1.14447996e-001, 3.56841981e-001, 1.66157596e-002,
-       3.16043317e-001, 1.16816960e-001, 3.66272032e-001,
-       1.52570484e-002, 3.53752635e-002, 3.26626264e-002,
-       5.18245213e-002, 2.50881445e-003, 9.70678963e-003,
-       6.15595700e-003, 1.41277323e-002, 1.06076486e-002,
-       9.83134210e-002, 3.72478366e-002, 1.27534211e-001,
-       -8.41326546e-003, 9.41439569e-002, 3.79238352e-002,
-       1.27418607e-001, -3.23687657e-003, 8.82302038e-003,
-       7.35660829e-003, 1.41352285e-002, -1.64404802e-003,
-       3.92447342e-004, 4.82142251e-003, 3.15649295e-003,
-       -1.83749329e-002, -1.58861950e-002, 3.72349583e-002,
-       2.99023036e-002, 1.66936796e-002, -1.83714572e-002,
-       5.38590737e-002, 3.17759253e-002, 2.91193207e-003,
-       8.75714177e-004, 6.88603753e-003, 3.11024114e-003,
-       -2.38313451e-002, -3.62528744e-003, 4.06976417e-002,
-       1.97391361e-002, -1.69369966e-001, -5.82701750e-002,
-       2.47128814e-001, 1.38084248e-001, 1.68469667e-001,
-       -6.56760186e-002, 4.75791186e-001, 1.38608858e-001,
-       2.97641512e-002, 1.88729074e-003, 5.62591292e-002,
-       1.86232328e-002, -2.17575897e-002, 4.50327480e-003,
-       3.87341529e-002, 1.93069503e-002, -1.85957253e-001,
-       6.38704076e-002, 2.58918196e-001, 1.29283771e-001,
-       1.78002775e-001, 4.91814278e-002, 5.26999056e-001,
-       1.20286942e-001, 2.72888895e-002, 7.17976247e-004,
-       5.65995201e-002, 1.82215646e-002, -1.48999854e-003,
-       -3.62582301e-004, 4.75414842e-003, 2.78097973e-003,
-       -2.57614814e-002, 1.16593447e-002, 4.09605838e-002,
-       2.48943362e-002, 2.27263775e-002, 1.54914754e-002,
-       6.48234934e-002, 2.71732286e-002, 2.28209305e-003,
-       -8.69906333e-004, 7.19930232e-003, 3.02038714e-003,
-       2.15283083e-003, -1.03846833e-003, 7.41043873e-003,
-       3.86316935e-003, 6.36200458e-002, 1.85453333e-002,
-       7.43713677e-002, 3.35111171e-002, 5.42623550e-003,
-       1.43855158e-002, 2.39103083e-002, 2.33878121e-002,
-       -1.14925625e-003, 6.69531000e-004, 3.35156219e-003,
-       2.60140235e-003, 3.00251618e-002, 8.29054322e-003,
-       5.88875487e-002, 2.62247548e-002, 4.16477829e-001,
-       9.59530100e-002, 4.87053782e-001, 1.69658020e-001,
-       -8.88054073e-003, 1.48125859e-002, 1.08007938e-001,
-       8.39666054e-002, -1.47291282e-002, -1.84091667e-004,
-       2.69065164e-002, 1.51565177e-002, 5.58463633e-002,
-       1.62923895e-002, 7.44118243e-002, 3.90527509e-002,
-       2.51060545e-001, -4.18364406e-002, 3.58623594e-001,
-       2.08874196e-001, -9.04270727e-003, -1.14901058e-001,
-       1.26962930e-001, 1.79194406e-001, -1.49709219e-002,
-       -1.41674876e-002, 3.23483497e-002, 2.65388172e-002,
-       3.62401758e-003, -3.83121497e-003, 6.70421869e-003,
-       1.04230074e-002, 5.92165627e-003, -9.31462422e-002,
-       4.05674651e-002, 1.43465325e-001, 5.05873468e-003,
-       -9.68122706e-002, 3.39880437e-002, 1.47926018e-001,
-       1.12899230e-003, -9.59601626e-003, 5.30394912e-003,
-       1.67218838e-002, 8.24340968e-004, 2.49260105e-003,
-       4.66691842e-003, 8.53133854e-003, 1.23416148e-002,
-       4.63266298e-002, 3.38055678e-002, 8.62741992e-002,
-       1.89903397e-002, 5.94463795e-002, 3.63817327e-002,
-       9.81378853e-002, 1.45299884e-003, 5.68654714e-003,
-       4.38441522e-003, 1.09752137e-002, 5.88627756e-002,
-       9.26223118e-003, 6.96791112e-002, 5.54952249e-002,
-       1.67349413e-001, 2.77220219e-001, 2.28151664e-001,
-       3.64908695e-001, 7.17163377e-004, 1.99986890e-001,
-       1.10109948e-001, 2.51462996e-001, -9.81207564e-003,
-       2.05822960e-002, 2.23116037e-002, 3.16888914e-002,
-       3.94334644e-002, -2.84751467e-002, 6.23225123e-002,
-       4.89907041e-002, 3.42380941e-001, -2.24685863e-001,
-       3.77891481e-001, 2.80112624e-001, -1.28449332e-002,
-       -3.45924869e-002, 9.24160257e-002, 9.99017730e-002,
-       -9.33077279e-003, -1.08606345e-003, 1.85161605e-002,
-       1.55095952e-002, 3.93646682e-004, 9.63852392e-004,
-       6.33800263e-003, 5.05425874e-003, 5.65369800e-002,
-       -2.87129171e-002, 6.85374290e-002, 4.91225608e-002,
-       1.72351599e-002, -2.86089350e-002, 3.17395367e-002,
-       3.80408876e-002, -1.46741440e-004, -1.21634302e-003,
-       2.77845212e-003, 3.18037439e-003, 2.90887593e-003,
-       1.01042364e-003, 6.66655134e-003, 6.12202985e-003,
-       -3.46626592e-004, 4.25331034e-002, 4.31754440e-002,
-       6.05596229e-002, -9.99998115e-003, 3.47037911e-002,
-       4.24779020e-002, 5.64086363e-002, -4.23930556e-004,
-       6.14948163e-004, 5.96437603e-003, 6.04854757e-003,
-       4.84874919e-002, -1.26212742e-002, 6.31966367e-002,
-       3.95596325e-002, 7.42610618e-002, -2.43160725e-002,
-       3.34331304e-001, 2.77823389e-001, -5.67018986e-002,
-       1.26083717e-001, 2.63533920e-001, 2.41162732e-001,
-       -3.29856351e-002, 1.80903431e-002, 5.46210594e-002,
-       3.81465182e-002, 2.50853933e-002, -1.51462452e-002,
-       4.77615893e-002, 3.74578275e-002, 2.48156726e-001,
-       -1.87747598e-001, 3.68923366e-001, 3.51646692e-001,
-       3.60826738e-002, -5.34147657e-002, 2.17152625e-001,
-       2.10634261e-001, -3.78820375e-002, 3.70443659e-003,
-       5.43114021e-002, 3.34283598e-002, -1.09538611e-004,
-       9.71348956e-004, 5.12104621e-003, 4.95364144e-003,
-       2.66056322e-002, -1.95497442e-002, 4.49500866e-002,
-       4.75237891e-002, 1.93452574e-002, -3.72578762e-002,
-       4.22570072e-002, 5.22306561e-002, -1.57073874e-003,
-       -1.76029641e-003, 5.75392554e-003, 5.36788162e-003,
-       -9.14825534e-004, -8.80310254e-004, 5.38215926e-003,
-       4.33205394e-003, 5.21465950e-003, -3.38053666e-002,
-       4.33093160e-002, 4.40932624e-002, 5.30197062e-002,
-       -2.50672717e-002, 6.31301403e-002, 4.27887440e-002,
-       -3.06701957e-004, 1.06290949e-003, 4.52589849e-003,
-       4.04087361e-003, -2.07198933e-002, -6.74040476e-003,
-       3.87595743e-002, 2.95916945e-002, -1.11944906e-001,
-       -4.83164936e-002, 2.11025566e-001, 1.74817413e-001,
-       3.27829063e-001, -2.87847489e-001, 3.85699928e-001,
-       3.43288451e-001, 3.44330855e-002, -4.07961644e-002,
-       5.02957627e-002, 5.15679196e-002, -1.96855515e-002,
-       3.11825122e-003, 3.55701782e-002, 2.91165281e-002,
-       -4.37406898e-002, 1.20760009e-001, 1.78096369e-001,
-       1.93183109e-001, 9.29959416e-002, 2.07731828e-001,
-       2.32177913e-001, 2.79255271e-001, 4.73063923e-002,
-       3.18703661e-003, 5.74427284e-002, 4.48784530e-002,
-       -2.98399536e-004, 1.05906208e-003, 4.83281445e-003,
-       4.67650592e-003, 1.03038736e-002, 2.49111969e-002,
-       3.70531641e-002, 4.00314666e-002, 1.80148855e-002,
-       2.94665080e-002, 4.28064205e-002, 4.57234941e-002,
-       8.82897351e-004, 1.80123886e-003, 5.13969036e-003,
-       5.36526786e-003, 1.17372640e-003, -3.82596394e-003,
-       5.69205917e-003, 6.03580102e-003, 3.08722928e-002,
-       -3.71636897e-002, 4.61173728e-002, 5.02632745e-002,
-       5.30462200e-003, -2.56294515e-002, 2.87182499e-002,
-       4.06738110e-002, -3.20921303e-004, -1.41783862e-003,
-       3.90886329e-003, 4.46093082e-003, -2.17698459e-002,
-       -1.84212793e-002, 3.92034017e-002, 3.47842202e-002,
-       1.46407992e-001, -2.57573783e-001, 2.60830969e-001,
-       3.15066546e-001, 5.20534366e-002, -3.59882414e-001,
-       2.27762550e-001, 4.11584347e-001, 4.06653136e-002,
-       -3.09844576e-002, 5.05621620e-002, 4.89158072e-002,
-       -1.81607045e-002, 1.12315379e-002, 3.44120152e-002,
-       2.96527222e-002, 2.41250787e-002, 1.07040152e-001,
-       1.70361027e-001, 1.91243649e-001, 1.28568679e-001,
-       1.48618609e-001, 2.18056202e-001, 2.34440267e-001,
-       4.16820571e-002, 1.70182772e-002, 5.16944975e-002,
-       4.07478251e-002, 4.49292944e-004, 1.32560416e-003,
-       4.76974249e-003, 4.81889257e-003, 1.01765888e-002,
-       3.16657387e-002, 3.54873799e-002, 4.66458984e-002,
-       1.88336670e-002, 3.00407261e-002, 3.77432518e-002,
-       4.68445793e-002, 1.26930245e-003, 5.83097048e-004,
-       5.08362195e-003, 5.15837315e-003, 4.51536058e-003,
-       -6.30015158e-004, 7.17256172e-003, 3.42827453e-003,
-       1.50481751e-003, 8.09004158e-003, 2.06233114e-002,
-       1.97090432e-002, -2.61747073e-002, 7.95795489e-003,
-       3.58824693e-002, 2.35213432e-002, -4.74452553e-003,
-       -1.53268292e-003, 9.06166155e-003, 5.23514021e-003,
-       4.54923436e-002, -7.87566043e-003, 6.21051192e-002,
-       2.48834733e-002, 4.88572605e-002, -8.26616678e-003,
-       1.40771180e-001, 1.09917209e-001, -1.65044159e-001,
-       4.62013707e-002, 2.26691097e-001, 1.36358693e-001,
-       -5.59300929e-002, 5.15262084e-003, 7.71782398e-002,
-       4.33438495e-002, 4.86216880e-002, -2.23657954e-002,
-       6.64402544e-002, 4.14840057e-002, 5.44595532e-002,
-       -1.79753125e-001, 1.76959991e-001, 2.76977748e-001,
-       -1.86743975e-001, -3.23111504e-001, 2.45216891e-001,
-       4.09035057e-001, -6.48325905e-002, -5.03575429e-002,
-       8.63393918e-002, 7.52198175e-002, 8.10848956e-004,
-       -1.84038971e-002, 6.93113403e-003, 2.33080611e-002,
-       -1.96736250e-002, -1.87951162e-001, 4.26854677e-002,
-       2.22669140e-001, -2.24048235e-002, -1.56806976e-001,
-       4.17777337e-002, 1.96762100e-001, 4.39157768e-004,
-       -9.87916626e-003, 6.82700984e-003, 1.80123989e-002,
-       -1.77077372e-002, 7.52239339e-006, 2.44247466e-002,
-       5.45470417e-003, -1.32334651e-002, -2.65540667e-002,
-       5.10200597e-002, 4.22737040e-002, 3.94944428e-003,
-       -2.42635105e-002, 3.21283899e-002, 4.08864170e-002,
-       1.71553867e-004, -1.80931750e-003, 5.38295927e-003,
-       5.32866456e-003, -1.70849711e-001, 9.89076216e-004,
-       2.10647061e-001, 3.49141620e-002, -1.05339997e-001,
-       -9.64723080e-002, 3.20783913e-001, 1.85270011e-001,
-       6.67648986e-002, -8.55200440e-002, 1.98685676e-001,
-       1.79234564e-001, 1.55347129e-002, -4.36372636e-003,
-       3.59015018e-002, 3.03908736e-002, -1.60337940e-001,
-       2.25986913e-003, 1.96217433e-001, 3.80732268e-002,
-       -1.85693994e-001, 9.50805992e-002, 3.30457121e-001,
-       2.52243072e-001, 7.69932196e-002, 2.23927181e-002,
-       2.31279865e-001, 2.88399011e-001, 2.60731932e-002,
-       9.04501975e-003, 4.44467589e-002, 4.62201238e-002,
-       -1.19487746e-002, 2.25587119e-003, 1.88990906e-002,
-       8.65814742e-003, -1.11155529e-002, 9.59074423e-002,
-       5.83304651e-002, 1.31050125e-001, 2.26843543e-003,
-       1.08841300e-001, 4.35165949e-002, 1.48622662e-001,
-       -5.42826368e-004, 7.78748048e-003, 6.57071313e-003,
-       1.52426269e-002, 3.77982797e-004, -2.39333371e-003,
-       6.12187013e-003, 6.85055554e-003, -4.57958085e-003,
-       -5.79439737e-002, 3.58104259e-002, 7.21580610e-002,
-       2.02425253e-002, -4.74769361e-002, 3.76996771e-002,
-       6.55148253e-002, 2.66869029e-005, -7.84699747e-004,
-       4.69531352e-003, 4.89120465e-003, -2.93799359e-002,
-       -3.04847620e-002, 5.26182465e-002, 4.94426899e-002,
-       -8.21013972e-002, -1.68493018e-001, 2.21307099e-001,
-       2.91143119e-001, 2.01612368e-001, -2.01489419e-001,
-       2.90814996e-001, 3.44116360e-001, 4.16495800e-002,
-       -2.73821801e-002, 6.35688603e-002, 4.84878868e-002,
-       -4.10652719e-002, -1.02877300e-002, 5.87255806e-002,
-       4.68403138e-002, 2.62671430e-002, -6.12613037e-002,
-       2.24031076e-001, 2.94217259e-001, 9.22827944e-002,
-       -4.58325706e-002, 2.49358132e-001, 3.14052165e-001,
-       5.74267395e-002, -1.14586996e-002, 7.23505095e-002,
-       5.06185964e-002, -1.47735584e-003, 2.94127665e-003,
-       6.88582612e-003, 9.11731366e-003, 2.67762179e-003,
-       5.69573715e-002, 4.14255261e-002, 8.20592865e-002,
-       7.18305213e-003, 4.47388440e-002, 4.11017463e-002,
-       7.19377846e-002, 3.11324839e-003, 6.55033858e-004,
-       7.42117828e-003, 8.73263832e-003, -1.09105720e-004,
-       3.17236263e-004, 5.44745149e-003, 4.21351288e-003,
-       6.14835590e-004, 2.11462565e-002, 4.78719734e-002,
-       4.81511541e-002, -8.36266670e-003, 1.98088214e-002,
-       2.81212442e-002, 4.77564149e-002, -5.15299733e-004,
-       9.28265858e-004, 3.51609266e-003, 4.85769706e-003,
-       7.64055504e-003, 2.87408911e-004, 4.67224047e-002,
-       2.22137850e-002, 6.13904670e-002, 5.86459152e-002,
-       4.83767658e-001, 2.25772396e-001, -6.95771053e-002,
-       3.90264094e-002, 1.87775582e-001, 2.94917911e-001,
-       -1.74354259e-002, 7.91245233e-003, 3.36113013e-002,
-       3.32661681e-002, 1.06511442e-002, 1.47309562e-003,
-       5.20217828e-002, 1.82299558e-002, -1.02220215e-002,
-       -2.92978249e-002, 5.47850847e-001, 1.42934918e-001,
-       -5.24625517e-002, -7.47075751e-002, 1.78034544e-001,
-       1.76643968e-001, -1.44187426e-002, -7.83698913e-003,
-       3.17337252e-002, 2.56432090e-002, 1.21156836e-003,
-       5.43804708e-005, 6.97531831e-003, 3.33430641e-003,
-       -6.77335029e-003, -1.49149345e-002, 6.21738806e-002,
-       3.43041942e-002, -7.54580833e-003, -7.31904712e-003,
-       2.90180873e-002, 3.07608452e-002, -6.00914878e-004,
-       -1.62647411e-004, 3.51832877e-003, 3.81053123e-003,
-       -3.94202163e-003, 1.24621519e-003, 6.30647875e-003,
-       2.72270944e-003, -3.96461710e-002, -1.24041941e-002,
-       5.29382937e-002, 2.31701266e-002, 3.31146382e-002,
-       -1.36308977e-002, 4.49249856e-002, 2.49353107e-002,
-       8.36578838e-004, 8.17770429e-004, 5.37381740e-003,
-       3.38728516e-003, -2.76293717e-002, 3.93432472e-003,
-       4.26195040e-002, 1.55946780e-002, -3.64180207e-001,
-       5.97567484e-003, 4.02398586e-001, 1.12554856e-001,
-       2.39854321e-001, -5.61563112e-002, 2.82966167e-001,
-       1.23238564e-001, 1.82982888e-002, -8.40071030e-003,
-       4.15301025e-002, 2.46791020e-002, -2.41217092e-002,
-       3.65454791e-004, 3.99578921e-002, 1.46849835e-002,
-       -3.58765721e-001, 7.43032396e-002, 3.98976564e-001,
-       1.34190753e-001, 1.50542185e-001, 5.74452281e-002,
-       2.17210084e-001, 1.32333443e-001, 2.56350916e-002,
-       -3.07174609e-003, 4.21839170e-002, 2.47446131e-002,
-       -2.27116840e-003, -5.32404345e-004, 5.24953101e-003,
-       2.47064559e-003, -3.81738767e-002, 2.03275960e-002,
-       5.23648039e-002, 2.98299287e-002, 1.03695858e-002,
-       2.14775316e-002, 3.34829390e-002, 3.14595625e-002,
-       1.91582949e-003, 2.91765667e-004, 5.25544584e-003,
-       3.80066410e-003, 2.89618620e-004, 1.10340700e-003,
-       3.73637024e-003, 5.96147915e-003, -2.65994878e-003,
-       1.55719398e-002, 2.78765708e-002, 5.36468849e-002,
-       -7.95364566e-003, -1.11135084e-003, 3.37510332e-002,
-       5.30682951e-002, -9.33317788e-005, -7.51856773e-004,
-       4.09037992e-003, 5.54494653e-003, 1.02812918e-002,
-       -2.06317399e-002, 4.05115150e-002, 5.48612475e-002,
-       9.99446493e-003, -1.59633934e-001, 2.29201213e-001,
-       5.24965465e-001, -6.06865287e-002, 5.35664521e-002,
-       2.55002290e-001, 3.70572776e-001, -1.04617793e-003,
-       1.29613141e-002, 3.74115855e-002, 3.98670323e-002,
-       -2.34552380e-003, -3.52888322e-003, 3.21510695e-002,
-       3.25390734e-002, 1.28385782e-001, 2.37673968e-002,
-       2.29985386e-001, 2.16592431e-001, 6.85705021e-002,
-       3.31941061e-002, 2.32383817e-001, 2.57119298e-001,
-       -9.15157702e-003, 6.56758901e-003, 3.83365378e-002,
-       3.55585627e-002, 3.00658023e-004, 5.95371122e-004,
-       3.82785220e-003, 4.00372641e-003, 1.07001932e-002,
-       -5.86283067e-003, 2.98825130e-002, 3.75984497e-002,
-       6.72252150e-003, -1.73600819e-002, 3.12981643e-002,
-       4.28169891e-002, -2.78869556e-004, -1.24549703e-003,
-       4.29221056e-003, 4.79799137e-003, 2.67186854e-003,
-       8.94724053e-006, 6.30975747e-003, 4.12600022e-003,
-       7.93014129e-004, 1.69133078e-002, 4.23345305e-002,
-       3.34622972e-002, 1.89557057e-002, 1.97221078e-002,
-       4.10278067e-002, 3.53127830e-002, -2.19257476e-004,
-       1.45146088e-003, 4.94546304e-003, 4.19589784e-003,
-       4.16785292e-002, 3.70034296e-003, 5.84318191e-002,
-       2.76379604e-002, -1.13416798e-002, 1.09704547e-001,
-       3.37160677e-001, 1.96451291e-001, 1.49498656e-001,
-       9.44341049e-002, 2.76976973e-001, 1.66842222e-001,
-       -2.00197455e-002, 2.24745437e-003, 3.63280587e-002,
-       2.33561881e-002, 3.56713794e-002, -1.93419699e-002,
-       4.92533483e-002, 3.91433388e-002, 7.89594278e-002,
-       -2.44785309e-001, 2.41824567e-001, 3.83015424e-001,
-       1.41952923e-002, -2.84608215e-001, 1.80937186e-001,
-       3.78860831e-001, -1.62413977e-002, -3.51480171e-002,
-       3.39127816e-002, 4.76940610e-002, 6.37955964e-005,
-       -4.96500987e-004, 3.50534497e-003, 4.77496255e-003,
-       1.42052665e-003, -1.96377803e-002, 2.19083373e-002,
-       4.57695350e-002, 3.17807426e-003, -1.61654856e-002,
-       2.10586097e-002, 4.71598431e-002, 2.00618291e-003,
-       -1.65004574e-003, 3.84690799e-003, 6.43092953e-003,
-       2.07435642e-003, 4.31420573e-004, 4.61803796e-003,
-       3.74295469e-003, -1.17841549e-003, 2.36109644e-002,
-       2.96828393e-002, 3.26051489e-002, -4.38484251e-002,
-       1.88496187e-002, 5.23062684e-002, 3.47284302e-002,
-       -8.21188150e-004, -1.48791180e-003, 4.92349919e-003,
-       4.08525532e-003, 3.41462605e-002, -8.80931225e-003,
-       4.37170155e-002, 2.85100937e-002, 8.65714625e-002,
-       2.74056904e-002, 1.66892141e-001, 1.34286210e-001,
-       -3.35248321e-001, 1.46516308e-001, 3.64468873e-001,
-       2.01447338e-001, -2.79261675e-002, 1.73951369e-002,
-       4.62843627e-002, 3.30038778e-002, 2.42298059e-002,
-       -3.45893502e-002, 3.95067073e-002, 4.39483970e-002,
-       1.73994169e-001, -3.40172499e-001, 2.27439508e-001,
-       3.61324966e-001, -9.73008573e-002, -1.40015796e-001,
-       2.33539417e-001, 2.45423511e-001, -4.81073894e-002,
-       9.03374329e-003, 5.82566634e-002, 3.65170352e-002,
-       -1.16245809e-003, -8.86177353e-004, 4.07968229e-003,
-       4.53907484e-003, 1.39241358e-002, -2.90402956e-002,
-       3.07569373e-002, 4.38754037e-002, 1.40174776e-002,
-       -4.64054756e-002, 3.56466807e-002, 5.56205586e-002,
-       -2.47544469e-003, -2.17692205e-003, 5.57487365e-003,
-       5.45539940e-003, 2.10910453e-003, -4.06313688e-004,
-       4.96956334e-003, 2.35398719e-003, 3.01903933e-002,
-       1.50193060e-002, 4.15527113e-002, 2.20894814e-002,
-       -2.83371620e-002, 1.36181116e-002, 4.11717035e-002,
-       2.20335461e-002, -3.50992708e-003, -6.94340677e-004,
-       5.54211205e-003, 2.77867727e-003, 2.33740844e-002,
-       -1.50345115e-003, 3.85779440e-002, 1.56889670e-002,
-       2.71237761e-001, 4.48433012e-002, 3.10179949e-001,
-       1.08028643e-001, -2.88554668e-001, 2.31837854e-002,
-       3.31245035e-001, 1.08195268e-001, -2.84288861e-002,
-       -5.24381269e-003, 4.05829363e-002, 1.85589623e-002,
-       2.35502142e-002, -1.04699587e-003, 3.88297550e-002,
-       1.57816093e-002, 2.80500621e-001, -4.64845635e-002,
-       3.20336401e-001, 1.13392390e-001, -3.44386697e-001,
-       -7.71420598e-002, 3.78186852e-001, 1.30212888e-001,
-       -2.13494189e-002, -4.46908735e-003, 3.61517929e-002,
-       1.74995512e-002, 2.36851652e-003, 3.12743359e-004,
-       5.11393277e-003, 2.44790944e-003, 2.77275071e-002,
-       -1.92491654e-002, 4.21104319e-002, 2.65625268e-002,
-       -4.14638668e-002, -2.03547534e-002, 5.13344929e-002,
-       2.79174838e-002, -1.49185816e-003, 3.66133230e-004,
-       4.34653182e-003, 2.56167515e-003, -4.82546777e-004,
-       8.14254337e-004, 4.46094293e-003, 3.52807995e-003,
-       -4.05639596e-002, -2.64247172e-002, 5.34367077e-002,
-       4.07927819e-002, 1.45648662e-002, -2.64035165e-002,
-       4.09743190e-002, 4.01855558e-002, 1.99037418e-003,
-       6.55231197e-005, 5.49529772e-003, 4.27258201e-003,
-       -1.20463986e-002, -1.29751079e-002, 3.50548588e-002,
-       2.92011350e-002, -3.75443995e-001, -5.03987744e-002,
-       4.14879650e-001, 2.17881963e-001, 1.89858377e-001,
-       -1.79910026e-002, 2.64216006e-001, 1.88787535e-001,
-       2.76132766e-002, -1.99032668e-003, 4.39910106e-002,
-       3.09180934e-002, -3.30590345e-002, -2.53317561e-002,
-       4.64196876e-002, 5.02985418e-002, -1.47115126e-001,
-       -8.13128054e-002, 2.39342511e-001, 3.00183415e-001,
-       1.88768178e-001, 6.66946769e-002, 2.53345311e-001,
-       2.04353228e-001, 2.09992770e-002, 6.10105810e-004,
-       3.81637625e-002, 3.25379968e-002, -2.60758842e-003,
-       9.80956946e-004, 5.73727954e-003, 5.36576752e-003,
-       -6.63519092e-003, 3.00421566e-002, 3.44486013e-002,
-       4.42136601e-002, 1.71690937e-002, 2.47194041e-002,
-       3.65825742e-002, 4.00261991e-002, 4.23919118e-004,
-       3.16203979e-004, 4.64043440e-003, 4.53786692e-003,
-       -3.56691936e-003, -1.47014635e-003, 1.02764610e-002,
-       8.08009785e-003, 5.34071103e-002, 5.24637997e-002,
-       9.31957215e-002, 7.58594796e-002, 9.92475636e-003,
-       4.00698520e-002, 5.48778139e-002, 5.76214232e-002,
-       -1.61392558e-002, -2.90618977e-003, 2.09105201e-002,
-       6.82256324e-003, 6.25742897e-002, 4.81890403e-002,
-       9.84695554e-002, 9.26701427e-002, 2.01510370e-001,
-       2.11082146e-001, 3.26656014e-001, 2.90964127e-001,
-       -7.84019455e-002, 5.28291129e-002, 1.91133007e-001,
-       1.41293555e-001, -1.90169349e-001, -9.03520640e-003,
-       2.19832540e-001, 3.82665657e-002, 6.77380636e-002,
-       -1.36373527e-002, 9.11791772e-002, 5.53615391e-002,
-       8.37476030e-002, -1.88397110e-001, 2.10516855e-001,
-       2.70799637e-001, -8.85705352e-002, -6.10203519e-002,
-       2.05734029e-001, 1.58850610e-001, -1.71845749e-001,
-       5.54455584e-003, 2.03767970e-001, 4.90017757e-002,
-       2.01359205e-003, -2.90890294e-003, 6.52724039e-003,
-       9.94793419e-003, 2.11343057e-002, -5.63294254e-002,
-       4.84789163e-002, 8.82393792e-002, 1.43941324e-002,
-       -4.77926359e-002, 5.83602414e-002, 6.63959458e-002,
-       -1.33471098e-002, 2.51228386e-003, 1.72555763e-002,
-       9.87787079e-003, 2.17777956e-003, 5.67050418e-004,
-       5.82611049e-003, 5.45673445e-003, -3.03299390e-002,
-       -3.58790085e-002, 5.28848357e-002, 6.08011968e-002,
-       -4.37262021e-002, -7.35825002e-002, 6.32381290e-002,
-       8.53088051e-002, -5.70921577e-004, -4.50625736e-003,
-       6.00393210e-003, 7.44324084e-003, -4.14827652e-002,
-       -5.53181469e-002, 6.38721958e-002, 6.92603886e-002,
-       -2.54547536e-001, -4.35968876e-001, 3.45436066e-001,
-       4.95792687e-001, -2.44764499e-002, -1.21702440e-001,
-       1.78065017e-001, 2.22687006e-001, 2.00447589e-002,
-       -8.13247263e-003, 3.43679450e-002, 3.06091886e-002,
-       -5.05792536e-002, -1.45518230e-002, 6.31573945e-002,
-       4.35329303e-002, -7.55495429e-002, 3.97204645e-002,
-       1.72285914e-001, 1.59182668e-001, 4.35511060e-002,
-       3.74847874e-002, 1.25466794e-001, 1.44714683e-001,
-       1.81623995e-002, 2.75270734e-003, 3.10526621e-002,
-       2.74530016e-002, -2.61209020e-003, 2.18323927e-004,
-       6.41126372e-003, 5.52855665e-003, -6.23021508e-003,
-       2.29570922e-002, 2.90556382e-002, 3.87151726e-002,
-       1.56730972e-003, 2.00467184e-002, 2.53731981e-002,
-       3.39965150e-002, 5.11069957e-004, 8.16334796e-004,
-       4.03755531e-003, 4.29850072e-003, 1.41956494e-003,
-       1.34115908e-004, 7.54652126e-003, 4.96148597e-003,
-       1.59447826e-002, 3.66905332e-002, 6.56107366e-002,
-       5.70183955e-002, -1.44415116e-003, 4.24282961e-002,
-       3.96796130e-002, 6.11045361e-002, -9.26901412e-004,
-       2.14825384e-003, 6.68815291e-003, 5.66210644e-003,
-       3.99944484e-002, 2.96033709e-003, 6.99780360e-002,
-       3.13098766e-002, 1.63007557e-001, 1.50402114e-001,
-       5.76265454e-001, 2.57686079e-001, -6.75063878e-002,
-       1.00149103e-001, 2.46229932e-001, 1.66161150e-001,
-       -3.26280408e-002, 9.92711820e-003, 6.37223721e-002,
-       2.71098297e-002, 3.47966142e-002, 3.29876854e-003,
-       6.19585179e-002, 2.81408131e-002, 2.05604345e-001,
-       -5.81823401e-002, 3.77255768e-001, 1.79321557e-001,
-       -6.19551986e-002, -1.93697202e-003, 1.65072277e-001,
-       1.13306113e-001, -4.12837863e-002, 6.80993684e-003,
-       5.86988479e-002, 2.31786892e-002, 2.07194337e-003,
-       1.07316801e-003, 7.11535476e-003, 3.78365233e-003,
-       3.03741395e-002, -1.65279768e-002, 4.84914966e-002,
-       2.89315265e-002, -2.29261746e-003, -1.22220069e-002,
-       3.01976148e-002, 2.39973273e-002, -3.27422633e-003,
-       3.17719852e-004, 6.26748055e-003, 3.26235802e-003,
-       1.03587518e-002, -3.07533261e-003, 1.35828592e-002,
-       4.99839615e-003, 1.98028535e-002, 5.89271821e-003,
-       3.45190428e-002, 1.78731475e-002, -2.16708407e-002,
-       1.03815924e-002, 3.53062563e-002, 1.87561233e-002,
-       -7.83631578e-003, -7.83876225e-004, 1.19542582e-002,
-       4.06571524e-003, 7.25692660e-002, -2.48592962e-002,
-       1.02418959e-001, 3.54194567e-002, 2.48378411e-001,
-       -3.56728807e-002, 3.09612155e-001, 1.04968853e-001,
-       -1.26788795e-001, 1.94368046e-002, 1.99240595e-001,
-       7.37686306e-002, -8.76573622e-002, -4.57811449e-003,
-       1.09009512e-001, 2.80926786e-002, 1.99685451e-002,
-       -8.57444573e-003, 7.29750246e-002, 2.56393421e-002,
-       4.54411209e-001, -1.29574910e-001, 4.96573329e-001,
-       1.65759936e-001, -1.44816458e-001, -2.43556947e-002,
-       2.16742977e-001, 8.60012248e-002, -8.55450705e-002,
-       -3.53215757e-004, 1.08614884e-001, 2.83822119e-002,
-       -1.99933723e-003, 1.46731758e-003, 9.18669254e-003,
-       3.45991435e-003, 7.93430507e-002, -2.45650485e-002,
-       8.93894434e-002, 3.42552587e-002, -2.00023204e-002,
-       -1.44932587e-002, 4.34716418e-002, 2.37052068e-002,
-       -7.51220295e-003, 1.20172009e-003, 1.21320970e-002,
-       4.13263682e-003, 1.58194068e-003, 1.15301483e-003,
-       6.15172600e-003, 5.12615778e-003, -3.40383238e-004,
-       4.13417891e-002, 4.54057083e-002, 5.33450469e-002,
-       -7.60150328e-002, 4.53879572e-002, 9.01818946e-002,
-       6.27788454e-002, 1.03703851e-003, -1.77927723e-003,
-       7.95174390e-003, 6.07462414e-003, 2.70644985e-002,
-       3.52750812e-003, 4.65705208e-002, 2.78788805e-002,
-       1.03035189e-001, 1.24013564e-002, 1.98826879e-001,
-       1.47207528e-001, -3.97412896e-001, 2.36225113e-001,
-       4.58425701e-001, 3.03237855e-001, -5.49223609e-002,
-       3.60968821e-002, 8.54638517e-002, 5.64432628e-002,
-       2.63260771e-002, -3.72053101e-003, 4.47022878e-002,
-       3.07876430e-002, 5.44722751e-002, -7.96962604e-002,
-       1.81072414e-001, 1.76651835e-001, -8.60578418e-002,
-       -8.24673623e-002, 2.15867683e-001, 2.08586812e-001,
-       -9.28842723e-002, 2.44577620e-002, 1.05652355e-001,
-       5.36154844e-002, 4.89670434e-004, -3.50345159e-003,
-       5.51807741e-003, 7.32674217e-003, -2.51668878e-003,
-       -5.27785569e-002, 3.71201001e-002, 6.94502145e-002,
-       -4.95869666e-003, -5.51631302e-002, 3.63920741e-002,
-       7.29352608e-002, -4.82410146e-003, -2.62751174e-003,
-       8.94907396e-003, 7.88427703e-003, -1.14653613e-002,
-       9.85054721e-005, 1.82415284e-002, 9.71999858e-003,
-       -4.51716408e-003, -9.46174189e-002, 7.86934569e-002,
-       1.28141195e-001, -2.10226793e-002, -9.59587619e-002,
-       5.66897690e-002, 1.32944524e-001, -1.84065849e-003,
-       -6.62017614e-003, 7.08946399e-003, 1.39005883e-002,
-       -1.77031472e-001, -3.76397133e-004, 2.06264451e-001,
-       3.97699885e-002, -1.66395292e-001, -1.08181074e-001,
-       3.78817558e-001, 2.86990821e-001, -6.67377710e-002,
-       -1.43699765e-001, 1.88416809e-001, 2.45289475e-001,
-       1.13764964e-002, -2.20306274e-002, 3.04424949e-002,
-       3.77230011e-002, -1.92234248e-001, -1.18389782e-002,
-       2.18624383e-001, 3.50411832e-002, -1.83629885e-001,
-       -4.28859666e-002, 3.40646654e-001, 1.68236569e-001,
-       -5.23082465e-002, -2.32460257e-002, 1.50205970e-001,
-       1.33863270e-001, 8.41017067e-003, -2.11417093e-003,
-       2.30619423e-002, 2.19395757e-002, -2.13791654e-002,
-       -2.99642864e-003, 2.60117147e-002, 6.84084464e-003,
-       -2.97131278e-002, 7.12682027e-003, 4.94422130e-002,
-       2.65106689e-002, -1.56545406e-003, 9.70755611e-003,
-       2.06394456e-002, 2.28620898e-002, 1.51201632e-004,
-       5.92931290e-004, 2.84550735e-003, 3.29332054e-003,
-       2.87039508e-003, -2.92273751e-003, 5.15063666e-003,
-       6.25011977e-003, -2.41341884e-003, -3.79598103e-002,
-       2.48989332e-002, 5.39868437e-002, 2.39855913e-003,
-       -3.84744070e-002, 2.49338802e-002, 5.28734401e-002,
-       -1.07839704e-003, -2.55158427e-003, 3.95357795e-003,
-       5.46494173e-003, -1.88811999e-002, -5.37979789e-002,
-       3.77575345e-002, 6.25194833e-002, -6.44850582e-002,
-       -4.10249650e-001, 1.66113630e-001, 4.56135750e-001,
-       1.22875638e-001, -3.85639966e-001, 1.92509964e-001,
-       4.33360308e-001, 2.79071797e-002, -4.72617298e-002,
-       4.18688916e-002, 5.81854358e-002, -1.84454750e-002,
-       -2.71977484e-003, 2.89371889e-002, 2.53099576e-002,
-       -2.59791091e-002, 3.21819782e-002, 1.07581586e-001,
-       1.16890885e-001, 7.60340765e-002, 1.36564551e-002,
-       1.29477456e-001, 1.20489888e-001, 2.89817899e-002,
-       -8.08072835e-003, 3.82132754e-002, 2.77814027e-002,
-       -7.30284024e-004, 3.25747096e-004, 3.41667142e-003,
-       3.31238657e-003, -2.26534088e-003, 1.12237846e-002,
-       1.92107912e-002, 2.31894627e-002, 6.73362426e-003,
-       1.10484315e-002, 2.09309142e-002, 2.32318193e-002,
-       2.02956819e-003, 1.07048363e-004, 4.43599792e-003,
-       3.51776020e-003, 1.15714148e-002, 5.11005661e-003,
-       2.03093179e-002, 1.02689303e-002, -6.31626043e-003,
-       1.19069062e-001, 4.68760021e-002, 1.50057524e-001,
-       -4.44165356e-002, 1.24437027e-001, 6.27774373e-002,
-       1.49491832e-001, -4.19286219e-003, 4.72460501e-003,
-       1.15651162e-002, 9.84418392e-003, 1.70612127e-001,
-       -1.03993984e-002, 2.03653693e-001, 3.23239863e-002,
-       2.91575324e-002, 8.29053521e-002, 1.99773386e-001,
-       1.62491888e-001, -2.11648881e-001, 1.49304703e-001,
-       3.35659593e-001, 2.05625281e-001, -1.48804262e-001,
-       1.57367941e-002, 1.98700830e-001, 3.87964845e-002,
-       1.63211226e-001, 5.47261909e-004, 2.05679581e-001,
-       3.83131094e-002, 7.15711564e-002, -1.41989924e-002,
-       2.44172469e-001, 1.08589754e-001, -1.12728864e-001,
-       9.91186872e-003, 2.65748918e-001, 9.92686301e-002,
-       -1.71578780e-001, 2.75157820e-002, 2.16747805e-001,
-       4.24630530e-002, 1.32811889e-002, 2.09920364e-003,
-       1.92391910e-002, 7.91439414e-003, 1.97727438e-002,
-       -1.98821574e-002, 4.28679399e-002, 3.07906736e-002,
-       -1.08812088e-002, -1.12594431e-002, 3.70054469e-002,
-       2.16797609e-002, -1.70287695e-002, 3.02536925e-003,
-       2.25223042e-002, 7.13726878e-003, 7.82367133e-004,
-       -1.90204580e-003, 4.09657788e-003, 4.97780368e-003,
-       1.16198640e-002, -2.04924699e-002, 3.15632969e-002,
-       4.75035869e-002, 8.04091617e-003, -2.45493967e-002,
-       2.84411069e-002, 5.05774468e-002, -3.87385262e-005,
-       -1.91732240e-003, 4.07275837e-003, 5.60520310e-003,
-       -2.80449679e-003, 2.37705582e-003, 3.03682256e-002,
-       3.35294530e-002, 5.27143404e-002, -1.61291696e-002,
-       1.71058252e-001, 2.84809709e-001, 2.35560387e-002,
-       9.15595144e-002, 1.93910807e-001, 5.23589611e-001,
-       1.28407637e-002, 7.01445201e-003, 3.82948183e-002,
-       7.00189024e-002, -5.79436542e-003, 1.33469924e-002,
-       3.45128179e-002, 3.02302502e-002, -3.23486105e-002,
-       -2.54728599e-003, 2.14022756e-001, 2.31885448e-001,
-       1.54229671e-001, -1.04133114e-001, 2.73041099e-001,
-       3.96115601e-001, 8.89610033e-003, 5.71912108e-003,
-       4.30686884e-002, 4.91254851e-002, -8.06216049e-005,
-       -4.49635845e-004, 4.39526793e-003, 3.91912088e-003,
-       -4.70918277e-003, 1.38344374e-002, 3.61316353e-002,
-       4.24920395e-002, 1.47048049e-002, 2.19751634e-002,
-       3.91494669e-002, 4.87100296e-002, 6.01112552e-004,
-       -4.72195650e-004, 5.15036797e-003, 5.33796474e-003,
-       1.37680222e-003, 1.10616162e-003, 5.20052528e-003,
-       5.30487159e-003, 1.41104385e-002, 3.70438471e-002,
-       3.36884037e-002, 5.66899963e-002, 6.97378349e-003,
-       3.73664014e-002, 3.19883563e-002, 5.77618629e-002,
-       4.84314398e-004, 2.36032112e-003, 4.13807621e-003,
-       6.42038416e-003, 5.23791946e-002, 1.47465467e-002,
-       6.38903379e-002, 3.53736877e-002, 1.20182596e-001,
-       1.99094325e-001, 2.20249802e-001, 2.64560252e-001,
-       -9.58455913e-003, 1.37647629e-001, 1.51822150e-001,
-       2.17833549e-001, -2.16035545e-002, 1.47271166e-002,
-       3.27121839e-002, 3.15667018e-002, 5.54000102e-002,
-       -1.88007299e-002, 6.74560666e-002, 3.73070389e-002,
-       -1.91078405e-003, -3.35321814e-001, 2.86631852e-001,
-       3.75499606e-001, 1.33016929e-001, -2.42126465e-001,
-       2.46761724e-001, 2.94863492e-001, -2.41457447e-002,
-       -1.27851749e-002, 3.75227779e-002, 3.10493559e-002,
-       9.28804395e-004, -1.65637024e-003, 5.39178867e-003,
-       4.78188647e-003, 1.04976323e-004, -2.44162176e-002,
-       3.47964205e-002, 4.37843725e-002, 2.40434781e-002,
-       -3.48202325e-002, 4.10634428e-002, 5.26041761e-002,
-       1.21385441e-003, -3.87992640e-003, 5.22370776e-003,
-       6.61025243e-003, -3.70401947e-004, 1.52464432e-003,
-       3.34715843e-003, 6.84986170e-003, -6.65065745e-005,
-       1.80765353e-002, 1.76666528e-002, 5.65608330e-002,
-       -8.38330889e-004, 1.74706578e-002, 1.78968441e-002,
-       5.66304810e-002, -3.87149950e-004, 1.20122801e-003,
-       3.14781745e-003, 6.48948830e-003, 1.30051374e-002,
-       1.89371016e-002, 2.85970904e-002, 6.26740605e-002,
-       2.51143388e-002, 1.52231261e-001, 1.15233883e-001,
-       5.67627192e-001, -5.62570430e-002, 1.35334209e-001,
-       1.42666012e-001, 5.83254218e-001, -2.47970484e-002,
-       9.82452370e-003, 3.92094180e-002, 6.24788143e-002,
-       1.37677658e-002, -1.69326318e-003, 2.85686329e-002,
-       2.50548497e-002, 1.08213099e-002, -2.88059935e-002,
-       1.11038357e-001, 1.41683549e-001, -7.78764263e-002,
-       -3.97381932e-002, 1.58096388e-001, 1.61449209e-001,
-       -2.66763251e-002, -6.30402239e-003, 4.27860096e-002,
-       2.93461978e-002, 6.99893921e-004, -1.23499543e-003,
-       3.65411164e-003, 4.36573988e-003, -2.66477873e-005,
-       -1.54749071e-002, 2.01678891e-002, 3.47049162e-002,
-       -1.15397563e-002, -1.71859898e-002, 2.48308424e-002,
-       3.64503749e-002, -2.10819114e-003, -5.35008730e-004,
-       5.36014652e-003, 4.30902326e-003, -2.74277409e-003,
-       1.08955905e-003, 8.03830754e-003, 3.31800780e-003,
-       -4.58923392e-002, -1.89108104e-002, 7.64036030e-002,
-       3.48437466e-002, 7.43011013e-003, -1.65824667e-002,
-       2.98996754e-002, 3.34651209e-002, 1.57458431e-004,
-       -4.55168949e-004, 3.73991788e-003, 3.85755394e-003,
-       -2.95322686e-002, -2.31468678e-003, 6.07944503e-002,
-       1.94854010e-002, -3.21806312e-001, 1.98847502e-002,
-       5.33819020e-001, 1.73681140e-001, 5.72664104e-002,
-       3.20060328e-002, 1.54639810e-001, 1.57837659e-001,
-       8.45384412e-003, 1.06075007e-004, 2.65813656e-002,
-       2.50525232e-002, -3.79981361e-002, -7.36629311e-003,
-       6.42939210e-002, 2.47323941e-002, -2.83599675e-001,
-       2.47543765e-004, 4.08480078e-001, 2.19947949e-001,
-       3.06573715e-002, -3.08870692e-002, 1.32238224e-001,
-       2.05227792e-001, 1.03618391e-002, -2.76188296e-003,
-       2.68374663e-002, 2.94455625e-002, -3.87750147e-003,
-       -4.27651103e-004, 7.94667285e-003, 4.36626375e-003,
-       -2.96430308e-002, 3.68025191e-002, 5.29608913e-002,
-       6.13942742e-002, -3.61237046e-003, 3.80289815e-002,
-       2.82509290e-002, 6.27428517e-002, -9.02639440e-005,
-       2.57383264e-003, 4.14165342e-003, 6.76513137e-003,
-       -3.41219176e-003, 2.05946824e-004, 7.72836525e-003,
-       4.28085215e-003, -2.17016991e-002, -3.80780213e-002,
-       5.28462343e-002, 5.59466295e-002, -3.63916568e-002,
-       -4.50059697e-002, 5.20534515e-002, 5.99261746e-002,
-       -5.21701528e-004, -3.22830677e-003, 4.47474374e-003,
-       5.85464807e-003, -5.48149645e-002, -1.37693062e-003,
-       7.39732087e-002, 2.40775701e-002, -3.07783812e-001,
-       -2.11163387e-001, 3.91726851e-001, 2.61332899e-001,
-       -1.00725271e-001, -1.51284575e-001, 1.92123458e-001,
-       2.03195527e-001, 1.40019907e-002, -9.02412925e-003,
-       2.57640500e-002, 2.26185266e-002, -5.75711466e-002,
-       -1.76899356e-003, 7.82598108e-002, 2.20349040e-002,
-       -3.60545784e-001, 4.15453687e-002, 4.18028146e-001,
-       1.42748430e-001, -5.31399390e-003, 6.43926039e-002,
-       1.31017059e-001, 1.30755186e-001, 1.17937727e-002,
-       8.35587829e-003, 2.44494043e-002, 2.04920433e-002,
-       -6.47854852e-003, -1.84040854e-003, 1.00298179e-002,
-       4.21752734e-003, -4.13328409e-002, 1.52920289e-002,
-       5.69869354e-002, 3.21877003e-002, -2.88933539e-003,
-       1.55650824e-002, 2.67238840e-002, 2.87398025e-002,
-       6.56597986e-005, 3.91842361e-004, 3.31543246e-003,
-       3.45755485e-003, 3.06791672e-003, -6.24236825e-004,
-       5.74120134e-003, 3.56121804e-003, 1.50307342e-002,
-       1.38628958e-002, 2.82610413e-002, 2.36662254e-002,
-       -2.45962199e-003, 1.25058498e-002, 2.07038298e-002,
-       2.24627368e-002, -2.85505294e-003, -5.12391271e-004,
-       4.94227326e-003, 3.87609261e-003, 4.08195518e-002,
-       -9.80988424e-003, 5.33841066e-002, 2.95618940e-002,
-       1.41797662e-001, 2.07527112e-002, 1.94433361e-001,
-       1.19586468e-001, -8.58261883e-002, -1.28589803e-002,
-       1.53331667e-001, 1.30182669e-001, -4.75986004e-002,
-       -3.41626778e-002, 5.67238554e-002, 4.73676138e-002,
-       3.97600941e-002, -1.19482139e-002, 5.51989041e-002,
-       3.26227508e-002, 1.76917538e-001, -1.14693202e-001,
-       2.55759418e-001, 1.89051285e-001, -3.77938032e-001,
-       -3.37045580e-001, 4.09167230e-001, 3.68912190e-001,
-       -2.57755313e-002, -4.49117199e-002, 5.03511056e-002,
-       5.84483407e-002, 1.98717485e-003, -1.61486480e-003,
-       6.25056541e-003, 4.98232665e-003, 5.86288865e-004,
-       -5.51928617e-002, 4.83641364e-002, 6.34929314e-002,
-       -4.74447012e-002, -3.75959948e-002, 6.06290437e-002,
-       5.57196252e-002, 1.55492721e-003, 8.89796473e-004,
-       4.78098309e-003, 4.57485113e-003, 2.32570851e-003,
-       -4.61000454e-005, 5.33271721e-003, 3.50850448e-003,
-       4.88811173e-003, 6.74983673e-003, 2.05036309e-002,
-       1.79786254e-002, -2.35402789e-002, 8.20016582e-003,
-       3.69760804e-002, 2.05052476e-002, -1.11714629e-002,
-       -2.09381105e-003, 1.70895122e-002, 5.55117009e-003,
-       3.55839282e-002, -1.62688699e-002, 5.16472049e-002,
-       3.51973958e-002, 4.62788455e-002, 2.86854128e-003,
-       1.27446324e-001, 9.87818986e-002, -1.65281788e-001,
-       1.02066835e-002, 2.36638039e-001, 9.76615697e-002,
-       -1.17021002e-001, -6.40790444e-003, 1.52675554e-001,
-       3.62193547e-002, 3.37887928e-002, -6.64581060e-002,
-       6.30477965e-002, 7.90274069e-002, 2.48829052e-001,
-       -3.66321445e-001, 3.04878056e-001, 4.06875074e-001,
-       -1.39927432e-001, -1.19348444e-001, 2.61016369e-001,
-       1.96960986e-001, -1.16238281e-001, 2.13985739e-004,
-       1.49088681e-001, 3.65309455e-002, -2.06618034e-003,
-       -1.78462046e-003, 7.03047495e-003, 8.73623602e-003,
-       3.69863249e-002, -7.26447701e-002, 5.99827208e-002,
-       9.97110158e-002, 1.65194776e-002, -9.33406204e-002,
-       6.03881702e-002, 1.07704751e-001, -7.51533173e-003,
-       -3.42265330e-003, 1.29981749e-002, 9.10419319e-003,
-       -1.80508872e-003, 2.12717947e-004, 4.70349658e-003,
-       4.25139675e-003, -1.38466023e-002, -1.22785475e-002,
-       3.08468733e-002, 4.18176986e-002, 1.95937022e-003,
-       -1.41376313e-002, 2.44666170e-002, 4.34284396e-002,
-       2.05769640e-004, -1.55254296e-004, 3.82689992e-003,
-       4.62718401e-003, -6.24190271e-003, 1.33972345e-002,
-       3.95702235e-002, 3.44763212e-002, -1.56583622e-001,
-       1.88542932e-001, 2.44617164e-001, 3.55492949e-001,
-       4.03271504e-002, 1.66625351e-001, 1.55895501e-001,
-       3.32995355e-001, 2.05395790e-003, 1.63328573e-002,
-       3.48845981e-002, 3.86462249e-002, -6.38879929e-003,
-       -7.70076364e-003, 4.18864898e-002, 3.31981666e-002,
-       -1.64861485e-001, -1.40449539e-001, 2.58063078e-001,
-       3.67556006e-001, 6.05277531e-002, -1.15619034e-001,
-       1.70414984e-001, 3.43002141e-001, -2.26436663e-004,
-       -8.43981933e-003, 3.72785591e-002, 3.84266078e-002,
-       -1.59260537e-003, -6.40274724e-004, 4.80833044e-003,
-       4.60673077e-003, -1.45996725e-002, 9.17916466e-003,
-       3.28245051e-002, 4.49648686e-002, 2.00779038e-003,
-       9.16458108e-003, 2.52255462e-002, 4.40596677e-002,
-       1.79938448e-004, -8.80469997e-006, 4.19697911e-003,
-       4.67996206e-003, 3.82736442e-003, -1.47625646e-002,
-       6.15786528e-003, 2.87267603e-002, 3.20863053e-002,
-       -1.75742760e-001, 5.46934567e-002, 2.55141199e-001,
-       -1.45298941e-002, -1.79312140e-001, 4.94085513e-002,
-       2.56484002e-001, -9.64415725e-004, -1.01419725e-002,
-       7.65354279e-003, 2.51454897e-002, 3.80204222e-003,
-       -4.41900222e-003, 1.66263636e-002, 2.16370504e-002,
-       2.96718650e-003, -2.02334486e-002, 9.00744498e-002,
-       1.67315602e-001, 1.96137801e-001, 1.01551991e-002,
-       2.61346638e-001, 2.53470033e-001, 4.46058251e-002,
-       3.72872048e-004, 8.32137391e-002, 5.76087013e-002,
-       7.48848263e-003, 1.21367595e-003, 1.97274294e-002,
-       1.92875955e-002, 8.05120096e-002, 9.78798941e-002,
-       1.34171054e-001, 1.72494054e-001, 1.64211005e-001,
-       2.10006863e-001, 2.50987917e-001, 3.34447294e-001,
-       4.83485386e-002, 2.67696269e-002, 8.11100006e-002,
-       7.48602003e-002, 7.05685979e-003, 1.51296956e-002,
-       8.77191778e-003, 2.01675426e-002, 3.66060399e-002,
-       1.79609865e-001, 7.07273036e-002, 2.27580771e-001,
-       5.63408853e-003, 1.19803786e-001, 8.34077895e-002,
-       1.65095791e-001, -3.83524527e-003, 3.64747993e-003,
-       1.27672656e-002, 1.41506819e-002, -9.08240792e-004,
-       8.55964376e-004, 7.63409957e-003, 6.91754464e-003,
-       3.89121734e-002, 5.90996593e-002, 5.83460070e-002,
-       8.21392983e-002, 7.66094134e-004, 5.59316836e-002,
-       3.67648937e-002, 7.82606155e-002, -6.81548379e-003,
-       1.47348634e-004, 9.65367071e-003, 7.87802786e-003,
-       5.38743362e-002, 2.69446597e-002, 8.16549435e-002,
-       4.18973900e-002, 1.95151150e-001, 1.74369559e-001,
-       2.57831395e-001, 2.13222459e-001, -2.29261369e-001,
-       -1.90966837e-002, 2.91934729e-001, 1.49338380e-001,
-       -6.53886795e-002, -2.32485719e-002, 8.35308209e-002,
-       3.73969525e-002, 6.89538047e-002, 1.73443798e-002,
-       8.53613988e-002, 2.96787657e-002, 7.10650012e-002,
-       1.43032477e-004, 1.49820998e-001, 7.83228800e-002,
-       -4.26771998e-001, -9.48134065e-002, 4.61324453e-001,
-       1.42411768e-001, -2.34566219e-002, -7.50664389e-003,
-       5.52680381e-002, 2.49793343e-002, 6.33119559e-003,
-       9.81841702e-004, 9.01949219e-003, 3.23741930e-003,
-       2.05036066e-003, -9.99634806e-003, 2.59505864e-002,
-       1.77629013e-002, -6.84816465e-002, -1.90864410e-002,
-       7.71601051e-002, 2.92942394e-002, -5.22628892e-004,
-       1.13108603e-003, 6.81534875e-003, 3.70208151e-003,
-       1.62208604e-003, 1.16287998e-003, 6.02226378e-003,
-       4.77323122e-003, -8.61352775e-003, 3.21521424e-002,
-       3.88680138e-002, 4.59227227e-002, -2.64585428e-002,
-       2.77195517e-002, 4.46678586e-002, 4.72423173e-002,
-       -1.23506505e-003, 2.60845845e-004, 5.09942882e-003,
-       4.94038360e-003, 3.65488045e-002, -1.50532171e-003,
-       5.44468984e-002, 2.95599923e-002, 1.36571778e-002,
-       7.06909597e-002, 2.35949054e-001, 1.83431238e-001,
-       -1.72302216e-001, 1.61880925e-001, 2.96505839e-001,
-       2.63676643e-001, -3.89818847e-002, 1.30138258e-002,
-       5.24068475e-002, 3.77169214e-002, 3.84665541e-002,
-       -8.70760530e-003, 5.75954765e-002, 2.92047057e-002,
-       -3.79103050e-002, -1.39585793e-001, 3.12056482e-001,
-       2.16379195e-001, -1.58542603e-001, -2.98350126e-001,
-       3.02868098e-001, 3.51077199e-001, -3.36919688e-002,
-       -2.14860104e-002, 4.88510467e-002, 3.97981852e-002,
-       1.92001334e-003, -1.60568266e-003, 6.50510378e-003,
-       4.93893214e-003, -1.91012584e-002, -3.33800614e-002,
-       5.01080453e-002, 4.83681709e-002, -2.17047017e-002,
-       -1.88618619e-002, 4.01641168e-002, 4.12308797e-002,
-       -7.52015476e-005, -2.28680598e-004, 4.32163570e-003,
-       4.35865903e-003, 2.70490479e-002, -6.84825704e-004,
-       3.43067050e-002, 6.17356366e-003, 2.39735134e-002,
-       2.27893274e-002, 4.21003662e-002, 3.11050676e-002,
-       -9.66988504e-003, 1.03852572e-002, 2.88341567e-002,
-       2.25668754e-002, -7.61128124e-003, -2.56301532e-003,
-       1.00554246e-002, 6.16265368e-003, 2.50551522e-001,
-       2.68245279e-003, 2.91790307e-001, 3.62576060e-002,
-       1.14721224e-001, 5.16858697e-003, 2.07068607e-001,
-       9.26084071e-002, -1.47486687e-001, 2.43814401e-002,
-       2.30100513e-001, 1.20975390e-001, -8.39462802e-002,
-       -1.49480198e-002, 1.17761582e-001, 5.79998344e-002,
-       2.15490162e-001, 1.45044457e-003, 2.54375815e-001,
-       5.29582873e-002, 1.25617504e-001, -1.51660472e-001,
-       2.43653700e-001, 2.25837618e-001, -1.23329937e-001,
-       -2.05825970e-001, 1.99427903e-001, 2.92766958e-001,
-       -9.02467221e-002, -2.81001697e-003, 1.10291027e-001,
-       6.96278661e-002, 1.48751903e-002, -3.79739387e-004,
-       2.19930466e-002, 9.06850956e-003, -6.24362566e-003,
-       -7.02111199e-002, 5.97794354e-002, 9.92358923e-002,
-       -9.06269625e-003, -6.96127862e-002, 5.14767580e-002,
-       1.15182832e-001, -2.38024490e-003, -1.97118358e-003,
-       9.73811187e-003, 9.38718487e-003, 1.17059308e-003,
-       2.05368524e-005, 3.94058926e-003, 4.11478197e-003,
-       -1.21010132e-002, -1.78996138e-002, 3.03023569e-002,
-       3.99378203e-002, -9.05270223e-003, -3.60604040e-002,
-       3.19008604e-002, 5.10208085e-002, 1.85278492e-004,
-       -2.39122077e-003, 4.08741459e-003, 6.24525594e-003,
-       -1.35850739e-002, -3.95950973e-002, 3.09544206e-002,
-       5.37258163e-002, -9.28112119e-002, -2.36258626e-001,
-       2.06774756e-001, 3.57305378e-001, 9.06552747e-002,
-       2.68377122e-002, 1.87125638e-001, 3.51409703e-001,
-       1.34615460e-002, 7.77042750e-003, 2.71302219e-002,
-       5.48958220e-002, -1.20140063e-002, 2.21604668e-002,
-       2.90827639e-002, 4.90229167e-002, 1.88260823e-002,
-       2.27099672e-001, 1.63243756e-001, 3.59339952e-001,
-       6.84766620e-002, 7.20704719e-002, 1.51662365e-001,
-       4.14011836e-001, 1.05738100e-002, 2.59768305e-004,
-       2.36111321e-002, 6.20392635e-002, 1.34602957e-003,
-       2.72351643e-003, 3.87334614e-003, 5.61112864e-003,
-       2.50762422e-003, 2.45754030e-002, 2.49570794e-002,
-       4.29275446e-002, -8.11550359e-004, 2.86219213e-002,
-       2.07919199e-002, 4.53207903e-002, -6.36888319e-004,
-       2.97988043e-003, 3.08256946e-003, 5.85132698e-003,
-       1.10182846e-002, -2.79207923e-003, 1.96487363e-002,
-       6.21868996e-003, 1.25084445e-002, 4.61043557e-003,
-       2.71300655e-002, 1.57057568e-002, -6.32894412e-003,
-       2.65450240e-003, 1.97184607e-002, 1.57960616e-002,
-       -1.44749442e-002, -4.69847675e-003, 2.14987192e-002,
-       8.17656424e-003, 1.47206277e-001, -1.22231748e-002,
-       2.51753181e-001, 4.20641005e-002, 5.26786223e-002,
-       7.07090273e-003, 1.92369491e-001, 9.22124982e-002,
-       -2.58383658e-002, -1.76173681e-003, 1.50639549e-001,
-       9.36209485e-002, -1.38693482e-001, -7.27060996e-003,
-       2.09240690e-001, 3.58006097e-002, 1.54830366e-001,
-       -6.99616503e-003, 2.47881278e-001, 4.26463336e-002,
-       7.52865821e-002, -1.05373777e-001, 1.85593292e-001,
-       2.15765759e-001, -1.21312708e-001, -1.51962832e-001,
-       2.29232714e-001, 2.59889036e-001, -1.35756359e-001,
-       -3.33890840e-002, 2.05378175e-001, 5.56154884e-002,
-       7.87807070e-003, -1.46997301e-002, 1.83449443e-002,
-       2.45136060e-002, 8.24750587e-003, -1.93263665e-001,
-       3.84137034e-002, 2.77849585e-001, -2.58357134e-002,
-       -1.82060033e-001, 4.69984263e-002, 2.69569874e-001,
-       -1.98798883e-003, -1.09475553e-002, 1.33612463e-002,
-       2.12974362e-002, -1.03651386e-004, 3.42746149e-003,
-       3.87865538e-003, 5.18378895e-003, -2.70733647e-002,
-       4.38179336e-002, 4.17963080e-002, 5.23216762e-002,
-       -3.93696167e-002, 2.27921307e-002, 5.00496626e-002,
-       4.38828431e-002, 9.72006295e-004, -9.05438792e-004,
-       4.21113614e-003, 4.63688653e-003, 1.53591372e-002,
-       1.69566472e-003, 2.47943643e-002, 2.26543434e-002,
-       -1.51467184e-002, 9.82322693e-002, 1.41803861e-001,
-       1.67497352e-001, -2.57571965e-001, 3.66989821e-001,
-       2.87033588e-001, 3.91064197e-001, -3.10255755e-002,
-       5.54798022e-002, 4.40977179e-002, 6.44582957e-002,
-       1.46722347e-002, -2.72763669e-002, 2.58744787e-002,
-       3.70310768e-002, 4.03834619e-002, -2.55324185e-001,
-       1.19679973e-001, 2.84334034e-001, -5.26406355e-002,
-       -2.56601214e-001, 1.37626931e-001, 3.10623854e-001,
-       -3.79404612e-002, -1.60005912e-002, 4.49377075e-002,
-       4.84186485e-002, -1.18090957e-003, -3.24822217e-003,
-       3.78579879e-003, 6.98036747e-003, -7.38616986e-003,
-       -3.94425318e-002, 2.59774439e-002, 5.87496236e-002,
-       -9.75577277e-004, -4.13582996e-002, 2.45748889e-002,
-       5.96196502e-002, -9.79117103e-005, -3.49405175e-003,
-       3.77443037e-003, 6.88561331e-003, 9.70340217e-004,
-       6.68021676e-004, 4.10342962e-003, 3.57557298e-003,
-       1.17320390e-002, 2.27749050e-002, 2.91489828e-002,
-       3.68467420e-002, -6.21194392e-003, 2.32785959e-002,
-       2.49584429e-002, 3.76470201e-002, -1.93215208e-004,
-       1.13768328e-003, 3.46699846e-003, 4.09401115e-003,
-       2.49638073e-002, 8.39341898e-003, 4.06371020e-002,
-       2.82993671e-002, 1.15032107e-001, 1.21473789e-001,
-       2.58370131e-001, 2.36102149e-001, -9.12555233e-002,
-       9.18864980e-002, 1.73926979e-001, 2.25072071e-001,
-       -1.52149918e-002, 1.35464640e-002, 2.90765706e-002,
-       3.05304416e-002, 2.61468235e-002, -4.29180590e-003,
-       4.37493287e-002, 3.42919789e-002, 2.11766198e-001,
-       -1.79170985e-002, 2.87803710e-001, 4.04025048e-001,
-       -8.32301378e-002, 9.83695388e-002, 1.81242645e-001,
-       4.87117946e-001, -2.71322727e-002, 7.62897264e-003,
-       3.81772034e-002, 4.42665406e-002, 9.01051855e-004,
-       -1.87269936e-004, 4.08086227e-003, 4.29510744e-003,
-       1.76048744e-002, -2.84400024e-002, 3.52592133e-002,
-       4.84885089e-002, -1.36308477e-003, -3.67296450e-002,
-       2.68296730e-002, 5.63360602e-002, -2.24978532e-004,
-       -1.76622241e-003, 4.00562398e-003, 6.20573992e-003,
-       2.39285757e-003, 6.89114095e-004, 8.92397948e-003,
-       7.39591941e-003, 1.79410409e-002, 5.55616617e-002,
-       4.47599553e-002, 8.60066116e-002, 6.86877454e-003,
-       7.19159395e-002, 3.61338742e-002, 9.40202475e-002,
-       -1.51869422e-003, 5.51153067e-003, 6.63688639e-003,
-       1.01911733e-002, 8.41937214e-002, 1.44711919e-002,
-       1.08053610e-001, 4.19539437e-002, 1.91650987e-001,
-       2.36072943e-001, 2.68174529e-001, 2.92722672e-001,
-       -4.06847037e-002, 1.49789780e-001, 1.53167129e-001,
-       2.29088798e-001, -5.34304976e-002, 9.04857181e-003,
-       6.52994439e-002, 4.30457592e-002, 9.65435877e-002,
-       -1.20250462e-003, 1.16165280e-001, 3.44101973e-002,
-       1.06911682e-001, -1.47572771e-001, 2.44407699e-001,
-       2.11413816e-001, -1.28516227e-001, -3.01024050e-001,
-       2.04677716e-001, 3.50684822e-001, -4.03924845e-002,
-       -3.18475328e-002, 6.20971508e-002, 5.63536063e-002,
-       6.57607894e-003, -2.47886666e-004, 1.07915634e-002,
-       6.16172981e-003, -9.62983817e-003, -4.51312587e-002,
-       5.08295670e-002, 6.72423914e-002, -1.78609006e-002,
-       -2.59389449e-002, 4.59052064e-002, 6.37313947e-002,
-       1.17163104e-003, -6.98963559e-005, 6.55550743e-003,
-       7.25533813e-003, -1.06967040e-004, 8.26718227e-004,
-       5.13120787e-003, 4.77318978e-003, -3.24981399e-002,
-       -3.22498716e-002, 4.95307706e-002, 5.13757542e-002,
-       -2.23821364e-002, -4.17967774e-002, 5.08044027e-002,
-       5.67234382e-002, 8.31860816e-004, -1.81219040e-003,
-       5.58810495e-003, 5.61108859e-003, -3.30744311e-002,
-       -2.65054647e-002, 4.99097407e-002, 4.44244742e-002,
-       -2.99735099e-001, -2.03918770e-001, 3.61009419e-001,
-       3.40502053e-001, -5.05651236e-002, -9.96610075e-002,
-       2.60790199e-001, 2.28453413e-001, 3.18538025e-002,
-       -3.96433845e-003, 4.47580032e-002, 3.37284841e-002,
-       -5.13346046e-002, -1.32723944e-002, 6.10941015e-002,
-       4.68703099e-002, -1.10169575e-001, 3.08302771e-002,
-       2.17644438e-001, 2.58864075e-001, 5.19696362e-002,
-       2.15851933e-001, 2.13513181e-001, 2.75007874e-001,
-       2.31907889e-002, 2.32532211e-002, 4.23328765e-002,
-       4.01153602e-002, -2.67685251e-003, 1.16107194e-003,
-       6.34597382e-003, 6.14679419e-003, -2.20540538e-003,
-       3.53972092e-002, 3.58454548e-002, 4.98482250e-002,
-       1.02983657e-002, 2.60643363e-002, 3.81390229e-002,
-       4.59006689e-002, -1.23990793e-003, 5.13078528e-004,
-       5.60203427e-003, 5.41330129e-003, -1.35241495e-002,
-       2.13620238e-004, 2.06730999e-002, 6.48547243e-003,
-       -1.53612858e-002, -2.81669777e-002, 4.07239795e-002,
-       5.20357341e-002, -8.98674503e-003, -2.23584082e-002,
-       2.93790437e-002, 4.77689356e-002, 5.27967240e-005,
-       -1.70024310e-003, 3.78364418e-003, 5.40492963e-003,
-       -1.69750825e-001, 2.08226661e-003, 2.12656796e-001,
-       3.43257263e-002, -1.33057415e-001, -1.66287974e-001,
-       2.41251528e-001, 2.13063374e-001, -1.00080390e-002,
-       -1.65259555e-001, 1.32692054e-001, 1.96903184e-001,
-       1.06437225e-002, -1.85134541e-002, 2.39597410e-002,
-       2.88606752e-002, -1.77872658e-001, 7.44023826e-003,
-       2.21580759e-001, 4.03177142e-002, -1.41448498e-001,
-       3.13311934e-001, 2.97782660e-001, 3.71222377e-001,
-       -9.54941884e-002, 1.14280388e-001, 1.75231472e-001,
-       1.97041512e-001, 1.52777201e-002, 2.08700192e-003,
-       2.56989729e-002, 2.23504156e-002, -9.00160521e-003,
-       1.35847344e-003, 1.98977720e-002, 6.39222562e-003,
-       -2.63894815e-002, 5.41677698e-002, 6.89711198e-002,
-       7.54081458e-002, -4.95041311e-002, 6.15689084e-002,
-       6.23987801e-002, 7.55310804e-002, -7.16296199e-004,
-       3.89817660e-003, 4.89080697e-003, 6.47186860e-003,
-       3.98698685e-005, -1.05521793e-003, 5.84879005e-003,
-       3.28823947e-003, 5.36942631e-002, 2.52552461e-002,
-       7.20391870e-002, 3.52777839e-002, 5.53023210e-003,
-       1.74229890e-002, 3.08262277e-002, 2.63905637e-002,
-       -5.22155175e-003, -8.74981284e-004, 7.24770036e-003,
-       4.14265692e-003, 2.25798618e-002, 9.19882022e-003,
-       5.04839495e-002, 2.36541964e-002, 3.52479488e-001,
-       1.21663958e-001, 4.84843552e-001, 1.72135711e-001,
-       -6.64514005e-002, 3.49435373e-003, 1.73392177e-001,
-       1.09648280e-001, -5.74043766e-002, -2.14436315e-002,
-       6.67066425e-002, 3.45392004e-002, 5.44992723e-002,
-       2.36885119e-002, 6.88984990e-002, 3.34420912e-002,
-       1.87246099e-001, 5.06492779e-002, 3.03388536e-001,
-       1.40016392e-001, -2.59850770e-001, -1.53221160e-001,
-       3.20479810e-001, 1.97534308e-001, -3.13718170e-002,
-       -2.39731520e-002, 5.16943745e-002, 3.61901112e-002,
-       7.49462657e-003, 1.99104263e-003, 9.48054157e-003,
-       4.33178525e-003, 3.21810832e-003, -1.77167896e-002,
-       3.63582931e-002, 2.83572897e-002, -5.60720824e-002,
-       -2.89188717e-002, 6.49824217e-002, 3.93444635e-002,
-       7.95509142e-004, 3.30914831e-004, 5.06167579e-003,
-       3.55706015e-003, 1.85941812e-003, 8.69608833e-004,
-       4.84401686e-003, 4.04066639e-003, -4.82021458e-002,
-       -4.38980870e-002, 6.12520054e-002, 5.73581420e-002,
-       8.18254519e-003, -5.17133772e-002, 4.67864089e-002,
-       6.34094775e-002, -5.99110826e-005, -1.26955518e-003,
-       5.42875659e-003, 5.25524188e-003, -2.42859237e-002,
-       -5.56003861e-002, 5.18759973e-002, 6.46374896e-002,
-       -3.87063414e-001, -3.39285523e-001, 4.31698173e-001,
-       3.86092544e-001, 1.66836083e-001, -1.80991992e-001,
-       2.27329150e-001, 2.47178346e-001, 2.28840504e-002,
-       -3.62328961e-002, 4.22494113e-002, 4.65700589e-002,
-       -4.43630219e-002, -3.61148529e-002, 5.61251342e-002,
-       5.23855537e-002, -5.79676032e-002, 1.82311924e-003,
-       1.40561298e-001, 1.33089915e-001, 5.98192215e-002,
-       2.79435124e-002, 1.16890974e-001, 1.12097286e-001,
-       2.23740060e-002, -7.06675369e-003, 3.22793797e-002,
-       2.69947760e-002, -1.82836573e-003, 3.21400468e-004,
-       4.69138799e-003, 4.31861356e-003, -2.00031954e-003,
-       1.24630947e-002, 2.08763704e-002, 2.37789042e-002,
-       5.76614030e-003, 1.22851040e-002, 2.01909114e-002,
-       2.29146220e-002, 1.25764275e-003, 4.92458872e-004,
-       3.71642527e-003, 3.50781740e-003, 1.20348495e-003,
-       1.72416074e-003, 4.10596840e-003, 4.18272009e-003,
-       8.26224778e-003, 3.34666260e-002, 3.52320857e-002,
-       4.77686524e-002, 2.35431399e-002, 4.19716947e-002,
-       4.29758616e-002, 5.64190075e-002, 2.45268364e-003,
-       4.70324466e-003, 5.92461601e-003, 7.31546711e-003,
-       4.45825569e-002, 1.21625410e-002, 5.50570562e-002,
-       3.17408666e-002, 1.22561246e-001, 3.00992042e-001,
-       3.33865166e-001, 3.56897324e-001, 1.31786346e-001,
-       2.62969017e-001, 2.45355755e-001, 3.00048888e-001,
-       -1.15499673e-002, 1.80970505e-002, 2.96120960e-002,
-       2.96610333e-002, 3.87850367e-002, -4.31514066e-003,
-       5.26699461e-002, 2.79314406e-002, 2.68324345e-001,
-       -8.45376179e-002, 3.35654169e-001, 1.95814922e-001,
-       3.12873721e-003, -4.28246185e-002, 1.22002549e-001,
-       1.18627504e-001, -1.17365699e-002, -2.49678409e-003,
-       2.36644950e-002, 1.78527720e-002, 2.37836037e-003,
-       1.28441071e-003, 5.57986321e-003, 4.00313456e-003,
-       3.70390266e-002, -1.83547586e-002, 4.95511517e-002,
-       3.52726094e-002, 7.28771277e-003, -1.76381916e-002,
-       2.69160066e-002, 2.94426363e-002, 1.77758979e-004,
-       -7.49962579e-004, 3.03392578e-003, 3.09457071e-003,
-       -1.19149801e-003, -1.08149182e-003, 4.39706119e-003,
-       3.69879347e-003, 3.64244846e-003, -1.96105037e-002,
-       2.57881284e-002, 2.96051465e-002, 1.44342724e-002,
-       -2.39679627e-002, 4.46302965e-002, 3.75758708e-002,
-       2.49624755e-002, 2.37988378e-003, 2.84343120e-002,
-       6.75866148e-003, -1.56284384e-002, -3.55908880e-003,
-       3.20439562e-002, 2.03037541e-002, -1.02747139e-002,
-       -4.79186922e-002, 1.34019956e-001, 1.07858457e-001,
-       9.44288075e-002, -3.63510400e-002, 3.05357516e-001,
-       1.63497373e-001, 2.47091368e-001, 2.27037109e-002,
-       2.65645623e-001, 4.47422378e-002, -1.55569008e-002,
-       8.85960064e-004, 3.19817178e-002, 2.03545690e-002,
-       -1.67914778e-002, 8.68693087e-003, 1.38204277e-001,
-       1.27875894e-001, 3.09672058e-001, 1.47580504e-001,
-       4.46895063e-001, 2.54223824e-001, 1.92097187e-001,
-       2.75932699e-002, 2.16839731e-001, 4.95694913e-002,
-       -9.88232903e-004, 2.96607357e-003, 4.63947421e-003,
-       6.46318309e-003, 1.35022392e-002, 4.57524024e-002,
-       3.45665291e-002, 6.27924129e-002, 8.68114680e-002,
-       8.04832578e-002, 1.07415333e-001, 9.52414051e-002,
-       8.04744475e-003, -5.75166312e-004, 1.52557530e-002,
-       7.63598597e-003, 1.90311242e-002, -2.40314077e-003,
-       2.56034527e-002, 5.08742174e-003, 3.33953127e-002,
-       5.16029075e-003, 4.59046029e-002, 1.84002928e-002,
-       6.91922731e-004, 2.88150809e-003, 1.29961511e-002,
-       1.07593508e-002, -3.49466893e-004, 2.61488321e-006,
-       1.75058388e-003, 1.43331382e-003, 1.60334691e-001,
-       -6.34170510e-003, 2.00514466e-001, 3.11112795e-002,
-       2.31425747e-001, 3.52172856e-003, 3.19053590e-001,
-       9.93250981e-002, -5.27968339e-004, 2.09930795e-003,
-       8.22112113e-002, 6.81145042e-002, -5.19519113e-003,
-       -4.74159257e-004, 1.36507638e-002, 1.07876873e-002,
-       1.47521466e-001, -5.95817855e-003, 1.82952717e-001,
-       3.90304551e-002, 2.32741252e-001, -2.16770694e-001,
-       3.35168809e-001, 2.96427101e-001, 3.99672164e-004,
-       -2.19943225e-001, 1.03204735e-001, 2.78349578e-001,
-       -5.40162856e-003, -2.82574240e-002, 1.82372164e-002,
-       3.80537175e-002, 7.98942614e-003, -7.62632489e-003,
-       1.18681518e-002, 1.17544346e-002, 8.63514096e-003,
-       -1.53867066e-001, 4.35971469e-002, 1.82709262e-001,
-       1.08698299e-002, -1.55900583e-001, 3.36352065e-002,
-       1.89235881e-001, 2.52159080e-003, -1.79909524e-002,
-       5.13185328e-003, 2.42942888e-002, -3.86357633e-003,
-       -2.73850933e-003, 8.40738695e-003, 8.13048333e-003,
-       -5.87489689e-004, -4.98416424e-002, 3.80313285e-002,
-       7.77640417e-002, -9.18287877e-003, -4.70381938e-002,
-       3.35176326e-002, 7.79544190e-002, -4.34074755e-004,
-       -3.51445586e-003, 5.28656784e-003, 8.38974304e-003,
-       -7.22312182e-002, 2.13446412e-002, 8.78918841e-002,
-       5.16420044e-002, -9.14717019e-002, -1.01260342e-001,
-       2.10852563e-001, 2.39998281e-001, -2.58193091e-002,
-       -1.59349129e-001, 1.44568756e-001, 2.21881643e-001,
-       2.15368923e-002, -1.32458406e-002, 3.42412181e-002,
-       3.29471342e-002, -4.47856262e-002, 3.53517421e-002,
-       7.56701753e-002, 5.50080612e-002, -3.77302855e-001,
-       1.89642251e-001, 4.38134164e-001, 3.15078944e-001,
-       5.52166551e-002, 1.25871912e-001, 1.67149231e-001,
-       2.37094998e-001, 2.09910143e-002, 1.95019562e-002,
-       3.55134234e-002, 3.78143340e-002, -7.25829450e-004,
-       -1.23684446e-003, 8.17917753e-003, 5.82051696e-003,
-       -5.25934063e-002, 3.40433717e-002, 7.16307387e-002,
-       5.70832379e-002, 2.14485032e-003, 2.96874903e-002,
-       3.95551883e-002, 5.24301939e-002, -1.32778302e-006,
-       9.94460657e-004, 5.07492991e-003, 6.27018884e-003,
-       -3.23928311e-004, 1.49933272e-003, 6.74494868e-003,
-       3.32968868e-003, -6.72481433e-002, -2.50052325e-002,
-       7.95577094e-002, 3.87396626e-002, -3.66781629e-003,
-       -2.33786553e-002, 2.67899148e-002, 3.53628099e-002,
-       4.78151545e-004, -1.46027957e-003, 3.55862128e-003,
-       4.15524095e-003, -2.56476868e-002, -5.80201810e-003,
-       5.69369160e-002, 1.87090710e-002, -4.76102054e-001,
-       -1.29274681e-001, 5.19352973e-001, 1.66201890e-001,
-       2.50380598e-002, -4.75100502e-002, 1.03745520e-001,
-       9.97768715e-002, 1.21787591e-002, -5.20892907e-003,
-       2.26638373e-002, 1.75256841e-002, -5.70426472e-002,
-       -1.50220022e-002, 7.90800080e-002, 2.47148462e-002,
-       -3.45961243e-001, -1.38807315e-002, 3.98294896e-001,
-       1.14090107e-001, 3.13989148e-002, 3.09592374e-002,
-       9.67002735e-002, 8.23300183e-002, 1.06661506e-002,
-       2.87019694e-003, 2.10336745e-002, 1.49638858e-002,
-       -8.95086769e-003, -2.67435261e-003, 1.19088925e-002,
-       4.40928247e-003, -3.19541208e-002, 1.05092973e-002,
-       4.68084812e-002, 2.56876126e-002, 3.04058054e-003,
-       1.38933808e-002, 1.94687359e-002, 2.46347077e-002,
-       3.76121461e-004, 8.52892175e-004, 2.90752365e-003,
-       3.19174374e-003, -1.74157950e-003, 1.64007500e-003,
-       7.24167190e-003, 3.96097684e-003, -3.20685096e-002,
-       -1.45699894e-002, 5.32972887e-002, 2.91964598e-002,
-       -1.15637865e-003, -1.07215988e-002, 2.11115684e-002,
-       2.45072674e-002, 7.31576991e-004, -3.65216634e-004,
-       3.43297073e-003, 3.10700596e-003, -3.03997062e-002,
-       -3.78691056e-003, 5.89896888e-002, 2.73270514e-002,
-       -2.58094132e-001, -4.21430059e-002, 3.54403883e-001,
-       1.49993807e-001, 2.55393647e-002, -3.06155551e-002,
-       1.02922983e-001, 1.21110864e-001, 1.29136136e-002,
-       1.20980018e-004, 2.42782179e-002, 2.08029076e-002,
-       -4.06285003e-002, 5.40943816e-003, 6.80232644e-002,
-       4.76889834e-002, -2.63116241e-001, 1.66703194e-001,
-       3.47084403e-001, 5.30446410e-001, 3.10972258e-002,
-       -2.61637819e-004, 1.51869357e-001, 2.56316096e-001,
-       1.77619644e-002, 5.56571649e-005, 2.90770344e-002,
-       2.90308557e-002, -1.43988605e-003, -8.67041468e-004,
-       6.98374351e-003, 5.53098414e-003, -3.48292179e-002,
-       9.22923256e-003, 5.58213033e-002, 6.74077943e-002,
-       -3.11009306e-002, 3.54543440e-002, 5.26124351e-002,
-       5.78895733e-002, 1.22508034e-003, 1.45630341e-003,
-       4.19611065e-003, 4.44500148e-003, 7.90028658e-004,
-       -4.80999530e-004, 5.71519975e-003, 2.30272324e-003,
-       1.69104885e-003, 4.29736637e-003, 5.07244319e-002,
-       2.16224492e-002, 7.24891480e-003, 4.40300442e-003,
-       5.46884909e-002, 2.42669284e-002, -2.98203994e-003,
-       -2.29227124e-004, 6.98046107e-003, 3.33554135e-003,
-       9.58750024e-003, -8.05163931e-004, 4.34402749e-002,
-       1.29191540e-002, -1.83201432e-002, 1.86561067e-002,
-       4.12497044e-001, 1.13015942e-001, 7.86208287e-002,
-       9.46782064e-003, 4.61269885e-001, 1.21605575e-001,
-       -2.62066610e-002, -3.03415977e-003, 5.62672503e-002,
-       1.89947542e-002, 1.03797000e-002, 1.70705968e-003,
-       4.48550470e-002, 1.36639467e-002, -3.30627640e-003,
-       -8.51789955e-003, 4.35526192e-001, 1.13804020e-001,
-       3.35606001e-002, -2.38368008e-002, 4.57458317e-001,
-       1.34065419e-001, -2.14574430e-002, -1.18186011e-003,
-       5.23424074e-002, 1.75685529e-002, 6.78375131e-004,
-       2.53583479e-004, 6.07082993e-003, 2.44880933e-003,
-       4.66674613e-003, -5.58829634e-003, 5.43123558e-002,
-       2.44626831e-002, -4.35855798e-003, -7.17898039e-003,
-       5.49796820e-002, 2.64951084e-002, -1.71965128e-003,
-       -2.20981718e-004, 6.22865139e-003, 2.76658847e-003,
-       9.02252330e-004, -9.02517757e-004, 4.21836600e-003,
-       3.39861657e-003, 3.12446686e-003, 5.17200259e-003,
-       2.37624217e-002, 2.25288719e-002, -1.24041922e-002,
-       7.04277819e-003, 2.83728708e-002, 2.31743120e-002,
-       -1.58788711e-002, -1.08444085e-003, 2.66969595e-002,
-       4.74068150e-003, 1.61481258e-002, -4.20043431e-003,
-       3.88615616e-002, 2.58607548e-002, 2.58022863e-002,
-       -4.28768583e-002, 1.37508139e-001, 1.36825740e-001,
-       -7.89732486e-002, -2.62764543e-002, 1.96789473e-001,
-       1.45689398e-001, -1.44741416e-001, -1.28571410e-002,
-       2.36176372e-001, 3.46129946e-002, 2.16463096e-002,
-       -1.60517674e-002, 4.76604402e-002, 5.80994934e-002,
-       7.57112447e-003, -5.73348925e-002, 1.71171606e-001,
-       2.85092682e-001, -1.02245219e-001, -1.18261985e-001,
-       2.34709978e-001, 2.76372910e-001, -1.40970200e-001,
-       -1.19846556e-002, 2.30256215e-001, 5.01368903e-002,
-       1.41083333e-003, -3.12350038e-002, 6.33377675e-003,
-       4.18054424e-002, 3.09599284e-003, -2.46471822e-001,
-       3.45784612e-002, 3.17137003e-001, -1.25991646e-002,
-       -2.36383244e-001, 4.38380204e-002, 3.02401066e-001,
-       -5.05522592e-003, -1.93533711e-002, 1.76845212e-002,
-       2.66413838e-002, -1.00809382e-003, -4.95219720e-004,
-       5.90430060e-003, 5.05420845e-003, 6.89927314e-004,
-       -3.08543444e-002, 3.79687846e-002, 4.46711592e-002,
-       3.70318517e-002, -2.91046686e-002, 4.92666140e-002,
-       4.32745814e-002, 1.88998575e-003, 6.69714762e-004,
-       4.55419486e-003, 3.40860221e-003, -2.21881848e-002,
-       3.66380648e-003, 4.65914644e-002, 3.43693979e-002,
-       -8.00025761e-002, 2.12891977e-002, 2.28287101e-001,
-       2.12390780e-001, 2.81302691e-001, -8.63127187e-002,
-       3.52442682e-001, 1.97802052e-001, 3.51786911e-002,
-       -4.40564146e-003, 4.73026522e-002, 2.36157756e-002,
-       -2.27466226e-002, -2.51641800e-003, 4.82367314e-002,
-       3.84670235e-002, -1.00387573e-001, -5.32503240e-002,
-       2.47183830e-001, 2.68763334e-001, 3.26810628e-001,
-       9.68248472e-002, 3.87035996e-001, 2.40516707e-001,
-       3.20061259e-002, 6.53688051e-003, 4.49231043e-002,
-       2.47845817e-002, -8.06183962e-004, 1.36633185e-004,
-       6.05399860e-003, 5.68357389e-003, 5.61926281e-003,
-       3.80941182e-002, 4.11810391e-002, 5.35609759e-002,
-       3.90191451e-002, 3.33131924e-002, 5.12483604e-002,
-       4.76814024e-002, 1.16959179e-003, -5.87249815e-004,
-       4.05293889e-003, 3.37092672e-003, 8.49662349e-003,
-       -3.05353664e-004, 1.19083980e-002, 5.94876427e-003,
-       1.26975402e-002, 1.24475705e-002, 2.65752748e-002,
-       2.55493708e-002, -4.30618459e-003, 8.85988493e-003,
-       1.76795255e-002, 2.19207015e-002, -9.84183745e-004,
-       1.68230501e-004, 3.66705609e-003, 3.06794699e-003,
-       1.03565156e-001, -2.84971539e-002, 1.22936711e-001,
-       5.51312417e-002, 9.86948833e-002, -1.18892659e-002,
-       1.75863817e-001, 1.31010458e-001, -4.37558703e-002,
-       3.87892220e-003, 1.02972172e-001, 1.02222525e-001,
-       -1.06558772e-002, 6.95119437e-004, 2.83989627e-002,
-       1.93237774e-002, 1.05732255e-001, -5.34436665e-002,
-       1.32150501e-001, 7.96161890e-002, 2.55580544e-001,
-       -2.44477093e-001, 3.25885385e-001, 3.37170571e-001,
-       -3.10328938e-002, -1.22067146e-001, 1.22326352e-001,
-       2.20863819e-001, -2.12104507e-002, -2.46767029e-002,
-       3.98123413e-002, 4.03812453e-002, 2.74505606e-003,
-       -1.04620103e-002, 8.48148763e-003, 2.05154531e-002,
-       3.10126878e-002, -2.07978517e-001, 5.02654053e-002,
-       2.82056272e-001, 1.01783937e-002, -2.26702958e-001,
-       3.85931320e-002, 3.02737713e-001, 9.47979279e-004,
-       -2.41731331e-002, 7.13347085e-003, 3.49345244e-002,
-       -1.93630622e-005, 1.84503139e-003, 4.89430828e-003,
-       3.89772258e-003, 5.92932152e-003, 2.59679332e-002,
-       3.30115259e-002, 3.68545055e-002, -2.14470476e-002,
-       3.87482755e-002, 6.66400492e-002, 5.26542366e-002,
-       -1.84487924e-002, -4.91144194e-004, 2.43405551e-002,
-       5.75977471e-003, 1.87686160e-002, 1.94139441e-003,
-       3.28042582e-002, 1.47143323e-002, 4.83184792e-002,
-       4.08203751e-002, 1.38996109e-001, 1.01905480e-001,
-       1.12733981e-002, 8.42738003e-002, 4.82205331e-001,
-       1.71598405e-001, -2.05836445e-001, -9.41928665e-005,
-       2.29555205e-001, 3.08672283e-002, 2.29558554e-002,
-       -2.64015724e-003, 3.72008383e-002, 1.61690284e-002,
-       5.88465817e-002, -9.55595821e-003, 1.50403216e-001,
-       1.01045892e-001, -1.06644921e-001, -1.54723510e-001,
-       4.45733964e-001, 2.27773011e-001, -1.83696941e-001,
-       -3.80635960e-003, 2.05120742e-001, 3.88505347e-002,
-       1.59599714e-003, -1.80544914e-003, 5.61793847e-003,
-       4.37735580e-003, 3.44996504e-003, -3.19538452e-002,
-       3.41449529e-002, 4.26940955e-002, -4.46109660e-002,
-       -5.21579199e-002, 8.86287317e-002, 6.48798347e-002,
-       -1.34079494e-002, -1.39535300e-003, 2.01129653e-002,
-       8.01844057e-003, 2.80911685e-004, -1.73327862e-003,
-       4.00827220e-003, 5.38913859e-003, 1.05805974e-002,
-       -3.52309160e-002, 2.97360215e-002, 5.30115366e-002,
-       2.60529798e-002, -3.42200659e-002, 4.43336666e-002,
-       5.73338866e-002, 3.49682197e-003, 9.50391754e-004,
-       6.85214577e-003, 6.92250393e-003, -1.48448413e-002,
-       5.48382197e-003, 2.94914208e-002, 2.93442141e-002,
-       4.96152453e-002, 6.23829961e-002, 1.59839049e-001,
-       2.11490780e-001, 2.45481551e-001, 8.59075338e-002,
-       2.95003384e-001, 2.70723194e-001, 4.35767993e-002,
-       -5.45060029e-004, 5.87911569e-002, 4.41728272e-002,
-       -9.05477069e-003, 3.31023671e-002, 3.19191106e-002,
-       4.83586676e-002, 6.66936859e-002, 2.79790640e-001,
-       1.89648405e-001, 3.78308177e-001, 1.08947054e-001,
-       1.76506460e-001, 2.08529934e-001, 3.89438629e-001,
-       3.97680067e-002, 5.43950917e-003, 5.23699634e-002,
-       5.16126566e-002, 3.00604454e-003, 4.61148843e-003,
-       5.08555770e-003, 8.04807432e-003, 1.26966778e-002,
-       4.69653830e-002, 3.05841658e-002, 6.67111576e-002,
-       1.98901212e-003, 4.80992757e-002, 2.35337224e-002,
-       6.61806092e-002, 1.24361439e-004, 3.40004964e-003,
-       3.73138371e-003, 6.48838608e-003, -1.37527403e-003,
-       1.92892947e-003, 8.01235158e-003, 7.86328129e-003,
-       6.53081015e-002, 4.60427329e-002, 8.07231963e-002,
-       7.35031962e-002, 2.97494177e-002, 3.92606258e-002,
-       4.68786545e-002, 4.83056195e-002, -6.82232901e-003,
-       -1.06348644e-003, 1.11599388e-002, 6.06541429e-003,
-       6.73312917e-002, 4.95019667e-002, 8.97477120e-002,
-       8.46346766e-002, 1.61065161e-001, 2.57616818e-001,
-       2.61434019e-001, 3.48728955e-001, -2.28945492e-003,
-       2.84578446e-002, 1.32455781e-001, 1.06937796e-001,
-       -8.88093784e-002, -8.35900754e-003, 1.58670262e-001,
-       2.71390658e-002, 5.84643632e-002, 1.17686866e-002,
-       7.60028288e-002, 5.67667037e-002, 2.11994946e-002,
-       -8.76122490e-002, 1.22656174e-001, 1.87910870e-001,
-       -4.92638536e-002, -1.13077439e-001, 1.36658385e-001,
-       1.92519382e-001, -1.08850814e-001, -3.02967466e-002,
-       1.99721113e-001, 4.22114804e-002, 1.51572807e-003,
-       -2.40699295e-002, 4.84113907e-003, 4.10504416e-002,
-       8.91006552e-004, -1.85930341e-001, 2.56168153e-002,
-       3.12425733e-001, -7.66061665e-003, -1.73747793e-001,
-       3.05944327e-002, 3.00116390e-001, -2.34762952e-003,
-       -1.20582655e-002, 1.55597394e-002, 2.50423327e-002,
-       4.64053452e-003, 1.31815327e-002, 1.03905369e-002,
-       1.98753886e-002, -2.85925902e-003, 1.78936675e-001,
-       3.58177237e-002, 2.34596774e-001, -6.85126986e-004,
-       1.77347541e-001, 2.82906666e-002, 2.40168005e-001,
-       8.79249827e-004, 1.98684540e-002, 4.89538629e-003,
-       2.98192706e-002, 1.19437180e-001, 1.23620015e-002,
-       1.59890369e-001, 5.71271740e-002, 1.32662177e-001,
-       2.01849014e-001, 2.53784329e-001, 3.57390255e-001,
-       -4.12550848e-003, 2.45275170e-001, 1.27774477e-001,
-       3.61175448e-001, -1.35213882e-002, 4.08731066e-002,
-       2.83008441e-002, 5.73501475e-002, 1.21517859e-001,
-       1.60262305e-002, 1.63952798e-001, 4.54361774e-002,
-       1.11065961e-001, -1.91418000e-003, 2.22473413e-001,
-       1.57723308e-001, 1.11467959e-002, -1.87419169e-002,
-       1.10898845e-001, 1.13510773e-001, -9.16777737e-003,
-       2.41897185e-004, 2.16876604e-002, 1.80089585e-002,
-       1.19621977e-002, 5.39656263e-004, 1.89288948e-002,
-       6.74266228e-003, 1.52879469e-002, -1.80801842e-002,
-       3.63262631e-002, 3.63762230e-002, 2.64065480e-003,
-       -1.52125303e-002, 2.05336530e-002, 3.02215423e-002,
-       -2.58399901e-004, -1.07357290e-003, 2.97610089e-003,
-       3.52839613e-003, 1.67528924e-004, 3.27421911e-002,
-       5.43456152e-003, 4.38110642e-002, -2.12557823e-003,
-       2.54531264e-001, 2.70993188e-002, 3.31151992e-001,
-       -1.59709565e-002, 2.28082031e-001, 4.16778363e-002,
-       3.07192862e-001, -3.94404400e-003, 1.93778165e-002,
-       1.45082371e-002, 2.90858168e-002, 1.79418139e-002,
-       2.81029437e-002, 4.20243479e-002, 4.60997596e-002,
-       9.45981010e-005, 1.65993407e-001, 1.13546304e-001,
-       2.69119233e-001, -1.46283776e-001, 2.24312827e-001,
-       2.22039789e-001, 3.28966886e-001, -1.30636141e-001,
-       2.89324448e-002, 2.12701291e-001, 6.49622902e-002,
-       1.32539282e-002, 2.52275588e-003, 3.66358869e-002,
-       1.77772660e-002, -6.22248789e-003, -6.71970053e-003,
-       8.78235102e-002, 8.92970040e-002, -8.30244124e-002,
-       2.58063991e-003, 1.60625920e-001, 1.10069282e-001,
-       -1.32420897e-001, 9.57973953e-003, 2.17087999e-001,
-       3.57983969e-002, 5.97037666e-004, -9.98505056e-005,
-       3.93639319e-003, 2.48794560e-003, -1.29124662e-003,
-       -2.93553458e-003, 1.42219122e-002, 1.36956833e-002,
-       -1.09455204e-002, -1.34272594e-003, 2.48647016e-002,
-       1.64720640e-002, -1.53922634e-002, 1.93777203e-003,
-       2.56655458e-002, 5.58676571e-003, 3.34015279e-003,
-       6.54860772e-003, 6.58317655e-003, 1.36035830e-002,
-       8.84217862e-003, 1.07475363e-001, 3.02014276e-002,
-       1.51424900e-001, 2.09895591e-003, 9.79838595e-002,
-       2.80720666e-002, 1.36248216e-001, 9.04590008e-004,
-       7.44963996e-003, 5.80043206e-003, 1.39671164e-002,
-       5.05666025e-002, -2.99624372e-002, 7.37488791e-002,
-       5.77796772e-002, 2.37446830e-001, -1.25191629e-001,
-       2.81919241e-001, 3.35360438e-001, -6.91805556e-002,
-       7.76329413e-002, 1.50753543e-001, 1.63696691e-001,
-       -1.73796453e-002, 1.92317739e-002, 4.36294600e-002,
-       4.85046506e-002, 3.16376239e-002, 9.39523056e-003,
-       5.99465519e-002, 4.78008986e-002, 3.79478782e-001,
-       8.83251056e-002, 4.19786721e-001, 3.16705465e-001,
-       -4.12204415e-002, 1.27333170e-003, 1.28486276e-001,
-       9.64839235e-002, -2.79018749e-002, -1.11262994e-002,
-       3.96513529e-002, 4.16703969e-002, 4.26674169e-003,
-       -7.29740656e-004, 8.34741909e-003, 5.18484600e-003,
-       4.54053022e-002, -3.54805067e-002, 5.53547665e-002,
-       5.14346994e-002, -9.86745581e-004, -1.92293432e-002,
-       2.74057314e-002, 3.21857333e-002, -1.86607649e-003,
-       4.83852258e-004, 5.40560111e-003, 3.98136815e-003,
-       -3.92367551e-003, -2.83178082e-003, 8.61285720e-003,
-       6.70304801e-003, 4.31893888e-004, -3.12998965e-002,
-       2.73820348e-002, 6.01236410e-002, -1.64162228e-003,
-       -3.52502614e-002, 3.48863751e-002, 6.56682923e-002,
-       8.21573939e-003, -5.36556065e-004, 1.53148817e-002,
-       6.31580129e-003, -5.69205098e-002, -9.56528541e-003,
-       7.24000484e-002, 2.87410952e-002, -4.67739776e-002,
-       -1.51513398e-001, 1.14133060e-001, 2.06995502e-001,
-       1.66307949e-002, -1.55291677e-001, 1.32269338e-001,
-       2.09946752e-001, 1.30890340e-001, 1.90299063e-003,
-       1.73274070e-001, 2.96688378e-002, -4.89410348e-002,
-       3.25130373e-002, 6.51761293e-002, 4.85050902e-002,
-       -4.94197570e-002, 3.51085663e-001, 1.12871088e-001,
-       4.14378762e-001, -6.17187237e-003, 3.28477353e-001,
-       1.40179306e-001, 3.76278162e-001, 1.28038615e-001,
-       7.89327174e-003, 1.70920596e-001, 3.48118320e-002,
-       3.68560955e-004, -4.52603679e-004, 6.51012361e-003,
-       8.13806243e-003, -2.94386875e-003, 2.83130339e-005,
-       2.93854456e-002, 5.96994646e-002, -1.13331676e-002,
-       3.61359701e-003, 3.30235772e-002, 5.72394207e-002,
-       4.73040016e-003, -1.23292184e-003, 1.13868788e-002,
-       7.24533200e-003, -1.67968939e-003, -4.13166155e-004,
-       7.22032553e-003, 5.06170746e-003, 2.27298457e-002,
-       -3.03943399e-002, 4.43106927e-002, 4.57297452e-002,
-       3.41034867e-002, -3.31700109e-002, 4.94486317e-002,
-       5.31987362e-002, 2.95169535e-003, -4.17179224e-004,
-       6.57134922e-003, 5.73574333e-003, -4.63713855e-002,
-       -2.94212485e-003, 6.76225871e-002, 3.06728166e-002,
-       1.29077241e-001, -9.41477939e-002, 2.59669214e-001,
-       1.73286468e-001, 2.10942000e-001, -1.35504737e-001,
-       2.90184826e-001, 2.38101676e-001, 5.56428283e-002,
-       -1.21572753e-002, 6.96907490e-002, 4.00109217e-002,
-       -4.38148119e-002, 1.52237415e-002, 6.56550899e-002,
-       4.71683666e-002, -8.85919854e-003, 9.33935717e-002,
-       2.22988218e-001, 3.09971601e-001, 1.90344289e-001,
-       -3.63429263e-002, 2.73177117e-001, 3.95235986e-001,
-       6.54967949e-002, -9.70427133e-003, 7.72961974e-002,
-       5.87210916e-002, 2.08443758e-004, 3.13077099e-003,
-       6.43938966e-003, 8.09351634e-003, 1.42409594e-003,
-       7.00284764e-002, 4.44484241e-002, 9.26235169e-002,
-       1.75023638e-002, 7.85790533e-002, 4.36227582e-002,
-       1.02633432e-001, 2.06024852e-003, 4.34791343e-003,
-       6.75012683e-003, 9.68222041e-003, -4.21689451e-003,
-       8.14601517e-005, 9.51836072e-003, 4.77901706e-003,
-       -2.07972601e-002, -3.18394452e-002, 4.74201068e-002,
-       5.08564375e-002, 2.13155355e-002, -3.70146595e-002,
-       5.02051637e-002, 6.54489845e-002, 5.74798603e-003,
-       2.96185073e-003, 1.68956406e-002, 9.38475598e-003,
-       -5.23452535e-002, -1.57598557e-003, 7.84670413e-002,
-       2.72139572e-002, -2.52419949e-001, -1.12847969e-001,
-       3.26467603e-001, 1.91814139e-001, 7.38653317e-002,
-       -1.64136410e-001, 2.30852738e-001, 2.40789086e-001,
-       1.54696643e-001, -9.49823018e-003, 2.18371123e-001,
-       4.56861295e-002, -5.53572662e-002, -3.00934468e-003,
-       8.30358639e-002, 2.48194262e-002, -2.40097120e-001,
-       6.29165322e-002, 3.32527548e-001, 1.57206148e-001,
-       7.60490000e-002, 1.41736805e-001, 2.13315055e-001,
-       2.11264268e-001, 1.39914721e-001, -1.18910382e-002,
-       2.02473328e-001, 4.24516611e-002, -5.85166272e-003,
-       -9.17680445e-004, 1.08797764e-002, 4.35456540e-003,
-       -1.07469959e-002, 2.94085070e-002, 4.89977188e-002,
-       4.33452241e-002, 7.90528394e-003, 3.04816756e-002,
-       4.12009656e-002, 4.73061427e-002, 8.21258966e-003,
-       1.31089109e-004, 1.77604053e-002, 6.09890791e-003,
-       4.40929987e-004, 8.63185152e-004, 4.32868255e-003,
-       3.59673519e-003, 6.47289259e-003, 2.04943214e-002,
-       3.45489308e-002, 3.44533585e-002, -5.85731026e-003,
-       1.78374946e-002, 4.20204997e-002, 3.29517461e-002,
-       -1.64285884e-003, -2.97739927e-004, 4.90933657e-003,
-       3.42626637e-003, 2.70892847e-002, 6.71734940e-003,
-       4.33158837e-002, 2.86409464e-002, 2.87829433e-002,
-       9.96745974e-002, 2.68039733e-001, 2.08969474e-001,
-       -8.02270100e-002, 1.04598656e-001, 3.82447988e-001,
-       1.95902407e-001, -2.93220319e-002, 3.94464983e-003,
-       4.89282981e-002, 2.49203816e-002, 2.19267346e-002,
-       -1.87307745e-002, 3.86776589e-002, 3.23566496e-002,
-       1.11303162e-002, -2.77801841e-001, 2.32485488e-001,
-       3.12873900e-001, 8.96740481e-002, -8.41004401e-002,
-       4.72381771e-001, 1.85945883e-001, -3.84881049e-002,
-       9.70959489e-004, 5.54731637e-002, 2.42060311e-002,
-       -1.39552314e-004, -6.85706967e-004, 3.69664817e-003,
-       3.38616106e-003, 8.64653569e-003, -8.30835290e-003,
-       2.85062939e-002, 2.59687342e-002, 2.05748174e-002,
-       -2.26104800e-002, 5.69485277e-002, 3.54308486e-002,
-       -3.26153799e-003, -4.26382059e-004, 6.17297553e-003,
-       3.51630221e-003, -2.66103772e-003, -2.73447856e-003,
-       8.44519865e-003, 7.77669437e-003, 2.56656781e-002,
-       -9.58578214e-002, 6.18887581e-002, 1.10472813e-001,
-       6.12745248e-002, -8.45582187e-002, 8.01504329e-002,
-       1.10613957e-001, -2.00882088e-003, 5.57318097e-004,
-       7.99408741e-003, 7.66139477e-003, -4.93056104e-002,
-       -8.46735667e-003, 7.01025724e-002, 3.37550528e-002,
-       -9.76232961e-002, -4.64017317e-002, 2.28782073e-001,
-       1.89945564e-001, 2.91581929e-001, -3.29016238e-001,
-       3.83022696e-001, 4.17531282e-001, 8.15534219e-002,
-       -6.28207177e-002, 1.11728013e-001, 7.99218714e-002,
-       -4.75611463e-002, -9.69609059e-003, 6.73274770e-002,
-       2.97328029e-002, -7.03858137e-002, -1.59801468e-002,
-       1.83945298e-001, 1.29438758e-001, 1.78236980e-002,
-       -2.26621944e-002, 1.79665372e-001, 1.36847496e-001,
-       9.03438181e-002, -3.35118435e-002, 1.10390738e-001,
-       5.10399938e-002, -4.10820264e-003, -2.98971543e-004,
-       7.84748234e-003, 4.14658571e-003, -9.97419003e-003,
-       1.13066817e-002, 2.77292766e-002, 2.50284132e-002,
-       8.93906632e-004, 1.14214281e-002, 2.47567203e-002,
-       2.47559734e-002, 7.02301040e-003, -4.26557061e-004,
-       1.07785240e-002, 4.83565265e-003, 8.07376346e-004,
-       -1.28706262e-004, 2.72284169e-003, 2.23531737e-003,
-       -7.39711220e-004, 2.02148710e-003, 1.28067341e-002,
-       1.24500906e-002, -1.66548155e-002, 4.29033581e-003,
-       2.97614262e-002, 1.70716289e-002, -2.28544101e-002,
-       -2.10601254e-003, 3.63247767e-002, 5.66788530e-003,
-       9.80014540e-003, 5.43274859e-004, 2.41594594e-002,
-       1.47911794e-002, 4.22519166e-004, 6.75543910e-003,
-       7.71960020e-002, 8.08040649e-002, -1.09644517e-001,
-       8.69427901e-003, 1.96708247e-001, 9.86399874e-002,
-       -1.86484277e-001, -4.89060581e-003, 2.87452281e-001,
-       2.74215229e-002, 1.22703072e-002, -3.14368382e-002,
-       2.92209908e-002, 4.52133715e-002, -1.54442638e-002,
-       -2.20148504e-001, 1.02646276e-001, 2.90767848e-001,
-       -1.34273693e-001, -2.64837623e-001, 2.34487623e-001,
-       3.28854084e-001, -1.67840287e-001, -1.21563040e-002,
-       2.64842927e-001, 4.59406450e-002, 1.19692704e-004,
-       -2.59645693e-002, 5.15031395e-003, 3.48444544e-002,
-       -2.83613522e-003, -1.93632752e-001, 2.58913320e-002,
-       2.50933588e-001, -5.93553437e-003, -1.75830483e-001,
-       3.71600315e-002, 2.26495385e-001, -6.74186414e-003,
-       -1.36888912e-002, 1.72063559e-002, 1.97356809e-002,
-       -1.00606913e-002, 1.47593697e-003, 1.41065298e-002,
-       3.79524427e-003, -1.06660295e-002, -5.94102638e-003,
-       3.27260941e-002, 1.97261348e-002, 9.54669341e-003,
-       -5.11965202e-003, 3.25875133e-002, 1.92207415e-002,
-       1.95254702e-002, 2.65741558e-003, 2.57893801e-002,
-       5.36316214e-003, -8.72490928e-002, 8.97634309e-003,
-       1.09697692e-001, 2.70425994e-002, -1.01479873e-001,
-       6.32993353e-004, 2.03746185e-001, 1.05412938e-001,
-       1.09129392e-001, 1.41416164e-002, 2.26249352e-001,
-       1.05069391e-001, 1.73130661e-001, 1.69854984e-002,
-       2.20244527e-001, 3.31395678e-002, -7.26372823e-002,
-       2.53679249e-002, 9.79285017e-002, 3.85388955e-002,
-       -1.44449458e-001, 2.59159476e-001, 2.45576486e-001,
-       3.08315903e-001, 1.71967775e-001, 2.58980542e-001,
-       2.74206191e-001, 3.09301674e-001, 1.40433967e-001,
-       1.26541313e-002, 1.89406186e-001, 4.13673259e-002,
-       -1.73848367e-003, 1.79615000e-003, 9.24829114e-003,
-       6.15360821e-003, -1.37112280e-002, 4.91004772e-002,
-       4.35283817e-002, 7.45901167e-002, 1.49363996e-002,
-       4.40160073e-002, 4.67681848e-002, 7.68262595e-002,
-       5.65097947e-003, -1.50164019e-003, 1.46066351e-002,
-       7.17638340e-003, -2.58789794e-003, 4.97759902e-005,
-       1.03954198e-002, 6.35587890e-003, -3.29220737e-003,
-       -7.85741359e-002, 6.69632256e-002, 1.01915762e-001,
-       9.83012840e-004, -9.02397782e-002, 4.59129997e-002,
-       1.20324314e-001, -1.18839927e-003, -7.98943546e-003,
-       6.52735308e-003, 1.38541292e-002, -1.21964693e-001,
-       -1.91310961e-002, 1.50258482e-001, 4.09639217e-002,
-       -8.62667784e-002, -2.59082735e-001, 4.26688522e-001,
-       3.33745748e-001, 3.23320292e-002, -1.73413783e-001,
-       1.72175303e-001, 3.15947086e-001, 1.59674957e-002,
-       -2.90793963e-002, 3.26542631e-002, 5.04920818e-002,
-       -1.64151981e-001, -2.32534334e-002, 1.83525324e-001,
-       3.80881019e-002, -6.05667755e-003, -3.06502115e-002,
-       2.95429349e-001, 1.48555651e-001, 4.40459251e-002,
-       -7.45010227e-002, 1.39359951e-001, 1.62214309e-001,
-       1.40695982e-002, -6.44925516e-003, 2.70182248e-002,
-       2.60434020e-002, -1.75874904e-002, -2.10459391e-003,
-       2.06520874e-002, 5.55473054e-003, -4.60935244e-003,
-       1.21763637e-002, 3.12872529e-002, 2.89448537e-002,
-       8.74072686e-003, 1.01558324e-002, 2.17585918e-002,
-       2.76143309e-002, 1.26826693e-003, 4.03747836e-004,
-       3.52936680e-003, 3.98725690e-003, -1.40487647e-003,
-       -4.70062601e-004, 7.09893228e-003, 4.83637024e-003,
-       7.07132090e-003, -2.14580819e-002, 6.44712299e-002,
-       3.91413420e-002, -2.01233160e-002, -2.53715962e-002,
-       6.22829571e-002, 3.81993018e-002, 1.24279466e-002,
-       1.60242047e-003, 1.54813603e-002, 4.75471932e-003,
-       -3.60027105e-002, -1.27295097e-002, 5.71787022e-002,
-       3.04605253e-002, 7.41299093e-002, -1.43613935e-001,
-       3.78137767e-001, 2.09294632e-001, -3.05251721e-002,
-       -4.34724800e-002, 4.12132442e-001, 1.57798439e-001,
-       1.13735132e-001, 1.53466212e-002, 1.33593336e-001,
-       3.11819185e-002, -3.45930867e-002, 7.80994596e-004,
-       5.17473035e-002, 2.51920931e-002, -2.20567938e-002,
-       3.65156084e-002, 2.34460250e-001, 1.49632514e-001,
-       2.38319546e-001, 8.16858709e-002, 4.15595740e-001,
-       1.76217228e-001, 7.09212944e-002, 8.30716360e-003,
-       9.95021760e-002, 3.13518122e-002, -2.56474363e-003,
-       3.89747409e-004, 6.81069912e-003, 4.49976651e-003,
-       -6.32025208e-003, 1.86515376e-002, 3.92984636e-002,
-       3.25152501e-002, 4.55881245e-002, 2.04939116e-002,
-       6.84917271e-002, 3.88184972e-002, 2.85918801e-003,
-       -2.36043753e-003, 9.37944558e-003, 5.53436810e-003,
-       -3.55755292e-005, 5.10710012e-003, 5.08267386e-003,
-       9.32455808e-003, -5.05786529e-003, 6.15353212e-002,
-       3.08603905e-002, 8.28966573e-002, -1.65740482e-003,
-       5.11609167e-002, 3.34313139e-002, 7.39110559e-002,
-       -1.72284420e-003, 3.98638705e-003, 5.29703870e-003,
-       7.95115810e-003, 3.21455263e-002, 6.80003921e-003,
-       4.87990491e-002, 3.88132371e-002, -2.02715248e-001,
-       6.50348887e-002, 3.39801699e-001, 2.56454825e-001,
-       1.34349853e-001, 9.63571817e-002, 3.47312629e-001,
-       2.60587484e-001, -5.96851371e-002, 1.18733232e-003,
-       7.63539225e-002, 4.51321788e-002, 2.23090239e-002,
-       -1.34472158e-002, 4.25291918e-002, 3.64798121e-002,
-       3.42806019e-002, 8.40516575e-003, 2.71845102e-001,
-       2.70094395e-001, -4.13391329e-002, 8.06378275e-002,
-       3.18724513e-001, 2.91111082e-001, -5.29102162e-002,
-       -4.55141766e-003, 7.52643570e-002, 3.91082540e-002,
-       6.11050520e-004, 7.69450620e-004, 4.78606531e-003,
-       5.93720935e-003, 8.00174195e-003, -2.83922851e-002,
-       3.88161875e-002, 5.37482239e-002, -8.62447266e-003,
-       -3.83470058e-002, 4.28222269e-002, 5.76414242e-002,
-       -2.93091754e-003, 6.99161319e-004, 7.90051185e-003,
-       6.44339062e-003, -3.18439677e-003, 8.43126327e-004,
-       6.35919813e-003, 5.50763076e-003, -9.02521610e-003,
-       -1.93983726e-002, 3.05954162e-002, 3.67300026e-002,
-       6.10128324e-003, -1.43011063e-002, 2.78378911e-002,
-       3.06066573e-002, 2.56129354e-003, -2.04709635e-004,
-       5.81366662e-003, 4.50799009e-003, -4.21293937e-002,
-       1.85967349e-002, 5.96162379e-002, 4.40169647e-002,
-       -1.51291117e-001, 7.60666803e-002, 2.46913582e-001,
-       2.08652258e-001, 5.02438508e-002, -1.81954112e-002,
-       1.60742506e-001, 1.51795745e-001, 4.22467589e-002,
-       1.22240428e-002, 5.40582500e-002, 3.60864215e-002,
-       -4.75319922e-002, 4.91343951e-003, 6.43219501e-002,
-       5.25610521e-002, -1.52119994e-001, 6.56209812e-002,
-       2.87779927e-001, 4.15883988e-001, 1.98886722e-001,
-       2.83940136e-001, 2.69149989e-001, 3.77630889e-001,
-       3.65253501e-002, 4.06953953e-002, 5.33575229e-002,
-       5.42236045e-002, -5.45071962e-004, 2.14188709e-003,
-       6.37035817e-003, 6.48479909e-003, 1.18714571e-003,
-       6.53429776e-002, 4.01938632e-002, 7.90698975e-002,
-       1.29537014e-002, 4.25115004e-002, 3.76559757e-002,
-       6.08736984e-002, -1.19177159e-003, 1.08459397e-004,
-       4.81045293e-003, 5.14263660e-003, -1.10354871e-002,
-       -9.84412269e-004, 1.57803576e-002, 6.45604730e-003,
-       -1.01217600e-002, -3.51575874e-002, 3.45370546e-002,
-       5.00263236e-002, 1.06274849e-002, -2.78948862e-002,
-       4.50723805e-002, 4.11879197e-002, 1.70449950e-002,
-       2.86078453e-003, 3.05599142e-002, 6.74868328e-003,
-       -1.28471062e-001, 8.06444511e-003, 1.56233832e-001,
-       3.74094769e-002, -1.10230640e-001, -7.49247223e-002,
-       2.10462496e-001, 1.50505155e-001, 1.57189399e-001,
-       -6.42924458e-002, 2.99584806e-001, 1.28127933e-001,
-       1.62739262e-001, -4.19129990e-003, 2.59014964e-001,
-       3.27983312e-002, -1.37722522e-001, -8.35986109e-004,
-       1.59479171e-001, 3.46532054e-002, -1.14119403e-001,
-       5.35783209e-002, 2.16460004e-001, 1.71086788e-001,
-       1.73671201e-001, 7.52907246e-002, 2.96701431e-001,
-       1.75314754e-001, 1.53851792e-001, -7.44988490e-003,
-       2.43045896e-001, 4.13947739e-002, -9.45762824e-003,
-       2.62156851e-003, 1.43021680e-002, 1.15444371e-002,
-       4.11565881e-003, 1.15078159e-001, 3.95081528e-002,
-       1.61773831e-001, 3.95926787e-003, 1.05916999e-001,
-       5.45068271e-002, 1.57652989e-001, 8.30027368e-003,
-       -6.58703793e-004, 1.95162445e-002, 1.38711734e-002,
-       -1.67466947e-004, -2.76064547e-003, 4.97301295e-003,
-       6.39693392e-003, -7.37376558e-003, -3.23273726e-002,
-       2.99282931e-002, 4.81397398e-002, -3.74012324e-003,
-       -2.72976737e-002, 2.58423816e-002, 4.07169685e-002,
-       2.31679194e-004, -1.89782155e-003, 3.73486406e-003,
-       4.50597936e-003, -2.97017191e-002, -6.99469913e-003,
-       4.08488698e-002, 4.14547212e-002, -3.52616422e-002,
-       -1.49125621e-001, 1.30143359e-001, 2.04507619e-001,
-       3.61363627e-002, -1.17855482e-001, 1.06558494e-001,
-       1.67518213e-001, 1.57507174e-002, -1.12719117e-002,
-       2.51267813e-002, 2.68110372e-002, -2.97467206e-002,
-       8.03866759e-002, 4.94560562e-002, 8.94883871e-002,
-       -2.58783340e-001, 4.68461752e-001, 3.03278923e-001,
-       5.04119515e-001, -9.01318714e-003, 1.13782525e-001,
-       1.42335698e-001, 1.86370999e-001, 1.77042782e-002,
-       6.90564513e-003, 2.75041796e-002, 2.70981155e-002,
-       2.80046556e-003, -1.18870626e-003, 5.59515785e-003,
-       5.28411474e-003, -5.24791330e-002, 2.57633589e-002,
-       6.51617646e-002, 5.56475259e-002, -3.58009636e-002,
-       5.21230660e-002, 5.16335778e-002, 6.33032992e-002,
-       7.93931861e-007, 3.45006655e-003, 4.94950917e-003,
-       5.67138661e-003, 1.11275376e-003, 1.10485853e-004,
-       8.03402998e-003, 4.29422874e-003, -1.36806667e-002,
-       2.78284904e-002, 7.02145398e-002, 4.25841585e-002,
-       7.88296387e-003, 2.07339581e-002, 5.33555150e-002,
-       3.91722322e-002, -2.93843169e-003, 1.76441704e-003,
-       7.57261179e-003, 5.17795188e-003, 3.13079618e-002,
-       9.65437200e-003, 6.09871037e-002, 2.77836546e-002,
-       -6.31582662e-002, 1.02010995e-001, 4.78460073e-001,
-       1.88287303e-001, 1.71223566e-001, 2.36993268e-001,
-       3.86554241e-001, 2.97252655e-001, -5.94406836e-002,
-       8.76009744e-003, 7.55067617e-002, 3.45307626e-002,
-       3.82441282e-002, 9.33016371e-003, 5.46697378e-002,
-       2.63902768e-002, 5.91133498e-002, -1.73165761e-002,
-       2.47937635e-001, 1.68654472e-001, 3.08601791e-003,
-       -8.97395685e-002, 2.37267867e-001, 2.01918185e-001,
-       -4.79256958e-002, -6.42168010e-003, 6.41158968e-002,
-       3.57386023e-002, 2.63169245e-003, -8.31829326e-004,
-       5.91636170e-003, 4.92899725e-003, 2.52606790e-003,
-       -2.69535985e-002, 3.33897732e-002, 4.20245118e-002,
-       -4.79709217e-003, -2.18368713e-002, 3.67036462e-002,
-       4.47480269e-002, -2.15552538e-003, -3.73141433e-004,
-       6.13019988e-003, 5.24189789e-003, 2.35755419e-004,
-       -1.12131611e-003, 4.90303664e-003, 5.23325009e-003,
-       -1.99312363e-002, -2.92828158e-002, 3.95784974e-002,
-       4.87325452e-002, -2.30289325e-002, -3.90469953e-002,
-       4.18192744e-002, 5.29230498e-002, -2.88001349e-004,
-       -2.90632108e-003, 4.66641551e-003, 5.66992955e-003,
-       -3.86912636e-002, -3.28221358e-002, 5.13542406e-002,
-       5.43496460e-002, -1.41935989e-001, -3.50868165e-001,
-       2.23830804e-001, 4.04724538e-001, 1.03419683e-004,
-       -1.91847876e-001, 1.57640204e-001, 2.51949698e-001,
-       1.81328561e-002, -1.42083773e-002, 3.03394850e-002,
-       3.21078077e-002, -3.69253270e-002, 3.32710482e-002,
-       5.15794381e-002, 5.02343141e-002, -1.99838549e-001,
-       2.64261007e-001, 2.65167862e-001, 3.17457765e-001,
-       3.54596265e-002, 1.08147509e-001, 1.45420253e-001,
-       1.84638947e-001, 1.79306548e-002, 8.52480624e-003,
-       2.93126684e-002, 2.88261864e-002, -2.27550438e-004,
-       -7.22045297e-005, 5.52645419e-003, 5.33826463e-003,
-       -3.45012024e-002, 2.48074960e-002, 4.96455990e-002,
-       4.64658700e-002, -1.12093613e-002, 2.95190699e-002,
-       3.43790650e-002, 4.21592928e-002, 2.04200143e-004,
-       1.52367877e-003, 4.18015523e-003, 4.57701692e-003,
-       4.38495452e-004, -2.86567927e-004, 5.68177085e-003,
-       4.44493257e-003, 3.47664356e-002, 1.68550350e-002,
-       5.18942773e-002, 3.65178064e-002, -5.56516135e-003,
-       2.08427291e-002, 4.46941480e-002, 3.32321823e-002,
-       -5.19445958e-003, -4.89973288e-004, 8.00019596e-003,
-       4.63047018e-003, 3.12016234e-002, 1.15708690e-002,
-       5.11614047e-002, 3.51619534e-002, 1.85953259e-001,
-       1.61021143e-001, 3.14585119e-001, 2.41949782e-001,
-       -1.61177278e-001, -2.50306842e-003, 3.19896758e-001,
-       1.50576323e-001, -5.01120128e-002, -1.00929653e-002,
-       6.63522258e-002, 2.82221697e-002, 2.64293831e-002,
-       -1.40775526e-002, 5.01673631e-002, 3.21521945e-002,
-       1.99655339e-001, -1.43755555e-001, 3.63628924e-001,
-       2.12399751e-001, -2.11582318e-001, -4.08238657e-002,
-       3.81332308e-001, 1.44136816e-001, -4.26723212e-002,
-       -1.36248744e-003, 6.20165952e-002, 2.34546270e-002,
-       7.71336665e-004, 4.86145873e-004, 6.18654350e-003,
-       3.97852529e-003, 3.26697044e-002, -1.97297558e-002,
-       5.48824072e-002, 3.55606079e-002, -2.06194818e-002,
-       -2.10146122e-002, 5.45160770e-002, 3.32980081e-002,
-       -3.73067567e-003, 4.76565358e-004, 7.35110883e-003,
-       3.82991764e-003, 4.12401091e-003, 2.19739657e-002,
-       1.06776701e-002, 3.46820503e-002, -1.55384594e-003,
-       1.89207584e-001, 3.62258703e-002, 3.00134242e-001,
-       2.71800975e-003, 1.85836986e-001, 3.50094773e-002,
-       3.00669372e-001, -4.60883556e-003, 1.47602754e-002,
-       1.52966306e-002, 3.03351581e-002, 8.38526711e-002,
-       -1.27242308e-003, 1.35251626e-001, 6.22728765e-002,
-       4.60779034e-002, 8.07707459e-002, 2.97255427e-001,
-       2.31690690e-001, -4.84810723e-003, 1.07380249e-001,
-       2.13377520e-001, 2.31346801e-001, -1.21020459e-001,
-       3.73563054e-003, 2.01629236e-001, 5.44286184e-002,
-       8.31865966e-002, 2.32443716e-002, 1.27538562e-001,
-       5.13542369e-002, 6.26667067e-002, 1.89372469e-002,
-       2.36343250e-001, 1.43187866e-001, -1.04482248e-001,
-       -5.09870313e-002, 2.21680075e-001, 1.44871607e-001,
-       -1.00097358e-001, -8.74007528e-004, 1.79414645e-001,
-       6.06866851e-002, 6.95256516e-003, -1.29868230e-003,
-       1.07491054e-002, 8.23279470e-003, 5.71512291e-003,
-       -1.59751326e-002, 3.04252636e-002, 4.63597476e-002,
-       -3.53042893e-002, -2.95351297e-002, 5.80053888e-002,
-       5.76200895e-002, -3.42385843e-003, 5.31396479e-004,
-       1.44946426e-002, 7.92821590e-003, -1.09873514e-003,
-       5.97195351e-004, 5.55882603e-003, 4.42652125e-003,
-       -2.57614255e-002, -1.60067100e-002, 3.87777463e-002,
-       3.14219147e-002, 1.47659220e-002, -1.65660251e-002,
-       3.36389802e-002, 2.83229966e-002, 4.04711301e-003,
-       1.22568384e-003, 7.00493390e-003, 4.38940851e-003,
-       -2.97235604e-002, -1.29998988e-002, 4.62000072e-002,
-       3.23164165e-002, -1.74545318e-001, -1.02250464e-001,
-       2.21590012e-001, 1.68145105e-001, 2.04567298e-001,
-       -1.21544627e-002, 2.43071571e-001, 1.25259459e-001,
-       4.61350717e-002, 8.18210840e-003, 5.96726649e-002,
-       3.05857155e-002, -3.45850177e-002, 8.08619615e-003,
-       4.75152172e-002, 3.58759202e-002, -1.95346847e-002,
-       2.50254840e-001, 1.92235604e-001, 2.97345251e-001,
-       2.19514325e-001, 3.62594336e-001, 2.59641021e-001,
-       3.92644525e-001, 3.87812667e-002, 2.93730721e-002,
-       5.42786717e-002, 4.50693108e-002, 5.92695316e-004,
-       4.57818341e-003, 6.22288743e-003, 7.73216086e-003,
-       3.23909931e-002, 7.50573948e-002, 4.74709012e-002,
-       8.57307762e-002, 1.27071822e-002, 6.59062862e-002,
-       3.75832506e-002, 7.90285468e-002, -1.44189491e-003,
-       3.14844889e-003, 5.19707473e-003, 6.68036612e-003,
-       -1.57141034e-003, 4.20028623e-003, 8.22775066e-003,
-       1.02095604e-002, -1.55187491e-002, -3.13070305e-002,
-       4.21758927e-002, 1.23698294e-001, -1.21266358e-002,
-       -8.84025469e-002, 5.03463075e-002, 1.48028448e-001,
-       4.61311638e-003, -6.20809093e-004, 1.22915730e-002,
-       9.58980247e-003, -9.39491540e-002, -3.01928781e-002,
-       1.15081131e-001, 5.64177223e-002, -1.71791837e-001,
-       -2.40671918e-001, 2.59548545e-001, 4.14805204e-001,
-       1.29000515e-001, -8.98676515e-002, 3.09890151e-001,
-       2.26958424e-001, 8.87085125e-002, -4.98942053e-003,
-       1.42437577e-001, 2.98285708e-002, -1.02239624e-001,
-       -8.47627409e-003, 1.19604088e-001, 2.57657338e-002,
-       -9.98179838e-002, -8.26956797e-003, 1.72935784e-001,
-       1.06125116e-001, 1.44359574e-001, -2.26313225e-003,
-       3.06711584e-001, 9.69486386e-002, 8.29439759e-002,
-       -6.23033801e-003, 1.40221044e-001, 2.24852022e-002,
-       -1.19965319e-002, -1.34888920e-003, 1.46460570e-002,
-       3.54949269e-003, -1.26480237e-002, 3.15028336e-003,
-       2.72203442e-002, 1.81745142e-002, 2.35456992e-002,
-       6.69004442e-003, 4.76993881e-002, 1.97165776e-002,
-       7.94531498e-003, -7.66413577e-004, 1.66391693e-002,
-       3.53784231e-003, 6.82530878e-003, 1.03434734e-003,
-       1.39330309e-002, 5.79186296e-003, -5.54630952e-003,
-       4.05632406e-002, 4.07154784e-002, 5.80740944e-002,
-       -3.02880863e-003, 4.27104831e-002, 2.54242029e-002,
-       6.03710897e-002, -1.22413051e-003, 3.42475437e-003,
-       4.37929342e-003, 7.12590665e-003, 8.51948187e-002,
-       -4.31965018e-004, 1.22381017e-001, 2.86346860e-002,
-       -2.12142784e-002, 3.92712429e-002, 2.56528705e-001,
-       1.50100365e-001, -4.58248006e-003, 5.08891754e-002,
-       1.32059306e-001, 1.52845010e-001, -2.42711324e-002,
-       7.19027128e-003, 3.43283378e-002, 2.79190037e-002,
-       7.43860528e-002, -2.57766470e-002, 1.07575856e-001,
-       4.52060662e-002, -1.31645752e-002, -3.56982261e-001,
-       2.34234229e-001, 3.96898985e-001, -1.50428591e-002,
-       -3.55777055e-001, 1.37652472e-001, 4.07687962e-001,
-       -1.78802740e-002, -4.58789654e-002, 3.25259604e-002,
-       5.75699173e-002, 1.38864131e-003, -3.80337262e-003,
-       6.78821001e-003, 8.18398967e-003, -5.47176134e-003,
-       -4.44288962e-002, 2.81892642e-002, 7.55864605e-002,
-       -9.51335067e-004, -3.88935208e-002, 2.04928741e-002,
-       7.32018054e-002, 8.99519306e-004, -4.71257837e-003,
-       3.71234585e-003, 9.74879600e-003, -1.75506540e-003,
-       -1.28522282e-003, 4.91556851e-003, 3.52824526e-003,
-       7.05349967e-002, 3.29220444e-002, 7.87264705e-002,
-       4.38657887e-002, 1.90762896e-002, 2.61330158e-002,
-       4.30946350e-002, 3.21095623e-002, -7.00387778e-003,
-       -1.27705385e-003, 9.53568798e-003, 4.05106088e-003,
-       2.73340456e-002, 2.95335352e-002, 4.90822345e-002,
-       4.12933007e-002, 4.24751043e-001, 2.86798120e-001,
-       4.43411797e-001, 3.02740872e-001, -7.25919604e-002,
-       1.78670026e-002, 1.72884822e-001, 9.62215662e-002,
-       -8.39383155e-002, -2.18592696e-002, 9.67164040e-002,
-       3.72344293e-002, 6.52155876e-002, 3.33060957e-002,
-       7.25034922e-002, 4.25110124e-002, 1.46655500e-001,
-       3.27944607e-002, 1.97993636e-001, 1.15368351e-001,
-       -2.15420216e-001, -9.73495767e-002, 2.63130128e-001,
-       1.40317589e-001, -6.54810965e-002, -1.34103717e-002,
-       8.66524279e-002, 3.48677784e-002, 6.00937987e-003,
-       1.90679915e-003, 7.66300783e-003, 4.58923494e-003,
-       3.60630895e-003, -1.40028466e-002, 2.52983011e-002,
-       2.32861321e-002, -4.57913205e-002, -2.64918413e-002,
-       5.61321974e-002, 3.44764069e-002, -2.52895360e-003,
-       8.90430470e-004, 8.04523565e-003, 3.68688628e-003,
-       -1.18846598e-003, 7.99353409e-004, 4.83294809e-003,
-       4.96930582e-003, 2.00237427e-002, 1.69494040e-002,
-       3.86182815e-002, 4.11371104e-002, 2.18218993e-002,
-       3.62040810e-002, 5.59835918e-002, 4.95300367e-002,
-       -4.34442842e-003, 1.10889366e-003, 8.33642483e-003,
-       5.14015788e-003, 2.88601462e-002, 3.66192125e-002,
-       4.58639599e-002, 5.05718999e-002, 6.42118677e-002,
-       3.57253253e-001, 2.54736453e-001, 4.07183141e-001,
-       3.98161747e-002, 7.71493465e-002, 3.37335080e-001,
-       2.19471738e-001, -6.26375601e-002, 1.09719171e-003,
-       7.98693076e-002, 3.29901874e-002, 3.47709209e-002,
-       -1.28563233e-002, 4.77203578e-002, 3.92255038e-002,
-       5.39819971e-002, -1.41661853e-001, 2.20112309e-001,
-       2.57159472e-001, -1.03395090e-001, -4.17406037e-002,
-       2.67610788e-001, 2.16380492e-001, -5.21981679e-002,
-       -4.60925017e-004, 7.21877813e-002, 3.33640352e-002,
-       4.67540201e-004, -1.11774495e-003, 4.75865556e-003,
-       5.30679012e-003, 1.14600165e-002, -2.94248387e-002,
-       3.60229164e-002, 4.78747934e-002, -6.82003389e-004,
-       -3.13998312e-002, 4.07956354e-002, 4.88276929e-002,
-       -3.30374762e-003, -1.85139099e-004, 7.33554922e-003,
-       5.25376434e-003, -5.81218861e-003, 9.75246658e-004,
-       1.01421373e-002, 5.11880498e-003, -1.28789591e-002,
-       -2.83942539e-002, 4.90979254e-002, 4.45175543e-002,
-       4.71973792e-002, -2.57508028e-002, 6.32508174e-002,
-       4.82745208e-002, -2.11554521e-004, 1.62806269e-003,
-       6.84130844e-003, 5.86893409e-003, -7.74707347e-002,
-       -7.98721705e-003, 9.77109745e-002, 3.38832028e-002,
-       -1.08144030e-001, -5.41070998e-002, 2.61021048e-001,
-       1.81937248e-001, 3.73302042e-001, -8.02939683e-002,
-       4.18802351e-001, 2.52882987e-001, 1.35148000e-002,
-       -2.65567712e-002, 5.14435470e-002, 5.13185970e-002,
-       -7.06844479e-002, -2.06210068e-003, 9.14429501e-002,
-       3.67633402e-002, -8.29557702e-002, 7.89183453e-002,
-       2.50843763e-001, 1.95483714e-001, 1.22827910e-001,
-       -6.95280358e-002, 2.44634405e-001, 2.93703943e-001,
-       3.88750881e-002, -2.06481796e-002, 6.04290627e-002,
-       5.33067547e-002, -4.61877696e-003, -4.43718862e-004,
-       9.71618667e-003, 5.42296842e-003, -9.68726072e-003,
-       2.26987451e-002, 4.34261486e-002, 4.26580347e-002,
-       7.39494618e-003, 2.83192787e-002, 3.94290797e-002,
-       4.79013622e-002, 2.44041975e-003, 3.87525244e-004,
-       7.30041414e-003, 6.76704617e-003, 2.59537424e-004,
-       2.23179493e-004, 5.96635323e-003, 4.21040319e-003,
-       5.21342969e-003, 2.88310498e-002, 4.74737026e-002,
-       4.21811007e-002, -2.56644078e-002, 1.57976784e-002,
-       4.46873941e-002, 3.93889844e-002, 5.52937796e-004,
-       -4.00160759e-004, 4.58477251e-003, 4.38915752e-003,
-       3.19865756e-002, 1.11644557e-002, 5.43653518e-002,
-       3.11369970e-002, 1.15580268e-001, 1.15404345e-001,
-       3.21548373e-001, 2.15470865e-001, -1.42044365e-001,
-       2.69356728e-001, 2.79873848e-001, 3.42517227e-001,
-       -3.29614617e-002, 3.12037151e-002, 4.93345596e-002,
-       4.54210714e-002, 4.85995859e-002, 4.13225638e-003,
-       6.40919134e-002, 2.91910172e-002, -6.48553669e-002,
-       -9.65381116e-002, 3.42018336e-001, 1.97833225e-001,
-       8.97923708e-002, -1.74389765e-001, 2.82666445e-001,
-       2.47004583e-001, -4.70224097e-002, -3.44106671e-003,
-       5.74761108e-002, 3.66617851e-002, 3.64125497e-003,
-       -2.70855468e-004, 7.10882619e-003, 4.83868411e-003,
-       -1.80798303e-002, -2.11880114e-002, 4.98473868e-002,
-       3.82026024e-002, 5.09530585e-003, -2.22715586e-002,
-       4.01552916e-002, 4.04942259e-002, -1.43909384e-003,
-       -1.47559913e-003, 5.71476715e-003, 5.10754623e-003,
-       -1.25507731e-003, 7.45190599e-004, 3.80149996e-003,
-       6.20600069e-003, 2.23698583e-003, 9.55703668e-003,
-       2.00041011e-002, 4.76151779e-002, 6.87249564e-003,
-       1.36524597e-002, 2.50700396e-002, 5.24508134e-002,
-       5.96610538e-004, 9.98592819e-004, 3.96254798e-003,
-       7.30070472e-003, 1.53599475e-002, 3.26453522e-002,
-       4.03602123e-002, 4.97906767e-002, 2.25695241e-002,
-       2.63898641e-001, 1.98550463e-001, 4.05049324e-001,
-       3.39142792e-002, 2.14805171e-001, 2.12186068e-001,
-       3.57633471e-001, -1.92655642e-002, 2.59528924e-002,
-       4.06120084e-002, 4.64949124e-002, 2.40897946e-002,
-       -1.82363123e-003, 4.43658940e-002, 2.95874625e-002,
-       -1.38830274e-001, -7.77805448e-002, 2.95958340e-001,
-       2.00628087e-001, 1.49220183e-001, -7.43938684e-002,
-       3.14405799e-001, 2.03001276e-001, -2.30113436e-002,
-       -4.62680298e-004, 4.62450236e-002, 3.18192691e-002,
-       9.87501349e-004, -1.82841846e-003, 5.06597944e-003,
-       6.02001185e-003, -1.00515326e-002, -1.95616111e-002,
-       3.92911024e-002, 4.90281209e-002, 1.71848312e-002,
-       -1.46692079e-002, 4.33679707e-002, 4.35384847e-002,
-       -9.92864370e-004, -9.45454871e-004, 5.05618937e-003,
-       4.45330096e-003, -1.89455482e-003, 1.01924664e-003,
-       5.47396298e-003, 5.50725264e-003, 2.64821835e-002,
-       3.85355279e-002, 4.61248159e-002, 5.40403724e-002,
-       -1.42985666e-002, 4.80444767e-002, 4.92304750e-002,
-       5.84372580e-002, -1.32342754e-003, -5.09445526e-005,
-       5.55007067e-003, 4.53268690e-003, 2.24945992e-002,
-       5.20680174e-002, 4.49400842e-002, 6.15933724e-002,
-       1.83242396e-001, 3.33588064e-001, 2.55692869e-001,
-       3.69943500e-001, -3.19953680e-001, 1.76736638e-001,
-       3.82789373e-001, 2.46170148e-001, -3.26596536e-002,
-       2.07271315e-002, 5.34179248e-002, 3.90191153e-002,
-       2.72653159e-002, 1.10321585e-002, 3.85627560e-002,
-       3.02170645e-002, 1.54554127e-002, -3.19822542e-002,
-       1.32366344e-001, 1.18247107e-001, -1.71698660e-001,
-       3.39517854e-002, 2.27179140e-001, 1.50341451e-001,
-       -4.71530296e-002, 3.01904995e-002, 6.06380068e-002,
-       4.44921255e-002, 9.07500449e-004, -4.87761019e-004,
-       3.89302662e-003, 3.77065153e-003, 2.17351771e-004,
-       -1.71029847e-002, 2.44812313e-002, 2.89724488e-002,
-       -1.11505417e-002, -1.65190008e-002, 2.83724628e-002,
-       2.99262200e-002, -3.63530195e-003, 8.17559601e-004,
-       6.07362483e-003, 4.72348463e-003, 1.28928141e-003,
-       1.68928283e-003, 4.57329350e-003, 4.24538134e-003,
-       -6.21611904e-003, 2.96066776e-002, 2.98969708e-002,
-       3.98681909e-002, -9.09856986e-003, 1.90154910e-002,
-       2.81123873e-002, 3.44849564e-002, -1.36532399e-004,
-       -1.98796552e-005, 3.91056109e-003, 3.77199799e-003,
-       2.99714282e-002, 4.61167097e-003, 4.25469130e-002,
-       2.19153557e-002, -1.56840719e-002, 4.31664772e-002,
-       1.94492772e-001, 1.80637419e-001, -5.18362932e-002,
-       2.24506557e-001, 3.65046412e-001, 2.84855336e-001,
-       -1.77851319e-002, 7.24218925e-003, 4.08620723e-002,
-       2.75726318e-002, 2.38238405e-002, -4.43117553e-003,
-       3.73514108e-002, 1.57569014e-002, 2.44181827e-002,
-       -5.06319478e-002, 1.74055710e-001, 1.23973772e-001,
-       3.53487730e-002, -4.94569130e-002, 6.35212183e-001,
-       1.92047298e-001, -2.49191094e-002, -2.97400169e-003,
-       4.92371209e-002, 2.44353879e-002, 1.88710692e-003,
-       -6.76598749e-004, 4.21818998e-003, 2.53437692e-003,
-       4.74869693e-003, -8.27151816e-003, 3.02943029e-002,
-       2.29838770e-002, -6.13266893e-004, -1.77254025e-002,
-       6.86361045e-002, 3.30270194e-002, -2.48508411e-003,
-       1.00771256e-003, 6.28326880e-003, 3.26665910e-003,
-       1.22059675e-004, 1.60762365e-003, 4.15758369e-003,
-       4.02511004e-003, 3.76585987e-003, 1.82261206e-002,
-       2.81589068e-002, 3.88235375e-002, -1.18863616e-004,
-       1.88206378e-002, 2.54783910e-002, 3.93809602e-002,
-       -5.67283307e-004, 1.25314947e-003, 3.84614454e-003,
-       4.29040054e-003, 1.94719080e-002, 5.13669383e-003,
-       4.70000058e-002, 3.07252258e-002, 5.14155440e-002,
-       1.74109742e-001, 2.75019288e-001, 2.82859087e-001,
-       -7.13021606e-002, 1.15653805e-001, 2.09029436e-001,
-       2.50683725e-001, -1.83513481e-002, 1.20600592e-003,
-       3.80684286e-002, 2.99978070e-002, 1.20677315e-002,
-       -3.52918729e-003, 4.85132411e-002, 2.57918667e-002,
-       2.22692922e-001, 1.69695914e-002, 4.28202957e-001,
-       1.91352293e-001, -2.81486988e-001, 2.08524112e-002,
-       3.55084360e-001, 1.84717759e-001, -7.94254895e-003,
-       -4.57191700e-003, 3.73882316e-002, 2.62823198e-002,
-       8.92978103e-004, 1.01834338e-003, 5.99345192e-003,
-       3.60697345e-003, 2.75109336e-002, -1.38299521e-002,
-       5.55288382e-002, 3.46056223e-002, -3.27798612e-002,
-       -1.05290618e-002, 4.88850251e-002, 3.23556140e-002,
-       -6.91882509e-004, 1.13581878e-003, 5.02510834e-003,
-       3.96001991e-003, 5.69914794e-003, 3.29310680e-003,
-       1.81126185e-002, 9.73004103e-003, -1.12414937e-002,
-       9.21124890e-002, 8.40357319e-002, 1.30033344e-001,
-       -2.94073503e-002, 1.64824203e-001, 6.36400655e-002,
-       2.25799844e-001, 4.73630056e-003, 1.56012084e-002,
-       1.13203768e-002, 2.15071701e-002, 1.17525138e-001,
-       8.08434933e-003, 2.02134818e-001, 4.13118936e-002,
-       1.68788165e-001, 9.13315117e-002, 3.75461936e-001,
-       1.72906205e-001, -1.00016080e-001, 1.06002994e-001,
-       3.24096680e-001, 2.33727187e-001, -1.65826976e-002,
-       1.36557287e-002, 5.35124615e-002, 3.22562046e-002,
-       1.46939114e-001, 1.71321966e-002, 2.09726676e-001,
-       3.74439880e-002, 9.64741558e-002, 1.32861119e-002,
-       2.49447271e-001, 1.00834787e-001, -1.43856421e-001,
-       -6.24281913e-002, 2.76076138e-001, 1.47826791e-001,
-       -2.64277123e-002, -2.13274565e-002, 5.34056611e-002,
-       4.43135574e-002, 1.55768525e-002, 3.06056114e-003,
-       2.22637877e-002, 5.95938088e-003, 4.52638138e-003,
-       -1.10237561e-002, 3.92321348e-002, 1.92736015e-002,
-       -3.02263685e-002, -1.60094090e-002, 4.79190312e-002,
-       3.55118215e-002, -7.05461658e-004, 4.46509710e-003,
-       6.27193833e-003, 1.12766903e-002, -4.39052819e-004,
-       6.70581998e-004, 5.84284635e-003, 3.22286831e-003,
-       -4.57185544e-002, -1.77277215e-002, 5.57319634e-002,
-       3.38994674e-002, 1.69988889e-002, -2.27995273e-002,
-       6.38282821e-002, 3.77635062e-002, 5.06386999e-003,
-       8.64604488e-004, 1.08921295e-002, 3.88158625e-003,
-       -2.52955817e-002, -1.14465309e-002, 5.09220064e-002,
-       2.24490277e-002, -2.53754228e-001, -7.95726404e-002,
-       3.21508855e-001, 1.70892626e-001, 5.61222211e-002,
-       -5.31281717e-002, 4.82954919e-001, 1.59555227e-001,
-       7.09870830e-002, -7.79745728e-003, 1.04557954e-001,
-       2.76902560e-002, -4.01923917e-002, -5.37408330e-003,
-       5.71514890e-002, 1.94807537e-002, -1.25349939e-001,
-       1.86355822e-002, 2.49871448e-001, 1.14773087e-001,
-       -5.94334491e-002, 2.77761407e-002, 4.59074318e-001,
-       1.17735602e-001, 8.59525874e-002, -7.77719356e-003,
-       1.15392476e-001, 2.87632272e-002, -4.49562212e-003,
-       -5.63683570e-004, 7.15726847e-003, 2.72315345e-003,
-       -1.52084334e-002, 9.83578432e-003, 3.79725583e-002,
-       2.18787976e-002, -7.45067419e-003, 1.24744168e-002,
-       5.60605377e-002, 2.39783023e-002, 9.23642423e-003,
-       -6.98259566e-004, 1.36937797e-002, 3.90645908e-003,
-       -7.77245779e-003, 2.08907435e-003, 1.12393023e-002,
-       4.94476920e-003, -1.66881476e-002, -1.39204003e-002,
-       5.08930273e-002, 3.50964181e-002, 1.03630302e-002,
-       -2.20317133e-002, 5.05632609e-002, 4.50082906e-002,
-       1.18324882e-003, 2.55386316e-004, 7.44419359e-003,
-       5.25524514e-003, -7.27737173e-002, 1.03610884e-002,
-       9.20159370e-002, 3.24739926e-002, -1.72712758e-001,
-       5.02074808e-002, 3.02426636e-001, 1.92412049e-001,
-       3.48184071e-002, 6.34253100e-002, 3.03254366e-001,
-       2.66115338e-001, 2.92054433e-002, 1.10223191e-003,
-       5.73338047e-002, 4.05868292e-002, -6.29234388e-002,
-       1.12263095e-002, 8.14971477e-002, 3.36680226e-002,
-       -1.89794540e-001, 1.28527358e-001, 3.18985492e-001,
-       2.71201640e-001, 5.08871675e-002, 1.54181153e-001,
-       2.43487909e-001, 3.44089210e-001, 2.34066714e-002,
-       1.84095930e-002, 5.14427200e-002, 4.99376468e-002,
-       -4.08498570e-003, 6.98811549e-004, 7.75707606e-003,
-       5.11439145e-003, -1.83952437e-003, 5.44626378e-002,
-       4.82029803e-002, 7.32534751e-002, 6.65971497e-003,
-       6.38282076e-002, 4.16138321e-002, 8.69351253e-002,
-       -1.61601650e-003, 4.86592622e-003, 6.62171328e-003,
-       9.13642161e-003, 4.71095741e-003, -1.15975272e-003,
-       9.51271504e-003, 3.57039319e-003, 1.39031131e-002,
-       1.39646865e-002, 5.13232648e-002, 2.51749977e-002,
-       -1.88226774e-002, 1.17449723e-002, 3.27024125e-002,
-       2.51939148e-002, -3.18952138e-003, -1.71043284e-005,
-       5.79566695e-003, 3.46143241e-003, 4.70647067e-002,
-       -6.60236971e-003, 7.59898499e-002, 2.23067384e-002,
-       1.20817497e-001, 2.72582322e-002, 4.06054109e-001,
-       1.25434905e-001, -1.28722757e-001, 2.97370274e-002,
-       2.03950241e-001, 1.26980647e-001, -3.29234339e-002,
-       4.65246942e-003, 4.53648344e-002, 2.37580910e-002,
-       4.59579788e-002, -9.27980430e-003, 7.36637264e-002,
-       2.69192010e-002, 8.53293166e-002, -1.93924293e-001,
-       5.48409522e-001, 2.50464231e-001, -6.99807927e-002,
-       -1.67458832e-001, 2.03133956e-001, 2.28832498e-001,
-       -3.27250175e-002, -1.48264123e-002, 4.61489856e-002,
-       2.91306321e-002, 2.50193337e-003, -1.07193983e-003,
-       6.50288211e-003, 4.33244929e-003, -1.81976648e-004,
-       -4.86934856e-002, 5.56824803e-002, 6.84103817e-002,
-       -2.10909551e-004, -4.81125750e-002, 3.17766592e-002,
-       7.19514713e-002, -9.48663976e-004, -3.43287387e-003,
-       4.65957914e-003, 6.81364629e-003, -5.00741648e-004,
-       1.43248832e-003, 8.48688278e-003, 3.53894662e-003,
-       -2.46845186e-002, -8.62894405e-004, 5.94778918e-002,
-       3.37854549e-002, 1.63937034e-003, -5.24619082e-003,
-       4.38687988e-002, 3.12263500e-002, -2.97254231e-003,
-       -2.43683637e-004, 6.82324357e-003, 3.98315676e-003,
-       6.14169613e-003, 3.89714981e-003, 6.60829097e-002,
-       2.33679954e-002, -2.64104217e-001, -1.62585033e-003,
-       4.43446100e-001, 1.67372420e-001, -3.75959789e-003,
-       -5.95724694e-002, 2.80353814e-001, 1.64237410e-001,
-       -1.37227410e-002, -1.16472626e-002, 5.06657884e-002,
-       2.52614077e-002, 1.06937892e-003, -1.33038920e-004,
-       6.94163293e-002, 2.24372540e-002, -1.42519623e-001,
-       9.82849449e-002, 3.57942611e-001, 2.04025477e-001,
-       -2.20066741e-001, 6.26464263e-002, 3.47821504e-001,
-       1.79192364e-001, 2.26421538e-003, -2.37939693e-003,
-       4.28808965e-002, 2.44935080e-002, -7.03600002e-004,
-       -9.22648527e-004, 8.08941387e-003, 3.51794390e-003,
-       -1.00610405e-002, -5.18130139e-004, 5.18572070e-002,
-       3.55166905e-002, -3.54895405e-002, 5.80575969e-003,
-       5.38809933e-002, 3.69104072e-002, 2.99434087e-005,
-       9.37770645e-004, 5.01755392e-003, 3.86567577e-003,
-       -1.92401092e-003, 1.61523651e-002, 7.93422759e-003,
-       1.99649744e-002, -2.86322869e-002, 1.50822923e-001,
-       6.05035722e-002, 1.77199394e-001, -1.61833502e-002,
-       1.14031769e-001, 6.79493099e-002, 1.46266684e-001,
-       -5.52987633e-003, 6.98042044e-004, 1.32759782e-002,
-       1.35815740e-002, 5.70966350e-003, 1.64318085e-002,
-       2.43609957e-002, 2.99686920e-002, -2.66293772e-002,
-       1.44048050e-001, 1.43301725e-001, 2.44441450e-001,
-       -2.19009116e-001, 3.23435664e-001, 3.62245411e-001,
-       3.96162540e-001, -1.59629732e-001, 3.47026512e-002,
-       2.08886668e-001, 6.47822618e-002, 5.78400493e-003,
-       -1.56099221e-003, 1.77475065e-002, 1.40359867e-002,
-       9.59723629e-003, -7.65937008e-003, 8.61959681e-002,
-       8.40598270e-002, -6.65547773e-002, 9.44685377e-003,
-       1.78458825e-001, 1.14265636e-001, -1.80084556e-001,
-       3.17367762e-002, 2.25233197e-001, 4.89150323e-002,
-       5.29777142e-004, -3.60576669e-004, 2.30879127e-003,
-       2.28367466e-003, 1.27915898e-003, -5.08071063e-003,
-       1.21255424e-002, 1.44864274e-002, -3.93652078e-003,
-       -3.91001813e-003, 2.15269737e-002, 1.81648713e-002,
-       -1.73137970e-002, 3.21909203e-003, 2.35285442e-002,
-       5.87911950e-003, -2.79317354e-003, -4.57583141e-004,
-       7.07548345e-003, 4.39220248e-003, 4.33313660e-003,
-       -2.34770551e-002, 3.83270346e-002, 3.70580107e-002,
-       3.00595313e-002, -2.80614030e-002, 6.37034923e-002,
-       4.22641151e-002, 5.65851899e-003, 2.26184377e-003,
-       1.10122589e-002, 5.16930316e-003, -4.45525832e-002,
-       -4.21713898e-003, 6.63596690e-002, 2.47258022e-002,
-       6.98553324e-002, -6.81030527e-002, 2.63832688e-001,
-       1.46659955e-001, 1.61318004e-001, -7.21315593e-002,
-       4.90701616e-001, 1.64811537e-001, 8.10271725e-002,
-       -1.33174553e-003, 1.10731266e-001, 2.48649996e-002,
-       -5.07935844e-002, 7.95128755e-004, 7.05482662e-002,
-       2.30821744e-002, 1.32930592e-001, 3.64802554e-002,
-       3.07359427e-001, 1.19167276e-001, 6.05384707e-002,
-       2.36136336e-002, 4.67237651e-001, 1.32293716e-001,
-       9.91441905e-002, -8.36287625e-003, 1.23440214e-001,
-       2.78424360e-002, -4.42914618e-003, -2.18291374e-004,
-       7.95381516e-003, 3.21509200e-003, 1.10977395e-002,
-       1.07077016e-002, 3.95790078e-002, 2.48210691e-002,
-       1.22093949e-002, 8.61310307e-003, 5.81321828e-002,
-       2.70890538e-002, 1.15663139e-002, -1.57680188e-003,
-       1.55390762e-002, 4.44419635e-003, 4.06940271e-005,
-       1.99208572e-003, 9.37540829e-003, 5.48625970e-003,
-       -6.38979152e-002, -3.48853730e-002, 8.18926319e-002,
-       5.91929257e-002, -1.37331793e-002, -3.92141826e-002,
-       4.99641113e-002, 6.08047731e-002, 1.23422984e-002,
-       3.23830289e-003, 2.11483166e-002, 8.72876775e-003,
-       -6.42955452e-002, -2.93162744e-002, 1.01604551e-001,
-       4.57810387e-002, -3.12171280e-001, -2.24990889e-001,
-       4.12157357e-001, 2.81330287e-001, 2.10236255e-002,
-       -3.18571664e-002, 2.03675166e-001, 1.32095084e-001,
-       1.66247338e-001, 3.10270861e-003, 2.33760118e-001,
-       3.94265540e-002, -1.08540811e-001, -1.54320858e-002,
-       1.35823756e-001, 4.14102338e-002, -1.24880902e-001,
-       -1.07525056e-003, 2.74286926e-001, 1.31105348e-001,
-       2.79390384e-002, 7.37826154e-003, 1.79938793e-001,
-       1.04068756e-001, 1.63259432e-001, -8.65376927e-003,
-       2.25626469e-001, 3.93561721e-002, -1.33689810e-002,
-       -1.23138272e-003, 1.79085582e-002, 4.52284236e-003,
-       -1.49320252e-002, 8.90577491e-003, 3.59397791e-002,
-       2.65999790e-002, 7.47720851e-003, 1.04378713e-002,
-       2.99874581e-002, 2.71008816e-002, 1.43444594e-002,
-       -1.82526628e-003, 2.29021944e-002, 6.44995179e-003,
-       -9.67613087e-005, -4.81938041e-004, 4.12259577e-003,
-       5.39779942e-003, -7.22128851e-003, -4.82471520e-003,
-       2.77866554e-002, 4.20214608e-002, 4.94691031e-003,
-       -4.85030934e-003, 4.49558012e-002, 3.84352133e-002,
-       5.35036597e-005, -1.35544338e-004, 5.08618494e-003,
-       3.69189028e-003, -3.32229654e-003, -9.81087214e-004,
-       3.50369625e-002, 5.64893000e-002, -3.68312076e-002,
-       8.51137447e-004, 1.69200897e-001, 4.71046209e-001,
-       3.62989381e-002, -2.33039707e-002, 3.59761149e-001,
-       2.86555678e-001, 1.02888206e-002, 1.21491903e-003,
-       4.62396890e-002, 2.50889566e-002, -5.49650239e-003,
-       -2.45926902e-003, 3.34274769e-002, 3.71960439e-002,
-       -3.04122847e-002, -4.30522859e-002, 1.81689113e-001,
-       2.60080278e-001, 2.97002736e-002, -8.91221873e-003,
-       4.36748832e-001, 1.85659051e-001, 1.27591826e-002,
-       -2.55350769e-003, 4.84493598e-002, 2.42675208e-002,
-       -5.94562385e-004, 3.50929884e-004, 4.69964417e-003,
-       4.58015781e-003, -4.35057795e-003, 7.88353104e-003,
-       3.01268864e-002, 3.48160416e-002, 3.41847329e-003,
-       4.40362515e-003, 5.42431846e-002, 3.10562402e-002,
-       1.08156283e-003, -3.92696267e-004, 6.27076579e-003,
-       3.26515012e-003, 5.66921481e-005, 1.30066974e-003,
-       3.83141614e-003, 4.37377114e-003, 8.25973228e-003,
-       2.61230469e-002, 2.66679209e-002, 3.99358310e-002,
-       -3.62263247e-003, 2.88011245e-002, 2.83258986e-002,
-       4.09652516e-002, -1.90219027e-003, 1.22684822e-003,
-       4.43796162e-003, 4.32462338e-003, 1.98847484e-002,
-       1.12434570e-002, 3.46057788e-002, 3.27889472e-002,
-       9.02206972e-002, 1.41839504e-001, 1.75394699e-001,
-       2.30788097e-001, -1.01057321e-001, 7.57101700e-002,
-       2.03508303e-001, 2.03122497e-001, -3.24133337e-002,
-       -5.02856914e-003, 4.22674082e-002, 3.13711204e-002,
-       2.42219549e-002, -1.71331484e-002, 3.89782339e-002,
-       4.62194122e-002, 1.34621397e-001, -1.40186459e-001,
-       2.19794527e-001, 4.48013544e-001, -2.69726783e-001,
-       -1.56227589e-001, 3.20433050e-001, 3.67640913e-001,
-       -2.12322492e-002, -1.73122101e-002, 3.73820700e-002,
-       3.58768553e-002, -6.54478616e-004, -1.60634855e-003,
-       4.10144450e-003, 5.49678225e-003, 6.24448853e-003,
-       -3.08806691e-002, 2.90776957e-002, 5.27223535e-002,
-       -1.02118943e-002, -2.80743428e-002, 3.17422599e-002,
-       4.87374403e-002, -3.83812207e-004, -2.03971460e-004,
-       3.79695999e-003, 4.20703599e-003, 9.79241682e-004,
-       2.84914230e-003, 4.64756927e-003, 5.52558899e-003,
-       -1.65319780e-003, 4.18981202e-002, 2.98663806e-002,
-       5.41070625e-002, -1.54641028e-002, 2.63760928e-002,
-       3.23166028e-002, 4.50081676e-002, 6.54445263e-004,
-       4.88321180e-004, 4.04462684e-003, 4.66005504e-003,
-       3.80743295e-002, 9.17382725e-003, 4.79715839e-002,
-       3.23547684e-002, 8.91879126e-002, 1.85812220e-001,
-       2.21095309e-001, 2.69712538e-001, -2.06896797e-001,
-       3.07109088e-001, 3.06048363e-001, 3.62228483e-001,
-       -2.07896587e-002, 3.04713864e-002, 4.23092172e-002,
-       4.46449630e-002, 3.40313315e-002, -7.94325955e-003,
-       4.76395749e-002, 3.12249865e-002, 2.03840613e-001,
-       -6.79615587e-002, 2.71566153e-001, 2.11351201e-001,
-       -6.87851086e-002, 4.92598787e-002, 2.53420085e-001,
-       2.38725513e-001, -3.56904566e-002, 2.27505472e-002,
-       5.16679212e-002, 4.40366454e-002, 1.45393598e-003,
-       -4.47923900e-004, 5.21792006e-003, 5.41143725e-003,
-       2.24383101e-002, -3.54746208e-002, 3.93679999e-002,
-       5.50007001e-002, 4.45130607e-003, -4.46897186e-002,
-       3.50439809e-002, 6.22434914e-002, -1.58807798e-003,
-       -1.66055688e-003, 5.61337452e-003, 6.47463743e-003,
-       -2.03082263e-002, 3.69805656e-003, 2.81881001e-002,
-       8.73330329e-003, -1.49118621e-003, -2.91114897e-002,
-       3.94707806e-002, 4.21071947e-002, 2.87185553e-002,
-       -3.51630822e-002, 4.45147902e-002, 5.06336801e-002,
-       6.24638237e-003, 1.00873338e-004, 1.58811100e-002,
-       6.85786596e-003, -2.38207400e-001, 2.38855500e-002,
-       3.16633135e-001, 4.52342480e-002, -6.78703412e-002,
-       -4.34211977e-002, 2.27936894e-001, 1.37411356e-001,
-       1.31687850e-001, -8.76225755e-002, 2.10173175e-001,
-       1.64064437e-001, 1.08756639e-001, -8.87705572e-003,
-       1.63078070e-001, 4.04106639e-002, -2.40746066e-001,
-       1.48500800e-002, 3.35276514e-001, 4.05234843e-002,
-       -1.26043648e-001, 8.08395296e-002, 3.00401062e-001,
-       1.69202670e-001, 8.59429464e-002, 6.24410659e-002,
-       1.85815409e-001, 1.45261794e-001, 1.24018192e-001,
-       -5.09468419e-003, 1.75127178e-001, 3.69037390e-002,
-       -2.21530776e-002, -2.13611801e-003, 3.69731784e-002,
-       8.58099293e-003, -3.09185758e-002, 2.33597513e-002,
-       6.30639568e-002, 4.24166843e-002, 3.99215100e-003,
-       1.61403511e-002, 3.52747180e-002, 3.33691277e-002,
-       1.15464507e-002, -2.29318067e-003, 1.89898573e-002,
-       5.45809092e-003, -1.09349762e-003, 1.92547421e-004,
-       5.07747615e-003, 3.77102778e-003, -1.92132164e-002,
-       -1.30272033e-002, 4.01099436e-002, 3.05344630e-002,
-       -8.56804941e-003, -2.02910695e-002, 4.41863835e-002,
-       3.45082842e-002, 4.77148592e-003, 6.69575064e-004,
-       9.42680426e-003, 4.95748548e-003, -1.86131261e-002,
-       -5.41603053e-003, 3.94998789e-002, 2.72325128e-002,
-       -1.63843870e-001, -6.97195008e-002, 2.62915581e-001,
-       1.85506105e-001, -2.02560741e-002, -1.30273262e-002,
-       3.19598079e-001, 1.95862323e-001, 6.06066473e-002,
-       2.08582617e-002, 8.68404657e-002, 3.95609327e-002,
-       -2.74542123e-002, -1.08068716e-002, 4.44816425e-002,
-       3.27081047e-002, -1.43045977e-001, -8.68205950e-002,
-       2.58705199e-001, 2.41302803e-001, 2.82456994e-001,
-       1.77506223e-001, 4.16479260e-001, 2.94485241e-001,
-       1.83004774e-002, 1.75511185e-002, 6.31242022e-002,
-       3.59751657e-002, -3.11358017e-003, -1.48592939e-004,
-       5.99183841e-003, 4.79491288e-003, 5.79231232e-003,
-       2.97785625e-002, 4.57531810e-002, 4.75684032e-002,
-       4.41647023e-002, 2.67524794e-002, 6.23162463e-002,
-       4.64891791e-002, -1.83489313e-003, -1.32761546e-003,
-       6.14902657e-003, 4.35579941e-003, -5.94246108e-003,
-       2.36318694e-004, 9.32025351e-003, 4.49399697e-003,
-       1.33604361e-002, -1.55792795e-002, 4.17626724e-002,
-       2.99339164e-002, 1.79507248e-002, -9.47551243e-003,
-       4.35472690e-002, 3.17171663e-002, 2.81336950e-003,
-       7.87395518e-004, 6.95409020e-003, 4.78534820e-003,
-       -7.25719780e-002, 1.36409923e-002, 8.70845988e-002,
-       3.44046094e-002, 6.68542534e-002, -3.75049710e-002,
-       2.77206451e-001, 1.49351478e-001, 1.30032420e-001,
-       -9.03392062e-002, 2.68762618e-001, 1.87425762e-001,
-       4.12325002e-002, 6.03705039e-003, 5.71639985e-002,
-       3.34852412e-002, -5.57631850e-002, 2.52005104e-002,
-       8.05010796e-002, 4.26077880e-002, -1.30467042e-001,
-       1.67951718e-001, 3.46082568e-001, 2.56070614e-001,
-       2.65554070e-001, 1.16157897e-001, 4.23641562e-001,
-       2.40377709e-001, 3.05502862e-002, 2.46165022e-002,
-       5.45057580e-002, 4.21090126e-002, -1.59740797e-003,
-       -8.07338278e-004, 8.23051762e-003, 5.17612696e-003,
-       -2.72540413e-002, 3.15245949e-002, 6.03555702e-002,
-       5.17397597e-002, 3.59360985e-002, 2.82335915e-002,
-       6.55857474e-002, 4.79425527e-002, 1.05818594e-003,
-       -1.34517776e-003, 6.90795900e-003, 5.05063403e-003,
-       3.82433855e-003, -3.13678081e-003, 8.56088009e-003,
-       1.11145293e-002, -6.88534528e-002, -6.70302883e-002,
-       9.03044492e-002, 1.04181461e-001, -3.24898399e-002,
-       -6.50608018e-002, 6.08675256e-002, 8.51779729e-002,
-       5.03614370e-004, -4.74074390e-003, 6.33614557e-003,
-       8.30581877e-003, -1.98481940e-002, -6.82903007e-002,
-       4.37250212e-002, 8.72333348e-002, -1.57058999e-001,
-       -3.43262315e-001, 2.37641439e-001, 4.41347122e-001,
-       -1.82775431e-003, -7.91592672e-002, 1.31337121e-001,
-       1.79477289e-001, 1.66959055e-002, -1.10097472e-002,
-       2.94818413e-002, 3.12093347e-002, -8.99937935e-003,
-       4.41092765e-003, 2.71005724e-002, 3.73738334e-002,
-       -1.27989231e-002, 1.56527638e-001, 1.26124114e-001,
-       2.61322170e-001, 4.23391350e-002, 2.18817636e-001,
-       1.16047420e-001, 2.91860014e-001, 1.52235078e-002,
-       3.17245983e-002, 2.99445894e-002, 4.70210686e-002,
-       3.86986975e-003, 1.20170759e-002, 7.57357804e-003,
-       1.73729416e-002, 2.63641477e-002, 1.37513876e-001,
-       5.07775247e-002, 1.76254451e-001, -5.95777808e-003,
-       1.26364186e-001, 4.16421555e-002, 1.63240999e-001,
-       -4.07395745e-003, 9.91008244e-003, 7.08855269e-003,
-       1.70877669e-002, -1.11170923e-002, -5.21705442e-005,
-       1.78142786e-002, 1.10911662e-002, -2.80756243e-002,
-       -1.21523730e-001, 7.11505637e-002, 1.61607161e-001,
-       -2.27243751e-002, -1.15835913e-001, 4.22964953e-002,
-       1.51776031e-001, -1.27945724e-003, -1.08911609e-002,
-       4.67973994e-003, 1.63722709e-002, -1.71199262e-001,
-       5.35608688e-003, 2.04372615e-001, 3.68477106e-002,
-       -3.28139424e-001, -1.04424931e-001, 4.04559374e-001,
-       1.86435297e-001, -2.86052725e-003, -6.11876436e-002,
-       8.77493173e-002, 1.34858981e-001, 6.02519745e-003,
-       -7.88215641e-003, 1.71965845e-002, 2.00764146e-002,
-       -1.86131686e-001, -2.92322622e-003, 2.19693244e-001,
-       2.66374499e-002, -3.08717489e-001, 3.38769965e-002,
-       3.86864036e-001, 1.13347843e-001, -1.23525120e-003,
-       1.20335817e-002, 8.04919899e-002, 7.51661733e-002,
-       3.51150404e-003, 5.93361445e-004, 1.38492770e-002,
-       1.25526851e-002, -2.24219467e-002, -1.49519218e-003,
-       2.83255577e-002, 5.40213659e-003, -4.53717001e-002,
-       1.80986635e-002, 6.24975972e-002, 3.35428864e-002,
-       -4.86023305e-003, 1.49603924e-002, 1.80897396e-002,
-       2.72400808e-002, 2.74706690e-004, 1.30891323e-003,
-       2.17083632e-003, 3.34587903e-003, 1.62541051e-003,
-       -8.51608114e-004, 2.64795101e-003, 3.25452769e-003,
-       -1.60800735e-003, 1.52363395e-002, 1.43066570e-002,
-       2.31050588e-002, -1.09619945e-002, 1.54972775e-002,
-       2.70695593e-002, 2.74317004e-002, -1.86361861e-003,
-       1.12638227e-004, 4.44639567e-003, 5.18121012e-003,
-       2.39312015e-002, -8.56994838e-003, 2.88776569e-002,
-       2.54549906e-002, 4.11925912e-002, -1.67479794e-002,
-       8.71123374e-002, 7.18192160e-002, -2.26621479e-001,
-       -1.72230706e-001, 2.45593518e-001, 2.66873866e-001,
-       -3.71600017e-002, -6.32971600e-002, 5.39278463e-002,
-       8.74221921e-002, 2.74242908e-002, -1.24342572e-002,
-       3.60504836e-002, 4.14114557e-002, 4.19543907e-002,
-       -9.53182578e-002, 1.37453571e-001, 1.83150455e-001,
-       -3.69004577e-001, -1.26253694e-001, 3.96372050e-001,
-       4.71263528e-001, -3.50879952e-002, -3.95747600e-003,
-       5.15815131e-002, 8.09085295e-002, 1.32712675e-003,
-       -6.69844775e-003, 4.72644018e-003, 1.13478480e-002,
-       -1.32245822e-002, -7.97027647e-002, 3.26517336e-002,
-       9.73274633e-002, -4.80537787e-002, -6.13638312e-002,
-       6.04412369e-002, 9.08696279e-002, 1.56564265e-003,
-       -3.26663692e-004, 5.16404957e-003, 6.60289638e-003,
-       1.24615140e-003, -9.45627969e-003, 7.05524720e-003,
-       1.11955618e-002, 1.23606073e-002, -1.14492550e-001,
-       4.01435420e-002, 1.23050898e-001, 8.49128049e-003,
-       -1.05451852e-001, 3.32790837e-002, 1.22101635e-001,
-       -5.07431745e-004, -7.58410711e-003, 5.21358568e-003,
-       1.04261981e-002, -2.84756385e-002, -1.63451321e-002,
-       4.50552590e-002, 3.75863127e-002, 1.96022853e-001,
-       -6.27512112e-002, 3.50889891e-001, 2.49414340e-001,
-       -8.24798569e-002, -1.59383133e-001, 3.50574374e-001,
-       2.56760359e-001, 6.98315278e-002, -1.06088072e-002,
-       8.51998255e-002, 3.31440121e-002, -1.29138837e-002,
-       -1.62390957e-003, 3.62456404e-002, 2.58322097e-002,
-       1.01054206e-001, -2.94539891e-002, 2.97698706e-001,
-       1.92304835e-001, -6.37620986e-002, -2.94753462e-002,
-       3.24267596e-001, 1.76750258e-001, 8.29481035e-002,
-       -3.53454729e-003, 9.61423665e-002, 3.59676071e-002,
-       -6.19188766e-004, 2.97186757e-003, 4.19584243e-003,
-       8.15980136e-003, 8.21798760e-003, 4.08153273e-002,
-       5.00195473e-002, 5.85759915e-002, -1.78319681e-003,
-       3.97550724e-002, 4.40193936e-002, 5.31620719e-002,
-       4.12888220e-003, -4.10497247e-004, 8.04116856e-003,
-       7.35706743e-003, -4.22175450e-004, -1.73599191e-003,
-       5.25541697e-003, 5.64784277e-003, -3.59286019e-003,
-       -5.37836254e-002, 3.72518711e-002, 7.12544546e-002,
-       1.13558369e-002, -3.12631540e-002, 3.39801982e-002,
-       5.68083040e-002, -8.68362433e-004, -2.49871489e-004,
-       4.08930844e-003, 4.75280127e-003, -2.02498846e-002,
-       2.88063660e-003, 4.74503264e-002, 4.09862474e-002,
-       -2.03744158e-001, 1.28458083e-001, 3.06850553e-001,
-       3.84440243e-001, 1.25932872e-001, -1.42566785e-001,
-       2.60690570e-001, 3.26525182e-001, 1.82061363e-002,
-       -2.46601701e-002, 4.71681990e-002, 4.65940386e-002,
-       -2.62444150e-002, -2.60885190e-002, 5.03471680e-002,
-       5.09062074e-002, -9.84249786e-002, -2.05924183e-001,
-       2.45774657e-001, 3.61178935e-001, -1.07422369e-002,
-       -1.09214326e-002, 1.82973027e-001, 1.73585668e-001,
-       2.37655770e-002, -8.62058811e-003, 4.23916765e-002,
-       3.30566727e-002, -2.31377198e-003, -7.94462569e-004,
-       6.09066663e-003, 4.88477387e-003, -8.67428165e-003,
-       8.43588170e-003, 3.22441757e-002, 3.41388471e-002,
-       4.94148722e-003, 7.09931273e-003, 2.79781129e-002,
-       2.96253227e-002, 1.12928229e-003, -1.88575323e-005,
-       4.75444784e-003, 4.28413786e-003, 6.47929916e-003,
-       7.54029863e-003, 1.21878916e-002, 1.05013493e-002,
-       -8.36565159e-003, 1.18670747e-001, 4.44035009e-002,
-       1.37261286e-001, 2.91956356e-003, 1.19618416e-001,
-       3.02474611e-002, 1.44324437e-001, 1.06339471e-003,
-       1.24209719e-002, 5.16832713e-003, 1.72012951e-002,
-       1.07969224e-001, 3.00955074e-003, 1.46908581e-001,
-       4.38648686e-002, 1.69745963e-002, 1.76735595e-001,
-       2.80311167e-001, 3.42543036e-001, 4.80395555e-003,
-       1.43440202e-001, 1.50018573e-001, 3.84488314e-001,
-       -1.49732223e-002, 2.21629925e-002, 3.61146778e-002,
-       6.38522878e-002, 1.03705287e-001, -2.53320765e-003,
-       1.55240387e-001, 3.74434218e-002, 1.81413114e-001,
-       2.38869097e-002, 2.85690099e-001, 2.08606988e-001,
-       -3.54666896e-002, 1.47195876e-001, 1.29157260e-001,
-       2.35372633e-001, -1.30524533e-002, 1.86451245e-002,
-       2.66041458e-002, 3.42372395e-002, 8.94248020e-003,
-       2.05510226e-003, 1.84131227e-002, 6.05363399e-003,
-       3.09058353e-002, -1.75713394e-002, 4.54613566e-002,
-       3.29612270e-002, -1.85871252e-003, -2.39344966e-002,
-       1.80598274e-002, 3.73671278e-002, -1.67032529e-003,
-       -2.87138228e-003, 3.68003338e-003, 6.13166159e-003,
-       -1.05921330e-003, 6.82556629e-003, 3.48771620e-003,
-       1.54898241e-002, -6.53912313e-004, 5.29005155e-002,
-       1.75646041e-002, 1.12349056e-001, 1.11676170e-003,
-       5.18174581e-002, 2.18419433e-002, 1.09552212e-001,
-       -3.24350040e-005, 4.50902432e-003, 6.94114855e-003,
-       1.21021466e-002, 1.04193585e-002, 5.98824844e-002,
-       2.41424628e-002, 6.74528107e-002, 5.93524938e-003,
-       4.22262639e-001, 8.12436566e-002, 4.64091033e-001,
-       -6.59171492e-002, 4.13061559e-001, 1.27198830e-001,
-       4.55871582e-001, -7.69714043e-002, 3.88441458e-002,
-       1.15428425e-001, 5.94496764e-002, 9.00141988e-003,
-       3.24318331e-004, 1.87567435e-002, 1.24475947e-002,
-       -2.71391030e-003, -9.53208935e-003, 5.68696782e-002,
-       6.60915226e-002, -6.54260814e-002, -1.33079169e-002,
-       1.12581410e-001, 8.19441229e-002, -8.35759714e-002,
-       2.67260056e-003, 1.25058964e-001, 2.59428825e-002,
-       4.71337698e-004, -1.02687860e-004, 2.07044743e-003,
-       1.80296134e-003, -1.28492553e-004, -3.71207437e-003,
-       1.05537353e-002, 1.11673707e-002, -1.06104873e-002,
-       -4.02181502e-003, 1.87476464e-002, 1.37650417e-002,
-       -9.02369339e-003, 6.57681143e-004, 1.52333472e-002,
-       3.21788318e-003, 8.87723546e-003, 2.60443557e-002,
-       1.98430177e-002, 4.92201708e-002, 2.83161504e-003,
-       2.49854103e-001, 2.69871261e-002, 4.20721799e-001,
-       1.15932082e-003, 2.54799098e-001, 2.56296862e-002,
-       4.19143796e-001, -4.80889762e-003, 2.80002132e-002,
-       1.80573147e-002, 4.69259284e-002, 1.52728140e-001,
-       1.23088236e-003, 2.66114771e-001, 6.21918552e-002,
-       5.41570969e-002, 7.97681510e-002, 1.55707762e-001,
-       1.66108161e-001, -3.13708149e-002, 6.82326183e-002,
-       7.60037899e-002, 1.30955413e-001, -9.22511369e-002,
-       8.51668604e-003, 1.91049680e-001, 3.25304940e-002,
-       1.36528224e-001, 2.00508963e-002, 2.53582060e-001,
-       5.29112443e-002, 4.51427363e-002, 2.62430636e-003,
-       1.32641762e-001, 7.43263140e-002, -3.16440277e-002,
-       -4.13773162e-003, 8.42526853e-002, 4.92422953e-002,
-       -8.99830312e-002, 2.99831876e-003, 1.81624100e-001,
-       2.06604302e-002, 6.68927841e-003, 3.47726978e-003,
-       1.47515098e-002, 8.65441840e-003, 1.01656355e-002,
-       -3.02586891e-002, 2.85781380e-002, 4.18639444e-002,
-       -9.05011548e-004, -5.95434336e-003, 1.55862123e-002,
-       1.30121950e-002, -8.81208479e-003, 2.54586083e-003,
-       1.80733465e-002, 4.76971548e-003, -8.27358861e-004,
-       2.18377355e-002, 5.13990177e-003, 2.63368096e-002,
-       -7.13481149e-003, 1.88986167e-001, 3.10087949e-002,
-       2.32074484e-001, -1.48925846e-002, 1.86773703e-001,
-       4.19135615e-002, 2.30617404e-001, -8.34476855e-003,
-       1.21585336e-002, 1.59020405e-002, 1.78011302e-002,
-       2.25374326e-002, 7.92513974e-003, 3.71329598e-002,
-       3.48735005e-002, -1.99006926e-002, 4.88522090e-002,
-       1.57278538e-001, 1.88754544e-001, -1.81692347e-001,
-       3.30694877e-002, 3.23339969e-001, 2.27319077e-001,
-       -1.35318249e-001, -8.28538276e-003, 2.23953128e-001,
-       4.42843325e-002, 1.49355158e-002, 4.09893179e-003,
-       3.16452049e-002, 2.36522276e-002, 1.05743324e-002,
-       7.00057251e-003, 1.49406955e-001, 1.12930261e-001,
-       -2.52727747e-001, 2.18888815e-003, 3.74347299e-001,
-       1.78051189e-001, -1.30598947e-001, -3.43654677e-003,
-       2.31296182e-001, 3.60466875e-002, 3.12888093e-004,
-       6.11276264e-005, 4.24777763e-003, 3.10039218e-003,
-       1.47112412e-003, -5.67848887e-003, 2.80046854e-002,
-       2.17481013e-002, -4.79628332e-002, -1.26542328e-002,
-       6.24828227e-002, 3.10126096e-002, -1.44989761e-002,
-       -4.45144455e-004, 2.92590316e-002, 5.60646504e-003,
-       7.78113538e-003, -1.05064071e-003, 1.37602808e-002,
-       4.42181900e-003, 1.82544086e-002, 8.77446774e-003,
-       3.29946019e-002, 2.54361518e-002, 5.04026655e-004,
-       8.09468701e-003, 1.46877980e-002, 2.22629029e-002,
-       -1.47044123e-003, 1.61177959e-004, 2.83315498e-003,
-       2.48481310e-003, 7.29041472e-002, -3.05160973e-003,
-       1.07438043e-001, 3.25134434e-002, 1.09158874e-001,
-       -1.01822838e-001, 1.88579097e-001, 2.03643531e-001,
-       6.38896367e-003, -9.76260155e-002, 9.91083756e-002,
-       1.73943818e-001, -1.25344191e-002, -9.18016396e-003,
-       2.25441270e-002, 2.31056269e-002, 6.89186826e-002,
-       -9.55175702e-003, 9.44803208e-002, 5.71145937e-002,
-       5.01949489e-002, -1.67774782e-001, 1.53527662e-001,
-       5.22301555e-001, 5.07369125e-003, -2.14458227e-001,
-       1.13948815e-001, 4.96716321e-001, -1.01674050e-002,
-       -3.12536843e-002, 2.14390568e-002, 6.26240298e-002,
-       2.72170105e-003, -5.54659590e-003, 5.73343923e-003,
-       1.19986236e-002, -5.77721803e-004, -6.33957461e-002,
-       2.08757017e-002, 1.20051377e-001, 7.17012808e-005,
-       -6.48574084e-002, 2.01973394e-002, 1.21036664e-001,
-       2.08065627e-004, -8.86558555e-003, 2.75856722e-003,
-       1.64034273e-002, 3.07575031e-003, -3.33705335e-003,
-       7.24127237e-003, 8.45715683e-003, 1.01433732e-002,
-       -5.73808551e-002, 4.27322239e-002, 7.95008317e-002,
-       1.13873966e-002, -6.20227680e-002, 4.29966971e-002,
-       7.93407559e-002, 5.38471155e-003, -8.23999406e-004,
-       8.14305991e-003, 6.05960423e-003, -1.51280910e-002,
-       -3.30471061e-002, 3.99828590e-002, 4.88087498e-002,
-       6.35074675e-002, -2.46789932e-001, 2.21069723e-001,
-       3.39118958e-001, 1.94414109e-001, -1.56965882e-001,
-       3.02428514e-001, 2.85379380e-001, 1.07464254e-001,
-       -5.99475065e-003, 1.18940353e-001, 3.85097414e-002,
-       -1.88522656e-002, 1.47113856e-003, 3.66571695e-002,
-       2.54150834e-002, 1.34830728e-001, 5.17636202e-002,
-       2.34486297e-001, 1.50422618e-001, 2.21448705e-001,
-       7.78468475e-002, 3.19044173e-001, 1.80511206e-001,
-       1.08744293e-001, 5.79220662e-003, 1.22558206e-001,
-       3.44812982e-002, -4.50449035e-004, 6.24160049e-004,
-       4.70181415e-003, 3.95265874e-003, 1.85695533e-002,
-       1.59964412e-002, 3.52064706e-002, 3.31921317e-002,
-       3.66733521e-002, 1.43799605e-002, 5.33194467e-002,
-       3.74446623e-002, 9.35266726e-003, -2.06462201e-003,
-       1.29954303e-002, 5.93745802e-003, -1.97881181e-003,
-       2.08896847e-004, 5.64521784e-003, 3.06073762e-003,
-       -3.09338886e-003, -2.93017505e-003, 2.21546423e-002,
-       1.95176955e-002, 6.70079421e-003, -6.68745069e-003,
-       3.64756137e-002, 2.14807354e-002, 2.00931728e-002,
-       1.97228161e-003, 2.64688954e-002, 4.57318267e-003,
-       -1.87848415e-002, -1.10911205e-005, 3.94506827e-002,
-       2.13202201e-002, -1.58588067e-002, 2.01393068e-002,
-       1.36659175e-001, 1.19895443e-001, 3.63181233e-002,
-       2.56677363e-002, 2.49240547e-001, 1.32837325e-001,
-       1.71335772e-001, 8.03564209e-003, 2.12338880e-001,
-       3.43939327e-002, -1.86923649e-002, 2.18006242e-002,
-       4.12342101e-002, 4.17094566e-002, 1.11967605e-002,
-       1.73387527e-001, 1.47351503e-001, 3.40681404e-001,
-       1.22564368e-001, 2.88264841e-001, 2.94072419e-001,
-       4.40229863e-001, 1.29985526e-001, 3.06768492e-002,
-       1.79168642e-001, 5.88516966e-002, 2.30424548e-003,
-       1.06819542e-002, 7.25968136e-003, 1.38812196e-002,
-       1.28335441e-002, 1.02502882e-001, 4.13689613e-002,
-       1.23032600e-001, 2.17666011e-002, 8.00532326e-002,
-       4.29950431e-002, 1.12208128e-001, -2.53576669e-004,
-       3.93571718e-005, 9.53486562e-003, 8.48504435e-003,
-       1.38973026e-003, 8.48550757e-004, 3.74633982e-003,
-       3.47734918e-003, -3.19009414e-003, 4.75269509e-003,
-       2.85249706e-002, 3.68416533e-002, 8.83590616e-003,
-       2.07535643e-003, 3.24989073e-002, 4.12286445e-002,
-       1.77503063e-003, 1.70148350e-003, 4.83152922e-003,
-       5.38766664e-003, 1.23339677e-002, 2.98987632e-003,
-       3.71842496e-002, 2.60314737e-002, 3.89226452e-002,
-       7.45005906e-002, 2.20299378e-001, 2.23788232e-001,
-       1.93452567e-001, 2.75172949e-001, 2.94719338e-001,
-       3.48253578e-001, -8.32299795e-003, 1.60259102e-002,
-       4.51488495e-002, 4.29881737e-002, 1.36661092e-002,
-       3.98822920e-003, 3.83371376e-002, 2.87935659e-002,
-       1.18393876e-001, 2.74649486e-002, 2.77803183e-001,
-       2.41906002e-001, 2.43289322e-002, -2.30741560e-001,
-       2.41815656e-001, 3.63216192e-001, -2.77034310e-003,
-       -2.54806131e-002, 4.28426266e-002, 4.58834916e-002,
-       1.63475843e-003, 9.13897413e-004, 4.44125570e-003,
-       4.96150553e-003, 9.26459688e-005, 1.06660940e-003,
-       3.28382999e-002, 5.18984683e-002, -3.81281134e-003,
-       7.58504868e-003, 3.14878151e-002, 5.11042103e-002,
-       1.23384281e-003, 1.00893514e-004, 4.20111511e-003,
-       5.10428753e-003, 7.27936393e-004, -2.54426821e-004,
-       5.06912917e-003, 4.88908682e-003, 3.41030699e-003,
-       1.42268883e-002, 3.07955649e-002, 4.46341969e-002,
-       -4.18339390e-003, 2.33396254e-002, 2.99146846e-002,
-       4.76376936e-002, -2.03169510e-003, 5.29046636e-004,
-       4.77279862e-003, 4.98667685e-003, 1.88505724e-002,
-       -7.35985814e-004, 4.76128571e-002, 3.60179953e-002,
-       -2.97344327e-002, -1.81745365e-002, 2.38403961e-001,
-       2.51475066e-001, -6.75313994e-002, -1.90334827e-001,
-       2.14080930e-001, 3.43468219e-001, -1.79009456e-002,
-       -1.81012731e-002, 4.19736989e-002, 3.96669917e-002,
-       1.05794230e-002, -1.78676173e-002, 4.80983667e-002,
-       4.05767038e-002, 9.25347358e-002, -2.96544433e-002,
-       3.32458407e-001, 3.13212365e-001, -2.08748907e-001,
-       1.21935323e-001, 3.01349312e-001, 3.47607315e-001,
-       -7.32508209e-003, -8.66176211e-004, 3.95084359e-002,
-       3.50218825e-002, -4.21574747e-004, 1.40183314e-004,
-       5.16130961e-003, 4.37905220e-003, 1.68641694e-002,
-       -1.73715241e-002, 4.30862010e-002, 4.92869765e-002,
-       -1.70458443e-002, -2.32463647e-002, 4.15493660e-002,
-       5.19373380e-002, -3.72756971e-004, 4.56568596e-005,
-       5.08059748e-003, 4.86868853e-003, 4.98040207e-003,
-       2.61038840e-002, 7.67301256e-003, 4.84894589e-002,
-       4.27468214e-003, 1.93786517e-001, 2.33575739e-002,
-       3.29910040e-001, -9.81517974e-003, 2.00091258e-001,
-       3.88790183e-002, 3.22174460e-001, -3.51005746e-003,
-       2.25339383e-002, 1.21458601e-002, 3.91999446e-002,
-       6.83316514e-002, -2.09338963e-002, 8.11480582e-002,
-       6.02415428e-002, 1.73144545e-002, 8.73486400e-002,
-       9.41953436e-002, 1.58770442e-001, -3.45752947e-002,
-       9.89154950e-002, 1.08083457e-001, 1.70344755e-001,
-       -8.27986896e-002, 2.33830642e-002, 1.33915618e-001,
-       4.24411595e-002, 1.04321145e-001, -7.44110867e-002,
-       1.22729756e-001, 8.65912735e-002, 1.89454749e-001,
-       -2.91429669e-001, 2.63647139e-001, 3.39328289e-001,
-       1.99410990e-002, -4.72663157e-002, 9.97839645e-002,
-       1.10732466e-001, -7.24833459e-002, 8.70351493e-003,
-       1.00089148e-001, 2.62471326e-002, -1.70180970e-003,
-       -5.86100575e-003, 9.04429611e-003, 1.23084467e-002,
-       1.12310089e-001, -6.64201751e-002, 1.18204884e-001,
-       9.92577896e-002, 2.70863120e-002, -2.77237669e-002,
-       3.95603143e-002, 4.72277030e-002, -2.63575418e-003,
-       1.19193748e-003, 7.31594348e-003, 4.77392739e-003,
-       -3.60072590e-003, 8.32299585e-004, 5.80790360e-003,
-       2.76488042e-003, -1.45108076e-002, -1.11240689e-002,
-       3.48514132e-002, 1.91537384e-002, 4.53401469e-002,
-       -1.11674899e-002, 5.45026287e-002, 2.09282171e-002,
-       2.31315289e-003, 1.21036964e-003, 5.59996860e-003,
-       2.72010127e-003, -3.21021602e-002, 8.65071546e-003,
-       4.47664410e-002, 1.96721014e-002, -1.70513839e-001,
-       -2.61928560e-003, 2.47165635e-001, 9.40007791e-002,
-       3.62221360e-001, -3.73418406e-002, 4.00760055e-001,
-       1.01908818e-001, 2.26104334e-002, 1.45704369e-003,
-       4.15865183e-002, 1.53429406e-002, -2.17782576e-002,
-       8.92482419e-003, 4.01601270e-002, 1.97058655e-002,
-       -2.50109434e-001, 8.21587592e-002, 3.06139499e-001,
-       1.29181981e-001, 3.47908825e-001, 2.35069059e-002,
-       3.89249831e-001, 1.07083097e-001, 2.60619801e-002,
-       -2.24323291e-003, 4.35935520e-002, 1.62664764e-002,
-       -8.33854603e-004, -3.14922392e-004, 4.92400397e-003,
-       2.63958913e-003, -3.53972986e-002, 1.92765482e-002,
-       4.84058410e-002, 2.72613522e-002, 3.71565744e-002,
-       1.63288526e-002, 5.04714474e-002, 2.54201051e-002,
-       3.17098340e-003, -1.09138619e-003, 5.93690621e-003,
-       2.81321653e-003, -3.70496814e-003, 3.92351154e-004,
-       7.78979296e-003, 7.17163458e-003, -1.04132816e-002,
-       -2.76347380e-002, 3.87598351e-002, 5.28140292e-002,
-       2.77243275e-003, -2.39244364e-002, 3.27184238e-002,
-       4.58800383e-002, 1.26031926e-004, -5.29244600e-004,
-       4.73394385e-003, 5.31433802e-003, -6.42648190e-002,
-       1.17642125e-002, 7.93384388e-002, 5.58253117e-002,
-       -9.31233317e-002, 6.11644685e-002, 2.45969415e-001,
-       3.26365739e-001, 1.80526040e-002, -3.42201404e-002,
-       1.92550734e-001, 2.24543497e-001, 1.92402396e-002,
-       -7.00740516e-003, 3.62571813e-002, 3.27185355e-002,
-       -4.87911217e-002, 2.86727287e-002, 7.23520964e-002,
-       5.83599210e-002, -2.25996971e-001, 1.97176352e-001,
-       3.46723855e-001, 4.41665113e-001, -5.23265451e-002,
-       5.11358045e-002, 2.22613841e-001, 2.25399449e-001,
-       2.20378116e-002, 5.12250978e-003, 3.90009508e-002,
-       3.03756315e-002, 4.96193068e-004, -1.20575925e-004,
-       6.85492018e-003, 6.13456964e-003, -4.01056148e-002,
-       3.86157781e-002, 6.23139255e-002, 6.56279102e-002,
-       -2.66264044e-002, 4.65123467e-002, 5.14871739e-002,
-       6.41984865e-002, 9.58009041e-004, 2.29028007e-003,
-       5.71412267e-003, 5.71809988e-003, 3.86371248e-004,
-       4.02186997e-004, 6.43571466e-003, 4.82628914e-003,
-       5.01139648e-003, 2.31649578e-002, 3.84076349e-002,
-       3.63075323e-002, -1.66108273e-002, 3.51314694e-002,
-       5.05697243e-002, 5.05171567e-002, -3.68827558e-003,
-       9.26950073e-004, 7.28707388e-003, 5.63388877e-003,
-       2.77649108e-002, 3.79563397e-004, 4.95463088e-002,
-       2.95147486e-002, 7.34439418e-002, 3.32887284e-002,
-       2.12087154e-001, 1.48412734e-001, -3.06454953e-002,
-       1.12179533e-001, 3.90021861e-001, 1.94157362e-001,
-       -5.17759323e-002, 8.64893256e-004, 6.96944371e-002,
-       3.13903987e-002, 3.81763354e-002, -8.97901785e-003,
-       5.76705076e-002, 3.55934910e-002, 9.86828431e-002,
-       5.36657944e-002, 2.95609474e-001, 2.70103872e-001,
-       -1.88393205e-001, -1.87578529e-001, 4.17067975e-001,
-       2.99989998e-001, -3.24126557e-002, -1.55223701e-002,
-       6.82310164e-002, 3.46063375e-002, 1.36885198e-003,
-       -5.36970329e-003, 6.91780867e-003, 9.74717457e-003,
-       -7.54494127e-003, -9.64072719e-002, 5.08550443e-002,
-       1.16051994e-001, -1.54905682e-002, -6.72430173e-002,
-       4.92810681e-002, 9.24144015e-002, 1.04615965e-003,
-       -6.57035387e-004, 5.55823231e-003, 6.52963482e-003,
-       1.00130029e-002, -6.49160997e-004, 1.33807864e-002,
-       4.26469184e-003, 1.96911916e-002, 1.71461366e-002,
-       4.47124653e-002, 2.90661156e-002, -5.34156226e-002,
-       2.00556368e-002, 6.77216202e-002, 3.44658308e-002,
-       -3.90850287e-003, 4.82012329e-005, 9.44601186e-003,
-       5.06851869e-003, 8.65020677e-002, -4.79233265e-003,
-       1.07230932e-001, 2.86896750e-002, 1.64223135e-001,
-       2.09264737e-003, 3.00520539e-001, 1.06736824e-001,
-       -2.88038611e-001, 7.56558925e-002, 3.52823257e-001,
-       1.46544084e-001, -5.56493849e-002, 1.85520388e-002,
-       8.78182277e-002, 3.85484025e-002, 6.70790225e-002,
-       -5.39676799e-003, 9.96635258e-002, 3.75436991e-002,
-       2.23307058e-001, -1.00335360e-001, 3.32042217e-001,
-       1.92136392e-001, -1.62950128e-001, -2.39624754e-002,
-       2.46767208e-001, 1.78781003e-001, -7.11942986e-002,
-       8.63853842e-003, 9.43103954e-002, 4.28909436e-002,
-       1.55141705e-003, -4.21166699e-003, 9.68140643e-003,
-       1.21774878e-002, 1.77509822e-002, -1.17996782e-001,
-       4.89403270e-002, 1.67351454e-001, 1.32873130e-004,
-       -1.19619392e-001, 3.78172174e-002, 1.66055530e-001,
-       -4.24491940e-003, -6.10710448e-003, 8.74687172e-003,
-       1.31739415e-002, 7.12433946e-004, -2.03897907e-005,
-       3.58625827e-003, 3.62933846e-003, 1.17288381e-002,
-       2.22420543e-002, 2.76645571e-002, 3.82921435e-002,
-       1.43213840e-002, 3.50011475e-002, 3.27770822e-002,
-       5.05237803e-002, 1.36609515e-003, 3.39938165e-003,
-       4.55830386e-003, 6.61629252e-003, 2.75865700e-002,
-       1.89931709e-002, 3.79007496e-002, 3.11278421e-002,
-       2.13486210e-001, 2.14173287e-001, 2.68442571e-001,
-       2.94540882e-001, 1.06456876e-001, 1.65616184e-001,
-       2.43395060e-001, 3.60361844e-001, -2.91061308e-002,
-       3.46325384e-003, 4.21498604e-002, 4.46490236e-002,
-       4.13087569e-002, 5.36750769e-003, 4.83754463e-002,
-       3.45737822e-002, 9.20789987e-002, -7.64372870e-002,
-       1.98110953e-001, 2.78736949e-001, -6.65126741e-002,
-       -2.60384887e-001, 2.03856677e-001, 3.33431154e-001,
-       -2.11337917e-002, -3.37661058e-002, 3.89528573e-002,
-       4.89000678e-002, 1.57442922e-003, -2.99224840e-003,
-       4.45807679e-003, 5.90406731e-003, -7.63245625e-004,
-       -4.30774838e-002, 2.67597344e-002, 5.70137650e-002,
-       -4.14376287e-003, -2.82976925e-002, 2.76060645e-002,
-       4.96991165e-002, 4.80773218e-004, -1.44047046e-003,
-       4.13747644e-003, 5.31413779e-003, 3.72035604e-004,
-       9.27797798e-003, 1.20818354e-002, 1.69682577e-002,
-       1.22484518e-002, 1.22288570e-001, 5.78640625e-002,
-       1.79550156e-001, 3.12056206e-003, 1.27192825e-001,
-       3.56264524e-002, 1.85517371e-001, -4.63341037e-003,
-       1.15872910e-002, 1.55726131e-002, 1.90611631e-002,
-       2.70312149e-002, 1.05001666e-002, 1.08881541e-001,
-       3.04630380e-002, 1.43641233e-001, 3.75434682e-002,
-       5.25782585e-001, 1.48664042e-001, 5.65424748e-002,
-       4.98670563e-002, 2.20828295e-001, 1.30074084e-001,
-       -8.17288011e-002, 5.04210265e-003, 1.48974687e-001,
-       2.47471314e-002, 3.48516069e-002, 1.64950062e-002,
-       8.65122825e-002, 3.28999721e-002, 4.01853547e-002,
-       3.04148402e-002, 4.44299966e-001, 1.14683598e-001,
-       1.02173291e-001, -4.17306228e-003, 2.30491161e-001,
-       8.39815214e-002, -8.44352990e-002, 2.33485643e-003,
-       1.40377641e-001, 2.02775691e-002, 3.29969870e-003,
-       1.20475772e-003, 8.18566419e-003, 4.31954116e-003,
-       2.31548678e-003, -4.66147345e-003, 5.06790355e-002,
-       2.28395034e-002, 8.85535497e-003, -3.22331372e-003,
-       3.30918878e-002, 1.65133234e-002, -8.04446638e-003,
-       1.71376672e-003, 1.29483836e-002, 4.62476211e-003,
-       1.76254846e-002, -1.88969926e-003, 2.77795680e-002,
-       4.41652630e-003, 1.06351841e-002, 1.14434108e-003,
-       1.96020175e-002, 1.29774855e-002, -8.33335434e-005,
-       3.87817330e-004, 7.83064589e-003, 7.41105061e-003,
-       -6.41104882e-004, -8.57562263e-005, 1.46575714e-003,
-       1.08489406e-003, 1.48824856e-001, -6.79569133e-003,
-       2.18783259e-001, 3.05516310e-002, 7.23954663e-002,
-       7.52755627e-003, 1.32944047e-001, 8.92203078e-002,
-       -4.59107896e-003, -2.45885877e-003, 4.99948859e-002,
-       6.19035698e-002, -5.65983634e-003, -2.04868658e-004,
-       1.24731613e-002, 9.81150381e-003, 1.43544123e-001,
-       -2.34643035e-002, 2.04809755e-001, 5.39528206e-002,
-       5.26381433e-002, -3.61999094e-001, 1.43025473e-001,
-       4.22223926e-001, 3.87005945e-004, -3.63429189e-001,
-       7.10218474e-002, 4.16151673e-001, -7.54907355e-003,
-       -5.24846762e-002, 1.71220843e-002, 5.99827319e-002,
-       5.67777548e-003, -9.73423943e-003, 1.07930051e-002,
-       1.62578784e-002, -5.16773714e-003, -1.14103779e-001,
-       2.61291806e-002, 1.76046938e-001, 1.77420396e-003,
-       -1.16954520e-001, 1.78385712e-002, 1.81201413e-001,
-       6.11299591e-004, -1.56468377e-002, 3.30709131e-003,
-       2.52980944e-002, 7.67303980e-004, 4.84730490e-003,
-       9.03593097e-003, 9.24420543e-003, -1.12873910e-004,
-       5.53825609e-002, 2.64938381e-002, 8.80580246e-002,
-       1.83939990e-002, 5.62089346e-002, 3.43471467e-002,
-       8.89839679e-002, 6.55163371e-004, 4.71199350e-003,
-       4.88332473e-003, 1.00303879e-002, 8.02734271e-002,
-       2.91258972e-002, 1.21182963e-001, 4.26616780e-002,
-       -7.37710968e-002, 3.17319810e-001, 2.57416725e-001,
-       3.52485329e-001, 9.89485011e-002, 2.77077794e-001,
-       3.11092913e-001, 3.18979979e-001, -4.65123206e-002,
-       2.36342642e-002, 6.63805157e-002, 3.95244509e-002,
-       8.36885348e-002, 1.56202447e-002, 1.15560718e-001,
-       2.63781101e-002, -7.03971609e-002, 1.35996444e-002,
-       2.25910857e-001, 9.56450403e-002, 2.83287261e-002,
-       -4.62947190e-002, 3.43361467e-001, 1.22615792e-001,
-       -5.08939959e-002, -5.74340718e-003, 6.85586780e-002,
-       2.59976368e-002, 6.81825029e-003, 1.72119495e-003,
-       1.15671773e-002, 3.14676110e-003, -7.89477676e-003,
-       -2.68789660e-003, 3.14119495e-002, 1.30906738e-002,
-       -9.03922319e-003, -3.26895551e-003, 5.32587506e-002,
-       1.78939532e-002, -4.46979934e-003, 1.35276990e-003,
-       8.41446407e-003, 3.26595362e-003, 1.89789291e-002,
-       -4.52619791e-003, 2.82740407e-002, 6.73630321e-003,
-       9.06412024e-003, 2.81206740e-004, 2.07586754e-002,
-       1.13295922e-002, -9.53839393e-004, 1.53555127e-003,
-       9.01862793e-003, 6.98903762e-003, -2.32783658e-003,
-       -1.47013896e-004, 3.93099990e-003, 1.68116856e-003,
-       1.76747426e-001, -5.71347727e-003, 2.76768714e-001,
-       3.39761227e-002, 6.74046651e-002, -5.03995689e-003,
-       1.49266437e-001, 8.27085599e-002, -1.45453615e-002,
-       -1.28070936e-002, 5.56600764e-002, 6.24992661e-002,
-       -2.48428620e-002, -5.86171728e-003, 3.82034406e-002,
-       1.53810587e-002, 1.84462368e-001, -1.30827073e-002,
-       2.75164962e-001, 4.61187772e-002, 6.54363409e-002,
-       -1.28927276e-001, 1.66673273e-001, 2.27842063e-001,
-       -1.40152313e-002, -1.14277549e-001, 7.24021345e-002,
-       1.90953001e-001, -3.17059457e-002, -1.59761012e-002,
-       4.86448444e-002, 3.33326086e-002, 1.08296489e-002,
-       -2.56141908e-002, 1.92166567e-002, 3.83531414e-002,
-       -5.29666897e-004, -2.78895885e-001, 3.30350772e-002,
-       3.90076041e-001, 5.72269270e-003, -2.83678681e-001,
-       2.52124332e-002, 4.02075440e-001, -4.57629329e-004,
-       -3.62164415e-002, 6.62843836e-003, 5.30124642e-002,
-       -1.11582205e-002, 9.53415583e-004, 1.55076813e-002,
-       4.15192731e-003, -1.09679429e-002, -2.37605460e-002,
-       7.39281401e-002, 3.69090959e-002, 1.94377434e-002,
-       -1.64805483e-002, 4.47896831e-002, 3.43992971e-002,
-       3.04943440e-003, 1.03234267e-003, 6.89421594e-003,
-       4.36733197e-003, -1.28743678e-001, -4.07976238e-003,
-       1.51495397e-001, 2.68022269e-002, -1.19218668e-002,
-       -5.10698147e-002, 4.70816851e-001, 1.49506986e-001,
-       1.79543108e-001, -9.62078944e-003, 2.78156161e-001,
-       1.36916697e-001, 3.40797715e-002, 3.91252711e-003,
-       5.39000109e-002, 2.50812806e-002, -1.41936973e-001,
-       -9.35586542e-003, 1.61275014e-001, 2.57711150e-002,
-       5.66888303e-002, 2.67902315e-002, 4.41444308e-001,
-       1.19776256e-001, 1.92103669e-001, 4.27865423e-002,
-       2.98687428e-001, 1.28920481e-001, 2.85674576e-002,
-       3.20508098e-003, 5.29180951e-002, 2.32867915e-002,
-       -1.49935447e-002, -1.97129557e-003, 1.81307085e-002,
-       4.85682115e-003, 8.71266425e-003, 2.06860267e-002,
-       5.76637387e-002, 3.21643911e-002, 2.83388402e-002,
-       1.50613505e-002, 4.60655764e-002, 3.11439689e-002,
-       1.63046131e-003, -7.27391336e-004, 6.97528711e-003,
-       4.39534476e-003, 1.32056409e-002, -3.08183674e-003,
-       2.09101290e-002, 6.58102334e-003, 1.29380189e-002,
-       -1.82978739e-003, 2.96450406e-002, 2.24079452e-002,
-       -9.91141656e-004, 4.16766526e-003, 1.82250049e-002,
-       2.69281697e-002, -5.23837749e-003, -1.95568384e-004,
-       7.70508032e-003, 4.04042099e-003, 1.45597786e-001,
-       -5.74542256e-003, 2.15709060e-001, 3.66077423e-002,
-       1.80239640e-002, -2.00821646e-002, 2.71021068e-001,
-       1.47090450e-001, 5.77085875e-002, -2.80024968e-002,
-       1.50770009e-001, 1.21794306e-001, -3.11835296e-002,
-       4.83946363e-003, 4.65476848e-002, 2.03601643e-002,
-       1.69091046e-001, -1.50763765e-002, 2.34937981e-001,
-       4.57500294e-002, 3.63125317e-002, -1.00671068e-001,
-       2.37603053e-001, 2.65611351e-001, 3.46937515e-002,
-       -9.32299495e-002, 1.38004556e-001, 2.57404953e-001,
-       -2.16272995e-002, -1.50187695e-002, 3.84778902e-002,
-       3.85537893e-002, 1.10169491e-002, -2.37038657e-002,
-       1.71175841e-002, 3.47833149e-002, 1.91903336e-003,
-       -2.45210767e-001, 3.53416130e-002, 3.34365904e-001,
-       2.93298205e-003, -2.41154477e-001, 2.70228069e-002,
-       3.39069307e-001, 1.03055546e-003, -3.21843103e-002,
-       6.30802754e-003, 4.51718718e-002, 1.41209527e-003,
-       -1.90737576e-003, 4.98726685e-003, 4.51006927e-003,
-       1.01096258e-002, -5.43930521e-003, 3.61862406e-002,
-       3.72759067e-002, -3.39565165e-002, -1.88250244e-002,
-       5.44485673e-002, 4.37305905e-002, 2.64843996e-003,
-       -1.40445388e-003, 6.19487790e-003, 4.03352967e-003,
-       -2.17624046e-002, -1.82713475e-002, 4.38660197e-002,
-       3.59877199e-002, 1.84757337e-001, -3.18248332e-001,
-       3.21517169e-001, 3.80470514e-001, -1.85171947e-001,
-       -1.06180757e-001, 3.72155517e-001, 2.35661969e-001,
-       3.20810117e-002, -3.23420833e-003, 5.44544458e-002,
-       3.23553383e-002, -2.06055008e-002, 8.72138329e-003,
-       4.09046449e-002, 3.12976055e-002, 5.90908192e-002,
-       7.96176195e-002, 2.29459539e-001, 2.06562266e-001,
-       3.27803120e-002, 2.60424241e-002, 2.17292830e-001,
-       1.71501860e-001, 1.76037475e-002, 5.79920106e-006,
-       4.40918878e-002, 2.77764536e-002, -2.51126883e-004,
-       -6.92724949e-004, 4.75406926e-003, 3.94283561e-003,
-       -3.10880714e-003, -3.39074410e-004, 3.13349813e-002,
-       3.44428271e-002, 8.16878956e-003, 1.09881524e-003,
-       3.41738127e-002, 3.51036638e-002, 5.47025877e-004,
-       -6.95373747e-004, 4.52382350e-003, 4.13652882e-003,
-       -3.42876161e-003, -6.98866742e-003, 9.08405893e-003,
-       1.40210763e-002, 7.56833842e-003, -1.19282879e-001,
-       4.51784171e-002, 1.67128816e-001, 6.43699849e-003,
-       -1.24637634e-001, 4.95574251e-002, 1.67468041e-001,
-       2.40992126e-003, -6.29011588e-003, 9.07869358e-003,
-       1.53142465e-002, -9.15075839e-002, 4.64412477e-003,
-       1.04631267e-001, 4.35410850e-002, -6.38875142e-002,
-       -7.48379827e-002, 1.80437595e-001, 2.22124502e-001,
-       1.87828511e-001, -5.92624620e-002, 2.48284832e-001,
-       2.23612577e-001, 7.58577138e-002, 1.76201575e-002,
-       9.58390757e-002, 5.68092614e-002, -7.91533068e-002,
-       1.33310119e-002, 1.01283863e-001, 4.12546322e-002,
-       -1.48838326e-001, 1.20405771e-001, 2.39482120e-001,
-       1.92808926e-001, 3.17184180e-001, 1.37051538e-001,
-       3.66446614e-001, 2.09678188e-001, 7.01371282e-002,
-       2.46880762e-002, 9.95559096e-002, 4.60574441e-002,
-       -4.82784398e-003, -6.27209432e-004, 1.07727284e-002,
-       5.74793294e-003, -2.79337782e-002, 2.18983311e-002,
-       5.12542538e-002, 3.98211032e-002, 5.67525476e-002,
-       2.08578669e-002, 7.10581914e-002, 4.89839725e-002,
-       2.38885800e-003, -3.08640162e-003, 1.03559084e-002,
-       7.78588606e-003, 3.67656304e-003, 3.34189972e-003,
-       5.14624780e-003, 9.78124142e-003, -1.26801990e-002,
-       7.83045143e-002, 4.71753180e-002, 1.51857793e-001,
-       2.62265317e-002, 7.81126022e-002, 4.14011292e-002,
-       1.59409836e-001, 1.65761303e-005, 1.04185538e-002,
-       2.81856325e-003, 2.28843633e-002, 6.58180937e-002,
-       -1.79790915e-003, 7.26784840e-002, 2.78007016e-002,
-       -1.25232577e-001, 5.61704226e-002, 4.81152952e-001,
-       1.74125269e-001, 2.52749711e-001, 7.81400576e-002,
-       3.23183924e-001, 1.34899333e-001, -4.12223907e-003,
-       5.97448787e-003, 1.32331513e-002, 1.51473787e-002,
-       3.66931446e-002, -1.29877534e-002, 5.06946072e-002,
-       2.60525923e-002, 1.98723480e-001, -1.56914979e-001,
-       3.53639513e-001, 2.60633737e-001, 7.08161294e-002,
-       3.82688479e-003, 1.84264898e-001, 1.02780506e-001,
-       1.03533268e-003, -5.97470254e-003, 1.20262103e-002,
-       1.22704888e-002, 1.20482058e-003, 2.78151361e-004,
-       5.56181837e-003, 3.41198966e-003, 4.47167233e-002,
-       -2.38288399e-002, 6.02623746e-002, 3.35751846e-002,
-       1.80067625e-002, -2.05779821e-002, 3.40854004e-002,
-       2.59864181e-002, -4.18487361e-005, -1.40403130e-003,
-       1.63604261e-003, 2.52205017e-003, 2.23135925e-003,
-       1.30197534e-003, 6.07227255e-003, 5.26877912e-003,
-       9.80108604e-003, 4.56156395e-002, 4.24742289e-002,
-       7.03627393e-002, -8.46046396e-003, 4.63926308e-002,
-       5.40388823e-002, 7.40533769e-002, -8.32801510e-004,
-       3.23944143e-003, 5.62913297e-003, 8.91475659e-003,
-       2.81320382e-002, -2.34957016e-003, 4.86738458e-002,
-       2.30867732e-002, 1.40906602e-001, 4.87614088e-002,
-       3.41252387e-001, 1.42254993e-001, -8.24360847e-002,
-       7.02397823e-002, 4.98901784e-001, 1.79703310e-001,
-       -1.56918094e-002, 6.99880160e-003, 4.34652753e-002,
-       2.34166998e-002, 1.82497334e-002, -6.16017496e-003,
-       4.42847684e-002, 2.47399062e-002, 2.67333269e-001,
-       -1.27810165e-001, 3.44027668e-001, 2.14701295e-001,
-       -7.12215751e-002, 3.24788205e-002, 2.91407645e-001,
-       1.59609511e-001, -1.95706300e-002, 7.73607893e-003,
-       4.12725210e-002, 2.40565110e-002, 1.35130482e-004,
-       5.87943883e-004, 4.79987729e-003, 3.36831133e-003,
-       3.95139754e-002, -2.10476257e-002, 5.31235412e-002,
-       3.89287770e-002, 4.35794238e-003, -2.70064417e-002,
-       3.90821211e-002, 3.80326621e-002, -1.70353218e-003,
-       -6.60260557e-004, 4.98709362e-003, 3.58469621e-003,
-       3.35493428e-003, -2.31384081e-004, 6.60338392e-003,
-       3.53649841e-003, 1.66865196e-002, 1.36947921e-002,
-       3.25152017e-002, 2.49032900e-002, -3.53922043e-003,
-       1.50139956e-002, 2.83893812e-002, 2.71606836e-002,
-       -3.67719424e-003, -3.60897364e-004, 6.70602685e-003,
-       4.36361087e-003, 4.09112275e-002, 8.41302332e-004,
-       5.53048812e-002, 2.28702687e-002, 1.28675058e-001,
-       3.34938504e-002, 2.00673744e-001, 1.06970891e-001,
-       -1.88834835e-002, 3.71163413e-002, 1.81975141e-001,
-       1.16173640e-001, -5.25426753e-002, -7.98252877e-003,
-       6.56578913e-002, 3.37604843e-002, 4.47024330e-002,
-       -6.44838717e-003, 5.79495467e-002, 2.62708254e-002,
-       4.62290794e-002, -1.37922868e-001, 2.36441508e-001,
-       2.03315943e-001, -1.81510463e-001, -4.66651529e-001,
-       2.87694544e-001, 4.90471721e-001, -4.30964902e-002,
-       -5.76362945e-002, 6.34526983e-002, 6.90355599e-002,
-       2.66015250e-003, -4.00859118e-003, 6.88023120e-003,
-       6.67537889e-003, -3.07201315e-002, -6.33280352e-002,
-       5.66047169e-002, 7.59194121e-002, -2.74921842e-002,
-       -2.73559876e-002, 4.46654148e-002, 5.36484793e-002,
-       1.61531719e-003, -8.30357822e-005, 4.86370362e-003,
-       5.70098730e-003, 5.20510133e-003, -2.21302453e-003,
-       1.25183286e-002, 6.09893026e-003, 2.42898855e-002,
-       7.43166124e-003, 4.08831313e-002, 2.35326365e-002,
-       -6.66292384e-003, 8.99123214e-003, 2.44419258e-002,
-       2.20882110e-002, -1.16733685e-002, -3.16659152e-003,
-       1.81619078e-002, 6.38693199e-003, 7.43015856e-002,
-       -1.19429212e-002, 1.48818731e-001, 4.80405129e-002,
-       1.83314160e-001, 1.65841486e-002, 2.54589468e-001,
-       1.13374270e-001, -6.09883927e-002, 7.00640865e-003,
-       1.39327288e-001, 8.98848325e-002, -1.23338006e-001,
-       -6.51265029e-003, 1.87236920e-001, 4.00198177e-002,
-       9.21804607e-002, -1.65872667e-002, 1.59318492e-001,
-       5.25956042e-002, 1.70404360e-001, -2.30027080e-001,
-       2.61933595e-001, 3.09825718e-001, -7.92384297e-002,
-       -2.44809687e-001, 1.85500771e-001, 3.13322812e-001,
-       -1.16979830e-001, -1.75097957e-002, 1.84891164e-001,
-       4.81431559e-002, 4.78243362e-003, -4.31177020e-003,
-       1.30245946e-002, 1.46375997e-002, 1.24762941e-003,
-       -7.56648332e-002, 4.70487662e-002, 1.71883538e-001,
-       -2.35420396e-003, -8.89780596e-002, 4.07618508e-002,
-       1.83640957e-001, -2.00394541e-003, -5.99988503e-003,
-       1.37780067e-002, 1.69243831e-002, 3.64120002e-003,
-       -1.79818328e-002, 7.13798637e-003, 2.36211475e-002,
-       -8.36881169e-004, -1.74317792e-001, 4.64359485e-002,
-       2.05320299e-001, 8.98172846e-004, -1.59219339e-001,
-       6.70857877e-002, 1.86270267e-001, 1.04062920e-002,
-       -4.12687333e-003, 1.65277217e-002, 1.30646462e-002,
-       -5.87530388e-003, -2.47012060e-002, 2.10013445e-002,
-       3.79484482e-002, -1.88243724e-002, -1.67529151e-001,
-       1.07763648e-001, 2.44292736e-001, 2.37248406e-001,
-       -1.30218700e-001, 3.30083191e-001, 2.39669025e-001,
-       1.80634007e-001, 3.88050568e-003, 2.09455580e-001,
-       3.81536447e-002, -7.90061057e-003, 1.97215169e-003,
-       1.82509702e-002, 1.33870859e-002, -8.02660361e-003,
-       8.41318443e-003, 8.26665759e-002, 7.99529776e-002,
-       2.67483532e-001, 7.71090295e-003, 3.40396166e-001,
-       9.76443440e-002, 1.86542749e-001, 2.10730266e-003,
-       2.15689510e-001, 2.91083604e-002, -8.31079786e-004,
-       6.75234129e-004, 3.22662923e-003, 2.71376758e-003,
-       -1.76371250e-003, 7.69818202e-003, 1.55002307e-002,
-       1.61868688e-002, 3.99414375e-002, 8.02045316e-003,
-       5.61552718e-002, 2.01973226e-002, 2.26068478e-002,
-       -8.59408930e-004, 2.71050930e-002, 5.01371687e-003,
-       1.14861724e-003, 1.50513742e-003, 5.50795300e-003,
-       4.71740356e-003, -1.86856429e-003, 2.33288463e-002,
-       3.86340208e-002, 3.95905413e-002, 2.00784812e-003,
-       2.90869698e-002, 3.12437061e-002, 4.19260003e-002,
-       -3.27296834e-003, 1.58889254e-003, 5.94886206e-003,
-       3.61894886e-003, 3.61735933e-002, -2.01671734e-003,
-       5.72656095e-002, 3.85267325e-002, -3.11265606e-002,
-       1.88015297e-001, 3.69316757e-001, 2.48565137e-001,
-       -1.64857716e-003, 9.81145948e-002, 1.91375405e-001,
-       1.69773683e-001, -5.50316311e-002, 1.00874947e-002,
-       6.64951727e-002, 2.45436896e-002, 2.23797094e-002,
-       -1.38527220e-002, 5.10221794e-002, 2.81748716e-002,
-       3.92138511e-002, -4.30637524e-002, 6.49698496e-001,
-       1.75239921e-001, -4.05457392e-002, -2.49719433e-002,
-       1.84973821e-001, 1.12328053e-001, -4.88360636e-002,
-       1.32316170e-004, 6.27473220e-002, 2.15638708e-002,
-       5.39895729e-004, 1.22886524e-003, 6.13088813e-003,
-       3.43482685e-003, 1.59300845e-002, -1.68861840e-002,
-       8.15144256e-002, 3.22992131e-002, -1.13205090e-002,
-       -1.05855735e-002, 3.30026187e-002, 2.62900740e-002,
-       -3.78088956e-003, 1.53493806e-004, 6.45236997e-003,
-       3.45515180e-003, -8.02707672e-003, -7.40883825e-003,
-       1.10471668e-002, 1.32651906e-002, -3.63130891e-003,
-       -1.55680418e-001, 3.69757935e-002, 1.91082507e-001,
-       1.29512008e-002, -1.51351407e-001, 4.08575721e-002,
-       1.89852118e-001, 5.36770327e-003, -4.48594429e-003,
-       1.30090201e-002, 1.14631671e-002, -1.25502214e-001,
-       -1.11660687e-003, 1.35139346e-001, 3.00246701e-002,
-       -9.36462581e-002, 4.54396755e-002, 2.23663732e-001,
-       2.34369293e-001, 1.53965920e-001, 2.84844097e-002,
-       3.34531516e-001, 2.55160838e-001, 1.24421395e-001,
-       -8.98631930e-004, 1.68898270e-001, 3.33501361e-002,
-       -1.29866973e-001, -2.05308013e-003, 1.43026441e-001,
-       1.95240621e-002, -1.14211885e-004, 2.77220048e-002,
-       2.20706537e-001, 1.29763022e-001, 2.17893459e-002,
-       2.71288343e-002, 3.24601620e-001, 1.40689954e-001,
-       1.42685577e-001, -3.21800751e-003, 1.92560256e-001,
-       2.52667293e-002, -1.57271400e-002, -1.51062827e-003,
-       1.90329328e-002, 3.72170494e-003, 2.65013357e-003,
-       8.81872140e-003, 3.53813209e-002, 2.39379909e-002,
-       4.97067859e-003, 7.94091914e-003, 5.45118712e-002,
-       2.49662325e-002, 1.67793836e-002, -5.99640844e-005,
-       2.57613100e-002, 4.23984602e-003, 9.11585521e-004,
-       1.23175501e-003, 5.51634468e-003, 3.99949821e-003,
-       -4.44465801e-002, -3.61757427e-002, 6.60553426e-002,
-       5.53800389e-002, -9.87967011e-003, -4.98970933e-002,
-       4.37918715e-002, 6.27485812e-002, 4.71158302e-004,
-       -2.10690009e-003, 5.02164336e-003, 5.59445005e-003,
-       -3.66213843e-002, -2.46193092e-002, 5.99575639e-002,
-       3.99093330e-002, -3.15856785e-001, -2.69604474e-001,
-       4.51675951e-001, 3.45172763e-001, 4.54344265e-002,
-       -4.02648859e-002, 1.75692856e-001, 2.02505335e-001,
-       2.07604691e-002, -9.98175610e-003, 3.57741714e-002,
-       3.04054283e-002, -8.15729126e-002, -2.75970101e-002,
-       9.48362425e-002, 4.20563407e-002, 3.64288725e-002,
-       3.95796970e-002, 3.55688095e-001, 1.79478407e-001,
-       -1.54695055e-002, 9.96134281e-002, 1.76530808e-001,
-       1.78467497e-001, 1.84328146e-002, 7.80479470e-003,
-       3.20577584e-002, 2.53488608e-002, -6.83331536e-003,
-       -1.31273479e-003, 1.02121141e-002, 5.08186920e-003,
-       1.34789683e-002, 1.81757342e-002, 4.47204001e-002,
-       3.28160748e-002, -4.18463023e-005, 1.28999650e-002,
-       3.20588164e-002, 3.07000652e-002, 4.80672694e-004,
-       8.51778605e-004, 4.23426880e-003, 4.02227556e-003,
-       1.86226374e-004, -1.31816021e-003, 2.59128795e-003,
-       3.27449734e-003, -1.16092488e-002, -1.36232646e-002,
-       2.45352481e-002, 2.60935836e-002, -1.54920826e-002,
-       -1.29484646e-002, 6.89565390e-002, 2.53210329e-002,
-       2.30698823e-003, -9.56227814e-005, 4.72718989e-003,
-       2.70532747e-003, -1.09986113e-002, -4.49674055e-002,
-       2.19032150e-002, 5.42535856e-002, -1.66546665e-002,
-       -3.14189941e-001, 1.45049676e-001, 3.55420709e-001,
-       1.04721477e-002, -1.77834049e-001, 3.56747538e-001,
-       2.38752276e-001, 2.45233011e-002, -2.40357965e-002,
-       3.75254489e-002, 3.69298123e-002, -1.18358061e-002,
-       4.28921022e-002, 2.11354587e-002, 5.41989766e-002,
-       -3.27079110e-002, 2.90153384e-001, 1.31759584e-001,
-       3.47058922e-001, 2.40639262e-002, 1.81866989e-001,
-       2.74744272e-001, 2.51230389e-001, 2.16414258e-002,
-       1.67539883e-002, 3.42084765e-002, 3.88511345e-002,
-       2.38018438e-005, 1.55139586e-003, 2.33600964e-003,
-       3.42549360e-003, -1.21949650e-002, 1.39298271e-002,
-       2.49184240e-002, 2.66312957e-002, -9.63842310e-003,
-       1.30343661e-002, 5.84793612e-002, 2.57744920e-002,
-       1.40069937e-003, 5.92209457e-004, 4.40399488e-003,
-       3.01517523e-003, -3.46985064e-004, -5.03952142e-005,
-       5.31752501e-003, 6.35228213e-003, 2.53152940e-002,
-       3.42324302e-002, 4.69049960e-002, 5.95137887e-002,
-       2.16109445e-003, 3.86528634e-002, 3.99573036e-002,
-       5.54553233e-002, -1.97702274e-003, 5.33642597e-004,
-       5.26886526e-003, 4.83393809e-003, 2.54760217e-002,
-       1.68767218e-002, 5.05727418e-002, 5.46420999e-002,
-       2.13189602e-001, 1.15637712e-001, 3.31940383e-001,
-       4.94554579e-001, -1.37116805e-001, 2.71728691e-002,
-       2.58520067e-001, 1.81873605e-001, -2.63011623e-002,
-       -2.54576467e-003, 4.74528745e-002, 3.08478847e-002,
-       3.69306542e-002, -1.41723664e-003, 5.85495159e-002,
-       3.99739146e-002, 1.23647198e-001, -2.37187631e-002,
-       2.38696530e-001, 2.58105665e-001, -1.77942291e-001,
-       -4.77271676e-002, 2.85946369e-001, 1.56311914e-001,
-       -2.13065092e-002, -7.48645468e-003, 4.57693934e-002,
-       3.08453776e-002, 1.84981676e-003, 2.12969506e-004,
-       6.61364151e-003, 5.78347594e-003, 1.69476066e-002,
-       -2.48001497e-002, 3.87588926e-002, 4.54713553e-002,
-       -1.71788558e-002, -2.28241533e-002, 4.02273573e-002,
-       3.85270342e-002, -1.31283817e-003, 6.63753424e-004,
-       5.56732854e-003, 4.32373071e-003, -2.59263651e-003,
-       -6.65440457e-004, 6.39319373e-003, 4.11480479e-003,
-       -3.46953352e-003, -2.36233175e-002, 3.10438070e-002,
-       3.83906141e-002, 3.24174725e-002, -1.70276947e-002,
-       4.72923927e-002, 3.89629677e-002, 6.42905897e-003,
-       2.20905524e-003, 1.09989131e-002, 5.60652558e-003,
-       -2.90253069e-002, 3.31235188e-003, 4.13050540e-002,
-       2.76916716e-002, -2.53912117e-002, 2.24262699e-002,
-       1.52028248e-001, 1.49900660e-001, 2.14929134e-001,
-       -3.26696411e-002, 2.86391824e-001, 1.57241821e-001,
-       6.74641728e-002, -1.96131021e-002, 8.69787857e-002,
-       4.39449362e-002, -2.65153255e-002, 3.10135316e-002,
-       5.00398688e-002, 5.10357581e-002, -8.82840082e-002,
-       2.01645777e-001, 1.92476094e-001, 2.95728713e-001,
-       1.59509063e-001, 1.39415428e-001, 2.85971344e-001,
-       2.80103922e-001, 4.78431731e-002, 1.64858438e-002,
-       7.82329068e-002, 6.05795681e-002, 2.55108043e-003,
-       1.47819733e-002, 8.47461913e-003, 2.41835117e-002,
-       5.80782024e-003, 1.79729596e-001, 5.25040440e-002,
-       2.48616025e-001, 6.90247398e-004, 2.04886511e-001,
-       5.61831258e-002, 2.63205618e-001, -1.71787839e-003,
-       1.03712017e-002, 1.29396813e-002, 2.11048536e-002,
-       7.52221036e-004, -1.26726954e-004, 5.59074292e-003,
-       3.45530384e-003, 1.18463486e-003, 9.13447607e-003,
-       5.20339385e-002, 3.44187580e-002, -5.62683446e-003,
-       1.04888463e-002, 3.85360345e-002, 3.23285684e-002,
-       -6.88143016e-004, 1.46538601e-004, 4.84671723e-003,
-       4.09424258e-003, 1.26695400e-002, 1.80267857e-003,
-       4.32734340e-002, 2.39847396e-002, -1.37384254e-002,
-       4.61643748e-002, 4.34518188e-001, 1.90165043e-001,
-       -9.27215163e-003, 3.25765945e-002, 2.69707650e-001,
-       2.08064899e-001, -1.85836218e-002, 1.76061818e-003,
-       4.27262969e-002, 2.94757877e-002, 1.56526342e-002,
-       -3.07228882e-003, 4.52620797e-002, 2.96953302e-002,
-       3.31496522e-002, -9.80771706e-002, 3.20279747e-001,
-       3.21695238e-001, -4.37824503e-002, -3.09181865e-002,
-       3.20898205e-001, 3.85530978e-001, -1.57355126e-002,
-       -7.30920304e-003, 4.23619039e-002, 3.69138345e-002,
-       1.34899688e-004, -5.74111647e-004, 4.79741115e-003,
-       3.98567459e-003, -1.11334759e-003, -1.51997106e-002,
-       3.93949002e-002, 4.14542519e-002, 3.27371294e-003,
-       -1.55838095e-002, 3.83089297e-002, 4.41002101e-002,
-       -5.90957876e-004, -7.91987113e-005, 4.46587754e-003,
-       4.32963157e-003, 3.31658777e-003, -1.05587300e-003,
-       5.97378612e-003, 1.01491939e-002, -1.72577538e-002,
-       -7.00797439e-002, 4.14733365e-002, 9.89260525e-002,
-       -4.05085906e-002, -1.02858774e-001, 6.47240505e-002,
-       1.17111683e-001, 7.22425710e-003, -4.17799642e-003,
-       1.48019744e-002, 8.62815790e-003, -2.27564983e-002,
-       -6.63803890e-002, 3.52139398e-002, 7.83590004e-002,
-       -5.58208935e-002, -3.72597009e-001, 1.65406600e-001,
-       4.68772531e-001, -5.36271073e-002, -1.66878074e-001,
-       2.75772512e-001, 2.71215588e-001, 1.43652931e-001,
-       9.64281266e-004, 1.74762920e-001, 3.26237455e-002,
-       -1.50290858e-002, 2.34136544e-003, 3.11335307e-002,
-       2.48657987e-002, 1.44594302e-002, 3.45998593e-002,
-       1.38346717e-001, 1.25195488e-001, 5.94761735e-003,
-       1.25080636e-002, 2.59729147e-001, 1.14005826e-001,
-       1.38629973e-001, -4.60010814e-003, 1.74479559e-001,
-       2.81239152e-002, -1.34839024e-003, 3.37739405e-003,
-       4.79178503e-003, 6.28814287e-003, -7.91021250e-003,
-       1.88464914e-002, 2.59633772e-002, 3.65990289e-002,
-       1.64833281e-003, 1.74697973e-002, 4.25480306e-002,
-       3.19722816e-002, 1.38249109e-002, -1.36349862e-003,
-       2.01439522e-002, 4.59381379e-003, -1.64641402e-004,
-       -4.04173479e-004, 3.58811277e-003, 3.51981586e-003,
-       1.48628419e-003, 3.48016899e-003, 2.50876751e-002,
-       2.44193599e-002, 9.21602082e-003, 8.59159045e-003,
-       6.05519265e-002, 2.68160272e-002, 7.13967311e-004,
-       7.30255037e-004, 6.54868642e-003, 3.33576859e-003,
-       2.21545482e-003, 1.17019322e-002, 2.92588249e-002,
-       2.97803860e-002, -7.92404637e-003, 9.33405682e-002,
-       1.48929015e-001, 1.89269349e-001, 8.67320001e-002,
-       4.09430824e-002, 5.09591103e-001, 1.61255985e-001,
-       -1.77204155e-003, 5.68440533e-004, 5.17220609e-002,
-       1.98756251e-002, 4.88318177e-003, -7.80621031e-003,
-       3.33701894e-002, 5.28696515e-002, 5.41221611e-002,
-       -1.74460728e-002, 1.88377142e-001, 4.30440098e-001,
-       -2.47789379e-002, 7.71614583e-003, 4.11523610e-001,
-       2.40406275e-001, -2.10693525e-003, 3.17033357e-003,
-       4.96479496e-002, 2.99403984e-002, -5.59468172e-004,
-       1.77953516e-005, 4.02552774e-003, 6.21560868e-003,
-       8.25765543e-003, -1.42405857e-003, 3.67207192e-002,
-       4.62592654e-002, 1.08522000e-002, -2.32805824e-003,
-       5.98602816e-002, 4.32243608e-002, -6.05787616e-004,
-       2.42577851e-004, 6.52677892e-003, 4.45520971e-003,
-       2.76852166e-003, -8.34983541e-004, 5.25853876e-003,
-       4.78431163e-003, 1.51227145e-002, 2.03391425e-002,
-       3.41737792e-002, 3.35749276e-002, 4.36852220e-003,
-       2.12276485e-002, 3.42700258e-002, 4.05239835e-002,
-       -2.52573285e-003, -1.11811177e-003, 7.11218221e-003,
-       5.08506503e-003, 3.86714861e-002, 1.24720838e-002,
-       5.08760847e-002, 3.12606245e-002, 7.61479884e-002,
-       1.12062760e-001, 1.96651518e-001, 2.05659911e-001,
-       6.51840642e-002, 1.43229410e-001, 2.91841924e-001,
-       2.17187658e-001, -5.43823019e-002, 1.91386137e-002,
-       7.49107897e-002, 3.96408252e-002, 4.97247502e-002,
-       -1.45514207e-002, 6.17339611e-002, 5.66507317e-002,
-       1.12742662e-001, -5.13944663e-002, 2.38511488e-001,
-       3.95964354e-001, 1.31948814e-001, 7.17137009e-004,
-       2.59704411e-001, 3.10301483e-001, -5.14029115e-002,
-       2.15244200e-002, 7.10075423e-002, 5.27296364e-002,
-       1.73363881e-003, -1.04769031e-002, 5.47071686e-003,
-       1.68058686e-002, 1.27297062e-002, -1.38758853e-001,
-       3.63955274e-002, 1.91837609e-001, 2.91840266e-002,
-       -1.58084959e-001, 4.39441353e-002, 2.02974558e-001,
-       8.37585772e-004, -1.37619274e-002, 6.62360340e-003,
-       1.94775686e-002, 3.27803369e-004, -5.33757091e-004,
-       6.18692674e-003, 4.05589771e-003, -2.76383682e-004,
-       -6.25664555e-003, 5.37534207e-002, 4.45099324e-002,
-       4.63864207e-003, -1.09774191e-002, 4.52622399e-002,
-       4.58335504e-002, -6.29627320e-005, 3.87704968e-005,
-       5.06274030e-003, 4.32718452e-003, -2.84210127e-003,
-       -8.57501570e-003, 5.22448309e-002, 3.03079318e-002,
-       3.86017933e-002, -7.93132558e-002, 4.83269244e-001,
-       2.86461920e-001, 3.11897527e-002, 2.50743958e-003,
-       3.37397307e-001, 2.13424429e-001, 8.01136158e-003,
-       -4.99300705e-003, 4.60651517e-002, 3.20640355e-002,
-       -4.27142996e-003, -1.06073003e-002, 4.94018868e-002,
-       3.32895257e-002, 5.94639592e-002, -5.89034334e-002,
-       3.24358553e-001, 2.39677593e-001, 7.89630786e-003,
-       -1.32399052e-001, 2.58479208e-001, 2.55604565e-001,
-       9.95129719e-003, -1.81891527e-002, 4.62219380e-002,
-       3.70838307e-002, 1.52333116e-004, -6.90068773e-005,
-       5.42562315e-003, 4.23521735e-003, 1.66372850e-003,
-       1.28490687e-003, 3.51890586e-002, 3.92919183e-002,
-       3.73867573e-004, 2.11879914e-003, 3.23241800e-002,
-       4.05631587e-002, 1.00262032e-003, 9.68229870e-006,
-       4.77328617e-003, 5.36736660e-003, 5.59988339e-003,
-       1.71302434e-003, 9.29309614e-003, 6.47302484e-003,
-       -4.59645735e-003, 3.71168144e-002, 3.84372808e-002,
-       5.78700900e-002, -5.33113815e-003, 3.04497238e-002,
-       3.59558314e-002, 6.14841878e-002, 1.32748648e-003,
-       2.76901806e-003, 5.07515715e-003, 8.23519100e-003,
-       8.58329460e-002, -6.09076815e-004, 9.94224697e-002,
-       3.74424681e-002, 8.84357914e-002, 1.71468392e-001,
-       2.04253390e-001, 2.39608839e-001, -3.42158340e-002,
-       2.65012383e-001, 1.43150672e-001, 3.07535440e-001,
-       -1.11470735e-002, 3.08231525e-002, 2.83209756e-002,
-       4.37656641e-002, 7.72918537e-002, -2.22982019e-002,
-       9.09510180e-002, 4.84188721e-002, 1.91579327e-001,
-       -2.72829920e-001, 2.44132787e-001, 3.46910506e-001,
-       -2.33611465e-003, -2.10956976e-001, 1.12750165e-001,
-       2.95897692e-001, -1.68745276e-002, -2.35843658e-002,
-       2.94871461e-002, 4.29613255e-002, 1.46999431e-003,
-       -2.40769540e-003, 6.25330396e-003, 9.44812875e-003,
-       7.73691572e-003, -7.90743157e-002, 3.28901038e-002,
-       1.18888989e-001, 7.73730502e-003, -1.02619477e-001,
-       2.89676040e-002, 1.41587704e-001, 1.35345687e-003,
-       -1.14994198e-002, 4.71179234e-003, 1.76804587e-002,
-       -8.73311516e-003, -2.96265032e-004, 1.31530138e-002,
-       5.27545484e-003, 1.41940592e-002, -8.57935026e-002,
-       6.83441758e-002, 9.64536294e-002, 1.07343040e-001,
-       -1.39529034e-001, 1.56038627e-001, 1.71288803e-001,
-       -1.30320806e-002, -3.96915246e-003, 1.64081622e-002,
-       1.33022992e-002, -1.25990793e-001, 5.44561120e-003,
-       1.54320180e-001, 3.61218974e-002, -5.55622987e-002,
-       -7.65958354e-002, 1.95310727e-001, 1.38151035e-001,
-       2.33739898e-001, -2.59036362e-001, 3.00421804e-001,
-       3.34109515e-001, 2.88515873e-002, -5.60630932e-002,
-       5.90530410e-002, 7.18742236e-002, -1.59539893e-001,
-       1.51301799e-002, 1.84768245e-001, 4.64650504e-002,
-       -2.43076030e-002, 7.57834464e-002, 1.82631075e-001,
-       2.01535776e-001, 1.15698718e-001, 6.39441833e-002,
-       1.74167827e-001, 1.68023631e-001, 3.01340576e-002,
-       6.57773402e-004, 4.46980670e-002, 2.84471400e-002,
-       -1.31297661e-002, 3.88145796e-003, 2.00503655e-002,
-       1.21191368e-002, 5.94441220e-003, 1.06587470e-001,
-       5.12968004e-002, 1.39909685e-001, -2.50547957e-002,
-       9.30951163e-002, 5.10406606e-002, 1.32480562e-001,
-       1.30955724e-003, 4.51177033e-003, 5.95032703e-003,
-       1.21263992e-002, -9.01567633e-004, -6.71040209e-004,
-       3.17750755e-003, 2.90092872e-003, 2.93604890e-003,
-       -1.61952469e-002, 2.17293389e-002, 2.41308901e-002,
-       7.78268501e-002, -2.46687774e-002, 8.85305628e-002,
-       3.81748118e-002, 3.88341793e-003, 3.45479394e-003,
-       1.10849636e-002, 5.39862877e-003, -1.23523623e-002,
-       1.37991563e-003, 2.26786137e-002, 1.53907649e-002,
-       -2.22730767e-002, 1.29416874e-002, 9.79454145e-002,
-       9.13293734e-002, 4.68888909e-001, -7.45782182e-002,
-       5.53779304e-001, 1.63228437e-001, 7.25829154e-002,
-       -1.12544922e-002, 1.04465850e-001, 2.86082737e-002,
-       -1.23833250e-002, 4.83490806e-003, 2.30499953e-002,
-       1.57644656e-002, -1.40017001e-002, 3.47276106e-002,
-       9.72236991e-002, 8.22671726e-002, 2.72090346e-001,
-       -1.23575274e-002, 3.76874745e-001, 1.20924078e-001,
-       1.15669660e-001, -2.19954364e-002, 1.37529418e-001,
-       3.54014896e-002, -9.06514702e-004, 1.11622759e-003,
-       3.44248302e-003, 3.20737483e-003, -2.31525931e-003,
-       1.34160165e-002, 1.92502569e-002, 2.14159545e-002,
-       2.71839499e-002, 1.26957502e-002, 4.68544587e-002,
-       2.35981233e-002, 1.42000625e-002, -3.48547054e-003,
-       1.77302659e-002, 5.92808332e-003, 2.32379641e-002,
-       -5.25489915e-003, 2.89710294e-002, 9.38143115e-003,
-       6.06249794e-002, 1.82796493e-002, 8.27816278e-002,
-       3.36056054e-002, 1.06068968e-003, 1.37684196e-002,
-       2.32883655e-002, 2.14003101e-002, -8.55620237e-005,
-       2.71067285e-004, 2.56011984e-003, 1.87297945e-003,
-       2.38402665e-001, 6.86540361e-003, 2.64383495e-001,
-       3.54370214e-002, 3.69333506e-001, 4.68392782e-002,
-       4.44394797e-001, 9.54948515e-002, -1.39188971e-002,
-       1.93603393e-002, 7.08659962e-002, 5.41271567e-002,
-       -8.42405390e-003, 2.71851337e-003, 1.57117266e-002,
-       8.81020911e-003, 2.65057325e-001, 1.33905662e-002,
-       2.84654349e-001, 3.25007215e-002, 2.92220950e-001,
-       -2.00551227e-002, 3.65475953e-001, 9.52477306e-002,
-       -1.41089028e-002, -1.50714805e-002, 6.37156218e-002,
-       5.10072708e-002, -9.46419407e-003, -4.10920614e-003,
-       1.62612703e-002, 1.13658784e-002, 3.11257821e-002,
-       4.53709951e-003, 3.36387604e-002, 8.17076582e-003,
-       4.19874638e-002, -2.52019130e-002, 6.54499754e-002,
-       4.11823615e-002, 5.47064294e-004, -2.30084565e-002,
-       2.10976079e-002, 3.08011528e-002, -1.11414003e-003,
-       -1.14384014e-003, 3.17322928e-003, 3.83398170e-003,
-       -1.57899526e-003, -4.13291808e-003, 8.43590870e-003,
-       7.99330603e-003, 3.43958922e-002, -6.59522042e-002,
-       5.72937131e-002, 8.26737806e-002, 2.85807513e-002,
-       -5.32896705e-002, 6.78831637e-002, 8.16897750e-002,
-       3.95463360e-003, 4.75657405e-004, 1.36386286e-002,
-       7.80364545e-003, -3.94968353e-002, -3.81128583e-003,
-       5.63770384e-002, 3.24881189e-002, 2.52660345e-002,
-       -1.19644493e-001, 1.73955977e-001, 2.01824069e-001,
-       1.79489613e-001, -3.16967994e-001, 3.43316615e-001,
-       3.66257936e-001, 1.37954012e-001, -1.43703213e-002,
-       1.83049187e-001, 4.56292853e-002, -3.18362266e-002,
-       1.89066343e-002, 5.55861630e-002, 3.49441804e-002,
-       -9.65992138e-002, 1.08612977e-001, 1.79961830e-001,
-       1.68873459e-001, 1.23454414e-001, 8.00265223e-002,
-       2.59060264e-001, 1.66611254e-001, 1.60219550e-001,
-       -6.42421283e-003, 2.01646894e-001, 3.89300436e-002,
-       -1.82872138e-003, -1.21824043e-004, 6.93430379e-003,
-       5.44634927e-003, -1.50113320e-002, 1.44005567e-002,
-       3.60265337e-002, 3.80336009e-002, 1.32540548e-002,
-       1.38102686e-002, 4.35172170e-002, 3.99822257e-002,
-       1.48715684e-002, -1.96879287e-003, 2.18772572e-002,
-       6.04122691e-003, -1.80603880e-002, 3.42165725e-003,
-       2.26863362e-002, 6.69563981e-003, -2.57283300e-002,
-       -1.43095218e-002, 4.62224819e-002, 2.96645574e-002,
-       6.83449721e-003, -9.96981002e-003, 2.47344449e-002,
-       2.30757222e-002, 1.74231792e-003, 5.07917372e-004,
-       4.91782697e-003, 3.38517339e-003, -2.00532272e-001,
-       1.93203073e-002, 2.27027074e-001, 4.34132069e-002,
-       -1.59467310e-001, 1.11828884e-002, 3.03548187e-001,
-       1.34803355e-001, 7.09123015e-002, 3.71835008e-002,
-       1.58790559e-001, 1.25229269e-001, 2.17518285e-002,
-       3.82123189e-003, 3.96100469e-002, 2.14699842e-002,
-       -2.08548278e-001, 1.92565769e-002, 2.40116328e-001,
-       4.45325300e-002, -1.48952186e-001, 2.67847538e-001,
-       3.74230087e-001, 3.08942169e-001, 9.28772497e-004,
-       1.41403109e-001, 1.84651092e-001, 2.03379169e-001,
-       2.20369007e-002, 1.05770696e-002, 4.27785367e-002,
-       2.95586810e-002, -1.23484246e-002, 6.48107962e-004,
-       2.20085792e-002, 7.42822560e-003, -3.10762059e-002,
-       6.87905326e-002, 8.20134953e-002, 8.78421441e-002,
-       -2.62798201e-002, 5.56517839e-002, 5.10867722e-002,
-       6.81435391e-002, 7.78003523e-005, 3.31580010e-003,
-       7.40378723e-003, 6.82929484e-003, -1.16520014e-003,
-       -3.50329326e-003, 3.93039733e-003, 6.05288474e-003,
-       -1.44932640e-003, -2.79454980e-002, 2.35758089e-002,
-       3.75214852e-002, 3.57960910e-002, -3.84781882e-002,
-       6.90986067e-002, 4.96469587e-002, 2.95826830e-002,
-       4.37073596e-003, 4.65552174e-002, 8.95102974e-003,
-       -1.26990974e-002, -5.25877485e-003, 2.28465628e-002,
-       1.94722824e-002, -2.27956437e-002, -3.04060280e-002,
-       1.05464503e-001, 1.05113313e-001, 1.69866025e-001,
-       -6.35107756e-002, 3.12670082e-001, 1.37495831e-001,
-       3.13361079e-001, -6.58902340e-003, 3.99461776e-001,
-       4.11871746e-002, -1.28430696e-002, 1.01598967e-002,
-       2.56596878e-002, 1.91458985e-002, -2.38159969e-002,
-       7.32836202e-002, 1.12053163e-001, 1.07124127e-001,
-       1.02870204e-001, 6.21872358e-002, 2.80696094e-001,
-       1.13716990e-001, 3.23663473e-001, -9.12736077e-003,
-       4.04724121e-001, 3.94104794e-002, -1.62818073e-003,
-       4.72497661e-003, 4.65753255e-003, 7.87023548e-003,
-       -1.42819306e-003, 4.28009033e-002, 2.80283615e-002,
-       6.68943450e-002, 4.94110584e-003, 2.53343172e-002,
-       5.31894639e-002, 4.55614068e-002, 3.70860323e-002,
-       -3.22115631e-003, 4.78403121e-002, 7.63620576e-003,
-       -1.31725578e-003, 2.85196258e-003, 4.01563803e-003,
-       7.37627968e-003, -6.29378334e-002, 6.51164055e-002,
-       7.56453425e-002, 9.12300199e-002, -1.05439480e-002,
-       7.95619562e-002, 6.20942116e-002, 1.13587290e-001,
-       -3.81259946e-003, 2.21663318e-003, 1.40280044e-002,
-       8.59492086e-003, 5.18649491e-003, 6.12037256e-003,
-       2.23718733e-002, 2.27380041e-002, -7.00574666e-002,
-       1.31534964e-001, 1.82413295e-001, 1.97621107e-001,
-       -6.87815920e-002, 2.63437390e-001, 2.44498685e-001,
-       3.70128244e-001, -1.26506284e-001, 1.42223164e-002,
-       1.59295842e-001, 5.89584485e-002, 1.19446917e-002,
-       -1.59429628e-002, 2.72178967e-002, 3.17737162e-002,
-       -2.71188598e-002, -8.68504122e-002, 1.38739750e-001,
-       1.86675951e-001, -1.40978560e-001, -1.84341788e-001,
-       2.58360595e-001, 2.66163856e-001, -1.07511915e-001,
-       -9.61795170e-003, 1.50227547e-001, 5.96396588e-002,
-       -1.28242915e-004, -1.45297162e-002, 6.71864441e-003,
-       1.90117452e-002, -2.77217384e-002, -1.40178517e-001,
-       5.34226187e-002, 1.68228701e-001, -5.46801044e-003,
-       -1.33699685e-001, 5.43692261e-002, 1.61031500e-001,
-       -4.08629281e-003, -6.31647371e-003, 1.43179009e-002,
-       1.44188693e-002, 7.20773404e-003, -1.08039344e-003,
-       1.58877410e-002, 5.61290188e-003, 3.21011357e-002,
-       4.40617912e-002, 5.53035028e-002, 5.41140251e-002,
-       -1.17129758e-002, 4.26699333e-002, 4.80313674e-002,
-       5.58231771e-002, -1.79779623e-002, -5.79153420e-004,
-       2.55838279e-002, 8.92208517e-003, 9.22345370e-002,
-       1.20251281e-002, 1.16040133e-001, 3.58671956e-002,
-       2.34262869e-001, 2.39307936e-002, 3.12692881e-001,
-       1.56017065e-001, -2.24983152e-002, 5.65324090e-002,
-       2.67311245e-001, 1.74979240e-001, -1.92895502e-001,
-       3.52373836e-003, 2.27009490e-001, 5.61031774e-002,
-       1.16468407e-001, 8.01826920e-003, 1.40487924e-001,
-       2.86860559e-002, 8.11902657e-002, -2.50531882e-002,
-       2.68358916e-001, 1.36613727e-001, 2.41586044e-002,
-       -1.12819128e-001, 3.56344789e-001, 1.89534321e-001,
-       -1.75679281e-001, -4.35267854e-003, 2.21132040e-001,
-       4.08056043e-002, 1.26955481e-002, 2.36365618e-003,
-       1.79749727e-002, 4.61699395e-003, -1.84053928e-002,
-       -3.04329153e-002, 6.73262402e-002, 4.25412357e-002,
-       -8.53231363e-003, -7.05022290e-002, 7.81466588e-002,
-       7.54325464e-002, -1.02863191e-002, -2.93857534e-003,
-       2.17440259e-002, 7.41611188e-003, -2.47597359e-002,
-       2.49445951e-003, 3.15877758e-002, 6.06227480e-003,
-       -5.05666025e-002, -1.54739702e-002, 6.44001737e-002,
-       2.73920204e-002, -5.09730948e-004, -1.16559416e-002,
-       1.93075817e-002, 2.19773650e-002, 1.16108602e-003,
-       -9.03045293e-004, 3.31779383e-003, 3.01444391e-003,
-       -2.30419204e-001, 2.50473176e-003, 2.76444644e-001,
-       3.01350206e-002, -3.13921630e-001, -2.40830574e-002,
-       3.88626546e-001, 1.07829839e-001, -6.76530832e-003,
-       -1.81471668e-002, 1.02409691e-001, 8.51773843e-002,
-       1.24582835e-002, -2.62532826e-003, 2.38880571e-002,
-       1.50719108e-002, -2.37691954e-001, -8.61239713e-003,
-       2.84230262e-001, 3.33867297e-002, -2.96004921e-001,
-       5.26871718e-002, 3.71568859e-001, 1.48500398e-001,
-       2.49161082e-003, 6.17422312e-002, 1.10814176e-001,
-       1.29722670e-001, 1.00924615e-002, 6.64435187e-003,
-       2.34634578e-002, 1.92077290e-002, -2.36092918e-002,
-       -2.91618379e-003, 3.02643515e-002, 9.16731078e-003,
-       -2.50446573e-002, 6.03477843e-002, 6.89561069e-002,
-       8.83836970e-002, -8.71155690e-003, 6.39709830e-002,
-       3.66609693e-002, 9.21602696e-002, -1.05720793e-003,
-       5.24457730e-003, 4.43346845e-003, 9.79377329e-003,
-       5.57302148e-004, 1.15439796e-003, 3.92750697e-003,
-       3.12922057e-003, -5.71732642e-003, 2.45009065e-002,
-       3.78852561e-002, 3.75423953e-002, -5.27135842e-002,
-       2.74700262e-002, 8.66812468e-002, 4.46223319e-002,
-       1.33825724e-005, -3.03541805e-004, 5.84903313e-003,
-       4.52302070e-003, 1.42743886e-002, 3.82958306e-003,
-       2.78293286e-002, 1.41082928e-002, 2.04094909e-002,
-       5.16655333e-002, 1.31353334e-001, 1.12603672e-001,
-       -3.43036473e-001, 1.83837950e-001, 5.73568463e-001,
-       2.40373090e-001, -2.08034143e-002, 2.31251065e-002,
-       5.65174669e-002, 4.27107438e-002, 1.39991362e-002,
-       -8.50635115e-003, 2.88135521e-002, 2.01325882e-002,
-       -8.39824323e-003, -1.35288224e-001, 1.22661144e-001,
-       1.86894998e-001, -1.11594044e-001, -1.55173317e-001,
-       2.48389468e-001, 2.93729544e-001, -5.13114929e-002,
-       1.03787249e-002, 6.95244893e-002, 5.44045679e-002,
-       -8.39073560e-004, -1.90486154e-003, 5.13474457e-003,
-       5.79105830e-003, -2.24558860e-002, -3.40926386e-002,
-       3.80256325e-002, 5.22457696e-002, -7.13752955e-003,
-       -3.08772940e-002, 3.52728553e-002, 5.23030013e-002,
-       -1.51626649e-003, -1.35737238e-003, 6.16440596e-003,
-       5.93446521e-003, 5.42144710e-003, 4.60648298e-004,
-       8.53316020e-003, 6.23580627e-003, -1.39827151e-002,
-       2.53829435e-002, 3.40735801e-002, 3.99512202e-002,
-       -5.46334404e-003, 2.36028228e-002, 2.99196169e-002,
-       3.97813916e-002, -1.22632447e-003, 1.81829964e-003,
-       6.05830876e-003, 5.66651998e-003, 9.61474851e-002,
-       -2.74193827e-002, 1.03648238e-001, 4.61002886e-002,
-       -1.05032220e-001, 9.30551738e-002, 2.88791597e-001,
-       1.98862642e-001, 5.77209182e-002, 1.57411933e-001,
-       2.06085637e-001, 2.15129048e-001, -3.30203883e-002,
-       1.70280281e-002, 5.62255308e-002, 3.39509882e-002,
-       5.53619377e-002, -3.24091800e-002, 7.93005601e-002,
-       5.14482260e-002, 2.74235308e-001, -1.00711212e-001,
-       4.60091561e-001, 3.27564448e-001, -7.25335851e-002,
-       1.48206782e-002, 2.18435988e-001, 2.07124755e-001,
-       -3.08191422e-002, -5.43476548e-003, 5.24915233e-002,
-       3.05754896e-002, -1.92884915e-003, 3.39482911e-003,
-       7.65309576e-003, 6.08912297e-003, 6.41766340e-002,
-       -4.66941595e-002, 7.98886195e-002, 6.87892660e-002,
-       -8.57512467e-003, -3.29010561e-002, 4.25806977e-002,
-       4.77607995e-002, -8.59156076e-004, -6.59302459e-004,
-       5.56133129e-003, 4.32816148e-003, -2.02884548e-004,
-       -5.10847749e-005, 4.69313189e-003, 2.95974570e-003,
-       3.41564119e-002, 2.54477747e-002, 4.76921722e-002,
-       3.53121683e-002, -5.60492417e-003, 2.71143038e-002,
-       3.57408486e-002, 3.70954163e-002, -2.77766748e-003,
-       3.85665859e-004, 5.00153610e-003, 3.65482876e-003,
-       2.38988791e-002, 1.38407936e-002, 4.45925593e-002,
-       2.60501988e-002, 2.21807510e-001, 2.05907419e-001,
-       3.86589020e-001, 2.55959392e-001, -1.44060716e-001,
-       2.06038728e-002, 2.44246513e-001, 1.60548672e-001,
-       -3.61935310e-002, -1.47429470e-003, 4.44673486e-002,
-       2.36029811e-002, 4.64454293e-002, 9.86780040e-003,
-       6.14871904e-002, 2.64012665e-002, -3.54809649e-002,
-       -5.97414002e-002, 4.60920662e-001, 1.85958534e-001,
-       -1.39554590e-001, -1.74606547e-001, 2.49421403e-001,
-       2.19785839e-001, -2.87548136e-002, -1.24701792e-002,
-       3.98490429e-002, 2.53598634e-002, 4.34497232e-003,
-       -1.64722034e-004, 7.38438126e-003, 3.87908635e-003,
-       -1.56984832e-002, -2.88501102e-002, 5.34661859e-002,
-       3.77516076e-002, -1.88391060e-002, -1.57075673e-002,
-       3.54725718e-002, 2.92595699e-002, -1.09411892e-003,
-       -1.91089828e-004, 4.22210386e-003, 3.22442688e-003,
-       -1.36062615e-002, 1.05247914e-003, 1.79585386e-002,
-       3.86288483e-003, -6.17308170e-003, -9.73103568e-003,
-       4.69529331e-002, 2.17833929e-002, 1.05656823e-002,
-       -1.06734205e-002, 2.79902183e-002, 2.60093212e-002,
-       3.04558454e-003, 2.10975966e-004, 6.54858071e-003,
-       4.03114501e-003, -1.30951539e-001, 5.71429776e-003,
-       1.53291121e-001, 2.22143419e-002, -3.21260914e-002,
-       -1.84248500e-002, 3.26950610e-001, 1.05043143e-001,
-       6.43414706e-002, -2.42694002e-003, 1.70530185e-001,
-       1.25270396e-001, 4.25674617e-002, 1.24265160e-002,
-       5.86441830e-002, 3.30683328e-002, -1.32363021e-001,
-       -1.44638529e-003, 1.49159253e-001, 3.01326197e-002,
-       3.31634209e-002, 1.10656016e-001, 3.54020745e-001,
-       1.76053196e-001, 2.15963557e-001, 3.58960688e-001,
-       2.70412385e-001, 3.91135663e-001, 3.47723812e-002,
-       5.21673486e-002, 6.21174723e-002, 6.15952797e-002,
-       -1.20083997e-002, -5.25435200e-004, 1.52393831e-002,
-       5.88657660e-003, 3.68944481e-002, 4.92485091e-002,
-       7.44043142e-002, 5.85696064e-002, 4.26059440e-002,
-       3.97698432e-002, 6.20104410e-002, 6.21217713e-002,
-       -2.99512106e-003, -1.51346321e-003, 7.67024234e-003,
-       7.29140267e-003, -2.19081100e-002, 1.62938784e-003,
-       3.02054062e-002, 5.55407722e-003, -9.43394378e-003,
-       -1.43591547e-002, 4.09824364e-002, 2.63625402e-002,
-       2.39185784e-002, -1.00178551e-002, 4.61641885e-002,
-       2.61390153e-002, 1.13441171e-002, 2.41404329e-003,
-       1.88232455e-002, 5.64646441e-003, -2.08024487e-001,
-       3.43158143e-003, 2.64386088e-001, 2.56371889e-002,
-       -4.95990366e-002, -3.70232016e-002, 2.08310276e-001,
-       9.33615491e-002, 2.46271312e-001, -2.53092051e-002,
-       3.50821316e-001, 9.94852036e-002, 9.28793773e-002,
-       1.29044745e-002, 1.52942255e-001, 3.02331895e-002,
-       -2.12025717e-001, -3.69173568e-003, 2.69855589e-001,
-       2.76996456e-002, -6.49028048e-002, 7.64461467e-003,
-       1.92067370e-001, 9.61353406e-002, 3.17508519e-001,
-       2.83307713e-002, 3.87722969e-001, 1.09714970e-001,
-       7.65533149e-002, -9.83712729e-004, 1.42217726e-001,
-       3.30454856e-002, -2.29455680e-002, -2.71740695e-003,
-       2.94756480e-002, 5.55390632e-003, -7.71900453e-003,
-       1.11731114e-002, 3.50102931e-002, 2.33130679e-002,
-       4.22947407e-002, 1.16984798e-002, 5.90405278e-002,
-       2.79223211e-002, 7.87995383e-003, -2.59227748e-003,
-       1.72567181e-002, 6.71987329e-003, -1.20394416e-002,
-       1.48220779e-003, 1.54185202e-002, 4.02399153e-003,
-       -3.16616073e-002, -1.11894216e-002, 4.71948758e-002,
-       2.24794503e-002, 8.71130172e-003, -8.97126738e-003,
-       2.39553917e-002, 2.07301322e-002, 3.49693699e-003,
-       3.82516955e-005, 8.44262820e-003, 4.49021626e-003,
-       -1.07319616e-001, 4.09964100e-003, 1.27259463e-001,
-       2.49791071e-002, -2.05961257e-001, -1.45705428e-003,
-       2.82777041e-001, 9.76810083e-002, 1.04983971e-001,
-       6.27673343e-002, 1.95430219e-001, 1.35582119e-001,
-       3.18247303e-002, 3.23163345e-002, 7.23246485e-002,
-       4.82086129e-002, -1.06010363e-001, -3.42765055e-003,
-       1.24640450e-001, 2.33189259e-002, -2.02040046e-001,
-       3.41712981e-002, 2.79922366e-001, 1.09340549e-001,
-       3.87853682e-001, 1.60595685e-001, 4.67429608e-001,
-       2.18994945e-001, -1.81544274e-002, 3.53516899e-002,
-       9.01426375e-002, 5.64363487e-002, -1.08309556e-002,
-       -1.47121947e-003, 1.38413021e-002, 3.97847919e-003,
-       -2.33413633e-002, 1.77652333e-002, 4.94348630e-002,
-       3.01202126e-002, 6.82704821e-002, 2.31151897e-002,
-       8.54375437e-002, 4.42842767e-002, -6.28036587e-003,
-       -2.79220403e-003, 1.20545514e-002, 6.98712841e-003,
-       1.90917854e-004, -4.43690456e-004, 5.16694738e-003,
-       5.04565705e-003, -2.04068888e-002, -1.84633527e-002,
-       4.11882885e-002, 4.40061092e-002, 9.11508501e-003,
-       -2.38819681e-002, 4.11570966e-002, 4.43160497e-002,
-       1.77409023e-003, -2.49434117e-004, 6.47644885e-003,
-       5.20561589e-003, -2.92123184e-002, -2.49857530e-002,
-       4.60102819e-002, 4.47427407e-002, -1.35693878e-001,
-       -2.03182861e-001, 2.12718219e-001, 2.92544812e-001,
-       1.14241533e-001, -1.67951614e-001, 2.54352748e-001,
-       2.49058425e-001, 4.72151414e-002, -5.37572196e-003,
-       6.59130439e-002, 4.01720591e-002, -3.41837704e-002,
-       3.01572704e-003, 4.75505292e-002, 3.28899547e-002,
-       -1.36454478e-002, 1.20497242e-001, 1.89006343e-001,
-       1.88455716e-001, 1.41477108e-001, 2.47198462e-001,
-       4.41509724e-001, 3.02717835e-001, 4.06770036e-002,
-       2.45115012e-002, 7.10767284e-002, 4.44169603e-002,
-       -1.71653950e-003, 9.73282207e-004, 5.35577536e-003,
-       4.58281301e-003, 5.04510291e-003, 2.05228347e-002,
-       3.87891904e-002, 3.46267521e-002, 2.91174557e-002,
-       1.74555071e-002, 6.93410411e-002, 3.95450965e-002,
-       -5.26728363e-005, -1.09300902e-003, 7.95292761e-003,
-       5.56783006e-003, 9.08821763e-004, -2.24834145e-003,
-       4.68082214e-003, 5.91779687e-003, 1.83910376e-003,
-       -2.94795800e-002, 3.49223502e-002, 4.86294664e-002,
-       -1.03316391e-002, -3.16753127e-002, 3.19195725e-002,
-       4.74771969e-002, 3.04021756e-004, -2.95576360e-003,
-       4.55233548e-003, 5.67006413e-003, -2.17900854e-002,
-       -2.08423510e-002, 3.41358930e-002, 4.04675342e-002,
-       5.79713881e-002, -1.85442120e-001, 1.86351612e-001,
-       2.75540262e-001, -4.15417030e-002, -1.30092099e-001,
-       1.42073527e-001, 2.15910167e-001, 2.25388911e-002,
-       -9.21247434e-003, 3.27286124e-002, 3.18597667e-002,
-       -1.55554479e-002, 3.98783349e-002, 2.99257468e-002,
-       4.91307750e-002, 2.86417250e-002, 3.59979063e-001,
-       1.40617162e-001, 3.99027705e-001, 2.85316110e-002,
-       3.59043926e-001, 1.26061156e-001, 4.03767914e-001,
-       1.83028840e-002, 4.51066680e-002, 3.15215997e-002,
-       5.35620041e-002, 1.45748863e-003, 3.46826646e-003,
-       4.07011900e-003, 5.77551872e-003, 7.65740499e-003,
-       2.79508885e-002, 2.36673411e-002, 4.47407551e-002,
-       -3.33503383e-004, 2.37928610e-002, 1.93922985e-002,
-       4.15808633e-002, -1.30219467e-003, 2.02090666e-003,
-       3.90930055e-003, 4.89130989e-003, -6.05806068e-004,
-       -2.92351027e-003, 7.88010098e-003, 7.08801532e-003,
-       9.89010558e-003, -3.98767404e-002, 3.72068100e-002,
-       5.99054396e-002, -2.17520948e-002, -2.97880098e-002,
-       4.88797240e-002, 5.17962873e-002, 3.53855212e-005,
-       -3.33034608e-004, 7.41690025e-003, 5.01275714e-003,
-       -5.51024526e-002, -2.67200195e-003, 6.93046227e-002,
-       3.24157812e-002, 3.09197046e-002, -1.49361372e-001,
-       1.95004344e-001, 2.24164456e-001, -1.27384216e-001,
-       -2.23411918e-001, 2.58619905e-001, 2.77117729e-001,
-       5.07877544e-002, -1.27773639e-002, 6.42648041e-002,
-       3.48535739e-002, -5.46033010e-002, 3.93911786e-002,
-       7.17816129e-002, 5.05776368e-002, -8.39272514e-002,
-       3.02607536e-001, 2.14085236e-001, 3.62470061e-001,
-       -1.67579457e-001, 1.59429029e-001, 2.89740264e-001,
-       2.30624706e-001, 5.86073473e-002, 9.54948366e-003,
-       7.72162080e-002, 3.04335654e-002, 6.49370253e-004,
-       -1.87737169e-004, 7.54403742e-003, 7.10637402e-003,
-       -1.28461560e-002, 4.53343801e-002, 4.66500409e-002,
-       7.08684921e-002, -5.34336083e-002, 4.19693179e-002,
-       7.20108747e-002, 6.20908476e-002, 2.18614750e-003,
-       1.07705803e-003, 8.83576367e-003, 4.50497214e-003,
-       -9.50324698e-004, 3.47396568e-003, 6.58482732e-003,
-       9.47102811e-003, 1.81556232e-002, 7.84319714e-002,
-       4.78195958e-002, 1.05147243e-001, -7.89934956e-003,
-       8.52155089e-002, 4.42460850e-002, 1.12552427e-001,
-       -2.19299644e-003, 4.61396761e-003, 8.35671369e-003,
-       9.85286571e-003, 1.84137858e-002, 5.82196303e-002,
-       5.98505400e-002, 7.60253593e-002, 2.69996971e-001,
-       2.74832577e-001, 3.47938180e-001, 4.02189672e-001,
-       -1.62171215e-001, 2.29011938e-001, 2.56482810e-001,
-       3.33429575e-001, -7.62702227e-002, 2.83829905e-002,
-       1.13329701e-001, 5.18410094e-002, 2.53723878e-002,
-       2.85243113e-002, 4.37922440e-002, 4.29126285e-002,
-       2.55283918e-002, 5.23957796e-002, 1.32534027e-001,
-       1.32073879e-001, -5.68600856e-002, 1.12185292e-002,
-       1.46881893e-001, 1.03744917e-001, -8.23501199e-002,
-       1.91164147e-002, 1.11492746e-001, 3.73669825e-002,
-       1.29195920e-003, 9.62972263e-005, 3.51895741e-003,
-       3.24542797e-003, 5.53198915e-004, -7.78890820e-003,
-       1.70703549e-002, 1.80437490e-002, -8.09771009e-003,
-       -7.41679268e-003, 2.04795580e-002, 1.97210610e-002,
-       -7.19455350e-003, 8.75104975e-004, 1.11770155e-002,
-       3.96838132e-003, -5.63427247e-003, 1.11700571e-003,
-       1.05389189e-002, 3.67103121e-003, -4.39266488e-002,
-       -1.29531985e-002, 5.61705716e-002, 2.30689961e-002,
-       2.36553513e-002, -8.02992936e-003, 4.12214249e-002,
-       2.24872194e-002, 6.58289576e-003, 3.15606827e-003,
-       1.10693313e-002, 5.73476916e-003, -6.78739697e-002,
-       2.58149044e-003, 9.46369022e-002, 2.38442887e-002,
-       -3.07767421e-001, -3.99018899e-002, 3.55418146e-001,
-       1.05499983e-001, 2.46170253e-001, 9.72394599e-004,
-       3.11702579e-001, 1.22805834e-001, 6.14283048e-002,
-       5.49100898e-003, 9.00931060e-002, 4.14946601e-002,
-       -9.00401548e-002, -8.78764503e-003, 1.10800855e-001,
-       2.45537031e-002, -2.15711907e-001, 1.72357168e-002,
-       2.92681694e-001, 1.09947354e-001, 2.97381401e-001,
-       1.44300267e-001, 3.45713973e-001, 1.87802926e-001,
-       4.47225459e-002, 7.95229524e-003, 7.51055479e-002,
-       3.60214524e-002, -1.11893108e-002, -1.93728833e-003,
-       1.40377367e-002, 4.14076168e-003, -8.45494308e-003,
-       1.87067688e-002, 4.45654355e-002, 2.84636300e-002,
-       4.83300649e-002, 2.63806563e-002, 6.34109676e-002,
-       3.93242091e-002, 1.14565599e-003, -3.13568220e-004,
-       7.85825402e-003, 5.25389053e-003, 2.44294060e-003,
-       2.42750184e-003, 4.78296634e-003, 5.26289502e-003,
-       1.14642894e-002, 4.30778749e-002, 3.58578935e-002,
-       5.83167672e-002, -2.54779644e-002, 2.60548703e-002,
-       4.00348082e-002, 4.51852977e-002, 2.72473117e-004,
-       1.01199863e-003, 4.48874431e-003, 4.69636405e-003,
-       2.82162335e-002, -3.98120191e-003, 4.15835157e-002,
-       3.45985219e-002, 1.76307589e-001, -3.77342924e-002,
-       2.83326983e-001, 2.93128550e-001, -2.01874346e-001,
-       1.28209829e-001, 2.65954554e-001, 2.59223312e-001,
-       -1.53193166e-002, 2.28801332e-002, 3.57125364e-002,
-       4.00145389e-002, 3.58659215e-002, 2.11239811e-002,
-       4.72436063e-002, 4.98791449e-002, 1.55122384e-001,
-       1.32576779e-001, 2.15446576e-001, 4.05249864e-001,
-       -6.00764453e-002, 1.08669348e-001, 1.60631984e-001,
-       3.16573739e-001, -2.39903964e-002, 2.32544169e-002,
-       4.16386761e-002, 4.67085503e-002, 7.38923787e-004,
-       -4.11611376e-003, 3.86038423e-003, 1.05979079e-002,
-       8.22571758e-003, -7.49883801e-002, 2.72722989e-002,
-       1.18851371e-001, 3.34989047e-003, -7.67947137e-002,
-       2.43261214e-002, 1.26759887e-001, 2.31939812e-005,
-       -6.89504948e-003, 4.86843893e-003, 1.34549541e-002,
-       2.65835179e-003, -5.65463037e-004, 5.64496685e-003,
-       3.90065624e-003, 2.91622207e-002, 2.32059136e-002,
-       4.20165956e-002, 3.74335647e-002, 9.71937552e-003,
-       2.71006674e-002, 3.54648158e-002, 3.89718972e-002,
-       -1.35485758e-003, 9.09453142e-004, 5.36696380e-003,
-       4.35321592e-003, 3.99548337e-002, 2.01310962e-003,
-       5.14443405e-002, 2.45061573e-002, 2.72968382e-001,
-       9.49313790e-002, 3.32186699e-001, 2.00856119e-001,
-       3.70291783e-003, 8.99963528e-002, 2.08381787e-001,
-       1.65421546e-001, -3.46575342e-002, -2.17440049e-003,
-       4.96577024e-002, 2.92146336e-002, 3.73614132e-002,
-       -1.06232213e-002, 4.80567254e-002, 2.60160547e-002,
-       2.44251937e-001, -2.38601699e-001, 3.36373001e-001,
-       2.88420022e-001, 7.25727007e-002, -1.59560084e-001,
-       3.35377723e-001, 2.24177107e-001, -4.14708853e-002,
-       -1.46759031e-002, 6.09082989e-002, 3.41559350e-002,
-       1.51184702e-003, -2.90232274e-004, 4.55083698e-003,
-       3.64449969e-003, 2.29397714e-002, -2.53504254e-002,
-       4.06986549e-002, 4.02112268e-002, 1.73116364e-002,
-       -4.11341190e-002, 5.39263301e-002, 5.31164370e-002,
-       -1.01077603e-003, -1.42367091e-003, 6.80600898e-003,
-       5.65620651e-003, -1.76228117e-004, -5.34199527e-004,
-       5.67487488e-003, 2.23183190e-003, 1.00441445e-002,
-       7.46616337e-004, 7.61599541e-002, 2.19836459e-002,
-       -2.33763756e-004, 4.26920597e-003, 2.85301916e-002,
-       1.94503982e-002, -7.69298174e-004, 2.36380074e-004,
-       5.38321771e-003, 2.52745836e-003, -4.30645328e-003,
-       -2.92758141e-005, 3.92679237e-002, 1.11128734e-002,
-       9.78806987e-002, 1.06478063e-002, 6.43846095e-001,
-       9.31661576e-002, -1.21229384e-002, 5.43623371e-003,
-       1.53589845e-001, 8.94345790e-002, 6.71541085e-004,
-       1.33169279e-003, 4.55232151e-002, 1.72809772e-002,
-       -8.95455573e-003, -5.90395299e-004, 4.25957069e-002,
-       1.18017578e-002, 1.24113195e-001, 3.96754313e-003,
-       5.90151131e-001, 9.92434621e-002, -3.63675840e-002,
-       2.11613905e-003, 1.64076895e-001, 8.79030004e-002,
-       4.84205550e-003, -1.11923995e-003, 4.67619449e-002,
-       1.71091389e-002, -2.68041942e-004, 7.30468659e-004,
-       5.96465589e-003, 2.45779031e-003, 1.50468834e-002,
-       -6.35766541e-004, 6.48049563e-002, 2.05660351e-002,
-       -4.61802725e-003, -8.25893949e-004, 2.85643954e-002,
-       1.90742183e-002, 2.14510248e-004, 3.58698853e-005,
-       5.31338062e-003, 3.06957681e-003, -2.19711731e-003,
-       3.75989545e-003, 5.80938021e-003, 7.42135942e-003,
-       -9.40195657e-003, 3.56943309e-002, 3.21472399e-002,
-       5.63004613e-002, 8.58347397e-003, 3.19095366e-002,
-       3.51317450e-002, 5.18210232e-002, -1.70136441e-003,
-       1.37849222e-003, 4.93236491e-003, 4.72068554e-003,
-       2.35266145e-002, 3.17094140e-002, 4.70931530e-002,
-       4.34285253e-002, -1.49594143e-001, 3.21884453e-001,
-       3.03081244e-001, 3.71884495e-001, -4.83593196e-002,
-       2.15402558e-001, 2.69723415e-001, 2.87446797e-001,
-       -4.87914644e-002, 9.16649494e-003, 6.32152185e-002,
-       3.05984486e-002, 3.00699007e-002, -9.80056543e-003,
-       4.73630391e-002, 2.98659895e-002, -1.28402382e-001,
-       -1.13855503e-001, 2.78228402e-001, 1.81477636e-001,
-       -1.15977041e-001, -6.86891750e-002, 2.60790676e-001,
-       1.68829679e-001, -4.92806546e-002, -3.75257782e-003,
-       6.63003176e-002, 2.87662987e-002, 4.72040119e-004,
-       -2.25436292e-003, 5.13981981e-003, 5.31879393e-003,
-       -1.36627564e-002, -3.26122828e-002, 4.23725657e-002,
-       4.75674570e-002, -1.11756455e-002, -3.11497133e-002,
-       3.84742841e-002, 4.72233221e-002, -3.76263307e-003,
-       -6.80940459e-004, 6.61981571e-003, 4.39543417e-003,
-       1.71720167e-003, -8.93132761e-003, 6.45093853e-003,
-       1.30165806e-002, -8.00827332e-003, -1.05911352e-001,
-       4.30164151e-002, 1.23715602e-001, -2.77498970e-003,
-       -9.34844688e-002, 5.47177382e-002, 1.09229900e-001,
-       1.67970490e-002, -1.49340834e-003, 2.46030111e-002,
-       9.84680559e-003, -2.68313084e-002, -2.39563501e-003,
-       5.02900258e-002, 3.45724262e-002, -4.43177558e-002,
-       -1.25150278e-001, 2.02189520e-001, 2.34211206e-001,
-       3.57102565e-002, -1.00962497e-001, 2.73136109e-001,
-       1.87526479e-001, 2.32135013e-001, 7.18920678e-003,
-       2.87316889e-001, 3.54088843e-002, -3.48386765e-002,
-       1.92256700e-002, 5.87226525e-002, 3.49941440e-002,
-       -1.15558021e-001, 9.01991948e-002, 2.35425428e-001,
-       1.86392307e-001, 4.61034589e-002, 5.44133782e-003,
-       3.05017442e-001, 1.43867388e-001, 2.43313387e-001,
-       -4.91690589e-003, 3.06260169e-001, 3.67767029e-002,
-       -3.33225960e-003, 2.58146174e-004, 8.49048421e-003,
-       5.97780198e-003, -2.19489560e-002, 1.84392650e-002,
-       4.72883843e-002, 4.19946574e-002, -2.15081847e-003,
-       1.52263707e-002, 5.23376577e-002, 2.96893362e-002,
-       2.73985155e-002, -2.24781269e-003, 3.51949856e-002,
-       5.32059791e-003, -4.98826965e-004, -7.86616467e-004,
-       5.61828911e-003, 3.92779103e-003, 2.08379934e-003,
-       -1.51677011e-002, 3.29723507e-002, 3.30230743e-002,
-       2.20715571e-002, -1.84691418e-002, 6.26353621e-002,
-       3.37988846e-002, 4.13050177e-003, 1.22256705e-003,
-       1.01178661e-002, 3.57012916e-003, -1.90855991e-002,
-       -1.09308679e-002, 3.76139171e-002, 2.53926367e-002,
-       1.47567810e-002, -1.33801445e-001, 1.60411566e-001,
-       1.82990491e-001, 2.73802191e-001, -3.44406441e-002,
-       4.56929833e-001, 1.33629382e-001, 3.12037449e-002,
-       3.27451318e-003, 7.54952207e-002, 1.93592999e-002,
-       -2.17034556e-002, 2.11804714e-002, 3.84898819e-002,
-       3.37422490e-002, 5.62095223e-003, 1.79407462e-001,
-       1.46931037e-001, 2.38333121e-001, 3.15349489e-001,
-       1.25552535e-001, 4.25946593e-001, 2.01110229e-001,
-       2.50952411e-002, -1.48531585e-003, 6.91053867e-002,
-       2.34109145e-002, 6.31303468e-004, 2.79925787e-003,
-       5.48894471e-003, 6.71290560e-003, 7.32302084e-004,
-       4.11350690e-002, 3.49964574e-002, 5.92407137e-002,
-       2.18003839e-002, 3.85633595e-002, 4.91592735e-002,
-       5.43430112e-002, 5.02467796e-004, -8.96583661e-004,
-       7.22839311e-003, 4.10622451e-003, -2.36469693e-003,
-       2.71263561e-004, 4.97689843e-003, 3.04938667e-003,
-       -9.83248278e-003, -5.59934229e-003, 3.15804891e-002,
-       2.42151152e-002, -1.10283270e-002, -8.19462910e-003,
-       6.34602383e-002, 2.45484617e-002, 1.01309158e-002,
-       5.39142871e-004, 1.27740791e-002, 3.16218100e-003,
-       -2.48553865e-002, 2.47672549e-004, 3.89128886e-002,
-       2.04578023e-002, -5.01269698e-002, -1.79246217e-002,
-       1.74967915e-001, 1.20787494e-001, -8.15110952e-002,
-       -3.50112165e-003, 5.26133418e-001, 1.11585997e-001,
-       8.42057317e-002, 7.11752940e-003, 9.90618318e-002,
-       1.98723711e-002, -2.05349773e-002, 1.48062026e-002,
-       3.58609930e-002, 2.93250419e-002, -6.66814819e-002,
-       1.24696851e-001, 1.90271363e-001, 1.94310576e-001,
-       -4.31094393e-002, 1.07073799e-001, 5.53210735e-001,
-       1.76720738e-001, 6.80803806e-002, 7.76414759e-003,
-       8.86258036e-002, 2.51701549e-002, -9.97185474e-004,
-       1.86643552e-003, 4.12429031e-003, 5.09901671e-003,
-       -1.14785125e-002, 3.02784890e-002, 3.67218703e-002,
-       4.80510853e-002, -8.64030886e-003, 3.48282754e-002,
-       7.25332201e-002, 5.03628068e-002, 4.53823153e-003,
-       -2.16682292e-005, 9.85342171e-003, 3.73164890e-003,
-       -1.94692941e-004, 1.71271991e-003, 3.81085323e-003,
-       1.17606670e-002, 2.12176330e-003, 1.07581364e-002,
-       2.12716572e-002, 9.01039541e-002, 1.99449761e-003,
-       5.49176941e-003, 2.23083571e-002, 9.19591039e-002,
-       5.37800894e-004, -9.54411880e-005, 4.15082136e-003,
-       1.18904673e-002, 3.01529299e-002, 4.13118601e-002,
-       4.22038250e-002, 5.79419136e-002, 5.27448878e-002,
-       3.77283901e-001, 1.23703599e-001, 4.33074206e-001,
-       -2.83136871e-002, 3.73059660e-001, 1.09496817e-001,
-       4.29316461e-001, -2.27331743e-002, 4.62900698e-002,
-       3.62023115e-002, 6.08008727e-002, 3.39721180e-002,
-       -1.38534941e-002, 4.56226394e-002, 3.66528183e-002,
-       6.56210333e-002, -9.41200480e-002, 1.24774344e-001,
-       1.70637861e-001, -3.35848071e-002, -7.47112632e-002,
-       9.39033329e-002, 1.57536492e-001, -2.45438609e-002,
-       -1.09931203e-002, 3.61485034e-002, 2.91584730e-002,
-       5.10202895e-004, -6.71185786e-003, 4.67723422e-003,
-       1.45036038e-002, 4.27734805e-003, -9.38326120e-002,
-       2.82978676e-002, 1.46824166e-001, 1.11081827e-004,
-       -9.86573100e-002, 2.68268771e-002, 1.52261481e-001,
-       -3.17375758e-004, -9.29237530e-003, 4.71507153e-003,
-       1.67271588e-002, 1.07489747e-003, -1.18991057e-003,
-       6.00941805e-003, 9.55977477e-003, -2.57819407e-002,
-       -6.94254488e-002, 4.95845899e-002, 1.07062519e-001,
-       -2.04380769e-002, -7.40858763e-002, 4.44759540e-002,
-       9.78846699e-002, -4.33005480e-004, -4.06903401e-003,
-       5.85848466e-003, 8.29321519e-003, -3.31305116e-002,
-       -2.69517358e-002, 5.40309027e-002, 6.49120063e-002,
-       -1.23842880e-001, -3.10098212e-002, 3.07431936e-001,
-       4.69439119e-001, 4.42483369e-003, 1.87655576e-002,
-       1.86200306e-001, 2.93116808e-001, 1.90981738e-002,
-       -3.99299804e-003, 3.81703265e-002, 3.83973718e-002,
-       -3.66593599e-002, 1.24313589e-003, 5.99002540e-002,
-       4.75870967e-002, -7.70235360e-002, -9.95777473e-002,
-       2.46509165e-001, 3.29576254e-001, -2.98869843e-003,
-       -5.05827479e-002, 1.68728873e-001, 3.08404684e-001,
-       2.08542645e-002, -4.97112691e-004, 3.80443744e-002,
-       4.25783657e-002, -2.72934278e-003, 2.35216878e-003,
-       7.98216090e-003, 7.24953227e-003, -8.41944944e-003,
-       5.20406775e-002, 4.15498167e-002, 7.54703060e-002,
-       2.09320709e-003, 4.82900105e-002, 2.98782587e-002,
-       7.59602860e-002, -3.79317557e-004, 3.18133226e-003,
-       5.33585902e-003, 8.91746208e-003, -5.50332852e-003,
-       -3.13695782e-004, 9.50451847e-003, 4.60966816e-003,
-       2.61870660e-002, -2.87075751e-002, 6.48848787e-002,
-       4.65245917e-002, -1.32335545e-002, -3.22434679e-002,
-       4.63708863e-002, 4.87490520e-002, 2.64079613e-003,
-       -3.19659594e-005, 6.92713074e-003, 4.87097772e-003,
-       -8.67482945e-002, -5.72921243e-003, 1.05465174e-001,
-       3.01229078e-002, 1.85530752e-001, -1.34304926e-001,
-       4.42220986e-001, 2.36426502e-001, -1.47165507e-001,
-       -1.71595007e-001, 4.05910671e-001, 2.53136992e-001,
-       6.41245618e-002, -5.82069391e-003, 7.76707307e-002,
-       3.28559391e-002, -8.10010284e-002, -3.03129083e-003,
-       1.00331925e-001, 2.66331974e-002, -2.57333163e-002,
-       6.04735408e-003, 2.60613412e-001, 1.71866491e-001,
-       6.49271086e-002, 7.12581153e-004, 2.52900690e-001,
-       1.75866202e-001, 5.03133722e-002, -6.98494306e-003,
-       6.55571073e-002, 3.62087376e-002, -5.91531536e-003,
-       -1.52604806e-003, 1.00624245e-002, 3.90631845e-003,
-       -3.94150894e-003, 1.84762366e-002, 3.82918678e-002,
-       3.58017348e-002, 2.76802829e-003, 1.56035861e-002,
-       3.49525735e-002, 3.27214971e-002, 2.71142321e-003,
-       -1.50907249e-003, 6.63377158e-003, 5.65727241e-003,
-       1.62432482e-003, 1.51139572e-002, 5.10483468e-003,
-       2.93546505e-002, -6.80830190e-003, 1.22371681e-001,
-       2.70263217e-002, 2.43943110e-001, -1.08346418e-002,
-       1.23633638e-001, 3.69075872e-002, 2.58595824e-001,
-       1.35764503e-003, 1.14808204e-002, 8.93679913e-003,
-       2.93713678e-002, 1.93250347e-002, 1.10404612e-003,
-       3.76472361e-002, 3.26946750e-002, 2.68288609e-002,
-       4.47165929e-002, 1.21133536e-001, 1.48674950e-001,
-       -5.36087714e-002, 8.12152848e-002, 1.42229661e-001,
-       1.68108374e-001, -2.62820795e-002, 1.49120465e-002,
-       6.11291900e-002, 3.81312966e-002, 3.03923637e-002,
-       -4.70609963e-002, 5.39006032e-002, 6.72720820e-002,
-       7.45122060e-002, -2.47739926e-001, 1.71537191e-001,
-       3.40257943e-001, -2.40236260e-002, -1.87481359e-001,
-       1.16379187e-001, 3.00258100e-001, -3.60659361e-002,
-       -2.32096966e-002, 6.63679615e-002, 3.91180031e-002,
-       -1.65261546e-004, -2.86889030e-003, 5.36406226e-003,
-       3.43324691e-002, 6.08660420e-003, -6.84589967e-002,
-       2.89289989e-002, 2.96898514e-001, 5.18821273e-003,
-       -8.85908157e-002, 2.95521375e-002, 3.11457753e-001,
-       4.32452798e-004, -1.02034705e-002, 8.39250442e-003,
-       3.45046110e-002, -3.30023060e-004, 3.17715248e-003,
-       3.90961440e-003, 7.81657267e-003, -4.25945688e-003,
-       5.54775409e-002, 2.98374612e-002, 8.37200955e-002,
-       1.04939081e-002, 7.78801069e-002, 3.21689472e-002,
-       1.00135699e-001, 1.49617472e-003, 7.07556307e-003,
-       5.36045991e-003, 1.14625357e-002, 2.16668714e-002,
-       3.12171318e-002, 3.89262103e-002, 4.99484353e-002,
-       1.24280844e-002, 2.80992955e-001, 2.04940200e-001,
-       3.84459466e-001, 3.79510187e-002, 8.29645023e-002,
-       2.71342307e-001, 4.24742907e-001, -2.89629418e-002,
-       2.59109633e-003, 5.30277751e-002, 5.30903228e-002,
-       2.95954347e-002, -1.47759216e-002, 4.26768772e-002,
-       3.95781994e-002, 9.72620547e-002, -4.15433049e-002,
-       1.77941635e-001, 1.86567605e-001, -1.10366285e-001,
-       1.12868018e-001, 2.45807901e-001, 2.77942806e-001,
-       -2.40960922e-002, 7.10086804e-003, 4.93664965e-002,
-       4.44020294e-002, 1.43286411e-003, -3.16695170e-003,
-       4.64364095e-003, 1.10888304e-002, 1.19861467e-002,
-       -6.07318282e-002, 3.06084994e-002, 9.13160816e-002,
-       -3.47453915e-003, -7.37789050e-002, 3.10838483e-002,
-       1.02456376e-001, -6.91589317e-004, -4.94363392e-003,
-       5.42175956e-003, 9.50117595e-003, -8.57459102e-003,
-       2.97975377e-003, 1.14271203e-002, 4.72496264e-003,
-       -2.90696602e-002, -6.36231015e-003, 4.15226035e-002,
-       2.59576160e-002, 4.10870137e-003, -9.68039781e-003,
-       2.58795638e-002, 2.38951892e-002, 8.85120127e-003,
-       2.62349402e-003, 1.26148295e-002, 4.59877495e-003,
-       -6.92161918e-002, 1.25312656e-002, 8.19750503e-002,
-       2.83107944e-002, -2.35732719e-001, 9.22704041e-002,
-       3.02019149e-001, 1.64944336e-001, -9.94042493e-003,
-       1.20740589e-002, 2.13061020e-001, 1.15125932e-001,
-       1.01787709e-001, 9.64067876e-003, 1.22909263e-001,
-       2.96113156e-002, -4.75387610e-002, 1.16195697e-002,
-       6.30609840e-002, 2.62219533e-002, -2.19712719e-001,
-       2.54752904e-001, 3.41269583e-001, 2.74984628e-001,
-       -1.78804323e-001, 1.44309953e-001, 3.60315591e-001,
-       1.82486162e-001, 1.07831284e-001, 5.36960491e-004,
-       1.28269121e-001, 2.89877243e-002, -1.15892920e-003,
-       8.86278169e-004, 4.99420566e-003, 4.31421073e-003,
-       -2.81735342e-002, 3.83082591e-002, 5.08154146e-002,
-       5.05706295e-002, -3.88417281e-002, 4.11613360e-002,
-       6.02349937e-002, 5.05011939e-002, 8.50107521e-003,
-       1.57887454e-003, 1.21016474e-002, 4.79667401e-003,
-       -4.61413106e-003, 1.58571568e-003, 1.62567664e-002,
-       6.40946953e-003, -6.37550652e-002, -3.73516455e-002,
-       8.92712772e-002, 4.82163467e-002, -9.38306912e-004,
-       -1.26114683e-002, 3.17917317e-002, 2.59730443e-002,
-       6.30235812e-003, 9.79930395e-004, 8.93434975e-003,
-       4.55480255e-003, -1.22770630e-001, -1.82586201e-002,
-       1.63378537e-001, 4.53053974e-002, -2.49445423e-001,
-       -9.78159830e-002, 4.06328231e-001, 1.81529045e-001,
-       5.69055341e-002, 4.17296495e-003, 1.91178754e-001,
-       1.24619648e-001, 7.25165755e-002, 2.77265068e-002,
-       8.45057741e-002, 4.24199961e-002, -1.56968296e-001,
-       -4.51552048e-002, 1.78847060e-001, 5.68467490e-002,
-       -5.55407405e-002, 5.34253474e-003, 2.13429630e-001,
-       1.28754288e-001, 2.77069986e-001, 1.92105964e-001,
-       3.48773062e-001, 2.45155275e-001, 5.22683784e-002,
-       4.13026325e-002, 7.83010274e-002, 5.25132865e-002,
-       -1.23536279e-002, -2.85793119e-003, 1.55950543e-002,
-       6.78951154e-003, 9.51058324e-003, 2.06938069e-002,
-       3.47044207e-002, 3.52543294e-002, 6.82940409e-002,
-       3.82144079e-002, 7.90959373e-002, 5.63451909e-002,
-       -1.14804856e-003, -1.74868642e-003, 8.29619635e-003,
-       6.90209121e-003, 4.90573235e-003, 7.01154349e-003,
-       1.04373451e-002, 1.14463856e-002, -7.27631375e-002,
-       -1.00009851e-001, 1.08693145e-001, 1.33295834e-001,
-       -3.79429478e-003, -7.52723068e-002, 6.61587194e-002,
-       9.39128622e-002, 4.15488752e-003, -2.05434440e-003,
-       9.47639346e-003, 7.07148015e-003, -8.66178796e-002,
-       -1.11137047e-001, 1.15494154e-001, 1.29684597e-001,
-       -2.01659784e-001, -2.81885743e-001, 4.29140329e-001,
-       4.00116712e-001, 1.61063984e-001, -8.19818452e-002,
-       2.60927618e-001, 1.89129755e-001, 5.61236069e-002,
-       -8.51336867e-003, 8.05868953e-002, 4.24915068e-002,
-       -4.22554202e-002, -2.53797993e-002, 5.62871285e-002,
-       4.70983610e-002, 3.87868173e-002, 2.02770121e-002,
-       1.43757090e-001, 1.18835725e-001, 1.27099276e-001,
-       -6.51791692e-003, 2.09670737e-001, 1.15584679e-001,
-       6.31195456e-002, -2.55762204e-003, 8.65577236e-002,
-       3.88255157e-002, -1.28198927e-003, 7.71958032e-004,
-       4.37876116e-003, 3.35119641e-003, 3.08339926e-003,
-       1.05303507e-002, 2.30713673e-002, 2.04586312e-002,
-       2.07124427e-002, 1.13012847e-002, 3.70752551e-002,
-       2.14702673e-002, 4.98828478e-003, 8.64515532e-005,
-       1.02276932e-002, 4.47560521e-003, -3.81779601e-003,
-       1.36464753e-003, 5.58763556e-003, 3.65285156e-003,
-       -4.13655071e-003, -5.56299556e-003, 1.75176114e-002,
-       1.67321023e-002, 9.22260713e-003, -5.00429096e-003,
-       2.14064661e-002, 1.67557038e-002, 4.17866139e-003,
-       1.42195355e-003, 6.52679848e-003, 3.76927550e-003,
-       -6.03038371e-002, 4.27438617e-002, 6.91918805e-002,
-       5.11959530e-002, -8.43329057e-002, 4.98080403e-002,
-       1.49911895e-001, 1.18057325e-001, 1.04593985e-001,
-       2.44206432e-002, 1.62239209e-001, 9.61746275e-002,
-       4.34135161e-002, 1.62015241e-002, 5.98978065e-002,
-       2.97506563e-002, -3.72296572e-002, 4.72790524e-002,
-       5.81042133e-002, 5.60080595e-002, -3.67406726e-001,
-       3.74141395e-001, 4.02259678e-001, 4.01143730e-001,
-       1.35038972e-001, 1.40202254e-001, 2.42719695e-001,
-       1.98769599e-001, 4.19962630e-002, 1.91215836e-002,
-       6.50438666e-002, 3.53781097e-002, 1.36398175e-003,
-       -1.09967077e-003, 4.70998371e-003, 3.86128225e-003,
-       -4.15291637e-002, 4.25053686e-002, 5.39959408e-002,
-       5.66324145e-002, -7.43458467e-003, 6.61409795e-002,
-       5.26940823e-002, 7.44498447e-002, 1.14739442e-003,
-       1.81748043e-003, 7.46846106e-003, 5.53872529e-003,
-       6.27481728e-004, 1.52442732e-003, 4.45928006e-003,
-       4.75080032e-003, 7.07501778e-004, 2.47310828e-002,
-       2.87153572e-002, 3.89706306e-002, -2.13905312e-002,
-       2.43685376e-002, 3.46790068e-002, 4.49020863e-002,
-       -2.21734299e-004, 8.14921339e-004, 3.54345469e-003,
-       3.53529374e-003, 6.09852653e-003, 1.03145456e-002,
-       3.44479829e-002, 3.09231319e-002, 4.62041944e-002,
-       4.32460047e-002, 1.60633460e-001, 1.69408277e-001,
-       -6.87505007e-002, 1.61549971e-001, 2.42016345e-001,
-       2.36310095e-001, -2.49767676e-002, 2.56587043e-002,
-       4.44714427e-002, 4.07596119e-002, 1.95577908e-002,
-       1.01010166e-002, 3.99741977e-002, 4.51948084e-002,
-       -1.00405268e-001, 2.92661265e-002, 2.81227231e-001,
-       5.13678908e-001, -5.30544482e-002, -2.27696195e-001,
-       2.04092368e-001, 4.09497559e-001, -3.05421073e-002,
-       -1.87538732e-002, 4.71128188e-002, 5.32201193e-002,
-       -1.13892462e-003, -7.22491043e-003, 4.28033154e-003,
-       8.88159592e-003, -2.12664083e-002, -4.09835875e-002,
-       3.67105380e-002, 6.61041364e-002, -1.34289660e-003,
-       -1.23327477e-002, 2.34996788e-002, 5.33899590e-002,
-       8.63789639e-004, -8.73284182e-004, 5.06539317e-003,
-       5.96527616e-003, -1.24043529e-003, 1.69587471e-002,
-       4.23492491e-003, 2.35944670e-002, -5.27649047e-003,
-       1.24127597e-001, 2.44911760e-002, 1.72694236e-001,
-       1.07771892e-003, 1.20087355e-001, 2.75717136e-002,
-       1.65300459e-001, -6.10584219e-004, 1.12859104e-002,
-       8.22739769e-003, 1.72632206e-002, 7.42112519e-003,
-       4.10377905e-002, 2.15362459e-002, 5.36268912e-002,
-       -3.01968195e-002, 3.05822313e-001, 1.20120794e-001,
-       3.80827576e-001, -6.93408921e-002, 2.67409116e-001,
-       1.83031201e-001, 4.11002576e-001, -9.02508497e-002,
-       7.57188257e-003, 1.25208661e-001, 6.61415607e-002,
-       6.03615632e-003, 6.59306243e-004, 1.70226004e-002,
-       1.68809928e-002, -2.18584742e-002, -1.00567639e-002,
-       1.06227852e-001, 1.16301544e-001, -1.85717717e-001,
-       -4.64929081e-002, 2.54150271e-001, 2.15452880e-001,
-       -9.15614218e-002, -1.52458167e-002, 1.43167078e-001,
-       5.70368543e-002, 4.25272992e-005, -2.64925853e-004,
-       2.54304917e-003, 2.60409177e-003, -7.49179302e-003,
-       -1.01252468e-002, 2.40737498e-002, 2.64798440e-002,
-       -4.21637930e-002, -2.33797971e-002, 5.65421507e-002,
-       4.79805171e-002, -4.87917429e-003, 1.91434287e-003,
-       1.66190788e-002, 7.67231965e-003, 1.33072352e-003,
-       -9.78686076e-005, 6.78903656e-003, 5.45646437e-003,
-       7.46300817e-002, 4.15001214e-002, 8.67150202e-002,
-       6.17935732e-002, 2.94497143e-002, 3.05122025e-002,
-       4.32188883e-002, 3.93493064e-002, -2.84205220e-004,
-       1.19737082e-003, 2.87835882e-003, 2.84028705e-003,
-       7.80180693e-002, 2.40470823e-002, 9.25106257e-002,
-       4.90432046e-002, 3.28646153e-001, 2.82004774e-001,
-       3.88466448e-001, 3.35129350e-001, 4.39490518e-003,
-       2.74974257e-002, 1.02260388e-001, 8.82497206e-002,
-       -8.18342436e-003, 7.36656148e-005, 1.67623125e-002,
-       1.22095998e-002, 7.77934119e-002, -1.76567510e-002,
-       9.48676094e-002, 4.40776534e-002, 3.03172678e-001,
-       -1.65985718e-001, 3.78487647e-001, 2.34448060e-001,
-       -2.09479611e-002, -3.93367112e-002, 1.00874558e-001,
-       9.62910578e-002, -8.45210906e-003, -3.97811178e-003,
-       1.85004156e-002, 1.45347575e-002, 3.42289405e-003,
-       3.10582225e-004, 8.34951270e-003, 6.17939001e-003,
-       5.71831353e-002, -4.34696265e-002, 7.29855224e-002,
-       6.59330711e-002, 1.12361042e-002, -3.51147316e-002,
-       3.37003097e-002, 4.98397127e-002, 2.37776461e-004,
-       -2.09215353e-003, 3.20749125e-003, 4.67557507e-003,
-       1.08460465e-003, -1.58078002e-003, 6.26542559e-003,
-       6.23548077e-003, -2.28077471e-002, -4.37737815e-002,
-       5.18673621e-002, 6.31949753e-002, 1.66369472e-002,
-       -4.78324890e-002, 6.45286143e-002, 6.34730458e-002,
-       1.50655920e-003, -2.60766737e-005, 8.24974477e-003,
-       5.57620451e-003, -3.00320406e-002, -3.99100892e-002,
-       5.33652529e-002, 5.46750389e-002, -1.47179499e-001,
-       -3.00637394e-001, 2.83807874e-001, 3.55758488e-001,
-       1.91871271e-001, -2.21259698e-001, 3.75735968e-001,
-       2.86309928e-001, 4.76833917e-002, -3.76007147e-002,
-       7.80327916e-002, 5.48400320e-002, -3.01048476e-002,
-       3.23646958e-003, 4.76263426e-002, 3.86994369e-002,
-       -8.79256949e-002, 9.28635299e-002, 1.89324200e-001,
-       1.88549146e-001, 1.00816645e-001, 4.14951667e-002,
-       2.07787663e-001, 1.70501798e-001, 4.76320609e-002,
-       -1.75777022e-002, 6.56624660e-002, 4.30362560e-002,
-       -8.78426246e-004, 5.29132842e-004, 5.55528468e-003,
-       5.45634096e-003, -1.32802734e-002, 1.97098907e-002,
-       3.53509970e-002, 3.88027318e-002, 5.43550914e-003,
-       1.95314735e-002, 3.36822830e-002, 3.63000594e-002,
-       2.96453969e-003, 3.45997338e-004, 6.66336855e-003,
-       5.29111736e-003, -4.24324255e-003, -1.72550317e-005,
-       8.91301874e-003, 7.58611364e-003, -1.47588598e-002,
-       -8.53176042e-002, 4.68110517e-002, 1.22012451e-001,
-       -2.70807813e-003, -9.16026831e-002, 3.34098712e-002,
-       1.31695464e-001, -2.50290235e-004, -6.12248341e-003,
-       5.63205639e-003, 1.30844777e-002, -5.05484082e-002,
-       1.11912768e-002, 8.04531351e-002, 2.66444273e-002,
-       -3.40809524e-001, -7.44860852e-003, 3.89816910e-001,
-       1.78419098e-001, 5.67384027e-002, -6.00901991e-002,
-       1.36478916e-001, 1.75254881e-001, 2.98385266e-002,
-       -7.55122490e-003, 4.65409905e-002, 3.08469962e-002,
-       -3.72882560e-002, 1.59910286e-003, 7.31606185e-002,
-       1.83523968e-002, -4.18866664e-001, 1.87555254e-002,
-       4.60109442e-001, 1.25374317e-001, 5.54817505e-002,
-       5.60201751e-003, 1.36322334e-001, 1.19310990e-001,
-       3.05398945e-002, 4.16364666e-004, 4.75649908e-002,
-       2.40068492e-002, -3.85612086e-003, -1.03118038e-003,
-       1.00460229e-002, 3.32013937e-003, -5.59931435e-002,
-       1.76706724e-002, 6.81127012e-002, 3.11804209e-002,
-       5.25416760e-003, 1.70073118e-002, 2.52347738e-002,
-       3.01045384e-002, 2.65405443e-003, 5.34436549e-004,
-       6.05701888e-003, 4.12437506e-003, 7.66065205e-004,
-       5.30321384e-003, 8.67406931e-003, 1.02001289e-002,
-       1.59658138e-002, 1.07309990e-001, 4.03410159e-002,
-       1.32884935e-001, -1.72508936e-002, 9.45583358e-002,
-       3.88353541e-002, 1.25197768e-001, -1.78346282e-003,
-       4.89227101e-003, 7.68853165e-003, 1.05564548e-002,
-       3.69745493e-002, -2.88413925e-004, 1.05328083e-001,
-       4.49599028e-002, 2.87217796e-001, 1.14178071e-002,
-       3.53052557e-001, 3.00575525e-001, -1.33457348e-001,
-       1.74220204e-001, 2.16695338e-001, 2.54705846e-001,
-       -7.01925606e-002, 2.20581442e-002, 1.05166577e-001,
-       4.44618426e-002, 5.86991496e-002, 3.40926461e-002,
-       1.09637685e-001, 5.26126847e-002, 1.96565643e-001,
-       1.58195183e-001, 2.68987775e-001, 2.49975741e-001,
-       -1.09739415e-001, -1.06912572e-002, 2.00793684e-001,
-       1.40791908e-001, -7.35393167e-002, -1.65361294e-003,
-       1.07865565e-001, 3.31357419e-002, 8.88100453e-003,
-       9.85716237e-004, 1.27087692e-002, 5.39219286e-003,
-       9.91348363e-003, -1.07484180e-002, 2.90263444e-002,
-       2.51683239e-002, -2.16029286e-002, -1.00446679e-002,
-       3.56367938e-002, 2.37711612e-002, -6.34079706e-003,
-       1.51869899e-004, 1.31145632e-002, 4.09506168e-003,
-       6.38593966e-003, 4.71096544e-004, 2.03711074e-002,
-       8.41846317e-003, 3.48604172e-002, 5.17429113e-002,
-       8.17406625e-002, 7.47280493e-002, -5.16920537e-003,
-       3.78000624e-002, 5.09400964e-002, 5.53336181e-002,
-       -1.32919326e-002, -3.22934403e-003, 2.13203765e-002,
-       7.96795171e-003, 1.42224967e-001, 2.76892651e-002,
-       2.02975690e-001, 5.78789562e-002, 1.21760421e-001,
-       1.44251794e-001, 2.75746256e-001, 2.17271656e-001,
-       -1.88143492e-001, 5.02246171e-002, 3.07975233e-001,
-       1.68761656e-001, -1.33560091e-001, -1.00740539e-002,
-       1.99939236e-001, 4.24872711e-002, 1.41997561e-001,
-       2.55586021e-002, 1.81826606e-001, 4.75769751e-002,
-       1.72120780e-002, -3.24046016e-002, 1.71318278e-001,
-       1.10139832e-001, -2.49061450e-001, -4.86445092e-002,
-       3.64622325e-001, 1.38596743e-001, -1.17098615e-001,
-       -5.54556632e-003, 1.98052034e-001, 3.79107259e-002,
-       1.01807741e-002, 1.03542686e-003, 1.61165111e-002,
-       4.86413948e-003, 4.28371644e-003, -1.15187988e-002,
-       3.40575650e-002, 2.42045857e-002, -4.84566949e-002,
-       -1.84776504e-002, 6.59929141e-002, 3.23043913e-002,
-       -8.26447364e-003, 4.93927801e-004, 2.13816408e-002,
-       6.07682345e-003, 2.56850407e-003, -1.28260267e-003,
-       5.59888640e-003, 6.14566822e-003, -6.38986239e-003,
-       -3.07733566e-002, 3.60840261e-002, 5.25087453e-002,
-       6.62272237e-003, -4.63882089e-002, 4.80177589e-002,
-       6.12564832e-002, 1.01628341e-003, -3.74758616e-004,
-       4.97409655e-003, 4.01774514e-003, -7.51104532e-003,
-       -3.90391611e-002, 3.92462909e-002, 5.13733700e-002,
-       -4.44275774e-002, -2.56930411e-001, 2.22605705e-001,
-       3.46573979e-001, 1.74536079e-001, -1.35904178e-001,
-       4.05359715e-001, 2.68215001e-001, 3.12223732e-002,
-       -1.44030498e-002, 5.22563234e-002, 3.58880423e-002,
-       -1.39208483e-002, -4.40870784e-003, 2.99210493e-002,
-       2.89249737e-002, 4.76978496e-002, -7.16011878e-003,
-       1.62448987e-001, 1.53468177e-001, 1.57207772e-001,
-       3.54196131e-002, 3.65552098e-001, 2.92077929e-001,
-       3.86876650e-002, -2.06909113e-004, 5.67679070e-002,
-       4.61119190e-002, -6.87375665e-004, 8.69148993e-004,
-       3.83950188e-003, 4.03268496e-003, 1.55322738e-002,
-       1.89655852e-002, 3.50074060e-002, 3.60263996e-002,
-       3.49808186e-002, 2.57034209e-002, 5.60228489e-002,
-       5.55419587e-002, 1.02251640e-003, -6.30586699e-004,
-       5.91233000e-003, 6.59376150e-003, 4.94902069e-003,
-       -1.86873472e-003, 7.60530448e-003, 3.81611567e-003,
-       3.83621752e-002, 1.22824227e-002, 5.14861643e-002,
-       2.63252426e-002, -3.31066474e-002, 1.96326599e-002,
-       4.68022078e-002, 3.06402706e-002, -4.03741980e-003,
-       -1.27014332e-003, 9.04868916e-003, 4.32978850e-003,
-       3.50493602e-002, -5.26706688e-003, 5.16249985e-002,
-       2.03453768e-002, 3.69972736e-001, -4.48030159e-002,
-       4.03539360e-001, 1.40177444e-001, -1.77495927e-001,
-       5.87065816e-002, 2.60529518e-001, 1.31213188e-001,
-       -6.54592291e-002, 9.00592562e-003, 8.73926803e-002,
-       2.92119682e-002, 3.20146047e-002, -1.84462755e-004,
-       4.83794734e-002, 1.88726839e-002, 3.45559090e-001,
-       -1.09153405e-001, 3.83754492e-001, 1.66600257e-001,
-       -2.52013002e-002, -6.20860048e-002, 2.35830322e-001,
-       1.35787621e-001, -7.76976645e-002, 8.66357703e-003,
-       9.31155309e-002, 2.95015704e-002, 2.51894491e-003,
-       3.43301217e-004, 5.85913472e-003, 3.22685018e-003,
-       3.42968926e-002, -2.38228980e-002, 4.81311865e-002,
-       3.42290960e-002, 1.06891291e-002, -2.99723987e-002,
-       4.33674715e-002, 3.78877223e-002, -6.81435782e-003,
-       -1.37472627e-004, 9.90772806e-003, 4.59276605e-003,
-       5.71267174e-006, 2.25598109e-003, 7.89625011e-003,
-       6.93986239e-003, -6.29912876e-003, 5.53602353e-002,
-       4.40634266e-002, 7.72960782e-002, -1.83164403e-002,
-       4.93812785e-002, 5.97080141e-002, 6.80798590e-002,
-       -6.75417599e-004, 5.17717504e-004, 6.02840818e-003,
-       4.81458055e-003, 2.07935758e-002, 7.09656207e-003,
-       5.07221036e-002, 3.19024101e-002, 6.60482189e-003,
-       3.48839723e-002, 2.54149646e-001, 2.26584241e-001,
-       -2.39599496e-001, 6.61971495e-002, 4.98392135e-001,
-       1.71931505e-001, -1.10178320e-002, 3.47741088e-003,
-       5.15836999e-002, 2.71472447e-002, 1.53584173e-002,
-       -2.83181202e-003, 4.02497798e-002, 2.57743280e-002,
-       5.73414005e-002, -1.21677248e-002, 1.82024553e-001,
-       1.56189561e-001, -2.61440963e-001, -2.22775899e-002,
-       4.40052480e-001, 1.50541261e-001, -1.28261326e-002,
-       1.69024023e-003, 5.60021028e-002, 2.50953250e-002,
-       -2.66160467e-004, -2.96943914e-003, 4.78079356e-003,
-       6.53145136e-003, -3.84344929e-003, -5.76544441e-002,
-       3.48366499e-002, 7.71493688e-002, -1.86418965e-002,
-       -5.58816157e-002, 5.25868386e-002, 7.48110935e-002,
-       -5.62298228e-004, 1.44153208e-004, 6.69383118e-003,
-       5.38853509e-003, 8.32493324e-003, 6.40204176e-003,
-       1.19810151e-002, 1.88249405e-002, 3.11126057e-002,
-       1.62196413e-001, 5.59694059e-002, 2.91855901e-001,
-       -1.99626070e-002, 1.72993764e-001, 3.90656926e-002,
-       3.00635219e-001, -3.21668386e-003, 1.36117740e-002,
-       1.75082423e-002, 2.29751673e-002, 1.38153225e-001,
-       2.68129297e-002, 1.56741038e-001, 7.70549402e-002,
-       1.73838720e-001, 1.00775205e-001, 2.75515139e-001,
-       2.05310538e-001, -1.33084998e-001, 5.05970381e-002,
-       2.04148635e-001, 1.77028626e-001, -1.03618704e-001,
-       1.45573216e-002, 1.81394681e-001, 4.61075641e-002,
-       1.83382481e-001, -1.87237766e-002, 1.97760582e-001,
-       8.73149335e-002, 1.35204062e-001, -2.39239782e-002,
-       2.54438788e-001, 1.40628681e-001, -6.43654689e-002,
-       1.84144601e-002, 1.50653601e-001, 1.07955910e-001,
-       -1.11444473e-001, 2.34487262e-002, 1.63343892e-001,
-       5.18857129e-002, 1.30196279e-002, 5.62183326e-003,
-       1.74581613e-002, 1.48049239e-002, 2.67971400e-002,
-       -1.60583202e-002, 4.26650457e-002, 3.80941145e-002,
-       9.27713700e-004, -3.36274249e-003, 1.59086287e-002,
-       1.44939227e-002, -6.58174977e-003, 4.69991053e-003,
-       9.44213476e-003, 5.83350006e-003, -2.01070751e-003,
-       7.02627050e-003, 8.59917887e-003, 1.52900806e-002,
-       1.16412640e-002, 9.72349346e-002, 4.13307138e-002,
-       1.38350740e-001, -7.50632258e-003, 1.00314751e-001,
-       4.16858792e-002, 1.36290237e-001, -3.98817938e-003,
-       5.46907447e-003, 9.24866740e-003, 1.23526109e-002,
-       1.61043741e-002, 2.64466926e-002, 5.53895347e-002,
-       4.57012281e-002, 8.86022598e-002, 1.05171211e-001,
-       1.87518120e-001, 2.07543731e-001, -1.65264010e-001,
-       4.09861542e-002, 2.46122658e-001, 2.04669520e-001,
-       -6.89859763e-002, -3.23389564e-003, 1.06713772e-001,
-       4.75442968e-002, 1.83009114e-002, -1.17725953e-002,
-       4.16268110e-002, 3.82095501e-002, 4.57344111e-003,
-       -1.26618043e-001, 1.63819835e-001, 2.25353420e-001,
-       -2.50031710e-001, -1.85364619e-001, 3.40604752e-001,
-       2.81969577e-001, -4.16241288e-002, -2.39963327e-002,
-       1.04248293e-001, 5.05095385e-002, -4.44970734e-004,
-       -1.63897332e-002, 6.22170791e-003, 2.57861931e-002,
-       -4.54655150e-003, -1.42566949e-001, 3.40666100e-002,
-       2.02057734e-001, -1.65482014e-002, -1.20208174e-001,
-       4.67606299e-002, 1.78047493e-001, 3.45984241e-004,
-       -5.14302775e-003, 8.58887658e-003, 1.37583334e-002,
-       -3.57981975e-004, 7.96325738e-004, 6.17344957e-003,
-       4.47339704e-003, 1.30980182e-002, 2.12750002e-003,
-       4.11835462e-002, 5.27174063e-002, -2.64226622e-003,
-       1.30782528e-002, 3.82300727e-002, 5.52873574e-002,
-       -8.83860223e-004, 8.81143089e-004, 4.72350232e-003,
-       6.03228621e-003, 4.28642752e-003, -1.92495086e-003,
-       4.97817360e-002, 2.46507172e-002, 2.41220966e-002,
-       -1.38729648e-003, 3.12360048e-001, 2.18596384e-001,
-       6.27988428e-002, -4.39027697e-002, 3.74912858e-001,
-       4.90667731e-001, -9.96470451e-003, 5.93375461e-003,
-       5.41904718e-002, 5.22951335e-002, 5.41513367e-003,
-       -1.56058857e-004, 4.32091691e-002, 1.97433569e-002,
-       -8.47502053e-003, -2.13523023e-002, 3.04045320e-001,
-       1.71369657e-001, 5.28724678e-002, -3.25847268e-002,
-       2.98050642e-001, 2.18972594e-001, 1.93685223e-003,
-       -5.12523577e-003, 5.39415814e-002, 3.82831469e-002,
-       -2.18496461e-005, -7.05721613e-005, 5.20970160e-003,
-       3.57400207e-003, -4.56330672e-005, -7.63911661e-003,
-       3.47761437e-002, 3.85068953e-002, 6.03024056e-003,
-       -7.38385832e-003, 3.61952037e-002, 4.21778187e-002,
-       2.22564660e-004, -9.21148981e-004, 5.83203882e-003,
-       5.15531190e-003, -6.86012488e-003, 7.41264841e-004,
-       1.02452142e-002, 3.10278661e-003, -1.48160486e-002,
-       -7.54278013e-003, 3.48589830e-002, 2.33035590e-002,
-       5.06343357e-002, -1.42429229e-002, 9.00403932e-002,
-       3.20422053e-002, -1.40751316e-003, 1.86681410e-003,
-       9.65119433e-003, 5.07272454e-003, -5.84177077e-002,
-       -3.48771602e-004, 7.75648430e-002, 1.94960330e-002,
-       -1.15567319e-001, 2.87522282e-003, 2.02719256e-001,
-       1.00827120e-001, 2.82412261e-001, -7.98782781e-002,
-       6.32183492e-001, 2.02341557e-001, 1.08435722e-002,
-       -2.00779047e-002, 7.62282163e-002, 4.46583256e-002,
-       -5.48206270e-002, -4.20943554e-003, 7.42413476e-002,
-       2.19402295e-002, -1.01499051e-001, 2.31318250e-002,
-       1.92801252e-001, 1.17116973e-001, 1.45916805e-001,
-       7.71507248e-002, 3.03799301e-001, 1.85407162e-001,
-       4.89964485e-002, -7.52447522e-004, 8.56002048e-002,
-       4.80317138e-002, -5.63204614e-003, 8.77296494e-004,
-       9.45582986e-003, 3.99675639e-003, -7.15318229e-003,
-       1.69315543e-002, 3.37829441e-002, 3.18339430e-002,
-       2.40230821e-002, 1.94318462e-002, 4.38940860e-002,
-       4.25206535e-002, 2.11683754e-003, -3.19715519e-003,
-       1.05595132e-002, 6.59760321e-003, -3.71438742e-004,
-       1.45214153e-002, 4.75508720e-003, 1.91784073e-002,
-       -1.97951943e-002, 1.40173718e-001, 4.37818654e-002,
-       1.81588069e-001, -3.81804295e-002, 1.12698525e-001,
-       6.57305494e-002, 1.70204014e-001, 4.51282738e-003,
-       7.50573399e-003, 1.28309317e-002, 1.70807410e-002,
-       4.85504838e-003, 2.95912684e-003, 1.69704184e-002,
-       2.10371353e-002, -1.20035233e-002, 7.61459321e-002,
-       1.28528133e-001, 1.43589646e-001, -1.84797421e-001,
-       2.35029057e-001, 2.42713764e-001, 3.04082930e-001,
-       -1.42969666e-002, 4.10731286e-002, 6.38739914e-002,
-       6.00985996e-002, 1.06659671e-002, -1.70213021e-002,
-       2.21641269e-002, 3.30471098e-002, 2.51056463e-003,
-       -1.08873211e-001, 9.30830911e-002, 1.93824068e-001,
-       -5.20968959e-002, -1.00527920e-001, 1.07092410e-001,
-       2.04365358e-001, -2.68926974e-002, -3.86623596e-003,
-       5.21116965e-002, 4.58438396e-002, 2.56258808e-003,
-       -2.50821244e-002, 6.00915961e-003, 4.48984094e-002,
-       -9.15090367e-003, -2.13016316e-001, 3.28570977e-002,
-       3.35866421e-001, -8.99429619e-003, -2.23973170e-001,
-       2.49315556e-002, 3.41769338e-001, 3.95945227e-003,
-       -2.62113232e-002, 9.79656167e-003, 4.24683467e-002,
-       1.87349948e-003, 9.84645355e-003, 1.00777950e-002,
-       1.94617566e-002, 2.18052622e-002, 1.51721671e-001,
-       5.76297008e-002, 2.09277600e-001, 7.69732287e-004,
-       1.70632228e-001, 4.49829176e-002, 2.37463459e-001,
-       9.43725638e-004, 1.78789496e-002, 6.67491090e-003,
-       2.71125417e-002, 6.67879879e-002, 9.81974602e-003,
-       9.53209326e-002, 6.07425235e-002, 2.58381993e-001,
-       1.15543835e-001, 3.36941540e-001, 2.28405222e-001,
-       -9.18492302e-003, 6.14163876e-002, 9.24348086e-002,
-       1.50450915e-001, -1.05824843e-002, 1.04980944e-002,
-       2.81263776e-002, 2.06585564e-002, 7.70776719e-002,
-       7.76046468e-003, 1.00062415e-001, 5.79406917e-002,
-       1.39666855e-001, -5.98824024e-002, 2.26813495e-001,
-       1.95354626e-001, 1.16358949e-002, -6.36395961e-002,
-       8.76043141e-002, 1.29100800e-001, -1.17384307e-002,
-       -1.27121080e-002, 2.94430666e-002, 2.29152516e-002,
-       2.84692808e-003, -1.31431911e-002, 7.43156765e-003,
-       2.69128866e-002, 7.30246305e-003, -1.81277424e-001,
-       3.70565131e-002, 2.82689184e-001, 7.19675515e-003,
-       -1.86331734e-001, 2.78705042e-002, 2.76835948e-001,
-       -5.84863119e-005, -2.09473278e-002, 5.23371948e-003,
-       3.24158072e-002, 6.20560779e-004, 5.59846312e-003,
-       4.98010498e-003, 1.72092989e-002, 1.49564845e-002,
-       9.59008262e-002, 4.89377603e-002, 1.55125827e-001,
-       -1.03257885e-002, 1.29862607e-001, 7.13427961e-002,
-       2.35838294e-001, 1.44414580e-003, 6.10541180e-003,
-       1.11658899e-002, 2.81679817e-002, 2.08213702e-002,
-       4.87733148e-002, 3.88153046e-002, 7.32768178e-002,
-       1.58719465e-001, 1.10154644e-001, 2.36384675e-001,
-       3.20800602e-001, -3.42339240e-002, 1.04679935e-001,
-       2.59444386e-001, 2.48260185e-001, -3.99012938e-002,
-       5.89206908e-003, 7.17140660e-002, 7.49280304e-002,
-       5.49725071e-003, 1.21550178e-002, 2.28959601e-002,
-       3.87788042e-002, -6.63904250e-002, -2.09386903e-003,
-       1.84957236e-001, 2.15710193e-001, 7.86916241e-002,
-       -1.14168219e-001, 2.90177226e-001, 2.12368712e-001,
-       -7.52578676e-002, -6.32758625e-003, 1.16911143e-001,
-       5.19949570e-002, -3.88519693e-004, -1.73486583e-002,
-       3.22982669e-003, 2.32010297e-002, -2.35942975e-002,
-       -1.48313284e-001, 3.51036638e-002, 1.95252329e-001,
-       -9.25061002e-004, -1.56310678e-001, 5.63877188e-002,
-       2.02185079e-001, -5.11548063e-003, -1.54674686e-002,
-       1.16099445e-002, 2.34665088e-002, 2.80642766e-003,
-       -3.65511427e-004, 5.59710804e-003, 2.08656583e-003,
-       -3.18262639e-004, 5.99283725e-003, 2.45897565e-002,
-       1.53120048e-002, -2.90753711e-002, 8.94530211e-003,
-       5.17762601e-002, 2.43959446e-002, -1.72347203e-003,
-       -1.52765401e-003, 9.02712904e-003, 4.07398492e-003,
-       2.89523732e-002, 4.35102003e-004, 4.28095870e-002,
-       1.40722878e-002, 9.85869113e-003, 1.70462504e-002,
-       1.69073060e-001, 9.97062773e-002, -1.65962309e-001,
-       3.20333727e-002, 3.95550072e-001, 1.47643238e-001,
-       -2.62758303e-002, 6.71335822e-003, 7.25318715e-002,
-       2.41552554e-002, 3.60712186e-002, -2.62402976e-003,
-       5.03392145e-002, 1.49321994e-002, -1.73340410e-001,
-       -8.88076648e-002, 3.29057306e-001, 1.51613802e-001,
-       -3.39162275e-002, -2.08006993e-001, 5.56526124e-001,
-       2.52405167e-001, -2.06759982e-002, -8.19038879e-003,
-       6.53652623e-002, 2.46379916e-002, 4.03581094e-003,
-       -1.73935003e-003, 7.00797234e-003, 3.76252108e-003,
-       -5.30277342e-002, -3.33810374e-002, 7.14490861e-002,
-       4.14084271e-002, 4.48293606e-004, -3.92354019e-002,
-       5.76164909e-002, 4.99886125e-002, -5.61877503e-004,
-       -1.99506595e-003, 5.86631009e-003, 3.74720921e-003,
-       2.48122000e-004, 6.06004428e-003, 4.84270556e-003,
-       9.14941169e-003, -1.34772360e-002, 7.44289458e-002,
-       3.71439718e-002, 9.23962817e-002, -1.95853058e-002,
-       3.24210338e-002, 4.11063097e-002, 7.32243359e-002,
-       1.66876160e-003, -1.00549718e-003, 5.20461332e-003,
-       8.26402940e-003, 2.98503656e-002, 2.94992188e-003,
-       4.37130667e-002, 3.69641855e-002, 7.98763037e-002,
-       8.35075676e-002, 1.97564900e-001, 2.41541028e-001,
-       -1.19720206e-001, 3.89236063e-001, 2.62408555e-001,
-       4.48110014e-001, -4.91748713e-002, 4.90706563e-002,
-       6.62173629e-002, 6.84985295e-002, 3.02371811e-002,
-       -2.11000489e-003, 4.34068069e-002, 3.92870530e-002,
-       1.43192634e-001, -7.30105070e-003, 2.10100383e-001,
-       2.60372698e-001, -4.89001386e-002, -1.26311466e-001,
-       1.97911799e-001, 2.36602679e-001, -5.43179810e-002,
-       -1.10569820e-002, 7.08812699e-002, 4.24184501e-002,
-       1.54498382e-003, -4.76601388e-004, 5.31441113e-003,
-       6.16529211e-003, 6.29850477e-003, -3.37387472e-002,
-       3.34497355e-002, 5.77023029e-002, -8.03876389e-003,
-       -3.41042578e-002, 3.58259641e-002, 5.72688803e-002,
-       -1.73254032e-003, -8.31985031e-004, 6.90766424e-003,
-       6.55100727e-003, 1.73307173e-002, -2.74645817e-003,
-       2.17273198e-002, 5.81444008e-003, 7.90261012e-003,
-       1.29678911e-002, 3.28157656e-002, 2.28558294e-002,
-       -4.12083268e-002, 1.20090405e-002, 5.38161062e-002,
-       2.38342080e-002, -6.20030006e-003, -1.41642941e-003,
-       1.11146485e-002, 5.49253821e-003, 1.75296739e-001,
-       -2.04450041e-002, 2.08604902e-001, 3.62349078e-002,
-       7.34942928e-002, 1.05393389e-002, 1.95594907e-001,
-       7.23996162e-002, -3.32623899e-001, 2.09648069e-002,
-       3.81029397e-001, 1.01538658e-001, -4.37683985e-002,
-       -2.58181058e-003, 7.99947158e-002, 3.27840745e-002,
-       1.53835043e-001, -1.44761847e-002, 2.05939472e-001,
-       3.91880348e-002, 1.76826879e-001, -6.22164384e-002,
-       2.87056744e-001, 1.18792541e-001, -3.17783117e-001,
-       -5.15993359e-003, 3.66875321e-001, 1.05949394e-001,
-       -4.67395745e-002, 7.97165930e-003, 7.85661563e-002,
-       3.15783434e-002, 1.08121401e-002, 2.30087060e-003,
-       2.40100399e-002, 6.21330226e-003, 4.53678183e-002,
-       -2.21918393e-002, 6.66830987e-002, 3.52239385e-002,
-       -3.78592536e-002, -1.39360577e-002, 5.33417352e-002,
-       2.94285752e-002, -5.22885891e-003, 1.69244164e-003,
-       9.70636401e-003, 5.62303979e-003, -4.38220450e-004,
-       5.92093042e-004, 4.64186911e-003, 4.56910767e-003,
-       9.65746678e-003, 2.87390705e-002, 3.48499827e-002,
-       4.35322486e-002, -1.27660874e-002, 2.83681601e-002,
-       3.49571519e-002, 4.09556627e-002, -1.68165145e-003,
-       1.04252955e-004, 4.64826077e-003, 4.02006740e-003,
-       3.03824674e-002, 2.01038197e-002, 4.55924384e-002,
-       3.75426523e-002, 4.51361202e-002, 1.88560903e-001,
-       2.60742933e-001, 2.71252215e-001, -1.97166324e-001,
-       6.35329485e-002, 2.76494175e-001, 2.17231840e-001,
-       -3.08353510e-002, 7.07984949e-003, 4.28827517e-002,
-       2.89144851e-002, 3.18031572e-002, -2.17463505e-002,
-       4.59147431e-002, 4.12405841e-002, -8.14863071e-002,
-       -3.25881004e-001, 2.79273719e-001, 3.64172131e-001,
-       -6.82911351e-002, -1.89375073e-001, 2.30375707e-001,
-       2.63114899e-001, -3.34911905e-002, -8.07714649e-003,
-       4.33289036e-002, 2.97675990e-002, -6.98961143e-004,
-       -2.42234650e-003, 4.14250931e-003, 5.52703207e-003,
-       -2.33380566e-003, -2.38639265e-002, 2.71185674e-002,
-       4.04958390e-002, 1.73171342e-003, -2.64544785e-002,
-       2.65978854e-002, 3.87204960e-002, -8.86554597e-004,
-       -1.36479805e-003, 3.74020892e-003, 4.07703314e-003,
-       1.42452645e-003, 3.96508753e-004, 3.78689822e-003,
-       3.77549161e-003, 1.40049635e-002, 3.60943452e-002,
-       3.77207398e-002, 5.24687879e-002, -5.00186253e-003,
-       3.83898281e-002, 2.90348809e-002, 5.97543567e-002,
-       2.26077856e-004, 2.42098072e-003, 4.30449983e-003,
-       6.61954097e-003, 2.19684541e-002, -1.31935312e-003,
-       3.63971740e-002, 2.35745851e-002, 2.26374477e-001,
-       3.43985297e-002, 3.34942251e-001, 2.55791038e-001,
-       -5.46679422e-002, 7.89841288e-004, 1.76281542e-001,
-       4.28227752e-001, -1.90640092e-002, 4.07471647e-003,
-       3.47835533e-002, 4.75241914e-002, 2.27731280e-002,
-       1.25472632e-003, 3.72697040e-002, 2.12778263e-002,
-       2.66798973e-001, 1.43162664e-002, 3.36752176e-001,
-       2.19823301e-001, -6.94490224e-002, 8.16009045e-002,
-       1.65427193e-001, 3.29582900e-001, -2.08972972e-002,
-       5.50982868e-003, 3.66881266e-002, 3.91745605e-002,
-       1.74252375e-003, 3.21815256e-004, 4.48521739e-003,
-       3.46260495e-003, 2.54907552e-002, -3.08065917e-002,
-       4.08474095e-002, 4.71400544e-002, -4.70628589e-003,
-       -3.81404459e-002, 2.82813851e-002, 5.65899797e-002,
-       -4.24364087e-004, -1.81930780e-003, 4.48606908e-003,
-       6.28054840e-003, -4.23456513e-005, 1.66161638e-003,
-       2.44106795e-003, 4.22534812e-003, 1.76459982e-003,
-       1.81697328e-002, 1.43938391e-002, 3.53702232e-002,
-       -1.69203046e-003, 1.70971155e-002, 1.49491383e-002,
-       3.41582671e-002, -9.07229478e-005, 1.26479950e-003,
-       2.27134861e-003, 3.98747344e-003, 1.10390168e-002,
-       2.33517364e-002, 2.14653052e-002, 3.80233377e-002,
-       2.83285975e-002, 1.77806556e-001, 9.88892540e-002,
-       2.79604644e-001, -3.53805013e-002, 1.78063720e-001,
-       1.03151873e-001, 2.74594903e-001, -1.19653540e-002,
-       2.40656249e-002, 2.17684489e-002, 3.72022241e-002,
-       1.37827508e-002, -1.29073123e-002, 2.34477594e-002,
-       6.28627837e-002, 3.61914188e-002, -9.16479602e-002,
-       1.03909343e-001, 5.46336055e-001, -3.03950962e-002,
-       -8.04238319e-002, 1.02356702e-001, 5.38302660e-001,
-       -1.40282968e-002, -9.31930542e-003, 2.35590935e-002,
-       6.23215139e-002, -2.85562681e-004, -1.92007667e-003,
-       2.77348305e-003, 5.61149698e-003, 1.30424870e-003,
-       -2.23890189e-002, 1.68343186e-002, 4.59387526e-002,
-       4.11018700e-004, -2.21157148e-002, 1.53852906e-002,
-       4.62391265e-002, 1.72702770e-004, -2.03558803e-003,
-       2.54593277e-003, 5.79388533e-003, 1.15702662e-003,
-       4.16022143e-004, 3.67589388e-003, 2.70864693e-003,
-       4.56775026e-003, 9.00508929e-003, 1.62339620e-002,
-       1.72136277e-002, -3.89261311e-003, 7.01204780e-003,
-       1.50520317e-002, 1.62174795e-002, -2.37151771e-003,
-       -8.36538893e-005, 4.34339093e-003, 3.24996957e-003,
-       2.89841946e-002, -1.95805859e-002, 4.11992148e-002,
-       3.53463776e-002, 2.55951658e-002, -4.96490719e-003,
-       1.06167853e-001, 1.01377510e-001, -5.77141158e-002,
-       -2.54620314e-002, 1.17147475e-001, 1.05475821e-001,
-       -3.73391248e-002, -3.17469761e-002, 4.97923531e-002,
-       4.54294682e-002, 4.34651822e-002, -7.16463327e-002,
-       6.71436191e-002, 8.79766867e-002, 2.41985604e-001,
-       -2.96507508e-001, 3.00974190e-001, 3.53799969e-001,
-       -3.04317117e-001, -2.38321379e-001, 3.62273306e-001,
-       3.05348158e-001, -4.75293621e-002, -7.14569762e-002,
-       7.85766840e-002, 8.75604153e-002, -1.28676672e-003,
-       -2.52495520e-003, 6.61523920e-003, 8.37263372e-003,
-       3.26525532e-002, -9.42325145e-002, 5.87534681e-002,
-       1.11764111e-001, -2.44678557e-002, -9.48260799e-002,
-       6.43202960e-002, 1.13797903e-001, -1.14947732e-003,
-       -3.83573701e-004, 7.41728023e-003, 7.63741182e-003,
-       1.07863289e-003, -1.97885279e-003, 5.99826733e-003,
-       6.70104753e-003, -1.65678449e-002, -3.36551070e-002,
-       4.91795540e-002, 5.87871037e-002, -3.80842690e-003,
-       -4.05573659e-002, 4.73157465e-002, 5.83044663e-002,
-       2.69333087e-003, -1.64417631e-003, 6.64612930e-003,
-       6.18805736e-003, -4.05251086e-002, -1.68106426e-002,
-       5.76436184e-002, 5.31540774e-002, 4.20534430e-004,
-       -2.54363567e-001, 2.68174708e-001, 3.47518712e-001,
-       9.50038731e-002, -2.96481382e-002, 2.58324206e-001,
-       2.48891294e-001, 4.41128723e-002, 1.92121521e-003,
-       5.88836819e-002, 4.22982611e-002, -3.86111885e-002,
-       3.92325670e-002, 5.81594929e-002, 5.64622916e-002,
-       -1.65954515e-001, 2.05544800e-001, 2.95285910e-001,
-       3.03745627e-001, 1.69497699e-001, -6.87054396e-002,
-       2.63151377e-001, 2.27899283e-001, 4.27119099e-002,
-       -1.08077880e-002, 5.83135709e-002, 4.23451960e-002,
-       -7.33535899e-006, -1.33037532e-003, 6.36608107e-003,
-       5.91794541e-003, -3.82060967e-002, 2.64509805e-002,
-       5.56011871e-002, 5.13820387e-002, 7.60364463e-004,
-       3.42363715e-002, 4.24196124e-002, 4.92314212e-002,
-       2.67057703e-003, -4.11717745e-004, 6.61276001e-003,
-       6.08804869e-003, 2.19713827e-003, 1.29396922e-003,
-       4.75354772e-003, 4.60508652e-003, -1.98240305e-004,
-       4.22377586e-002, 3.51304375e-002, 5.14660329e-002,
-       -2.73072403e-002, 2.58358009e-002, 4.04664576e-002,
-       4.30108197e-002, 6.34649536e-004, -3.84897081e-004,
-       3.90471611e-003, 4.11391957e-003, 2.75315735e-002,
-       -5.35860425e-003, 3.65735441e-002, 2.67491452e-002,
-       1.83188304e-001, -8.58959556e-002, 2.57568330e-001,
-       2.69653380e-001, -1.99571237e-001, 2.30363667e-001,
-       3.22497040e-001, 3.31420481e-001, -2.83673462e-002,
-       2.52011232e-002, 4.44216244e-002, 4.02410664e-002,
-       2.06619222e-002, -8.20607692e-003, 3.01746484e-002,
-       2.42782328e-002, 1.24723487e-001, -1.28083631e-001,
-       2.07011014e-001, 2.11988360e-001, 7.76381940e-002,
-       -2.28807479e-001, 2.93384522e-001, 3.04326922e-001,
-       -4.37437519e-002, -3.82132013e-003, 5.38253933e-002,
-       3.89983393e-002, 8.40971188e-004, -1.08972145e-003,
-       3.43402615e-003, 3.73311783e-003, 4.95361304e-003,
-       -2.34485958e-002, 2.55162511e-002, 3.50086503e-002,
-       1.72425678e-003, -2.88469102e-002, 2.96949428e-002,
-       4.17819917e-002, -4.42938268e-004, -1.92393432e-003,
-       4.46829852e-003, 5.18261641e-003, 3.69543181e-004,
-       -1.59951963e-003, 3.93762346e-003, 5.78814652e-003,
-       -1.12184137e-003, -2.48987023e-002, 2.15706974e-002,
-       4.77993600e-002, -6.00643270e-003, -2.80696880e-002,
-       2.35450082e-002, 4.74224277e-002, -1.40940119e-003,
-       -3.27531295e-003, 3.74166924e-003, 6.44595083e-003,
-       -1.40981087e-002, -2.43048696e-003, 2.98326164e-002,
-       5.60167469e-002, -8.59203711e-002, -6.02166057e-002,
-       1.61611304e-001, 4.02052969e-001, -3.18184793e-002,
-       -1.34040952e-001, 1.56238690e-001, 3.95601898e-001,
-       1.18285576e-002, -1.12403166e-002, 2.85633299e-002,
-       4.88060117e-002, -2.27975100e-002, -2.41165385e-002,
-       3.56014520e-002, 6.28538579e-002, -6.99950084e-002,
-       -1.58647522e-001, 1.62244901e-001, 4.36351627e-001,
-       8.30271989e-002, 3.95276397e-002, 1.82579458e-001,
-       3.45244437e-001, 1.49705810e-002, 1.86171532e-002,
-       2.98302919e-002, 4.81688902e-002, 1.94524284e-004,
-       4.39067371e-003, 4.53423103e-003, 8.80029239e-003,
-       3.16244387e-003, 5.66499270e-002, 2.74247006e-002,
-       7.45502785e-002, 1.04588317e-002, 4.04985622e-002,
-       2.84064449e-002, 6.24506809e-002, -1.03793929e-004,
-       2.10452615e-003, 4.14585602e-003, 6.66545192e-003,
-       -2.18234886e-003, -1.31676365e-002, 7.48362532e-003,
-       2.21068934e-002, -9.37326904e-003, -7.92185068e-002,
-       3.94669548e-002, 9.96319950e-002, 9.13007092e-003,
-       -6.35812134e-002, 5.01077883e-002, 7.90558383e-002,
-       9.53181554e-003, 1.37107295e-003, 1.67170800e-002,
-       7.53458962e-003, -3.02319750e-002, 1.25650978e-002,
-       5.30114062e-002, 4.34347726e-002, -4.19244096e-002,
-       5.70846535e-002, 1.73060685e-001, 3.43476564e-001,
-       1.31401047e-001, 7.55042350e-003, 2.65651971e-001,
-       3.50536466e-001, 1.60775200e-001, -1.47862034e-003,
-       1.99804530e-001, 4.57878634e-002, -3.87166850e-002,
-       2.33999752e-002, 6.96328804e-002, 5.26673943e-002,
-       -1.04012452e-001, 1.71452146e-002, 2.17494547e-001,
-       3.54905188e-001, 4.98272851e-002, -6.94948360e-002,
-       2.23041341e-001, 2.33348027e-001, 1.65717468e-001,
-       -1.55858723e-002, 1.98014840e-001, 4.08611670e-002,
-       -1.02810294e-003, -3.94828571e-003, 7.53542408e-003,
-       1.25457263e-002, -3.28204148e-002, 1.84723418e-002,
-       4.40765284e-002, 5.76498322e-002, 1.57398707e-003,
-       3.28500308e-002, 3.46641466e-002, 5.10399193e-002,
-       1.90921146e-002, 1.33939413e-003, 2.45246366e-002,
-       5.91939455e-003, -6.65524130e-005, -1.06110156e-003,
-       3.84681649e-003, 3.56194493e-003, 1.88292395e-002,
-       -2.27825046e-002, 3.52051929e-002, 3.43467556e-002,
-       5.35981059e-002, -2.54571233e-002, 7.18974620e-002,
-       4.43622321e-002, 1.15995167e-003, 1.30922592e-003,
-       4.91026184e-003, 3.26128164e-003, -1.08446879e-002,
-       -2.92651844e-003, 2.71990821e-002, 1.64176617e-002,
-       5.39902337e-002, -3.84052359e-002, 1.45949215e-001,
-       1.06688388e-001, 3.34792852e-001, -1.53650463e-001,
-       5.09475350e-001, 2.12439999e-001, 2.69271452e-002,
-       -4.97345021e-003, 4.67213355e-002, 1.72465798e-002,
-       -1.02411713e-002, 2.20132852e-003, 2.62058396e-002,
-       1.40369432e-002, 4.17838842e-002, 2.40029413e-002,
-       1.39159217e-001, 8.82183835e-002, 2.94579774e-001,
-       5.07280976e-002, 4.85946983e-001, 1.34981841e-001,
-       3.48585509e-002, 4.11695248e-004, 5.46953157e-002,
-       1.72158014e-002, -4.07174026e-004, 4.58582799e-004,
-       3.68206785e-003, 2.39736633e-003, 7.97929242e-003,
-       1.12368185e-002, 2.53656916e-002, 2.16882806e-002,
-       4.49780151e-002, 1.60622932e-002, 6.53081611e-002,
-       3.30015942e-002, 3.43775749e-003, -1.76580274e-003,
-       7.05644768e-003, 3.60756530e-003, -1.82968881e-002,
-       2.28092237e-003, 2.19480358e-002, 5.26339235e-003,
-       -2.53076293e-002, -1.31526506e-002, 4.31229733e-002,
-       2.61019785e-002, 5.93696628e-003, -1.10500082e-002,
-       1.99888218e-002, 2.40944158e-002, 1.36934663e-003,
-       -4.77164343e-004, 4.24561417e-003, 3.13628605e-003,
-       -1.65200204e-001, 1.13170119e-002, 1.84047341e-001,
-       2.95111444e-002, -1.93463624e-001, -1.07397803e-003,
-       2.68933237e-001, 1.06378488e-001, 5.62227331e-002,
-       1.01090875e-003, 1.17141485e-001, 9.88355353e-002,
-       1.90064758e-002, 4.32223780e-003, 3.16794887e-002,
-       1.95609443e-002, -1.60333276e-001, 7.96520617e-003,
-       1.75969034e-001, 3.40282321e-002, -1.68447360e-001,
-       1.96170956e-001, 2.87853867e-001, 2.48394758e-001,
-       8.48664641e-002, 3.02411705e-001, 1.59927517e-001,
-       3.52337629e-001, 2.13708710e-002, 4.59003896e-002,
-       4.06478085e-002, 5.66133261e-002, -8.38494115e-003,
-       4.38263919e-003, 1.37876272e-002, 1.06997080e-002,
-       1.39651829e-002, 1.46962553e-001, 5.98059632e-002,
-       1.80999950e-001, 8.57435353e-003, 1.38435915e-001,
-       4.98143956e-002, 1.93211362e-001, -2.36879499e-003,
-       1.10734152e-002, 8.01132154e-003, 2.10893229e-002,
-       1.24821032e-004, 6.48642005e-003, 6.48116041e-003,
-       1.23806810e-002, -4.11966443e-003, 8.75025764e-002,
-       4.01131548e-002, 1.26188949e-001, 1.45872533e-002,
-       1.10040061e-001, 4.16060425e-002, 1.48449674e-001,
-       -6.11961959e-003, 8.66094045e-003, 1.53312441e-002,
-       1.32317897e-002, 2.85408795e-002, 4.89524826e-002,
-       6.66152909e-002, 5.59064336e-002, -9.55517441e-002,
-       2.59016544e-001, 2.57449269e-001, 3.11179996e-001,
-       1.08343579e-001, 1.72636822e-001, 3.80554169e-001,
-       2.50716329e-001, -1.22324482e-001, 6.22495357e-003,
-       2.11616069e-001, 2.89736446e-002, 1.56539772e-002,
-       5.60364593e-003, 3.55095677e-002, 1.85840204e-002,
-       -1.13650128e-001, 1.49750598e-002, 2.02576712e-001,
-       9.39987078e-002, 5.51842563e-002, 1.66663416e-002,
-       2.95798659e-001, 1.16885163e-001, -1.32956252e-001,
-       2.98539642e-003, 2.12818980e-001, 2.00466271e-002,
-       4.34994960e-004, 5.21557922e-005, 3.42982495e-003,
-       1.66597567e-003, -5.03522344e-003, -2.98739760e-003,
-       2.12993510e-002, 1.01075042e-002, -2.48304056e-003,
-       -2.10201673e-004, 3.04214824e-002, 1.17884809e-002,
-       -1.67161115e-002, 4.11193323e-004, 2.67517120e-002,
-       3.29559413e-003, -8.67887284e-005, 6.83491118e-004,
-       3.23015056e-003, 5.61385788e-003, 7.93764601e-004,
-       6.47771265e-003, 1.65681448e-002, 4.50002924e-002,
-       1.49063219e-003, 5.08792372e-003, 1.64718460e-002,
-       4.46539596e-002, 7.59229692e-008, 1.80004950e-004,
-       2.60030222e-003, 5.49038965e-003, 9.40784439e-003,
-       9.79674794e-003, 2.69971862e-002, 5.69208786e-002,
-       2.23405920e-002, 8.78425464e-002, 1.10762596e-001,
-       4.90677834e-001, -1.08080655e-002, 9.60031971e-002,
-       1.18249096e-001, 4.71778929e-001, -1.26613602e-002,
-       1.30781969e-002, 2.70224866e-002, 5.50071746e-002,
-       1.29334284e-002, 8.91406927e-003, 2.86143944e-002,
-       4.74378988e-002, 1.62735116e-002, 7.78941512e-002,
-       1.19027629e-001, 3.72666895e-001, -2.83086300e-002,
-       4.19319123e-002, 1.25490859e-001, 3.99730027e-001,
-       -1.59253720e-002, -6.75024465e-004, 2.97833681e-002,
-       5.00456430e-002, 4.56545473e-004, -2.32382189e-003,
-       3.81741277e-003, 6.34500897e-003, 1.46218541e-003,
-       -2.75618993e-002, 2.08140183e-002, 5.62902987e-002,
-       -2.69174739e-003, -2.06507575e-002, 1.98137555e-002,
-       5.39795980e-002, -7.48837367e-004, -3.99786542e-004,
-       3.25969420e-003, 6.46836078e-003, 6.27137115e-003,
-       -3.32042435e-003, 8.39549862e-003, 6.41762931e-003,
-       1.59239806e-002, 8.80506355e-003, 2.58925520e-002,
-       2.37315111e-002, -2.22683791e-003, 8.19365773e-003,
-       1.53973168e-002, 1.67266242e-002, -1.12891488e-003,
-       4.30405416e-005, 2.78563937e-003, 2.40906421e-003,
-       6.37746602e-002, -3.13538238e-002, 7.43469819e-002,
-       4.84850146e-002, 1.98825225e-001, -9.91070792e-002,
-       2.50993550e-001, 1.88637033e-001, -4.37479578e-002,
-       -3.77146825e-002, 1.08437136e-001, 1.12378381e-001,
-       -2.15687454e-002, -1.68507677e-002, 3.25180553e-002,
-       2.96073649e-002, 2.87146755e-002, -1.70945600e-002,
-       4.63621803e-002, 3.16513814e-002, 4.25698370e-001,
-       -1.53129712e-001, 4.60694134e-001, 2.47009754e-001,
-       -1.75435215e-001, -1.45802289e-001, 2.45831966e-001,
-       2.48770267e-001, -2.52736900e-002, -3.99410799e-002,
-       4.96812090e-002, 5.58678173e-002, 1.44576887e-003,
-       2.73878795e-005, 4.79019433e-003, 4.24682116e-003,
-       4.75220755e-002, -4.70626652e-002, 6.30484223e-002,
-       6.23796284e-002, -3.15854177e-002, -5.54462187e-002,
-       5.80265932e-002, 7.13087991e-002, 7.38039031e-004,
-       -2.02778121e-003, 6.61313348e-003, 7.05678575e-003,
-       -2.08143424e-003, -8.27605370e-004, 5.99915581e-003,
-       6.86885137e-003, -3.92675102e-002, -1.89665798e-002,
-       5.61572462e-002, 4.40132320e-002, 4.89961775e-003,
-       -2.19647232e-002, 3.04939523e-002, 3.58640961e-002,
-       5.63327968e-003, 1.87023325e-004, 1.07844509e-002,
-       4.02334379e-003, -2.46436503e-002, 3.99428513e-003,
-       4.60460149e-002, 3.54363620e-002, -2.84928262e-001,
-       4.54134904e-002, 3.54940802e-001, 3.03789198e-001,
-       2.33690031e-002, 3.10072280e-003, 1.87491491e-001,
-       1.58535764e-001, 7.26837590e-002, 5.88101940e-003,
-       1.01046689e-001, 3.06301303e-002, -3.29809263e-002,
-       3.59937269e-003, 5.83046712e-002, 4.24659364e-002,
-       -2.47799799e-001, -1.19102784e-002, 3.49719405e-001,
-       4.16214496e-001, 4.34158221e-002, 3.12209036e-002,
-       1.93990663e-001, 1.77567735e-001, 6.42955601e-002,
-       -2.15344061e-003, 9.82713178e-002, 2.99583152e-002,
-       -1.68484310e-003, -2.56158854e-003, 6.58672536e-003,
-       6.57970738e-003, -3.29718441e-002, 1.36453090e-002,
-       5.39514646e-002, 5.42430095e-002, -4.30670567e-003,
-       2.68396772e-002, 3.86757404e-002, 4.63876426e-002,
-       4.37040534e-003, -3.10397700e-005, 1.01857232e-002,
-       4.85892314e-003, -2.28214599e-002, 1.93887600e-003,
-       2.97464654e-002, 6.71910821e-003, -1.32578108e-002,
-       -1.27486726e-002, 3.91910449e-002, 3.07627674e-002,
-       1.89906522e-003, -1.21468455e-002, 4.17032391e-002,
-       3.02004647e-002, 2.22005975e-002, 1.10714429e-003,
-       4.16604877e-002, 5.96430292e-003, -2.15327710e-001,
-       -2.81288754e-003, 2.72572517e-001, 3.23386379e-002,
-       -3.58449481e-002, -4.17982489e-002, 2.46193796e-001,
-       1.02470778e-001, 2.52390113e-002, -2.01622788e-002,
-       2.43984088e-001, 9.45421457e-002, 1.82084307e-001,
-       8.87028035e-003, 3.37933779e-001, 3.69837955e-002,
-       -2.17555344e-001, -9.05580167e-003, 2.70862460e-001,
-       3.34528163e-002, -2.07999516e-002, 4.50216327e-003,
-       2.29700074e-001, 1.08453736e-001, 7.95385614e-002,
-       4.14223075e-002, 2.69605875e-001, 1.11240864e-001,
-       1.68293089e-001, 2.17323890e-003, 3.32303047e-001,
-       4.23391685e-002, -2.16700882e-002, -3.76634463e-003,
-       2.93307081e-002, 7.81653449e-003, -1.01036849e-002,
-       8.79059918e-003, 3.64241526e-002, 3.23366076e-002,
-       3.14473286e-002, 9.19404998e-003, 5.23079596e-002,
-       3.36387306e-002, 1.11030694e-002, -3.13510001e-003,
-       3.90099958e-002, 7.34901801e-003, 3.35005205e-003,
-       -1.44242086e-002, 9.08225589e-003, 2.16540284e-002,
-       7.52594089e-004, -1.59733817e-001, 4.38964479e-002,
-       2.00025484e-001, -1.94473900e-002, -1.51978597e-001,
-       5.68009987e-002, 1.84772432e-001, 2.40888423e-003,
-       -7.95705151e-003, 9.84948501e-003, 1.64568815e-002,
-       -1.66888218e-002, -3.51421423e-002, 4.01505791e-002,
-       5.23397848e-002, -6.68081827e-003, -2.42433220e-001,
-       1.57869652e-001, 3.33118439e-001, 1.51536360e-001,
-       -1.37717575e-001, 2.26744905e-001, 2.54637778e-001,
-       6.65263608e-002, -9.61021241e-003, 8.70029181e-002,
-       4.52347174e-002, -1.55396648e-002, 1.88018233e-002,
-       3.41394916e-002, 3.86698917e-002, 4.92296144e-002,
-       2.29868323e-001, 1.81432351e-001, 2.79409975e-001,
-       1.32137492e-001, 1.57684743e-001, 2.40641445e-001,
-       2.16503978e-001, 6.64402321e-002, 1.34315398e-002,
-       8.48373026e-002, 4.07522693e-002, 1.97490514e-003,
-       1.96140003e-003, 5.42812143e-003, 6.52181404e-003,
-       7.99873844e-003, 2.99588889e-002, 3.82190123e-002,
-       5.81677854e-002, 4.54371981e-003, 3.29344459e-002,
-       4.57573645e-002, 5.48286587e-002, 5.69850858e-003,
-       1.65850658e-003, 1.02333855e-002, 7.42370309e-003,
-       9.66663472e-003, 3.98465339e-003, 1.59423258e-002,
-       1.06651718e-002, -2.60092337e-002, 7.80294836e-002,
-       7.43217096e-002, 1.05455354e-001, -4.03619818e-002,
-       6.73521161e-002, 6.83145598e-002, 1.10458821e-001,
-       4.50173020e-003, 1.68426242e-003, 1.03925020e-002,
-       1.20077627e-002, 9.75166112e-002, 2.22937632e-002,
-       1.45129949e-001, 5.31426705e-002, 3.51136886e-002,
-       1.12471767e-001, 2.23020002e-001, 2.08721250e-001,
-       -1.66315660e-001, 3.29337656e-001, 2.68460482e-001,
-       4.03116435e-001, -1.94589570e-002, 5.75234108e-002,
-       4.90084216e-002, 7.65251368e-002, 9.08851996e-002,
-       -7.49821682e-003, 1.31940186e-001, 4.09017615e-002,
-       5.29311411e-002, -7.61322826e-002, 1.70482323e-001,
-       1.75399408e-001, -3.51554379e-002, -3.91571149e-002,
-       1.39186606e-001, 1.61112547e-001, -2.27410011e-002,
-       2.81348312e-003, 3.41602005e-002, 3.21452431e-002,
-       4.20119707e-003, -8.72459542e-003, 1.20065408e-002,
-       1.79318171e-002, 6.78880000e-003, -1.45347312e-001,
-       4.10046168e-002, 2.01325864e-001, 3.20593710e-003,
-       -1.48504421e-001, 3.20748612e-002, 2.01267287e-001,
-       5.84245950e-004, -1.64301917e-002, 5.31215686e-003,
-       2.33682860e-002, -1.03477295e-003, -8.08060449e-003,
-       1.14416070e-002, 1.44516118e-002, -1.16265109e-002,
-       -1.48728505e-001, 3.80698219e-002, 1.78742751e-001,
-       -4.17823344e-002, -1.26893565e-001, 7.43493959e-002,
-       1.46232352e-001, 1.04536144e-002, -5.47732227e-003,
-       1.85780749e-002, 1.26594147e-002, -1.34469241e-001,
-       -9.63224750e-003, 1.63188517e-001, 5.27468212e-002,
-       3.69179919e-002, -1.65717021e-001, 2.46863514e-001,
-       3.71550441e-001, -3.85109931e-002, -7.76038840e-002,
-       2.38932699e-001, 2.48217881e-001, 1.74084142e-001,
-       2.86748335e-002, 2.13713616e-001, 5.74842617e-002,
-       -1.32424518e-001, -8.97204690e-003, 1.76383257e-001,
-       3.52796987e-002, 1.26293469e-002, -1.14066005e-002,
-       2.02849284e-001, 1.45012811e-001, 3.67810763e-002,
-       6.43545063e-003, 1.75823346e-001, 1.04455955e-001,
-       1.84136257e-001, -1.46732517e-002, 2.35375345e-001,
-       3.75069976e-002, -1.69954412e-002, -2.59373547e-003,
-       2.48981174e-002, 4.72699897e-003, 1.55925297e-003,
-       -5.48796309e-003, 2.51795445e-002, 2.31935065e-002,
-       2.14869380e-002, 1.27053412e-003, 3.61189842e-002,
-       2.17252318e-002, 1.70578007e-002, -1.58339075e-003,
-       2.50720046e-002, 7.41704134e-003, 7.20828865e-003,
-       -8.78648309e-004, 1.14194052e-002, 6.30124100e-003,
-       4.90153208e-002, 1.53575623e-002, 5.75937741e-002,
-       2.90749557e-002, -4.92087472e-003, 5.07648103e-003,
-       2.09432784e-002, 1.58325322e-002, -5.91392396e-003,
-       -1.10903359e-003, 9.05016437e-003, 3.85071500e-003,
-       7.02350512e-002, -4.95020626e-003, 8.99137855e-002,
-       4.03524823e-002, 3.06842744e-001, 4.45743417e-003,
-       3.69855583e-001, 1.25736818e-001, -5.94219640e-002,
-       -2.35547824e-003, 1.43987000e-001, 8.86593312e-002,
-       -8.41847286e-002, -2.23859698e-002, 1.29604280e-001,
-       4.21727002e-002, 7.96579346e-002, 1.70817617e-002,
-       9.87790078e-002, 5.06731197e-002, 2.42436215e-001,
-       -3.70802656e-002, 3.23549092e-001, 1.95689440e-001,
-       -9.86783803e-002, -9.17345807e-002, 1.90716654e-001,
-       1.69988051e-001, -9.61741805e-002, -2.06407849e-002,
-       1.76590607e-001, 3.92339565e-002, 4.73369192e-003,
-       -9.59016196e-003, 8.49189330e-003, 2.21809801e-002,
-       8.25073943e-003, -1.61512226e-001, 3.92331332e-002,
-       2.57056922e-001, -4.74566733e-003, -1.61992475e-001,
-       3.73556502e-002, 2.46977895e-001, -3.78594780e-003,
-       -1.13120973e-002, 1.47678824e-002, 1.96886826e-002,
-       -1.24254962e-003, -5.72413031e-004, 4.81134839e-003,
-       4.28083260e-003, 1.65580865e-002, -1.74620412e-002,
-       3.71975042e-002, 3.30952704e-002, 1.23861404e-002,
-       -9.00926813e-003, 4.10833806e-002, 3.73846516e-002,
-       1.93217280e-003, 9.23215412e-004, 6.56950381e-003,
-       5.52603230e-003, -3.64701338e-002, 2.41369046e-002,
-       5.06005846e-002, 4.49962355e-002, 1.06183186e-001,
-       5.56003489e-002, 2.46184230e-001, 2.08884075e-001,
-       1.55601301e-003, -1.05952494e-001, 2.22581178e-001,
-       2.18729034e-001, 4.55288403e-002, -1.75271404e-003,
-       5.63349463e-002, 3.74986567e-002, -1.97846200e-002,
-       4.57579978e-002, 4.86673117e-002, 5.98435849e-002,
-       -1.85129732e-001, 2.30785325e-001, 3.14039111e-001,
-       3.55149150e-001, 1.38114601e-001, 2.56498903e-001,
-       2.76118755e-001, 3.54222000e-001, 3.14700045e-002,
-       3.45920995e-002, 4.72597033e-002, 4.70246039e-002,
-       1.03462278e-003, 4.69364517e-004, 5.07896161e-003,
-       4.66642622e-003, -1.62968766e-002, 4.23371419e-002,
-       3.91983129e-002, 5.52831963e-002, 1.86461452e-002,
-       4.03288081e-002, 3.59147303e-002, 5.20155467e-002,
-       -7.76813715e-004, 1.30126276e-003, 3.75249772e-003,
-       3.96848423e-003, -8.95436038e-004, 8.57915916e-003,
-       9.81993135e-003, 1.68246180e-002, -1.26015088e-002,
-       1.78807452e-001, 1.12598501e-001, 2.16117978e-001,
-       1.46292849e-002, 1.29700512e-001, 9.54886824e-002,
-       1.57382533e-001, 5.66842500e-003, 4.11624648e-003,
-       8.51849187e-003, 9.43869632e-003, 2.95033376e-003,
-       4.06296849e-002, 2.62950510e-002, 4.68285754e-002,
-       4.75936010e-002, 1.12457059e-001, 1.03654526e-001,
-       1.84783250e-001, -6.84231669e-002, 1.54155120e-001,
-       1.38706714e-001, 2.24251196e-001, -1.06166834e-002,
-       2.81758569e-002, 2.67874096e-002, 4.07331102e-002,
-       -3.73946340e-003, -5.58146322e-003, 1.23636294e-002,
-       1.38119888e-002, -5.27931526e-002, -1.42651677e-001,
-       1.10127434e-001, 2.16249734e-001, -6.48872033e-002,
-       -3.88970286e-001, 1.40779465e-001, 4.33127970e-001,
-       -5.36733214e-003, -4.19739597e-002, 2.83957087e-002,
-       5.89544363e-002, -8.86638276e-003, -1.15589015e-002,
-       1.03126690e-002, 1.45138409e-002, -5.56251407e-002,
-       -1.72949955e-001, 8.17847699e-002, 1.92729041e-001,
-       -1.14088855e-003, -9.08540264e-002, 5.05947918e-002,
-       1.26989737e-001, 1.09854685e-002, -5.47971902e-003,
-       1.33353854e-002, 1.12777613e-002, 6.59291167e-004,
-       1.59349910e-003, 6.28427882e-003, 6.73511717e-003,
-       2.32498776e-002, 3.74304876e-002, 4.61532772e-002,
-       5.82000911e-002, 7.53040239e-003, 2.92146243e-002,
-       3.67151983e-002, 4.31878529e-002, -5.80099504e-003,
-       -1.04270887e-003, 8.64268281e-003, 6.33917563e-003,
-       3.11492402e-002, 1.84581764e-002, 5.01483306e-002,
-       5.81489429e-002, 1.07676737e-001, 2.77912132e-002,
-       2.43804082e-001, 3.13723564e-001, -1.70640685e-002,
-       -9.78934020e-003, 2.47890443e-001, 2.47254074e-001,
-       -1.08357064e-001, -3.07382811e-002, 1.20284811e-001,
-       4.86185923e-002, 4.03407142e-002, 8.64624325e-003,
-       5.38653694e-002, 4.67623845e-002, -4.96211387e-002,
-       9.67717618e-002, 2.51400739e-001, 2.27691695e-001,
-       -1.18616834e-001, -1.15484998e-001, 4.43067729e-001,
-       2.85725802e-001, -9.82302576e-002, -2.63372045e-002,
-       1.37942791e-001, 5.43118715e-002, 4.67133056e-003,
-       -5.37409913e-004, 6.67474000e-003, 5.90794021e-003,
-       -1.86919607e-002, -2.73863748e-002, 4.56019267e-002,
-       5.03652655e-002, -5.91723546e-002, -5.95827885e-002,
-       8.98123309e-002, 7.18297362e-002, 1.26509822e-003,
-       7.08687119e-004, 1.43976957e-002, 8.87328852e-003,
-       -1.99844060e-003, -3.06076766e-003, 1.73305385e-002,
-       6.70076208e-003, 7.64205381e-002, 3.27122770e-002,
-       1.06375873e-001, 5.24907373e-002, -1.81955285e-002,
-       1.60929300e-002, 4.19857651e-002, 2.99543850e-002,
-       -8.68473202e-003, -1.18865550e-003, 1.31611498e-002,
-       6.01145765e-003, 6.19457737e-002, 1.36973374e-002,
-       1.52371705e-001, 5.31633757e-002, 3.49369764e-001,
-       1.44813612e-001, 4.51011240e-001, 2.14785710e-001,
-       -1.61425680e-001, 1.35681024e-002, 2.37555534e-001,
-       1.13709919e-001, -9.60813463e-002, -5.01833390e-003,
-       1.19325288e-001, 4.22143526e-002, 1.43970236e-001,
-       3.00619230e-002, 1.87482998e-001, 5.51302247e-002,
-       8.86099413e-002, -2.33556759e-002, 2.29525626e-001,
-       1.41158998e-001, -1.43909335e-001, -5.50887398e-002,
-       2.24921376e-001, 1.52187899e-001, -9.38251466e-002,
-       3.34124290e-003, 1.20082758e-001, 4.32570130e-002,
-       1.22700054e-002, 4.94150852e-004, 1.87496617e-002,
-       8.58842116e-003, -5.47111034e-003, -4.90706638e-002,
-       4.50686552e-002, 7.04606473e-002, -1.18034491e-002,
-       -4.71538082e-002, 4.52539101e-002, 7.09344670e-002,
-       -5.95206954e-003, -8.83581175e-004, 1.24197444e-002,
-       8.35446268e-003, -1.62472425e-003, -2.61424086e-003,
-       9.25463159e-003, 6.41806237e-003, 6.08516373e-002,
-       3.54989022e-002, 7.60517567e-002, 5.51611520e-002,
-       7.81275425e-003, 2.53387690e-002, 3.10769659e-002,
-       3.72789800e-002, -1.89315388e-003, 8.08635843e-004,
-       4.61317133e-003, 4.12559183e-003, 4.81330715e-002,
-       4.04382274e-002, 8.38159099e-002, 6.13711029e-002,
-       2.79197454e-001, 1.77102044e-001, 3.24458778e-001,
-       2.24291489e-001, -2.43166890e-002, 1.76882967e-002,
-       1.15483351e-001, 1.08782806e-001, -3.62240486e-002,
-       -1.07295513e-002, 4.82967086e-002, 3.36252972e-002,
-       5.92457354e-002, 2.36764494e-002, 7.06092864e-002,
-       5.16814105e-002, 2.72954199e-002, -1.06313303e-001,
-       1.59472838e-001, 2.10547701e-001, -1.70536861e-001,
-       -3.50952774e-001, 2.36370996e-001, 3.96579385e-001,
-       -4.22462672e-002, -6.03122972e-002, 6.91486597e-002,
-       7.89439008e-002, 8.22363363e-004, -1.13858217e-002,
-       6.52248133e-003, 1.66172236e-002, -2.77964976e-002,
-       -1.20045714e-001, 4.74569425e-002, 1.57119021e-001,
-       -1.56206712e-002, -6.22651055e-002, 4.47975248e-002,
-       1.22498393e-001, 1.45513262e-003, -1.09787553e-003,
-       6.00438518e-003, 1.22955758e-002, -1.74213815e-002,
-       2.25609052e-003, 2.38086469e-002, 5.66131482e-003,
-       -3.35167907e-002, -1.17008956e-002, 5.79560474e-002,
-       2.71552615e-002, 7.86995701e-003, -1.48343137e-002,
-       3.63463573e-002, 3.57013233e-002, -5.73390889e-006,
-       7.22031400e-004, 4.78915544e-003, 4.18055942e-003,
-       -1.76527604e-001, -5.17044729e-003, 2.01901168e-001,
-       2.77936533e-002, -2.34132662e-001, -3.47851366e-002,
-       3.22582364e-001, 1.40710205e-001, 1.39503283e-002,
-       -9.08391476e-002, 1.48920983e-001, 1.57009497e-001,
-       1.86376702e-002, -1.40116224e-002, 3.06301806e-002,
-       2.80938596e-002, -1.74103722e-001, -1.41507946e-002,
-       1.92344025e-001, 3.07144802e-002, -5.65386228e-002,
-       1.33384034e-001, 3.32575977e-001, 2.21464202e-001,
-       -1.16468586e-001, 2.59879470e-001, 2.62859493e-001,
-       3.12559128e-001, 1.79832503e-002, 1.52228493e-002,
-       3.66701074e-002, 3.00899595e-002, -1.93158854e-002,
-       -6.02561922e-005, 2.16832962e-002, 5.52778412e-003,
-       4.34536189e-002, 4.70335931e-002, 9.09525529e-002,
-       6.34539574e-002, -4.04050425e-002, 5.27097769e-002,
-       8.31450447e-002, 7.68677518e-002, -4.88594873e-004,
-       2.23085005e-003, 7.30625354e-003, 6.69738092e-003,
-       -3.25112487e-003, 1.33269688e-003, 7.77188689e-003,
-       2.85564642e-003, -5.50278053e-002, -1.03343679e-002,
-       6.68534115e-002, 2.25628726e-002, 3.28114908e-003,
-       -1.04902526e-002, 2.26064641e-002, 2.21030898e-002,
-       8.33858387e-004, -3.45329609e-004, 3.82246659e-003,
-       2.97581917e-003, -3.05625927e-002, -7.23082514e-004,
-       5.59096634e-002, 1.59852579e-002, -4.18322325e-001,
-       -3.23474593e-002, 4.63808089e-001, 1.10267542e-001,
-       3.43031511e-002, -2.34650914e-002, 1.14641368e-001,
-       1.04293682e-001, 1.55378375e-002, 1.02294190e-003,
-       2.83121709e-002, 2.01449972e-002, -4.27287854e-002,
-       -6.29606331e-003, 6.20699711e-002, 1.88187659e-002,
-       -3.18509698e-001, 7.98978806e-002, 3.87731433e-001,
-       1.67371765e-001, 6.87665418e-002, 2.19300851e-001,
-       1.54360175e-001, 2.53252536e-001, 1.33688273e-002,
-       2.89176069e-002, 3.26796249e-002, 3.93739417e-002,
-       -4.88459226e-003, -5.10366051e-004, 7.86504056e-003,
-       3.61655606e-003, -1.36990007e-002, 3.54004279e-002,
-       4.98689339e-002, 4.99379374e-002, 1.49004152e-002,
-       3.57778035e-002, 4.06149887e-002, 5.94827794e-002,
-       -2.08988483e-003, 2.08756304e-003, 5.47591178e-003,
-       7.06083700e-003, 2.64994334e-003, 2.42869183e-002,
-       1.16043119e-002, 3.78509201e-002, -2.77332217e-002,
-       1.94373220e-001, 4.49737422e-002, 2.99294949e-001,
-       1.26034059e-002, 2.05309466e-001, 2.62415186e-002,
-       3.19219381e-001, -4.20307880e-003, 2.76183598e-002,
-       1.08086662e-002, 4.47507165e-002, 3.41629833e-002,
-       -1.36152878e-002, 1.56913444e-001, 5.70916459e-002,
-       -8.38238299e-002, 6.52475357e-002, 3.82773459e-001,
-       1.91979349e-001, 1.92601204e-001, 4.78615612e-002,
-       2.34196752e-001, 1.29965529e-001, -6.53986558e-002,
-       9.64397192e-003, 1.01678580e-001, 2.80649029e-002,
-       8.90700221e-002, 2.65293848e-003, 1.60302550e-001,
-       4.60950956e-002, -1.30675256e-001, 1.25082638e-002,
-       3.25767517e-001, 1.32798955e-001, 1.44974321e-001,
-       8.75109434e-003, 1.92446202e-001, 7.93249905e-002,
-       -4.28371280e-002, 1.06659327e-002, 5.86416647e-002,
-       2.64632851e-002, 4.49337577e-003, -2.77790800e-003,
-       6.78816298e-003, 1.40824569e-002, -5.36177214e-003,
-       -7.63363466e-002, 3.06228288e-002, 1.40581027e-001,
-       2.55671572e-002, -6.53660521e-002, 2.98401155e-002,
-       1.29212320e-001, 9.73588787e-004, 7.35071488e-004,
-       7.28581287e-003, 4.51543368e-003, 1.05983648e-003,
-       -8.82957771e-004, 4.42293612e-003, 3.19142966e-003,
-       3.89666595e-002, 2.17392109e-002, 4.95926440e-002,
-       3.42099704e-002, -2.07984932e-002, 2.51339823e-002,
-       3.97413336e-002, 3.73882465e-002, -2.45343777e-003,
-       -7.06466730e-004, 4.90371417e-003, 3.79261072e-003,
-       1.96522307e-002, 2.40573473e-003, 3.59884463e-002,
-       2.18528472e-002, 3.25126380e-001, -5.03037870e-003,
-       3.77621442e-001, 2.04742670e-001, -2.75386482e-001,
-       -1.35408118e-001, 3.18976343e-001, 2.54470646e-001,
-       -2.41863169e-002, -9.49549489e-003, 3.65392379e-002,
-       2.75376830e-002, 2.67403666e-002, 2.63165202e-005,
-       3.77420932e-002, 2.07274575e-002, 1.76023722e-001,
-       -6.41531423e-002, 2.78439760e-001, 1.77207947e-001,
-       -2.16138422e-001, -3.40133198e-002, 2.70559162e-001,
-       1.79101214e-001, -2.02413481e-002, -1.24008255e-003,
-       3.17563117e-002, 2.25694608e-002, 1.93503231e-003,
-       -5.56566520e-004, 4.27528843e-003, 3.01670516e-003,
-       1.46617005e-002, -2.89002471e-002, 3.26571502e-002,
-       3.66509706e-002, -1.65911634e-002, -2.73714103e-002,
-       3.23431082e-002, 3.59291360e-002, -1.29684119e-003,
-       -3.45894834e-004, 3.70232086e-003, 3.34104011e-003,
-       5.98311750e-003, 1.05492342e-002, 8.94202478e-003,
-       2.15263944e-002, -2.24543549e-003, 1.33578286e-001,
-       2.72637066e-002, 2.10825384e-001, -2.80982489e-003,
-       1.25109613e-001, 3.42728235e-002, 2.15699464e-001,
-       -1.06604840e-003, 1.05930772e-002, 4.23323456e-003,
-       2.65961103e-002, 1.04978681e-001, -2.91036665e-002,
-       1.17106736e-001, 4.91518006e-002, 5.44691160e-002,
-       -2.90812179e-002, 2.71324694e-001, 1.90588176e-001,
-       5.97921759e-002, 6.45737797e-002, 2.46676832e-001,
-       1.76535428e-001, -1.62088666e-002, 1.90236829e-002,
-       3.84315178e-002, 2.83595175e-002, 6.08282946e-002,
-       -1.51563054e-002, 8.50100815e-002, 3.44708040e-002,
-       2.63631016e-001, -9.64099020e-002, 5.37047148e-001,
-       1.75775170e-001, 8.00439119e-002, 2.33679842e-002,
-       2.19382852e-001, 9.68189538e-002, -1.18050762e-002,
-       5.91749791e-003, 3.45138609e-002, 1.39079764e-002,
-       2.84454273e-003, 1.59241096e-003, 8.26416072e-003,
-       5.78078907e-003, 5.28927818e-002, -2.95505580e-002,
-       7.24359155e-002, 6.06346689e-002, 1.24500198e-002,
-       -3.65224704e-002, 3.15008536e-002, 6.09368794e-002,
-       -5.69956552e-004, -2.75520468e-003, 3.08373757e-003,
-       7.85585307e-003, 1.26846815e-002, -6.91740017e-004,
-       1.87041443e-002, 3.55033507e-003, 9.03022662e-003,
-       8.90522823e-003, 3.49560007e-002, 1.99282728e-002,
-       -1.28647862e-002, 3.40154464e-003, 3.87335233e-002,
-       2.03660522e-002, -1.32454382e-002, -1.09547889e-003,
-       1.56957991e-002, 3.92811000e-003, 1.25010908e-001,
-       1.04702578e-003, 1.74962640e-001, 2.46070195e-002,
-       -3.99378547e-003, 2.09764466e-002, 2.41176739e-001,
-       1.07775360e-001, -7.58463368e-002, 1.00631258e-002,
-       3.08007687e-001, 1.21695712e-001, -1.17995515e-001,
-       -7.34300911e-003, 1.41341016e-001, 3.29686962e-002,
-       1.53735548e-001, -1.04859825e-002, 2.02723324e-001,
-       3.15070674e-002, -1.18820615e-001, -3.41519751e-002,
-       3.71897846e-001, 1.52923867e-001, -6.61689341e-002,
-       -2.20375478e-001, 3.45083982e-001, 2.80703038e-001,
-       -1.22433752e-001, -1.02961352e-002, 1.64475620e-001,
-       3.42212878e-002, 1.66145544e-002, -1.51824940e-003,
-       2.63023190e-002, 5.88553958e-003, -4.39064503e-002,
-       -5.60438856e-002, 8.76970515e-002, 8.75728056e-002,
-       -2.40339804e-002, -5.69314361e-002, 7.61434361e-002,
-       1.10439233e-001, -2.54171551e-003, -1.54053618e-003,
-       1.20543297e-002, 8.59299395e-003, -1.41131342e-003,
-       -9.13567189e-003, 1.35897109e-002, 1.89275723e-002,
-       -3.89265176e-003, -2.18484595e-001, 4.85950448e-002,
-       2.66246140e-001, -2.80276388e-002, -2.40196109e-001,
-       5.33464402e-002, 2.89449722e-001, -8.05054884e-003,
-       -2.33632326e-002, 1.21557582e-002, 2.98089013e-002,
-       -1.35208592e-001, -4.39819135e-002, 1.61036953e-001,
-       6.07778318e-002, -1.90229401e-001, -2.90586680e-001,
-       2.44155020e-001, 3.62976432e-001, -2.75845397e-002,
-       -1.94769472e-001, 1.21536814e-001, 2.81165689e-001,
-       6.94625685e-003, -2.52989680e-002, 2.52536628e-002,
-       3.79954502e-002, -1.24589831e-001, -2.30955537e-002,
-       1.42129973e-001, 3.90058458e-002, -8.74977112e-002,
-       -1.67187117e-002, 1.59336612e-001, 1.17778756e-001,
-       -4.26835474e-003, 2.16860026e-002, 7.88923800e-002,
-       9.64503735e-002, 4.88287117e-003, 2.46278942e-003,
-       1.51494732e-002, 1.59776900e-002, -1.27295591e-002,
-       -1.53874164e-003, 1.61789618e-002, 5.44271944e-003,
-       -7.39214383e-003, 1.41087631e-002, 2.46753264e-002,
-       2.57309563e-002, 2.65528518e-003, 1.28444936e-002,
-       1.73884165e-002, 2.42166556e-002, -1.21407669e-004,
-       1.69111066e-003, 2.82203313e-003, 3.71065550e-003,
-       1.88758038e-003, 8.45111813e-003, 6.39547175e-003,
-       1.72391851e-002, 1.44747943e-002, 1.41498759e-001,
-       3.63598540e-002, 2.25383416e-001, 1.19609572e-003,
-       1.47837818e-001, 2.36476883e-002, 2.42902711e-001,
-       3.55396536e-004, 1.62318666e-002, 4.57418524e-003,
-       2.99176294e-002, 5.08022681e-002, 5.44940704e-004,
-       7.54169896e-002, 4.26972210e-002, 2.67546207e-001,
-       6.34463653e-002, 3.51942629e-001, 2.03692630e-001,
-       -1.87716726e-002, 6.66949227e-002, 1.03664704e-001,
-       1.66914955e-001, -1.31935868e-002, 1.29902940e-002,
-       2.86322925e-002, 2.89405733e-002, 5.11522368e-002,
-       -6.43924903e-003, 7.68340677e-002, 3.97391878e-002,
-       2.37451404e-001, -1.73909754e-001, 3.83761883e-001,
-       2.68665165e-001, 4.03497666e-002, -9.58756655e-002,
-       1.56452358e-001, 1.66524500e-001, -9.81937815e-003,
-       -3.13206622e-003, 2.80732326e-002, 1.88269410e-002,
-       4.08705045e-003, -5.93176926e-004, 8.71066377e-003,
-       6.97281165e-003, 2.57596765e-002, -3.39146182e-002,
-       6.78618625e-002, 6.51184171e-002, 2.44160239e-002,
-       -3.76202576e-002, 4.93437387e-002, 6.26700148e-002,
-       4.82371659e-004, -3.27464822e-003, 3.93599365e-003,
-       6.58074580e-003, 1.10128662e-002, -3.08342604e-003,
-       1.66147109e-002, 6.05509616e-003, 1.05698276e-002,
-       1.62674598e-002, 5.44309802e-002, 2.81373169e-002,
-       -1.49958869e-002, 1.75805520e-002, 4.24731560e-002,
-       3.46491858e-002, -9.46246833e-003, -9.71004891e-004,
-       1.25037292e-002, 5.00692846e-003, 1.13130040e-001,
-       -1.07134320e-002, 1.48930982e-001, 3.34431864e-002,
-       8.93445164e-002, -4.96498570e-002, 4.15395588e-001,
-       1.58998951e-001, -6.60490468e-002, -1.29164075e-002,
-       2.80113250e-001, 1.43223062e-001, -1.12517990e-001,
-       -1.27327237e-002, 1.33305445e-001, 3.42390724e-002,
-       9.58336890e-002, -8.90097115e-003, 1.30984202e-001,
-       4.26444523e-002, 1.80302694e-001, -1.62449554e-001,
-       3.47904086e-001, 2.51560181e-001, -6.60199448e-002,
-       -4.04988602e-002, 3.06649953e-001, 1.76101953e-001,
-       -1.20991230e-001, -4.29056212e-003, 1.51547372e-001,
-       2.97486652e-002, 5.35155041e-003, 2.84516631e-004,
-       1.35986870e-002, 7.22637633e-003, 3.15988883e-002,
-       -4.20694649e-002, 5.96374199e-002, 5.77878058e-002,
-       2.98642000e-004, -4.52206470e-002, 6.08334318e-002,
-       5.64006977e-002, -9.15018842e-003, -8.41179339e-004,
-       1.58458371e-002, 5.63843409e-003, -3.70763894e-003,
-       3.21061118e-003, 7.95662031e-003, 6.23942865e-003,
-       8.48632772e-003, 5.31310588e-002, 2.49078665e-002,
-       7.62265697e-002, 2.31094211e-002, 5.78247197e-002,
-       3.72273624e-002, 8.47638100e-002, 3.49799008e-003,
-       5.13303466e-003, 6.86264131e-003, 9.25934315e-003,
-       2.32218131e-002, 9.83480550e-003, 5.38297147e-002,
-       5.60335927e-002, 1.95671156e-001, 1.08206041e-001,
-       2.77432650e-001, 5.51889539e-001, 5.61283305e-002,
-       2.14217156e-001, 1.58072203e-001, 3.49859685e-001,
-       -8.09477363e-003, 2.06422880e-002, 2.23646034e-002,
-       2.94207223e-002, 3.66437286e-002, 1.28806541e-002,
-       5.75631186e-002, 6.58236966e-002, 1.76569074e-001,
-       1.71115711e-001, 2.24078968e-001, 2.83594906e-001,
-       1.88144930e-002, 2.11703330e-002, 8.66428167e-002,
-       1.04101621e-001, -7.67380279e-003, -1.72545156e-003,
-       1.54361306e-002, 1.04095004e-002, 4.79483139e-003,
-       2.64027878e-003, 8.35080817e-003, 7.36422883e-003,
-       1.56317912e-002, -9.00123734e-003, 2.53972020e-002,
-       2.73718182e-002, 1.64362218e-003, -1.18365213e-002,
-       1.34894894e-002, 2.16449630e-002, -5.95791440e-004,
-       -6.42523577e-004, 2.48112855e-003, 2.09046155e-003,
-       5.13723877e-004, 2.93643272e-004, 1.94743683e-003,
-       1.42010523e-003, -1.42255682e-003, 4.51209443e-003,
-       1.23385377e-002, 1.12579232e-002, -5.03232069e-002,
-       7.39971455e-003, 5.72440811e-002, 2.08255760e-002,
-       -7.40556652e-003, -1.99095509e-003, 1.85458791e-002,
-       5.72558260e-003, 5.48350811e-003, -9.70116176e-004,
-       1.35167930e-002, 9.99524910e-003, -5.79456508e-004,
-       2.12536915e-003, 6.83251545e-002, 5.89919984e-002,
-       -3.35776508e-001, 1.14239482e-002, 3.82017851e-001,
-       1.00731753e-001, -7.86184222e-002, 9.75667033e-004,
-       1.45826727e-001, 3.51343676e-002, 1.01812081e-002,
-       -2.68782210e-002, 2.03344058e-002, 3.77266333e-002,
-       5.32368943e-003, -1.45732820e-001, 8.74532536e-002,
-       2.09643826e-001, -3.06798637e-001, -1.32122964e-001,
-       3.64205211e-001, 2.29624271e-001, -7.10763559e-002,
-       3.82087845e-003, 1.36817515e-001, 4.43529524e-002,
-       -2.88051990e-004, -2.22879183e-002, 4.27468587e-003,
-       3.12904827e-002, 1.25310454e-003, -1.80142775e-001,
-       2.61247605e-002, 2.42000416e-001, -1.60471257e-002,
-       -1.69776127e-001, 4.04993072e-002, 2.23564044e-001,
-       -2.02506245e-003, -1.05635338e-002, 1.00153657e-002,
-       1.57333370e-002, 3.58883408e-004, -1.67186852e-004,
-       4.37369850e-003, 4.28260397e-003, -2.73137609e-003,
-       -1.71613730e-002, 3.16858478e-002, 3.68122831e-002,
-       4.90725506e-003, -2.10989751e-002, 3.36624943e-002,
-       3.80461030e-002, 5.23035554e-003, 8.84734967e-004,
-       7.31526874e-003, 5.39280986e-003, -1.94773450e-002,
-       -1.17196711e-002, 3.48596573e-002, 3.04324273e-002,
-       -5.81919355e-003, -1.08188942e-001, 1.65408209e-001,
-       1.92925915e-001, 1.71427682e-001, 7.11412057e-002,
-       2.35706136e-001, 2.18820125e-001, 6.97030723e-002,
-       3.45403440e-002, 7.65585005e-002, 5.04302457e-002,
-       -2.05171723e-002, 2.48517338e-002, 3.94436531e-002,
-       4.04048450e-002, 6.69953451e-002, 2.64179677e-001,
-       2.06430376e-001, 3.11080307e-001, 3.10308158e-001,
-       2.54111052e-001, 3.56920749e-001, 3.10335547e-001,
-       5.31823896e-002, 2.62643155e-002, 6.39579520e-002,
-       3.97957936e-002, 2.52756500e-003, 4.68656654e-003,
-       6.33759703e-003, 7.32412096e-003, 1.73103362e-002,
-       6.17721975e-002, 4.35455292e-002, 7.37462267e-002,
-       2.29243916e-002, 5.72882369e-002, 4.19478975e-002,
-       6.79040179e-002, 9.29715519e-004, 4.10428300e-004,
-       4.61936183e-003, 4.06084443e-003, 6.95818308e-005,
-       -1.18192786e-003, 5.97311556e-003, 2.90824659e-003,
-       -1.10366950e-002, 9.55316611e-003, 3.31960581e-002,
-       2.55409069e-002, -5.55871008e-003, 1.45146549e-002,
-       5.12323454e-002, 2.93190703e-002, -1.95253529e-002,
-       -6.19365019e-004, 2.86678392e-002, 4.99462290e-003,
-       1.67356730e-002, 3.62715684e-003, 4.19208817e-002,
-       2.08192896e-002, -7.63984770e-002, 2.82643326e-002,
-       1.84789151e-001, 1.21493272e-001, -3.03851403e-002,
-       1.73099581e-002, 3.62230748e-001, 1.10172018e-001,
-       -1.41491011e-001, 2.15373002e-003, 2.09176794e-001,
-       3.02386768e-002, 1.68433189e-002, -1.52206849e-002,
-       3.87028381e-002, 3.34514529e-002, -4.43859994e-002,
-       -1.07878566e-001, 1.59776181e-001, 2.06782609e-001,
-       -6.71390891e-002, -1.11549139e-001, 3.14831167e-001,
-       2.44776085e-001, -1.36883616e-001, -2.55417824e-003,
-       2.01917797e-001, 3.79958674e-002, -2.05533882e-003,
-       -2.49289013e-002, 6.65189512e-003, 3.40777822e-002,
-       -8.32035299e-003, -2.25880802e-001, 3.35402340e-002,
-       2.78852016e-001, -2.38425541e-003, -2.12515056e-001,
-       4.04483490e-002, 2.72824049e-001, -5.41373389e-003,
-       -1.51050910e-002, 1.46798296e-002, 2.51965523e-002,
-       3.28544353e-004, -1.01296767e-003, 4.73848311e-003,
-       4.29364154e-003, 4.27467609e-003, -3.12066488e-002,
-       3.43826748e-002, 4.33048382e-002, 3.66432481e-002,
-       -3.13708968e-002, 5.00328764e-002, 4.84031029e-002,
-       2.49213283e-003, 8.69672513e-004, 5.60807902e-003,
-       4.73081553e-003, -1.25363786e-002, -6.62288954e-003,
-       3.25829722e-002, 2.58605834e-002, -6.81583881e-002,
-       -7.25039244e-002, 1.63401246e-001, 1.54411554e-001,
-       2.74495572e-001, -1.32860854e-001, 3.17939103e-001,
-       2.12959677e-001, 5.31102344e-002, -7.74333766e-003,
-       6.31474033e-002, 3.38516980e-002, -1.63366441e-002,
-       6.06924223e-005, 3.33300382e-002, 2.51825098e-002,
-       9.42465942e-003, 7.72646889e-002, 1.71498895e-001,
-       1.61176518e-001, 3.39013845e-001, 3.18586260e-001,
-       3.70980978e-001, 3.52898479e-001, 4.20461819e-002,
-       2.68870667e-002, 5.38445674e-002, 3.77738811e-002,
-       -1.65939400e-006, 1.63618708e-003, 4.82202135e-003,
-       4.67878673e-003, 3.16721238e-002, 4.20777798e-002,
-       4.69677597e-002, 5.04483469e-002, 4.93438691e-002,
-       2.97953635e-002, 5.69230951e-002, 4.65946533e-002,
-       -2.32982697e-004, -5.36465028e-004, 3.74315400e-003,
-       3.50161269e-003, 1.88231375e-003, -1.11577509e-003,
-       5.49448561e-003, 4.10272554e-003, 5.57923643e-003,
-       9.99026746e-003, 1.76667701e-002, 2.83040758e-002,
-       -2.48951581e-003, 9.66558792e-003, 1.76278856e-002,
-       2.87030041e-002, -3.89932352e-003, 8.82583990e-005,
-       6.80968584e-003, 4.79276851e-003, 4.14978974e-002,
-       -1.41752148e-002, 6.53098524e-002, 2.98719257e-002,
-       3.57008539e-002, -1.92438196e-002, 1.65761128e-001,
-       1.04054295e-001, 1.88212248e-003, -6.75615389e-003,
-       1.11162327e-001, 9.21090245e-002, -3.45320217e-002,
-       3.50292794e-005, 5.61929345e-002, 1.78152397e-002,
-       3.21657881e-002, -1.91562548e-002, 6.19173199e-002,
-       3.49889174e-002, -1.16199665e-001, -2.79949278e-001,
-       3.86816353e-001, 3.36381167e-001, 1.50553003e-001,
-       -3.60438198e-001, 2.95482695e-001, 3.99347633e-001,
-       -3.44697051e-002, -3.23702917e-002, 6.07984550e-002,
-       4.27243896e-002, 3.80643673e-004, -5.81025984e-003,
-       4.62861033e-003, 9.30092111e-003, -1.18243266e-002,
-       -5.05149588e-002, 3.22521105e-002, 7.36146718e-002,
-       6.36878284e-003, -3.58109735e-002, 2.91315615e-002,
-       6.17260896e-002, 1.06456115e-004, -5.80688938e-003,
-       4.66731144e-003, 9.51723754e-003, 1.97191694e-004,
-       9.67261090e-004, 5.60472906e-003, 6.39913417e-003,
-       1.77485067e-002, 2.92439163e-002, 3.96610089e-002,
-       6.05651252e-002, 1.36183975e-002, 4.75671478e-002,
-       3.68796028e-002, 6.98997080e-002, 5.58855209e-006,
-       3.87767586e-003, 5.20102400e-003, 7.54049979e-003,
-       5.58151901e-002, 2.67330352e-002, 6.96822554e-002,
-       4.98208851e-002, 5.65642193e-002, 2.77478635e-001,
-       2.94552565e-001, 3.53384405e-001, 4.65109386e-002,
-       1.10925227e-001, 2.04188988e-001, 2.13570043e-001,
-       -1.75752193e-002, 1.41695384e-002, 4.21235338e-002,
-       3.26525010e-002, 5.20209931e-002, -2.45910026e-002,
-       6.94213659e-002, 5.46869487e-002, 1.43021598e-001,
-       -2.36789614e-001, 2.81019628e-001, 3.87359440e-001,
-       1.02502415e-002, -1.43431658e-002, 1.75873995e-001,
-       2.45484591e-001, -2.15339791e-002, -2.67324038e-003,
-       4.22308072e-002, 3.15342471e-002, -8.46233510e-004,
-       1.53629947e-003, 5.82786975e-003, 8.63396749e-003,
-       1.42120160e-002, -2.89945267e-002, 4.01692167e-002,
-       8.79405662e-002, 1.69208571e-002, -7.46910945e-002,
-       3.84317674e-002, 1.16007477e-001, -1.10925554e-004,
-       -6.80860784e-003, 5.76472515e-003, 1.22775780e-002,
-       -2.21425275e-004, 7.44451943e-004, 5.12384297e-003,
-       4.85592242e-003, 2.62726448e-003, 3.17397639e-002,
-       2.95482110e-002, 4.68709655e-002, -5.57423860e-004,
-       3.50576937e-002, 2.53477339e-002, 5.31601198e-002,
-       2.97162973e-004, 2.23001605e-003, 3.22378008e-003,
-       6.15735026e-003, 3.05648893e-002, 5.87524613e-003,
-       4.90624867e-002, 3.39574814e-002, 1.13968350e-001,
-       1.72992334e-001, 2.45145142e-001, 2.91240841e-001,
-       -2.79367696e-002, 1.00443512e-001, 1.83127314e-001,
-       3.26978713e-001, -2.51318179e-002, 1.40352407e-002,
-       3.50051858e-002, 4.14774977e-002, 4.85881716e-002,
-       1.48267136e-003, 6.51879907e-002, 3.43687125e-002,
-       -7.43400902e-002, 2.53281612e-002, 4.94765818e-001,
-       2.97551304e-001, -2.92268060e-002, -1.22492209e-001,
-       2.21942127e-001, 2.59482503e-001, -2.02000868e-002,
-       -1.36411367e-002, 3.43958810e-002, 3.50589007e-002,
-       1.59909343e-003, -5.51175675e-004, 6.62288722e-003,
-       5.80993388e-003, -8.38255696e-003, -5.17987385e-002,
-       5.16177081e-002, 6.76556453e-002, -7.68287294e-003,
-       -3.27656493e-002, 3.02220322e-002, 5.30003011e-002,
-       -5.91722201e-005, -1.95023813e-003, 3.89568764e-003,
-       5.56715345e-003, 4.66486299e-003, 1.43891270e-003,
-       8.34287517e-003, 4.94920975e-003, -1.69729888e-002,
-       3.64180133e-002, 3.96390110e-002, 4.55564409e-002,
-       -5.33069037e-002, 2.83498242e-002, 6.37847334e-002,
-       4.47733775e-002, -2.78380699e-004, -1.00494362e-003,
-       5.03736082e-003, 4.85244580e-003, 7.13837072e-002,
-       1.74643693e-003, 8.37836266e-002, 2.60839239e-002,
-       -5.63283600e-002, 8.88512358e-002, 2.00957805e-001,
-       1.56170994e-001, -4.19699013e-001, 2.04038396e-001,
-       4.54217374e-001, 2.64305025e-001, -2.25776285e-002,
-       2.25124881e-002, 4.57991585e-002, 3.97994630e-002,
-       6.45081848e-002, -6.79824781e-003, 8.09997246e-002,
-       2.80361790e-002, -1.84712969e-002, -5.86147942e-002,
-       2.33145192e-001, 1.57272384e-001, -1.64518788e-001,
-       6.09235652e-002, 2.34422982e-001, 2.38212943e-001,
-       -5.03773876e-002, 3.49799208e-002, 6.12876080e-002,
-       5.64637817e-002, 2.73879711e-003, -1.95857487e-003,
-       8.34751129e-003, 6.90189190e-003, -4.59205871e-003,
-       -5.60285002e-002, 4.49822843e-002, 7.30758980e-002,
-       -9.96068213e-003, -5.73877655e-002, 3.07754595e-002,
-       7.87687823e-002, -3.66957206e-003, -3.36516555e-003,
-       6.40444737e-003, 8.50577187e-003, -2.08723103e-003,
-       -7.64476019e-004, 6.44099619e-003, 3.95299261e-003,
-       -3.47771123e-002, -2.85140947e-002, 5.70369773e-002,
-       4.27256115e-002, -3.64222424e-003, -2.90612485e-002,
-       3.12815011e-002, 4.81411070e-002, 1.03924435e-003,
-       -1.51970505e-003, 4.15520184e-003, 5.48098143e-003,
-       -5.37472256e-002, -1.72775276e-002, 7.08328784e-002,
-       3.73780727e-002, -8.08379501e-002, -1.39284119e-001,
-       2.85501629e-001, 2.75230229e-001, 1.17987823e-002,
-       4.36873585e-002, 1.71803758e-001, 2.40589380e-001,
-       1.40819103e-002, -2.57596665e-004, 3.23393643e-002,
-       3.07598412e-002, -6.27659783e-002, 1.25958482e-004,
-       7.51355737e-002, 4.25715260e-002, -9.70252901e-002,
-       -1.75918583e-002, 2.88605899e-001, 3.75122041e-001,
-       -6.04836969e-003, -2.18808904e-001, 1.72980443e-001,
-       4.45677221e-001, 2.14748718e-002, -2.17600092e-002,
-       3.98902036e-002, 5.14828041e-002, -2.85050040e-003,
-       2.35331594e-003, 5.44968434e-003, 6.62699202e-003,
-       -2.19829436e-002, 5.81128336e-002, 4.07170653e-002,
-       8.93514305e-002, -1.48128020e-002, 6.58066049e-002,
-       3.39474827e-002, 8.65821689e-002, 6.15101831e-004,
-       4.03344864e-003, 5.73894521e-003, 9.02773254e-003,
-       -2.96423794e-003, -3.74801806e-004, 4.80135204e-003,
-       1.82749215e-003, -4.93010040e-003, -2.56425375e-003,
-       1.57650728e-002, 1.19777583e-002, 1.71591230e-002,
-       -4.22705570e-003, 3.33453268e-002, 1.33876558e-002,
-       2.89804265e-002, 2.10388494e-003, 3.22497152e-002,
-       4.90438845e-003, -2.41479725e-002, 4.09375690e-003,
-       3.71269658e-002, 1.74719170e-002, -3.80633622e-002,
-       -3.75433057e-003, 1.10820778e-001, 7.66928196e-002,
-       1.02951594e-001, 3.93996341e-003, 2.28210643e-001,
-       9.14131105e-002, 2.48852029e-001, 1.31586948e-002,
-       2.82466859e-001, 3.53262872e-002, -3.22775431e-002,
-       1.93732996e-002, 5.21613099e-002, 3.58043313e-002,
-       -3.16391066e-002, 9.63910893e-002, 1.50816396e-001,
-       1.79051965e-001, 1.16279073e-001, 1.15481794e-001,
-       2.92898864e-001, 2.06440315e-001, 2.44840413e-001,
-       -2.96096341e-003, 2.96607435e-001, 4.02708054e-002,
-       -6.77103002e-004, 1.72345731e-002, 6.85100816e-003,
-       2.66855117e-002, 5.75993769e-003, 1.97700217e-001,
-       3.76241915e-002, 2.91799873e-001, 1.79196743e-003,
-       1.87076792e-001, 5.58962524e-002, 3.06606263e-001,
-       1.62473936e-002, 7.11637177e-003, 2.28770077e-002,
-       2.43901536e-002, -8.02659197e-004, -5.82251523e-004,
-       4.71593346e-003, 4.23265621e-003, -1.27662416e-003,
-       -2.90690809e-002, 3.28107476e-002, 4.97474559e-002,
-       4.25184378e-003, -3.46114747e-002, 3.06960400e-002,
-       6.13563731e-002, -6.31362665e-004, -1.80305878e-003,
-       6.52923388e-003, 7.76922423e-003, -3.30388546e-002,
-       -9.07722511e-004, 5.20674512e-002, 2.67417151e-002,
-       -1.34928882e-001, -9.94756296e-002, 2.97784716e-001,
-       3.29619378e-001, 3.67239304e-002, 7.91565608e-003,
-       1.53477862e-001, 4.88602251e-001, 3.15186046e-002,
-       -1.00291241e-003, 4.55329418e-002, 6.38340041e-002,
-       -3.92641872e-002, 1.87628320e-003, 5.67576960e-002,
-       2.14469731e-002, 2.97757555e-002, 1.00835271e-001,
-       4.11128700e-001, 2.00953439e-001, 4.24192995e-002,
-       1.14984065e-001, 2.00282350e-001, 2.27953270e-001,
-       1.83834005e-002, 1.43973473e-002, 4.16165181e-002,
-       4.08860557e-002, -3.48834554e-003, 5.47931821e-004,
-       6.19303761e-003, 3.40461917e-003, 4.94752661e-004,
-       2.49030571e-002, 3.95718291e-002, 3.70527990e-002,
-       4.85173427e-003, 1.49124805e-002, 3.27660777e-002,
-       3.61025147e-002, -1.41835786e-004, 5.95143763e-004,
-       5.18111419e-003, 5.13957907e-003, -1.47947168e-004,
-       -3.85181955e-003, 5.86132985e-003, 7.96777382e-003,
-       -9.92553215e-003, -7.77272806e-002, 2.98860390e-002,
-       9.19389576e-002, -3.11118062e-003, -7.38328174e-002,
-       3.21875252e-002, 9.33854729e-002, -1.64491474e-003,
-       -5.38385846e-003, 5.24049951e-003, 9.12229065e-003,
-       -6.86973557e-002, 2.33002403e-003, 7.92483687e-002,
-       4.43610176e-002, -1.36922421e-002, -1.01912562e-002,
-       2.54621118e-001, 2.51841813e-001, -8.57497826e-002,
-       -6.79493025e-002, 2.01974154e-001, 2.26923138e-001,
-       2.11396571e-002, -1.46172727e-002, 3.21907252e-002,
-       3.60895842e-002, -6.38606250e-002, 1.77231953e-002,
-       7.86225945e-002, 4.62427512e-002, 3.58692221e-002,
-       2.45607704e-001, 2.64881641e-001, 3.32261086e-001,
-       -2.54311949e-001, 2.01649830e-001, 3.49975526e-001,
-       2.80974120e-001, 2.26280093e-002, 1.72002912e-002,
-       3.95475626e-002, 3.79420854e-002, 5.11280145e-004,
-       4.33513150e-003, 7.28435861e-003, 8.12688842e-003,
-       -1.95956766e-003, 5.77406399e-002, 3.82833444e-002,
-       6.93659633e-002, -3.26914750e-002, 4.67399172e-002,
-       5.38718924e-002, 6.58656210e-002, -2.08039326e-003,
-       2.40251073e-003, 5.42022614e-003, 6.65185694e-003,
-       9.14087333e-003, 1.53226743e-003, 1.35176545e-002,
-       8.19332711e-003, -3.89672145e-002, 8.33824873e-002,
-       6.28880784e-002, 1.04758836e-001, -3.46402600e-002,
-       7.63722658e-002, 7.95815587e-002, 1.35905847e-001,
-       2.60733720e-003, -2.38925428e-003, 1.00908801e-002,
-       1.30867567e-002, 1.18854754e-001, -3.28307413e-002,
-       1.65073037e-001, 5.83434068e-002, 5.26432879e-002,
-       3.19198035e-002, 1.67323560e-001, 1.41029194e-001,
-       -2.36076847e-001, 2.46608078e-001, 3.05232137e-001,
-       3.07126492e-001, -5.03024608e-002, 4.83891964e-002,
-       1.07771143e-001, 8.32045600e-002, 7.39616752e-002,
-       -2.55668703e-002, 1.83337554e-001, 5.50030284e-002,
-       2.51794875e-001, -1.66076094e-001, 3.44955087e-001,
-       2.23814979e-001, -1.19727915e-002, -1.52720623e-002,
-       1.26117855e-001, 1.19070522e-001, -6.25133812e-002,
-       2.57450864e-002, 8.36250558e-002, 4.53135371e-002,
-       -2.77447933e-003, 2.24903645e-003, 2.05979813e-002,
-       7.38678407e-003, 6.18702359e-002, -3.71369049e-002,
-       8.45960304e-002, 5.76383248e-002, 8.42082687e-003,
-       -2.74863765e-002, 3.29888985e-002, 3.98232453e-002,
-       -3.62534099e-003, -1.09046046e-003, 7.44684786e-003,
-       4.99122543e-003, 3.30174167e-004, 1.75632432e-003,
-       3.07390443e-003, 4.76462999e-003, 2.04821141e-003,
-       2.33261529e-002, 1.96362827e-002, 4.30928767e-002,
-       2.37061860e-004, 1.99527945e-002, 1.83976144e-002,
-       4.26252149e-002, 7.65452685e-004, 1.70565175e-003,
-       2.89900019e-003, 5.43131866e-003, 2.97831204e-002,
-       1.59908868e-002, 3.77649479e-002, 4.14538309e-002,
-       1.07545100e-001, 2.42882803e-001, 1.77385554e-001,
-       4.01604801e-001, -4.49024998e-002, 2.84000963e-001,
-       1.20847501e-001, 4.26839173e-001, -1.48563078e-002,
-       3.44624147e-002, 2.56727282e-002, 5.26169725e-002,
-       2.80823614e-002, -1.97957829e-002, 3.76503095e-002,
-       3.35798599e-002, 1.44872144e-001, -2.25964293e-001,
-       2.08335876e-001, 2.81076372e-001, -2.78643239e-003,
-       -1.86168492e-001, 1.22566983e-001, 2.51025856e-001,
-       -1.40528465e-002, -1.60724763e-002, 2.47277413e-002,
-       3.25649641e-002, 6.29489834e-004, -4.17065225e-004,
-       3.54974368e-003, 3.73348990e-003, 1.09654665e-002,
-       -2.00430918e-002, 2.61087976e-002, 3.66511531e-002,
-       8.02257191e-003, -2.50714459e-002, 2.35067606e-002,
-       4.00906876e-002, 5.57786785e-004, -2.28350470e-003,
-       3.20954178e-003, 4.95643867e-003, 2.12119985e-003,
-       7.15561237e-006, 5.86288888e-003, 4.91014635e-003,
-       -1.10025778e-002, 7.36276060e-003, 3.48969996e-002,
-       4.37127575e-002, -2.90894751e-002, -4.68284823e-003,
-       4.29497547e-002, 4.54899259e-002, -1.33357279e-003,
-       -1.93550705e-003, 4.83035669e-003, 4.53680428e-003,
-       8.98269657e-003, -1.75060797e-002, 5.53474650e-002,
-       4.27659787e-002, -5.40366657e-002, -1.95379883e-001,
-       2.51240820e-001, 3.47566217e-001, -2.05801085e-001,
-       -6.83485940e-002, 2.96994954e-001, 2.35444888e-001,
-       -6.32117409e-003, -1.77536334e-003, 3.75755504e-002,
-       2.71590613e-002, -4.56818612e-004, 6.32111914e-004,
-       5.40362820e-002, 4.94065322e-002, -6.55270414e-003,
-       4.89841849e-002, 2.18497545e-001, 4.26713616e-001,
-       -1.40088931e-001, 1.95105597e-002, 2.50015974e-001,
-       2.73149133e-001, -9.31747630e-003, 3.08796461e-003,
-       3.57319154e-002, 2.91202217e-002, 3.42218671e-004,
-       -2.53720034e-004, 5.11252647e-003, 6.70111738e-003,
-       -8.38120840e-003, -2.24237028e-003, 3.31882425e-002,
-       6.10440895e-002, -1.69946607e-002, -2.03478872e-003,
-       3.30808721e-002, 5.23775741e-002, -8.51096585e-004,
-       -7.73909851e-005, 4.30699857e-003, 4.47563827e-003,
-       4.55483235e-003, -3.89329018e-003, 8.05460569e-003,
-       6.76912488e-003, -5.41445101e-003, -3.86715159e-002,
-       5.70466258e-002, 6.51440397e-002, -3.62111256e-002,
-       -3.30192931e-002, 7.50630274e-002, 5.98762669e-002,
-       2.89329421e-003, -8.87587608e-004, 1.00208884e-002,
-       6.90011540e-003, -4.47321776e-003, -3.84330750e-002,
-       3.66221406e-002, 4.91597764e-002, 1.16785094e-002,
-       -3.65496427e-001, 1.80147856e-001, 4.02411550e-001,
-       -8.71297345e-003, -1.90325558e-001, 2.53278166e-001,
-       2.60298878e-001, 3.76425236e-002, -2.61387154e-002,
-       5.40537164e-002, 4.47049141e-002, -1.42049901e-002,
-       2.43558325e-002, 3.45904119e-002, 4.47728336e-002,
-       -7.91274570e-003, 1.26053885e-001, 1.29286438e-001,
-       2.89625943e-001, 1.97478030e-002, 4.38251086e-002,
-       1.32739946e-001, 2.63029456e-001, 3.25412974e-002,
-       -5.70038892e-003, 4.18094918e-002, 4.53527942e-002,
-       2.99141742e-003, 1.39229856e-002, 6.89103967e-003,
-       1.85722243e-002, 2.25810520e-003, 1.55748442e-001,
-       3.81871909e-002, 1.78829029e-001, -3.09727415e-002,
-       1.51333123e-001, 4.49357480e-002, 1.72039419e-001,
-       -1.19250349e-003, 1.20285572e-002, 6.55570440e-003,
-       1.55077688e-002, 5.43350237e-004, 4.57366789e-003,
-       3.89117375e-003, 8.22381023e-003, -5.42272162e-003,
-       5.16736619e-002, 2.56724022e-002, 7.00947046e-002,
-       -8.97827093e-003, 4.10633981e-002, 2.71934643e-002,
-       6.40471280e-002, -3.83849372e-004, 2.12616147e-003,
-       4.03889967e-003, 6.88570738e-003, 1.84078868e-002,
-       -8.92488472e-003, 3.20464894e-002, 5.02474084e-002,
-       2.94699986e-002, -9.73020270e-002, 1.48453653e-001,
-       4.32251394e-001, -5.63038029e-002, 4.41433154e-002,
-       1.85732841e-001, 3.92939150e-001, -3.00827678e-002,
-       6.76399283e-003, 4.44026329e-002, 5.01308143e-002,
-       1.46046178e-002, -1.71333663e-002, 3.08295209e-002,
-       4.01750654e-002, 3.11496425e-002, -1.13229819e-001,
-       1.61999971e-001, 2.95637935e-001, -8.05965587e-002,
-       -2.66377360e-001, 2.27708817e-001, 3.72137249e-001,
-       -2.35633068e-002, -3.73542793e-002, 4.15070541e-002,
-       5.09118587e-002, 1.20522709e-004, -1.84217782e-003,
-       3.57989501e-003, 5.80979697e-003, -5.60796075e-003,
-       -2.66489927e-002, 2.42793635e-002, 4.96328585e-002,
-       -1.29103446e-002, -1.62364803e-002, 2.87972111e-002,
-       4.37877141e-002, 4.62657888e-004, -1.39673633e-004,
-       3.73359025e-003, 5.03206812e-003, -1.97072374e-003,
-       1.38638978e-004, 4.81132884e-003, 5.75274089e-003,
-       2.60256784e-004, -2.27960628e-002, 3.12421974e-002,
-       4.08319756e-002, 5.59533983e-002, -1.41263269e-002,
-       6.59846291e-002, 3.96792293e-002, 9.54545918e-004,
-       3.73169174e-003, 6.62680436e-003, 6.33880170e-003,
-       -2.69088689e-002, 2.26040520e-002, 4.09678295e-002,
-       3.81396227e-002, -4.27943654e-002, 1.98146537e-001,
-       1.85570210e-001, 3.01988959e-001, 3.22893232e-001,
-       -1.56873763e-002, 3.91788781e-001, 2.39118457e-001,
-       3.34662721e-002, -1.49043109e-002, 6.37920424e-002,
-       3.83266583e-002, -1.89706981e-002, 1.14094904e-002,
-       3.74381989e-002, 3.24338600e-002, -1.49641186e-001,
-       2.03410294e-002, 2.10529059e-001, 2.08128244e-001,
-       1.35924503e-001, -3.02735418e-002, 3.29068601e-001,
-       2.90853620e-001, 6.38792664e-002, 2.13075848e-003,
-       8.37696120e-002, 3.73819321e-002, -1.02580199e-003,
-       4.60926531e-004, 5.97379403e-003, 4.88086278e-003,
-       -1.45497657e-002, 2.74407770e-002, 3.64612006e-002,
-       4.65492979e-002, 2.35654600e-002, 4.12867852e-002,
-       4.53993455e-002, 5.32473847e-002, 4.73097060e-003,
-       2.53317830e-006, 8.06004554e-003, 3.96798365e-003,
-       1.35607785e-003, -6.12339703e-003, 5.66907600e-003,
-       9.63900797e-003, 2.00614370e-002, -7.53771886e-002,
-       4.82102372e-002, 9.08600092e-002, 3.28707099e-002,
-       -3.86093371e-002, 5.19364141e-002, 6.97669536e-002,
-       -2.26015248e-003, -3.37343314e-004, 5.69884153e-003,
-       6.52516540e-003, -1.30105913e-002, -2.63928026e-002,
-       3.07559129e-002, 4.02638614e-002, -3.13743316e-002,
-       -2.00148463e-001, 1.64439827e-001, 2.67777234e-001,
-       2.12639943e-001, -4.37118471e-001, 2.52407759e-001,
-       4.79260266e-001, 1.87500622e-002, -8.10827389e-002,
-       4.11963165e-002, 8.87224823e-002, -1.81997102e-002,
-       1.28496001e-002, 3.00125368e-002, 3.83042023e-002,
-       -4.04954292e-002, 8.08756351e-002, 1.09016374e-001,
-       2.02919886e-001, 2.81703807e-002, 6.93894252e-002,
-       9.62149203e-002, 1.86371297e-001, 1.50213754e-002,
-       -1.58442592e-003, 2.47605741e-002, 3.68225910e-002,
-       5.00717375e-004, 6.52053952e-003, 4.71751858e-003,
-       9.98587906e-003, 1.97680015e-003, 8.39863643e-002,
-       2.96587776e-002, 1.00039355e-001, -3.52372439e-003,
-       9.50648934e-002, 3.37301195e-002, 1.11481041e-001,
-       -2.17978680e-003, 8.79410375e-003, 5.08794421e-003,
-       1.17453802e-002, 1.61545060e-003, 4.78364236e-005,
-       5.00028953e-003, 3.11536645e-003, 7.71656586e-003,
-       1.35009354e-002, 3.53333876e-002, 2.76290923e-002,
-       -8.21095658e-004, 2.12103017e-002, 5.23241013e-002,
-       3.58537212e-002, -2.40820134e-003, -4.64563229e-004,
-       6.11215550e-003, 3.98330577e-003, 2.56521124e-002,
-       4.69451630e-003, 4.17481847e-002, 2.15203669e-002,
-       7.73107186e-002, 6.55902624e-002, 2.57272989e-001,
-       1.64885879e-001, -9.30566993e-003, 6.11668751e-002,
-       5.25375068e-001, 2.14177057e-001, -2.92603094e-002,
-       -1.93271041e-003, 4.97442782e-002, 2.75376067e-002,
-       2.79242881e-002, -4.60363040e-003, 4.20134440e-002,
-       2.38966793e-002, 5.75222671e-002, -7.37482682e-002,
-       2.34605283e-001, 2.10531771e-001, -9.87575278e-002,
-       -2.08648592e-001, 3.86702895e-001, 2.87373304e-001,
-       -1.99444834e-002, -7.67423352e-003, 3.98892090e-002,
-       2.76112407e-002, 1.06045546e-003, -1.04756642e-003,
-       4.51228209e-003, 3.70519795e-003, -5.60555025e-004,
-       -2.56067924e-002, 2.85933260e-002, 3.73951718e-002,
-       -1.26620540e-002, -1.99783444e-002, 3.21357325e-002,
-       3.52144577e-002, 9.11065072e-005, -2.02013878e-004,
-       3.76578560e-003, 3.55157023e-003, -3.33454320e-003,
-       4.10201639e-004, 9.78872180e-003, 7.78554007e-003,
-       -2.77551040e-002, -3.20915617e-002, 5.11835888e-002,
-       5.77469990e-002, -6.63046166e-003, -3.22476663e-002,
-       3.38956639e-002, 4.69299741e-002, 2.03429791e-003,
-       -1.55915169e-003, 5.58066973e-003, 5.38526569e-003,
-       -8.62716883e-002, 7.99179450e-003, 1.07687630e-001,
-       5.86653240e-002, -1.54251218e-001, -1.15553945e-001,
-       2.49367073e-001, 2.86276340e-001, 4.88600768e-002,
-       2.34745890e-002, 1.61236614e-001, 2.07980648e-001,
-       3.17801498e-002, 1.38038406e-002, 4.50507887e-002,
-       3.89117710e-002, -1.04344681e-001, 2.22968459e-002,
-       1.25854462e-001, 5.60314842e-002, -1.79265767e-001,
-       2.49685779e-001, 2.73829252e-001, 3.79831940e-001,
-       1.80363029e-001, 1.71742395e-001, 2.49753565e-001,
-       2.75118142e-001, 2.73196995e-002, 3.34055908e-002,
-       5.10744676e-002, 5.05552106e-002, -3.26072797e-003,
-       -6.70396141e-004, 9.77349840e-003, 6.88678585e-003,
-       -3.20020169e-002, 2.85952594e-002, 5.41312993e-002,
-       5.96797690e-002, 1.16633885e-002, 3.18943746e-002,
-       4.48976234e-002, 5.66300303e-002, 8.47240386e-004,
-       1.21494224e-004, 6.58221822e-003, 6.58132182e-003,
-       -1.65892616e-002, 4.03536391e-003, 1.94510035e-002,
-       8.57209601e-003, -2.38093901e-002, -1.04000624e-002,
-       4.46915887e-002, 2.58333664e-002, 8.21203552e-003,
-       -7.32394541e-003, 2.60365643e-002, 2.20809970e-002,
-       5.33624133e-003, 1.90914888e-003, 7.61658605e-003,
-       3.80945834e-003, -1.69497058e-001, -1.56501140e-002,
-       1.86612859e-001, 5.21386154e-002, -1.24710269e-001,
-       -1.53161706e-002, 2.82756746e-001, 1.36313528e-001,
-       1.36523306e-001, 4.93918844e-002, 1.89053401e-001,
-       1.41525015e-001, 9.68733504e-002, 5.20693623e-002,
-       1.17283888e-001, 5.86220846e-002, -1.48752511e-001,
-       3.35638002e-002, 1.88525572e-001, 7.23898932e-002,
-       -1.24431290e-001, 2.50432253e-001, 3.40552241e-001,
-       3.32232863e-001, 1.62018731e-001, 3.81762162e-002,
-       2.54065603e-001, 1.41431436e-001, 1.39672101e-001,
-       1.22789694e-002, 1.70240015e-001, 4.75406013e-002,
-       -2.72067403e-003, 3.92899988e-003, 1.70398038e-002,
-       8.49058293e-003, -9.96070877e-002, 6.42258599e-002,
-       1.29133686e-001, 9.05876309e-002, 1.63411833e-002,
-       2.17016861e-002, 6.03858754e-002, 3.99267077e-002,
-       1.29428450e-002, -7.52837950e-005, 1.95167344e-002,
-       7.75230443e-003, 2.55775172e-003, 2.51491694e-003,
-       6.82042073e-003, 1.00866416e-002, 5.45678008e-003,
-       5.15178703e-002, 2.45315060e-002, 7.86454380e-002,
-       6.11653784e-003, 4.64550257e-002, 1.63711477e-002,
-       7.34289661e-002, -7.81794137e-004, 4.69851028e-003,
-       2.82226969e-003, 8.99036229e-003, 7.01598153e-002,
-       -3.42703611e-002, 8.92712623e-002, 5.36060743e-002,
-       7.94733241e-002, 1.33386962e-002, 1.27370372e-001,
-       1.12854734e-001, -7.74584478e-003, 1.82406437e-002,
-       4.71638776e-002, 6.36180267e-002, -4.58368612e-003,
-       3.84159130e-003, 1.24643343e-002, 1.07321478e-002,
-       3.22266445e-002, -5.70458248e-002, 8.29402730e-002,
-       7.96613097e-002, 3.99361193e-001, -4.10801232e-001,
-       4.36187387e-001, 4.39678103e-001, 1.51392976e-002,
-       -7.46120065e-002, 7.83542246e-002, 1.19253419e-001,
-       -3.67898704e-003, -4.42544371e-003, 1.14085171e-002,
-       1.17721707e-002, -1.81350647e-003, -1.51101639e-003,
-       5.82912005e-003, 5.79280965e-003, 4.17498499e-002,
-       -8.06101486e-002, 5.93314245e-002, 1.05016321e-001,
-       5.16103581e-002, -1.30070120e-001, 6.38544187e-002,
-       1.50803730e-001, 2.13455711e-003, -8.15332029e-003,
-       3.92981013e-003, 1.20285191e-002, -8.67477991e-003,
-       -9.00379382e-004, 1.37896156e-002, 6.61088200e-003,
-       6.23583188e-003, -4.27704342e-002, 5.17358631e-002,
-       6.51276261e-002, 1.20016485e-002, -2.88157966e-002,
-       4.40721624e-002, 6.37135580e-002, 1.52084453e-004,
-       -7.29720283e-004, 6.92598196e-003, 8.24486464e-003,
-       -1.25313029e-001, -2.44369195e-003, 1.55721679e-001,
-       3.61184478e-002, -5.11795841e-002, -1.37664989e-001,
-       2.63244539e-001, 2.51671702e-001, 1.10412516e-001,
-       -1.91670403e-001, 2.10115716e-001, 3.57090503e-001,
-       3.57334279e-002, -1.62907317e-002, 5.73476963e-002,
-       5.55963442e-002, -1.41709924e-001, -9.25085228e-003,
-       1.71430677e-001, 3.51634920e-002, -1.10952975e-002,
-       3.23220678e-002, 2.70042866e-001, 1.79707661e-001,
-       1.86251834e-001, 1.36584729e-001, 2.94079274e-001,
-       2.67049193e-001, 3.49304527e-002, 2.69636884e-002,
-       7.37457499e-002, 5.24348021e-002, -1.40627921e-002,
-       -1.18172809e-003, 1.86375659e-002, 5.68898162e-003,
-       5.56398323e-003, 2.15645116e-002, 5.00674434e-002,
-       3.81175652e-002, 2.88468078e-002, 1.52209383e-002,
-       5.17584123e-002, 4.40176949e-002, 1.77867757e-003,
-       -1.88513484e-003, 9.62228607e-003, 6.75863773e-003,
-       -7.30971806e-004, 1.96680874e-002, 5.81944222e-003,
-       3.41417827e-002, -9.98075848e-005, 1.72535285e-001,
-       2.38857120e-002, 2.96292633e-001, -5.39748883e-003,
-       1.60892621e-001, 2.35883128e-002, 2.96147078e-001,
-       -3.27035552e-004, 1.88485142e-002, 4.83066309e-003,
-       3.81570831e-002, 5.10751419e-002, 5.47478953e-003,
-       7.61002824e-002, 5.18250726e-002, 4.96721417e-002,
-       1.79872349e-001, 1.03732884e-001, 2.56640226e-001,
-       -4.62925844e-002, 2.17724189e-001, 1.02524079e-001,
-       2.82083184e-001, -3.29142660e-002, 3.48918587e-002,
-       4.34469096e-002, 4.76160422e-002, 6.89600855e-002,
-       -5.34864441e-002, 1.11038782e-001, 6.90601245e-002,
-       1.31470963e-001, -1.50439814e-001, 1.88463077e-001,
-       2.19413668e-001, -6.62948890e-003, -6.72333986e-002,
-       7.82764629e-002, 1.45098791e-001, -2.24420037e-002,
-       -3.30112613e-004, 3.05936188e-002, 2.63521466e-002,
-       8.83279543e-004, -7.34073669e-003, 1.04943877e-002,
-       1.85603388e-002, 3.34959291e-002, -1.71613216e-001,
-       5.02593294e-002, 2.36062959e-001, 2.21349727e-002,
-       -1.65700346e-001, 4.02434207e-002, 2.23978952e-001,
-       7.17928400e-004, -1.47089465e-002, 3.97443725e-003,
-       2.33997330e-002, -2.21629743e-003, -2.30151275e-003,
-       9.76651348e-003, 8.33857805e-003, -1.53388092e-002,
-       -7.38399029e-002, 5.15144244e-002, 9.69782472e-002,
-       1.07455207e-002, -7.34038725e-002, 4.59394418e-002,
-       9.54778194e-002, -2.31426908e-004, -2.78426916e-003,
-       5.95851848e-003, 9.15692281e-003, -1.18406191e-001,
-       -1.41399605e-002, 1.45151392e-001, 4.94290255e-002,
-       -1.28488094e-001, -2.94580221e-001, 2.52426773e-001,
-       3.47584546e-001, 2.40091383e-001, -2.20405936e-001,
-       2.91038990e-001, 2.73339897e-001, 3.05306632e-002,
-       -3.20104174e-002, 5.80754206e-002, 4.90452871e-002,
-       -1.48925588e-001, -1.38374313e-003, 1.80973336e-001,
-       4.08986099e-002, -8.82560238e-002, 6.36450797e-002,
-       2.14674279e-001, 1.48463383e-001, 1.44541755e-001,
-       -3.55506688e-002, 2.08877027e-001, 1.38395742e-001,
-       3.79211418e-002, -1.69529598e-002, 5.56270555e-002,
-       3.50310169e-002, -1.19623514e-002, -1.12859963e-003,
-       1.96548365e-002, 6.11991761e-003, -2.54540183e-002,
-       1.52359297e-002, 4.67033200e-002, 3.47368829e-002,
-       8.70873872e-003, 9.97837633e-003, 3.07421628e-002,
-       2.86673233e-002, 4.10103751e-003, -6.10973220e-004,
-       7.01292325e-003, 4.71144682e-003, -7.81707652e-003,
-       2.58172606e-003, 1.28300535e-002, 7.23296916e-003,
-       -1.82083882e-002, -1.11090317e-002, 3.42993923e-002,
-       2.34477110e-002, 4.02863231e-003, -1.17148748e-002,
-       2.04295143e-002, 2.07123477e-002, 9.66751203e-003,
-       2.72245216e-003, 1.46165276e-002, 5.22843981e-003,
-       -8.42837244e-002, -7.02780811e-003, 1.11834005e-001,
-       4.75348867e-002, -1.27868310e-001, -2.46014725e-002,
-       1.98246226e-001, 1.10542476e-001, 9.29168314e-002,
-       -1.03035232e-003, 1.56614155e-001, 1.14102431e-001,
-       1.53111964e-001, 4.34607714e-002, 1.86193451e-001,
-       6.30954802e-002, -8.94326642e-002, -6.44102087e-003,
-       1.13285281e-001, 4.18955684e-002, -5.67858629e-002,
-       9.71562415e-002, 1.77119270e-001, 1.49813160e-001,
-       2.53508925e-001, 3.49664152e-001, 3.19897622e-001,
-       3.82466018e-001, 1.54838905e-001, 5.14986552e-002,
-       1.95776135e-001, 7.90366158e-002, -5.85956965e-003,
-       5.54569473e-004, 9.49125551e-003, 6.28033420e-003,
-       3.64574566e-002, 5.88962249e-002, 5.59521765e-002,
-       6.81414828e-002, 8.62266049e-002, 9.51982364e-002,
-       1.10268161e-001, 1.20778941e-001, -4.24751826e-003,
-       -5.82489138e-003, 1.34689957e-002, 1.21337809e-002,
-       -8.34936509e-005, 4.23420314e-003, 4.01255535e-003,
-       6.27668109e-003, -3.68115380e-002, 5.74663579e-002,
-       5.01602069e-002, 7.26081580e-002, -3.25533785e-002,
-       5.67078143e-002, 5.86624071e-002, 8.23160410e-002,
-       2.99515622e-003, 3.84343439e-003, 6.89842366e-003,
-       9.48753487e-003, 1.04607362e-002, 5.39250858e-003,
-       2.02122666e-002, 2.15681624e-002, -2.80284956e-002,
-       9.71683487e-002, 1.07155591e-001, 1.57161325e-001,
-       -1.04721747e-001, 2.93412477e-001, 1.89170986e-001,
-       3.42645377e-001, -3.47822793e-002, 3.24315391e-002,
-       4.92360927e-002, 6.26657158e-002, 1.05063189e-002,
-       -6.92323502e-003, 1.98652092e-002, 2.07365062e-002,
-       -1.45460935e-002, -7.87787959e-002, 1.04093961e-001,
-       1.43590584e-001, -2.37645850e-001, -3.82837325e-001,
-       2.78824627e-001, 4.28192735e-001, -3.71116214e-002,
-       -7.17717707e-002, 5.54870069e-002, 8.83301795e-002,
-       -2.82948109e-004, -4.11467999e-003, 4.16791253e-003,
-       6.84443675e-003, -3.92960645e-002, -6.22455105e-002,
-       5.36780581e-002, 7.28962943e-002, -4.95195650e-002,
-       -4.39485237e-002, 6.71724081e-002, 7.60098025e-002,
-       1.83184235e-003, 1.00338459e-003, 5.31941000e-003,
-       7.02515524e-003, -9.65593383e-004, -2.95139253e-005,
-       5.91636356e-003, 3.48725007e-003, -4.78290319e-002,
-       -4.47953828e-002, 6.49282038e-002, 5.41700572e-002,
-       3.54897901e-002, -3.84164825e-002, 5.70075437e-002,
-       5.17693609e-002, 1.33770774e-003, 7.86266290e-004,
-       6.74651237e-003, 4.80730506e-003, -3.50259505e-002,
-       -1.45394905e-002, 6.06278814e-002, 2.93314327e-002,
-       -3.53443295e-001, -1.58047512e-001, 4.15484786e-001,
-       2.15315923e-001, 2.59250849e-001, -1.59209922e-001,
-       3.16507995e-001, 2.15177760e-001, 3.95505093e-002,
-       -4.13186401e-002, 6.44060150e-002, 5.26583679e-002,
-       -5.56888059e-002, -2.22918186e-002, 7.51728714e-002,
-       3.56990658e-002, -2.26749241e-001, -5.31787351e-002,
-       3.01416129e-001, 1.38055757e-001, 6.55907169e-002,
-       -6.89667463e-002, 1.45244136e-001, 1.39461905e-001,
-       4.53977920e-002, -3.30237634e-002, 5.80175407e-002,
-       4.30821180e-002, -7.03862496e-003, -2.23918445e-003,
-       9.80588980e-003, 4.71280748e-003, -2.27945819e-002,
-       5.09563228e-003, 3.61236110e-002, 2.09535118e-002,
-       2.86792312e-003, 5.50441863e-003, 1.97760109e-002,
-       1.94085166e-002, 3.28989164e-003, -7.22377212e-004,
-       5.28881280e-003, 3.77289765e-003, -1.58255566e-002,
-       3.56937479e-003, 1.84999555e-002, 5.33697102e-003,
-       -4.65641823e-003, -1.13093220e-002, 2.98564192e-002,
-       2.74102017e-002, -1.64790812e-003, -1.77564174e-002,
-       2.00928822e-002, 3.51977944e-002, -6.24772656e-005,
-       -3.06288101e-004, 3.11386376e-003, 2.92482739e-003,
-       -1.57734931e-001, 3.51910777e-002, 1.77037299e-001,
-       4.59024943e-002, -1.38368398e-001, 1.50970593e-002,
-       2.08250076e-001, 1.13266699e-001, 1.48639074e-002,
-       -2.03976948e-002, 8.03243220e-002, 9.20794755e-002,
-       9.19605326e-003, -3.80107813e-004, 1.76734384e-002,
-       1.64489690e-002, -1.09087318e-001, 3.26658003e-002,
-       1.37021884e-001, 5.02364151e-002, -3.65577430e-001,
-       3.07806462e-001, 4.21183378e-001, 3.55395377e-001,
-       3.91955813e-003, 1.43490270e-001, 1.04641259e-001,
-       2.14415491e-001, 1.15129557e-002, 1.82705633e-002,
-       2.23889053e-002, 3.12754288e-002, -1.15024496e-003,
-       -1.18980417e-003, 9.17264167e-003, 7.01621175e-003,
-       -3.81472521e-002, 9.69716012e-002, 6.41557202e-002,
-       1.25111774e-001, -1.66879278e-002, 1.30744189e-001,
-       4.20526564e-002, 1.55315533e-001, -1.85977947e-003,
-       1.33659616e-002, 5.20033669e-003, 1.73628666e-002,
-       -2.28310542e-004, 2.13460153e-004, 3.57350148e-003,
-       3.78237804e-003, 2.48431675e-002, 2.24747397e-002,
-       3.65355425e-002, 3.55460234e-002, -3.80017608e-003,
-       2.92415470e-002, 3.84101607e-002, 3.69393937e-002,
-       -2.32585007e-003, 1.14794137e-004, 4.70346585e-003,
-       3.41753243e-003, 2.60092430e-002, 2.89402306e-002,
-       3.66553925e-002, 3.94680575e-002, 1.92758799e-001,
-       2.68922657e-001, 2.40484044e-001, 2.99331337e-001,
-       -2.36317039e-001, 7.81045780e-002, 3.07749718e-001,
-       1.69822037e-001, -2.75430009e-002, -1.66598812e-003,
-       3.98922972e-002, 2.31601708e-002, 2.79587545e-002,
-       -2.14798786e-002, 3.72069664e-002, 3.70181799e-002,
-       1.28586143e-001, -2.70108014e-001, 1.99709028e-001,
-       3.00852865e-001, -2.22715721e-001, -1.31727085e-001,
-       3.00425589e-001, 2.01196730e-001, -2.64981408e-002,
-       -1.31097739e-003, 3.87561396e-002, 2.40289643e-002,
-       5.95855545e-006, -1.06531905e-003, 3.56732286e-003,
-       4.06508800e-003, 1.43362302e-002, -2.32495815e-002,
-       2.99086366e-002, 3.62043381e-002, -4.35675634e-003,
-       -2.67176144e-002, 3.51736993e-002, 3.64090241e-002,
-       -1.71036168e-003, -2.67110765e-004, 4.30406863e-003,
-       3.42701236e-003, -1.14987424e-005, -2.12864857e-003,
-       5.41772274e-003, 6.00436376e-003, 3.09422985e-003,
-       -4.40808795e-002, 3.51433307e-002, 6.19166382e-002,
-       2.02555694e-002, -3.74743231e-002, 3.53691839e-002,
-       5.53699769e-002, 3.63059138e-004, -4.39924916e-004,
-       4.07773815e-003, 4.48367884e-003, -1.57914646e-002,
-       -8.42627510e-003, 4.12846431e-002, 4.14634906e-002,
-       -9.34060961e-002, 1.88800246e-002, 2.10078523e-001,
-       3.35175276e-001, 2.54463196e-001, -4.74326313e-002,
-       3.27940822e-001, 3.65533620e-001, 1.85500681e-002,
-       -1.12754172e-002, 3.89013514e-002, 4.14239541e-002,
-       -1.60572845e-002, -1.11280354e-002, 3.98239978e-002,
-       3.83491032e-002, -8.29314440e-002, -1.35914475e-001,
-       1.75489947e-001, 2.74523586e-001, 1.84098557e-001,
-       -1.44276738e-001, 2.64535964e-001, 2.89355814e-001,
-       2.84252428e-002, -1.37501722e-002, 4.74175550e-002,
-       4.25344035e-002, -1.27451855e-003, -4.28255997e-004,
-       4.83500073e-003, 4.52282559e-003, -1.00242654e-002,
-       1.39201134e-002, 2.95566823e-002, 3.17612104e-002,
-       2.06563063e-002, 1.22941313e-002, 3.51597145e-002,
-       3.42351608e-002, 2.85295956e-003, -1.40194932e-003,
-       6.32999698e-003, 5.45328436e-003, 6.21810229e-003,
-       -3.24859493e-003, 1.22227930e-002, 8.32603406e-003,
-       -3.57502773e-002, -1.15245365e-001, 7.84774870e-002,
-       1.36435598e-001, 2.93669309e-002, -1.13847367e-001,
-       6.51264414e-002, 1.34170651e-001, -3.13886628e-003,
-       -6.57658186e-003, 1.27593400e-002, 1.13828247e-002,
-       -3.74913588e-002, -2.81267054e-002, 1.06384240e-001,
-       4.35996130e-002, -2.09264502e-001, -2.29155675e-001,
-       3.16753626e-001, 3.06186259e-001, 1.13774367e-001,
-       -2.22287357e-001, 2.04746306e-001, 2.93637216e-001,
-       1.05529852e-001, 4.68778936e-003, 1.53705195e-001,
-       5.85209429e-002, -7.82986507e-002, 1.14345783e-002,
-       1.22977085e-001, 4.63806316e-002, -1.45113796e-001,
-       2.52825320e-002, 2.06496134e-001, 1.39409050e-001,
-       9.86898839e-002, 7.80096650e-003, 1.79870009e-001,
-       9.65633690e-002, 1.73165902e-001, 9.87163559e-003,
-       2.10688308e-001, 3.22640836e-002, -5.65829268e-003,
-       -1.60328019e-003, 1.48856463e-002, 7.00380001e-003,
-       -3.77885513e-002, 2.01688241e-002, 5.52481748e-002,
-       3.97455767e-002, 1.26071563e-002, 7.38629978e-003,
-       3.33055854e-002, 2.16322392e-002, 1.75981354e-002,
-       -3.69633688e-003, 2.41020154e-002, 6.85144588e-003,
-       9.06318601e-004, 7.81024992e-003, 1.47611378e-002,
-       1.44329611e-002, -5.98598383e-002, -5.01252711e-002,
-       8.68707523e-002, 7.17533901e-002, 6.45369291e-003,
-       -2.00197343e-002, 3.46050449e-002, 4.21628207e-002,
-       6.93635596e-003, -1.33459107e-003, 1.15727549e-002,
-       9.60416347e-003, -8.38796645e-002, -7.05609918e-002,
-       1.13557786e-001, 1.04425713e-001, -1.71845496e-001,
-       -1.61344230e-001, 2.71050185e-001, 2.11795300e-001,
-       1.07270107e-001, -7.25258440e-002, 1.92323953e-001,
-       1.65091529e-001, 1.00651637e-001, 4.34536785e-002,
-       1.26211017e-001, 8.23069289e-002, -4.51985523e-002,
-       -2.43255794e-002, 6.39352798e-002, 4.02798951e-002,
-       -5.20008989e-002, -1.28944144e-002, 1.34407744e-001,
-       1.14397332e-001, 3.85636866e-001, 1.49000481e-001,
-       4.38872963e-001, 2.01866820e-001, 9.58601832e-002,
-       5.35207503e-002, 1.67259216e-001, 9.29074660e-002,
-       -2.78536556e-003, 5.51769277e-004, 6.80372352e-003,
-       4.61367751e-003, -2.72678537e-003, 1.27270781e-002,
-       2.50405837e-002, 2.37836391e-002, 8.86232853e-002,
-       2.23160721e-002, 9.50567275e-002, 4.36796509e-002,
-       -6.45555207e-004, -5.74268959e-003, 1.71296746e-002,
-       1.03530586e-002, 2.20547454e-003, -5.32490574e-003,
-       5.94822876e-003, 9.75549407e-003, 1.90389976e-002,
-       -1.05187714e-001, 5.24189919e-002, 1.71760425e-001,
-       -2.25121737e-003, -8.49239826e-002, 5.59320487e-002,
-       1.46590009e-001, 3.67752649e-003, -1.25810178e-002,
-       9.86880809e-003, 3.55103314e-002, -1.01647943e-001,
-       1.20674275e-001, 1.32978812e-001, 1.39334306e-001,
-       -1.46340400e-001, -2.94070728e-002, 2.44774386e-001,
-       2.52030045e-001, 7.88169876e-002, -9.27875042e-002,
-       1.39433175e-001, 2.27798298e-001, 5.49784414e-002,
-       4.39540148e-002, 7.03410059e-002, 9.18798149e-002,
-       -1.73881665e-001, -5.06140441e-002, 2.09472924e-001,
-       8.60636234e-002, -2.44910970e-001, 4.08623144e-002,
-       3.10250252e-001, 1.52825475e-001, 2.03699380e-001,
-       1.48925573e-001, 2.53663808e-001, 1.95629895e-001,
-       1.21416435e-001, 4.21434119e-002, 1.49103120e-001,
-       7.30224550e-002, -9.54130944e-003, -4.45372472e-003,
-       1.62897781e-002, 8.87369551e-003, -2.53450293e-002,
-       1.45159671e-002, 3.72615084e-002, 3.10172569e-002,
-       8.13030824e-002, 1.88597627e-002, 8.79620016e-002,
-       5.37458919e-002, 5.50467428e-003, -2.83223833e-003,
-       1.57510266e-002, 2.08275095e-002, 1.83676530e-004,
-       9.03229986e-004, 4.10112692e-003, 4.51469561e-003,
-       2.87920479e-002, 2.13119388e-002, 3.95604074e-002,
-       3.85019332e-002, 2.15402897e-002, 2.81980261e-002,
-       3.57639603e-002, 3.80568840e-002, -5.83644258e-004,
-       1.76083855e-003, 3.67404008e-003, 4.03144583e-003,
-       3.01363114e-002, 1.32720880e-002, 4.21545096e-002,
-       3.74899656e-002, 1.97863325e-001, 2.42865384e-001,
-       2.40347743e-001, 2.87764132e-001, -9.91866086e-003,
-       9.11137313e-002, 1.27681360e-001, 1.54341951e-001,
-       -2.31506433e-002, -8.44845083e-003, 3.14572155e-002,
-       2.86164619e-002, 2.92256624e-002, -2.32633613e-002,
-       4.33342010e-002, 3.70949171e-002, 2.38661826e-001,
-       -1.51055112e-001, 3.18262219e-001, 2.07999140e-001,
-       -2.39437595e-001, -3.03338647e-001, 2.72440940e-001,
-       3.38459522e-001, -1.73134506e-002, -4.95616719e-002,
-       3.79595384e-002, 5.77284768e-002, 1.87190296e-003,
-       -1.51089043e-004, 4.82055312e-003, 3.95567389e-003,
-       1.08667575e-002, -4.15320583e-002, 4.75283638e-002,
-       5.16317487e-002, -3.60470451e-002, -2.95012612e-002,
-       4.99121509e-002, 4.80109006e-002, 1.75862154e-003,
-       -8.97697682e-005, 4.61722352e-003, 4.27371589e-003,
-       -5.28975157e-004, 1.50564173e-002, 4.53517772e-003,
-       2.03918628e-002, -5.29018743e-003, 1.36526883e-001,
-       2.53539234e-002, 1.69783190e-001, -6.33132702e-004,
-       1.34878084e-001, 3.09306104e-002, 1.68604583e-001,
-       -1.76901126e-003, 1.09000430e-002, 6.75821025e-003,
-       1.61595270e-002, 1.50614846e-002, 2.34295949e-002,
-       2.82192994e-002, 3.63745466e-002, 9.40661877e-003,
-       1.48815423e-001, 9.21299607e-002, 2.18654618e-001,
-       -1.12741567e-001, 1.24332637e-001, 1.82420403e-001,
-       2.39759162e-001, -9.31991190e-002, -1.23043936e-002,
-       1.10761069e-001, 5.68285659e-002, 1.15235923e-002,
-       -2.08995468e-003, 2.25355495e-002, 1.90246832e-002,
-       -2.26539355e-002, -5.98320253e-002, 1.03463151e-001,
-       1.31637946e-001, -3.41406047e-001, -2.93333858e-001,
-       3.87073785e-001, 3.43156159e-001, -5.63143864e-002,
-       -3.65525186e-002, 1.01616234e-001, 6.58347309e-002,
-       -4.61678719e-004, -3.54605401e-003, 3.81427677e-003,
-       6.27603382e-003, -2.36361828e-002, -4.47143503e-002,
-       3.86454538e-002, 6.13419712e-002, -6.16142601e-002,
-       -3.72558162e-002, 8.21236297e-002, 7.49506950e-002,
-       6.69433735e-004, 2.17396556e-003, 9.48141329e-003,
-       7.30402814e-003, -2.41998537e-003, 6.72886556e-004,
-       6.98183151e-003, 3.36222537e-003, -3.65058444e-002,
-       -1.70214344e-002, 5.22754416e-002, 3.02827992e-002,
-       2.38700975e-002, -2.10816227e-002, 4.34360355e-002,
-       3.57817747e-002, 4.00589639e-003, 7.96473760e-005,
-       8.11100472e-003, 5.40830195e-003, -3.52989882e-002,
-       -1.35501325e-002, 5.80313876e-002, 2.93182638e-002,
-       -2.29868516e-001, -6.36366680e-002, 3.04730892e-001,
-       1.57731220e-001, 2.59741753e-001, 1.09072655e-001,
-       3.08339775e-001, 2.27508888e-001, 3.96154784e-002,
-       1.71705838e-002, 5.85515276e-002, 4.30494547e-002,
-       -3.84891443e-002, -1.89088639e-002, 5.40634058e-002,
-       3.86518501e-002, -1.10235013e-001, 9.31981206e-003,
-       2.12148711e-001, 1.73672244e-001, 2.78932065e-001,
-       -4.04671058e-002, 3.28501701e-001, 3.61906588e-001,
-       2.02057753e-002, -1.95378345e-002, 4.63716649e-002,
-       7.08448142e-002, -3.15711810e-003, 1.60643796e-003,
-       6.91681402e-003, 5.64122386e-003, 3.23591242e-003,
-       3.84119079e-002, 3.78990732e-002, 5.46258725e-002,
-       3.01924758e-002, 5.31493761e-002, 5.03080226e-002,
-       7.39711002e-002, -1.13380363e-003, 2.36034673e-003,
-       5.69111807e-003, 8.39841645e-003, 4.84363036e-003,
-       -1.05758011e-003, 8.07187334e-003, 4.37400863e-003,
-       1.16271768e-002, 1.02450196e-002, 2.35503614e-002,
-       2.55878493e-002, -1.60521967e-003, 1.21377390e-002,
-       1.92345642e-002, 2.19516940e-002, -2.95806443e-003,
-       5.30926627e-004, 3.82313924e-003, 2.96925381e-003,
-       4.07354906e-002, -1.06836809e-002, 6.36227727e-002,
-       2.34888606e-002, 1.35646522e-001, -3.33557557e-003,
-       2.38392696e-001, 1.30309522e-001, -9.57113877e-003,
-       4.07871697e-003, 1.38606071e-001, 9.48471725e-002,
-       -3.99062224e-002, -8.78191926e-003, 4.51554731e-002,
-       1.84774231e-002, 3.35965380e-002, -6.20611757e-003,
-       5.93316369e-002, 2.58754194e-002, 2.03014374e-001,
-       1.83250979e-002, 5.31269133e-001, 3.55426252e-001,
-       -2.01026946e-001, -1.88330680e-001, 2.96766669e-001,
-       3.08104604e-001, -3.01885195e-002, -2.83924937e-002,
-       4.78415117e-002, 3.87350470e-002, 2.76434282e-003,
-       6.47513720e-004, 6.58219121e-003, 3.11721629e-003,
-       -1.69452303e-003, -4.37020212e-002, 6.01945892e-002,
-       5.91781288e-002, -1.83670670e-002, -2.74641030e-002,
-       4.34098616e-002, 4.95339856e-002, 3.13883007e-004,
-       3.62393999e-004, 5.11013623e-003, 3.99845745e-003,
-       -5.62978955e-003, -7.03558093e-004, 1.12049635e-002,
-       4.63882787e-003, 3.71981934e-002, -3.25125344e-002,
-       6.06115609e-002, 4.36437763e-002, 2.72057056e-002,
-       -2.51210649e-002, 4.16152291e-002, 3.93030196e-002,
-       2.87217001e-004, -4.77778347e-004, 4.28234739e-003,
-       3.43768275e-003, -7.56150633e-002, -3.50143877e-003,
-       9.87986773e-002, 2.78912783e-002, 1.92199171e-001,
-       -9.33976173e-002, 3.97039562e-001, 1.84402570e-001,
-       1.19616523e-001, -2.41970986e-001, 2.95733869e-001,
-       2.94926286e-001, 4.65764627e-002, -2.21215989e-002,
-       6.13531582e-002, 3.28923203e-002, -7.06946403e-002,
-       -4.87567764e-003, 9.30460319e-002, 2.75175739e-002,
-       1.55018866e-001, 4.83342968e-002, 3.67158651e-001,
-       1.48348704e-001, 2.55682901e-003, 3.42204841e-003,
-       2.91420013e-001, 1.60977200e-001, 6.44893795e-002,
-       -1.03151174e-002, 7.87693709e-002, 3.07294298e-002,
-       -4.28526476e-003, -9.87592619e-004, 8.92510917e-003,
-       4.59110131e-003, 1.57562904e-002, 1.48301516e-002,
-       5.02570048e-002, 3.44702527e-002, 1.17067504e-003,
-       1.43528534e-002, 4.08337340e-002, 3.65633443e-002,
-       5.17992722e-003, -1.41209702e-003, 8.25782586e-003,
-       5.09208255e-003, -8.32149386e-003, 1.02457602e-003,
-       1.19968979e-002, 4.50426154e-003, 4.61680721e-003,
-       -1.85163449e-002, 6.12457506e-002, 3.29499505e-002,
-       8.89861316e-004, -2.05016378e-002, 7.18710124e-002,
-       3.74812856e-002, 3.52339121e-003, 1.01223693e-003,
-       9.97480005e-003, 4.48434241e-003, -7.88560808e-002,
-       1.13098463e-002, 1.00852810e-001, 2.69217882e-002,
-       -7.57560059e-002, -7.30525032e-002, 3.71071130e-001,
-       1.68702528e-001, 4.84727286e-002, -1.09198563e-001,
-       4.29800719e-001, 1.81332558e-001, 5.22998832e-002,
-       -3.75273917e-003, 8.53522569e-002, 3.01133916e-002,
-       -6.13130815e-002, 2.92353216e-003, 8.77674818e-002,
-       2.27669701e-002, -2.49688044e-001, 5.27797863e-002,
-       3.81646007e-001, 1.41624779e-001, 1.51934460e-001,
-       5.51085584e-002, 2.97241509e-001, 1.54401213e-001,
-       4.96586375e-002, -2.93173105e-003, 7.83035681e-002,
-       3.09378263e-002, -5.17716119e-003, -1.22459466e-003,
-       9.95039754e-003, 3.46741639e-003, -3.35953869e-002,
-       1.88843906e-002, 5.89477681e-002, 3.13318372e-002,
-       1.80176143e-002, 1.57015659e-002, 4.54421043e-002,
-       3.19822170e-002, 3.99032375e-003, -9.83043341e-004,
-       8.96487013e-003, 4.91761975e-003, 2.15991773e-003,
-       4.22784186e-004, 8.08266085e-003, 5.13284467e-003,
-       2.24389918e-002, 4.91165631e-002, 4.38130051e-002,
-       6.12910502e-002, -1.05454810e-002, 4.34743352e-002,
-       3.77665162e-002, 5.34516573e-002, -1.89818558e-003,
-       1.47118361e-003, 5.15285181e-003, 5.05927671e-003,
-       8.23311731e-002, 1.44106606e-002, 1.03894129e-001,
-       3.50735299e-002, 1.17517665e-001, 2.31888443e-001,
-       3.31259072e-001, 2.74613529e-001, -2.43794814e-001,
-       8.06550235e-002, 2.96272099e-001, 1.71080649e-001,
-       -2.89492309e-002, 2.13343929e-003, 4.56141829e-002,
-       2.54166927e-002, 9.27531272e-002, 9.82943820e-005,
-       1.13380343e-001, 3.15459259e-002, 6.25228956e-002,
-       -1.07970215e-001, 3.46735954e-001, 1.81613386e-001,
-       -2.65372157e-001, -5.37307374e-002, 3.13411295e-001,
-       1.40018612e-001, -2.68470608e-002, -7.83822179e-005,
-       4.52930965e-002, 2.30832528e-002, 7.00818188e-003,
-       6.29157585e-004, 1.10854460e-002, 4.54794243e-003,
-       9.80879460e-003, -2.81101111e-002, 4.73144166e-002,
-       4.07397337e-002, -2.38365792e-002, -2.11877655e-002,
-       4.07109782e-002, 3.34610268e-002, -2.30932981e-003,
-       1.67768376e-004, 5.72293811e-003, 3.73526546e-003,
-       -1.54131267e-003, -7.22254743e-004, 7.32038403e-003,
-       5.09858970e-003, 3.09108254e-002, 2.30049808e-002,
-       4.94346395e-002, 4.61623780e-002, 1.60545930e-002,
-       4.40101922e-002, 4.16422039e-002, 5.48333414e-002,
-       -3.86339519e-003, 1.91842113e-003, 7.36322394e-003,
-       5.72490646e-003, 3.66873965e-002, 2.37029810e-002,
-       6.50935769e-002, 4.20257375e-002, 1.71491593e-001,
-       2.75564492e-001, 3.67537558e-001, 3.36738229e-001,
-       8.82315710e-002, 8.23247582e-002, 2.55665898e-001,
-       1.99136421e-001, -7.18799904e-002, -6.44575630e-004,
-       7.86595121e-002, 3.35934795e-002, 7.75107220e-002,
-       2.81589832e-002, 9.20865834e-002, 4.90237549e-002,
-       -1.40321692e-002, 3.87688875e-002, 2.95666128e-001,
-       2.87636369e-001, -7.70059451e-002, -8.48799348e-002,
-       2.42755622e-001, 2.48881787e-001, -6.42615184e-002,
-       -1.66146383e-002, 7.58634955e-002, 3.90949249e-002,
-       4.70924005e-003, -8.48724390e-004, 8.89133010e-003,
-       6.65535033e-003, -6.85316185e-003, -3.76422592e-002,
-       3.87330987e-002, 5.93405478e-002, -1.86313484e-002,
-       -3.31572145e-002, 4.16278802e-002, 5.65866344e-002,
-       -2.19480926e-003, -2.09323916e-004, 7.20872870e-003,
-       5.91328973e-003, -3.25989537e-002, 1.52222859e-003,
-       4.02766317e-002, 8.12417828e-003, -4.61099064e-003,
-       -3.59404087e-002, 5.82243130e-002, 5.08422814e-002,
-       1.12706807e-003, -3.73952240e-002, 3.04052159e-002,
-       4.94256876e-002, -1.39960990e-004, -3.17896134e-003,
-       4.84147109e-003, 5.66236814e-003, -3.07693660e-001,
-       9.26868815e-004, 3.63224953e-001, 3.75396758e-002,
-       -4.42899903e-003, -4.20799702e-002, 3.55723411e-001,
-       1.47191554e-001, -1.86457355e-002, -5.93729727e-002,
-       1.52452901e-001, 1.56049162e-001, 1.34515129e-002,
-       -6.39348384e-003, 3.27428877e-002, 2.47365627e-002,
-       -3.07217717e-001, 4.01203008e-003, 3.51678491e-001,
-       3.47446911e-002, -4.66584936e-002, 5.07887006e-002,
-       3.20690781e-001, 1.47166163e-001, -3.41927726e-003,
-       2.48110685e-002, 1.37284622e-001, 1.29523143e-001,
-       1.35859745e-002, 3.63061763e-003, 2.93487106e-002,
-       2.10516453e-002, -3.05660646e-002, 3.54303542e-004,
-       3.73068936e-002, 7.77133135e-003, -2.09497064e-002,
-       4.76303734e-002, 5.87778240e-002, 6.66702017e-002,
-       -3.83587461e-003, 3.96722667e-002, 2.59761829e-002,
-       6.09298646e-002, 7.14655733e-004, 3.28405295e-003,
-       4.55714110e-003, 7.65579427e-003, -1.31406193e-003,
-       -7.27548904e-004, 6.44619297e-003, 4.53365920e-003,
-       -6.98551582e-003, -2.77062003e-002, 4.29056846e-002,
-       4.84577604e-002, -1.32744131e-003, -3.07953916e-002,
-       3.70878503e-002, 4.77877185e-002, 2.89395597e-004,
-       -1.61353254e-003, 5.69275999e-003, 5.37303416e-003,
-       -5.06274961e-002, -4.63641342e-003, 7.10608810e-002,
-       3.32405418e-002, -5.11159487e-002, -2.29415387e-001,
-       3.60794216e-001, 3.12274426e-001, 3.66751999e-002,
-       -1.49465114e-001, 2.22807854e-001, 2.40830928e-001,
-       3.08251102e-002, -1.50602162e-002, 4.93398681e-002,
-       3.58205140e-002, -4.67853025e-002, 3.75623931e-003,
-       7.34357312e-002, 3.00360452e-002, -8.99611712e-002,
-       6.42353371e-002, 4.92218763e-001, 2.01206744e-001,
-       5.58249578e-002, 2.53910068e-002, 2.42328137e-001,
-       1.72378227e-001, 3.29393856e-002, 7.60844967e-004,
-       5.28907850e-002, 3.05317733e-002, -3.00034578e-003,
-       -1.30974210e-003, 8.57172254e-003, 4.81364783e-003,
-       -1.82340536e-002, 1.67770591e-002, 6.18554056e-002,
-       3.90736051e-002, 8.51552747e-003, 1.18038999e-002,
-       3.86049077e-002, 3.53164412e-002, 2.18143151e-003,
-       -2.30550329e-004, 6.35900674e-003, 5.18346531e-003,
-       3.46404588e-004, -4.33046371e-003, 4.60857013e-003,
-       9.15692281e-003, 4.59169224e-003, -4.99174073e-002,
-       2.79453322e-002, 8.55296925e-002, -1.58599857e-002,
-       -3.75558734e-002, 4.02214676e-002, 7.52290115e-002,
-       3.83314298e-004, -3.58277187e-003, 7.62842735e-003,
-       8.27426650e-003, -3.17617469e-002, -1.81581061e-002,
-       4.44437638e-002, 5.33860140e-002, 1.42594837e-002,
-       -1.67271391e-001, 1.71081871e-001, 4.13983524e-001,
-       -4.92057092e-002, -2.81786740e-001, 2.43432567e-001,
-       4.04018641e-001, 2.68707145e-002, -3.63139920e-002,
-       5.18088154e-002, 4.94607501e-002, -3.28091718e-002,
-       6.99435920e-003, 5.12428321e-002, 2.92499345e-002,
-       -1.18237613e-002, 6.10682368e-002, 1.71376482e-001,
-       1.93892956e-001, -2.10398898e-001, -1.87141134e-003,
-       3.23407829e-001, 1.88059852e-001, 3.38000692e-002,
-       -1.05887512e-002, 5.11242710e-002, 3.31155844e-002,
-       -2.29785428e-003, 3.78044264e-004, 7.13466434e-003,
-       5.24482969e-003, -2.18707416e-003, 8.93210713e-003,
-       3.82017307e-002, 3.78416181e-002, -3.30203474e-002,
-       1.88009869e-002, 5.34507893e-002, 3.78219485e-002,
-       2.91874679e-003, 4.15529619e-004, 6.80686813e-003,
-       4.83216718e-003, -3.61686433e-003, 7.40143645e-004,
-       8.06656852e-003, 2.93873204e-003, -4.10023630e-002,
-       -1.93818267e-002, 6.45799860e-002, 3.12858894e-002,
-       -2.14252453e-002, -2.42229104e-002, 4.31840010e-002,
-       3.49110849e-002, 2.44862773e-003, -5.30309801e-004,
-       5.65203093e-003, 4.19266243e-003, -4.67761420e-002,
-       -3.04626650e-003, 6.71595186e-002, 1.98466331e-002,
-       -2.93861121e-001, -1.06121644e-001, 4.14635539e-001,
-       1.69083714e-001, -6.68187961e-002, 3.08317970e-002,
-       2.44071007e-001, 1.76632509e-001, 3.20093669e-002,
-       1.76722798e-002, 4.71422784e-002, 3.60917822e-002,
-       -5.88266887e-002, -8.44880845e-003, 7.67854825e-002,
-       2.23729555e-002, -3.13645035e-001, -4.18056883e-002,
-       3.82764518e-001, 1.58449039e-001, 1.85297191e-001,
-       3.05158459e-002, 2.86063731e-001, 1.88102320e-001,
-       1.57465637e-002, 1.89125631e-002, 4.64565344e-002,
-       3.86512317e-002, -7.84882065e-003, -1.98254106e-003,
-       1.04301330e-002, 3.70511459e-003, -3.31616737e-002,
-       1.33872489e-002, 5.14948815e-002, 2.96012871e-002,
-       2.85110343e-002, 1.67666450e-002, 4.50386368e-002,
-       3.37841399e-002, 4.75532579e-005, -1.21653068e-003,
-       5.78371622e-003, 4.61213151e-003, -2.29212208e-004,
-       -1.26664608e-003, 4.40054899e-003, 6.25038520e-003,
-       -1.82187241e-002, -3.31833735e-002, 3.53433043e-002,
-       5.41896112e-002, -4.25815815e-003, -3.38595398e-002,
-       3.20827328e-002, 5.13938554e-002, -1.71281747e-004,
-       -1.82594464e-003, 3.93732451e-003, 5.82820829e-003,
-       -2.62190830e-002, -1.86573211e-002, 3.80350612e-002,
-       5.98706938e-002, -1.37944654e-001, -1.01511464e-001,
-       2.03793377e-001, 4.15439427e-001, 6.96743950e-002,
-       -9.67548341e-002, 1.58026099e-001, 2.72438020e-001,
-       1.54150594e-002, -1.49314338e-002, 2.69830860e-002,
-       4.06774431e-002, -1.97498370e-002, 2.77509019e-002,
-       3.09833623e-002, 4.78284024e-002, -9.00867283e-002,
-       2.66545385e-001, 1.60112426e-001, 3.55691254e-001,
-       1.53649012e-002, 2.91331083e-001, 1.34724617e-001,
-       3.64948988e-001, 1.10214856e-002, 3.11973412e-002,
-       2.52757706e-002, 4.77040820e-002, 3.02384928e-004,
-       2.14467105e-003, 3.50753614e-003, 5.49935829e-003,
-       -3.33877606e-003, 2.84164697e-002, 2.31992081e-002,
-       4.60871533e-002, -2.90524401e-003, 2.79576853e-002,
-       2.42474023e-002, 4.66770455e-002, -1.50892907e-003,
-       2.70783575e-003, 3.94184375e-003, 6.05526939e-003,
-       -1.71739177e-003, 9.10960371e-004, 4.19625640e-003,
-       1.94047589e-003, 5.00428118e-003, -1.69913145e-003,
-       1.94388907e-002, 1.49271134e-002, -6.63863635e-003,
-       -2.21591047e-003, 5.10425679e-002, 1.52156530e-002,
-       3.99949513e-002, 1.01634802e-003, 4.86041084e-002,
-       4.02971404e-003, -1.66825168e-002, 5.34384511e-003,
-       3.18923481e-002, 1.36441644e-002, 4.64664511e-002,
-       6.45104935e-003, 1.41907319e-001, 6.87559769e-002,
-       -5.07442206e-002, 2.48434022e-002, 3.56890589e-001,
-       8.55500922e-002, 2.80872047e-001, 2.26843683e-003,
-       3.27858418e-001, 2.40171775e-002, -1.98393501e-002,
-       6.83295261e-003, 3.85356545e-002, 1.75124221e-002,
-       3.98903117e-002, 4.36933823e-002, 1.74095020e-001,
-       1.18959270e-001, 2.38126460e-002, 1.76420540e-001,
-       4.19639707e-001, 2.51190692e-001, 2.56992429e-001,
-       7.31619028e-003, 3.01294059e-001, 3.17225903e-002,
-       3.55697353e-004, 1.06818345e-003, 5.23681240e-003,
-       5.39730676e-003, 3.02889422e-002, 2.99790222e-002,
-       5.69364317e-002, 5.04035540e-002, 3.04385703e-002,
-       8.27111974e-002, 1.46308720e-001, 9.73300040e-002,
-       2.16101278e-002, -5.95875608e-004, 3.05383205e-002,
-       7.36426329e-003, 1.94882916e-004, 3.55297280e-003,
-       4.02533589e-003, 6.18556049e-003, -1.07792243e-002,
-       5.25169335e-002, 3.02367546e-002, 6.29578307e-002,
-       -2.86403187e-002, 4.62795347e-002, 4.68209349e-002,
-       6.14315234e-002, -1.87792140e-003, 1.78894016e-003,
-       5.53230057e-003, 5.61506860e-003, 1.66053958e-002,
-       1.20111052e-002, 2.99917106e-002, 3.15665156e-002,
-       6.25048205e-003, 8.19678903e-002, 1.47044674e-001,
-       2.19856873e-001, -2.29311481e-001, 1.35692954e-001,
-       3.33114415e-001, 2.70861626e-001, -5.91594912e-002,
-       1.46653047e-002, 6.94082156e-002, 3.89854126e-002,
-       2.13108528e-002, -3.72759928e-003, 3.51684280e-002,
-       4.79875877e-002, 3.19603831e-002, 1.66347120e-002,
-       1.35271177e-001, 3.97316843e-001, -1.42750934e-001,
-       6.01988137e-002, 2.22181201e-001, 4.55333024e-001,
-       -7.73204416e-002, 2.59201694e-002, 8.40919018e-002,
-       6.14897348e-002, -2.98114930e-004, -2.89880112e-003,
-       4.89723356e-003, 8.19013081e-003, -2.27209367e-003,
-       -3.78590301e-002, 2.74952520e-002, 8.16965476e-002,
-       -6.45009847e-003, -3.69347185e-002, 2.83332355e-002,
-       8.10514688e-002, -3.55081842e-003, -2.08312995e-003,
-       6.40326226e-003, 8.39988794e-003, 1.55635516e-003,
-       3.22418404e-004, 4.95856255e-003, 2.45227991e-003,
-       3.40192649e-003, 1.11984350e-002, 2.52747294e-002,
-       1.96957383e-002, -2.75562946e-002, 1.13746133e-002,
-       5.85814603e-002, 2.46515106e-002, -7.64752366e-003,
-       -1.84121029e-003, 1.08597772e-002, 4.15686518e-003,
-       2.09204927e-002, 1.54479954e-003, 3.66895087e-002,
-       1.37324687e-002, 2.58134343e-002, 2.20695455e-002,
-       1.48267761e-001, 7.39045590e-002, -2.45220765e-001,
-       1.36512788e-002, 4.95540708e-001, 1.03378288e-001,
-       -5.36383912e-002, -7.55352015e-003, 7.30138943e-002,
-       2.07842439e-002, 2.07700096e-002, -5.60142286e-003,
-       3.64100561e-002, 1.64932217e-002, 4.05506045e-002,
-       -4.58947942e-002, 1.75748289e-001, 1.02835618e-001,
-       -3.06635737e-001, -6.39601052e-002, 5.78143418e-001,
-       1.26157030e-001, -3.71527486e-002, -1.29354734e-003,
-       6.13058694e-002, 1.99467689e-002, 1.14140031e-003,
-       -1.08074117e-003, 5.19737415e-003, 3.61978821e-003,
-       4.50550672e-003, -2.45287027e-002, 3.59902233e-002,
-       3.64113376e-002, -4.24602069e-002, -2.86726020e-002,
-       7.84873515e-002, 4.06797677e-002, -2.41185585e-003,
-       9.83131933e-004, 6.98380545e-003, 3.85345030e-003,
-       4.71611461e-003, -4.83978976e-004, 6.91370619e-003,
-       5.56505518e-003, 9.30752663e-004, 1.79366991e-002,
-       2.49398015e-002, 3.07160784e-002, -1.11418804e-002,
-       1.35458345e-002, 2.43133679e-002, 3.09762303e-002,
-       -2.35003652e-003, -8.19308043e-004, 6.80588046e-003,
-       5.50254248e-003, 7.40206763e-002, -5.13923727e-002,
-       9.27531198e-002, 6.55217990e-002, 5.82322739e-002,
-       -1.19233228e-001, 1.78966507e-001, 1.91455469e-001,
-       -2.00747978e-002, -3.27459211e-003, 1.55864909e-001,
-       1.42017961e-001, -5.32920361e-002, -1.12874769e-002,
-       7.09209740e-002, 4.25595418e-002, 5.89560308e-002,
-       -2.26159915e-002, 1.04467466e-001, 5.04477806e-002,
-       2.14278281e-001, -1.08398274e-001, 3.64775121e-001,
-       2.57217377e-001, -1.30475536e-001, -3.46996844e-001,
-       2.62242168e-001, 4.08912241e-001, -5.58257662e-002,
-       -5.32311127e-002, 8.09195563e-002, 7.18642324e-002,
-       1.96223008e-003, -2.35084235e-003, 1.17784468e-002,
-       8.58369656e-003, -2.86529568e-004, -9.28469524e-002,
-       6.47330955e-002, 1.12127967e-001, -3.13763544e-002,
-       -6.57994673e-002, 5.65804392e-002, 9.36488286e-002,
-       1.14990794e-003, -1.51371059e-003, 6.45485520e-003,
-       8.10413063e-003, -1.56469438e-002, 2.30434677e-003,
-       1.82590876e-002, 8.27633869e-003, 1.85845792e-002,
-       -4.40408625e-002, 4.91485223e-002, 5.90974502e-002,
-       2.61749551e-002, -3.02803181e-002, 4.72509451e-002,
-       7.94327781e-002, 1.43134280e-003, 4.40916652e-003,
-       1.28263365e-002, 9.02407989e-003, -1.56811565e-001,
-       7.23659154e-003, 1.90863982e-001, 2.42276508e-002,
-       1.73114296e-002, -9.50165465e-003, 2.36683771e-001,
-       1.75873846e-001, 2.12027598e-002, -8.43186602e-002,
-       3.02137405e-001, 3.21587205e-001, 1.18167214e-001,
-       -1.69496089e-002, 1.98556751e-001, 4.37344499e-002,
-       -1.24861032e-001, 5.11789136e-003, 1.84632301e-001,
-       2.66463719e-002, 3.07817832e-002, 3.61661166e-002,
-       3.76492083e-001, 1.51459485e-001, -1.27898723e-001,
-       -2.28915010e-002, 2.91694373e-001, 1.25014782e-001,
-       1.57256156e-001, -1.00498237e-002, 2.27622777e-001,
-       2.88922433e-002, -1.10817188e-002, 6.88462169e-004,
-       2.14108322e-002, 4.64624679e-003, -2.17063129e-002,
-       2.39228308e-002, 5.58744557e-002, 3.75918336e-002,
-       -1.39374090e-002, 1.49316890e-002, 3.33753638e-002,
-       2.73402501e-002, 2.04027370e-002, 3.92397429e-004,
-       2.97033787e-002, 3.22228251e-003, 1.24689366e-003,
-       4.83799027e-003, 6.07795920e-003, 6.18716655e-003,
-       -1.31932925e-002, 4.51060310e-002, 3.27501781e-002,
-       5.02277650e-002, -2.97103841e-002, 5.53484447e-002,
-       5.20044044e-002, 6.36056066e-002, -4.34716837e-003,
-       -7.54823777e-005, 7.81835802e-003, 6.32238155e-003,
-       1.77749339e-002, 4.85101389e-003, 3.20248529e-002,
-       1.46123879e-002, -4.47391234e-002, 5.01364879e-002,
-       1.59231380e-001, 1.05769232e-001, -7.36944154e-002,
-       1.70142934e-001, 5.10575831e-001, 2.13050663e-001,
-       -1.06191404e-001, 5.84275136e-003, 1.24908544e-001,
-       2.83710826e-002, 1.47405583e-002, -1.18224103e-004,
-       2.69890521e-002, 8.98585282e-003, -4.11141180e-002,
-       -1.10586463e-002, 1.62450686e-001, 6.79127127e-002,
-       2.69526131e-002, -1.33046331e-002, 5.86734176e-001,
-       1.05020367e-001, -1.35794416e-001, 4.71076835e-003,
-       1.57826811e-001, 2.39446294e-002, 1.43291755e-003,
-       -2.19860885e-006, 3.47075798e-003, 1.71652157e-003,
-       -8.55224673e-003, -9.85298771e-003, 2.72536110e-002,
-       1.69787221e-002, 6.07191538e-003, -1.17333755e-002,
-       8.08662102e-002, 2.26165131e-002, -1.79608818e-002,
-       1.65247626e-003, 2.14046706e-002, 3.88355274e-003,
-       2.19066557e-003, 6.68815104e-004, 8.88740923e-003,
-       4.27618949e-003, 2.05420200e-002, 2.86849663e-002,
-       4.26763035e-002, 3.92883308e-002, -4.69542816e-002,
-       3.30395140e-002, 6.76424429e-002, 4.25013639e-002,
-       -2.09953524e-002, -2.74086068e-003, 2.66528372e-002,
-       7.30434665e-003, 3.73170413e-002, 3.69184767e-003,
-       6.75168559e-002, 2.39875689e-002, 1.46921709e-001,
-       4.29609902e-002, 2.18470186e-001, 1.00307234e-001,
-       -2.79013544e-001, 5.46418242e-002, 3.84975791e-001,
-       1.11078098e-001, -2.19717160e-001, 4.60073398e-003,
-       2.55154490e-001, 3.54533345e-002, 3.69044207e-002,
-       1.39276986e-003, 6.22727387e-002, 2.17052028e-002,
-       1.32734492e-001, -2.48421691e-002, 2.01251373e-001,
-       8.91648084e-002, -2.30999246e-001, -2.80022360e-002,
-       3.40363443e-001, 1.03819355e-001, -2.30976418e-001,
-       9.69690923e-003, 2.60723352e-001, 3.53434868e-002,
-       3.17442603e-003, -1.34911708e-004, 7.13710068e-003,
-       3.04258079e-003, 1.96486097e-002, -1.56308357e-002,
-       3.71166281e-002, 2.42023319e-002, -3.62726152e-002,
-       -1.72974337e-002, 5.80446832e-002, 2.87320111e-002,
-       -2.51475256e-002, 3.29923443e-003, 3.03794127e-002,
-       7.22943339e-003, 6.92454923e-004, 1.06170285e-003,
-       3.89877986e-003, 4.64659510e-003, 6.13440946e-003,
-       3.12994048e-002, 2.85161342e-002, 4.75677177e-002,
-       -2.69282833e-002, 2.35801730e-002, 4.01450656e-002,
-       4.19453084e-002, -1.28012427e-004, -1.58849187e-004,
-       3.23708449e-003, 3.37902200e-003, 1.70977768e-002,
-       -6.26720022e-003, 3.29164825e-002, 3.53398249e-002,
-       1.14335775e-001, -1.23710074e-001, 1.93413213e-001,
-       3.44226360e-001, -2.87343800e-001, -4.26162407e-002,
-       3.34271550e-001, 3.03608626e-001, -8.56557209e-003,
-       7.51062343e-003, 2.87973657e-002, 2.72815097e-002,
-       1.03967376e-002, -1.83080311e-003, 2.91441958e-002,
-       3.08306273e-002, 1.25309572e-001, 2.65241582e-002,
-       1.94637969e-001, 2.82497764e-001, -1.13399878e-001,
-       8.43790695e-002, 2.11987302e-001, 4.03188527e-001,
-       -2.29815468e-002, 9.79533326e-003, 3.66402939e-002,
-       4.13119458e-002, 3.57528974e-004, -8.50969285e-004,
-       3.78345908e-003, 4.14568465e-003, 5.17414557e-003,
-       -2.30316985e-002, 2.86948290e-002, 4.29576598e-002,
-       -9.54912696e-003, -2.64788456e-002, 3.01133804e-002,
-       4.68082093e-002, -8.01219314e-004, -7.87400466e-004,
-       4.04055603e-003, 4.47188877e-003, 6.40040438e-004,
-       -1.33682985e-003, 4.96554654e-003, 5.41159464e-003,
-       4.14180756e-003, -2.04081293e-002, 3.26852761e-002,
-       5.05959913e-002, 1.05961757e-002, -9.48182773e-003,
-       3.14307548e-002, 4.32595052e-002, -1.62019324e-003,
-       -6.53710798e-004, 4.91388189e-003, 3.76264588e-003,
-       -4.32598917e-003, -1.58449467e-002, 5.80548793e-002,
-       4.18656841e-002, 1.64360215e-004, -1.22783624e-001,
-       3.38172466e-001, 2.82517850e-001, 1.12735689e-001,
-       -2.19620004e-001, 2.70351946e-001, 3.19340467e-001,
-       -8.36875197e-003, -2.05825828e-002, 5.72749563e-002,
-       3.91617268e-002, -8.94700643e-003, -2.07729675e-002,
-       5.27976230e-002, 3.89223881e-002, -5.86418211e-002,
-       -1.56017140e-001, 2.83294708e-001, 2.72187203e-001,
-       1.40099406e-001, -1.02259271e-001, 2.88652688e-001,
-       2.61355937e-001, -1.54582187e-004, -1.26115270e-002,
-       5.96887693e-002, 3.97265479e-002, -1.23587658e-003,
-       -1.78395119e-003, 5.42678172e-003, 5.44302259e-003,
-       -8.02349532e-004, -5.26296953e-003, 3.16153616e-002,
-       3.92549187e-002, 1.31373666e-002, -1.50939208e-002,
-       3.59441899e-002, 4.50666919e-002, 1.48179103e-003,
-       -3.00703011e-003, 5.88011416e-003, 6.23734435e-003,
-       -1.52564673e-002, -7.51489133e-004, 2.38852669e-002,
-       1.16055673e-002, -1.76824257e-002, -8.10102001e-002,
-       4.66611907e-002, 1.47878677e-001, -2.13244394e-003,
-       -9.44563523e-002, 3.22866887e-002, 1.60883218e-001,
-       -1.03913080e-004, -1.01339538e-002, 5.49491448e-003,
-       1.95136853e-002, -2.15928167e-001, -2.92103295e-003,
-       2.70941436e-001, 4.15475257e-002, -1.27651811e-001,
-       -1.29334480e-001, 2.42392614e-001, 2.93311685e-001,
-       5.39826462e-004, -9.40144360e-002, 1.23859592e-001,
-       2.39644840e-001, 1.98750775e-002, -1.46922404e-002,
-       3.69985513e-002, 3.59789804e-002, -2.32906386e-001,
-       3.28777730e-003, 2.90346414e-001, 3.36431377e-002,
-       -7.66290277e-002, 1.40115008e-001, 2.48724341e-001,
-       2.15012312e-001, 2.32417341e-002, 1.76633418e-001,
-       1.48618102e-001, 2.26693302e-001, 1.05154663e-002,
-       2.31141988e-002, 3.34584713e-002, 3.46070118e-002,
-       -2.35917997e-002, -9.01623222e-004, 3.16990279e-002,
-       6.98272139e-003, -8.14964157e-003, 3.31896879e-002,
-       5.35090826e-002, 5.04345819e-002, 1.75983831e-003,
-       2.40155552e-002, 3.19822542e-002, 4.82540540e-002,
-       1.01306278e-003, 3.12518422e-003, 5.95681276e-003,
-       7.10177189e-003, -8.75588134e-003, -1.13281363e-003,
-       1.30461287e-002, 6.14008261e-003, 2.42160801e-002,
-       -6.41828775e-002, 6.65777922e-002, 8.45852941e-002,
-       1.16577409e-002, -5.07468767e-002, 5.49072735e-002,
-       8.33673403e-002, -3.85455159e-003, -3.06390622e-003,
-       7.77196558e-003, 9.02619120e-003, -9.66656506e-002,
-       1.57034099e-002, 1.25196144e-001, 3.16129923e-002,
-       -1.37549594e-001, -1.02670029e-001, 3.43434662e-001,
-       1.97145984e-001, 5.08663878e-002, -3.04473490e-001,
-       1.62482977e-001, 3.45012993e-001, 1.66499745e-002,
-       -3.59971002e-002, 3.69183570e-002, 4.85986955e-002,
-       -7.99521133e-002, 8.53854325e-003, 1.18213303e-001,
-       2.47120280e-002, -2.93016911e-001, 5.90252057e-002,
-       4.61616814e-001, 1.34185448e-001, 1.17528765e-003,
-       1.13714607e-002, 1.24866709e-001, 1.03871800e-001,
-       2.19782330e-002, -3.20411706e-003, 3.49047296e-002,
-       2.12210882e-002, -7.61823263e-003, -1.08751131e-003,
-       1.42345596e-002, 3.77741153e-003, -4.74640578e-002,
-       1.32188406e-002, 7.86157846e-002, 2.68746745e-002,
-       -3.37184593e-003, 9.42952093e-003, 2.45362911e-002,
-       2.18839329e-002, 1.85805233e-003, 2.07765443e-005,
-       4.46985243e-003, 3.18174856e-003, 3.96452984e-003,
-       1.24290492e-002, 7.41807884e-003, 2.36084498e-002,
-       -6.54568663e-004, 1.45649254e-001, 2.92988420e-002,
-       2.30450705e-001, -1.76023832e-003, 1.42762288e-001,
-       2.62466278e-002, 2.34722540e-001, 9.42551182e-004,
-       1.59927458e-002, 4.85798251e-003, 2.82373596e-002,
-       1.01190962e-001, -4.90590036e-002, 1.15656182e-001,
-       7.43094310e-002, 1.47054464e-001, 4.24219575e-003,
-       2.16759473e-001, 1.93812504e-001, -9.43294447e-003,
-       8.83460417e-002, 6.77234679e-002, 1.44792736e-001,
-       -1.26302745e-002, 1.67930257e-002, 2.59718765e-002,
-       2.67845131e-002, 5.17386757e-002, -2.62266546e-002,
-       8.37103501e-002, 4.61855754e-002, 4.55904245e-001,
-       -1.68314770e-001, 4.91800874e-001, 2.26460800e-001,
-       1.59095647e-003, -8.13593343e-003, 6.28370643e-002,
-       5.88767305e-002, -9.49641224e-003, -2.30405072e-004,
-       1.71244778e-002, 1.00556184e-002, 2.39651930e-003,
-       7.31562788e-004, 8.30175541e-003, 4.56552161e-003,
-       8.37943628e-002, -3.51427458e-002, 9.05814916e-002,
-       5.21511585e-002, 1.29860137e-002, -1.90313309e-002,
-       2.27437746e-002, 2.84858979e-002, -3.75628966e-004,
-       -7.90796417e-004, 1.96324917e-003, 2.45304732e-003,
-       -1.77521762e-002, 2.09974661e-003, 2.24949811e-002,
-       6.75659720e-003, 4.66813184e-002, -1.33072704e-001,
-       7.74649531e-002, 1.81468382e-001, -4.71969433e-002,
-       -1.42653599e-001, 6.32495582e-002, 2.06932589e-001,
-       -3.31821991e-003, -5.32206753e-003, 5.41589549e-003,
-       1.08908163e-002, -2.00564981e-001, 2.82297600e-002,
-       2.19814137e-001, 3.98928598e-002, -9.57921892e-002,
-       -2.73772497e-002, 2.14422002e-001, 2.44247675e-001,
-       -6.40288927e-003, -4.88287248e-002, 1.00571096e-001,
-       2.08862752e-001, 4.25036717e-003, 9.73148854e-004,
-       1.27698071e-002, 1.86571088e-002, -1.83594853e-001,
-       2.53168829e-002, 1.96652398e-001, 4.07920256e-002,
-       -2.24218935e-001, 1.69132262e-001, 2.78916836e-001,
-       2.45280772e-001, 8.88510514e-003, 1.08495653e-001,
-       9.29454491e-002, 2.10110337e-001, 9.52841062e-003,
-       2.16062590e-002, 1.63731705e-002, 3.17132287e-002,
-       -7.74490321e-003, 5.83941862e-003, 1.06999325e-002,
-       8.25528894e-003, -3.54793854e-002, 1.71069458e-001,
-       4.65564616e-002, 1.80178940e-001, 5.57668740e-004,
-       1.90297365e-001, 2.92694885e-002, 2.00037792e-001,
-       -1.65108463e-003, 2.25899108e-002, 4.79070656e-003,
-       2.44598668e-002, 1.80059957e-004, -4.32784529e-003,
-       3.50250816e-003, 6.08948292e-003, 1.89119931e-002,
-       -5.78489751e-002, 2.87469197e-002, 6.39186427e-002,
-       4.16415110e-002, -6.92130476e-002, 5.26470654e-002,
-       7.92342946e-002, -1.66944228e-003, -5.33506274e-004,
-       1.09952474e-002, 6.74429908e-003, -6.73099747e-003,
-       7.64961587e-004, 1.64508224e-002, 2.32506990e-002,
-       7.14968657e-003, -2.72602811e-002, 8.91361684e-002,
-       1.20297737e-001, 1.58493370e-001, -9.61348489e-002,
-       1.92882195e-001, 1.94306463e-001, 3.73240672e-002,
-       -3.99250537e-002, 5.80271780e-002, 5.19052595e-002,
-       -1.70792434e-002, 9.52241570e-002, 3.89218405e-002,
-       1.01110429e-001, -1.69361070e-001, 4.06691521e-001,
-       2.23217532e-001, 5.05890846e-001, 4.79469523e-002,
-       3.82565334e-002, 1.61373407e-001, 2.01952145e-001,
-       3.81840169e-002, 9.54689109e-004, 5.06112911e-002,
-       2.95590218e-002, 5.50897792e-003, 3.90926702e-003,
-       8.53205100e-003, 1.31700523e-002, -4.76848930e-002,
-       1.14776649e-001, 6.66833892e-002, 1.52252570e-001,
-       -6.29956126e-002, 1.59893453e-001, 8.16197693e-002,
-       1.77724108e-001, -3.89179651e-004, 4.87279426e-003,
-       8.14234186e-003, 1.13073979e-002, 5.92001561e-005,
-       1.52814391e-004, 4.76050703e-003, 4.09348914e-003,
-       3.23731601e-002, 4.24687862e-002, 5.59562705e-002,
-       5.38084991e-002, -1.38153834e-002, 4.76859808e-002,
-       4.32378612e-002, 5.98375164e-002, -4.71370033e-004,
-       9.43023770e-004, 5.23750484e-003, 5.49931824e-003,
-       2.29331050e-002, 2.61536520e-002, 4.66741547e-002,
-       3.92675772e-002, 3.14139485e-001, 2.00985402e-001,
-       4.30057973e-001, 2.87919104e-001, -1.92880705e-001,
-       8.04885700e-002, 2.96711355e-001, 2.63694048e-001,
-       -2.92443056e-002, 1.57794729e-002, 5.30563034e-002,
-       4.13397551e-002, 4.71234508e-002, 3.50536034e-002,
-       6.08605593e-002, 4.98932563e-002, 1.06439441e-001,
-       8.09308439e-002, 2.16102839e-001, 1.92791969e-001,
-       -1.16552509e-001, 1.07613824e-001, 1.89628020e-001,
-       2.05502361e-001, -3.03186271e-002, 2.52305660e-002,
-       4.83948626e-002, 4.21441570e-002, 3.10105667e-003,
-       7.80529750e-004, 5.74282743e-003, 4.70207259e-003,
-       8.12051911e-003, -1.39821544e-002, 2.55892221e-002,
-       2.82187015e-002, -6.36877771e-003, -1.24370875e-002,
-       2.20994949e-002, 2.66908575e-002, -1.90869137e-003,
-       1.11202127e-003, 4.56804829e-003, 4.26159007e-003,
-       -1.00897411e-002, 2.30413466e-003, 2.55171880e-002,
-       7.55373854e-003, -5.44544756e-002, -5.18252365e-002,
-       8.28978270e-002, 7.72583783e-002, -8.87585711e-003,
-       -4.85961922e-002, 3.96469422e-002, 6.81347698e-002,
-       1.63247518e-004, -4.45987098e-003, 5.28175803e-003,
-       8.12995248e-003, -1.97904542e-001, -2.34643966e-002,
-       2.84148008e-001, 4.89599966e-002, -2.98363805e-001,
-       -2.20036402e-001, 3.86182487e-001, 2.66301155e-001,
-       4.14095968e-002, -1.00957222e-001, 1.38989523e-001,
-       1.67045802e-001, 2.02221293e-002, -9.41098481e-003,
-       3.33556682e-002, 2.73382347e-002, -2.45431542e-001,
-       -3.37865278e-002, 3.15566421e-001, 5.14333621e-002,
-       -1.04246542e-001, 2.75196470e-002, 2.17154324e-001,
-       1.33675814e-001, 5.08723147e-002, 5.62837645e-002,
-       1.22063011e-001, 1.18573613e-001, 1.97577477e-002,
-       6.19824277e-003, 3.31990346e-002, 2.44811531e-002,
-       -2.25959700e-002, -3.62529024e-003, 3.08176856e-002,
-       7.42721930e-003, -9.73141007e-003, 1.66534744e-002,
-       3.30288522e-002, 3.26809138e-002, 7.38299172e-003,
-       1.70016512e-002, 2.24371422e-002, 3.23258601e-002,
-       1.01254380e-003, 9.61776765e-004, 4.35983902e-003,
-       4.68499027e-003, -1.68471911e-003, 3.27906990e-003,
-       6.49005687e-003, 1.23669356e-002, 1.96814593e-002,
-       8.67909566e-002, 4.00127061e-002, 1.33498728e-001,
-       1.70452725e-002, 9.34439674e-002, 3.63927782e-002,
-       1.09683208e-001, 2.83468398e-003, 6.97329221e-003,
-       4.64478135e-003, 8.82301014e-003, 3.81514989e-002,
-       -1.18453251e-002, 4.53443937e-002, 8.93317387e-002,
-       5.56037910e-002, 6.86805993e-002, 1.46500096e-001,
-       2.71810859e-001, -7.72528583e-003, -4.35554236e-003,
-       9.37689841e-002, 1.90121591e-001, -1.37347057e-002,
-       3.60932946e-003, 2.29736436e-002, 3.85741256e-002,
-       8.47029909e-002, -1.31934181e-001, 1.07066773e-001,
-       1.49540499e-001, 4.61336225e-001, -1.54443443e-001,
-       5.02783895e-001, 2.98660666e-001, -1.29426215e-002,
-       5.67510910e-002, 1.20045759e-001, 1.27766624e-001,
-       -1.53508438e-002, -2.57523934e-004, 2.49130540e-002,
-       3.09553798e-002, 5.49294939e-003, 3.47756967e-003,
-       1.44799724e-002, 7.98248127e-003, 1.03850953e-001,
-       -3.92488092e-002, 1.09534048e-001, 5.29849418e-002,
-       5.92857599e-004, -1.89922713e-002, 1.89149361e-002,
-       2.77445652e-002, 2.56561994e-004, -2.99550797e-004,
-       3.63254361e-003, 4.29712236e-003, 3.37589672e-003,
-       -9.60683729e-003, 6.77052466e-003, 1.37001080e-002,
-       2.08351258e-002, -1.07175276e-001, 4.16811146e-002,
-       1.30612478e-001, 4.60258685e-003, -9.34066474e-002,
-       3.10975295e-002, 1.17136911e-001, -3.41809541e-003,
-       -8.74252338e-003, 5.92444697e-003, 1.30509175e-002,
-       -2.52539385e-002, -2.23839488e-002, 4.14384566e-002,
-       4.89966236e-002, -1.50320046e-002, -2.44212583e-001,
-       1.70816258e-001, 4.41245139e-001, 4.65789661e-002,
-       -3.25874209e-001, 1.47136703e-001, 5.50833702e-001,
-       1.76616460e-002, -4.80836518e-002, 3.39088924e-002,
-       7.61392340e-002, -2.73733847e-002, 2.21322756e-003,
-       4.04435471e-002, 2.39152666e-002, -3.90051231e-002,
-       2.54411772e-002, 1.37929350e-001, 1.29252180e-001,
-       3.27230953e-002, 2.46082451e-002, 1.07974939e-001,
-       1.30163252e-001, 1.47969285e-002, 4.21899930e-003,
-       2.65202690e-002, 2.59270128e-002, -2.06703157e-003,
-       5.98859566e-004, 5.21669863e-003, 3.50626884e-003,
-       -5.40547352e-003, 1.59090273e-002, 2.24859957e-002,
-       2.74776798e-002, 3.76517465e-003, 1.51116289e-002,
-       2.00846903e-002, 2.61050388e-002, 8.83611909e-004,
-       1.08302757e-003, 3.66585399e-003, 3.84748145e-003,
-       -4.53232927e-003, 2.13210049e-004, 7.66834849e-003,
-       2.62418413e-003, -6.52712770e-003, -1.43959932e-002,
-       1.75094139e-002, 2.03190092e-002, 6.68413378e-003,
-       -1.30573260e-002, 1.57881510e-002, 2.22535171e-002,
-       3.26823769e-003, 1.53304345e-003, 6.32089330e-003,
-       4.57400829e-003, -4.84338962e-002, 5.67208882e-003,
-       6.32411987e-002, 1.57376286e-002, -5.90663664e-002,
-       -3.08754910e-002, 1.24362268e-001, 9.17106420e-002,
-       7.27721304e-002, -9.09589902e-002, 2.01324984e-001,
-       2.20824167e-001, 5.78638390e-002, 3.13202408e-003,
-       6.86503276e-002, 5.12866527e-002, -4.69773859e-002,
-       2.19918471e-002, 6.05197176e-002, 2.97580883e-002,
-       -1.42391056e-001, 1.98401749e-001, 2.45766699e-001,
-       2.54409283e-001, 8.69051274e-003, 4.10059886e-003,
-       6.02072239e-001, 3.77868950e-001, 3.38777415e-002,
-       -7.35832192e-003, 5.88214286e-002, 5.91683611e-002,
-       -5.28327073e-004, 9.93547030e-004, 3.51478998e-003,
-       6.11588592e-003, -2.18984839e-002, 3.97582054e-002,
-       4.09078896e-002, 6.88193068e-002, -2.47332975e-002,
-       4.86144349e-002, 7.29966909e-002, 8.79400447e-002,
-       1.77149102e-003, 2.01001950e-003, 8.76454730e-003,
-       1.19140949e-002, -3.29753011e-003, -2.06337380e-003,
-       5.45515679e-003, 7.34313205e-003, -9.54866689e-003,
-       -3.16783153e-002, 2.56122705e-002, 4.93084565e-002,
-       1.40361404e-002, -2.30222698e-002, 3.11789643e-002,
-       4.00814563e-002, 2.44095153e-003, 3.00714491e-005,
-       6.30533043e-003, 5.85682224e-003, -3.22275274e-002,
-       4.73407917e-002, 5.19629009e-002, 6.33029863e-002,
-       -1.40353531e-001, 2.13359356e-001, 2.15321526e-001,
-       3.13431203e-001, 1.19664505e-001, 5.68541288e-002,
-       1.84516340e-001, 1.82624698e-001, 3.85853350e-002,
-       1.26558067e-002, 5.41655682e-002, 3.80176827e-002,
-       -6.24717912e-003, 1.87376402e-002, 5.33515923e-002,
-       3.44716422e-002, -3.77855837e-001, 7.34382728e-003,
-       4.71207529e-001, 2.32344553e-001, 1.51478574e-001,
-       8.24241266e-002, 2.32626200e-001, 1.93647504e-001,
-       4.71086614e-002, 8.38151388e-003, 6.53928444e-002,
-       3.06898206e-002, 4.00181249e-004, -9.98583855e-004,
-       6.61894819e-003, 4.62633418e-003, -3.31680514e-002,
-       4.35605980e-002, 6.78036809e-002, 5.62645793e-002,
-       1.57556348e-002, 4.51259278e-002, 4.96869981e-002,
-       5.65708540e-002, 2.16461392e-003, 1.20938162e-003,
-       6.80013234e-003, 5.09044295e-003, -2.25039646e-002,
-       2.50254245e-003, 3.20146345e-002, 4.51842416e-003,
-       -4.58461884e-003, -2.02304320e-004, 4.25392389e-002,
-       1.83877833e-002, -5.52035216e-003, -2.88544619e-003,
-       3.08764558e-002, 1.93782970e-002, 2.26653013e-002,
-       1.15680613e-003, 3.51136588e-002, 3.52979009e-003,
-       -2.13837966e-001, 9.49613750e-003, 2.51317233e-001,
-       3.24760154e-002, 2.07583643e-002, 1.46231177e-004,
-       2.36650988e-001, 1.10436797e-001, -5.36509603e-002,
-       2.60277893e-002, 1.92949638e-001, 9.68060121e-002,
-       1.75000772e-001, 7.39143929e-003, 2.61558861e-001,
-       2.63006296e-002, -1.94168434e-001, 1.47105253e-003,
-       2.20765904e-001, 3.30405347e-002, 1.57990009e-002,
-       2.10336655e-001, 1.94111347e-001, 2.55377263e-001,
-       -1.08776921e-002, 2.23440111e-001, 2.28952244e-001,
-       2.52769053e-001, 1.40596986e-001, 2.03038789e-002,
-       2.36850500e-001, 3.99096683e-002, -1.46476915e-002,
-       4.54191258e-003, 1.87139306e-002, 8.72020982e-003,
-       1.73757300e-002, 1.05825491e-001, 5.94443977e-002,
-       1.20233126e-001, -4.49058833e-003, 9.61780399e-002,
-       5.64192906e-002, 1.22615673e-001, -7.62603129e-004,
-       -2.42801290e-003, 1.88168380e-002, 1.06761986e-002,
-       5.74130099e-003, 1.36673346e-003, 1.37334224e-002,
-       5.42041240e-003, -1.01182740e-002, 6.58582151e-002,
-       6.46215528e-002, 7.21444339e-002, -1.89087559e-002,
-       4.76420447e-002, 4.16890867e-002, 6.42536506e-002,
-       -3.25259357e-003, 8.50516779e-004, 6.48437627e-003,
-       5.91553748e-003, 1.06076144e-001, -3.99829634e-003,
-       1.42084569e-001, 2.56643686e-002, -1.34803861e-001,
-       -1.04076220e-002, 4.47984099e-001, 1.64244458e-001,
-       -1.52597800e-001, 4.65116324e-003, 2.51990378e-001,
-       1.71532691e-001, -3.79061513e-002, 1.86602166e-003,
-       5.34768105e-002, 2.64082924e-002, 1.27649859e-001,
-       9.48011177e-004, 1.63946435e-001, 2.26171110e-002,
-       -2.17801377e-001, -8.88232216e-002, 4.51748788e-001,
-       1.71019852e-001, -8.02108571e-002, -8.31919238e-002,
-       2.17769697e-001, 1.55570239e-001, -3.71817760e-002,
-       -7.19217537e-003, 4.89033349e-002, 2.68655755e-002,
-       1.28538441e-002, -1.61057385e-003, 1.84912942e-002,
-       5.74892946e-003, -3.67784649e-002, -5.05644158e-002,
-       5.62765934e-002, 6.71126172e-002, -6.37809001e-003,
-       -4.13277037e-002, 2.70979162e-002, 6.08220957e-002,
-       -2.62409984e-003, -2.53780535e-003, 4.76884004e-003,
-       5.86870220e-003, 9.31169838e-004, -4.29841893e-004,
-       5.49719343e-003, 3.16402456e-003, 1.39500545e-002,
-       9.53196455e-003, 4.23918068e-002, 2.82701720e-002,
-       -1.04921116e-002, 1.16368104e-002, 3.27304378e-002,
-       2.76197642e-002, -7.73510837e-004, 2.60999106e-004,
-       4.74677468e-003, 3.16379801e-003, 1.56348273e-002,
-       4.18037293e-004, 4.79726456e-002, 1.98994912e-002,
-       1.24622226e-001, 9.46563762e-003, 3.34592521e-001,
-       1.65492445e-001, -3.66607830e-002, 6.23145550e-002,
-       2.71118402e-001, 1.81674495e-001, -2.15408187e-002,
-       4.64539556e-003, 4.41956148e-002, 2.27121767e-002,
-       2.10137535e-002, -1.47938903e-003, 4.47542518e-002,
-       1.76033340e-002, -4.54423875e-002, -5.25308251e-002,
-       4.90941554e-001, 1.61674306e-001, 1.53047070e-001,
-       -8.80972520e-002, 4.81700212e-001, 1.80729851e-001,
-       -2.80383173e-002, -2.99371290e-003, 5.04407994e-002,
-       2.13340614e-002, 2.04935973e-003, 3.49082373e-004,
-       5.78847853e-003, 2.71230820e-003, -1.06977820e-002,
-       -1.01394178e-002, 6.27121106e-002, 2.85978261e-002,
-       1.77132189e-002, -1.43219111e-002, 6.30712286e-002,
-       3.15307006e-002, -1.95124291e-003, -3.11003241e-004,
-       5.99165354e-003, 3.08896811e-003, 2.42121122e-003,
-       1.06420796e-002, 8.17823038e-003, 1.78888720e-002,
-       -2.01245028e-004, 1.45069286e-001, 3.82633507e-002,
-       1.96204633e-001, -1.63492560e-002, 1.37881026e-001,
-       4.17634323e-002, 1.98992550e-001, -1.52708904e-003,
-       8.67773592e-003, 9.45415907e-003, 1.87234003e-002,
-       4.43958864e-002, -1.25978906e-002, 8.55146274e-002,
-       4.71734777e-002, 1.68548316e-001, -7.39118923e-003,
-       2.75422961e-001, 1.98889181e-001, -1.65110350e-001,
-       5.55756241e-002, 2.49433011e-001, 2.31552616e-001,
-       -6.37830198e-002, 1.10180397e-002, 1.00861840e-001,
-       4.85367924e-002, 3.38043049e-002, -1.43442964e-002,
-       8.91780257e-002, 4.37856540e-002, 2.59326071e-001,
-       -3.50530520e-002, 3.58681142e-001, 1.75620034e-001,
-       -1.61552086e-001, -1.20382085e-002, 2.56343722e-001,
-       1.74750209e-001, -5.76816164e-002, -3.54665564e-003,
-       9.43849906e-002, 4.43255194e-002, 1.86320650e-003,
-       -1.24557980e-003, 9.89352819e-003, 8.42454750e-003,
-       4.10072319e-002, -4.88180593e-002, 6.44139275e-002,
-       7.26546496e-002, -2.04384066e-002, -3.88097316e-002,
-       5.01644760e-002, 6.58384487e-002, -2.53244070e-003,
-       -2.64367089e-004, 9.26064979e-003, 7.61232525e-003,
-       2.44193990e-003, -1.92455409e-004, 5.79185737e-003,
-       3.01145087e-003, -2.09538881e-002, 1.79365892e-002,
-       6.93018809e-002, 3.01097184e-002, -1.21124340e-002,
-       8.56109057e-003, 3.01664378e-002, 2.73285154e-002,
-       1.84875520e-004, 4.39875148e-004, 3.29409167e-003,
-       3.42154386e-003, 2.97670402e-002, -8.98429542e-004,
-       5.02393432e-002, 2.00085435e-002, -4.79674861e-002,
-       8.59869942e-002, 5.10316610e-001, 1.65427729e-001,
-       -2.50242427e-002, 2.84421712e-001, 1.82070196e-001,
-       3.14003468e-001, -1.88814122e-002, 2.92366557e-002,
-       3.17081995e-002, 3.80588844e-002, 2.91955341e-002,
-       -3.62924970e-004, 4.81902026e-002, 2.18803324e-002,
-       7.95612857e-002, -1.56995326e-001, 3.56884331e-001,
-       2.22633451e-001, -2.21029893e-002, -1.60291702e-001,
-       1.63175881e-001, 2.50164002e-001, -2.63939146e-002,
-       -1.85395740e-002, 3.46446671e-002, 3.34456973e-002,
-       1.35740556e-003, -3.17673723e-004, 5.01369685e-003,
-       3.44949146e-003, 4.44236328e-004, -1.80099141e-002,
-       3.94029133e-002, 3.52337174e-002, -3.03288642e-003,
-       -1.70861781e-002, 2.39271540e-002, 3.62734348e-002,
-       -3.50351358e-004, -5.14473533e-004, 3.22293607e-003,
-       4.06442396e-003, 1.74086087e-003, 2.10487843e-003,
-       6.43465342e-003, 4.60413517e-003, 3.33201811e-002,
-       3.83582786e-002, 4.45931628e-002, 4.84145135e-002,
-       -1.26975579e-002, 3.03558912e-002, 9.10795331e-002,
-       4.26852815e-002, -2.12124754e-002, -2.25826123e-004,
-       2.81452686e-002, 4.79766307e-003, 3.96316685e-002,
-       1.93895970e-003, 5.79160117e-002, 3.81590575e-002,
-       2.83649981e-001, 1.78542733e-001, 3.04909468e-001,
-       2.33015269e-001, -2.20180109e-001, 5.81068248e-002,
-       3.94886792e-001, 1.39802098e-001, -1.77894801e-001,
-       2.67717596e-002, 2.13060617e-001, 3.84483188e-002,
-       5.09302169e-002, 2.82108616e-002, 6.64171875e-002,
-       5.66018447e-002, 1.43868938e-001, -8.58105905e-003,
-       2.16344699e-001, 2.02602074e-001, -1.19682617e-001,
-       -6.81871921e-003, 2.31623545e-001, 1.49554595e-001,
-       -1.32345274e-001, 7.59607032e-002, 1.69976875e-001,
-       8.35645199e-002, 2.81291734e-003, -5.60370181e-003,
-       9.85210575e-003, 1.32469442e-002, 2.24379860e-002,
-       -7.62686655e-002, 5.77503964e-002, 1.16357170e-001,
-       2.44655646e-002, -4.30439599e-002, 4.92986329e-002,
-       6.66027218e-002, -4.45180293e-003, 2.68664188e-003,
-       9.46549885e-003, 6.78850431e-003, 4.76267375e-003,
-       -2.43157591e-003, 6.76602917e-003, 5.50673064e-003,
-       3.49725522e-002, -9.45124105e-002, 7.78127462e-002,
-       1.07648097e-001, -5.24548143e-002, -1.04286827e-001,
-       7.74367452e-002, 1.18334576e-001, -2.52487021e-003,
-       -8.84128548e-003, 5.73958363e-003, 1.21014826e-002,
-       -2.47942191e-003, -1.72658991e-002, 2.17104536e-002,
-       3.45880650e-002, -8.22033361e-003, -1.79885760e-001,
-       1.46344155e-001, 3.11188877e-001, 6.47725537e-003,
-       -2.82933321e-002, 1.58741400e-001, 2.75050312e-001,
-       7.33831711e-003, 7.86926784e-003, 2.37514377e-002,
-       3.83198410e-002, -2.01576273e-003, 4.14689118e-003,
-       1.82863064e-002, 2.75298115e-002, 1.06794544e-001,
-       1.45601645e-001, 1.89364403e-001, 2.63394624e-001,
-       1.04108363e-001, 2.63331681e-001, 3.32486629e-001,
-       3.91566873e-001, 1.90675557e-002, 7.22771883e-002,
-       5.42027168e-002, 9.22736749e-002, 8.40551686e-004,
-       2.76328437e-003, 3.81199853e-003, 4.36198106e-003,
-       7.62141943e-002, 5.11805303e-002, 8.77551138e-002,
-       6.57824948e-002, -3.40026175e-003, 6.28068671e-002,
-       1.05400667e-001, 8.19263682e-002, -3.28511451e-005,
-       2.36160029e-003, 1.22520011e-002, 9.37700924e-003,
-       -1.34862692e-003, 3.45295790e-004, 8.10280535e-003,
-       5.27992612e-003, -2.93277260e-002, -3.21672000e-002,
-       6.55033290e-002, 4.81707044e-002, 2.65089814e-002,
-       -2.95173340e-002, 4.83318344e-002, 4.75644059e-002,
-       8.11143313e-003, 1.14454294e-003, 1.26632284e-002,
-       5.71653061e-003, -3.30766365e-002, -1.62088219e-002,
-       6.74201027e-002, 3.60259116e-002, -1.46192908e-001,
-       -6.54312298e-002, 4.28320944e-001, 1.86237127e-001,
-       1.85812816e-001, -1.22226169e-002, 2.99338967e-001,
-       1.63204491e-001, 9.84954163e-002, 9.05199628e-003,
-       1.28436074e-001, 3.38679962e-002, -4.35395613e-002,
-       -9.85285453e-003, 6.76977858e-002, 3.55215445e-002,
-       -9.98639911e-002, 7.30782747e-003, 2.94003218e-001,
-       1.90815881e-001, 2.33433932e-001, -3.03077493e-002,
-       3.60501230e-001, 1.90961033e-001, 9.64143202e-002,
-       3.50253657e-003, 1.28442749e-001, 3.86247225e-002,
-       -3.51797394e-003, -4.28458559e-004, 8.88364110e-003,
-       4.88780299e-003, -1.10449903e-002, 1.97714083e-002,
-       4.29308526e-002, 3.76972370e-002, 3.14412825e-002,
-       2.28237044e-002, 5.99124022e-002, 3.99299078e-002,
-       7.69410562e-003, -2.00457592e-003, 1.39758866e-002,
-       5.69211785e-003, 4.75884927e-003, -1.13463355e-003,
-       7.35423993e-003, 4.24194010e-003, 1.26330303e-002,
-       3.56916455e-003, 2.57436559e-002, 1.71126109e-002,
-       -1.90759788e-003, 4.86451387e-003, 2.76504811e-002,
-       1.56348851e-002, -1.94615722e-002, -2.56011263e-003,
-       2.27923952e-002, 5.37089584e-003, 5.10844402e-002,
-       -1.09267943e-002, 6.62183687e-002, 2.34373566e-002,
-       1.25229880e-001, -1.67210605e-002, 2.02890143e-001,
-       9.93153080e-002, -1.71233173e-002, 2.74183112e-003,
-       2.13544518e-001, 9.87389982e-002, -1.96619824e-001,
-       -2.22825129e-002, 2.42035478e-001, 3.98514718e-002,
-       5.12014776e-002, -1.74384415e-002, 6.78889081e-002,
-       3.84422801e-002, 9.88085046e-002, -2.42248490e-001,
-       2.87722319e-001, 3.08648705e-001, 3.03351339e-002,
-       -1.55386880e-001, 3.93110901e-001, 2.19698980e-001,
-       -1.93621665e-001, -9.56698880e-003, 2.48706535e-001,
-       3.36209089e-002, 9.86593950e-005, -4.61276062e-003,
-       6.55496959e-003, 9.03705042e-003, -4.58396738e-003,
-       -7.92407319e-002, 6.13561608e-002, 1.02737777e-001,
-       4.39756885e-002, -8.24455246e-002, 9.71775949e-002,
-       9.80468839e-002, -1.55990878e-002, -1.59507629e-003,
-       2.31970344e-002, 8.26739427e-003, -4.32869792e-003,
-       3.83659522e-003, 9.87992715e-003, 7.52601307e-003,
-       -3.14193331e-002, -1.46670034e-002, 4.53598574e-002,
-       3.31311151e-002, 3.38886376e-003, -1.71365738e-002,
-       2.08889935e-002, 2.78895255e-002, 1.47538679e-003,
-       -1.08235283e-003, 4.49589221e-003, 3.82469525e-003,
-       -6.80902824e-002, -2.52992939e-002, 8.64792019e-002,
-       5.44143915e-002, -1.71241164e-001, -7.33570084e-002,
-       2.30297163e-001, 1.50433317e-001, 3.54716964e-002,
-       -1.94128081e-002, 9.53393281e-002, 9.65049565e-002,
-       1.39784086e-002, -5.47042582e-003, 2.61925329e-002,
-       2.02020034e-002, -5.53396232e-002, 4.88188267e-002,
-       7.74982646e-002, 7.55191222e-002, -1.96054652e-001,
-       4.30493861e-001, 2.66480088e-001, 4.93275493e-001,
-       -2.82646529e-002, 1.62614211e-001, 1.24890365e-001,
-       2.31150240e-001, 1.13564031e-002, 1.06157325e-002,
-       2.36350596e-002, 2.82927826e-002, 2.43831519e-003,
-       2.96040718e-003, 7.13093253e-003, 1.12135168e-002,
-       -2.14938223e-002, 8.44228342e-002, 5.20127565e-002,
-       1.27543271e-001, -4.00785878e-002, 1.48950934e-001,
-       5.65044247e-002, 1.75807118e-001, -4.40494157e-003,
-       1.26206456e-002, 7.67016085e-003, 1.54020935e-002,
-       -1.01818633e-003, 5.10009821e-004, 4.69575590e-003,
-       2.06609420e-003, -3.64657827e-002, -1.54589200e-002,
-       6.23908937e-002, 2.58709267e-002, 2.76372712e-002,
-       -9.38500743e-003, 4.78669070e-002, 2.67200563e-002,
-       1.57873589e-003, 9.90386354e-004, 5.58040617e-003,
-       3.56196403e-003, -1.70223713e-002, -1.73824886e-003,
-       3.91931385e-002, 1.47038959e-002, -2.28044003e-001,
-       -5.95516302e-002, 4.71014172e-001, 1.48030326e-001,
-       2.13917196e-001, -1.78244745e-003, 3.02497178e-001,
-       1.38412267e-001, 2.09475532e-002, -1.35384779e-003,
-       4.44230139e-002, 2.23051310e-002, -3.03374510e-002,
-       -3.41265905e-003, 4.79463823e-002, 1.66503824e-002,
-       -7.59960413e-002, 4.71530184e-002, 5.04686654e-001,
-       1.51131496e-001, 1.17853910e-001, 5.99650256e-002,
-       2.50344962e-001, 1.45309478e-001, 2.35589258e-002,
-       -1.70191473e-004, 4.39609736e-002, 2.22499929e-002,
-       -4.81144199e-003, -1.24858099e-003, 7.49635883e-003,
-       2.89938110e-003, 8.98780941e-004, 1.59622319e-002,
-       6.23695552e-002, 2.88896393e-002, 1.13922525e-002,
-       1.30928447e-002, 3.96658964e-002, 2.68502552e-002,
-       1.42455194e-003, 7.48928505e-005, 5.54292835e-003,
-       3.30723356e-003, -1.99135183e-003, -2.91516930e-002,
-       9.35478322e-003, 3.56892161e-002, 2.78464295e-002,
-       -2.95861542e-001, 4.84714955e-002, 3.35765690e-001,
-       -2.15529688e-002, -2.71628708e-001, 6.16846569e-002,
-       3.34282637e-001, -3.42834229e-003, -1.94667447e-002,
-       9.72766336e-003, 3.60523872e-002, -6.40760362e-002,
-       1.20691294e-002, 9.50896665e-002, 5.10741286e-002,
-       -6.16372637e-002, 5.40885469e-003, 1.51007459e-001,
-       2.83815771e-001, 2.51552649e-002, -5.87099604e-002,
-       1.34575725e-001, 2.59947151e-001, 1.73454117e-002,
-       -2.94607468e-002, 2.92706247e-002, 6.58893958e-002,
-       -1.17937267e-001, 4.55250591e-002, 1.32896215e-001,
-       9.51755568e-002, -1.15133107e-001, 1.63633153e-001,
-       2.01125726e-001, 2.83465773e-001, 2.12552561e-003,
-       8.90538022e-002, 1.11582927e-001, 1.60126507e-001,
-       -3.77685321e-003, 8.85276869e-003, 2.57821325e-002,
-       2.53912248e-002, -1.00254072e-002, 4.11357352e-004,
-       1.26575455e-002, 1.13239381e-002, -3.16801630e-002,
-       2.31894571e-002, 4.06656936e-002, 4.55900133e-002,
-       -1.06343552e-002, 9.26025864e-003, 1.98788829e-002,
-       2.49065291e-002, -2.62894406e-004, 3.44482047e-004,
-       2.89183669e-003, 2.45490135e-003, -4.09084460e-004,
-       -4.07697586e-003, 9.24574491e-003, 1.31581882e-002,
-       -3.83171141e-002, -1.00541897e-001, 6.41818494e-002,
-       1.32579058e-001, -4.53954376e-003, -5.73748574e-002,
-       4.48365360e-002, 8.41871798e-002, 1.20778964e-003,
-       -1.41595933e-003, 5.55447768e-003, 7.71318329e-003,
-       -7.18145072e-002, 1.21264504e-002, 9.25416797e-002,
-       6.54275715e-002, -2.21284628e-001, 6.75177723e-002,
-       3.00246030e-001, 3.61931086e-001, 1.09772407e-001,
-       -1.25457803e-002, 2.07248241e-001, 2.04877034e-001,
-       2.60304380e-002, -1.43883880e-002, 4.10668738e-002,
-       4.22195494e-002, -6.95980489e-002, 1.05342874e-002,
-       8.68378282e-002, 5.14513105e-002, -1.50644317e-001,
-       1.61415681e-001, 3.16269010e-001, 3.00638258e-001,
-       -6.93799853e-002, 1.70005500e-001, 2.08569229e-001,
-       2.52459168e-001, 2.26058066e-002, 8.74301791e-003,
-       3.67155150e-002, 3.72057855e-002, -3.83469113e-003,
-       3.20990017e-004, 8.99770018e-003, 6.58165477e-003,
-       -1.48384552e-002, 4.22370583e-002, 4.98291738e-002,
-       6.09592833e-002, -1.89638864e-002, 3.80522013e-002,
-       4.84936275e-002, 5.62159494e-002, 4.99896632e-005,
-       2.33597704e-003, 5.49103506e-003, 6.12294907e-003,
-       -7.71824329e-004, 5.82240405e-004, 6.13551307e-003,
-       2.93014618e-003, -1.61223263e-002, -1.37084275e-002,
-       7.41625279e-002, 3.64944525e-002, 3.90502089e-003,
-       -1.14151565e-002, 5.65126166e-002, 4.07396220e-002,
-       -1.50810624e-003, -5.38130000e-004, 6.20542048e-003,
-       4.78202756e-003, -1.43761290e-002, -3.86561849e-003,
-       4.99169640e-002, 1.84314623e-002, -1.44817621e-001,
-       -1.69265717e-002, 5.18385947e-001, 1.75098211e-001,
-       -7.84544200e-002, -1.30449951e-001, 3.48768413e-001,
-       2.32900068e-001, 1.42285246e-002, -1.34077584e-002,
-       4.36089262e-002, 3.07046901e-002, -3.13071497e-002,
-       -1.29738208e-002, 6.19351901e-002, 2.52215546e-002,
-       -1.20995902e-001, -6.27626181e-002, 3.56413096e-001,
-       1.95494592e-001, -6.34026751e-002, 3.64647470e-002,
-       2.46092275e-001, 1.84784800e-001, 1.56363416e-002,
-       4.71968250e-003, 4.04297672e-002, 2.82372013e-002,
-       -4.81332559e-003, -1.09081960e-003, 8.63374490e-003,
-       4.19476442e-003, -7.21734250e-003, 1.26541238e-002,
-       4.22949679e-002, 3.78860906e-002, -9.10237606e-004,
-       1.19231520e-002, 3.53859253e-002, 4.09455784e-002,
-       -1.11077337e-004, -3.27217422e-004, 4.84320149e-003,
-       4.75737592e-003, 9.63984523e-004, -5.79284504e-003,
-       4.88267792e-003, 8.50282330e-003, 1.55060273e-002,
-       -7.06099197e-002, 3.73208970e-002, 8.26703757e-002,
-       1.63667426e-002, -4.83516902e-002, 3.95947620e-002,
-       6.96052611e-002, 2.13222243e-004, -2.35975647e-004,
-       5.78866107e-003, 6.10255450e-003, -2.69379821e-002,
-       3.11622396e-003, 3.74095067e-002, 4.39261347e-002,
-       -2.70618871e-003, -4.74660620e-002, 1.52776837e-001,
-       2.85112023e-001, 1.60932884e-001, -2.31426045e-001,
-       2.59831578e-001, 3.51418406e-001, 5.08670695e-002,
-       -3.81588228e-002, 6.51163459e-002, 5.63422404e-002,
-       -1.82956457e-002, 3.82069908e-002, 3.55954915e-002,
-       4.86532152e-002, -7.98544586e-002, 3.19400400e-001,
-       1.83370441e-001, 3.52430850e-001, -9.67199057e-002,
-       1.64156988e-001, 2.48546436e-001, 2.35393465e-001,
-       5.11071905e-002, -6.46500941e-003, 6.18662089e-002,
-       3.68976481e-002, 1.00248680e-003, 1.97886460e-004,
-       5.05011017e-003, 5.36689814e-003, -1.08008357e-002,
-       1.67091358e-002, 3.32958773e-002, 4.16252166e-002,
-       -2.43683532e-002, 3.59370373e-002, 4.37936001e-002,
-       4.88570109e-002, 1.72213872e-003, 2.76342337e-003,
-       6.76896656e-003, 5.92192821e-003, 9.91710927e-004,
-       1.10953534e-003, 4.47873166e-003, 5.38565591e-003,
-       5.29420003e-003, 2.62925420e-002, 3.11920512e-002,
-       4.11145948e-002, -4.65577748e-003, 2.50468627e-002,
-       2.79572122e-002, 3.91852669e-002, -1.62782974e-003,
-       4.28021245e-004, 4.65683034e-003, 4.75305784e-003,
-       4.11563702e-002, -4.75057820e-003, 5.09294048e-002,
-       3.81671079e-002, -7.92466197e-003, 1.16040997e-001,
-       2.34972462e-001, 2.32842669e-001, -1.07488990e-001,
-       -3.70125636e-003, 2.09116906e-001, 2.04548001e-001,
-       -2.32850872e-002, 5.15305728e-004, 3.73538174e-002,
-       3.12812813e-002, 2.44310871e-002, -3.90146002e-002,
-       4.19321582e-002, 5.24927340e-002, 2.86414772e-001,
-       -2.78357565e-001, 3.69032323e-001, 3.75509679e-001,
-       -1.32747337e-001, 1.02613889e-001, 2.30477691e-001,
-       2.92335033e-001, -2.79293805e-002, 6.80394284e-003,
-       4.15258557e-002, 3.39747034e-002, -1.23533315e-003,
-       1.41144695e-003, 4.25563473e-003, 4.28238558e-003,
-       3.82743739e-002, -2.25123987e-002, 5.18439487e-002,
-       4.34742048e-002, 8.42247251e-003, -4.71044704e-002,
-       4.27491404e-002, 5.74363060e-002, -1.76996342e-003,
-       -1.70387060e-003, 5.41298650e-003, 4.84407833e-003,
-       1.18921197e-003, 8.03085219e-004, 4.92508709e-003,
-       4.23768815e-003, -4.44024988e-002, -3.22775468e-002,
-       5.71374632e-002, 4.61636372e-002, 3.57143767e-003,
-       -3.58511247e-002, 4.88371402e-002, 4.83069867e-002,
-       3.63853038e-003, 1.60450768e-003, 6.42674137e-003,
-       5.11125894e-003, -2.97877192e-002, -3.45042162e-002,
-       4.75512855e-002, 4.82439660e-002, -2.62141317e-001,
-       -1.93007514e-001, 3.35654289e-001, 3.12967867e-001,
-       2.75472969e-001, 1.00610740e-001, 3.26298714e-001,
-       2.44420946e-001, 3.00210435e-002, 9.73101123e-004,
-       4.47108001e-002, 3.59692164e-002, -4.36109379e-002,
-       -5.82592189e-003, 5.32487966e-002, 4.23397683e-002,
-       5.17870896e-002, 1.46337375e-001, 2.18458831e-001,
-       2.29019761e-001, 1.70835674e-001, 1.00330405e-001,
-       2.31804430e-001, 2.06157833e-001, 2.47918610e-002,
-       2.36964202e-003, 3.87800075e-002, 3.15889865e-002,
-       -1.18779764e-003, 1.48646859e-003, 5.12089254e-003,
-       4.98089381e-003, 9.94762592e-003, 3.06941476e-002,
-       3.37069109e-002, 4.13827933e-002, 1.07594375e-002,
-       2.30879392e-002, 3.14994156e-002, 3.57699879e-002,
-       8.12507351e-004, 2.15222128e-004, 4.58039949e-003,
-       4.31003701e-003, 5.72152948e-003, -3.29974946e-003,
-       1.53530119e-002, 8.63438658e-003, 3.99812534e-002,
-       2.41139289e-002, 5.51103912e-002, 4.62612249e-002,
-       7.92269688e-003, 1.46881370e-002, 2.35587172e-002,
-       2.78917234e-002, -2.71555898e-003, 5.61527733e-004,
-       4.85743303e-003, 4.54851007e-003, 1.10344090e-001,
-       3.23484875e-002, 1.41834319e-001, 5.94594702e-002,
-       1.47700384e-001, 1.15724422e-001, 2.24014074e-001,
-       1.79204732e-001, -2.57454440e-002, 7.51721859e-003,
-       1.15406327e-001, 1.08644918e-001, -3.91388647e-002,
-       -2.24339329e-002, 5.18556722e-002, 3.74825373e-002,
-       8.57920721e-002, -1.20337829e-002, 1.12677738e-001,
-       6.32452369e-002, 1.23117588e-001, -1.99011356e-001,
-       2.19603628e-001, 2.61282206e-001, -2.96416163e-001,
-       -2.80424953e-001, 3.74209166e-001, 3.37881148e-001,
-       -2.19310056e-002, -7.00626820e-002, 7.00021833e-002,
-       8.72031301e-002, 2.83091771e-003, -1.01395918e-003,
-       1.11695016e-002, 7.81765208e-003, 2.50462927e-002,
-       -5.58367595e-002, 7.12842047e-002, 8.67249668e-002,
-       -5.45785800e-002, -5.88398352e-002, 8.04548115e-002,
-       8.50546360e-002, 2.39484711e-003, 4.82954812e-004,
-       8.81364290e-003, 9.62932687e-003, -9.11710318e-004,
-       -1.21381355e-003, 5.08051366e-003, 5.73022803e-003,
-       1.79700088e-002, -3.62003446e-002, 3.98952924e-002,
-       5.12947887e-002, 3.97735983e-002, -2.05916557e-002,
-       5.88893183e-002, 4.93196473e-002, 1.25685323e-003,
-       2.55843694e-003, 5.78517281e-003, 6.44517830e-003,
-       -1.64405368e-002, 6.95594959e-003, 3.45546044e-002,
-       3.23686376e-002, 2.03613024e-002, 1.04416303e-001,
-       1.86022863e-001, 2.42648438e-001, 1.93231434e-001,
-       -1.56614482e-001, 3.50618213e-001, 2.98841089e-001,
-       4.31124121e-002, -3.34894396e-002, 5.95759004e-002,
-       5.51513322e-002, -1.20637584e-002, 2.67147762e-003,
-       3.34946252e-002, 4.81774397e-002, -6.49641035e-003,
-       -4.13092348e-004, 1.62827820e-001, 3.66396755e-001,
-       1.22596279e-001, 1.70844302e-001, 2.61772364e-001,
-       3.84056419e-001, 4.63911816e-002, 2.26969663e-002,
-       5.93108572e-002, 6.07941225e-002, 1.32592744e-003,
-       3.69202951e-003, 5.33902505e-003, 7.53941154e-003,
-       1.31486226e-002, 4.99192551e-002, 3.71339731e-002,
-       6.85912967e-002, 2.37686355e-002, 3.91728878e-002,
-       4.02738601e-002, 6.20657429e-002, 9.85423336e-004,
-       1.14950945e-003, 4.44103964e-003, 5.54118492e-003,
-       1.27186693e-004, -8.72454711e-006, 2.28019501e-003,
-       1.77230663e-003, -5.16927335e-004, 3.23122717e-003,
-       1.38080874e-002, 1.22169862e-002, -1.21239042e-002,
-       5.62007725e-003, 2.46085823e-002, 1.72696058e-002,
-       -1.25031630e-002, -2.76528462e-003, 1.62749011e-002,
-       5.38343471e-003, 5.67435240e-003, 4.09376080e-004,
-       1.63128171e-002, 1.43620232e-002, 9.92179033e-004,
-       1.31636802e-002, 7.81255886e-002, 7.80217871e-002,
-       -1.24732934e-001, -2.77080983e-002, 1.88626230e-001,
-       1.14496633e-001, -1.34904489e-001, -4.56465781e-002,
-       1.60025746e-001, 5.95668778e-002, 6.17742771e-003,
-       -2.13569086e-002, 2.02966575e-002, 3.22119780e-002,
-       2.18098168e-003, -1.56634286e-001, 1.11254148e-001,
-       2.15527371e-001, -3.65352184e-001, -2.88371146e-001,
-       4.25460249e-001, 3.46150100e-001, -1.17214248e-001,
-       -4.06603515e-002, 1.54158682e-001, 6.69434667e-002,
-       -2.77499482e-003, -1.64732635e-002, 5.72401052e-003,
-       2.23144740e-002, -1.71263255e-002, -1.62101641e-001,
-       4.33162488e-002, 1.93076953e-001, -3.38115282e-002,
-       -1.40637308e-001, 6.02002516e-002, 1.69924513e-001,
-       -2.45325849e-003, -3.41204088e-003, 9.77481436e-003,
-       1.03651704e-002, -7.26740528e-003, -3.58593045e-003,
-       1.18726557e-002, 7.23145530e-003, 2.41286624e-002,
-       -7.48852417e-002, 5.56551144e-002, 9.42301899e-002,
-       1.08347111e-003, -9.51273963e-002, 5.91545030e-002,
-       1.15508899e-001, 6.77875651e-004, -4.28714138e-003,
-       9.48405638e-003, 8.73037428e-003, -9.63879228e-002,
-       -6.59124786e-003, 1.17428191e-001, 3.37394774e-002,
-       1.29955605e-001, -2.12800931e-002, 3.17641914e-001,
-       2.91659325e-001, 2.24857833e-002, 2.97256336e-002,
-       3.44558090e-001, 2.99134761e-001, 4.08593863e-002,
-       -1.22044999e-002, 6.53255656e-002, 4.93306071e-002,
-       -9.68516842e-002, -8.34284257e-003, 1.19033717e-001,
-       2.76494548e-002, 1.38038889e-001, -5.97001947e-002,
-       3.02343339e-001, 2.40932107e-001, 1.10745236e-001,
-       2.59553902e-002, 2.45675191e-001, 2.31060520e-001,
-       2.32428815e-002, 4.86940262e-004, 4.61277775e-002,
-       4.46506180e-002, -8.24036635e-003, 5.70588745e-004,
-       1.36376088e-002, 4.15120693e-003, 2.01220885e-002,
-       2.61301808e-002, 4.87105362e-002, 4.35289256e-002,
-       2.52523422e-002, 2.91649234e-002, 4.80079353e-002,
-       5.43023497e-002, -4.31194319e-004, 3.09137511e-003,
-       6.26415526e-003, 8.02386459e-003, 4.91960626e-003,
-       -2.12092209e-003, 1.13886958e-002, 7.44185410e-003,
-       6.41784966e-002, 2.26504356e-002, 7.69353658e-002,
-       4.27838862e-002, 5.54048223e-004, 1.22083137e-002,
-       2.36831307e-002, 2.22725999e-002, -1.04391074e-003,
-       5.90021722e-004, 3.37421009e-003, 2.88324454e-003,
-       8.88686851e-002, 1.72510482e-002, 1.11976147e-001,
-       5.10826856e-002, 3.12906176e-001, 1.11723758e-001,
-       4.03347999e-001, 1.83425307e-001, -1.61819290e-002,
-       -8.00883677e-003, 1.02687269e-001, 8.15642476e-002,
-       -1.28538059e-002, 3.19579709e-003, 2.23942213e-002,
-       1.42960204e-002, 1.05109259e-001, -9.98404063e-003,
-       1.19465239e-001, 6.21911921e-002, 2.16711104e-001,
-       -3.29144150e-001, 3.19124788e-001, 3.95830512e-001,
-       4.66456152e-002, -5.35510555e-002, 1.37946129e-001,
-       1.21883325e-001, -9.01449006e-003, -1.56820740e-003,
-       1.93936899e-002, 1.49162253e-002, 5.49409364e-004,
-       -1.93613500e-003, 7.78739294e-003, 7.49731064e-003,
-       5.93920201e-002, -5.89559823e-002, 7.82636553e-002,
-       8.07761699e-002, 4.94143702e-002, -5.17975800e-002,
-       6.13793395e-002, 6.39493912e-002, 3.06129659e-004,
-       -1.90572673e-003, 3.34855379e-003, 4.25321748e-003,
-       4.14586905e-003, -2.15830325e-004, 5.96309919e-003,
-       5.15014306e-003, -1.62897687e-002, 2.69058123e-002,
-       3.48768160e-002, 3.97610962e-002, -2.51480862e-002,
-       1.80179998e-002, 4.32830229e-002, 5.05530201e-002,
-       -6.11143885e-004, -1.74157831e-005, 4.53185290e-003,
-       5.25088143e-003, 4.76863012e-002, -6.06824970e-003,
-       6.77232891e-002, 3.34341750e-002, -1.94513369e-002,
-       1.76196955e-002, 1.97374344e-001, 1.64042071e-001,
-       -1.96629077e-001, 4.05161716e-002, 3.01894277e-001,
-       4.58897144e-001, -2.54150778e-002, 9.71975457e-003,
-       4.37671654e-002, 4.78334539e-002, 3.04383244e-002,
-       -1.76682454e-002, 6.14769682e-002, 3.81665044e-002,
-       7.81330094e-002, -2.11151928e-001, 2.35876933e-001,
-       3.18331689e-001, -3.26546207e-002, 5.74125126e-002,
-       2.32143015e-001, 3.58242154e-001, -4.60571274e-002,
-       1.45525392e-002, 5.74037433e-002, 4.69065234e-002,
-       -1.39381923e-003, 1.17463336e-004, 5.72303543e-003,
-       5.11422288e-003, 1.27401538e-002, -2.18839720e-002,
-       3.52866128e-002, 4.85431403e-002, 1.18084615e-002,
-       -3.40429880e-002, 3.70427258e-002, 5.51990718e-002,
-       -1.52682688e-003, -1.53877761e-003, 4.64258576e-003,
-       6.59513194e-003, 3.14834039e-003, 8.14557262e-003,
-       7.27135269e-003, 1.20233791e-002, 9.00821574e-003,
-       1.17878959e-001, 3.01428605e-002, 1.61247239e-001,
-       1.32296036e-003, 1.12153023e-001, 2.64062211e-002,
-       1.65703416e-001, 1.62248034e-004, 9.08811297e-003,
-       5.02414349e-003, 1.90774836e-002, 5.72738908e-002,
-       -7.39885028e-003, 7.62105659e-002, 4.52032499e-002,
-       1.46631941e-001, -1.30366340e-001, 2.40663394e-001,
-       3.87438327e-001, 2.21429206e-002, 4.51709284e-003,
-       1.35835201e-001, 2.48528406e-001, -1.73460487e-002,
-       1.67886056e-002, 2.67657097e-002, 3.77208032e-002,
-       4.91403565e-002, -7.00293668e-003, 6.56439960e-002,
-       3.43977846e-002, 1.97104141e-001, 3.58753689e-002,
-       2.85298645e-001, 3.36663157e-001, 1.82820801e-002,
-       -1.19011097e-001, 1.45363629e-001, 3.30358952e-001,
-       -7.31761707e-003, -1.81157161e-002, 2.53885835e-002,
-       3.77679989e-002, 2.83774734e-003, -5.51424455e-004,
-       8.25546589e-003, 5.98403625e-003, -6.24255091e-003,
-       -5.10095730e-002, 5.78164086e-002, 7.37923160e-002,
-       1.47843175e-003, -6.00679964e-002, 4.16112095e-002,
-       8.83620754e-002, 4.44008317e-003, -2.87137320e-003,
-       6.61125267e-003, 8.64280108e-003, -1.17297715e-003,
-       -1.45118660e-003, 6.20078109e-003, 3.91866267e-003,
-       9.40639675e-002, 4.20831554e-002, 1.02949075e-001,
-       5.49624301e-002, 7.69771775e-003, 2.48063505e-002,
-       3.20868939e-002, 3.44174504e-002, -8.42369569e-004,
-       3.13420052e-004, 3.66113055e-003, 3.24203772e-003,
-       3.79581153e-002, 2.00885199e-002, 6.77982569e-002,
-       3.84937637e-002, 5.21571279e-001, 2.38172203e-001,
-       5.48439860e-001, 2.66868472e-001, -4.57748659e-002,
-       2.86270883e-002, 9.52256396e-002, 7.34859407e-002,
-       -1.62113868e-002, 5.54383406e-003, 2.67833397e-002,
-       1.58567242e-002, 1.13128088e-001, 4.71736267e-002,
-       1.23338588e-001, 6.03235066e-002, 1.72369912e-001,
-       1.07287709e-002, 2.26895466e-001, 1.51522651e-001,
-       -2.88985521e-002, -3.10444590e-002, 7.90714100e-002,
-       6.92945793e-002, -1.31597398e-002, -9.09362105e-004,
-       2.41378229e-002, 1.40088433e-002, 8.55990220e-003,
-       3.03837401e-003, 1.06725758e-002, 6.73867576e-003,
-       1.23549532e-002, -1.66065842e-002, 2.52263062e-002,
-       3.04246284e-002, 1.26531813e-003, -1.67009942e-002,
-       1.80753656e-002, 2.46483125e-002, -7.43108802e-004,
-       -1.14959292e-003, 3.40870325e-003, 2.78511131e-003,
-       -1.20196017e-002, 7.09106505e-004, 1.55769689e-002,
-       3.61757400e-003, -2.02922337e-002, -1.75283290e-002,
-       5.56593947e-002, 2.75833197e-002, 5.55415452e-002,
-       -2.23492272e-002, 7.68521801e-002, 4.16082516e-002,
-       -3.75773432e-003, -1.33777596e-003, 8.45014304e-003,
-       6.47046557e-003, -1.16903171e-001, 1.83656544e-003,
-       1.39058560e-001, 2.46354584e-002, -2.19363511e-001,
-       -5.09362333e-002, 3.15806031e-001, 1.19500808e-001,
-       1.52521774e-001, -2.46123865e-001, 2.44895488e-001,
-       2.93502003e-001, 1.06246825e-002, -4.09191884e-002,
-       4.06643450e-002, 5.83126694e-002, -1.22074686e-001,
-       -7.05565279e-003, 1.43628597e-001, 2.36293469e-002,
-       -1.87875211e-001, 4.37108390e-002, 2.98975080e-001,
-       1.28931478e-001, 1.21572815e-001, 2.52035767e-001,
-       2.05595836e-001, 2.99814969e-001, 1.52703160e-002,
-       3.44310477e-002, 3.86621840e-002, 5.03433906e-002,
-       -1.36506017e-002, -1.48443028e-003, 1.77174639e-002,
-       4.03770199e-003, -9.73554153e-004, 2.13259123e-002,
-       5.56404144e-002, 3.25966366e-002, 4.23436351e-002,
-       3.34243253e-002, 6.77175745e-002, 5.27229011e-002,
-       -2.77487841e-003, 2.19498016e-003, 7.15140114e-003,
-       6.56306837e-003, 1.34410671e-004, 1.64499655e-002,
-       4.19090781e-003, 2.52091475e-002, -5.82545623e-003,
-       1.28788054e-001, 2.63748039e-002, 2.11293176e-001,
-       -8.56187136e-004, 1.04743332e-001, 2.61282455e-002,
-       2.04690963e-001, -5.17555862e-004, 8.49393476e-003,
-       4.25663078e-003, 2.52183937e-002, 2.34050043e-002,
-       5.48164593e-003, 3.74192148e-002, 3.44791822e-002,
-       1.71896555e-002, 8.92477557e-002, 9.66668278e-002,
-       1.53380707e-001, -4.73476723e-002, 1.16194233e-001,
-       9.77584794e-002, 1.91202804e-001, -2.57597659e-002,
-       1.70368161e-002, 3.84038165e-002, 4.86507602e-002,
-       8.47215764e-003, -5.93791790e-002, 5.41112721e-002,
-       7.15952814e-002, 1.85095578e-001, -2.33301654e-001,
-       2.48316050e-001, 2.94120222e-001, -2.76739508e-001,
-       -2.60231614e-001, 3.18681389e-001, 3.42605919e-001,
-       -1.95328463e-002, -7.79805556e-002, 5.33857271e-002,
-       1.02474548e-001, -3.94486636e-003, -7.54225708e-004,
-       9.31040011e-003, 7.80457119e-003, 4.56442423e-002,
-       -5.54100312e-002, 6.90153688e-002, 7.96524212e-002,
-       -3.61261331e-002, -2.68852711e-002, 6.55465126e-002,
-       6.89273924e-002, -1.84021576e-003, 6.40186336e-005,
-       6.35614293e-003, 6.61389204e-003, -1.30143133e-003,
-       2.54510925e-003, 6.53148303e-003, 1.62102953e-002,
-       1.64551176e-002, 6.81603253e-002, 4.49332222e-002,
-       1.27745166e-001, 2.91505773e-002, 1.18380323e-001,
-       4.21140492e-002, 1.66006714e-001, 7.55410176e-004,
-       1.69656649e-002, 4.71303798e-003, 2.35054623e-002,
-       3.44817787e-002, 6.22400343e-002, 4.57683802e-002,
-       8.40884447e-002, 8.72064531e-002, 3.85684788e-001,
-       1.57220483e-001, 4.60705459e-001, 3.80550846e-002,
-       1.66860238e-001, 1.03713565e-001, 2.78680146e-001,
-       -1.05876802e-002, 1.28242616e-002, 2.04849448e-002,
-       3.32116745e-002, 3.26590501e-002, -2.29069516e-002,
-       4.59408388e-002, 5.41775562e-002, 4.77909446e-002,
-       -1.14343747e-001, 1.54609799e-001, 2.40499184e-001,
-       -7.60955503e-003, -8.20948184e-002, 1.03122599e-001,
-       2.01560125e-001, -7.65755353e-003, -1.21942777e-002,
-       1.85018014e-002, 3.42913121e-002, 9.78266122e-004,
-       -8.29388760e-003, 5.47792856e-003, 1.61848478e-002,
-       -1.08153541e-002, -1.37865961e-001, 5.35918102e-002,
-       1.76562533e-001, 1.49060460e-002, -1.39977723e-001,
-       4.95108403e-002, 1.75210208e-001, 1.46125501e-003,
-       -1.11821545e-002, 5.82258264e-003, 1.73453838e-002,
-       -2.33155722e-003, -7.78986374e-004, 7.19777588e-003,
-       3.72230634e-003, 2.64774878e-002, -1.47577785e-002,
-       6.42494932e-002, 3.57873403e-002, -3.30119557e-003,
-       -2.15085186e-002, 6.29343390e-002, 4.13894802e-002,
-       2.06761621e-003, 6.28487498e-004, 4.93334560e-003,
-       2.63890321e-003, -2.79782899e-002, -5.59677184e-003,
-       5.25603183e-002, 2.30937190e-002, 1.75126433e-001,
-       -1.05714209e-001, 4.13554192e-001, 1.87306449e-001,
-       -3.33481580e-002, -9.25442725e-002, 5.77470183e-001,
-       2.03202561e-001, 2.42739096e-002, -1.21376850e-002,
-       4.35453132e-002, 2.55699810e-002, -1.48941763e-002,
-       7.21396739e-003, 4.03475389e-002, 2.43883934e-002,
-       -7.56554585e-003, 1.04525834e-001, 1.97373107e-001,
-       1.99026510e-001, 6.57298416e-002, 5.98370470e-002,
-       2.36653239e-001, 2.04023927e-001, 2.12874152e-002,
-       -1.38284573e-002, 3.73149440e-002, 3.43601257e-002,
-       -9.68146720e-004, 3.98598699e-004, 4.80315601e-003,
-       4.13468899e-003, 2.84541748e-003, 1.78378355e-002,
-       3.30709368e-002, 3.85954268e-002, 4.02964652e-004,
-       1.97904669e-002, 2.90558562e-002, 3.93125601e-002,
-       7.26587023e-004, 1.23271043e-003, 4.01500659e-003,
-       4.48359828e-003, 7.50464329e-004, 2.24117818e-003,
-       3.87913687e-003, 6.39902242e-003, 2.38473574e-003,
-       3.04043088e-002, 2.36730929e-002, 5.89518324e-002,
-       -4.64486470e-003, 2.54923571e-002, 2.46210955e-002,
-       5.40269502e-002, -2.62174784e-004, 1.67913688e-003,
-       3.16990702e-003, 5.50161954e-003, 2.25601140e-002,
-       -7.32300291e-003, 3.86476144e-002, 5.30682504e-002,
-       2.27644369e-002, -3.54614519e-002, 1.82337567e-001,
-       4.81197089e-001, -5.21164425e-002, 1.79409590e-002,
-       1.60479322e-001, 3.88937771e-001, -1.62275583e-002,
-       1.58993481e-003, 3.03340964e-002, 3.95686254e-002,
-       1.19002173e-002, -1.92012824e-002, 3.60896103e-002,
-       4.26079556e-002, 2.07371935e-001, -5.89284264e-002,
-       2.75929600e-001, 3.52559924e-001, -1.16519578e-001,
-       8.41485150e-003, 2.00968325e-001, 2.77339220e-001,
-       -1.48386983e-002, -7.79278111e-003, 3.02750077e-002,
-       3.21614482e-002, -6.76233380e-004, 6.08983333e-004,
-       3.98165826e-003, 4.51160502e-003, 1.81819089e-002,
-       -2.05755215e-002, 3.54565457e-002, 4.71466146e-002,
-       -1.50235859e-003, -2.91556753e-002, 2.99692899e-002,
-       5.09882905e-002, -6.54059229e-004, -7.10124965e-004,
-       3.81427421e-003, 4.20979504e-003, -4.91841184e-003,
-       -1.87745795e-003, 8.27672426e-003, 7.84526300e-003,
-       2.23014341e-003, -7.83179849e-002, 3.77381630e-002,
-       1.03750519e-001, -1.83309789e-003, -1.14446744e-001,
-       2.83743180e-002, 1.41243830e-001, 2.69964570e-004,
-       -8.98812152e-003, 5.96565334e-003, 1.34852314e-002,
-       -7.79604316e-002, 1.87837631e-002, 9.16943848e-002,
-       5.01100346e-002, -7.72255138e-002, 1.50209069e-001,
-       1.94900200e-001, 3.31805259e-001, -3.41008157e-002,
-       2.25346610e-001, 1.51692361e-001, 3.97963077e-001,
-       2.09391322e-002, 1.67266261e-002, 4.18518521e-002,
-       4.83844876e-002, -6.61831051e-002, 2.22105216e-002,
-       8.76504555e-002, 5.37437312e-002, -6.06683418e-002,
-       1.29410252e-001, 2.62842596e-001, 3.02639097e-001,
-       2.01667808e-002, 9.97784808e-002, 2.20158055e-001,
-       2.81862915e-001, 6.11494249e-003, 2.53867898e-002,
-       3.72144915e-002, 4.68049608e-002, -1.97293819e-003,
-       -2.17387523e-003, 5.72506851e-003, 6.72116596e-003,
-       -2.01470889e-002, 3.30827311e-002, 5.26809730e-002,
-       5.74348308e-002, -6.07565918e-004, 2.56680865e-002,
-       3.06153167e-002, 4.94007207e-002, 1.41718413e-003,
-       3.36669036e-003, 5.08494396e-003, 7.16210948e-003,
-       -3.64865898e-003, 1.79135372e-004, 7.84783158e-003,
-       5.36978524e-003, -3.67412083e-002, -2.00653989e-002,
-       4.99652289e-002, 4.16210368e-002, 1.75459404e-002,
-       -2.02116575e-002, 3.98996621e-002, 4.56640162e-002,
-       6.28005993e-003, 5.12273109e-004, 9.98723228e-003,
-       5.74387377e-003, -3.62507477e-002, -1.37023702e-002,
-       5.84010892e-002, 3.94610427e-002, -2.61781603e-001,
-       -2.38020148e-004, 3.24246317e-001, 2.21755341e-001,
-       1.77355602e-001, 6.44726604e-002, 2.43660152e-001,
-       2.24946827e-001, 6.16523325e-002, 1.15570314e-004,
-       8.70910063e-002, 3.64226140e-002, -3.59684043e-002,
-       8.02152557e-004, 5.27877919e-002, 4.63989452e-002,
-       -1.21221818e-001, 1.47993371e-001, 2.36466378e-001,
-       3.30398828e-001, 4.60396372e-002, 2.93641891e-002,
-       1.89813390e-001, 2.62610137e-001, 4.81880046e-002,
-       -1.72771886e-002, 6.93210512e-002, 4.67685722e-002,
-       1.33569085e-003, 8.60678870e-003, 8.26859847e-003,
-       1.33798495e-002, 3.68200964e-003, 1.50160953e-001,
-       5.63060939e-002, 1.79446533e-001, -5.15271612e-002,
-       1.30464643e-001, 7.34591261e-002, 1.51276082e-001,
-       2.13181064e-003, 7.70314783e-003, 8.92657321e-003,
-       1.22100404e-002, 1.18732045e-003, 7.65733246e-004,
-       5.85186575e-003, 4.65716328e-003, -4.18909453e-003,
-       3.67063135e-002, 4.87794429e-002, 4.79075797e-002,
-       -2.78437417e-002, 2.07162760e-002, 4.26824614e-002,
-       3.70518267e-002, -1.86808596e-004, -4.26368992e-004,
-       3.89638194e-003, 3.45254852e-003, 3.16888541e-002,
-       3.88002372e-003, 4.97809798e-002, 2.99168807e-002,
-       6.21309578e-002, 6.12473078e-002, 3.64365995e-001,
-       2.51158267e-001, -2.89238751e-001, 1.89972445e-001,
-       3.59742641e-001, 2.71179944e-001, -2.26549767e-002,
-       1.28677357e-002, 3.78450304e-002, 2.69357041e-002,
-       2.92257704e-002, -7.51869893e-003, 4.39788997e-002,
-       2.85392031e-002, 8.92219767e-002, -1.80165276e-001,
-       2.21313193e-001, 2.42788374e-001, -1.51268423e-001,
-       -9.76980180e-002, 2.76334614e-001, 2.26032734e-001,
-       -3.51525359e-002, 4.20892262e-004, 4.59612794e-002,
-       2.77766977e-002, 8.50461714e-004, -8.99970008e-004,
-       4.57809819e-003, 4.03703889e-003, 5.96846221e-003,
-       -2.32962091e-002, 2.90357694e-002, 3.66356224e-002,
-       -8.82886350e-003, -2.57492978e-002, 3.20549682e-002,
-       3.83790992e-002, -2.06946558e-003, -3.50945891e-004,
-       4.83447500e-003, 4.07188106e-003, 3.94025585e-003,
-       -3.74669413e-004, 6.04484323e-003, 6.38121460e-003,
-       -3.97757962e-002, -3.15726735e-002, 5.85243627e-002,
-       5.75922355e-002, -1.65693127e-002, -5.29180095e-002,
-       5.38002588e-002, 6.34381101e-002, 3.68952076e-003,
-       -1.88516779e-003, 6.81232801e-003, 5.75521355e-003,
-       -1.69188827e-002, -6.85228184e-002, 3.94022875e-002,
-       7.85503462e-002, -1.61301389e-001, -4.36454833e-001,
-       2.34471262e-001, 4.94691163e-001, 1.57601133e-001,
-       -1.22095808e-001, 2.57962555e-001, 2.11394370e-001,
-       4.86678891e-002, -6.46237191e-003, 6.08368926e-002,
-       3.39575633e-002, -1.65934246e-002, 4.04428411e-003,
-       2.81268917e-002, 2.89993789e-002, -2.33427039e-003,
-       9.31551084e-002, 1.18815623e-001, 1.48872882e-001,
-       1.98359951e-001, 7.65042827e-002, 2.33333409e-001,
-       1.48453608e-001, 4.26839031e-002, 2.83619459e-003,
-       5.74660040e-002, 3.17276604e-002, 1.33595109e-004,
-       1.39951368e-003, 3.65513354e-003, 4.18334967e-003,
-       -2.88504711e-003, 1.77955404e-002, 2.54990105e-002,
-       3.01294066e-002, 2.55902577e-002, 1.27715040e-002,
-       3.81816663e-002, 2.90862806e-002, 3.26051842e-003,
-       -2.99101113e-004, 6.59214705e-003, 4.84864274e-003,
-       1.41978753e-003, 1.97510730e-004, 4.44359658e-003,
-       3.48245515e-003, 1.55904572e-002, 2.15105973e-002,
-       3.70825194e-002, 3.63282040e-002, -4.31499770e-003,
-       2.32386570e-002, 3.31078395e-002, 4.26009260e-002,
-       -1.44442078e-003, 7.10593245e-004, 5.19512454e-003,
-       5.03425254e-003, 1.88857149e-002, -1.77745533e-003,
-       3.88019271e-002, 2.40922496e-002, 1.79174826e-001,
-       4.48936187e-002, 2.81453371e-001, 1.89224228e-001,
-       -8.21173489e-002, 1.29935099e-002, 2.46366337e-001,
-       2.51994729e-001, -2.54593212e-002, -5.62938675e-003,
-       4.60904539e-002, 3.55283841e-002, 1.70826670e-002,
-       -4.90109576e-003, 3.77143659e-002, 2.06562188e-002,
-       2.49546841e-001, -4.54383716e-002, 3.47839683e-001,
-       1.78325504e-001, -1.85107350e-001, -1.88971404e-002,
-       4.53343660e-001, 2.99562395e-001, -1.49822915e-002,
-       -9.49839782e-003, 4.39223163e-002, 3.48730013e-002,
-       1.30940462e-003, 2.52760598e-004, 4.74944664e-003,
-       3.13538429e-003, 2.39964500e-002, -2.13064197e-002,
-       4.46394049e-002, 3.59850451e-002, -1.87703148e-002,
-       -2.45611519e-002, 5.61842397e-002, 4.43073995e-002,
-       -5.17950393e-004, 2.83795147e-004, 5.32535138e-003,
-       4.46322514e-003, -3.67312157e-003, -7.60574403e-005,
-       7.17477407e-003, 2.49817967e-003, 1.89000014e-002,
-       -1.81849138e-003, 6.04680479e-002, 2.47969721e-002,
-       -1.17674908e-002, -7.63860065e-004, 4.27823700e-002,
-       2.29421351e-002, 7.79252878e-005, 9.31390514e-006,
-       5.09184971e-003, 3.04434216e-003, -3.25278305e-002,
-       2.90132104e-003, 5.71906567e-002, 1.63739044e-002,
-       1.51719898e-001, -1.06997211e-002, 5.15663266e-001,
-       1.30116165e-001, -9.20621008e-002, -9.89184808e-003,
-       3.25444251e-001, 1.18067190e-001, 4.17985301e-003,
-       1.25314202e-003, 4.07654457e-002, 1.89517234e-002,
-       -2.13459712e-002, 6.67384919e-003, 5.60940206e-002,
-       2.03114655e-002, 3.69206183e-002, 6.13168515e-002,
-       5.12996614e-001, 1.73896343e-001, -3.68402340e-002,
-       -2.72160955e-003, 2.73212016e-001, 1.37997478e-001,
-       3.97117017e-003, 3.62511753e-004, 3.90600562e-002,
-       1.96656603e-002, -2.16359505e-004, -8.19059569e-005,
-       6.32023206e-003, 3.45024653e-003, -8.06626212e-003,
-       3.88182956e-003, 5.39551564e-002, 3.31015699e-002,
-       -3.74492910e-003, 2.81699654e-003, 3.50402333e-002,
-       2.86348239e-002, 1.73209948e-004, -6.52550341e-007,
-       4.55450267e-003, 3.24259163e-003, 2.49434891e-003,
-       -5.39243629e-004, 4.23545344e-003, 3.20127443e-003,
-       1.06027396e-002, 6.10917108e-003, 3.65208648e-002,
-       3.21512520e-002, -6.96552079e-003, 1.00239227e-002,
-       3.09807695e-002, 3.35780084e-002, -2.89249525e-004,
-       2.62062851e-004, 3.34707927e-003, 3.35824327e-003,
-       2.17627976e-002, -1.04032857e-002, 3.14080007e-002,
-       2.45893579e-002, 1.29577801e-001, -4.64301147e-002,
-       2.78756529e-001, 1.88164815e-001, -9.95825827e-002,
-       -5.29473908e-002, 2.07312852e-001, 2.47182950e-001,
-       -8.55040736e-003, -9.24579613e-003, 3.05026844e-002,
-       3.61233652e-002, 1.18430480e-002, 2.08588038e-003,
-       2.89704334e-002, 2.14896705e-002, 2.54777074e-001,
-       1.28250523e-002, 3.35876048e-001, 2.30023563e-001,
-       -7.69679919e-002, 8.83805379e-002, 1.95021868e-001,
-       5.71902990e-001, -1.74674895e-002, 1.64946746e-002,
-       3.53997797e-002, 6.62132427e-002, 6.89282140e-004,
-       5.18717337e-004, 3.89178982e-003, 3.28795495e-003,
-       2.01269519e-002, -1.59732122e-002, 4.34812978e-002,
-       4.05005999e-002, -9.25200339e-003, -1.49755124e-002,
-       3.53490300e-002, 4.61958535e-002, -6.88211119e-004,
-       -7.20071897e-004, 4.84027481e-003, 4.48046206e-003,
-       -1.11179112e-003, 2.45237653e-003, 6.88879332e-003,
-       6.75582839e-003, -2.67655924e-002, 5.45321740e-002,
-       6.38809204e-002, 7.02608451e-002, 2.41633430e-002,
-       5.64922281e-002, 5.89427911e-002, 6.89941049e-002,
-       -7.35645602e-003, 7.70294864e-004, 1.25134587e-002,
-       6.38121367e-003, 3.29120047e-002, 1.04398141e-002,
-       5.09554744e-002, 3.95521410e-002, -2.79386081e-002,
-       1.89436436e-001, 2.24758282e-001, 2.44640231e-001,
-       -3.86997312e-002, 1.57701761e-001, 2.84486920e-001,
-       2.52663702e-001, -1.16993845e-001, -2.48841457e-002,
-       1.32301673e-001, 4.57080752e-002, 3.11600398e-002,
-       5.97739452e-003, 4.48898710e-002, 2.65854970e-002,
-       5.42008057e-002, -7.63810880e-004, 1.55541927e-001,
-       1.14749521e-001, -3.64028752e-001, -1.51221111e-001,
-       4.33298796e-001, 2.25674912e-001, -7.93955922e-002,
-       -2.47079674e-002, 1.04524061e-001, 4.35902737e-002,
-       2.00248626e-003, -6.58654782e-004, 4.58886940e-003,
-       3.80632561e-003, 1.10130385e-003, -1.83117576e-002,
-       3.06155737e-002, 2.95897163e-002, -7.72265419e-002,
-       -3.21330689e-002, 8.81182477e-002, 5.05396649e-002,
-       -3.13322945e-003, 1.83617545e-003, 9.61852726e-003,
-       5.56910783e-003, 9.13706725e-004, -6.40166458e-003,
-       4.71822545e-003, 1.06743798e-002, 3.00959242e-003,
-       -9.22912955e-002, 3.13251354e-002, 1.17893785e-001,
-       2.45489795e-002, -8.13205242e-002, 4.90741022e-002,
-       1.07957527e-001, 2.80404952e-003, 6.75891526e-004,
-       7.58469757e-003, 6.39112433e-003, -1.83694866e-002,
-       -6.35738252e-003, 2.98497677e-002, 2.25333404e-002,
-       -3.00698448e-002, -2.60253474e-002, 1.05011530e-001,
-       1.53355971e-001, 3.43222588e-001, -4.66869324e-002,
-       4.82977659e-001, 1.45535275e-001, 3.84837091e-002,
-       5.39036002e-003, 7.14373514e-002, 1.84410457e-002,
-       -1.79088041e-002, 4.93185828e-004, 2.91469041e-002,
-       1.24418149e-002, -3.48930359e-002, -6.44662371e-003,
-       1.02807812e-001, 7.66315609e-002, 3.58466148e-001,
-       2.38946988e-003, 5.19783258e-001, 8.11385512e-002,
-       3.37305889e-002, -1.59230793e-003, 6.95184544e-002,
-       1.44266486e-002, -2.24622153e-003, 1.23444624e-004,
-       4.21982678e-003, 2.32033944e-003, -4.87080729e-003,
-       7.30465213e-003, 1.70273967e-002, 1.65178198e-002,
-       5.18320389e-002, 8.97702016e-003, 7.34046474e-002,
-       1.87111273e-002, 3.51888919e-003, -9.92342480e-004,
-       9.59439576e-003, 2.89425650e-003, -5.63216442e-003,
-       2.04323488e-003, 9.32397693e-003, 4.98143397e-003,
-       -3.05779241e-002, -2.91098356e-002, 4.93045710e-002,
-       5.42449914e-002, 8.13977234e-003, -3.77751999e-002,
-       3.24760340e-002, 6.03877604e-002, 7.92237988e-004,
-       -2.19364627e-003, 5.38194785e-003, 6.65593473e-003,
-       -7.27171972e-002, -5.08275721e-003, 8.79726186e-002,
-       2.92562488e-002, -2.93569624e-001, 6.67999834e-002,
-       3.51181269e-001, 3.56117606e-001, 1.27660111e-001,
-       1.32147044e-001, 1.85326770e-001, 4.03047025e-001,
-       2.81682238e-002, 1.22856619e-002, 4.32753786e-002,
-       4.63096760e-002, -7.33460560e-002, -3.65217961e-003,
-       8.45019445e-002, 2.86105387e-002, -1.62914157e-001,
-       6.85278550e-002, 2.41208047e-001, 2.03275785e-001,
-       8.66145715e-002, 5.74209951e-002, 1.64388686e-001,
-       2.12089241e-001, 2.65413038e-002, 1.04090488e-002,
-       4.13337126e-002, 3.72841358e-002, -5.85025130e-003,
-       7.38210510e-004, 8.45078845e-003, 4.81624017e-003,
-       -1.24461334e-002, 4.29833792e-002, 3.72547396e-002,
-       5.43817766e-002, 8.11573956e-003, 4.80955392e-002,
-       3.25077809e-002, 6.03934526e-002, 3.76726639e-005,
-       3.31738894e-003, 4.57146065e-003, 6.40926883e-003,
-       -5.60983364e-003, 2.00925744e-003, 1.35249272e-002,
-       5.06134098e-003, -5.12224287e-002, -2.84946933e-002,
-       1.00729778e-001, 5.91160841e-002, -1.98118910e-002,
-       -2.47577317e-002, 4.10197340e-002, 3.96770723e-002,
-       5.21428185e-003, -3.28109745e-004, 1.05997864e-002,
-       4.92375204e-003, -1.12461805e-001, -1.92105956e-002,
-       1.33365899e-001, 4.06322591e-002, -2.15012789e-001,
-       -2.80148387e-001, 3.36258054e-001, 3.30601305e-001,
-       2.15863530e-003, -5.62064014e-002, 1.46962285e-001,
-       1.36582762e-001, 7.10860044e-002, 4.82389983e-003,
-       9.35010836e-002, 3.07120122e-002, -1.26802862e-001,
-       -4.09821374e-003, 1.40749678e-001, 3.92769501e-002,
-       -4.81321178e-002, 2.03805014e-001, 2.16493070e-001,
-       2.68000394e-001, 1.49956914e-002, 2.36668155e-001,
-       1.63454309e-001, 2.78078109e-001, 6.71037436e-002,
-       1.47500047e-002, 9.39728916e-002, 3.98815796e-002,
-       -8.43151659e-003, 2.97998544e-003, 1.35957813e-002,
-       7.24974321e-003, 2.37959940e-002, 6.24877624e-002,
-       6.64726719e-002, 7.91979656e-002, -1.77796260e-002,
-       6.59509301e-002, 5.32273464e-002, 8.55309516e-002,
-       1.52676855e-003, 3.86949279e-003, 8.77636671e-003,
-       8.96560680e-003, 9.87497717e-003, -1.36469386e-003,
-       1.78284440e-002, 5.57726854e-003, 2.71405987e-002,
-       1.20574143e-002, 4.30051833e-002, 2.39298549e-002,
-       -1.45808095e-002, 2.03608088e-002, 3.38823199e-002,
-       3.25157009e-002, 3.81857069e-004, 3.75626027e-004,
-       8.93296208e-003, 5.19145094e-003, 1.04800865e-001,
-       -1.29784560e-002, 1.46145731e-001, 5.19228689e-002,
-       1.78097934e-001, -1.14730664e-001, 2.69070506e-001,
-       2.40138188e-001, -1.86336376e-002, -6.75824210e-002,
-       1.41526356e-001, 2.31261462e-001, -2.01206524e-002,
-       8.09950009e-003, 5.81396893e-002, 4.05617096e-002,
-       7.84139410e-002, -3.67731787e-003, 1.22782163e-001,
-       7.99466521e-002, 1.90023661e-001, -7.82767013e-002,
-       3.57923836e-001, 3.52104306e-001, 7.87331760e-002,
-       -2.03682184e-002, 1.73083290e-001, 2.59228766e-001,
-       -1.70512255e-002, -4.67852876e-003, 4.01559807e-002,
-       3.52006629e-002, 2.56402767e-003, -1.96489948e-003,
-       9.32824239e-003, 1.64788552e-002, 1.43030146e-002,
-       -1.33963764e-001, 5.71478233e-002, 1.74329102e-001,
-       1.85824335e-002, -1.48412690e-001, 4.14357968e-002,
-       1.89350545e-001, 3.94192338e-003, -1.30676208e-002,
-       7.32711377e-003, 1.93268806e-002, 2.76556442e-004,
-       -3.61341168e-003, 5.24652703e-003, 6.49969419e-003,
-       1.18461074e-002, -3.94580252e-002, 3.36980447e-002,
-       5.43810390e-002, 8.84901918e-003, -2.37374082e-002,
-       2.82761827e-002, 4.23306562e-002, -5.24826115e-004,
-       -6.02129847e-004, 3.98259750e-003, 4.50738100e-003,
-       -4.08308059e-002, -1.56698108e-003, 5.31217717e-002,
-       4.55582067e-002, 2.26500835e-002, -2.09255084e-001,
-       2.17852175e-001, 3.39945525e-001, 1.63975760e-001,
-       -3.13885599e-001, 2.44544938e-001, 3.73071432e-001,
-       2.59307008e-002, -3.12532261e-002, 4.18095700e-002,
-       4.53325398e-002, -3.09141409e-002, 2.16293503e-002,
-       4.92426157e-002, 4.16162051e-002, -1.92524523e-001,
-       1.42888919e-001, 2.74732023e-001, 2.45920479e-001,
-       7.74121657e-002, -1.49978325e-003, 1.94003105e-001,
-       2.36758336e-001, 3.47569324e-002, -1.61381569e-002,
-       4.58805449e-002, 4.14186157e-002, -5.65634517e-004,
-       -9.89682274e-004, 5.38604939e-003, 5.07680094e-003,
-       -2.39894222e-002, 2.22063847e-002, 4.29083928e-002,
-       4.26381528e-002, -2.47296854e-003, 2.86274236e-002,
-       3.36477049e-002, 4.29444388e-002, 1.35519681e-003,
-       1.11392571e-003, 5.12818201e-003, 5.19749383e-003,
-       1.64629088e-003, -9.38480534e-003, 6.96147699e-003,
-       2.11874284e-002, -4.82031930e-004, -1.48007974e-001,
-       4.18348014e-002, 2.33757541e-001, 1.54557563e-002,
-       -1.54307097e-001, 4.91860807e-002, 2.37028360e-001,
-       3.00411484e-003, -7.03976629e-003, 8.91109463e-003,
-       1.86351296e-002, -2.59815510e-002, -1.51742585e-002,
-       4.92141619e-002, 4.51194569e-002, -1.68787569e-001,
-       -8.86592120e-002, 2.40848869e-001, 2.42227659e-001,
-       2.75793850e-001, -9.69375819e-002, 3.37410390e-001,
-       2.51982093e-001, 8.01013410e-002, -1.85150187e-002,
-       1.01309888e-001, 5.40461242e-002, -2.15440392e-002,
-       5.59841683e-005, 4.26494926e-002, 3.44100222e-002,
-       -1.16521433e-001, 6.35871142e-002, 2.04155624e-001,
-       1.74970314e-001, 1.77401111e-001, 5.63835949e-002,
-       2.47169197e-001, 1.68072507e-001, 6.85527176e-002,
-       -1.80316027e-002, 8.76215100e-002, 4.87841591e-002,
-       -1.28958863e-003, 2.77076266e-003, 6.09808601e-003,
-       7.20193004e-003, -1.01684229e-002, 3.64678279e-002,
-       2.97533572e-002, 5.36860526e-002, 1.52088031e-002,
-       3.38656232e-002, 3.80792990e-002, 5.33976071e-002,
-       4.86477651e-003, 1.26327225e-003, 8.92824307e-003,
-       8.30965489e-003, -2.67459516e-004, 3.04392586e-003,
-       5.54976519e-003, 1.16706574e-002, 2.18802486e-002,
-       7.77656436e-002, 3.99984829e-002, 1.25773087e-001,
-       1.35464827e-002, 9.29378942e-002, 3.31023671e-002,
-       1.43704772e-001, -3.15261190e-004, 7.19192950e-003,
-       5.14673255e-003, 1.48228770e-002, 3.55780311e-002,
-       1.71085652e-002, 6.70908689e-002, 3.47563289e-002,
-       2.19991535e-001, 1.25479624e-001, 2.81764030e-001,
-       2.29247048e-001, 1.95646286e-003, -8.09937157e-003,
-       1.67915002e-001, 1.91572815e-001, -2.74912938e-002,
-       -4.96994983e-003, 4.36998717e-002, 3.19761783e-002,
-       5.40900119e-002, 2.42775725e-003, 7.08587170e-002,
-       4.06177901e-002, 4.77029532e-002, -3.74409109e-002,
-       2.66276121e-001, 1.83872461e-001, -1.33353308e-001,
-       -2.29954824e-001, 4.60932285e-001, 2.94707596e-001,
-       -8.06838926e-003, -3.59890573e-002, 6.01086877e-002,
-       5.17259464e-002, 3.37483734e-003, -1.71671354e-003,
-       7.14890799e-003, 7.34532764e-003, -1.87521824e-003,
-       -5.62387332e-002, 4.43892404e-002, 7.66281486e-002,
-       -2.75735259e-002, -3.80121581e-002, 5.95967695e-002,
-       6.58756718e-002, 2.68907868e-003, -1.88308093e-003,
-       7.27972854e-003, 8.73624720e-003, -1.55560247e-005,
-       -6.02673274e-004, 3.80799104e-003, 2.80174450e-003,
-       3.84754501e-003, -1.46354707e-002, 2.40768790e-002,
-       2.42457390e-002, 4.61907722e-002, -1.94696859e-002,
-       5.71537055e-002, 3.22498567e-002, 3.36638046e-003,
-       1.91552180e-003, 5.84996492e-003, 4.09778347e-003,
-       -6.10712776e-003, -1.51165237e-003, 2.67117061e-002,
-       2.22498812e-002, -3.78498025e-002, -2.32646298e-002,
-       1.34806335e-001, 1.19225785e-001, 3.92681926e-001,
-       -2.83958986e-002, 4.59770590e-001, 1.74532324e-001,
-       2.43820418e-002, -7.16004847e-003, 3.49517949e-002,
-       2.99156085e-002, -4.05543949e-003, 7.76756927e-003,
-       2.54307352e-002, 3.15017216e-002, -2.40201429e-002,
-       9.42004323e-002, 1.29108056e-001, 2.23287836e-001,
-       2.06024483e-001, 6.71485290e-002, 2.74864703e-001,
-       4.62534368e-001, 2.97666751e-002, -2.53698826e-002,
-       4.17665951e-002, 1.06264114e-001, 1.22228160e-003,
-       1.47006882e-003, 4.31830576e-003, 4.29997360e-003,
-       8.15567002e-003, 2.40041167e-002, 3.59472185e-002,
-       3.69494669e-002, 4.24004681e-002, 2.75447443e-002,
-       5.46981245e-002, 4.51332591e-002, 3.68535315e-004,
-       2.48218770e-003, 3.75940907e-003, 5.19724842e-003,
-       -1.97575577e-002, 4.71365114e-004, 2.22432055e-002,
-       6.20893249e-003, -8.69370531e-003, -3.87955569e-002,
-       3.93117964e-002, 6.34621084e-002, 1.08491637e-004,
-       -3.11224945e-002, 2.05930006e-002, 5.95620647e-002,
-       -4.11981127e-005, -1.13327336e-003, 4.51683020e-003,
-       6.99322624e-003, -1.89599156e-001, 2.35819421e-003,
-       2.07561940e-001, 3.01356670e-002, -1.07692182e-001,
-       -1.50575101e-001, 2.73875773e-001, 2.29183361e-001,
-       4.97470647e-002, -2.04314813e-001, 1.03261992e-001,
-       2.70723462e-001, 8.38981010e-003, -3.21825705e-002,
-       2.36299131e-002, 4.18924987e-002, -1.57712758e-001,
-       3.82768293e-003, 1.78719774e-001, 2.80579906e-002,
-       -3.31345111e-001, -1.59385744e-002, 4.10287559e-001,
-       1.90761074e-001, 1.26150576e-002, -1.49381578e-001,
-       1.17368244e-001, 2.62421340e-001, 1.60489213e-002,
-       -1.78551488e-002, 2.18375381e-002, 3.52173224e-002,
-       -1.32445535e-002, -2.00858735e-003, 1.85183007e-002,
-       6.88977540e-003, -4.86274250e-002, 3.28524262e-002,
-       5.95686212e-002, 4.92536463e-002, -8.81417841e-003,
-       3.83048356e-002, 2.29568407e-002, 4.90171760e-002,
-       1.53296266e-003, 2.35276157e-003, 3.24593973e-003,
-       4.97597177e-003, 1.21036638e-003, 1.32715970e-003,
-       4.37564822e-003, 4.47577750e-003, -1.29883019e-002,
-       2.37159133e-002, 2.98142284e-002, 4.52913754e-002,
-       -4.14641760e-002, 2.05905363e-002, 5.73123433e-002,
-       5.85190132e-002, -9.52254329e-003, -1.33363798e-003,
-       1.88626964e-002, 7.46837817e-003, 2.31908411e-002,
-       -2.92773475e-004, 3.34734656e-002, 2.76542921e-002,
-       -2.87888590e-002, 5.30468561e-002, 1.19824603e-001,
-       1.60027117e-001, -2.47763127e-001, 1.54644668e-001,
-       2.95068771e-001, 3.13712656e-001, -1.15557894e-001,
-       2.53871959e-002, 1.60822809e-001, 5.22234216e-002,
-       4.52227481e-002, -3.59008498e-002, 5.84801100e-002,
-       5.20862266e-002, 1.13174058e-002, -1.52560472e-001,
-       1.37810737e-001, 2.40272909e-001, -8.31650421e-002,
-       -7.53733814e-002, 1.91386670e-001, 2.43082926e-001,
-       -1.40539691e-001, 6.20485051e-003, 1.77751958e-001,
-       5.82804941e-002, 2.66808667e-004, -1.82325840e-002,
-       6.39393739e-003, 2.47308221e-002, -5.54268598e-004,
-       -2.06186265e-001, 3.85860428e-002, 2.57171154e-001,
-       4.45586909e-003, -2.09759891e-001, 3.26697119e-002,
-       2.48302609e-001, -5.86076407e-003, -1.62559114e-002,
-       1.14833778e-002, 2.10228972e-002, -1.85006112e-003,
-       -3.49195930e-003, 9.83188394e-003, 1.60573721e-002,
-       4.12996598e-002, -1.54115647e-001, 5.94082996e-002,
-       2.33852386e-001, 1.45626208e-002, -1.13559894e-001,
-       5.44555709e-002, 2.41132677e-001, 6.53220690e-004,
-       3.86031158e-003, 1.18156439e-002, 8.33884533e-003,
-       -5.97242415e-002, 3.80253233e-003, 7.48976320e-002,
-       2.60607898e-002, -1.05924033e-001, 9.74281132e-002,
-       2.44428024e-001, 2.57793903e-001, 1.16617512e-002,
-       -1.19952232e-001, 2.32935220e-001, 4.12375778e-001,
-       1.73777148e-001, -1.72849875e-002, 2.35744998e-001,
-       4.61671613e-002, -5.61849549e-002, 1.48297288e-003,
-       6.28127605e-002, 2.17173286e-002, -1.05700754e-001,
-       5.86438179e-002, 1.75349057e-001, 1.17919289e-001,
-       -7.46212304e-002, 4.46269326e-002, 2.14300558e-001,
-       9.76358503e-002, 1.82804942e-001, 1.76521093e-002,
-       2.68599838e-001, 2.95187682e-002, -9.25229304e-003,
-       2.18150765e-003, 1.23895733e-002, 6.61695283e-003,
-       -5.59147028e-003, 1.16646867e-002, 1.49396006e-002,
-       3.21556330e-002, 2.30985315e-004, 1.75419115e-002,
-       4.50544581e-002, 3.08282133e-002, 2.26812568e-002,
-       3.22245969e-003, 3.61762904e-002, 5.48109319e-003,
-       -1.22680306e-003, -8.05731979e-004, 6.13426417e-003,
-       4.54399083e-003, 7.14737875e-003, -1.71991829e-002,
-       3.84208784e-002, 3.59234139e-002, 3.21548583e-007,
-       -2.19737105e-002, 4.61683311e-002, 4.22518440e-002,
-       3.67381936e-003, -7.29486463e-004, 8.52717180e-003,
-       5.59642771e-003, -3.13352235e-002, -4.04901523e-003,
-       4.71002124e-002, 3.09353191e-002, 1.11786854e-002,
-       -1.21590078e-001, 1.87465727e-001, 2.00737998e-001,
-       -1.23808058e-002, -1.39255315e-001, 2.78137624e-001,
-       2.33854160e-001, 7.55087584e-002, 1.59720201e-002,
-       8.83130357e-002, 4.48287949e-002, -3.13055702e-002,
-       4.50677332e-003, 4.74375226e-002, 2.99801398e-002,
-       -3.40944789e-002, 6.25776574e-002, 1.86852247e-001,
-       1.83158159e-001, 2.82909274e-001, 3.36237103e-001,
-       3.73888105e-001, 3.90415609e-001, 5.32277040e-002,
-       4.06903923e-002, 7.19588622e-002, 5.48201092e-002,
-       -1.61132799e-003, 1.14827522e-003, 5.92047302e-003,
-       4.80761239e-003, 2.19225511e-002, 4.20638695e-002,
-       4.64040264e-002, 5.33538982e-002, 4.81040142e-002,
-       3.04667577e-002, 6.05837144e-002, 5.03945388e-002,
-       -6.97566429e-004, -1.60690350e-003, 5.54053206e-003,
-       4.79159784e-003, -4.14587063e-004, -4.98476380e-004,
-       4.31435928e-003, 3.00756446e-003, -2.12289020e-003,
-       -7.61172175e-003, 1.89601071e-002, 2.09380109e-002,
-       2.31580194e-002, -1.01184165e-002, 4.40785140e-002,
-       2.56014802e-002, 2.05420833e-002, 2.81646475e-003,
-       2.86088511e-002, 7.27974018e-003, -1.16830161e-002,
-       1.16944488e-003, 2.94711757e-002, 2.42323931e-002,
-       -2.45547593e-002, -3.13934498e-003, 1.20942473e-001,
-       1.16529688e-001, 1.56813741e-001, -8.29500891e-003,
-       2.74374872e-001, 1.33286133e-001, 1.86954394e-001,
-       -1.06799081e-002, 2.23466843e-001, 4.10143360e-002,
-       -1.88702792e-002, 6.25096783e-002, 5.53989410e-002,
-       7.71982893e-002, -1.57670125e-001, 3.32175255e-001,
-       2.36318529e-001, 4.41060901e-001, 1.10645212e-001,
-       6.85563013e-002, 2.57616401e-001, 1.94070101e-001,
-       1.41578823e-001, -2.60049161e-002, 1.72226518e-001,
-       4.23270464e-002, 4.93208924e-003, 1.80520152e-003,
-       1.04170237e-002, 1.34608196e-002, -4.00916114e-002,
-       7.78833181e-002, 9.10698622e-002, 1.41085654e-001,
-       -4.07957025e-002, 7.10447580e-002, 7.65799433e-002,
-       1.01033308e-001, 1.12377163e-002, -1.52755156e-003,
-       1.80319902e-002, 6.41471287e-003, -2.61260360e-003,
-       -2.73568067e-003, 4.38343221e-003, 4.42126254e-003,
-       -2.07072706e-003, -3.85009758e-002, 2.97011565e-002,
-       5.03676794e-002, 1.09645901e-002, -2.87856963e-002,
-       3.62139679e-002, 5.62905557e-002, 1.76754256e-003,
-       -6.48950180e-003, 3.51893948e-003, 1.30040050e-002,
-       -3.97187881e-002, 1.53097427e-002, 4.34479825e-002,
-       2.96350904e-002, 1.41670285e-002, -2.83488929e-002,
-       1.29340455e-001, 1.23240523e-001, -1.91467404e-002,
-       -7.29033202e-002, 7.71474689e-002, 1.46291777e-001,
-       4.12590010e-003, -2.11242232e-002, 1.57635584e-002,
-       2.71109231e-002, -7.23597035e-002, 5.43392859e-002,
-       8.11565146e-002, 7.31130615e-002, -3.93732600e-002,
-       2.20686793e-001, 2.28788331e-001, 3.39271039e-001,
-       -6.36478662e-002, 1.62812099e-001, 1.33742154e-001,
-       2.62644619e-001, -1.15736504e-003, 1.18553713e-002,
-       1.39079243e-002, 2.31874604e-002, 2.47825775e-003,
-       2.31213626e-002, 1.33404927e-002, 3.49339433e-002,
-       -2.34416258e-002, 3.25424910e-001, 7.40770772e-002,
-       3.59021991e-001, -3.78945284e-002, 3.14933628e-001,
-       6.43301755e-002, 3.38412106e-001, -1.41039295e-002,
-       2.31596380e-002, 1.42404186e-002, 2.55701076e-002,
-       1.85776502e-003, -4.90245270e-003, 5.08431438e-003,
-       1.06273023e-002, 7.27141649e-003, -6.09149002e-002,
-       3.11368685e-002, 9.28095430e-002, -4.30432474e-003,
-       -7.03934431e-002, 3.61965522e-002, 1.00825183e-001,
-       5.92045020e-003, -2.41314573e-003, 9.20187589e-003,
-       9.17347055e-003, -6.83627417e-003, -3.17858830e-002,
-       2.30071303e-002, 4.06759121e-002, -2.19295211e-002,
-       -2.48425707e-001, 1.02617204e-001, 2.80588210e-001,
-       1.79319739e-001, -1.38932392e-001, 2.49961853e-001,
-       2.42518097e-001, 9.82038751e-002, 2.18479168e-002,
-       1.15200460e-001, 4.75657322e-002, -8.48654192e-003,
-       -2.54593394e-003, 1.87503621e-002, 2.13948097e-002,
-       1.67926382e-002, 1.80545282e-002, 9.75752473e-002,
-       1.32544339e-001, 4.05628026e-001, 1.40651226e-001,
-       4.34829682e-001, 2.08779573e-001, 8.15311000e-002,
-       2.10091826e-002, 1.06021576e-001, 4.25153784e-002,
-       6.70394569e-004, 5.17478213e-003, 3.70954792e-003,
-       8.11660569e-003, 1.73965041e-002, 6.09829836e-002,
-       3.30628343e-002, 8.06211457e-002, 5.43179475e-002,
-       5.65731041e-002, 7.17372522e-002, 8.33689868e-002,
-       3.93370539e-003, -1.68131478e-003, 8.98726285e-003,
-       6.75608171e-003, -1.55918460e-004, -1.06471414e-002,
-       3.73842148e-003, 1.74788386e-002, 4.94505465e-003,
-       -9.88337025e-002, 2.23641898e-002, 1.41826600e-001,
-       -4.69428068e-003, -9.70657766e-002, 2.91280970e-002,
-       1.41187534e-001, 2.19296757e-003, -8.02977383e-003,
-       6.32687565e-003, 1.51379257e-002, -1.70481633e-002,
-       -2.43295589e-003, 2.81641372e-002, 2.74696965e-002,
-       -5.25707612e-003, -6.31552264e-002, 8.91146734e-002,
-       1.58184677e-001, 9.84647274e-002, -1.07897194e-002,
-       1.57481790e-001, 1.75205961e-001, 4.59649339e-002,
-       4.58684601e-002, 6.28862083e-002, 7.38186613e-002,
-       -1.32223982e-002, 2.31330078e-002, 2.92539131e-002,
-       4.34949063e-002, -9.91055928e-003, 2.23511681e-001,
-       1.11768857e-001, 2.93547601e-001, 3.48678499e-001,
-       3.02428812e-001, 3.96567762e-001, 3.57936263e-001,
-       5.24925925e-002, 5.52886277e-002, 8.52566287e-002,
-       7.27374703e-002, 3.63473519e-004, 1.81082787e-003,
-       4.68523521e-003, 9.59894247e-003, 1.82636688e-003,
-       1.67077389e-002, 2.87277326e-002, 7.01795444e-002,
-       4.00258601e-002, 1.91664919e-002, 5.81940152e-002,
-       7.67548159e-002, 1.88615895e-003, -5.00176474e-003,
-       9.14293434e-003, 9.28911287e-003, 1.64793839e-003,
-       -6.83686789e-003, 4.43674065e-003, 1.30447205e-002,
-       5.94475539e-003, -8.94137397e-002, 4.06418815e-002,
-       1.27449036e-001, -1.47921452e-002, -7.19128698e-002,
-       4.19099256e-002, 1.03668198e-001, 5.16306097e-003,
-       -3.04284133e-003, 9.14845709e-003, 8.18577688e-003,
-       -1.23305004e-002, -1.83213353e-002, 2.26889085e-002,
-       2.97473930e-002, 3.88922007e-003, -1.24401510e-001,
-       9.16897282e-002, 1.59540147e-001, 8.64675641e-002,
-       -6.29156455e-002, 1.57033324e-001, 1.82902828e-001,
-       5.32115884e-002, 1.20660001e-002, 7.89698735e-002,
-       6.28747940e-002, -9.44260694e-003, 4.20896569e-003,
-       2.11651009e-002, 1.98920611e-002, 5.18904161e-003,
-       9.91752651e-003, 9.31693986e-002, 7.87807181e-002,
-       4.90468174e-001, 2.17577964e-001, 5.45350850e-001,
-       2.75885016e-001, 8.84943735e-003, 9.10193026e-002,
-       8.90576690e-002, 1.07712269e-001, -1.03838416e-003,
-       1.51333888e-003, 4.70098061e-003, 6.29985193e-003,
-       1.96184643e-004, 1.81059074e-002, 2.67090704e-002,
-       3.25354189e-002, 9.63269547e-002, 1.45191457e-002,
-       1.06395759e-001, 5.31108640e-002, -4.39680211e-004,
-       -5.71597787e-003, 1.04749408e-002, 9.61002428e-003,
-       -4.53245034e-003, -2.76415114e-004, 7.25037651e-003,
-       3.36920843e-003, -4.75484692e-003, -4.11361046e-002,
-       5.36602847e-002, 4.87151146e-002, 5.49023487e-002,
-       -2.95732245e-002, 6.59300610e-002, 4.69772518e-002,
-       -2.52083666e-003, 4.86107368e-004, 5.45300916e-003,
-       4.37150383e-003, -4.36708033e-002, 2.90680397e-003,
-       5.83577342e-002, 2.05718484e-002, -2.30826154e-001,
-       -4.68047708e-002, 3.19910914e-001, 1.36913270e-001,
-       2.85634011e-001, -3.31178188e-001, 3.28024715e-001,
-       3.57540637e-001, 1.72746796e-002, -5.60589209e-002,
-       4.27742191e-002, 6.37066811e-002, -3.85528356e-002,
-       -3.84222338e-004, 5.48451468e-002, 1.86159890e-002,
-       -2.85029203e-001, 4.27347496e-002, 3.26245695e-001,
-       1.09884106e-001, 4.06613052e-002, 1.23494538e-002,
-       1.25545472e-001, 1.13271035e-001, 3.31956111e-002,
-       -1.73727199e-002, 4.19846773e-002, 3.25110853e-002,
-       -4.23404342e-003, -9.38369078e-004, 7.21762842e-003,
-       2.76287855e-003, -3.58625576e-002, 8.96021165e-003,
-       4.81635742e-002, 2.01505441e-002, 9.23817628e-004,
-       1.09186154e-002, 2.24567726e-002, 2.07947567e-002,
-       1.81765889e-003, 3.11570548e-005, 4.35752003e-003,
-       3.22273909e-003, 5.81747619e-003, -5.53563237e-003,
-       1.88940112e-002, 1.55906091e-002, 2.61265617e-002,
-       8.47341865e-002, 7.57700503e-002, 1.24947555e-001,
-       -4.25030999e-002, 1.29227936e-001, 7.18067884e-002,
-       1.69766426e-001, 6.19246066e-003, -1.05162691e-002,
-       2.07324214e-002, 1.74350943e-002, 1.52545020e-001,
-       5.43566458e-002, 2.27144822e-001, 7.53707215e-002,
-       1.21577464e-001, 1.21937953e-001, 1.88997954e-001,
-       2.14897662e-001, -1.28845423e-001, 9.09518600e-002,
-       2.33302131e-001, 2.07678407e-001, -1.43306747e-001,
-       7.93517083e-002, 1.98554590e-001, 1.03344396e-001,
-       1.59512475e-001, -2.02734433e-002, 2.35052437e-001,
-       6.20498769e-002, 6.37435839e-002, -3.80065143e-002,
-       1.71268031e-001, 1.73839688e-001, -3.96836065e-002,
-       -1.43778790e-002, 1.73222780e-001, 1.77476823e-001,
-       -1.17345296e-001, -4.31922339e-002, 1.68449432e-001,
-       9.60156545e-002, 8.29045102e-003, -9.40925442e-004,
-       1.78689528e-002, 2.05856822e-002, -3.74606834e-003,
-       -1.47416770e-001, 9.65892151e-002, 1.75010920e-001,
-       -1.69417616e-002, -1.51340827e-001, 8.46059248e-002,
-       1.97709963e-001, 7.01084547e-003, 1.09726274e-002,
-       2.06279699e-002, 1.66942384e-002, -8.09909892e-004,
-       -4.13636037e-004, 3.08730826e-003, 2.92872405e-003,
-       -3.48492875e-003, -1.10118166e-002, 1.90993361e-002,
-       2.19671186e-002, 3.37822805e-003, -1.18426206e-002,
-       2.99333297e-002, 2.29363907e-002, 4.99552349e-003,
-       2.13136082e-004, 8.11321195e-003, 3.69334058e-003,
-       -1.26943002e-002, -8.47622752e-004, 2.23078225e-002,
-       2.05670204e-002, -2.16618869e-002, -3.16213584e-003,
-       1.06712900e-001, 1.13275304e-001, 1.12441061e-002,
-       -1.44501710e-002, 2.32958853e-001, 1.21269137e-001,
-       5.17598875e-002, 5.61430492e-003, 6.72229379e-002,
-       2.89292596e-002, -1.21139707e-002, 4.05479334e-002,
-       2.50230599e-002, 5.14201559e-002, 5.54307888e-004,
-       3.38965803e-001, 1.14934072e-001, 3.94614369e-001,
-       6.58179820e-002, 4.35957968e-001, 2.16978967e-001,
-       4.74527657e-001, 3.54448482e-002, 4.00975980e-002,
-       5.70700429e-002, 5.37699759e-002, 2.15455820e-003,
-       5.88562712e-003, 4.26468253e-003, 8.22618697e-003,
-       7.66275125e-003, 4.89755794e-002, 2.19315104e-002,
-       6.10697307e-002, 3.83311138e-003, 3.81830037e-002,
-       2.27178708e-002, 5.28702177e-002, -2.92234239e-003,
-       2.32034642e-003, 5.21214120e-003, 5.66072948e-003,
-       -2.10081879e-003, 9.52562876e-003, 6.42348826e-003,
-       1.26076909e-002, -1.10063432e-002, 1.04100026e-001,
-       4.32166047e-002, 1.16329998e-001, 2.12082323e-002,
-       7.00489059e-002, 6.86474442e-002, 8.45467746e-002,
-       -6.98681595e-003, 2.33312696e-003, 1.15801599e-002,
-       7.26387138e-003, 1.71104800e-002, 1.31501835e-002,
-       3.21898758e-002, 2.87185777e-002, -2.48556733e-002,
-       1.40013054e-001, 1.18989691e-001, 2.14553535e-001,
-       -1.74905092e-001, 1.01975724e-001, 3.06733131e-001,
-       1.81361273e-001, -9.55056325e-002, -3.35094752e-003,
-       1.22204207e-001, 3.03580668e-002, 5.06291632e-003,
-       -3.81192081e-002, 3.58180180e-002, 5.19198515e-002,
-       -3.68979829e-003, -3.38967472e-001, 2.12744847e-001,
-       3.72689992e-001, -6.89838827e-002, -1.28922343e-001,
-       3.69126022e-001, 1.76719517e-001, -1.00249469e-001,
-       3.35551472e-003, 1.32480949e-001, 2.46820208e-002,
-       -5.34613850e-003, -2.67402292e-003, 9.45194624e-003,
-       8.05305410e-003, 8.62057973e-003, -4.46014106e-002,
-       6.46252409e-002, 7.93935359e-002, 3.41464654e-002,
-       -5.18113114e-002, 8.16631988e-002, 6.71057850e-002,
-       -1.00116320e-002, -1.60061521e-004, 1.40995458e-002,
-       5.89588843e-003, -1.22028571e-002, 1.66258903e-003,
-       1.55804632e-002, 3.65617243e-003, -3.36562023e-002,
-       -1.08805383e-002, 4.48960960e-002, 2.22829916e-002,
-       -7.29304156e-004, -1.22606177e-002, 1.53470067e-002,
-       2.27847882e-002, 6.91336099e-005, -5.32791833e-004,
-       2.24458799e-003, 2.55364925e-003, -9.76068005e-002,
-       5.80297364e-003, 1.18709251e-001, 2.15333309e-002,
-       -2.76746064e-001, 2.91627739e-003, 3.11177105e-001,
-       9.04835910e-002, 6.34432212e-003, -3.23233218e-003,
-       7.68961310e-002, 8.06895941e-002, 6.13378501e-003,
-       1.10184366e-003, 1.54637108e-002, 1.38862506e-002,
-       -8.63348842e-002, 5.77811850e-003, 1.06660858e-001,
-       2.83078700e-002, -2.52873927e-001, 3.03821951e-001,
-       2.96730191e-001, 3.53919029e-001, 4.20081802e-003,
-       3.37979525e-001, 8.78435299e-002, 3.82222205e-001,
-       8.48846603e-003, 4.50656265e-002, 1.97842065e-002,
-       5.31141944e-002, -4.84244898e-003, -2.67968193e-004,
-       8.35486688e-003, 6.54239440e-003, -5.95733896e-003,
-       1.61615890e-002, 2.88567431e-002, 9.21257883e-002,
-       2.03969874e-004, 2.23711580e-002, 2.05021016e-002,
-       1.05263531e-001, -7.34490575e-004, 3.80427623e-003,
-       3.73281143e-003, 1.44311665e-002, 4.39427281e-003,
-       -1.34923747e-002, 1.12893675e-002, 1.84994601e-002,
-       3.74269381e-004, -2.15129554e-001, 5.85843623e-002,
-       2.24945515e-001, 2.62635071e-002, -1.85676545e-001,
-       4.98662665e-002, 1.93976685e-001, 6.28474692e-004,
-       -7.71223987e-003, 8.08763225e-003, 1.07709877e-002,
-       -5.76881282e-002, -5.20279147e-002, 8.27928409e-002,
-       7.09721744e-002, -3.85704413e-002, -1.61802858e-001,
-       2.32809335e-001, 3.06498975e-001, 2.62223840e-001,
-       -2.76443839e-001, 3.03370744e-001, 3.65231246e-001,
-       6.00255169e-002, -9.03257951e-002, 8.42350572e-002,
-       1.02681682e-001, -2.22484954e-002, -1.03433570e-002,
-       4.01387662e-002, 3.71562168e-002, -7.40546081e-003,
-       -2.94038579e-002, 1.18899643e-001, 1.43523961e-001,
-       1.05747975e-001, -2.50554625e-002, 1.55688986e-001,
-       1.40099391e-001, 3.23507227e-002, -1.24276076e-002,
-       4.69393432e-002, 3.37979011e-002, -3.15851276e-003,
-       -2.52488871e-006, 5.93248289e-003, 3.59337195e-003,
-       -3.10008088e-003, 3.41321342e-003, 1.58813111e-002,
-       2.14652307e-002, 1.31223043e-002, 1.19486346e-003,
-       1.99467428e-002, 2.07926407e-002, 2.41305353e-003,
-       -1.15330284e-003, 4.92620608e-003, 4.20467323e-003,
-       7.00262748e-003, -1.51262700e-003, 1.35379005e-002,
-       5.33547997e-003, -1.50159234e-002, 3.48147824e-002,
-       7.20562860e-002, 4.93696965e-002, -6.42433688e-002,
-       5.84984273e-002, 1.00281917e-001, 8.29437971e-002,
-       1.25214411e-003, 1.64666027e-003, 8.76513030e-003,
-       1.02677401e-002, 6.36182278e-002, -5.43290982e-003,
-       1.13197178e-001, 2.81273834e-002, 1.65960714e-001,
-       3.45886499e-002, 3.13121498e-001, 1.44054636e-001,
-       -1.87220812e-001, 3.04067403e-001, 3.28451484e-001,
-       3.57821316e-001, -1.03000268e-001, 2.93903705e-002,
-       1.39741942e-001, 6.83136284e-002, 5.99155128e-002,
-       1.73235184e-003, 1.12490259e-001, 2.39729676e-002,
-       2.31913865e-001, -3.12884636e-002, 2.98036277e-001,
-       1.00917928e-001, -3.88592966e-002, -1.87512599e-002,
-       1.80931583e-001, 1.02243274e-001, -1.26258403e-001,
-       2.11516190e-002, 1.46120608e-001, 4.33994569e-002,
-       6.18442148e-003, 1.17891002e-003, 1.39128957e-002,
-       4.11897432e-003, 3.37341689e-002, -6.54919492e-003,
-       4.42831665e-002, 1.99233945e-002, -7.09044142e-003,
-       -8.59060045e-003, 2.65660454e-002, 1.93172898e-002,
-       -9.16751940e-003, 2.01052870e-003, 1.23599274e-002,
-       4.63829190e-003, 5.06103924e-003, 4.57719807e-003,
-       1.38534093e-002, 9.92608350e-003, -8.95958673e-003,
-       8.66820067e-002, 5.25001660e-002, 1.16698973e-001,
-       1.30443536e-002, 9.09856707e-002, 4.44005728e-002,
-       1.16035327e-001, -4.75651678e-003, 5.02193859e-003,
-       1.23336865e-002, 1.04276426e-002, 9.92574617e-002,
-       1.93956625e-002, 1.45672739e-001, 4.43809740e-002,
-       9.98246484e-003, 1.77656710e-001, 2.89932221e-001,
-       2.87646383e-001, -1.76726580e-002, 1.21804662e-001,
-       2.66783506e-001, 2.77214527e-001, -1.07206844e-001,
-       5.55674313e-003, 1.46244705e-001, 4.25599068e-002,
-       9.11556855e-002, 7.31728133e-003, 1.33413255e-001,
-       4.55310903e-002, -4.97774631e-002, -1.08147055e-001,
-       2.62937963e-001, 2.32274830e-001, -3.01729292e-002,
-       -9.41922590e-002, 2.40458742e-001, 2.11945474e-001,
-       -1.05220526e-001, -1.06087066e-002, 1.44157082e-001,
-       3.93645875e-002, 2.64797593e-003, -1.21190806e-003,
-       1.15150074e-002, 9.08006914e-003, -6.37178123e-003,
-       -6.82668909e-002, 5.03222160e-002, 1.00352563e-001,
-       -3.88272339e-003, -6.78803176e-002, 4.21344936e-002,
-       9.90557373e-002, -6.19287509e-003, -1.85709656e-003,
-       1.24629997e-002, 9.60523635e-003, -1.36622333e-003,
-       -1.23033498e-003, 4.14337637e-003, 5.68396412e-003,
-       2.00600307e-002, 2.57541556e-002, 3.86269279e-002,
-       5.72149195e-002, 2.15829629e-002, 5.45605123e-002,
-       3.94870490e-002, 6.60258383e-002, -1.83183409e-003,
-       2.82449904e-003, 5.07107191e-003, 6.03607995e-003,
-       2.79293768e-002, 4.59653847e-002, 4.23458479e-002,
-       6.17416054e-002, 1.70571685e-001, 2.49539748e-001,
-       2.38043770e-001, 4.10917491e-001, -8.01144540e-002,
-       -6.99708099e-003, 1.85695902e-001, 2.56539404e-001,
-       -3.75351682e-002, -1.44372117e-002, 4.55080979e-002,
-       3.85646038e-002, 2.62856372e-002, -7.13040540e-003,
-       3.63787264e-002, 3.59216817e-002, -4.19188626e-002,
-       -1.70188531e-001, 1.67571664e-001, 2.40926892e-001,
-       -1.92219526e-001, -2.79223084e-001, 2.41965979e-001,
-       3.30489159e-001, -2.69453526e-002, -3.10549941e-002,
-       3.88574786e-002, 4.40163538e-002, -6.96206334e-005,
-       -4.24308563e-003, 4.14147787e-003, 6.85347570e-003,
-       -1.74545329e-002, -4.46877703e-002, 3.27633396e-002,
-       5.82632236e-002, -1.63063388e-002, -2.34762225e-002,
-       2.97389925e-002, 4.29826677e-002, 5.58075553e-004,
-       -5.69442091e-005, 3.47106624e-003, 4.02146019e-003,
-       2.24379729e-003, 1.47196725e-002, 8.71003419e-003,
-       2.72806343e-002, 7.22607225e-003, 1.65550575e-001,
-       2.79460885e-002, 2.91683853e-001, -7.62722408e-003,
-       1.67753443e-001, 2.32925490e-002, 3.07089299e-001,
-       -2.52659429e-005, 1.68864708e-002, 9.01035964e-003,
-       3.35740037e-002, 6.18946664e-002, 1.37281511e-002,
-       9.30509493e-002, 4.42898199e-002, 8.46037641e-003,
-       7.64548481e-002, 1.28456652e-001, 1.62858590e-001,
-       -1.30335987e-002, 3.87448817e-002, 1.04606345e-001,
-       1.56527668e-001, -4.19250391e-002, 3.82222841e-003,
-       6.71359822e-002, 3.89254317e-002, 4.82605994e-002,
-       -2.93998071e-003, 9.56867784e-002, 4.12237421e-002,
-       -1.20963890e-003, -4.79025207e-002, 1.56138688e-001,
-       1.50027990e-001, -1.78641364e-001, -2.09245786e-001,
-       2.25507528e-001, 2.87724674e-001, -7.11345673e-002,
-       -8.46889168e-002, 1.11328617e-001, 1.11888051e-001,
-       1.11969573e-004, -1.93208531e-002, 8.75106361e-003,
-       2.46620532e-002, -1.53327137e-002, -1.96167096e-001,
-       5.03820069e-002, 2.43347570e-001, -3.27558517e-002,
-       -1.61860749e-001, 6.26685545e-002, 2.44140789e-001,
-       3.73927737e-003, 4.59208124e-004, 1.10650817e-002,
-       1.86626110e-002, 7.61220232e-004, -1.44610060e-002,
-       5.28764725e-003, 3.57624255e-002, 2.22971570e-002,
-       -1.99268490e-001, 5.64659610e-002, 3.24017853e-001,
-       -3.72787900e-002, -2.99042046e-001, 7.26571754e-002,
-       4.02101487e-001, -9.10983142e-003, -2.10894644e-002,
-       1.03285825e-002, 2.84378584e-002, -6.45861356e-003,
-       -2.55130380e-002, 1.20718917e-002, 4.83404100e-002,
-       -3.64058465e-002, -1.46747097e-001, 9.02608335e-002,
-       2.69847840e-001, -3.99865210e-003, -7.21030757e-002,
-       9.92402285e-002, 1.64861590e-001, 2.14197971e-002,
-       2.24410314e-002, 4.23695631e-002, 4.10634689e-002,
-       1.79228475e-004, -3.86670610e-004, 9.54726338e-003,
-       2.90323794e-002, -3.57874669e-002, 7.71570131e-002,
-       9.90983844e-002, 2.02203795e-001, 1.78622582e-003,
-       9.85516831e-002, 1.30019590e-001, 2.55097985e-001,
-       1.42334672e-002, -1.74580831e-002, 2.48222891e-002,
-       4.34826314e-002, 2.22473661e-003, 1.48785012e-002,
-       4.86173807e-003, 1.84554793e-002, 5.56745492e-002,
-       1.65849879e-001, 8.18048120e-002, 1.90983340e-001,
-       -5.06180935e-002, 1.92048505e-001, 8.92649144e-002,
-       2.40593344e-001, -2.81847315e-004, 1.34121152e-002,
-       5.38507802e-003, 1.94257684e-002, -2.53511779e-003,
-       -1.87167991e-003, 9.39314812e-003, 1.76298805e-002,
-       2.44198050e-002, 9.92514268e-002, 5.53391874e-002,
-       1.77844942e-001, 2.77391430e-002, 1.68157786e-001,
-       5.21966927e-002, 2.06580490e-001, 1.87820673e-003,
-       1.61271375e-002, 5.59474761e-003, 2.13157088e-002,
-       4.79842164e-002, 8.16401169e-002, 6.93023354e-002,
-       9.59987789e-002, 1.39966920e-001, 2.92439789e-001,
-       1.95783034e-001, 3.53520006e-001, -4.31462675e-002,
-       5.92719652e-002, 1.18294060e-001, 1.75542757e-001,
-       -2.46926099e-002, -4.51147510e-003, 3.48235890e-002,
-       3.90887856e-002, 1.79128349e-002, -2.24077012e-002,
-       3.18942703e-002, 5.29178455e-002, 8.16246786e-004,
-       -2.40099996e-001, 1.15737192e-001, 2.77979225e-001,
-       -8.47764686e-002, -2.71941960e-001, 1.43167451e-001,
-       3.31070900e-001, -2.81248298e-002, -3.64504643e-002,
-       4.57100868e-002, 6.20351546e-002, -7.41330325e-004,
-       -1.15322424e-002, 6.11557905e-003, 1.64024942e-002,
-       -4.90107853e-003, -1.00676194e-001, 4.05861177e-002,
-       1.28760725e-001, -9.80801135e-003, -8.14794749e-002,
-       3.51655595e-002, 1.15923129e-001, 2.46347394e-003,
-       -7.77256442e-003, 7.05783768e-003, 1.27796223e-002,
-       -5.54262754e-003, -1.75778440e-003, 1.33497911e-002,
-       7.03146588e-003, -4.52580908e-003, -4.45129946e-002,
-       4.78074998e-002, 8.25360119e-002, 1.64643824e-002,
-       -4.17351983e-002, 4.41454537e-002, 8.82919729e-002,
-       4.07131901e-003, 1.41470949e-003, 1.39201134e-002,
-       8.84434674e-003, -9.38056484e-002, -2.08039116e-002,
-       1.13339886e-001, 3.79471295e-002, -1.00779831e-001,
-       -2.43223503e-001, 2.13953793e-001, 3.11732709e-001,
-       4.21374477e-002, -2.97459841e-001, 2.39999473e-001,
-       3.66988122e-001, 1.77595526e-001, -2.03074012e-002,
-       2.22555608e-001, 4.65260185e-002, -1.00033656e-001,
-       -7.25942338e-003, 1.19283274e-001, 2.11886168e-002,
-       -8.06131363e-002, 5.27100544e-003, 1.73036337e-001,
-       1.02851622e-001, -6.93270378e-003, 1.68878622e-002,
-       2.07953885e-001, 1.25182346e-001, 1.84842780e-001,
-       -1.72524229e-002, 2.38714412e-001, 3.05736866e-002,
-       -1.14301126e-002, -5.31551312e-004, 1.54930428e-002,
-       4.15565819e-003, -4.35662130e-003, 1.64635666e-002,
-       2.92106476e-002, 3.15201804e-002, -1.95261289e-003,
-       2.02018358e-002, 3.12557593e-002, 3.25492620e-002,
-       1.91445593e-002, -6.15759753e-004, 2.60124523e-002,
-       4.02618339e-003, -3.62793775e-003, -1.88346763e-004,
-       5.62443025e-003, 2.85091484e-003, 5.04172547e-003,
-       -1.19298184e-002, 2.27659550e-002, 2.52695512e-002,
-       5.94801176e-003, -1.96608510e-002, 3.02870348e-002,
-       3.00440006e-002, 1.79764070e-002, 1.39723241e-003,
-       2.86098123e-002, 5.31167304e-003, -4.87314239e-002,
-       8.60863831e-003, 5.74382320e-002, 2.91539803e-002,
-       7.61206262e-003, -4.90169972e-003, 1.16425365e-001,
-       1.02615558e-001, 2.69128624e-002, -1.35601265e-002,
-       1.46090373e-001, 9.72044691e-002, 1.70148700e-001,
-       6.20021205e-003, 2.20734060e-001, 2.98856292e-002,
-       -6.36804029e-002, 8.37154463e-002, 6.97877407e-002,
-       9.11362693e-002, -1.02061845e-001, 3.88053477e-001,
-       1.95926920e-001, 4.48968709e-001, 4.54390934e-003,
-       1.76725402e-001, 1.71595857e-001, 2.39962280e-001,
-       1.73737630e-001, 8.99113435e-003, 2.16489568e-001,
-       4.47811522e-002, -8.64268921e-004, 3.10077542e-003,
-       5.82239730e-003, 1.15659116e-002, -1.61019936e-002,
-       1.14252508e-001, 4.13555205e-002, 1.52059078e-001,
-       -3.46456654e-002, 1.69237897e-001, 5.52174896e-002,
-       1.89092413e-001, 4.90377704e-003, 7.44469557e-003,
-       1.53493956e-002, 1.09524289e-002, 4.33953898e-003,
-       1.55449277e-004, 9.81401093e-003, 4.80439747e-003,
-       2.63554207e-003, 2.64467858e-002, 4.17594723e-002,
-       4.24640253e-002, -1.36710871e-002, 3.58879231e-002,
-       5.14536947e-002, 5.74514046e-002, -4.22218582e-003,
-       2.21319191e-004, 8.69288761e-003, 5.69426315e-003,
-       6.02068342e-002, 1.34274526e-003, 9.30348188e-002,
-       2.49307361e-002, 6.32244870e-002, 3.03695165e-002,
-       2.25322291e-001, 1.32796481e-001, -1.35363236e-001,
-       -1.09324791e-001, 3.64196837e-001, 3.08465511e-001,
-       -5.04478924e-002, -1.20183271e-004, 7.30055124e-002,
-       4.67708781e-002, 6.63449988e-002, 5.03359130e-003,
-       8.80245566e-002, 2.10517682e-002, 3.58726494e-002,
-       -7.37824803e-003, 2.04302803e-001, 1.37039423e-001,
-       -2.54635066e-001, 5.31075336e-002, 4.89409238e-001,
-       2.95535803e-001, -2.64205001e-002, -1.14346240e-002,
-       5.57546616e-002, 4.10876386e-002, 4.96127596e-003,
-       5.12153201e-004, 8.74224212e-003, 4.02371679e-003,
-       -5.90661584e-005, -2.33890545e-002, 3.45673822e-002,
-       3.60449590e-002, -2.69707907e-002, -2.54809596e-002,
-       6.22320883e-002, 5.35255261e-002, -1.49507867e-003,
-       3.20149557e-004, 6.66130381e-003, 7.52661610e-003,
-       9.75552131e-004, -8.90539028e-003, 5.89061016e-003,
-       1.18177505e-002, 2.90643238e-002, -9.91650596e-002,
-       4.72457036e-002, 1.15205370e-001, 2.22075451e-002,
-       -5.91444820e-002, 4.60259430e-002, 9.10050198e-002,
-       -2.24469788e-003, -2.09692353e-003, 5.86894620e-003,
-       8.75913724e-003, -2.76828818e-002, 1.32472506e-002,
-       3.98835801e-002, 4.16413508e-002, -2.42399704e-002,
-       -9.49432775e-002, 1.62148342e-001, 2.36022845e-001,
-       1.67443708e-001, -3.63246471e-001, 2.19231576e-001,
-       4.12130594e-001, 2.47723311e-002, -5.49264662e-002,
-       4.33420986e-002, 6.99300244e-002, -2.41134167e-002,
-       2.32923459e-002, 4.26836833e-002, 4.59465943e-002,
-       -2.07575634e-001, 1.32055596e-001, 2.48290241e-001,
-       2.16157719e-001, 1.41033307e-001, 1.70660362e-001,
-       1.97638676e-001, 2.44241953e-001, 2.29847357e-002,
-       2.64914073e-002, 4.05835584e-002, 4.79005575e-002,
-       -5.71614946e-004, 1.68837467e-003, 5.51099516e-003,
-       7.01800920e-003, -1.79012436e-002, 4.83867526e-002,
-       4.31310199e-002, 6.43281490e-002, 1.85527634e-002,
-       4.63168100e-002, 4.50736210e-002, 6.59679398e-002,
-       -3.28322669e-004, 2.37414963e-003, 5.51500265e-003,
-       7.48978881e-003, -1.13122608e-003, -1.59911544e-003,
-       5.15985256e-003, 5.90146193e-003, -9.74682625e-003,
-       -3.46526764e-002, 3.23192589e-002, 5.33674248e-002,
-       -3.70967551e-003, -3.25897373e-002, 2.84731314e-002,
-       5.36606200e-002, 5.06607001e-004, -2.74912897e-003,
-       4.88145556e-003, 7.21981050e-003, -2.50673443e-002,
-       1.10549098e-002, 4.48444337e-002, 3.87453139e-002,
-       -9.50505659e-002, 3.64706293e-002, 2.09245935e-001,
-       2.59839475e-001, -3.15295742e-003, 2.93734241e-002,
-       1.56220660e-001, 2.33845100e-001, 2.14202441e-002,
-       5.75616583e-003, 4.09482904e-002, 3.77559774e-002,
-       -2.27497313e-002, 1.47756673e-002, 4.85600829e-002,
-       3.53253335e-002, -1.87664092e-001, -1.15620256e-004,
-       3.47034156e-001, 3.20692241e-001, 1.19390339e-001,
-       9.77379605e-002, 2.68479854e-001, 4.91407037e-001,
-       1.72696672e-002, 2.93582659e-002, 4.28602137e-002,
-       5.83193526e-002, -1.13582693e-003, 5.60694549e-004,
-       6.25597034e-003, 4.81882691e-003, -7.68804550e-003,
-       4.71744277e-002, 4.85571697e-002, 6.24863915e-002,
-       1.80463940e-002, 3.36503424e-002, 4.09602113e-002,
-       6.01952896e-002, -1.37766474e-003, 3.07371374e-004,
-       5.57053834e-003, 5.95340226e-003, -3.23188072e-003,
-       -4.60453797e-003, 9.42326058e-003, 1.06439041e-002,
-       6.16172515e-003, -9.28222314e-002, 4.73512746e-002,
-       1.27958328e-001, 3.07338405e-002, -6.23625852e-002,
-       4.97863777e-002, 1.13385387e-001, -5.96807280e-004,
-       1.41286419e-003, 7.00194202e-003, 1.03857536e-002,
-       -9.32527781e-002, -1.54472174e-004, 1.11272775e-001,
-       4.40242477e-002, -8.00707191e-002, -8.30981284e-002,
-       1.99194193e-001, 2.51533985e-001, 3.06384206e-001,
-       -2.77822554e-001, 3.43120307e-001, 3.57510000e-001,
-       3.16575803e-002, -6.11487553e-002, 5.71254790e-002,
-       7.57751688e-002, -9.10836607e-002, 1.36194378e-002,
-       1.13430284e-001, 3.66913266e-002, -1.07445017e-001,
-       1.90828979e-001, 1.99616417e-001, 2.33710185e-001,
-       4.33604009e-002, 1.22935690e-001, 1.36940032e-001,
-       1.96233600e-001, 3.50361802e-002, -7.48341950e-003,
-       4.62701395e-002, 3.75838317e-002, -6.48028543e-003,
-       5.88972645e-004, 1.20590851e-002, 5.60918218e-003,
-       -1.27907628e-002, 2.71686818e-002, 3.51582244e-002,
-       4.22004014e-002, -1.89794227e-003, 3.30020860e-002,
-       2.33328491e-002, 4.32423204e-002, 1.47878518e-003,
-       3.39246728e-003, 4.69856011e-003, 5.94115118e-003,
-       9.55132581e-003, 2.15499708e-003, 1.49380341e-002,
-       7.03370944e-003, -3.16139162e-002, 5.31317443e-002,
-       6.51054829e-002, 7.41591603e-002, -1.83096752e-002,
-       4.18510325e-002, 4.03063260e-002, 8.19547847e-002,
-       2.75286217e-003, 3.78870079e-003, 5.92775783e-003,
-       1.02996733e-002, 1.44980550e-001, -5.44255367e-003,
-       1.72327906e-001, 3.74251604e-002, 1.13354847e-002,
-       2.03917816e-001, 2.64879614e-001, 2.64799118e-001,
-       -5.75669855e-002, 3.98982853e-001, 1.51757866e-001,
-       4.33211207e-001, -1.79364346e-002, 5.26980460e-002,
-       3.78777087e-002, 6.18029125e-002, 1.51882887e-001,
-       -5.33180870e-003, 1.82432368e-001, 3.20830904e-002,
-       1.10796846e-001, -6.76282123e-002, 2.50506938e-001,
-       1.43943563e-001, -2.57883891e-002, -8.06501657e-002,
-       1.18651308e-001, 1.52939022e-001, -1.82865579e-002,
-       -2.96240323e-003, 2.99782939e-002, 2.48595700e-002,
-       1.56129431e-002, 1.06136920e-003, 2.14185007e-002,
-       5.01225749e-003, 9.19520669e-003, -1.99501496e-002,
-       4.90558110e-002, 3.44220363e-002, 1.40875287e-003,
-       -2.09451839e-002, 2.46716887e-002, 3.27798091e-002,
-       -8.95869569e-004, -1.65809214e-003, 4.01698193e-003,
-       4.13006777e-003, -1.01093133e-003, 2.75056879e-003,
-       3.80560663e-003, 5.68798371e-003, 1.02286576e-003,
-       2.42391564e-002, 2.43934002e-002, 4.08867113e-002,
-       2.52700225e-002, 2.95370743e-002, 3.89812626e-002,
-       4.32503857e-002, -7.34390167e-004, 2.62236292e-003,
-       5.18507138e-003, 5.45468600e-003, 2.49237753e-002,
-       3.59755009e-002, 3.57055366e-002, 4.80251238e-002,
-       -9.28272586e-003, 3.73590291e-001, 1.52778789e-001,
-       3.95874709e-001, 5.60876578e-002, 2.41749346e-001,
-       1.79572180e-001, 2.80102879e-001, -3.42387855e-002,
-       1.19087165e-002, 4.52542379e-002, 3.33844349e-002,
-       2.72192582e-002, -4.73960936e-002, 3.80094461e-002,
-       5.58599532e-002, 9.14752334e-002, -3.30771327e-001,
-       1.70150340e-001, 3.62137914e-001, 2.46107369e-003,
-       -1.33768618e-001, 1.63554952e-001, 1.94718644e-001,
-       -3.82096432e-002, -1.05312290e-002, 4.95080389e-002,
-       2.77470127e-002, -7.09535554e-004, -4.57331305e-004,
-       3.75698856e-003, 5.12724183e-003, 1.76548380e-002,
-       -2.42766943e-002, 3.08282375e-002, 4.51764241e-002,
-       2.33527198e-002, -3.71615663e-002, 4.17157039e-002,
-       4.92761694e-002, -2.30138307e-003, -2.26810621e-003,
-       5.71692083e-003, 5.31189749e-003, 2.67166062e-003,
-       -3.73991061e-004, 3.75068234e-003, 2.93837790e-003,
-       3.64309773e-002, -2.74607986e-002, 4.46797200e-002,
-       3.41875367e-002, 1.08133569e-001, -8.13693553e-002,
-       1.16576463e-001, 9.11385864e-002, 3.33198230e-004,
-       -1.08414644e-003, 1.14685437e-002, 6.63078111e-003,
-       6.17290940e-003, 7.96602014e-003, 1.89287458e-002,
-       1.55329155e-002, 6.77400678e-002, 1.74569786e-002,
-       1.23158120e-001, 1.09403059e-001, 1.81371406e-001,
-       -2.65786201e-001, 3.29789102e-001, 3.01108032e-001,
-       2.10208803e-001, -3.27741131e-002, 2.34483868e-001,
-       4.69385460e-002, 9.92077496e-003, 2.31616627e-002,
-       1.96031667e-002, 2.53477786e-002, 2.83630528e-002,
-       1.67934045e-001, 1.23776816e-001, 1.86014876e-001,
-       -1.07217468e-001, 4.78840508e-002, 3.01611781e-001,
-       1.10303268e-001, 2.78605163e-001, -5.62937697e-003,
-       2.91855454e-001, 2.76518017e-002, 4.02141502e-003,
-       -4.32653585e-004, 4.96540451e-003, 8.63949955e-003,
-       2.09528394e-002, 4.57991995e-002, 3.84368896e-002,
-       8.32659304e-002, -2.29912791e-002, 1.16028056e-001,
-       7.08428472e-002, 1.46314681e-001, 2.76465919e-002,
-       4.18593688e-003, 3.03247031e-002, 1.05717015e-002,
-       4.10556931e-005, 5.47782065e-006, 3.95056186e-003,
-       4.04823059e-003, 2.48663709e-003, -1.10447546e-003,
-       2.28779204e-002, 3.75634134e-002, 8.55020527e-003,
-       5.35290572e-004, 2.30089277e-002, 4.16131169e-002,
-       1.51798292e-003, 1.40665704e-003, 4.17345529e-003,
-       5.93227707e-003, 1.25975460e-002, 2.09615082e-002,
-       3.68420705e-002, 4.22667563e-002, -1.37527718e-003,
-       2.35657588e-001, 1.55803815e-001, 3.57747465e-001,
-       1.34922080e-002, 1.36216670e-001, 1.85031071e-001,
-       3.30672264e-001, 9.84616298e-003, 1.38099836e-002,
-       4.47650515e-002, 4.60116789e-002, 1.10337585e-002,
-       -2.76449379e-002, 3.56586464e-002, 4.48397137e-002,
-       7.04698712e-002, -2.11448580e-001, 2.04768091e-001,
-       3.42265189e-001, 1.70449346e-001, 1.27650738e-001,
-       2.87436396e-001, 3.21916699e-001, 2.67925818e-004,
-       2.74900999e-002, 4.16759774e-002, 4.19275425e-002,
-       3.73615156e-004, 2.42786948e-003, 4.27396083e-003,
-       5.30246366e-003, 2.51244120e-002, 2.84993127e-002,
-       4.11799513e-002, 5.78130744e-002, 2.83711068e-002,
-       -2.42636236e-003, 4.47621085e-002, 5.29692881e-002,
-       2.65599636e-004, -1.80040416e-003, 3.82724754e-003,
-       4.17712703e-003, 2.34807003e-003, 2.77095212e-004,
-       4.62996820e-003, 5.12624998e-003, -7.19377119e-003,
-       1.87041815e-002, 3.97229008e-002, 5.26629277e-002,
-       -2.02921834e-002, 8.60368425e-004, 4.04450782e-002,
-       5.12271263e-002, 1.35356234e-003, -4.30489366e-004,
-       4.87988582e-003, 5.14057418e-003, 8.22671968e-003,
-       -1.35106025e-002, 4.54730168e-002, 3.81248146e-002,
-       9.81493071e-002, -1.79034114e-001, 2.66553134e-001,
-       3.09897155e-001, -1.42210439e-001, 1.31674901e-001,
-       2.73030788e-001, 2.80651361e-001, 6.77522318e-003,
-       1.20072579e-002, 4.40188348e-002, 4.16769423e-002,
-       -6.40941411e-003, 4.61748755e-003, 4.04526778e-002,
-       3.11206914e-002, 2.52262622e-001, 1.15549415e-001,
-       3.84186387e-001, 2.34998673e-001, -2.13781055e-002,
-       1.14923038e-001, 2.41579622e-001, 2.27980331e-001,
-       -1.16300052e-002, 1.63994469e-002, 4.59515490e-002,
-       3.72152030e-002, 1.52303849e-003, 1.45126821e-003,
-       4.63301130e-003, 4.15345561e-003, 2.44043134e-002,
-       8.68704449e-003, 4.41613607e-002, 3.91413718e-002,
-       3.54443304e-003, 8.01682705e-004, 3.27797346e-002,
-       3.50313410e-002, -1.84986612e-003, 1.71697733e-003,
-       4.99306992e-003, 4.68960544e-003, 5.10395411e-003,
-       1.12266594e-003, 7.95055367e-003, 5.27536031e-003,
-       -7.57039478e-003, 7.03711286e-002, 5.17709889e-002,
-       8.50789919e-002, -1.31171839e-002, 9.27046090e-002,
-       2.70829275e-002, 1.16086178e-001, -1.10728643e-003,
-       6.78000087e-003, 4.10181563e-003, 1.25275850e-002,
-       3.92752513e-002, -1.00238752e-002, 4.91716564e-002,
-       3.16047184e-002, 2.03195602e-001, -1.82169795e-001,
-       2.97130466e-001, 3.77565503e-001, -6.67669177e-002,
-       -1.93542019e-001, 1.79359004e-001, 4.75757062e-001,
-       -2.66502462e-002, -1.14176208e-002, 4.43411395e-002,
-       6.14481196e-002, 3.81181203e-002, -3.26797381e-005,
-       4.80438136e-002, 2.36879606e-002, 1.11288942e-001,
-       3.48286494e-003, 2.27431878e-001, 1.90528676e-001,
-       -1.25602216e-001, -6.69063702e-002, 1.85061336e-001,
-       1.95893630e-001, -7.42678856e-003, -1.60704926e-002,
-       3.37194391e-002, 2.70600822e-002, 4.18965518e-003,
-       1.48338091e-004, 5.02062310e-003, 3.64479865e-003,
-       8.28680862e-003, -2.68084295e-002, 2.90694311e-002,
-       3.60291637e-002, -1.97898000e-002, -2.73845606e-002,
-       3.01895179e-002, 3.74379307e-002, 1.65482739e-003,
-       -1.21066475e-003, 5.50704496e-003, 4.84648440e-003,
-       -4.33636684e-004, -7.44459277e-004, 3.94829642e-003,
-       3.67998611e-003, -3.16428253e-003, -1.23588275e-002,
-       1.90968644e-002, 2.38851346e-002, 1.92771647e-002,
-       -1.09582916e-002, 3.41539122e-002, 2.25507524e-002,
-       4.60080989e-003, 7.52920401e-004, 7.39393430e-003,
-       2.97898776e-003, -1.51508469e-002, -1.17048062e-003,
-       3.19115780e-002, 2.38144509e-002, -2.15194542e-002,
-       -2.44621597e-002, 1.19461842e-001, 1.27884537e-001,
-       1.78868875e-001, -7.44976755e-003, 2.60074824e-001,
-       1.28004327e-001, 3.83862257e-002, 6.32318482e-003,
-       5.79544380e-002, 2.40111127e-002, -1.79503746e-002,
-       2.28224285e-002, 4.06474508e-002, 6.12009056e-002,
-       -5.06392270e-002, 1.53149456e-001, 1.54557079e-001,
-       5.09295106e-001, 2.45041743e-001, 1.43610314e-001,
-       3.16570759e-001, 4.40626770e-001, 2.78763995e-002,
-       5.32171829e-003, 4.93583493e-002, 4.13649194e-002,
-       1.57954777e-003, 1.07760029e-003, 4.96343384e-003,
-       7.55449291e-003, 4.80425690e-004, 2.32400596e-002,
-       3.19367796e-002, 5.81250563e-002, 9.73290019e-003,
-       2.85761934e-002, 3.31349038e-002, 5.40119149e-002,
-       1.33447276e-004, 8.12836806e-004, 3.99384694e-003,
-       4.21616202e-003, -1.47391688e-002, 1.72297133e-003,
-       3.12173609e-002, 7.07013858e-003, -5.82329109e-002,
-       -2.15702318e-002, 9.08551663e-002, 4.00014073e-002,
-       4.33203857e-003, -1.08790891e-002, 2.37658843e-002,
-       2.57260334e-002, 7.98967609e-004, -1.14245142e-003,
-       3.94765334e-003, 3.69218644e-003, -1.98778823e-001,
-       -4.41241488e-002, 2.98409015e-001, 6.40694946e-002,
-       -1.89635694e-001, -6.78242370e-002, 3.78329486e-001,
-       1.87878832e-001, 5.97293489e-003, -2.32063439e-002,
-       1.27965108e-001, 1.47664696e-001, 1.17157875e-002,
-       -6.07482763e-003, 2.62415819e-002, 2.16520187e-002,
-       -1.71669662e-001, -4.47521992e-002, 2.20215708e-001,
-       7.38954842e-002, -3.48993428e-002, 1.42397076e-001,
-       1.92921251e-001, 3.21413517e-001, -6.03389181e-003,
-       1.38844386e-001, 1.21871471e-001, 2.69907624e-001,
-       6.37554144e-003, 1.15966899e-002, 2.02802774e-002,
-       3.54737565e-002, -6.04110071e-003, 9.51711647e-003,
-       1.43136196e-002, 1.62586197e-002, 4.49610502e-003,
-       1.11716680e-001, 3.22493948e-002, 1.58570990e-001,
-       -9.68908984e-003, 1.13486364e-001, 2.82335114e-002,
-       1.54994935e-001, -3.18851415e-003, 1.28238723e-002,
-       5.30577404e-003, 1.79843754e-002, 7.11071771e-003,
-       -3.52058606e-003, 2.03536265e-002, 7.72427395e-003,
-       2.15592887e-002, 1.68594569e-002, 4.18753251e-002,
-       2.86639072e-002, -3.02520711e-002, 1.98839288e-002,
-       4.53059636e-002, 4.42835055e-002, -9.13450401e-003,
-       4.76457935e-004, 1.69408992e-002, 9.97602846e-003,
-       1.41764104e-001, 5.15141478e-003, 1.94425419e-001,
-       6.22507446e-002, 1.15205258e-001, 3.59149948e-002,
-       2.08755672e-001, 1.02138795e-001, -1.71665028e-001,
-       -8.46340973e-003, 2.51106799e-001, 1.65522709e-001,
-       -9.96977165e-002, -5.35712503e-002, 1.15049332e-001,
-       9.14267823e-002, 1.39870718e-001, 2.86286697e-002,
-       1.72552884e-001, 4.75914739e-002, 5.77459335e-002,
-       5.26575372e-003, 1.35833159e-001, 7.42807910e-002,
-       -4.46265727e-001, -8.77772942e-002, 4.99511510e-001,
-       1.59517944e-001, -5.88605963e-002, -1.48461219e-002,
-       8.89199302e-002, 3.88230830e-002, 1.14193568e-002,
-       1.38791231e-003, 1.51903238e-002, 4.59819380e-003,
-       7.25835888e-003, -6.32820046e-003, 2.52129119e-002,
-       1.46629997e-002, -8.27691182e-002, -1.75622460e-002,
-       9.11385641e-002, 2.96891686e-002, -2.45597749e-003,
-       1.00927777e-003, 8.76131468e-003, 4.57453355e-003,
-       -4.93178749e-003, -7.31408290e-005, 9.66112595e-003,
-       4.68234764e-003, 1.61515512e-002, -5.03954897e-003,
-       3.99988331e-002, 3.58376093e-002, -6.63255900e-003,
-       4.89252619e-003, 3.74410823e-002, 2.93498393e-002,
-       8.28131195e-003, 1.51007471e-003, 1.21374186e-002,
-       4.97961044e-003, -6.65398017e-002, 1.59550458e-002,
-       1.13623343e-001, 3.46256085e-002, 2.14014709e-001,
-       1.61933750e-001, 3.55306000e-001, 2.51409173e-001,
-       -8.11822191e-002, 7.68863708e-002, 3.21733654e-001,
-       1.67033285e-001, 4.53073718e-002, 5.10452082e-003,
-       1.00489639e-001, 2.74773519e-002, -4.37942632e-002,
-       -3.40804062e-003, 8.89402777e-002, 3.37117650e-002,
-       4.47437763e-002, -2.81216726e-002, 2.58164406e-001,
-       3.49774599e-001, -6.39286637e-002, -1.23526208e-001,
-       2.74275333e-001, 2.62451440e-001, 4.95370030e-002,
-       -5.71349263e-003, 9.66437012e-002, 3.21820118e-002,
-       9.23754415e-004, 1.82924920e-003, 6.48164749e-003,
-       6.67320564e-003, -6.10130373e-004, 3.79292890e-002,
-       2.63262782e-002, 9.11339521e-002, -1.61599293e-002,
-       4.68499735e-002, 4.48870510e-002, 9.57465619e-002,
-       1.15937192e-003, -8.37466447e-004, 8.09020270e-003,
-       7.40146637e-003, -2.62043846e-004, 1.00936498e-002,
-       5.11721009e-003, 1.35020781e-002, -2.92811450e-002,
-       1.01758987e-001, 3.77682410e-002, 1.11194298e-001,
-       -1.13735469e-002, 6.41069934e-002, 2.58408673e-002,
-       7.99148679e-002, 7.27974519e-004, 2.39935541e-003,
-       3.63809220e-003, 7.04846019e-003, 2.07270309e-002,
-       -1.25295352e-002, 2.95236260e-002, 4.57613282e-002,
-       -2.07316922e-003, -2.93783378e-002, 1.31984964e-001,
-       3.91419083e-001, -9.77345705e-002, 1.66298375e-001,
-       1.79805458e-001, 5.54704130e-001, -3.15360092e-002,
-       3.90634015e-002, 3.94621342e-002, 6.86925277e-002,
-       1.09174149e-002, -2.15613022e-002, 2.34835073e-002,
-       3.38322632e-002, 3.81164961e-002, -1.94510162e-001,
-       1.09637350e-001, 2.57138491e-001, -1.36892227e-002,
-       -2.16829911e-001, 1.17310353e-001, 2.88594693e-001,
-       -2.49721631e-002, -2.77375318e-002, 3.44741754e-002,
-       4.24770452e-002, -5.48975717e-004, -3.81111004e-003,
-       3.38943605e-003, 5.85174467e-003, 2.41730642e-003,
-       -3.17363441e-002, 2.04946380e-002, 4.54392880e-002,
-       -4.35311580e-003, -3.56048420e-002, 2.22886987e-002,
-       4.47486006e-002, -7.32227229e-004, -4.32862714e-003,
-       3.51722399e-003, 6.16371445e-003, 2.97816121e-003,
-       1.49872969e-003, 7.14136194e-003, 4.74884920e-003,
-       -2.45376732e-002, 2.87135486e-002, 4.19487022e-002,
-       3.96280251e-002, -1.65858455e-002, 1.65805407e-002,
-       3.48681137e-002, 3.43850926e-002, -2.08284915e-003,
-       2.34739578e-004, 6.07172726e-003, 4.10529925e-003,
-       5.35812639e-002, -7.81466160e-003, 6.65266737e-002,
-       3.10774390e-002, -1.11255817e-001, 1.07682750e-001,
-       2.56251693e-001, 1.86541095e-001, -1.38894022e-001,
-       2.09005207e-001, 2.19032422e-001, 2.56047845e-001,
-       -4.34675775e-002, 1.31105436e-002, 5.83447777e-002,
-       3.14093567e-002, 3.78959365e-002, -3.46550904e-002,
-       5.54147437e-002, 4.74134497e-002, 1.34141728e-001,
-       -3.22357714e-001, 2.24988431e-001, 3.87486458e-001,
-       -1.34002790e-001, -1.53068766e-001, 2.38351449e-001,
-       3.32072198e-001, -5.05038798e-002, -9.94181726e-003,
-       6.60036951e-002, 3.84027623e-002, -8.47181189e-004,
-       3.59772122e-004, 4.80589224e-003, 5.27808676e-003,
-       8.12687539e-003, -2.05225106e-002, 3.02825719e-002,
-       4.68006879e-002, 1.68419885e-003, -3.36409286e-002,
-       3.16737518e-002, 5.48659228e-002, -1.54406461e-003,
-       -8.36964638e-004, 5.65440999e-003, 5.47827827e-003,
-       3.00389202e-003, -3.06106318e-004, 5.14835073e-003,
-       3.02027981e-003, 1.08462451e-002, 7.43671134e-003,
-       2.71571334e-002, 1.74016990e-002, -2.43979711e-002,
-       8.50206241e-003, 7.44743273e-002, 1.83573831e-002,
-       -8.00927542e-003, -6.14359917e-004, 1.11945905e-002,
-       2.86742463e-003, 3.28906700e-002, -1.61029063e-002,
-       4.35687043e-002, 2.74938829e-002, 9.10242498e-002,
-       -1.10601801e-002, 1.68122098e-001, 9.89660993e-002,
-       -1.29666388e-001, 2.39968225e-002, 4.92402226e-001,
-       1.00435413e-001, -8.03612247e-002, 1.31913612e-003,
-       1.00387573e-001, 2.01334953e-002, 2.37573069e-002,
-       -3.17599438e-002, 4.23502102e-002, 3.98889296e-002,
-       2.23776594e-001, -2.20729858e-001, 2.73362547e-001,
-       2.54373699e-001, -5.18934689e-002, -6.52114153e-002,
-       4.68709916e-001, 1.45166174e-001, -9.58235189e-002,
-       7.99281523e-003, 1.11666873e-001, 2.11845301e-002,
-       -1.39860599e-003, -2.96385551e-005, 4.89919307e-003,
-       4.07125708e-003, 3.74374166e-002, -3.08716018e-002,
-       4.93756905e-002, 4.39082533e-002, 1.43590383e-002,
-       -4.02882919e-002, 6.35192096e-002, 4.96096760e-002,
-       -1.03798257e-002, 6.58471254e-004, 1.26773585e-002,
-       4.19083657e-003, 1.97935943e-003, -3.44666303e-003,
-       6.54494623e-003, 7.27041019e-003, 1.13139413e-002,
-       -8.11877325e-002, 4.89027761e-002, 9.53832939e-002,
-       5.05181216e-002, -7.91750625e-002, 6.72292486e-002,
-       9.49235186e-002, 3.99956596e-004, 6.22697757e-004,
-       5.42188901e-003, 5.40932221e-003, -1.96601469e-002,
-       -1.16167329e-002, 3.91390398e-002, 2.99727656e-002,
-       -5.87646589e-002, -9.81272236e-002, 1.56825334e-001,
-       1.80357799e-001, 4.74902958e-001, -1.99814215e-001,
-       4.99063253e-001, 2.82205552e-001, 3.64755429e-002,
-       -3.81739102e-002, 6.49431571e-002, 5.22781722e-002,
-       -2.28802413e-002, -7.20346812e-004, 3.82376574e-002,
-       2.37834360e-002, -3.97987962e-002, 9.55879129e-003,
-       1.24405347e-001, 1.10679835e-001, 1.28395125e-001,
-       -1.15691483e-001, 2.02092052e-001, 2.04338461e-001,
-       6.84544817e-002, -5.39530963e-002, 8.23058784e-002,
-       6.97960779e-002, -1.53873605e-003, -2.94656144e-004,
-       4.20436403e-003, 3.45851947e-003, -5.08013275e-003,
-       1.07644657e-002, 2.08901092e-002, 2.44327486e-002,
-       7.64348172e-003, 1.45210959e-002, 2.41600592e-002,
-       2.71458272e-002, 5.41709270e-003, -6.15599449e-004,
-       7.94671569e-003, 5.98494662e-003, 4.65579651e-004,
-       -4.41344164e-004, 4.85925190e-003, 4.49044490e-003,
-       -1.43764904e-002, -3.29540707e-002, 3.48185636e-002,
-       4.77364026e-002, 1.36153838e-002, -3.15263122e-002,
-       3.32035907e-002, 4.66542169e-002, 2.46289768e-004,
-       -3.09562049e-004, 4.26112721e-003, 4.29023243e-003,
-       -3.63339745e-002, -3.41698453e-002, 5.31568117e-002,
-       4.65337932e-002, -1.70916304e-001, -2.85818875e-001,
-       2.51899332e-001, 3.40039730e-001, 1.82642981e-001,
-       -2.67032534e-001, 2.41203398e-001, 3.23687077e-001,
-       3.51611078e-002, -3.36484201e-002, 4.85713854e-002,
-       4.57657948e-002, -4.70421165e-002, -2.58738827e-003,
-       5.88250794e-002, 3.73075008e-002, 2.67620571e-002,
-       1.86962336e-001, 1.94747463e-001, 2.49060169e-001,
-       2.20354274e-002, 2.06460759e-001, 1.73167154e-001,
-       2.60169595e-001, 4.17118333e-002, 3.83001473e-003,
-       5.19390628e-002, 3.56087275e-002, -1.66220951e-003,
-       1.55541569e-003, 6.27521239e-003, 5.39341057e-003,
-       1.44354226e-002, 2.59734448e-002, 3.86290587e-002,
-       4.35895063e-002, -5.58670470e-003, 2.35421956e-002,
-       3.47469486e-002, 4.16458435e-002, 1.27607642e-003,
-       1.25204143e-003, 5.58253936e-003, 5.11964597e-003,
-       -8.79896805e-003, 1.32707029e-003, 1.58960950e-002,
-       6.95422990e-003, -8.09610821e-003, -1.52166253e-002,
-       4.37026769e-002, 6.16802536e-002, 1.29686494e-003,
-       -1.02687422e-002, 4.49863002e-002, 6.10742122e-002,
-       -7.77885201e-004, 2.18779128e-003, 5.62580070e-003,
-       7.27037154e-003, -1.16848961e-001, -3.62931471e-003,
-       1.82427138e-001, 4.29307297e-002, -2.06548311e-002,
-       5.08054718e-002, 2.59953439e-001, 4.73318636e-001,
-       5.84108531e-002, -5.12373745e-002, 2.48354018e-001,
-       2.62310624e-001, 1.96785182e-002, -2.14768834e-002,
-       4.71662357e-002, 4.73994240e-002, -1.12921819e-001,
-       -7.33608287e-003, 1.82605147e-001, 4.41734903e-002,
-       6.26856983e-002, -2.98760533e-002, 2.77407527e-001,
-       3.34598958e-001, -4.76339906e-002, 4.63109314e-002,
-       2.02058733e-001, 2.07075343e-001, 9.82822292e-003,
-       6.93875831e-003, 3.57035361e-002, 3.84088606e-002,
-       -5.53745404e-003, 2.68868520e-003, 1.64885707e-002,
-       9.69096273e-003, 1.54967129e-003, 5.56757748e-002,
-       4.89524864e-002, 7.89220929e-002, 1.04932196e-003,
-       5.74533790e-002, 3.26015465e-002, 8.21767896e-002,
-       1.67489704e-003, 7.95653462e-003, 4.17469302e-003,
-       1.08131645e-002, -2.78737396e-003, 1.87240040e-003,
-       6.72812341e-003, 3.79101816e-003, -2.39625107e-002,
-       -9.98353958e-003, 4.42876220e-002, 2.60762703e-002,
-       4.79949219e-003, -1.28846345e-002, 2.97820233e-002,
-       2.79311668e-002, 3.31939384e-003, 5.44925046e-004,
-       6.80438196e-003, 4.41580685e-003, -2.87333485e-002,
-       2.51034624e-003, 5.40246814e-002, 2.17476021e-002,
-       -2.03958690e-001, 1.50280371e-002, 3.31114501e-001,
-       1.56416982e-001, 6.33608848e-002, 4.85296808e-002,
-       2.15028211e-001, 1.53501630e-001, 4.10871096e-002,
-       2.13674530e-002, 6.18381985e-002, 3.58793773e-002,
-       -3.77763584e-002, -8.23731709e-004, 5.85008599e-002,
-       2.22142860e-002, -6.24908246e-002, 3.08758672e-002,
-       3.90569985e-001, 1.64647862e-001, 9.42505449e-002,
-       1.39041662e-001, 5.43623686e-001, 2.21617579e-001,
-       3.05598676e-002, 2.31016688e-002, 6.78352788e-002,
-       3.71151343e-002, -4.70380578e-003, -6.42093364e-004,
-       7.52448570e-003, 3.37966997e-003, -1.29945902e-003,
-       1.84150226e-002, 5.70950843e-002, 3.54518704e-002,
-       2.25953553e-002, 1.83126777e-002, 7.86346644e-002,
-       3.78185399e-002, 1.10629352e-003, -1.16096344e-003,
-       7.71018956e-003, 4.49743588e-003, -8.45809642e-004,
-       -4.56593325e-003, 6.13682158e-003, 9.68991034e-003,
-       -3.31893377e-003, -5.80651648e-002, 3.85785662e-002,
-       8.72055590e-002, -3.07695544e-003, -6.47175014e-002,
-       3.73481028e-002, 9.16496739e-002, 1.93981477e-003,
-       -4.58307983e-003, 8.82959273e-003, 9.92925558e-003,
-       -3.08368262e-002, -2.25585233e-002, 4.86216135e-002,
-       4.17394117e-002, -1.15440533e-001, -2.36366421e-001,
-       2.02344060e-001, 2.92098999e-001, 4.87179607e-002,
-       -2.28496403e-001, 1.85947210e-001, 2.93665767e-001,
-       6.05125651e-002, -1.30459424e-002, 8.14412534e-002,
-       4.30663303e-002, -3.56248729e-002, 2.13223509e-002,
-       5.39118722e-002, 5.02406061e-002, -1.71931773e-001,
-       1.28153414e-001, 2.40247846e-001, 3.11559170e-001,
-       7.53823817e-002, 5.04223369e-002, 2.24586472e-001,
-       2.67523140e-001, 6.48993030e-002, 1.22191280e-003,
-       8.47725943e-002, 4.28443365e-002, 2.42244045e-004,
-       6.35466911e-003, 6.81659766e-003, 1.19800055e-002,
-       -1.48605043e-002, 1.03433132e-001, 4.57069650e-002,
-       1.38330221e-001, -1.17139947e-002, 1.18388183e-001,
-       4.55854647e-002, 1.46206930e-001, 2.53734039e-003,
-       7.75874546e-003, 9.19829775e-003, 1.30278040e-002,
-       -4.60278883e-004, 1.80898991e-004, 4.59211180e-003,
-       3.18889972e-003, -2.51087565e-002, -2.82430407e-002,
-       4.62506078e-002, 4.46346812e-002, 2.67560012e-003,
-       -3.89389060e-002, 3.45505066e-002, 5.71106039e-002,
-       5.85017515e-005, -1.72228087e-003, 5.07401209e-003,
-       6.05732249e-003, -2.02398822e-002, -6.66680094e-003,
-       4.46861386e-002, 2.40154602e-002, -2.76327342e-001,
-       -1.28294885e-001, 3.82719606e-001, 2.57636011e-001,
-       1.24548286e-001, 3.85902897e-002, 2.17263803e-001,
-       3.23281407e-001, 1.62646864e-002, -8.28004035e-004,
-       3.73357981e-002, 4.15418074e-002, -2.80726869e-002,
-       -1.35913130e-003, 5.04260696e-002, 2.30060630e-002,
-       -2.22478181e-001, 1.40157342e-002, 3.78087491e-001,
-       1.80817455e-001, 1.00551195e-001, -1.10080399e-001,
-       2.00790122e-001, 2.49718189e-001, 1.75035521e-002,
-       -1.10985646e-002, 3.73217836e-002, 3.72580178e-002,
-       -3.62777687e-003, -1.46768708e-003, 7.27092242e-003,
-       3.68944323e-003, -2.66007371e-002, 1.41701773e-002,
-       4.92532589e-002, 3.30297463e-002, 4.54383111e-003,
-       1.69439558e-002, 2.94590667e-002, 3.35752517e-002,
-       1.24395418e-003, -1.09734072e-004, 4.71779518e-003,
-       4.46122373e-003, -3.63622396e-003, -7.52761168e-003,
-       1.32953888e-002, 1.62517913e-002, -1.77829847e-004,
-       -1.03208624e-001, 5.05455844e-002, 1.55822262e-001,
-       -2.33560093e-002, -8.16735104e-002, 3.86324599e-002,
-       1.33025229e-001, 1.96353602e-003, -7.72255100e-003,
-       5.17343637e-003, 1.46187674e-002, -1.23140708e-001,
-       5.71334325e-002, 1.73660502e-001, 1.00092813e-001,
-       -3.02082151e-002, -1.17621869e-001, 1.72237575e-001,
-       2.59130329e-001, -4.09268215e-002, -1.38341516e-001,
-       1.43492833e-001, 2.44333208e-001, 1.83457993e-002,
-       -1.26208737e-002, 3.36469449e-002, 3.47530544e-002,
-       -1.63730621e-001, -2.72463076e-002, 2.09712967e-001,
-       1.08281694e-001, -9.21715349e-002, -4.68866229e-002,
-       2.51610160e-001, 3.55649918e-001, 1.08303331e-001,
-       9.22282934e-002, 2.11930439e-001, 2.23428234e-001,
-       2.09839568e-002, 3.68121713e-002, 3.69850770e-002,
-       4.60800603e-002, -9.07868263e-004, 4.14665509e-003,
-       1.68643482e-002, 2.57156193e-002, -6.55339211e-002,
-       1.42212629e-001, 1.11357175e-001, 1.93707287e-001,
-       1.46038085e-002, 4.46341895e-002, 4.82161902e-002,
-       7.85841569e-002, 3.05223628e-004, 7.60014169e-004,
-       5.78378653e-003, 8.15208256e-003, 6.32282638e-004,
-       -3.44030734e-004, 9.84863006e-003, 1.87262408e-002,
-       -2.75156777e-002, -1.26734376e-001, 4.86639589e-002,
-       2.79387534e-001, 7.24973343e-003, -2.03455016e-001,
-       4.54863906e-002, 3.56008738e-001, -1.53053214e-003,
-       -2.75175553e-002, 1.18604740e-002, 3.73181142e-002,
-       -3.94964330e-002, -8.31912160e-002, 7.03688562e-002,
-       9.80356187e-002, -1.74284831e-001, -1.71088547e-001,
-       2.55501658e-001, 3.21338028e-001, 8.52759257e-002,
-       -3.30499373e-002, 1.42558530e-001, 1.63774282e-001,
-       5.24554700e-002, -9.10147559e-004, 5.95341288e-002,
-       3.71854715e-002, -3.75895202e-002, 6.56894967e-002,
-       6.55314103e-002, 8.60054046e-002, -1.65891096e-001,
-       1.77704766e-001, 2.29466915e-001, 2.80774266e-001,
-       4.49911058e-002, 4.60568666e-002, 1.15966320e-001,
-       1.50826842e-001, 4.19541188e-002, -3.75478342e-003,
-       4.75504361e-002, 2.83611864e-002, -3.25990841e-003,
-       3.73824936e-004, 1.09981820e-002, 1.00738900e-002,
-       -3.31190787e-002, 5.39920293e-002, 5.08198254e-002,
-       8.26826915e-002, -1.38692455e-002, 5.84070422e-002,
-       3.48113067e-002, 7.19625130e-002, 1.70690566e-003,
-       2.95558549e-003, 5.47475135e-003, 7.00620236e-003,
-       -9.51632333e-004, 3.05814971e-003, 5.85853728e-003,
-       5.11475746e-003, -5.50816162e-003, -8.52752104e-003,
-       1.59340706e-002, 1.71644893e-002, 1.12753420e-004,
-       -3.23723978e-003, 8.75148084e-003, 1.10054966e-002,
-       1.75363198e-003, 1.20790594e-003, 2.39717588e-003,
-       2.14242726e-003, -1.43323511e-001, 1.19436577e-001,
-       1.59776643e-001, 1.30729213e-001, -4.92475443e-002,
-       4.53563593e-002, 1.57589376e-001, 1.47728160e-001,
-       -1.91188534e-003, -5.71616401e-004, 9.34194252e-002,
-       6.31112084e-002, 3.25649343e-002, 1.60832461e-002,
-       3.69622968e-002, 2.19526701e-002, -1.61799163e-001,
-       -4.02335599e-002, 2.26066187e-001, 2.18820453e-001,
-       -1.72192425e-001, 2.04100296e-001, 3.30163896e-001,
-       3.93756688e-001, 3.21903005e-002, 7.30957761e-002,
-       1.82238325e-001, 1.34330928e-001, 3.82908694e-002,
-       9.32848919e-003, 4.91716638e-002, 2.21791100e-002,
-       4.29221475e-003, -4.56765527e-003, 2.28333622e-002,
-       2.67047789e-002, -4.95903008e-002, 1.68924138e-001,
-       1.72732159e-001, 2.93685883e-001, -6.38587922e-002,
-       7.84180388e-002, 8.69291052e-002, 8.73902738e-002,
-       6.70213427e-004, 3.07535799e-003, 6.63654599e-003,
-       6.47347420e-003, -9.48659703e-003, 9.88898100e-004,
-       1.32084386e-002, 3.91233806e-003, -1.40818479e-002,
-       -2.14675106e-002, 5.78392819e-002, 3.53172645e-002,
-       1.07272081e-002, -2.82468945e-002, 4.32438776e-002,
-       4.67266887e-002, -1.50360318e-003, -1.69740862e-003,
-       4.84234188e-003, 5.32143703e-003, -6.73240125e-002,
-       6.91981940e-003, 9.06102061e-002, 2.34094430e-002,
-       -2.98551291e-001, -2.12404225e-002, 3.80563617e-001,
-       1.45018995e-001, 3.96468900e-002, -1.59373194e-001,
-       1.47702768e-001, 2.05682978e-001, 1.31122768e-002,
-       -1.63738541e-002, 3.09394542e-002, 3.01608834e-002,
-       -4.98071164e-002, -1.83456088e-003, 7.41054788e-002,
-       2.53728852e-002, -3.73858899e-001, 9.49815661e-002,
-       4.13251460e-001, 1.80096403e-001, 2.50923224e-002,
-       1.29744306e-001, 1.29008472e-001, 1.99848905e-001,
-       1.78568680e-002, 1.29578104e-002, 3.15309241e-002,
-       3.12272720e-002, -3.26213473e-003, 1.08027412e-003,
-       7.54996808e-003, 6.60314271e-003, -1.61480177e-002,
-       7.69173801e-002, 5.69744408e-002, 1.18018620e-001,
-       1.23269472e-003, 1.07515253e-001, 4.60283570e-002,
-       1.68176785e-001, -1.58447679e-003, 1.06169870e-002,
-       5.39008435e-003, 1.80412848e-002, -1.06958745e-004,
-       -4.11127367e-005, 4.06554854e-003, 1.82961824e-003,
-       8.81348923e-003, -4.89858771e-003, 2.28288323e-002,
-       1.52036641e-002, 2.55309846e-002, -9.27345920e-003,
-       4.85627577e-002, 2.43004002e-002, 1.61810834e-002,
-       4.42358991e-003, 1.97329596e-002, 7.65402196e-003,
-       -4.18204902e-004, -4.22479026e-003, 2.10555270e-002,
-       1.82035323e-002, 9.65647176e-002, 1.89343709e-002,
-       1.82346329e-001, 1.11893706e-001, 1.84631243e-001,
-       6.99327663e-002, 3.05250973e-001, 1.49323389e-001,
-       1.56915814e-001, 1.31559940e-002, 1.98027343e-001,
-       3.95078622e-002, -6.95450325e-003, 9.53957718e-003,
-       2.42782980e-002, 2.48330068e-002, 1.90998331e-001,
-       1.06283598e-001, 2.35000759e-001, 1.87965244e-001,
-       1.26191929e-001, 2.97340062e-002, 4.18037474e-001,
-       2.05303028e-001, 1.63620293e-001, 1.70715712e-003,
-       2.29321048e-001, 4.06452529e-002, 1.76643569e-003,
-       1.78027451e-002, 4.84835310e-003, 2.88087036e-002,
-       1.69785470e-002, 1.34138286e-001, 4.27183062e-002,
-       2.11746648e-001, -9.80927516e-003, 1.30767912e-001,
-       5.76723814e-002, 2.09538862e-001, 1.36687253e-002,
-       2.11192737e-003, 2.09472682e-002, 1.79477092e-002,
-       1.16040872e-003, 1.33494462e-003, 3.40848137e-003,
-       5.87707665e-003, 1.56783048e-004, 3.25802751e-002,
-       2.33185012e-002, 5.16500138e-002, -6.36090199e-003,
-       4.40624692e-002, 2.45456100e-002, 5.94937578e-002,
-       -1.95751223e-003, 3.00365197e-003, 5.17215207e-003,
-       7.09456950e-003, 2.69283298e-002, 8.73602228e-004,
-       3.44321206e-002, 3.50231789e-002, 5.07614650e-002,
-       -1.81544945e-002, 1.47568047e-001, 2.80271441e-001,
-       -1.42789811e-001, -1.95928171e-001, 2.12737724e-001,
-       4.36290294e-001, -4.45560515e-002, -3.83493379e-002,
-       5.28454743e-002, 6.23363219e-002, 1.65820550e-002,
-       -3.30091082e-002, 3.59518602e-002, 4.25840542e-002,
-       4.33693640e-002, -2.42866516e-001, 1.69373989e-001,
-       3.13166112e-001, -2.42014423e-001, -1.36343166e-001,
-       2.88455635e-001, 2.84032106e-001, -2.90495828e-002,
-       -1.52056571e-002, 4.09855284e-002, 3.99911366e-002,
-       -1.56023225e-003, -2.32894463e-003, 4.48975572e-003,
-       6.01907400e-003, 9.52217029e-004, -4.06646319e-002,
-       2.70428304e-002, 5.42452075e-002, -1.28469290e-002,
-       -4.41030674e-002, 2.49584615e-002, 5.30830398e-002,
-       -3.95661802e-004, -1.05626381e-003, 3.63892363e-003,
-       4.24063392e-003, 2.75456434e-004, 3.86284199e-003,
-       4.10470366e-003, 6.67211926e-003, -9.24688578e-003,
-       4.05570604e-002, 2.79692803e-002, 5.46062849e-002,
-       -6.54421654e-003, 2.77421921e-002, 2.60822419e-002,
-       4.71791066e-002, 7.45561614e-004, 1.25583669e-003,
-       3.56624555e-003, 5.48089854e-003, 3.37802581e-002,
-       4.16765781e-003, 4.13915142e-002, 3.93010825e-002,
-       2.17163060e-002, 2.04369068e-001, 1.45332158e-001,
-       2.61830032e-001, -1.17930442e-001, 2.90553868e-001,
-       1.68974444e-001, 3.18677038e-001, -2.00734455e-002,
-       3.46109308e-002, 3.17750350e-002, 4.54578027e-002,
-       2.72881258e-002, -5.08222543e-002, 4.13771085e-002,
-       5.98933809e-002, 2.42593899e-001, -3.66635174e-001,
-       2.73789495e-001, 3.90594572e-001, -7.15945894e-003,
-       -1.10689305e-001, 1.46518320e-001, 1.88646600e-001,
-       -2.23192014e-002, 1.47561997e-003, 3.07221301e-002,
-       2.90843453e-002, -1.05089345e-003, 9.17182188e-004,
-       3.88170639e-003, 4.30825539e-003, 2.90645473e-002,
-       -2.05615740e-002, 4.14606556e-002, 4.12905551e-002,
-       2.58888584e-002, -4.18852568e-002, 4.05224375e-002,
-       5.06710149e-002, -2.28926598e-004, -2.99873250e-003,
-       3.97398276e-003, 5.16920770e-003, -2.04847296e-004,
-       -2.66932114e-003, 3.87112726e-003, 6.25491701e-003,
-       -2.76621291e-003, -3.54945995e-002, 2.97561195e-002,
-       5.48025593e-002, -1.07928633e-003, -4.07627076e-002,
-       2.51836181e-002, 6.01492897e-002, 1.38693152e-003,
-       -1.85922929e-003, 4.80087195e-003, 5.71877509e-003,
-       -1.59829780e-002, -4.58126655e-004, 3.46194059e-002,
-       3.39114964e-002, -2.65541635e-002, 2.26086956e-002,
-       1.70555204e-001, 2.29228571e-001, 8.93885717e-002,
-       1.99362725e-001, 1.75448924e-001, 3.54962736e-001,
-       2.09707916e-002, 3.17102820e-002, 4.00461033e-002,
-       5.75318821e-002, -1.97488442e-002, 1.90699585e-002,
-       4.20336463e-002, 5.27260341e-002, -6.35360777e-002,
-       4.43950407e-002, 2.10707441e-001, 4.52969730e-001,
-       1.76394910e-001, -1.44012138e-001, 2.54477084e-001,
-       3.82407904e-001, 2.05584206e-002, -1.20654069e-002,
-       4.26462516e-002, 4.69137914e-002, -4.01910074e-004,
-       -9.86050218e-005, 4.51852940e-003, 6.91884430e-003,
-       -1.43256122e-002, 2.37194020e-002, 3.34734395e-002,
-       5.86244650e-002, -9.00373212e-004, 3.16223614e-002,
-       3.23653519e-002, 5.76433130e-002, 2.21734215e-003,
-       1.22592074e-003, 5.35870716e-003, 5.83042251e-003,
-       -4.24872991e-003, 5.70317090e-004, 7.07844272e-003,
-       4.30849101e-003, 2.74533909e-002, -2.79171765e-002,
-       6.61220625e-002, 3.73843834e-002, 2.06158403e-002,
-       -2.14061905e-002, 4.67597395e-002, 3.42280865e-002,
-       -6.52693037e-004, -6.55997312e-004, 4.60550468e-003,
-       3.93938133e-003, -4.97170016e-002, 9.26639419e-003,
-       6.36371076e-002, 2.87748408e-002, 8.48205090e-002,
-       -7.67726079e-002, 4.56829935e-001, 1.85688138e-001,
-       9.50200036e-002, -2.20760435e-001, 2.75151849e-001,
-       2.80119240e-001, 2.45736111e-002, -2.13910826e-002,
-       3.96631472e-002, 3.66083160e-002, -2.75792684e-002,
-       1.12015940e-002, 4.88307737e-002, 2.92126294e-002,
-       -2.15318501e-001, 1.40586361e-001, 3.73289734e-001,
-       2.20551118e-001, 1.22988999e-001, -4.44618464e-002,
-       2.18036503e-001, 1.81989387e-001, 2.96242628e-002,
-       -8.22033547e-003, 4.09173518e-002, 3.17489132e-002,
-       -3.82822298e-004, -8.47593124e-004, 5.05193509e-003,
-       3.50557314e-003, -3.61695364e-002, 1.91900209e-002,
-       5.30442968e-002, 3.41191106e-002, 4.03171685e-003,
-       1.94641501e-002, 3.74366827e-002, 3.30065340e-002,
-       2.28554662e-003, -7.84028307e-005, 5.19632269e-003,
-       4.47154604e-003, 1.46820012e-003, -1.59915781e-003,
-       6.48016855e-003, 5.93817700e-003, 2.59448085e-002,
-       -3.83874029e-002, 5.86754754e-002, 5.94361387e-002,
-       6.41462440e-003, -6.83029965e-002, 4.67450358e-002,
-       7.83665255e-002, 1.94308360e-003, -1.65849912e-003,
-       5.17800963e-003, 5.37444139e-003, -1.94522180e-002,
-       -7.78504508e-003, 4.29268293e-002, 3.77309732e-002,
-       5.46585657e-002, -2.56222606e-001, 2.75912046e-001,
-       3.13981175e-001, 1.76513165e-001, -1.50953904e-001,
-       3.24262947e-001, 2.27317512e-001, 4.29966077e-002,
-       -1.86384842e-002, 5.92762828e-002, 3.58936451e-002,
-       -1.97716132e-002, 1.08652152e-002, 4.50229049e-002,
-       3.55333202e-002, 4.25924314e-003, 8.82187635e-002,
-       2.74907351e-001, 1.89079121e-001, 2.63736755e-001,
-       1.42668441e-001, 3.17199260e-001, 2.47643560e-001,
-       3.48071977e-002, 1.24665508e-002, 5.46741001e-002,
-       3.91902700e-002, 2.00515162e-004, -1.65050988e-005,
-       6.19086344e-003, 4.78535797e-003, 5.68040647e-003,
-       2.27136165e-002, 4.80661169e-002, 4.08665389e-002,
-       4.17510942e-002, 1.86616536e-002, 5.43286987e-002,
-       4.55168299e-002, 1.39400433e-003, -1.36151619e-004,
-       5.92752779e-003, 6.04055636e-003, 3.95962968e-004,
-       7.51584477e-004, 3.93527932e-003, 5.30162267e-003,
-       -2.98725395e-003, 1.32810129e-002, 2.70998608e-002,
-       5.53422756e-002, -7.21727684e-003, 1.30236102e-002,
-       2.74868831e-002, 5.39796352e-002, -4.23419027e-004,
-       2.10318700e-004, 4.23532166e-003, 5.23283612e-003,
-       4.69921436e-003, -2.96816137e-003, 3.59262861e-002,
-       3.56009007e-002, 8.17939406e-004, -5.16731925e-002,
-       1.72580257e-001, 3.36938232e-001, -6.30593076e-002,
-       -9.36082304e-002, 1.81982428e-001, 5.17933965e-001,
-       -8.49689357e-003, -7.64974300e-003, 3.51192914e-002,
-       5.29414229e-002, 5.78917470e-003, 1.12878270e-002,
-       3.80113721e-002, 3.09340116e-002, 4.46310416e-002,
-       1.70171499e-001, 2.03360379e-001, 2.77898997e-001,
-       -1.67313397e-001, 1.75547093e-001, 2.36085281e-001,
-       3.13985020e-001, -4.91442764e-003, 5.16349589e-003,
-       3.24448012e-002, 3.32316868e-002, 6.30123541e-004,
-       4.90393395e-005, 4.38194862e-003, 3.91706685e-003,
-       5.83796715e-003, -9.49508045e-003, 2.83928420e-002,
-       3.89802046e-002, -2.02545617e-002, -6.37643086e-003,
-       3.75449955e-002, 4.33449708e-002, -1.27945025e-003,
-       1.35534687e-003, 4.34910739e-003, 4.56487993e-003,
-       3.72425467e-003, -4.43414273e-003, 7.77760334e-003,
-       1.07558127e-002, -1.82005931e-002, -6.13081194e-002,
-       3.94846126e-002, 8.79138112e-002, -2.08626762e-002,
-       -6.45509437e-002, 5.21939807e-002, 8.24112222e-002,
-       8.10296088e-003, -4.81933035e-004, 1.89025626e-002,
-       7.75385462e-003, -7.67646683e-003, -4.85253483e-002,
-       2.96577998e-002, 5.68284728e-002, -7.13000298e-002,
-       -3.11135083e-001, 1.34485409e-001, 3.73482376e-001,
-       3.81336175e-002, -2.04295799e-001, 2.05763236e-001,
-       2.66556442e-001, 1.59922034e-001, 3.66240530e-003,
-       2.31272280e-001, 4.55969088e-002, -9.49852820e-003,
-       1.19118951e-002, 2.40164045e-002, 3.16817872e-002,
-       -5.41711925e-003, 1.08325019e-001, 9.09401178e-002,
-       1.98508725e-001, 1.36691242e-001, 1.83469325e-001,
-       2.49760211e-001, 2.40791962e-001, 1.20359629e-001,
-       -4.00019437e-003, 1.95433423e-001, 4.42303084e-002,
-       3.90562724e-004, 1.09927654e-002, 6.21494930e-003,
-       1.33439349e-002, 5.27119264e-003, 9.07220021e-002,
-       4.08466831e-002, 1.07175283e-001, 4.92540095e-003,
-       6.36320412e-002, 5.17148711e-002, 8.50694478e-002,
-       3.17349378e-003, -1.89534866e-003, 1.66676659e-002,
-       8.16792902e-003, 1.03956796e-002, -1.35210517e-003,
-       2.09612623e-002, 7.23763136e-003, 3.38469632e-002,
-       1.56964045e-002, 5.03984243e-002, 2.91587450e-002,
-       -1.22667123e-002, 1.47512099e-002, 2.78307274e-002,
-       3.14304978e-002, -1.59350522e-002, -2.68975203e-003,
-       2.05153208e-002, 8.40161089e-003, 1.38985097e-001,
-       -3.03798951e-002, 1.82761014e-001, 6.30058572e-002,
-       2.65795857e-001, -8.44465010e-003, 3.33757192e-001,
-       1.05665118e-001, -1.20891549e-001, -5.41507499e-003,
-       2.09117219e-001, 9.76893380e-002, -1.74074695e-001,
-       -2.95424853e-002, 2.01780483e-001, 5.94180450e-002,
-       1.53584644e-001, 3.18393894e-002, 1.93329602e-001,
-       5.73856421e-002, 2.40615651e-001, 1.17450003e-002,
-       3.19325447e-001, 1.11526959e-001, -2.18351483e-001,
-       -3.37283909e-002, 3.17335993e-001, 1.06643900e-001,
-       -1.47603452e-001, -4.70431615e-003, 1.97119623e-001,
-       4.27883230e-002, 1.67372692e-002, 3.81291588e-003,
-       2.22299714e-002, 8.45205877e-003, 2.33051665e-002,
-       -5.77816973e-003, 4.65625226e-002, 2.28337385e-002,
-       -4.55655046e-002, -1.52117638e-002, 6.62005544e-002,
-       2.89952420e-002, -7.22252904e-003, 5.27536729e-003,
-       1.93973426e-002, 7.76726613e-003, -5.78009337e-003,
-       2.01173898e-004, 7.99467135e-003, 3.86811537e-003,
-       -1.36355858e-003, -1.64525565e-002, 3.59169059e-002,
-       3.22358645e-002, 1.88792087e-002, -1.30560389e-002,
-       3.61784101e-002, 3.32219824e-002, 7.51598086e-003,
-       7.53957953e-004, 1.00500016e-002, 4.58367495e-003,
-       -9.04834494e-002, 1.19813522e-002, 1.02172814e-001,
-       3.19397449e-002, 8.92588049e-002, 2.98850201e-002,
-       2.38249913e-001, 1.61262110e-001, 7.17349946e-002,
-       5.21193519e-002, 3.15499365e-001, 1.83947906e-001,
-       8.01235586e-002, 2.29765922e-002, 1.00068919e-001,
-       3.87772545e-002, -1.10929698e-001, 6.90261554e-003,
-       1.26438722e-001, 2.68867239e-002, 1.73499852e-001,
-       1.19525110e-002, 3.52442265e-001, 1.50942683e-001,
-       1.27283096e-001, 1.12200290e-001, 5.10628939e-001,
-       2.26510704e-001, 6.03162423e-002, 1.54473502e-002,
-       9.15090889e-002, 3.00240312e-002, -8.90333764e-003,
-       -4.89351223e-004, 1.31063517e-002, 5.74123021e-003,
-       1.73923522e-002, 2.85008829e-002, 5.85607402e-002,
-       4.89346087e-002, 4.25645821e-002, 3.60783786e-002,
-       7.88349807e-002, 5.39999679e-002, 1.31129415e-003,
-       -2.05039838e-003, 8.49770103e-003, 5.08160191e-003,
-       1.68967396e-002, -1.86649314e-003, 2.51586866e-002,
-       5.12996502e-003, 4.26695272e-002, 7.53701199e-003,
-       5.29758669e-002, 1.70898326e-002, 2.13146466e-003,
-       2.43817829e-003, 1.52253043e-002, 1.01721995e-002,
-       -3.20324954e-003, -3.57783487e-004, 5.03244856e-003,
-       2.40695663e-003, 1.69839576e-001, -7.95013562e-004,
-       2.18068823e-001, 2.53918488e-002, 2.41887301e-001,
-       4.04369598e-003, 3.16819757e-001, 8.58440325e-002,
-       -1.79993967e-003, -2.51091365e-002, 1.29746065e-001,
-       8.31235498e-002, -3.81218903e-002, -1.40201217e-002,
-       5.11188209e-002, 2.51677204e-002, 1.64095685e-001,
-       1.57723036e-002, 2.07330078e-001, 4.07269336e-002,
-       1.81588039e-001, -5.41595295e-002, 3.55763316e-001,
-       1.38410226e-001, -1.07141204e-001, -2.79901326e-001,
-       3.44485909e-001, 3.17845017e-001, -3.51869985e-002,
-       -3.34844887e-002, 6.06423318e-002, 4.68460582e-002,
-       1.61979739e-002, 2.99819658e-004, 2.21219566e-002,
-       7.43346382e-003, -1.14767384e-002, -3.66641581e-002,
-       7.54754767e-002, 5.30073568e-002, -2.96219345e-002,
-       -3.74110937e-002, 1.10603034e-001, 7.44454339e-002,
-       -1.29279186e-004, -2.14673649e-003, 7.89303333e-003,
-       8.00702162e-003, -3.55816708e-004, -1.50433439e-003,
-       4.59379423e-003, 5.23783499e-003, -2.33323826e-003,
-       -3.27579677e-002, 3.06847580e-002, 4.67499457e-002,
-       5.33228973e-003, -3.54385898e-002, 2.90634800e-002,
-       5.18598855e-002, 8.63337365e-004, -1.70802569e-003,
-       4.40308126e-003, 6.62777852e-003, -2.27029156e-002,
-       -5.08074416e-003, 3.62944938e-002, 3.26981880e-002,
-       -4.36918363e-002, -4.22718301e-002, 1.41438663e-001,
-       1.77678466e-001, 6.29486367e-002, -1.12537127e-002,
-       1.38767585e-001, 1.90983772e-001, 3.17224599e-002,
-       2.28672405e-003, 4.05708551e-002, 3.84939462e-002,
-       -2.91046239e-002, 2.24299207e-002, 4.36065793e-002,
-       3.98995355e-002, 1.18336238e-001, 2.41921604e-001,
-       2.73072749e-001, 2.95843273e-001, 9.26279128e-002,
-       4.51798916e-001, 1.98908940e-001, 4.80067849e-001,
-       2.61726547e-002, 5.50267398e-002, 4.07138467e-002,
-       6.33226782e-002, 3.50724353e-004, 3.58919124e-003,
-       6.19273540e-003, 6.34760922e-003, 3.42590399e-002,
-       4.78516221e-002, 5.61500676e-002, 5.90546578e-002,
-       1.17663024e-002, 2.06441898e-002, 2.99468134e-002,
-       3.94999124e-002, -1.55315665e-003, 6.88949309e-004,
-       3.93471401e-003, 4.64997813e-003, 1.63442467e-003,
-       2.95321170e-005, 6.29084883e-003, 3.40910489e-003,
-       -5.54669369e-003, 1.87315997e-002, 6.59035891e-002,
-       3.43432948e-002, -9.63128451e-003, 8.10372457e-003,
-       4.81005348e-002, 3.40096280e-002, -1.26962186e-005,
-       3.40588391e-004, 5.89704653e-003, 3.25475330e-003,
-       1.30542722e-002, -5.74512733e-003, 4.47737053e-002,
-       2.15008724e-002, 9.82614756e-002, 3.99350040e-002,
-       4.76026267e-001, 1.80224180e-001, -7.09339753e-002,
-       2.27731615e-001, 3.15481544e-001, 2.87112623e-001,
-       -4.55164770e-003, 2.24314667e-002, 5.43553233e-002,
-       4.02581692e-002, 1.60799157e-002, 5.35508245e-003,
-       4.33185212e-002, 2.18553450e-002, 2.01845080e-001,
-       -3.38387340e-002, 3.35197806e-001, 1.38259128e-001,
-       -8.52973387e-002, -1.15432523e-001, 3.26655835e-001,
-       2.27457777e-001, 2.19760004e-005, -2.09443271e-003,
-       5.60991839e-002, 3.98828313e-002, 1.33511249e-003,
-       1.60573551e-003, 5.02931420e-003, 4.22474789e-003,
-       1.51154287e-002, -1.82561893e-002, 3.63222770e-002,
-       2.97271889e-002, -1.09784286e-002, -5.50341979e-003,
-       4.59549427e-002, 3.57262753e-002, 1.35616574e-003,
-       1.80393326e-005, 6.85231434e-003, 4.29489464e-003,
-       -3.87540698e-004, -1.21334707e-003, 3.56191816e-003,
-       4.04055510e-003, -6.94740005e-003, -1.33861471e-002,
-       2.18328107e-002, 2.47714855e-002, 5.88611932e-003,
-       -1.71522051e-002, 2.78736912e-002, 2.90805176e-002,
-       1.07136380e-004, -6.36112643e-004, 5.72867785e-003,
-       4.87936987e-003, -2.05542725e-002, 4.85821441e-003,
-       3.24027464e-002, 2.47700382e-002, -4.43100706e-002,
-       -2.35706754e-002, 1.21578172e-001, 1.33094594e-001,
-       -1.56875211e-003, -1.83015224e-002, 1.43429279e-001,
-       1.42815530e-001, 2.61236038e-002, 6.18480891e-003,
-       4.20159139e-002, 3.25707905e-002, -1.96352396e-002,
-       2.93479096e-002, 3.91125008e-002, 5.11396080e-002,
-       -4.19350490e-002, 2.80603319e-001, 1.76231831e-001,
-       3.54079664e-001, 6.90405890e-002, 3.80391985e-001,
-       2.66267151e-001, 4.48893487e-001, 4.19376865e-002,
-       6.58913404e-002, 7.14671984e-002, 8.02744478e-002,
-       7.14503322e-003, 1.44220646e-002, 1.09569039e-002,
-       1.86987333e-002, 1.19617330e-002, 1.69201970e-001,
-       5.19076325e-002, 1.88433617e-001, -1.20836608e-002,
-       1.15993723e-001, 7.76311830e-002, 1.48149401e-001,
-       4.60873616e-006, 7.80100469e-003, 1.08162640e-002,
-       1.35300197e-002, -1.65956952e-002, -1.05176208e-004,
-       2.37145033e-002, 1.06512429e-002, 6.42464822e-003,
-       -1.09732293e-001, 6.18760176e-002, 1.36166126e-001,
-       1.60135124e-002, -1.15996115e-001, 5.19592650e-002,
-       1.47797063e-001, -2.21228879e-003, -8.40728730e-003,
-       7.64017273e-003, 1.57120451e-002, -2.08527610e-001,
-       1.02868769e-003, 2.57042944e-001, 3.63462567e-002,
-       -1.47033274e-001, -9.35699120e-002, 3.18281353e-001,
-       1.99234828e-001, 1.66236445e-001, -1.41909987e-001,
-       2.32330620e-001, 2.45344937e-001, 2.01718528e-002,
-       -1.82803795e-002, 4.53983620e-002, 4.28916886e-002,
-       -1.96952820e-001, -4.51093633e-003, 2.43210554e-001,
-       3.12291924e-002, -1.82069749e-001, 3.60700116e-002,
-       2.99091697e-001, 1.33812740e-001, 1.25085369e-001,
-       3.07240733e-003, 1.94483534e-001, 1.30060270e-001,
-       2.47059409e-002, -6.26065861e-003, 4.07871008e-002,
-       2.76664756e-002, -2.16882396e-002, -1.12653791e-003,
-       2.76190583e-002, 5.61413821e-003, -2.69233901e-002,
-       2.07597148e-002, 4.90357503e-002, 3.55397351e-002,
-       9.21619777e-003, 1.61829293e-002, 2.86486205e-002,
-       3.26148681e-002, 2.12422176e-003, 2.99327658e-004,
-       5.10174176e-003, 4.58301185e-003, -1.21163540e-002,
-       1.33775186e-003, 1.90636329e-002, 9.47875530e-003,
-       1.19037256e-002, -1.11554854e-001, 6.74166679e-002,
-       1.61656603e-001, -1.58893708e-002, -1.45345420e-001,
-       2.55185310e-002, 1.84868887e-001, -1.87297573e-003,
-       -1.49160735e-002, 4.37914394e-003, 2.04330329e-002,
-       -1.49251938e-001, -2.41759187e-003, 1.85905248e-001,
-       2.36241166e-002, -1.57711819e-001, 6.78215921e-002,
-       2.96772271e-001, 2.21132755e-001, -7.96178728e-002,
-       2.60447524e-002, 1.60538003e-001, 1.96851432e-001,
-       5.75255556e-003, -4.81809489e-003, 1.58622488e-002,
-       2.48918477e-002, -1.55509591e-001, -3.12824431e-003,
-       1.89418837e-001, 2.23425534e-002, -5.51562831e-002,
-       1.96764506e-002, 3.97690088e-001, 2.21783236e-001,
-       -2.13397771e-001, -1.61662400e-002, 2.81198800e-001,
-       1.39237493e-001, 2.37127906e-003, -5.62586309e-003,
-       1.77115314e-002, 1.65733397e-002, -1.79207493e-002,
-       -2.10354148e-004, 2.17294190e-002, 6.76144427e-003,
-       -1.47840362e-002, 3.64527255e-002, 5.39730266e-002,
-       8.92421007e-002, -2.46494580e-002, 4.56240401e-002,
-       4.06830870e-002, 8.87427926e-002, -1.11297111e-003,
-       5.02921594e-003, 4.13622102e-003, 7.69458339e-003,
-       6.03095919e-004, -1.64646807e-003, 5.50510548e-003,
-       5.77050261e-003, -2.37975991e-003, -2.25906521e-002,
-       3.99322845e-002, 4.37904671e-002, -1.11798802e-002,
-       -2.70714797e-002, 3.85185927e-002, 4.25030962e-002,
-       2.36566062e-003, -1.29049714e-003, 5.65338461e-003,
-       5.56803821e-003, -2.41542011e-002, -2.13644654e-003,
-       4.40126546e-002, 4.14218046e-002, 3.57227633e-003,
-       -1.63788661e-001, 2.03056350e-001, 2.45629057e-001,
-       -1.52587462e-002, -7.81229064e-002, 1.83228180e-001,
-       1.83430910e-001, 3.77829373e-002, 4.84122476e-003,
-       4.78067808e-002, 3.46608013e-002, -2.55100932e-002,
-       4.25828546e-002, 5.26129119e-002, 5.81378974e-002,
-       -1.06171280e-001, 2.03854904e-001, 3.36379170e-001,
-       3.21810961e-001, 1.98300734e-001, 2.96181023e-001,
-       2.80671179e-001, 3.65335971e-001, 3.01200524e-002,
-       4.74735387e-002, 4.73317206e-002, 5.81393503e-002,
-       4.97959147e-004, 9.25677246e-004, 6.12848951e-003,
-       5.52322203e-003, -6.98977010e-003, 5.05447388e-002,
-       5.19849211e-002, 6.31082058e-002, 2.44418308e-002,
-       3.74043286e-002, 4.41478118e-002, 5.20016588e-002,
-       -9.15296841e-004, 3.32925963e-004, 4.63333167e-003,
-       4.71677538e-003, 5.03763848e-004, -1.98037736e-003,
-       3.89940687e-003, 4.55256272e-003, -4.74891439e-003,
-       -3.37945446e-002, 2.23623011e-002, 4.41325083e-002,
-       -1.02991343e-003, -3.29208039e-002, 2.03422830e-002,
-       4.48409244e-002, -5.42168214e-004, -2.88935774e-003,
-       2.96523725e-003, 5.25953015e-003, -2.25743614e-002,
-       -2.00079326e-002, 3.75576131e-002, 3.59028988e-002,
-       -9.04465988e-002, -2.42162660e-001, 1.78084910e-001,
-       3.04124355e-001, 3.02551836e-002, -2.46823534e-001,
-       1.30629212e-001, 3.04035693e-001, 9.65639018e-003,
-       -3.23390178e-002, 2.18496658e-002, 4.57231142e-002,
-       -2.91546639e-002, 8.89243092e-003, 4.73579057e-002,
-       4.03394438e-002, -1.55873299e-001, 3.40573164e-003,
-       2.83408970e-001, 3.65057826e-001, 8.14642608e-002,
-       6.87353611e-002, 1.58431977e-001, 4.33598638e-001,
-       1.31028593e-002, 1.53033426e-002, 2.70468947e-002,
-       5.51502816e-002, -1.72201777e-003, 9.69781773e-004,
-       5.64512191e-003, 5.11924876e-003, 1.50232029e-003,
-       4.48125750e-002, 4.31459099e-002, 5.96158206e-002,
-       1.10494606e-002, 4.08019386e-002, 3.12549621e-002,
-       5.84650859e-002, -8.80992156e-004, 3.41142761e-003,
-       3.92990513e-003, 6.76693860e-003, -1.77282825e-004,
-       2.11524288e-003, 5.02387993e-003, 4.27929033e-003,
-       1.21628735e-002, 4.76827957e-002, 3.08492519e-002,
-       5.84773906e-002, 1.09726505e-003, 4.36249934e-002,
-       3.13689150e-002, 5.67705780e-002, -1.40541885e-003,
-       1.83197716e-003, 5.84754301e-003, 5.19265467e-003,
-       2.82555595e-002, 1.82185192e-002, 5.05466759e-002,
-       2.70346794e-002, 2.21898168e-001, 1.89916298e-001,
-       2.88308471e-001, 2.60601372e-001, -1.10854115e-002,
-       2.88052410e-001, 3.06724578e-001, 3.36208403e-001,
-       -7.00653866e-002, 1.68290436e-002, 8.52186680e-002,
-       3.73817757e-002, 3.85530554e-002, 7.85385072e-003,
-       5.89552782e-002, 2.03490499e-002, 1.62852913e-001,
-       -1.38437254e-002, 2.40799472e-001, 1.20453589e-001,
-       7.16571659e-002, -3.60217653e-002, 3.90250564e-001,
-       1.39951289e-001, -8.85554403e-002, -3.47383873e-004,
-       1.06367908e-001, 2.59297565e-002, 4.34431061e-003,
-       9.67808417e-004, 7.29547394e-003, 3.41833103e-003,
-       1.71017591e-002, -5.56934625e-003, 3.18434015e-002,
-       2.17110403e-002, 2.61576683e-003, -1.68814231e-002,
-       5.22397645e-002, 2.86835730e-002, -8.42118077e-003,
-       5.20810660e-004, 1.21328514e-002, 3.78960138e-003,
-       1.71909895e-004, 3.86715183e-005, 3.93724116e-003,
-       2.61972775e-003, 3.39045934e-002, 2.03350149e-002,
-       4.36919928e-002, 2.94427928e-002, 1.26175079e-002,
-       3.28411683e-002, 5.44092506e-002, 3.84182893e-002,
-       -4.37767524e-003, 2.12742554e-004, 7.31271366e-003,
-       3.37915961e-003, 1.78026576e-002, 1.50541468e-002,
-       3.37259807e-002, 2.48233993e-002, 3.17163497e-001,
-       1.95933238e-001, 3.65726113e-001, 2.33875200e-001,
-       -4.01799493e-002, 6.19501770e-002, 3.72328758e-001,
-       1.47367761e-001, -4.44300584e-002, -9.96230752e-004,
-       6.02653846e-002, 2.18826942e-002, 3.97152603e-002,
-       2.25214195e-002, 4.93190698e-002, 3.50312665e-002,
-       2.05640063e-001, 1.37335777e-001, 2.66468793e-001,
-       2.28158310e-001, -2.07307637e-001, -5.19851744e-002,
-       3.11397880e-001, 1.43373057e-001, -3.31479870e-002,
-       -1.03028084e-003, 5.23997843e-002, 2.36013234e-002,
-       4.38164128e-003, 9.46603192e-004, 6.41561113e-003,
-       4.46594507e-003, 8.69522151e-003, -2.30209772e-002,
-       3.15758474e-002, 3.55651937e-002, -2.76942756e-002,
-       -2.30062995e-002, 4.22632955e-002, 3.45785022e-002,
-       -1.67984248e-003, 1.02275889e-003, 5.86266210e-003,
-       3.83741548e-003, 1.06833398e-003, 8.31702142e-004,
-       4.46159812e-003, 5.47010731e-003, 5.84147265e-003,
-       2.32155938e-002, 2.79954877e-002, 5.29279970e-002,
-       -7.92615116e-003, 2.13255994e-002, 2.81974301e-002,
-       4.80505899e-002, -6.78965880e-004, -1.71891457e-004,
-       3.70869739e-003, 4.53552464e-003, 1.74840093e-002,
-       1.48181280e-003, 3.73642482e-002, 4.35668826e-002,
-       1.10922463e-001, -5.16277067e-002, 2.11941466e-001,
-       3.69832605e-001, -8.03550109e-002, 8.04162025e-002,
-       2.35196128e-001, 2.54111171e-001, -1.99878439e-002,
-       1.01381959e-002, 4.04158384e-002, 3.01622953e-002,
-       1.68773178e-002, 4.53998102e-003, 3.82013060e-002,
-       5.40724397e-002, 6.11022338e-002, 3.93857658e-002,
-       1.99431419e-001, 4.96222377e-001, -3.54067632e-003,
-       -4.67355512e-002, 3.25032413e-001, 3.08213621e-001,
-       -2.72595100e-002, -5.85700013e-003, 4.61108647e-002,
-       3.43926884e-002, 6.01105276e-004, -1.05728942e-003,
-       4.60903952e-003, 6.36796979e-003, 3.05198715e-003,
-       -2.53695697e-002, 3.06176562e-002, 6.04950376e-002,
-       3.16481735e-003, -2.21901201e-002, 3.95245142e-002,
-       5.49951717e-002, -9.73760267e-004, -4.29980253e-004,
-       4.83027287e-003, 5.27476426e-003, 5.04804682e-003,
-       6.47991954e-004, 1.07677486e-002, 4.26651724e-003,
-       -7.55437277e-003, 1.62067972e-002, 2.97986399e-002,
-       2.23787092e-002, -1.61217190e-002, 1.06618404e-002,
-       3.94266807e-002, 1.82856806e-002, -6.76109083e-003,
-       -3.69132613e-004, 8.87269620e-003, 2.48449296e-003,
-       8.18506628e-002, -1.73311532e-002, 1.05233200e-001,
-       3.76114473e-002, -1.22961245e-001, 7.18732104e-002,
-       2.98008978e-001, 1.58466205e-001, -1.45222247e-001,
-       -3.37675889e-003, 2.55448133e-001, 1.03757843e-001,
-       -5.30952103e-002, -3.58974445e-003, 6.56032115e-002,
-       1.77445952e-002, 5.06028868e-002, -1.59144606e-002,
-       8.43386054e-002, 3.63386869e-002, -2.65045511e-003,
-       -2.86469907e-002, 5.60987830e-001, 2.87762076e-001,
-       -2.21051499e-001, -1.10654160e-002, 3.03568840e-001,
-       1.22553244e-001, -4.68913652e-002, -2.01055710e-003,
-       6.24820217e-002, 1.68039557e-002, -9.47138178e-004,
-       1.63554843e-003, 9.31480713e-003, 4.58995253e-003,
-       4.04534228e-002, -3.71799693e-002, 8.47432986e-002,
-       5.47914840e-002, -4.47790213e-002, -8.22508708e-003,
-       6.29075766e-002, 3.35442983e-002, -4.23039263e-003,
-       5.45016192e-005, 7.50059122e-003, 3.43044568e-003,
-       7.25447608e-004, 8.74210309e-005, 3.77529557e-003,
-       3.87979066e-003, 3.71844098e-002, 2.55364291e-002,
-       4.76887785e-002, 4.29058783e-002, 2.09468380e-002,
-       3.02380361e-002, 3.67543139e-002, 4.18252982e-002,
-       1.60014592e-004, 1.41307514e-003, 3.57161369e-003,
-       4.07247525e-003, 2.12622937e-002, 1.95101406e-002,
-       3.80740166e-002, 3.53576466e-002, 3.38091195e-001,
-       1.32450700e-001, 3.74272048e-001, 2.87900686e-001,
-       3.99416313e-002, 6.15144670e-002, 1.55863822e-001,
-       1.70051992e-001, -1.36197377e-002, 5.69877727e-003,
-       2.42585130e-002, 2.35735998e-002, 4.33196947e-002,
-       1.83566697e-002, 5.20903841e-002, 6.29108325e-002,
-       1.36462674e-001, 3.05237118e-002, 2.09854364e-001,
-       4.79015440e-001, -2.34015957e-002, -1.15609109e-001,
-       1.29263312e-001, 2.78856277e-001, -1.09239360e-002,
-       -1.39875803e-002, 2.47610994e-002, 3.40635553e-002,
-       1.39705651e-003, -4.14768001e-003, 4.44820290e-003,
-       8.05130880e-003, 8.42157938e-003, -5.25054634e-002,
-       2.69808453e-002, 7.81298131e-002, 1.00707803e-002,
-       -4.98191491e-002, 2.59159803e-002, 7.51152560e-002,
-       1.21403753e-003, -4.37847758e-003, 3.48692713e-003,
-       8.14371835e-003, -7.45446980e-003, 7.53172091e-004,
-       1.18006170e-002, 8.19007587e-003, -1.77534427e-002,
-       -7.69834369e-002, 4.90998589e-002, 1.36281639e-001,
-       7.77797401e-003, -8.84587541e-002, 4.09714356e-002,
-       1.63971245e-001, 1.31307112e-003, -5.07162558e-003,
-       8.65323003e-003, 1.59333348e-002, -1.10161684e-001,
-       -1.61198480e-003, 1.25741154e-001, 2.98139434e-002,
-       -2.73430794e-001, -2.39487900e-003, 3.60573500e-001,
-       2.69833118e-001, 3.79244015e-002, -1.67110432e-002,
-       2.30266839e-001, 3.36761743e-001, 4.32565659e-002,
-       -4.95251827e-003, 7.51781911e-002, 4.67584208e-002,
-       -1.22001179e-001, -8.53351410e-003, 1.36428341e-001,
-       2.39765216e-002, -1.80863574e-001, -4.57492564e-003,
-       2.90991604e-001, 1.27592847e-001, 3.28647159e-002,
-       3.23180817e-002, 2.84825146e-001, 1.32859722e-001,
-       3.13459411e-002, 6.57503167e-003, 6.93409666e-002,
-       2.90808715e-002, -1.56216063e-002, -1.90001994e-003,
-       1.85412411e-002, 4.06023208e-003, -2.13752631e-002,
-       5.39143942e-003, 4.14301828e-002, 2.55589038e-002,
-       1.10799680e-002, 8.94335005e-003, 4.04287949e-002,
-       2.81401016e-002, 2.23116414e-003, 2.98713094e-005,
-       8.90087802e-003, 4.23161499e-003, 1.19911958e-004,
-       -1.41971430e-003, 4.19651624e-003, 4.80509549e-003,
-       1.81745645e-003, -1.32776275e-002, 3.03254724e-002,
-       5.08002676e-002, -5.40358620e-003, -1.63513105e-002,
-       2.57856399e-002, 5.61693460e-002, -8.77005572e-004,
-       -2.21490324e-003, 3.97921726e-003, 5.51851699e-003,
-       -3.47679034e-002, -1.91733632e-002, 5.38248941e-002,
-       5.49081750e-002, 1.07857876e-001, -2.09192529e-001,
-       2.96756804e-001, 5.43811262e-001, -2.06370000e-002,
-       -1.48320481e-001, 1.75880060e-001, 3.45002979e-001,
-       1.27882073e-002, -1.93475112e-002, 3.53497006e-002,
-       3.96275632e-002, -2.39074137e-002, 4.35530581e-003,
-       4.47298475e-002, 3.97503935e-002, 2.58627045e-003,
-       8.13347548e-002, 2.01185912e-001, 2.56234080e-001,
-       3.29468981e-003, -5.47402073e-003, 1.76366404e-001,
-       2.68243164e-001, 1.66999660e-002, 5.98109793e-003,
-       3.66247967e-002, 3.96916717e-002, -1.31595100e-003,
-       2.03858232e-004, 4.66672145e-003, 4.47571604e-003,
-       1.39705918e-003, 1.01884278e-002, 3.23548652e-002,
-       3.76112275e-002, 2.37986399e-003, 1.39465192e-002,
-       2.96727233e-002, 3.70467156e-002, 6.93258655e-004,
-       -6.71735761e-005, 3.84703744e-003, 5.20185195e-003,
-       4.61869733e-003, -6.95251161e-004, 1.07208714e-002,
-       5.85935498e-003, 3.84886935e-002, 1.70633234e-002,
-       4.92920578e-002, 3.34134325e-002, 3.20927211e-004,
-       1.13022663e-002, 1.81721486e-002, 2.01777611e-002,
-       -9.45114938e-004, 9.54437273e-005, 3.65193584e-003,
-       2.93838815e-003, 5.91344833e-002, 2.21813247e-002,
-       9.01662260e-002, 4.60916683e-002, 1.76128671e-001,
-       7.54697770e-002, 2.34983593e-001, 1.54930055e-001,
-       -2.37480868e-002, 4.89273574e-003, 8.33520293e-002,
-       8.48859921e-002, -1.66363306e-002, -3.28867027e-004,
-       3.11390627e-002, 1.66322887e-002, 6.09279722e-002,
-       -2.72116736e-002, 8.13502297e-002, 7.55993277e-002,
-       7.93766379e-002, -3.39807868e-001, 1.55834064e-001,
-       4.42745358e-001, -4.67118574e-003, -2.91789830e-001,
-       9.86690968e-002, 3.82649601e-001, -2.04385575e-002,
-       -3.64860743e-002, 3.62087414e-002, 5.38093261e-002,
-       1.24119909e-003, -6.23045536e-003, 5.45891374e-003,
-       2.23511606e-002, 4.61798813e-003, -7.58453906e-002,
-       2.50383951e-002, 2.03459457e-001, 5.22784889e-003,
-       -9.50815901e-002, 2.34812573e-002, 2.15370387e-001,
-       7.41192896e-004, -1.29826888e-002, 4.83357906e-003,
-       2.80836020e-002, 6.44448213e-004, -1.76497304e-003,
-       7.68008409e-003, 6.84937509e-003, -2.46213432e-002,
-       -7.37072527e-002, 6.05081730e-002, 8.60706121e-002,
-       6.87361956e-002, -8.94910321e-002, 8.09561014e-002,
-       1.06553979e-001, -2.86013680e-003, -4.04404430e-003,
-       1.04707703e-002, 9.17548407e-003, -2.71323696e-002,
-       -5.18851429e-002, 5.74124977e-002, 6.39104769e-002,
-       -1.46437660e-001, -1.79545283e-001, 2.65271634e-001,
-       2.53487021e-001, 1.58597514e-001, -2.51928270e-001,
-       2.83516318e-001, 3.49722326e-001, 4.55268286e-002,
-       -9.33844820e-002, 7.29614943e-002, 1.08234249e-001,
-       -1.82391386e-002, 1.27363503e-002, 4.30315025e-002,
-       5.11444882e-002, -8.09251219e-002, 5.44424318e-002,
-       1.93828300e-001, 2.12206200e-001, 3.56442779e-002,
-       1.13769427e-001, 1.87795296e-001, 3.37368309e-001,
-       1.66967753e-002, 1.94460656e-002, 4.22576591e-002,
-       6.56719506e-002, -1.23184186e-003, 3.62553913e-003,
-       7.92597141e-003, 7.67818606e-003, -1.31269181e-002,
-       4.74211127e-002, 6.14628829e-002, 7.34005868e-002,
-       4.81148846e-002, 6.46985918e-002, 7.94393867e-002,
-       9.02144760e-002, -3.80965136e-003, 6.40054699e-003,
-       8.04995280e-003, 1.20394947e-002 ]
diff --git a/samples/cpp/fabmap_sample.cpp b/samples/cpp/fabmap_sample.cpp
deleted file mode 100644 (file)
index cd06b55..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-// This file originates from the openFABMAP project:
-// [http://code.google.com/p/openfabmap/]
-//
-// For published work which uses all or part of OpenFABMAP, please cite:
-// [http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6224843]
-//
-// Original Algorithm by Mark Cummins and Paul Newman:
-// [http://ijr.sagepub.com/content/27/6/647.short]
-// [http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5613942]
-// [http://ijr.sagepub.com/content/30/9/1100.abstract]
-//
-//                           License Agreement
-//
-// Copyright (C) 2012 Arren Glover [aj.glover@qut.edu.au] and
-//                    Will Maddern [w.maddern@qut.edu.au], all rights reserved.
-//
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include <iostream>
-
-#include "opencv2/contrib.hpp"
-#include "opencv2/highgui.hpp"
-#include "opencv2/nonfree.hpp"
-
-using namespace cv;
-using namespace std;
-
-int main(int argc, char * argv[]) {
-
-    /*
-
-    Note: the vocabulary and training data is specifically made for this openCV
-    example. It is not reccomended for use with other datasets as it is
-    intentionally small to reduce baggage in the openCV project.
-
-    A new vocabulary can be generated using the supplied BOWMSCtrainer (or other
-    clustering method such as K-means
-
-    New training data can be generated by extracting bag-of-words using the
-    openCV BOWImgDescriptorExtractor class.
-
-    vocabulary, chow-liu tree, training data, and test data can all be saved and
-    loaded using openCV's FileStorage class and it is not necessary to generate
-    data each time as done in this example
-
-    */
-
-    cout << "This sample program demonstrates the FAB-MAP image matching "
-        "algorithm" << endl << endl;
-
-    string dataDir;
-    if (argc == 1) {
-        dataDir = "fabmap/";
-    } else if (argc == 2) {
-        dataDir = string(argv[1]);
-        dataDir += "/";
-    } else {
-        //incorrect arguments
-        cout << "Usage: fabmap_sample <sample data directory>" <<
-            endl;
-        return -1;
-    }
-
-    FileStorage fs;
-
-    //load/generate vocab
-    cout << "Loading Vocabulary: " <<
-        dataDir + string("vocab_small.yml") << endl << endl;
-    fs.open(dataDir + string("vocab_small.yml"), FileStorage::READ);
-    Mat vocab;
-    fs["Vocabulary"] >> vocab;
-    if (vocab.empty()) {
-        cerr << "Vocabulary not found" << endl;
-        return -1;
-    }
-    fs.release();
-
-    //load/generate training data
-
-    cout << "Loading Training Data: " <<
-        dataDir + string("train_data_small.yml") << endl << endl;
-    fs.open(dataDir + string("train_data_small.yml"), FileStorage::READ);
-    Mat trainData;
-    fs["BOWImageDescs"] >> trainData;
-    if (trainData.empty()) {
-        cerr << "Training Data not found" << endl;
-        return -1;
-    }
-    fs.release();
-
-    //create Chow-liu tree
-    cout << "Making Chow-Liu Tree from training data" << endl <<
-        endl;
-    of2::ChowLiuTree treeBuilder;
-    treeBuilder.add(trainData);
-    Mat tree = treeBuilder.make();
-
-    //generate test data
-    cout << "Extracting Test Data from images" << endl <<
-        endl;
-    Ptr<FeatureDetector> detector(
-        new DynamicAdaptedFeatureDetector(
-            AdjusterAdapter::create("STAR"), 130, 150, 5));
-    Ptr<DescriptorExtractor> extractor(
-        new SurfDescriptorExtractor(1000, 4, 2, false, true));
-    Ptr<DescriptorMatcher> matcher =
-        DescriptorMatcher::create("FlannBased");
-
-    BOWImgDescriptorExtractor bide(extractor, matcher);
-    bide.setVocabulary(vocab);
-
-    vector<string> imageNames;
-    imageNames.push_back(string("stlucia_test_small0000.jpeg"));
-    imageNames.push_back(string("stlucia_test_small0001.jpeg"));
-    imageNames.push_back(string("stlucia_test_small0002.jpeg"));
-    imageNames.push_back(string("stlucia_test_small0003.jpeg"));
-    imageNames.push_back(string("stlucia_test_small0004.jpeg"));
-    imageNames.push_back(string("stlucia_test_small0005.jpeg"));
-    imageNames.push_back(string("stlucia_test_small0006.jpeg"));
-    imageNames.push_back(string("stlucia_test_small0007.jpeg"));
-    imageNames.push_back(string("stlucia_test_small0008.jpeg"));
-    imageNames.push_back(string("stlucia_test_small0009.jpeg"));
-
-    Mat testData;
-    Mat frame;
-    Mat bow;
-    vector<KeyPoint> kpts;
-
-    for(size_t i = 0; i < imageNames.size(); i++) {
-        cout << dataDir + imageNames[i] << endl;
-        frame = imread(dataDir + imageNames[i]);
-        if(frame.empty()) {
-            cerr << "Test images not found" << endl;
-            return -1;
-        }
-
-        detector->detect(frame, kpts);
-
-        bide.compute(frame, kpts, bow);
-
-        testData.push_back(bow);
-
-        drawKeypoints(frame, kpts, frame);
-        imshow(imageNames[i], frame);
-        waitKey(10);
-    }
-
-    //run fabmap
-    cout << "Running FAB-MAP algorithm" << endl <<
-        endl;
-    Ptr<of2::FabMap> fabmap;
-
-    fabmap.reset(new of2::FabMap2(tree, 0.39, 0, of2::FabMap::SAMPLED |
-        of2::FabMap::CHOW_LIU));
-    fabmap->addTraining(trainData);
-
-    vector<of2::IMatch> matches;
-    fabmap->compare(testData, matches, true);
-
-    //display output
-    Mat result_small = Mat::zeros(10, 10, CV_8UC1);
-    vector<of2::IMatch>::iterator l;
-
-    for(l = matches.begin(); l != matches.end(); l++) {
-            if(l->imgIdx < 0) {
-                result_small.at<char>(l->queryIdx, l->queryIdx) =
-                    (char)(l->match*255);
-
-            } else {
-                result_small.at<char>(l->queryIdx, l->imgIdx) =
-                    (char)(l->match*255);
-            }
-    }
-
-    Mat result_large(100, 100, CV_8UC1);
-    resize(result_small, result_large, Size(500, 500), 0, 0, INTER_NEAREST);
-
-    cout << endl << "Press any key to exit" << endl;
-    imshow("Confusion Matrix", result_large);
-    waitKey();
-
-    return 0;
-}
diff --git a/samples/cpp/facerec_at_t.txt b/samples/cpp/facerec_at_t.txt
deleted file mode 100644 (file)
index c0b8d23..0000000
+++ /dev/null
@@ -1,400 +0,0 @@
-/path/to/at/s13/2.pgm;12
-/path/to/at/s13/7.pgm;12
-/path/to/at/s13/6.pgm;12
-/path/to/at/s13/9.pgm;12
-/path/to/at/s13/5.pgm;12
-/path/to/at/s13/3.pgm;12
-/path/to/at/s13/4.pgm;12
-/path/to/at/s13/10.pgm;12
-/path/to/at/s13/8.pgm;12
-/path/to/at/s13/1.pgm;12
-/path/to/at/s17/2.pgm;16
-/path/to/at/s17/7.pgm;16
-/path/to/at/s17/6.pgm;16
-/path/to/at/s17/9.pgm;16
-/path/to/at/s17/5.pgm;16
-/path/to/at/s17/3.pgm;16
-/path/to/at/s17/4.pgm;16
-/path/to/at/s17/10.pgm;16
-/path/to/at/s17/8.pgm;16
-/path/to/at/s17/1.pgm;16
-/path/to/at/s32/2.pgm;31
-/path/to/at/s32/7.pgm;31
-/path/to/at/s32/6.pgm;31
-/path/to/at/s32/9.pgm;31
-/path/to/at/s32/5.pgm;31
-/path/to/at/s32/3.pgm;31
-/path/to/at/s32/4.pgm;31
-/path/to/at/s32/10.pgm;31
-/path/to/at/s32/8.pgm;31
-/path/to/at/s32/1.pgm;31
-/path/to/at/s10/2.pgm;9
-/path/to/at/s10/7.pgm;9
-/path/to/at/s10/6.pgm;9
-/path/to/at/s10/9.pgm;9
-/path/to/at/s10/5.pgm;9
-/path/to/at/s10/3.pgm;9
-/path/to/at/s10/4.pgm;9
-/path/to/at/s10/10.pgm;9
-/path/to/at/s10/8.pgm;9
-/path/to/at/s10/1.pgm;9
-/path/to/at/s27/2.pgm;26
-/path/to/at/s27/7.pgm;26
-/path/to/at/s27/6.pgm;26
-/path/to/at/s27/9.pgm;26
-/path/to/at/s27/5.pgm;26
-/path/to/at/s27/3.pgm;26
-/path/to/at/s27/4.pgm;26
-/path/to/at/s27/10.pgm;26
-/path/to/at/s27/8.pgm;26
-/path/to/at/s27/1.pgm;26
-/path/to/at/s5/2.pgm;4
-/path/to/at/s5/7.pgm;4
-/path/to/at/s5/6.pgm;4
-/path/to/at/s5/9.pgm;4
-/path/to/at/s5/5.pgm;4
-/path/to/at/s5/3.pgm;4
-/path/to/at/s5/4.pgm;4
-/path/to/at/s5/10.pgm;4
-/path/to/at/s5/8.pgm;4
-/path/to/at/s5/1.pgm;4
-/path/to/at/s20/2.pgm;19
-/path/to/at/s20/7.pgm;19
-/path/to/at/s20/6.pgm;19
-/path/to/at/s20/9.pgm;19
-/path/to/at/s20/5.pgm;19
-/path/to/at/s20/3.pgm;19
-/path/to/at/s20/4.pgm;19
-/path/to/at/s20/10.pgm;19
-/path/to/at/s20/8.pgm;19
-/path/to/at/s20/1.pgm;19
-/path/to/at/s30/2.pgm;29
-/path/to/at/s30/7.pgm;29
-/path/to/at/s30/6.pgm;29
-/path/to/at/s30/9.pgm;29
-/path/to/at/s30/5.pgm;29
-/path/to/at/s30/3.pgm;29
-/path/to/at/s30/4.pgm;29
-/path/to/at/s30/10.pgm;29
-/path/to/at/s30/8.pgm;29
-/path/to/at/s30/1.pgm;29
-/path/to/at/s39/2.pgm;38
-/path/to/at/s39/7.pgm;38
-/path/to/at/s39/6.pgm;38
-/path/to/at/s39/9.pgm;38
-/path/to/at/s39/5.pgm;38
-/path/to/at/s39/3.pgm;38
-/path/to/at/s39/4.pgm;38
-/path/to/at/s39/10.pgm;38
-/path/to/at/s39/8.pgm;38
-/path/to/at/s39/1.pgm;38
-/path/to/at/s35/2.pgm;34
-/path/to/at/s35/7.pgm;34
-/path/to/at/s35/6.pgm;34
-/path/to/at/s35/9.pgm;34
-/path/to/at/s35/5.pgm;34
-/path/to/at/s35/3.pgm;34
-/path/to/at/s35/4.pgm;34
-/path/to/at/s35/10.pgm;34
-/path/to/at/s35/8.pgm;34
-/path/to/at/s35/1.pgm;34
-/path/to/at/s23/2.pgm;22
-/path/to/at/s23/7.pgm;22
-/path/to/at/s23/6.pgm;22
-/path/to/at/s23/9.pgm;22
-/path/to/at/s23/5.pgm;22
-/path/to/at/s23/3.pgm;22
-/path/to/at/s23/4.pgm;22
-/path/to/at/s23/10.pgm;22
-/path/to/at/s23/8.pgm;22
-/path/to/at/s23/1.pgm;22
-/path/to/at/s4/2.pgm;3
-/path/to/at/s4/7.pgm;3
-/path/to/at/s4/6.pgm;3
-/path/to/at/s4/9.pgm;3
-/path/to/at/s4/5.pgm;3
-/path/to/at/s4/3.pgm;3
-/path/to/at/s4/4.pgm;3
-/path/to/at/s4/10.pgm;3
-/path/to/at/s4/8.pgm;3
-/path/to/at/s4/1.pgm;3
-/path/to/at/s9/2.pgm;8
-/path/to/at/s9/7.pgm;8
-/path/to/at/s9/6.pgm;8
-/path/to/at/s9/9.pgm;8
-/path/to/at/s9/5.pgm;8
-/path/to/at/s9/3.pgm;8
-/path/to/at/s9/4.pgm;8
-/path/to/at/s9/10.pgm;8
-/path/to/at/s9/8.pgm;8
-/path/to/at/s9/1.pgm;8
-/path/to/at/s37/2.pgm;36
-/path/to/at/s37/7.pgm;36
-/path/to/at/s37/6.pgm;36
-/path/to/at/s37/9.pgm;36
-/path/to/at/s37/5.pgm;36
-/path/to/at/s37/3.pgm;36
-/path/to/at/s37/4.pgm;36
-/path/to/at/s37/10.pgm;36
-/path/to/at/s37/8.pgm;36
-/path/to/at/s37/1.pgm;36
-/path/to/at/s24/2.pgm;23
-/path/to/at/s24/7.pgm;23
-/path/to/at/s24/6.pgm;23
-/path/to/at/s24/9.pgm;23
-/path/to/at/s24/5.pgm;23
-/path/to/at/s24/3.pgm;23
-/path/to/at/s24/4.pgm;23
-/path/to/at/s24/10.pgm;23
-/path/to/at/s24/8.pgm;23
-/path/to/at/s24/1.pgm;23
-/path/to/at/s19/2.pgm;18
-/path/to/at/s19/7.pgm;18
-/path/to/at/s19/6.pgm;18
-/path/to/at/s19/9.pgm;18
-/path/to/at/s19/5.pgm;18
-/path/to/at/s19/3.pgm;18
-/path/to/at/s19/4.pgm;18
-/path/to/at/s19/10.pgm;18
-/path/to/at/s19/8.pgm;18
-/path/to/at/s19/1.pgm;18
-/path/to/at/s8/2.pgm;7
-/path/to/at/s8/7.pgm;7
-/path/to/at/s8/6.pgm;7
-/path/to/at/s8/9.pgm;7
-/path/to/at/s8/5.pgm;7
-/path/to/at/s8/3.pgm;7
-/path/to/at/s8/4.pgm;7
-/path/to/at/s8/10.pgm;7
-/path/to/at/s8/8.pgm;7
-/path/to/at/s8/1.pgm;7
-/path/to/at/s21/2.pgm;20
-/path/to/at/s21/7.pgm;20
-/path/to/at/s21/6.pgm;20
-/path/to/at/s21/9.pgm;20
-/path/to/at/s21/5.pgm;20
-/path/to/at/s21/3.pgm;20
-/path/to/at/s21/4.pgm;20
-/path/to/at/s21/10.pgm;20
-/path/to/at/s21/8.pgm;20
-/path/to/at/s21/1.pgm;20
-/path/to/at/s1/2.pgm;0
-/path/to/at/s1/7.pgm;0
-/path/to/at/s1/6.pgm;0
-/path/to/at/s1/9.pgm;0
-/path/to/at/s1/5.pgm;0
-/path/to/at/s1/3.pgm;0
-/path/to/at/s1/4.pgm;0
-/path/to/at/s1/10.pgm;0
-/path/to/at/s1/8.pgm;0
-/path/to/at/s1/1.pgm;0
-/path/to/at/s7/2.pgm;6
-/path/to/at/s7/7.pgm;6
-/path/to/at/s7/6.pgm;6
-/path/to/at/s7/9.pgm;6
-/path/to/at/s7/5.pgm;6
-/path/to/at/s7/3.pgm;6
-/path/to/at/s7/4.pgm;6
-/path/to/at/s7/10.pgm;6
-/path/to/at/s7/8.pgm;6
-/path/to/at/s7/1.pgm;6
-/path/to/at/s16/2.pgm;15
-/path/to/at/s16/7.pgm;15
-/path/to/at/s16/6.pgm;15
-/path/to/at/s16/9.pgm;15
-/path/to/at/s16/5.pgm;15
-/path/to/at/s16/3.pgm;15
-/path/to/at/s16/4.pgm;15
-/path/to/at/s16/10.pgm;15
-/path/to/at/s16/8.pgm;15
-/path/to/at/s16/1.pgm;15
-/path/to/at/s36/2.pgm;35
-/path/to/at/s36/7.pgm;35
-/path/to/at/s36/6.pgm;35
-/path/to/at/s36/9.pgm;35
-/path/to/at/s36/5.pgm;35
-/path/to/at/s36/3.pgm;35
-/path/to/at/s36/4.pgm;35
-/path/to/at/s36/10.pgm;35
-/path/to/at/s36/8.pgm;35
-/path/to/at/s36/1.pgm;35
-/path/to/at/s25/2.pgm;24
-/path/to/at/s25/7.pgm;24
-/path/to/at/s25/6.pgm;24
-/path/to/at/s25/9.pgm;24
-/path/to/at/s25/5.pgm;24
-/path/to/at/s25/3.pgm;24
-/path/to/at/s25/4.pgm;24
-/path/to/at/s25/10.pgm;24
-/path/to/at/s25/8.pgm;24
-/path/to/at/s25/1.pgm;24
-/path/to/at/s14/2.pgm;13
-/path/to/at/s14/7.pgm;13
-/path/to/at/s14/6.pgm;13
-/path/to/at/s14/9.pgm;13
-/path/to/at/s14/5.pgm;13
-/path/to/at/s14/3.pgm;13
-/path/to/at/s14/4.pgm;13
-/path/to/at/s14/10.pgm;13
-/path/to/at/s14/8.pgm;13
-/path/to/at/s14/1.pgm;13
-/path/to/at/s34/2.pgm;33
-/path/to/at/s34/7.pgm;33
-/path/to/at/s34/6.pgm;33
-/path/to/at/s34/9.pgm;33
-/path/to/at/s34/5.pgm;33
-/path/to/at/s34/3.pgm;33
-/path/to/at/s34/4.pgm;33
-/path/to/at/s34/10.pgm;33
-/path/to/at/s34/8.pgm;33
-/path/to/at/s34/1.pgm;33
-/path/to/at/s11/2.pgm;10
-/path/to/at/s11/7.pgm;10
-/path/to/at/s11/6.pgm;10
-/path/to/at/s11/9.pgm;10
-/path/to/at/s11/5.pgm;10
-/path/to/at/s11/3.pgm;10
-/path/to/at/s11/4.pgm;10
-/path/to/at/s11/10.pgm;10
-/path/to/at/s11/8.pgm;10
-/path/to/at/s11/1.pgm;10
-/path/to/at/s26/2.pgm;25
-/path/to/at/s26/7.pgm;25
-/path/to/at/s26/6.pgm;25
-/path/to/at/s26/9.pgm;25
-/path/to/at/s26/5.pgm;25
-/path/to/at/s26/3.pgm;25
-/path/to/at/s26/4.pgm;25
-/path/to/at/s26/10.pgm;25
-/path/to/at/s26/8.pgm;25
-/path/to/at/s26/1.pgm;25
-/path/to/at/s18/2.pgm;17
-/path/to/at/s18/7.pgm;17
-/path/to/at/s18/6.pgm;17
-/path/to/at/s18/9.pgm;17
-/path/to/at/s18/5.pgm;17
-/path/to/at/s18/3.pgm;17
-/path/to/at/s18/4.pgm;17
-/path/to/at/s18/10.pgm;17
-/path/to/at/s18/8.pgm;17
-/path/to/at/s18/1.pgm;17
-/path/to/at/s29/2.pgm;28
-/path/to/at/s29/7.pgm;28
-/path/to/at/s29/6.pgm;28
-/path/to/at/s29/9.pgm;28
-/path/to/at/s29/5.pgm;28
-/path/to/at/s29/3.pgm;28
-/path/to/at/s29/4.pgm;28
-/path/to/at/s29/10.pgm;28
-/path/to/at/s29/8.pgm;28
-/path/to/at/s29/1.pgm;28
-/path/to/at/s33/2.pgm;32
-/path/to/at/s33/7.pgm;32
-/path/to/at/s33/6.pgm;32
-/path/to/at/s33/9.pgm;32
-/path/to/at/s33/5.pgm;32
-/path/to/at/s33/3.pgm;32
-/path/to/at/s33/4.pgm;32
-/path/to/at/s33/10.pgm;32
-/path/to/at/s33/8.pgm;32
-/path/to/at/s33/1.pgm;32
-/path/to/at/s12/2.pgm;11
-/path/to/at/s12/7.pgm;11
-/path/to/at/s12/6.pgm;11
-/path/to/at/s12/9.pgm;11
-/path/to/at/s12/5.pgm;11
-/path/to/at/s12/3.pgm;11
-/path/to/at/s12/4.pgm;11
-/path/to/at/s12/10.pgm;11
-/path/to/at/s12/8.pgm;11
-/path/to/at/s12/1.pgm;11
-/path/to/at/s6/2.pgm;5
-/path/to/at/s6/7.pgm;5
-/path/to/at/s6/6.pgm;5
-/path/to/at/s6/9.pgm;5
-/path/to/at/s6/5.pgm;5
-/path/to/at/s6/3.pgm;5
-/path/to/at/s6/4.pgm;5
-/path/to/at/s6/10.pgm;5
-/path/to/at/s6/8.pgm;5
-/path/to/at/s6/1.pgm;5
-/path/to/at/s22/2.pgm;21
-/path/to/at/s22/7.pgm;21
-/path/to/at/s22/6.pgm;21
-/path/to/at/s22/9.pgm;21
-/path/to/at/s22/5.pgm;21
-/path/to/at/s22/3.pgm;21
-/path/to/at/s22/4.pgm;21
-/path/to/at/s22/10.pgm;21
-/path/to/at/s22/8.pgm;21
-/path/to/at/s22/1.pgm;21
-/path/to/at/s15/2.pgm;14
-/path/to/at/s15/7.pgm;14
-/path/to/at/s15/6.pgm;14
-/path/to/at/s15/9.pgm;14
-/path/to/at/s15/5.pgm;14
-/path/to/at/s15/3.pgm;14
-/path/to/at/s15/4.pgm;14
-/path/to/at/s15/10.pgm;14
-/path/to/at/s15/8.pgm;14
-/path/to/at/s15/1.pgm;14
-/path/to/at/s2/2.pgm;1
-/path/to/at/s2/7.pgm;1
-/path/to/at/s2/6.pgm;1
-/path/to/at/s2/9.pgm;1
-/path/to/at/s2/5.pgm;1
-/path/to/at/s2/3.pgm;1
-/path/to/at/s2/4.pgm;1
-/path/to/at/s2/10.pgm;1
-/path/to/at/s2/8.pgm;1
-/path/to/at/s2/1.pgm;1
-/path/to/at/s31/2.pgm;30
-/path/to/at/s31/7.pgm;30
-/path/to/at/s31/6.pgm;30
-/path/to/at/s31/9.pgm;30
-/path/to/at/s31/5.pgm;30
-/path/to/at/s31/3.pgm;30
-/path/to/at/s31/4.pgm;30
-/path/to/at/s31/10.pgm;30
-/path/to/at/s31/8.pgm;30
-/path/to/at/s31/1.pgm;30
-/path/to/at/s28/2.pgm;27
-/path/to/at/s28/7.pgm;27
-/path/to/at/s28/6.pgm;27
-/path/to/at/s28/9.pgm;27
-/path/to/at/s28/5.pgm;27
-/path/to/at/s28/3.pgm;27
-/path/to/at/s28/4.pgm;27
-/path/to/at/s28/10.pgm;27
-/path/to/at/s28/8.pgm;27
-/path/to/at/s28/1.pgm;27
-/path/to/at/s40/2.pgm;39
-/path/to/at/s40/7.pgm;39
-/path/to/at/s40/6.pgm;39
-/path/to/at/s40/9.pgm;39
-/path/to/at/s40/5.pgm;39
-/path/to/at/s40/3.pgm;39
-/path/to/at/s40/4.pgm;39
-/path/to/at/s40/10.pgm;39
-/path/to/at/s40/8.pgm;39
-/path/to/at/s40/1.pgm;39
-/path/to/at/s3/2.pgm;2
-/path/to/at/s3/7.pgm;2
-/path/to/at/s3/6.pgm;2
-/path/to/at/s3/9.pgm;2
-/path/to/at/s3/5.pgm;2
-/path/to/at/s3/3.pgm;2
-/path/to/at/s3/4.pgm;2
-/path/to/at/s3/10.pgm;2
-/path/to/at/s3/8.pgm;2
-/path/to/at/s3/1.pgm;2
-/path/to/at/s38/2.pgm;37
-/path/to/at/s38/7.pgm;37
-/path/to/at/s38/6.pgm;37
-/path/to/at/s38/9.pgm;37
-/path/to/at/s38/5.pgm;37
-/path/to/at/s38/3.pgm;37
-/path/to/at/s38/4.pgm;37
-/path/to/at/s38/10.pgm;37
-/path/to/at/s38/8.pgm;37
-/path/to/at/s38/1.pgm;37
diff --git a/samples/cpp/facerec_demo.cpp b/samples/cpp/facerec_demo.cpp
deleted file mode 100644 (file)
index 3a104b8..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>.
- * Released to public domain under terms of the BSD Simplified license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *   * Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   * Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *   * Neither the name of the organization nor the names of its contributors
- *     may be used to endorse or promote products derived from this software
- *     without specific prior written permission.
- *
- *   See <http://www.opensource.org/licenses/bsd-license>
- */
-
-#include "opencv2/core.hpp"
-#include "opencv2/core/utility.hpp"
-#include "opencv2/highgui.hpp"
-#include "opencv2/contrib.hpp"
-
-#include <iostream>
-#include <fstream>
-#include <sstream>
-
-using namespace cv;
-using namespace std;
-
-static Mat toGrayscale(InputArray _src) {
-    Mat src = _src.getMat();
-    // only allow one channel
-    if(src.channels() != 1) {
-        CV_Error(Error::StsBadArg, "Only Matrices with one channel are supported");
-    }
-    // create and return normalized image
-    Mat dst;
-    cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
-    return dst;
-}
-
-static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
-    std::ifstream file(filename.c_str(), ifstream::in);
-    if (!file) {
-        string error_message = "No valid input file was given, please check the given filename.";
-        CV_Error(Error::StsBadArg, error_message);
-    }
-    string line, path, classlabel;
-    while (getline(file, line)) {
-        stringstream liness(line);
-        getline(liness, path, separator);
-        getline(liness, classlabel);
-        if(!path.empty() && !classlabel.empty()) {
-            images.push_back(imread(path, 0));
-            labels.push_back(atoi(classlabel.c_str()));
-        }
-    }
-}
-
-int main(int argc, const char *argv[]) {
-    // Check for valid command line arguments, print usage
-    // if no arguments were given.
-    if (argc != 2) {
-        cout << "usage: " << argv[0] << " <csv.ext>" << endl;
-        exit(1);
-    }
-    // Get the path to your CSV.
-    string fn_csv = string(argv[1]);
-    // These vectors hold the images and corresponding labels.
-    vector<Mat> images;
-    vector<int> labels;
-    // Read in the data. This can fail if no valid
-    // input filename is given.
-    try {
-        read_csv(fn_csv, images, labels);
-    } catch (cv::Exception& e) {
-        cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
-        // nothing more we can do
-        exit(1);
-    }
-    // Quit if there are not enough images for this demo.
-    if(images.size() <= 1) {
-        string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
-        CV_Error(Error::StsError, error_message);
-    }
-    // Get the height from the first image. We'll need this
-    // later in code to reshape the images to their original
-    // size:
-    int height = images[0].rows;
-    // The following lines simply get the last images from
-    // your dataset and remove it from the vector. This is
-    // done, so that the training data (which we learn the
-    // cv::FaceRecognizer on) and the test data we test
-    // the model with, do not overlap.
-    Mat testSample = images[images.size() - 1];
-    int testLabel = labels[labels.size() - 1];
-    images.pop_back();
-    labels.pop_back();
-    // The following lines create an Eigenfaces model for
-    // face recognition and train it with the images and
-    // labels read from the given CSV file.
-    // This here is a full PCA, if you just want to keep
-    // 10 principal components (read Eigenfaces), then call
-    // the factory method like this:
-    //
-    //      cv::createEigenFaceRecognizer(10);
-    //
-    // If you want to create a FaceRecognizer with a
-    // confidennce threshold, call it with:
-    //
-    //      cv::createEigenFaceRecognizer(10, 123.0);
-    //
-    Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
-    model->train(images, labels);
-    // The following line predicts the label of a given
-    // test image:
-    int predictedLabel = model->predict(testSample);
-    //
-    // To get the confidence of a prediction call the model with:
-    //
-    //      int predictedLabel = -1;
-    //      double confidence = 0.0;
-    //      model->predict(testSample, predictedLabel, confidence);
-    //
-    string result_message = format("Predicted class = %d / Actual class = %d.", predictedLabel, testLabel);
-    cout << result_message << endl;
-    // Sometimes you'll need to get/set internal model data,
-    // which isn't exposed by the public cv::FaceRecognizer.
-    // Since each cv::FaceRecognizer is derived from a
-    // cv::Algorithm, you can query the data.
-    //
-    // First we'll use it to set the threshold of the FaceRecognizer
-    // to 0.0 without retraining the model. This can be useful if
-    // you are evaluating the model:
-    //
-    model->set("threshold", 0.0);
-    // Now the threshold of this model is set to 0.0. A prediction
-    // now returns -1, as it's impossible to have a distance below
-    // it
-    predictedLabel = model->predict(testSample);
-    cout << "Predicted class = " << predictedLabel << endl;
-    // Here is how to get the eigenvalues of this Eigenfaces model:
-    Mat eigenvalues = model->getMat("eigenvalues");
-    // And we can do the same to display the Eigenvectors (read Eigenfaces):
-    Mat W = model->getMat("eigenvectors");
-    // From this we will display the (at most) first 10 Eigenfaces:
-    for (int i = 0; i < min(10, W.cols); i++) {
-        string msg = format("Eigenvalue #%d = %.5f", i, eigenvalues.at<double>(i));
-        cout << msg << endl;
-        // get eigenvector #i
-        Mat ev = W.col(i).clone();
-        // Reshape to original size & normalize to [0...255] for imshow.
-        Mat grayscale = toGrayscale(ev.reshape(1, height));
-        // Show the image & apply a Jet colormap for better sensing.
-        Mat cgrayscale;
-        applyColorMap(grayscale, cgrayscale, COLORMAP_JET);
-        imshow(format("%d", i), cgrayscale);
-    }
-    waitKey(0);
-
-    return 0;
-}
diff --git a/samples/cpp/fern_params.xml b/samples/cpp/fern_params.xml
deleted file mode 100644 (file)
index d083534..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0"?>
-<opencv_storage>
-    <nclasses>0</nclasses>
-    <patchSize>31</patchSize>
-    <signatureSize>INT_MAX</signatureSize>
-    <nstructs>50</nstructs>
-    <structSize>9</structSize>
-    <nviews>1000</nviews>
-    <compressionMethod>0</compressionMethod>
-</opencv_storage>
diff --git a/samples/cpp/freak_demo.cpp b/samples/cpp/freak_demo.cpp
deleted file mode 100644 (file)
index 140b28f..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-//  demo.cpp
-//
-//     Here is an example on how to use the descriptor presented in the following paper:
-//     A. Alahi, R. Ortiz, and P. Vandergheynst. FREAK: Fast Retina Keypoint. In IEEE Conference on Computer Vision and Pattern Recognition, 2012.
-//  CVPR 2012 Open Source Award winner
-//
-//     Copyright (C) 2011-2012  Signal processing laboratory 2, EPFL,
-//     Kirell Benzi (kirell.benzi@epfl.ch),
-//     Raphael Ortiz (raphael.ortiz@a3.epfl.ch),
-//     Alexandre Alahi (alexandre.alahi@epfl.ch)
-//     and Pierre Vandergheynst (pierre.vandergheynst@epfl.ch)
-//
-//  Redistribution and use in source and binary forms, with or without modification,
-//  are permitted provided that the following conditions are met:
-//
-//   * Redistribution's of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//
-//   * Redistribution's in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//
-//   * The name of the copyright holders may not be used to endorse or promote products
-//     derived from this software without specific prior written permission.
-//
-//  This software is provided by the copyright holders and contributors "as is" and
-//  any express or implied warranties, including, but not limited to, the implied
-//  warranties of merchantability and fitness for a particular purpose are disclaimed.
-//  In no event shall the Intel Corporation or contributors be liable for any direct,
-//  indirect, incidental, special, exemplary, or consequential damages
-//  (including, but not limited to, procurement of substitute goods or services;
-//  loss of use, data, or profits; or business interruption) however caused
-//  and on any theory of liability, whether in contract, strict liability,
-//  or tort (including negligence or otherwise) arising in any way out of
-//  the use of this software, even if advised of the possibility of such damage.
-
-#include <iostream>
-#include <string>
-#include <vector>
-
-#include <opencv2/core.hpp>
-#include "opencv2/core/utility.hpp"
-#include <opencv2/highgui.hpp>
-#include <opencv2/features2d.hpp>
-#include <opencv2/nonfree.hpp>
-
-using namespace cv;
-
-static void help( char** argv )
-{
-    std::cout << "\nUsage: " << argv[0] << " [path/to/image1] [path/to/image2] \n"
-              << "This is an example on how to use the keypoint descriptor presented in the following paper: \n"
-              << "A. Alahi, R. Ortiz, and P. Vandergheynst. FREAK: Fast Retina Keypoint. \n"
-              << "In IEEE Conference on Computer Vision and Pattern Recognition, 2012. CVPR 2012 Open Source Award winner \n"
-              << std::endl;
-}
-
-int main( int argc, char** argv ) {
-    // check http://docs.opencv.org/doc/tutorials/features2d/table_of_content_features2d/table_of_content_features2d.html
-    // for OpenCV general detection/matching framework details
-
-    if( argc != 3 ) {
-        help(argv);
-        return -1;
-    }
-
-    // Load images
-    Mat imgA = imread(argv[1], IMREAD_GRAYSCALE );
-    if( !imgA.data ) {
-        std::cout<< " --(!) Error reading image " << argv[1] << std::endl;
-        return -1;
-    }
-
-    Mat imgB = imread(argv[2], IMREAD_GRAYSCALE );
-    if( !imgB.data ) {
-        std::cout << " --(!) Error reading image " << argv[2] << std::endl;
-        return -1;
-    }
-
-    std::vector<KeyPoint> keypointsA, keypointsB;
-    Mat descriptorsA, descriptorsB;
-    std::vector<DMatch> matches;
-
-    // DETECTION
-    // Any openCV detector such as
-    SurfFeatureDetector detector(2000,4);
-
-    // DESCRIPTOR
-    // Our proposed FREAK descriptor
-    // (rotation invariance, scale invariance, pattern radius corresponding to SMALLEST_KP_SIZE,
-    // number of octaves, optional vector containing the selected pairs)
-    // FREAK extractor(true, true, 22, 4, std::vector<int>());
-    FREAK extractor;
-
-    // MATCHER
-    // The standard Hamming distance can be used such as
-    // BFMatcher matcher(NORM_HAMMING);
-    // or the proposed cascade of hamming distance using SSSE3
-    BFMatcher matcher(extractor.defaultNorm());
-
-    // detect
-    double t = (double)getTickCount();
-    detector.detect( imgA, keypointsA );
-    detector.detect( imgB, keypointsB );
-    t = ((double)getTickCount() - t)/getTickFrequency();
-    std::cout << "detection time [s]: " << t/1.0 << std::endl;
-
-    // extract
-    t = (double)getTickCount();
-    extractor.compute( imgA, keypointsA, descriptorsA );
-    extractor.compute( imgB, keypointsB, descriptorsB );
-    t = ((double)getTickCount() - t)/getTickFrequency();
-    std::cout << "extraction time [s]: " << t << std::endl;
-
-    // match
-    t = (double)getTickCount();
-    matcher.match(descriptorsA, descriptorsB, matches);
-    t = ((double)getTickCount() - t)/getTickFrequency();
-    std::cout << "matching time [s]: " << t << std::endl;
-
-    // Draw matches
-    Mat imgMatch;
-    drawMatches(imgA, keypointsA, imgB, keypointsB, matches, imgMatch);
-
-    namedWindow("matches", WINDOW_KEEPRATIO);
-    imshow("matches", imgMatch);
-    waitKey(0);
-}
diff --git a/samples/cpp/gencolors.cpp b/samples/cpp/gencolors.cpp
deleted file mode 100644 (file)
index e95d2a9..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "opencv2/imgproc/imgproc.hpp"
-#include "opencv2/contrib/contrib.hpp"
-#include "opencv2/highgui/highgui.hpp"
-
-#include <cstdio>
-#include <iostream>
-#include <ctime>
-
-using namespace cv;
-using namespace std;
-
-int main(int argc, char** argv)
-{
-    if( argc != 2 )
-    {
-        cout << "Colors count should be passed." << endl;
-        return -1;
-    }
-
-    int colorsCount = atoi(argv[1]);
-    vector<Scalar> colors;
-    theRNG() = (uint64)time(0);
-    generateColors( colors, colorsCount );
-
-    int stripWidth = 20;
-    Mat strips(300, colorsCount*stripWidth, CV_8UC3);
-    for( int i = 0; i < colorsCount; i++ )
-    {
-        strips.colRange(i*stripWidth, (i+1)*stripWidth) = colors[i];
-    }
-
-    imshow( "strips", strips );
-    waitKey();
-
-    return 0;
-}
diff --git a/samples/cpp/generic_descriptor_match.cpp b/samples/cpp/generic_descriptor_match.cpp
deleted file mode 100644 (file)
index 01bb10c..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#include "opencv2/calib3d/calib3d.hpp"
-#include "opencv2/features2d/features2d.hpp"
-#include "opencv2/highgui/highgui.hpp"
-#include "opencv2/imgproc/imgproc.hpp"
-#include "opencv2/nonfree/nonfree.hpp"
-
-#include <cstdio>
-
-using namespace std;
-using namespace cv;
-
-static void help()
-{
-    printf("Use the SURF descriptor for matching keypoints between 2 images\n");
-    printf("Format: \n./generic_descriptor_match <image1> <image2> <algorithm> <XML params>\n");
-    printf("For example: ./generic_descriptor_match ../c/scene_l.bmp ../c/scene_r.bmp FERN fern_params.xml\n");
-}
-
-Mat DrawCorrespondences(const Mat& img1, const vector<KeyPoint>& features1, const Mat& img2,
-                        const vector<KeyPoint>& features2, const vector<DMatch>& desc_idx);
-
-int main(int argc, char** argv)
-{
-    if (argc != 5)
-    {
-        help();
-        return 0;
-    }
-
-    std::string img1_name = std::string(argv[1]);
-    std::string img2_name = std::string(argv[2]);
-    std::string alg_name = std::string(argv[3]);
-    std::string params_filename = std::string(argv[4]);
-
-    Ptr<GenericDescriptorMatcher> descriptorMatcher = GenericDescriptorMatcher::create(alg_name, params_filename);
-    if( !descriptorMatcher )
-    {
-        printf ("Cannot create descriptor\n");
-        return 0;
-    }
-
-    //printf("Reading the images...\n");
-    Mat img1 = imread(img1_name, IMREAD_GRAYSCALE);
-    Mat img2 = imread(img2_name, IMREAD_GRAYSCALE);
-
-    // extract keypoints from the first image
-    SURF surf_extractor(5.0e3);
-    vector<KeyPoint> keypoints1;
-
-    // printf("Extracting keypoints\n");
-    surf_extractor(img1, Mat(), keypoints1);
-
-    printf("Extracted %d keypoints from the first image\n", (int)keypoints1.size());
-
-    vector<KeyPoint> keypoints2;
-    surf_extractor(img2, Mat(), keypoints2);
-    printf("Extracted %d keypoints from the second image\n", (int)keypoints2.size());
-
-    printf("Finding nearest neighbors... \n");
-    // find NN for each of keypoints2 in keypoints1
-    vector<DMatch> matches2to1;
-    descriptorMatcher->match( img2, keypoints2, img1, keypoints1, matches2to1 );
-    printf("Done\n");
-
-    Mat img_corr = DrawCorrespondences(img1, keypoints1, img2, keypoints2, matches2to1);
-
-    imshow("correspondences", img_corr);
-    waitKey(0);
-}
-
-Mat DrawCorrespondences(const Mat& img1, const vector<KeyPoint>& features1, const Mat& img2,
-                        const vector<KeyPoint>& features2, const vector<DMatch>& desc_idx)
-{
-    Mat part, img_corr(Size(img1.cols + img2.cols, MAX(img1.rows, img2.rows)), CV_8UC3);
-    img_corr = Scalar::all(0);
-    part = img_corr(Rect(0, 0, img1.cols, img1.rows));
-    cvtColor(img1, part, COLOR_GRAY2RGB);
-    part = img_corr(Rect(img1.cols, 0, img2.cols, img2.rows));
-    cvtColor(img1, part, COLOR_GRAY2RGB);
-
-    for (size_t i = 0; i < features1.size(); i++)
-    {
-        circle(img_corr, features1[i].pt, 3, Scalar(0, 0, 255));
-    }
-
-    for (size_t i = 0; i < features2.size(); i++)
-    {
-        Point pt(cvRound(features2[i].pt.x + img1.cols), cvRound(features2[i].pt.y));
-        circle(img_corr, pt, 3, Scalar(0, 0, 255));
-        line(img_corr, features1[desc_idx[i].trainIdx].pt, pt, Scalar(0, 255, 0));
-    }
-
-    return img_corr;
-}
diff --git a/samples/cpp/hybridtrackingsample.cpp b/samples/cpp/hybridtrackingsample.cpp
deleted file mode 100644 (file)
index d5a91cb..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- *
- * Hybrid Tracking in OpenCV
- * Usage: ./hybridtrackingsample live
- *
- * For Benchmarking against the Bonn benchmark dataset
- * wget http://www.iai.uni-bonn.de/~kleind/tracking/datasets/seqG.zip
- * unzip seqG.zip -d ./seqG
- * ffmpeg -i seqG/Vid_G_rubikscube.avi seqG/%04d.png
- * ./hytrack seqG/Vid_G_rubikscube.txt
- *
- */
-
-#include <stdio.h>
-#include <time.h>
-#include <iostream>
-
-#include "opencv2/highgui/highgui.hpp"
-#include "opencv2/contrib/hybridtracker.hpp"
-
-#ifndef _CRT_SECURE_NO_WARNINGS
-# define _CRT_SECURE_NO_WARNINGS
-#endif
-
-using namespace cv;
-using namespace std;
-
-Mat frame, image;
-Rect selection;
-Point origin;
-bool selectObject = false;
-int trackObject = 0;
-int live = 1;
-
-static void drawRectangle(Mat* img, Rect win) {
-    rectangle(*img, Point(win.x, win.y), Point(win.x + win.width, win.y
-            + win.height), Scalar(0, 255, 0), 2, CV_AA);
-}
-
-static void onMouse(int event, int x, int y, int, void*) {
-    if (selectObject) {
-        selection.x = MIN(x, origin.x);
-        selection.y = MIN(y, origin.y);
-        selection.width = std::abs(x - origin.x);
-        selection.height = std::abs(y - origin.y);
-        selection &= Rect(0, 0, image.cols, image.rows);
-    }
-
-    switch (event) {
-    case EVENT_LBUTTONDOWN:
-        origin = Point(x, y);
-        selection = Rect(x, y, 0, 0);
-        selectObject = true;
-        break;
-    case EVENT_LBUTTONUP:
-        selectObject = false;
-        trackObject = -1;
-        break;
-    }
-}
-
-static void help()
-{
-    printf("Usage: ./hytrack live or ./hytrack <test_file> \n\
-For Live View or Benchmarking. Read documentation is source code.\n\n");
-}
-
-
-int main(int argc, char** argv)
-{
-    if(argc != 2) {
-        help();
-        return 1;
-    }
-
-    FILE* f = 0;
-    VideoCapture cap;
-    char test_file[20] = "";
-
-    if (strcmp(argv[1], "live") != 0)
-    {
-        sprintf(test_file, "%s", argv[1]);
-        f = fopen(test_file, "r");
-        char vid[20];
-        int values_read = fscanf(f, "%s\n", vid);
-        CV_Assert(values_read == 1);
-        cout << "Benchmarking against " << vid << endl;
-        live = 0;
-    }
-    else
-    {
-        cap.open(0);
-        if (!cap.isOpened())
-        {
-            cout << "Failed to open camera" << endl;
-            return 0;
-        }
-        cout << "Opened camera" << endl;
-        cap.set(CAP_PROP_FRAME_WIDTH, 640);
-        cap.set(CAP_PROP_FRAME_HEIGHT, 480);
-        cap >> frame;
-    }
-
-    HybridTrackerParams params;
-    // motion model params
-    params.motion_model = CvMotionModel::LOW_PASS_FILTER;
-    params.low_pass_gain = 0.1f;
-    // mean shift params
-    params.ms_tracker_weight = 0.8f;
-    params.ms_params.tracking_type = CvMeanShiftTrackerParams::HS;
-    // feature tracking params
-    params.ft_tracker_weight = 0.2f;
-    params.ft_params.feature_type = CvFeatureTrackerParams::OPTICAL_FLOW;
-    params.ft_params.window_size = 0;
-
-    HybridTracker tracker(params);
-    char img_file[20] = "seqG/0001.png";
-    char img_file_num[10];
-    namedWindow("Win", 1);
-
-    setMouseCallback("Win", onMouse, 0);
-
-    int i = 0;
-    float w[4];
-    for(;;)
-    {
-        i++;
-        if (live)
-        {
-            cap >> frame;
-            if( frame.empty() )
-                break;
-            frame.copyTo(image);
-        }
-        else
-        {
-            int values_read = fscanf(f, "%d %f %f %f %f\n", &i, &w[0], &w[1], &w[2], &w[3]);
-            CV_Assert(values_read == 5);
-            sprintf(img_file, "seqG/%04d.png", i);
-            image = imread(img_file, IMREAD_COLOR);
-            if (image.empty())
-                break;
-            selection = Rect(cvRound(w[0]*image.cols), cvRound(w[1]*image.rows),
-                             cvRound(w[2]*image.cols), cvRound(w[3]*image.rows));
-        }
-
-        sprintf(img_file_num, "Frame: %d", i);
-        putText(image, img_file_num, Point(10, image.rows-20), FONT_HERSHEY_PLAIN, 0.75, Scalar(255, 255, 255));
-        if (!image.empty())
-        {
-
-            if (trackObject < 0)
-            {
-                tracker.newTracker(image, selection);
-                trackObject = 1;
-            }
-
-            if (trackObject)
-            {
-                tracker.updateTracker(image);
-                drawRectangle(&image, tracker.getTrackingWindow());
-            }
-
-            if (selectObject && selection.width > 0 && selection.height > 0)
-            {
-                Mat roi(image, selection);
-                bitwise_not(roi, roi);
-            }
-
-            drawRectangle(&image, Rect(cvRound(w[0]*image.cols), cvRound(w[1]*image.rows),
-                                       cvRound(w[2]*image.cols), cvRound(w[3]*image.rows)));
-            imshow("Win", image);
-
-            waitKey(100);
-        }
-        else
-            i = 0;
-    }
-
-    fclose(f);
-    return 0;
-}
index 80f80c7..4d7a571 100644 (file)
@@ -2,12 +2,10 @@
 #include <iostream>
 #include <opencv2/imgproc/imgproc.hpp>
 #include <opencv2/highgui/highgui.hpp>
-#include <opencv2/flann/miniflann.hpp>
 #include <opencv2/core/utility.hpp>
 
 using namespace cv; // all the new API is put into "cv" namespace. Export its content
 using namespace std;
-using namespace cv::flann;
 
 static void help()
 {
diff --git a/samples/cpp/latentsvm_multidetect.cpp b/samples/cpp/latentsvm_multidetect.cpp
deleted file mode 100644 (file)
index d6ea4d5..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-#include <iostream>
-#include "opencv2/objdetect/objdetect.hpp"
-#include "opencv2/highgui/highgui.hpp"
-#include "opencv2/contrib/contrib.hpp"
-
-#if defined(WIN32) || defined(_WIN32)
-#include <io.h>
-#else
-#include <dirent.h>
-#endif
-
-using namespace std;
-using namespace cv;
-
-static void help()
-{
-    cout << "This program demonstrated the use of the latentSVM detector." << endl <<
-            "It reads in a trained object models and then uses them to detect the objects in an images." << endl <<
-             endl <<
-            "Call:" << endl <<
-            "./latentsvm_multidetect <imagesFolder> <modelsFolder> [<overlapThreshold>][<threadsNumber>]" << endl <<
-            "<overlapThreshold> - threshold for the non-maximum suppression algorithm." << endl <<
-            "Example of <modelsFolder> is opencv_extra/testdata/cv/latentsvmdetector/models_VOC2007" << endl <<
-             endl <<
-            "Keys:" << endl <<
-            "'n' - to go to the next image;" << endl <<
-            "'esc' - to quit." << endl <<
-            endl;
-}
-
-static void detectAndDrawObjects( Mat& image, LatentSvmDetector& detector, const vector<Scalar>& colors, float overlapThreshold, int numThreads )
-{
-    vector<LatentSvmDetector::ObjectDetection> detections;
-
-    TickMeter tm;
-    tm.start();
-    detector.detect( image, detections, overlapThreshold, numThreads);
-    tm.stop();
-
-    cout << "Detection time = " << tm.getTimeSec() << " sec" << endl;
-
-    const vector<String> classNames = detector.getClassNames();
-    CV_Assert( colors.size() == classNames.size() );
-
-    for( size_t i = 0; i < detections.size(); i++ )
-    {
-        const LatentSvmDetector::ObjectDetection& od = detections[i];
-        rectangle( image, od.rect, colors[od.classID], 3 );
-    }
-    // put text over the all rectangles
-    for( size_t i = 0; i < detections.size(); i++ )
-    {
-        const LatentSvmDetector::ObjectDetection& od = detections[i];
-        putText( image, classNames[od.classID], Point(od.rect.x+4,od.rect.y+13), FONT_HERSHEY_SIMPLEX, 0.55, colors[od.classID], 2 );
-    }
-}
-
-static void readDirectory( const string& directoryName, vector<String>& filenames, bool addDirectoryName=true )
-{
-    filenames.clear();
-
-#if defined(WIN32) | defined(_WIN32)
-    struct _finddata_t s_file;
-    string str = directoryName + "\\*.*";
-
-    intptr_t h_file = _findfirst( str.c_str(), &s_file );
-    if( h_file != static_cast<intptr_t>(-1.0) )
-    {
-        do
-        {
-            if( addDirectoryName )
-                filenames.push_back(directoryName + "\\" + s_file.name);
-            else
-                filenames.push_back((string)s_file.name);
-        }
-        while( _findnext( h_file, &s_file ) == 0 );
-    }
-    _findclose( h_file );
-#else
-    DIR* dir = opendir( directoryName.c_str() );
-    if( dir != NULL )
-    {
-        struct dirent* dent;
-        while( (dent = readdir(dir)) != NULL )
-        {
-            if( addDirectoryName )
-                filenames.push_back( directoryName + "/" + string(dent->d_name) );
-            else
-                filenames.push_back( string(dent->d_name) );
-        }
-
-        closedir( dir );
-    }
-#endif
-
-    sort( filenames.begin(), filenames.end() );
-}
-
-int main(int argc, char* argv[])
-{
-    help();
-
-    string images_folder, models_folder;
-    float overlapThreshold = 0.2f;
-    int numThreads = -1;
-    if( argc > 2 )
-    {
-        images_folder = argv[1];
-        models_folder = argv[2];
-        if( argc > 3 ) overlapThreshold = (float)atof(argv[3]);
-        if( overlapThreshold < 0 || overlapThreshold > 1)
-        {
-            cout << "overlapThreshold must be in interval (0,1)." << endl;
-            exit(-1);
-        }
-
-        if( argc > 4 ) numThreads = atoi(argv[4]);
-    }
-
-    vector<String> images_filenames, models_filenames;
-    readDirectory( images_folder, images_filenames );
-    readDirectory( models_folder, models_filenames );
-
-    LatentSvmDetector detector( models_filenames );
-    if( detector.empty() )
-    {
-        cout << "Models cann't be loaded" << endl;
-        exit(-1);
-    }
-
-    const vector<String>& classNames = detector.getClassNames();
-    cout << "Loaded " << classNames.size() << " models:" << endl;
-    for( size_t i = 0; i < classNames.size(); i++ )
-    {
-        cout << i << ") " << classNames[i] << "; ";
-    }
-    cout << endl;
-
-    cout << "overlapThreshold = " << overlapThreshold << endl;
-
-    vector<Scalar> colors;
-    generateColors( colors, detector.getClassNames().size() );
-
-    for( size_t i = 0; i < images_filenames.size(); i++ )
-    {
-        Mat image = imread( images_filenames[i] );
-        if( image.empty() )  continue;
-
-        cout << "Process image " << images_filenames[i] << endl;
-        detectAndDrawObjects( image, detector, colors, overlapThreshold, numThreads );
-
-        imshow( "result", image );
-
-        for(;;)
-        {
-            int c = waitKey();
-            if( (char)c == 'n')
-                break;
-            else if( (char)c == '\x1b' )
-                exit(0);
-        }
-    }
-
-    return 0;
-}
diff --git a/samples/cpp/logpolar_bsm.cpp b/samples/cpp/logpolar_bsm.cpp
deleted file mode 100644 (file)
index fc4a4b3..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*Authors
-* Manuela Chessa, Fabio Solari, Fabio Tatti, Silvio P. Sabatini
-*
-* manuela.chessa@unige.it, fabio.solari@unige.it
-*
-* PSPC-lab - University of Genoa
-*/
-
-#include "opencv2/contrib.hpp"
-#include "opencv2/highgui.hpp"
-
-#include <iostream>
-#include <cmath>
-
-using namespace cv;
-using namespace std;
-
-static void help()
-{
-    cout << "LogPolar Blind Spot Model sample.\nShortcuts:"
-        "\n\tn for nearest pixel technique"
-        "\n\tb for bilinear interpolation technique"
-        "\n\to for overlapping circular receptive fields"
-        "\n\ta for adjacent receptive fields"
-        "\n\tq or ESC quit\n";
-}
-
-int main(int argc, char** argv)
-{
-    Mat img = imread(argc > 1 ? argv[1] : "lena.jpg",1); // open the image
-    if(img.empty()) // check if we succeeded
-    {
-        cout << "can not load image\n";
-        return 0;
-    }
-    help();
-
-    Size s=img.size();
-    int w=s.width, h=s.height;
-    int ro0=3; //radius of the blind spot
-    int R=120;  //number of rings
-
-    //Creation of the four different objects that implement the four log-polar transformations
-    //Off-line computation
-    Point2i center(w/2,h/2);
-    LogPolar_Interp nearest(w, h, center, R, ro0, INTER_NEAREST);
-    LogPolar_Interp bilin(w,h, center,R,ro0);
-    LogPolar_Overlapping overlap(w,h,center,R,ro0);
-    LogPolar_Adjacent adj(w,h,center,R,ro0,0.25);
-
-    namedWindow("Cartesian",1);
-    namedWindow("retinal",1);
-    namedWindow("cortical",1);
-    int wk='n';
-    Mat Cortical, Retinal;
-
-    //On-line computation
-    for(;;)
-    {
-        if(wk=='n'){
-            Cortical=nearest.to_cortical(img);
-            Retinal=nearest.to_cartesian(Cortical);
-        }else if (wk=='b'){
-            Cortical=bilin.to_cortical(img);
-            Retinal=bilin.to_cartesian(Cortical);
-        }else if (wk=='o'){
-            Cortical=overlap.to_cortical(img);
-            Retinal=overlap.to_cartesian(Cortical);
-        }else if (wk=='a'){
-            Cortical=adj.to_cortical(img);
-            Retinal=adj.to_cartesian(Cortical);
-        }
-
-        imshow("Cartesian", img);
-        imshow("cortical", Cortical);
-        imshow("retinal", Retinal);
-
-        int c=waitKey(15);
-        if (c>0) wk=c;
-        if(wk =='q' || (wk & 255) == 27) break;
-    }
-
-    return 0;
-}
diff --git a/samples/cpp/matcher_simple.cpp b/samples/cpp/matcher_simple.cpp
deleted file mode 100644 (file)
index 39d3620..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <stdio.h>
-#include "opencv2/core/core.hpp"
-#include "opencv2/features2d/features2d.hpp"
-#include "opencv2/highgui/highgui.hpp"
-#include "opencv2/nonfree/nonfree.hpp"
-
-using namespace std;
-using namespace cv;
-
-static void help()
-{
-    printf("\nThis program demonstrates using features2d detector, descriptor extractor and simple matcher\n"
-            "Using the SURF desriptor:\n"
-            "\n"
-            "Usage:\n matcher_simple <image1> <image2>\n");
-}
-
-int main(int argc, char** argv)
-{
-    if(argc != 3)
-    {
-        help();
-        return -1;
-    }
-
-    Mat img1 = imread(argv[1], IMREAD_GRAYSCALE);
-    Mat img2 = imread(argv[2], IMREAD_GRAYSCALE);
-    if(img1.empty() || img2.empty())
-    {
-        printf("Can't read one of the images\n");
-        return -1;
-    }
-
-    // detecting keypoints
-    SurfFeatureDetector detector(400);
-    vector<KeyPoint> keypoints1, keypoints2;
-    detector.detect(img1, keypoints1);
-    detector.detect(img2, keypoints2);
-
-    // computing descriptors
-    SurfDescriptorExtractor extractor;
-    Mat descriptors1, descriptors2;
-    extractor.compute(img1, keypoints1, descriptors1);
-    extractor.compute(img2, keypoints2, descriptors2);
-
-    // matching descriptors
-    BFMatcher matcher(extractor.defaultNorm());
-    vector<DMatch> matches;
-    matcher.match(descriptors1, descriptors2, matches);
-
-    // drawing the results
-    namedWindow("matches", 1);
-    Mat img_matches;
-    drawMatches(img1, keypoints1, img2, keypoints2, matches, img_matches);
-    imshow("matches", img_matches);
-    waitKey(0);
-
-    return 0;
-}
diff --git a/samples/cpp/matching_to_many_images.cpp b/samples/cpp/matching_to_many_images.cpp
deleted file mode 100644 (file)
index 152b400..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-#include "opencv2/highgui/highgui.hpp"
-#include "opencv2/features2d/features2d.hpp"
-#include "opencv2/contrib/contrib.hpp"
-
-#include <iostream>
-#include <fstream>
-
-using namespace cv;
-using namespace std;
-
-const string defaultDetectorType = "SURF";
-const string defaultDescriptorType = "SURF";
-const string defaultMatcherType = "FlannBased";
-const string defaultQueryImageName = "../../opencv/samples/cpp/matching_to_many_images/query.png";
-const string defaultFileWithTrainImages = "../../opencv/samples/cpp/matching_to_many_images/train/trainImages.txt";
-const string defaultDirToSaveResImages = "../../opencv/samples/cpp/matching_to_many_images/results";
-
-static void printPrompt( const string& applName )
-{
-    cout << "/*\n"
-         << " * This is a sample on matching descriptors detected on one image to descriptors detected in image set.\n"
-         << " * So we have one query image and several train images. For each keypoint descriptor of query image\n"
-         << " * the one nearest train descriptor is found the entire collection of train images. To visualize the result\n"
-         << " * of matching we save images, each of which combines query and train image with matches between them (if they exist).\n"
-         << " * Match is drawn as line between corresponding points. Count of all matches is equel to count of\n"
-         << " * query keypoints, so we have the same count of lines in all set of result images (but not for each result\n"
-         << " * (train) image).\n"
-         << " */\n" << endl;
-
-    cout << endl << "Format:\n" << endl;
-    cout << "./" << applName << " [detectorType] [descriptorType] [matcherType] [queryImage] [fileWithTrainImages] [dirToSaveResImages]" << endl;
-    cout << endl;
-
-    cout << "\nExample:" << endl
-         << "./" << applName << " " << defaultDetectorType << " " << defaultDescriptorType << " " << defaultMatcherType << " "
-         << defaultQueryImageName << " " << defaultFileWithTrainImages << " " << defaultDirToSaveResImages << endl;
-}
-
-static void maskMatchesByTrainImgIdx( const vector<DMatch>& matches, int trainImgIdx, vector<char>& mask )
-{
-    mask.resize( matches.size() );
-    fill( mask.begin(), mask.end(), 0 );
-    for( size_t i = 0; i < matches.size(); i++ )
-    {
-        if( matches[i].imgIdx == trainImgIdx )
-            mask[i] = 1;
-    }
-}
-
-static void readTrainFilenames( const string& filename, string& dirName, vector<string>& trainFilenames )
-{
-    trainFilenames.clear();
-
-    ifstream file( filename.c_str() );
-    if ( !file.is_open() )
-        return;
-
-    size_t pos = filename.rfind('\\');
-    char dlmtr = '\\';
-    if (pos == string::npos)
-    {
-        pos = filename.rfind('/');
-        dlmtr = '/';
-    }
-    dirName = pos == string::npos ? "" : filename.substr(0, pos) + dlmtr;
-
-    while( !file.eof() )
-    {
-        string str; getline( file, str );
-        if( str.empty() ) break;
-        trainFilenames.push_back(str);
-    }
-    file.close();
-}
-
-static bool createDetectorDescriptorMatcher( const string& detectorType, const string& descriptorType, const string& matcherType,
-                                      Ptr<FeatureDetector>& featureDetector,
-                                      Ptr<DescriptorExtractor>& descriptorExtractor,
-                                      Ptr<DescriptorMatcher>& descriptorMatcher )
-{
-    cout << "< Creating feature detector, descriptor extractor and descriptor matcher ..." << endl;
-    featureDetector = FeatureDetector::create( detectorType );
-    descriptorExtractor = DescriptorExtractor::create( descriptorType );
-    descriptorMatcher = DescriptorMatcher::create( matcherType );
-    cout << ">" << endl;
-
-    bool isCreated = featureDetector && descriptorExtractor && descriptorMatcher;
-    if( !isCreated )
-        cout << "Can not create feature detector or descriptor extractor or descriptor matcher of given types." << endl << ">" << endl;
-
-    return isCreated;
-}
-
-static bool readImages( const string& queryImageName, const string& trainFilename,
-                 Mat& queryImage, vector <Mat>& trainImages, vector<string>& trainImageNames )
-{
-    cout << "< Reading the images..." << endl;
-    queryImage = imread( queryImageName, IMREAD_GRAYSCALE);
-    if( queryImage.empty() )
-    {
-        cout << "Query image can not be read." << endl << ">" << endl;
-        return false;
-    }
-    string trainDirName;
-    readTrainFilenames( trainFilename, trainDirName, trainImageNames );
-    if( trainImageNames.empty() )
-    {
-        cout << "Train image filenames can not be read." << endl << ">" << endl;
-        return false;
-    }
-    int readImageCount = 0;
-    for( size_t i = 0; i < trainImageNames.size(); i++ )
-    {
-        string filename = trainDirName + trainImageNames[i];
-        Mat img = imread( filename, IMREAD_GRAYSCALE );
-        if( img.empty() )
-            cout << "Train image " << filename << " can not be read." << endl;
-        else
-            readImageCount++;
-        trainImages.push_back( img );
-    }
-    if( !readImageCount )
-    {
-        cout << "All train images can not be read." << endl << ">" << endl;
-        return false;
-    }
-    else
-        cout << readImageCount << " train images were read." << endl;
-    cout << ">" << endl;
-
-    return true;
-}
-
-static void detectKeypoints( const Mat& queryImage, vector<KeyPoint>& queryKeypoints,
-                      const vector<Mat>& trainImages, vector<vector<KeyPoint> >& trainKeypoints,
-                      Ptr<FeatureDetector>& featureDetector )
-{
-    cout << endl << "< Extracting keypoints from images..." << endl;
-    featureDetector->detect( queryImage, queryKeypoints );
-    featureDetector->detect( trainImages, trainKeypoints );
-    cout << ">" << endl;
-}
-
-static void computeDescriptors( const Mat& queryImage, vector<KeyPoint>& queryKeypoints, Mat& queryDescriptors,
-                         const vector<Mat>& trainImages, vector<vector<KeyPoint> >& trainKeypoints, vector<Mat>& trainDescriptors,
-                         Ptr<DescriptorExtractor>& descriptorExtractor )
-{
-    cout << "< Computing descriptors for keypoints..." << endl;
-    descriptorExtractor->compute( queryImage, queryKeypoints, queryDescriptors );
-    descriptorExtractor->compute( trainImages, trainKeypoints, trainDescriptors );
-
-    int totalTrainDesc = 0;
-    for( vector<Mat>::const_iterator tdIter = trainDescriptors.begin(); tdIter != trainDescriptors.end(); tdIter++ )
-        totalTrainDesc += tdIter->rows;
-
-    cout << "Query descriptors count: " << queryDescriptors.rows << "; Total train descriptors count: " << totalTrainDesc << endl;
-    cout << ">" << endl;
-}
-
-static void matchDescriptors( const Mat& queryDescriptors, const vector<Mat>& trainDescriptors,
-                       vector<DMatch>& matches, Ptr<DescriptorMatcher>& descriptorMatcher )
-{
-    cout << "< Set train descriptors collection in the matcher and match query descriptors to them..." << endl;
-    TickMeter tm;
-
-    tm.start();
-    descriptorMatcher->add( trainDescriptors );
-    descriptorMatcher->train();
-    tm.stop();
-    double buildTime = tm.getTimeMilli();
-
-    tm.start();
-    descriptorMatcher->match( queryDescriptors, matches );
-    tm.stop();
-    double matchTime = tm.getTimeMilli();
-
-    CV_Assert( queryDescriptors.rows == (int)matches.size() || matches.empty() );
-
-    cout << "Number of matches: " << matches.size() << endl;
-    cout << "Build time: " << buildTime << " ms; Match time: " << matchTime << " ms" << endl;
-    cout << ">" << endl;
-}
-
-static void saveResultImages( const Mat& queryImage, const vector<KeyPoint>& queryKeypoints,
-                       const vector<Mat>& trainImages, const vector<vector<KeyPoint> >& trainKeypoints,
-                       const vector<DMatch>& matches, const vector<string>& trainImagesNames, const string& resultDir )
-{
-    cout << "< Save results..." << endl;
-    Mat drawImg;
-    vector<char> mask;
-    for( size_t i = 0; i < trainImages.size(); i++ )
-    {
-        if( !trainImages[i].empty() )
-        {
-            maskMatchesByTrainImgIdx( matches, (int)i, mask );
-            drawMatches( queryImage, queryKeypoints, trainImages[i], trainKeypoints[i],
-                         matches, drawImg, Scalar(255, 0, 0), Scalar(0, 255, 255), mask );
-            string filename = resultDir + "/res_" + trainImagesNames[i];
-            if( !imwrite( filename, drawImg ) )
-                cout << "Image " << filename << " can not be saved (may be because directory " << resultDir << " does not exist)." << endl;
-        }
-    }
-    cout << ">" << endl;
-}
-
-int main(int argc, char** argv)
-{
-    string detectorType = defaultDetectorType;
-    string descriptorType = defaultDescriptorType;
-    string matcherType = defaultMatcherType;
-    string queryImageName = defaultQueryImageName;
-    string fileWithTrainImages = defaultFileWithTrainImages;
-    string dirToSaveResImages = defaultDirToSaveResImages;
-
-    if( argc != 7 && argc != 1 )
-    {
-        printPrompt( argv[0] );
-        return -1;
-    }
-
-    if( argc != 1 )
-    {
-        detectorType = argv[1]; descriptorType = argv[2]; matcherType = argv[3];
-        queryImageName = argv[4]; fileWithTrainImages = argv[5];
-        dirToSaveResImages = argv[6];
-    }
-
-    Ptr<FeatureDetector> featureDetector;
-    Ptr<DescriptorExtractor> descriptorExtractor;
-    Ptr<DescriptorMatcher> descriptorMatcher;
-    if( !createDetectorDescriptorMatcher( detectorType, descriptorType, matcherType, featureDetector, descriptorExtractor, descriptorMatcher ) )
-    {
-        printPrompt( argv[0] );
-        return -1;
-    }
-
-    Mat queryImage;
-    vector<Mat> trainImages;
-    vector<string> trainImagesNames;
-    if( !readImages( queryImageName, fileWithTrainImages, queryImage, trainImages, trainImagesNames ) )
-    {
-        printPrompt( argv[0] );
-        return -1;
-    }
-
-    vector<KeyPoint> queryKeypoints;
-    vector<vector<KeyPoint> > trainKeypoints;
-    detectKeypoints( queryImage, queryKeypoints, trainImages, trainKeypoints, featureDetector );
-
-    Mat queryDescriptors;
-    vector<Mat> trainDescriptors;
-    computeDescriptors( queryImage, queryKeypoints, queryDescriptors,
-                        trainImages, trainKeypoints, trainDescriptors,
-                        descriptorExtractor );
-
-    vector<DMatch> matches;
-    matchDescriptors( queryDescriptors, trainDescriptors, matches, descriptorMatcher );
-
-    saveResultImages( queryImage, queryKeypoints, trainImages, trainKeypoints,
-                      matches, trainImagesNames, dirToSaveResImages );
-    return 0;
-}
diff --git a/samples/cpp/matching_to_many_images/query.png b/samples/cpp/matching_to_many_images/query.png
deleted file mode 100755 (executable)
index 9aa1199..0000000
Binary files a/samples/cpp/matching_to_many_images/query.png and /dev/null differ
diff --git a/samples/cpp/matching_to_many_images/train/1.png b/samples/cpp/matching_to_many_images/train/1.png
deleted file mode 100755 (executable)
index c52e19e..0000000
Binary files a/samples/cpp/matching_to_many_images/train/1.png and /dev/null differ
diff --git a/samples/cpp/matching_to_many_images/train/2.png b/samples/cpp/matching_to_many_images/train/2.png
deleted file mode 100755 (executable)
index 7b1189c..0000000
Binary files a/samples/cpp/matching_to_many_images/train/2.png and /dev/null differ
diff --git a/samples/cpp/matching_to_many_images/train/3.png b/samples/cpp/matching_to_many_images/train/3.png
deleted file mode 100755 (executable)
index dc2389a..0000000
Binary files a/samples/cpp/matching_to_many_images/train/3.png and /dev/null differ
diff --git a/samples/cpp/matching_to_many_images/train/trainImages.txt b/samples/cpp/matching_to_many_images/train/trainImages.txt
deleted file mode 100644 (file)
index b376639..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-1.png
-2.png
-3.png
diff --git a/samples/cpp/meanshift_segmentation.cpp b/samples/cpp/meanshift_segmentation.cpp
deleted file mode 100644 (file)
index eb71619..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#include "opencv2/highgui/highgui.hpp"
-#include "opencv2/core/core.hpp"
-#include "opencv2/imgproc/imgproc.hpp"
-
-#include <iostream>
-
-using namespace cv;
-using namespace std;
-
-static void help(char** argv)
-{
-    cout << "\nDemonstrate mean-shift based color segmentation in spatial pyramid.\n"
-    << "Call:\n   " << argv[0] << " image\n"
-    << "This program allows you to set the spatial and color radius\n"
-    << "of the mean shift window as well as the number of pyramid reduction levels explored\n"
-    << endl;
-}
-
-//This colors the segmentations
-static void floodFillPostprocess( Mat& img, const Scalar& colorDiff=Scalar::all(1) )
-{
-    CV_Assert( !img.empty() );
-    RNG rng = theRNG();
-    Mat mask( img.rows+2, img.cols+2, CV_8UC1, Scalar::all(0) );
-    for( int y = 0; y < img.rows; y++ )
-    {
-        for( int x = 0; x < img.cols; x++ )
-        {
-            if( mask.at<uchar>(y+1, x+1) == 0 )
-            {
-                Scalar newVal( rng(256), rng(256), rng(256) );
-                floodFill( img, mask, Point(x,y), newVal, 0, colorDiff, colorDiff );
-            }
-        }
-    }
-}
-
-string winName = "meanshift";
-int spatialRad, colorRad, maxPyrLevel;
-Mat img, res;
-
-static void meanShiftSegmentation( int, void* )
-{
-    cout << "spatialRad=" << spatialRad << "; "
-         << "colorRad=" << colorRad << "; "
-         << "maxPyrLevel=" << maxPyrLevel << endl;
-    pyrMeanShiftFiltering( img, res, spatialRad, colorRad, maxPyrLevel );
-    floodFillPostprocess( res, Scalar::all(2) );
-    imshow( winName, res );
-}
-
-int main(int argc, char** argv)
-{
-    if( argc !=2 )
-    {
-        help(argv);
-        return -1;
-    }
-
-    img = imread( argv[1] );
-    if( img.empty() )
-        return -1;
-
-    spatialRad = 10;
-    colorRad = 10;
-    maxPyrLevel = 1;
-
-    namedWindow( winName, WINDOW_AUTOSIZE );
-
-    createTrackbar( "spatialRad", winName, &spatialRad, 80, meanShiftSegmentation );
-    createTrackbar( "colorRad", winName, &colorRad, 60, meanShiftSegmentation );
-    createTrackbar( "maxPyrLevel", winName, &maxPyrLevel, 5, meanShiftSegmentation );
-
-    meanShiftSegmentation(0, 0);
-    waitKey();
-    return 0;
-}
similarity index 100%
rename from samples/c/motempl.c
rename to samples/cpp/motempl.cpp
diff --git a/samples/cpp/peopledetect.cpp b/samples/cpp/peopledetect.cpp
deleted file mode 100644 (file)
index c96f3e3..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-#include <opencv2/core/utility.hpp>
-#include <opencv2/imgproc.hpp>
-#include <opencv2/objdetect.hpp>
-#include <opencv2/highgui.hpp>
-#include <opencv2/softcascade.hpp>
-
-#include <iostream>
-#include <vector>
-#include <string>
-#include <fstream>
-
-void filter_rects(const std::vector<cv::Rect>& candidates, std::vector<cv::Rect>& objects);
-
-int main(int argc, char** argv)
-{
-    const std::string keys =
-    "{help h usage ?    |     | print this message and exit }"
-    "{cascade c         |     | path to cascade xml, if empty HOG detector will be executed }"
-    "{frame f           |     | wildchart pattern to frame source}"
-    "{min_scale         |0.4  | minimum scale to detect }"
-    "{max_scale         |5.0  | maxamum scale to detect }"
-    "{total_scales      |55   | prefered number of scales between min and max }"
-    "{write_file wf     |0    | write to .txt. Disabled by default.}"
-    "{write_image wi    |0    | write to image. Disabled by default.}"
-    "{show_image si     |1    | show image. Enabled by default.}"
-    "{threshold thr     |-1   | detection threshold. Detections with score less then threshold will be ignored.}"
-    ;
-
-    cv::CommandLineParser parser(argc, argv, keys);
-    parser.about("Soft cascade training application.");
-
-    if (parser.has("help"))
-    {
-        parser.printMessage();
-        return 0;
-    }
-
-    if (!parser.check())
-    {
-        parser.printErrors();
-        return 1;
-    }
-
-    int wf = parser.get<int>("write_file");
-    if (wf) std::cout << "resulte will be stored to .txt file with the same name as image." << std::endl;
-
-    int wi = parser.get<int>("write_image");
-    if (wi) std::cout << "resulte will be stored to image with the same name as input plus dt." << std::endl;
-
-    int si = parser.get<int>("show_image");
-
-    float minScale =  parser.get<float>("min_scale");
-    float maxScale =  parser.get<float>("max_scale");
-    int scales     =  parser.get<int>("total_scales");
-    int thr        =  parser.get<int>("threshold");
-
-    cv::HOGDescriptor hog;
-    cv::softcascade::Detector cascade;
-
-    bool useHOG = false;
-    std::string cascadePath = parser.get<std::string>("cascade");
-    if (cascadePath.empty())
-    {
-        useHOG = true;
-        hog.setSVMDetector(cv::HOGDescriptor::getDefaultPeopleDetector());
-        std::cout << "going to use HOG detector." << std::endl;
-    }
-    else
-    {
-        cv::FileStorage fs(cascadePath, cv::FileStorage::READ);
-        if( !fs.isOpened())
-        {
-            std::cout << "Soft Cascade file " << cascadePath << " can't be opened." << std::endl << std::flush;
-            return 1;
-        }
-
-        cascade = cv::softcascade::Detector(minScale, maxScale, scales, cv::softcascade::Detector::DOLLAR);
-
-        if (!cascade.load(fs.getFirstTopLevelNode()))
-        {
-            std::cout << "Soft Cascade can't be parsed." << std::endl << std::flush;
-            return 1;
-        }
-    }
-
-    std::string src = parser.get<std::string>("frame");
-    std::vector<cv::String> frames;
-    cv::glob(parser.get<std::string>("frame"), frames);
-    std::cout << "collected " << src << " " << frames.size() << " frames." << std::endl;
-
-    for (int i = 0; i < (int)frames.size(); ++i)
-    {
-        std::string frame_sourse = frames[i];
-        cv::Mat frame = cv::imread(frame_sourse);
-
-        if(frame.empty())
-        {
-            std::cout << "Frame source " << frame_sourse << " can't be opened." << std::endl << std::flush;
-            continue;
-        }
-
-        std::ofstream myfile;
-        if (wf)
-            myfile.open((frame_sourse.replace(frame_sourse.end() - 3, frame_sourse.end(), "txt")).c_str(), std::ios::out);
-
-        ////
-        if (useHOG)
-        {
-            std::vector<cv::Rect> found, found_filtered;
-            // run the detector with default parameters. to get a higher hit-rate
-            // (and more false alarms, respectively), decrease the hitThreshold and
-            // groupThreshold (set groupThreshold to 0 to turn off the grouping completely).
-            hog.detectMultiScale(frame, found, 0, cv::Size(8,8), cv::Size(32,32), 1.05, 2);
-
-            filter_rects(found, found_filtered);
-            std::cout << "collected: " << (int)found_filtered.size() << " detections." << std::endl;
-
-            for (size_t ff = 0; ff < found_filtered.size(); ++ff)
-            {
-                cv::Rect r = found_filtered[ff];
-                cv::rectangle(frame, r.tl(), r.br(), cv::Scalar(0,255,0), 3);
-
-                if (wf) myfile << r.x << "," << r.y << "," << r.width << "," << r.height << "," << 0.f << "\n";
-            }
-        }
-        else
-        {
-            std::vector<cv::softcascade::Detection> objects;
-            cascade.detect(frame,  cv::noArray(), objects);
-            std::cout << "collected: " << (int)objects.size() << " detections." << std::endl;
-
-            for (int obj = 0; obj  < (int)objects.size(); ++obj)
-            {
-                cv::softcascade::Detection d = objects[obj];
-
-                if(d.confidence > thr)
-                {
-                    float b = d.confidence * 1.5f;
-
-                    std::stringstream conf(std::stringstream::in | std::stringstream::out);
-                    conf << d.confidence;
-
-                    cv::rectangle(frame, cv::Rect((int)d.x, (int)d.y, (int)d.w, (int)d.h), cv::Scalar(b, 0, 255 - b, 255), 2);
-                    cv::putText(frame, conf.str() , cv::Point((int)d.x + 10, (int)d.y - 5),1, 1.1, cv::Scalar(25, 133, 255, 0), 1, cv::LINE_AA);
-
-                    if (wf)
-                        myfile << d.x << "," <<  d.y << "," << d.w << "," <<  d.h << "," << d.confidence << "\n";
-                }
-            }
-        }
-
-        if (wi) cv::imwrite(frame_sourse + ".dt.png", frame);
-        if (wf) myfile.close();
-
-        if (si)
-        {
-            cv::imshow("pedestrian detector", frame);
-            cv::waitKey(10);
-        }
-    }
-
-    if (si) cv::waitKey(0);
-    return 0;
-}
-
-void filter_rects(const std::vector<cv::Rect>& candidates, std::vector<cv::Rect>& objects)
-{
-    size_t i, j;
-    for (i = 0; i < candidates.size(); ++i)
-    {
-        cv::Rect r = candidates[i];
-
-        for (j = 0; j < candidates.size(); ++j)
-            if (j != i && (r & candidates[j]) == r)
-                break;
-
-        if (j == candidates.size())
-            objects.push_back(r);
-    }
-}
similarity index 100%
rename from samples/c/puzzle.png
rename to samples/cpp/puzzle.png
diff --git a/samples/cpp/rgbdodometry.cpp b/samples/cpp/rgbdodometry.cpp
deleted file mode 100644 (file)
index 0db2fab..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-#include "opencv2/imgproc/imgproc.hpp"
-#include "opencv2/calib3d/calib3d.hpp"
-#include "opencv2/contrib/contrib.hpp"
-#include "opencv2/highgui/highgui.hpp"
-
-#include <cstdio>
-#include <iostream>
-#include <ctime>
-
-using namespace cv;
-using namespace std;
-
-static
-void cvtDepth2Cloud( const Mat& depth, Mat& cloud, const Mat& cameraMatrix )
-{
-    const float inv_fx = 1.f/cameraMatrix.at<float>(0,0);
-    const float inv_fy = 1.f/cameraMatrix.at<float>(1,1);
-    const float ox = cameraMatrix.at<float>(0,2);
-    const float oy = cameraMatrix.at<float>(1,2);
-    cloud.create( depth.size(), CV_32FC3 );
-    for( int y = 0; y < cloud.rows; y++ )
-    {
-        Point3f* cloud_ptr = (Point3f*)cloud.ptr(y);
-        const float* depth_prt = (const float*) depth.ptr(y);
-        for( int x = 0; x < cloud.cols; x++ )
-        {
-            float z = depth_prt[x];
-            cloud_ptr[x].x = (x - ox) * z * inv_fx;
-            cloud_ptr[x].y = (y - oy) * z * inv_fy;
-            cloud_ptr[x].z = z;
-        }
-    }
-}
-
-template<class ImageElemType>
-static void warpImage( const Mat& image, const Mat& depth,
-                       const Mat& Rt, const Mat& cameraMatrix, const Mat& distCoeff,
-                       Mat& warpedImage )
-{
-    const Rect rect = Rect(0, 0, image.cols, image.rows);
-
-    vector<Point2f> points2d;
-    Mat cloud, transformedCloud;
-
-    cvtDepth2Cloud( depth, cloud, cameraMatrix );
-    perspectiveTransform( cloud, transformedCloud, Rt );
-    projectPoints( transformedCloud.reshape(3,1), Mat::eye(3,3,CV_64FC1), Mat::zeros(3,1,CV_64FC1), cameraMatrix, distCoeff, points2d );
-
-    Mat pointsPositions( points2d );
-    pointsPositions = pointsPositions.reshape( 2, image.rows );
-
-    warpedImage.create( image.size(), image.type() );
-    warpedImage = Scalar::all(0);
-
-    Mat zBuffer( image.size(), CV_32FC1, FLT_MAX );
-    for( int y = 0; y < image.rows; y++ )
-    {
-        for( int x = 0; x < image.cols; x++ )
-        {
-            const Point3f p3d = transformedCloud.at<Point3f>(y,x);
-            const Point p2d = pointsPositions.at<Point2f>(y,x);
-            if( !cvIsNaN(cloud.at<Point3f>(y,x).z) && cloud.at<Point3f>(y,x).z > 0 &&
-                rect.contains(p2d) && zBuffer.at<float>(p2d) > p3d.z )
-            {
-                warpedImage.at<ImageElemType>(p2d) = image.at<ImageElemType>(y,x);
-                zBuffer.at<float>(p2d) = p3d.z;
-            }
-        }
-    }
-}
-
-int main(int argc, char** argv)
-{
-    float vals[] = {525., 0., 3.1950000000000000e+02,
-                    0., 525., 2.3950000000000000e+02,
-                    0., 0., 1.};
-
-    const Mat cameraMatrix = Mat(3,3,CV_32FC1,vals);
-    const Mat distCoeff(1,5,CV_32FC1,Scalar(0));
-
-    if( argc != 5 && argc != 6 )
-    {
-        cout << "Format: image0 depth0 image1 depth1 [transformationType]" << endl;
-        cout << "Depth file must be 16U image stored depth in mm." << endl;
-        cout << "Transformation types:" << endl;
-        cout << "   -rbm - rigid body motion (default)" << endl;
-        cout << "   -r   - rotation rotation only" << endl;
-        cout << "   -t   - translation only" << endl;
-        return -1;
-    }
-
-    Mat colorImage0 = imread( argv[1] );
-    Mat depth0 = imread( argv[2], -1 );
-
-    Mat colorImage1 = imread( argv[3] );
-    Mat depth1 = imread( argv[4], -1 );
-
-    if( colorImage0.empty() || depth0.empty() || colorImage1.empty() || depth1.empty() )
-    {
-        cout << "Data (rgb or depth images) is empty.";
-        return -1;
-    }
-
-    int transformationType = RIGID_BODY_MOTION;
-    if( argc == 6 )
-    {
-        string ttype = argv[5];
-        if( ttype == "-rbm" )
-        {
-            transformationType = RIGID_BODY_MOTION;
-        }
-        else if ( ttype == "-r")
-        {
-            transformationType = ROTATION;
-        }
-        else if ( ttype == "-t")
-        {
-            transformationType = TRANSLATION;
-        }
-        else
-        {
-            cout << "Unsupported transformation type." << endl;
-            return -1;
-        }
-    }
-
-    Mat grayImage0, grayImage1, depthFlt0, depthFlt1/*in meters*/;
-    cvtColor( colorImage0, grayImage0, COLOR_BGR2GRAY );
-    cvtColor( colorImage1, grayImage1, COLOR_BGR2GRAY );
-    depth0.convertTo( depthFlt0, CV_32FC1, 1./1000 );
-    depth1.convertTo( depthFlt1, CV_32FC1, 1./1000 );
-
-    TickMeter tm;
-    Mat Rt;
-
-    vector<int> iterCounts(4);
-    iterCounts[0] = 7;
-    iterCounts[1] = 7;
-    iterCounts[2] = 7;
-    iterCounts[3] = 10;
-
-    vector<float> minGradMagnitudes(4);
-    minGradMagnitudes[0] = 12;
-    minGradMagnitudes[1] = 5;
-    minGradMagnitudes[2] = 3;
-    minGradMagnitudes[3] = 1;
-
-    const float minDepth = 0.f; //in meters
-    const float maxDepth = 4.f; //in meters
-    const float maxDepthDiff = 0.07f; //in meters
-
-    tm.start();
-    bool isFound = cv::RGBDOdometry( Rt, Mat(),
-                                     grayImage0, depthFlt0, Mat(),
-                                     grayImage1, depthFlt1, Mat(),
-                                     cameraMatrix, minDepth, maxDepth, maxDepthDiff,
-                                     iterCounts, minGradMagnitudes, transformationType );
-    tm.stop();
-
-    cout << "Rt = " << Rt << endl;
-    cout << "Time = " << tm.getTimeSec() << " sec." << endl;
-
-    if( !isFound )
-    {
-        cout << "Rigid body motion cann't be estimated for given RGBD data."  << endl;
-        return -1;
-    }
-
-    Mat warpedImage0;
-    warpImage<Point3_<uchar> >( colorImage0, depthFlt0, Rt, cameraMatrix, distCoeff, warpedImage0 );
-
-    imshow( "image0", colorImage0 );
-    imshow( "warped_image0", warpedImage0 );
-    imshow( "image1", colorImage1 );
-    waitKey();
-
-    return 0;
-}
diff --git a/samples/cpp/rgbdodometry/depth_00000.png b/samples/cpp/rgbdodometry/depth_00000.png
deleted file mode 100644 (file)
index 705ad12..0000000
Binary files a/samples/cpp/rgbdodometry/depth_00000.png and /dev/null differ
diff --git a/samples/cpp/rgbdodometry/depth_00002.png b/samples/cpp/rgbdodometry/depth_00002.png
deleted file mode 100644 (file)
index e708283..0000000
Binary files a/samples/cpp/rgbdodometry/depth_00002.png and /dev/null differ
diff --git a/samples/cpp/rgbdodometry/image_00000.png b/samples/cpp/rgbdodometry/image_00000.png
deleted file mode 100644 (file)
index 7f48891..0000000
Binary files a/samples/cpp/rgbdodometry/image_00000.png and /dev/null differ
diff --git a/samples/cpp/rgbdodometry/image_00002.png b/samples/cpp/rgbdodometry/image_00002.png
deleted file mode 100644 (file)
index 7ee283d..0000000
Binary files a/samples/cpp/rgbdodometry/image_00002.png and /dev/null differ
index 2f6a8b9..92ebc48 100644 (file)
@@ -10,7 +10,6 @@
 #include "opencv2/calib3d/calib3d.hpp"
 #include "opencv2/imgproc/imgproc.hpp"
 #include "opencv2/highgui/highgui.hpp"
-#include "opencv2/contrib/contrib.hpp"
 #include "opencv2/core/utility.hpp"
 
 #include <stdio.h>
@@ -20,7 +19,7 @@ using namespace cv;
 static void print_help()
 {
     printf("\nDemo stereo matching converting L and R images into disparity and point clouds\n");
-    printf("\nUsage: stereo_match <left_image> <right_image> [--algorithm=bm|sgbm|hh|var] [--blocksize=<block_size>]\n"
+    printf("\nUsage: stereo_match <left_image> <right_image> [--algorithm=bm|sgbm|hh] [--blocksize=<block_size>]\n"
            "[--max-disparity=<max_disparity>] [--scale=scale_factor>] [-i <intrinsic_filename>] [-e <extrinsic_filename>]\n"
            "[--no-display] [-o <disparity_image>] [-p <point_cloud_file>]\n");
 }
@@ -69,7 +68,6 @@ int main(int argc, char** argv)
 
     Ptr<StereoBM> bm = createStereoBM(16,9);
     Ptr<StereoSGBM> sgbm = createStereoSGBM(0,16,3);
-    StereoVar var;
 
     for( int i = 1; i < argc; i++ )
     {
@@ -249,19 +247,6 @@ int main(int argc, char** argv)
     sgbm->setDisp12MaxDiff(1);
     sgbm->setMode(alg == STEREO_HH ? StereoSGBM::MODE_HH : StereoSGBM::MODE_SGBM);
 
-    var.levels = 3;                                 // ignored with USE_AUTO_PARAMS
-    var.pyrScale = 0.5;                             // ignored with USE_AUTO_PARAMS
-    var.nIt = 25;
-    var.minDisp = -numberOfDisparities;
-    var.maxDisp = 0;
-    var.poly_n = 3;
-    var.poly_sigma = 0.0;
-    var.fi = 15.0f;
-    var.lambda = 0.03f;
-    var.penalization = var.PENALIZATION_TICHONOV;   // ignored with USE_AUTO_PARAMS
-    var.cycle = var.CYCLE_V;                        // ignored with USE_AUTO_PARAMS
-    var.flags = var.USE_SMART_ID | var.USE_AUTO_PARAMS | var.USE_INITIAL_DISPARITY | var.USE_MEDIAN_FILTERING ;
-
     Mat disp, disp8;
     //Mat img1p, img2p, dispp;
     //copyMakeBorder(img1, img1p, 0, 0, numberOfDisparities, 0, IPL_BORDER_REPLICATE);
@@ -270,9 +255,6 @@ int main(int argc, char** argv)
     int64 t = getTickCount();
     if( alg == STEREO_BM )
         bm->compute(img1, img2, disp);
-    else if( alg == STEREO_VAR ) {
-        var(img1, img2, disp);
-    }
     else if( alg == STEREO_SGBM || alg == STEREO_HH )
         sgbm->compute(img1, img2, disp);
     t = getTickCount() - t;
similarity index 100%
rename from samples/c/tree.avi
rename to samples/cpp/tree.avi
diff --git a/samples/cpp/video_dmtx.cpp b/samples/cpp/video_dmtx.cpp
deleted file mode 100644 (file)
index e410f7c..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * starter_video.cpp
- *
- *  Created on: Nov 23, 2010
- *      Author: Ethan Rublee
- *
- * A starter sample for using opencv, get a video stream and display the images
- * Use http://datamatrix.kaywa.com/  to generate datamatrix images using strings of length 3 or less.
- * easy as CV_PI right?
- */
-#include "opencv2/highgui/highgui.hpp"
-#include <opencv2/objdetect/objdetect.hpp>
-#include <opencv2/imgproc/imgproc.hpp>
-#include <iostream>
-#include <vector>
-#include <stdio.h>
-
-using namespace cv;
-using namespace std;
-
-//hide the local functions in an anon namespace
-namespace
-{
-    void help(char** av)
-    {
-        cout << "\nThis program justs gets you started reading images from video\n"
-        "Usage:\n./" << av[0] << " <video device number>\n" << "q,Q,esc -- quit\n"
-        << "space   -- save frame\n\n"
-        << "\tThis is a starter sample, to get you up and going in a copy pasta fashion\n"
-        << "\tThe program captures frames from a camera connected to your computer.\n"
-        << "\tTo find the video device number, try ls /dev/video* \n"
-        << "\tYou may also pass a video file, like my_vide.avi instead of a device number"
-        << "\n"
-        << "DATA:\n"
-        << "Generate a datamatrix from  from http://datamatrix.kaywa.com/  \n"
-        << "  NOTE: This only handles strings of len 3 or less\n"
-        << "  Resize the screen to be large enough for your camera to see, and it should find an read it.\n\n"
-        << endl;
-    }
-
-    int process(VideoCapture& capture)
-    {
-        int n = 0;
-        char filename[200];
-        string window_name = "video | q or esc to quit";
-        cout << "press space to save a picture. q or esc to quit" << endl;
-        namedWindow(window_name, WINDOW_KEEPRATIO); //resizable window;
-        Mat frame;
-        for (;;)
-        {
-            capture >> frame;
-            if (frame.empty())
-                break;
-            cv::Mat gray;
-            cv::cvtColor(frame,gray,COLOR_RGB2GRAY);
-            vector<String> codes;
-            Mat corners;
-            findDataMatrix(gray, codes, corners);
-            drawDataMatrixCodes(frame, codes, corners);
-            imshow(window_name, frame);
-            char key = (char) waitKey(5); //delay N millis, usually long enough to display and capture input
-            switch (key)
-            {
-                case 'q':
-                case 'Q':
-                case 27: //escape key
-                    return 0;
-                case ' ': //Save an image
-                    sprintf(filename, "filename%.3d.jpg", n++);
-                    imwrite(filename, frame);
-                    cout << "Saved " << filename << endl;
-                    break;
-                default:
-                    break;
-            }
-        }
-        return 0;
-    }
-
-}
-
-int main(int ac, char** av)
-{
-
-    if (ac != 2)
-    {
-        help(av);
-        return 1;
-    }
-    std::string arg = av[1];
-    VideoCapture capture(arg); //try to open string, this will attempt to open it as a video file
-    if (!capture.isOpened()) //if this fails, try to open as a video camera, through the use of an integer param
-        capture.open(atoi(arg.c_str()));
-    if (!capture.isOpened())
-    {
-        cerr << "Failed to open a video device or video file!\n" << endl;
-        help(av);
-        return 1;
-    }
-    return process(capture);
-}
diff --git a/samples/python2/facerec_demo.py b/samples/python2/facerec_demo.py
deleted file mode 100755 (executable)
index 9eeb04e..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-#!/usr/bin/env python
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2012, Philipp Wagner <bytefish[at]gmx[dot]de>.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-#  * Redistributions of source code must retain the above copyright
-#    notice, this list of conditions and the following disclaimer.
-#  * Redistributions in binary form must reproduce the above
-#    copyright notice, this list of conditions and the following
-#    disclaimer in the documentation and/or other materials provided
-#    with the distribution.
-#  * Neither the name of the author nor the names of its
-#    contributors may be used to endorse or promote products derived
-#    from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-# ------------------------------------------------------------------------------------------------
-# Note:
-# When using the FaceRecognizer interface in combination with Python, please stick to Python 2.
-# Some underlying scripts like create_csv will not work in other versions, like Python 3.
-# ------------------------------------------------------------------------------------------------
-
-import os
-import sys
-import cv2
-import numpy as np
-
-def normalize(X, low, high, dtype=None):
-    """Normalizes a given array in X to a value between low and high."""
-    X = np.asarray(X)
-    minX, maxX = np.min(X), np.max(X)
-    # normalize to [0...1].
-    X = X - float(minX)
-    X = X / float((maxX - minX))
-    # scale to [low...high].
-    X = X * (high-low)
-    X = X + low
-    if dtype is None:
-        return np.asarray(X)
-    return np.asarray(X, dtype=dtype)
-
-
-def read_images(path, sz=None):
-    """Reads the images in a given folder, resizes images on the fly if size is given.
-
-    Args:
-        path: Path to a folder with subfolders representing the subjects (persons).
-        sz: A tuple with the size Resizes
-
-    Returns:
-        A list [X,y]
-
-            X: The images, which is a Python list of numpy arrays.
-            y: The corresponding labels (the unique number of the subject, person) in a Python list.
-    """
-    c = 0
-    X,y = [], []
-    for dirname, dirnames, filenames in os.walk(path):
-        for subdirname in dirnames:
-            subject_path = os.path.join(dirname, subdirname)
-            for filename in os.listdir(subject_path):
-                try:
-                    im = cv2.imread(os.path.join(subject_path, filename), cv2.IMREAD_GRAYSCALE)
-                    # resize to given size (if given)
-                    if (sz is not None):
-                        im = cv2.resize(im, sz)
-                    X.append(np.asarray(im, dtype=np.uint8))
-                    y.append(c)
-                except IOError, (errno, strerror):
-                    print "I/O error({0}): {1}".format(errno, strerror)
-                except:
-                    print "Unexpected error:", sys.exc_info()[0]
-                    raise
-            c = c+1
-    return [X,y]
-
-if __name__ == "__main__":
-    # This is where we write the images, if an output_dir is given
-    # in command line:
-    out_dir = None
-    # You'll need at least a path to your image data, please see
-    # the tutorial coming with this source code on how to prepare
-    # your image data:
-    if len(sys.argv) < 2:
-        print "USAGE: facerec_demo.py </path/to/images> [</path/to/store/images/at>]"
-        sys.exit()
-    # Now read in the image data. This must be a valid path!
-    [X,y] = read_images(sys.argv[1])
-    # Convert labels to 32bit integers. This is a workaround for 64bit machines,
-    # because the labels will truncated else. This will be fixed in code as
-    # soon as possible, so Python users don't need to know about this.
-    # Thanks to Leo Dirac for reporting:
-    y = np.asarray(y, dtype=np.int32)
-    # If a out_dir is given, set it:
-    if len(sys.argv) == 3:
-        out_dir = sys.argv[2]
-    # Create the Eigenfaces model. We are going to use the default
-    # parameters for this simple example, please read the documentation
-    # for thresholding:
-    model = cv2.createEigenFaceRecognizer()
-    # Read
-    # Learn the model. Remember our function returns Python lists,
-    # so we use np.asarray to turn them into NumPy lists to make
-    # the OpenCV wrapper happy:
-    model.train(np.asarray(X), np.asarray(y))
-    # We now get a prediction from the model! In reality you
-    # should always use unseen images for testing your model.
-    # But so many people were confused, when I sliced an image
-    # off in the C++ version, so I am just using an image we
-    # have trained with.
-    #
-    # model.predict is going to return the predicted label and
-    # the associated confidence:
-    [p_label, p_confidence] = model.predict(np.asarray(X[0]))
-    # Print it:
-    print "Predicted label = %d (confidence=%.2f)" % (p_label, p_confidence)
-    # Cool! Finally we'll plot the Eigenfaces, because that's
-    # what most people read in the papers are keen to see.
-    #
-    # Just like in C++ you have access to all model internal
-    # data, because the cv::FaceRecognizer is a cv::Algorithm.
-    #
-    # You can see the available parameters with getParams():
-    print model.getParams()
-    # Now let's get some data:
-    mean = model.getMat("mean")
-    eigenvectors = model.getMat("eigenvectors")
-    # We'll save the mean, by first normalizing it:
-    mean_norm = normalize(mean, 0, 255, dtype=np.uint8)
-    mean_resized = mean_norm.reshape(X[0].shape)
-    if out_dir is None:
-        cv2.imshow("mean", mean_resized)
-    else:
-        cv2.imwrite("%s/mean.png" % (out_dir), mean_resized)
-    # Turn the first (at most) 16 eigenvectors into grayscale
-    # images. You could also use cv::normalize here, but sticking
-    # to NumPy is much easier for now.
-    # Note: eigenvectors are stored by column:
-    for i in xrange(min(len(X), 16)):
-        eigenvector_i = eigenvectors[:,i].reshape(X[0].shape)
-        eigenvector_i_norm = normalize(eigenvector_i, 0, 255, dtype=np.uint8)
-        # Show or save the images:
-        if out_dir is None:
-            cv2.imshow("%s/eigenface_%d" % (out_dir,i), eigenvector_i_norm)
-        else:
-            cv2.imwrite("%s/eigenface_%d.png" % (out_dir,i), eigenvector_i_norm)
-    # Show the images:
-    if out_dir is None:
-        cv2.waitKey(0)
diff --git a/samples/python2/video_dmtx.py b/samples/python2/video_dmtx.py
deleted file mode 100755 (executable)
index d523252..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env python
-
-'''
-Data matrix detector sample.
-Usage:
-   video_dmtx {<video device number>|<video file name>}
-
-   Generate a datamatrix from  from http://datamatrix.kaywa.com/ and print it out.
-   NOTE: This only handles data matrices, generated for text strings of max 3 characters
-
-   Resize the screen to be large enough for your camera to see, and it should find an read it.
-
-Keyboard shortcuts:
-
-   q or ESC - exit
-   space - save current image as datamatrix<frame_number>.jpg
-'''
-
-import cv2
-import numpy as np
-
-# built-in modules
-import sys
-
-def data_matrix_demo(cap):
-    window_name = "Data Matrix Detector"
-    frame_number = 0
-    need_to_save = False
-
-    while 1:
-        ret, frame = cap.read()
-        if not ret:
-            break
-
-        gray = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
-        codes, corners, dmtx = cv2.findDataMatrix(gray)
-
-        cv2.drawDataMatrixCodes(frame, codes, corners)
-        cv2.imshow(window_name, frame)
-
-        key = cv2.waitKey(30)
-        c = chr(key & 255)
-        if c in ['q', 'Q', chr(27)]:
-            break
-
-        if c == ' ':
-            need_to_save = True
-
-        if need_to_save and codes:
-            filename = ("datamatrix%03d.jpg" % frame_number)
-            cv2.imwrite(filename, frame)
-            print "Saved frame to " + filename
-            need_to_save = False
-
-        frame_number += 1
-
-
-if __name__ == '__main__':
-    print __doc__
-
-    if len(sys.argv) == 1:
-        cap = cv2.VideoCapture(0)
-    else:
-        cap = cv2.VideoCapture(sys.argv[1])
-        if not cap.isOpened():
-            cap = cv2.VideoCapture(int(sys.argv[1]))
-
-    if not cap.isOpened():
-        print 'Cannot initialize video capture'
-        sys.exit(-1)
-
-    data_matrix_demo(cap)