Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add bsc configuration support for video stabilization

  • Loading branch information...
commit 50bf7a8787586a1d4f0e82b9ab3f3dede7e9152b 1 parent 37a9ff1
@mmontero mmontero authored
View
3  src/Makefile.am
@@ -19,6 +19,9 @@ ipiped_VALAFLAGS += --define=RRAEW
ipipe_client_VALAFLAGS += --define=RRAEW
endif
+#ipiped_VALAFLAGS += --define=BSC_ENABLE
+#ipipe_client_VALAFLAGS += --define=BSC_ENABLE
+
interfaces_xml := com.ridgerun.ipiped.IpipeInterface.xml
EXTRA_DIST= $(interfaces_xml)
View
3  src/Makefile.in
@@ -239,6 +239,9 @@ ipipe_client_VALAFLAGS = --vapidir=@VAPIDIR@ --pkg glib-2.0 --pkg \
$(am__append_4)
ipipe_client_CFLAGS = @GIO_CFLAGS@ -DGETTEXT_PACKAGE=\"ipipe-client\"
ipipe_client_LDADD = @GIO_LIBS@ -lreadline -lncurses
+
+#ipiped_VALAFLAGS += --define=BSC_ENABLE
+#ipipe_client_VALAFLAGS += --define=BSC_ENABLE
interfaces_xml := com.ridgerun.ipiped.IpipeInterface.xml
EXTRA_DIST = $(interfaces_xml)
interfacedir = $(datadir)/dbus-1/interfaces/
View
41 src/cli_dm365ipipe.vala
@@ -10,6 +10,7 @@ public interface Idm365ipipe: Object{
out double blue_gain, out double green_gain) throws IOError;
public abstract bool set_luminance_adj(int bright, double contr) throws IOError;
public abstract bool get_luminance_adj(out int bright, out double contr) throws IOError;
+ public abstract bool config_bsc(uint inwidth, uint inheight) throws IOError;
}
public class cli_dm365ipipe : AbstcCliRegister{
@@ -167,6 +168,36 @@ public class cli_dm365ipipe : AbstcCliRegister{
}
}
+ private int cmd_config_video_stabilization(string[]? args) {
+#if BSC_ENABLE
+ if (args[1] == null || args[2] == null) {
+ stdout.printf("Error:\nMissing argument.Execute:'help config_video_stabilization'\n");
+ return -1;
+ }
+ uint width = int.parse(args[1]);
+ uint height = int.parse(args[2]);
+
+ try {
+ if (!ipipe.config_bsc(width, height)) {
+ stderr.
+ printf("Error:\n Failed to config bsc\n");
+ return -1;
+ } else {
+ if (_debug)
+ stdout.printf("Ok.Set bsc configuration\n");
+ return 0;
+ }
+ }
+ catch(Error e) {
+ stderr.printf("Fail to execute command:%s\n", e.message);
+ return -1;
+ }
+#else
+ stdout.printf("Video stabilization not supported\n");
+ return 0;
+#endif
+ }
+
/* Initialize the Command Array. */
public override void registration(IpipeCli cli) throws IOError{
cli.cmd.new_command("set-previewer-mode", cmd_set_previewer_mode,
@@ -201,6 +232,16 @@ public class cli_dm365ipipe : AbstcCliRegister{
"\033[1mget-luminance\033[m",
"Returns the value of the Brightness(Br) and contrast(C) adjustment",
"", "");
+ cli.cmd.new_command("config-vs", cmd_config_video_stabilization,
+ "\033[1mconfig-vs\033[m width height",
+ "Configures the boundary signal calculator module(bsc)"
+ +" needed by the video stabilization",
+ "\tThe video stabilization algorithm uses the vectors of sums"
+ +"\n\tgiven by the bsc to calculate the compensation for"
+ +"\n\tthe camera shaking."
+ +"\n\tThe bsc is configured for an image of the given dimensions.",
+ "\n\twidth: input image's width"
+ +"\n\theight: input image's height");
ipipe = Bus.get_proxy_sync (BusType.SYSTEM, "com.ridgerun.ipiped",
"/com/ridgerun/ipiped/ipipe");
View
75 src/ipiped-dm365.vala
@@ -429,6 +429,81 @@ public class Ipiped_dm365 : AbstcVideoProcessor{
return true;
}
+#if BSC_ENABLE
+ /**
+ * Sets Boundary Signal Calculator parameters
+ */
+ public bool config_bsc(uint inwidth, uint inheight) throws IOError{
+ ModuleParam mod_param = ModuleParam();
+ PrevBSC bsc_mod = PrevBSC();
+ Cap cap = Cap();
+ uint rowlh =0, collv=0;
+ cap.index =0 ;
+
+ if (Posix.ioctl(this.previewer_fd , PREV_ENUM_CAP, &cap)<0) {
+ if (debug)
+ Posix.stderr.printf("Ipiped:Error in getting cap from driver\n");
+ return false;
+ }
+ /* Enable bsc in continous mode, using the Y component */
+ bsc_mod.en = 1;
+ bsc_mod.mode = 0;
+ bsc_mod.col_en = 1;
+ bsc_mod.row_en = 1;
+ bsc_mod.y_cb_cr = IpipeBscIn.Y;
+ /* Using the maximun number of vectors and try to cover the
+ * major image area */
+ bsc_mod.row_vct = 3;
+ bsc_mod.row_shf = 0;
+ bsc_mod.row_vpos = 0;
+ bsc_mod.row_vskip = ((bsc_mod.row_vct + 1) * inheight)/1920;
+ bsc_mod.row_vnum = inheight/(bsc_mod.row_vskip + 1) - 1;
+ bsc_mod.row_hpos = 0;
+ rowlh = inwidth/(bsc_mod.row_vct + 1);
+ bsc_mod.row_hskip = bsc_mod.row_vskip;
+ bsc_mod.row_hnum = rowlh / (bsc_mod.row_vskip + 1) - 1;
+
+ bsc_mod.col_vct = 3;
+ bsc_mod.col_shf = 0;
+ bsc_mod.col_hpos = 0;
+ bsc_mod.col_hskip = ((bsc_mod.col_vct + 1) * inwidth)/1920;;
+ bsc_mod.col_hnum = inwidth/(bsc_mod.col_hskip + 1) - 1;
+ bsc_mod.col_vpos = 0;
+ collv = inheight/(bsc_mod.col_vct + 1);
+ bsc_mod.col_vskip = bsc_mod.col_hskip;
+ bsc_mod.col_vnum = collv / (bsc_mod.col_hskip + 1) - 1;
+
+ cap.module_id = PREV_BSC;
+ strcpy(mod_param.version,cap.version);
+ mod_param.module_id = cap.module_id;
+ mod_param.len =(uint8)sizeof(PrevBSC);
+ mod_param.param = &bsc_mod;
+
+ if (Posix.ioctl(this.previewer_fd , PREV_S_PARAM, &mod_param) < 0) {
+ if (debug)
+ Posix.stderr.printf("Ipiped:Error in Setting params to driver\n");
+ Posix.close(this.previewer_fd );
+ return false;
+ }
+
+ if (debug) {
+ Posix.stdout.printf(" \nIPIPE BSC Info,\n");
+ Posix.stdout.printf(" inwidth = %u,\n", inwidth);
+ Posix.stdout.printf(" inheight = %u,\n", inheight);
+ Posix.stdout.printf(" rowNumV = %u,\n", bsc_mod.row_vnum);
+ Posix.stdout.printf(" rowSkipV = %u,\n", bsc_mod.row_vskip);
+ Posix.stdout.printf(" rowNumH = %u,\n", bsc_mod.row_hnum);
+ Posix.stdout.printf(" rowSkipH = %u,\n", bsc_mod.row_hskip);
+ Posix.stdout.printf(" colNumVectors = %u,\n", bsc_mod.col_vct);
+ Posix.stdout.printf(" colNumV = %u,\n", bsc_mod.col_vnum);
+ Posix.stdout.printf(" colSkipV = %u,\n", bsc_mod.col_vskip);
+ Posix.stdout.printf(" colNumH = %u,\n", bsc_mod.col_hnum);
+ Posix.stdout.printf(" colSkipH = %u,\n\n", bsc_mod.col_hskip);
+ }
+ return true;
+ }
+#endif
+
#if (RRAEW)
public override bool get_video_processor_data(RraewInterface *interf){
*interf = dm365_vpfe_interface;
View
42 vapi/impprev.vapi
@@ -121,6 +121,47 @@ namespace ImpPrev {
int out_ofst_b;
}
+ [CCode (cprefix = "IPIPE_BSC_IN_")]
+ public enum IpipeBscIn{
+ Y,
+ CB,
+ CR
+ }
+
+ [CCode (cname = "struct prev_bsc")]
+ /**
+ * Struct for configuring BSC module
+ */
+ public struct PrevBSC {
+
+ uchar en;
+
+ uchar mode;
+ uchar col_en;
+ uchar row_en;
+ IpipeBscIn y_cb_cr;
+
+ uint row_vct;
+ uint row_shf;
+ uint row_vpos;
+ uint row_vnum;
+ uint row_vskip;
+ uint row_hpos;
+ uint row_hnum;
+ uint row_hskip;
+
+ uint col_vct;
+ uint col_shf;
+ uint col_vpos;
+ uint col_vnum;
+ uint col_vskip;
+ uint col_hpos;
+ uint col_hnum;
+ uint col_hskip;
+
+ void* tb_ptr;
+ }
+
[CCode (cprefix = "IPIPEIF_DECIMATION_")]
public enum IpipeifDecimation {
OFF,
@@ -222,5 +263,6 @@ namespace ImpPrev {
public const uint8 PREV_WB;
public const uint8 PREV_LUM_ADJ;
public const uint8 PREV_RGB2RGB_1;
+ public const uint8 PREV_BSC;
}
Please sign in to comment.
Something went wrong with that request. Please try again.