我正在使用Java Maven程序而且我不知道要输入什么<mainClass>.我已经根据众多 stackoverflow问题尝试了各种各样的东西,但他们没有解决错误.
每次说:
Maven Error: Could not find or load main class ...
Run Code Online (Sandbox Code Playgroud)
我在里面写了这个pom.xml(减去???)
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass> ??? </mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
Run Code Online (Sandbox Code Playgroud)
我该如何解决这些错误?
有没有办法调整任何形状或大小[500x500]的图像,但要保持图像的纵横比,空白空间填充白色/黑色填充物?
所以说图像是[2000x1000]在调整尺寸以[500x500]使实际图像本身成为之后[500x250],125任何一面都是白色/黑色填充物.
像这样的东西:
输入

产量

编辑
我不希望简单地在方形窗口中显示图像,而是将图像更改为该状态,然后保存到文件中,创建尽可能少的图像失真的相同尺寸图像的集合.
我遇到的唯一一个问类似问题的是这篇文章,但是它的内容php.
应用程序的要点是从已经设置的图像列表中识别图像.图像列表已将SIFT描述符提取并保存在文件中.这里没什么有趣的:
std::vector<cv::KeyPoint> detectedKeypoints;
cv::Mat objectDescriptors;
// Extract data
cv::SIFT sift;
sift.detect(image, detectedKeypoints);
sift.compute(image, detectedKeypoints, objectDescriptors);
// Save the file
cv::FileStorage fs(file, cv::FileStorage::WRITE);
fs << "descriptors" << objectDescriptors;
fs << "keypoints" << detectedKeypoints;
fs.release();
Run Code Online (Sandbox Code Playgroud)
然后设备拍照.SIFT描述符以相同的方式提取.现在的想法是将描述符与文件中的描述符进行比较.我正在使用OpenCV的FLANN匹配器.我试图通过图像来量化相似性.经过整个清单后,我应该有最好的匹配.
const cv::Ptr<cv::flann::IndexParams>& indexParams = new cv::flann::KDTreeIndexParams(1);
const cv::Ptr<cv::flann::SearchParams>& searchParams = new cv::flann::SearchParams(64);
// Match using Flann
cv::Mat indexMat;
cv::FlannBasedMatcher matcher(indexParams, searchParams);
std::vector< cv::DMatch > matches;
matcher.match(objectDescriptors, readDescriptors, matches);
Run Code Online (Sandbox Code Playgroud)
匹配后我明白我得到了特征向量之间最近找到的距离列表.我找到了最小距离,并且使用它我可以计算"好的匹配",甚至可以获得相应点的列表:
// Count the number of mathes where the distance is less than 2 * min_dist
int goodCount …Run Code Online (Sandbox Code Playgroud) 查看直方图文档,有4(5)种不同的比较方法:
它们都提供不同的输出,如比较直方图文档中所示.但我找不到任何能说明每种方法相互比较的效果的方法.当然每种方法都有优点和缺点,否则为什么有多种方法呢?
甚至OpenCV 2计算机视觉应用程序编程手册也没有什么可说的差异:
对cv :: compareHist的调用很简单.您只需输入两个直方图,该函数将返回测量的距离.要使用的特定测量方法是使用标志指定的.在ImageComparator类中,使用了交集方法(带有标志CV_COMP_INTERSECT).对于每个箱,该方法简单地比较每个直方图中的两个值,并保持最小值.然后,相似性度量就是这些最小值的总和.因此,具有没有共同颜色的直方图的两个图像将获得0的交叉值,而两个相同的直方图将获得等于总像素数的值.
可用的其他方法是卡方(标志CV_COMP_CHISQR) ,它对二进制位之间的归一化方差进行求和,相关方法(标志CV_COMP_CORREL)基于信号处理中使用的归一化互相关算子来测量两者之间的相似性.信号和Bhattacharyya度量(标志CV_COMP_BHATTACHARYYA)在统计中用于估计两个概率分布之间的相似性.
这些方法之间肯定存在差异,所以我的问题是它们是什么?什么情况下他们最好?
在没有回答这个问题之后,我最终遇到了一些有趣的看起来可能的解决方案:
设置好Canny Edge Detector,参考其文档并实现Robust Matcher我链接的第一页中所示的内容之后,我获得了一些徽标/衣服图片,并且将两者结合起来取得了不错的成绩:

