Beispiel #1
0
 public static int TangoService_connectOnFrameAvailable(TangoEnums.TangoCameraId cameraId,
                                                        IntPtr context,
                                                        [In, Out] TangoService_onImageAvailable onImageAvailable)
 {
     return(Tango.Common.ErrorType.TANGO_SUCCESS);
 }
Beispiel #2
0
 public static extern int TangoService_updateTexture(
     TangoEnums.TangoCameraId cameraId, ref double timestamp);
 public void _OnExperimentalUnityFrameAvailable(IntPtr callbackContext, Tango.TangoEnums.TangoCameraId cameraId)
 {
     m_previousCameraId = cameraId;
     m_shouldSendEvent = true;
 }
Beispiel #4
0
    /// <summary>
    /// This will be called when a new frame is available from the camera.
    /// </summary>
    /// <param name="cameraId">Camera identifier.</param>
    /// <param name="imageBuffer">Tango camera image buffer.</param>
    public void OnTangoImageAvailableEventHandler(TangoEnums.TangoCameraId cameraId, TangoUnityImageData imageBuffer)
    {
        if (fCount == 0)
        {
            TangoEnums.TangoImageFormatType enumDisplayStatus = (TangoEnums.TangoImageFormatType)imageBuffer.format;
            string stringValue = enumDisplayStatus.ToString();
            JLog("TangoImageAvailable on cameraId: " + cameraId + "  Format: " + imageBuffer.format + "(" + stringValue + "),  length: " + imageBuffer.data.Length + "  (" + imageBuffer.width + "x" + imageBuffer.height + "),  timestamp: " + imageBuffer.timestamp + ",  Stride: " + imageBuffer.stride);
        }

        fCount++;
//		if (_FileStream!= null && _FileStream.Length >= 600464512) {
//			JLog ("Closed File: " + _FileStream.Name);
//			_FileStream.Close();
//			_FileStream = null;
//		} else if ( _FileStream.CanWrite) {
//			JLog ("Write File: " + _FileStream.Length);
//			_FileStream.Write (imageBuffer.data, 0, imageBuffer.data.Length);
//		}

//		//For each YV12 frame  BROKEN
//		for (int i = 0; i < imageBuffer.width * imageBuffer.height; i+=36) {
//			for (int y = 0; y < 24; y++)
//				JLog ("Y: " + imageBuffer.data[i+y]);
//			for (int u = 24; u < 30; u++)
//				JLog ("U: " + imageBuffer.data[i+u]);
//			for (int v = 30; v < 36; v++)
//				JLog ("V: " + imageBuffer.data[i+v]);
//			JLog ("--------------");

//			size.total = size.width * size.height;
//			y = yuv [position.y * size.width + position.x];
//			u = yuv [(position.y / 2) * (size.width / 2) + (position.x / 2) + size.total];
//			v = yuv [(position.y / 2) * (size.width / 2) + (position.x / 2) + size.total + (size.total / 4)];
//		}

//		if(fCount%100==0)
//		System.Diagnostics.Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();

        callUnityTangoARPlayer("arwAcceptVideoImage", new object[] {
            halveYUV420(
                halveYUV420(imageBuffer.data, imageBuffer.width, imageBuffer.height),
                imageBuffer.width / 2,
                imageBuffer.height / 2
                )
        }
                               );
//
//		timer.Stop();
//		TimeSpan timespan = timer.Elapsed;
////
//		JLog( String.Format("{0:00}:{1:00}:{2:00}", timespan.Minutes, timespan.Seconds, timespan.Milliseconds / 10) );


        //We are calling ARToolkit Library native function, through JNI, to feed in a frame of Tango video to the ARToolkit processing.

        /**
         * Passes a video frame to the native library for processing.
         *
         * @param image               Buffer containing the video frame
         * @param width               Width of the video frame in pixels
         * @param height              Height of the video frame in pixels
         * @param cameraIndex         Zero-based index of the camera in use. If only one camera is present, will be 0.
         * @param cameraIsFrontFacing false if camera is rear-facing (the default) or true if camera is facing toward the user.
         * @return true if no error occurred, otherwise false
         */
        //public static native boolean arwAcceptVideoImage(byte[] image, int width, int height, int cameraIndex, boolean cameraIsFrontFacing);
        //public static native boolean arwAcceptVideoImage(byte[] image);
    }
Beispiel #5
0
 public static extern int TangoService_Experimental_connectTextureIdUnity(
     TangoEnums.TangoCameraId id, UInt32 texture_y, UInt32 texture_Cb, UInt32 texture_Cr, IntPtr context,
     APIOnTextureAvailable callback);
Beispiel #6
0
 public static int TangoService_updateTextureExternalOes(
     TangoEnums.TangoCameraId cameraId, UInt32 glTextureId, out double timestamp)
 {
     timestamp = 0;
     return(Common.ErrorType.TANGO_SUCCESS);
 }
 public static extern int TangoService_updateTexture(TangoEnums.TangoCameraId cameraId);
Beispiel #8
0
 public static extern int TangoService_connectOnImageAvailable(
     TangoEnums.TangoCameraId cameraId, IntPtr context,
     [In, Out] APIOnImageAvailable callback);
