HarmonyOS C++ Camera相关的接口,没看到跟设置帧率有关系的接口,ArkTS是有的?

如题:HarmonyOS C++ Camera相关的接口,没看到跟设置帧率有关系的接口,ArkTS是有的?

阅读 501
1 个回答

预览流不支持设置帧率,需要采集可以通过录像流VideoOutput设置系统所支持的帧率,参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/\_o\_h\_\_\_camera-V5\#oh\_cameramanager\_createvideooutput

https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/native-camera-recording-case-V5

Camera\_VideoProfile中设置帧率:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/\_camera\_\_\_video\_profile-V5

Camera_VideoOutput* CameraNdkUnitTest::CreateVideoOutput(int32_t width, int32_t height)
{
  uint32_t video_width = width;
  uint32_t video_height = height;
  Camera_Format format = (Camera_Format)CAMERA_FORMAT_RGBA_8888;
  Camera_OutputCapability* OutputCapability = new Camera_OutputCapability;
  Camera_ErrorCode ret = OH_CameraManager_GetSupportedCameraOutputCapability(cameraManager,
  cameraDevice, &OutputCapability);
  EXPECT_EQ(ret, CAMERA_OK);
  video_width = OutputCapability->videoProfiles[0]->size.width;
  video_height = OutputCapability->videoProfiles[0]->size.height;
  format = OutputCapability->videoProfiles[0]->format;
  delete OutputCapability;
  Camera_Size videoSize = {
  .width = video_width,
  .height = video_height
};
  Camera_FrameRateRange videoRange = {
  .min = 30,
  .max = 30
};
  Camera_VideoProfile videoProfile = {
  .format = format,
  .size = videoSize,
  .range = videoRange
};
  sptr<IConsumerSurface> videoSurface = IConsumerSurface::Create();
  sptr<IBufferProducer> videoProducer = videoSurface->GetProducer();
  sptr<Surface> pSurface = Surface::CreateSurfaceAsProducer(videoProducer);
  int64_t surfaceIdInt = videoProducer->GetUniqueId();
  string surfaceIdStr = std::to_string(surfaceIdInt);
  const char *surfaceId = nullptr;
  surfaceId = surfaceIdStr.c_str();
  SurfaceUtils::GetInstance()->Add(surfaceIdInt, pSurface);
  Camera_VideoOutput* videoOutput = nullptr;
  ret = OH_CameraManager_CreateVideoOutput(cameraManager, &videoProfile, surfaceId, &videoOutput);
  EXPECT_EQ(ret, CAMERA_OK);
  EXPECT_NE(videoOutput, nullptr);
  return videoOutput;
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进