Communication between a QObject and imported functions
-
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 ismy_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 !
-
C++ is not a dynamic language. You can't add methods to an object at runtime.
QCamera
class has no methodactivateCamera
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)
. -
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 } ... }
-
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 !
-
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? -
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.) -
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 { ... };
-
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 { ... };
@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. -
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();