Mac下使用c++玩opencv

利用pkg-config 获取相应的库, 安装命令:
brew install pkg-config
重新安装opencv
brew reinstall opencv
编译程序
>g++ $(pkg-config --cflags --libs opencv) /Users/wgg/Downloads/TestOpenCV.cpp -o testOpencv
>testOpencv 
可以查看具体引用库
pkg-config --cflags --libs opencv

-I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core -lopencv_hal

Mac下安装cx_Oracle

经历了各种错误,都想放弃了,本打算最后再试试最后一种方法,安装mac下的python 32位版本,偶然间发现了下面的文章,一步一步照做(连安装cx_oracle都没有用yum,直接下载的源码),竟然成功了!!!Happy
转载下: (非常感谢)
Build and Install cx_Oracle on Mac Leopard Intel

I finally succeeded in building and installing cx_Oracle on a Mac. I will outline the steps that I took. There are many redundant steps that I may later take out. But there are checks that I made on the way that really helped.

The first Mac that I installed cx_Oracle was a 2.4 GHz Intel Core 2 Duo running Mac OSX 10.6.6. It had 4 GB of Memory. Most of my work was done on a terminal window.

Check Python Installation

The OSX comes with a Python interpreter. I ran a check to find the version number.

$ python -V
Python 2.6.1
This was sufficient for my needs. I decided not to upgrade to Python version 2.7.1
Xcode from Apple

The Xcode package is available from Apple Developer. You will need a login account but that is free. Now you do not need Xcode 4. Xcode 3 is sufficient because all we are interested in is the gcc compiler. After you login look for a link that says Looking for Xcode 3? I downloaded X code 3.2.6 and iOS SDK 4.3. It was 4.1 GB in size and is best done when you know you will not be using your Mac.

After the download, the installation went off smoothly. I restarted the Mac and on a terminal window checked that the gcc compiler was installed correctly.

$ which gcc
/usr/bin/gcc

$ gcc -v
gcc version 4.2.1
You can also do man gcc to get the online manual for gcc.
Install Oracle Instant Client

The cx_Oracle has a dependency. It needs Oracle Instant Client from Oracle. Click on the link Instant Client for Mac OS X (Intel x86). Accept the license agreement and download Version 10.2.0.4 (64-bit). I tried the 32-bit and it does NOT work. You will need your Oracle account to download the following packages:

instantclient-basic-10.2.0.4.0-macosx-x64.zip
instantclient-sdk-10.2.0.4.0-macosx-x64.zip
I created a directory called oracle to unpack the packages. The pathname on my machine was /Users/utcs/oracle. On your machine, it will be your user name instead of utcs. I moved both the basic and sdk packages into the oracle directory and unzipped them. After unzipping the basic package I got a folder instantclient_10_2.

After unzipping the sdk package, I got a folder called instantclient_10_2-1. Inside that folder was another folder called sdk. I moved the folder named sdk inside the folder instantclient_10_2.

From a terminal window I changed directory to sdk. On my machine, the full path name was /Users/utcs/oracle/instantclient_10_2/sdk. There is another .zip file called ottclasses.zip. I unzipped that as follows:

$ unzip ottclasses.zip
It produced a folder called oracle. I changed directory to /Users/utcs/oracle/instantclient_10_2. I ran the following command to copy all the files in the sdk folder.
$ cp -R ./sdk/* .
$ cp -R ./sdk/include/* .
The last two commands may not have been necessary. But it makes it easier to locate the header files.
Setting up the Environment Variables

In my home directory /Users/utcs I created a .profile file. Its content was as follows:

export ORACLE_HOME=/Users/utcs/oracle/instantclient_10_2
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME
Restart the machine. Open another terminal window and run the following commands to check that the environment variables have been set properly:
$ source .profile
$ echo $ORACLE_HOME
$ echo $DYLD_LIBRARY_PATH
$ echo $LD_LIBRARY_PATH
You should see the path names printed out correctly. I created two symbolic links in the $ORACLE_HOME directory (/Users/utcs/oracle/instantclient_10_2) as follows:
ln -s libclntsh.dylib.10.1 libclntsh.dylib
ln -s libocci.dylib.10.1 libocci.dylib
If you run the command ls -l in that directory you should see the symbolic links.
Building and Installing cx_Oracle

Download from SourceForge cx_Oracle version 5.0.4. You need to get the package that says Source Code only. In your Download folder you will find cx_Oracle-5.0.4.tar. I moved it to /Users/utcs/oracle. To untar, I used the following command:

tar -xvf cx_Oracle-5.0.4.tar
After untarring I had a subdirectory called cx_Oracle-5.0.4. In a terminal window I changed directory to /Users/utcs/oracle/cx_Oracle-5.0.4. I checked in that window that all the environment variables were set properly by doing

echo $ORACLE_HOME
echo $LD_LIBRARY_PATH
echo $DYLD_LIBRARY_PATH
which python
which gcc
I did not have administrative privileges on this Mac so to build I did
python setup.py build
I checked to output. There were many warning messages that I ignored. Even a single error message would have indicated that the build process did not succeed. I next installed cx_Oracle by
python setup.py install
The install also finished without any error messages.
Test the cx_Oracle installation

On a terminal window type python. It should bring up Python in interactive mode. Then type import cx_Oracle. It should add the package to your path without any errors. Get out of the interactive mode using Control-D.

Now copy and paste this script into a file called Check.py. Change the user name and run it on the command line.

import cx_Oracle, string, getpass

def main():
# Get password
pswd = getpass.getpass()

# Build connection string
user = “CS327_jdoe”
host = “oracle.microlab.cs.utexas.edu”
port = “1521”
sid = “orcl”
dsn = cx_Oracle.makedsn (host, port, sid)

# Connect to Oracle and test
con = cx_Oracle.connect (user, pswd, dsn)
if (con):
print “Connection successful”
print con.version
else:
print “Connection not successful”

con.close()

main()
You should see Connection successful if all the other tests were successful.

Mac中安装mariadb

1、

brew update

2、

brew install mariadb

3、执行:

unset TMPDIR
mysql_install_db

4、启动

mysql.server start

5、使用

mysql -uroot
>create database xxxxx

#查看数据库编码
>use xxxxx
>show variables like 'character_set_database';

6、实例:
1)插入数据

#coding=utf-8
__author__ = 'liwf'

import MySQLdb

try:
conn=MySQLdb.connect(host='localhost',user='root',passwd='',port=3306)
cur=conn.cursor()

#cur.execute('create database if not exists python')
conn.select_db('dbinfo')
#cur.execute('create table test(id int,info varchar(20))')

#value=[1,'188888888',0,'jsonstr']
#cur.execute('insert into UserInfo values(%s,%s,%s,%s)',value)

#values=[]
#for i in range(20):
# values.append((i,'hi rollen'+str(i)))

#cur.executemany('insert into test values(%s,%s)',values)
#
#cur.execute('update test set info="I am rollen" where id=3')
#
#conn.commit()
cur.close()
conn.close()

except MySQLdb.Error,e:
print "Mysql Error %d: %s" % (e.args[0], e.args[1])

7、主键操作

mysql的主键问题:
Mysql的两种主键。Primary key 和not null auto_incriment
在建立mysql表时,给一个字段添加了主键primary key
在insert数据时可以不用insert主键,mysql会自动添加0,但是在第二次insert时没有填写值mysql数据库还是默认添加0,会导致有重复的主键,这是不可以的。所有在定义了primary key时,在insert数据时要给主键填写值。
在建立mysql表时,给一个字段添加了主键not null auto_increment=1;
这也是一个主键。时自增长的以1为开始。这个字段是可以不用填写值的,mysql数据库会自动给填写值,不会出现primary key的状况。
Alter table tb add primary key(id);
Alter table tb change id id int(10) not null auto_increment=1;
删除自增长的主键id
先删除自增长在删除主键
Alter table tb change id id int(10);//删除自增长
Alter table tb drop primary key;//删除主建

Mac邮件只能收不能发的问题

公司邮箱,能够正常接收,但是无法发送,网上找了很多方法(例如说取消SSL选择,但是实际操作怎么也取消不成功,取消了再打开又自动勾选了),没有办法,各种蒙最终用下面的奇葩方式解决:

删除原邮箱账号,重新新建…   终于可以正常发邮件了!!! -_-!

————————华丽的分割线————————-

补充:好吧,我承认我膜(fu)拜(qi)了,昨天才弄好今天又莫名地不行了,不折腾了,果断换foxmail了

mac安装配置使用stunnel-客户端

  1. >brew install stunnel
  2. >brew link –overwrite stunnel

   3.配置:

   cp /usr/local/etc/stunnel/stunnel.conf-sample /usr/local/etc/stunnel/stunnel.conf

  增加:

[example-proxy]

client = yes

accept = 127.0.0.1:8080

connect = 118.28.18.158:443   #配置的服务器ip地址

启动stunnel:

sudo stunnel

关闭stunnel:

> ps aux | grep stunnel | grep root | awk ‘{print $2}’| xargs sudo kill -9

或者:

> cat /usr/local/etc/stunnel/stunnel.pid | xargs sudo kill -9

Mac Pro使用过程中的那些事

换了一个Mac Pro,刚开始各种不习惯,现把碰到的问题做一个总结:

1、无法ping通内网ip,172.16.*.*

$netstat -nr

发现路由到172.的都被连接到了安装的虚拟机网卡vmnet1上了

解决方法:$vi /Library/Preferences/VMware\ Fusion/networking

更改172.为173,解决!

2、安装brew

ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

工具选择:

1、Oracle客户端:免费的Toad