Thread: [artoolkit-commits] artoolkit/lib/SRC/VideoMacOSX video.c,1.16,1.17
Optical marker tracking and overlay for augmented reality.
Brought to you by:
philip_lamb
From: Philip L. <phi...@us...> - 2006-05-24 03:35:21
|
Update of /cvsroot/artoolkit/artoolkit/lib/SRC/VideoMacOSX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22308 Modified Files: video.c Log Message: Begin transition from QD to Quartz. Index: video.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/lib/SRC/VideoMacOSX/video.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** video.c 22 May 2006 22:18:25 -0000 1.16 --- video.c 24 May 2006 03:35:18 -0000 1.17 *************** *** 95,99 **** #define AR_VIDEO_DEBUG_BUFFERCOPY // Uncomment to have ar2VideoGetImage() return a copy of video pixel data. //#define AR_VIDEO_SUPPORT_OLD_QUICKTIME // Uncomment to allow use of non-thread safe QuickTime (pre-6.4). ! //#define AR_VIDEO_DEBUG_FIX_DUAL_PROCESSOR_RACE #define AR_VIDEO_IDLE_INTERVAL_MILLISECONDS_MIN 20L --- 95,99 ---- #define AR_VIDEO_DEBUG_BUFFERCOPY // Uncomment to have ar2VideoGetImage() return a copy of video pixel data. //#define AR_VIDEO_SUPPORT_OLD_QUICKTIME // Uncomment to allow use of non-thread safe QuickTime (pre-6.4). ! #define AR_VIDEO_DEBUG_FIX_DUAL_PROCESSOR_RACE #define AR_VIDEO_IDLE_INTERVAL_MILLISECONDS_MIN 20L *************** *** 993,1010 **** AR2VideoParamT *vid; int keepAlive = 1; struct timeval tv; // Seconds and microseconds since Jan 1, 1970. struct timespec ts; // Seconds and nanoseconds since Jan 1, 1970. - ComponentResult err; int err_i; int isUpdated = 0; - // Variables for fps counter. - //float fps = 0; - //float averagefps = 0; - char status[64]; - Str255 theString; - CGrafPtr theSavedPort; - GDHandle theSavedDevice; - #ifndef AR_VIDEO_SUPPORT_OLD_QUICKTIME --- 993,1005 ---- AR2VideoParamT *vid; int keepAlive = 1; + + #ifndef AR_VIDEO_DEBUG_FIX_DUAL_PROCESSOR_RACE struct timeval tv; // Seconds and microseconds since Jan 1, 1970. struct timespec ts; // Seconds and nanoseconds since Jan 1, 1970. int err_i; + #endif // !AR_VIDEO_DEBUG_FIX_DUAL_PROCESSOR_RACE + ComponentResult err; int isUpdated = 0; #ifndef AR_VIDEO_SUPPORT_OLD_QUICKTIME *************** *** 1032,1036 **** while (keepAlive && vdgIsGrabbing(vid->pVdg)) { ! #ifndef AR_VIDEO_DEBUG_FIX_DUAL_PROCESSOR_RACE gettimeofday(&tv, NULL); ts.tv_sec = tv.tv_sec; --- 1027,1031 ---- while (keepAlive && vdgIsGrabbing(vid->pVdg)) { ! #ifndef AR_VIDEO_DEBUG_FIX_DUAL_PROCESSOR_RACE gettimeofday(&tv, NULL); ts.tv_sec = tv.tv_sec; *************** *** 1084,1087 **** --- 1079,1088 ---- // Write status information onto the frame if so desired. if (vid->showFPS) { + + // Variables for fps counter. + //float fps = 0; + //float averagefps = 0; + char status[64]; + // Reset frame and time counters after a stop/start. /* *************** *** 1100,1103 **** --- 1101,1112 ---- } */ + //fps = (float)vid->timeScale / (float)(time - vid->lastTime); + //averagefps = (float)vid->frameCount * (float)vid->timeScale / (float)time; + //sprintf(status, "time: %ld, fps:%5.1f avg fps:%5.1f", time, fps, averagefps); + sprintf(status, "frame: %ld", vid->frameCount); + #if 0 + Str255 theString; + CGrafPtr theSavedPort; + GDHandle theSavedDevice; GetGWorld(&theSavedPort, &theSavedDevice); SetGWorld(vid->pGWorld, NULL); *************** *** 1105,1115 **** TextMode(srcCopy); MoveTo(vid->theRect.left + 10, vid->theRect.bottom - 14); - //fps = (float)vid->timeScale / (float)(time - vid->lastTime); - //averagefps = (float)vid->frameCount * (float)vid->timeScale / (float)time; - //sprintf(status, "time: %ld, fps:%5.1f avg fps:%5.1f", time, fps, averagefps); - sprintf(status, "frame: %ld", vid->frameCount); CopyCStringToPascal(status, theString); DrawString(theString); SetGWorld(theSavedPort, theSavedDevice); //vid->lastTime = time; } --- 1114,1130 ---- TextMode(srcCopy); MoveTo(vid->theRect.left + 10, vid->theRect.bottom - 14); CopyCStringToPascal(status, theString); DrawString(theString); SetGWorld(theSavedPort, theSavedDevice); + #else + CGContextRef ctx; + QDBeginCGContext(vid->pGWorld, &ctx); + CFStringRef str = CFStringCreateWithCString(NULL, status, kCFStringEncodingMacRoman); + CGContextSelectFont(ctx, "Monaco", 12, kCGEncodingMacRoman); + CGContextSetTextDrawingMode(ctx, kCGTextFillStroke); + CGContextShowTextAtPoint(ctx, 10, 10, status, strlen(status)); + CFRelease(str); + QDEndCGContext(vid->pGWorld, &ctx); + #endif //vid->lastTime = time; } *************** *** 1202,1206 **** a = config; if (a) { ! for(;;) { while (*a == ' ' || *a == '\t') a++; // Skip whitespace. if (*a == '\0') break; --- 1217,1222 ---- a = config; if (a) { ! err_i = 0; ! for (;;) { while (*a == ' ' || *a == '\t') a++; // Skip whitespace. if (*a == '\0') break; *************** *** 1208,1236 **** if (strncmp(a, "-width=", 7) == 0) { sscanf(a, "%s", line); ! if (sscanf( &line[7], "%d", &width) == 0 ) { ! ar2VideoDispOption(); ! return(NULL); ! } } else if (strncmp(a, "-height=", 8) == 0) { sscanf(a, "%s", line); ! if (sscanf(&line[8], "%d", &height) == 0) { ! ar2VideoDispOption(); ! return (NULL); ! } } else if (strncmp(a, "-grabber=", 9) == 0) { sscanf(a, "%s", line); ! if (sscanf(&line[9], "%d", &grabber) == 0) { ! ar2VideoDispOption(); ! return (NULL); ! } } else if (strncmp(a, "-pixelformat=", 13) == 0) { sscanf(a, "%s", line); ! if (sscanf(&line[13], "%c%c%c%c", (char *)&pixFormat, ((char *)&pixFormat) + 1, ! ((char *)&pixFormat) + 2, ((char *)&pixFormat) + 3) < 4) { // Try 4-cc first. ! if (sscanf(&line[13], "%li", (long *)&pixFormat) < 1) { // Fall back to integer. ! ar2VideoDispOption(); ! return (NULL); ! } ! } } else if (strncmp(a, "-fps", 4) == 0) { showFPS = 1; --- 1224,1241 ---- if (strncmp(a, "-width=", 7) == 0) { sscanf(a, "%s", line); ! if (strlen(line) <= 7 || sscanf(&line[7], "%d", &width) == 0) err_i = 1; } else if (strncmp(a, "-height=", 8) == 0) { sscanf(a, "%s", line); ! if (strlen(line) <= 8 || sscanf(&line[8], "%d", &height) == 0) err_i = 1; } else if (strncmp(a, "-grabber=", 9) == 0) { sscanf(a, "%s", line); ! if (strlen(line) <= 9 || sscanf(&line[9], "%d", &grabber) == 0) err_i = 1; } else if (strncmp(a, "-pixelformat=", 13) == 0) { sscanf(a, "%s", line); ! if (strlen(line) <= 13) err_i = 1; ! else { ! if (strlen(line) == 17) err_i = (sscanf(&line[13], "%4c", (char *)&pixFormat) < 1); ! else err_i = (sscanf(&line[13], "%li", (long *)&pixFormat) < 1); // Integer. ! } } else if (strncmp(a, "-fps", 4) == 0) { showFPS = 1; *************** *** 1238,1246 **** showDialog = 0; } else { ! ar2VideoDispOption(); ! return (NULL); } ! ! while (*a != ' ' && *a != '\t' && *a != '\0') a++; // Skip non-whitespace. } } --- 1243,1255 ---- showDialog = 0; } else { ! err_i = 1; } ! ! if (err_i) { ! ar2VideoDispOption(); ! return (NULL); ! } ! ! while (*a != ' ' && *a != '\t' && *a != '\0') a++; // Skip to next whitespace. } } *************** *** 1291,1295 **** // Once only, initialize for Carbon. ! if(initF == 0) { InitCursor(); initF = 1; --- 1300,1304 ---- // Once only, initialize for Carbon. ! if (initF == 0) { InitCursor(); initF = 1; *************** *** 1467,1470 **** --- 1476,1486 ---- // Erase to black. + #if 0 + QDBeginCGContext(vid->pGWorld, &ctx); + CGContextSetRGBFillColor(ctx, 1, 1, 1, 1); + CGContextFillRect(ctx, CGRectMake(0, 0, (vid->theRect).left - (vid->theRect).right, (vid->theRect).top - (vid->theRect).bottom)); + CGContextFlush(ctx); + QDEndCGContext (vid->pGWorld, &ctx); + #else GetGWorld(&theSavedPort, &theSavedDevice); SetGWorld(vid->pGWorld, NULL); *************** *** 1473,1476 **** --- 1489,1493 ---- EraseRect(&(vid->theRect)); SetGWorld(theSavedPort, theSavedDevice); + #endif // Set the decompression destination to the offscreen GWorld. |