///////////////
// Constructor
LAVCVideoProvider::LAVCVideoProvider(wxString filename, wxString subfilename) {
	// Init variables
	codecContext = NULL;
	lavcfile = NULL;
	codec = NULL;
	stream = NULL;
	frame = NULL;
	buffer1 = NULL;
	buffer2 = NULL;
	buffer1Size = 0;
	buffer2Size = 0;
	vidStream = -1;
	zoom = 1.0;
	validFrame = false;
	overlay = NULL;

	// Load
	LoadVideo(filename);

	// Attach subtitles
	try {
		SubtitleProvider::Class::GetProvider(_T("libass"), AssFile::top)->Bind(this);
	} catch (...) {
		/* warn user? */
	}
}
Ejemplo n.º 2
0
	void LoadProcesses()
	{
		if (bootType == '  dc')
		{
			LoadKeybAndMouse();
			//CreateProcess("Partition.bin");
			//CreateProcess("FAT.bin");
		}
		else if ((bootType == ' 3df') || (bootType == ' 5df'))
		{
			CreateProcess("Partition.bin");
			//CreateProcess("ATA.bin");
			LoadKeybAndMouse();
		}
		else
		{
			return;
		}
		CreateProcess("PCI.bin");
		CreateProcess("Network.bin");
		CreateProcess("NE2000.bin");
		CreateProcess("Am79C970.bin");
		CreateProcess("Rtl8139.bin");

		char* videoDrvList[] =
		{
			"BochsVideo.bin",
			"CLGD5446Video.bin",
			"S3Trio64Video.bin",
			"GeForceVideo.bin",
			"VMwareVideo.bin",
			"VGAVideo.bin",
			null
		};
		LoadVideo(videoDrvList);

		CreateProcess("Renderer.bin");
		CreateProcess("SurfMgr.bin");
		CreateProcess("Cursor.bin");
		CreateProcess("Desktop.bin");
		CreateProcess("Font.bin");

		KeWaitForSymbol(SmCursor_Ready);
		KeWaitForSymbol(SmDesktop_Ready);
		KeWaitForSymbol(SmFont_Ready);
		KeSetSymbol(Sm_InitStage2);

		CreateProcess("Viewer.bin");
	}
Ejemplo n.º 3
0
/// @brief Constructor 
/// @param filename The filename to open
FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(wxString filename)
: VideoSource(NULL)
, VideoInfo(NULL)
, Width(-1)
, Height(-1)
, FrameNumber(-1)
, COMInited(false)
{
#ifdef WIN32
	HRESULT res = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
	if (SUCCEEDED(res)) 
		COMInited = true;
	else if (res != RPC_E_CHANGED_MODE)
		throw VideoOpenError("COM initialization failure");
#endif
	// initialize ffmpegsource
	// FIXME: CPU detection?
#if FFMS_VERSION >= ((2 << 24) | (14 << 16) | (0 << 8) | 0)
	FFMS_Init(0, 1);
#else
	FFMS_Init(0);
#endif

	ErrInfo.Buffer		= FFMSErrMsg;
	ErrInfo.BufferSize	= sizeof(FFMSErrMsg);
	ErrInfo.ErrorType	= FFMS_ERROR_SUCCESS;
	ErrInfo.SubType		= FFMS_ERROR_SUCCESS;

	SetLogLevel();

	// and here we go
	try {
		LoadVideo(filename);
	}
	catch (wxString const& err) {
		Close();
		throw VideoOpenError(STD_STR(err));
	}
	catch (...) {
		Close();
		throw;
	}
}
/// @brief Constructor
/// @param filename The filename to open
FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(wxString filename) try
: VideoSource(NULL, FFMS_DestroyVideoSource)
, VideoInfo(NULL)
, Width(-1)
, Height(-1)
, FrameNumber(-1)
{
	ErrInfo.Buffer		= FFMSErrMsg;
	ErrInfo.BufferSize	= sizeof(FFMSErrMsg);
	ErrInfo.ErrorType	= FFMS_ERROR_SUCCESS;
	ErrInfo.SubType		= FFMS_ERROR_SUCCESS;

	SetLogLevel();

	// and here we go
	LoadVideo(filename);
}
catch (wxString const& err) {
	throw VideoOpenError(STD_STR(err));
}
catch (const char * err) {
	throw VideoOpenError(err);
}
Ejemplo n.º 5
0
	//----------------------------------------------------------------------------------------------------
	bool EEVideo::Open(const char* _fileName)
	{
		m_music.Open(_fileName);

		return LoadVideo(_fileName);
	}
