久久99精品国产麻豆婷婷,久久国语露脸国产精品电影,伊人久久大香线蕉影院95http://m.shnenglu.com/kongque/category/14627.html專注并致力于手機客戶端開發zh-cnSun, 06 Nov 2011 11:48:41 GMTSun, 06 Nov 2011 11:48:41 GMT60linux下批量命名和批量處理圖片的例子http://m.shnenglu.com/kongque/archive/2011/11/06/159706.html孔雀孔雀Sun, 06 Nov 2011 04:46:00 GMThttp://m.shnenglu.com/kongque/archive/2011/11/06/159706.htmlhttp://m.shnenglu.com/kongque/comments/159706.htmlhttp://m.shnenglu.com/kongque/archive/2011/11/06/159706.html#Feedback0http://m.shnenglu.com/kongque/comments/commentRss/159706.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/159706.html
解決如下:
1)批量改名:for var in *.png; do mv "$var" "${var%@2x.png}.png"; done

2)批量修改圖像:for png in *.png; do convert $png -resize 50% $png

其中的批量修改圖像中使用到了一個convert命令,這個命令是命令行圖像處理工具ImageMagick的一個子命令。關于ImageMagick我之前的隨筆中也有提到,感興趣的童鞋可以參考一下。

孔雀 2011-11-06 12:46 發表評論
]]>
OpenCV使用經驗總結http://m.shnenglu.com/kongque/archive/2011/07/14/150993.html孔雀孔雀Thu, 14 Jul 2011 09:01:00 GMThttp://m.shnenglu.com/kongque/archive/2011/07/14/150993.htmlhttp://m.shnenglu.com/kongque/comments/150993.htmlhttp://m.shnenglu.com/kongque/archive/2011/07/14/150993.html#Feedback2http://m.shnenglu.com/kongque/comments/commentRss/150993.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/150993.html閱讀全文

孔雀 2011-07-14 17:01 發表評論
]]>
關于全景圖像的拼接http://m.shnenglu.com/kongque/archive/2011/06/23/149314.html孔雀孔雀Thu, 23 Jun 2011 09:13:00 GMThttp://m.shnenglu.com/kongque/archive/2011/06/23/149314.htmlhttp://m.shnenglu.com/kongque/comments/149314.htmlhttp://m.shnenglu.com/kongque/archive/2011/06/23/149314.html#Feedback2http://m.shnenglu.com/kongque/comments/commentRss/149314.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/149314.html這段時間一直在做全景圖像拼接,略有小成。總結一下:

圖像拼接概括起來說,分兩大步驟。第一步,配準。第二步,融合。

配準有基于模板匹配的,有基于特征點匹配的。現在的主流是基于特征點匹配的,SIFT是熱點。

融合的方法有很多,有最簡單的線性過渡,有經典的拉普拉斯金字塔融合(多波段融合),有基于小波變換的融合,還有比較新而且效果很贊的泊松圖像編輯融合,可惜泊松圖像編輯的這個方法我還沒有實現出來,只是實現了基于拉普拉斯金字塔的融合,效果挺不錯。

以下三篇論文是權威和經典,如果有能力消化并實現,那么一個完整的全景拼接系統就有了。
1) Construction of panoramic mosaics with global and local alignment.
   Heung-Yeung Shum and Richard Szeliski. 2000.
2) Eliminating Ghosting and Exposure Artifacts in Image Mosaics.
   Matthew Uyttendaele, Ashley Eden and Richard Szeliski. 2001.
3) Automatic Panoramic Image Stitching using Invariant Features.
   Matthew Brown and David G. Lowe. 2007.

ps: 上面論文作者其中的Richard Szeliski是計算機視覺界的翹楚,在微軟研究院工作,最近出了新書《Computer Vision: Algorithm and Applications》英文版,200多美刀。不過該大牛在他的個人網站上放了書稿,pdf格式,絕對值得下載。

孔雀 2011-06-23 17:13 發表評論
]]>
數字圖像處理:Sobel算子http://m.shnenglu.com/kongque/archive/2011/05/28/147529.html孔雀孔雀Sat, 28 May 2011 13:32:00 GMThttp://m.shnenglu.com/kongque/archive/2011/05/28/147529.htmlhttp://m.shnenglu.com/kongque/comments/147529.htmlhttp://m.shnenglu.com/kongque/archive/2011/05/28/147529.html#Feedback0http://m.shnenglu.com/kongque/comments/commentRss/147529.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/147529.html
今天遇到一個問題是需要一個類似Sobel算子的功能,因為Sobel算子沒有考慮到像素點周圍的相似性,現在需要考慮這個問題。所以需要的算子的元素與Sobel算子不同。于是自己動手寫了sobel算子的實現,這樣對于不同的參數修改算子的元素值即可。代碼如下:

 1 void MySobel(IplImage* gray, IplImage* gradient)
 2 {
 3     /* Sobel template
 4     a00 a01 a02
 5     a10 a11 a12
 6     a20 a21 a22
 7     */
 8 
 9     unsigned char a00, a01, a02, a20, a21, a22;
10    unsigned char a10, a11, a12;
11 
12     for (int i=1; i<gray->height-1++i)
13     {
14         for (int j=1; j<gray->width-1++j)
15         {
16             CvScalar color = cvGet2D(gray, i, j);
17             
18             a00 = cvGet2D(gray, i-1, j-1).val[0];
19             a01 = cvGet2D(gray, i-1, j).val[0];
20             a02 = cvGet2D(gray, i-1, j+1).val[0];
21 
22             a10 = cvGet2D(gray, i, j-1).val[0];
23             a11 = cvGet2D(gray, i, j).val[0];
24             a12 = cvGet2D(gray, i, j+1).val[0];
25 
26             a20 = cvGet2D(gray, i+1, j-1).val[0];
27             a21 = cvGet2D(gray, i+1, j).val[0];
28             a22 = cvGet2D(gray, i+1, j+1).val[0];
29             
30             // x方向上的近似導數
31             double ux = a20 * (1+ a21 * (2+ a22 * (1
32                 + (a00 * (-1+ a01 * (-2+ a02 * (-1));
33 
34             // y方向上的近似導數
35             double uy = a02 * (1+ a12 * (2+ a22 * (1)
36                 + a00 * (-1+ a10 * (-2+ a20 * (-1);
37 
38             color.val[0= ux;
39 
40             cvSet2D(gradient, i, j, color);
41         }
42     }
43 }

上面代碼中訪問圖像的像素使用了OpenCV的接口,這個不如直接使用指針的效率高,可以修改。


孔雀 2011-05-28 21:32 發表評論
]]>
OpenCV中二維點求取進行透視變換之后的坐標點方法http://m.shnenglu.com/kongque/archive/2011/05/24/147014.html孔雀孔雀Tue, 24 May 2011 02:46:00 GMThttp://m.shnenglu.com/kongque/archive/2011/05/24/147014.htmlhttp://m.shnenglu.com/kongque/comments/147014.htmlhttp://m.shnenglu.com/kongque/archive/2011/05/24/147014.html#Feedback0http://m.shnenglu.com/kongque/comments/commentRss/147014.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/147014.html
最終得以解決,還是使用了CvMat類而不是Mat類。代碼如下:

1 CvPoint transformPoint(const CvPoint pointToTransform, const CvMat* matrix) 
2 {
3     double coordinates[3= {pointToTransform.x, pointToTransform.y, 1};
4     CvMat originVector = cvMat(31, CV_64F, coordinates);
5     CvMat transformedVector = cvMat(31, CV_64F, coordinates);
6     cvMatMul(matrix, &originVector, &transformedVector);
7     CvPoint outputPoint = cvPoint((int)(cvmGet(&transformedVector, 00/ cvmGet(&transformedVector, 20)), (int)(cvmGet(&transformedVector, 10/ cvmGet(&transformedVector, 20)));
8     return outputPoint;
9 }

這個函數一個很有用的地方就在于,原本二維圖上的一個像素點位于(x,y)處,經過一個變換(仿射變換、透視變換)之后,求取它的新的坐標點(x', y')。

孔雀 2011-05-24 10:46 發表評論
]]>
關于OpenGL ES中的紋理壓縮http://m.shnenglu.com/kongque/archive/2011/03/31/143062.html孔雀孔雀Wed, 30 Mar 2011 16:38:00 GMThttp://m.shnenglu.com/kongque/archive/2011/03/31/143062.htmlhttp://m.shnenglu.com/kongque/comments/143062.htmlhttp://m.shnenglu.com/kongque/archive/2011/03/31/143062.html#Feedback0http://m.shnenglu.com/kongque/comments/commentRss/143062.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/143062.html1. ETC1(Ericcson texture compression)
2. PVRTC(PowerVR texture compression)
3. ATITC(ATI texture compression)
對于集成了NVIDIA Tegra2的手機如Motorola XOOM,ATRIX和DRIOID BIONIC則支持如下的紋理壓縮
4. S3TC(S3 texture compression)  閱讀全文

孔雀 2011-03-31 00:38 發表評論
]]>
Linux下編譯Irrlicht注意事項http://m.shnenglu.com/kongque/archive/2011/01/29/139559.html孔雀孔雀Fri, 28 Jan 2011 16:25:00 GMThttp://m.shnenglu.com/kongque/archive/2011/01/29/139559.htmlhttp://m.shnenglu.com/kongque/comments/139559.htmlhttp://m.shnenglu.com/kongque/archive/2011/01/29/139559.html#Feedback3http://m.shnenglu.com/kongque/comments/commentRss/139559.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/139559.html閱讀全文

孔雀 2011-01-29 00:25 發表評論
]]>
Linux上運行Milkshapehttp://m.shnenglu.com/kongque/archive/2010/12/22/137200.html孔雀孔雀Wed, 22 Dec 2010 09:00:00 GMThttp://m.shnenglu.com/kongque/archive/2010/12/22/137200.htmlhttp://m.shnenglu.com/kongque/comments/137200.htmlhttp://m.shnenglu.com/kongque/archive/2010/12/22/137200.html#Feedback0http://m.shnenglu.com/kongque/comments/commentRss/137200.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/137200.html

環境:Ubuntu 10.04 + MilkShape 1.8.4 + Wine 1.2

方法:

     1)在dll-files.com上下載msvcirt.dll, 注意是msvcirt.dll而不是msvcrt.dll.

     2)在dlldump.com上下載mfc42.dll

     3) 將上述兩個dll拷貝到system32目錄下和Milkshape的安裝目錄下(ms3d.exe所在的目錄)

     4)使用wine運行之




孔雀 2010-12-22 17:00 發表評論
]]>
call to OpenGL ES API with no current context 錯誤及解決方案http://m.shnenglu.com/kongque/archive/2010/12/14/136415.html孔雀孔雀Tue, 14 Dec 2010 13:56:00 GMThttp://m.shnenglu.com/kongque/archive/2010/12/14/136415.htmlhttp://m.shnenglu.com/kongque/comments/136415.htmlhttp://m.shnenglu.com/kongque/archive/2010/12/14/136415.html#Feedback9http://m.shnenglu.com/kongque/comments/commentRss/136415.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/136415.html

    錯誤: call to OpenGL ES API with no current context

    可能的原因:OGL ES所在的線程被阻塞或者被掛起,導致渲染設備上下文丟失。

    解決方案:將可能導致渲染線程被阻塞或被掛起的代碼移動到別處。比如在渲染循環之前執行或之后執行。



