Ask Your Question

Connect OpenCV with SQlite

asked 2015-10-19 01:10:20 -0500

Atul_iOS gravatar image

Hi, I want to connect OpenCV with sqlite in iOS. The scenario is , I have few images into which have to find the identical image matched scanned by the camera. for a single image its working fine, but for a group of Images when I used for loop inside it, is taking so much Time. I searched a lot and find that ,if i use a database of Images and give indexes using FLANN, the the search will become faster. The Problem is now , How I can connect OpenCV with Sqlite ? and How to store Images into Sqlite using OpenCV ,and then fetch from there for matching.

Please if anyone will help me , I am very thankful to him.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-10-20 02:26:37 -0500

pklab gravatar image

I don't understand your idea.

Anyway time required for matching doesn't depends from storage type but from algorithm used for. If you have to search an image A into a set of N images you have to performs N matches. After this, you can save matching results in a file or in a DB.

You could use threads to perform more than 1 match at time but I don't know how much you will gain considering enhanced parallelization built in OpenCV (it depends on your build cfg of ocv)

Yes you could save some key points (or features) in a DB or xml file for further query, but largest time would remains key points (or features) calculation.

FLANN performs a quick and efficient matching rotation and scale invariant.

If you are looking for identical images, may be simple image difference or Histogram Comparison could be enough.

Finally if you want to use SQLite with OpenCV please follow some "SQLite C/C++ Tutorial" on the net.

I don't like to store images into a DB but in case you need to store a cv::Mat into a SQLite field then define your field as binary and use imdecode/imencode to read/encode an image from/to a memory buffer.

edit flag offensive delete link more


Hi, As per you said , yes definitely its a foolish idea to store in SQLite. Now I am storing in file type of XML/YML.

As you said for perform match parallel, I tried and went through tutorials also but not got enough knowledge.. Currently I am storing the Image keypoints and descriptors in a file to perform match. Can you provide me something regarding the parallel matching technique.

I am doing this all in iOS.

Atul_iOS gravatar imageAtul_iOS ( 2015-10-28 00:50:45 -0500 )edit

For sure, if you build OpenCV with some library for parallel processing you will have a valuable improvement. I think that for iOS, the Grand Central Dispatch library is the library. Intel TBB , OpenMP, etc. are other options but at the time I'm not sure they have full support for iOS.

On the application side (your code) you could start a thread for each image. But I can't help you on how to do this on iOS. Start from here: iOS Threading Programming Guide

pklab gravatar imagepklab ( 2015-10-28 03:29:55 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-10-19 01:10:20 -0500

Seen: 679 times

Last updated: Oct 20 '15