glm::vec3 Camera::getDirectionFromCoordinate(int sx, int sy) { if (!camSet) { setCameraState(); } glm::vec3 P = M + (2*((float)sx/(imgWidth-1)) - 1)*H + (2*((float)sy/(imgHeight-1)) - 1)*V; return P; }
void LadybugWidget::navigationMousePress(QMouseEvent* e) { QRect arrowRect = QRect(QPoint(-5, 0), QPoint(5, -10)); QPoint centerPt = NAVIGATION_RECT.center(); QMatrix m; m.translate(centerPt.x(), centerPt.y()); for (int i = 0; i < 5; i++) { QMatrix m2 = m; m2.rotate(i*360/5); m2.translate(0,-16); QPoint resPt = m2.inverted().map(e->pos()); if (arrowRect.contains(resPt)) { // invert camera on/off setting setCameraState(i, !cameraState(i)); if (mPaused) updateVideo(getSingleFrame(mCurrentFrame)); } } }
void QDeclarativeCamera::setupDevice(const QString &deviceName) { QMediaService *service = m_camera->service(); if (!service) return; QVideoDeviceSelectorControl *deviceControl = qobject_cast<QVideoDeviceSelectorControl*>(service->requestControl(QVideoDeviceSelectorControl_iid)); if (!deviceControl) return; int deviceIndex = -1; if (deviceName.isEmpty()) { deviceIndex = deviceControl->defaultDevice(); } else { for (int i = 0; i < deviceControl->deviceCount(); ++i) { if (deviceControl->deviceName(i) == deviceName) { deviceIndex = i; break; } } } if (deviceIndex == -1) return; State previousState = cameraState(); setCameraState(UnloadedState); deviceControl->setSelectedDevice(deviceIndex); QCameraInfo oldCameraInfo = m_currentCameraInfo; m_currentCameraInfo = QCameraInfo(*m_camera); emit deviceIdChanged(); if (oldCameraInfo.description() != m_currentCameraInfo.description()) emit displayNameChanged(); if (oldCameraInfo.position() != m_currentCameraInfo.position()) emit positionChanged(); if (oldCameraInfo.orientation() != m_currentCameraInfo.orientation()) emit orientationChanged(); setCameraState(previousState); }
void LadybugWidget::keyPressEvent(QKeyEvent* e) { if (e->key() >= Qt::Key_1 && e->key() <= Qt::Key_5) { int i = e->key()-Qt::Key_1; // invert camera on/off setting setCameraState(i, !cameraState(i)); if (mPaused) updateVideo(getSingleFrame(mCurrentFrame)); } switch (e->key()) { case Qt::Key_Space: pause(); break; case Qt::Key_Left: seekToFrame(mCurrentFrame-1); break; case Qt::Key_Right: seekToFrame(mCurrentFrame+1); break; case Qt::Key_Home: seekToFrame(0); break; case Qt::Key_End: seekToFrame(mStream.framesCount()-1); break; case Qt::Key_PageUp: seekToFrame(mCurrentFrame-25); break; case Qt::Key_PageDown: seekToFrame(mCurrentFrame+25); break; // %%% seek to random position (for testing) case Qt::Key_S: { uint msecs = rand() % (mStream.framesCount() / 15 * 1000); printf("RANDOM TIME SEEK! %d ms\n", msecs); seekToTime(msecs); break; } } }
/*! \qmlmethod QtMultimedia::Camera::stop() Stops the camera, but leaves the camera stack loaded. */ void QDeclarativeCamera::stop() { setCameraState(QDeclarativeCamera::LoadedState); }
/*! \qmlmethod QtMultimedia::Camera::start() Starts the camera. Viewfinder frames will be available and image or movie capture will be possible. */ void QDeclarativeCamera::start() { setCameraState(QDeclarativeCamera::ActiveState); }
void QDeclarativeCamera::componentComplete() { m_componentComplete = true; setCameraState(m_pendingState); }