Ejemplo n.º 6
0
int mainTest(int argNumber, char* argString[])
{
    //Init Logger
    Logger::getInstance()->setLoggingLevel(eINFO);

    //We create a folder for background substraction configuration file. BGSLib will crash if that folder doesn't exist.
    boost::filesystem::create_directory("config");

    //We load the tracking configuration
    po::options_description fileConfig("Configuration file options");
    po::variables_map vm = LoadConfigurationSettings(argNumber, argString, fileConfig);
    if(vm.count("logging-level") >0)
    {
        unsigned int level = vm["logging-level"].as<unsigned int>();
        if(level >= 0 && level <= eNONE)
            Logger::getInstance()->setLoggingLevel(ELoggingLevel(level));
    }


    //We load the video
    bool overrideTotalNbFrame = false;
    unsigned int lastFrame = -1;
    InputFrameProviderIface* vfm = LoadVideo(vm, overrideTotalNbFrame, lastFrame);
    try
    {
        if(vfm && vfm->isOpen())
        {
            LOGINFO("Starting tracker");

            bool success = true;
            DrawableTimer dt;


            float pixelByMeter = 1;
            if(vm.count("scaleratio-filename") > 0 && vm["scaleratio-filename"].as<std::string>() != "none" && vm["scaleratio-filename"].as<std::string>() != "None")
            {
                success = Utils::IO::LoadScalar<float>(vm["scaleratio-filename"].as<std::string>(), pixelByMeter);
                if(!success)
                {
                    pixelByMeter = 1;
                    LOGWARNING("Can't load scale ratio file. Using 1px/m ratio");
                }
            }

            cv::Mat homography = cv::Mat::eye(3,3, CV_32FC1);
            if(vm.count("homography-filename") > 0 && vm["homography-filename"].as<std::string>() != "none" && vm["homography-filename"].as<std::string>() != "None")
            {
                success = Utils::IO::LoadMatrix<double>(vm["homography-filename"].as<std::string>(), homography);
                if(!success)
                {
                    homography = cv::Mat::eye(3,3, CV_32FC1);
                    LOGWARNING("Can't load homography file. Using identity.");
                }
            }
            cv::Mat mask;

            if(vm.count("mask-filename") > 0 && vm["mask-filename"].as<std::string>() != "none" && vm["mask-filename"].as<std::string>() != "None")
            {
                mask = cv::imread(vm["mask-filename"].as<std::string>());
                cv::cvtColor(mask, mask, CV_BGR2GRAY);
            }
            else
            {
                mask = cv::Mat(vfm->getHeight(), vfm->getWidth(), CV_8UC1);
                mask.setTo(cv::Scalar(255,255,255));
            }


            /*if(vm.count("aerialview-filename") > 0)
            {
                std::string aerialfn(vm["aerialview-filename"].as<std::string>());
                const cv::Mat aerialView = cv::imread(aerialfn);
            }*/


            DrawingFlags drawFlags = LoadDrawingFlags(vm);
            BlobTrackerAlgorithmParams algoParams = LoadTrackerParams(vm);
            DisplayInstruction();

            ApplicationContext context(mask, homography,(float)vfm->getNbFPS(), pixelByMeter, drawFlags, algoParams, vm["record-bgs"].as<bool>(), vfm);
            TrackerPersistance op(&context, vm["object-sqlite-filename"].as<std::string>());
            op.init();
            std::string bgsRecord = vm["bgs-filepath"].as<std::string>();
            context.setBGSPath(bgsRecord);
            std::string bgsType = vm["bgs-type"].as<std::string>();

            Tracker t(&context, bgsType);
            if(bgsType == "PlaybackBGS" && vm.count("bgs-filepath") > 0)
            {
                IBGS* bgs = t.getBlobDetector()->getBGS();
                PlaybackBGS* pbBGS = dynamic_cast<PlaybackBGS*>(bgs);
                if(pbBGS)
                    pbBGS->setPath(bgsRecord);
//                std::cout<<"remove playBackBgs\n";
//                exit(-1);
            }

            //bgs-filepath
            cv::Mat m;
            bool stepByStep = false;
            bool quit = false;
            bool displayMemory = vm["draw-memory"].as<bool>();


            if(!vfm->isOpen())
            {
                LOGERROR("Can't open video file");
                return 0;
            }
            int nbFrameProcess = 0;
            while(vfm->getNextFrame(m) && !quit && (!overrideTotalNbFrame || vfm->getNextFramePos() <= vfm->getNbFrame()) &&  (vfm->getNextFramePos() <= lastFrame || lastFrame == -1))
            {
                context.setCurrentFrame(m);
                dt.start();
                t.processFrame(m);
                dt.stop();
                if(context.getRefDrawingFlags()->mDrawFPS)
                    dt.drawFPS(m);

                cv::Mat trajectoryPictureClone = m.clone();
                if(drawFlags.mDrawPerspective)
                {
                    t.draw(m);
                    #ifdef _WIN32
                    if(displayMemory)
                    {
                        PROCESS_MEMORY_COUNTERS memCounter;
                        bool result = GetProcessMemoryInfo(GetCurrentProcess(), &memCounter, sizeof( memCounter ));
                        float nbMeg = memCounter.WorkingSetSize/(1048576.f);
                        cv::putText(m, Utils::String::toString(nbMeg)+ " Mo", cv::Point(0,m.rows-5), cv::FONT_HERSHEY_DUPLEX, 1, cv::Scalar(0,255,255),2);
                    }
                    #endif
                    cv::imshow("Video", m);
                    int key;
                    if(stepByStep)
                    {
                        key = cv::waitKey();
                    }
                    else
                        key = cv::waitKey(1);

                    if(key == 's')
                    {
                        stepByStep = !stepByStep;
                    }
                    else if(key == 'm')
                    {
                        displayMemory = !displayMemory;
                    }
                    else if(key == 'q')
                    {
                        std::cout << "Quit was requested. Exiting...";
                        quit = true;
                    }
                    else
                        UpdateContextFromKeys(&context, key);
                }
                ++nbFrameProcess;
                if(nbFrameProcess %50 == 0)
                    std::cout << "Frame " << nbFrameProcess << std::endl;
            }
            delete vfm;
        }
        else
        {
            LOGWARNING("Config file not loaded");
            LOGINFO("Loaded options:\n" << getParameterDescription(fileConfig, vm));

            if (vm.count("help"))
            {
                std::cout << fileConfig << std::endl;
            }
        }
    }
    catch(std::exception& e)
    {
        LOGASSERT(false, "Unhandled exception: " << e.what());
    }



    Logger::getInstance()->cleanUp();
    return 0;
}