Results 1 to 7 of 7

Thread: Linking pb file to the Qt program.

  1. #1
    Join Date
    May 2019
    Posts
    6
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Linking pb file to the Qt program.

    Hello Qt devs. I have a pb file generated from TensorFlow, I linked that pb file to OpenCV in my program successfully in my computer. However, when I copy the deployed folder with the pb file inside to another machine the pb file doesn't work but OpenCV works fine. How do I link that file to my program?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Linking pb file to the Qt program.

    How do you "link" the file to OpenCV?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Linking pb file to the Qt program.

    How do you "link" the file to OpenCV?
    Especially since AFAIK OpenCV is a set of libraries like Qt, and not a stand-alone application.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Linking pb file to the Qt program.

    Quote Originally Posted by comvis View Post
    However, when I copy the deployed folder with the pb file inside to another machine the pb file doesn't work but OpenCV works fine. How do I link that file to my program?
    You are probably either:
    • not copying all the relevant run-time dependencies necessary for QT/OpenCV/Tensorflow to ingest and handle a protocol buffer file or,
    • assuming the current working directory of the program is somewhere it is not and addressing the procotol buffer file with an unqualified name "realcool.pb" (i.e. the file open fails).

    It may be something else, but we cannot see your system.
    Last edited by ChrisW67; 2nd August 2019 at 08:55.

  5. #5
    Join Date
    May 2019
    Posts
    6
    Thanks
    4
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Linking pb file to the Qt program.

    Quote Originally Posted by ChrisW67 View Post
    You are probably either:
    • not copying all the relevant run-time dependencies necessary for QT/OpenCV/Tensorflow to ingest and handle a protocol buffer file or,
    • assuming the current working directory of the program is somewhere it is not and addressing the procotol buffer file with an unqualified name "realcool.pb" (i.e. the file open fails).

    It may be something else, but we cannot see your system.
    Qt Code:
    1. pbFile = "tensorflowfile.pb";
    2. #pbFile = "./tensorflowfile.pb";
    3. #pbFile = "C:/Users/Computer/Documents/Program/release/tensorflowfile.pb";
    4. #pbFile = ":/file/release/tensorflowfile.pb";
    5. using namespace cv;
    6.  
    7. neural_net=dnn::readNet(pbFile.toStdString());
    8.  
    9. neural_net.setPreferableBackend(dnn::DNN_BACKEND_OPENCV);
    10.  
    11. neural_net.setPreferableTarget(dnn::DNN_TARGET_CPU);
    To copy to clipboard, switch view to plain text mode 
    The third code only works when I ran my program inside my machine and I understand that since it is the absolute directory of my pb file.
    After I deployed the release, I ran all three "pbFile" then copied the release folder with the pb file inside and all dlls needed including opencv_411world.dll. Launched the program well but when I clicked the button which run the function containing neural_net nothing happenned. Even adding the pb file to the resource didn't solve.
    Last edited by comvis; 3rd August 2019 at 12:41.

  6. #6
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Linking pb file to the Qt program.

    You can get the path of your executable with QCoreApplication::applicationDirPath() so creating a full path to your file should be easy when you put it beside our exectuable.

  7. The following user says thank you to ChristianEhrlicher for this useful post:

    comvis (3rd August 2019)

  8. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Linking pb file to the Qt program.

    Quote Originally Posted by comvis View Post
    The third code only works when I ran my program inside my machine and I understand that since it is the absolute directory of my pb file.
    Yes, correct.

    And the first two are relative paths, the program will look for these in the current working directory.
    The current working directory is very often not the program's installation location.

    As ChristianErlicher wrote, you can create a path relative to the executable.

    Quote Originally Posted by comvis View Post
    Even adding the pb file to the resource didn't solve.
    Well, not if you pass the resource path to a non-Qt library, it won't understand this type of path.
    For this kind of usage the resource data needs to be first extracted into a real file, e.g. using QTemporaryFile::createNativeFile().

    Cheers,
    _

  9. The following user says thank you to anda_skoa for this useful post:

    comvis (3rd August 2019)

Similar Threads

  1. Replies: 4
    Last Post: 26th September 2017, 08:49
  2. Replies: 5
    Last Post: 11th December 2010, 14:49
  3. linking a google protobuf file and a QT file
    By pratikag in forum Newbie
    Replies: 2
    Last Post: 29th June 2010, 19:52
  4. Linking with dbf file
    By prasenjit in forum Qt Programming
    Replies: 3
    Last Post: 13th January 2010, 13:21
  5. Program not linking with static image plugins
    By andyp in forum Qt Programming
    Replies: 7
    Last Post: 8th December 2009, 11:15

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.