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

Greetings,
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?

Thanks!

Hello.

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->setHighWaterMark(2);
sender->bind(string("tcp://*:") + "anyport");

void testApp::send(ofImage img)
{
    ofBuffer imgbuf;
    ofSaveImage(img.getPixelsRef(), imgbuf);
    sender->send(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;        
        receiver.getNextMessage(data);
        ofLoadImage(px, data);
        img.setFromPixels(px);        
    }
}

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 . https://github.com/roymacdonald/ofxiOSFTP
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?

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

A

It works like a charm! thanks.

Still no luck running it on an iOS device.

For test purpose, I hard coded the ip
sender->bind(string(“tcp://192.168.0.103:9999”));
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: http://osdir.com/ml/zermq-development/2011-11/msg00095.html

need a lib built for arm7!