TF-Unity-ARFoundation icon indicating copy to clipboard operation
TF-Unity-ARFoundation copied to clipboard

NullReferenceException of Texture on RunTF function in cameracontroller (Android)

Open Bricktheworld opened this issue 6 years ago • 5 comments

I get a null reference exception when trying to run this code. Here is the error:

NullReferenceException: Object reference not set to an instance of an object 06-09 06:39:28.025 18910 18967 E Unity : at CameraController.RunTF (UnityEngine.Texture2D texture) [0x00001] in C:\Users\Brand\Desktop\TF-Unity-ARFoundation-master\Assets\Scripts\CameraController.cs:157 06-09 06:39:28.025 18910 18967 E Unity : at CameraController.OnCameraFrameReceived (UnityEngine.XR.ARFoundation.ARCameraFrameEventArgs eventArgs) [0x0012d] in C:\Users\Brand\Desktop\TF-Unity-ARFoundation-master\Assets\Scripts\CameraController.cs:109 06-09 06:39:28.073 18910 18967 E Unity : at CameraController.OnCameraFrameReceived (UnityEngine.XR.ARFoundation.ARCameraFrameEventArgs eventArgs) [0x0012d] in C:\Users\Brand\Desktop\TF-Unity-ARFoundation-master\Assets\Scripts\CameraController.cs:109

any idea why the texture is not being referenced correctly?

Bricktheworld avatar Jun 09 '19 13:06 Bricktheworld

Hello, texture should be created at this line. Can you please set a breakpoint at the if condition? https://github.com/shaqian/TF-Unity-ARFoundation/blob/master/Assets/Scripts/CameraController.cs#L85

        if (m_Texture == null || m_Texture.width != image.width || m_Texture.height != image.height)
            m_Texture = new Texture2D(image.width, image.height, format, false);

shaqian avatar Jun 11 '19 12:06 shaqian

Are you able to see the camera preview on the phone or a black screen?

shaqian avatar Jun 11 '19 12:06 shaqian

Hi I am also getting the same error please help me out

Unity version -- 2018.3.11 Android version 8.0

using SSD model for object detection

Here is the log coco_labels_list.txt

