小编use*_*615的帖子

OpenCV相机定位问题

我有一个简单的项目,只用org.opencv.android.JavaCameraView显示相机.

我的问题是,默认情况下,相机处于横向模式,我无法更改此原因,我需要定义CameraBridgeViewBase而不是常规的相机意图.

这是我的代码的一部分:

XML代码:

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <org.opencv.android.JavaCameraView
                android:layout_width="fill_parent"
                android:layout_height="300dp"
                android:visibility="gone"
                android:id="@+id/HelloOpenCvView"
                opencv:show_fps="true"
                opencv:camera_id="1" />


        </LinearLayout>  

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >


            <Button
                android:id="@+id/BtnVideo"
                android:layout_marginLeft="2dp"
                android:layout_marginRight="2dp"                    
                android:layout_width="0dp"
                style="@style/button"
                android:layout_height="wrap_content"
                android:layout_weight="1.00"
                android:text="@string/videoBtn"
                android:textSize="18dip" />


        </LinearLayout>   
Run Code Online (Sandbox Code Playgroud)

Java代码:

 CameraBridgeViewBase mOpenCvCameraView;
    Button VideoButton;
 protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        overridePendingTransition(0, 0);

        VideoButton = (Button) this.findViewById(R.id.BtnVideo);

        VideoButton.setOnClickListener(onClickListener);

        mOpenCvCameraView= (CameraBridgeViewBase) findViewById(R.id.HelloOpenCvView);
        mOpenCvCameraView.setVisibility(SurfaceView.INVISIBLE);

    } 

        private OnClickListener onClickListener = new OnClickListener() {

            @Override
            public void onClick(View v) {
                    switch (v.getId()){

                        case R.id.BtnVideo:
                            if(mOpenCvCameraView.getVisibility() == SurfaceView.VISIBLE)
                            {
                                mOpenCvCameraView.setVisibility(SurfaceView.INVISIBLE);
                            } …
Run Code Online (Sandbox Code Playgroud)

android opencv android-orientation

14
推荐指数
4
解决办法
3万
查看次数

在SurfaceView上绘制矩形

我想知道如何在特定位置和大小绘制矩形.

我在这里和网上尝试了几个试验和例子,但没有任何对我有用.

我正在使用SurfaceView和SurfaceHolder来保存相机预览.

我只想在用户触摸屏幕时绘制一个矩形.

我不想使用外部库,当我试图从持有者那里获得画布时我得到了null.

现在没有代码,因为没有什么工作对我来说,如果有人知道怎么做,我会尝试.

这是我已经尝试过的:

链接1

链接2

链接3

感谢帮助!

surfaceview android-camera

7
推荐指数
1
解决办法
2万
查看次数

OpenGL ES 2不适用于Android API23

在我的应用程序中,我正在做一些图像像素操作.我的代码基于这个例子.

我所做的唯一改变是将其更改FRAGMENT_SHADER为灰度,它看起来像这样:

private static final String FRAGMENT_SHADER =
        "#extension GL_OES_EGL_image_external : require\n" +
        "precision mediump float;\n" +      // highp here doesn't seem to matter
        "varying vec2 vTextureCoord;\n" +
        "uniform samplerExternalOES sTexture;\n" +
        "void main() {\n" +
        "    vec4 tc = texture2D(sTexture, vTextureCoord);\n" +
        "    gl_FragColor.r = tc.r * 0.3 + tc.g * 0.59 + tc.b * 0.11;\n" +
        "    gl_FragColor.g = tc.r * 0.3 + tc.g * 0.59 + tc.b * 0.11;\n" +
        "    gl_FragColor.b = …
Run Code Online (Sandbox Code Playgroud)

android opengl-es opencv4android

6
推荐指数
1
解决办法
157
查看次数

如何使用基于Android上GLES30的glreadpixels从特定缓冲区读取数据

据我所知,GLES30没有更多的gl_FragColor缓冲区(我在这里看到)

由于我无法阅读"特殊变量",如何读取"out"缓冲区?

这是我的代码:

private static final String FRAGMENT_SHADER =
        "#version 300 es\n"+
        "#extension GL_OES_EGL_image_external_essl3 : require\n" +
        "precision mediump float;\n" +      // highp here doesn't seem to matter
        "in vec2 vTextureCoord;\n" +
        "uniform sampler2D sTexture;\n" +
        "out vec4 fragColor ;\n" +
        "void main() {\n" +
        "    vec4 tc = texture(sTexture, vTextureCoord);\n" +
        "    fragColor.r = tc.r * 0.3 + tc.g * 0.59 + tc.b * 0.11;\n" +
        "    fragColor.g = tc.r * 0.3 + tc.g * …
Run Code Online (Sandbox Code Playgroud)

android opengl-es

6
推荐指数
1
解决办法
398
查看次数

设置个人资料后,Android MediaRecorder崩溃了

我有一个问题是在Android上使用MediaRecorder将视频保存到SD卡.

我的代码工作,直到我到达将配置文件设置为高质量的行.

这是我的代码:

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        setContentView(R.layout.activity_sample_testing);
        // Show the Up button in the action bar.
        //setupActionBar();
        overridePendingTransition(0, 0);

        SurfaceView cameraView = (SurfaceView)findViewById(R.id.videoView1);

        holder = cameraView.getHolder();
        holder.addCallback(this);
        holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

        intentTestResults = new Intent(this, TestResultsAct.class);

        TestPB = (ProgressBar) findViewById(R.id.ProgressBarTest);

        new Thread(new Runnable() {

            @Override
            public void run() {
                while(mProgressStatus < 100){
                    if(mProgressStatus == 1)
                        record();
                    if(mProgressStatus == 35)
                        record();
                    mProgressStatus += 1;
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    mHandler.post(new …
Run Code Online (Sandbox Code Playgroud)

android android-mediarecorder

5
推荐指数
1
解决办法
5148
查看次数

线性布局不适合屏幕尺寸

为什么滚动视图中的线性布局不适合屏幕尺寸?我试图用"Layout_Height"进行一些更改,但没有成功.

这是我的XML代码:

感谢帮助!

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollViewPhysicalExam"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/background"
        android:orientation="vertical" >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            style="@style/HeaderText"
            android:orientation="vertical" >
    <!-- ++++++++++++++++++ Row18 ++++++++++++++++++ -->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" >                  
                <Button
                    android:id="@+id/btnBack"
                    android:text="@string/Back"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1.00"
                    android:textSize="15dip" />
                <Button
                    android:id="@+id/btnSave"
                    android:text="Save"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1.00"
                    android:textSize="15dip" />
            </LinearLayout>

    <!-- +++++++++++++++++++++++++++++++++++++++++++ -->
        </LinearLayout>
    </LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

android android-linearlayout

2
推荐指数
1
解决办法
3465
查看次数

在JavaScript上设置图像背景到形状

我想采用这个例子,将每个精子的颜色改为图像.

在示例中,他们将所有精子染成白色,我想要放置一个图像.

我怎样才能做到这一点?

我有android应用程序,我应该添加脚本,所以我在Eclipse上工作,我将图像保存在资产文件夹中.

如果我将背景更改为图像效果很好,但每次尝试更改精子背景都不适合我.

感谢帮助!

编辑1:

这是尝试在CSS中做到这一点:

ellipse {
    background-image:url('head.png');
    background-repeat: no-repeat;
    background-size: cover;
}
Run Code Online (Sandbox Code Playgroud)

这是尝试在脚本中执行此操作

var head = g.append("ellipse")
    .attr("rx", 26.5)
    .attr("ry", 24)
    .attr("xlink:href", "/assets/head.png");
Run Code Online (Sandbox Code Playgroud)

html javascript css

2
推荐指数
1
解决办法
383
查看次数