【问题标题】:how to turn on camera flash light or torch light using qt?如何使用qt打开相机闪光灯或手电筒?
【发布时间】:2016-05-14 17:10:54
【问题描述】:

我需要知道如何使用 qt 打开相机闪光灯或手电筒?有没有办法做到这一点?我正在使用 qt 5.5。请给建议。

这是我的代码

#include "flashon.h"

FlashOn::FlashOn()
{
    cam = new QCamera;
    camExpos = cam->exposure ();
}

FlashOn::~FlashOn()
{
    delete this;
}

void FlashOn::lightOn()
{
    camExpos->setFlashMode (QCameraExposure::FlashOn);
    qDebug() << " light is on ";
}

【问题讨论】:

  • 请更具体。前任。设备、部署等
  • 我正在构建一个跨平台应用程序来打开相机闪光灯。我的代码很简单,但它不起作用。我能做什么?
  • 您可以在您的 C++ 应用程序(或其他)中实现一个目标 c 文件,然后在此处使用 tibidabo 解决方案:stackoverflow.com/questions/5882829/…

标签: qt


【解决方案1】:

好吧,如果您阅读文档,QCameraExposure::FlashModes 中有 QCameraExposure::FlashTorch

camExpos->setFlashMode(QCameraExposure::FlashTorch);

并非所有设备都支持:

QCameraExposure::FlashTorch - 0x20 - 恒定光源。如果支持,可以在不加载相机的情况下启用手电筒。

所以你可能想检查它是否可用:

if (!camExpos->isFlashModeSupported(QCameraExposure::FlashTorch)) {
    // ...not supported...
}

【讨论】:

  • 我已经像这样编辑过但没有运气 cam->start (); if(camExpos->isFlashModeSupported (QCameraExposure::FlashTorch)){ camExpos->setFlashMode (QCameraExposure::FlashTorch); }
  • @coder_hasib 好吧,如果您对其进行了编辑,您是否确保 isFlashModeSupported 为手电筒模式返回了 true,以便调用 setFlashMode?​​span>
  • 我已经检查过但仍然没有运气 if(camExpos->isFlashModeSupported (QCameraExposure::FlashTorch)){ qDebug() setFlashMode (QCameraExposure::FlashTorch); } else { qDebug()
  • @coder_hasib 如果您想说的是“Flash 支持”但它不起作用,那么我建议您从像Qt Camera Example 这样的完整示例开始工作。我之前没有检查过,但似乎more involved 在设置有效的相机实例时比new QCamera 更重要,例如new QCamera (QCameraInfo::defaultCamera())。因此,在尝试此特定调整之前,请确保您可以运行一个有效的演示。
  • 对不起,我已阅读但找不到相机曝光或任何相关内容。
猜你喜欢
  • 1970-01-01
  • 2011-03-12
  • 1970-01-01
  • 2019-12-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多