@@ -16,6 +16,7 @@ public class ImagePublisher : MonoBehaviour
1616
1717 //private MessageTypes.Sensor.CompressedImage message;
1818 private Texture2D texture2D ;
19+ private Texture2D texture2DFlipped ;
1920 private Rect rect ;
2021 private const int isBigEndian = 1 ;
2122 private const int step = 3 ;
@@ -27,7 +28,7 @@ public class ImagePublisher : MonoBehaviour
2728 /// Arg original: incoming texture
2829 /// Returns: void
2930 //*************************************************************************
30- public static void FlipTextureVerticallyInplace ( Texture2D original )
31+ public void FlipTextureVerticallyInplace ( Texture2D original )
3132 {
3233 var originalPixels = original . GetPixels ( ) ;
3334
@@ -53,25 +54,18 @@ public static void FlipTextureVerticallyInplace(Texture2D original)
5354 /// Arg original: incoming texture
5455 /// Returns: Flipped texture
5556 //*************************************************************************
56- public static Texture2D FlipTextureVertically ( Texture2D original )
57+ public Texture2D FlipTextureVertically ( Texture2D original )
5758 {
58- Texture2D flipped = new Texture2D (
59- original . width , original . height , original . format , false ) ;
60-
6159 int xN = original . width ;
6260 int yN = original . height ;
6361
6462 for ( int i = 0 ; i < xN ; i ++ )
65- {
6663 for ( int j = 0 ; j < yN ; j ++ )
67- {
68- flipped . SetPixel ( i , yN - j - 1 , original . GetPixel ( i , j ) ) ;
69- }
70- }
64+ texture2DFlipped . SetPixel ( i , yN - j - 1 , original . GetPixel ( i , j ) ) ;
7165
72- flipped . Apply ( ) ;
66+ texture2DFlipped . Apply ( ) ;
7367
74- return flipped ;
68+ return texture2DFlipped ;
7569 }
7670
7771 //************************************************************************
@@ -105,6 +99,7 @@ private void InitializeGameObject()
10599 {
106100 ImageCamera . enabled = true ;
107101 texture2D = new Texture2D ( resolutionWidth , resolutionHeight , TextureFormat . RGB24 , false ) ;
102+ texture2DFlipped = new Texture2D ( resolutionWidth , resolutionHeight , TextureFormat . RGB24 , false ) ;
108103 rect = new Rect ( 0 , 0 , resolutionWidth , resolutionHeight ) ;
109104 ImageCamera . targetTexture = new RenderTexture ( resolutionWidth , resolutionHeight , 24 ) ;
110105 }
@@ -121,7 +116,7 @@ private void InitializeMessage()
121116
122117 //************************************************************************
123118 /// Description: Update message, send to ROS
124- /// Returns: void
119+ /// Returns: void
125120 //*************************************************************************
126121 public IEnumerator UpdateMessage ( )
127122 {
0 commit comments