logo logo
Inicio arrow Foros...
Sunday, 04 de January de 2009
 
 
English English  Español Español  
Próximos Eventos
10.Jun. 2009

IWANN 2009
Salamanca, Spain
11.Jun. 2009

Toward a Science of Consciousness
Hong Kong, China
15.Jun. 2009

International Workshop on Machine Consciousness
Hong Kong, China
15.Jun. 2009

The 8th IEEE International Conference on Cognitive Informatics
Hong Kong, China
22.Jun. 2009

IWINAC 2009
Santiago de Compostela, Spain
Etiquetas
Análisis Artificial Científicos Conciencia Consciencia Consciencia Artificial Conscientes Consciousness Developer Documentación Documentation Español Howto Investigación Publicaciones Reviews Robotics Robots Robótica Servicios Spanish Studio VPL artificial
Destacados
Conscious-Robots.com Forum  


Raúl
Moderador

Moderador
Mensajes: 444
graph
Karma: 6  
Re:Simulated WebCam exception in QueryFrame - 2007/09/18 13:25 The code after making the mentioned changes is as follows (this code seems to work ok. I am unsure whether or not some frames are loss when the method is called when the simulator engine has blocked the image).

Code:

         // Raul - Service handler changed from Concurrent to Exclusive.         [ServiceHandler(ServiceHandlerBehavior.Exclusive)]         public IEnumerator<ITaskQueryFrameHandler(webcam.QueryFrame query)         {             if (_state.Image == null)             {                 query.ResponsePort.Post(new webcam.QueryFrameResponse());                 yield break;             }             Size size = new Size((int)query.Body.Size.X, (int)query.Body.Size.Y);             if (query.Body.Format == Guid.Empty)             {                 // raw image requested;                 BitmapData raw null;                 try                 {                     // Raul - This check moved into the try-catch block.                     // size not specified                     if (size.Width == 0)                         size _state.Image.Size;                     raw _state.Image.LockBits(new Rectangle(Point.Empty, size),                         ImageLockMode.ReadOnlyPixelFormat.Format24bppRgb);                     int byteSize raw.Height raw.Stride;                     webcam.QueryFrameResponse response = new webcam.QueryFrameResponse();                     response.TimeStamp _state.LastFrameUpdate;                     response.Frame = new byte[byteSize];                     response.Size = new Size(raw.Widthraw.Height);                     response.Format Guid.Empty;                     System.Runtime.InteropServices.Marshal.Copy(raw.Scan0response.Frame0byteSize);                     query.ResponsePort.Post(response);                 }                 catch (Exception ex)                 {                     query.ResponsePort.Post(Fault.FromException(ex));                 }                 finally                 {                     if (raw != null)                     {                         _state.Image.UnlockBits(raw);                     }                 }             }             else             {                 ImageFormat format = new ImageFormat(query.Body.Format);                 using (MemoryStream stream = new MemoryStream())                 {                                         if (size == _state.Image.Size ||                         size.Width == ||                         size.Height == ||                         size.Width >= _state.Image.Width ||                         size.Height >= _state.Image.Height)                     {                         size _state.Image.Size;                         _state.Image.Save(streamformat);                     }                     else                     {                         using (Bitmap temp = new Bitmap(                             _state.Imagesize))                         {                             temp.Save(streamformat);                         }                     }                     webcam.QueryFrameResponse response = new webcam.QueryFrameResponse();                     response.TimeStamp _state.LastFrameUpdate;                     response.Frame = new byte[(int)stream.Length];                     response.Size size;                     response.Format format.Guid;                     stream.Position 0;                     stream.Read(response.Frame0response.Frame.Length);                     query.ResponsePort.Post(response);                 }             }             yield break;         }

Raúl Arrabales Moreno. conscious-robots.com/raul
  El administrador ha deshabilitado la escritura de mensajes a los usuarios no registrados.

      Temas Autor Fecha
    emo
Simulated WebCam exception in QueryFrame
Raúl 2007/09/18 12:31
    emo
thread linkthread link Re:Simulated WebCam exception in QueryFrame
Raúl 2007/09/18 13:25
Titulares RSS
 Conscious Robots RSS FeedFuente RSS de Conscious Robots





¿Recuperar contraseña?
¿Quieres registrarte? Hazlo aquí
Mensajes en el Foro
 
Top! Top!