Ask Your Question

Marde's profile - activity

2019-04-09 03:19:30 -0600 received badge  Popular Question (source)
2014-02-03 09:21:05 -0600 asked a question How to draw lines on OpenCV Camera Preview?

Im using OpenCV camera preview.

I want to draw a rectangle over the live preview. Ive tried to override the ondraw method, but I cant see a line. Please help.

import org.opencv.android.JavaCameraView;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;

public class CustomOpenCVJavaCameraView extends JavaCameraView {

    public CustomOpenCVJavaCameraView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private Paint linePaint;
    protected void init() { 
        Resources r = this.getResources();
        linePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        linePaint.setAlpha(200);
        linePaint.setStrokeWidth(1);
        linePaint.setStyle(Paint.Style.STROKE);
        linePaint.setColor(r.getColor(R.color.marker_color));
        linePaint.setShadowLayer(2, 1, 1, r.getColor(R.color.shadow_color));        
    }

    @Override
      protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);       
        linePaint.setStrokeWidth(5);
        canvas.drawLine(10,20,1000,200,linePaint);
    }
}
2013-05-15 06:30:10 -0600 commented answer OpenCV android camera preview with custom layout?

Ok thanks. I keep it in mind if I need it again. Its just I thought about how to get an ad banner to an opencv view. But it seems those Ad banner could just be overlayed.

2013-05-15 06:11:51 -0600 received badge  Supporter (source)
2013-05-15 06:09:58 -0600 commented answer JavaCameraView terrible on OpenCV above 2.4.3

Thank you very much for your answer. Its a good idea, and Im glad anyone answering. But unfortunately its not the solution. I testet it in both versions and even with the lowest resolution possible its still terrible with version 2.4.5. With 2.4.3. theres no problem even with higher resolution.

So it must be something else. I really hope the developers will fix this.

2013-05-15 02:08:05 -0600 asked a question JavaCameraView terrible on OpenCV above 2.4.3

I already asked that question, but without response. So Im gonna ask again and make the problem clearer this time, so everybody should be able to reproduce it.

If Im running "OpenCV Tutorial 5 - CameraControl" which can be found in the samples from the OpenCV 2.4.3 release everything is fine, that means, the JavaCameraPreview is smooth and looks as good as the NativeCameraView or the standard app camera preview that comes with my phone to take pictures.

But if Im now running "OpenCV Tutorial 3 - CameraControl" which can be found in the samples from the OpenCV 2.4.5 release, the CameraPreview now looks horrible. Its slow and blury and it stutters and it hurts to see it.

I dont want to start speculating what could be going wrong, because I really dont know it. But it should be possible for some of you to tell me if your having the same problen with it.

Maybe its a bug and it would be a good idea if some developer realize that problem if they already didn't.

2013-05-15 01:51:40 -0600 received badge  Editor (source)
2013-05-08 19:41:01 -0600 asked a question OpenCV android camera preview with custom layout?

I want to add a button to the opencvcamera preview, but the button isnt visible and the Preview still fills the whole screen. Is there a way to make a custom layout where the OpenCV camera preview does not fill the whole scrren to display an additional button?

 <LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:opencv="http://schemas.android.com/apk/res-auto"

        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="horizontal">

        <org.opencv.android.NativeCameraView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone"
            android:id="@+id/HelloOpenCvView"
            opencv:show_fps="true"
            opencv:camera_id="any" />

       <Button
        android:id="@+id/takepicture"  
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text=" * Take Picture " 
        android:layout_gravity="bottom|right"
        android:layout_margin="10px"
        />

     </LinearLayout >
2013-05-08 18:17:44 -0600 asked a question opencv 2.4.4 slow Java Camera on Android (bug)?

Im using OpenCV on my Xperia Mini St15i Android device. With version 2.4.3 theres no difference between using NativeCameraView and JavaCameraView in the camera preview. But with version 2.4.4 and 2.4.5 JavaCameraView is now really slow and blury in comparison to NativeCameraView, regardless if Im using CvCameraViewListener or CvCameraViewListener2.

Could it be this is a bug?

Anyway can I use the NativeCameraView like a normal JavaCameraPreview with setting autofocus callback, setting camera parameters and all that stuff? And if so wheres the difference between Java and Native camera?

Thanks