Ask Your Question

deathracer99's profile - activity

2017-08-05 05:14:59 -0600 received badge  Editor (source)
2017-08-05 05:09:53 -0600 asked a question temporally synch videos from multiple cameras

I have videos coming from 3 raspberry pi cameras with following timestamps (each video is recorded for 4 hours):

camera1, camera2, camera3
0.000000,0.000000,0.000000
33.315000,33.315000,33.315000
66.631000,66.632000,66.637000 
...................................
...................................
9486161.970000,9486187.786000,9486187.786000
9486195.285000,9486221.102000,9486221.102000 
9486228.601000,9486254.418000,9486254.418000

Now the problem is that each camera clock has its own slewing rate and at the end, frame difference across cameras goes up to 25ms in case of camera 1 wrt others (while each of them started at sub millisecond difference). This makes tracking position according to each of them really tough task cause of misalignment of frames across cameras.

The answer mentioned here https://stackoverflow.com/questions/3... might have been useful but it changes the sampling rate for the final position estimate generated across cameras.

My aim is to get position estimate according to each frame across cameras. How can the videos be synched so that it is possible?

2017-03-16 12:49:05 -0600 received badge  Enthusiast
2017-03-13 05:49:30 -0600 received badge  Student (source)
2017-03-13 01:56:07 -0600 asked a question python alternative to K and R (camera parameters used in C++) while warping?

I was working on opencv stitching_detailed.cpp file where I came across cameraParams ( which basically stores different camera parameters). In the script, once these parameters are estimated, they are used to warp the input images for which the function call looks like this:

warper->warp(img, K, cameras[img_idx].R, INTER_LINEAR, BORDER_REFLECT, img_warped);

where img: input image K : intrinsic parameters R : Rotation matrix

Now I store these parameters (K,R) in a file and later want to use them to make some calls in python. Python opencv provides function called cv2.warpPerspective which takes a transformation matrix , M as input.

From my understanding of the code, M is basically same as K mentioned above but there is no input for R in python. So my question how do I perform warp as done in stitching c++ code in python if I know the parameters involved?

2017-03-07 04:58:06 -0600 commented question load camera parameters from yml file cpp

@LBerger I accept that fact totally, but I am short on time that is why this approach. Although side by side I am trying to learn C++. Thanks for the help

2017-03-07 03:25:26 -0600 commented question How to write python wrapper for OpenCV C++ code

has anyone resolved it?

2017-03-06 23:16:39 -0600 commented question load camera parameters from yml file cpp

Then how can I initialize it ?

2017-03-06 00:40:01 -0600 commented question load camera parameters from yml file cpp

sorry ppy thing was a typo. Yes I have initialized the array as vector<cameraparams> camerasTest(num_images) //where num_images=8

2017-03-05 06:49:51 -0600 asked a question load camera parameters from yml file cpp

I saved the CameraParams which is defined in Opencv Stitching Detailed sample. Here is the how camera parameter structure looks like:

struct CV_EXPORTS CameraParams
 {
    CameraParams();
    CameraParams(const CameraParams& other);
    const CameraParams& operator =(const CameraParams& other);
    Mat K() const;

    double focal; // Focal length
    double aspect; // Aspect ratio
    double ppx; // Principal point X
    double ppy; // Principal point Y
    Mat R; // Rotation
    Mat t; // Translation
};

I wrote the camera Parameters calculated from the stitching_detailed.cpp using the following code:

  <cameraParams> cameras;
  FileStorage fs(fileName, FileStorage::WRITE);
  fs << "K" << cameras.K();
  fs << "R" << cameras.R;
  fs << "t" << cameras.t;
  fs << "ppx" << cameras.ppx;
  fs << "ppy" << cameras.ppy;
  fs << "focal" << cameras.focal;
  fs << "aspect" << cameras.aspect;
  fs.release();

Here is how the file content looked like:

  %YAML:1.0
  ---
  K: !!opencv-matrix
    rows: 3
    cols: 3
    dt: d
    data: [ 2.4125938056164614e+003, 0., 447., 0.,
        2.4125938056164614e+003, 3.3550000000000000e+002, 0., 0., 1. ]
  R: !!opencv-matrix
    rows: 3
    cols: 3
    dt: f
    data: [ -9.67408061e-001, 7.91518241e-002, -2.40534484e-001,
        -4.17553373e-002, -9.86752093e-001, -1.56770796e-001,
        -2.49756604e-001, -1.41617730e-001, 9.57896829e-001 ]
  t: !!opencv-matrix
    rows: 3
    cols: 1
    dt: d
    data: [ 0., 0., 0. ]
  ppx: 447.
  ppy: 3.3550000000000000e+002
  focal: 2.4125938056164614e+003
  aspect: 1.

How can I now load these camera parameters to initialize CameraParams. This is the read function I was using:

Mat K, R, t;
double ppx, ppy, focal, aspect;
FileStorage fs(fileName, FileStorage::READ);
fs["K"] >> K;
fs["R"] >> R;
fs["t"] >> t;
fs["ppx"] >> ppx;
fs["ppx"] >> ppy;
fs["focal"] >> focal;
fs["aspect"] >> aspect;
camerasTest[i].K() = (Mat)K;
camerasTest[i].R = R;
camerasTest[i].t = t;
camerasTest[i].ppx = (double)ppx;
camerasTest[i].ppy = (double)ppy;
camerasTest[i].focal = (double)focal;
camerasTest[i].aspect = (double)aspect;
fs.release()

but this gives Run time error. So what transformation can be done