void CameraExample::enableCamera() { m_camera = new QCamera(); m_camera->setCaptureMode(QCamera::CaptureStillImage); connect(m_camera, SIGNAL(error(QCamera::Error)), this, SLOT(error(QCamera::Error))); connect(m_camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)), this, SLOT(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason))); // Own video output drawing that shows camera view finder pictures //! [0] QMediaService* ms = m_camera->service(); QVideoRendererControl* vrc = ms->requestControl<QVideoRendererControl*>(); m_myVideoSurface = new MyVideoSurface(this,this,this); vrc->setSurface(m_myVideoSurface); //! [0] // Image capturer m_stillImageCapture = new QCameraImageCapture(m_camera); connect(m_stillImageCapture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(imageCaptured(int,QImage))); // Start camera if (m_camera->state() == QCamera::ActiveState) { m_camera->stop(); } m_videoWidget->show(); m_camera->start(); showViewFinder = true; }
void ChilitagsDetection::setSource(QObject *source) { QVariant mediaObjectProperty = source->property("mediaObject"); QMediaObject *mediaObject = qvariant_cast<QMediaObject *>(mediaObjectProperty); QMediaService *mediaService = mediaObject->service(); QVideoRendererControl *rendererControl = mediaService->requestControl<QVideoRendererControl *>(); rendererControl->setSurface(&m_surface); m_source = source; }
void QGraphicsVideoItemPrivate::clearService() { if (rendererControl) { surface->stop(); rendererControl->setSurface(0); service->releaseControl(rendererControl); rendererControl = 0; } if (service) { QObject::disconnect(service, SIGNAL(destroyed()), q_ptr, SLOT(_q_serviceDestroyed())); service = 0; } }
void ARCameraQml::setMediaObject(QMediaObject* mediaObject) { if (mediaObject != _mediaObject) { QMediaService* service = mediaObject->service(); if (service) { QVideoRendererControl* rendererControl = dynamic_cast<QVideoRendererControl*>( service->requestControl(QVideoRendererControl_iid)); if (rendererControl) { rendererControl->setSurface(&_surface); //updateOrientation(); _mediaObject = mediaObject; emit mediaObjectChanged(); return; } } } qDebug() << Q_FUNC_INFO << ": Failed to set media object"; }