<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 07/12/2013 05:14 PM,
<a class="moz-txt-link-abbreviated" href="mailto:Martin.Azkarate@esa.int">Martin.Azkarate@esa.int</a> wrote:<br>
</div>
<blockquote
cite="mid:3093_1373642069_51E01D55_3093_12976_1_OF7C47FE7C.A4A3BAF6-ONC1257BA6.00525BFE-C1257BA6.0053BB4D@esa.int"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=US-ASCII">
Hello,<br>
<br>
I have the following code that works fine to separate two
interlaced images
that arrive in a single port and separates them into two frames
that are
sent out in two different ports:<br>
<br>
void Task::updateHook()<br>
{<br>
TaskBase::updateHook();<br>
<br>
if (_frame_in.read(input_frame)==RTT::NewData)<br>
{<br>
Frame* left = new Frame(input_frame->size.width,
input_frame->size.height, 8, input_frame->frame_mode);<br>
Frame* right = new Frame(input_frame->size.width,
input_frame->size.height, 8, input_frame->frame_mode);<br>
deInterlace(*input_frame,*left,*right);<br>
Frame* left_gray = new Frame(left->size.width,
left->size.height, 8, MODE_GRAYSCALE);<br>
Frame* right_gray = new Frame(right->size.width,
right->size.height, 8, MODE_GRAYSCALE);<br>
frame_helper.convertColor(*left,*left_gray);<br>
frame_helper.convertColor(*right,*right_gray);<br>
frame_left.reset(left_gray);<br>
frame_right.reset(right_gray);<br>
_frame_left.write(frame_left);<br>
_frame_right.write(frame_right);<br>
}<br>
}<br>
</blockquote>
why do you convert the colour insight the component? Is not the
component supposed to just split the frame?<br>
<br>
<blockquote
cite="mid:3093_1373642069_51E01D55_3093_12976_1_OF7C47FE7C.A4A3BAF6-ONC1257BA6.00525BFE-C1257BA6.0053BB4D@esa.int"
type="cite">
<br>
void Task::deInterlace(const base::samples::frame::Frame
&input, base::samples::frame::Frame
&left, base::samples::frame::Frame &right)<br>
{
<br>
//! Note: input frame has a data depth of
16bits while the left and right have a data depth of 8 bits. Bytes
in the
input frame are mixed in order, one byte from the left, one byte
from the
right, and so on.
<br>
//! So in "one pixel" of 16bits
of the input frame there are "two pixels" of 8bits one of each
left and right frames.<br>
uint32_t width=(input.size.width*2);<br>
uint32_t height=input.size.height;<br>
<br>
int i = (width*height)-1;<br>
int j = ((width*height)>>1)-1;<br>
<br>
while (i >= 0) {<br>
right.image[j] = input.image[i--];<br>
left.image[j--] = input.image[i--];<br>
}<br>
<br>
left.copyImageIndependantAttributes(input);<br>
right.copyImageIndependantAttributes(input);<br>
<br>
}<br>
</blockquote>
I guess running the loop while i == 0 is not what you intended. In
general I would stay away from bit shifting and these kind of
programming. It is horrible to maintain and is asking for trouble. I
would also not assume that your function is called with frames
having the right size. If you have wired problems like you described
running the hole component under valgrind helps most of the time<br>
<br>
Greets<br>
Alex<br>
<br>
<br>
<blockquote
cite="mid:3093_1373642069_51E01D55_3093_12976_1_OF7C47FE7C.A4A3BAF6-ONC1257BA6.00525BFE-C1257BA6.0053BB4D@esa.int"
type="cite">
<br>
input_frame, frame_left and frame_right are ReadOnlyPointers of
type Frame
defined in Task.hpp. Rest of the Hooks are empty/default.<br>
<u><br>
Question</u>: Even thought this does the work for me, I would
like to know
if this is a correct way of doing it. Mostly regarding the
creation of
several Frame pointers and allocation of memory for those in the
middle
of the updateHook? (This is actually important because it is
related to
the question below)<br>
<br>
Now, I would like to send out both images left and right in a
single port
using the structure FramePair, to make sure that they arrive
together to
the stereo processing component with a single timestamp for both
(as they
were both taken at the same time by a stereo camera). However, I
have tried
to replicate the same logic using the FramePair structure and
always got
errors in execution (compilation is ok).<br>
<br>
Changing the last part of the updateHook to the following:<br>
<br>
void Task::updateHook()<br>
{<br>
TaskBase::updateHook();<br>
<br>
if (_frame_in.read(input_frame)==RTT::NewData)<br>
{<br>
Frame* left = new Frame(input_frame->size.width,
input_frame->size.height, 8, input_frame->frame_mode);<br>
Frame* right = new Frame(input_frame->size.width,
input_frame->size.height, 8, input_frame->frame_mode);<br>
deInterlace(*input_frame,*left,*right);<br>
Frame* left_gray = new Frame(left->size.width,
left->size.height, 8, MODE_GRAYSCALE);<br>
Frame* right_gray = new Frame(right->size.width,
right->size.height, 8, MODE_GRAYSCALE);<br>
frame_helper.convertColor(*left,*left_gray);<br>
frame_helper.convertColor(*right,*right_gray);<br>
FramePair* frame_pair;<br>
frame_pair->id=index_frame++; //! index_frame
is defined in Task.hpp and initialized to 0 in configureHook.<br>
frame_pair->time = input_frame->time;<br>
frame_pair->first = *left_gray;<br>
frame_pair->second = *right_gray;<br>
output_frame_pair.reset(frame_pair); //! output_frame_pair
is also a ReadOnlyPointer in Task.hpp<br>
_frame_out.write(output_frame_pair);<br>
}<br>
}<br>
<br>
gives me the following error when I run it: Orocos[WARN]:
deployment <i>[myTaskContext]</i>
unexpectedly terminated with signal 11<br>
<br>
After trying several ways of assigning the frames's data to the
frame_pair
structure without success I understood I was not using FramePair
the right
way. So I tried something very simple as:<br>
<br>
void Task::updateHook()<br>
{<br>
TaskBase::updateHook(); <br>
<br>
if (_frame_in.read(input_frame)==RTT::NewData)<br>
{<br>
FramePair* frame_pair;<br>
frame_pair->time=input_frame->time;<br>
frame_pair->id=index_frame++;<br>
frame_pair->first.init(1024,768,8,MODE_GRAYSCALE);<br>
frame_pair->second.init(1024,768,8,MODE_GRAYSCALE);<br>
output_frame_pair.reset(frame_pair);<br>
_frame_out.write(output_frame_pair);<br>
}<br>
}<br>
<br>
And it gives the same error as above and actually the execution
stops before
the end of the updateHook at the line where the first.init()
function is
called.<br>
<br>
I make it even simpler:<br>
<br>
void Task::updateHook()<br>
{<br>
TaskBase::updateHook(); <br>
<br>
if (_frame_in.read(input_frame)==RTT::NewData)<br>
{<br>
FramePair* frame_pair;<br>
frame_pair->time=input_frame->time;<br>
frame_pair->id=index_frame++;<br>
output_frame_pair.reset(frame_pair);<br>
_frame_out.write(output_frame_pair);<br>
}<br>
}<br>
<br>
I get the same error when exiting the updateHook.<br>
<u><br>
Question:</u> What is it that I am missing about FramePair
structure that
makes it so different to the Frame structure when it comes to
memory allocation?
Somebody can put some light in this?<br>
<br>
Thank you very much for your attention,<br>
<br>
Martin<br>
<br>
<p>Martin Azkarate
</p>
<p><b>ESA - European Space Agency</b><br>
Spanish Trainee, TEC-MMA - Automation and Robotics Section </p>
<p><b>ESTEC - European Space
research and TEchnology Centre</b><br>
Keplerlaan 1, PO Box 299 <br>
NL-2200 AG Noordwijk, The Netherlands <br>
<a class="moz-txt-link-abbreviated" href="mailto:Martin.Azkarate@esa.int">Martin.Azkarate@esa.int</a> | <a moz-do-not-send="true">www.esa.int</a>
<br>
Tel +31 71 565 3480 | Mob +31 650 625 564 </p>
<pre>This message and any attachments are intended for the use of the addressee or addressees only. The unauthorised disclosure, use, dissemination or copying (either in whole or in part) of its content is not permitted. If you received this message in error, please notify the sender and delete it from your system. Emails can be altered and their integrity cannot be guaranteed by the sender.
Please consider the environment before printing this email.
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Rock-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Rock-dev@dfki.de">Rock-dev@dfki.de</a>
<a class="moz-txt-link-freetext" href="http://www.dfki.de/mailman/cgi-bin/listinfo/rock-dev">http://www.dfki.de/mailman/cgi-bin/listinfo/rock-dev</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Dipl.-Ing. Alexander Duda
Unterwasserrobotik
DFKI Bremen
Robotics Innovation Center
Robert-Hooke-Straße 5
28359 Bremen, Germany
Phone: +49 (0)421 178-456620
Fax: +49 (0)421 178-454150
E-Mail: <a class="moz-txt-link-abbreviated" href="mailto:alexander.duda@dfki.de">alexander.duda@dfki.de</a>
Weitere Informationen: <a class="moz-txt-link-freetext" href="http://www.dfki.de/robotik">http://www.dfki.de/robotik</a>
-----------------------------------------------------------------------
Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
Firmensitz: Trippstadter Straße 122, D-67663 Kaiserslautern
Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster
(Vorsitzender) Dr. Walter Olthoff
Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
Amtsgericht Kaiserslautern, HRB 2313
Sitz der Gesellschaft: Kaiserslautern (HRB 2313)
USt-Id.Nr.: DE 148646973
Steuernummer: 19/673/0060/3
</pre>
</body>
</html>