コード例 #1
0
    public override Result ExitAndFinish(int sessionID, Constants.TestTypes testType, int testID, bool moveTempFiles)
    {
        ExitCamera();

        if (!findIfThereAreImagesToConvert())
        {
            return(new Result(false, "", Constants.VideoNothingCaptured));
        }

        //Convert video to the name and format expected
        if (!convertImagesToVideo())
        {
            return(new Result(false, "", programFfmpegNotInstalled));
        }

        if (!moveTempFiles)
        {
            return(new Result(true, ""));
        }

        //Copy the video to expected place
        if (!Util.CopyTempVideo(sessionID, testType, testID))
        {
            return(new Result(false, "", Constants.FileCopyProblem));
        }

        //Delete temp photos and video
        deleteTempFiles();

        return(new Result(true, ""));
    }
コード例 #2
0
ファイル: util.cs プロジェクト: davidfombella/chronojump
    public static bool CopyTempVideo(int sessionID, Constants.TestTypes type, int uniqueID)
    {
        string origin      = GetVideoTempFileName();
        string destination = GetVideoFileName(sessionID, type, uniqueID);

        Console.WriteLine("destination is: " + destination);
        if (File.Exists(origin))
        {
            CreateVideoSessionDirIfNeeded(sessionID);

            /*
             * no more move it, just copy it, because maybe is still being recorded
             * try {
             * File.Move(origin, destination);
             * } catch {
             */
            File.Copy(origin, destination, true);             //can be overwritten
            //}
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #3
0
ファイル: webcam.cs プロジェクト: davidfombella/chronojump
 public WebcamEndParams(int camera, int sessionID, Constants.TestTypes testType, int uniqueID, WebcamManage.GuiContactsEncoder guiContactsEncoder)
 {
     this.camera             = camera;
     this.sessionID          = sessionID;
     this.testType           = testType;
     this.uniqueID           = uniqueID;
     this.guiContactsEncoder = guiContactsEncoder;
 }
コード例 #4
0
ファイル: util.cs プロジェクト: davidfombella/chronojump
    public static void DeleteVideo(int sessionID, Constants.TestTypes type, int uniqueID)
    {
        string fileName = GetVideoFileName(sessionID, type, uniqueID);

        if (File.Exists(fileName))
        {
            File.Delete(fileName);
        }
    }
コード例 #5
0
ファイル: webcam.cs プロジェクト: davidfombella/chronojump
    //do this to start them at the "same moment"
    //can pass a -1 uniqueID if test is cancelled
    private void webcamEndTwoCams(Constants.TestTypes testType, int uniqueID)
    {
        WebcamManage.GuiContactsEncoder guiContactsEncoder = WebcamManage.GuiContactsEncoder.CONTACTS;
        if (testType == Constants.TestTypes.ENCODER)
        {
            guiContactsEncoder = WebcamManage.GuiContactsEncoder.ENCODER;
            label_video_encoder_feedback.Text = "";
        }

        //button_video_play_this_test.Sensitive = false;
        //button_video_play_this_test_sensitive (guiContactsEncoder, false);

        if (!preferences.videoOn || webcamManage == null)
        {
            return;
        }

        Webcam.Result result1 = webcamManage.RecordEnd(1);
        Webcam.Result result2 = webcamManage.RecordEnd(2);

        string errorMessage = "";

        if (result1.success)
        {
            Webcam.Result result1Exit = webcamManage.ExitAndFinish(1, currentSession.UniqueID, testType, uniqueID, guiContactsEncoder);
            if (uniqueID != -1 && !result1Exit.success)
            {
                errorMessage += result1Exit.error + "\n";
            }
        }
        else
        {
            errorMessage += result1.error + "\n";
        }

        if (result2.success)
        {
            Webcam.Result result2Exit = webcamManage.ExitAndFinish(2, currentSession.UniqueID, testType, -1 * uniqueID, guiContactsEncoder);
            if (uniqueID != -1 && !result2Exit.success)
            {
                errorMessage += result2Exit.error + "\n";
            }
        }
        else
        {
            errorMessage += result2.error + "\n";
        }

        if (errorMessage != "")
        {
            new DialogMessage(Constants.MessageTypes.WARNING, errorMessage);
        }

        //button_video_play_this_test.Sensitive = (uniqueID != -1 && errorMessage == "");
        button_video_play_this_test_sensitive(guiContactsEncoder, (uniqueID != -1 && errorMessage == ""));
        button_video_play_selected_test(current_menuitem_mode);
    }
コード例 #6
0
ファイル: webcam.cs プロジェクト: davidfombella/chronojump
    //can pass a -1 uniqueID if test is cancelled
    private void webcamEnd(Constants.TestTypes testType, int uniqueID)
    {
        //on contacts tests, we have WebcamStarted. No need to stop camera because it is not recording
        if (testType != Constants.TestTypes.ENCODER && !webcamManage.ReallyStarted)
        {
            return;
        }

        WebcamManage.GuiContactsEncoder guiContactsEncoder = WebcamManage.GuiContactsEncoder.CONTACTS;
        if (testType == Constants.TestTypes.ENCODER)
        {
            guiContactsEncoder = WebcamManage.GuiContactsEncoder.ENCODER;
            label_video_encoder_feedback.Text = "";

            hbox_video_encoder.Sensitive            = true;
            hbox_video_encoder_no_capturing.Visible = true;
            hbox_video_encoder_capturing.Visible    = false;
        }

        if (!preferences.videoOn || webcamManage == null)
        {
            return;
        }

        Webcam.Result result = webcamManage.RecordEnd(1);

        if (!result.success)
        {
            new DialogMessage(Constants.MessageTypes.WARNING, result.error);
            return;
        }

        webcamEndParams = new WebcamEndParams(1, currentSession.UniqueID, testType, uniqueID, guiContactsEncoder);

        //on encoder do not have a delayed call to not have problems with CopyTempVideo on src/gui/encoder.cs
        //also on encoder exercise ends when movement has really finished
        if (testType == Constants.TestTypes.ENCODER)
        {
            LogB.Information("Encoder, immediate call to webcamEndDo()");
            webcamEndDo();
        }
        else
        {
            if (preferences.videoStopAfter == 0)
            {
                webcamEndDo();
            }
            else
            {
                //call it later to be able to have some video on a short test like a jump.
                LogB.Information(string.Format("Preparing to call webcamEndDo() in {0} s", preferences.videoStopAfter));
                GLib.Timeout.Add(Convert.ToUInt32(preferences.videoStopAfter * 1000), new GLib.TimeoutHandler(webcamEndDo));
            }
        }
    }
コード例 #7
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, "");
    }
