QCamera switches not to Active State
I have Windows-Desktop program which work on the PC an some tablets. Now I have an other tablet and cannot take photos with it.
The problem is that the camera switches not to active state.
I get only Loaded and Starting Status, but in the docu I read.
[slot] void QCamera::start()
Starts the camera.
State is changed to QCamera::ActiveState if camera is started successfully, otherwise error() signal is emitted.
While the camera state is changed to QCamera::ActiveState, starting the camera service can be asynchronous with the actual status reported with QCamera::status property.
I have conneted the error slot of the camera, but I get no signal.
With a connected USB-Webcam all works correct!
What can be the problem with the internal camera ?
PS. The System ist Windows 10, 64-bit, Qt 5.6.0.
Must I active some user-rights for the camera maybe?
Maybe a silly question, but is it working correctly outside of Qt ?
Can you give more information about the hardware you have ?
Hi @SGaist ,
the camera works with the store Camera app from Microsoft and with some camera desktop programs.
May be I found a correlation. For my tested tablets, Qt works always with camera connected via USB, external or internal (you can see it in the devicemanger under driver.)
All cameras internal connected (how ever the producer made this) do not work!
Any ideas ?
What does the device manager say about the internal camera ?
What do you get if you list all available cameras from Qt ?
In the device-manger I see under Image-Processings (translation from German) the Intel(R) Imaging Signal-Projessor 2400.
When I scan with Qt I get 2 camera names.
HM 2056Front and HM 2056Rear
IMX175 and OV27200
This differs indeed from the name in the device-manager. So I dont see the real camera name here, especialy the 2 camera names for front and rear, in the device manager.
This differs complete for a USB connected camera - here I see in the device manager the same name as in Qt.
But I find under System Devices entries for it.
Camera Sensor IMX175 and Camera Sensor OV27200.
Maybe this is the problem. Any ideas to solve the problem ?
An other thing that I do not understand is the constructor of a QCamera:
Cam=new QCamera(QByteArray(" Nonsens "), this);
This gives always a pointer != NULL,
How can I check if the returned QCamera is valid ?
Because there's no reason for new to return a null pointer. If new would fail it will throw a std::bad_alloc error.
What I usually do is to follow the QCamera detailed explanation example. Doing so you ensure that you create a valid camera.
Yes, this is indeed near to my code. I use the CameraInfo to construct the QCamera. Nevertheless I tested with the QByteArray in the constructor. This should work too but
it gives for every nonsens-camera name a valid pointer. This confused me.
Is there a way to check if the constructed QCamera is valid?
That's basic C++:
newwill create a new object. It has absolutely not reason to return a null pointer. The fact that you are giving random invalid parameter to the constructor has no influence on the functionality of
For more detailed information, look here.
You can always check the error function but I don't think that it will work on a just constructed camera (might be wrong though, test it).
As for your application, it's up to you to not allow your users to enter invalid values. Use QCameraInfo::availableCameras to create a list of device name they can access so you ensure that you are always working with supported devices.
Yes of course I was a little bit stupid. I was so absorbed from my primary camera problem that I forgot the C++ basics. New MUST give something back if there is enough memory for allocating it.
The errorfunction give no error - but it switches not to active state :-( . That seem the only problem ....
Does it also happen if you use the QCameraInfo matching the device name ?
cam = new QCamera(CamInfos, this);
This is the code from the integrated Qt example -> does not work on tablet
QString devname = CamInfos.deviceName();
Cam= new QCamera(QByteArray(devname.toUtf8()), this);
I took this code with converting to Utf8. I get no access on the tablet. Not activated.
On my PC with a USB WebCam it works, but it is independent from the device name. For any device name it seem that I get my one and only WebCam. So that I cannot check of if the name converting is correct. Is this a default behaviour of the QCamera - constructor that it picks a camera if the device name does not match?
AFAIK, it should just get you an invalid camera.
So currently, you get both cameras from your tablet listed but none get started properly ?
Does it also happen with the QML Camera example ?
I am seeing this very same issue on a different tablet with the same cameras: Camera Sensor IMX175 and Camera Sensor OV27200. Seeing this issue even with the latest qt bits and still seeing this issue. Did you ever figure this out?
No, never solved the problem.
I take the standard windows camera now. The communication is a little bit complicated but it works for me.