• 星瞳AI VISION软件内测!可以离线标注,训练,并生成OpenMV的模型。可以替代edge impulse https://forum.singtown.com/topic/8206
  • 我们只解决官方正版的OpenMV的问题(STM32),其他的分支有很多兼容问题,我们无法解决。
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 能否提供android的MJpegViewer源码参考,自己写的源码出现了问题,找不到思路



    • 手动@技术人员kidswong999



    • package com.cyk.OpenMvViewModel;

      import java.io.InputStream;
      import java.net.HttpURLConnection;
      import java.net.URL;

      import android.app.Activity;
      import android.content.pm.ActivityInfo;
      import android.graphics.Bitmap;
      import android.graphics.BitmapFactory;
      import android.graphics.Canvas;
      import android.graphics.Color;
      import android.graphics.RectF;
      import android.os.Bundle;
      import android.util.Log;
      import android.view.SurfaceHolder;
      import android.view.Window;
      import android.view.SurfaceHolder.Callback;
      import android.view.SurfaceView;
      import com.cyk.decktop.R;

      public class OpenMvConnect extends Activity implements Runnable{

      private final String TAG = "OpenMvConnect";
      private SurfaceHolder holder;
      private Thread mythread;
      private Canvas canvas;
      URL videoUrl;
      private String url;
      private int w;
      private int h;
      HttpURLConnection conn;
      Bitmap bmp;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          requestWindowFeature(Window.FEATURE_NO_TITLE);
          setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      
          url = "http://192.168.247.2:8080/";
      
          w = getWindowManager().getDefaultDisplay().getWidth();
          h = getWindowManager().getDefaultDisplay().getHeight();
      
          SurfaceView surface = (SurfaceView)findViewById(R.id.surface);
      
          surface.setKeepScreenOn(true);// 保持屏幕常亮
          mythread = new Thread(this);
          holder = surface.getHolder();
          holder.addCallback(new Callback() {
      
              @Override
              public void surfaceDestroyed(SurfaceHolder holder) {
                  // TODO Auto-generated method stub
      
              }
      
              @Override
              public void surfaceCreated(SurfaceHolder holder) {
                  // TODO Auto-generated method stub
                  mythread.start();
              }
      
              @Override
              public void surfaceChanged(SurfaceHolder holder, int format, int width,
                                         int height) {
                  // TODO Auto-generated method stub
      
              }
          });
          mythread.start();
      }
      private void draw() {
          // TODO Auto-generated method stub
          try {
              InputStream inputstream = null;
              videoUrl=new URL(url);
              //利用HttpURLConnection对象从网络中获取网页数据
              conn = (HttpURLConnection)videoUrl.openConnection();
              //设置输入流
              conn.setDoInput(true);
              //连接
              conn.connect();
              //得到网络返回的输入流
              inputstream = conn.getInputStream();
              //创建出一个bitmap
              bmp = BitmapFactory.decodeStream(inputstream);
              canvas = holder.lockCanvas();
              canvas.drawColor(Color.WHITE);
              RectF rectf = new RectF(0, 0, w, h);
              canvas.drawBitmap(bmp, null, rectf, null);
              holder.unlockCanvasAndPost(canvas);
              //关闭HttpURLConnection连接
              conn.disconnect();
          } catch (Exception ex) {
          } finally {
          }
      }
      
      @Override
      public void run() {
          // TODO Auto-generated method stub
          Log.d(TAG,"OpenMvConnect:run");
          while(true){
              draw();
          }
      }
      
      public void startActivity() {
      }
      

      }



    • 这是我在网上找到的代码,修改了url后,openmv连接显示的IP地址并不对



    • 没有安卓的代码参考。

      你直接建一个webview就行了。