09-11 15:58:55.342 30766 30810 I Unity : SystemInfo CPU = ARMv7 VFPv3 NEON, Cores = 8, Memory = 1799mb 09-11 15:58:55.343 30766 30810 I Unity : SystemInfo ARM big.LITTLE configuration: 4 big (mask: 0xf), 4 little (mask: 0xf0) 09-11 15:58:55.343 30766 30810 I Unity : ApplicationInfo com.vaya.arapple version 0.1 build e90a0950-6074-43e6-b417-19cd7e291941 09-11 15:58:55.344 30766 30810 I Unity : Built from '2018.3/staging' branch, Version '2018.3.11f1 (5063218e4ab8)', Build type 'Release', Scripting Backend 'mono', CPU 'armeabi-v7a' 09-11 15:58:56.009 30766 30810 D Unity : GL_EXT_debug_marker GL_ANDROID_extension_pack_es31a GL_EXT_blend_minmax GL_EXT_buffer_storage GL_EXT_clear_texture GL_EXT_color_buffer_float GL_EXT_conservative_depth GL_EXT_copy_image GL_EXT_discard_framebuffer GL_EXT_draw_buffers GL_EXT_draw_buffers_indexed GL_EXT_draw_elements_base_vertex GL_EXT_float_blend GL_EXT_geometry_point_size GL_EXT_geometry_shader GL_EXT_gpu_shader5 GL_EXT_multi_draw_arrays GL_EXT_multisampled_render_to_texture GL_EXT_occlusion_query_boolean GL_EXT_polygon_offset_clamp GL_EXT_primitive_bounding_box GL_EXT_pvrtc_sRGB GL_EXT_read_format_bgra GL_EXT_robustness GL_EXT_separate_shader_objects GL_EXT_shader_framebuffer_fetch GL_EXT_shader_group_vote GL_EXT_shader_io_blocks GL_EXT_shader_non_constant_global_initializers GL_EXT_shader_pixel_local_storage GL_EXT_shader_pixel_local_storage2 GL_EXT_shader_texture_lod GL_EXT_sparse_texture GL_EXT_sRGB_write_control GL_EXT_tessellation_point_size GL_EXT_tessellation_shader GL_EXT_texture_border_clamp GL_EXT_texture_buffer GL_EXT_texture_cube 09-11 15:58:56.009 30766 30810 D Unity : _map_array GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_EXT_texture_sRGB_decode GL_EXT_texture_sRGB_R8 GL_EXT_texture_sRGB_RG8 GL_EXT_YUV_target GL_IMG_bindless_texture GL_IMG_framebuffer_downsample GL_IMG_multisampled_render_to_texture GL_IMG_program_binary GL_IMG_read_format GL_IMG_shader_binary GL_IMG_texture_compression_pvrtc GL_IMG_texture_compression_pvrtc2 GL_IMG_texture_format_BGRA8888 GL_IMG_texture_npot GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_KHR_debug GL_KHR_robustness GL_KHR_texture_compression_astc_ldr GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth24 GL_OES_depth_texture GL_OES_draw_buffers_indexed GL_OES_draw_elements_base_vertex GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_image_external_essl3 GL_OES_EGL_sync GL_OES_element_index_uint GL_OES_fragment_precision_high GL_OES_geometry_point_size GL_OES_geometry_shader GL_OES_get_program_binary GL_OES_gpu_shader5 GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES 09-11 15:58:56.009 30766 30810 D Unity : _required_internalformat GL_OES_rgb8_rgba8 GL_OES_sample_shading GL_OES_sample_variables GL_OES_shader_image_atomic GL_OES_shader_io_blocks GL_OES_shader_multisample_interpolation GL_OES_standard_derivatives GL_OES_surfaceless_context GL_OES_tessellation_point_size GL_OES_tessellation_shader GL_OES_texture_border_clamp GL_OES_texture_buffer GL_OES_texture_cube_map_array GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_npot GL_OES_texture_stencil8 GL_OES_texture_storage_multisample_2d_array GL_OES_vertex_array_object GL_OES_vertex_half_float GL_OVR_multiview GL_OVR_multiview2 GL_OVR_multiview_multisampled_render_to_texture 09-11 15:58:59.930 30766 30810 E Unity : Unable to find libtensorflow 09-11 15:59:00.322 30766 30810 E Unity : NullReferenceException: Object reference not set to an instance of an object 09-11 15:59:00.322 30766 30810 E Unity : at Detector..ctor (UnityEngine.TextAsset modelFile, UnityEngine.TextAsset labelFile, DetectionModels model, System.String input, System.String output, System.Int32 height, System.Int32 width, System.Single mean, System.Single std, System.Int32 blockSize, System.Int32 numBoxesPerBlock, System.Double[] anchors) [0x0002e] in :0 09-11 15:59:00.322 30766 30810 E Unity : at CameraController.InitTF () [0x00000] in :0 09-11 15:59:00.322 30766 30810 E Unity : at CameraController.OnEnable () [0x0001c] in :0 09-11 15:59:00.322 30766 30810 E Unity :
09-11 15:59:00.322 30766 30810 E Unity : (Filename: Line: 0) 09-11 15:59:00.322 30766 30810 E Unity :

jahnavim-prog avatar Sep 11 '19 10:09 jahnavim-prog

I am using ssd_mobilenet_v1_android_export.bytes file for model

jahnavim-prog avatar Sep 11 '19 11:09 jahnavim-prog

@Bricktheworld @jahnavim-prog Hi, have you managed to solve your issues? I'm getting a black screen when pressing play button.

AnaRhisT94 avatar Oct 20 '19 17:10 AnaRhisT94