I'm working on project to provide some Kinect functions as WCF services. I'm having a problem with some classes such as ColorImageFrame which cannot be serialized. I was thinking to inherit from it and make it "Serializable" but the problem is ColorImageFrame class is a sealed class. Any ideas?
Here a simple example of what I want to do; I'm not sure if I'm doing it in the right way.
[ServiceContract]
public interface IKinectTools
{
[OperationContract]
ColorImageFrame getVideoStream();
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class KinectTools : IKinectTools
{
KinectSensor sensor;
ColorImageFrame videoData = null;
void sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
videoData = e.OpenColorImageFrame();
}
public ColorImageFrame getVideoStream()
{
return videoData;
}
}
I just want to build a WCF service to make the video stream available to the clients.
In a property, getter convert your ColorImageFrame to byte[].
byte[] can be serialized !
Use this method to obtain byte datas :
ColorImageFrame.CopyPixelDataTo(Byte[])
sample :
public byte[] ColorImageFrameData
{
get
{
byte[] ret= new byte[_colorImageFrame.PixelDataLength];
_colorImageFrame.CopyPixelDataTo(ret);
return ret;
}
}