小编Has*_*ash的帖子

识别图像中的数字

我正在尝试编写一个应用程序来查找图像中的数字并添加它们.

如何识别图像中的书写号码?

在此输入图像描述

我需要在图像中有许多方框来获取左侧的数字并将它们相加以得出总数.我怎样才能做到这一点?

编辑:我在图像上做了一个java tesseract ocr,但我没有得到任何正确的结果.我怎么训练呢?

我做了边缘检测我得到了这个:

在此输入图像描述

java ocr tesseract image-processing hough-transform

33
推荐指数
4
解决办法
6233
查看次数

For loops与apply-templates

我最近开始在我的一些XML文档中使用XSLT,我有一些问题.我在下面添加代码.在代码中,我有一个匹配电子书元素的模板.然后我想列出写这本书的所有作者.我使用for为每个循环执行它,但我也可以应用模板.我什么时候使用循环以及何时使用模板时看不清楚.

另一个问题是,当你现在不会在你正在编写它的元素的其他子元素时,只说say-templates是正常的.在我的情况下,在模板中匹配文档根我说的是apply-templates.然后它找到了电子书,它是唯一的孩子,但我可以有一个"书籍"元素区分"常规"书籍和电子书籍然后它只列出书籍的字符数据.如果我只想在我的最终文档中使用电子书,那么我就需要编写apply-templates select ="ebooks".这是一个案例,它取决于你对文件的了解程度如何?

谢谢,这是我的代码(这只是为了练习):

XML:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="ebooks.xsl"?>
<ebooks>
    <ebook>
        <title>Advanced Rails Recipes: 84 New Ways to Build Stunning Rails Apps</title>
        <authors>
            <author><name>Mike Clark</name></author>
        </authors>
        <pages>464</pages>
        <isbn>978-0-9787-3922-5</isbn>
        <programming_language>Ruby</programming_language>
        <date>
            <year>2008</year>
            <month>5</month>
            <day>1</day>
        </date>
        <publisher>The Pragmatic Programmers</publisher>
    </ebook>
    ...
Run Code Online (Sandbox Code Playgroud)

XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:template match="/">
        <html>
            <head>
                <title>Library</title>
            </head>
            <body>
                <xsl:apply-templates />            
            </body>
        </html>    
    </xsl:template>

    <xsl:template match="ebooks">
        <h1>Ebooks</h1>
        <xsl:apply-templates>
            <xsl:sort select="title"/>
        </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="ebook">
        <h3><xsl:value-of select="title"/></h3>
        <xsl:apply-templates select="date" />

        <xsl:for-each select="authors/author/name">
            <b><xsl:value-of select="."/>,</b> …
Run Code Online (Sandbox Code Playgroud)

xml xslt xslt-1.0

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

如何在XSL中为每个组使用

即时通讯仍在学习for-each-group使用XSL分组这样的东西的最佳方法是什么?(按国家/地区)我正在尝试使用XSL将此XML转换为另一种XML.

<?xml version="1.0" encoding="UTF-8"?>
<Person>
    <Student>
        <Info Country="England" Name="Dan" Age="20" Class="C" />
    </Student>
    <Student>
        <Info Country="England" Name="Dan" Age="20" Class="B" />

    </Student>
    <Student>
        <Info Country="England" Name="Sam" Age="20" Class="A" />
    </Student>

    <Student>
       <Info Country="Australia" Name="David" Age="22" Class="D" />
    </Student>
    <Student>
        <Info Country="Australia" Name="David" Age="22" Class="A" />
    </Student>

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

xml xslt xpath xslt-2.0

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

JUnit测试自定义异常

我正在使用JUnit,并不太确定如何测试自定义异常类.我创造了,

public class CustomException extends Exception {

    //@param message is the exception message

    public CustomException(final String message) {
        super(message);
    }

    //@param message is the exception message
    //@param cause is the cause of the original exception

    public CustomException(final String message, final Throwable cause) {
        super(message, cause);
    }
}
Run Code Online (Sandbox Code Playgroud)

主要类会有很多尝试捕获,如;