孔雀 2010-12-14 21:56 發表評論
]]>
3D游戲引擎Irrlicht淺談(二)http://m.shnenglu.com/kongque/archive/2010/11/11/133307.html孔雀孔雀Thu, 11 Nov 2010 06:25:00 GMThttp://m.shnenglu.com/kongque/archive/2010/11/11/133307.htmlhttp://m.shnenglu.com/kongque/comments/133307.htmlhttp://m.shnenglu.com/kongque/archive/2010/11/11/133307.html#Feedback5http://m.shnenglu.com/kongque/comments/commentRss/133307.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/133307.html
Irrlicht中的兩個抽象接口,IrrlichtDevice和IVideoDriver分別將設備與驅動抽象出來。對于不同的設備(比如Android手機或iPhone手機)只需要實現這兩個接口,那么Irrlicht就基本可以被你所用了,因為引擎的其他部分大部分都是平臺無關的,涉及到的平臺相關的部分根據需要做調整就可以了。
  閱讀全文

孔雀 2010-11-11 14:25 發表評論
]]>
OpenGL學習的兩個利器http://m.shnenglu.com/kongque/archive/2010/10/04/128584.html孔雀孔雀Mon, 04 Oct 2010 10:12:00 GMThttp://m.shnenglu.com/kongque/archive/2010/10/04/128584.htmlhttp://m.shnenglu.com/kongque/comments/128584.htmlhttp://m.shnenglu.com/kongque/archive/2010/10/04/128584.html#Feedback3http://m.shnenglu.com/kongque/comments/commentRss/128584.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/128584.html

這里推薦兩個利器來解決這兩個問題。讓我們可以更加專注和有效的學習OpenGL。分別是GLUT和GLEW  閱讀全文

