Process network = new Process(); network.StartInfo.RedirectStandardOutput = true; network.StartInfo.RedirectStandardInput = true; network.StartInfo.CreateNoWindow = true; network.StartInfo.UseShellExecute = false; network.StartInfo.FileName = Application.StartupPath + @"\Solver\bin\deepcl_predict.exe"; network.StartInfo.Arguments = "weightsfile=\"" + Application.StartupPath + "\\Solver\\weights.dat\" batchsize=1 outputformat=text"; network.Start(); Thread.Sleep(5000); using (Bitmap bmp = new Bitmap(Application.StartupPath + "\\test.jpeg")) { int offSet = bmp.Width * bmp.Height; float[] dataPoint = new float[offSet * 3]; #region Get the colours straight from memory unsafe { BitmapData bitmapData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, bmp.PixelFormat); int bytesPerPixel = Image.GetPixelFormatSize(bmp.PixelFormat) / 8; int heightInPixels = bitmapData.Height; int widthInBytes = bitmapData.Width * bytesPerPixel; byte* ptrFirstPixel = (byte*)bitmapData.Scan0; int index = 0; for (int y = 0; y < heightInPixels; y++) { byte* currentLine = ptrFirstPixel + (y * bitmapData.Stride); for (int x = 0; x < widthInBytes; x = x + bytesPerPixel) { dataPoint[index] = currentLine[x + 2]; // Red dataPoint[index + offSet] = currentLine[x + 1]; // Green dataPoint[index + offSet + offSet] = currentLine[x]; // Blue index++; } } bmp.UnlockBits(bitmapData); } #endregion network.StandardInput.BaseStream.Write(BitConverter.GetBytes(3), 0, 4); network.StandardInput.BaseStream.Write(BitConverter.GetBytes(96), 0, 4); network.StandardInput.BaseStream.Write(BitConverter.GetBytes(96), 0, 4); for (int i = 0; i < dataPoint.Length; i++) { byte[] bytes = BitConverter.GetBytes(dataPoint[i]); network.StandardInput.BaseStream.Write(bytes, 0, bytes.Length); } } network.StandardInput.BaseStream.Flush(); while (true) { Thread.Sleep(100); string tmpData = network.StandardOutput.ReadLine(); if (tmpData != null && tmpData.Length > 0) Logg(tmpData); // same as console.writeline }