小编Tap*_*tro的帖子

我们可以在xml中为android背景制作多色渐变吗?

我一直在尝试用XML创建一个多色背景,但只有3个选项可用的开始,中心,结束和指定角度.我们不能在下面制作这样的背景..不同角度的多色

不同角度的多色

我们能在android中做出这样的背景吗?

java xml android background image

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

在Android中裁剪检测到的脸部

我需要的:

从图像中裁剪出唯一的面孔。

我做了什么:

https://github.com/blundell/FaceDetectionTutorialWithPreview

用这种方式或用

https://github.com/googlesamples/android-vision

两种方式都可以检测到人脸。但是我无法裁剪检测到的人脸。

我尝试过

Matrix matrix = new Matrix();

        RectF sourceRect = null , destRect = null;

        for (Camera.Face f : mFaces) {

            // Draws a circle at the position of the detected face, with the face's track id below.
            float x = translateX(f.rect.centerX() + f.rect.width() / 2);
            float y = translateY(f.rect.centerY() + f.rect.height() / 2);
            //canvas.drawCircle(x, y, FACE_POSITION_RADIUS, mFacePositionPaint);
            //  canvas.drawText("id: " + mFaceId, x + ID_X_OFFSET, y + ID_Y_OFFSET, mIdPaint);
            // canvas.drawText("happiness: " + …
Run Code Online (Sandbox Code Playgroud)

android crop face-detection

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

使用 Web(Html css) 和 Python 进行人脸检测

我对网络技术很陌生。我正在制作一个集成了人脸检测的聊天机器人,尽管我知道如何使用 python 及其库与其他作品一起工作,但我在加载页面时遇到了问题

需求:web上的人脸检测,目前我们可以将其称为localhost。因此,为此,我准备了 OpenCV Harcascade 文件,并且检测部分也在发生。示例下面的图像和代码用于 web 和 pyton。

错误:通过单击 Weblink,python 烧瓶导航将进入挂起状态。

在此处输入图片说明

正如您在此处看到的那样,人脸检测正在运行,但是当我单击“收集我的图像”链接时,它会永远加载。请帮忙解决这个问题。

html代码:

<!DOCTYPE html>
<html>
<head>
    <title>Video Stream</title>
    <!-- <link rel="stylesheet" href="templates/css/main.css"> -->
</head>
<body>

<h2>ChatBot</h2>
<p >{{ alert }}</p>

<div class="container">
  <img class="bottomright" class="center" style="width: 500px;height: 300px;"src="{{ url_for('video_feed') }}">
  <div class="col-md-6 col-sm-6 col-xs-6"> <a href="/exec2" class="btn btn-sm animated-button victoria-one">Collect My Images</a> </div>
</div>  
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

Python Main.py 类:-

from flask import Flask, render_template, Response
from camera import VideoCamera
# import create_data

app = Flask(__name__) …
Run Code Online (Sandbox Code Playgroud)

html python opencv python-webbrowser flask-restful

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

如何在片段中保存Recyclerview的滚动位置

我从这里得到了很多答案..但是没有一个答案解决我的问题..这就是为什么我要问。

我想将滚动位置保存在一个片段中。他们在很多文章中建议遵循

@Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
    }
Run Code Online (Sandbox Code Playgroud)

@Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
    }
Run Code Online (Sandbox Code Playgroud)

但是这两种方法并不是一成不变的。

我的代码:

private int mPositionIng = RecyclerView.NO_POSITION;

private String KEY_POSITION_ING = "KeyPositionIng";
Run Code Online (Sandbox Code Playgroud)

在OnCreateView()中

if (savedInstanceState != null) {

            if (savedInstanceState.containsKey(KEY_POSITION_ING)) {
                mPositionIng = savedInstanceState.getInt(KEY_POSITION_ING);
            }
}
Run Code Online (Sandbox Code Playgroud)

片段中的重写方法与上面的方法不同。我不知道我在哪里做错了。

@Override
    public void onSaveInstanceState(Bundle outState) {

        int scrollPositionIng = mRecyclerViewIngredients.computeVerticalScrollOffset();

        mPositionIng = scrollPositionIng;

        outState.putInt(KEY_POSITION_ING, mPositionIng);
        super.onSaveInstanceState(outState);
    }

@Override
    public void onViewStateRestored(@Nullable Bundle savedInstanceState) {

        if (mPositionIng != RecyclerView.NO_POSITION) {

            mRecyclerViewIngredients.getLayoutManager().scrollToPosition(mPositionIng);
        }


        super.onViewStateRestored(savedInstanceState);
    }
Run Code Online (Sandbox Code Playgroud)

我只需要在方向更改时保存滚动位置即可。任何建议将全程帮助您。谢谢......

android position android-recyclerview

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