Commit 2400c619 authored by Xavier de Blas's avatar Xavier de Blas

DB 1.61. webcam with resolution and framerate

parent 8d26a1d6
......@@ -3420,6 +3420,94 @@ Other</property>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox_camera_resolution_framerate">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">20</property>
<child>
<widget class="GtkHBox" id="hbox25">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">10</property>
<child>
<widget class="GtkLabel" id="label62">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Resolution</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox_combo_camera_resolution">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox31">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">10</property>
<child>
<widget class="GtkLabel" id="label76">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Framerate</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox_combo_camera_framerate">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
......
......@@ -323,7 +323,7 @@ public class EditEventWindow
*/
//using ffmpeg
Webcam webcam = new WebcamFfmpeg (Webcam.Action.PLAYFILE, UtilAll.GetOSEnum(), "");
Webcam webcam = new WebcamFfmpeg (Webcam.Action.PLAYFILE, UtilAll.GetOSEnum(), "", "", "");
Webcam.Result result = webcam.PlayFile (videoFileName);
}
}
......
......@@ -1079,7 +1079,7 @@ public class PersonAddModifyWindow
//webcam = new WebcamMplayer (videoDevice);
//Webcam.Result result = webcam.CapturePrepare (Webcam.CaptureTypes.PHOTO);
//constructor for playpreview
webcam = new WebcamFfmpeg (Webcam.Action.PLAYPREVIEW, UtilAll.GetOSEnum(), videoDevice);
webcam = new WebcamFfmpeg (Webcam.Action.PLAYPREVIEW, UtilAll.GetOSEnum(), videoDevice, "", "");
//Webcam.Result result = webcam.PlayPreviewNoBackground ();
Webcam.Result result = webcam.PlayPreview ();
......@@ -1093,7 +1093,7 @@ public class PersonAddModifyWindow
void on_button_take_photo_do_clicked (object o, EventArgs args)
{
if(webcam == null)
webcam = new WebcamFfmpeg (Webcam.Action.PLAYPREVIEW, UtilAll.GetOSEnum(), videoDevice);
webcam = new WebcamFfmpeg (Webcam.Action.PLAYPREVIEW, UtilAll.GetOSEnum(), videoDevice, "", "");
else if(webcam != null && webcam.Running)
{
webcam.ExitCamera();
......
......@@ -145,6 +145,10 @@ public class PreferencesWindow
[Widget] Gtk.Label label_test_sound_result;
[Widget] Gtk.Box hbox_combo_camera;
[Widget] Gtk.ComboBox combo_camera;
[Widget] Gtk.Box hbox_combo_camera_resolution;
[Widget] Gtk.ComboBox combo_camera_resolution;
[Widget] Gtk.Box hbox_combo_camera_framerate;
[Widget] Gtk.ComboBox combo_camera_framerate;
[Widget] Gtk.Label label_no_cameras;
[Widget] Gtk.Label label_webcam_windows;
......@@ -290,7 +294,9 @@ public class PreferencesWindow
PreferencesWindowBox.radio_sound_systemsounds.Active = true;
PreferencesWindowBox.label_test_sound_result.Text = "";
PreferencesWindowBox.createComboCamera(UtilMultimedia.GetVideoDevices(), preferences.videoDevice);
PreferencesWindowBox.createComboCamera(UtilMultimedia.GetVideoDevices(), preferences.videoDevice,
preferences.videoDeviceResolution, preferences.videoDeviceFramerate);
string [] decs = {"1", "2", "3"};
......@@ -583,8 +589,10 @@ public class PreferencesWindow
* end of triggers stuff
*/
private void createComboCamera(WebcamDeviceList wd_list, string current)
private void createComboCamera(WebcamDeviceList wd_list, string current, string resolution, string framerate)
{
//videoDevice
combo_camera = ComboBox.NewText ();
if(wd_list.Count() == 0) {
......@@ -604,6 +612,31 @@ public class PreferencesWindow
// current = 0;
combo_camera.Active = UtilGtk.ComboMakeActive(combo_camera, current);
//resolution
combo_camera_resolution = ComboBox.NewText ();
//string [] resolutions = { "320x240", "640x480", "1280x720" };
List<string> resolutions = new List<string>();
resolutions.Add("320x240");
resolutions.Add("640x480");
resolutions.Add("1280x720");
UtilGtk.ComboUpdate(combo_camera_resolution, resolutions);
hbox_combo_camera_resolution.PackStart(combo_camera_resolution, true, true, 0);
hbox_combo_camera_resolution.ShowAll();
combo_camera_resolution.Active = UtilGtk.ComboMakeActive(combo_camera_resolution, resolution);
//framerate
combo_camera_framerate = ComboBox.NewText ();
//string [] framerates = { "30", "60" };
List<string> framerates = new List<string>();
framerates.Add("30");
framerates.Add("60");
UtilGtk.ComboUpdate(combo_camera_framerate, framerates);
hbox_combo_camera_framerate.PackStart(combo_camera_framerate, true, true, 0);
hbox_combo_camera_framerate.ShowAll();
combo_camera_framerate.Active = UtilGtk.ComboMakeActive(combo_camera_framerate, framerate);
}
private void on_check_appearance_maximized_toggled (object obj, EventArgs args)
......@@ -1459,11 +1492,24 @@ public class PreferencesWindow
preferences.gstreamer = Preferences.GstreamerTypes.SYSTEMSOUNDS;
}
//camera stuff
if( preferences.videoDevice != UtilGtk.ComboGetActive(combo_camera) ) {
SqlitePreferences.Update("videoDevice", UtilGtk.ComboGetActive(combo_camera), true);
preferences.videoDevice = UtilGtk.ComboGetActive(combo_camera);
}
if( preferences.videoDeviceResolution != UtilGtk.ComboGetActive(combo_camera_resolution) ) {
SqlitePreferences.Update("videoDeviceResolution", UtilGtk.ComboGetActive(combo_camera_resolution), true);
preferences.videoDeviceResolution = UtilGtk.ComboGetActive(combo_camera_resolution);
}
if( preferences.videoDeviceFramerate != UtilGtk.ComboGetActive(combo_camera_framerate) ) {
SqlitePreferences.Update("videoDeviceFramerate", UtilGtk.ComboGetActive(combo_camera_framerate), true);
preferences.videoDeviceFramerate = UtilGtk.ComboGetActive(combo_camera_framerate);
}
//end of camera stuff
if(PreferencesWindowBox.radio_export_latin.Active) {
SqlitePreferences.Update("CSVExportDecimalSeparator","COMMA", true);
......
......@@ -104,13 +104,13 @@ public partial class ChronoJumpWindow
button_video_preview_visibile (guiContactsEncoder, false);
string errorMessage = "";
if(ncams == 1 && webcamManage.RecordPrepare(preferences.videoDevice).success)
if(ncams == 1 && webcamManage.RecordPrepare(preferences.videoDevice, preferences.videoDeviceResolution, preferences.videoDeviceFramerate).success)
{
webcamManage.RecordStart(1);
//label_video_feedback.Text = "Preparing camera";
label_video_feedback_text (guiContactsEncoder, "Preparing camera");
}
else if(ncams == 2 && webcamManage.RecordPrepare(preferences.videoDevice, "/dev/video1").success)
else if(ncams == 2 && webcamManage.RecordPrepare(preferences.videoDevice, "/dev/video1", preferences.videoDeviceResolution, preferences.videoDeviceFramerate).success)
{
webcamManage.RecordStart(2);
//label_video_feedback.Text = "Preparing camera";
......@@ -433,7 +433,7 @@ public partial class ChronoJumpWindow
private void playPreview ()
{
//constructor for playpreview
webcamPlay = new WebcamFfmpeg (Webcam.Action.PLAYPREVIEW, UtilAll.GetOSEnum(), preferences.videoDevice);
webcamPlay = new WebcamFfmpeg (Webcam.Action.PLAYPREVIEW, UtilAll.GetOSEnum(), preferences.videoDevice, preferences.videoDeviceResolution, preferences.videoDeviceFramerate);
Webcam.Result result = webcamPlay.PlayPreviewNoBackground ();
}
......@@ -452,7 +452,7 @@ public partial class ChronoJumpWindow
private void playVideo (string fileName)
{
//constructor for playpreview
webcamPlay = new WebcamFfmpeg (Webcam.Action.PLAYFILE, UtilAll.GetOSEnum(), "");
webcamPlay = new WebcamFfmpeg (Webcam.Action.PLAYFILE, UtilAll.GetOSEnum(), "", "", "");
Webcam.Result result = webcamPlay.PlayFile (fileName);
/*
......
......@@ -75,6 +75,8 @@ public class Preferences
public Constants.Encoder1RMMethod encoder1RMMethod;
public string videoDevice;
public string videoDeviceResolution;
public string videoDeviceFramerate;
public string CSVExportDecimalSeparator;
public string language;
public string crashLogLanguage;
......
......@@ -125,7 +125,7 @@ class Sqlite
/*
* Important, change this if there's any update to database
*/
static string lastChronojumpDatabaseVersion = "1.60";
static string lastChronojumpDatabaseVersion = "1.61";
public Sqlite() {
}
......@@ -2370,6 +2370,15 @@ class Sqlite
currentVersion = updateVersion("1.60");
}
if(currentVersion == "1.60")
{
LogB.SQL("Added to preferences: videoDeviceResolution, videoDeviceFramerate");
SqlitePreferences.Insert ("videoDeviceResolution", "");
SqlitePreferences.Insert ("videoDeviceFramerate", "");
currentVersion = updateVersion("1.61");
}
......
......@@ -171,6 +171,8 @@ class SqlitePreferences : Sqlite
Insert ("videoDevice", "", dbcmdTr); //first
Insert ("videoDeviceResolution", "", dbcmdTr);
Insert ("videoDeviceFramerate", "", dbcmdTr);
Insert ("inertialmomentum", "0.01", dbcmdTr);
Insert ("CSVExportDecimalSeparator", Util.GetDecimalSeparatorFromLocale(), dbcmdTr);
Insert ("RGraphsTranslate", "True", dbcmdTr);
......@@ -369,6 +371,10 @@ class SqlitePreferences : Sqlite
//video... other
else if(reader[0].ToString() == "videoDevice")
preferences.videoDevice = reader[1].ToString();
else if(reader[0].ToString() == "videoDeviceResolution")
preferences.videoDeviceResolution = reader[1].ToString();
else if(reader[0].ToString() == "videoDeviceFramerate")
preferences.videoDeviceFramerate = reader[1].ToString();
else if(reader[0].ToString() == "CSVExportDecimalSeparator")
preferences.CSVExportDecimalSeparator = reader[1].ToString();
else if(reader[0].ToString() == "language")
......
......@@ -111,6 +111,8 @@ public abstract class Webcam
protected Process process;
protected string videoDevice;
protected string videoDeviceResolution;
protected string videoDeviceFramerate;
protected StreamWriter streamWriter;
protected string executable = "";
......@@ -186,15 +188,15 @@ public class WebcamManage
}
// 1 camera
public Webcam.Result RecordPrepare (string videoDevice)
public Webcam.Result RecordPrepare (string videoDevice, string videoDeviceResolution, string videoDeviceFramerate)
{
return recordPrepareDo (ref webcam, videoDevice);
return recordPrepareDo (ref webcam, videoDevice, videoDeviceResolution, videoDeviceFramerate);
}
// 2 cameras
public Webcam.Result RecordPrepare (string videoDevice, string videoDevice2)
public Webcam.Result RecordPrepare (string videoDevice, string videoDevice2, string videoDeviceResolution, string videoDeviceFramerate)
{
Webcam.Result result1 = recordPrepareDo (ref webcam, videoDevice);
Webcam.Result result2 = recordPrepareDo (ref webcam2, videoDevice2);
Webcam.Result result1 = recordPrepareDo (ref webcam, videoDevice, videoDeviceResolution, videoDeviceFramerate);
Webcam.Result result2 = recordPrepareDo (ref webcam2, videoDevice2, videoDeviceResolution, videoDeviceFramerate);
return new Webcam.Result (
result1.success && result2.success,
......@@ -202,7 +204,7 @@ public class WebcamManage
result1.error + result2.error
);
}
private Webcam.Result recordPrepareDo (ref Webcam w, string videoDevice)
private Webcam.Result recordPrepareDo (ref Webcam w, string videoDevice, string videoDeviceResolution, string videoDeviceFramerate)
{
if(videoDevice == "" || videoDevice == "0")
{
......@@ -214,7 +216,7 @@ public class WebcamManage
LogB.Information("wRS at gui chronojump.cs 0, videoDevice: " + videoDevice);
//w = new WebcamMplayer (videoDevice);
w = new WebcamFfmpeg (Webcam.Action.CAPTURE, os, videoDevice);
w = new WebcamFfmpeg (Webcam.Action.CAPTURE, os, videoDevice, videoDeviceResolution, videoDeviceFramerate);
Webcam.Result result = w.CapturePrepare (Webcam.CaptureTypes.VIDEO);
LogB.Information("wRS at gui chronojump.cs 1, videoDevice: " + videoDevice);
......
......@@ -34,11 +34,13 @@ public class WebcamFfmpeg : Webcam
// constructor ----------------------------------
public WebcamFfmpeg (Webcam.Action action, UtilAll.OperatingSystems os, string videoDevice)
public WebcamFfmpeg (Webcam.Action action, UtilAll.OperatingSystems os, string videoDevice, string videoDeviceResolution, string videoDeviceFramerate)
{
this.action = action;
this.os = os;
this.videoDevice = videoDevice;
this.videoDeviceResolution = videoDeviceResolution;
this.videoDeviceFramerate = videoDeviceFramerate;
if(action == Webcam.Action.CAPTURE)
{
......@@ -235,9 +237,16 @@ public class WebcamFfmpeg : Webcam
parameters.Insert (i ++, "dshow");
parameters.Insert (i ++, "-framerate");
parameters.Insert (i ++, "30");
if(videoDeviceFramerate != "" && Util.IsNumber(videoDeviceFramerate, false))
parameters.Insert (i ++, videoDeviceFramerate);
else
parameters.Insert (i ++, "30");
parameters.Insert (i ++, "-video_size");
parameters.Insert (i ++, "640x480");
if(videoDeviceResolution != "")
parameters.Insert (i ++, videoDeviceResolution);
else
parameters.Insert (i ++, "640x480");
if(os == UtilAll.OperatingSystems.LINUX) {
parameters.Insert (i ++, "-input_format");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment