Menu

DLIB_JPEG_SUPPORT not #defined?

Help
icedecker
2014-06-13
2016-10-08
  • icedecker

    icedecker - 2014-06-13

    Hi,
    I'm not sure what I'm doing wrong, but when I compile any new program that loads a image in the folder examples of dlib, I get the following error:
    exception thrown: DLIB_JPEG_SUPPORT not #defined: Unable to load image in file test10.jpg

    I get a similar error when I load a png image, with DLIB_PNG_SUPPORT
    The command I used is the following:
    g++ -O3 -I.. -lpthread -lX11 -lpng -ljpeg -lz img2edge.cpp -o img2edge

    What is wrong? I'm sure that I have the libs png and jpeg loaded.

     
    • Davis

      Davis - 2014-06-13

      You need to add -DDLIB_JPEG_SUPPORT and -DDLIB_PNG_SUPPORT to the command line.

      Cheers,
      Davis

       
    • Shubham Mittal

      Shubham Mittal - 2017-05-09

      folllowing solution WORKED PERFECTLY for visual studio with dlib:
      1. add all the source files inside the dlib/externel/jpeg folder to the project
      2. include the path of "C:/ dlib/external/jpeg ", to ur additional include directories and additional library directories in general, and linker respectively.
      3. add "DLIB_JPEG_SUPPORT" to C/C++ -> preprocessor-> preprocessor definitions
      4. compile and run the program. it works!

       
  • icedecker

    icedecker - 2014-06-13

    Now it worked, thanks for the quick reply! I need to read better the documentation, but would be nice if each section of a group of functions specify the needed libs to link. I'm sorry if they are already in the documentation.

    For anyone using QtCreator, in the .pro file, the following will work:
    INCLUDEPATH += /home/user/libs/dlib-18.8
    LIBS += -L/home/user/libs/dlib-18.8
    LIBS += -pthread
    LIBS += -lpng -ljpeg
    CONFIG += link_pkgconfig
    PKGCONFIG += x11
    QMAKE_CXXFLAGS += -std=c++11 -DDLIB_PNG_SUPPORT -DDLIB_JPEG_SUPPORT

    Anyway, the lib is very useful, good job! :)

     
    • Davis

      Davis - 2014-06-14

      No problem :)

      Cheers,
      Davis

      On Fri, Jun 13, 2014 at 2:25 PM, icedecker icedecker@users.sf.net wrote:

      Now it worked, thanks for the quick reply! I need to read better the
      documentation, but would be nice if each section of a group of functions
      specify the needed libs to link. I'm sorry if they are already in the
      documentation.

      For anyone using QtCreator, in the .pro file, the following will work:
      INCLUDEPATH += /home/user/libs/dlib-18.8
      LIBS += -L/home/user/libs/dlib-18.8
      LIBS += -pthread
      LIBS += -lpng -ljpeg
      CONFIG += link_pkgconfig
      PKGCONFIG += x11
      QMAKE_CXXFLAGS += -std=c++11 -DDLIB_PNG_SUPPORT -DDLIB_JPEG_SUPPORT

      Anyway, the lib is very useful, good job! :)


      DLIB_JPEG_SUPPORT not #defined?


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/dclib/discussion/442518/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • Fedor

    Fedor - 2014-06-25

    Hi,
    I have same error, but I'm using VS 2010. I performed the following steps:

    1) I build libjpeg using this tutorial http://www.dahlsys.com/misc/compiling_ijg_libjpeg/index.html , include it to example program shows how dlib make an object detector :
    1. in additional include dir folder containing jpeglib
    2. in additional library dir folder with jpeg.lib (jpeg-9a\x64\Release)
    3. in additional dependencies - jpeg.lib

    2) I include to project dlib/all/source.cpp, it has the following lines :

    ifdef DLIB_JPEG_SUPPORT
    include "../image_loader/jpeg_loader.cpp" - highlighted !!
    endif

    It highlightes appeared after connecting libjpeg.

    3)Succeeded build project, and get dlib_train.exe

    4)Try to train with command dlib_train ../trainHog have same error :

    exception thrown!
    DLIB_JPEG_SUPPORT not #defined: Unable to load image in file tmp\images(1).jpg

     
    • Davis

      Davis - 2014-06-25

      You have to add the DLIB_JPEG_SUPPORT #define. If you are not
      familiar with creating #defines in visual studio then you should use
      cmake to setup your visual studio project. CMake will automatically
      link in libjpeg and everything will work. See also
      http://dlib.net/compile.html

      Cheers,
      Davis

       
  • Fedor

    Fedor - 2014-06-25

    Thank you ! Adding define to VS helped me.

     
    • Davis

      Davis - 2014-06-25

      No problem :)

       
  • Jithin

    Jithin - 2014-09-20

    Hi Davis

    I am using VS2010.

    How can I #define DLIB_JPEG_SUPPORT.Got the same error as reported by Fedor,anyway I could build using cmake,ran some examples, great results. But it would be great if you could answer my query

    Thanks

     

    Last edit: Jithin 2014-09-20
    • Davis

      Davis - 2014-09-20

      If you use cmake it will generate an entire visual studio project for
      you that is correctly configured. You can then open the project in
      visual studio and do what you like. So I still recommend using cmake
      if you are unfamiliar with visual studio's setup GUI. Additionally,
      if you do this yourself you need to link your program with libjpeg.
      There are a number of ways you can do this in visual studio, but the
      easiest is to just add the files in dlib/external/libjpeg into your
      project and also add the dlib/external/libjpeg folder into the include
      search path. All these things are available through the right click
      menu in the project bar.

      There is a stack overflow question that mentions how to add
      preprocessor definitions:
      http://stackoverflow.com/questions/9038738/preprocessor-definition-in-vs2010-for-c.
      I don't remember off the top of my head the exact sequence of button
      clicks that gets you to the "add this folder to the include search
      path" but it's similar. But really, just use cmake if you are having
      trouble navigating visual studio's setup GUI.

      Cheers,
      Davis

       
  • Jithin

    Jithin - 2014-09-20

    Your answer was spot on Thanks Davis.

     
  • Altaf Korejo

    Altaf Korejo - 2016-10-08

    I'm not sure what I'm doing wrong, but when I compile any new program that loads a image in the folder examples of dlib, I get the following error in run time:
    it compile correctly but run time when i execute with commond ./a.out
    Unable to load image in file faces/1.jpg.
    You must #define DLIB_JPEG_SUPPORT and link to libjpeg to read JPEG files.
    yet i have defined #define DLIB_JPEG_SUPPORT in my program ex.cpp
    The command I used is the following:
    g++ -O3 -I.. ../dlib/all/source.cpp -lpthread -lX11 -ljpeg -lz ex.cpp

    What is wrong?

     

    Last edit: Altaf Korejo 2016-10-08
    • Davis

      Davis - 2016-10-08

      You must #define DLIB_JPEG_SUPPORT for your whole program, not just for
      some part of one file.

       
      • Altaf Korejo

        Altaf Korejo - 2016-10-08

        how can i do for whole program...what i have to do...i have to make changes in my program
        plzzz sir...mene ap ka time tu waste kya but iam in difficulty...bz iam new in ubuntu

         

        Last edit: Altaf Korejo 2016-10-08
        • Davis

          Davis - 2016-10-08

          -D

           
          • Altaf Korejo

            Altaf Korejo - 2016-10-08

            ok

             

            Last edit: Altaf Korejo 2016-10-08
            • Davis

              Davis - 2016-10-08

              Have you modified dlib source files? Don't do that.

              And since you don't know how to use gcc you should just use cmake. This
              page litterally tells you what to type: http://dlib.net/compile.html

               
              • Altaf Korejo

                Altaf Korejo - 2016-10-08

                yes i have modified now by putting -D in my DLIB_JPEG SUPPORT....but i i have remove -D it is same as first
                i have installed by typing following commond...inspite i have this error
                cd examples
                mkdir build
                cd build
                cmake ..
                cmake --build . --config Release

                i have installed cmake snap shot is as bellow in example folder where i have ex.cpp

                 
  • Altaf Korejo

    Altaf Korejo - 2016-10-08

    sir this is the file which i have sent just now... how can i define for the whole program

     
    • Davis

      Davis - 2016-10-08

      Use the -D compiler switch

       
      • Altaf Korejo

        Altaf Korejo - 2016-10-08

        sir where i have to use -D to switch my compiler...How can i switch my compile and where i have to use this -D

         
        • Davis

          Davis - 2016-10-08
           
          • Altaf Korejo

            Altaf Korejo - 2016-10-08

            sir if u tell me the commonds then i run those commands in my ubuntu terminal but now i do not know how to switch gcc compiler.. i have installed camke but same error...if u will help then Thanx...otherwise i have waste ur time...

             

            Last edit: Altaf Korejo 2016-10-08
  • Ihsan Ullah

    Ihsan Ullah - 2017-05-13
    Post awaiting moderation.

Log in to post a comment.