OpenCV4Android

时间:2015-10-04 12:37:50

标签: android opencv image-processing

我尝试通过点击屏幕获得投资回报率。这是发生错误的部分。

@Override
    public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
        Mat rgba = inputFrame.rgba();
        Mat roi_mat = new Mat();

        if (startX!=0 && endX!=0){
            //Toast.makeText(this, "start:"+start_point+"   end:"+end_point, Toast.LENGTH_SHORT).show();
            Core.rectangle(rgba,start_point,end_point,border_colour,0,8, 0 );
            roi_rect = new Rect(startX,startY,(endX-startX),(endY-startY));
            Mat roi_mat_ref = new Mat(rgba,roi_rect);
            roi_mat_ref.copyTo(roi_mat);
            //rgba.copyTo(roi_mat);

        }
        return rgba;
    }

运行应用程序时一切正常。但是,当我想获得投资回报率时,它会显示错误。

  

10-04 20:19:18.754 6794-6859 / com.example.tew.roi E / cv :: error():OpenCV错误:断言失败(0< = _rowRange.start&& _rowRange。 cv :: Mat :: Mat(const cv :: Mat&,const cv :: Range&,const cv :: Range& amp; amp;& ),文件/home/reports/ci/slave_desktop/50-SDK/opencv/modules/core/src/matrix.cpp,第284行

     

10-04 20:19:18.755 6794-6859 / com.example.tew.roi E / org.opencv.core.Mat:mat :: n_1Mat__JIIII()抓住了cv ::异常:/ home / reports / ci /slave_desktop/50-SDK/opencv/modules/core/src/matrix.cpp:284:错误:(-215)0< = _rowRange.start&& _rowRange.start< = _rowRange.end&& _rowRange.end< = m.rows in function cv :: Mat :: Mat(const cv :: Mat&,const cv :: Range&,const cv :: Range&)

     

10-04 20:19:18.755 6794-6859 / com.example.tew.roi W / dalvikvm:threadid = 11:线程退出未捕获的异常(group = 0x40fbf258)

     

10-04 20:19:18.756 6794-6859 / com.example.tew.roi E / AndroidRuntime:FATAL EXCEPTION:Thread-3348

     

CvException [org.opencv.core.CvException:cv :: Exception:/home/reports/ci/slave_desktop/50-SDK/opencv/modules/core/src/matrix.cpp:284:error:(215 )0< = _rowRange.start&& _rowRange.start< = _rowRange.end&& _rowRange.end< = m.rows in function cv :: Mat :: Mat(const cv :: Mat&,const cv :: Range&,const cv :: Range&)       ]

     

at org.opencv.core.Mat.n_Mat(原生方法)

     

at org.opencv.core.Mat。(Mat.java:676)

     

at com.example.tew.roi.MainActivity.onCameraFrame(MainActivity.java:154)

     

at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:387)

     

at org.opencv.android.JavaCameraView $ CameraWorker.run(JavaCameraView.java:346)

     

在java.lang.Thread.run(Thread.java:856)

This is my full coding.

1 个答案:

答案 0 :(得分:-1)

调整EndX-StartX值似乎对我有用。在将其发送到Mat之前,您可以尝试减少它。