Will OpenCV 3.2+ FileStorage save the SimpleBlobDetector_create object in XML or YML?
I was making the problem much harder than necessary. The solution is simple:
# Setup SimpleBlobDetector parameters.
params = cv.SimpleBlobDetector_Params()
# Change desired parameters
params.minThreshold = 20
params.maxThreshold = 220
# Create the blob detector
detect = cv.SimpleBlobDetector_create(params)
# Write detector parameters to .yml file
fs_write = cv.FileStorage('blob_params_modified.yml',
cv.FILE_STORAGE_WRITE)
detect.write(fs_write)
fs_write.release()
You can read this file in as input instead of fiddling with the code every time you want to tweak a parameter.
Reading image file (file storage object) using OpenCV
I had similar issues while using opencv with flask server, for that first i saved the image to disk and read that image using saved filepath again using cv.imread()
Here is a sample code:
data =request.files['file']
filename = secure_filename(file.filename) # save file
filepath = os.path.join(app.config['imgdir'], filename);
file.save(filepath)
cv.imread(filepath)
But now i have got even more efficient approach from here by using cv.imdecode() to read image from numpy array as below:
#read image file string data
filestr = request.files['file'].read()
#convert string data to numpy array
file_bytes = numpy.fromstring(filestr, numpy.uint8)
# convert numpy array to image
img = cv.imdecode(file_bytes, cv.IMREAD_UNCHANGED)
Related Topics
C++11 Compiler: Closest to the Standard and How Close
Use #Ifdefs and #Define to Optionally Turn a Function Call into a Comment
How to Execute a Command and Get Return Code Stdout and Stderr of Command in C++
Visualising 4D Objects in Opengl
Ensuring C++ Doubles Are 64 Bits
This Declaration Has No Storage Class or Type Specifier in C++
Should We Still Be Optimizing "In the Small"
Performance Degradation Due to Default Initialisation of Elements in Standard Containers
Std Linker Error with Apple Llvm 4.1
Qthread Emits Finished() Signal But Isrunning() Returns True and Isfinished() Returns False
What Is Copy/Move Constructor Choosing Rule in C++? When Does Move-To-Copy Fallback Happen
Std::Make_Tuple Doesn't Make References
Warning C4003 and Errors C2589 and C2059 On: X = Std::Numeric_Limits<Int>::Max();
Why Does Visual Studio Not Perform Return Value Optimization (Rvo) in This Case
Race-Condition in Pthread_Once()
Getting a Buffer into a Stringstream in Hex Representation: