我的macbook pro安装os x是OS X Yosemite系统,版本10.10.5,连华为3G网卡(型号:HU

阅读(3313)
&& && 自从系统从OS X Mavericks 10.9升级到OS X&Yosemite 10.10 后之前配置apache和php均不能正常使用了,
&& 重新设置配置如下:
 首先,查看当前系统的apache版本,终端下输入:httpd -v
  Apache/2.4.0 && 1. 启动Apache 服务&&&&& sudo apachectl start&&&&& 打开safari,访问:http://localhost,显示&It works!&表示Apache启动正常&&&&& 当前访问的是Apache的默认目录,/Library/WebServer/Documents/&& 2. 配置用户访问目录&&&&& 因为之前已经配置过用户目录,这里提一下,首先创建用户目录:mkdir& ~/Sites 此时会在当前用户的根目录下创建一个Sites目录&&&&& 可以在Sites目录下创建一个测试的html,或者cp /Library/WebServer/Documents/index.html.en ~/Sites/&&&& &&&&&& 修改当前用户目录的访问权限,这个与上一个版本一致没有变化,这里提一下修改方式:&&&&& cd /etc/apache2/users&&&&& sudo vim username.conf&&&&& 注意:这里的username是当前用户名,请根据实际情况修改& &&&&&& 输入以下内容:
&Directory "/Users/username/Sites/"&
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
&/Directory&
  保存文件,重启apache ,sudo& apachectl restart
&&&&& 修改当前文件的访问权限:sudo chmod 775 username.conf
  此时打开safari,访问http://localhost/~username/&&& , 此时页面提示~username服务器不存在,我们还需要进入下一步的设置
3. 修改apache的httpd.conf文件
  cd& /etc/apache2/
  sudo vim httpd.conf
  找到以下信息,将其前面的#去掉:
LoadModule php5_module libexec/apache2/libphp5.so
LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
Include /private/etc/apache2/extra/httpd-userdir.conf
  修改/etc/apache2/extra/httpd-userdir.conf
  sudo vim /etc/apache2/extra/httpd-userdir.conf
  找到一下信息修,将其前面的#去掉:
Include /private/etc/apache2/users/*.conf
  此时访问http://localhost/~username/, 依然无法访问,提示:You don't have permission to access /~username/ on this server.
  这里是就是新版本与老版本的区别了,需要重新打开httpd.conf文件,
  sudo vim /etc/apache2/httpd.conf
&Directory /&
AllowOverride none
Require all denied
&/Directory&
  修改为:
&Directory /&
AllowOverride none
Require all granted
&/Directory&
  重启apache,sudo apachectl restart
  此时访问:http://localhost/~username/,显示:&It works!&,恭喜你,Apache配置成功!
4. 配置PHP
  cd /etc
  sudo cp /etc/php.ini.default /etc/php.ini
  sudo apachectl restart
  创建info.php文件测试php是否安装成功
  cd ~/Sites
  vim info.php
  输入以下信息:
&h1&It works!&/h1&
&?php phpinfo(); ?&
  打开浏览器,访问http://localhost/~username/info.php,显示一下信息表示php安装配置成功~
&原文链接:
阅读排行榜如何安装Mac OS X 10.10 Yosemite系统,新手必看的完整教学_百度知道
如何安装Mac OS X 10.10 Yosemite系统,新手必看的完整教学
提问者采纳
更新Mac系统是透过线上下载的方式,例如,如果不确定MacBook Pro以及Mac是否支援Yosemite、或2009早期以上MacBook Air 2008晚期以上MacBook Pro 2007年中&#47,一般而言,紧接著是安装Yosemite的时刻;晚期以上Mac Mini 2008早期以上Mac Pro 2008早期以上Xserve 2009早期即使你的机型在上列的名单中,系统会重开机,最简单的方式为点选左上的苹果开启「关於这台Mac」、记忆体等条件),产生以下的画面。当然你最少要有2GB的记忆体.当安装完成时!接下来只要设定Apple ID、确定你的Mac型号可以执行Yosemite以及iTunes帐号可以购买更新系统,若你平常就有备份的习惯,大多数的人都会选择内建硬碟:iMac 2007年中以上机种MacBook 2008晚期铝制机种,例如运用相同空间的外接硬碟或Time Capsule备份。6,大约30分钟会完成(还是取决於你的机种,同时也要搭配具有Lightning和iOS 8的iPhone或iPad、Mac Mini以及2013晚期Mac Pro上执行,此步骤如同每次变更系统档案的动作:1,下载完毕後、iCloud云端等功能即可使用.6。紧接著会在重开机一次:在安装之前,按下那神圣的「开始」按钮吧.再次确认,按下同意就对了,管理者会以第一个优先进行安装,觉得不安心的话!4。如果进度卡在「剩下少於一分钟」即将完成的画面、MacBook Pro。5,处理器,但不代表可执行Yosemite所有的功能,备份是必备的前置作业。需特别注意的是。如果你有设定超过两个使用者的话.首次安装,系统会自动开启安装视窗。安装Yosemite、 iCloud钥匙圈,可点选「立即备份」,安装系统都会先经过苹果官方条款,备份显得格外的简单,电脑会进行最後一次的重开机,有点类似iOS更新画面,在安装之前请再次确认最後使用Time Machine的时间,下载Yosemite需要花费约一小时的时间.一如往常。备份资料.10 Yosemite了吗:无论升级任何软体、记忆体等资讯都会在这里详细的呈现.8或是更高的系统.备份完毕!以下是可以安装OS X Yosemite的Mac型号。安装之前系统会先要求输入密码,点选「软体更新」会自动帮你检查电脑需要更新的软体,请不要重新开机,打开萤幕最上方Time Machine图示会显示时间。型号更新.恭喜你已经安装完成罗,所以你必须确定「关於这台Mac」是显示10。7。8,因为从Mavericks版本开始?在正式更新前!透过苹果内建Time Machine软体,你会看见系统安装完成等字样、MacBook Air!2,Handoff及Instant Hotspot(Mac可遥控启用 iPhone 的个人热点)可在2012年以上的iMac.选择安装的硬碟,约七分钟,有几件事情你可能须要注意,耐心的等候.几分钟後想要尝试Mac OS X 10!3、OSX版本,除非你有安装第二颗硬碟在Mac里!首先
其他类似问题
为您推荐:
mac的相关知识
其他1条回答
下载好安装包后直接点击就可以安装了
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁学习笔记(3)
作为一个需要写代码的研究生,入手Macbook是很纠结的。还是想要体验一下Macbook,入手以后各种软件balabala的安装也是费了好大功夫还算顺利。安装libsvm的时候,发现可以参考的经验还停留在两年前。内心是崩溃的。
半参考半尝试,最终成功安装了Libsvm。
环境:OS X OS X Yosemite 10.10.5+matlab2014b +Xcode7.11+Libsvm-3.20
安装matlab
安装Xcode+Command line tool
编译Libsvm的准备
有查到一种方法是使用patch打补丁,可是能够找到的patch真的是很老很老的,没法用。
在这里不用patch。只是在两个文件里相应的位置修改一下以适应自己安装的Xcode版本。
(1) mex -setup
这一步运行成功,可以看到的是
/Applications/MATLAB_R2013a.app/bin/mexopts.sh :
Template Options file for building MEX-files
所以,首先需要改的就是对应目录下的mexopts.sh文件。
打开mexopts.sh文件
$ vi ~/.matlab/R2012b/mexopts.sh
第162~164行改成:
SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX***10.11***.sdk'
MACOSX_DEPLOYMENT_TARGET='***10.11***'
加粗斜体的***10.11***部分,可以根据SDKROOT前面的目录在自己安装的Xcode里面找到,正确设置才可以。
(2) mbuild -setup
这一步运行成功,可以看到的是
/Applications/MATLAB_R2013a.app/bin/mbuildopts.sh :
Build and link with MATLAB Compiler generated library via the system ANSI C/C++ compiler
因此第二个需要修改的文件就是mbuildopts.sh
跟修改mexopts.sh相同,打开mbuildopts.sh,在相应的位置修改:
SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX***10.11***.sdk'
MACOSX_DEPLOYMENT_TARGET='***10.11***'
(3)还可能出现的错误
In file included from /Applications/MATLAB_R2013a.app/extern/include/mex.h:58:
In file included from /Applications/MATLAB_R2013a.app/extern/include/matrix.h:294:
/Applications/MATLAB_R2013a.app/extern/include/tmwtypes.h:819:9: error: unknown type name 'char16_t'
typedef char16_t CHAR16_T;
把tmwtypes.h文件里面的
typedef char16_t CHAR16_T;
typedef UINT16_T CHAR16_T;
然后就可以进行编译了。
4.编译Libsvm
将matlab的工作目录切换到limsvm-3.20所在的路径,在command 里面进行
当你看到产生了一些mexmaci64后缀的文件,说明编译成功了。
也可以在网上找一下包里自带的例子测试一下。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:512次
排名:千里之外OS X yosemite 10.10.5(1)
opencv2.4.10
MacBook Pro (系统10.10) 安装opencv2.4.10过程
需要安装的内容
home brewcmake3.3.1opencv2.4.10
安装流程:
安装home brew:
根据官网说明,在终端中输入 ruby -e &$(curl -fsSL /Homebrew/install/master/install)” & 即可
安装cmake3.3.1:
home brew 安装成功后 在终端输入 sudo brew install cmake& 自动安装最新版本的cmake;&
安装opencv2.4.10
下载opencv2.4.10压缩包,双击会自动解压;进入opencv2.4.10目录;
例如我的opencv2.4.10下载放在下载文件夹中,打开终端正常会在下载文件夹的上一个目录,所以在终端输入
cd Downloads/opencv-2.4-2.10 & “opencv-2.4-2.10 ”是我的opencv文件名;需要修改为自己的opencv 文件名;
进去之后在终端中输入分别如下内容
& mkdir release
& cd release
& cmake -G &Unix Makefiles& ..
& 由于opencv2.4.10在make的过程中会出问题,所以直接修改其原文件,需要修改的文件名为////calibfilter.cpp,点击modules链接也可直接进入网络参考页面,用下面的内容(放在最后了)替换下载的calibfilter.
最后在终端输入sudo make install 就可以完成opencv2.4.10的安装;
安装文件会放在usr/local/include,
& & & usr/local/lib;
在Xcode6.4上测试安装的opencv,测试代码我直接在 这里copy的;
打开Xcode,点击 Get a& new Xcode Project;点击左侧的Application,选择右侧的command line tool,点击右下角的next,进入下一页,创建自己的工程名以及公司名,选择C++选项,点击next ,最后点击create,这样一个简单的工程就建立起来;在测试opencv2.4.10之前,还需要配置工程;
点击左侧的工程名,进入
找到search paths&
在header search paths中添加/usr/local/include和/usr/local/include/opencv&
同样在Library search paths中添加/usr/local/
最后一步配置linking,
在Other Linker Flags中添加一下内容
-lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab
好,所有的配置已经结束,下面替换main中的内容,需要替换册程序为
#include &iostream&
#include &opencv2/core/core.hpp&
#include &opencv2/highgui/highgui.hpp&
#include &opencv2/opencv.hpp&
IplImage* doCanny(IplImage* image_input,
& & & & & & & & & double lowThresh,
& & & & & & & & & double highThresh,
& & & & & & & & & double aperture)
& & if(image_input-&nChannels != 1)
& & & & return (0);
& & IplImage* image_output = cvCreateImage(cvGetSize(image_input),
&& & & & & & & & & & & & & & & & & & & & & image_input-&depth,
&& & & & & & & & & & & & & & & & & & & & & image_input-&nChannels);
& & cvCanny(image_input,image_output,lowThresh,highThresh,aperture);
& & return(image_output);
int main(int argc, char* argv[])
& & cvNamedWindow(&Camera& , CV_WINDOW_AUTOSIZE );
& & CvCapture* capture = cvCreateCameraCapture(CV_CAP_ANY);
& & assert(capture != NULL);
& & IplImage *frame = 0;
& & frame = cvQueryFrame(capture);
& & IplImage *frame_edge = cvCreateImage(cvGetSize(frame),
&& & & & & & & & & & & & & & & & & & & & IPL_DEPTH_8U,
&& & & & & & & & & & & & & & & & & & & & 1);
& & while(1)
& & & & frame = cvQueryFrame(capture);
& & & & if(!frame)
& & & & cvConvertImage(frame,frame_edge,0);
& & & & frame = cvCloneImage(frame_edge);
& & & & frame_edge = doCanny(frame_edge,70,90,3);
& & & & cvShowImage(&Camera&,frame_edge);
& & & & char c = cvWaitKey(15);
& & & & if(c == 27)&
& & cvReleaseCapture(&capture);
& & cvReleaseImage( &frame_edge );
& & cvReleaseImage( &frame);
& & return (int)0;
附录(需要替换的calibfilter.cpp):
/*M///////////////////////////////////////////////////////////////////////////////////////
//& IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//& By downloading, copying, installing or using the software you agree to this license.
//& If you do not agree to this license, do not download, install,
//& copy or use the software.
//& & & & & & & & & & & & Intel License Agreement
//& & & & & & & & For Open Source Computer Vision Library
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
// & * Redistribution's of source code must retain the above copyright notice,
// & & this list of conditions and the following disclaimer.
// & * Redistribution's in binary form must reproduce the above copyright notice,
// & & this list of conditions and the following disclaimer in the documentation
// & & and/or other materials provided with the distribution.
// & * The name of Intel Corporation may not be used to endorse or promote products
// & & derived from this software without specific prior written permission.
// This software is provided by the copyright holders and contributors &as is& and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitu
// loss of use, data, or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
&precomp.hpp&
#undef quad
CvCalibFilter::CvCalibFilter()
& & /* etalon data */
& & etalonType = CV_CALIB_ETALON_USER;
& & etalonParamCount = 0;
& & etalonParams = 0;
& & etalonPointCount = 0;
& & etalonPoints = 0;
& & /* camera data */
& & cameraCount = 1;
& & memset( points, 0,
sizeof(points));
& & memset( undistMap, 0,
sizeof(undistMap));
& & undistImg = 0;
& & memset( latestCounts, 0,
sizeof(latestCounts));
& & memset( latestPoints, 0,
sizeof(latestPoints));
& & memset( &stereo, 0,
sizeof(stereo) );
& & maxPoints = 0;
& & framesTotal = 15;
& & framesAccepted = 0;
& & isCalibrated = false;
& & imgSize = cvSize(0,0);
& & grayImg = 0;
& & tempImg = 0;
& & storage = 0;
& & memset( rectMap, 0,
sizeof(rectMap));
CvCalibFilter::~CvCalibFilter()
& & SetCameraCount(0);
& & cvFree( &etalonParams );
& & cvFree( &etalonPoints );
& & cvReleaseMat( &grayImg );
& & cvReleaseMat( &tempImg );
& & cvReleaseMat( &undistImg );
& & cvReleaseMemStorage( &storage );
bool CvCalibFilter::SetEtalon( CvCalibEtalonType type,
double* params,
&& & & & & & & & & & & & & & & int pointCount, CvPoint2D32f* _points )
& & int i, arrS
& & Stop();
& & for( i = 0; i & MAX_CAMERAS; i++ )
& & & & cvFree( latestPoints + i );
& & if( type == CV_CALIB_ETALON_USER || type != etalonType )
& & & & if (etalonParams != NULL)
& & & & & & cvFree( &etalonParams );
& & etalonType =
& & switch( etalonType )
& & case CV_CALIB_ETALON_CHESSBOARD:
& & & & etalonParamCount = 3;
& & & & if( !params || cvRound(params[0]) != params[0] || params[0] &
& & & & & & cvRound(params[1]) != params[1] || params[1] &
3 || params[2] &= 0 )
& & & & & & assert(0);
& & & & & & return false;
& & & & pointCount = cvRound((params[0] -
1)*(params[1] - 1));
& & & & break;
& & case CV_CALIB_ETALON_USER:
& & & & etalonParamCount = 0;
& & & & if( !_points || pointCount &
& & & & & & assert(0);
& & & & & & return false;
& & & & break;
& & default:
& & & & assert(0);
& & & & return false;
& & if( etalonParamCount & 0 )
& & & & arrSize = etalonParamCount * sizeof(etalonParams[0]);
& & & & etalonParams = (double*)cvAlloc( arrSize );
& & arrSize = pointCount * sizeof(etalonPoints[0]);
& & if( etalonPointCount != pointCount )
& & & & if (etalonPoints != NULL)
& & & & & & cvFree( &etalonPoints );
& & & & etalonPointCount = pointC
& & & & etalonPoints = (CvPoint2D32f*)cvAlloc( arrSize );
& & switch( etalonType )
& & case CV_CALIB_ETALON_CHESSBOARD:
& & & & & & int etalonWidth = cvRound( params[0] ) -
& & & & & & int etalonHeight = cvRound( params[1] ) -
& & & & & & int x, y, k = 0;
& & & & & & etalonParams[0] = etalonW
& & & & & & etalonParams[1] = etalonH
& & & & & & etalonParams[2] = params[2];
& & & & & & for( y = 0; y & etalonH y++ )
& & & & & & & & for( x = 0; x & etalonW x++ )
& & & & & & & & {
& & & & & & & & & & etalonPoints[k++] = cvPoint2D32f( (etalonWidth -
1 - x)*params[2],
& & & & & & & & & & & & & & & & & & & & & & & & & & & y*params[2] );
& & & & & & & & }
& & & & break;
& & case CV_CALIB_ETALON_USER:
& & & & if (params != NULL)
& & & & & & memcpy( etalonParams, params, arrSize );
& & & & if (_points != NULL)
& & & & & & memcpy( etalonPoints, _points, arrSize );
& & & & break;
& & default:
& & & & assert(0);
& & & & return false;
& & return true;
CvCalibEtalonType
CvCalibFilter::GetEtalon( int* paramCount,
const double** params,
& & & & & & & & & & & & & int* pointCount,
const CvPoint2D32f** _points ) const
& & if( paramCount )
& & & & *paramCount = etalonParamC
& & if( params )
& & & & *params = etalonP
& & if( pointCount )
& & & & *pointCount = etalonPointC
& & if( _points )
& & & & *_points = etalonP
& & return etalonT
void CvCalibFilter::SetCameraCount(
int count )
& & Stop();
& & if( count != cameraCount )
& & & & for( int i =
0; i & cameraC i++ )
& & & & & & cvFree( points + i );
& & & & & & cvFree( latestPoints + i );
& & & & & & cvReleaseMat( &undistMap[i][0] );
& & & & & & cvReleaseMat( &undistMap[i][1] );
& & & & & & cvReleaseMat( &rectMap[i][0] );
& & & & & & cvReleaseMat( &rectMap[i][1] );
& & & & memset( latestCounts, 0,
sizeof(latestCounts) );
& & & & maxPoints = 0;
& & & & cameraCount =
bool CvCalibFilter::SetFrames(
int frames )
& & if( frames & 5 )
& & & & assert(0);
& & & & return false;
& & framesTotal =
& & return true;
void CvCalibFilter::Stop(
bool calibrate )
& & int i,
& & isCalibrated = false;
& & // deallocate undistortion maps
& & for( i = 0; i & cameraC i++ )
& & & & cvReleaseMat( &undistMap[i][0] );
& & & & cvReleaseMat( &undistMap[i][1] );
& & & & cvReleaseMat( &rectMap[i][0] );
& & & & cvReleaseMat( &rectMap[i][1] );
& & if( calibrate && framesAccepted &
& & & & int n = framesA
& & & & CvPoint3D32f* buffer =
& & & & & & (CvPoint3D32f*)cvAlloc( n * etalonPointCount *
sizeof(buffer[0]));
& & & & CvM
& & & & float* rotMatr = (float*)cvAlloc( n *
9 * sizeof(rotMatr[0]));
& & & & float* transVect = (float*)cvAlloc( n *
3 * sizeof(transVect[0]));
& & & & int* counts = (int*)cvAlloc( n *
sizeof(counts[0]));
& & & & cvInitMatHeader( &mat, 1,
sizeof(CvCamera)/sizeof(float), CV_32FC1,
& & & & memset( cameraParams, 0, cameraCount *
sizeof(cameraParams[0]));
& & & & for( i = 0; i & framesA i++ )
& & & & & & counts[i] = etalonPointC
& & & & & & for( j = 0; j & etalonPointC j++ )
& & & & & & & & buffer[i * etalonPointCount + j] = cvPoint3D32f( etalonPoints[j].x,
&& & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & etalonPoints[j].y,
& & & & for( i = 0; i & cameraC i++ )
& & & & & & cvCalibrateCamera( framesAccepted, counts,
&& & & & & & & & & & & & & & & imgSize, points[i], buffer,
&& & & & & & & & & & & & & & & cameraParams[i].distortion,
&& & & & & & & & & & & & & & & cameraParams[i].matrix,
&& & & & & & & & & & & & & & & transVect, rotMatr, 0 );
& & & & & & cameraParams[i].imgSize[0] = (float)imgSize.
& & & & & & cameraParams[i].imgSize[1] = (float)imgSize.
//& & & & & & cameraParams[i].focalLength[0] = cameraParams[i].matrix[0];
//& & & & & & cameraParams[i].focalLength[1] = cameraParams[i].matrix[4];
//& & & & & & cameraParams[i].principalPoint[0] = cameraParams[i].matrix[2];
//& & & & & & cameraParams[i].principalPoint[1] = cameraParams[i].matrix[5];
& & & & & & memcpy( cameraParams[i].rotMatr, rotMatr,
9 * sizeof(rotMatr[0]));
& & & & & & memcpy( cameraParams[i].transVect, transVect,
3 * sizeof(transVect[0]));
& & & & & & mat.data.ptr = (uchar*)(cameraParams + i);
& & & & & & /* check resultant camera parameters: if there are some INF's or NAN's,
&& & & & & & & stop and reset results */
& & & & & & if( !cvCheckArr( &mat, CV_CHECK_RANGE | CV_CHECK_QUIET, -10000,
& & & & & & & & break;
& & & & isCalibrated = i == cameraC
& & & & {/* calibrate stereo cameras */
& & & & & & if( cameraCount == 2 )
& & & & & & {
& & & & & & & & stereo.camera[0] = &cameraParams[0];
& & & & & & & & stereo.camera[1] = &cameraParams[1];
& & & & & & & & icvStereoCalibration( framesAccepted, counts,
&& & & & & & & & & & & & & & & & & imgSize,
&& & & & & & & & & & & & & & & & & points[0],points[1],
&& & & & & & & & & & & & & & & & & buffer,
&& & & & & & & & & & & & & & & & & &stereo);
& & & & & & }
& & & & cvFree( &buffer );
& & & & cvFree( &counts );
& & & & cvFree( &rotMatr );
& & & & cvFree( &transVect );
& & framesAccepted = 0;
bool CvCalibFilter::FindEtalon( IplImage** imgs )
& & return FindEtalon( (CvMat**)imgs );
bool CvCalibFilter::FindEtalon( CvMat** mats )
& & bool result = true;
& & if( !mats || etalonPointCount ==
& & & & assert(0);
& & & & result = false;
& & if( result )
& & & & int i, tempPointCount0 = etalonPointCount*2;
& & & & for( i = 0; i & cameraC i++ )
& & & & & & if( !latestPoints[i] )
& & & & & & & & latestPoints[i] = (CvPoint2D32f*)
& & & & & & & & & & cvAlloc( tempPointCount0*2*sizeof(latestPoints[0]));
& & & & for( i = 0; i & cameraC i++ )
& & & & & & CvS
& & & & & & int tempPointCount = tempPointCount0;
& & & & & & bool found = false;
& & & & & & if( !CV_IS_MAT(mats[i]) && !CV_IS_IMAGE(mats[i]))
& & & & & & {
& & & & & & & & assert(0);
& & & & & & & & break;
& & & & & & }
& & & & & & size = cvGetSize(mats[i]);
& & & & & & if( size.width != imgSize.width || size.height != imgSize.height )
& & & & & & {
& & & & & & & & imgSize =
& & & & & & }
& & & & & & if( !grayImg || grayImg-&width != imgSize.width ||
& & & & & & & & grayImg-&height != imgSize.height )
& & & & & & {
& & & & & & & & cvReleaseMat( &grayImg );
& & & & & & & & cvReleaseMat( &tempImg );
& & & & & & & & grayImg = cvCreateMat( imgSize.height, imgSize.width, CV_8UC1 );
& & & & & & & & tempImg = cvCreateMat( imgSize.height, imgSize.width, CV_8UC1 );
& & & & & & }
& & & & & & if( !storage )
& & & & & & & & storage = cvCreateMemStorage();
& & & & & & switch( etalonType )
& & & & & & {
& & & & & & case CV_CALIB_ETALON_CHESSBOARD:
& & & & & & & & if( CV_MAT_CN(cvGetElemType(mats[i])) ==
& & & & & & & & & & cvCopy( mats[i], grayImg );
& & & & & & & & else
& & & & & & & & & & cvCvtColor( mats[i], grayImg, CV_BGR2GRAY );
& & & & & & & & found = cvFindChessBoardCornerGuesses( grayImg, tempImg, storage,
&& & & & & & & & & & & & & & & & & & & & & & & & & & &
cvSize( cvRound(etalonParams[0]),
&& & & & & & & & & & & & & & & & & & & & & & & & & & &
cvRound(etalonParams[1])),
&& & & & & & & & & & & & & & & & & & & & & & & & & & & latestPoints[i], &tempPointCount ) !=
& & & & & & & & if( found )
& & & & & & & & & & cvFindCornerSubPix( grayImg, latestPoints[i], tempPointCount,
& & & & & & & & & & & & & & & & & & & & cvSize(5,5),
cvSize(-1,-1),
& & & & & & & & & & & & & & & & & & & & cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,10,0.1));
& & & & & & & & break;
& & & & & & default:
& & & & & & & & assert(0);
& & & & & & & & result = false;
& & & & & & & & break;
& & & & & & }
& & & & & & latestCounts[i] = found ? tempPointCount : -tempPointC
& & & & & & result = result &&
& & if( storage )
& & & & cvClearMemStorage( storage );
& & return
bool CvCalibFilter::Push(
const CvPoint2D32f** pts )
& & bool result = true;
& & int i, newMaxPoints = etalonPointCount*(MAX(framesAccepted,framesTotal) +
& & isCalibrated = false;
& & if( !pts )
& & & & for( i = 0; i & cameraC i++ )
& & & & & & if( latestCounts[i] &=
& & & & & & & & return false;
& & & & pts = (const CvPoint2D32f**)latestP
& & for( i = 0; i & cameraC i++ )
& & & & if( !pts[i] )
& & & & & & assert(0);
& & & & & & break;
& & & & if( maxPoints & newMaxPoints )
& & & & & & CvPoint2D32f* prev = points[i];
& & & & & & cvFree( points + i );
& & & & & & points[i] = (CvPoint2D32f*)cvAlloc( newMaxPoints *
sizeof(prev[0]));
& & & & & & memcpy( points[i], prev, maxPoints *
sizeof(prev[0]));
& & & & memcpy( points[i] + framesAccepted*etalonPointCount, pts[i],
& & & & & & & & etalonPointCount*sizeof(points[0][0]));
& & if( maxPoints & newMaxPoints )
& & & & maxPoints = newMaxP
& & result = i == cameraC
& & if( ++framesAccepted &= framesTotal )
& & & & Stop( true );
& & return
bool CvCalibFilter::GetLatestPoints(
int idx, CvPoint2D32f** pts,
&& & & & & & & & & & & & & & & & & & int* count,
bool* found )
& & if( (unsigned)idx &= (unsigned)cameraCount ||
& & & & !pts || !count || !found )
& & & & assert(0);
& & & & return false;
& & n = latestCounts[idx];
& & *found = n & 0;
& & *count = abs(n);
& & *pts = latestPoints[idx];
& & return true;
void CvCalibFilter::DrawPoints( IplImage** dst )
& & DrawPoints( (CvMat**)dst );
void CvCalibFilter::DrawPoints( CvMat** dstarr )
& & int i,
& & if( !dstarr )
& & & & assert(0);
& & & & return;
& & for( i = 0; i & cameraC i++ )
& & & & if( dstarr[i] && latestCounts[i] )
& & & & & & CvMat dst_stub, *
& & & & & & int count = 0;
& & & & & & bool found = false;
& & & & & & CvPoint2D32f* pts = 0;
& & & & & & GetLatestPoints( i, &pts, &count, &found );
& & & & & & dst = cvGetMat( dstarr[i], &dst_stub );
& & & & & & static const CvScalar line_colors[] =
& & & & & & {
& & & & & & & & {{0,0,255}},
& & & & & & & & {{0,128,255}},
& & & & & & & & {{0,200,200}},
& & & & & & & & {{0,255,0}},
& & & & & & & & {{200,200,0}},
& & & & & & & & {{255,0,0}},
& & & & & & & & {{255,0,255}}
& & & & & & };
& & & & & & const int colorCount =
sizeof(line_colors)/sizeof(line_colors[0]);
& & & & & & const int r =
& & & & & & CvScalar color = line_colors[0];
& & & & & & CvPoint prev_pt = { 0,
& & & & & & for( j = 0; j & j++ )
& & & & & & {
& & & & & & & & CvP
& & & & & & & & pt.x = cvRound(pts[j].x);
& & & & & & & & pt.y = cvRound(pts[j].y);
& & & & & & & & if( found )
& & & & & & & & {
& & & & & & & & & & if( etalonType == CV_CALIB_ETALON_CHESSBOARD )
& & & & & & & & & & & & color = line_colors[(j/cvRound(etalonParams[0]))%colorCount];
& & & & & & & & & & else
& & & & & & & & & & & & color = CV_RGB(0,255,0);
& & & & & & & & & & if( j != 0 )
& & & & & & & & & & & & cvLine( dst, prev_pt, pt, color,
1, CV_AA );
& & & & & & & & }
& & & & & & & & cvLine( dst, cvPoint( pt.x - r, pt.y - r ),
& & & & & & & & & & & & cvPoint( pt.x + r, pt.y + r ), color,
1, CV_AA );
& & & & & & & & cvLine( dst, cvPoint( pt.x - r, pt.y + r),
& & & & & & & & & & & & cvPoint( pt.x + r, pt.y - r), color,
1, CV_AA );
& & & & & & & & cvCircle( dst, pt, r+1, color,
1, CV_AA );
& & & & & & & & prev_pt =
& & & & & & }
/* Get total number of frames and already accepted pair of frames */
int CvCalibFilter::GetFrameCount(
int* total ) const
& & if( total )
& & & & *total = framesT
& & return framesA
/* Get camera parameters for specified camera. If camera is not calibrated
&& the function returns 0 */
const CvCamera* CvCalibFilter::GetCameraParams(
int idx ) const
& & if( (unsigned)idx &= (unsigned)cameraCount )
& & & & assert(0);
& & & & return 0;
& & return isCalibrated ? cameraParams + idx :
/* Get camera parameters for specified camera. If camera is not calibrated
&& the function returns 0 */
const CvStereoCamera* CvCalibFilter::GetStereoParams()
& & if( !(isCalibrated && cameraCount ==
& & & & assert(0);
& & & & return 0;
& & return &
/* Sets camera parameters for all cameras */
bool CvCalibFilter::SetCameraParams( CvCamera* params )
& & int arrS
& & Stop();
& & if( !params )
& & & & assert(0);
& & & & return false;
& & arrSize = cameraCount * sizeof(params[0]);
& & cvInitMatHeader( &mat, 1, cameraCount * (arrSize/sizeof(float)),
&& & & & & & & & & & CV_32FC1, params );
& & cvCheckArr( &mat, CV_CHECK_RANGE, -10000,
& & memcpy( cameraParams, params, arrSize );
& & isCalibrated = true;
& & return true;
bool CvCalibFilter::SaveCameraParams(
const char* filename )
& & if( isCalibrated )
& & & & int i,
& & & & FILE* f = fopen( filename,
& & & & if( !f ) return
& & & & fprintf( f, &%d\n\n&, cameraCount );
& & & & for( i = 0; i & cameraC i++ )
& & & & & & for( j = 0; j & (int)(sizeof(cameraParams[i])/sizeof(float)); j++ )
& & & & & & {
& & & & & & & & fprintf( f, &%15.10f &, ((float*)(cameraParams + i))[j] );
& & & & & & }
& & & & & & fprintf( f, &\n\n& );
& & & & /* Save stereo params */
& & & & /* Save quad */
& & & & for( i = 0; i &
2; i++ )
& & & & & & for( j = 0; j &
4; j++ )
& & & & & & {
& & & & & & & & fprintf(f, &%15.10f &, stereo.quad[i][j].x );
& & & & & & & & fprintf(f, &%15.10f &, stereo.quad[i][j].y );
& & & & & & }
& & & & & & fprintf(f, &\n&);
& & & & /* Save coeffs */
& & & & for( i = 0; i &
2; i++ )
& & & & & & for( j = 0; j &
9; j++ )
& & & & & & {
& & & & & & & & fprintf(f, &%15.10lf &, stereo.coeffs[i][j/3][j%3] );
& & & & & & }
& & & & & & fprintf(f, &\n&);
& & & & fclose(f);
& & & & return true;
& & return true;
bool CvCalibFilter::LoadCameraParams(
const char* filename )
& & int i,
& & int d = 0;
& & FILE* f = fopen( filename,
& & isCalibrated = false;
& & if( !f ) return
& & if( fscanf( f,
&%d&, &d ) != 1 || d &=
0 || d & 10 )
& & & & return false;
& & SetCameraCount( d );
& & for( i = 0; i & cameraC i++ )
& & & & for( j = 0; j & (int)(sizeof(cameraParams[i])/sizeof(float)); j++ )
& & & & & & int values_read = fscanf( f,
&%f&, &((float*)(cameraParams + i))[j] );
& & & & & & CV_Assert(values_read ==
& & /* Load stereo params */
& & /* load quad */
& & for( i = 0; i &
2; i++ )
& & & & for( j = 0; j &
4; j++ )
& & & & & & int values_read = fscanf(f,
&%f &, &(stereo.quad[i][j].x) );
& & & & & & CV_Assert(values_read ==
& & & & & & values_read = fscanf(f,
&%f &, &(stereo.quad[i][j].y) );
& & & & & & CV_Assert(values_read ==
& & /* Load coeffs */
& & for( i = 0; i &
2; i++ )
& & & & for( j = 0; j &
9; j++ )
& & & & & & int values_read = fscanf(f,
&%lf &, &(stereo.coeffs[i][j/3][j%3]) );
& & & & & & CV_Assert(values_read ==
& & fclose(f);
& & stereo.warpSize = cvSize( cvRound(cameraParams[0].imgSize[0]),
cvRound(cameraParams[0].imgSize[1]));
& & isCalibrated = true;
& & return true;
bool CvCalibFilter::Rectify( IplImage** srcarr, IplImage** dstarr )
& & return Rectify( (CvMat**)srcarr, (CvMat**)dstarr );
bool CvCalibFilter::Rectify( CvMat** srcarr, CvMat** dstarr )
& & if( !srcarr || !dstarr )
& & & & assert(0);
& & & & return false;
& & if( isCalibrated && cameraCount ==
& & & & for( i = 0; i & cameraC i++ )
& & & & & & if( srcarr[i] && dstarr[i] )
& & & & & & {
& & & & & & & & IplImage src_stub, *
& & & & & & & & IplImage dst_stub, *
& & & & & & & & src = cvGetImage( srcarr[i], &src_stub );
& & & & & & & & dst = cvGetImage( dstarr[i], &dst_stub );
& & & & & & & & if( src-&imageData == dst-&imageData )
& & & & & & & & {
& & & & & & & & & & if( !undistImg ||
& & & & & & & & & & & & undistImg-&width != src-&width ||
& & & & & & & & & & & & undistImg-&height != src-&height ||
& & & & & & & & & & & & CV_MAT_CN(undistImg-&type) != src-&nChannels )
& & & & & & & & & & {
& & & & & & & & & & & & cvReleaseMat( &undistImg );
& & & & & & & & & & & & undistImg = cvCreateMat( src-&height, src-&width,
&& & & & & & & & & & & & & & & & & & & & & & & & CV_8U + (src-&nChannels-1)*8 );
& & & & & & & & & & }
& & & & & & & & & & cvCopy( src, undistImg );
& & & & & & & & & & src = cvGetImage( undistImg, &src_stub );
& & & & & & & & }
& & & & & & & & cvZero( dst );
& & & & & & & & if( !rectMap[i][0] || rectMap[i][0]-&width != src-&width ||
& & & & & & & & & & rectMap[i][0]-&height != src-&height )
& & & & & & & & {
& & & & & & & & & & cvReleaseMat( &rectMap[i][0] );
& & & & & & & & & & cvReleaseMat( &rectMap[i][1] );
& & & & & & & & & & rectMap[i][0] =
cvCreateMat(stereo.warpSize.height,stereo.warpSize.width,CV_32FC1);
& & & & & & & & & & rectMap[i][1] =
cvCreateMat(stereo.warpSize.height,stereo.warpSize.width,CV_32FC1);
& & & & & & & & & & cvComputePerspectiveMap(stereo.coeffs[i], rectMap[i][0], rectMap[i][1]);
& & & & & & & & }
& & & & & & & & cvRemap( src, dst, rectMap[i][0], rectMap[i][1] );
& & & & & & }
& & & & for( i = 0; i & cameraC i++ )
& & & & & & if( srcarr[i] != dstarr[i] )
& & & & & & & & cvCopy( srcarr[i], dstarr[i] );
& & return true;
bool CvCalibFilter::Undistort( IplImage** srcarr, IplImage** dstarr )
& & return Undistort( (CvMat**)srcarr, (CvMat**)dstarr );
bool CvCalibFilter::Undistort( CvMat** srcarr, CvMat** dstarr )
& & if( !srcarr || !dstarr )
& & & & assert(0);
& & & & return false;
& & if( isCalibrated )
& & & & for( i = 0; i & cameraC i++ )
& & & & & & if( srcarr[i] && dstarr[i] )
& & & & & & {
& & & & & & & & CvMat src_stub, *
& & & & & & & & CvMat dst_stub, *
& & & & & & & & src = cvGetMat( srcarr[i], &src_stub );
& & & & & & & & dst = cvGetMat( dstarr[i], &dst_stub );
& & & & & & & & if( src-&data.ptr == dst-&data.ptr )
& & & & & & & & {
& & & & & & & & & & if( !undistImg || undistImg-&width != src-&width ||
& & & & & & & & & & & & undistImg-&height != src-&height ||
& & & & & & & & & & & & CV_ARE_TYPES_EQ( undistImg, src ))
& & & & & & & & & & {
& & & & & & & & & & & & cvReleaseMat( &undistImg );
& & & & & & & & & & & & undistImg = cvCreateMat( src-&height, src-&width, src-&type );
& & & & & & & & & & }
& & & & & & & & & & cvCopy( src, undistImg );
& & & & & & & & & & src = undistI
& & & & & & & & }
& & & & & & #if 1
& & & & & & & & {
& & & & & & & & CvMat A = cvMat(
3, 3, CV_32FC1, cameraParams[i].matrix );
& & & & & & & & CvMat k = cvMat(
1, 4, CV_32FC1, cameraParams[i].distortion );
& & & & & & & & if( !undistMap[i][0] || undistMap[i][0]-&width != src-&width ||
&& & & & & & & & & & undistMap[i][0]-&height != src-&height )
& & & & & & & & {
& & & & & & & & & & cvReleaseMat( &undistMap[i][0] );
& & & & & & & & & & cvReleaseMat( &undistMap[i][1] );
& & & & & & & & & & undistMap[i][0] =
cvCreateMat( src-&height, src-&width, CV_32FC1 );
& & & & & & & & & & undistMap[i][1] =
cvCreateMat( src-&height, src-&width, CV_32FC1 );
& & & & & & & & & & cvInitUndistortMap( &A, &k, undistMap[i][0], undistMap[i][1] );
& & & & & & & & }
& & & & & & & & cvRemap( src, dst, undistMap[i][0], undistMap[i][1] );
& & & & & & #else
& & & & & & & & cvUndistort2( src, dst, &A, &k );
& & & & & & #endif
& & & & & & & & }
& & & & & & }
& & & & for( i = 0; i & cameraC i++ )
& & & & & & if( srcarr[i] != dstarr[i] )
& & & & & & & & cvCopy( srcarr[i], dstarr[i] );
& & return true;
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:372次
排名:千里之外

我要回帖

更多关于 macbook air os x下载 的文章

 

随机推荐