我在网上安装了OpenCV3和brew的其他指南,
usrs/local/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install opencv3
/usr/local/Cellar/opencv3/3.2.0
#in fact this path "/usr/local/Cellar/opencv3/3.2.0" contains all
software installed by brew, and I have also try
to install opencv,
its path is "/usr/local/Cellar/opencv/2.4.13.2"
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
# Homebrew
#export PATH=/usr/local/bin:$PATH
# OpenCV3
export PATH="/usr/local/opt/opencv3/bin:$PATH"
add openCV3 to "Header search paths" and "Library search Paths"
Mat cv_input_image = imread("image_0001.jpg");
cout << "rows:" << cv_input_image.rows << endl;
cout << "cols:" << cv_input_image.cols << endl;
cout << "channels:" << cv_input_image.channels() << endl;
rows:0
cols:0
channels:1
我已尝试多次在我的Macbook中使用brew和不同的设置方法安装OpenCV(我是Mac新手),所有这些都不能很好地工作,我可以成功地包含其他关于OpenCV的内容,我只是不要我不知道从哪里开始解决这个问题?
顺便说一句,我也尝试过openCV(不是openCV3),我可以将它们成功地包含在我的C ++代码中
inline
MatConstIterator::MatConstIterator(const Mat* _m)
: m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0)
{
if( m && m->isContinuous() )
{
sliceStart = m->ptr();
sliceEnd = sliceStart + m->total()*elemSize;
}
seek((const int*)0);// <=======something wrong here
}
我的Xcode给了我信息:
Thread 1: EXC_ARITHMETIC(code=EXC_I386_DIV, subcode=0x0)
在我的Xcode左侧,有一个Threads列表表单索引0到9,
希望得到你的帮助~~
答案 0 :(得分:2)
使用Xcode编译时,可执行文件放在一些奇怪的临时文件夹中。因此,imread("image_0001.jpg")
很可能会失败,因为您在此处使用相对路径(即image_0001.jpg
需要与可执行文件位于同一文件夹中。要解决此问题,请尝试使用图像的绝对路径,即{ {1}}。
另一个错误可能是因为/Users/your_home/Desktop/image_0001.jpg
失败后cv_image_input
为空。