jetson使用opencv和gstreamer调用csi摄像头报错:[ WARN:0] | GStreamer warning: Cannot query video position:

[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1

出现类似的warning基本都是一个问题

VideoCapture加个参数就好了

cap = VideoCapture(0, cv.CAP_V4L2)
  • 29
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
Jetson Nano 使用 CSI (Camera Serial Interface) 接口连接摄像头。要在 Jetson Nano 上使用 CSI 摄像头,您需要使用 NVIDIA JetPack SDK 安装相应的软件和驱动程序,并编写相应的 C 代码来访问和控制摄像头。 以下是一些基本的步骤,可以帮助您开始使用 CSI 摄像头: 1. 安装 JetPack SDK:JetPack SDK 包含了 NVIDIA Jetson Nano 的所有软件和驱动程序。您可以从 NVIDIA 的官方网站上下载 JetPack SDK,并按照指南进行安装。 2. 连接 CSI 摄像头:将 CSI 摄像头插入 Jetson Nano 的 CSI 接口。 3. 编写 C 代码:使用 GStreamer 库编写 C 代码来访问和控制摄像头GStreamer 是一种流媒体框架,可以帮助您在 Jetson Nano 上捕获和处理视频流。您可以使用 GStreamer 的 nvarguscamerasrc 插件来访问 CSI 摄像头。 以下是一个简单的 C 代码示例,可以使用 nvarguscamerasrc 插件捕获 CSI 摄像头的视频流: ```c #include <gst/gst.h> int main(int argc, char* argv[]) { GstElement *pipeline, *source, *sink; GstBus *bus; GstMessage *msg; GstStateChangeReturn ret; /* Initialize GStreamer */ gst_init(&argc, &argv); /* Create the elements */ source = gst_element_factory_make("nvarguscamerasrc", "source"); sink = gst_element_factory_make("nveglglessink", "sink"); /* Create the empty pipeline */ pipeline = gst_pipeline_new("test-pipeline"); if (!pipeline || !source || !sink) { g_printerr("Not all elements could be created.\n"); return -1; } /* Build the pipeline */ gst_bin_add_many(GST_BIN(pipeline), source, sink, NULL); if (gst_element_link(source, sink) != TRUE) { g_printerr("Elements could not be linked.\n"); gst_object_unref(pipeline); return -1; } /* Start playing */ ret = gst_element_set_state(pipeline, GST_STATE_PLAYING); if (ret == GST_STATE_CHANGE_FAILURE) { g_printerr("Unable to set the pipeline to the playing state.\n"); gst_object_unref(pipeline); return -1; } /* Wait until error or EOS */ bus = gst_element_get_bus(pipeline); msg = gst_bus_timed_pop_filtered(bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS); /* Parse message */ if (msg != NULL) { GError *err; gchar *debug_info; switch (GST_MESSAGE_TYPE(msg)) { case GST_MESSAGE_ERROR: gst_message_parse_error(msg, &err, &debug_info); g_printerr("Error received from element %s: %s\n", GST_OBJECT_NAME(msg->src), err->message); g_printerr("Debugging information: %s\n", debug_info ? debug_info : "none"); g_clear_error(&err); g_free(debug_info); break; case GST_MESSAGE_EOS: g_print("End-Of-Stream reached.\n"); break; default: /* We should not reach here because we only asked for ERRORs and EOS */ g_printerr("Unexpected message received.\n"); break; } gst_message_unref(msg); } /* Free resources */ gst_object_unref(bus); gst_element_set_state(pipeline, GST_STATE_NULL); gst_object_unref(pipeline); return 0; } ``` 4. 编译和运行代码:使用 gcc 编译上述 C 代码,并在 Jetson Nano 上运行它。您应该能够看到 CSI 摄像头的视频流在屏幕上显示出来。 请注意,上述代码仅仅是一个简单的示例。如果您需要更复杂的功能,例如捕获图像、处理视频流等,请参考 GStreamer 的官方文档,并编写相应的 C 代码来实现您的需求。
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值