随笔:78 文章:7 评论:38 引用:0
C++博客 首页 发新随笔
发新文章 联系 聚合管理

char *name = const_cast<char*> (sname.c_str());


posted @ 2011-03-06 20:31 未央 阅读(363) | 评论 (0)编辑 收藏
 
突然想起来那年去宁波比赛,等待结果时候的焦虑,当主持人念到我们队名时,我激动的和ht握紧双手,那叫一个激动啊,摇头晃脑的,恨不得哭了。然后ht说别那么夸张,yc他们都在后面看着呢,现在想想真是好傻啊,一个铜牌至于的吗,人家拿金牌都比这淡定多了,呵呵,好傻好傻。。。。。。
posted @ 2011-03-02 16:29 未央 阅读(258) | 评论 (0)编辑 收藏
 
 

从topcoder赚钱的方法~

 (2006-11-15 19:22)
  • 标签: -  分类: 未分类

1. 算法
1.1  SRM
 钱少($30左右),而且很难。
1.2  Tournament
 钱多($1000~$10000),太难~

2. 设计和开发
2.1  构件设计和开发
 钱比较多($1000左右),而且机会很多,王道啊!
2.2  Digital Run
 分季度,前5名有很多钱($1000~$10000),而且可以去米国接受荣誉~可以争取!
2.3  Rookie of the Year
 只要在一年赛季(对于我就是2007.5.3)前通过review的submission少于6个,
 就可以参评,前十有几千刀,第一名可以去米国接受荣誉~可以争取!
 
差点忘了,还有3系列: 当reviewer,这个可是固定工资啊!
 
总结:
 以1系列和ACM修炼内功,以2系列和3系列修炼外功和赚钱~争取在研究生阶段挣个几万刀!
 
 
看了一下WishingBone的发展历程,我主要关注挣钱的事哈:
开始阶段他主要是做development,特点是工作量大,挣钱“少”,
对他来说这已经是03年的事了~
那时他最多的03年5月,做了9个~一个挣100~200刀。
然后他开始做design,特点是工作量小,挣钱多,
对他主要是05年的事,一个能挣500~1500刀。
再然后就开始他最挣钱的工作了,做reviewer!
这个工作特点是工作量极小,钱很多,一个200~1000刀。
他最多05年10月做了20个,挣了8000刀。。。。
 
牛人的经验是要学习的。
 
另外象minhu那样猛做一季的development或者design,
得个Digital Run Payment 的10000多刀也是很爽的。
另外我还有一次Rookie的机会,
要是抓住了也有好几千刀啊。
 
努力努力,money就在眼前啊!
posted @ 2011-02-25 00:47 未央 阅读(9149) | 评论 (0)编辑 收藏
 
    为什么烦躁呢?原因有很多吧,最直接的原因有两个,一 research做的不顺,二 感情方面走不出来。有什么办法吗?琦说做不出来就一直钻,直到做出来为止,因为没有别的办法,所以只能这样很痛苦的一直钻,让我想起了vuze,呵呵,总会有这样的难题发生,今天有,今后也还会有。至于感情方面,理性的我告诉自己,不合适就是不合适,现在不分早晚也会分的,委屈不一定能求全,为了别人放弃自己的理想是件大事,即使这个人非常值得这么做,时间长了也会有后悔的一天,更何况这个人并不值得;感性上的自己却不停的因为这件事而郁郁寡欢。昨天看到一个师姐的状态“看完将爱,在一起的人要坚持,因为错过的就真的回不去了”,于是鼓起勇气去了他的校内,想给他留言,问问他我们就真的这样错过了吗?结果看到他已经在move on了,自己笑了笑,我又何尝不是呢~于是想算了吧,就当教训吧,下次说分手不要那么冲动就是了,而且这个也确实不合适。今天上午还是不开心,程序又好多bug,发现写写文字真是能调节情绪啊,现在已经舒服多了,呵呵。