コード例 #8
0
ファイル: server.cs プロジェクト: davidfombella/chronojump
    private void fillTest(Constants.TestTypes type, int countU, int countE, int countS)
    {
        string u = countU.ToString();
        string e = countE.ToString();
        string s = countS.ToString();

        if (u == "0")
        {
            u = "";
        }
        if (e == "0")
        {
            e = "";
        }
        if (s == "0")
        {
            s = "";
        }

        switch (type)
        {
        case Constants.TestTypes.JUMP:
            store_j.AppendValues(u, e, s);
            break;

        case Constants.TestTypes.JUMP_RJ:
            store_jr.AppendValues(u, e, s);
            break;

        case Constants.TestTypes.RUN:
            store_r.AppendValues(u, e, s);
            break;

        case Constants.TestTypes.RUN_I:
            store_ri.AppendValues(u, e, s);
            break;

        case Constants.TestTypes.RT:
            store_rts.AppendValues(u, e, s);
            break;

        case Constants.TestTypes.PULSE:
            store_pulses.AppendValues(u, e, s);
            break;

        case Constants.TestTypes.MULTICHRONOPIC:
            store_mcs.AppendValues(u, e, s);
            break;
        }
    }
コード例 #9
0
    public Webcam.Result ExitAndFinish(int ncam, int sessionID,
                                       Constants.TestTypes testType, int testID, GuiContactsEncoder guiContactsEncoder)
    {
        bool moveTempFiles = guiContactsEncoder == GuiContactsEncoder.CONTACTS;

        if (ncam == 1)
        {
            return(exitAndFinishDo(ref webcam, sessionID, testType, testID, moveTempFiles));
        }
        else         //ncam == 2
        {
            return(exitAndFinishDo(ref webcam2, sessionID, testType, testID, moveTempFiles));
        }
    }
