Remove AF😿
Prepare for release Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
ed2e965f9c
commit
c63b547bac
5 changed files with 0 additions and 169 deletions
|
@ -1,102 +0,0 @@
|
|||
public class AutoFocus : Object {
|
||||
void set_camfocus (double pos) {
|
||||
PipeTap.instance.focus = (int) (pos * 10);
|
||||
}
|
||||
|
||||
private double best_score { get; set; default = 0; }
|
||||
private double best_lens_pos { get; set; default = 0; }
|
||||
public double prev_pos { get; private set; default = 0; }
|
||||
private double step { get; set; default = 10; }
|
||||
private double max_pos { get; set; default = 100; }
|
||||
private bool focus_in_process { get; set; default = false; }
|
||||
private int fc { get; set; default = 0; }
|
||||
|
||||
public void reset_focus () {
|
||||
best_score = 0;
|
||||
best_lens_pos = 0;
|
||||
prev_pos = 0;
|
||||
step = 10;
|
||||
max_pos = 100;
|
||||
focus_in_process = true;
|
||||
fc = 0;
|
||||
set_camfocus (0);
|
||||
}
|
||||
|
||||
void set_diff (double diff) {
|
||||
max_pos = double.min (best_lens_pos + diff, 100);
|
||||
prev_pos = double.max (best_lens_pos - diff, 0);
|
||||
}
|
||||
|
||||
public void adjust_step (double prev_score) {
|
||||
// message ("%lf < %lf < %lf : %lf %lf / %lf", best_lens_pos, prev_pos, max_pos, step, prev_score, best_score);
|
||||
if (fc < EyeNeko.Env.get_variable_or ("FRAME_DELAY", "3").to_int ()) {
|
||||
fc++;
|
||||
return;
|
||||
} else
|
||||
fc = 0;
|
||||
if (prev_pos >= max_pos) {
|
||||
message ("Best focus %lf", best_lens_pos);
|
||||
switch ((int) (step * 10)) {
|
||||
case 100:
|
||||
message ("meow on 10");
|
||||
step = 5;
|
||||
set_diff (10);
|
||||
set_camfocus (prev_pos);
|
||||
break;
|
||||
case 50:
|
||||
message ("meow on 5");
|
||||
step = 2;
|
||||
set_diff (5);
|
||||
set_camfocus (prev_pos);
|
||||
break;
|
||||
case 20:
|
||||
message ("meow on 2");
|
||||
step = 0.5;
|
||||
set_diff (2);
|
||||
set_camfocus (prev_pos);
|
||||
break;
|
||||
case 5:
|
||||
message ("meow on 0.5");
|
||||
step = 0.1;
|
||||
set_diff (1);
|
||||
set_camfocus (prev_pos);
|
||||
break;
|
||||
case 1:
|
||||
message ("meow on 0.1");
|
||||
step = 10;
|
||||
max_pos = 100;
|
||||
focus_in_process = false;
|
||||
if (prev_pos != best_lens_pos) {
|
||||
prev_pos = best_lens_pos;
|
||||
set_camfocus (best_lens_pos);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
message ("meow on def?");
|
||||
step = 10;
|
||||
break;
|
||||
}
|
||||
message ("min %lf max %lf step %lf", prev_pos, max_pos, step);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!focus_in_process)
|
||||
return;
|
||||
if (prev_score > best_score) {
|
||||
best_score = prev_score;
|
||||
best_lens_pos = prev_pos;
|
||||
message ("%lf better than %lf", prev_pos, best_lens_pos);
|
||||
}
|
||||
prev_pos += step;
|
||||
set_camfocus (prev_pos);
|
||||
}
|
||||
|
||||
private static AutoFocus _instance = null;
|
||||
public static AutoFocus instance {
|
||||
get {
|
||||
if (_instance == null)
|
||||
_instance = new AutoFocus ();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,11 +15,6 @@ public class EyeNeko.Gstreamer : Object {
|
|||
return paintable;
|
||||
}
|
||||
}
|
||||
public Gdk.Paintable focus_paintable {
|
||||
owned get {
|
||||
return focus_analyze.paintable;
|
||||
}
|
||||
}
|
||||
|
||||
// Private elements
|
||||
private Gst.Bin camerabin = (Gst.Bin) Gst.ElementFactory.make ("camerabin", "camerabin");
|
||||
|
@ -27,7 +22,6 @@ public class EyeNeko.Gstreamer : Object {
|
|||
private Gst.Element viewfinder = Gst.ElementFactory.make ("gtk4paintablesink", "paintablesink");
|
||||
|
||||
private Gst.Bin camerasrc_wrapper = (Gst.Bin) Gst.ElementFactory.make ("wrappercamerabinsrc");
|
||||
public Elements.FocusAnalyze focus_analyze = new Elements.FocusAnalyze ();
|
||||
private Elements.ColorCorrectionMatrix color_correction_matrix = new Elements.ColorCorrectionMatrix ();
|
||||
private Elements.Downscale downscale = new Elements.Downscale ();
|
||||
|
||||
|
@ -165,7 +159,6 @@ public class EyeNeko.Gstreamer : Object {
|
|||
|
||||
camerasrc_wrapper.set_property ("video-source-filter",
|
||||
pipe_elements ("Camera Processing",
|
||||
focus_analyze,
|
||||
Gst.ElementFactory.make ("glupload"),
|
||||
color_correction_matrix,
|
||||
downscale
|
||||
|
|
|
@ -5,12 +5,10 @@ eyeneko_sources = [
|
|||
'window.vala',
|
||||
'gst.vala',
|
||||
'pipetap_proxy.vala',
|
||||
'auto_focus.vala',
|
||||
'logic/helpers.vala',
|
||||
'elements/bin_base.vala',
|
||||
'elements/camerasrc.vala',
|
||||
'elements/downscale.vala',
|
||||
'elements/focus_analyze.vala',
|
||||
'elements/gl_filter.vala',
|
||||
'elements/color_correction_matrix.vala',
|
||||
'ui/preferences.vala',
|
||||
|
|
|
@ -20,12 +20,6 @@ template $EyeNekoWindow: Adw.ApplicationWindow {
|
|||
};
|
||||
}
|
||||
|
||||
Gtk.Picture focus_overlay {
|
||||
opacity: 0.5;
|
||||
halign: start;
|
||||
valign: start;
|
||||
}
|
||||
|
||||
Adw.ToolbarView toolbar {
|
||||
styles [
|
||||
"flat",
|
||||
|
@ -70,33 +64,6 @@ Adw.ToolbarView toolbar {
|
|||
valign: center;
|
||||
}
|
||||
|
||||
Button focus_btn {
|
||||
valign: center;
|
||||
halign: end;
|
||||
width-request: 60;
|
||||
height-request: 60;
|
||||
|
||||
Box {
|
||||
halign: center;
|
||||
valign: center;
|
||||
orientation: vertical;
|
||||
|
||||
Image {
|
||||
icon-name: "camera-focus-symbolic";
|
||||
pixel-size: 24;
|
||||
}
|
||||
|
||||
Label focus_label {
|
||||
label: _("100.0");
|
||||
}
|
||||
}
|
||||
|
||||
styles [
|
||||
"circular",
|
||||
"focus-btn",
|
||||
]
|
||||
}
|
||||
|
||||
Button capture_btn {
|
||||
width-request: 80;
|
||||
height-request: 80;
|
||||
|
|
|
@ -27,18 +27,12 @@ public class EyeNeko.Window : Adw.ApplicationWindow {
|
|||
[GtkChild]
|
||||
private unowned Gtk.Picture viewfinder;
|
||||
[GtkChild]
|
||||
private unowned Gtk.Picture focus_overlay;
|
||||
[GtkChild]
|
||||
private unowned Gtk.MenuButton video_source_btn;
|
||||
[GtkChild]
|
||||
private unowned Gtk.Button capture_btn;
|
||||
[GtkChild]
|
||||
private unowned Adw.ToggleGroup camera_mode;
|
||||
|
||||
[GtkChild]
|
||||
private unowned Gtk.Button focus_btn;
|
||||
[GtkChild]
|
||||
private unowned Gtk.Label focus_label;
|
||||
|
||||
public string camera_path { get; set; default = "Unknown"; }
|
||||
private void setup_video_source_changer () {
|
||||
|
@ -81,31 +75,12 @@ public class EyeNeko.Window : Adw.ApplicationWindow {
|
|||
public Window (Gtk.Application app) {
|
||||
Object (application: app);
|
||||
overlay.add_overlay (toolbar);
|
||||
overlay.add_overlay (focus_overlay);
|
||||
|
||||
|
||||
setup_video_source_changer ();
|
||||
|
||||
Gstreamer.instance.bind_property ("focus-paintable", focus_overlay, "paintable", BindingFlags.SYNC_CREATE);
|
||||
|
||||
viewfinder.set_paintable (Gstreamer.instance.viewfinder_paintable);
|
||||
Gstreamer.instance.start_stream_from (Gstreamer.Camera.get_all ()[0]);
|
||||
var ec = new Gtk.GestureClick ();
|
||||
overlay.add_controller (ec);
|
||||
ec.pressed.connect ((n, x, y) => {
|
||||
if (!viewfinder.contains (x, y))
|
||||
return;
|
||||
var width = x / viewfinder.get_width ();
|
||||
var height = y / viewfinder.get_height ();
|
||||
|
||||
Gstreamer.instance.focus_analyze.window_hpos = height;
|
||||
Gstreamer.instance.focus_analyze.window_wpos = width;
|
||||
});
|
||||
ec.button = 0;
|
||||
|
||||
|
||||
focus_btn.clicked.connect (AutoFocus.instance.reset_focus);
|
||||
AutoFocus.instance.bind_property ("prev_pos", focus_label, "label", GLib.BindingFlags.SYNC_CREATE, (b, src, ref tgt) => { tgt = "%.1f".printf (src.get_double ()); return true; });
|
||||
|
||||
capture_btn.clicked.connect (() => {
|
||||
message ("%d %d", Gstreamer.instance.camerabin_mode, (int) Gstreamer.instance.ready);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue