socketref,再见!高德

https://github.com/adoggie

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  246 Posts :: 4 Stories :: 312 Comments :: 0 Trackbacks

常用链接

留言簿(54)

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜

#

利用windows capture Api捕获的视频流是RGB数据
 1 
 2 /*
 3 
 4     capture.h
 5     caputre用户捕获pc camera的 RGB视频源
 6     做到capture,encoder,mgr 独立,不会有依赖性,以便之后的复用
 7 */
 8 
 9 #ifndef _DESKCAM_CAPTURE_H
10 #define _DESKCAM_CAPTURE_H
11 
12 
13 #include <windows.h>
14 #include "vfw.h"
15 #pragma comment(lib, "winmm.lib")
16 #pragma comment(lib, "vfw32.lib")
17 #include <nv.h>
18 
19 
20 struct CaptureInfo{
21     NVString        sid;
22     unsigned int    index;    //
23     unsigned int    type;    //类别
24     unsigned short    width;
25     unsigned short  height;    
26     void (*after_capture)(void * data,unsigned int size,void * user);
27     void * user;
28 };
29 
30 class  PCDeskCamera:public NVObject{
31 public:
32     PCDeskCamera(){ _bmpInfo = NULL;}
33     ~PCDeskCamera(){    if(_bmpInfo)    {delete _bmpInfo;_bmpInfo=NULL;} }
34 
35     bool                Open();
36     void                Close();
37     CaptureInfo&        GetCaptureInfo(){    return _ctx;}
38 private:    
39     static LRESULT    CALLBACK    StreamCapture(HWND hwnd,LPVIDEOHDR hdr);
40     bool                GetBitmapInfo(HWND cap);
41     HWND                _hwnd;
42     CaptureInfo            _ctx;
43     HWND                _capture_wnd;
44     LPBITMAPINFO        _bmpInfo;        
45 };
46 #endif
47 
 1 
 2 #include "capture.h"
 3 
 4 /*
 5 视频捕获,必须提供消息处理机制:    
 6 while(GetMessage()){
 7     TranslateMessage();
 8     DispatchMessage();
 9 }
10 而且回调函数必须声明为 static LRESULT    CALLBACK,否则产生异常
11 */
12 
13 LRESULT PCDeskCamera::StreamCapture(HWND hwnd,LPVIDEOHDR hdr){
14     PCDeskCamera * cam;    
15     //int i;
16     //i=100;
17 //    MessageBeep(100);
18 //    return 0;
19     
20     cam = (PCDeskCamera*)GetWindowLong(hwnd,GWL_USERDATA);
21     if( cam== NULL){        
22         return 0;
23     }    
24     //--     
25     cam->GetCaptureInfo().after_capture(hdr->lpData,hdr->dwBytesUsed,
26         cam->GetCaptureInfo().user);
27     return 1;
28 }
29  
30 
31 bool PCDeskCamera::GetBitmapInfo(HWND cap){
32     int vfs=capGetVideoFormatSize(cap);    
33     if(!vfs)        return false;    
34     if(_bmpInfo)    {delete _bmpInfo;_bmpInfo=NULL;}
35     _bmpInfo =(BITMAPINFO*)( new char[vfs]);    
36     LPBITMAPINFOHEADER bmpIH=( LPBITMAPINFOHEADER )_bmpInfo;    
37     bmpIH->biSize= sizeof(BITMAPINFOHEADER);
38     BOOL ret=capGetVideoFormat(cap, _bmpInfo, (WORD)vfs);    
39     _ctx.width = bmpIH->biWidth;
40     _ctx.height = bmpIH->biHeight;
41     return true;
42 }
43 
44 bool PCDeskCamera::Open(){
45     int ret;
46     CAPTUREPARMS cpp;        
47     _capture_wnd = capCreateCaptureWindow("AviCap_Basic1", WS_CHILD|WS_VISIBLE, 
48         00200,200,
49         GetDesktopWindow(),
50         0xff00);    
51     if(_capture_wnd == NULL){
52         return false;
53     }
54     SetWindowLong(_capture_wnd,GWL_USERDATA,(LONG)this);
55     capPreviewRate(_capture_wnd,50);
56     ret =capDriverConnect(_capture_wnd, _ctx.index);
57     if( ret == FALSE){
58         return false;
59     }
60 
61     if(!GetBitmapInfo(_capture_wnd))    {
62         return false;
63     }    
64     ret = capSetCallbackOnVideoStream(_capture_wnd,PCDeskCamera::StreamCapture);
65     capCaptureGetSetup(_capture_wnd, &cpp, sizeof(CAPTUREPARMS));
66        cpp.fYield = true ;
67     cpp.fAbortLeftMouse = false;
68     cpp.fAbortRightMouse = false;
69     cpp.fCaptureAudio = false;
70     ret = capCaptureSetSetup (_capture_wnd, &cpp, sizeof(CAPTUREPARMS));
71     capCaptureSequenceNoFile(_capture_wnd);
72     //capCaptureSequence(_capture_wnd);
73     ShowWindow(_capture_wnd,SW_HIDE);    
74 
75 
76     return true;
77 }
78 
79 void PCDeskCamera::Close(){
80 //    capCaptureAbort(_capture_wnd);    
81     capSetCallbackOnVideoStream(0 ,NULL);
82     capDriverDisconnect(_capture_wnd);    
83     capCaptureStop(_capture_wnd);
84     SetWindowLong(_capture_wnd,GWL_USERDATA,(LONG)NULL);
85     ::CloseWindow(_capture_wnd);
86     DestroyWindow(_capture_wnd);    
87 }
88 
89 
90 
posted @ 2006-03-02 00:36 放屁阿狗 阅读(1188) | 评论 (0)编辑 收藏

     摘要:     1 #include <windows.h>  2   3 long int crv_tab[256];  4 long int cbu_tab[256];  5 lo...  阅读全文
posted @ 2006-03-02 00:33 放屁阿狗 阅读(4628) | 评论 (2)编辑 收藏

     摘要: 由于视频开发的需求,封装xvid c调用接口,使之优雅易用我已经对pc camera视频流(RGB)进行尝试,编码之后传输到远程主机进行解码回放,效果不错具体的xvid的参数可以进一步优化,这里只是提供简单的范例1. xvid 解码  1  2 /* 3     encode.cpp 4...  阅读全文
posted @ 2006-03-02 00:28 放屁阿狗 阅读(4578) | 评论 (6)编辑 收藏

公司的项目中有访问DB2数据的需求,我以前也只是听说DB2有这么个咚咚,据说也是个恐龙级的数据库。以前也没有用过DB2 在c语言的接口(访问oracle我一直用oci),网上一兜,才发现DB2有JDBC的访问接口,c方面的很少。
项目的工期比较紧,同时我也不想花太多的时间研究数据库访问接口,所以在项目中许多模块都是用python编写,开发周期短,调试,跨平台也是很吸引人,所以就用python拉。在python.org一搜索,便找到了pydb2,OK! 马上下载pydb1.2,一解开压缩包,原来是原代码,只能编译拉。还好有编译脚本:), 运行setup.py install
出现以下异常:
Compiling under Visual Studio .NET v7 recieves the
following error:

_db2_module.c(1855) : error C2036: 'SQLPOINTER' :
unknown size

This can be resolved by casting to (SQLCHAR *) instead
of a (void *):

< SQLPOINTER buf = (SQLPOINTER)((SQLCHAR
*)bs->buf + (bs->bufLen * idx));

发现原来SQLCHAR类型没有找到,没问题,找到_db2_module.c:1855行修改为:
SQLPOINTER buf = (SQLPOINTER)((void *)bs->buf +
(bs->bufLen * idx));
再次 setup.py install
ok,编译成功,db2.py的模块也被拷贝得到 $PYTHONHOME/lib/site_pakages/下去了
然后安装db2 client runtime
这样就完成了pydb2的运行配置。然后就在odbc中配置一个dsn
测试以下代码:

import DB2
conn = DB2.connect(dsn='sample', uid='db2inst1', pwd='secret')
无异常表示成功连接上DB2
之后访问数据库只要遵循python DBI2.0的规范就可以拉!
生活在python世界是很快乐的事情!

*注意: python2.4的话必须用vc7.1编译pydb2的扩展模块,因为python2.4(win32)也是用vc7.1编译的


posted @ 2006-03-02 00:18 放屁阿狗 阅读(1578) | 评论 (1)编辑 收藏

读ICE core 源码
读linux 2.4 kernel
学习e文
学习computer graphic

posted @ 2006-02-23 13:06 放屁阿狗 阅读(168) | 评论 (0)编辑 收藏

linux kernel 0.11学习计划
posted @ 2006-01-29 20:16 放屁阿狗 阅读(336) | 评论 (0)编辑 收藏

近日我将Ice源码库中的Base64的代码挖掘出来以便自己使用,做了一些试验,发现其对二进制编码之后的产生0x0D,0x0A字符,不得其解
用了一下python的base64库,发现其也是在编码只有加上0D,0A字符,嘿嘿,难道这是标准阿?
posted @ 2006-01-06 09:46 放屁阿狗 阅读(444) | 评论 (2)编辑 收藏

      参阅 www.xmlrpc.org 的xmlrpc规范,发现其规格比较简单,网站list top50中xmlrpc的不同语言的实现,研究了xmlrpc-c,sexyRcp,phpRpc等代码,发现其都实现比较复杂,有些只是提供了xmlrpc的语言规格实现,但没有实现网络传输的功能。
      由于xmlrpc规范的网络传输采用http,一个请求必须创建一次tcp的交互,导致性能上得不到提高,而且只是单向调用等限制,我考虑重新编写xmlrpc的实现,提供xmlrpc-server,简化其操作接口,支持在客户机和服务器之间保持一个tcp连接,持续的进行xmlrpc双向调用.
      支持语言:      C++ / Python
      计划时间:   2005.12.31    ~ 2006.1.3

2006.1.4    完成rpcServer c++版本

posted @ 2006-01-02 00:52 放屁阿狗 阅读(2030) | 评论 (2)编辑 收藏

     摘要: 本人一直使用的日志类,支持3种输出方式(windows窗体,udp,常规文件),并格式化输出:   1  2/**//*  3    nvlog.h  4    ----------------  5 &nb...  阅读全文
posted @ 2005-12-11 20:31 放屁阿狗 阅读(3828) | 评论 (4)编辑 收藏

linux9.0 用dlopen,动态加载函数XmlParse(),能成功被加载,但是访问core dump ,很是奇怪,错误点在memmove....,实在没有办法,只能直接连接到libexpat.so,直接用XmlParse而没有任何问题,很是奇怪
libexpat.dll在windows下动态加载无任何问题
所以只能改写:

 1NVXML_INLINE
 2bool    NVXmlTree::Init_XmlLib(const char * libexpat){    
 3#ifdef WIN32
 4    if ( !_xml_dll.LoadDll(libexpat)){
 5        return false;    
 6    }
    
 7    _xmlf.XML_Parse= (NV_XML_Parse)_xml_dll.LoadSymbol("XML_Parse");    
 8    _xmlf.XML_ParserCreate = (NV_XML_ParserCreate)_xml_dll.LoadSymbol("XML_ParserCreate");    
 9    _xmlf.XML_ParserFree=(NV_XML_ParserFree)_xml_dll.LoadSymbol("XML_ParserFree");
10    _xmlf.XML_SetElementHandler=(NV_XML_SetElementHandler)_xml_dll.LoadSymbol("XML_SetElementHandler");
11    _xmlf.XML_SetUserData = (NV_XML_SetUserData)_xml_dll.LoadSymbol("XML_SetUserData");        
12    _xmlf.XML_SetEncoding = (NV_XML_SetEncoding) _xml_dll.LoadSymbol("XML_SetEncoding");    
13    _xmlf.XML_SetCharacterDataHandler = (NV_XML_SetCharacterDataHandler)
14                            _xml_dll.LoadSymbol("XML_SetCharacterDataHandler");    
15#endif
16#ifdef _UNIX
17//-- on unix,using expat api directly
18    _xmlf.XML_Parse= (NV_XML_Parse)XML_Parse;    
19    _xmlf.XML_ParserCreate = (NV_XML_ParserCreate)XML_ParserCreate;    
20    _xmlf.XML_ParserFree=(NV_XML_ParserFree)XML_ParserFree;
21    _xmlf.XML_SetElementHandler=(NV_XML_SetElementHandler)XML_SetElementHandler;
22    _xmlf.XML_SetUserData = (NV_XML_SetUserData)XML_SetUserData;        
23    _xmlf.XML_SetEncoding = (NV_XML_SetEncoding)XML_SetEncoding;    
24    _xmlf.XML_SetCharacterDataHandler = (NV_XML_SetCharacterDataHandler)XML_SetCharacterDataHandler;    
25
26#endif
27    return true;
28}
    
posted @ 2005-12-11 20:26 放屁阿狗 阅读(757) | 评论 (0)编辑 收藏

仅列出标题
共25页: First 17 18 19 20 21 22 23 24 25