小编Har*_*aki的帖子

创建自定义初始时的tensorflow.python.framework.errors_impl.NotFoundError

我使用以下代码使用tensorflow创建自定义初始化.

import tensorflow as tf
import sys

interesting_class = sys.argv[1:]
print("Interesting class: ", interesting_class)

# Read in the image_data

from os import listdir
from shutil import copyfile
from os.path import isfile, join
varPath = 'toScan/'
destDir = "scanned/"
imgFiles = [f for f in listdir(varPath) if isfile(join(varPath, f))]


# Loads label file, strips off carriage return
label_lines = [line.rstrip() for line 
                   in tf.gfile.GFile("/tf_files/retrained_labels.txt")]

# Unpersists graph from file
with tf.gfile.FastGFile("/tf_files/retrained_graph.pb", 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    _ = tf.import_graph_def(graph_def, …
Run Code Online (Sandbox Code Playgroud)

python machine-learning tensorflow

10
推荐指数
1
解决办法
6171
查看次数

在实时视频中统计人数

我使用以下代码从早到晚计算实时网络摄像头的人数

people_list = []

while True:
    _, frame = video_capture.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    faces = faceCascade.detectMultiScale(gray, 1.3, 5)

    detections = faceCascade.detectMultiScale(gray, 1.15, 5)

    for i in range(len(detections)):
        face_i = detections[i]
        x, y, w, h = face_i

        cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 222, 0), 1)
        font = cv2.FONT_HERSHEY_SIMPLEX
        people_list.insert(len(people_list)+1,i)

        cv2.putText(frame, "id: "+str ( people_list[i]), (x, y), font, 2, (255, 255, 255), 2, cv2.LINE_AA)

    # Display the resulting frame
    cv2.imshow('Video', frame)
Run Code Online (Sandbox Code Playgroud)

每次检测到新面孔时,people_list计数都会增加.但是,每个帧而不是每个新面都会增加people_list计数.我怎样才能解决这个问题?

python webcam opencv face-detection

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

更改uibutton的文本大小不起作用

我在故事板上创建了一个按钮,我正在尝试以编程方式设置字体大小和字体样式,如下所示:

_login.titleLabel.textColor = [UIColor whiteColor];
_login.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[_login.titleLabel setFont:[UIFont boldSystemFontOfSize:13.f]];
[_login setBackgroundColor:[UIColor purpleColor]];
Run Code Online (Sandbox Code Playgroud)

但按钮文本大小保持不变.我错过了什么吗?

objective-c uibutton ios

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

NSInvalidArgumentException,同时将图像保存到相册

我正在尝试下载图像文件并将其保存到照片相册,如下所示

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSLog(@"Downloading Started");
        NSString *urlToDownload = @"http://wallpapercave.com/wp/66iglE0.jpg";
        NSURL  *url = [NSURL URLWithString:urlToDownload];

        NSData *urlData = [NSData dataWithContentsOfURL:url];

        if ( urlData )
        {
            NSArray  *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
            NSString  *documentsDirectory = [paths objectAtIndex:0];
            NSString  *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"filename.jpg"];
            dispatch_async(dispatch_get_main_queue(), ^{
                [urlData writeToFile:filePath atomically:YES];
                NSLog(@"File Saved !");
                NSData *retrievedData = [NSData dataWithContentsOfFile:filePath];
               ;


                dispatch_async(dispatch_get_main_queue(), ^{
                    UIImageWriteToSavedPhotosAlbum( [UIImage imageWithData:retrievedData],
                                                   self,
                                                   @selector(done),
                                                   NULL);                });
            });
        } else {
            dispatch_async(dispatch_get_main_queue(), ^{
                NSLog(@"Failed");
            });
        }

    });
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误,

由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[NSInvocation setArgument:atIndex:]:索引(2)超出范围[-1,1]'***第一个抛出调用堆栈:(0x1816751b8 0x1800ac55c 0x18156db24 …

objective-c ios

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

无法更改项目文字的颜色和项目图标的色彩

