int main (int argc, char **argv) { ArvViewer *viewer; int status; GOptionContext *context; GError *error = NULL; bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); arv_g_thread_init (NULL); gtk_init (&argc, &argv); gst_init (&argc, &argv); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, arv_viewer_option_entries, NULL); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_group (context, gst_init_get_option_group ()); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_option_context_free (context); g_print ("Option parsing failed: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } g_option_context_free (context); arv_debug_enable (arv_viewer_option_debug_domains); viewer = arv_viewer_new (); if (!ARV_IS_VIEWER (viewer)) return EXIT_FAILURE; arv_viewer_set_options (viewer, arv_viewer_option_auto_socket_buffer, !arv_viewer_option_no_packet_resend, arv_viewer_option_packet_timeout, arv_viewer_option_frame_retention); notify_init ("Aravis Viewer"); status = g_application_run (G_APPLICATION (viewer), argc, argv); g_object_unref (viewer); notify_uninit (); return status; }
int main (int argc, char **argv) { ArvEvaluator *evaluator; GOptionContext *context; GError *error = NULL; int i; double value; context = g_option_context_new (NULL); g_option_context_add_main_entries (context, arv_option_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_option_context_free (context); g_print ("Option parsing failed: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } g_option_context_free (context); arv_debug_enable (arv_option_debug_domains); evaluator = arv_evaluator_new (NULL); arv_evaluator_set_double_variable (evaluator, "TDBL", 124.2); arv_evaluator_set_int64_variable (evaluator, "TINT", 3200); if (arv_option_expressions == NULL) { g_print ("Missing expression.\n"); return EXIT_FAILURE; } for (i = 0; arv_option_expressions[i] != NULL; i++) { arv_evaluator_set_expression (evaluator, arv_option_expressions[i]); value = arv_evaluator_evaluate_as_double (evaluator, &error); if (error != NULL) { g_print ("Error in '%s': %s\n", arv_option_expressions[i], error->message); g_error_free (error); error = NULL; } else g_print ("%s = %g\n", arv_option_expressions[i], value); } g_object_unref (evaluator); return EXIT_SUCCESS; }
int main (int argc, char **argv) { ArvZip *zip; char *buffer; size_t size; GOptionContext *context; GError *error = NULL; int i; g_type_init (); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, arv_option_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_option_context_free (context); g_print ("Option parsing failed: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } g_option_context_free (context); arv_debug_enable (arv_option_debug_domains); if (arv_option_filenames == NULL) { g_print ("Missing input filename.\n"); return EXIT_FAILURE; } for (i = 0; arv_option_filenames[i] != NULL; i++) { g_file_get_contents (arv_option_filenames[i], &buffer, &size, NULL); if (buffer != NULL) { zip = arv_zip_new (buffer, size); arv_zip_free (zip); } } return EXIT_SUCCESS; }
int main (int argc, char **argv) { ArvGc *genicam; char *xml; size_t size; GOptionContext *context; GError *error = NULL; int i; arv_g_type_init (); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, arv_option_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_option_context_free (context); g_print ("Option parsing failed: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } g_option_context_free (context); arv_debug_enable (arv_option_debug_domains); if (arv_option_filenames == NULL) { g_print ("Missing input filename.\n"); return EXIT_FAILURE; } for (i = 0; arv_option_filenames[i] != NULL; i++) { g_file_get_contents (arv_option_filenames[i], &xml, &size, NULL); if (xml != NULL) { ArvGcNode *node; g_print ("Loading '%s'.\n", arv_option_filenames[i]); genicam = arv_gc_new (NULL, xml, size); node = arv_gc_get_node (genicam, "RegAcquisitionCommand"); if (node != NULL) { g_print ("RegAcquisitionCommand address = 0x%Lx - length = 0x%Lx\n", (unsigned long long) arv_gc_register_get_address (ARV_GC_REGISTER (node), NULL), (unsigned long long) arv_gc_register_get_length (ARV_GC_REGISTER (node), NULL)); } node = arv_gc_get_node (genicam, "IntWidthIncrement"); if (node != NULL) { g_print ("IntWidthIncrement value = %Ld\n", (long long) arv_gc_integer_get_value (ARV_GC_INTEGER (node), NULL)); } node = arv_gc_get_node (genicam, "WhitebalValueMin"); if (node != NULL) { g_print ("WhitebalValueMin value = %g\n", arv_gc_float_get_value (ARV_GC_FLOAT (node), NULL)); } g_free (xml); g_object_unref (genicam); } else g_print ("File '%s' not found.\n", arv_option_filenames[i]); } return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { ArvDevice *device; ArvStream *stream; ArvCamera *camera; ArvGcFeatureNode *feature; guint64 n_completed_buffers; guint64 n_failures; guint64 n_underruns; GOptionContext *context; GError *error = NULL; void (*old_sigint_handler)(int); int i, payload; arv_g_thread_init (NULL); arv_g_type_init (); context = g_option_context_new (NULL); g_option_context_set_summary (context, "Test of heartbeat robustness while continuously changing a feature."); g_option_context_add_main_entries (context, arv_option_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_option_context_free (context); g_print ("Option parsing failed: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } g_option_context_free (context); arv_debug_enable (arv_option_debug_domains); camera = arv_camera_new (arv_option_camera_name); if (!ARV_IS_CAMERA (camera)) { printf ("Device not found\n"); return EXIT_FAILURE; } device = arv_camera_get_device (camera); stream = arv_camera_create_stream (camera, NULL, NULL); if (!ARV_IS_STREAM (stream)) { printf ("Invalid device\n"); } else { payload = arv_camera_get_payload (camera); if (ARV_IS_GV_STREAM (stream)) { g_object_set (stream, //"socket-buffer", ARV_GV_STREAM_SOCKET_BUFFER_AUTO, "socket-buffer", ARV_GV_STREAM_SOCKET_BUFFER_FIXED, "socket-buffer-size", payload*6, "packet-timeout", 1000 * 1000, "frame-retention", 100 * 1000, "packet-resend", ARV_GV_STREAM_PACKET_RESEND_ALWAYS, NULL); } for (i = 0; i < 100; i++) arv_stream_push_buffer(stream, arv_buffer_new(payload, NULL)); arv_camera_set_acquisition_mode(camera, ARV_ACQUISITION_MODE_CONTINUOUS); feature = ARV_GC_FEATURE_NODE (arv_device_get_feature (device, arv_option_feature_name)); arv_camera_start_acquisition (camera); old_sigint_handler = signal (SIGINT, set_cancel); while (!cancel) { ArvBuffer *buffer = arv_stream_timeout_pop_buffer(stream, 2000000); if (buffer) { usleep(10); arv_stream_push_buffer (stream, buffer); } if (!(++i%5)) { char *value; if ((i/100) % 2 == 0) value = g_strdup_printf ("%d", arv_option_min); else value = g_strdup_printf ("%d", arv_option_max); fprintf (stderr, "Setting %s from %s to %s\n", arv_option_feature_name, arv_gc_feature_node_get_value_as_string (feature, NULL), value); arv_gc_feature_node_set_value_from_string (feature, value, NULL); g_free (value); } } signal (SIGINT, old_sigint_handler); arv_stream_get_statistics (stream, &n_completed_buffers, &n_failures, &n_underruns); printf ("\nCompleted buffers = %Lu\n", (unsigned long long) n_completed_buffers); printf ("Failures = %Lu\n", (unsigned long long) n_failures); printf ("Underruns = %Lu\n", (unsigned long long) n_underruns); arv_camera_stop_acquisition (camera); } g_object_unref (camera); return 0; }
int main (int argc, char **argv) { ArvFakeGvCamera *gv_camera; int n_events; GInputVector input_vector; GOptionContext *context; GError *error = NULL; arv_g_thread_init (NULL); arv_g_type_init (); context = g_option_context_new (NULL); g_option_context_set_summary (context, "Fake GigEVision camera."); g_option_context_set_description (context, "Example: 'arv-fake-gv-camera-" ARAVIS_API_VERSION " -i eth0'"); g_option_context_add_main_entries (context, arv_option_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_option_context_free (context); g_print ("Option parsing failed: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } g_option_context_free (context); arv_debug_enable (arv_option_debug_domains); gv_camera = arv_fake_gv_camera_new (arv_option_interface_name); if (gv_camera == NULL) { g_print ("Can't instantiate a new fake camera.\n"); g_print ("An existing instance may already use the '%s' interface.\n", arv_option_interface_name); return EXIT_FAILURE; } input_vector.buffer = g_malloc0 (ARV_FAKE_GV_CAMERA_BUFFER_SIZE); input_vector.size = ARV_FAKE_GV_CAMERA_BUFFER_SIZE; signal (SIGINT, set_cancel); do { n_events = g_poll (gv_camera->gvcp_fds, 2, 1000); g_print ("n_events = %d\n", n_events); if (n_events > 0) { GSocketAddress *remote_address; int count; count = g_socket_receive_message (gv_camera->gvcp_socket, &remote_address, &input_vector, 1, NULL, NULL, G_SOCKET_MSG_NONE, NULL, NULL); if (count > 0) handle_control_packet (gv_camera, gv_camera->gvcp_socket, remote_address, input_vector.buffer, count); if (gv_camera->discovery_socket != NULL) { count = g_socket_receive_message (gv_camera->discovery_socket, &remote_address, &input_vector, 1, NULL, NULL, G_SOCKET_MSG_NONE, NULL, NULL); if (count > 0) handle_control_packet (gv_camera, gv_camera->discovery_socket, remote_address, input_vector.buffer, count); } } } while (!cancel); g_free (input_vector.buffer); arv_fake_gv_camera_free (gv_camera); return EXIT_SUCCESS; }
int main (int argc, char **argv) { ArvCamera * camera; ArvStream *stream; ArvBuffer *buffer; GOptionContext *context; GError *error = NULL; char memory_buffer[100000]; int i; arv_g_thread_init (NULL); arv_g_type_init (); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, arv_option_entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_option_context_free (context); g_print ("Option parsing failed: %s\n", error->message); g_error_free (error); return EXIT_FAILURE; } g_option_context_free (context); if (arv_option_max_frames < 0) arv_option_max_errors_before_abort = -1; save_buffer_fn = GetSaveBufferFn(arv_option_save_type); arv_debug_enable (arv_option_debug_domains); if (arv_option_camera_name == NULL) g_print ("Looking for the first available camera\n"); else g_print ("Looking for camera '%s'\n", arv_option_camera_name); camera = arv_camera_new (arv_option_camera_name); int errors = 0; if (camera == NULL) { g_print("No device found"); return 1; } guint payload_size = arv_camera_get_payload(camera); g_print ("payload size = %d (0x%x)\n", payload_size, payload_size); stream = arv_camera_create_stream (camera, NULL, NULL); if (arv_option_auto_buffer) { g_object_set (stream,"socket-buffer", ARV_GV_STREAM_SOCKET_BUFFER_AUTO,"socket-buffer-size", 0,NULL); } for (i = 0; i < 30; i++) { arv_stream_push_buffer (stream, arv_buffer_new (payload_size, NULL)); } arv_camera_stop_acquisition(camera); // set the bit depth ArvDevice * device = arv_camera_get_device(camera); ArvGcNode * feature = arv_device_get_feature(device, "PixelFormat"); char * pix_format = "Mono8"; if (arv_option_pixel_format == 14) pix_format = "Mono14"; arv_gc_feature_node_set_value_from_string(ARV_GC_FEATURE_NODE(feature), pix_format, NULL); if (arv_option_pixel_format == 14) { feature = arv_device_get_feature(device, "CMOSBitDepth"); arv_gc_feature_node_set_value_from_string(ARV_GC_FEATURE_NODE(feature), "bit14bit", NULL); } signal (SIGINT, set_cancel); signal (SIGQUIT, set_cancel); int captured_frames = 0; guint64 timeout=1000000; #define _CAN_STOP (arv_option_max_frames > 0 && captured_frames >= arv_option_max_frames) arv_camera_start_acquisition(camera); do { g_usleep (100000); do { buffer = arv_stream_timeout_pop_buffer (stream, timeout); if (buffer == NULL) break; ArvBufferStatus status = arv_buffer_get_status(buffer); fprintf(stderr, "Status is %d\n", status); if (status == ARV_BUFFER_STATUS_SUCCESS) { if (timeout > 100000) timeout -= 1000; errors = 0; if (save_buffer_fn != NULL) { struct timespec timestamp; clock_gettime(CLOCK_REALTIME, ×tamp); char filename[BUFSIZ]; if (strcmp(arv_option_save_prefix,"") != 0) { sprintf(filename, "%s/%s%d.%s", arv_option_save_dir,arv_option_save_prefix, captured_frames, arv_option_save_type); } else { sprintf(filename, "%s/%d.%03ld.%s", arv_option_save_dir, (int)timestamp.tv_sec, (long)(timestamp.tv_nsec/1.0e6), arv_option_save_type); } if ((*save_buffer_fn)(buffer, filename) == false) { g_print("Couldn't save frame %d to %s\n", captured_frames, filename); set_cancel(SIGQUIT); } g_print("Saved frame %d to %s\n", captured_frames, filename); char latest[] = "latest.png"; sprintf(latest, "latest.%s", arv_option_save_type); unlink(latest); symlink(filename, latest); } captured_frames++; g_usleep(arv_option_sample_period); } else { if (timeout < 10000000) timeout+=1000; fprintf(stderr, "%d errors out of %d allowed\n", errors, arv_option_max_errors_before_abort); arv_camera_stop_acquisition(camera); if (++errors > arv_option_max_errors_before_abort && arv_option_max_errors_before_abort >= 0) { set_cancel(SIGQUIT); } else { arv_camera_start_acquisition(camera); } } arv_stream_push_buffer (stream, buffer); } while (!cancel && buffer != NULL && !_CAN_STOP); } while (!cancel && !_CAN_STOP); arv_camera_stop_acquisition(camera); guint64 n_processed_buffers; guint64 n_failures; guint64 n_underruns; arv_stream_get_statistics (stream, &n_processed_buffers, &n_failures, &n_underruns); g_print ("Processed buffers = %Lu\n", (unsigned long long) n_processed_buffers); g_print ("Failures = %Lu\n", (unsigned long long) n_failures); g_print ("Underruns = %Lu\n", (unsigned long long) n_underruns); g_object_unref (stream); g_object_unref (camera); return (errors > 0); }