小编luc*_*rot的帖子

用于使用Zbar确定QR码的角落位置的Python代码

我想在这里扩展代码以提取QCodes的角落.

#!/usr/bin/python
from sys import argv
import zbar
from PIL import Image

if len(argv) < 2: exit(1)

# create a reader
scanner = zbar.ImageScanner()

# configure the reader
scanner.parse_config('enable')

# obtain image data
pil = Image.open(argv[1]).convert('L')
width, height = pil.size
raw = pil.tostring()

# wrap image data
image = zbar.Image(width, height, 'Y800', raw)

# scan the image for barcodes
scanner.scan(image)

# extract results
for symbol in image.symbols:
    # do something useful with results
    print 'decoded', symbol.type, 'symbol', '"%s"' % symbol.data …
Run Code Online (Sandbox Code Playgroud)

python zbar-sdk zbar

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

Div 不填充父级宽度:100%

html

<main>
    <div class="homediv">
        <p>test</p>
    </div>
</main
Run Code Online (Sandbox Code Playgroud)

CSS

div.homediv {
  background-color: yellow;
  width: 100%;
  position: static;
  /*The lower the z-index, the further in the background the element*/
  z-index: -1;
}
Run Code Online (Sandbox Code Playgroud)

乍一看,这应该使 div 水平填满屏幕。但事实并非如此。这里的一些答案说 width:100% 仅当设置了父级的宽度时才起作用,但那已经设置了。为了确保这一点,我什至给 html、body、main 和我的 div 设置了 width:100% 属性。这并没有解决它。

html css

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

IntelliJ IDEA灰显了一些未使用的方法,但不是全部

在IntelliJ IDEA 2017.2.6中,我有以下Java类.

public class EinzUnregisterResponseMessageBody extends EinzMessageBody {

    private final String username, reason;

    public EinzUnregisterResponseMessageBody(String username, String reason){
        this.username = username;

        this.reason = reason;
    }

    /**
     * @return the body as JSONobject, ready to be included as "body":{this returned Object} in a message
     */
    @Override
    public JSONObject toJSON() throws JSONException {
        return new JSONObject("{\"username\":\""+this.username+"\"," +
                "\"reason\":\""+this.reason+"\"}");
    }

    public String getReason() {
        return reason;
    }

    public String getUsername() {
        return username;
    }
}
Run Code Online (Sandbox Code Playgroud)

IntelliJ通常以浅灰色显示未使用的属性.在这堂课中,它只会变灰getReason().有意义的是它不会使构造函数或字段变灰.该方法toJSON()在抽象超类中定义,EinzMessageBody因此必须存在,所以它也不是灰色的是正确的. …

java intellij-idea

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

网络接口rmnet_ipa0的含义

在android设备上运行时adb shellifconfig我会得到一个网络接口列表。虽然此答案涵盖了大多数接口名称,但我想知道它代表什么rmnet_ipa0

lo通常代表回送接口(localhost)

无线局域网通常代表无线网络接口

rmnet接口通常与蜂窝连接和USB绑定相关联

坐接口与通过IPv4的IPv6隧道关联

p2p接口通常与对等连接相关联(也许您的Android设备支持WiFi Direct?)

虚拟接口为回送接口提供特殊的别名

我相信USB中继通常是类似的东西rmnet_usb0,而我手机的移动数据连接可能rmnet_data0就是这样,那是什么rmnet_ipa0?

的整个输出ifconfig

rmnet_ipa0 Link encap:UNSPEC
          UP RUNNING  MTU:2000  Metric:1
          RX packets:88626 errors:0 dropped:0 overruns:0 frame:0
          TX packets:64896 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:89068838 TX bytes:9380664

wlan0     Link encap:UNSPEC
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:1756445 errors:0 dropped:53160 overruns:0 frame:0
          TX packets:650187 errors:0 dropped:186 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:985553036 TX bytes:283899452

dummy0    Link …
Run Code Online (Sandbox Code Playgroud)

android network-interface

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

为什么 HandlerThread 需要名称?

为什么android HandlerThread需要构造函数的名称?

公共构造函数


HandlerThread(String name)

HandlerThread(String name, int priority)

构造一个HandlerThread。

即为什么没有没有new HandlerThread()参数的构造函数?内部使用的名称是什么?我可以用它做什么?

在文档中搜索“名称”只会给出这些构造函数作为结果。

android

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

为什么 Rust 编译器需要 Option&lt;&amp;impl Trait&gt; 的类型注释?

鉴于此 MCVE:

fn main() {
    println!("{}", foo(None));
}

trait Trait {}
struct Struct {}
impl Trait for Struct {}

fn foo(maybe_trait: Option<&impl Trait>) -> String {
    return "hello".to_string();
}
Run Code Online (Sandbox Code Playgroud)

Rust 编译器不高兴:

error[E0282]: type annotations needed
 --> src\main.rs:2:20
  |
2 |     println!("{}", foo(None));
  |                    ^^^ cannot infer type for `impl Trait`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0282`.
Run Code Online (Sandbox Code Playgroud)

使用类型注释使这个编译:

fn main() {
    let nothing: Option<&Struct> = None;
    println!("{}", foo(nothing));
}

trait Trait …
Run Code Online (Sandbox Code Playgroud)

rust

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

IMDbPy:如何捕获 IMDbDataAccessError?

我完全不擅长处理异常,而且我一直在学习使用 IMDbPy。如果用户输入无效 ID,我想捕获异常。我试过

import imdb
from imdb import IMDbDataAccessError
ia = imdb.IMDb(accessSystem='http')
try:
    movie = ia.get_movie('12121212212121')
except IMDbDataAccessError:
    print("error")
Run Code Online (Sandbox Code Playgroud)

但它不会打印文本“错误”,而是显示错误消息。这是——

IMDbDataAccessError exception raised; args: ({'errcode': None,
'errmsg': 'None', 'url':
'https://www.imdb.com/title/tt12121212212121/reference', 'proxy': '',
'exception type': 'IOError', 'original exception': <HTTPError 404:
'Not Found'>},); kwds: {}
Run Code Online (Sandbox Code Playgroud)

python exception imdbpy

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

将ConcurrentHashMap转换为HashMap

是否有可能转换ConcurrentHashMapHashMapjava?

这是我的示例程序,我从哪里转换ConcurrentHashMapHashMap但是我得到以下异常:

线程"main"中的异常java.lang.ClassCastException:java.util.concurrent.ConcurrentHashMap无法转换为com.Hi.main中的java.util.HashMap(Hi.java:18)

我的代码:

package com;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class Hi {

    public static void main(String args[]) {

        Map<String, String> conpage = new ConcurrentHashMap<String, String>();

        conpage.put("1", "A");
        conpage.put("2", "B");
        conpage.put("3", "C");

        HashMap hm = (HashMap) conpage;

        System.out.println(hm.get("1"));

    }

}
Run Code Online (Sandbox Code Playgroud)

java

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