我正在尝试如下更改导航视图的文本颜色和图标色调颜色,

<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

        <include layout="@layout/include_list_viewpager"/>


        <android.support.design.widget.NavigationView
            android:id="@+id/nav_view"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:background="@color/colorPrimary"
            android:fitsSystemWindows="true"
            android:minHeight="?attr/actionBarSize"
            app:itemIconTint="@android:color/white"
            android:theme="@style/AppTheme.NavigationView"
            app:itemTextAppearance="?android:attr/textAppearanceSmall"
            app:itemTextColor="@android:color/white"
            app:menu="@menu/drawer_view"/>

    </android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

但这并没有帮助我更改颜色。因此,我尝试以编程方式如下设置颜色,

   // FOR NAVIGATION VIEW ITEM TEXT COLOR
        int[][] state = new int[][]{
                new int[]{-android.R.attr.state_enabled}, // disabled
                new int[]{android.R.attr.state_enabled}, // enabled
                new int[]{-android.R.attr.state_checked}, // unchecked
                new int[]{android.R.attr.state_pressed}  // pressed

        };

        int[] color = new int[]{
                Color.WHITE,
                Color.WHITE,
                Color.WHITE,
                Color.WHITE
        };

        ColorStateList csl = new ColorStateList(state, color);


// FOR NAVIGATION VIEW ITEM …
Run Code Online (Sandbox Code Playgroud)

android android-navigationview

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

创建db时出现sqlite异常

我试图使用以下sqlite查询创建表.

private static final String CREATE_EMPLOYEE_TABLE = "CREATE TABLE " + TABLE_EMPLOYEE + "("
            + KEY_DOMAIN_ID + " INTEGER PRIMARY KEY,"
            + KEY_FROM + " TEXT,"
            + KEY_TO + " TEXT" + ")";

private static final String CREATE_GROUPS_TABLE = "CREATE TABLE " + TABLE_GROUPS + "("
        + KEY_USERID + " INTEGER PRIMARY KEY,"
        + KEY_NAME + " TEXT,"
        + KEY_SESSION_TOKEN + " TEXT,"
        + KEY_GROUP_ID + " TEXT,"
        + KEY_GROUP_NAME + " TEXT" + ")";`
Run Code Online (Sandbox Code Playgroud)

我使用以下代码向db添加元素,

db.addEmployees(new Employee(id,from,to));
db.addGroup(new Group(Integer.valueOf(userId),name,session,groupId,groupName)); …
Run Code Online (Sandbox Code Playgroud)

android sqliteopenhelper

0
推荐指数
1
解决办法
103
查看次数

无法获取与sqlite中的id匹配的所有行

我有以下代码,我试图抓住所有匹配id的行.

public ChartData getCompliedChartCounts(int id) {
        SQLiteDatabase db = this.getReadableDatabase();

        SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();


        Cursor cursor = db.query(TABLE_COMPLIANCE_CHART_COUNTS, new String[]{KEY_ID,
                        KEY_FILTER_ID, KEY_YEAR, KEY_COUNTRY_ID, KEY_DOMAIN_ID, KEY_COMPLIED_COUNT, KEY_NOT_COMPLIED_COUNT, KEY_DELAYED_COUNT, KEY_INPROGRESS_COUNT}, KEY_COUNTRY_ID + "=?",
                new String[]{String.valueOf(id)}, null, null, null, null);
        if (cursor != null)
            cursor.moveToFirst();
        ChartData country = new ChartData(cursor.getInt(0), cursor.getInt(1), cursor.getInt(2), cursor.getInt(3), cursor.getInt(4), cursor.getInt(5), cursor.getInt(6), cursor.getInt(7), cursor.getInt(8));
        // return contact
        return country;
    }
Run Code Online (Sandbox Code Playgroud)

当我像getCompliedChartCounts(3)一样调用它时,我希望它抓取包含id 3的所有行.

但问题是,它只捕获与id 3匹配的第一行,而其余行未被获取.我该如何解决这个问题?

sqlite android

0
推荐指数
1
解决办法
45
查看次数