コード例 #1
0
 private void ReadServerMessage(ServerMsg srvMsg)
 {
     if (srvMsg.msgType == MsgType.MSG_TYPE_IMAGE)
     {
         Debug.Log("Updating texture...");
         String message = srvMsg.msg;
         Mat    image   = str2mat(message);
         if (image.width() > 0 && image.height() > 0)
         {
             Core.flip(image, image, 0);
             Core.flip(image, image, 1);
             if (image.type() == CvType.CV_8UC3)
             {
                 Imgproc.cvtColor(image, image, Imgproc.COLOR_BGR2RGB);
                 Utils.matToTexture2D(image, ImageTexture_);
             }
             else if (image.type() == CvType.CV_32FC1)
             {
                 Mat disp_colormap = DisparityController.Disparity2Colormap(image, 255, false);
                 Imgproc.cvtColor(disp_colormap, disp_colormap, Imgproc.COLOR_BGR2RGB);
                 Utils.matToTexture2D(disp_colormap, ImageTexture_);
             }
             else
             {
                 Debug.Log("Unsupported CV image type: " + image.type().ToString());
             }
         }
     }
     else if (srvMsg.msgType == MsgType.MSG_TYPE_STRING)
     {
         Debug.Log(srvMsg.msg);
     }
 }
コード例 #2
0
 private void UpdateTexture(Mat image)
 {
     if (image.width() > 0 && image.height() > 0)
     {
         Core.flip(image, image, 0);
         Core.flip(image, image, 1);
         if (image.type() == CvType.CV_8UC3)
         {
             Imgproc.cvtColor(image, image, Imgproc.COLOR_BGR2RGB);
             Utils.matToTexture2D(image, ImageTexture);
         }
         else if (image.type() == CvType.CV_32FC1)
         {
             Mat disp_colormap = DisparityController.Disparity2Colormap(image, 255, false);
             Imgproc.cvtColor(disp_colormap, disp_colormap, Imgproc.COLOR_BGR2RGB);
             Utils.matToTexture2D(disp_colormap, ImageTexture);
         }
         else
         {
             Debug.Log("Unsupported CV image type: " + image.type().ToString());
         }
     }
 }