Beispiel #9
0
 /// <summary>
 /// DEPRECATED: Handle the callback set by the Tango Service when a new image is available.
 /// </summary>
 /// <param name="callbackContext">Callback context.</param>
 /// <param name="cameraId">Camera identifier.</param>
 protected void _OnExperimentalUnityFrameAvailable(IntPtr callbackContext, Tango.TangoEnums.TangoCameraId cameraId)
 {
     m_previousCameraId = cameraId;
     m_shouldSendEvent  = true;
 }
 public static int TangoService_updateTexture(TangoEnums.TangoCameraId cameraId)
 {
     return(Tango.Common.ErrorType.TANGO_SUCCESS);
 }
Beispiel #11
0
 void ITangoVideoOverlay.OnTangoImageAvailableEventHandler(TangoEnums.TangoCameraId cameraId, TangoUnityImageData imageBuffer)
 {
     m_imagebuffer = imageBuffer;
     //Debug.Log("<<<<<<<<<< In Image Available Event Handler: " + imageBuffer.data.GetValue(0));
 }
 public static int TangoService_Experimental_connectTextureIdUnity(
     TangoEnums.TangoCameraId id, UInt32 texture_y, UInt32 texture_Cb, UInt32 texture_Cr,
     IntPtr context, APIOnTextureAvailable callback)
 {
     return(Common.ErrorType.TANGO_SUCCESS);
 }
 public static int TangoService_connectOnTextureAvailable(
     TangoEnums.TangoCameraId cameraId, IntPtr context, APIOnTextureAvailable callback)
 {
     return(Common.ErrorType.TANGO_SUCCESS);
 }
Beispiel #14
0
 public static extern int TangoService_updateTextureExternalOes(
     TangoEnums.TangoCameraId cameraId, UInt32 glTextureId, out double timestamp);
Beispiel #15
0
 public void SetTargetCameraTexture(TangoEnums.TangoCameraId cameraId)
 {
     VideoOverlayProvider.ConnectTexture(cameraId,
                                         m_texture.GetNativeTextureID());
 }
Beispiel #16
0
 public static extern int TangoService_getCameraIntrinsics(
     TangoEnums.TangoCameraId cameraId, [Out] TangoCameraIntrinsics intrinsics);
Beispiel #17
0
 public static extern int TangoService_connectTextureId(TangoEnums.TangoCameraId cameraId, int textureHandle);
Beispiel #18
0
 public static extern int TangoService_connectOnTextureAvailable(
     TangoEnums.TangoCameraId cameraId, IntPtr ContextMenu, APIOnTextureAvailable callback);
Beispiel #19
0
 public static extern int TangoService_connectOnFrameAvailable(TangoEnums.TangoCameraId cameraId,
                                                               IntPtr context,
                                                               [In, Out] TangoService_onImageAvailable onImageAvailable);
Beispiel #20
0
 public static int TangoService_updateTexture(TangoEnums.TangoCameraId cameraId, ref double timestamp)
 {
     return(Common.ErrorType.TANGO_SUCCESS);
 }
Beispiel #21
0
 public static extern int TangoService_Experimental_connectTextureIdUnity(TangoEnums.TangoCameraId id,
                                                                          uint texture_y,
                                                                          uint texture_Cb,
                                                                          uint texture_Cr,
                                                                          IntPtr context,
                                                                          TangoService_onUnityFrameAvailable onUnityFrameAvailable);
Beispiel #22
0
 public static int TangoService_getCameraIntrinsics(
     TangoEnums.TangoCameraId cameraId, [Out] TangoCameraIntrinsics intrinsics)
 {
     return(Common.ErrorType.TANGO_SUCCESS);
 }
Beispiel #23
0
 public static int TangoService_connectTextureId(TangoEnums.TangoCameraId cameraId, int textureHandle)
 {
     return(Tango.Common.ErrorType.TANGO_SUCCESS);
 }
        /// <summary>
        /// Handle the callback sent by the Tango Service
        /// when a new image is sampled.
        /// </summary>
        /// <param name="cameraId">Camera identifier.</param>
        /// <param name="callbackContext">Callback context.</param>
        /// <param name="imageBuffer">Image buffer.</param>
        protected void _OnImageAvailable(IntPtr callbackContext,
    	                                 TangoEnums.TangoCameraId cameraId, 
    	                                 TangoImageBuffer imageBuffer)
        {
            m_previousCameraId = cameraId;

            if(m_previousImageBuffer.data == null)
            {
                m_previousImageBuffer.data = new byte[imageBuffer.width * imageBuffer.height * 2];
            }

            m_previousImageBuffer.width = imageBuffer.width;
            m_previousImageBuffer.height = imageBuffer.height;
            m_previousImageBuffer.stride = imageBuffer.stride;
            m_previousImageBuffer.timestamp = imageBuffer.timestamp;
            m_previousImageBuffer.format = imageBuffer.format;
            m_previousImageBuffer.frame_number = imageBuffer.frame_number;

            Marshal.Copy(imageBuffer.data, m_previousImageBuffer.data, 0, m_previousImageBuffer.data.Length);

            m_shouldSendEvent = true;
        }
Beispiel #25
0
 /// <summary>
 /// This will be called when a new frame is available from the camera.
 /// </summary>
 /// <param name="cameraId">Camera identifier.</param>
 /// <param name="imageBuffer">Tango camera image buffer.</param>
 public void OnTangoImageAvailableEventHandler(TangoEnums.TangoCameraId cameraId, TangoUnityImageData imageBuffer)
 {
     _ComputeDiffuseCoefficients(imageBuffer);
 }