但是在其他非常相似的情况下,它关闭了:

与“完全相同”设计相同的不同徽标图像,与上述服装图像相同。
这让我感到奇怪,是否有一种方法可以匹配图像上定义给定图像某些区域的几个特定点?
因此,不是让图像读入然后进行的所有匹配,而是keypoints丢弃“坏” keypoints等。是否有可能让系统知道一个keypoint相对于另一个的位置,然后丢弃一个图像上正确的匹配彼此相邻,但彼此的位置完全不同吗?
(如左图所示,淡蓝色和宝蓝色“匹配”彼此相邻,但在右图的完全分开的部分中匹配)
编辑
对于米卡

“矩形”绘制在(在油漆中添加的)白盒的中心。
cv::Mat ransacTest(const std::vector<cv::DMatch>& matches, const std::vector<cv::KeyPoint>& trainKeypoints, const std::vector<cv::KeyPoint>& testKeypoints, std::vector<cv::DMatch>& outMatches){
// Convert keypoints into Point2f
std::vector<cv::Point2f> points1, points2;
cv::Mat fundemental;
for (std::vector<cv::DMatch>::const_iterator it= matches.begin(); it!= matches.end(); ++it){
// Get the position of left keypoints
float x= trainKeypoints[it->queryIdx].pt.x;
float y= trainKeypoints[it->queryIdx].pt.y;
points1.push_back(cv::Point2f(x,y));
// Get the position of …Run Code Online (Sandbox Code Playgroud) 按照本指南,我运行了命令
mvn assembly:assembly
Run Code Online (Sandbox Code Playgroud)
并得到了Build Failure的
Error reading assemblies: No assembly descriptors found.
Run Code Online (Sandbox Code Playgroud)
我已经看过很多关于这方面的问题,但无济于事.
从这篇文章中,我创建了一个.xml内部:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>jar-with-dependencies</id>
<formats>
<format>jar</format>
</formats>
<dependencySets>
<dependencySet>
<scope>runtime</scope>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<exclude>**/LICENSE*</exclude>
<exclude>**/README*</exclude>
</excludes>
</unpackOptions>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/resources/META-INF/services</directory>
<outputDirectory>META-INF/services</outputDirectory>
</fileSet>
</fileSets>
</assembly>
Run Code Online (Sandbox Code Playgroud)
并将其包括在pom.xml:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>jar-with-dependencies.xml</descriptor>
</descriptors>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但仍然没有运气.
你可能会说,我对这个很陌生,我该如何运行呢?
~~ ~~编辑
在pom.xml我改变了
<descriptor>jar-with-dependencies.xml</descriptor>
Run Code Online (Sandbox Code Playgroud)
至
<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
Run Code Online (Sandbox Code Playgroud)
~~编辑2 ~~
pom.xml 现在包含这个: …
我遇到OpenCV(断言失败)的问题,因为当它应该作为CV_32F加载时,图像被加载为CV_8U.
那么我如何从CV_8U转换为CV_32F?
非常感谢.
由于已经有很多关于此的问题,我有点担心要问......但是
我看过许多不同的问题,但没有任何一个对我有用。我有这个代码作为我的尝试,但它不起作用:
#include "boost/property_tree/ptree.hpp"
#include "boost/property_tree/json_parser.hpp"
using namespace boost::property_tree;
...
std::ifstream jsonFile("test_file.json");
if (!jsonFile){
std::cerr << "Error opening file\n";
return -1;
}
ptree pt;
json_parser::read_json(jsonFile, pt);
for (auto& array_element : pt) {
for (auto& property : array_element.second) {
std::cout << property.first << " = " << property.second.get_value<std::string>() << "\n";
}
}
Run Code Online (Sandbox Code Playgroud)
其内容格式如下:
[{"number": 1234,"string": "hello world"}, {"number": 5678,"string": "foo bar"}, ... etc }]
Run Code Online (Sandbox Code Playgroud)
我无法让它读出 ,1234然后读出hello world。事实上,它什么也没做。如何从我的.JSON文件中读出?
BOWImgDescriptorExtractor必须接收 32F 所以SURF或SIFT必须用于DescriptorExtractor,但对于FeatureDetector肯定可以是任何你想要的,对吧?
我只需要在这里澄清一下,我只见过人们说“您不能使用ORBwith Bow”,但是在检测功能时,为什么使用哪个很重要?