RE:video streaming from Aibo to PC
I posted a question about video streaming from Aibo to PC in OPEN-R forum:
| Hi,
|
| In past weeks I tried to implement the video streaming from Aibo to PC. The main
| idea is to have a buffer (array of 44x38x3) in the Aibo storing the YUV data
| received from Camera. Every time the main program is notified by FbkImageSensor,
| it send the whole buffer to the client by TCP/IP connection. The client does the
| YUV2RGB convertion.
|
| The problem is, the video received by the client is corrupted. Here are 3
| screenshots:
|
| http://msw.mcmaster.ca/~wangy/temp/s1.png
| http://msw.mcmaster.ca/~wangy/temp/s2.png
| http://msw.mcmaster.ca/~wangy/temp/s3.png
|
| However, if I make the server only transmit the first frame, the image received
| by client is fine.
|
| The wireless mode for Aibo and PC is ad-hoc, so I think the network delay can be
| ignored.
|
| Here is the code of Notify() to be called by subject FbkImageSensor:
|
| void gEye::Notify(const ONotifyEvent& event)
| {
| if (gEyeState == _IDLE) {
| return;
| //do nothing
| }
|
| static int x, y;
|
| OFbkImageVectorData* fbkImageVectorData
| = (OFbkImageVectorData*)event.Data(0);
|
| OFbkImageInfo* info = fbkImageVectorData->GetInfo(layer);
| byte* data = fbkImageVectorData->GetData(layer);
|
| OFbkImage current_Y(info, data, ofbkimageBAND_Y);
| OFbkImage current_Cr(info, data, ofbkimageBAND_Cr);
| OFbkImage current_Cb(info, data, ofbkimageBAND_Cb);
|
| gEye_snd_data.width = info->width;
| gEye_snd_data.height = info->height;
|
| if ((current_Y.IsValid() == true)
| && (current_Cr.IsValid() == true)
| && (current_Cb.IsValid() == true)){
|
| for (y = 0; y < info->height - 1; y++){
| for (x = 0; x < info->width; x++){
| gEye_snd_data.image[x][y][0] =
| current_Y.Pixel(x, y);
| gEye_snd_data.image[x][y][1] =
| current_Cr.Pixel(x, y);
| gEye_snd_data.image[x][y][2] =
| current_Cb.Pixel(x, y);
| }
| }
| Snd();
| }
| observer[event.ObsIndex()]->AssertReady(event.SenderID());
| }
|
| Any helps are appreciated.
|
| Yu
And it got replied from aibopet:
My guess is the old data has not being completely transmitted before the next
Image notification comes in (and over-writes the old data).
This will depend what is going on in your 'Snd()' routine. It should lock out
the buffer access until all the data is transmitted, and/or copy it to the
TCP/IP buffer first.
In most of the other TCP/IP samples (eg: EchoServer/Client) copy the data to a
transmit buffer before starting the send process ('SetSendData' or something
like that, followed by 'Send'). The transmission is not complete until
the 'SendCont' callback is called.