Ask Your Question

ertan's profile - activity

2017-04-30 16:28:57 -0500 asked a question Error received on cvLoadHaarClassifierCascade() function

Hello,

Using OpenCV 2.4.13 (64bit) on a Windows 10 system.

When using subject function to load my own trained cascade.xml file, I am getting below error:

OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) in cvRead, file C:\builds\2_4_PackSlave-win64-vc12-shared\opencv\modules\core\src\persistence.cpp, line 5008

I couldn't understand what I am doing wrong. I have tried two different format of the cascade.xml (one is old format). Both failing.

My cascade.xml files are as follows (couldn't provide links as my karma points are not sufficient):

original format cascade.xml:

<?xml version="1.0"?>
<opencv_storage>
<cascade>
  <stageType>BOOST</stageType>
  <featureType>HAAR</featureType>
  <height>48</height>
  <width>48</width>
  <stageParams>
    <boostType>GAB</boostType>
    <minHitRate>9.9900001287460327e-001</minHitRate>
    <maxFalseAlarm>5.0000000000000000e-001</maxFalseAlarm>
    <weightTrimRate>9.4999999999999996e-001</weightTrimRate>
    <maxDepth>1</maxDepth>
    <maxWeakCount>100</maxWeakCount></stageParams>
  <featureParams>
    <maxCatCount>0</maxCatCount>
    <featSize>1</featSize>
    <mode>BASIC</mode></featureParams>
  <stageNum>1</stageNum>
  <stages>
    <!-- stage 0 -->
    <_>
      <maxWeakCount>2</maxWeakCount>
      <stageThreshold>0.</stageThreshold>
      <weakClassifiers>
        <_>
          <internalNodes>
            0 -1 1 4.8126034438610077e-002</internalNodes>
          <leafValues>
            -9.9589323997497559e-001 1.</leafValues></_>
        <_>
          <internalNodes>
            0 -1 0 -1.1564785242080688e-001</internalNodes>
          <leafValues>
            1. -1.</leafValues></_></weakClassifiers></_></stages>
  <features>
    <_>
      <rects>
        <_>
          0 8 16 36 -1.</_>
        <_>
          0 8 8 18 2.</_>
        <_>
          8 26 8 18 2.</_></rects>
      <tilted>0</tilted></_>
    <_>
      <rects>
        <_>
          30 27 15 9 -1.</_>
        <_>
          35 27 5 9 3.</_></rects>
      <tilted>0</tilted></_></features></cascade>
</opencv_storage>

old format cascade.xml:

<?xml version="1.0"?>
<opencv_storage>
<cascade>
  <size>
    48 48</size>
  <stages>
    <_>
      <trees>
        <_>
          <_>
            <feature>
              <rects>
                <_>
                  30 27 15 9 -1.</_>
                <_>
                  35 27 5 9 3.</_></rects>
              <tilted>0</tilted></feature>
            <threshold>4.8126034438610077e-002</threshold>
            <left_val>-9.9589322381930179e-001</left_val>
            <right_val>1.</right_val></_></_>
        <_>
          <_>
            <feature>
              <rects>
                <_>
                  0 8 16 36 -1.</_>
                <_>
                  0 8 8 18 2.</_>
                <_>
                  8 26 8 18 2.</_></rects>
              <tilted>0</tilted></feature>
            <threshold>-1.1564785242080688e-001</threshold>
            <left_val>1.</left_val>
            <right_val>-1.</right_val></_></_></trees>
      <stage_threshold>0.</stage_threshold>
      <parent>-1</parent>
      <next>-1</next></_></stages></cascade>
</opencv_storage>

As it may be relevant, you can find my cascade training command line and output is below. Please ignore baseFormatSave parameter. I put it for test purposes:

C:\training>opencv_traincascade -data c:\training\data -vec c:\training\my.vec -bg c:\training\bg.txt -numPos 7 -numNeg 486 -numStages 1 -w 48 -h 48 -minHitRate 0.999 -baseFormatSave
PARAMETERS:
cascadeDirName: c:\training\data
vecFileName: c:\training\my.vec
bgFileName: c:\training\bg.txt
numPos: 7
numNeg: 486
numStages: 1
precalcValBufSize[Mb] : 1024
precalcIdxBufSize[Mb] : 1024
acceptanceRatioBreakValue : -1
stageType: BOOST
featureType: HAAR
sampleWidth: 48
sampleHeight: 48
boostType: GAB
minHitRate: 0.999
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: BASIC
Number of unique features given windowSize [48,48] : 2570880

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   7 : 7
NEG count : acceptanceRatio    486 : 1
Precalculation time: 8.279 ...
(more)
2017-04-28 04:51:08 -0500 asked a question fingerprinting and object recognition specific functions

Hello,

First of all, I have never developed a computer vision software before. Found OpenCV thru an internet search.

I would like to do an object recognition for hospital surgery tools. Like scissors, scalpel, etc. Those tools will be passing on a conveyor belt. It is assumed that there will be around 250 different tools for a given operation. Total amount of recognition objects is more than a thousand.

After forum searches and reading some tutorials, I think I should do following:

  1. Take quality pictures of each tool. If not identical on both sides, take two pictures per tool on each side.
  2. Develop an application with OpenCV to create fingerprint data out of these pictures.
  3. Save that fingerprint data into a disc file using "XML/YAML Persistence" classes. Depending on usage, saving whole file into a database is an option.
  4. Develop an application with OpenCV to do object recognition. To do that load all necessary saved fingerprint data into memory. Take a picture from camera, then create a fingerprint of taken picture and compare if both are similar.

My general questions are;

  • Did I miss some important step above?
  • Did I wrote a wrong information above? It is quite possible I mis-understand what I read.
  • What kind of a camera I should be using?
  • I will computer control conveyor and stop it for maybe a 0.5 seconds and take a picture and then continue to next part. Is this approach better than a continuous camera feed object recognition?

My detail questions about above items are:

  1. Position of the tool on the conveyor is not going to be same as the position of the studio taken picture. In order to be able to recognize correctly, what specific function should I use to create my fingerprint data for such a case?
  2. Very much like to above question, What specific function I should use to do the comparison and a decision to recognize the part on the conveyor belt. (As to my readings I think I should be using feature2d, not quite sure though. And absolutely do not know specific functions)
  3. Is OpenCV doing automatic use of CUDA? If not, is there GPU accelerated module I can use for my case?

Lastly, I could not find a complete example to my case. I appreciate that if it can be advised several examples which combines all above I want to do.

Thanks & regards.