posted @ 2011-02-20 11:04 未央 阅读(227) | 评论 (0)编辑 收藏
 
    我一直不明白,为什么越是伤害过我的人,我越是不能忘记。而那些爱我的关心我的有恩于我的人,反而到不容易记的深刻与长久。我知道我现在一切的纠结都来自于我的不自信,心情不好的时候总是想起伤心事和那些我因爱生恨的人。所以要忘掉他们就该让自己高兴吧,自己开心了是谁也替代不了的,我不可能用我的生活去惩罚任何人,所以不要为了别人的关注而过的好或者不好,你想他的时候他存在,你不想他的时候他就不存在,那么让他消失吧,每天少想一点,总会有一天就忘记了要去想。有时候就想,找个人结婚,过一辈子,这个人得千挑万选啊,不能随便啊,可是人就是这样,在各种环境中焦虑,于是就想随便找一个差不多的算了吧,省心了,可是这样其实很对不起自己啊,而真正找到一个我爱并且爱我的人,能真心对待彼此的人又是件难于登天的事啊。既然这种事情如此困难,以至于我可以把它当做一个梦想去企及,不如还是定一个简单一点儿的目标吧,这样奋斗起来还希望一些。好吧,我未来三年的目标就是进google!至于后面的路,我是真的希望能有自己的事业,不过这只是个愿景,还没有具体的想法和行动方案。还是google简单一点,嗯嗯,好好学习理论,好好编写代码,多思考,这些做起来更有确定性,更在我的控制范围之内。所以朝着这个相对简单的目标出发吧,我会越来越好哒!层次会越来越高哒! O(∩_∩)O哈哈~
  
posted @ 2011-02-16 14:36 未央 阅读(572) | 评论 (3)编辑 收藏
 
C++中hash_map用法 orz锟大神

在所有操作中hash_map比map性能优越些。

一、构造函数
      默认构造函数、部分后全部复制另外一个hash_map。
#include <ostream>
#include <hash_map>
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;

typedef char * MyStr;

struct MyInt
{
    int i;
    friend ostream& operator<<(ostream& ii, MyInt& jj);
    MyInt(int j = 0) {
        i = j;
    }
};

struct greater_str
{
    bool operator()(const MyStr & x, const MyStr & y) const {
        if (strcmp(x, y) < 0)
            return true;

        return false;
    }
};


struct less_str {
    bool operator()(const MyStr & x, const MyStr & y) const
    {
        if (strcmp(x, y) > 0)
            return true;

        return false;
    }
};

ostream& operator<<(ostream& o, MyInt& j) {
    o << j.i;
    return o;
}

