Не могу создать FakeCamera с пользовательским рисунком, используя AravisC++

Программы на C++. Форум разработчиков
Ответить Пред. темаСлед. тема
Anonymous
 Не могу создать FakeCamera с пользовательским рисунком, используя Aravis

Сообщение Anonymous »

Опишите ошибку < /strong>
Я пытаюсь создать фальшивый источник камеры с помощью собственного конкретного шаблона с помощью OpenCV. Однако камера начинается, но, кажется, никогда не поднимается Arvtools/Arvviewer.
для воспроизведения

Вот мой код: br />

Код: Выделить всё

#include 
#include 
#include 
#include 
#include 

// Define image properties
#define WIDTH 320
#define HEIGHT 240
#define PIXEL_FORMAT ARV_PIXEL_FORMAT_MONO8 // Using MONO8 for simplicity

struct FillPatternData {
guint64 frame_counter;
int width;
int height;
};

// Correct callback signature matching ArvFakeCameraFillPattern
void fill_pattern_callback(ArvBuffer *buffer, void *user_data, guint32 width,
guint32 height, guint32 padding_x) {
FillPatternData *data = static_cast(user_data);

// Generate a new 8-bit grayscale image using OpenCV
cv::Mat gray_image(data->height, data->width, CV_8UC1, cv::Scalar(0));

// Create a dynamic pattern that changes with frame_counter
// For simplicity, we'll create a moving horizontal gradient
for (int y = 0; y < data->height; y++) {
for (int x = 0; x < data->width; x++) {
gray_image.at(y, x) =
static_cast((x + data->frame_counter) % 256);
}
}

// Get the buffer data pointer and size
size_t buffer_size;
void *buffer_data = (void *)arv_buffer_get_data(buffer, &buffer_size);
if (!buffer_data) {
std::cerr height; // 1 byte per pixel for MONO8
if (image_size > buffer_size) {
std::cerr 








 ОС: 5.10.192-tegra < /li>
 Аппаратный ARM64 < /li>
< /ul>
Я также попробовал более простой метод без XML и пользовательской заполнения шаблон, но он не работает: < /p>
#include 
#include 
#include 

static GMainLoop *g_main_loop = nullptr;

// Callback matching ArvFakeCameraFillPattern signature.
// Parameters:
//   - buffer: The image buffer to fill.
//   - user_data: A user pointer (unused in this example).
//   - width, height: Dimensions of the image.
//   - payload: The expected size of the image buffer in bytes.
void fill_pattern_callback(ArvBuffer *buffer, void *user_data,
unsigned int width, unsigned int height,
unsigned int payload) {
size_t size;
// Obtain a writable pointer to the buffer data (casting away const is safe
// here).
uint8_t *pixels = const_cast(
static_cast(arv_buffer_get_data(buffer, &size)));
if (!pixels)
return;

// Fill with a simple gradient pattern.
for (unsigned int y = 0; y < height; ++y) {
for (unsigned int x = 0; x < width; ++x) {
pixels[y * width + x] = static_cast((x + y) & 0xFF);
}
}
}

static void signal_handler(int signum) {
if (g_main_loop)
g_main_loop_quit(g_main_loop);
}

int main(int argc, char **argv) {
// g_type_init() is deprecated in GLib 2.36 and later, so only call it if
// needed.
#if !GLIB_CHECK_VERSION(2, 36, 0)
g_type_init();
#endif

// Create a fake GigE Vision camera. Passing nullptr uses the loopback
// interface.
ArvGvFakeCamera *gv_cam = arv_gv_fake_camera_new(nullptr, "SIMCAM01");
if (!gv_cam) {
std::cerr 
Однако оба: < /p>
gst-launch-1.0 -v aravissrc camera-name=Fake_1 ! videoconvert ! autovideosink

Setting pipeline to PAUSED ...
ERROR: from element /GstPipeline:pipeline0/GstAravis:aravis0: Could not find camera "Fake_1": Device 'Fake_1' not found
Additional debug info:
../gst/gstaravis.c(457): gst_aravis_init_error (): /GstPipeline:pipeline0/GstAravis:aravis0
ERROR: pipeline doesn't want to preroll.
ERROR: from element /GstPipeline:pipeline0/GstAravis:aravis0: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failu
re.
Additional debug info:
../libs/gst/base/gstbasesrc.c(3556): gst_base_src_start (): /GstPipeline:pipeline0/GstAravis:aravis0:
Failed to start
ERROR: pipeline doesn't want to preroll.
Failed to set pipeline to PAUSED.
Setting pipeline to NULL ...
Freeing pipeline ...

// OR

gst-launch-1.0 -v aravissrc camera-name=Aravis-Fake-SIMCAM01 ! videoconvert ! autovideosink

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstAravis:aravis0: stream = (null)
/GstPipeline:pipeline0/GstAravis:aravis0.GstPad:src: caps = video/x-raw, format=(string)GRAY8, width=(int)512, height=(int)512, framerate=(fraction)5/1
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:src: caps = video/x-raw, width=(int)512, height=(int)512, framerate=(fraction)5/1, format=(string)YUY2
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink.GstProxyPad:proxypad0: caps = video/x-raw, width=(int)512, height=(int)512, framerate=(fraction)5/1, format=(st
ring)YUY2
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/GstXvImageSink:autovideosink0-actual-sink-xvimage.GstPad:sink: caps = video/x-raw, width=(int)512, height=(int)512, framerate=(f
raction)5/1, format=(string)YUY2
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink: caps = video/x-raw, width=(int)512, height=(int)512, framerate=(fraction)5/1, format=(string)YUY2
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:sink: caps = video/x-raw, format=(string)GRAY8, width=(int)512, height=(int)512, framerate=(fraction)5/1
Redistribute latency...
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:05.321237118
Setting pipeline to NULL ...
Freeing pipeline ...
Получите абсолютно черный экран.


Подробнее здесь: https://stackoverflow.com/questions/794 ... ing-aravis
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C++»