コード例 #10
0
ファイル: webcam.cs プロジェクト: davidfombella/chronojump
    private void on_video_play_last_test_clicked(object o, EventArgs args)
    {
        Constants.TestTypes type = Constants.TestTypes.JUMP;
        int id = 0;

        switch (currentEventType.Type)
        {
        case EventType.Types.JUMP:
            if (lastJumpIsSimple)
            {
                type = Constants.TestTypes.JUMP;
                id   = currentJump.UniqueID;
            }
            else
            {
                type = Constants.TestTypes.JUMP_RJ;
                id   = currentJumpRj.UniqueID;
            } break;

        case EventType.Types.RUN:
            if (lastRunIsSimple)
            {
                type = Constants.TestTypes.RUN;
                id   = currentRun.UniqueID;
            }
            else
            {
                type = Constants.TestTypes.RUN_I;
                id   = currentRunInterval.UniqueID;
            }
            break;

        case EventType.Types.PULSE:
            type = Constants.TestTypes.PULSE;
            id   = currentPulse.UniqueID;
            break;

        case EventType.Types.REACTIONTIME:
            type = Constants.TestTypes.RT;
            id   = currentReactionTime.UniqueID;
            break;

        case EventType.Types.MULTICHRONOPIC:
            type = Constants.TestTypes.MULTICHRONOPIC;
            id   = currentMultiChronopic.UniqueID;
            break;
        }

        playVideo(Util.GetVideoFileName(currentSession.UniqueID, type, id));
    }
コード例 #11
0
ファイル: main.cs プロジェクト: davidfombella/chronojump
    /*
     * there are problems calling the process with the "|"
     * better call a shell script like this:
     * ffmpeg_capture_and_play.sh
     *
     * #!/bin/bash
     * ffmpeg -y -f v4l2 -i /dev/video0 -map 0 -c:v libx264 -f tee "/tmp/chronojump-last-video.mp4|[f=nut]pipe:" | ffplay pipe:
     */


    public Result ExitAndFinish(int sessionID, Constants.TestTypes testType, int testID)
    {
        ExitCamera();         //this works

        //testing this now

        //Copy the video to expected place
        if (!Util.CopyTempVideo(sessionID, testType, testID))
        {
            return(new Result(false, "", Constants.FileCopyProblem));
        }

        //Delete temp video
        deleteTempFiles();

        return(new Result(true, ""));
    }
コード例 #12
0
    protected virtual void initializeValues()
    {
        typeOfTest           = Constants.TestTypes.JUMP;
        showType             = true;
        showRunStart         = false;
        showTv               = true;
        showTc               = true;
        showFall             = true;
        showDistance         = true;
        distanceCanBeDecimal = true;
        showTime             = true;
        showSpeed            = true;
        showWeight           = true;
        showLimited          = true;
        showAngle            = true;
        showMistakes         = false;

        label_simulated.Hide();
    }
