os : linux
gstreamer version : 0.10(this is requirement , so I cant migrate to 1.0)
Issue: change default text with grey to something more visible like black for clock display
Summary:
I am using gstreamer c code to stream video from webcam and at top of video it display time but unfortunately its in grey so its difficult to see it . Can someone please let me know how to make to black or to some other colour.
below is my snippet of code.
source = gst_element_factory_make( "v4l2src", "source" );
g_object_set( G_OBJECT ( source ), "device", "/dev/video0", NULL );
clockDisplay = gst_element_factory_make( "clockoverlay", "clock-time" );
capsFilter = gst_element_factory_make( "capsfilter", "camera_caps" );
conv = gst_element_factory_make( "ffmpegcolorspace", "Colorconverter" );
videoRate = gst_element_factory_make( "videorate", "videorate-element");
capsFilterRate = gst_element_factory_make( "capsfilter", "video-rate");
videoEnc = gst_element_factory_make( "ffenc_mpeg4", "videoenc" );
udpSink = gst_element_factory_make( "udpsink", "udpsink" );
g_object_set( G_OBJECT( udpSink ),
"host", hostAdd.c_str(),
"port", PORT_NUM_REMOTE_FOR_STREAMING,
NULL
);
// cap filter #1
caps = gst_caps_from_string( "video/x-raw-yuv,format=(fourcc)YUY2,width=320,height=240,framerate=10/1" );
g_object_set ( capsFilter, "caps", caps, NULL );
gst_caps_unref( caps );
You can list the properties of clockoverlay with:
gst-inspect-1.0 clockoverlay
There should be properties related to the color of the text. In 1.0 it is named 'color'. Then just use g_object_set to set the color as an int in ARGB format. There is also an 'outline-color' to make it even more visible.
Related
I have a Flink job processing the data stream with windowing as follows:
StreamExecutionEnvironment env = ...;
FlinkKafkaConsumer011<MyType1> consumer = ...;
AssignerWithPunctuatedWatermarks<MyType1> myAssigner = ...;
SingleOutputStreamOperator<MyType1> stream = env
.addSource( consumer )
.assignTimestampsAndWatermarks( myAssigner );
ProcessFunction<MyType1, MyType2> preProcessor = ...;
ProcessAllWindowFunction<MyType2, MyType3, TimeWindow> processor = ...;
RichSinkFunction<MyType3> mySink = ...;
stream
.process( preProcessor )
.windowAll( TumblingEventTimeWindows.of( Time.seconds( 60 ) ) )
.process( processor )
.addSink( mySink );
This code works as expected triggering the windows every corresponding 60 seconds. But if the code is modified/appended to produce an additional stream
__HERE_THE_WHOLE_ABOVE_CODE__
ProcessFunction<MyType1, MyType4> processor2 = ...;
RichSinkFunction<MyType4> mySink2 = ...;
stream
.process( processor2 )
.addSink( mySink2 );
then no one window on the first stream will be triggered at all. I don't want the additional stream be processed with windowing. How to make it - one stream windowed, another not?
Thank you.
I would like to add an extra column to indicate volatility in the backtest report.
Here is my code. The extra column volatility_recent appears but no value appears in the column. However, if I were to use the commented line trade.AddCustomMetric( "proceeds", trade.Shares*trade.ExitPrice );, some numerical value appears in the column.
What is wrong with the code?
if ( Status( "action" ) == actionPortfolio )
{
bo = GetBacktesterObject();
// run default backtest procedure without generating the trade list
bo.Backtest( True );
volatility_recent = ATR(30);
// iterate through closed trades
for ( trade = bo.GetFirstTrade( ); trade; trade = bo.GetNextTrade( ) )
{
trade.AddCustomMetric( "volatility_recent", volatility_recent );
//trade.AddCustomMetric( "proceeds", trade.Shares*trade.ExitPrice );
}
// iterate through open positions
for ( trade = bo.GetFirstOpenPos( ); trade; trade = bo.GetNextOpenPos( ) )
{
trade.AddCustomMetric( "volatility_recent", volatility_recent );
//trade.AddCustomMetric( "proceeds", trade.Shares*trade.ExitPrice );
}
// generate trade list
bo.ListTrades( );
}
I'm finding it really interesting that you copy text and code solution by others line by line without giving reference.
Your second post here at stackoverflow is line by line copy of responses by Tomasz and me to you at forum.amibroker.com
https://forum.amibroker.com/t/unable-to-add-this-custom-metric-to-backtest-report/7153
Custom metric needs to be scalar (number), not array. ATR(30) is an array. So, use LastValue to get last value of array or Lookup to get the value at specified bar. Pass ATR array of symbol from 1st phase to 2nd phase of backtest via static variables. Then in custom metric line use lookup to extract array element at certain date time (trade.EntryDateTime or trade.ExitDateTime).
StaticVarSet( "CBT_ATR_" + Name(), ATR(30) );
if ( Status( "action" ) == actionPortfolio )
{
bo = GetBacktesterObject();
// run default backtest procedure without generating the trade list
bo.Backtest( True );
// iterate through closed trades
for ( trade = bo.GetFirstTrade( ); trade; trade = bo.GetNextTrade( ) )
{
trade.AddCustomMetric( "volatility_recent", Lookup( StaticVarGet( "CBT_ATR_" + trade.Symbol ), trade.ExitDateTime ) );
//trade.AddCustomMetric( "proceeds", trade.Shares*trade.EntryPrice );
}
// iterate through open positions
for ( trade = bo.GetFirstOpenPos( ); trade; trade = bo.GetNextOpenPos( ) )
{
trade.AddCustomMetric( "volatility_recent", Lookup( StaticVarGet( "CBT_ATR_" + trade.Symbol ), Trade.ExitDateTime ) );
//trade.AddCustomMetric( "proceeds", trade.Shares*trade.EntryPrice );
}
// generate trade list
bo.ListTrades( );
}
EDIT: The credit goes to fxshrat who posted the answer at https://forum.amibroker.com/t/unable-to-add-this-custom-metric-to-backtest-report/7153/2
His answer was posted here and it was rude to post without references. Apologies to fxshrat and Tomasz.
I have wind data from multiple weather stations and I have the coordinates of the each weather station. I want to overlay wind roses from each station over a map using the stations' lat and long. Is there a straight forward way of doing this in R?
This is how I did it so far in R. I saved the windroses as png and then overlayed it on map.
#######################################
########produce map of GTA##############
#######################################
ggmap=get_map(location=c(left=-80.7 , bottom=43 , right=-77.7 , top=44.9))
gta=ggmap(ggmap)+ scale_y_continuous(limits=c(43.2, 44.5))
####################################################
###########for loop to make wind roses##############
###################################################
data_list<- list.files(path= "/home/npak/Documents/weather_data/meso_west_data/", pattern = "\\.csv$", recursive = FALSE, full.names = TRUE)
l<-length(data_list)
for (i in 1:l){
header<-readLines(data_list[i], 8)
variables = strsplit(header, ',')
vars=variables[[7]]
info= strsplit(header, ':')
lat= as.numeric(info[[3]][2])
long= as.numeric(info[[4]][2])
elev= as.numeric(info[[5]][2])
name=info[[2]][2]
data <- read.table(data_list[i], header= FALSE, sep=",", col.names = paste0("V",seq_len(30)), fill=TRUE, skip=8)
missing= length(data)-length(vars)
colnames(data)= c(vars, rep("Empty", missing) )
print(unique(data$Station_ID))
data$ws<-data$wind_speed_set_1
data$wd<-data$wind_direction_set_1
data$date<- as.POSIXct(data$Date_Time, format = "%Y-%m-%d %H:%M")
ID<-unique(data$Station_ID)
png(filename=(file<- paste('/home/npak/Documents/weather_data/meso_west_data/map_1year/', ID ,'all_year_map.png')),
width = 2400, height = 2400,bg = "transparent")
windRose(data,
breaks = c(1.5,3.3,5.5,8),
max.freq = 25
,paddle = FALSE,
, annotate = FALSE, key= FALSE,
auto.text = FALSE, ,grid.line = list(lty =0, value= 10),
cols=c("red", "red2", "red3", "red4"))
#,annotate = FALSE, key= FALSE)
#dev.off()
dev.off.crop(file=file)
mypng <- readPNG(file<- paste('/home/npak/Documents/weather_data/meso_west_data/map_1year/', ID ,'all_year_map.png'))
gta=gta+inset_raster(mypng, ymin = lat-0.2,ymax= lat+0.2,xmin = long-0.2,xmax = long+0.2)
}
######################################################
###############save map into png#######################################
##########################################################
png('/home/npak/Documents/weather_data/meso_west_data/map_1year/gta_annual.png',
width = 2400, height = 2400)
print(gta)
dev.off()
But it doesn't look as good. Right now I am saving the png image with a transparent background but the axis and frames are still there which makes the map look a bit messy. This is how it looks like:
Windroses overlayed on map
So I am looking for something simillar but to directly plot it over the map and not using the png pictures.
I try to use ChartSetSymbolPeriod() for my [ Custom Indicator ], but this indicator slows down my MT4 platform when I try to use it with another [ Expert Advisors ].
Specially while 'Order, Depth of Market' type of [ Expert Advisors ].
//+------------------------------------------------------------------+
//| ChangeSymbol Indicator.mq4 |
//| Copyright 2016, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_chart_window
string ChangeSP = "Where I go?";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit() {
//---
ObjectCreate ( 0, ChangeSP, OBJ_BUTTON, 0, 0, 0 );
ObjectSetInteger ( 0, ChangeSP, OBJPROP_XDISTANCE, 15 );
ObjectSetInteger ( 0, ChangeSP, OBJPROP_YDISTANCE, 100 );
ObjectSetInteger ( 0, ChangeSP, OBJPROP_XSIZE, 200 );
ObjectSetInteger ( 0, ChangeSP, OBJPROP_YSIZE, 40 );
ObjectSetString ( 0, ChangeSP, OBJPROP_TEXT, "Go to GBPUSD M15" );
ObjectSetInteger ( 0, ChangeSP, OBJPROP_COLOR, White );
ObjectSetInteger ( 0, ChangeSP, OBJPROP_BGCOLOR, Red );
ObjectSetInteger ( 0, ChangeSP, OBJPROP_BORDER_COLOR, Red );
ObjectSetInteger ( 0, ChangeSP, OBJPROP_BORDER_TYPE, BORDER_FLAT );
ObjectSetInteger ( 0, ChangeSP, OBJPROP_BACK, false );
ObjectSetInteger ( 0, ChangeSP, OBJPROP_HIDDEN, true );
ObjectSetInteger ( 0, ChangeSP, OBJPROP_STATE, false );
ObjectSetInteger ( 0, ChangeSP, OBJPROP_FONTSIZE, 12 );
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start(){
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit(){
return(0);
}
//+------------------------------------------------------------------+
void OnChartEvent( const int id,
const long &lparam,
const double &dparam,
const string &sparam
) {
if ( sparam == ChangeSP ) {
ChangeSPClick( ChangeSP );
ObjectSetInteger( 0, ChangeSP, OBJPROP_STATE, false );
}
}
//+------------------------------------------------------------------+
void ChangeSPClick( bool ChartSetSymbolPeriod ) {
bool ChangeSP_action = ChartSetSymbolPeriod( 0, "GBPUSD", 15 );
}
Performance? First: ALL [ Custom Indicators ] SHARE one SINGLE THREAD !
This New-MQL4.56789 architecture feature imposes even higher need for due care to be taken for non-blocking, performance focused code in [ Custom Indicators ].
An MQL4 documentation next states, that a call to ChartSetSymbolPeriod() is not synchronous, but just adds one more ticket into a TaskQueue.
ChartSetSymbolPeriod()Changes the symbol and period of the specified chart. The function is asynchronous, i.e. it sends the command and does not wait for its execution completion. The command is added to chart message queue and executed only after all previous commands have been processed.
What else might be in the Queue already?MQL4 recognises the following types of <ChartEVENT>-s :
OnChartEvent() is the handler of a group of ChartEvent events:
·CHARTEVENT_KEYDOWN — event of a keystroke, when the chart window is focused;
·CHARTEVENT_MOUSE_MOVE — mouse move events and mouse click events ( if CHART_EVENT_MOUSE_MOVE = true is set for the chart );
·CHARTEVENT_OBJECT_CREATE — event of graphical object creation ( if CHART_EVENT_OBJECT_CREATE = true is set for the chart );
·CHARTEVENT_OBJECT_CHANGE — event of change of an object property via the properties dialog;
·CHARTEVENT_OBJECT_DELETE — event of graphical object deletion ( if CHART_EVENT_OBJECT_DELETE = true is set for the chart );
·CHARTEVENT_OBJECT_CLICK — event of a mouse click in a graphical object belonging to the chart;
·CHARTEVENT_OBJECT_DRAG — event of a graphical object move using the mouse;
·CHARTEVENT_OBJECT_ENDEDIT — event of the finished text editing in the entry box of the LabelEdit graphical object;
·CHARTEVENT_CLICK — event of a mouse click on the chart;
·CHARTEVENT_CHART_CHANGE — event of chart changes; <<<<<<<<<<<<<<<<<<<<
·CHARTEVENT_CUSTOM + n — ID of the user event, where n is in the range from 0 to 65535.
·CHARTEVENT_CUSTOM_LAST — the last acceptable ID of a custom event == ( CHARTEVENT_CUSTOM +65535 ).
A change of Symbol and Period is a major chart undertaking, it makes [ MetaTrader Terminal 4 ] to throw away all current state of the instrument depicted inside the chart, next to move into the Back-of-the-House and to fetch all historically saved records from a [HistoryCentre] ( try F2 to see that facility in action ) and it has to repaint the GUI accordingly.
And guess what,
1) that takes some time
2) that makes a <ChartEVENT> which, again, triggers, the OnChartEvent() handler.
3) move back to the "Square No. 1"
Does it create a mouse-trap-wheel arrangement, to have to run infinitely in a loop?Yes, it does.
Also, one might have already noticed a side-effect
A name in a function call signature masks the name of MQL4 Function
//+------------------------------------------------------------------+
void ChangeSPClick( bool ChartSetSymbolPeriod ) {
bool ChangeSP_action = ChartSetSymbolPeriod( 0, "GBPUSD", 15 );
}
I am attempting to use the NAudio lib like the below. When I have a WAV file saved as Mono, 4KHz, the AudioBytesOriginal array has all zeroes. The file does play when double-clicked in Windows, so the data is there. It also plays in Audacity.
using ( var waveFileReader = new WaveFileReader( FileNameIn ) )
{
var thisIsWhat = waveFileReader.WaveFormat; // reports as 8KHz
AudioBytesOriginal = new byte[waveFileReader.Length];
int read = waveFileReader.Read( AudioBytesOriginal , 0 , AudioBytesOriginal.Length );
short[] sampleBuffer = new short[read/2];
Buffer.BlockCopy( AudioBytesOriginal , 0 , sampleBuffer , 0 , read );
}
I need the extremely low sample rate for playback on a limited device, but am using .NET Framework 4.6.1 with NAudio to handle the byte work.
Thanks.
a couple of things to check
1) what is the value of read? Is it 0?
2) how far into sampleBuffer did you check? Even half a second of silence at the start of an audio file will result in several thousand samples with 0 value