Access to my camera not granted.
-
Hello,
My environment is below,
Mac mini, MacOS M1 64bit, Sonoma 14.5
XCode: 15.2The required usage description in my Info.plist is below,
<key>NSPhotoLibraryUsageDescription</key> <!-- added this for photo library permission -->
<string>Need library access to upload images</string>
<key>NSCameraUsageDescription</key> <!-- added this for camera permission -->
<string>Need camera access to take pictures</string>
<key>NSMicrophoneUsageDescription</key> <!-- added this for microphone permission -->
<string>Multimedia Example</string>I use QCamera and QVideoSink for video streaming capturing,
if I use Qt 6.5.3, my application works fine;
but if I use Qt 6.6.3 and Qt 6.7.1, my application can not work with my camera due to the following message,
qt.permissions: Could not find permission plugin for QCameraPermission. Please make sure you have included the required usage description in your Info.plist.
Access to camera not granted.May I know if I misunderstand something?
Thanks.
Have a nice day. -
Hello,
Here I answer this question by myself, hope my answer can help someone who also meets this issue.-
Set QMAKE_INFO_PLIST in your pro file.
Please refer https://doc.qt.io/qt-6/ios-platform-notes.html#info-plist-with-qmake -
Make one function to check camera permission.
For example,
void MainWindow::checkCameraPermission(void)
{ // please refer https://code.qt.io/cgit/qt/qtmultimedia.git/tree/examples/multimedia/camera?h=6.7
#if QT_CONFIG(permissions)QCameraPermission cameraPermission;
switch (qApp->checkPermission(cameraPermission)) {
case Qt::PermissionStatus::Undetermined:
qApp->requestPermission(cameraPermission, this, &MainWindow::checkCameraPermission);
return;
case Qt::PermissionStatus::Denied:
std::cout << "Camera permission is not granted!" << std::endl;
return;
case Qt::PermissionStatus::Granted:
std::cout << "Camera permission is granted!" << std::endl;
break;
}
#endif
}-
Make one function to check camera permission status.
For example,
void MainWindow::checkAuthorizationStatus(void)
{
#if QT_CONFIG(permissions)QCameraPermission cameraPermission;
Qt::PermissionStatus auth_status = Qt::PermissionStatus::Undetermined;
while(true)
{
QThread::msleep(1);
auth_status = qApp->checkPermission(cameraPermission);if(auth_status == Qt::PermissionStatus::Undetermined) continue; break;
}
#endif // if QT_CONFIG
}- Before searching your camera, call the following functions,
checkCameraPermission();
checkAuthorizationStatus();
At my side, this issue had been solved.
Thanks.
Have a nice day. -
-
Hello,
Here I answer this question by myself, hope my answer can help someone who also meets this issue.-
Set QMAKE_INFO_PLIST in your pro file.
Please refer https://doc.qt.io/qt-6/ios-platform-notes.html#info-plist-with-qmake -
Make one function to check camera permission.
For example,
void MainWindow::checkCameraPermission(void)
{ // please refer https://code.qt.io/cgit/qt/qtmultimedia.git/tree/examples/multimedia/camera?h=6.7
#if QT_CONFIG(permissions)QCameraPermission cameraPermission;
switch (qApp->checkPermission(cameraPermission)) {
case Qt::PermissionStatus::Undetermined:
qApp->requestPermission(cameraPermission, this, &MainWindow::checkCameraPermission);
return;
case Qt::PermissionStatus::Denied:
std::cout << "Camera permission is not granted!" << std::endl;
return;
case Qt::PermissionStatus::Granted:
std::cout << "Camera permission is granted!" << std::endl;
break;
}
#endif
}-
Make one function to check camera permission status.
For example,
void MainWindow::checkAuthorizationStatus(void)
{
#if QT_CONFIG(permissions)QCameraPermission cameraPermission;
Qt::PermissionStatus auth_status = Qt::PermissionStatus::Undetermined;
while(true)
{
QThread::msleep(1);
auth_status = qApp->checkPermission(cameraPermission);if(auth_status == Qt::PermissionStatus::Undetermined) continue; break;
}
#endif // if QT_CONFIG
}- Before searching your camera, call the following functions,
checkCameraPermission();
checkAuthorizationStatus();
At my side, this issue had been solved.
Thanks.
Have a nice day. -
-