顯示具有 98360985鄒金唐 標籤的文章。 顯示所有文章
顯示具有 98360985鄒金唐 標籤的文章。 顯示所有文章

2013年6月9日 星期日

課程回顧

1.最喜歡哪個作業

        最喜歡的作業是透明人,因為在想要怎麼去做透明處理,那時候跟同學一起討論了很久,最後因為不太確定要怎麼做,於是就使用不太確定的方法去寫,最後成功的寫出了透明人,雖然效果沒有很好,但是有成功的達到透明的方法。

2.在課程中學到甚麼
        在課堂當中,因為老師只引入門的方法,而老師也會提出其他要我們去實作,於是我們就要開始去尋找要怎麼達到老師的要求,在這之中要想到解決的方法,以及要成功做出來的效果,花了不少時間,不過到成功的那一刻成就感是很歡喜的,學到最多的也許就是成功解決問題的方法吧。

3.上完課之後有甚麼改變
        上完這堂課之後,改變最多的是對多媒體的概念,以前對多媒體並沒有太多的認識,但是在學了webcam之後,要去變色,翻轉等等效果的影像處理,對以前沒修過的我還是挺新鮮的。而另一方面,Arduino也是新接觸,把電路板跟程式結合在一起,以前是想都沒有想過有這個 皆會,但是Arduino卻能簡單的達到目的,而在期中專案發表也能與組員寫出一項還不錯的專案,能夠接觸到這些都要好好的謝謝老師。

2013年5月26日 星期日

98360985_鄒金唐_上機考



考試題目:
        將畫面從中切成兩半,並在中間切割處畫上紅線,同時兩邊分別各有一頂不同皇冠,當頭移至右邊時,戴上右邊黃冠,左邊時,戴上左邊皇冠。

考試結果:
      紅線、皇冠沒有戴在頭上、也沒有去背,皇冠圖案沒有出現在左右(沒時間寫出來)

事後debug:
      皇冠戴在頭上
       for (int y=0; y<pink->height; y++) {  
            uchar* ptr1=(uchar*) (pink->imageData +y*pink->widthStep);
            for (int x=0; x<pink->width; x++) {     
                if(ptr1[x] ==255) 
                {
                               skinPixelNumber++;
                               skinPixelX+=x;
                               skinPixelY+=y;
                               }
                if(skinPixelNumber>0)
                {
                         mouseX=(int)(skinPixelX/skinPixelNumber)-50;
                         mouseY=(int)(skinPixelY/skinPixelNumber)-100;
                         }
        
        }
        }

位置稍微修改mouseXY即可


沒有去背:


 if(mouseX>160)
        {
        if( (crownleft->height + mouseX) < frame->height) {
            for (int y=0; y<crownleft->height; y++) {  
                uchar* ptr1=(uchar*) (crownleft->imageData +y*crownleft->widthStep);
                uchar* ptr2=(uchar*) (frame->imageData +(y+mouseY)*frame->widthStep);
                for (int x=0; x<(crownleft->width); x++) {
                     if(ptr1[3*(x)]!=255 && ptr1[3*(x)+1]!=255 && ptr1[3*(x)+2]!=255)
                    {     
                    ptr2[3*(x+mouseX)]=ptr1[3*(x)]; 
                    ptr2[3*(x+mouseX)+1]=ptr1[3*(x)+1]; 
                    ptr2[3*(x+mouseX)+2]=ptr1[3*(x)+2];   
                    } 
                    }
                    
                               }
                }    
                }
        if(mouseX<=160)
        {
        if( (crownright->height + mouseX) < frame->height) {
            for (int y=0; y<crownright->height; y++) {  
                uchar* ptr1=(uchar*) (crownright->imageData +y*crownright->widthStep);
                uchar* ptr2=(uchar*) (frame->imageData +(y+mouseY)*frame->widthStep);
                for (int x=0; x<(crownright->width); x++) { 
                    if(ptr1[3*(x)]!=255 && ptr1[3*(x)+1]!=255 && ptr1[3*(x)+2]!=255)
                    {
                    ptr2[3*(x+mouseX)]=ptr1[3*(x)]; 
                    ptr2[3*(x+mouseX)+1]=ptr1[3*(x)+1]; 
                    ptr2[3*(x+mouseX)+2]=ptr1[3*(x)+2];
                    }    
                    }
                    
                               }
                }    
                }

加了紅字那段就可以去背
一直想不到要怎麼去背
寫一個if即可



皇冠圖案出現在左右:

for (int y=0; y<crownright->height; y++) {  
                uchar* ptr1=(uchar*) (crownright->imageData +y*crownright->widthStep);
                uchar* ptr2=(uchar*) (frame->imageData +(y+y1)*frame->widthStep); 
                for (int x=0; x<crownright->width; x++) {     
                    ptr2[3*(x+x1)]=alpha*ptr1[3*(x)] + (1-alpha)*ptr2[3*(x+x1)]; 
                    ptr2[3*(x+x1)+1]=alpha*ptr1[3*(x)+1] + (1-alpha)*ptr2[3*(x+x1)+1]; 
                    ptr2[3*(x+x1)+2]=alpha*ptr1[3*(x)+2] + (1-alpha)*ptr2[3*(x+x1)+2];    
                    }
                }    
                
            
            for (int y=0; y<crownleft->height; y++) {  
                uchar* ptr1=(uchar*) (crownleft->imageData +y*crownleft->widthStep);
                uchar* ptr2=(uchar*) (frame->imageData +(y+y1)*frame->widthStep); 
                for (int x=0; x<crownleft->width; x++) {     
                    ptr2[3*(x+x2)]=alpha*ptr1[3*(x)] + (1-alpha)*ptr2[3*(x+x2)]; 
                    ptr2[3*(x+x2)+1]=alpha*ptr1[3*(x)+1] + (1-alpha)*ptr2[3*(x+x2)+1]; 
                    ptr2[3*(x+x2)+2]=alpha*ptr1[3*(x)+2] + (1-alpha)*ptr2[3*(x+x2)+2];    
                    }
                }    

考試實在de前面幾個bug沒有時間寫上去

考試之後補齊上去

考試心得:
      這次考試沒有說很難,只是需要一點時間我完成,最後還是順利寫出來了,感謝林志光同學的幫忙。