How to pass an image from an iOS app to a laptop app

I’m trying to upload an image from my ios app to my laptop app and can’t find an easy way to do this.
I did a quick search and found threads about streaming Kinect data, ofxHttpUtils, and poco. Is it possible to use udp or tcp to do this?



Probably the easiest way to do this is to use zmq.
(I have not tested it on iOS, but should work)

On sender side,

#include "ofxZmq.h"

ofPtr<ofxZmqPublisher> sender;

sender = ofPtr<ofxZmqPublisher>(new ofxZmqPublisher);
sender->bind(string("tcp://*:") + "anyport");

void testApp::send(ofImage img)
    ofBuffer imgbuf;
    ofSaveImage(img.getPixelsRef(), imgbuf);

On receiver side,

#include "ofxZmqSubscriber.h"

ofxZmqSubscriber receiver;
receiver.connect("tcp://" + "anyhost" + ":" + "anyport"));

void update()
    while (receiver.hasWaitingMessage())
        ofBuffer data;
        ofPixels px;
        ofImage img;        
        ofLoadImage(px, data);

Hope this help!

1 Like

I did this once for an instalation i did.
I used an ftp client I implemented, and have it as an addon .
althought the zmq option seems easier.

@Akira_At_Asia, thanks. I tried passing a png from one osx app to the other and got the following log:
[ error ] ofImage: loadImage(): couldn’t load image from ofBuffer, unable to guess image format from memory
[ error ] ofPixels: allocate(): unknown image type, not allocating
[ error ] ofPixels: setFromPixels(): image type 3 not supported, not copying
[warning] ofGLRenderer: drawing an unallocated texture

I then tried specifying format and quality on the sender side but no luck:
ofSaveImage(img.getPixelsRef(), imgbuf, OF_IMAGE_FORMAT_PNG, OF_IMAGE_QUALITY_MEDIUM);
any suggestion on how to work around this? maybe on the receiver side?

No luck with passing image from ios app to osx app yet. I had an error while the app launches:
libc++abi.dylib: terminate called throwing an exception

@roymacdonald, thanks, is there an ofxiOSFTP example?

Could you try these apps? They works on my local.


It works like a charm! thanks.

Still no luck running it on an iOS device.

For test purpose, I hard coded the ip
and kept getting this error:
libc++abi.dylib: terminate called throwing an exception at launch

However, it works in the simulator,
sender->bind(string(“tcp://*:”) + “9999”);

any thought? thanks.

Found out about this issue,

“Success in the iPhone Simulator! The simulator requires i386 static libraries
built to the iPhone simulator SDK. I now can use ZeroMQ functionality within an
iPhone app in the Simulator ONLY. It does not work however on a real iPhone.”

from here:

need a lib built for arm7!