コード例 #1
0
ファイル: main.cs プロジェクト: davidfombella/chronojump
    public Result PlayFile(string filename)
    {
        string executable = "ffplay";

        if (os == UtilAll.OperatingSystems.WINDOWS)
        {
            executable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffplay.exe");
        }

        if (process != null || filename == "")
        {
            return(new Result(false, ""));
        }

        List <string> parameters = createParametersPlayFile(filename);

        process = new Process();
        bool success = ExecuteProcess.RunAtBackground(ref process, executable, parameters, false, false, false);

        if (!success)
        {
            process = null;
            return(new Result(false, "", programFfmpegNotInstalled));
        }

        Running = true;
        return(new Result(true, ""));
    }
コード例 #2
0
    public override Result PlayFile(string filename)
    {
        if (process != null || filename == "")
        {
            return(new Result(false, ""));
        }

        executable = "mplayer";
        List <string> parameters = new List <string>();

        parameters.Insert(0, filename);
        //parameters.Insert (0, "-noborder"); //on X11 can be: title "Chronojump"". -noborder makes no accept 's', or 'q'
        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX)
        {
            parameters.Insert(0, "-title");              //on X11 can be: title "Chronojump"". -noborder makes no accept 's', or 'q'
            parameters.Insert(1, "Chronojump video");
        }
        else
        {
            parameters.Insert(0, "-noborder");
        }


        process = new Process();
        bool success = ExecuteProcess.RunAtBackground(ref process, executable, parameters, false, true, false, true, true);

        if (!success)
        {
            process = null;
            return(new Result(false, "", programMplayerNotInstalled));
        }

        Running = true;
        return(new Result(true, ""));
    }
コード例 #3
0
    void on_button_rfid_start_clicked(object o, EventArgs args)
    {
        string script_path = Util.GetRFIDCaptureScript();

        if (!File.Exists(script_path))
        {
            LogB.Debug("ExecuteProcess does not exist parameter: " + script_path);
            label_rfid.Text = "Error starting rfid capture";
            return;
        }

        string filePath = Util.GetRFIDCapturedFile();

        Util.FileDelete(filePath);


        // ---- start process ----
        //
        // on Windows will be different, but at the moment RFID is only supported on Linux (Raspberrys)
        // On Linux and OSX we execute Python and we pass the path to the script as a first argument

        string executable = "python";                 // TODO: check if ReadChronojump.py works on Python 2 and Python 3

        List <string> parameters = new List <string> ();

        // first argument of the Python: the path to the script
        parameters.Insert(0, script_path);


        processRFIDcapture = new Process();
        bool calledOk = ExecuteProcess.RunAtBackground(processRFIDcapture, executable, parameters);

        if (calledOk)
        {
            button_rfid_start.Sensitive = false;
            label_rfid.Text             = "...";
        }
        else
        {
            label_rfid.Text = "Error starting rfid capture";
        }

        // ----- process is launched

        //create a new FileSystemWatcher and set its properties.
        FileSystemWatcher watcher = new FileSystemWatcher();

        watcher.Path   = Path.GetDirectoryName(filePath);
        watcher.Filter = Path.GetFileName(filePath);

        //add event handlers.
        watcher.Changed += new FileSystemEventHandler(rfid_watcher_changed);

        //start watching
        watcher.EnableRaisingEvents = true;

        //also perform an initial search
        rfid_read();
    }
コード例 #4
0
ファイル: main.cs プロジェクト: davidfombella/chronojump
    public FfmpegCapture(string[] args)
    {
        if (args.Length != 1)
        {
            Console.WriteLine("Need to pass the videoDevice");
            return;
        }

        os          = UtilAll.GetOSEnum();
        videoDevice = args[0];

        if (os == UtilAll.OperatingSystems.WINDOWS)
        {
            captureExecutable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffmpeg.exe");
        }

        process = new Process();
        List <string> parameters = createParametersOnlyCapture();
        //List<string> parameters = createParametersCaptureAndDelayedView();
        bool success = ExecuteProcess.RunAtBackground(ref process, captureExecutable, parameters,
                                                      true, false, true); //createNoWindow, useShellExecute, redirectInput

        if (!success)
        {
            streamWriter = null;
            process      = null;
            //return new Result (false, "", programFfmpegNotInstalled);
            return;
        }

        processID    = process.Id;
        streamWriter = process.StandardInput;
        Running      = true;

        Console.WriteLine("Recording 5 seconds ...");
        for (int countA = 4; countA >= 0; countA--)
        {
            System.Threading.Thread.Sleep(1000);
            Console.WriteLine(countA.ToString());
        }

        int sessionID = 0;

        Constants.TestTypes testType = Constants.TestTypes.RUN;
        int testID = 1;

        ExitAndFinish(sessionID, testType, testID);

        Console.WriteLine("Recorded, copied, and deleted ok. Now we are going to play it");

        PlayFile(Util.GetVideoFileName(sessionID, testType, testID));

        //return new Result (true, "");
    }
