Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Communication between a QObject and imported functions

Communication between a QObject and imported functions

Scheduled Pinned Locked Moved Unsolved General and Desktop
dllqobject
11 Posts 3 Posters 3.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Suji
    wrote on last edited by Suji
    #1

    Hi there !

    I create a new thread because the previous has derived to another problem I had (solved now).

    I got a QCamera object in my code, I called (library linked) some functions from a DLL which was made in VS2013.
    Suppose a function in the DLL likeactivateCamera(bool), and my QCamera object is my_qcameraobject. I'm actually trying to do something likemy_qcameraobject.activateCamera(true).

    Someone told me I will have to do some glue code, or that I wil have create my own camera object (so without QCamera), but i'm new and I have no ideas how I can do this ?

    Is it possible to have some ideas please ?

    Thanks a lot !

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      C++ is not a dynamic language. You can't add methods to an object at runtime. QCamera class has no method activateCamera so you can't call it like that.
      What you can do is export a function that takes a camera object as a parameter (pointer or ref), so you would call it like this (for a pointer option): activateCamera(&my_qcameraobject, true).

      1 Reply Last reply
      0
      • jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Does this DLL provide an interface to control a camera?
        If so then you probably do not need to use QCamera at all (QCamera does not know anything about your DLL and how to use it), just use what this DLL provides.
        You can create your own Camera class with a nice interface to hide the DLL functions behind this interface:

        class MyCamera
        {
        public:
        ...
            void enable()
            {
                activateCamera(true); // Here you call a function from the DLL
            }
        
            void disable()
            {
                activateCamera(false); // Here you call a function from the DLL
            }
        ...
        }
        

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Suji
          wrote on last edited by Suji
          #4

          Thanks @Chris-Kawa and @jsulm for your answers !

          To @jsulm : I have 2 DLLs. And I dont think they provide an interface (except maybe the XcompanyControlPanel in my second DLL shown below), but i built one.

          One is a CameraDisplayPlugin with functions like :

          typedef int	 (*pfDisplayPluginGetNbCameraFunction) (void);
          typedef BOOL (*pfDisplayPluginGetCameraFunction) (int, unsigned char *, unsigned char *);
          typedef BOOL (*pfDisplayPluginInitFunction) (HWND, LPRECT, LPVOID, UINT, int);
          typedef BOOL (*pfDisplayPluginDestroyFunction) (void);
          typedef void (*pfDisplayPluginResizeFunction) (LPRECT);
          typedef void (*pfDisplayPluginPreviewFunction) (BOOL);
          typedef void (*pfDisplayPluginFitToWinFunction) (BOOL);
          typedef void (*pfDisplayPluginShrinkToWinFunction) (BOOL);
          

          And another with functions more to control camera settings like :

          typedef BOOL (*pfApiPluginXcompanyControlPanel) (); //This function display the driver control panel to allow user to set parameters externally of current application.
          typedef BOOL (*pfApiPluginGetExpoTime) (double *);
          typedef BOOL (*pfApiPluginSetExpoTime) (double );
          typedef BOOL (*pfApiPluginSetLuminanceGain) (int,int,int );
          typedef BOOL (*pfApiPluginGetLuminanceGain) (int *, int *, int*);
          typedef BOOL (*pfApiPluginSetAutoExpoTime) (bool );
          typedef BOOL (*pfApiPluginGetAutoExpoTime) ( bool  *);
          typedef BOOL (*pfApiPluginSetAutoWhiteBalance) (bool );
          typedef BOOL (*pfApiPluginGetAutoWhiteBalance) (bool *);
          typedef BOOL (*pfApiPluginGetResolutionInfos) (int ,int *, int *);
          

          Hope I understood your question :)

          But I will have to create my own camera object in order to manage the stream etc, it's like writting a QCamera like. Have you got some keypoints to do that ?

          Have a nice day !

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Suji
            wrote on last edited by Suji
            #5

            Hi,

            So, do someone have some keypoints to do that please ?

            Have a nice day !

            1 Reply Last reply
            0
            • jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Why do you want to use these DLLs? To do what? It is not really clear what you actually want to do.
              Can't you just use QCamera to access the camera?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Suji
                wrote on last edited by Suji
                #7

                Hi @jsulm , and thank you for your answer !

                I want to use these dlls because the company gave me the camera with 2 dlls with so many functions integrated in the camera. So I want to use these functions in a home made soft. I can use the QCamera object to access the camera, but I can't use the functions to act on this QCamera object, because like @Chris-Kawa said, my QCamera object don't know anything about my imported functions.

                Imagine I have an imported function from my dll like activateCamera, I can't use it with my QCamera. So I think I have to integrate my imported functions into a QCamera like class for example. But I don't know how to proceed properly.

                EDIT : I want to use the campany's functions, not the QCameraImageProcessing functions. Moreover, I can't use the QCameraImageProcessing functions, because my camera don't allow it. (QCameraImageProcessing::isAvailable() returns false.)

                1 Reply Last reply
                0
                • jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  You cannot integrate those functions into QCamera, except you change its source code and compile Qt by yourself. But you can implement your own camera class which inherits from QCamera and adds what you need:

                  class MyCamera: public QCamera
                  {
                  ...
                  };
                  

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  S 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    You cannot integrate those functions into QCamera, except you change its source code and compile Qt by yourself. But you can implement your own camera class which inherits from QCamera and adds what you need:

                    class MyCamera: public QCamera
                    {
                    ...
                    };
                    
                    S Offline
                    S Offline
                    Suji
                    wrote on last edited by Suji
                    #9

                    @jsulm said:

                    You cannot integrate those functions into QCamera, except you change its source code and compile Qt by yourself. But you can implement your own camera class which inherits from QCamera and adds what you need:

                    class MyCamera: public QCamera
                    {
                    ...
                    };
                    

                    Yes sure, I understand and I know that, but my question was about how can I organize which is inside class MyCamera : public QCamera ? In order to do something, in the concept, activateCamera which will act on a constructed object camera.
                    I repeat, I'm a rookie, so I'm lost about how to build my ideas.

                    1 Reply Last reply
                    0
                    • jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Not sure whether I understand the question/problem, here how it can look like:

                      class MyCamera: public QCamera
                      {
                          public:
                              void activateCamera()
                              {
                                  // Call here the function from the DLL
                              }
                      };
                      // Then somethere in your application you create an instance of your class and call the method:
                      MyCamera camera;
                      camera.activateCamera();
                      

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        Suji
                        wrote on last edited by
                        #11

                        @jsulm Thanks ! It's clear !

                        Yes, sorry for the lack of clarity, but it's as hard to explain for me as it's hard to understand for you :) By the way, thank you for your help, and your patience !

                        Have a nice day

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved