尝试使用JAXB从XSD架构生成Java类时,我收到以下错误.我正在指定一个我希望它们所在的目录但是当我尝试运行该命令时出现以下错误.
命令:
java -jar /home/Alison/Programs/jaxb-ri-2.2.6/lib/jaxb-xjc.jar xmlSchema.xjb -d com.q1labs.qa.xmlgenerator.model.xmlclasses xmlSchema.xsd
错误:
怯懦拒绝写入不存在的目录"com.q1labs.qa.xmlgenerator.model.xmlclasses"
我发现了以下补丁http://jira.codehaus.org/browse/MJAXB-2但是从评论看来它似乎不再适用于当前版本.
如果目录不存在,我可以指定创建目录吗?
我已经使用示例 OpenCV 程序计算了我的相机的相机矩阵和失真系数,并生成了一个包含相关数据的 xml 文件。
我正在尝试通过undistort函数使用它,但我不确定如何将值存储为Mat.
Mat cameraMatrix;
Mat distortionCoefficients;
undistort(image, newImage, cameraMatrix, distortionCoefficients);
Run Code Online (Sandbox Code Playgroud)
我试过了:
Mat cameraMatrix = 1.7514028018776246e+03 0. 1.2635000000000000e+03 0. 1.7514028018776246e+03 9.2750000000000000e+02 0. 0. 1.;
Mat distortionCoefficients = 1.3287735059062630e-01 -6.8376776294978103e-01 0. 0. 8.1215478360827675e-01;
Run Code Online (Sandbox Code Playgroud)
我是否需要尝试为Matvar指定一系列行和列,然后为每个值分配一个索引?
当我将代码输入XSD验证器时,我的XSD出现问题,我收到此错误:"no-xmlns:属性声明的{name}必须与'xmlns'不匹配."
这是我的XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Test">
<xs:complexType>
<xs:attribute name="xmlns" type="xs:string" use="required"/>
<xs:sequence>
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element name="Screens" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Screen" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="package" type="xs:string" use="required"/>
<xs:attribute name="class" type="xs:string" use="required"/>
<xs:sequence>
<xs:element name="ScreenData" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="step" type="xs:int" use="required"/>
<xs:attribute name="description" type="xs:string" use="required"/>
<xs:sequence>
<xs:element name="element" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence> …Run Code Online (Sandbox Code Playgroud) 我想从一个单独的Java项目中获取所有包名称,我最好如何使用反射在Java中执行此操作?
我已将项目导入到构建路径中,并且我尝试使用下面的代码来获取包名称.
Package[] pack = Package.getPackages();
编辑:我没有使用jar文件,我刚刚导入了项目,因为它将在同一个目录中.我只需要我创建的包,特别是以某个目录开头的包.
我希望在用户单击“注销”时销毁会话,我试图通过使用 jQuery 调用 onClick 函数来执行此操作,然后该函数将调用包含 .php 的 .PHP 文件session_destroy();。
索引.php
<?php
if(isset($_SESSION['username'])) {
echo "<li><a href='#' id='logOut' onclick='logOut();'>Log Out</a></li>";
}
?>
Run Code Online (Sandbox Code Playgroud)
这使得注销按钮仅在用户登录并且 onClick 应该调用logOut()Nav.js 中包含的时候可见。
导航.js
function logOut() {
$.get("../Controller/logOut.php");
return false;
}
Run Code Online (Sandbox Code Playgroud)
登出.php
<?php
session_destroy();
?>
Run Code Online (Sandbox Code Playgroud)
当我单击“注销”时,似乎没有任何反应,我在 Chrome Dev 控制台中也没有收到任何错误。问题是什么?
我希望用户输入一个字符串,如果该字符串与我的正则表达式不匹配,那么我希望输出一条消息,并且用户再次输入一个值。
问题是,即使字符串与正则表达式匹配,它也会将其视为不匹配。
我的正则表达式:这应该等于 -Name, Name
[[A-Z][a-zA-Z]*,\s[A-Z][a-zA-Z]*]
我的while循环:
System.out.println("Enter the student's name in the following format - surname, forename: "); studentName = input.next();
while (!studentName.equals("[[A-Z][a-zA-Z]*,\\s[A-Z][a-zA-Z]*]")) {
System.out.println("try again");
studentName = input.next();
}
Run Code Online (Sandbox Code Playgroud) 我正在使用SURF/FLANN探测器,我正在寻找将图像,点,描述符保存到文件中,这样我就可以比较这个图像,然后将它指向第二个图像并指向我但是当我得到以下错误时试着写:
In file included from detectFlannPoints.cpp:4:0:
/usr/local/include/opencv2/features2d/features2d.hpp:112:17: note: void cv::write(cv::FileStorage&, const string&, const std::vector<cv::KeyPoint>&)
/usr/local/include/opencv2/features2d/features2d.hpp:112:17: note: candidate expects 3 arguments, 4 provided
Run Code Online (Sandbox Code Playgroud)
这是我用来编写的代码:
FileStorage fs("Keypoints.yml", FileStorage::WRITE);
write(fs, "templateImageOne", keypoints_1, tempDescriptors_1);
fs.release();
Run Code Online (Sandbox Code Playgroud)
我不确定在哪里可以指定额外的参数(tempDescriptors_1),因为它可以正常删除这个arg.
代码立即高于写代码:
//Detect the keypoints using SURF Detector
int minHessian = 400;
SurfFeatureDetector detector( minHessian );
std::vector<KeyPoint> keypoints_1;
detector.detect( img_1, keypoints_1 );
//-- Step 2: Calculate descriptors (feature vectors)
SurfDescriptorExtractor extractor;
Mat tempDescriptors_1;
extractor.compute( img_1, keypoints_1, tempDescriptors_1 );
//-- Draw keypoints
Mat img_keypoints_1;
drawKeypoints( img_1, keypoints_1, img_keypoints_1, …Run Code Online (Sandbox Code Playgroud) 我在工作中使用 OpenCV Haar 分类器,但我一直在阅读有关 OpenCV Haar 分类器是否是 SVM 的相互矛盾的报告,有人能澄清它是否使用 SVM 吗?另外,如果不使用 SVM,Haar 方法相对于 SVM 方法有何优势?
resource构建 JAR 后,我正在尝试读取文件夹的内容。资源文件夹source在 IDE 设置 (IntelliJ) 中标记为 a 。
我尝试了以下方法:
InputStream input = getClass().getResourceAsStream("../objectLocation.json");
JsonReader jsonReader = new JsonReader(new InputStreamReader(input));
Run Code Online (Sandbox Code Playgroud)
我也试过:
JsonReader jsonReader = new JsonReader(new FileReader("../resources/objectLocation.json"));
Run Code Online (Sandbox Code Playgroud)
这两种方法都会导致:
结果是:
java.io.FileNotFoundException: com/layers/resources/objectLocation.json (No such file or directory)
Run Code Online (Sandbox Code Playgroud)
文件结构:
src
-com.layers -> myClasses
-resources -> JSON
Run Code Online (Sandbox Code Playgroud)
编辑:
InputStream input = getClass().getResourceAsStream("objectLocation.json");
JsonReader jsonReader = new JsonReader(new InputStreamReader(input));
Run Code Online (Sandbox Code Playgroud)
结果在:
java.lang.NullPointerException
Run Code Online (Sandbox Code Playgroud) 在我的Java动态Web项目中,我正在使用Build Path导入另一个Java项目,因此我可以查询类并使用Java反射.在编写我的类时,我最初通过将其作为Java应用程序运行来测试它并且它有效.但是我现在使用相同的类作为动态Web项目的一部分,它似乎无法访问导入的Java项目.我已经尝试将它导入Eclipse中的项目引用,它仍然无法正常工作并输出以下错误:
HTTP Status 500 - javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/q1labs/qa/selenium/widgets/WidgetHandler
--------------------------------------------------------------------------------
type Exception report
message javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/q1labs/qa/selenium/widgets/WidgetHandler
description The server encountered an internal error (javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/q1labs/qa/selenium/widgets/WidgetHandler) that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/q1labs/qa/selenium/widgets/WidgetHandler
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/q1labs/qa/selenium/widgets/WidgetHandler
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
org.apache.jsp.UpdatingDb_jsp._jspService(UpdatingDb_jsp.java:98)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.lang.NoClassDefFoundError: com/q1labs/qa/selenium/widgets/WidgetHandler
com.q1labs.qa.xmlgenerator.controller.updatedb.DbUpdateScript.updateObjectTypes(DbUpdateScript.java:40)
com.q1labs.qa.xmlgenerator.controller.updatedb.DbUpdateScript.updateDb(DbUpdateScript.java:31)
org.apache.jsp.UpdatingDb_jsp._jspService(UpdatingDb_jsp.java:88)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Run Code Online (Sandbox Code Playgroud)