找回密碼 或 安全提問
 註冊
|註冊|登錄

伊莉討論區

搜索
感激所有對伊莉作出奉獻的人尊貴會員無限看帖不用回覆認識好友、聊天,分享生活趣事
mega 無無修無碼流出fate鬼父3d
家有女友一騎當千itunes87pokemon逸臣餘生彩月七緒

休閒聊天興趣交流學術文化旅遊交流飲食交流家庭事務PC GAMETV GAME
熱門線上其他線上感情感性寵物交流家族門派動漫交流貼圖分享BL/GL
音樂世界影視娛樂女性頻道潮流資訊BT下載區GB下載區下載分享短片
電腦資訊數碼產品手機交流交易廣場網站事務長篇小說體育運動時事經濟
上班一族博彩娛樂

[繁]我的英雄學院 Mem

[繁中]霹靂英雄戰紀之

[簡] 為美好的世界獻

[繁]狼與辛香料 MERCH

(4月新番)[繁]無職轉

(4月新番)[繁]怪獸八
C & C++ 語言C# 語言Visual Basic 語言PHP 語言JAVA 語言
查看: 2203|回復: 4
打印上一主題下一主題

[討論]Dev-C++ OpenCV Warning[複製鏈接]

帖子
373
積分
254 點
潛水值
19561 米
跳轉到指定樓層
樓主
發表於 2014-6-11 10:52 PM|只看該作者|倒序瀏覽
若有安裝色情守門員,可用無界、自由門等軟件瀏覽伊莉。或使用以下網址瀏覽伊莉: http://www.eyny.com:81/index.php
我是使用 Dev-C++4.9.9.2的版本
  1. #include <stdio.h>
  2. #include <cv.h>
  3. #include <highgui.h>
  4. #define alpha 0.9
  5. #define alphaf 0.8

  6. int Fishx[15];
  7. int Fishy[15];
  8. int tacox;
  9. int tacoy;

  10. int main()
  11. {
  12. CvCapture *capture;
  13. IplImage *frame,*grey,*mergeImg;
  14. IplImage* logoImg = NULL;
  15. IplImage* MouseImg1 = NULL;   
  16. IplImage* win = NULL;
  17. IplImage* PicTaco =NULL;
  18. IplImage* black =NULL;
  19. IplImage* white =NULL;

  20. CvPoint TextPosition1,TextPosition2,TextPosition3,TextPosition4;
  21. double Scale;
  22. int Thickness;
  23. CvScalar Color;
  24. Scale=1;
  25. Thickness=1;
  26. CvFont Font1=cvFont(Scale,Thickness);
  27. Color=CV_RGB(0,0,255);
  28. TextPosition1=cvPoint(220,20);
  29. TextPosition2=cvPoint(280,20);
  30. TextPosition3=cvPoint(220,40);
  31. TextPosition4=cvPoint(280,40);

  32. logoImg=cvLoadImage("fish.PNG");
  33. //cvFlip(logoImg,logoImg,0);
  34. MouseImg1=cvLoadImage("t01.PNG");
  35. win=cvLoadImage("win.jpg");
  36. PicTaco = cvLoadImage("taco.jpg");
  37. black = cvLoadImage("black.jpg");
  38. white = cvLoadImage("background.jpg");
  39. //cvFlip(MouseImg1,MouseImg1,0);
  40. CvFont font;

  41. int MouseX=0;
  42. int MouseY=0;
  43. int Fish=15;
  44. int Grade=0;
  45. int direct=0;


  46. int taco=1;

  47. char final[3];
  48. char times[3];
  49. int count=0;

  50. capture=cvCreateCameraCapture( 0 );
  51. frame = cvQueryFrame(capture);
  52. mergeImg = cvQueryFrame(capture);
  53. grey = cvCreateImage(cvSize(frame->width,frame->height), IPL_DEPTH_8U, 1);

  54. cvNamedWindow("now",0);
  55. cvNamedWindow("trans",0);
  56. cvNamedWindow("Black",0);
  57. cvNamedWindow("DE",0);

  58. /*Random fish position*/
  59. for(int i=0;i<Fish;i++){
  60.             Fishx[i]= rand() % (frame->width - logoImg->width - 2);
  61.             Fishy[i]= rand() % (frame->height - logoImg->height - 2);
  62.             }
  63. /*Random taco position*/
  64. tacox=rand() % (frame->width - logoImg->width - 2);
  65. tacoy=rand() % (frame->height - logoImg->height - 2);;

  66. int con=1;


  67. while(1)
  68. {
  69.         white = cvLoadImage("background.jpg");
  70.    mergeImg = white;
  71.    cvPutText(mergeImg,"Grade",TextPosition1,&Font1,Color);
  72.    cvShowImage("DE", mergeImg);
  73.    if(Grade==15){
  74.     cvShowImage("DE",win);
  75.             }
  76.    frame = cvQueryFrame(capture);
  77.    //cvFlip(frame,frame,1);
  78.    cvShowImage("now", frame);

  79.    cvCvtColor(frame, frame, CV_BGR2YCrCb);
  80.    cvShowImage("trans", frame);
  81.    cvInRangeS(frame, cvScalar(0,137,77), cvScalar(256,177,127),grey);
  82.    cvFlip(grey,grey,0);
  83.    cvErode(grey,grey,0,5);
  84.    cvDilate(grey,grey,0,5);
  85.    cvShowImage("Black", grey);
  86.    /*Regulate the Fish Position*/
  87.    direct=Fish;
  88.    for(int i=0;i<Fish;i++){
  89.          if(Fishy[i]!=frame->height*2){
  90.            if (i<(direct/3))
  91.               Fishy[i] = ((Fishy[i] - 5) % (frame->height - logoImg->height + 20));
  92.            else if(i<((2*direct)/3))
  93.               Fishx[i] = ((Fishx[i] + 5) % (frame->width - logoImg->width - 2));
  94.            else{
  95.               Fishy[i] = ((Fishy[i] - 5) % (frame->height - logoImg->height + 20));
  96.               Fishx[i] = ((Fishx[i] + 5) % (frame->width - logoImg->width - 2));
  97.                 }
  98.               }
  99.          if(Fishy[i]==(frame->height*2)){
  100.              Fishy[i]+=0;
  101.              Fishx[i]+=0;
  102.                                   }
  103.          else if ((Fishy[i] < 0) || (Fishy[i]>(frame->height)) || (Fishx[i] < 0) || (Fishx[i]>(frame->width))){
  104.             Fishy[i] = rand() % (frame->height - logoImg->height - 2);
  105.             Fishx[i] = rand() % (frame->width - logoImg->width - 2);
  106.             }
  107.           }
  108.    /*Regulate the taco Position*/
  109.    if(taco==1){
  110.          if(tacoy!=frame->height*2){
  111.               tacoy = ((tacoy - 5) % (frame->height - logoImg->height + 20));
  112.               tacox = ((tacox + 5) % (frame->width - logoImg->width - 2));
  113.               }
  114.          if(tacoy==(frame->height*2)){
  115.              tacoy+=0;
  116.              tacox+=0;
  117.                                   }
  118.          else if ((tacoy < 0) || (tacoy>(frame->height)) || (tacox < 0) || (tacox>(frame->width))){
  119.             tacoy = rand() % (frame->height - logoImg->height - 2);
  120.             tacox = rand() % (frame->width - logoImg->width - 2);
  121.             }
  122.           }

  123.    /*Show the Fish*/   
  124.    for(int i=0;i<Fish;i++){         
  125.       for (int y1=0; y1<logoImg->height; y1++) {  
  126.       uchar* ptr1=(uchar*) (logoImg->imageData +y1*logoImg->widthStep);
  127.       uchar* ptr2=(uchar*) (mergeImg->imageData +(y1+Fishy[i])*mergeImg->widthStep);
  128.         for (int x1=0; x1<logoImg->width; x1++) {     
  129.           ptr2[3*(x1+Fishx[i])]=alphaf*ptr1[3*(x1)] + (1-alphaf)*ptr2[3*(x1+Fishx[i])];
  130.           ptr2[3*(x1+Fishx[i])+1]=alphaf*ptr1[3*(x1)+1] + (1-alphaf)*ptr2[3*(x1+Fishx[i])+1];
  131.           ptr2[3*(x1+Fishx[i])+2]=alphaf*ptr1[3*(x1)+2] + (1-alphaf)*ptr2[3*(x1+Fishx[i])+2];   
  132.               }   
  133.            }
  134.          }
  135.    /*Show the taco*/
  136.    if(taco==1){         
  137.       for (int y1=0; y1<PicTaco->height; y1++) {  
  138.       uchar* ptr1=(uchar*) (PicTaco->imageData +y1*PicTaco->widthStep);
  139.       uchar* ptr2=(uchar*) (mergeImg->imageData +(y1+tacoy)*mergeImg->widthStep);
  140.         for (int x1=0; x1<logoImg->width; x1++) {     
  141.           ptr2[3*(x1+tacox)]=alpha*ptr1[3*(x1)] + (1-alpha)*ptr2[3*(x1+tacox)];
  142.           ptr2[3*(x1+tacox)+1]=alpha*ptr1[3*(x1)+1] + (1-alpha)*ptr2[3*(x1+tacox)+1];
  143.           ptr2[3*(x1+tacox)+2]=alpha*ptr1[3*(x1)+2] + (1-alpha)*ptr2[3*(x1+tacox)+2];   
  144.               }   
  145.            }
  146.          }

  147.    /*Detect the Skin*/
  148.    for (int y=0; y<grey->height; y++) {
  149.     uchar* ptr1=(uchar*) (grey->imageData +y*grey->widthStep);
  150.     for (int x=0; x<grey->width; x++) {
  151.       if(ptr1[x]==255){
  152.         MouseX=x;
  153.         MouseY=grey->height-y;
  154.         y=grey->height-1;
  155.         x=grey->width-1;
  156.                      }
  157.        }
  158.       }
  159.    /*Show the Mouse*/
  160.   if( (MouseImg1->height + MouseY) > mergeImg->height)
  161.      //MouseY = mergeImg->height - MouseImg1->height - 1;
  162.     MouseY =MouseImg1->height - 1;

  163.   for (int y1=0; y1<MouseImg1->height; y1++) {  
  164.     uchar* ptr1=(uchar*) (MouseImg1->imageData +y1*MouseImg1->widthStep);
  165.     uchar* ptr7=(uchar*) (mergeImg->imageData +(y1+MouseY)*mergeImg->widthStep);
  166.     for (int x1=0; x1<MouseImg1->width; x1++) {     
  167.      ptr7[3*(x1+MouseX)]=alphaf*ptr1[3*(x1)] + (1-alphaf)*ptr7[3*(x1+MouseX)];
  168.      ptr7[3*(x1+MouseX)+1]=alphaf*ptr1[3*(x1)+1] + (1-alphaf)*ptr7[3*(x1+MouseX)+1];
  169.      ptr7[3*(x1+MouseX)+2]=alphaf*ptr1[3*(x1)+2] + (1-alphaf)*ptr7[3*(x1+MouseX)+2];   
  170.      }
  171.   }
  172.   cvPutText(mergeImg,"Grade",TextPosition1,&Font1,Color);
  173.   /*Show the user time*/
  174.   cvPutText(mergeImg,"Time: ",TextPosition3,&Font1,Color);
  175.     if(count%5==0){
  176.       /*times[0]=(char)(count/5/10+48);
  177.       times[1]=(char)(count/5%10+48);*/
  178.   times[2]=(char)(count/5%10+48);
  179.   times[1]=(char)((count/5/10)%10+48);
  180.   times[0]=(char)(count/5/100+48) ;
  181. }
  182.   cvPutText(mergeImg,times, TextPosition4, &Font1, Color);
  183.   cvShowImage("DE", mergeImg);
  184.   if(Grade==15){
  185.     cvShowImage("DE",win);
  186.             }

  187.   /*Counting the grades and Fishes disapear*/
  188.   for(int i=0;i<Fish;i++){
  189.     double temp =  sqrt((MouseX-Fishx[i])*(MouseX-Fishx[i])+(MouseY-Fishy[i])*(MouseY-Fishy[i]));
  190.     if(temp<=12.0){
  191.       Grade++;
  192.       final[0]=(char)(Grade/10+48);
  193.       final[1]=(char)(Grade%10+48);
  194.       Fishx[i]=Fishx[Fish-1];
  195.       Fishy[i]=Fishy[Fish-1];
  196.       Fish--;
  197.       }
  198.           }
  199.    cvPutText(mergeImg,final, TextPosition2, &Font1, Color);
  200.   /*taco disapear and the page black*/
  201.   if(taco==1){
  202.     double tacotemp =  sqrt((MouseX-tacox)*(MouseX-tacox)+(MouseY-tacoy)*(MouseY-tacoy));
  203.     if(tacotemp <= 12.0){
  204.       tacox=NULL;
  205.       tacoy=NULL;
  206.       taco=0;
  207.       cvShowImage("DE",black);
  208.       count+=15;
  209.       cvWaitKey(3000);
  210.       }
  211.           }

  212.   cvShowImage("DE", mergeImg);
  213.   /*Pass Image*/
  214.   if(Grade==15){
  215.     cvShowImage("DE",win);
  216.             }

  217. count+=1;
  218. cvWaitKey(200);
  219. }

  220. cvReleaseCapture(&capture);
  221. cvDestroyWindow("now");
  222. cvDestroyWindow("trans");
  223. cvDestroyWindow("Black");
  224. cvDestroyWindow("DE");
  225. }
