我正在使用canny边缘检测和查找轮廓功能(两个OpenCV)来创建分水岭变换的标记.一切正常,但我对结果并不是百分之百满意.原因是缺少一些边缘,因此丢失了重要信息.更详细的说,我得到了一堆窗口(前视图),它们是矩形,在分水岭变换之后,我最终得到了这样的结果:
但我宁愿有漂亮的矩形,这些矩形是完整的,不向一边开放.同时保持不规则的形状(房子前面的灌木,汽车..)任何想法如何解决这个问题?我想用网格覆盖整个图像,但我不能让它工作.
非常感谢你.
这是我的代码:
Mat gray;
cvtColor(im, gray, CV_BGR2GRAY);
// Use Canny instead of threshold to catch squares with gradient shading
Mat bw;
Canny(gray, bw, 0, 100, 5, true);
// Find contours
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
findContours( bw, contours, hierarchy,
CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE );
// watershed
Mat markers(bw.size(), CV_32S);
markers = Scalar::all(0);
int idx = 0;
int compCount = 0;
for( ; idx >= 0; idx = hierarchy[idx][0], compCount++ ) {
if (fabs(contourArea(contours[compCount])) < min_size )
continue;
drawContours(markers, contours, idx, …Run Code Online (Sandbox Code Playgroud) 我目前正在寻找满足我要求的C++中最快的数据结构:
我不需要删除/插入(除了最初的删除/插入)或其他任何内容.我认为堆是最好的选择.在查看STL之后,我发现大多数数据结构都不支持更新(这是关键部分).解决方案是删除并重新插入看起来很慢的元素(我的程序的瓶颈).然后我查看了boost提供的堆,发现pairing_heap给了我最好的结果.但是,所有堆仍然比MultiMap上的删除/插入过程慢.有没有人有建议,我可以尝试哪种方法/实施?
非常感谢你.
再次为了完整起见,这是我目前的时间:
编辑我的帖子以澄清一些事情:
我所拥有的:Tensorflow中经过训练的递归神经网络。
我想要的是:一个可以尽快运行此网络的移动应用程序(仅推理模式,无需培训)。
我相信有多种方法可以实现我的目标,但是我想请您提供反馈/更正和补充,因为我以前从未这样做过。
有关移动应用程序的一些详细信息。该应用程序将对用户进行录音,进行一些处理(例如Speech2Text)并输出文本。我不想找到“足够快”的解决方案,而是最快的选择,因为这将在非常大的声音文件中发生。因此,几乎每个速度提高都至关重要。您有什么建议,我应该如何解决这个问题?
最后一个问题:如果我尝试雇用某个人来帮助我,我是否应该寻找Android / iOS,嵌入式或Tensorflow型人员?
我正在尝试导入我之前在Windows下使用C++ 11和OpenCV编写的项目,但它给了我麻烦,我无法弄清楚为什么.这是一个MakeFile项目,我添加了一行来启用C++ 11支持.但是,当我试图在eclipse中运行"make"或运行项目时,我收到以下错误(以及其他一些错误)
use of deleted function ‘std::basic_filebuf<char>& std::basic_filebuf<char>::operator=(const std::basic_filebuf<char>&)’ FacadeLabelingV2 line 599, external location: /usr/include/c++/4.8/fstream
Run Code Online (Sandbox Code Playgroud)
我的代码看起来像这样:
#ifndef _FILEUTIL_CPP_
#define _FILEUTIL_CPP_
#include "Configuration.h"
#include "Utilities.cpp"
#include <iostream>
#include <fstream>
static void saveFeatures(const std::pair<cv::Mat, cv::Mat>& features, const Configuration& config, bool training, bool append, int counter = 0){
string prefix;
if (training) {
prefix = "train";
} else {
prefix = "test";
}
std::string directory = config.dir_classifiers + config.name_of_run;
std::ofstream save_file;
std::string counter_appendix = std::to_string(counter / 50);
std::string path_temp = directory + …Run Code Online (Sandbox Code Playgroud) 对于我当前的项目,我需要创建一个 256 位 AVX 向量的向量。我用了
myVector = vector<__m256d>(nrVars(), _mm256_set1_pd(1.0));
Run Code Online (Sandbox Code Playgroud)
一次工作正常,但在执行该行两次后,它给了我一个分段错误。我能够想出以下代码
vector<__m256d> temp;
__m256d entry = _mm256_set1_pd(1.0);
temp = vector<__m256d>(10, entry);
temp = vector<__m256d>(10, entry);
Run Code Online (Sandbox Code Playgroud)
总是会产生分段错误。您能否向我解释为什么会这样,以及我将来如何避免这个问题?
非常感谢!
PS即使这样也行不通:
myVector.clear();
myVector.reserve(nrVars());
for (size_t i=0; i<nrVars(); ++i) {
myVector[i] = _mm256_set1_pd(1.0);
}
Run Code Online (Sandbox Code Playgroud)
并回答评论。这是一个产生段错误的完整示例:
#include <vector>
#include "immintrin.h"
using namespace std;
int main(int argc, char **argv) {
vector<__m256d> temp;
__m256d entry = _mm256_set1_pd(1.0);
temp = vector<__m256d>(10, entry);
temp = vector<__m256d>(10, entry);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
要阅读 m256d 和我正在使用的功能,请查看英特尔内部网站(https://software.intel.com/sites/landingpage/IntrinsicsGuide/)