public double[,] captureRGBCloud() { Mmind.Response reply = sendRequest(CaptureGratingImage, 4, ""); Mat depthC3 = read32FC3Mat(reply.ImageGrating); Mat color = captureColorImg(); int nums = color.Rows * color.Cols; double[,] xyzbgr = new double[nums, 6]; int count = 0; for (int i = 0; i < depthC3.Rows; i++) { for (int j = 0; j < depthC3.Cols; j++) { xyzbgr[count, 0] = (double)depthC3.At <Vec3f>(i, j)[0] * 0.001; xyzbgr[count, 1] = (double)depthC3.At <Vec3f>(i, j)[1] * 0.001; xyzbgr[count, 2] = (double)depthC3.At <Vec3f>(i, j)[2] * 0.001; xyzbgr[count, 3] = color.At <Vec3b>(i, j)[0]; xyzbgr[count, 4] = color.At <Vec3b>(i, j)[1]; xyzbgr[count, 5] = color.At <Vec3b>(i, j)[2]; count++; } } return(xyzbgr); }
public double[] getCameraIntri() { Mmind.Response reply = sendRequest(GetCameraIntri, 0.0, ""); string intri_original = reply.CamIntri; int start = intri_original.LastIndexOf('['); int end = intri_original.LastIndexOf(']'); int length = intri_original.Length; if (start == -1 || end == -1 || end < start) { Console.WriteLine("Wrong camera intrinsics"); return(null); } string intri_str = intri_original.Remove(0, start + 1).Substring(0, end - start - 1); string[] intrivalue_str = intri_str.Split(','); if (intrivalue_str.Length != 4) { Console.WriteLine("Wrong intrinscis value"); return(null); } CameraIntri intri = new CameraIntri(); intri.setValue(double.Parse(intrivalue_str[0]), double.Parse(intrivalue_str[1]), double.Parse(intrivalue_str[2]), double.Parse(intrivalue_str[3]) ); double[] rel = intri.getValue(); //Console.WriteLine("fx = " + rel[0].ToString()); //Console.WriteLine("fy = " + rel[1].ToString()); //Console.WriteLine("u = " + rel[2].ToString()); //Console.WriteLine("v = " + rel[3].ToString()); return(rel); }
public Mmind.Response sendReq(Mmind.Request req) { reqbuf = new byte[req.CalculateSize()]; Serialize(reqbuf, req); client.SendFrame(reqbuf); resbuf = client.ReceiveFrameBytes(); Mmind.Response rel = Mmind.Response.Parser.ParseFrom(resbuf); return(rel); }
Mmind.Response sendRequest(int command, double value_num, string value_str) { Mmind.Request Request = new Mmind.Request(); Request.Command = command; Request.ValueDouble = value_num; Request.ValueString = value_str; Mmind.Response reply = sendReq(Request); return(reply); }
Mmind.CameraStatus getCameraStatus() { Mmind.Response reply = sendRequest(GetCameraStatus, 0.0, ""); string StatusUnicode = reply.CameraStatus; byte[] StatusBytes = Encoding.UTF8.GetBytes(StatusUnicode); Mmind.CameraStatus cmstatus = new CameraStatus(); cmstatus = Mmind.CameraStatus.Parser.ParseFrom(StatusBytes); return(cmstatus); }
public Mat captureDepthImg() { Mmind.Response reply = sendRequest(CaptureImage, DEPTH, ""); if (reply.ImageDepth.Length == 0) { Console.WriteLine("Client depth image is empty!"); return(null); } Console.WriteLine("Depth image captured!"); return(read32FC1Mat(reply.ImageDepth, 2)); }
public Mat captureColorImg() { Mmind.Response reply = sendRequest(CaptureImage, COLOR, ""); if (reply.ImageRGB.Length == 0) { Console.WriteLine("Client depth image is empty!"); return(null); } Console.WriteLine("Color image captured!"); Mat img = asMat(reply.ImageRGB); return(Cv2.ImDecode(img, ImreadModes.Color)); }
public string setParameter(string paraname, double value) { Mmind.Response error = sendRequest(SetCameraParameter, value, paraname); return(error.Error); }
public double getParameter(string paraname) { Mmind.Response reply = sendRequest(GetCameraParameter, 0.0, paraname); return(double.Parse(reply.ParameterValue)); }