2014年10月30日 星期四

VC++ 2012 opencv error "0xc0000005讀取位置0x00000000時發生存取違規"

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <opencv/cv.h>

using namespace cv;
using namespace std;

int main( int argc, char** argv ){
    Mat image;
    image = imread("1.jpg");
    namedWindow( "show window", CV_WINDOW_AUTOSIZE );
    imshow( "show window", image );
    waitKey(0);
    return 0;
}

應該是沒找到圖檔
建置VC++空專案時不要為方案建立目錄
將圖檔放在專案資料夾即可找到圖
x64系統
組態管理員->新增x64平台(來源複製Win32,勾選建立新專案平台

2014年10月15日 星期三

replace string in files

if we want to replace some strings in files of a folder, we can use find, xargs and sed.
for example, i want to change string '/opt/anaconda' to 'home/robot2/anaconda in many files of '/home/robot2/anaconda/bin'.
first, go to the folder
$ cd /home/robot2/anaconda/bin
then, find all files to replace the string
$ find * | xargs -i sed -i 's/\/opt\/anaconda/\/home\/robot2\/anaconda/g' {}
where '/' needs '\' to escape