Ask Your Question

goldroses's profile - activity

2019-07-05 05:51:45 -0600 received badge  Popular Question (source)
2016-06-24 16:23:04 -0600 asked a question How to flip matrix in place?

I would like to reduce the 3 matrixes to just 2 matrixes by converting and flipping in one command, or flipping in place. Is there any way how to increase efficiency of the code?

cv::Mat dImg; // assume its initalized with TYPE_16UC1
cv::Mat dImg_grey;
cv::Mat dImg_grey_flip;
dImg.convertTo(dImg_grey, CV_8UC1, 255. / (2500 - 0), 0);//  to grayscale cv::Mat, (max - min)
cv::flip(dImg_grey, dImg_grey_flip, 1);// cannot flip in place

Is it somehow possible to stuff the flip into the convert.

2016-02-12 13:02:46 -0600 asked a question flip image throws invalid initialization

here is the code, which does not compile also its so basic.

     cv::Mat dImgnotmirr;
     cv::Mat dImg;
    cv::flip(&dImgnotmirr, &dImg, 1);


error: invalid initialization of reference of type ‘cv::InputArray {aka const cv::_InputArray&}’ from expression of type ‘cv::Mat*’ cv::flip(&dImgmirr, &dImg, 1); ^

2016-02-09 09:07:45 -0600 commented answer Calibrate depth images from Kinect with given examples.

Thank you good idea. Also this helped. Furthermore I could not calibrate because the ir light source of emitter is to weak. Would have to use additional halogen which too much . So i took parameters from here

2016-02-08 13:58:42 -0600 asked a question Calibrate depth images from Kinect with given examples.

I want to calibrate my kinect camera. The RGB-Images work fine with ./cpp-example-calibration but what do I do with the depth information. How do I calibrate these pictures or can i at all? Because the cv::mat is filled with depth information and not with RGB-Pixels. What sample to use with it? This is an example:
image description

2016-02-05 07:01:10 -0600 asked a question Assigning uchar pixel going wrong

I want to set a pixel which meets certain criteria to 4096 (2^12), but what I end up with is 14; Its an cv::Mat dImg in the format 16UC1

        for(int j=0;j<dImg.rows;j++) 
        uchar* pixrow = dImg.ptr<uchar>(j); 

        for (int i=0;i<dImg.cols;i++)
            if(j == 240 && pixrow[i] ==0)<uchar>(j,i) = 2^12;

also this results in cout=14:

                if(j == 240 && pixrow[i] ==0)  pixrow[i]  = 2^12; //= 4096

I check the value with

 cout<<"\nmodified: "<<endl;
for(int i = 0; i<dImg.cols;i++){
  cout<<" "<<unsigned(<uchar>(240,i));

SOLUTION (thank your for answering)

 for(int j=0;j<dImg.rows;j++) 
        ushort* pixrow = dImg.ptr<ushort>(j);  //not uchar

        for (int i=0;i<dImg.cols;i++)
            if(j == 239 && pixrow[i] ==0)  pixrow[i]  = 4096;
2016-02-05 06:49:45 -0600 answered a question using cout with Mat object

just to add: I print every 3 seconds one line of my cv::Mat encoded as 16UC1 as my video-feed has @30fps

    int count; cv::Mat dImg;
    if(count == 90){
        for(int i = 0; i<dImg.cols;i++){
            cout<<" "<<unsigned(<uchar>(240,i));
        count = 0; 
2016-02-05 06:37:57 -0600 received badge  Supporter (source)
2016-02-04 15:38:29 -0600 received badge  Student (source)
2016-02-04 12:09:06 -0600 received badge  Scholar (source)
2016-02-04 12:03:22 -0600 received badge  Editor (source)
2016-02-04 11:53:06 -0600 asked a question Obtaining Pixelvalue with various formats

I tried to get the value underneath an cv::Mat dImg in the format 16UC1 but only get rubbish when obtaining one pixel value. I expect an int ranging inbetween 0 and 2^16-1 (65535) but this is what i get:




EDIT: The image resolution is 640x480. I choose the position randomly, for others i get the same. (c++). EDIT2: Using ansers solution i get:


This looks fine yay :)