Beispiel #1
0
NetCamView::NetCamView(int friendId, QWidget* parent)
    : GenericNetCamView(parent)
    , selfFrame{nullptr}
    , friendId{friendId}
{
    QString id = FriendList::findFriend(friendId)->getToxId().toString();
    videoSurface = new VideoSurface(Nexus::getProfile()->loadAvatar(id), this);
    videoSurface->setMinimumHeight(256);
    videoSurface->setContentsMargins(6, 6, 6, 6);

    verLayout->insertWidget(0, videoSurface, 1);

    selfVideoSurface = new VideoSurface(Nexus::getProfile()->loadAvatar(), this, true);
    selfVideoSurface->setObjectName(QStringLiteral("CamVideoSurface"));
    selfVideoSurface->setMouseTracking(true);
    selfVideoSurface->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    selfFrame = new MovableWidget(videoSurface);
    selfFrame->show();

    QHBoxLayout* frameLayout = new QHBoxLayout(selfFrame);
    frameLayout->addWidget(selfVideoSurface);
    frameLayout->setMargin(0);

    updateRatio();
    connect(selfVideoSurface, &VideoSurface::ratioChanged, this, &NetCamView::updateRatio);

    connect(videoSurface, &VideoSurface::boundaryChanged, [this]()
    {
        QRect boundingRect = videoSurface->getBoundingRect();
        updateFrameSize(boundingRect.size());
        selfFrame->setBoundary(boundingRect);
    });

    connect(videoSurface, &VideoSurface::ratioChanged, [this]()
    {
        selfFrame->setMinimumWidth(selfFrame->minimumHeight() * selfVideoSurface->getRatio());
        QRect boundingRect = videoSurface->getBoundingRect();
        updateFrameSize(boundingRect.size());
        selfFrame->resetBoundary(boundingRect);
    });

    connect(Core::getInstance(), &Core::selfAvatarChanged, [this](const QPixmap& pixmap)
    {
        selfVideoSurface->setAvatar(pixmap);
    });

    connect(Core::getInstance(), &Core::friendAvatarChanged, [this](int FriendId, const QPixmap& pixmap)
    {
        if (this->friendId == FriendId)
            videoSurface->setAvatar(pixmap);
    });

    VideoMode videoMode;
    QSize videoSize = Settings::getInstance().getCamVideoRes();
    videoMode.width = videoSize.width();
    videoMode.height = videoSize.height();
    qDebug() << "SIZER" << videoSize;
    videoMode.FPS = Settings::getInstance().getCamVideoFPS();
}
Beispiel #2
0
NetCamView::NetCamView(int friendId, QWidget* parent)
    : GenericNetCamView(parent)
    , selfFrame{nullptr}
    , friendPk{FriendList::findFriend(friendId)->getPublicKey()}
    , e(false)
{
    videoSurface = new VideoSurface(Nexus::getProfile()->loadAvatar(friendPk), this);
    videoSurface->setMinimumHeight(256);

    verLayout->insertWidget(0, videoSurface, 1);

    selfVideoSurface = new VideoSurface(Nexus::getProfile()->loadAvatar(), this, true);
    selfVideoSurface->setObjectName(QStringLiteral("CamVideoSurface"));
    selfVideoSurface->setMouseTracking(true);
    selfVideoSurface->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    selfFrame = new MovableWidget(videoSurface);
    selfFrame->show();

    QHBoxLayout* frameLayout = new QHBoxLayout(selfFrame);
    frameLayout->addWidget(selfVideoSurface);
    frameLayout->setMargin(0);

    updateRatio();
    connections +=
        connect(selfVideoSurface, &VideoSurface::ratioChanged, this, &NetCamView::updateRatio);

    connections += connect(videoSurface, &VideoSurface::boundaryChanged, [this]() {
        QRect boundingRect = videoSurface->getBoundingRect();
        updateFrameSize(boundingRect.size());
        selfFrame->setBoundary(boundingRect);
    });

    connections += connect(videoSurface, &VideoSurface::ratioChanged, [this]() {
        selfFrame->setMinimumWidth(selfFrame->minimumHeight() * selfVideoSurface->getRatio());
        QRect boundingRect = videoSurface->getBoundingRect();
        updateFrameSize(boundingRect.size());
        selfFrame->resetBoundary(boundingRect);
    });

    connections += connect(Nexus::getProfile(), &Profile::selfAvatarChanged,
                           [this](const QPixmap& pixmap) { selfVideoSurface->setAvatar(pixmap); });

    connections += connect(Nexus::getProfile(), &Profile::friendAvatarChanged,
                           [this](ToxPk friendPk, const QPixmap& pixmap) {
                               if (this->friendPk == friendPk)
                                   videoSurface->setAvatar(pixmap);
                           });

    QRect videoSize = Settings::getInstance().getCamVideoRes();
    qDebug() << "SIZER" << videoSize;
}
Beispiel #3
0
void highSpeed::setROI(int _x, int _y, int w, int h)
{
	unsigned long roiStep=0;
	XsGetCameraInfo(hCam,XSI_ROI_STEP,&roiStep,&nHi);
	XsGetCameraInfo(hCam,XSI_SNS_WIDTH,&maxWidth,&nHi);
	XsGetCameraInfo(hCam,XSI_SNS_HEIGHT,&maxHeight,&nHi);
	if(_x>=0&&_x+w<=maxWidth){
		if(_y>=0&&_y+h<=maxHeight){
			x=_x,y=_y;
			int found=w;
			int diff=2048;
			int num=0;
			for(int i=0; i<maxWidth/roiStep+1; i++){
				int k=i*roiStep;
				if(abs(w-(k))<diff) diff=abs(w-(k)),found=k;
			}
			width=found;
			height=h;
			XsSetParameter(hCam,&xsCfg,XSP_ROIX,x);
			XsSetParameter(hCam,&xsCfg,XSP_ROIY,y);
			XsSetParameter(hCam,&xsCfg,XSP_ROIWIDTH,width);
			XsSetParameter(hCam,&xsCfg,XSP_ROIHEIGHT,height);
			refreshSettings();
		}
	}
	updateFrameSize();
}
Beispiel #4
0
CameraImageSource::CameraImageSource(int device, QObject *parent):ImageSource(parent)
{
    capture = new VideoCapture(device);
    if(!capture->isOpened())
        throw new Exception();
    updateFrameSize();
}
int FormStreamingImp::switchResolution(int w,int h )
{
      
   if( webcam_frame->size() == QSize(w,h) )
          return 1;
    
   WebcamController.clear();  
   if( current_webcam->setResolution(w,h) )
     {
	/* Resolution Switch was ok, but not with our requested values.
	 * This is needed because of the qimage processing....
	 * gdk_rgb.. (gtk) wouldn't need this */
	if( QSize(w,h) != current_webcam->getSize() )
	  {
	     QMessageBox::information(this,tr("Informacion"),tr("La resolucion solicitada no esta disponible\nSe ajustaran los valores adquiridos"));
	     w = current_webcam->getSize().width();
	     h = current_webcam->getSize().height();
	     qDebug("Trying: %dx%d Got: %dx%d\n",w,h,current_webcam->getSize().width(),current_webcam->getSize().height());
	  }
	
	updateFrameSize(w,h);
	current_webcam->setDrawSurface( webcam_frame);
       	return 1;
     }
   else
     handleError();

   return 0;

}
Beispiel #6
0
FileImageSource::FileImageSource(QString fileName, QObject *parent) : ImageSource(parent), fileName(fileName)
{
    capture = new VideoCapture(fileName.toStdString());
    if(!capture->isOpened()) {
        throw new Exception();
    }
    frameGettingTime = 0;
    interval = (int)(1000000 / (capture->get(CV_CAP_PROP_FPS) + 1) );
    updateFrameSize();
}
void GLViewImpl::setFrameZoomFactor(float zoomFactor)
{
    CCASSERT(zoomFactor > 0.0f, "zoomFactor must be larger than 0");

    if (fabs(_frameZoomFactor - zoomFactor) < FLT_EPSILON)
    {
        return;
    }

    _frameZoomFactor = zoomFactor;
    updateFrameSize();
}
void GLViewImpl::enableRetina(bool enabled)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
    _isRetinaEnabled = enabled;
    if (_isRetinaEnabled)
    {
        _retinaFactor = 1;
    }
    else
    {
        _retinaFactor = 2;
    }
    updateFrameSize();
#endif
}
Beispiel #9
0
CustomRuler::CustomRuler(const Timecode &tc, const QList<QAction *> &rulerActions, CustomTrackView *parent) :
        QWidget(parent),
        m_timecode(tc),
        m_view(parent),
        m_duration(0),
        m_offset(0),
        m_hidePreview(true),
        m_headPosition(SEEK_INACTIVE),
        m_clickedGuide(-1),
        m_rate(-1),
        m_mouseMove(NO_MOVE)
{
    setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
    QFontMetricsF fontMetrics(font());
    // Define size variables
    LABEL_SIZE = fontMetrics.ascent();
    FONT_WIDTH = fontMetrics.averageCharWidth();
    PREVIEW_SIZE = LABEL_SIZE / 3;
    setFixedHeight(LABEL_SIZE * 2);
    MAX_HEIGHT = height() - 1;
    FULL_HEIGHT = MAX_HEIGHT;
    int mark_length = MAX_HEIGHT - LABEL_SIZE - 1;
    MIDDLE_MARK_X = LABEL_SIZE + mark_length / 3;
    LITTLE_MARK_X = LABEL_SIZE + mark_length / 2;
    updateFrameSize();
    m_scale = 3;
    m_zoneStart = 0;
    m_zoneEnd = 100;
    m_contextMenu = new QMenu(this);
    m_contextMenu->addActions(rulerActions);
    QAction *addGuide = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("list-add")), i18n("Add Guide"));
    connect(addGuide, SIGNAL(triggered()), m_view, SLOT(slotAddGuide()));
    m_editGuide = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18n("Edit Guide"));
    connect(m_editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
    m_deleteGuide = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Delete Guide"));
    connect(m_deleteGuide , SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
    QAction *delAllGuides = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Delete All Guides"));
    connect(delAllGuides, SIGNAL(triggered()), m_view, SLOT(slotDeleteAllGuides()));
    m_goMenu = m_contextMenu->addMenu(i18n("Go To"));
    connect(m_goMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotGoToGuide(QAction*)));
    setMouseTracking(true);
    m_zoneBG = palette().color(QPalette::Highlight);
    m_zoneBG.setAlpha(KdenliveSettings::useTimelineZoneToEdit() ? 180 : 60);
}
Beispiel #10
0
void highSpeed::intitialize(int cameraNum)
{
	err = XsLoadDriver(0);
	if( err == XS_SUCCESS )
	{
		bDriverLoaded=true;
		//fills the xsArray with available cameras, based on the filter value (in this case, looking for N-type cameras on Gig-E)
		err = XsEnumCameras(&xsArray[0],&nItems,XS_EF_GE_N);
		if( err == XS_SUCCESS && nItems>0)
		{
			err = XsOpenCamera(xsArray[cameraNum].nCameraId,&hCam);
			if( err == XS_SUCCESS )
			{
				bOpen=true;
				// 4 - Get the parameter structure from the camera

				xsCfg.cbSize = sizeof(XS_SETTINGS);	// don't forget this!!!
				err = XsReadCameraSettings(hCam,&xsCfg);
				//err = XsReadDefaultSettings( hCam, &xsCfg );
				if( err==XS_SUCCESS )
				{
					//XsSetParameter(hCam, &xsCfg, XSP_TRIGIN_CFG, XS_TIC_EDGE_HI);  //this is for setting the trigger with the bnc on cam
					XsSetParameter(hCam, &xsCfg, XSP_SYNCIN_CFG,XS_SIC_INTERNAL);
					XsSetParameter(hCam, &xsCfg, XSP_REC_MODE, XS_RM_CIRCULAR);
					//unsigned long newDesign;
					XsGetCameraInfo(hCam,XSI_LIVE_BUF_SIZE,&memOffset,&nHi);
					err = XsRefreshCameraSettings(hCam,&xsCfg);
					if( err == XS_SUCCESS )
					{
						// 9 - Get the image size
						updateFrameSize();
					}
					else ofLog(OF_LOG_WARNING,"Unable to configure the camera!!!\n");
				}
				else ofLog(OF_LOG_WARNING,"Unable to read camera settings!!!\n");
			}
			else ofLog(OF_LOG_WARNING,"Unable to open camera %i!!!\n", cameraNum);
		}
		else ofLog(OF_LOG_WARNING,"Unable to enumerate cameras!!!\n");
	}
	bFramesCaptured=bFramesSaved=justTriggered=false;
}
void GeneralTab::updateVidCapFormat()
{
	v4l2_fmtdesc desc;
	v4l2_format fmt;

	g_fmt_cap(fmt);
	m_pixelformat = fmt.fmt.pix.pixelformat;
	m_width       = fmt.fmt.pix.width;
	m_height      = fmt.fmt.pix.height;
	updateFrameSize();
	if (enum_fmt_cap(desc, true)) {
		do {
			if (desc.pixelformat == fmt.fmt.pix.pixelformat)
				break;
		} while (enum_fmt_cap(desc));
	}
	if (desc.pixelformat != fmt.fmt.pix.pixelformat)
		return;
	m_vidCapFormats->setCurrentIndex(desc.index);
}
Beispiel #12
0
CustomRuler::CustomRuler(const Timecode &tc, CustomTrackView *parent) :
        QWidget(parent),
        m_timecode(tc),
        m_view(parent),
        m_duration(0),
        m_offset(0),
        m_headPosition(SEEK_INACTIVE),
        m_clickedGuide(-1),
        m_rate(-1),
        m_mouseMove(NO_MOVE)
{
    setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
    QFontMetricsF fontMetrics(font());
    // Define size variables
    LABEL_SIZE = fontMetrics.ascent();
    FONT_WIDTH = fontMetrics.averageCharWidth();
    setMinimumHeight(LABEL_SIZE * 2);
    setMaximumHeight(LABEL_SIZE * 2);
    MAX_HEIGHT = height();
    BIG_MARK_X = LABEL_SIZE + 1;
    int mark_length = MAX_HEIGHT - BIG_MARK_X;
    MIDDLE_MARK_X = BIG_MARK_X + mark_length / 2;
    LITTLE_MARK_X = BIG_MARK_X + mark_length / 3;
    updateFrameSize();
    m_scale = 3;
    m_zoneStart = 0;
    m_zoneEnd = 100;
    m_contextMenu = new QMenu(this);
    QAction *addGuide = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("document-new")), i18n("Add Guide"));
    connect(addGuide, SIGNAL(triggered()), m_view, SLOT(slotAddGuide()));
    m_editGuide = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18n("Edit Guide"));
    connect(m_editGuide, SIGNAL(triggered()), this, SLOT(slotEditGuide()));
    m_deleteGuide = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Delete Guide"));
    connect(m_deleteGuide , SIGNAL(triggered()), this, SLOT(slotDeleteGuide()));
    QAction *delAllGuides = m_contextMenu->addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Delete All Guides"));
    connect(delAllGuides, SIGNAL(triggered()), m_view, SLOT(slotDeleteAllGuides()));
    m_goMenu = m_contextMenu->addMenu(i18n("Go To"));
    connect(m_goMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotGoToGuide(QAction*)));
    setMouseTracking(true);
}
bool FormStreamingImp::setWebcamDevice( const QString &fname, const QSize &max_size )
{
   if( fname.isEmpty() )
     return false;
   qDebug("SETTING WEBCAM DEVICE\n");
   
   current_webcam->setDevice(fname);
   WebcamController.clear();
   if( !initialize(max_size) )
     {
	
	qDebug("Initialize Error\n");
	handleError(); //no se pudo inicializar
	enableButtons(false);
	return false;
     }
   updateFrameSize(max_size.width(),max_size.height());
   current_webcam->setDrawSurface( webcam_frame);
  	qDebug("Initialize OK\n"); 
   enableButtons();
   webcam_opened = true;
   return true;

}
void GLViewImpl::setFrameSize(float width, float height)
{
    GLView::setFrameSize(width, height);
    updateFrameSize();
}
void WindowGrabber::start()
{
    if (m_active)
        return;

    int result = 0;

#ifdef Q_OS_BLACKBERRY_TABLET

    // HACK: On the Playbook, screen_read_window() will fail for invisible windows.
    //       To workaround this, make the window visible again, but set a global
    //       alpha of less than 255. The global alpha makes the window completely invisible
    //       (due to a bug?), but screen_read_window() will work again.

    errno = 0;
    int val = 200; // anything less than 255
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_GLOBAL_ALPHA, &val);
    if (result != 0) {
        qWarning() << "WindowGrabber: unable to set global alpha:" << strerror(errno);
        return;
    }

    errno = 0;
    val = 1;
    result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_VISIBLE, &val);
    if (result != 0) {
        qWarning() << "WindowGrabber: unable to make window visible:" << strerror(errno);
        return;
    }
