ROI FastCMOS::getROI() { ROI r; checkIMAQ(imgGetAttribute(session, IMG_ATTR_ROI_LEFT, &r.x)); checkIMAQ(imgGetAttribute(session, IMG_ATTR_ROI_TOP, &r.y)); checkIMAQ(imgGetAttribute(session, IMG_ATTR_ROI_WIDTH, &r.w)); checkIMAQ(imgGetAttribute(session, IMG_ATTR_ROI_HEIGHT, &r.h)); return r; }
ROI FastCMOS::getAcqWindow() { ROI roi; checkIMAQ(imgGetAttribute(session, IMG_ATTR_ACQWINDOW_LEFT, &roi.x)); checkIMAQ(imgGetAttribute(session, IMG_ATTR_ACQWINDOW_TOP, &roi.y)); checkIMAQ(imgGetAttribute(session, IMG_ATTR_ACQWINDOW_WIDTH, &roi.w)); checkIMAQ(imgGetAttribute(session, IMG_ATTR_ACQWINDOW_HEIGHT, &roi.h)); return roi; }
int FastCMOS::getFramecount() { uInt32 v; checkIMAQ(imgGetAttribute(session, IMG_ATTR_FRAME_COUNT, &v)); return v; }
int FastCMOS::getLostFrames() { uInt32 lost; checkIMAQ(imgGetAttribute(session, IMG_ATTR_LOST_FRAMES, &lost)); return lost; }
/** * gst_niimaqsrc_get_cam_caps: * src: #GstNiImaq instance * * Get caps of camera attached to open IMAQ interface * * Returns: the #GstCaps of the src pad. Unref the caps when you no longer need it. */ GstCaps * gst_niimaqsrc_get_cam_caps (GstNiImaqSrc * src) { GstCaps *gcaps = NULL; Int32 rval; uInt32 val; gint depth, bpp; GstVideoInfo vinfo; if (!src->iid) { GST_ELEMENT_ERROR (src, RESOURCE, FAILED, ("Camera interface not open"), ("Camera interface not open")); goto error; } gst_video_info_init (&vinfo); GST_LOG_OBJECT (src, "Retrieving attributes from IMAQ interface"); rval = imgGetAttribute (src->iid, IMG_ATTR_BITSPERPIXEL, &val); gst_niimaqsrc_report_imaq_error (rval); bpp = val; rval &= imgGetAttribute (src->iid, IMG_ATTR_BYTESPERPIXEL, &val); gst_niimaqsrc_report_imaq_error (rval); depth = val * 8; rval &= imgGetAttribute (src->iid, IMG_ATTR_ROI_WIDTH, &val); gst_niimaqsrc_report_imaq_error (rval); vinfo.width = val; rval &= imgGetAttribute (src->iid, IMG_ATTR_ROI_HEIGHT, &val); gst_niimaqsrc_report_imaq_error (rval); vinfo.height = val; if (rval) { GST_ELEMENT_ERROR (src, STREAM, FAILED, ("attempt to read attributes failed"), ("attempt to read attributes failed")); goto error; } if (depth == 8) vinfo.finfo = gst_video_format_get_info (GST_VIDEO_FORMAT_GRAY8); else if (depth == 16) vinfo.finfo = gst_video_format_get_info (GST_VIDEO_FORMAT_GRAY16_LE); else if (depth == 32) vinfo.finfo = gst_video_format_get_info (GST_VIDEO_FORMAT_BGRA); else { GST_ERROR_OBJECT (src, "Depth %d (%d-bit) not supported yet", depth, bpp); goto error; } vinfo.fps_n = 30; vinfo.fps_d = 1; /* hard code framerate and par as IMAQ doesn't tell us anything about it */ gcaps = gst_video_info_to_caps (&vinfo); GST_LOG_OBJECT (src, "the camera caps are %" GST_PTR_FORMAT, gcaps); return gcaps; error: if (gcaps) { gst_caps_unref (gcaps); } return NULL; }
/** * gst_niimaqsrc_class_probe_interfaces: * @klass: #GstNiImaqClass * @check: whether to enumerate interfaces * * Probes NI-IMAQ driver for available interfaces * * Returns: TRUE always */ static gboolean gst_niimaqsrc_class_probe_interfaces (GstNiImaqSrcClass * klass, gboolean check) { if (!check) { guint32 n; gchar name[256]; /* clear interface list */ while (interfaces) { gchar *iface = interfaces->data; interfaces = g_list_remove (interfaces, iface); g_free (iface); } GST_LOG_OBJECT (klass, "About to probe for IMAQ interfaces"); /* enumerate interfaces, limiting ourselves to the first 64 */ for (n = 0; n < 64; n++) { guint32 iid; guint32 nports; guint32 port; gchar *iname; uInt32 rval; /* get interface names until there are no more */ if (rval = imgInterfaceQueryNames (n, name) != 0) { gst_niimaqsrc_report_imaq_error (rval); break; } /* ignore NICFGen */ if (g_strcmp0 (name, "NICFGen.iid") == 0) continue; /* try and open the interface */ if (rval = imgInterfaceOpen (name, &iid) != 0) { gst_niimaqsrc_report_imaq_error (rval); continue; } /* find how many ports the interface provides */ rval = imgGetAttribute (iid, IMG_ATTR_NUM_PORTS, &nports); gst_niimaqsrc_report_imaq_error (rval); rval = imgClose (iid, TRUE); gst_niimaqsrc_report_imaq_error (rval); /* iterate over all the available ports */ for (port = 0; port < nports; port++) { /* if the there are multiple ports append the port number */ if (nports > 1) iname = g_strdup_printf ("%s::%d", name, port); else iname = g_strdup (name); /* TODO: should check to see if a camera is actually attached */ interfaces = g_list_append (interfaces, iname); GST_DEBUG_OBJECT (klass, "Adding interface '%s' to list", iname); } } init = TRUE; } klass->interfaces = interfaces; return init; }