static void oneOff(skiatest::Reporter* reporter, const SkDConic& c1, const SkDConic& c2,
        bool coin) {
#if DEBUG_VISUALIZE_CONICS
    writeFrames();
#endif
    chopBothWays(c1, 0.5, "c1");
    chopBothWays(c2, 0.5, "c2");
#if DEBUG_VISUALIZE_CONICS
    writeDPng(c1, "d1");
    writeDPng(c2, "d2");
#endif
    SkASSERT(ValidConic(c1));
    SkASSERT(ValidConic(c2));
    SkIntersections intersections;
    intersections.intersect(c1, c2);
    if (coin && intersections.used() != 2) {
        SkDebugf("");
    }
    REPORTER_ASSERT(reporter, !coin || intersections.used() == 2);
    double tt1, tt2;
    SkDPoint xy1, xy2;
    for (int pt3 = 0; pt3 < intersections.used(); ++pt3) {
        tt1 = intersections[0][pt3];
        xy1 = c1.ptAtT(tt1);
        tt2 = intersections[1][pt3];
        xy2 = c2.ptAtT(tt2);
        const SkDPoint& iPt = intersections.pt(pt3);
        REPORTER_ASSERT(reporter, xy1.approximatelyEqual(iPt));
        REPORTER_ASSERT(reporter, xy2.approximatelyEqual(iPt));
        REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
    }
    reporter->bumpTestCount();
}
Пример #2
0
int main(int argc,char* argv[])
	{
	/* Open the requested 3D video stream: */
	std::string colorFileName=argv[1];
	colorFileName.append(".color");
	std::string depthFileName=argv[1];
	depthFileName.append(".depth");
	Kinect::FileFrameSource frameSource(colorFileName.c_str(),depthFileName.c_str());
	
	/* Get the 3D video stream's intrinsic parameters: */
	Kinect::FrameSource::IntrinsicParameters ip=frameSource.getIntrinsicParameters();
	
	/* Create a 3D video projector: */
	Kinect::Projector projector(frameSource);
	projector.setFilterDepthFrames(false,true);
	
	/* Read pairs of frames from the source and export them to a sequence of Lightwave Object files: */
	unsigned int minIndex=argc>3?atoi(argv[3]):0;
	unsigned int maxIndex=argc>4?atoi(argv[4]):Math::Constants<unsigned int>::max;
	unsigned int frameIndex=0;
	std::cout<<"Processing frame      0"<<std::flush;
	while(true)
		{
		std::cout<<"\b\b\b\b\b\b"<<std::setw(6)<<frameIndex<<std::flush;
		/* Read the next pair of frames: */
		Kinect::FrameBuffer color=frameSource.readNextColorFrame();
		Kinect::FrameBuffer depth=frameSource.readNextDepthFrame();
		
		/* Bail out if either frame is invalid: */
		if(color.timeStamp==Math::Constants<double>::max||depth.timeStamp==Math::Constants<double>::max)
			break;
		
		if(frameIndex>=minIndex&&frameIndex<maxIndex)
			{
			/* Convert the depth frame to a mesh: */
			Kinect::MeshBuffer mesh;
			projector.processDepthFrame(depth,mesh);
			
			/* Export the frame pair to an LWO file: */
			char lwoFileName[1024];
			snprintf(lwoFileName,sizeof(lwoFileName),argv[2],frameIndex);
			writeFrames(ip,color,mesh,lwoFileName);
			}
		
		++frameIndex;
		}
	std::cout<<std::endl;
	
	return 0;
	}
