I am attempting to update the ofxVideoGrabberPtgrey addon to work with openFrameworks 0.8.4. I first tried with Windows 8.1, then with Ubuntu 15.04. I essentially got the same error on both. I am now focused on making it work with Codeblocks under Ubuntu. I feel if I could get help solving one of the Undefined Reference problems I could do the rest on my own. Though I am not the most knowledgeable about addon development, I believe what is happening is that it isn’t compiling in the correct order. Even though I can find the declaration by right clicking on the call in Codeblocks, it isn’t being found at the time of compiling.
Initial Error:
/of_v0.8.4_linux64_release/apps/myApps/ptGreyExample2/…/…/…/addons/ofxVideoGrabberPtgrey/src/ofxVideoGrabberDc1394.cpp|27|undefined reference to `dc1394_new’|
The error shows up first at:
driver = dc1394_new();
ofxVideograbberPtgrey Constructor (from ofxVideoGrabberDc1394.cpp):
#include "ofxVideoGrabberDc1394.h"
//--------------------------------------------------------------------
ofxVideoGrabberPtgrey::ofxVideoGrabberPtgrey(){
bIsFrameNew = false;
bVerbose = false;
bGrabberInited = false;
bUseTexture = true;
bChooseDevice = false;
deviceID = 0;
width = 320; // default setting
height = 240; // default setting
pixels = NULL;
frame = NULL;
driver = NULL;
deviceList = NULL;
camera = NULL;
video_mode = DC1394_VIDEO_MODE_FORMAT7_1; //2x2 pixel binning
color_coding = DC1394_COLOR_CODING_MONO8;
framerate = DC1394_FRAMERATE_60;
driver = dc1394_new();
if (!driver) { return; }
err = dc1394_camera_enumerate(driver, &deviceList);
if(err){ ofLog(OF_LOG_ERROR, "Failed to enumerate cameras"); }
if( deviceList->num == 0 ) {
ofLog(OF_LOG_ERROR, "No cameras found");
}
}
The declaration of dc1394_new is in dc1394/camera.h
Full Script: Pastbin
Here is the snippet where it is defined:
typedef struct __dc1394_camera
{
/* system/firmware information */
uint64_t guid;
int unit;
uint32_t unit_spec_ID;
uint32_t unit_sw_version;
uint32_t unit_sub_sw_version;
uint32_t command_registers_base;
uint32_t unit_directory;
uint32_t unit_dependent_directory;
uint64_t advanced_features_csr;
uint64_t PIO_control_csr;
uint64_t SIO_control_csr;
uint64_t strobe_control_csr;
uint64_t format7_csr[DC1394_VIDEO_MODE_FORMAT7_NUM];
dc1394iidc_version_t iidc_version;
char * vendor;
char * model;
uint32_t vendor_id;
uint32_t model_id;
dc1394bool_t bmode_capable;
dc1394bool_t one_shot_capable;
dc1394bool_t multi_shot_capable;
dc1394bool_t can_switch_on_off;
dc1394bool_t has_vmode_error_status;
dc1394bool_t has_feature_error_status;
int max_mem_channel;
/* not used, for future use: */
uint32_t flags;
} dc1394camera_t;
/**
* A unique identifier for a functional camera unit
*
* Since a single camera can contain several functional units (think stereo cameras), the GUID is not enough to identify an IIDC camera.
* The unit number must also be used, hence this struct.
*/
typedef struct
{
uint16_t unit;
uint64_t guid;
} dc1394camera_id_t;
/**
* A list of cameras
*
* Usually returned by dc1394_camera_eumerate().
*/
typedef struct __dc1394camera_list_t
{
uint32_t num;
dc1394camera_id_t *ids;
} dc1394camera_list_t;
typedef struct __dc1394_t dc1394_t;
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************
General system functions
***************************************************************************/
/**
* Creates a new context in which cameras can be searched and used. This should be called before using any other libdc1394 function.
*/
dc1394_t* dc1394_new (void);
/**
* Liberates a context. Last function to use in your program. After this, no libdc1394 function can be used.
*/
void dc1394_free (dc1394_t *dc1394);
/**
* Sets and gets the broadcast flag of a camera. If the broadcast flag is set,
* all devices on the bus will execute the command. Useful to sync ISO start
* commands or setting a bunch of cameras at the same time. Broadcast only works
* with identical devices (brand/model). If the devices are not identical your
* mileage may vary. Some cameras may not answer broadcast commands at all. Also,
* this only works with cameras on the SAME bus (IOW, the same port).
*/
dc1394error_t dc1394_camera_set_broadcast(dc1394camera_t *camera, dc1394bool_t pwr);
dc1394error_t dc1394_camera_get_broadcast(dc1394camera_t *camera, dc1394bool_t *pwr);
/**
* Resets the IEEE1394 bus which camera is attached to. Calling this function is
* "rude" to other devices because it causes them to re-enumerate on the bus and
* may cause a temporary disruption in their current activities. Thus, use it
* sparingly. Its primary use is if a program shuts down uncleanly and needs to
* free leftover ISO channels or bandwidth. A bus reset will free those things
* as a side effect.
*/
dc1394error_t dc1394_reset_bus(dc1394camera_t *camera);
dc1394error_t dc1394_read_cycle_timer (dc1394camera_t * camera,
uint32_t * cycle_timer, uint64_t * local_time);
/**
* Gets the IEEE 1394 node ID of the camera.
*/
dc1394error_t dc1394_camera_get_node(dc1394camera_t *camera, uint32_t *node,
uint32_t * generation);
I am a new user so I cannot upload the files.
The original repository is at code.google.com/p/ofxvideograbberptgrey/
The only real changes I’ve made so far that have stuck are a couple additional OS checks so that the compiler doesn’t define the same classes and functions multiple times since there is a different approach for Windows as there is from Linux or OSX.
Here is the folder structure of the Addon in relation to the camera.h and dc1394.h files:
- ofxVideoGrabberPtgrey
- —libs
- ------dc1394
- ---------include
- ------------dc1394
- ---------------camera.h
- ---------------dc1394.h
- ---------lib
- ------FlyCapture
- —src
- ------ofxVideoGrabberDc1394.cpp
- ------ofxVideoGrabberDc1394.h
- ------ofxVideoGrabberyFlyCapture.cpp
- ------ofxVideoGrabberyFlyCapture.h
- ------ofxVideoGrabberPtgrey.h
------ofxVideoGrabberyFlyCapture.cpp
Let me know if there is any further information I could add to better help diagnose my issue. Thanks for your time.
*****Edit
I have also been trying to implement the changes the googlecode page suggests for oF 0.06 .cbp files. However, the structure seems different and I am not sure where to put these.
Howto setup an Example project in Linux code::blocks
These step-by-step instructions are based on OpenFrameworks 0.06. Starting from a working example project might be the easiest. As a fallback here are the steps to make any oF project a ofxVideoGrabberPtgrey project.
take a OpenFrameworks Example and modify it
open .cbp project file in a text editor
under the general <Compiler> add
<Add directory="../../../addons/ofxVideoGrabberPtgrey/libs/dc1394/include" />
<Add directory="../../../addons/ofxVideoGrabberPtgrey/src" />
under the general <Linker> add
<Add library="../../../addons/ofxVideoGrabberPtgrey/libs/dc1394/lib/linux/libdc1394.a" />
under '<Option virtualFolders=' add
'addons/ofxVideoGrabberPtgrey/src/'
In the <Unit> list add
<Unit filename="../../../addons/ofxVideoGrabberPtgrey/src/ofxVideoGrabberDc1394.cpp"> <Option virtualFolder="addons/ofxVideoGrabberPtgrey/src" /> </Unit>
<Unit filename="../../../addons/ofxVideoGrabberPtgrey/src/ofxVideoGrabberDc1394.h"> <Option virtualFolder="addons/ofxVideoGrabberPtgrey/src" /> </Unit>
<Unit filename="../../../addons/ofxVideoGrabberPtgrey/src/ofxVideoGrabberPtgrey.h"> <Option virtualFolder="addons/ofxVideoGrabberPtgrey/src" /> </Unit>
Pastebin: Full .cbp file.