[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss-gnuradio] new TV receive examples, with realtime video-window
From: |
Martin Dvh |
Subject: |
[Discuss-gnuradio] new TV receive examples, with realtime video-window |
Date: |
Wed, 26 Apr 2006 04:53:29 +0200 |
User-agent: |
Debian Thunderbird 1.0.2 (X11/20051002) |
Eric Blossom wrote:
> [Martin, can you please update or remove that example? Thanks.]
I removed the old broken tvrx_tv_rcv.py example and added new working examples.
usrp_tv_rcv.py and usrp_tv_rcp_nogui.py
They work out of the box when you use realtime capturing and processing, but
then you need a high decimation factor (for my PC 64 or higher)
This means you get a much lower horizontal resolution then you want (you really
want decimation 4 or 8)
They can output to a file, so you can view it with imagemagick.
They can also output to a realtime sdl video window.
For this you need to build and install gr-video-sdl
(This is only in cvs and not yet in a tarball)
There is no synchronisation yet. I am still working on the sync blocks but they
still don't work reliably.
Also note that when you want to receive a Tv channel that the video-carrier is
not at the centre of the channel.
When you want to first capture to file, you need a decent way of capturing to
interleaved shorts.
(usrp_rx_file.py is a bit outdated)
I made an updated version of usrp_rx_cfile.py which can also output interleaved
shorts.
(It can also do 8 bit transfers and automatically disables halfband when you
use decimation < 8)
I attached a diff for usrp_rx_cfile.py to add these features to this mail.
(Eric, if you like it, I can apply it to cvs)
If this new usrp_rx_cfile.py works fine, we should probably remove
usrp_rx_file.py.
greetings,
Martin
Index: usrp_rx_cfile.py
===================================================================
RCS file: /sources/gnuradio/gnuradio-examples/python/usrp/usrp_rx_cfile.py,v
retrieving revision 1.7
diff -u -r1.7 usrp_rx_cfile.py
--- usrp_rx_cfile.py 13 Mar 2006 01:11:22 -0000 1.7
+++ usrp_rx_cfile.py 26 Apr 2006 02:31:59 -0000
@@ -2,7 +2,7 @@
"""
Read samples from the USRP and write to file formatted as binary
-single-precision complex values.
+outputs single precision complex float values or complex short values
(interleaved 16 bit signed short integers).
"""
@@ -11,7 +11,6 @@
from gnuradio import usrp
from gnuradio.eng_option import eng_option
from optparse import OptionParser
-import sys
class my_graph(gr.flow_graph):
@@ -28,6 +27,12 @@
help="set frequency to FREQ", metavar="FREQ")
parser.add_option("-g", "--gain", type="eng_float", default=None,
help="set gain in dB (default is midpoint)")
+ parser.add_option("-8", "--width-8", action="store_true",
default=False,
+ help="Enable 8-bit samples across USB")
+ parser.add_option( "--no-hb", action="store_true", default=False,
+ help="don't use halfband filter in usrp")
+ parser.add_option( "-s","--output-shorts", action="store_true",
default=False,
+ help="output interleaved shorts in stead of complex
floats")
parser.add_option("-N", "--nsamples", type="eng_float", default=None,
help="number of samples to collect [default=+inf]")
(options, args) = parser.parse_args ()
@@ -42,12 +47,34 @@
raise SystemExit, 1
# build the graph
- self.u = usrp.source_c(decim_rate=options.decim)
- self.dst = gr.file_sink(gr.sizeof_gr_complex, filename)
+ if options.no_hb or (options.decim<8):
+ self.fpga_filename="std_4rx_0tx.rbf" #Min decimation of this
firmware is 4. contains 4 Rx paths without halfbands and 0 tx paths.
+ if options.output_shorts:
+ self.u =
usrp.source_s(decim_rate=options.decim,fpga_filename=self.fpga_filename)
+ else:
+ self.u =
usrp.source_c(decim_rate=options.decim,fpga_filename=self.fpga_filename)
+ else:
+ #standard fpga firmware "std_2rxhb_2tx.rbf" contains 2 Rx paths with
halfband filters and 2 tx paths (the default) min decimation 8
+ if options.output_shorts:
+ self.u = usrp.source_s(decim_rate=options.decim)
+ else:
+ self.u = usrp.source_c(decim_rate=options.decim)
+ if options.width_8:
+ sample_width = 8
+ sample_shift = 8
+ format = self.u.make_format(sample_width, sample_shift)
+ r = self.u.set_format(format)
+ if options.output_shorts:
+ self.dst = gr.file_sink(gr.sizeof_short, filename)
+ else:
+ self.dst = gr.file_sink(gr.sizeof_gr_complex, filename)
if options.nsamples is None:
self.connect(self.u, self.dst)
else:
- self.head = gr.head(gr.sizeof_gr_complex, int(options.nsamples))
+ if options.output_shorts:
+ self.head = gr.head(gr.sizeof_short, int(options.nsamples)*2)
+ else:
+ self.head = gr.head(gr.sizeof_gr_complex, int(options.nsamples))
self.connect(self.u, self.head, self.dst)
if options.rx_subdev_spec is None:
@@ -64,6 +91,7 @@
# if no gain was specified, use the mid-point in dB
g = self.subdev.gain_range()
options.gain = float(g[0]+g[1])/2
+
self.subdev.set_gain(options.gain)
r = self.u.tune(0, self.subdev, options.freq)