mat

opencv single h264 raw frame as a binary string

倾然丶 夕夏残阳落幕 提交于 2020-01-03 17:17:09
问题 have created a rtsp client in python that receives a h264 stream and returns single h264 raw frames as a binary strings. I am trying to process each h264 frames on-the-fly. I have unsuccessfully tried several ways to convert this frame into a numpy array for processing. So far I know that cv2.VideoCapture only accepts a file name as it argument, not a frame neither a StringIO object (file like pointer to a buffer), but I need to pass to it my string. I have also tried something like: nparr =

C++ opencv Mat to QPixmap errors

匆匆过客 提交于 2020-01-03 02:28:08
问题 I am attempting to write a function which puts a greyscale OpenCv Mat into a Qt QPixmap, then into a QLabel. A third of the time it works. A third of the time, it skews the image... becomes The rest of the time, the program crashes, specifically on the fromImage() line. I know that the incoming Mat objects are greyscale and non-null in each case. Here is the code in question... void MainWindow::updateCanvasLabel(Mat mat){ imwrite("c:/pics/last-opened.jpg", mat); //to verify that Mat is //

creating Mat with openCV in python

怎甘沉沦 提交于 2019-12-31 07:38:28
问题 I am used to java 's implementation of OpenCV . I want to create a Mat structure, fill data into it, extract a submat and then apply some image transform. So in java , I use my_mat = new Mat(my_rows, my_cols, CvType.CV_8U); my_mat.put(0, 0, my_data); my_mat.submat(0, my_other_rows, 0, my_other_cols); But I didn't find anything working in python 's OpenCV . I found this link but it is broken 回答1: For OpenCV 1.x : You can use CreateMat to do that : Creates a matrix header and allocates the

Creating OpenCV Mat from user data results in image with circular shifted columns

此生再无相见时 提交于 2019-12-31 03:04:16
问题 I have an image that I load from a file. Is it a .png. I convert this to a 1D array for use in a function via a pointer to the array. When I create a Mat from the 1D pointer, the resulting image looks like it takes the right-most dozen or so columns, and puts them on the left side of the image, almost like a circular shift of columns. // SAMPLE CODE Mat img = imread(argv[1], CV_LOAD_IMAGE_ANYDEPTH); // 16U1 png int ncols = img.cols; int nrows = img.rows; //--Create input array and pointer--

Change type of Mat object from CV_32F to CV_8U

假装没事ソ 提交于 2019-12-28 08:08:31
问题 I tried to display an image of CV_32F type using imshow function but it showed a WHITE image . In the Documentation its given that floating point images will be mapped to 0-255 and displayed but it just showed a white image.I tried to convert it to CV_8U using Mat A=Mat::ones(300,300,CV_32FC1)*1000; do some processing - assigning float values to pixels in A ...... Mat B; A.convertTo(B,CV_8U) When I imshow 'B' i get a black & white image, there are no shades of gray . Are the float valued

Change type of Mat object from CV_32F to CV_8U

半世苍凉 提交于 2019-12-28 08:08:06
问题 I tried to display an image of CV_32F type using imshow function but it showed a WHITE image . In the Documentation its given that floating point images will be mapped to 0-255 and displayed but it just showed a white image.I tried to convert it to CV_8U using Mat A=Mat::ones(300,300,CV_32FC1)*1000; do some processing - assigning float values to pixels in A ...... Mat B; A.convertTo(B,CV_8U) When I imshow 'B' i get a black & white image, there are no shades of gray . Are the float valued

load image with openCV Mat c++

给你一囗甜甜゛ 提交于 2019-12-28 04:32:05
问题 I want to load an image using Mat in openCV My code is: Mat I = imread("C:/images/apple.jpg", 0); namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display. imshow( "Display window", I ); I am getting the following error in a message box: Unhandled exception at 0x70270149 in matching.exe: 0xC0000005: Access violation reading location 0xcccccccc. Please note that I am including: #include <cv.h> #include <cxcore.h> #include <highgui.h> #include <iostream> #include <math

Efficiently load a large Mat into memory in OpenCV

一曲冷凌霜 提交于 2019-12-27 10:17:12
问题 Is there a more efficient way to load a large Mat object into memory than the FileStorage method in OpenCV? I have a large Mat with 192 columns and 1 million rows I want to store locally in a file and load into memory then my application starts. There is no problem using the FileStorage, but I was wondering if there exists a more efficient method to do this. At the moment it takes about 5 minutes to load the Mat into memory using the Debug mode in Visual Studio and around 3 minutes in the

Print multidimensional Mat in OpenCV (C++)

a 夏天 提交于 2019-12-25 09:37:55
问题 In the OpenCV Tutorial http://docs.opencv.org/master/d6/d6d/tutorial_mat_the_basic_image_container.html is the following example for creating a Mat. int sz[3] = {2,2,2}; Mat L(3,sz, CV_8UC(1), Scalar::all(0)); This works fine, but when i try to print the Mat my programm crashes. cout << "L = " << endl << " " << L << endl << endl; Why doesn't this work ? Is there a way to do this without loops or splitting the Mat L ? 回答1: To print n-dim matrix you could use Matrix slice. Since 2d matrices are

Vector of cv::Mat are linked between them

半世苍凉 提交于 2019-12-25 05:22:00
问题 std::vector<cv::Mat1f> mat = std::vector<cv::Mat1f>(10,cv::Mat1f::zeros(1,10)); mat[0]+=1; for(size_t i=0;i<mat.size();i++) std::cout<<mat[i]<<std::endl; And it prints: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] How can I avoid