Obtaining images using mediawiki apis - wiki

Im trying to follow the tutorials from mediawiki
One of the examples they used is
http://en.wikipedia.org/w/api.php?action=query&titles=Albert%20Einstein&prop=images
So I am wondering how would i convert
File:1919 eclipse positive.jpg
into the actual link to the file?

Use the imageinfo property, as mentioned in the docs. E.g.:
http://en.wikipedia.org/w/api.php?action=query&titles=File:1919%20eclipse%20positive.jpg&prop=imageinfo&iilimit=50&iiend=20071231235959&iiprop=timestamp|user|url

Here is an example in Java:
Get the image link

Related

Is there a way to display .eps (vector) files in Ruby on Rails?

I'm new to RoR and can't seem find anything that simply explains what file types are supported. I'm assuming .eps is not because it simply won't work in my app (other file types do such as .png so I know it's not some other problem), so curious if there is a workaround to get .eps images to show in a RoR app?
Appreciate any help.
Did some digging. .svg files work in Rails and they are vector images. I used an online file converter like this one to convert .eps files.
http://image.online-convert.com/convert-to-svg
Googled around and found this old project:
https://github.com/Bluejade/PrawnVectorImport
No activity for a while. They might just be done?

'AddMatVector' is not a member of 'caffe::MemoryDataLayer'

I am using the Caffe framework for Ubuntu 14.04 and I want to use caffemodel to classify.
At first,I convert the face database into lmdb format and I have trained the caffemodel(lenet_iter_10000.caffemodel).
Next, I try to use my caffemodel to classify.
I read the codefrom google caffe users and rewrite some of the content , but I have some errors.
'AddMatVector' is not a member of 'caffe::MemoryDataLayer'
I asked in some forums, but I did not receive a reply.
Could anyone help me?
If my description is not clear enough, I will make it clearly. Thank you.
I don't see any AddMatVector in the documentation.
But I can see it in the source code in an #ifdef USE_OPENCV. HTH.

How to open and display a PDF file using Qt/C++?

I am trying to open and read a PDF file using Qt, but there is no specific way to do that.
I know the subject is a bit old, but...
I found a really simple way to render PDFs in Qt via QtWebKit using pdf.js (http://mozilla.github.com/pdf.js/).
Here is my realization of the idea for Qt5 and the WebEngine: https://github.com/Archie3d/qpdf
Qt itself does not include PDF reading/rendering functionality as far as I know. You might want to have a look at libpoppler which has Qt bindings.
I found this very interesting article on qt-project.org - "Handling PDF - Qt Project".
This page discusses various available options for working with PDF documents in a Qt application. The page does not exactly show how to "open and display an existing PDF document" but it can help you deduce something useful out of all that is explained there.
Here, the page says:
For rendering pages or elements from existing PDF documents to image
files or in-memory pixmaps (useful e.g. for thumbnail generation or
implementing custom viewers), third-party libraries can be used (for
example: poppler-qt4 (freedesktop.org) and muPDF (mupdf.com)).
Alternatively, the task can be delegated to existing command-line
tools (like poppler-utils (freedesktop.org) and muPDF (mupdf.com)).
You can use PdfViewer which is a lightweight PDF viewer that only uses Qt. It contains a PdfView widget which can be easily embedded in your application.
Simple answer : it is not supported in the Qt API.
Other answer : you can code it, I suggest you have a look at this Qt application which uses Ghostscript
The best way I have found to open a pdf is using QProcess in Qt.
You may want to use okular for pdf proccessing.
I know this is an old post, but I stumbled on it during my initial search so I figured I would post some documentation from the solutions I used.
As of Qt 5.10
Check out the QPdfDocument Class. This class can open a PDF and you can use the render function to render a page to an image. I use the QQuickPaintedItem to then "draw" this image but I am sure there are more ways to handle the QImage output.
Prior to Qt 5.10
I used libpoppler to do a VERY similar process.
#include <poppler/qt5/poppler-qt5.h>
Use the Poppler::Document Class to load and handle the entire PDF document and look at the Poppler::Page::renderToImage function to output the page as a QImage.
Qt does not support reading PDF files out of the box and among many approaches you can use Adobe's PDF Reader ActiveX object along with a QAxObject.
You may want to check out this link which describes how to read PDF files in Qt/C++ using ActiveX and has a downloadable example project.

Get a particular text from website

I'm looking for a way if you know the location where to read the text for example say, under a particular category, how would you connect to a website and search & read the text from it?
what steps do i need to follow to learn about that?
you could use libcurl/cURL for your HTML retrival
You're probably looking for a web crawler.
Here's an example of a simple crawler written in C++.
Moreover, you might want to have a look to wget, a software to retrieve files via HTTP, HTTPS and FTP.
if you are looking at a specific web-page, you could try retrieving the page and parsing it to get to the exact location you want. e.g. specific div, etc.
since you are using c++, you could try reading up on using libcurl to retrieve the information you need from the URL.
You can download an html file with WinHTTP(working example) and then search the file. There's some find algos in the std::string class for searching if your needs are relatively basic.

Connected Component Labeling in C++

I need to use the connected component labeling algorithm on an image in a C++ application. I can implement that myself, but I was trying to use Boost's union-find/disjoint sets implementation since it was mentioned in the union-find wiki article.
I can't figure out how to create the disjoint_sets object so that it'll work with the image data I have (unsigned shorts). What am I missing? The examples in the Boost documentation aren't making any sense to me. Do I need all the extra Graph mumbo-jumbo in those examples when I have an image? OR, is there already an OpenCV connected component labeling implementation. Currently we're using OpenCV 1.1pre1 and Boost 1.37.
Surprisingly, there is no CCL in OpenCV. However, there is a workaround that is described in the reference manual. See the example for cvDrawContours. When I tried to use it, I had some strange behaviour on first and last rows and columns of an image, but I probably did something wrong.
An alternative way is to use cvBlobs library.
We ended up writing the algorithms for CCL and Union-Find ourselves using the descriptions found on Wikipedia and elsewhere. It seemed easier and faster than adding another library to our application just for this purpose.
Another possibility is to use the source codes provided provided by Ali Rahimi, and you can have a look at this.
I was able to use disjoint_sets of the boost library for the connected component labeling.
But to test, I was trying to create an image with pixel intensities having the value same as its label.
This led to the problem which I haven't been able to handle yet. Have a look at the thread.