孔雀 2010-10-04 18:12 發表評論
]]>
OpenGL中FBO的概念及其應用http://m.shnenglu.com/kongque/archive/2010/08/26/124754.html孔雀孔雀Wed, 25 Aug 2010 20:33:00 GMThttp://m.shnenglu.com/kongque/archive/2010/08/26/124754.htmlhttp://m.shnenglu.com/kongque/comments/124754.htmlhttp://m.shnenglu.com/kongque/archive/2010/08/26/124754.html#Feedback4http://m.shnenglu.com/kongque/comments/commentRss/124754.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/124754.htmlFBO一個最常見的應用就是:渲染到紋理(render to texture),通過這項技術可以實現發光效果,環境映射,陰影映射等很炫的效果。

在OpenGL渲染管線中,幾何數據和紋理最終都是以2d像素繪制到屏幕上。最后一步的渲染目標在OpenGL渲染管線中被稱為幀緩存(frame buffer)。幀緩存是顏色緩存、深度緩存、模板緩存、累積緩存的集合。默認情況下, OpenGL使用的幀緩存是由窗體系統創建和管理的。

在OpenGL擴展中,GL_EXT_framebuffer_object擴展提供了一個創建額外幀緩存對象(FBO)的接口。這個幀緩存的創建和控制完全是由OpenGL完成的,有別于窗體系統創建的默認的幀緩存。與系統默認的幀緩存類似,一個FBO也是顏色緩存、深度緩存、模板緩存的集合(FBO不包括累積緩存),然后OpenGL程序就可以把渲染重定向到FBO  閱讀全文

孔雀 2010-08-26 04:33 發表評論
]]>
OpenGL ES中實現gluPerspective函數http://m.shnenglu.com/kongque/archive/2010/08/19/123900.html孔雀孔雀Wed, 18 Aug 2010 16:14:00 GMThttp://m.shnenglu.com/kongque/archive/2010/08/19/123900.htmlhttp://m.shnenglu.com/kongque/comments/123900.htmlhttp://m.shnenglu.com/kongque/archive/2010/08/19/123900.html#Feedback3http://m.shnenglu.com/kongque/comments/commentRss/123900.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/123900.html
 1 
 2 void __gluPerspective(double fovy, double aspect, double zNear, double zFar)
 3 {
 4     glMatrixMode(GL_PROJECTION);
 5     glLoadIdentity();
 6 
 7     double xmin, xmax, ymin, ymax;
 8     ymax = zNear * tan(fovy * KPI / 360);
 9     ymin = -ymax;
10     xmin = ymin * aspect;
11     xmax = ymax * aspect;
12 
13     glFrustumf(xmin, xmax, ymin, ymax, zNear, zFar);
14 }
15 
16 

在需要調用gluPerspective的地方,用該函數替換即可。




孔雀 2010-08-19 00:14 發表評論
]]>
四元數概念及其應用http://m.shnenglu.com/kongque/archive/2010/08/18/123824.html孔雀孔雀Wed, 18 Aug 2010 06:01:00 GMThttp://m.shnenglu.com/kongque/archive/2010/08/18/123824.htmlhttp://m.shnenglu.com/kongque/comments/123824.htmlhttp://m.shnenglu.com/kongque/archive/2010/08/18/123824.html#Feedback1http://m.shnenglu.com/kongque/comments/commentRss/123824.htmlhttp://m.shnenglu.com/kongque/services/trackbacks/123824.html
介紹四元數之前,先做如下約定:

1.采用右手坐標系(OpenGL)

2.旋轉次序:x->y->z

3.  矩陣是列優先存儲


1.
什么是四元數?

直接用數學上的定義來解釋,因為我很難在現實生活中找到可以描述明白的例子。

 

i, j, k 為虛數

Q = w + xi + yj + zk

其中w是實數,而x,y,z為復數。

另外一種常見的表達方式是:

Q = [w, v]

其中v=(x,y,z)稱為矢量部(雖然稱為矢量,但是這個不是三維空間中的矢量,而是四維空間的,想象吧L),w稱為標量部。


2.
四元數可以做什么?

有了四元數的概念還不行,四元數可以干什么?四元數可以用來描述方向。

先來看下如何求取四元數的長度:

||q|| = Norm(q) = sqrt(w2 + x2 + y2 + z2)

單位長度的四元數有以下屬性:

w2 + x2 + y2 + z2 = 1

所以我們使用如下方法來標準化(Normalize)一個四元數:

q = q / ||q|| = q / sqrt(w2 + x2 + y2 + z2)

 

使用一個單位四元數來描述方向,請記住必須是單位四元數才可以描述方向。


3.
四元數的乘法

因為一個單位四元數可以代表一個三維空間中的方向,那么兩個四元數相乘得到的結果仍然是一個四元數,這個四元素依舊可以標識一個方向。

 

