【问题标题】:TangoService_connectOnFrameAvailable() gets stuck or crashes using Google Tango Leibniz Release 1.10TangoService_connectOnFrameAvailable() 使用 Google Tango Leibniz 1.10 版卡住或崩溃
【发布时间】:2015-04-24 02:53:52
【问题描述】:

在 Leibniz Release 1.10 中似乎也存在关于接收彩色帧的问题:当使用注册回调时 TangoService_connectOnFrameAvailable(TANGO_CAMERA_COLOR,NULL,onFrameAvailable) 回调 onFrameAvailable() 将永远不会被调用或 TangoService_connectOnFrameAvailable() 崩溃并出现以下错误:

04-20 13:29:44.384: E/tango_client_api(4712): TangoErrorType TangoService_connectOnFrameAvailable(TangoCameraId,无效*,无效 ()(void, TangoCameraId, const TangoImageBuffer*)):内部错误: connectSurface(),cam id 0,内部失败。

发行说明说

[...] config_enable_color_camera 已添加到配置标志中。如果访问彩色相机,我们建议您始终将此标志明确设置为 true。您必须将标志设置为 true TangoService_connectOnFrameAvailable() 或 TangoService_connectTextureId() 成功后 TangoService_connect() 被调用。 [...]

因此,如果我在TangoService_connect()TangoService_connectOnFrameAvailable() 的调用之间将该标志设置为true,则回调onFrameAvailable() 将永远不会被调用,如果我在TangoService_connect() TangoService_connectOnFrameAvailable() 之前将该标志设置为true 将总是崩溃。

那么,我做错了什么?是否有可用的代码 sn-p 或什么?这真的很有帮助...不幸的是,这些示例都没有使用彩色框架...

伙计,在 Kalman Release 1.9 遇到类似问题后,我开始怀疑 SDK 在发布之前是否经过了彻底的测试...

