本文介绍了检测记录的视频在机器人的方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让我的自定义的媒体播放器和视频需要的方向信息(检测它从前面或后面的相机记录)。 JPEG图像,我可以使用ExifInterface.TAG_ORIENTATION但对于视频我怎么能找到这些信息。

I want to make my custom media player and requires orientation info of video (for detecting it is recorded from front or back camera). for jpeg images i can use ExifInterface.TAG_ORIENTATION but for video how i can find this information.

我试图从视频文件中抓取帧,并将其转换成JPEG却又总是会提供方向0在所有情况下。

I tried to grab frame from video file and convert it into jpeg but again it always provides orientation 0 in all cases.

请帮忙提前me.Thanks。

Please help me.Thanks in advance.

推荐答案

在太多的努力,我才知道,媒体播放器提供的高度和宽度的视频文件,从中我们可以鳍片出视频的旋转。

After too much effort i came to know that media player provides height and width of video file from which we can fin out rotation of video.

MediaPlayer mp = new MediaPlayer();
  try {
      mp.setDataSource(viewSource);
      mp.prepare();
      mp.setOnVideoSizeChangedListener(new OnVideoSizeChangedListener() {
          @Override
          public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {

              int orientation = -1;

              if(width < height){
                  orientation = 0;
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);}
              else{
                  orientation = 1;
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);}

          }
      });
  } catch (IllegalArgumentException e) {
      e.printStackTrace();
  } catch (SecurityException e) {
      e.printStackTrace();
  } catch (IllegalStateException e) {
      e.printStackTrace();
  } catch (IOException e) {
      e.printStackTrace();
  }

这篇关于检测记录的视频在机器人的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 08:07