複製代碼




它會顯示 [Warning] converting to `unsigned char' from `double'

請各位大大教我如何解決
...
瀏覽完整內容,請先 註冊登入會員

點評

snowflying Warning 會顯示行數吧  發表於 2014-6-11 11:10 PM
分享分享0收藏收藏0支持支持0
系統已重置禁訪用戶到普通用戶和密碼一次
回覆中加入附件並不會使你增加積分,請使用主題方式發佈附件。

使用道具檢舉

帖子
373
積分
254 點
潛水值
19561 米
頭香
發表於 2014-6-11 11:01 PM|只看該作者
這是一個撈金魚的視訊小遊戲

使用道具檢舉

帖子
373
積分
254 點
潛水值
19561 米
3
發表於 2014-6-11 11:58 PM|只看該作者
如果發覺自己無法使用一些功能或出現問題,請按重新整理一次,並待所有網頁內容完全載入後5秒才進行操作。
它顯示 146 147 148 158 159 160 186 187 188 224 225
我試了一個下午,不知道錯哪裡~"~

點評

snowflying uchar* ptrN 然後再與 double 做運算,Warning 只是提醒你這一部份吧  發表於 2014-6-12 01:00 AM

使用道具檢舉

Rank: 2Rank: 2

帖子
380
積分
462 點
潛水值
12140 米
4
發表於 2014-6-12 12:20 PM|只看該作者
分享使你變得更實在,可以使其他人感到快樂,分享是我們的動力。今天就來分享你的資訊、圖片或檔案吧。
可以查詢c++轉型相關資訊,我只能大概提一下,完整的資訊還是得去爬文。
基本上,編譯器會自動將兩個不同型態的變數先轉成相同的型態,轉成較大的型態。
浮點數轉非浮點數雖然也有自動轉型,但是會在特別提示你,
正在將浮點數轉成非浮點數,小數點的部分會被捨去,
你可以用強制轉型的方式,或者一些函式處理。
可以無條件捨去,可以無條件進位。
...
瀏覽完整內容,請先 註冊登入會員
--
人人有把握,各個沒機會。
成為伊莉的版主,你將獲得更高級和無限的權限。把你感興趣的版面一步步地發展和豐盛,那種滿足感等著你來嚐嚐喔。

使用道具檢舉

帖子
373
積分
254 點
潛水值
19561 米
5
發表於 2014-6-14 12:22 AM|只看該作者
若新密碼無法使用,可能是數據未更新。請使用舊密碼看看。
我已經解決了^^
謝謝各位大大




使用道具檢舉

您需要登錄後才可以回帖 登錄 | 註冊

Powered by Discuz!

© Comsenz Inc.

重要聲明:本討論區是以即時上載留言的方式運作,對所有留言的真實性、完整性及立場等,不負任何法律責任。而一切留言之言論只代表留言者個人意見,並非本網站之立場,用戶不應信賴內容,並應自行判斷內容之真實性。於有關情形下,用戶應尋求專業意見(如涉及醫療、法律或投資等問題)。 由於本討論區受到「即時上載留言」運作方式所規限,故不能完全監察所有留言,若讀者發現有留言出現問題,請聯絡我們。有權刪除任何留言及拒絕任何人士上載留言,同時亦有不刪除留言的權利。切勿上傳和撰寫 侵犯版權(未經授權)、粗言穢語、誹謗、渲染色情暴力或人身攻擊的言論,敬請自律。本網站保留一切法律權利。
回頂部