コード例 #13
0
    //can pass a -1 uniqueID if test is cancelled
    public override Result ExitAndFinish(int sessionID, Constants.TestTypes testType, int testID, bool moveTempFiles)
    {
        ExitCamera();

        if (!moveTempFiles)
        {
            return(new Result(true, ""));
        }

        //Copy the video to expected place
        //but only if the test has not been cancelled
        if (testID != -1)
        {
            if (!Util.CopyTempVideo(sessionID, testType, testID))
            {
                return(new Result(false, "", Constants.FileCopyProblem));
            }
        }

        //Delete temp video
        deleteTempFiles();

        return(new Result(true, ""));
    }
コード例 #14
0
ファイル: util.cs プロジェクト: davidfombella/chronojump
 public static string GetVideoFileName(int sessionID, Constants.TestTypes testType, int uniqueID)
 {
     return(GetVideoSessionDir(sessionID) + Path.DirectorySeparatorChar +
            testType.ToString() + "-" + uniqueID.ToString() +
            GetMultimediaExtension(Constants.MultimediaItems.VIDEO));
 }
コード例 #15
0
ファイル: event.cs プロジェクト: dineshkummarc/chronojump
    protected virtual void initializeValues()
    {
        typeOfTest = Constants.TestTypes.JUMP;
        showType = true;
        showRunStart = false;
        showTv = true;
        showTc = true;
        showFall = true;
        showDistance = true;
        distanceCanBeDecimal = true;
        showTime = true;
        showSpeed = true;
        showWeight = true;
        showLimited = true;
        showAngle = true;
        showMistakes = false;

        label_simulated.Hide();
    }
コード例 #16
0
 private Webcam.Result exitAndFinishDo(ref Webcam webcam, int sessionID,
                                       Constants.TestTypes testType, int testID, bool moveTempFiles)
 {
     return(webcam.ExitAndFinish(sessionID, testType, testID, moveTempFiles));
 }
コード例 #17
0
ファイル: server.cs プロジェクト: kleopatra999/chronojump
    //upload a test
    private static Constants.UploadCodes serverUploadTest(ChronojumpServer myServer, Constants.TestTypes type, string tableName, Event myTest)
    {
        Constants.UploadCodes uCode;

        if (myTest.Simulated == Constants.Simulated)
        {
            //Test is simulated, don't upload
            uCode = Constants.UploadCodes.SIMULATED;
        }
        else if (myTest.Simulated > 0)
        {
            //Test is already uploaded, don't upload
            uCode = Constants.UploadCodes.EXISTS;
        }
        else
        {
            int idAtServer = -1;
            switch (type)
            {
            case Constants.TestTypes.JUMP:
                Jump jump = (Jump)myTest;
                idAtServer = myServer.UploadJump(jump);
                break;

            case Constants.TestTypes.JUMP_RJ:
                JumpRj jumpRj = (JumpRj)myTest;
                idAtServer = myServer.UploadJumpRj(jumpRj);
                break;

            case Constants.TestTypes.RUN:
                Run run = (Run)myTest;
                idAtServer = myServer.UploadRun(run);
                break;

            case Constants.TestTypes.RUN_I:
                RunInterval runI = (RunInterval)myTest;
                idAtServer = myServer.UploadRunI(runI);
                break;

            case Constants.TestTypes.RT:
                ReactionTime rt = (ReactionTime)myTest;
                idAtServer = myServer.UploadRT(rt);
                break;

            case Constants.TestTypes.PULSE:
                Pulse pulse = (Pulse)myTest;
                idAtServer = myServer.UploadPulse(pulse);
                break;

            case Constants.TestTypes.MULTICHRONOPIC:
                MultiChronopic mc = (MultiChronopic)myTest;
                idAtServer = myServer.UploadMultiChronopic(mc);
                break;
            }


            //update test (simulated) on client database
            myTest.Simulated = idAtServer;
            SqliteEvent.UpdateSimulated(true, tableName, myTest.UniqueID, idAtServer);

            uCode = Constants.UploadCodes.OK;
        }
        return(uCode);
    }
コード例 #18
0
 public abstract Result ExitAndFinish(int sessionID, Constants.TestTypes testType, int testID, bool moveTempFiles);