Ask Your Question
0

storing images in database for template matching?

asked 2014-01-06 20:16:42 -0600

habisravi gravatar image

What is the best way to store image in database for template matching? I considering to store image Mat in database.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2014-01-08 13:25:02 -0600

xaffeine gravatar image

If you can get good enough performance storing them as png or jpg in directories, that is the thing to do. If that isn't fast enough, you may need a real database or a custom file format. No xml or yml approach will be as good as either of those options.

edit flag offensive delete link more
1

answered 2014-01-07 00:34:25 -0600

Haris gravatar image

You may need to use OpenCV XML/YAML file storages to store Mat in to file and later read back.

Writing Mat to file

Mat src = imread( "img.jpg",1);
FileStorage Data_W("Data.yml",FileStorage::WRITE); // Store the  data in a file
Data_W << "data" << src;
Data_W.release();

Reading back from file

Mat dst;
FileStorage Data_R("Data.yml",FileStorage::READ); // Read traing data to a Mat
Data_R["data"] >> dst;
Data_R.release();
imshow("dst",dst);
waitKey();
edit flag offensive delete link more

Comments

What is the best approach for processing large no of images? Storing them as Mat in database / Storing them in a folder, And retrieving them for processing.

habisravi gravatar imagehabisravi ( 2014-01-07 07:44:20 -0600 )edit
1

@habisravi If you have large set of image and you need to save the space then better to store the images to a folder by compressing it, like jpg. The above method store the pixel value directly to file and no compression uses, and I observed that for large resolution image the file size will be huge, like for the jpg compressed image with resolution 835X668 of size 266 KB the above code created file size of 8.7 MB.

Haris gravatar imageHaris ( 2014-01-08 00:13:03 -0600 )edit

How can I store my images to database and then use for image recognition.

praveeng06 gravatar imagepraveeng06 ( 2015-02-18 01:21:37 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-01-06 20:16:42 -0600

Seen: 1,756 times

Last updated: Jan 08 '14