Changeset 349 in flair-src
- Timestamp:
- Feb 19, 2020, 10:18:36 AM (5 years ago)
- Location:
- trunk/lib/FlairSensorActuator/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/V4LCamera.cpp
r348 r349 31 31 #include <VisionFilter.h> 32 32 33 #define DEFAULT_V4L_BUFFERS 434 35 33 using std::string; 36 34 using namespace flair::core; … … 65 63 } 66 64 67 /* This is just a technicality, but all buffers must be filled up before any68 staggered SYNC is applied. SO, filler up. (see V4L HowTo) */69 65 70 66 allocBuffers(); … … 151 147 if(-1 == xioctl (device, VIDIOC_S_FMT, &form)) { 152 148 Thread::Err("Could not set specifics of capture window.\n"); 153 return -1;154 }155 156 /* Get window info again, to get the real value */157 if(-1 == xioctl (device, VIDIOC_G_FMT, &form)) {158 Thread::Err("Could not obtain specifics of capture window.\n");159 149 return -1; 160 150 } … … 320 310 321 311 int V4LCamera::AllocBuffers(void) { 322 struct v4l2_requestbuffers requestbuffers; 323 memset(&requestbuffers, 0, sizeof (v4l2_requestbuffers)); 324 325 unsigned int buffer_number = DEFAULT_V4L_BUFFERS; 326 327 try_again: 328 329 requestbuffers.count = buffer_number; 330 requestbuffers.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 331 requestbuffers.memory = V4L2_MEMORY_USERPTR; 332 333 if (xioctl (device, VIDIOC_REQBUFS, &requestbuffers)==-1) { 312 struct v4l2_requestbuffers req; 313 memset(&req, 0, sizeof (v4l2_requestbuffers)); 314 nbBuffers=DEFAULT_V4L_BUFFERS; 315 316 req.count = nbBuffers; 317 req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 318 req.memory = V4L2_MEMORY_USERPTR; 319 320 if (xioctl (device, VIDIOC_REQBUFS, &req)==-1) { 334 321 if (errno==EINVAL) { 335 322 Thread::Err("VIDIOC_REQBUFS user memory not supported\n"); … … 340 327 } 341 328 342 nbBuffers=DEFAULT_V4L_BUFFERS;343 329 for (int i=0; i<nbBuffers; i++) { 344 330 buffers[i] =AllocFunction(output->GetDataType().GetSize()); … … 517 503 memset(&buf, 0, sizeof (v4l2_buffer)); 518 504 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 519 buf.memory = V4L2_MEMORY_USERPTR; //V4L2_MEMORY_MMAP;505 buf.memory = V4L2_MEMORY_USERPTR; 520 506 buf.index = (unsigned long)index; 521 507 buf.m.userptr=(unsigned long)(buffers[index]); -
trunk/lib/FlairSensorActuator/src/V4LCamera.h
r348 r349 19 19 #include <linux/videodev2.h> 20 20 #include <libv4l1-videodev.h> 21 #define MAX_V4L_BUFFERS 10 21 22 #define DEFAULT_V4L_BUFFERS 4 22 23 23 24 namespace flair { … … 149 150 int device; 150 151 bool hasProblems; 151 struct video_mmap *mmaps; 152 void* buffers[MAX_V4L_BUFFERS]; 152 void* buffers[DEFAULT_V4L_BUFFERS]; 153 153 int nbBuffers; 154 154 int bufferIndex; … … 166 166 167 167 int cvGrabFrame(void); 168 169 168 int read_frame_v4l2(void); 170 169 void cvRetrieveRawFrame(void);
Note:
See TracChangeset
for help on using the changeset viewer.