int main()
{
    using namespace stdext;
    typedef pair <MyStr, MyInt> Int_Pair;
    hash_map<MyStr, MyInt>::iterator hm1_Iter, hm3_Iter, hm4_Iter, hm5_Iter, hm6_Iter, hm7_iter;
    hash_map<MyStr, MyInt, hash_compare<MyStr, greater_str> >::iterator hm2_Iter;

    // Create an empty hash_map hm0 of key type integer
    hash_map<MyStr, MyInt> hm0;

    // Create an empty hash_map hm1 with the key comparison function of less than, then insert 4 elements
    hash_map<MyStr, MyInt, hash_compare<MyStr, less_str> > hm1;
    hm1.insert(Int_Pair("one", 0));
    hm1.insert(Int_Pair("two", 10));
    hm1.insert(Int_Pair("three", 20));
    hm1.insert(Int_Pair("four", 30));
    hm1.insert(Int_Pair("five", 40));

    // Create an empty hash_map hm2 with the key comparison function of geater than, then insert 2 elements
    hash_map<MyStr, MyInt, hash_compare<MyStr, greater_str> > hm2;
    hm2.insert(Int_Pair("one", 10));
    hm2.insert(Int_Pair("two", 20));

    // Create a hash_map hm3 with the allocator of hash_map hm1
    hash_map<MyStr, MyInt>::allocator_type hm1_Alloc;
    hm1_Alloc = hm1.get_allocator(); //成员函数get_allocator(Returns a copy of the allocator object used to construct the hash_map)
    hash_map<MyStr, MyInt, hash_compare<MyStr, less_str> > hm3(hash_compare<MyStr, less_str > (), hm1_Alloc);
    hm3.insert(Int_Pair("three", 30));

    // Create a copy, hash_map hm4, of hash_map hm1
    hash_map<MyStr, MyInt, hash_compare<MyStr, less_str> > hm4(hm1);

    // Create a hash_map hm5 by copying the range hm1[_First, _Last)
    hash_map<MyStr, MyInt>::const_iterator hm1_bcIter, hm1_ecIter;
    hm1_bcIter = hm1.begin();
    hm1_ecIter = hm1.begin();
    hm1_ecIter++;
    hm1_ecIter++;
    hash_map<MyStr, MyInt> hm5(hm1_bcIter, hm1_ecIter);

    // Create a hash_map hm6 by copying the range hm4[_First, _Last) and with the allocator of hash_map hm2
    hash_map<MyStr, MyInt>::allocator_type hm2_Alloc;
    hm2_Alloc = hm2.get_allocator();
    hash_map<MyStr, MyInt, hash_compare<MyStr, less_str> > hm6(hm4.begin(), ++hm4.begin(), hash_compare<MyStr, less_str > (), hm2_Alloc);

    cout << "hm1 =";
    for (hm1_Iter = hm1.begin(); hm1_Iter != hm1.end(); hm1_Iter++)
        cout << " " << hm1_Iter -> second;
    cout << endl;

    cout << "hm2 =";
    for (hm2_Iter = hm2.begin(); hm2_Iter != hm2.end(); hm2_Iter++)
        cout << " " << hm2_Iter -> second;
    cout << endl;

    cout << "hm3 =";
    for (hm3_Iter = hm3.begin(); hm3_Iter != hm3.end(); hm3_Iter++)
        cout << " " << hm3_Iter -> second;
    cout << endl;

    cout << "hm4 =";
    for (hm4_Iter = hm4.begin(); hm4_Iter != hm4.end(); hm4_Iter++)
        cout << " " << hm4_Iter -> second;
    cout << endl;

    cout << "hm5 =";
    for (hm5_Iter = hm5.begin(); hm5_Iter != hm5.end(); hm5_Iter++)
        cout << " " << hm5_Iter -> second;
    cout << endl;

    cout << "hm6 =";
    for (hm6_Iter = hm6.begin(); hm6_Iter != hm6.end(); hm6_Iter++)
        cout << " " << hm6_Iter -> second;
    cout << endl;

    // Create a copy, hash_map hm7, of hash_map hm1 by moving
    hash_map<MyStr, MyInt, hash_compare<MyStr, less_str> > hm7(move(hm1));

    cout << "hm7 =";
    for (hm7_Iter = hm7.begin(); hm7_Iter != hm7.end(); hm7_Iter++)
        cout << " " << hm7_Iter -> second;
    cout << endl;
}

