- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试编写一些使用 openCV 函数的代码。我从文档中提供的一些示例代码开始:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1]); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image ); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
当我尝试在 Eclipse-CDT 中构建它时,我得到了这个:
**** Build of configuration Debug for project openCV1 ****
make all
Building target: openCV1
Invoking: Cross G++ Linker
g++ -L/usr/local/lib -o "openCV1" ./src/displayImage.o
./src/displayImage.o: In function `main':
/home/jackstinger/workspace1/openCV1/Debug/../src/displayImage.cpp:25: undefined reference to `cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/home/jackstinger/workspace1/openCV1/Debug/../src/displayImage.cpp:33: undefined reference to `cv::namedWindow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
/home/jackstinger/workspace1/openCV1/Debug/../src/displayImage.cpp:34: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
/home/jackstinger/workspace1/openCV1/Debug/../src/displayImage.cpp:34: undefined reference to `cv::imshow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
/home/jackstinger/workspace1/openCV1/Debug/../src/displayImage.cpp:36: undefined reference to `cv::waitKey(int)'
./src/displayImage.o: In function `~Mat':
/usr/local/include/opencv2/core/mat.hpp:278: undefined reference to `cv::fastFree(void*)'
./src/displayImage.o: In function `cv::Mat::operator=(cv::Mat const&)':
/usr/local/include/opencv2/core/mat.hpp:298: undefined reference to `cv::Mat::copySize(cv::Mat const&)'
./src/displayImage.o: In function `cv::Mat::release()':
/usr/local/include/opencv2/core/mat.hpp:367: undefined reference to `cv::Mat::deallocate()'
collect2: ld returned 1 exit status
make: *** [openCV1] Error 1
**** Build Finished ****
相同的代码,当我使用 g++ 构建时(g++ -o displayImageInput displayImageInput.cpp
pkg-config opencv --cflags --libs)有效。
然后我更改了代码使图像变成灰度,
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1]); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
Mat grey;
cvtColor(image, grey, CV_BGR2GRAY);
namedWindow("image", CV_WINDOW_AUTOSIZE);
imshow("image", grey);
waitKey(); // Wait for a keystroke in the window
return 0;
}
在使用 g++ 构建时出现以下错误:
dispImgSobel.cpp: In function ‘int main(int, char**)’:
dispImgSobel.cpp:34:27: error: ‘CV_BGR2GRAY’ was not declared in this scope
dispImgSobel.cpp:34:38: error: ‘cvtColor’ was not declared in this scope
我在两件事上需要帮助,如何让它在 Eclipse 中工作,其次,如何解决这个范围错误,用于这个和 future 的用例。
最佳答案
第一个错误是链接器问题。你没有链接到 opencv_core.a 和 opencv_highgui.a
经验法则:对于您包含的每个模块 header ,您都需要链接相应的库。
第二个是编译器问题,您忘记了 header ,#include <opencv2/imgproc/imgproc.hpp>
而且,当然。需要链接opencv_imgproc
关于c++ - "Function not declared in this scope"编译openCV代码出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17878160/
我在这里有我的 javascript 代码: define(['controllers/controllers', 'services/alerts'], function(module) {
的意义是什么scope = scope-token *( SP scope-token ) scope-token = 1*( %x21 / %x23-5B / %x5D-7E ) 在 RFC6749
我是 AngularJS 的新手。我试图找出这两个 Controller 定义之间的区别: app.controller('simpleController', ['$scope', function
似乎所有 Guice 的开箱即用 Scope 实现本质上都是基于线程的(或完全忽略线程): Scopes.SINGLETON和 Scopes.NO_SCOPE忽略线程并且是边缘情况:全局范围和无范围。
如果这个问题涉及的是一个常见问题,我很抱歉,但我发现这个问题非常抽象,并且无法真正为其构建一个好的 Google 搜索词。 我试图理解并找到 Maven 中提供的依赖项的用例。我的想法是这样的: 假设
假设我有以下 Controller angular.module('scopeExample', []) .controller('MyController', ['$scope', func
当前在TmThemeEditor上注册的243种配色方案中, 我注意到几乎没有人使用范围选择器运算符。 对于以下情况,运算符非常有用: (text.html | text.xml) & (meta.t
我有一些行为不符合预期的代码......我在 AngularJS Controller 中有一个事件监听器,如下所示: $scope.$on("newClipSelected", function(e
首先,如果帖子太长,我深表歉意。另外,为了以防万一这会以某种方式干扰您可能给我的答案,我不会以通常的方式定义我的 Controller 。相反,我关注http://www.technofattie.c
我有一个模式,其中许多项目类型都是“可编辑的”。这意味着我有很多模板(每种可编辑项目类型一个),这些模板期望具有唯一的字段,但具有通用功能(编辑、保存、取消编辑、删除等)。这些常见功能导致 Contr
$evalAsync 和 $applyAsync 之间有什么区别?我的理解是,当我从指令中使用 $evalAsync 时,表达式将在浏览器呈现之前进行计算。 举个例子,如果我想滚动到页面上的特定位置但
我试图为一个 $scope 变量提供另一个 $scope 变量的值。有人能告诉我出了什么问题吗?查看简单的 plunker 了解详细信息: http://plnkr.co/edit/TlKnd2fM5
我有以下一段 Angular 代码 $scope.prepare = function(){ $scope.elems = [1,2,3]; }; $scope.action = functio
我正在关注 Angularjs 的官方教程,但我陷入了第 2 步。 这是一个片段,我不明白 $scope:scope 的含义, describe('PhoneListCtrl', function()
根据文档, Global: Component is shared among all users. Session: Separate instances of the component are
显示作用域变量,类似于 Angularjs 中的 ng-repeat 元素 这些是我的范围变量 $scope.published = true; $scope.count = 3; 我还有一个名为 l
我是 Angular 的新手,我想在普通的 javascript 中做一些非常简单的事情,但我无法找到如何在 Angular 中正确地做到这一点! 我想设置一个通用函数来清除输入文本字段: 我有这个
在article中发现了这样一个idea : Notice how the value function takes the scope as parameter (without the $ in
注释部分将位于 $scope.$on 下。我需要将 options 返回到我保存 $scope.$emit 的地方。请帮助!!! if (gridConfig.Batch) {
我有一个带有 2 个作用域的 Controller : app.controller('search', function($scope) { $scope.value1 = '';
我是一名优秀的程序员,十分优秀!