コード例 #5
0
    public override Result PlayFile(string filename)
    {
        if (process != null || filename == "")
        {
            return(new Result(false, ""));
        }

        List <string> parameters = createParametersPlayFile(filename);

        process = new Process();
        bool success = ExecuteProcess.RunAtBackground(ref process, executable, parameters, true, false, false, false, false);

        if (!success)
        {
            process = null;
            return(new Result(false, "", programFfplayNotInstalled));
        }

        Running = true;
        return(new Result(true, ""));
    }
コード例 #6
0
    public override Result PlayPreview()
    {
        if (process != null)
        {
            return(new Result(false, ""));
        }

        List <string> parameters = createParametersPlayPreview();

        process = new Process();
        bool success = ExecuteProcess.RunAtBackground(ref process, executable, parameters, true, false, true, false, false);

        if (!success)
        {
            process = null;
            return(new Result(false, "", programFfplayNotInstalled));
        }

        streamWriter = process.StandardInput;
        Running      = true;
        return(new Result(true, ""));
    }
コード例 #7
0
    public override Result VideoCaptureStart()
    {
        //Delete temp video if exists
        deleteTempFiles();

        process = new Process();
        List <string> parameters = createParametersOnlyCapture();
        //List<string> parameters = createParametersCaptureAndDelayedView();
        bool success = ExecuteProcess.RunAtBackground(ref process, executable, parameters, true, false, true, false, false);          //redirectInput, not output, not stderr

        if (!success)
        {
            streamWriter = null;
            process      = null;
            return(new Result(false, "", programFfmpegNotInstalled));
        }

        processID    = process.Id;
        streamWriter = process.StandardInput;
        Running      = true;

        return(new Result(true, ""));
    }
コード例 #8
0
    public override Result CapturePrepare(CaptureTypes captureType)
    {
        if (process != null)
        {
            return(new Result(false, ""));
        }

        string tempFile = Util.GetWebcamPhotoTempFileNamePost(videoDeviceToFilename());

        Util.FileDelete(tempFile);

        List <string> parameters = new List <string>();
        //-noborder -nosound -tv driver=v4l2:gain=1:width=400:height=400:device=/dev/video0:fps=10:outfmt=rgb16 tv:// -vf screenshot=/tmp/chronojump-last-photo
        //parameters.Insert (0, "-noborder"); //on X11 can be: title "Chronojump"". -noborder makes no accept 's', or 'q'

        int i = 0;

        if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX)
        {
            parameters.Insert(i++, "-title");               //on X11 can be: title "Chronojump"". -noborder makes no accept 's', or 'q'
            if (captureType == CaptureTypes.PHOTO)
            {
                parameters.Insert(i++, "Chronojump snapshot");
            }
            else             //if(captureType == CaptureTypes.VIDEO)
            {
                parameters.Insert(i++, "Chronojump video record");
            }
        }
        else
        {
            parameters.Insert(i++, "-noborder");
        }

        parameters.Insert(i++, "-nosound");
        parameters.Insert(i++, "-tv");
        parameters.Insert(i++, "driver=v4l2:gain=1:width=400:height=400:device=" + videoDevice + ":fps=10:outfmt=rgb16");
        parameters.Insert(i++, "tv://");
        parameters.Insert(i++, "-vf");
        parameters.Insert(i++, "screenshot=" + Util.GetWebcamPhotoTempFileNamePre(videoDeviceToFilename()));

        process = new Process();
        bool success = ExecuteProcess.RunAtBackground(ref process, executable, parameters, true, false, true, true, true);          //redirectInput, redirectOutput, redirectError

        if (!success)
        {
            streamWriter = null;
            process      = null;
            return(new Result(false, "", programMplayerNotInstalled));
        }

        /*
         * experimental double camera start
         */
        /*
         * List<string> parametersB = parameters;
         * parametersB[4] = "driver=v4l2:gain=1:width=400:height=400:device=/dev/video1:fps=10:outfmt=rgb16";
         * parametersB[7] = "screenshot=/tmp/b/chronojump-last-photo";
         * Process processB = new Process();
         * ExecuteProcess.RunAtBackground (processB, executable, parametersB, true); //redirectInput
         */
        /*
         * experimental double camera end
         */


        streamWriter = process.StandardInput;
        Running      = true;

        return(new Result(true, ""));
    }