Ask Your Question
2

Need to load image from database c++

asked 2014-01-17 06:13:43 -0600

Shan gravatar image

I am newbie for Opencv. I need write a C++ program to load the tiff image stored in the database. So I read the image as char buffer and not sure how to create Mat object from the char buffer

edit retag flag offensive close merge delete

Comments

2

have a look at imdecode

berak gravatar imageberak ( 2014-01-17 06:26:54 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-01-17 12:20:43 -0600

Assuming you retrieve an unsigned char* as your image data from the database, first you have to create the Mat structure that will hold this data:

cv::Mat image(rows, cols, type); //create Mat strucutre
image.data = (unsigned char*) charsFromDataBase; //add the data

cv::imshow("Image", image); //show the image
cv::waitKey(0); //wait until key is pressed

rows and cols are the dimensions of your image. Type is CV_8UC, which means 8bit unsigned char, which is what you have in your data base.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-01-17 06:13:43 -0600

Seen: 590 times

Last updated: Jan 17 '14