Can't get images from 2 cameras
Hello guys, my problem is that I can't get get images from 2 cameras. They are identical and resolution 320x240. Encoding is MJPEG which is compressed one.
The problem I get:
VIDIOC_STREAMON: No space left on device
Right video camera is not working at the moment. Capture Error!
My df -i results:
Filesystem Inodes IUsed IFree IUse% Mounted on
udev 183230 1425 181805 1% /dev
tmpfs 219824 1652 218172 1% /run
/dev/mmcblk0p2 966656 72370 894286 8% /
tmpfs 219824 1 219823 1% /dev/shm
tmpfs 219824 2 219822 1% /run/lock
tmpfs 219824 16 219808 1% /sys/fs/cgroup
/dev/mmcblk0p1 0 0 0 - /media/boot
tmpfs 219824 4 219820 1% /run/user/0
The code I use:
// OpenCV libraries
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/core.hpp"
#include "opencv2/shape.hpp"
#include <opencv2/aruco.hpp>
// Std libraries
#include <iostream>
#include <string>
#include <cstdlib>
#include <stdio.h>
#include <cmath>
#include <ctime>
#include <signal.h>
#include <algorithm>
#include <unistd.h>
//Namespaces
using namespace std;
using namespace cv;
bool isSingleBoard = true;
VideoCapture capL, capR;
VideoWriter leftWriter, rightWriter;
//Signal handling for SIGINT ( CTRL + C )
void my_handler(int s){
if(!isSingleBoard)
destroyAllWindows();
capL.release(); // opencv camera release
capR.release(); // opencv camera release
//SDL_Quit(); // OpenGL release
exit(0);
}
int main(int argc, char **argv){
cv::Mat cameraMatrixL = cv::Mat(3,3, CV_64F);
cv::Mat distCoeffsL = cv::Mat(1,4, CV_64F);
cv::Mat cameraMatrixR = cv::Mat(3,3, CV_64F);
cv::Mat distCoeffsR = cv::Mat(1,4, CV_64F);
int width = 320, height = 240; // Change as you desire, care that most of the cameras are not supporting all ratios!
// Signal is needed because capture should be released in any case. I use sigint for closing, I handled it.
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = my_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
if(!isSingleBoard){
capL = VideoCapture("/dev/video1", cv::CAP_V4L);
capR = VideoCapture("/dev/video2", cv::CAP_V4L);
}
else{
capL = VideoCapture("/dev/video0", cv::CAP_V4L);
capR = VideoCapture("/dev/video1", cv::CAP_V4L);
}
capL.set(CV_CAP_PROP_FPS, 10);
capR.set(CV_CAP_PROP_FPS, 10);
capL.set(CV_CAP_PROP_FRAME_WIDTH,width);
capL.set(CV_CAP_PROP_FRAME_HEIGHT,height);
capR.set(CV_CAP_PROP_FRAME_WIDTH,width);
capR.set(CV_CAP_PROP_FRAME_HEIGHT,height);
// For unique video names.
time_t seconds;
seconds = time(NULL);
string leftname, rightname;
leftname = string("left_") + to_string(seconds) + string(".avi");
rightname = string("right_") + to_string(seconds) + string(".avi");
// CV_FOURCC('M','J','P','G')
leftWriter = VideoWriter(leftname,CV_FOURCC('M','J','P','G'), 10, Size(width,height));
rightWriter = VideoWriter(rightname,CV_FOURCC('M','J','P','G'), 10, Size(width,height));
// BLACK BOX RIGHT CAMERA
cameraMatrixR.at<double>(0,0) = 8.7030170819798286e+02;
cameraMatrixR.at<double>(0,1) = 0.;
cameraMatrixR.at<double>(0,2) = 320.;
cameraMatrixR.at<double>(1,0) = 0.;
cameraMatrixR.at<double>(1,1) = 8.7030170819798286e+02;
cameraMatrixR.at<double>(1,2) = 240.;
cameraMatrixR.at<double>(2,0) = 0.;
cameraMatrixR.at<double>(2,1) = 0.;
cameraMatrixR.at<double>(2,2) = 1.;
distCoeffsR.at<double>(0,0) = -4.7851541557875366e-01;
distCoeffsR.at<double>(0,1) = 1.0494014645561520e+00;
distCoeffsR.at<double>(0,2) = 0.;
distCoeffsR.at<double>(0,3) = 0.;
distCoeffsR.at<double>(0,4) = -3.0666278646347642e+00;
// BLACK BOX LEFT CAMERA
cameraMatrixL.at<double>(0,0 ...
pro tip, you want to put the error at the top, not 500 lines down !
Thank you for looking the post. Against your unnecessary critism, I want to give a pro tip to you: 1- Insted of using exclamation point and yelling, you can do a nice critism so I can understand and swap the code and error location. 2- You also commented( and removed ) this: ''' "No space left on device" <-- what exactly do you NOT understand here ?''' I already search every single post and tried everything. I need spesific solution and I am willing to give every detail people need. I have enough space in every part and my bandwith is enough to receive 2 1080P images in a second. I looked and change the buffer for higher storage value and I couldn't find something. Thanks Mr. Genius like you, looks like I can't find the answer till the eternity. I am editing the post so you can be happy.
touché (and i got it even wrong. apologies.)
Again, thanks for looking up on the post. I can give the necessary information. I am adding "df -i" output and some info also.