-
Notifications
You must be signed in to change notification settings - Fork 1
/
frmonmem.c
638 lines (558 loc) · 18.7 KB
/
frmonmem.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
//frmonmem
//based on captVideo.c
//
//compile
// C_INCLUDE_PATH=.\OpenCV2.0\include\opencv;
// LIBRARY_PATH=.\OpenCV2.0\lib;
// gcc frmonmem.c -o frmonmem.exe -lcxcore200.dll -lcv200.dll -lhighgui200.dll -lcvaux200.dll -lml200.dll -lwinmm -g -mwindows -lwinmm
//
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <ctype.h>
#include <windows.h>
#include "./SetHeaderIplImg_VGA.c"
const char gsVersion[]="FrmOnMem_v00_1_2";
enum{
MAX_N_FRAME = 400,
TGT_N_FRAME = 295,
MAX_M_TIME = 1,
WIDTH = 640,
HEIGHT = 480,
AREA = WIDTH * HEIGHT,
WAIT_FRAME_MS = 105 //33ms = 30fps , 66 ms = 15fps, 50ms = 20fps , 105 is for macBook
};
IplImage *gpimgMat[MAX_N_FRAME];
//IplImage *gpimgTmp;
IplImage gMimgMat[MAX_N_FRAME];
IplImage *gpimgRep[MAX_N_FRAME];
IplImage gMimgRep[MAX_N_FRAME];
unsigned int guiFlagFrameOver=0;
//IplImage gImgLgCapt[276480000]; // 30*30*640*480 //2147483647
long gImgLgCapt[MAX_M_TIME][MAX_N_FRAME][AREA]; // 30*30*640*480 //2147483647
long gImgLgRept[MAX_M_TIME][MAX_N_FRAME][AREA]; // 30*30*640*480 //2147483647
unsigned int guiMatHBuf[WIDTH*3+2];
void SetHeaderIplImg_VGA(IplImage *phead);
#define NBUF 1024
//int main (int argc, char *argv[])
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pCmdLine, int showCmd)
{
SYSTEMTIME stTime;
//int argc;char *argv[];
CvCapture *capture = 0;
CvCapture *captFile=0;
IplImage *frame = 0;
IplImage *LoadImg = 0;
double w = WIDTH, h = HEIGHT;//QVGA
int c;
unsigned int uilp;
const char FileNameSv[]=".\\captMv.avi"; //"captMv.avi";
const char FileNameLd[]="captImage.avi";
char FNameSv[NBUF];
char FNameLd[NBUF];
unsigned int uiFlagOpenWin=0;
unsigned int uiIndxCam=0;
CvVideoWriter *vw;//for video
CvFont font;//for video
char str[64];//for video
int FlmNum=0;
unsigned int uilpPX,uilpPY,uilpPBGR;
double dRemainWaitTime;
double dFreqTick = cvGetTickFrequency();
long long int llTickA;
long long int llTickB;
double dTakesTimeResult;
long long *pllMemDistination;
long long *pllMemSource;
unsigned int uiTargetWaitMs=WAIT_FRAME_MS;
unsigned int uiNumFrameMax=MAX_N_FRAME;
unsigned int uiFlCounter =1;
FILE *fid;
char cMessBuf[256];
char cFnameLdbuf[256];
unsigned int uiFlgPlayNow=0;
guiFlagFrameOver=0;
capture = cvCaptureFromCAM ( 0 );
cvSetCaptureProperty (capture, CV_CAP_PROP_FRAME_WIDTH, w);
cvSetCaptureProperty (capture, CV_CAP_PROP_FRAME_HEIGHT, h);
dFreqTick = cvGetTickFrequency();
// // --------------------------------------------------------------
// // make matrix
// // --------------------------------------------------------------
//gpimgTmp = cvCreateImage(cvSize(w,h),IPL_DEPTH_8U,3);
unsigned int uilpT=0;
for(uilp=0;uilp<MAX_N_FRAME;uilp++)
{
gpimgMat[uilp] = &gMimgMat[uilp];
SetHeaderIplImg_VGA(gpimgMat[uilp]);
gpimgMat[uilp]->imageData = (char *)&gImgLgCapt[uilpT][uilp][0];
gpimgRep[uilp] = &gMimgRep[uilp];
SetHeaderIplImg_VGA(gpimgRep[uilp]);
gpimgRep[uilp]->imageData = (char *)&gImgLgRept[uilpT][uilp][0];
}
// // --------------------------------------------------------------
// // check last file
// // --------------------------------------------------------------
for (uilp=0;uilp<256;uilp++) cFnameLdbuf[uilp]=0;
for (uilp=0;uilp<1000;uilp++) // todo: change max num
{
wsprintf(cFnameLdbuf,".\\LogCapt\\capt%05d_frm%03d.jpg",uilp,(int)(TGT_N_FRAME)-1);
// wsprintf(FNameLd,".\\captMv%05d.avi",uilp);
fid=fopen(FNameLd,"r");
if (fid==NULL)
{
wsprintf(cMessBuf,"no file: %X",uilp);
//MessageBox(NULL,cMessBuf , "error", MB_OK);
break;
}
fclose(fid);
}
//uiFlCounter = (int)uilp-1;
uiFlCounter = (int)uilp;
// // --------------------------------------------------------------
// // load previous file
// // --------------------------------------------------------------
// wsprintf(FNameLd,".\\captMv%05d.avi",uiFlCounter);
// captFile = cvCaptureFromAVI(FNameLd);
// uilp=0;
// while(1) // todo: change max loop
// {
// if(NULL==(frame=cvQueryFrame(captFile)))
// {
// break;
// }
// cvCopyImage(frame,gpimgMat[uilp]);
// uilp++;
// }
// uiNumFrameMax = uilp;
// cvReleaseCapture (&captFile);
for (uilp=0;uilp<TGT_N_FRAME;uilp++)
{
wsprintf(cFnameLdbuf,".\\LogCapt\\capt%05d_frm%03d.jpg",uiFlCounter,uilp);
frame=cvLoadImage(cFnameLdbuf,CV_LOAD_IMAGE_ANYCOLOR);
for (uilpPX=0; uilpPX<(WIDTH*HEIGHT*3); uilpPX++ )
{
gpimgMat[uilp]->imageData[uilpPX] = frame->imageData[uilpPX];
}
cvReleaseImage(&frame);
}
uiNumFrameMax = TGT_N_FRAME;
// flip LR
for(uilp=0;uilp<uiNumFrameMax;uilp++)
for(uilpPY=0;uilpPY<(HEIGHT);uilpPY++)
for(uilpPX=0;uilpPX<(WIDTH);uilpPX++)
for(uilpPBGR=0;uilpPBGR<(3);uilpPBGR++)
{
gpimgRep[uilp]->imageData[WIDTH*3*uilpPY+ WIDTH*3-uilpPX*3 + uilpPBGR ] = gpimgMat[uilp]->imageData[WIDTH*3*uilpPY+uilpPX*3 +uilpPBGR];
}
// // --------------------------------------------------------------
// // check processtime
// // --------------------------------------------------------------
cvNamedWindow ("Camera", CV_WINDOW_AUTOSIZE);
cvNamedWindow ("Replay", CV_WINDOW_AUTOSIZE);
cvMoveWindow ("Camera", 50,50);
cvMoveWindow ("Replay", 700,50);
#define N_LOOP_EVAL_SYS 50
double dTakesTimeCalc[N_LOOP_EVAL_SYS];
printf("checking process time\n");
for(uilp=0;uilp<N_LOOP_EVAL_SYS;uilp++)
{
llTickA = cvGetTickCount();
frame = cvQueryFrame (capture);
for(uilpPY=0;uilpPY<(HEIGHT);uilpPY++)
for(uilpPX=0;uilpPX<(WIDTH);uilpPX++)
for(uilpPBGR=0;uilpPBGR<(3);uilpPBGR++)
{
gpimgMat[uilp]->imageData[WIDTH*3*uilpPY+ WIDTH*3-uilpPX*3 + 2-uilpPBGR ] = frame->imageData[WIDTH*3*uilpPY+uilpPX*3 +uilpPBGR];
}
cvShowImage ("Camera", gpimgMat[uilp]);
cvShowImage ("Replay", gpimgRep[uilp]);
llTickB = cvGetTickCount();
dTakesTimeResult = ( llTickB - llTickA)/cvGetTickFrequency() /1000;
dTakesTimeCalc[uilp]=dTakesTimeResult;
}
//printf("takeTicks%e\n",cvGetTickCount() - cvGetTickCount());
//for(uilp=0;uilp<N_LOOP_EVAL_SYS;uilp++)
// printf("time%d\t%e\n",uilp,dTakesTimeCalc[uilp]);
// takeTicks0.000000e+000
// time0 8.883266e+000
// time1 1.295886e+001
// time2 3.246333e+001
// time3 3.233828e+001
// time4 3.217605e+001
// time5 3.334306e+001
// time6 3.247026e+001
// time7 3.251036e+001
// time8 3.275937e+001
// time9 3.179434e+001
cvDestroyWindow ("Camera");
cvDestroyWindow ("Replay");
cvReleaseCapture (&capture);
double dMaxTmp=0;
double dSumTmp=0;
for(uilp=0;uilp<N_LOOP_EVAL_SYS;uilp++)
{
// printf("time%d\t%e\n",uilp,dTakesTimeCalc[uilp]);
dSumTmp += dTakesTimeCalc[uilp]*(uilp!=0); //skip first count
if (dMaxTmp<dTakesTimeCalc[uilp])
{
dMaxTmp = dTakesTimeCalc[uilp];
}
}
uiTargetWaitMs = (int)(dMaxTmp+0.9)+10;
printf("max time= %f\tavefage= %f\n",dMaxTmp, dSumTmp/(N_LOOP_EVAL_SYS-1));
if (uiTargetWaitMs < WAIT_FRAME_MS)
{
uiTargetWaitMs = WAIT_FRAME_MS;
printf("change wait to = %d\n",uiTargetWaitMs);
}
IplImage *imgPict = 0;
while(1){
// // --------------------------------------------------------------
// // title
// // --------------------------------------------------------------
cvNamedWindow ("Title", CV_WINDOW_AUTOSIZE);
cvMoveWindow ("Title", 700,50);
imgPict=cvLoadImage(".\\title.png",CV_LOAD_IMAGE_ANYCOLOR);
cvShowImage ("Title", imgPict);
cvReleaseImage(&imgPict);
c = cvWaitKey (2000); // wait n milliseconds
// cvDestroyWindow ("Title");
if (c == '\x1b') uiFlgPlayNow=1;
cvDestroyWindow ("Title");
if (uiFlgPlayNow==1)
{
// // --------------------------------------------------------------
// // instruction
// // --------------------------------------------------------------
capture = cvCaptureFromCAM ( 0 );
cvNamedWindow ("Camera", CV_WINDOW_AUTOSIZE);
cvNamedWindow ("Replay", CV_WINDOW_AUTOSIZE);
cvMoveWindow ("Camera", 50,50);
cvMoveWindow ("Replay", 700,50);
imgPict=cvLoadImage(".\\inst.png",CV_LOAD_IMAGE_ANYCOLOR);
cvShowImage ("Title", imgPict);
cvReleaseImage(&imgPict);
// c = cvWaitKey (2000); // wait n milliseconds
for(uilp=0;uilp<20;uilp++)
{
llTickA = cvGetTickCount();
frame = cvQueryFrame (capture);
cvShowImage ("Camera", frame);
llTickB = cvGetTickCount();
dTakesTimeResult = ( llTickB - llTickA)/dFreqTick /1000;
dRemainWaitTime = uiTargetWaitMs - dTakesTimeResult;
if (dRemainWaitTime <= 0)
{
dRemainWaitTime=1;
}
else
{
c = cvWaitKey ((int)dRemainWaitTime); // wait n milliseconds
}
if (c == '\x1b') break;
}
imgPict=cvLoadImage(".\\3.png",CV_LOAD_IMAGE_ANYCOLOR);
cvShowImage ("Title", imgPict);
cvReleaseImage(&imgPict);
//c = cvWaitKey (1000); // wait n milliseconds
for(uilp=0;uilp<10;uilp++)
{
llTickA = cvGetTickCount();
frame = cvQueryFrame (capture);
cvShowImage ("Camera", frame);
llTickB = cvGetTickCount();
dTakesTimeResult = ( llTickB - llTickA)/dFreqTick /1000;
dRemainWaitTime = uiTargetWaitMs - dTakesTimeResult;
if (dRemainWaitTime <= 0)
{
dRemainWaitTime=1;
}
else
{
c = cvWaitKey ((int)dRemainWaitTime); // wait n milliseconds
}
if (c == '\x1b') break;
}
imgPict=cvLoadImage(".\\2.png",CV_LOAD_IMAGE_ANYCOLOR);
cvShowImage ("Title", imgPict);
cvReleaseImage(&imgPict);
//c = cvWaitKey (1000); // wait n milliseconds
for(uilp=0;uilp<10;uilp++)
{
llTickA = cvGetTickCount();
frame = cvQueryFrame (capture);
cvShowImage ("Camera", frame);
llTickB = cvGetTickCount();
dTakesTimeResult = ( llTickB - llTickA)/dFreqTick /1000;
dRemainWaitTime = uiTargetWaitMs - dTakesTimeResult;
if (dRemainWaitTime <= 0)
{
dRemainWaitTime=1;
}
else
{
c = cvWaitKey ((int)dRemainWaitTime); // wait n milliseconds
}
if (c == '\x1b') break;
}
cvReleaseImage(&imgPict);
imgPict=cvLoadImage(".\\1.png",CV_LOAD_IMAGE_ANYCOLOR);
cvShowImage ("Title", imgPict);
cvReleaseImage(&imgPict);
//c = cvWaitKey (1000); // wait n milliseconds
for(uilp=0;uilp<10;uilp++)
{
llTickA = cvGetTickCount();
frame = cvQueryFrame (capture);
cvShowImage ("Camera", frame);
llTickB = cvGetTickCount();
dTakesTimeResult = ( llTickB - llTickA)/dFreqTick /1000;
dRemainWaitTime = uiTargetWaitMs - dTakesTimeResult;
if (dRemainWaitTime <= 0)
{
dRemainWaitTime=1;
}
else
{
c = cvWaitKey ((int)dRemainWaitTime); // wait n milliseconds
}
if (c == '\x1b') break;
}
cvDestroyWindow ("Title");
// // --------------------------------------------------------------
// // main
// // --------------------------------------------------------------
dFreqTick = cvGetTickFrequency();
dRemainWaitTime=0;
PlaySound("kakumabon03.wav",NULL,SND_FILENAME | SND_ASYNC);//sound start
for(uilp=0;uilp<uiNumFrameMax;uilp++)
{
llTickA = cvGetTickCount();
frame = cvQueryFrame (capture);
for(uilpPY=0;uilpPY<(HEIGHT);uilpPY++)
for(uilpPX=0;uilpPX<(WIDTH);uilpPX++)
for(uilpPBGR=0;uilpPBGR<(3);uilpPBGR++)
{
gpimgMat[uilp]->imageData[WIDTH*3*uilpPY+ WIDTH*3-(uilpPX+0)*3 + uilpPBGR ] = frame->imageData[WIDTH*3*uilpPY+uilpPX*3 +uilpPBGR];
}
// for(uilpPX=0;uilpPX<(WIDTH*HEIGHT*3);uilpPX++)
// {
// gpimgMat[uilp]->imageData[uilpPX] = frame->imageData[uilpPX];
// }
// pllMemDistination =(long long *)&(gpimgMat[uilp]->imageData[0]);
// pllMemSource =(long long *)&(frame->imageData[0]);
// for(uilpPX=0;uilpPX<(640*480*3)/8;uilpPX++)
// {
// pllMemDistination[uilpPX] = pllMemSource[uilpPX];
// }
// printf("in\t%d\t %X\n",uilp,gpimgMat[uilp]->imageData); // ok
cvShowImage ("Camera", gpimgMat[uilp]);
cvShowImage ("Replay", gpimgRep[uilp]);
llTickB = cvGetTickCount();
dTakesTimeResult = ( llTickB - llTickA)/dFreqTick /1000;
dRemainWaitTime = uiTargetWaitMs - dTakesTimeResult;
if (dRemainWaitTime <= 0)
{
guiFlagFrameOver=1;
dRemainWaitTime=1;
}
else
{
c = cvWaitKey ((int)dRemainWaitTime); // wait n milliseconds
}
if (c == '\x1b') break;
}// end of for uilp
PlaySound(NULL,NULL,0);//sound stop
cvDestroyWindow ("Camera");
cvDestroyWindow ("Replay");
cvReleaseCapture (&capture);
// // --------------------------------------------------------------
// // flip LP current data
// // --------------------------------------------------------------
for(uilp=0;uilp<uiNumFrameMax;uilp++)
for(uilpPY=0;uilpPY<(HEIGHT);uilpPY++)
{
for(uilpPX=0;uilpPX<(WIDTH);uilpPX++)
for(uilpPBGR=0;uilpPBGR<(3);uilpPBGR++)
{
guiMatHBuf[WIDTH*3-uilpPX*3 + uilpPBGR -0] = gpimgMat[uilp]->imageData[WIDTH*3*uilpPY+uilpPX*3 +uilpPBGR];
}
for(uilpPX=0;uilpPX<(WIDTH*3);uilpPX++)
gpimgMat[uilp]->imageData[WIDTH*3*uilpPY+ uilpPX ] = guiMatHBuf[uilpPX];
}
// // --------------------------------------------------------------
// // replay
// // --------------------------------------------------------------
cvNamedWindow ("ReplayNow", CV_WINDOW_AUTOSIZE);
cvMoveWindow ("ReplayNow", 50,50);
PlaySound("kakumabon03.wav",NULL,SND_FILENAME | SND_ASYNC);//sound start
for(uilp=0;uilp<uiNumFrameMax;uilp++)
{
llTickA = cvGetTickCount();
cvShowImage ("ReplayNow", gpimgMat[uilp]);
llTickB = cvGetTickCount();
dTakesTimeResult = ( llTickB - llTickA)/dFreqTick /1000;
dRemainWaitTime = uiTargetWaitMs - dTakesTimeResult;
if (dRemainWaitTime <= 0)
{
guiFlagFrameOver=1;
dRemainWaitTime=1;
}
else
{
c = cvWaitKey ((int)dRemainWaitTime); // wait n milliseconds
}
if (c == '\x1b') break;
}
cvDestroyWindow ("ReplayNow");
//int iFlgRtn = 0;
// // --------------------------------------------------------------
// // file save
// // --------------------------------------------------------------
cvNamedWindow ("Title", CV_WINDOW_AUTOSIZE);
cvMoveWindow ("Title", 700,50);
imgPict=cvLoadImage(".\\savenow.png",CV_LOAD_IMAGE_ANYCOLOR);
cvShowImage ("Title", imgPict);
cvReleaseImage(&imgPict);
c = cvWaitKey (100); // wait n milliseconds
char cFnamesvbuf[100];
uiFlCounter = uiFlCounter+1;
//uiFlCounter = 0;
for(uilp=0;uilp< uiNumFrameMax;uilp++)
{
wsprintf(cFnamesvbuf,".\\LogCapt\\capt%05d_frm%03d.jpg",uiFlCounter,uilp);
cvSaveImage(cFnamesvbuf, gpimgMat[uilp],0);
}
uiFlgPlayNow=0;
cvReleaseImage(&imgPict);
// // --------------------------------------------------------------
// // load previous file
// // --------------------------------------------------------------
// for (uilp=0;uilp<TGT_N_FRAME;uilp++)
// {
// wsprintf(cFnameLdbuf,".\\LogCapt\\capt%05d_frm%03d.jpg",uiFlCounter,uilp);
// gpimgMat[uilp]=cvLoadImage(cFnameLdbuf,CV_LOAD_IMAGE_ANYCOLOR);
// }
//
// uiNumFrameMax = TGT_N_FRAME;
// flip LR
for(uilp=0;uilp<uiNumFrameMax;uilp++)
for(uilpPY=0;uilpPY<(HEIGHT);uilpPY++)
for(uilpPX=0;uilpPX<(WIDTH);uilpPX++)
for(uilpPBGR=0;uilpPBGR<(3);uilpPBGR++)
{
gpimgRep[uilp]->imageData[WIDTH*3*uilpPY+ WIDTH*3-(uilpPX+0)*3 + uilpPBGR ] = gpimgMat[uilp]->imageData[WIDTH*3*uilpPY+uilpPX*3 +uilpPBGR];
}
}
else
{
// demo inst
imgPict=cvLoadImage(".\\exitp.png",CV_LOAD_IMAGE_ANYCOLOR);
cvShowImage ("Title", imgPict);
cvMoveWindow ("Title", 700,50);
cvReleaseImage(&imgPict);
c = cvWaitKey (1000); // wait n milliseconds
if (c == '\x1b') break;//halt
imgPict=cvLoadImage(".\\demo01.png",CV_LOAD_IMAGE_ANYCOLOR);
cvShowImage ("Title", imgPict);
cvMoveWindow ("Title", 700,50);
cvReleaseImage(&imgPict);
c = cvWaitKey (1000); // wait n milliseconds
if (c == '\x1b') break;//halt
// load file for demo replay
for (uilp=0;uilp<TGT_N_FRAME;uilp++)
{
wsprintf(cFnameLdbuf,".\\LogCapt\\capt%05d_frm%03d.jpg",uiFlCounter,uilp);
frame=cvLoadImage(cFnameLdbuf,CV_LOAD_IMAGE_ANYCOLOR);
for (uilpPX=0; uilpPX<(WIDTH*HEIGHT*3); uilpPX++ )
{
gpimgRep[uilp]->imageData[uilpPX] = frame->imageData[uilpPX];
}
cvReleaseImage(&frame);
}
cvDestroyWindow ("Title");
// // --------------------------------------------------------------
// // replay demo
// // --------------------------------------------------------------
cvNamedWindow ("ReplayDemo", CV_WINDOW_AUTOSIZE);
cvMoveWindow ("ReplayDemo", 50,50);
PlaySound("kakumabon03.wav",NULL,SND_FILENAME | SND_ASYNC);//sound start
for(uilp=0;uilp<uiNumFrameMax;uilp++)
{
llTickA = cvGetTickCount();
cvShowImage ("ReplayDemo", gpimgRep[uilp]);
llTickB = cvGetTickCount();
dTakesTimeResult = ( llTickB - llTickA)/dFreqTick /1000;
dRemainWaitTime = uiTargetWaitMs - dTakesTimeResult;
if (dRemainWaitTime <= 0)
{
guiFlagFrameOver=1;
dRemainWaitTime=1;
}
else
{
c = cvWaitKey ((int)dRemainWaitTime); // wait n milliseconds
}
if (c == '\x1b') break;
}
cvDestroyWindow ("ReplayDemo");
imgPict=cvLoadImage(".\\exitp.png",CV_LOAD_IMAGE_ANYCOLOR);
cvShowImage ("Title", imgPict);
cvMoveWindow ("Title", 700,50);
cvReleaseImage(&imgPict);
c = cvWaitKey (1000); // wait n milliseconds
if (c == '\x1b') break;// halt
cvDestroyWindow ("Title");
}//else if
// rem : save as video
// double dRecodeFps = (1/(double)(uiTargetWaitMs)*1000);
// // MessageBox(NULL, sprintf("ovFlg=%d intrvl=%d[ms]",guiFlagFrameOver,uiTargetWaitMs), "message", MB_OK);
// char cFnamesvbuf[16];
// uiFlCounter = uiFlCounter+1;
// wsprintf(cFnamesvbuf,".\\captMv%05d.avi",uiFlCounter);
// vw = cvCreateVideoWriter (cFnamesvbuf, CV_FOURCC ('M', 'S', 'V', 'C'), dRecodeFps, cvSize (WIDTH, HEIGHT),1);
//
// if (vw == NULL)
// {
// wsprintf(cMessBuf,"ERROR in create video writer %X",vw);
// MessageBox(NULL,cMessBuf , "error", MB_OK);
// }
// else
// {
// wsprintf(cMessBuf,"create video writer %X",vw);
// // MessageBox(NULL,cMessBuf , "message", MB_OK);
// }
//
// // MessageBox(NULL, "save file start", "message", MB_OK);
// for(uilp=0;uilp<uiNumFrameMax;uilp++)
// {
// iFlgRtn=cvWriteFrame (vw, gpimgMat[uilp]);//for video
// //return 1 is correct. if (iFlgRtn!=0)
// // if (iFlgRtn!=1)
// // {
// // wsprintf(cMessBuf,"error in write frame %d",iFlgRtn);
// // MessageBox(NULL, cMessBuf, "error", MB_OK);
// // break;
// // }
// // it takes too much time!
// }
// cvReleaseVideoWriter (&vw);//for video
// // MessageBox(NULL, "save file done", "message", MB_OK);
}//while
cvDestroyWindow ("Title");
MessageBox(NULL, "halted", "message", MB_OK);
// // --------------------------------------------------------------
// // epilogue
// // --------------------------------------------------------------
return 0;
}
//
// to do
//
// 1: change flow to loop
// 2: add demo routine
// 3: change max num of search record file
// 4: sound play from memory
// 5: lead replay and ontime replay on small window
// 6: