小编Gob*_*ffi的帖子

62
推荐指数
4
解决办法
11万
查看次数

将图像叠加到相机预览SurfaceView上

我有一个SurfaceView用于绘制图像的,我想将它们叠加到手机相机的实时信息中.

目前,SurfaceView包含图像的图像具有白色背景,但如果我将它们叠加到手机的相机源上,则它们必须是透明的.相机和动画绘图不能在同一个上完成SurfaceView.

追求使用涉及管理相机和绘制图像的多个视图的最佳方法是什么?是否可以SurfaceView透明化?

graphics camera android surfaceview

32
推荐指数
4
解决办法
6万
查看次数

将包含多个数字的String转换为整数

我意识到这个问题可能在过去曾多次被问过,但我会继续不管.

我有一个程序,它将从键盘输入中获取一串数字.数字将始终采用"66 33 9"的形式.基本上,每个数字都用空格分隔,用户输入将始终包含不同数量的数字.

我知道如果每个用户输入的字符串中的数字量不变,使用'sscanf'会有效,但对我来说情况并非如此.另外,因为我是C++的新手,所以我更喜欢处理'字符串'变量而不是字符数组.

c++ string integer

31
推荐指数
3
解决办法
7万
查看次数

使用Python minidom读取XML并迭代每个节点

我有一个类似于以下的XML结构,但规模要大得多:

<root>
    <conference name='1'>
        <author>
            Bob
        </author>
        <author>
            Nigel
        </author>
    </conference>
    <conference name='2'>
        <author>
            Alice
        </author>
        <author>
            Mary
        </author>
    </conference>
</root>
Run Code Online (Sandbox Code Playgroud)

为此,我使用了以下代码:

dom = parse(filepath)
conference=dom.getElementsByTagName('conference')
for node in conference:
    conf_name=node.getAttribute('name')
    print conf_name
    alist=node.getElementsByTagName('author')
    for a in alist:
        authortext= a.nodeValue
        print authortext
Run Code Online (Sandbox Code Playgroud)

但是,打印出来的authortext是"None".我尝试使用如下所示的变体,但它会导致我的程序中断.

authortext=a[0].nodeValue
Run Code Online (Sandbox Code Playgroud)

正确的输出应该是:

1
Bob
Nigel
2
Alice
Mary
Run Code Online (Sandbox Code Playgroud)

但我得到的是:

1
None
None
2
None
None
Run Code Online (Sandbox Code Playgroud)

有关如何解决这个问题的任何建议?

python xml parsing minidom

24
推荐指数
2
解决办法
6万
查看次数

WHERE语句中的SQL Server AS语句别名列

我想执行一个查询,在该查询中,我使用'AS'语句重命名其中一个列,并在'WHERE'语句中重用该别名列名.以下是一个例子:

SELECT lat AS latitude 
FROM poi_table 
WHERE latitude < 500
Run Code Online (Sandbox Code Playgroud)

这里的问题是SQL Server不喜欢这个查询,因为WHERE子句和WHERE子句中引用的AS语句名称.任何人都可以解释为什么会发生这种情况以及我可以做些什么来弥补我的情况?

假设我在查询的SELECT部分​​中有一个别名的公式,我该如何处理?

SELECT *, 
( 6371*1000 * acos( cos( radians(42.3936868308) ) * cos( radians( lat ) ) * cos( radians( lon ) - radians(-72.5277256966) ) + sin( radians(42.3936868308) ) * sin( radians( lat ) ) ) ) 
AS distance
FROM poi_table 
WHERE distance < 500;
Run Code Online (Sandbox Code Playgroud)

sql t-sql sql-server

21
推荐指数
3
解决办法
10万
查看次数

确定智能手机相机的视角

我正在尝试确定Droid Incredible智能手机相机的视野的大小.我需要知道我正在开发的应用程序的这个值.有谁知道如何以编程方式找出/计算它?

math camera android angle

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

使用下半部分颜色和上半部分颜色创建div

我有一个我要打成一个按钮.上半部分应为#ffd41a,下半部分应为#fac915.这是目前按钮的链接.http://jsfiddle.net/WnwNW/