Пример #3
0
int main(int argc, char **argv)
{
    CFBundleRef myBundle;
    UInt32 numDevs, i;
    UInt32 standard;
    Boolean isEnabled;
    OSErr err;
    DVDeviceID device;
    DVNotificationID notifyID;
    char name[256];
    int file;
    int pos = 1;
    int destruct = 0;
    
    while(argc > pos) {
        if(strcmp(argv[pos], "-w") == 0)
            sWrite = 1;
        else if(strcmp(argv[pos], "-r") == 0)
            sWrite = 0;
        else if(strcmp(argv[pos], "-d") == 0)
            destruct = 1;
        else if(strcmp(argv[pos], "-l") == 0)
            sLoop = 1;
        else if(strcmp(argv[pos], "-sdl") == 0)
            sSDL = 1;
        else if(strcmp(argv[pos], "-DVCPro") == 0)
            sDVCPro = 1;
        else if(strcmp(argv[pos], "-n") == 0)
            sNotifyTest = 1;
        else if(strcmp(argv[pos], "-h") == 0) {
            printf("%s [-w/-r] [-l(oop)] [-d(estructoTest)] [-sdl/-DVCPro] [-n(otify test] [filename]\n", argv[0]);
            exit(0);
        }
        else
            sFile = argv[pos];
        pos++;
    }
    myBundle = findMe();
    printf("sLoop = %d\n", sLoop);
    numDevs = sDVFuncs.fDVCountDevices();
    printf("Number of devices: %ld\n", numDevs);
    if(numDevs == 0) {
        err = sDVFuncs.fDVNewNotification( kEveryDVDeviceRefNum, myNotifyProc,
						0x1234, &notifyID );
        if(err)
            printf("Error %d calling DVNewNotification(, %ld)\n", err, kEveryDVDeviceRefNum);
        err = sDVFuncs.fDVNotifyMeWhen( kEveryDVDeviceRefNum, notifyID,
            kDVDeviceAdded | kDVDeviceRemoved);
        if(err)
            printf("Error %d calling NotifyMeWhen(%ld, %ld)\n", err, kEveryDVDeviceRefNum, notifyID);

        while (numDevs == 0 || sNotifyTest) {
            printf("Waiting for devices: %ld\n", numDevs);
            usleep(1000000);	// 1000 milliseconds
            numDevs = sDVFuncs.fDVCountDevices();
        }
    }
    for(i=1; i<=numDevs; i++) {
        DVDeviceRefNum refNum;
        err = sDVFuncs.fDVGetIndDevice(&device, i);
        if(err)
            printf("Error %d calling DVGetIndDevice(, %ld)\n", err, i);
        err = sDVFuncs.fDVGetDeviceName(device, name);
        if(err)
            printf("Error %d calling DVGetDeviceName(%ld)\n", err, device);
        else
            printf("Device %ld name is %s\n", device, name);
            
        err = sDVFuncs.fDVOpenDriver( device, &refNum );
        if(err) {
            if(err == (OSErr)kIOReturnExclusiveAccess) {
                do {
                    sleep(1);
                	err = sDVFuncs.fDVOpenDriver( device, &refNum );
                }
                while (err == (OSErr)kIOReturnExclusiveAccess);
            }
            printf("Error %d calling DVOpenDriver(%ld)\n", err, device);
        }
        err = sDVFuncs.fDVGetDeviceStandard(refNum, &standard);
        if(err)
            printf("Error %d calling DVGetDeviceStandard(%ld)\n", err, device);
        else if(standard == kNTSCStandard)
            printf("Device %ld video standard is NTSC\n", device);
        else if(standard == kPALStandard)
            printf("Device %ld video standard is PAL\n", device);
        else
            printf("Device %ld, unknown video standard %ld\n", device, standard);

        err = sDVFuncs.fDVIsEnabled(refNum, &isEnabled);
        if(err)
            printf("Error %d calling DVIsEnabled(%ld)\n", err, device);
        else
            printf("Device %ld isEnabled: %d\n", device, isEnabled);
        
        if(sWrite) {
            if(sSDL) {
                err = sDVFuncs.fDVSetWriteSignalMode(refNum, kAVCSignalModeSDL525_60);
            }
            file = open(sFile, O_RDONLY, 0666);
            printf("opened file, %d\n", file);
            if(destruct)
                destructoWrite(device, refNum, file);
            else
                writeFrames(refNum, file);
        }
        else {
            file = open(sFile, O_CREAT | O_WRONLY | O_TRUNC, 0666);
    // Start camera playing
            
            err = doControlTest(refNum, kAVCPlayOpcode, kAVCPlayForward);
            
            if(destruct)
                destructoRead(refNum);
            else
                readFrames(refNum, file, 300);
        
            //sleep(10);
            err = doControlTest(refNum, kAVCWindOpcode, kAVCWindStop);
            
            err = sDVFuncs.fDVCloseDriver( refNum );
            if(err)
                printf("Error %d calling DVCloseDriver(%ld)\n", err, device);
            while(sLoop) {
                readFrames(refNum, 0, 300);
            }
        }
        err = sDVFuncs.fDVCloseDriver(refNum );

    }
    
    sleep(10);
    // Unload the bundle's executable code.
    // Don't, because there's no way to stop it!
    //CFBundleUnloadExecutable( myBundle );
    //CFRelease( myBundle );
    return 0;
}