flickrScraperSlideShow

flickrScraperSlideShow is an application I created with oF “00573-Xcode-Fat-YCAM-WithGui”. It queries Flickr for a keyword and then displays the resulting (up to 100) images in a slideshow format.

It uses a blocking call for getting the results from Flickr using their REST API:

http://www.flickr.com/services/api/request.rest.html

It then uses a thread to download images from Flickr.com, while allowing the slideshow to continue.

Any comments welcome.

System design and assembly by Joel Gethin Lewis
http://www.joelgethinlewis.com
XML query and manipulation of Flickr API by Brian Balantine, Jesús Gollonet Bailén
http://forum.openframeworks.cc/t/problem-with-ofmemoryimage-and-threaded-web-scraper/1081/12">Problem with ofMemoryImage and threaded web scraper]http://forum.openframeworks.cc/t/problem-with-ofmemoryimage-and-threaded-web-scraper/1081/12

Hey i thought i would try this out as I do lots of stuff with Flickr. It compiled just fine (in Xcode), but the application fails to launch. has anyone else gotten it to run correctly?

update: since xcode didnt work out for me, I tried running this in windows/codeblocks. Again i got it to compile, but it crashes soon after startup on this line:

  
cout << "The URL I have started to load is " << webImages[vecIndex].theUrl << endl;  

OK I tried and got this working in Linux using Codeblocks.

Firstly you need to get a flickr api key. This is mentioned in testApp.h
This is the api and the page also includes a link to get a key:
http://www.flickr.com/services/api/flic-…-earch.html

Then I ran into a problem to do with a bug in ofImage where the copy constructor was borking due to an uninitialised variable (this is often compiler specific). See this post for the details.

Also being on a little endian computer this code in ofMemoryImage.cpp is no longer necessary in 0.06
#ifdef TARGET_LITTLE_ENDIAN
if (byteCount != 1) swapRgb(pix);
#endif
as this is already being called in ofImage::resize()

Also I was getting sporadic crashes passing the resultsPageAsString() function to the getFlickrImageUrls() function, so I did this instead:

std::ostringstream oss;
oss << flickrResultsPage;
std::vectorstd::string img_urls = getFlickrImageUrls(REST_URL, API_KEY, oss.str(), SEARCH_KEYWORD);

Ok I’m totally stumped.

I’ve been trying for a while now to get this example to work. I have a flickr api key, and even managed once to get the example compiled and working.

However 99% of the time I open the Xcode project (openFrameworks.xcodeproj), Xcode freezes up after a couple of seconds - before I even try to compile anything at all!

This seems like pretty weird behavior to me. I have tried starting with blank projects and inserting sections of code to see what might cause the crash - I have some suspicions about HTTPStreamFactory.h, as when I include only this in an otherwise blank testApp it also freezes/crashes Xcode. I really don’t understand how this is possible, but, well it’s quite consistent and I have no idea why.

I am using a MacBook Pro 2.4Ghz, OS X 10.5.5 and Xcode 3.1 and have been using other Poco code successfully, based on 00573-Xcode-Fat-YCAM-WithGui.

Any ideas would be really great…

Do you want to post code of where you are?

JGL

If I put:

  
#include "Poco/Net/HTTPStreamFactory.h"  

into a completely blank testApp, the application will compile fine and run. But as soon as I quite that application, Xcode freezes. From then on, every time I open the Xcode project, Xcode will freeze 5-10 seconds later.

This is much the same behavior as when I try to compile the flickrScraper.

It’s really very odd.

M

Hi,
looks like there’s some conflict going on with the Poco libs…very strange though.
Could you perhaps try with this latest version and see if you still have problems?
http://www.openframeworks.cc/files/006/-…-de-FAT.zip

Hi M,

It’s important to register your factory once and once only somewhere in your code.

For example:

Poco::Net::HTTPStreamFactory::registerFactory();

Have you got that somewhere?

JGL

So after about a thousand crashes I have a repeatable method for safely compiling this example. I still have no idea why it works (or why it wasn’t working to begin with), but it appears to be something to do with poco includes and the Header Search Paths.

To recap: any attempt to open the flickrScraper Xcode project leads to my Xcode freezing. This is before compiling, or making any changes to code.

In addition, if I open a blank testApp project and simply add to testApp.h:

  
#include "Poco/Net/HTTPStreamFactory.h"  

Xcode will freeze as soon as I save the file(!!!) *before* even attempting to compile.

This occurs in both 00573-Xcode-Fat-YCAM-WithGui and of_preRelease_v0.06_xcode_FAT.

The solution (for me):

  1. Make a new blank oF project by making a copy of ‘allAddonsExample’ or ‘emptyExample’ (0.006) or ‘allTestExample’ or ‘_emptyExample’ (0.0573)
  2. Open the new Xcode project
  3. Go to ‘Edit Project Settings’ in the ‘Project’ drop down menu
  4. Delete ‘…/…/…/libs/poco/include’ from the ‘Header Search Paths’
  5. Close the project or quit Xcode
  6. Copy the ‘src’ files from flickrScraperSlideShow to the ‘src’ folder of the new project (ie., main.cpp, ofMemoryImage.cpp, ofMemoryImage.h, SimpleWebScraper.cpp, SimpleWebScraper.h, testApp.cpp, testApp.h)
  7. Open the new project again, and add ofMemoryImage.cpp/.h and SimpleWebScraper.cpp/.h to the project by dragging the files from the Finder into the src folder of the project.
  8. Click ‘Build & Go’ - this will result in just under 2000 errors as Xcode tries to compile and fails to find the poco includes (I’ve tried omitting this step, and Xcode will freeze on the next step unless I’ve done this unsuccessful build!)
  9. Go to ‘Edit Project Settings’ in the ‘Project’ drop down menu and re-add ‘…/…/…/libs/poco/include’ to the ‘Header Search Paths’
  10. Re-compile. Xcode is happy now, and the project appears to be stable.

The same method (ie., deleting the Header Search Paths, attempting to compile, re-adding the Header Search Paths, re-compiling) also fixes Xcode freezing when I simply #include “Poco/Net/HTTPStreamFactory.h”.

Also, if I make a copy of a ‘fixed’ poco project it will exhibit the same Xcode-freeze behaviour as soon as I open it…makes me think that there is something about HTTPStreamFactory and the registerFactory() stuff that causes this, but it’s beyond my knowledge to work out what is really going on…

Another mystery, wrapped in an enigma :slight_smile:

what version of xcode do you have ? that’s a curious bug. thanks for the write up on the solution.

I get no crash, with 3.1.2, adding that line to a testApp.h and saving / compiling.

take care!
zach

Hey Zach

I’m using Xcode 3.1

Will try updating to the latest version and see if that helps.

Congrats on the new release - looking forward to trying it out!