我面临的问题是我应该如何处理两种背景颜色.有没有办法做我想做的事情而不需要额外的div或跨度?我可以在同一个CSS类中有两个背景属性吗?

html css css3

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

Guava迭代器,迭代列表对象中的列表

我有以下示例代码,其中包含3个嵌套的for循环.

for(Continent continent : continentList) 
{
    for(Country country : continent.getCountries())
    {
        for(City city : country.getCities())
        {
            //Do stuff with city objects
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

有没有办法使用Guava和迭代器来模仿这个嵌套的for循环?我一直试图找到一个没有太多运气的合适例子,我想知道是否有人可以帮助我?我的一位同事提到使用过滤器.

编辑:修复了示例代码中的小错误

java iterator guava

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

使用Python中的BeautifulSoup解析数据

我试图使用BeautifulSoup来解析DOM树并提取作者的名字.下面是一段HTML代码,展示了我要抓取的代码的结构.

<html>
<body>
<div class="list-authors">
<span class="descriptor">Authors:</span> 
<a href="/find/astro-ph/1/au:+Lin_D/0/1/0/all/0/1">Dacheng Lin</a>, 
<a href="/find/astro-ph/1/au:+Remillard_R/0/1/0/all/0/1">Ronald A. Remillard</a>, 
<a href="/find/astro-ph/1/au:+Homan_J/0/1/0/all/0/1">Jeroen Homan</a> 
</div>
<div class="list-authors">
<span class="descriptor">Authors:</span> 
<a href="/find/astro-ph/1/au:+Kosovichev_A/0/1/0/all/0/1">A.G. Kosovichev</a>
</div>

<!--There are many other div tags with this structure-->
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我的困惑之处在于,当我做soup.find时,它会找到我正在搜索的第一次出现的div标签.之后,我搜索所有'a'链接标记.在此阶段,如何从每个链接标记中提取作者姓名并将其打印出来?有没有办法使用BeautifulSoup或我需要使用正则表达式吗?如何继续迭代所有其他div标签并提取作者姓名?

import re
import urllib2,sys
from BeautifulSoup import BeautifulSoup, NavigableString
html = urllib2.urlopen(address).read()
    soup = BeautifulSoup(html)

    try:

        authordiv = soup.find('div', attrs={'class': 'list-authors'})
        links=tds.findAll('a')


        for link in links:
            print ''.join(link[0].contents)

        #Iterate through entire page and print authors


    except IOError: 
        print 'IO error'
Run Code Online (Sandbox Code Playgroud)

html python parsing beautifulsoup

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

Radix Sort用C++实现

我试图通过创建一个程序来改进我的C++,该程序将需要1到10 ^ 6之间的大量数字.将在每次传递中存储数字的存储桶是一个节点数组(其中node是我创建的包含值和下一个节点属性的结构).

根据最低有效值将数字排序到桶中后,我将一个桶的末尾指向另一个桶的开头(这样我可以快速获取存储的数字而不会中断订单).我的代码没有错误(编译或运行时),但我已经找到了解决剩下的6次迭代的问题(因为我知道数字的范围).

我遇到的问题是,最初这些数字是以int数组的形式提供给radixSort函数的.在排序的第一次迭代之后,数字现在存储在结构数组中.有没有什么方法可以重新编写我的代码,以便我只有一个for循环进行7次迭代,或者我需要一个for循环,它将运行一次,而另一个循环下面将运行6次,然后返回完全排序清单?

#include <iostream>
#include <math.h>
using namespace std;

struct node
{
    int value;
    node *next; 
};

//The 10 buckets to store the intermediary results of every sort
node *bucket[10];
//This serves as the array of pointers to the front of every linked list
node *ptr[10];
//This serves as the array of pointer to the end of every linked list
node *end[10];
node *linkedpointer;
node *item;
node *temp;

void append(int value, int n)
{
    node *temp; 
    item=new …
Run Code Online (Sandbox Code Playgroud)

c++ sorting algorithm radix-sort

8
推荐指数
2
解决办法
4万
查看次数