#endif

    result = screen_create_context(&m_screenContext, SCREEN_APPLICATION_CONTEXT);
    if (result != 0) {
        qWarning() << "WindowGrabber: cannot create screen context:" << strerror(errno);
        return;
    } else {
        m_screenContextInitialized = true;
    }

    result = screen_create_pixmap(&m_screenPixmaps[0], m_screenContext);
    result = screen_create_pixmap(&m_screenPixmaps[1], m_screenContext);
    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot create pixmaps:" << strerror(errno);
        return;
    }

    const int usage = SCREEN_USAGE_NATIVE;
    result = screen_set_pixmap_property_iv(m_screenPixmaps[0], SCREEN_PROPERTY_USAGE, &usage);
    result |= screen_set_pixmap_property_iv(m_screenPixmaps[1], SCREEN_PROPERTY_USAGE, &usage);

    const int format = SCREEN_FORMAT_RGBX8888;
    screen_set_pixmap_property_iv(m_screenPixmaps[0], SCREEN_PROPERTY_FORMAT, &format);
    screen_set_pixmap_property_iv(m_screenPixmaps[1], SCREEN_PROPERTY_FORMAT, &format);

    int size[2] = { 0, 0 };

    result = screen_get_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, size);
    if (result != 0) {
        cleanup();
        qWarning() << "WindowGrabber: cannot get window size:" << strerror(errno);
        return;
    }

    m_screenBufferWidth = size[0];
    m_screenBufferHeight = size[1];

    updateFrameSize();

    m_timer.start();

    m_active = true;
}