Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

XML file whose path is specified in qrc file is not loaded



  • CascadeClassifier faceClassifier;
    CascadeClassifier eyeClassifier;
    Q_ASSERT(faceClassifier.load(":/resources/haarcascade_frontalface_default.xml"));
    Q_ASSERT(eyeClassifier.load(":/resources/haarcascade_eye.xml"));
    

    This is a simple OpenCV code and load() function is blocked by Q_ASSERT. (which means it can not find the xml file)

    <!DOCTYPE RCC><RCC version="1.0">
    <qresource>
      <file>resources/icon.ico</file>
      <file>resources/MaestroTimes.ttf</file>
      <file>resources/haarcascade_eye.xml</file>
      <file>resources/haarcascade_frontalface_default.xml</file>
    </qresource>
    </RCC>
    

    This is the qrc file

    0_1539497012101_capture.PNG


  • Lifetime Qt Champion

    Hi
    What XML parser are you using ?
    The Qt one ?

    Also please show code for
    faceClassifier.load

    for test, please delete whole build folder so tmp files are 100% surely deleted.
    then rebuild all.



  • @mrjj CascadeClassifier::load is not a function I made, but a function in OpenCV module.
    I tried deleting the build folder, but it doesn't work either


  • Qt Champions 2019

    @Aaron-Kim Does OpenCV know anything about Qt resource files? If not this can't work. You will need to copy the XML file from the resource to some temporary location.



  • @jsulm Yes I guess that OpenCV does not support it. thanks!


Log in to reply