二、基本操作方法
      访问元素——正向迭代和反向迭代:begin()、end() 与 rbegin()、rend()
      返回迭代器——hash_map::iterator(最常用的) 和 hash_map::const_iterator、hash_map::reverse_iterator(双向迭代器)

      操作符operator[ ](Inserts an element into a hash_map with a specified key value)
   typedef pair <const int, int> cInt2Int;
   hash_map <int, int> hm1;
   hash_map <int, int> :: iterator pIter;
   
   // Insert a data value of 10 with a key of 1 into a hash_map using the operator[] member function
   hm1[ 1 ] = 10;

   // Compare other ways to insert objects into a hash_map
   hm1.insert ( hash_map <int, int> :: value_type ( 2, 20 ) );
   hm1.insert ( cInt2Int ( 3, 30 ) );

   cout << "The keys of the mapped elements are:";
   for ( pIter = hm1.begin( ) ; pIter != hm1.end( ) ; pIter++ )
      cout << " " << pIter -> first;
   cout << "." << endl;

   cout << "The values of the mapped elements are:";
   for ( pIter = hm1.begin( ) ; pIter != hm1.end( ) ; pIter++ )
      cout << " " << pIter -> second;
   cout << "." << endl;

   // If the key already exists, operator[] changes the value of the datum in the element
   hm1[ 2 ] = 40;

   // operator[] will also insert the value of the data type's default constructor if the value is unspecified
   hm1[5];

   cout << "The keys of the mapped elements are now:";
   for ( pIter = hm1.begin( ) ; pIter != hm1.end( ) ; pIter++ )
      cout << " " << pIter -> first;
   cout << "." << endl;

   cout << "The values of the mapped elements are now:";
   for ( pIter = hm1.begin( ) ; pIter != hm1.end( ) ; pIter++ )
      cout << " " << pIter -> second;
   cout << "." << endl;

    hash_map的大小:size()成员函数;
    重新置hash_map为空:clear()成员函数;
    交换两个hash_map之间的元素:swap(有两种版本:一种是hash_map自身的成员函数;一种是<algrithm>中方法)
   hash_map <int, int> hm1, hm2, hm3;
   hash_map <int, int>::iterator hm1_Iter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );
   hm1.insert ( Int_Pair ( 3, 30 ) );

   hm2.insert ( Int_Pair ( 10, 100 ) );
   hm2.insert ( Int_Pair ( 20, 200 ) );

   hm3.insert ( Int_Pair ( 30, 300 ) );

   hm1.swap( hm2 );//此时,hs1中的元素就是100,200

   swap( hm1, hm3 );//此时,hs1中的元素就是300

    查找某个元素:find()成员函数;
    判断是否为空:empty()成员函数;
    统计hash_map中某个元素的个数:count( element );要么是1(即出现了该元素),要么是0(即没出现这样的元素)

    比较两个hash_map之间的关系——操作符operator==、operator!=、operator>=、operator<=
   hash_map <int, int> hm1, hm2, hm3, hm4;
   typedef pair <int, int> Int_Pair;

   for ( int i = 1 ; i < 3 ; i++ )
   {
      hm1.insert ( Int_Pair ( i, i ) );
      hm2.insert ( Int_Pair ( i, i * i ) );
      hm3.insert ( Int_Pair ( i, i - 1 ) );
      hm4.insert ( Int_Pair ( i, i ) );
   }

   if ( hm1 == hm2 )
      cout << "The hash_maps hm1 and hm2 are equal." << endl;
   else
      cout << "The hash_maps hm1 and hm2 are not equal." << endl;

   if ( hm1 <= hm2 )
      cout << "The hash_map hm1 is less than or equal to the hash_map hm2." << endl;
   else
      cout << "The hash_map hm1 is greater than the hash_map hm2." << endl;

   if ( hm1 != hm2 )
      cout << "The hash_maps hm1 and hm2 are not equal." << endl;
   else
      cout << "The hash_maps hm1 and hm2 are equal." << endl;
   if ( hm1 >= hm3 )
      cout << "The hash_map hm1 is greater than or equal to the hash_map hm3." << endl;
   else
      cout << "The hash_map hm1 is less than the hash_map hm3." << endl;

   if ( hm1 == hm4 )
      cout << "The hash_maps hm1 and hm4 are equal." << endl;
   else
      cout << "The hash_maps hm1 and hm4 are not equal." << endl;

    移除元素:erase()成员函数(Removes an element or a range of elements in a hash_map from specified positions or removes elements that match a specified key)

    hash_map<int, int> hm1, hm2, hm3;
    hash_map<int, int> :: iterator pIter, Iter1, Iter2;
    hash_map<int, int>::size_type n;
    typedef pair<int, int> Int_Pair;

    for ( int i = 1; i < 5; i++)
    {
        hm1.insert(Int_Pair (i, i));
        hm2.insert(Int_Pair (i, i*i));
        hm3.insert(Int_Pair (i, i-1));
    }

    // The 1st member function removes an element at a given position
    Iter1 = ++hm1.begin();
    hm1.erase(Iter1);

    // The 2nd member function removes elements n the range [_First, _Last)
    Iter1 = ++hm2.begin();
    Iter2 = --hm2.end();
    hm2.erase(Iter1, Iter2);

    // The 3rd member function removes elements with a given _Key
    n = hm3.erase(2);

    // The dereferenced iterator can also be used to specify a key
    Iter1 = ++hm3.begin();
    hm3.erase(Iter1);

      成员函数make_value()和value_type()用法:
#include <cliext/hash_map> 

