2013-07-19 4 views
0

그래서 내 이미지 처리 프로젝트에서 각 프레임을 처리하는 데 걸리는 평균 시간을 계산하기 위해 gettickcount()를 사용하고 있습니다. 그러나 속도를 위해 모든 다른 프레임을 처리하기로했습니다. 이론적으로 프로그램은 더 빨리 실행되어야합니다. 그러나 gettickcount에서 얻은 값은 동일하게 유지됩니다. 따라서 gettickcount 함수가 아직 처리되지 않은 프로그램 이미지의 눈금을 계산하고 있다고 생각하게됩니다.내 프로그램의 실행 시간 계산

while(capture.grab()) 
{ 
    int64 t = getTickCount(); 

    if(count == 0) //count is each image number. this segment processes the first image 
    { 

    } 

    if(count % 2 == 1) //processes every other image 
    { 

    } 
} 

getTickCount 기능을 사용하지 않아도 if (count % 2 == 1)의 틱을 계산합니까?

감사합니다.

+0

당신이 [윈도우] (에있어 있으리라 믿고있어 http://msdn.microsoft.com/en-us/library/windows/desktop/ms724408%28v = vs.85 % 29.aspx) C++을 사용합니다. 이것은 올바른 가정입니까? – tjameson

+1

@Jordy - 당신은 그것에 관해 절대적으로 확신합니까? 커피 시간이야? – Zec

+0

@Zec 예, 모듈러스 연산자는 나눗셈 후 나머지를 반환합니다. 그래서 나머지는 0입니다. – Jordy

답변

0
#include<stdio.h> 
#include<time.h> 

int main() 
{ 

clock_t start = clock(); 

//write your code here, and this will calculate the execution time of the code... 

clock_t ends = clock(); 

printf("run time: %.5f \n", ((double)(ends - 

start))/CLOCKS_PER_SEC); 

return 0; 

} 
0

예. "count"의 값에 관계없이 while 루프의 각 패스에서 getTickCount를 호출합니다.

시도 :

while(capture.grab()) 
{ 
    int64 t = 0; 

    if(count == 0) //count is each image number. this segment processes the first image 
    { 
     t = getTickCount(); 
    } 
    if(count % 2 == 1) //processes every other image 
    { 
     t = getTickCount(); 
    } 
} 
+0

내가 겪고있는 문제는 지금까지 공유 한 조건과 마찬가지로 나중에 "t"로 수행하는 것과 관련이 있다고 덧붙여 야합니다. "t"로 뭐하고 있니? – Zec