Changeset 349 in flair-src for trunk/lib


Ignore:
Timestamp:
Feb 19, 2020, 10:18:36 AM (5 years ago)
Author:
Sanahuja Guillaume
Message:

modifs v4l2

Location:
trunk/lib/FlairSensorActuator/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSensorActuator/src/V4LCamera.cpp

    r348 r349  
    3131#include <VisionFilter.h>
    3232
    33 #define DEFAULT_V4L_BUFFERS 4
    34 
    3533using std::string;
    3634using namespace flair::core;
     
    6563  }
    6664 
    67   /* This is just a technicality, but all buffers must be filled up before any
    68   staggered SYNC is applied.  SO, filler up. (see V4L HowTo) */
    6965
    7066  allocBuffers();
     
    151147  if(-1 == xioctl (device, VIDIOC_S_FMT, &form)) {
    152148    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");
    159149    return -1;
    160150  }
     
    320310
    321311int 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) {
    334321    if (errno==EINVAL) {
    335322      Thread::Err("VIDIOC_REQBUFS user memory not supported\n");
     
    340327  }
    341328
    342   nbBuffers=DEFAULT_V4L_BUFFERS;
    343329  for (int i=0; i<nbBuffers; i++) {
    344330    buffers[i] =AllocFunction(output->GetDataType().GetSize());
     
    517503        memset(&buf, 0, sizeof (v4l2_buffer));
    518504        buf.type        = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    519         buf.memory      = V4L2_MEMORY_USERPTR;//V4L2_MEMORY_MMAP;
     505        buf.memory      = V4L2_MEMORY_USERPTR;
    520506        buf.index       = (unsigned long)index;
    521507        buf.m.userptr=(unsigned long)(buffers[index]);
  • trunk/lib/FlairSensorActuator/src/V4LCamera.h

    r348 r349  
    1919#include <linux/videodev2.h>
    2020#include <libv4l1-videodev.h>
    21 #define MAX_V4L_BUFFERS 10
     21
     22#define DEFAULT_V4L_BUFFERS 4
    2223
    2324namespace flair {
     
    149150  int device;
    150151  bool hasProblems;
    151   struct video_mmap *mmaps;
    152   void* buffers[MAX_V4L_BUFFERS];
     152  void* buffers[DEFAULT_V4L_BUFFERS];
    153153  int nbBuffers;
    154154  int bufferIndex;
     
    166166
    167167int cvGrabFrame(void);
    168 
    169168int read_frame_v4l2(void);
    170169void cvRetrieveRawFrame(void);
Note: See TracChangeset for help on using the changeset viewer.