typedef cliext::hash_map<wchar_t, int> Myhash_map; 
int main() 

    Myhash_map c1; 
    c1.insert(Myhash_map::make_value(L'a', 1)); 
    c1.insert(Myhash_map::make_value(L'b', 2)); 
    c1.insert(Myhash_map::make_value(L'c', 3)); 

    // display contents " [a 1] [b 2] [c 3]" 
    for each (Myhash_map::value_type elem in c1) 
        System::Console::Write(" [{0} {1}]", elem->first, elem->second); 
    System::Console::WriteLine(); 
    return (0); 
}

   成员函数to_array():
cli::array<hash_map<Key, Mapped>::value_type>^ to_array();

posted @ 2011-01-23 20:07 未央 阅读(3741) | 评论 (0)编辑 收藏
 
在编译VS时候,出现fatal error C1010: unexpected end of file while looking for precompiled head。问题详细解释:致命错误C1010,在寻找预编译指示头文件时,文件未预期结束。就是没有找到预编译指示信息的问文件。问题一般发生在:通过添加文件的方式,添加了一些cpp文件到一个MFC的程序,但该cpp文件并不是MFC,而是标准的C++。 解决方案1: 右键单击项目工程中的cpp文件,在菜单Project->Settings->C/C++->Precompile Header,设置为第一项:Not using precompile headers。 解决方案2:在.cpp文件开头添加包含文件stdafx.h。 #include"stdafx.h"



posted @ 2011-01-14 11:03 未央 阅读(6740) | 评论 (0)编辑 收藏
 
http://wenku.baidu.com/view/fdbf4ef5f61fb7360b4c657d.html
简单易懂,而且很好玩,呵呵
posted @ 2010-12-02 20:07 未央 阅读(748) | 评论 (0)编辑 收藏
 

 vs2008 + OpenCV-2.1.0-win32安装配置
http://blog.csdn.net/scarletty/archive/2010/05/05/5559295.aspx

vs2008 + OpenCV-2.1.0-win32-vs2008安装
1. 安装vs2008+sp1
2. 安装opencv-2.1.0-win32-vs2008,假设安装目录为c:\opencv2.1。安装过程中注意选择添加环境变量,把 “add it to your Current User PATH “前的复选框勾上 .
3. 为vs2008配置openvc,过程如下:
   工具->选项->项目和解决方案->vc++目录,
       “显示一下内容的目录”下拉列表中选择“包含文件”,添加条目“C:\OpenCV2.1\include\opencv”;
       “显示一下内容的目录”下拉列表中选择“库文件” ,添加条目“C:\OpenCV2.1\lib”;
 "显示一下内容的目录"下拉列表选择“源文件”,添加条目”C:\OpenCV2.1\src\cv” ,”C:\OpenCV2.1\src\cvaux” ,”C:

\OpenCV2.1\src\cxcore” ,”C:\OpenCV2.1\src\highgui”。
        点击“确定”。
4. 为单个工程配置运行环境,如:
   (1) 新建一个win32命令控制台项目opencvhello
   (2) 在解决方案资源管理器中右键点击项目名称opencvhello,选择“属性”,
       在“配置(C)”下拉列表中选择Debug, 然后“配置属性”->“链接器”->“输入”->附加依赖项,添加    cxcore210d.lib

cv210d.lib highgui210d.lib
       在“配置(C)”下拉列表中选择Release, 然后“配置属性”->“链接器”->“输入”->附加依赖项,添加   cxcore210.lib

cv210.lib highgui210.lib
       中间如果提示要保存的话,就保存。最后点击确定。
   (3) 测试。用下列代码代替源代码,注意imagename中保存的是图片的硬盘地址,程序的运行结果是显示imagename指向的图片。
  /***********************************************************************
 * OpenCV 2.0 测试例程
 * 于仕琪 提供
 ***********************************************************************/
 
#include "stdafx.h"
#include "highgui.h"
 
//所有的以新风格命名的函数都在 cv 命名空间中
//如果希望不要每次都输入 cv:: ,则可使用下面语句
//using namespace cv;
 