給定兩個四元數:

Q1 = (w1, x1, y1, z1)

Q2 = (w2, x2, y2, z2)

 

Q1 * Q2 = (w1.w2 – v1.v2, w1.v2 + w2.v1 + v1 x v2)

注意:.代表向量間的點積,x代表叉積。v1=(x1, y1, z1)  v2=(x2, y2, z2)

 

優化一下:

w=w1w2 - x1x2 - y1y2 - z1z2
x = w1x2 + x1w2 + y1z2 - z1y2
y = w1y2 + y1w2 + z1x2 - x1z2
z = w1z2 + z1w2 + x1y2 - y1x2

 

4.四元數的轉換

       為什么要轉換,因為我們還不能直接使用四元數來進行3D物體的旋轉。在OpenGL中和Direct3D中都是通過矩陣來描述3D旋轉的。


4.1 四元數到矩陣的轉換

 

使用單位四元數轉換到矩陣:

Matrix = [ 1 - 2y2 - 2z2   2xy - 2wz      2xz + 2wy
             2xy + 2wz      1 - 2x2 - 2z2   2yz - 2wx
             2xz - 2wy      2yz + 2wx      1 - 2x2 - 2y2 ]

 

4.2 四元數到軸角的轉換

軸角也是一種表達空間旋轉的方式。

如果旋轉軸是:(ax, ay, az)

旋轉角度是:angle (單位:弧度)

那么四元數與軸角之間的轉換關系如下:

 

angle = 2 * acos(w)

ax = x / scale

ay = y / scale

az = y / scale

其中scale = sqrt(x2 + y2 + z2)


  4.3
軸角到四元數的轉換

假設旋轉軸是(ax, ay, az),記得必須是一個單位向量。

旋轉角度是theta. (單位:弧度)

那么轉換如下:

w = cos(theta / 2 )

x = ax * sin(theta / 2)

y = ay * sin(theta / 2)

z = az * sin(theta / 2 )


  4.4
歐拉角到四元數的轉換

如果你的歐拉角為(a, b, c)那么就可以形成三個獨立的四元數,如下:

 

Qx = [ cos(a/2), (sin(a/2), 0, 0)]
Qy = [ cos(b/2), (0, sin(b/2), 0)]
Qz = [ cos(c/2), (0, 0, sin(c/2))]


最終的四元數是Qx * Qy * Qz的乘積的結果。

 

 
5.
使用四元數來避免Gimbal Lock

 

基本思路如下:

1)  使用一個四元數來標識一個方向

2)  創建一個臨時的四元數來標識當前方向到新方向的變化

3)  右乘臨時的四元數和初始四元數,結果是一個合并了兩個四元數的新的四元數

4)  將四元數轉換成矩陣


6.
更深入的學習四元數

SLERP:球狀線性插值對于三位模型進行動畫處理非常有用,因為這種方式在模型的各種方向之間提供了平滑的轉換。





孔雀 2010-08-18 14:01 發表評論
]]>
国产69精品久久久久9999APGF| 国产精品99久久久精品无码| 午夜精品久久久久久毛片| 国产69精品久久久久99尤物| 久久国产精品77777| 国产精品亚洲综合久久| 久久中文精品无码中文字幕| 久久99精品久久久久久水蜜桃| 欧美一区二区精品久久| 97r久久精品国产99国产精| 久久精品国产第一区二区三区| 欧美亚洲色综久久精品国产| 久久人人爽人人爽人人片AV高清 | 精品久久人人爽天天玩人人妻| 色婷婷噜噜久久国产精品12p | 久久影院午夜理论片无码| 久久99精品国产99久久| 99久久免费只有精品国产| 国内精品久久久久久中文字幕| 狠狠人妻久久久久久综合| 久久免费99精品国产自在现线| 欧美久久一区二区三区| 久久精品成人欧美大片| 久久99精品国产自在现线小黄鸭| 色综合久久久久综合体桃花网| 亚洲精品美女久久777777| 久久精品aⅴ无码中文字字幕不卡| 国产成人综合久久综合| 久久99精品九九九久久婷婷| 久久综合视频网站| 亚洲精品tv久久久久久久久 | 开心久久婷婷综合中文字幕| 一本久道久久综合狠狠躁AV| 色欲久久久天天天综合网精品| 久久精品九九亚洲精品| 大蕉久久伊人中文字幕| 亚洲人AV永久一区二区三区久久| 久久久久久久女国产乱让韩| 91精品国产91热久久久久福利 | 国产精品免费福利久久| 国产精品日韩深夜福利久久|