catch (ParseException e) {

    throw new CustomException("Date format incorerect", e);
Run Code Online (Sandbox Code Playgroud)

而且我不确定如何为它编写测试类..非常感谢.

谢谢.

java junit unit-testing exception junit4

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

使用CSS构建复杂的形状

我对iPhone和Android浏览器中的一个项目工作,需要我建一个温度计般的进度表,可以用浏览器大小调整反应,并能够轻松地更改进度.它需要尽可能地像设计.也就是说,它需要花式渐变,嵌入突出显示,边框.

仪表:

在此输入图像描述

注意白色插入阴影和边框

进展应延伸到圆形部分,并继续产生奇特的效果.

我继续前进,得到一个粗略的原型工作(用chrome测试)http://jsfiddle.net/xduQ9/3/

html,
body {
  padding: 25px;
}

.circle {
  margin-left: -6px;
  width: 48px;
  height: 48px;
  border-radius: 25px 25px 25px 24px;
  border: solid rgba(178, 181, 188, 0.8) 1px;
  box-shadow: inset 1px 2px 0 #fff, inset 1px -2px 0 #fff, inset -2px 0 0 #fff, inset -2px -2px 0 #fff, inset 0 3px 0 rgba(255, 255, 255, 0.35), -20px -20px 0 #fff, 20px -20px 0 #fff, 20px 20px 0 #fff, -20px 20px 0 #fff;
}

.circle-wrap { …
Run Code Online (Sandbox Code Playgroud)

html css jquery html5

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

正确的浮动列表项

我想向右滑动蓝色元素,向左滑动灰色元素.列表项必须在另一个下面订购.

以下是解释我的意思的示例图像链接:

在此输入图像描述

任何帮助赞赏.

.chat {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: hidden;

}
.chat li {
  margin-bottom: 15px;
  padding: 10px 20px;
  border-radius: 20px;
}
.chat li:nth-child(odd) {
  float: right;
  background-color: #52adf4;
  color: #fff;
}
.chat li:nth-child(even) {
  float: left;
  background-color: #e9e7e8;
  color: #333;
}
Run Code Online (Sandbox Code Playgroud)
<ul class="chat">
<li>Hi Joe</li>
<li>Hi, how're u?</li>
<li>Fine, how's it going bro?</li>
<li>Thanks as usual</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

html css html5 css3

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

XSLT:执行流程的调用模板与模式

哪个是用于执行流、调用模板或模式的更好实践?

数据文件

<Properties>
    <foo>me</foo>
    <bar>you</bar>
</Properties>
Run Code Online (Sandbox Code Playgroud)

一个.xsl

<xsl:include href="translations_nomodes.xml"
<xsl:template match="/">
    <xsl:call-template name="a_display"/>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

b.xsl

<xsl:include href="translations_nomodes.xml"
<xsl:template match="/">
    <xsl:call-template name="b_display"/>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

翻译_nomodes.xsl

<xsl:template name="a_display">
    <!-- display option a -->
    ...
</xsl:template>

<xsl:template name="b_display">
    <!-- display option b -->
    ...
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

或者使用模式是更好的做法

.xsl

<xsl:include href="translations_modes.xml"
<xsl:template match="/">
    <xsl:apply-templates select="/Properties" mode="c_display"/>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

d.xsl

<xsl:include href="translations_modes.xml"
<xsl:template match="/">
    <xsl:apply-templates select="/Properties" mode="d_display"/>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

翻译模式.xsl

<xsl:template match="Properties" mode="c_display">
    <!-- display option c -->
    ...
</xsl:template>

<xsl:template match="Properties" mode="d_display">
    <!-- display option d -->
    ... …
Run Code Online (Sandbox Code Playgroud)

xml xslt

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

XSLT 自定义函数返回节点集或 XML 片段(非简单数据类型)

我正在尝试开发一个可以返回节点集或 XML 片段的 XSLT 自定义函数,让我们说一下:

输入文件:

<root>
<!--
 author: blablabla
 usage: more blablabla
 labelC: [in=2] <b>formatted</b> blablabla
-->
<tag1 name="first">
    <tag2>content a</tag2>
    <tag2>content b</tag2>
    <tag3 attrib="val">content c</tag3>
</tag1>

<!--
 author: blebleble
 usage: more blebleble
 labelC: blebleble
-->
<tag1 name="second">
    <tag2>content x</tag2>
    <tag2>content y</tag2>
    <tag3 attrib="val">content z</tag3>
</tag1>
</root>
Run Code Online (Sandbox Code Playgroud)

这样一个 XSLT 模板,例如:

    <xsl:template match="//tag1/preceding::comment()[1]" xmlns:d="java:com.dummy.func">
    <section>
     <para>
      <xsl:value-of select="d:genDoc(.)"/>
     </para>
    </section>
    </xsl:template>
Run Code Online (Sandbox Code Playgroud)

会产生:

    <section>
     <para>
      <author>blablabla</author>
      <usage>more blablabla</usage>
      <labelC in="2"><b>formatted</b> blablabla</labelC>
     </para>
    </section>
Run Code Online (Sandbox Code Playgroud)

当第一次出现 tag1 和

    <section>
     <para>
      <author>blebleble</author>
      <usage>more blebleble</usage> …
Run Code Online (Sandbox Code Playgroud)

java xslt

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

没有排序的XSLT Number节点

我有以下xml:

<policy>
    <games>
         <game startTime="11:00"/>
         <game startTime="11:20"/>
         <game startTime="11:40"/>
    </games>
    <games>
         <game startTime="11:10"/>
         <game startTime="11:30"/>
         <game startTime="11:50"/>
    </games>
</Policy>
Run Code Online (Sandbox Code Playgroud)

我正在尝试编写一个xslt,它将为每个游戏节点添加一个新属性,并按时间顺序添加值,例如

<policy>
    <games>
         <game startTime="11:00" id="1"/>
         <game startTime="11:20" id="3"/>
         <game startTime="11:40" id="5"/>
    </games>
    <games>
         <game startTime="11:10" id="2"/>
         <game startTime="11:30" id="4"/>
         <game startTime="11:50" id="6"/>
    </games>
</policy>
Run Code Online (Sandbox Code Playgroud)

我需要游戏节点保持当前的顺序,所以我不确定xsl:sort是否可行.

目前我有这个,显然只是按当前顺序编号,不会考虑时间属性:

<xsl:template match="game">
    <xsl:copy>
      <xsl:attribute name="id">
        <xsl:value-of select="count(preceding::game) + 1"/>
      </xsl:attribute>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

sorting xslt xslt-1.0

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

如果 - 然后在XSLT中

我在从XML文件中提取一些数据时遇到问题.我仍然有问题要弄清楚如果有多个但是输出应该看起来像不喜欢如何处理ph:Attributea .也许是if-then案例!?ph:Element(s_rel0 = 5, par_s_rel0 = 5)(s_rel0 = 5)(par_s_rel0 = 5)

第二个连接应该由flange_b而不是flange_a.我在搜索错误时却找不到它.

你知道我哪里弄错了吗??谢谢你的帮助.

XML:

<?xml version="1.0" encoding="UTF-8"?>
    <ph:Graphs xmlns:ph="http://www.merge.something.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <ph:Graph name="mass_spring_mo">
            <ph:Element id="0" type="Fixed">
                <ph:Port id="1" type="port">
                    <ph:Attribute>
                        <ph:AttributeField name="type" value="string"/>
                        <ph:AttributeField name="name" value="type"/>
                        <ph:AttributeField name="value" value="flange"/>
                    </ph:Attribute>
                </ph:Port>
            </ph:Element>
            <ph:Element id="2" type="Spring">
                <ph:Attribute>
                    <ph:AttributeField name="type" value="int"/>
                    <ph:AttributeField name="name" value="s_rel0"/>
                    <ph:AttributeField name="value" value="5"/>
                </ph:Attribute>
                <ph:Attribute>
                    <ph:AttributeField name="type" value="int"/>
                    <ph:AttributeField name="name" value="par_s_rel0"/>
                    <ph:AttributeField name="value" value="5"/>
                </ph:Attribute>
                <ph:Port id="3" type="port">
                    <ph:Attribute>
                        <ph:AttributeField …
Run Code Online (Sandbox Code Playgroud)

xml xslt xslt-1.0

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