int _tmain(int argc, _TCHAR* argv[])
{
 
    const char* imagename = "E:\\OpenCV2.1\\samples\\c\\lena.jpg";
 
 cv::Mat img = cv::imread(imagename); // Matlab风格的 cvLoadImage 函数的另一种调用
    if(img.empty())
    {
        fprintf(stderr, "Can not load image %s\n", imagename);
        return -1;
    }
 
    if( !img.data ) // 检查是否正确载入图像
        return -1;
 
 cv::namedWindow("image", CV_WINDOW_AUTOSIZE); //创建窗口
 cv::imshow("image", img); //显示图像
 
 cv::waitKey();
 
 return 0;
}

VC 2008 Express下安装OpenCV2.0/2.1

http://www.opencv.org.cn/index.php/VC_2008_Express%E4%B8%8B%E5%AE%89%E8%A3%85OpenCV2.0

安装VC++ 2008 Express

Visual C++ Express是微软推出的一款免费集成开发环境,如果你没有足够资金购买Visual C++,你可以使用Visual C++ Express。本安装说明撰写时,最新的版本是Visual C++ 2008 Express.

Visual C++ 2008 Express可以从微软网站下载安装(http://www.microsoft.com/express/product/default.aspx )。

安装OpenCV

http://www.opencv.org.cn/index.php/Download 下载OpenCV 2.0,并安装,本文档假定安装目录为:D:\Program Files\OpenCV2.0

安装CMake

http://www.cmake.org/cmake/resources/software.html 下载 Windows (Win32 Installer) 安装。

编译OpenCV

用CMake导出VC++项目文件

  • 运行cmake-gui,设置路径为OpenCV安装路径(本文档假定安装位置为:D:\Program Files\OpenCV2.0),并创建子目录D:\Program Files\OpenCV2.0\vc2008,用于存放编译结果。
  • 然后点 configure,在弹出的对话框内选择 Visual Studio 9 2008。
  • 如果是VC++2008的Express版本,则不支持OpenMP,所以需要取消ENABLE_OPENMP选项,取消后再次选择“Congfigure”,完成后选择“Generate”。VC++ 2008(不是Express版本)支持OpenMP,如果你使用VC++2008,强烈建议不要取消这个选项。

点击看大图
Enlarge
点击看大图
点击看大图
Enlarge
点击看大图
点击看大图
Enlarge
点击看大图

编译 OpenCV Debug和Release版本库

完成上一步骤后,将在D:\Program Files\OpenCV2.0\vc2008目录下生成OpenCV.sln的VC Solution File,请用VC++ 2008 Express打开OpenCV.sln,然后执行如下操作:

  • 在Debug下,选择Solution Explorer里的 Solution OpenCV,点右键,运行"Rebuild Solution";如编译无错误,再选择INSTALL项目,运行"Build"。
  • 在Release下,选择Solution Explorer里的 Solution OpenCV,点右键,运行"Rebuild Solution";如编译无错误,再选择INSTALL项目,运行"Build"。

此时,OpenCV的*d.dll文件(for debug)和*.dll文件(for release)将出现在D:\Program Files\OpenCV2.0\vc2008\bin目录中;OpenCV的*d.lib文件(for debug)和*.lib文件(for release)将出现在D:\Program Files\OpenCV2.0\vc2008\lib目录;头文件*.h出现在D:\Program Files\OpenCV2.0\vc2008\include\opencv中。

可以被VC++ 2008 Express调用的OpenCV动态库生成完毕。

点击看大图
Enlarge
点击看大图
点击看大图
Enlarge
点击看大图
点击看大图
Enlarge
点击看大图
点击看大图
Enlarge
点击看大图
点击看大图
Enlarge
点击看大图

配置Windows环境变量Path

将D:\Program Files\OpenCV2.0\vc2008\bin加入Windows系统环境变量Path中。加入后可能需要注销当前Windows用户(或重启)后重新登陆才生效。

点击看大图
Enlarge
点击看大图
点击看大图
Enlarge
点击看大图

为VC++ 2008 Express配置OpenCV环境

打开VC++ 2008 Express,菜单 Tools -> Options -> Projects and Solutions -> VC++ Directories

  • Show directories for选择include files,加入目录 D:\Program Files\OpenCV2.0\vc2008\include\opencv
  • Show directories for选择library files,加入目录 D:\Program Files\OpenCV2.0\vc2008\lib

关闭VC++ 2008 Express。

点击看大图
Enlarge
点击看大图
点击看大图
Enlarge
点击看大图

使用OpenCV 2.0编程

  • 打开VC++ 2008 Express,创建一个Win32控制台程序opencvhello;
  • 选择Solution Explorer里的opencvhello项目,点击鼠标右键,选择Properties,在[链接器 LINKER]的[输入INPUT]中;
  • 为项目的Debug配置增加依赖的库:cxcore200d.lib cv200d.lib highgui200d.lib(注意,文件名cv200d.lib 可能是cv***d.lib等形式,具体应查看D:\Program Files\OpenCV2.0\vc2008\lib )
  • 为项目的Release配置增加依赖的库:cxcore200.lib cv200.lib highgui200.lib
  • 配置属性-字符集修改为使用“多字节字符集” (由于2008默认是以Unicode字符集编译的)
  • 编译运行下面的例程(需要将lena.jpg文件放在项目目录下)。
/***********************************************************************
* OpenCV 2.0 测试例程
* 于仕琪 提供
***********************************************************************/
 
#include "stdafx.h"
#include "highgui.h"
 
//所有的以新风格命名的函数都在 cv 命名空间中
//如果希望不要每次都输入 cv:: ,则可使用下面语句
//using namespace cv;
 
int _tmain(int argc, _TCHAR* argv[])
{
 
const char* imagename = "lena.jpg";
 
cv::Mat img = cv::imread(imagename); // Matlab风格的 cvLoadImage 函数的另一种调用
if(img.empty())
{
fprintf(stderr, "Can not load image %s\n", imagename);
return -1;
}
 
if( !img.data ) // 检查是否正确载入图像
return -1;
 
cv::namedWindow("image", CV_WINDOW_AUTOSIZE); //创建窗口
cv::imshow("image", img); //显示图像
 
cv::waitKey();
 
return 0;
}

点击看大图
Enlarge
点击看大图
点击看大图
Enlarge
点击看大图
点击看大图
Enlarge
点击看大图
点击看大图
Enlarge
点击看大图
点击看大图
Enlarge
点击看大图
点击看大图
Enlarge
点击看大图

作者

注:使用OpenCV 2.1 的,请将上图中的 *200.lib 和 *200d.lib 分别改为 *210.lib 和 *210d.lib


Win7 下使用opencv2.1 VC++2008时该程序中加载图像时要写完整路径,不然加载不了。例如:

   const char* imagename = "lena.jpg";

需要修改为

   const char* imagename = "D:\\lena.jpg";



posted @ 2010-12-01 23:20 未央 阅读(5340) | 评论 (0)编辑 收藏
 

网上下了MATLAB7.0,解压后,运行setup.exe,出现了以下安装问题: The installer cannot read the mwinstall.dll file, This is probably due to a CD reader which can only read files with an eight.three naming convention.网上收集的解决方法,哈哈,可以正常使用MATLAB了。

解决方法:

下面进行软件安装:我们下载的文件大多是镜像文件,这里我们需要的是一个较为稳定的虚拟光驱。我用的是VirtualCloneDrive是一个windows7下较为好的虚拟光驱软件。用虚拟光驱加载MATLAB   CD1(如果是只有一个镜像文件的话 就没有插入cd2的一部 . 要是rar 文件就直接双击setup.exe    记住 不要解压   直接在winrar 下双击setup),然后打开虚拟光盘,再在内部双击setup文件,现在就可以正常安装了。

安装结束后,我们双击MATLAB快捷方式,会发现怎么打不开,出现一大堆的warning,不要着急,windows7有个很好的功能,就是可以设置兼容模式,在MATLAB的图标右键--属性--兼容性下选择windows vista (service pack 1)点确定。现在再双击,就可以正常开启MATLAB了
设置兼容性是关键!!
来自: http://hi.baidu.com/lan2xhy27/blog/item/c37913faa672ab1c6d22ebce.html

posted @ 2010-11-30 09:11 未央 阅读(2361) | 评论 (0)编辑 收藏
仅列出标题
共8页: 1 2 3 4 5 6 7 8 
CALENDER
<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(6)

随笔档案

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜


Powered By: 博客园
模板提供沪江博客