- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我想使用 gstreamer 更改网络摄像头的输出/输入分辨率。例如,我想将结果从 800x600 像素更改为 640x480 像素。我在 C 中找不到执行此操作的语法。谁能帮帮我?
此代码应显示来自网络摄像头的视频流:
#include <gst/gst.h>
int main(int argc, char *argv[]) {
GstElement *pipeline, *source, *sink, *convert;
GstBus *bus;
GstMessage *msg;
GstStateChangeReturn ret;
/* Initialize GStreamer */
gst_init (&argc, &argv);
/* Create the elements */
source = gst_element_factory_make ("v4l2src", "source");
sink = gst_element_factory_make ("autovideosink", "sink");
convert =gst_element_factory_make("ffmpegcolorspace","convert");
/* Create the empty pipeline */
pipeline = gst_pipeline_new ("test-pipeline");
if (!pipeline || !source || !sink || !convert) {
g_printerr ("Not all elements could be created.\n");
return -1;
}
/*set der source*/
g_object_set (source, "device", "/dev/video0", NULL);
/* Build the pipeline */
gst_bin_add_many (GST_BIN (pipeline), source, sink, convert, NULL);
if (gst_element_link (convert, sink) != TRUE) {
g_printerr ("Elements could not be linked confert sink.\n");
gst_object_unref (pipeline);
return -1;
}
if (gst_element_link (source, convert) != TRUE) {
g_printerr ("Elements could not be linked source -convert.\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;
}
最佳答案
谢谢你,你救了我的命。无论如何,我拼命地找到一个代码来使用 C++ 代码捕获 video0。你的问题解决了吗??希望这个附件能帮到你
static gboolean initialize_pipeline(AppData *appdata,
int *argc, char ***argv)
{
GstElement *pipeline, *camera_src, *screen_sink, *image_sink;
GstElement *screen_queue, *image_queue;
GstElement *csp_filter, *image_filter, *tee;
GstCaps *caps;
GstBus *bus;
/* Initialize Gstreamer */
gst_init(argc, argv);
/* Create pipeline and attach a callback to it's
* message bus */
pipeline = gst_pipeline_new("test-camera");
bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
gst_bus_add_watch(bus, (GstBusFunc)bus_callback, appdata);
gst_object_unref(GST_OBJECT(bus));
/* Save pipeline to the AppData structure */
appdata->pipeline = pipeline;
/* Create elements */
/* Camera video stream comes from a Video4Linux driver */
camera_src = gst_element_factory_make(VIDEO_SRC, "camera_src");
/* Colorspace filter is needed to make sure that sinks understands
* the stream coming from the camera */
csp_filter = gst_element_factory_make("ffmpegcolorspace", "csp_filter");
/* Tee that copies the stream to multiple outputs */
tee = gst_element_factory_make("tee", "tee");
/* Queue creates new thread for the stream */
screen_queue = gst_element_factory_make("queue", "screen_queue");
/* Sink that shows the image on screen. Xephyr doesn't support XVideo
* extension, so it needs to use ximagesink, but the device uses
* xvimagesink */
screen_sink = gst_element_factory_make(VIDEO_SINK, "screen_sink");
/* Creates separate thread for the stream from which the image
* is captured */
image_queue = gst_element_factory_make("queue", "image_queue");
/* Filter to convert stream to use format that the gdkpixbuf library
* can use */
image_filter = gst_element_factory_make("ffmpegcolorspace", "image_filter");
/* A dummy sink for the image stream. Goes to bitheaven */
image_sink = gst_element_factory_make("fakesink", "image_sink");
/* Check that elements are correctly initialized */
if(!(pipeline && camera_src && screen_sink && csp_filter && screen_queue
&& image_queue && image_filter && image_sink))
{
g_critical("Couldn't create pipeline elements");
return FALSE;
}
/* Set image sink to emit handoff-signal before throwing away
* it's buffer */
g_object_set(G_OBJECT(image_sink),
"signal-handoffs", TRUE, NULL);
/* Add elements to the pipeline. This has to be done prior to
* linking them */
gst_bin_add_many(GST_BIN(pipeline), camera_src, csp_filter,
tee, screen_queue, screen_sink, image_queue,
image_filter, image_sink, NULL);
/* Specify what kind of video is wanted from the camera */
caps = gst_caps_new_simple("video/x-raw-rgb",
"width", G_TYPE_INT, 640,
"height", G_TYPE_INT, 480,
NULL);
/* Link the camera source and colorspace filter using capabilities
* specified */
if(!gst_element_link_filtered(camera_src, csp_filter, caps))
{
return FALSE;
}
gst_caps_unref(caps);
/* Connect Colorspace Filter -> Tee -> Screen Queue -> Screen Sink
* This finalizes the initialization of the screen-part of the pipeline */
if(!gst_element_link_many(csp_filter, tee, screen_queue, screen_sink, NULL))
{
return FALSE;
}
/* gdkpixbuf requires 8 bits per sample which is 24 bits per
* pixel */
caps = gst_caps_new_simple("video/x-raw-rgb",
"width", G_TYPE_INT, 640,
"height", G_TYPE_INT, 480,
"bpp", G_TYPE_INT, 24,
"depth", G_TYPE_INT, 24,
"framerate", GST_TYPE_FRACTION, 15, 1,
NULL);
/* Link the image-branch of the pipeline. The pipeline is
* ready after this */
if(!gst_element_link_many(tee, image_queue, image_filter, NULL)) return FALSE;
if(!gst_element_link_filtered(image_filter, image_sink, caps)) return FALSE;
gst_caps_unref(caps);
/* As soon as screen is exposed, window ID will be advised to the sink */
g_signal_connect(appdata->screen, "expose-event", G_CALLBACK(expose_cb),
screen_sink);
gst_element_set_state(pipeline, GST_STATE_PLAYING);
return TRUE;
谢谢。
关于c++ - gstreamer:如何更改网络摄像头的输入/输出分辨率?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15758208/
避免必须自己创建整个相机应用程序,我调用: Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); this.startActivit
我使用这种方法从前置摄像头录制视频: Recording video via Mediarecorder 它在我的 Nexus 4 上运行良好,但有人说有很多手机的前置摄像头无法录制视频,只能拍照。我
我正在使用 Android 手机的摄像头作为输入来测试成像算法,并且需要一种方法来始终如一地测试算法。理想情况下,我想获取预先录制的视频源并让手机“假装”视频源是来自相机的实时视频。 我理想的解决方案
我想在 android 上通过 v4l 访问外部 USB 摄像头。 我试过了 SimpleWebCam .在对原始源代码进行一些细微修改后,我实现了使其在 Root过的 android 设备上运行。然
我正在尝试连接两个连接到单个 USB 端口的 USB 网络摄像头。问题是当时只有一个摄像头工作...我在 python 中使用 OpenCV。这可能吗?我的目标是将多台相机连接到一台计算机以进行机器视
我想知道如何在 virtualbox 中使用笔记本电脑的内置网络摄像头和 android x86。 我已经尝试启动默认的“相机”应用程序,它告诉我必须配置 SDCard,我在本教程中所做的:SD ca
我在 64 位华硕的 Ubuntu 12.10 上安装了 ARToolKit。安装没有错误,所以我觉得我没问题。但是当我想尝试一个例子时,它找不到相机。如果我在 char *vconf = ""; 没
我想以编程方式移动 webvr 场景中 View 的位置。为此,我使用了position.add 方法。 以下是我如何以编程方式移动相机: 摄像机移至此处: var obj3d = docume
我正在使用 Camera 2 API 将 JPEG 图像保存在磁盘上。我的 Nexus 5X 目前有 3-4 fps,我想将其提高到 20-30。可能吗? 将图像格式更改为 YUV 我设法生成 30
Baby Monitor (http://www.babymonitor3g.com/) 等应用程序可让两台 iOS 设备相互连接。连接后,一台设备可以激活另一台设备上的摄像头、灯光和麦克风,即使该应
我有一个论坛帖子表单,允许发帖人附加录音和/或网络摄像头快照。这两个都是使用 navigator.getUserMedia() 实现的应用程序接口(interface)。对于音频,我建立了 varia
我对 Opencv 和 Python 有疑问。当我尝试从相机中查看帧时,它无法识别 USB 相机,我使用了带有两个 USB 相机的书籍中的标准代码,问题是只有一个相机工作,我不知道。我在 window
我编写了一个程序,基本上使用步进电机 + a4988 驱动程序将托盘放在连接到 Raspberry Pi 的相机下方。代码将托盘带到起始位置,迈出一步,拍照并重复 10 次。然后托盘返回到起始位置。我
我的 uEye 相机遇到了一个问题。使用我的笔记本电脑摄像头(id 0)或 usb 上的网络摄像头(id 1)这条线完美运行: TheVideoCapturer.open(1); (TheVideoC
我是 Android 版 openCV 的新手,我需要一个在后台运行的图像处理应用(检测图像的线条)。 我已经制作了一个应用程序来完成我需要的所有图像处理(使用 jni),但它不能在后台运行并且它使用
我正在尝试使用 OpenCV 从 USB 摄像头捕获视频。 #include #include using namespace std; using namespace cv; int main(
我正在寻找启用和禁用默认 iPhone 相机的方法,例如在特定时间或纬度/经度。有些地方是禁止摄像头的,所以我们可以在到达这样的地方时关闭它,这里只是举个例子。好吧,我认为在 iPhone 中禁用和启
有人有这种“东西”的工作样本吗? 在理论上,以这种方式实现它是个好主意,但我没有看到任何相关的代码 fragment 来说明如何实现它。 我不要花哨的东西,越简单越好。我只想在单独的线程上实现与相机控
我正在开发一个新网站。您可以加入房间通话并进行语音通话,因此可以使用您的网络摄像头,但您也可以共享您的屏幕。 问题是当我将轨道添加到流中时,对等点不再工作......我不知道如何解决这个问题。我还尝试
我需要在 Flutter 中创建一个考试应用程序,我们需要每隔一段时间拍摄用户的照片和视频,而在执行此操作时我们不想显示相机屏幕。 我尝试使用 Flutter 的 Camera 插件,但我无法找到任何
我是一名优秀的程序员,十分优秀!