【问题讨论】:

  • 好的,这个版本开始闻起来像昨天的鱼 - 所有一直低着头的人都出现了问题:=(我还没有整合这些变化,但我已经阅读您拥有的相同内容,我只能(微弱地)建议您非常仔细地查看回调绑定,以确保非常确定。您对示例很了解,简单的 GitHub 搜索证明了这一点。至于您的最后一点,我已经因为这种行为解雇了一些人。
  • 抱歉,您遇到了问题。这还在发生吗?我之所以这么问,是因为在 PlayStore 上更新 TangoCore 和 OTA 退出之间存在一些时间间隔(如果 OTA 和 TangoCore 不匹配,这可能会导致这个问题)。我只是想在诊断之前确保您在 TangoCore 和 OTA 上都进行了更新。另外,请确保您在 android manifestl 中拥有相机权限。
  • 嗯,在我的 Tango 平板电脑上,实际上存在您所说的 OTA 和 TangoCore 之间的不匹配......在再次仔细更新所有内容后,我终于能够绑定回调......谢谢很多...对于那些对如何将 NV21 转换为 RGB 框架感兴趣的人,我在下面附上我的代码...

标签: android c++ google-project-tango


【解决方案1】:

好吧,假设问题不是我在 cmets 部分中提到的。这是测试 onFrameAvailable 回调的代码 sn-p。

注意:我已经为此修改了 Tango-examples-c 存储库中的 HelloTangoJni Example

在 TangoHandler.h 中添加

 TangoErrorType ConnectYUVFrameCallback();

修改 TangoHandler.cc

TangoErrorType TangoHandler::SetupConfig() {
  // TANGO_CONFIG_DEFAULT is enabling Motion Tracking and disabling Depth
  // Perception.
  tango_config_ = TangoService_getConfig(TANGO_CONFIG_DEFAULT);
  if (tango_config_ == nullptr) {
  return TANGO_ERROR;
  }
  TangoConfig_setBool(tango_config_,"config_enable_color_camera",true);
  return TANGO_SUCCESS;
}


TangoErrorType TangoHandler::ConnectYUVFrameCallback() {
    TangoErrorType onFrameErrorType=TangoService_connectOnFrameAvailable( TANGO_CAMERA_COLOR, NULL, onFrameAvailable);
    if( onFrameErrorType!= TANGO_SUCCESS)
    {
         LOGI("GOOGLE TANGO ONFRAMEAVAILABLE FAILED!");
    }
    LOGI("GOOGLE TANGO ONFRAMEAVAILABLE SUCCESS!");
    return onFrameErrorType;
}

static void onFrameAvailable( void* context, const TangoCameraId id, const TangoImageBuffer* buffer )
{
  int width = buffer->width;
  int height = buffer->height;
  LOGI("width and height is: %d,%d",width,height);
}

在 TangoNative.cc 中添加

JNIEXPORT jint JNICALLJava_com_projecttango_experiments_nativehellotango_TangoJNINative_connectOnFrameAvailableCallback(
JNIEnv*, jobject) 
{
    return static_cast<int>(tango_handler.ConnectYUVFrameCallback());
}

在 TangoJNINative.java 中添加

// Connect the onFrameAvailable callback.
public static native int connectOnFrameAvailableCallback();

在 HelloTangoActivity.java 中修改 onResume()

protected void onResume() {
   super.onResume();
   // Setup Tango configuraturation.
   TangoJNINative.setupConfig();
   int status = 0;
   TangoJNINative.connect();
   status = TangoJNINative.connectOnFrameAvailableCallback();
   mIsTangoServiceConnected = true;
}

【讨论】:

    【解决方案2】:

    这是我将 NV21 转换为 RGB 帧的代码。也许它有什么用......

    static void
      cb_onFrameAvailable
      (
        void*                     contextA,
        TangoCameraId             idA,
        const TangoImageBuffer*  imageBufferA
      )
    {
      // --- local constants ------------------------------
    
      // image width and height
      const int W               = imageBufferA->width;
      const int H               = imageBufferA->height;
    
      // sizes of Y, U, and V pixel arrays.
      const int sizeOfYDataL   = W * H;
    
      // indices, marking the begin of the y, u, and v data in the pixel buffer.
      const int beginOfYDataL  = 0;
      const int beginOfUVDataL  = sizeOfYDataL;
    
      // YUV, Y, and UV pixel sub arrays.
      const byte*  yuvArrL     = imageBufferA->data;
      const byte*  yArrL       = &yuvArrL[ beginOfYDataL  ];
      const byte*  uvArrL      = &yuvArrL[ beginOfUVDataL ];
    
      // --- local variables ------------------------------
    
      // image pixel coordinates.
      int xL,yL;
    
      // halved image pixel coordinates.
      int hxL,hyL;
    
      // ARGB value.
      int argbL;
    
      // --------------------------------------------------
    
      // translate YUV NV21 -> ARGB, using
      //
      //      / R \   / 1.000   0.000   1.596 \   /   Y   \
      //      | G | = | 1.000  -0.391  -0.813 | * | U-128 |
      //      \ B /   \ 1.000   2.018   0.000 /   \ V-128 /
      //
    
      // Note: start value yL=1 as the first scan line of the color image is ..
      //       .. reserved for metadata instead of image pixels.
    
      for( yL=1,hyL=0; yL<H; yL++,hyL=yL>>1 )
      {
        for( xL=0,hxL=0; xL<W; xL++,hxL=xL>>1 )
        {
          const int y = static_cast<int>( yArrL [  yL*W +    xL   ] )      ;
          const int v = static_cast<int>( uvArrL[ hyL*W + 2*hxL   ] ) - 128;
          const int u = static_cast<int>( uvArrL[ hyL*W + 2*hxL+1 ] ) - 128;
    
          int R = static_cast<int>( y               + ( 1.596f*v) );
          int G = static_cast<int>( y + (-0.391f*u) + (-0.813f*v) );
          int B = static_cast<int>( y + ( 2.018f*u)               );
    
          // clip RGB values to [0..255].
          R = R < 0 ? 0 : (R > 255 ? 255 : R);
          G = G < 0 ? 0 : (G > 255 ? 255 : G);
          B = B < 0 ? 0 : (B > 255 ? 255 : B);
    
          // combine to ARGB value.
          argbL = 0xff000000 | (R << 16) | (G << 8) | B;
        } // for
      } // for
    } // function
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-22
      • 2018-05-06
      • 1970-01-01
      • 1970-01-01
      • 2014-02-01
      相关资源
      最近更新 更多