Пример #1
0
VideoControl::VideoControl(MediaElement::ElementsDB& elementsDB,
                           const Glib::RefPtr<Gtk::Builder>& refGlade) : elementsDB(elementsDB),
    encoder(elementsDB, refGlade),
    videoMode(refGlade, "videoMode"), videoFramerate(refGlade,"videoFramerate"),
    videoResolution(refGlade, "videoResolution"), resolutionDialog(elementsDB, refGlade) {

    isEnabledSignals = true;

    initVideoMode(videoMode);
    initVideoFramerate(videoFramerate);
    initVideoResolution(videoResolution);

    videoMode.signal_changed().connect(sigc::mem_fun(*this, &VideoControl::videoModeChanged));
    videoFramerate.signal_changed().connect(sigc::mem_fun(*this, &VideoControl::videoFramerateChanged));
    videoResolution.signal_changed().connect(sigc::mem_fun(*this, &VideoControl::videoResolutinChanged));
    encoder.signalUserInput().connect(sigc::mem_fun(*this, &VideoControl::encoderUserInput));
}
Пример #2
0
Libdc1394SequenceGrabber::Libdc1394SequenceGrabber(const std::string& name, unsigned int w, unsigned int h, unsigned int rate)
:	cefix::SequenceGrabber(name, w, h, rate),
	_context(Libdc1394Context::get()),
	_camera(NULL),
	_firstFrame(true),
	_bayerMethod(DC1394_BAYER_METHOD_BILINEAR),
	_bayerPattern(DC1394_COLOR_FILTER_RGGB)

{
	msg(osg::INFO) << "LibdcSequenceGrabber " << name << std::endl;
	
	setImage(new osg::ImageStream());
	getImage()->setOrigin(osg::Image::TOP_LEFT);
	
	uint64_t uid = 0;
	
	bool grey = false;
    _format7 = false;
	int format_7_format_delta(0);
	if (name.empty() == false) {
		std::vector<std::string> parts;
		
		cefix::strTokenize(name,parts,":");
		uid=cefix::hexToLong(parts[0]);
		
		for(unsigned int i = 1; i < parts.size(); ++i) {
			std::string part = cefix::strToLower(parts[i]);
			if (part == "grey")
				grey = true;
            else if (part == "format7") {
                _format7 = true;
                if (i+1 < parts.size()) {
                    format_7_format_delta = atoi(parts[i+1].c_str());
                    ++i;
                }
            }
		}
	}
    
    
    if (_roi.height == 0) _roi.height = h;
    if (_roi.width == 0) _roi.width = w;
    
	initCamera(uid);
    
	if (_camera) {
        unsigned int video_mode(0);
        unsigned int color_mode(0);
        if (_format7)
        {
            video_mode = DC1394_VIDEO_MODE_FORMAT7_0+format_7_format_delta;
            color_mode = (!grey) ?  DC1394_COLOR_CODING_RGB8 : DC1394_COLOR_CODING_MONO8;
        }
		if (!initVideoMode(w,h, grey, video_mode, color_mode)) {
			grey  = !grey;
			msg(osg::INFO) << " could not find suitable video mode, toggling grey/color " << std::endl;
			if (!initVideoMode(w,h, grey)) {
				msg(osg::WARN) << "could not find suitable video mode for " << w << "x" << h << std::endl;
			}
		}
	
		initFrameRate(rate);
	
        dc1394error_t  err;
        if (_format7) {
             err = dc1394_format7_set_color_coding(_camera, _videomode, (dc1394color_coding_t)color_mode);
             checkSuccess(err, "dc1394_format7_set_color_coding failed");
        }
        
        if (_format7) {
            err = dc1394_format7_get_image_size(_camera, _videomode, &w, &h);
            checkSuccess(err, "dc1394_format7_get_image_size failed");
        }
        else
        {
            err = dc1394_get_image_size_from_video_mode(_camera, _videomode, &w, &h);
            checkSuccess(err, "dc1394_get_image_size_from_video_mode failed");
        }
    }
    
	if (grey) {
		getImage()->allocateImage(w,h,1,GL_LUMINANCE, GL_UNSIGNED_BYTE);
	} else { 
		getImage()->allocateImage(w,h,1,GL_RGB, GL_UNSIGNED_BYTE);
	}
	
	_grey = grey;
}