Video Capture 2

    imageIt’s easy to live in the 21st century. It’s even easier to get a video picture from any of the iPhone cameras inside your application.
    How to do this and how I did it, was told in an article about a fruit-cutter.

    Imagination did not stop there.
    The resulting photos can be used in the three-dimensional world.
    An example of a three-dimensional object with a flat picture on its side you see to the left of the text.
    If you don’t see the logo on the image of the vase, turn on the image viewing mode in your browser.

    Below I will give an example of turning a flat image into a GL texture and tell how I secretly spied on the iOS Review Team .

    I remind you that iOS Review Team Are the people who test our apps for approval on the appStore.



    A bit of code


    To convert a bitmap image to a GL texture, one function is enough.

    Function
    uploadTexture
    - (GLuint) uploadTexture:(UIImage*) image
    {
        GLuint width = 256;
        GLuint height = 256;
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
        void *imageData = malloc( height * width * 4 );
        CGContextRef ctx = CGBitmapContextCreate( imageData, width, height, 8, 4 * width, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big );
        CGColorSpaceRelease( colorSpace );
        CGContextClearRect( ctx, CGRectMake( 0, 0, width, height ) );
        CGContextTranslateCTM( ctx, 0, height - height );
        CGContextDrawImage( ctx, CGRectMake( 0, 0, width, height ), image.CGImage );
        GLuint texName;
        glGenTextures(1, &texName);
        glBindTexture(GL_TEXTURE_2D, texName);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);
        CGContextRelease(ctx);
        free(imageData);
    ///////////////////////////////////////////////////////////////    
    //  а вот теперь наша текстура в нашем же openGL мире    
        glBindTexture(GL_TEXTURE_2D, texName);
    ///////////////////////////////////////////////////////////////    
        return texName;
    }
    

    An attentive reader will notice that I turn the picture upside down, which of course is optional.
    Image orientation can be done at the level of OpenGL functions, which is even simpler.

    Potter's wheel


    I immediately used the resulting code in my ancient application Potter’s Wheel. Why is it in it?
    The application brought me 5 bucks a day for 2 years, when suddenly (about a month ago) the flow of money stopped.
    The application was primitive - you twist a potter's wheel. It is spinning, spinning.
    And you drag your finger across the screen and deform the cylinder into a vase, glass or amphora in accordance with your artistic talent.
    You can pull a picture on a vase and even paint it.

    To understand what kind of trouble happened with the program, I had to look at the application page, and oh! I was horrified.
    Rating is zero! And the only review hangs: -DON'T BUY THIS APP! It is not a pottery wheel nifiga! Spend your money in vain!

    Well, I think, competitors, Jews or the mafia. Mario Kyuda la Finestra!

    And you can’t answer. Whether it’s the case on Google Play, deal with users at least until midnight.
    That's why I do not go to the pages of my applications in the appStore and do not read reviews - the nerves to hell, and health is more expensive.

    The only way to remove negative feedback is to release a new version .
    If not, correct me.

    New version with video capture



    Done, said, released an update by screwing the function described above, that is, he began to pull the user's photo on the fly, sculpt it on a vase online and hide it at the same time on his server.
    I posted the application for verification. And for 20 long nights he watched the directory where the photos of the inspectors were supposed to appear. Insolents! As the catch felt, for three weeks neither hearing nor spirit.

    And yesterday, bang! Done, I got a man, pretty pretty, young, about 30 years old, staring at my application and his iPhone.
    And today, clops-2, the application is approved in appstore!

    For ethical reasons, a photo of a man (and Brazilian women from Una Frutta from a previous article) will not show anyone.
    Jokes are jokes, and no one is stopping you from doing the same trick in your programs.
    The resulting photos can be used in the halls of fame, rating tables and lists of winners of daily championships.
    I personally consider doing this in Chapai. The audience of the game has settled for six months, the same 100-200 people play and everyone (that is, me) is extremely curious about how the permanent professional champions Slavyan74 or DimonSergeich or FabioHaddad from Brazil look ... Maybe there are hawkers among them.

    Of course, do not forget to warn players about this feature of the application.
    And analyze the pictures. Players, after all, do not just put faces there.

    Also popular now: