Ask Your Question

TakiEddine's profile - activity

2019-12-09 14:22:54 -0600 asked a question How to compile an opencv c++ code using linaro arm-gcc cross-compiler

How to compile an opencv c++ code using linaro arm-gcc cross-compiler I'm trying to cross-compile a simple OpenCV 4.1.2

2019-12-04 09:38:17 -0600 marked best answer How to copy frames read by videoCapture

I"m trying to use the OpenCV VideoCapture class to read images sequentially from a specific folder, as shown in the code below, which is extracted from https://www.kevinhughes.ca/tutorials/.... The reading works just fine and I can view the video streaming of the read images (imgSrc) correctly. The problem happens when I try to copy each frame into a new Mat object using nested for loops, the new image (imgDst) is different from the original one. I attached the results of the frame below. I did try using image.clone() and it worked perfectly, however, it is not an option for me, as I need to read the image on a pixel-by-pixel basis. Is there anything I am doing wrong so that I get this weird result? I'm reading 16 bit png images, but I assume that the VideoCapture is changing this in some way, could this really be the issue ?

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;

void help(char** argv)
{
cout << "\nThis program gets you started reading a sequence of images using cv::VideoCapture.\n"
     << "Image sequences are a common way to distribute video data sets for computer vision.\n"
     << "Usage: " << argv[0] << " <path to the first image in the sequence>\n"
     << "example: " << argv[0] << " right%%02d.jpg\n"
     << "q,Q,esc -- quit\n"
     << "\tThis is a starter sample, to get you up and going in a copy paste fashion\n"
     << endl;
}

