2

I've just generated using opencv_traincascade.exe (opencv 2.4.11 (vc10)) cascade.xml file.

Then when I try to use it in javacv 0.8 (and 1.0 too), I get this error:

OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) 
in cvRead, file ..\..\..\..\opencv\modules\core\src\persistence.cpp, line 4991
Exception in thread "main" java.lang.RuntimeException:
 ..\..\..\..\opencv\modules\core\src\persistence.cpp:4991: error: (-2) The node does not represent a user      object (unknown type?) in function cvRead

Windows PATH variable looks to the folder, which consists my opencv_traincascade.exe. So I try to use cacade.xml by library, which made it.

I also have another cascade.xml, which works fine. I found the difference between to cascades:

Working:

<opencv_storage>
    <haarcascade_frontalface_default type_id="opencv-haar-classifier">
        <size>24 24</size>
            <stages>
                 <trees>
                    ...  some tags for one stage
                 </trees>
            </stages>
    </haarcascade_frontalface_default>
</opencv_storage>

Don't working:

<opencv_storage>
   <cascade>
   <stageType>BOOST</stageType>
   <featureType>HAAR</featureType>
   <height>20</height>
   <width>20</width>
   <stageParams>
      <boostType>GAB</boostType>
      <minHitRate>9.9000000953674316e-001</minHitRate>
      <maxFalseAlarm>4.0000000596046448e-001</maxFalseAlarm>
      <weightTrimRate>9.4999999999999996e-001</weightTrimRate>
      <maxDepth>1</maxDepth>
      <maxWeakCount>100</maxWeakCount>
   </stageParams>
   <featureParams>
      <maxCatCount>0</maxCatCount>
      <featSize>1</featSize>
      <mode>ALL</mode>
   </featureParams>
   <stageNum>16</stageNum>
   <stages>
      <!-- stage 0 -->
       <_>
       <maxWeakCount>1</maxWeakCount>
       <stageThreshold>1.</stageThreshold>
       <weakClassifiers>
        <_>
      <internalNodes>
        0 -1 1 -2.3408320546150208e-001</internalNodes>
      <leafValues>
        1. -1.</leafValues></_></weakClassifiers></_>
      <!-- stage 1 -->
      .... //16 stages
      <features>
      .... // a lot of "rect" tags
      </features>
  </cascade>
</opencv_storage>

Everybody can notice, that the structures are different. I guess, this is the reason of the error.

What I'm doing wrong? How can I use my cascade.xml?

kosbr
  • 388
  • 2
  • 11
  • 1
    "What I'm doing wrong?" - you're using javacv. as you noted, the cascade format used in opencv changed, and the outdated c-api functions, javacv is based on, can't read the newer format. – berak Jul 30 '15 at 11:51
  • Thank you for advice. I'll try to use it not by javacv. But I saw here https://github.com/bytedeco/javacv is compatible with opencv 3.0... – kosbr Jul 30 '15 at 11:56
  • @berak We can use the C++ API too from JavaCV, no problem there. – Samuel Audet Jul 31 '15 at 13:05
  • I've posted the example of using new API by javacv here. http://www.kosdev.ru/2015/08/opencv.html – kosbr Aug 18 '15 at 06:13

1 Answers1

0

Yes, the problem was that I used javacv methods, which use old cascade xml format. Using c++ - everything works. Thank you, berak!

kosbr
  • 388
  • 2
  • 11
  • can you show me how to use C++ API to load classifier and detect – Chance Door Aug 03 '15 at 11:29
  • Look here: http://docs.opencv.org/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.html and Mat frame = imread("C:\\imgs\\points.jpg", 0) to use static image instead of video – kosbr Aug 04 '15 at 05:00