Firefly开源社区
标题:
V4L2如何设置帧率?
[打印本页]
作者:
luffy
时间:
2019-12-6 16:44
标题:
V4L2如何设置帧率?
本帖最后由 luffy 于 2019-12-6 16:54 编辑
RK3399平台
Sensor 支持120FPS, 我设置的60FPS, 但是我v4l2读取速率一直都是30FPS, 测MIPI信号也是差不多60FPS
Screenshot from 2019-12-06 16-42-53.png
(20.03 KB, 下载次数: 795)
下载附件
2019-12-6 16:43 上传
读取代码如下:
int Camera::readFrame()
{
struct v4l2_buffer buf;
int i, bytesused;
CLEAR(buf);
buf.type = m_bufType;
buf.memory = V4L2_MEMORY_MMAP;
if (V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE == m_bufType) {
struct v4l2_plane planes[FMT_NUM_PLANES];
buf.m.planes = planes;
buf.length = FMT_NUM_PLANES;
}
if (-1 == xioctl(m_camfd, VIDIOC_DQBUF, &buf)) {
ERR("VIDIOC_DQBUF");
return -1;
}
i = buf.index;
if (V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE == m_bufType)
bytesused = buf.m.planes[0].bytesused;
else
bytesused = buf.bytesused;
uint8_t *pdata = (uint8_t *)(m_imgBuffers[i].start);
for (size_t i = 0; i < m_width*m_height*2; i+=2) {
m_rawBuffer[i] = pdata[i+1];
m_rawBuffer[i+1] = pdata[i];
}
if (-1 == xioctl(m_camfd, VIDIOC_QBUF, &buf)) {
ERR("VIDIOC_QBUF");
return -1;
}
return 0;
}
bool Camera::trigger()
{
struct reg_map regs[] = {
{0x1100, 0x01},
{REG_NULL, 0x00},
};
return ioctl(m_camconf_fd, SET_REGS_ONLINE_CMD, regs) == 0 ? true : false;
}
int Camera::nextFrame(std::vector<CameraFrame> &frames)
{
if (m_triggerMode) {
if (!trigger()) {
LOG(ERROR) << "trigger error";
return -1;
}
}
std::lock_guard<std::mutex> l(m_runLock);
if (!m_isRunning) {
LOG(ERROR) << "not running, can not read frame";
return -1;
}
TimeMeasure tm;
tm.addRecord("all");
tm.addRecord("read");
if (readFrame() == -1) {
return -1;
}
LOG(INFO) << "read frame cost: " << tm.stopRecord("read") << "ms";
CameraFrame frame;
frame.pdata = m_rawBuffer;
frame.step = m_width * 2;
frame.type = kTypeGray;
frame.width = m_width;
frame.height = m_height;
frame.fmt = kFmt16Gray;
frames.push_back(frame);
return 0;
}
复制代码
驱动配置如下:
{
.width = 640,
.height = 480,
.max_fps = {
.numerator = 1,
.denominator = 120,
},
.hts_def = 640,
.vts_def = 480,
.regs_size = ARRAY_SIZE(cam_640x480_regs),
.reg_list = cam_640x480_regs,
},
复制代码
static int cam_g_frame_interval(struct v4l2_subdev *sd,
struct v4l2_subdev_frame_interval *fi)
{
struct mycam *mycam = to_mycam(sd);
const struct mycam_mode *mode = mycam->cur_mode;
mutex_lock(&mycam->mutex);
fi->interval = mode->max_fps;
mutex_unlock(&mycam->mutex);
return 0;
}
复制代码
作者:
yy834277137
时间:
2022-6-17 10:55
请问解决了吗
作者:
via
时间:
2022-12-2 23:36
这代码是在哪里? 可以提供下代码文件?
欢迎光临 Firefly开源社区 (https://dev.t-firefly.com/)
Powered by Discuz! X3.1