int main(int argc, char** argv)
{
if(argc != 2)
{
  help(argv);
  return 1;
}

string arg = argv[1];
VideoCapture sequence(arg);
if (!sequence.isOpened())
{
  cerr << "Failed to open Image Sequence!\n" << endl;
  return 1;
}

Mat imgSrc; // source image
for(;;)
{
  sequence >> imgSrc;

if(imgSrc.empty())
  {
      cout << "End of Sequence" << endl;
      break;
  }
  Mat imgDst = cv::Mat::zeros(cv::Size(imgSrc.size().width,imgSrc.size().height),CV_16U);


  // Copying the elements of imgSrc to imgDst
  uint16_t* imgSrcPtr;
  uint16_t* imgDstPtr;
  for(int i = 0; i < imgSrc.rows; i++)
  {
      imgDstPtr = imgDst.ptr<uint16_t>(i);
      imgSrcPtr = imgSrc.ptr<uint16_t>(i);

       for(int j= 0; j < imgSrc.cols; j++)
       imgDstPtr[j] = imgSrcPtr[j];
  }

  namedWindow("Source image ",WINDOW_AUTOSIZE );

  namedWindow("Destination image ",WINDOW_AUTOSIZE );
  imshow("Destination image ", imgDst);
  waitKey(0;

return 0;
}

Source image Destination image

2019-12-03 05:00:21 -0600 received badge  Editor (source)
2019-12-03 05:00:21 -0600 edited question How to cross compile OpenCV for ARM-linux in windows ?

How to cross compile OpenCV for ARM-linux in windows ? How can I use Cmake GUI in 64-bits windows to Cross-compile OpenC

2019-12-03 04:56:52 -0600 asked a question How to cross compile OpenCV for ARM-linux in windows ?

How to cross compile OpenCV for ARM-linux in windows ? How can I use Cmake GUI in 64-bits windows to Cross-compile OpenC

2019-11-30 15:20:04 -0600 commented question How can I resolve conflicting declaration 'typedef uint32_t uint' ?

Ok, I installed OpenCV 4.12 I'm getting this new error error: 'Mutex' is not a member of 'cv' and a bench of other error

2019-11-29 14:13:07 -0600 asked a question How can I resolve conflicting declaration 'typedef uint32_t uint' ?

How can I resolve conflicting declaration 'typedef uint32_t uint' ? I'm using OpenCV 3.2.0 compiled for eclipse using Mi

2019-11-29 14:12:39 -0600 asked a question How can I resolve conflicting declaration 'typedef uint32_t uint' ?

How can I resolve conflicting declaration 'typedef uint32_t uint' ? I'm using OpenCV 3.2.0 compiled for eclipse using Mi

2019-11-04 21:28:52 -0600 received badge  Teacher (source)
2019-11-04 18:27:51 -0600 received badge  Self-Learner (source)
2019-11-04 09:28:05 -0600 answered a question How to copy frames read by videoCapture

Using imread function with the flag IMREAD_UNCHANGED in the same manner solved the problem, I can now read the images se

2019-11-04 03:13:34 -0600 received badge  Enthusiast
2019-11-02 13:14:31 -0600 commented question How to copy frames read by videoCapture

Alright, I'm not really familiar with strings in c++, so can you tell me how can I format the path to my images, in orde

2019-11-02 05:57:05 -0600 commented question How to copy frames read by videoCapture

The fact is that I'm using OpenCV only to facilitate the reading and writing operations, I'm really concerned with perfo

2019-10-31 05:12:07 -0600 commented question How to copy frames read by videoCapture

I converted the read frames from color to grayscale and this solved the problem. However, I would like to know whether I

2019-10-31 05:11:29 -0600 commented question How to copy frames read by videoCapture

I converted the read frames from color to grayscale and this solved the problem, however, I would like to know whether I

2019-10-31 04:26:47 -0600 commented question How to copy frames read by videoCapture

So, although my images are grayscale, the VideoCapture is reading them as if they were in color space, is there anyway t

2019-10-30 13:48:16 -0600 commented question How to copy frames read by videoCapture

the output of imgSrc.type() at runtime is 16

2019-10-30 13:25:39 -0600 asked a question How to copy frames read by videoCapture

How to copy frames read by videoCapture I"m trying to use the OpenCV VideoCapture class to read images sequentially from

2019-10-29 15:07:43 -0600 received badge  Supporter (source)
2019-10-29 15:07:40 -0600 marked best answer stereoBM and SGBM not working

I am trying to test the OpenCV classes stereoBM and StereoSGBM classes. when compiling the code below using

g++ main.cpp -o app pkg-config --cflags --libs opencv I get this error, fatal error: opencv2/contrib/contrib.hpp: No such file or directory

I am using Ubuntu 18.04 on an ARM platform (ODROID-XU4), and I have installed OpenCV version 3.2 using Synaptic Package Manager. The libraries are installed as indicated in the picture. However, I cannot locate contrib.hpp

image description

#include "opencv2/core/core.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "opencv2/contrib/contrib.hpp"  
#include <stdio.h>
#include <string.h>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
Mat g1, g2;
Mat disp, disp8;
char* method = argv[3];
g1 = imread(argv[1]);
g2 = imread(argv[2]);
//cvtColor(img1, g1, CV_BGR2GRAY);
//cvtColor(img2, g2, CV_BGR2GRAY);

if (!(strcmp(method, "BM")))
{
    StereoBM sbm;
    sbm.state->SADWindowSize = 9;
    sbm.state->numberOfDisparities = 112;
    sbm.state->preFilterSize = 5;
    sbm.state->preFilterCap = 61;
    sbm.state->minDisparity = -39;
    sbm.state->textureThreshold = 507;
    sbm.state->uniquenessRatio = 0;
    sbm.state->speckleWindowSize = 0;
    sbm.state->speckleRange = 8;
    sbm.state->disp12MaxDiff = 1;
    sbm(g1, g2, disp);
}
else if (!(strcmp(method, "SGBM")))
{
    StereoSGBM sbm;
    sbm.SADWindowSize = 3;
    sbm.numberOfDisparities = 144;
    sbm.preFilterCap = 63;
    sbm.minDisparity = -39;
    sbm.uniquenessRatio = 10;
    sbm.speckleWindowSize = 100;
    sbm.speckleRange = 32;
    sbm.disp12MaxDiff = 1;
    sbm.fullDP = false;
    sbm.P1 = 216;
    sbm.P2 = 864;
    sbm(g1, g2, disp);
}


normalize(disp, disp8, 0, 255, CV_MINMAX, CV_8U);

imshow("left", g1;
imshow("right", g2);
imshow("disp", disp8);

waitKey(0);

return(0);
}
2019-10-29 15:07:40 -0600 received badge  Scholar (source)
2019-10-29 04:46:58 -0600 commented answer stereoBM and SGBM not working

@break Thanks for the remark, the code in the link you listed compiled successfully, however, it's a little bit confusin

2019-10-29 04:46:18 -0600 commented answer stereoBM and SGBM not working

Thanks for the remark, the code in the link you listed compiled successfully, however, it's a little bit confusing and I

2019-10-28 14:34:15 -0600 asked a question stereoBM and SGBM not working

stereoBM and SGBM not working I am trying to test the OpenCV classes stereoBM and StereoSGBM classes. when compiling the