static void Main(string[] args) { Network.init(); BufferedPortBottle p = new BufferedPortBottle(); if (!p.open("/csharp")) System.Environment.Exit(1); p.close(); Network.fini(); }
static void Main(string[] args) { Network.init(); BufferedPortBottle p = new BufferedPortBottle(); p.open("/csharp"); p.close(); Network.fini(); }
public static void Main(string[] args) { var serviceProvider = BuildDIContainer(); // Initialize Yarp Network.init(); using (var videoSource = serviceProvider.GetRequiredService <IVideoSource>()) using (var audioSource = serviceProvider.GetRequiredService <IAudioSource>()) using (var videoPort = new BufferedPortImageRgb()) using (var audioPort = new BufferedPortBottle()) using (var videoFrameRgbBuffer = new Image <Rgb, byte>(640, 480)) { // Stream the video frames to a yarp port videoPort.open("/camera"); videoSource.FrameReady += (_, frame) => { using (var msg = videoPort.prepare()) { // Convert the incoming image which is BGR to RGB var bits = frame.Image.LockBits(new Rectangle(0, 0, frame.Image.Width, frame.Image.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb); using (var videoFrameBgr = new Image <Bgr, byte>(frame.Image.Width, frame.Image.Height, bits.Stride, bits.Scan0)) CvInvoke.CvtColor(videoFrameBgr, videoFrameRgbBuffer, ColorConversion.Bgr2Rgb); frame.Image.UnlockBits(bits); // Send the RGB image over yarp var handle = GCHandle.Alloc(videoFrameRgbBuffer.Bytes, GCHandleType.Pinned); msg.setExternal(new SWIGTYPE_p_void(handle.AddrOfPinnedObject(), true), (uint)frame.Image.Width, (uint)frame.Image.Height); videoPort.write(); videoPort.waitForWrite(); handle.Free(); } }; // Stream the audio samples to a yarp port audioPort.open("/microphone"); audioSource.SampleReady += (_, sample) => { using (var bottle = audioPort.prepare()) { var handle = GCHandle.Alloc(sample.Data, GCHandleType.Pinned); bottle.clear(); bottle.add(Value.makeBlob(new SWIGTYPE_p_void(handle.AddrOfPinnedObject(), true), sample.Data.Length)); audioPort.write(); audioPort.waitForWrite(); handle.Free(); } }; // Run the sample application RunDemoApplication(videoSource, audioSource); } // Explicitely shutdown NLog and Yarp Network.fini(); NLog.LogManager.Shutdown(); }
// Use this for initialization void Start() { Network.init(); p = new BufferedPortBottle(); p.open ("/unityYarp"); // globalRed = 1.0f; // globalBlue = 0.5f; // globalGreen = 0.2f; }
// Use this for initialization void Start() { Network.init(); p = new BufferedPortBottle(); //while(p.getOutputCount == 0) //{ p.open ("/unityYarp"); //} Network.connect("/unityYarp", destPortName); }
static void Main(string[] args) { Network.init(); BufferedPortBottle p = new BufferedPortBottle(); if (!p.open("/csharp")) { System.Environment.Exit(1); } p.close(); Network.fini(); }
public override void Initialise() { portReal = new BufferedPortBottle(); portPredicted = new BufferedPortBottle(); portPerceived = new BufferedPortBottle(); portReal.open("/" + mapName + "/" + name + "/real:i"); portPredicted.open("/" + mapName + "/" + name + "/predicted:o"); portPerceived.open("/" + mapName + "/" + name + "/perceived:o"); if (autoconnect_source != null) { Network.connect(autoconnect_source, YarpModalityVector.getRealPortName(mapName, name)); } base.Initialise(); }
/// <summary> /// /// </summary> /// <param name="nameInputPort"></param> /// <param name="nameOutputPort"></param> public void openReceiver(string nameOutputPort,string nameInputPort) { if (!String.IsNullOrEmpty(nameInputPort) && !String.IsNullOrEmpty(nameOutputPort)) { Network.init(); input = new BufferedPortBottle(); input.open(nameInputPort); style = new ContactStyle(); style.persistent=true; if(Network.isConnected(nameOutputPort,nameInputPort,style)) Network.disconnect(nameOutputPort,nameInputPort,style); if (Network.connect(nameOutputPort, nameInputPort, style)) Console.WriteLine(nameInputPort + " port is connected to " + nameOutputPort); } }
static void Main(string[] args) { Network.init(); BufferedPortBottle p = new BufferedPortBottle(); p.open("/csharp"); int top = 100; for (int i=1; i<top; i++) { Bottle bottle = p.prepare(); bottle.clear(); bottle.addString("count"); bottle.addInt(i); bottle.addString("of"); bottle.addInt(top); Console.WriteLine("Sending " + bottle.toString()); p.write(); Time.delay(0.5); } p.close(); Network.fini(); }
static void Main(string[] args) { Network.init(); BufferedPortBottle p = new BufferedPortBottle(); p.open("/csharp"); int top = 100; for (int i = 1; i < top; i++) { Bottle bottle = p.prepare(); bottle.clear(); bottle.addString("count"); bottle.addInt32(i); bottle.addString("of"); bottle.addInt32(top); Console.WriteLine("Sending " + bottle.toString()); p.write(); Time.delay(0.5); } p.close(); Network.fini(); }
internal static HandleRef getCPtr(BufferedPortBottle obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BufferedPortBottle obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
// Use this for initialization void Start() { Network.init(); p = new BufferedPortBottle(); p.open ("/unityYarp"); }
// Use this for initialization void Start() { //open all ports Network.init(); rightLegState = new BufferedPortBottle(); leftLegState = new BufferedPortBottle(); rightArmState = new BufferedPortBottle(); leftArmState = new BufferedPortBottle(); headState = new BufferedPortBottle(); torsoState = new BufferedPortBottle(); rightLegState.open (rLegPortName); leftLegState.open (lLegPortName); rightArmState.open (rArmPortName); leftArmState.open (lArmPortName); headState.open (headPortName); torsoState.open (torsoPortName); portCheckIter = 0; bottleTagInt = yarp.BOTTLE_TAG_INT; bottleTagString = yarp.BOTTLE_TAG_STRING; bottleTagDouble = yarp.BOTTLE_TAG_DOUBLE; bottleTagList = yarp.BOTTLE_TAG_LIST; Debug.Log ("INT: " + bottleTagInt + " DOUBLE: " + bottleTagDouble + " STRING: " + bottleTagString); }
public void openInputPort(string namePort) { if (!String.IsNullOrEmpty(namePort)) { Network.init(); input = new BufferedPortBottle(); input.open(namePort); } }