mat

how to read Mat v7.3 files in python ?

风格不统一 提交于 2019-12-07 05:43:56
问题 I am trying to read the mat file given in the following website, ufldl.stanford.edu/housenumbers, in the file train.tar.gz, there is a mat file named digitStruct.mat. when i used scipy.io to read the mat file, it alerts me with the message ' please use hdf reader for matlab v7.3 files '. the original matlab file is provided as below load digitStruct.mat for i = 1:length(digitStruct) im = imread([digitStruct(i).name]); for j = 1:length(digitStruct(i).bbox) [height, width] = size(im); aa = max

get histogram data from Mat , opencv android

隐身守侯 提交于 2019-12-06 15:51:22
问题 i am working on an android project using opencv , i am creating a histogram for a black and white image (1-0 values on image file) . i am following some tutorials i found on internet on how to create the histogram . i am doing something like this ArrayList<Mat> list = new ArrayList<Mat>(); list.add(mRgba); MatOfInt channels = new MatOfInt(0); Mat hist= new Mat(); MatOfInt histSize = new MatOfInt(25); MatOfFloat ranges = new MatOfFloat(0f, 1f); Imgproc.calcHist(list, channels, new Mat(), hist,

Convert between OpenCV Mat and Leptonica Pix

只愿长相守 提交于 2019-12-06 09:59:49
I need to convert between OpenCV Mat image and Leptonica Pix image formats in C++. This is being used for binarization of 8bit gray images. loot I found found @ikarliga's answer worked for me because what I needed was to actually convert to the Mat format not necessarily use it with the Tesseract API which is what that OP was asking. Here are both the functions I use. The pix8ToMat function is taken from the node-dv project Pix *mat8ToPix(cv::Mat *mat8) { Pix *pixd = pixCreate(mat8->size().width, mat8->size().height, 8); for(int y=0; y<mat8->rows; y++) { for(int x=0; x<mat8->cols; x++) {

Template Matching in Android using openCV

余生长醉 提交于 2019-12-06 06:04:48
问题 I'm trying to match an image with the camera input in Android using template matching. When i try this with static 2 images like in here: OpenCV Template Matching example in Android, everything works just fine. But when I try to use the captured images from the camera, I do not get the correct result. Following is the code that I have written: String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath(); Mat img = Highgui.imread(baseDir + "/mediaAppPhotos/img2.png"); Mat templ

cv::Mat matrix, HOW TO Reduce digits to the right of the decimal point in cv::Mat?

半腔热情 提交于 2019-12-06 01:41:49
问题 I have an app that prints a 3x3 cv::Mat on the iPhone screen. I need to reduce the decimals, as the screen is not so big, see: [1.004596557012473, -0.003116992336797859, 5.936915104939593; -0.007241746117066327, 0.9973985665720294, -0.2118670500989478; 1.477734234970711e-05, -1.03363734495053e-05, 1.000089074805124] so I would like to reduce the decimals .4 or .6 or six decimals. Any ideas? Cheers 回答1: If you were using printf cv::Mat data(3, 3, CV_64FC1); for (int y = 0; y < data.rows; ++y)

Get Mat object from Camera frame Android for OpenCV

放肆的年华 提交于 2019-12-05 07:57:13
问题 I am developing an android application based on Tutorial 2 given by OpenCV4Android. What I want to achieve is to get the Mat object of the camera frame when I touch the phone's screen ( onTouch() ). I want to modify the code such that I store the image as Mat instead of a jpeg file on the phone's memory. The Mat will then go under further processing. Do I need to involve the onCameraFrame() function? Any guidance will be much appreciated. I am very new to Android developing and OpenCV as well

get histogram data from Mat , opencv android

别说谁变了你拦得住时间么 提交于 2019-12-04 21:52:03
i am working on an android project using opencv , i am creating a histogram for a black and white image (1-0 values on image file) . i am following some tutorials i found on internet on how to create the histogram . i am doing something like this ArrayList<Mat> list = new ArrayList<Mat>(); list.add(mRgba); MatOfInt channels = new MatOfInt(0); Mat hist= new Mat(); MatOfInt histSize = new MatOfInt(25); MatOfFloat ranges = new MatOfFloat(0f, 1f); Imgproc.calcHist(list, channels, new Mat(), hist, histSize, ranges); Then i want to view the data on hist Mat, if i try something like this... for(int i

Add the contents of 2 Mats to another Mat opencv c++

て烟熏妆下的殇ゞ 提交于 2019-12-04 12:07:34
问题 I just want to add the contents of 2 different Mat s to 1 other Mat . I tried: Mat1.copyTo(newMat); Mat2.copyTo(newMat); But that just seemed to overwrite the previous contents of the Mat . This may be a simple question, but I'm lost. 回答1: It depends on what you want to add . For example, you have two 3x3 Mat: cv::Mat matA(3, 3, CV_8UC1, cv::Scalar(20)); cv::Mat matB(3, 3, CV_8UC1, cv::Scalar(80)); You can add matA and matB to a new 3x3 Mat with value 100 using matrix operation: auto matC =

Complex Matlab struct mat file read by python

折月煮酒 提交于 2019-12-04 11:40:08
I know the version issues of mat files which correspond to different loading modules in python, namely scipy.io and h5py . I also searched a lot of similar problems like scipy.io.loadmat nested structures (i.e. dictionaries) and How to preserve Matlab struct when accessing in python? . But they both fail when it comes to more complex mat files. My anno_bbox.mat file structure is shown as follows: The first two level: In the size: In the hoi: In the hoi bboxhuman: When I use spio.loadmat('anno_bbox.mat', struct_as_record=False, squeeze_me=True) , it could only get the first level information as

Template Matching in Android using openCV

血红的双手。 提交于 2019-12-04 10:20:51
I'm trying to match an image with the camera input in Android using template matching. When i try this with static 2 images like in here: OpenCV Template Matching example in Android , everything works just fine. But when I try to use the captured images from the camera, I do not get the correct result. Following is the code that I have written: String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath(); Mat img = Highgui.imread(baseDir + "/mediaAppPhotos/img2.png"); Mat templ = Highgui.imread(baseDir+ "/mediaAppPhotos/chars.png"); int result_cols = img.cols() - templ.cols() +