Revision: 8042
http://playerstage.svn.sourceforge.net/playerstage/?rev=8042&view=rev
Author: thjc
Date: 2009-07-16 19:50:26 +0000 (Thu, 16 Jul 2009)
Log Message:
-----------
applied patch 2805687
fixes to camera1394 driver
Modified Paths:
--------------
code/player/branches/release-2-1-patches/acinclude.m4
code/player/branches/release-2-1-patches/server/drivers/camera/1394/camera1394.cc
Modified: code/player/branches/release-2-1-patches/acinclude.m4
===================================================================
--- code/player/branches/release-2-1-patches/acinclude.m4 2009-07-16
19:35:01 UTC (rev 8041)
+++ code/player/branches/release-2-1-patches/acinclude.m4 2009-07-16
19:50:26 UTC (rev 8042)
@@ -169,6 +169,13 @@
dnl to see what the function signatures look like
dc1394_dma_setup_args="0"
AC_CHECK_LIB(raw1394,main)
+
+linux_dc1394="0"
+AC_CHECK_HEADER(
+ dc1394/linux/control.h,
+ linux_dc1394="1",[],
+ [[#include <dc1394/dc1394.h>]])
+
AC_CHECK_HEADER(dc1394/control.h,
[dc1394_dma_setup_args="20"
AC_CHECK_HEADER(
@@ -194,6 +201,9 @@
AC_DEFINE_UNQUOTED(DC1394_DMA_SETUP_CAPTURE_ARGS, $dc1394_dma_setup_args,
[arg count for dma capture function])
+AC_DEFINE_UNQUOTED(DC1394_2_LINUX, $linux_dc1394,
+ [using dc1394 v2 with Linux])
+
PLAYER_ADD_DRIVER([cameracompress],[yes],[jpeglib.h],[],[-ljpeg])
Modified:
code/player/branches/release-2-1-patches/server/drivers/camera/1394/camera1394.cc
===================================================================
---
code/player/branches/release-2-1-patches/server/drivers/camera/1394/camera1394.cc
2009-07-16 19:35:01 UTC (rev 8041)
+++
code/player/branches/release-2-1-patches/server/drivers/camera/1394/camera1394.cc
2009-07-16 19:50:26 UTC (rev 8042)
@@ -53,9 +53,19 @@
@par Configuration file options
+- guid (string [16 digits])
+ - Default: None
+ - The GUID of the 1394 camera to use (only for libdc1394 >= 2.0)
+ - Example: guid "0800460200060121"
+ - Currently, if using libdc1394 >= 2.0
+ - You should probably use GUID if you are on port > 0
+ - To get GUID, run Player once with no GUID and look at the .player log
file for the GUID of detected cameras.
+ - Using GUID lets you plug the camera into any Firewire connection on the
machine.
+
- port (integer)
- Default: 0
- - The 1394 port the camera is attached to.
+ - The 1394 port the camera is attached to.
+ - v2 of the dc1394 API no longer supports ports other than 0. If your
camera is on a port > 0, and you are on Linux, you probably have
/usr/include/dc1394/linux/control.h, which should allow you to use ports > 0
(if this file was detected during ./configure). Otherwise, use the GUID of the
camera.
- node (integer)
- Default: 0
@@ -134,7 +144,8 @@
- whitebalance (string)
- Default: None
- - Sets the manual camera white balance setting. Only valid option:
+ - Sets the manual camera white balance setting. Valid modes are:
+ - "auto" (only for dc1394 v2)
- a string containing two suitable blue and red value unsigned integers
- dma_buffers
@@ -183,6 +194,16 @@
#include <libplayercore/playercore.h>
#include <libplayercore/error.h>
+#if DC1394_2_LINUX == 1
+
+extern "C" {
+#include <dc1394/linux/control.h>
+ void get_port(dc1394camera_t* camera, uint& cam_port){
+ dc1394_camera_get_linux_port(camera, &cam_port);
+ }
+}
+#endif
+
// for color and format conversion (located in cmvision)
#include "conversions.h"
@@ -316,6 +337,8 @@
// Video device
private: unsigned int port;
private: unsigned int node;
+ private: char guid[1024];
+ private: bool use_guid;
#ifdef HAVE_LIBRAW1394
private: raw1394handle_t handle;
@@ -369,7 +392,7 @@
// Camera settings
private: bool setBrightness, setExposure, setWhiteBalance, setShutter,
setGain;
- private: bool autoBrightness, autoExposure, autoShutter, autoGain;
+ private: bool autoBrightness, autoExposure, autoWhiteBalance, autoShutter,
autoGain;
private: unsigned int brightness, exposure, redBalance, blueBalance,
shutter, gain;
};
@@ -407,6 +430,16 @@
#endif
this->method = methodNone;
+ const char* str;
+ // The guid of the camera
+ str = cf->ReadString(section, "guid", "NONE");
+ this->use_guid=false;
+ if (strcmp(str,"NONE"))
+ {
+ use_guid=true;
+ strcpy(this->guid,str);
+ }
+
// The port the camera is attached to
this->port = cf->ReadInt(section, "port", 0);
@@ -434,7 +467,6 @@
// Image size. This determines the capture resolution. There are a limited
// number of options available. At 640x480, a camera can capture at
// _RGB or _MONO or _MONO16.
- const char* str;
str = cf->ReadString(section, "mode", "640x480_yuv422");
/*
if (0==strcmp(str,"160x120_yuv444"))
@@ -650,12 +682,24 @@
str = cf->ReadString(section, "whitebalance", "NONE");
if (strcmp(str,"NONE"))
{
- if(sscanf(str,"%u %u",&this->blueBalance,&this->redBalance)==2)
- this->setWhiteBalance=true;
+ if (!strcmp(str,"auto"))
+ {
+#if LIBDC1394_VERSION == 0200
+ this->setWhiteBalance=true;
+ this->autoWhiteBalance=true;
+#else
+ this->setWhiteBalance=false;
+#endif
+ }
else
- PLAYER_ERROR1("didn't understand white balance values [%s]", str);
+ {
+ this->autoWhiteBalance=false;
+ if(sscanf(str,"%u %u",&this->blueBalance,&this->redBalance)==2)
+ this->setWhiteBalance=true;
+ else
+ PLAYER_ERROR1("didn't understand white balance values [%s]",
str);
+ }
}
-
// Force into raw mode
this->forceRaw = cf->ReadInt(section, "force_raw", 0);
@@ -719,8 +763,7 @@
//dc1394_release_camera(this->camera);
break;
case methodVideo:
- //dc1394_dma_unlisten(this->camera);
- //dc1394_dma_release_camera(this->camera);
+ dc1394_capture_stop(this->camera);
break;
}
dc1394_camera_free(this->camera);
@@ -771,41 +814,90 @@
int err;
dc1394_t *d;
dc1394camera_list_t *list;
-
+
d = dc1394_new ();
err = dc1394_camera_enumerate (d, &list);
if (err != DC1394_SUCCESS)
- {
- PLAYER_ERROR1("Could not get Camera List: %d\n", err);
- return -1;
- }
-
+ {
+ PLAYER_ERROR1("Could not get Camera List: %d\n", err);
+ return -1;
+ }
+
if (list->num == 0)
- {
- PLAYER_ERROR("No cameras found");
- return -1;
- }
+ {
+ PLAYER_ERROR("No cameras found");
+ return -1;
+ }
+
+ char* temp=(char*)malloc(1024*sizeof(char));
+ for (unsigned i=0; i < list->num; i++)
+ {
+ uint32_t camNode, camGeneration;
+
+ // Create a camera
+ this->camera = dc1394_camera_new (d, list->ids[i].guid);
+ if (!camera)
+ PLAYER_ERROR1("Failed to initialize camera with guid %016llx",
+ list->ids[i].guid);
+ else PLAYER_MSG1(2,"Found camera with GUID %016llx",
+ list->ids[i].guid);
+
+ if (this->use_guid) {
+
+ quadlet_t value[3];
+
+ value[0]= camera->guid & 0xffffffff;
+ value[1]= (camera->guid >>32) & 0x000000ff;
+ value[2]= (camera->guid >>40) & 0xfffff;
+
+ sprintf(temp,"%06x%02x%08x", value[2], value[1], value[0]);
+
+ PLAYER_MSG2(5,"Comparing %s to %s",this->guid,temp);
+ if (strcmp(temp,this->guid)==0)
+ break;
+ }
+ else
+ {
+ // Get the node of the camera
+ dc1394_camera_get_node(this->camera, &camNode, &camGeneration);
+
+ // Make sure we have the correct camera
+ if (camNode == this->node)
+#if DC1394_2_LINUX == 1
+ {
+ unsigned int cam_port=99;
+ get_port(this->camera, cam_port);
+ if (cam_port == this->port)
+ break;
+ }
+#else
+ break;
+#endif
+ }
+ this->SafeCleanup();
+ }
+ free (temp);
+ dc1394_camera_free_list (list);
- // we just use the first one returned and then free the rest
- camera = dc1394_camera_new (d, list->ids[0].guid);
-
if (!camera)
- {
- PLAYER_ERROR1("Failed to initialize camera with guid %llx",
- list->ids[0].guid);
- this->SafeCleanup();
- return -1;
- }
-
- dc1394_camera_free_list (list);
-
- //dc1394_cleanup_iso_channels_and_bandwidth(camera);
- /* Above has been removed from API. */
-
+ {
+ if (this->use_guid)
+ PLAYER_ERROR1("Could not find camera with guid %s",
+ this->guid);
+ else
+#if DC1394_2_LINUX == 1
+ PLAYER_ERROR2("Could not find camera with node %d, port %d",
+ this->node, this->port);
#else
+ PLAYER_ERROR("On this system, you cannot specify a node/port. You
should specify the GUID of the camera.");
+#endif
+ return -1;
+ }
+
+#else
this->handle = dc1394_create_handle(this->port);
if (this->handle == NULL)
- {
+ {
PLAYER_ERROR("Unable to acquire a dc1394 handle");
this->SafeCleanup();
return -1;
@@ -815,6 +907,7 @@
this->camera.port = this->port;
#endif
+
// apply user config file provided camera settings
if (this->setBrightness)
{
@@ -906,7 +999,7 @@
this->SafeCleanup();
return -1;
}
- if (!this->autoShutter)
+ if (!this->autoGain)
{
#if LIBDC1394_VERSION == 0200
if (DC1394_SUCCESS != dc1394_feature_set_value(this->camera,
FEATURE_GAIN,this->gain))
@@ -923,7 +1016,14 @@
if (this->setWhiteBalance)
{
#if LIBDC1394_VERSION == 0200
- if (DC1394_SUCCESS !=
dc1394_feature_whitebalance_set_value(this->camera,this->blueBalance,this->redBalance))
+ if (DC1394_SUCCESS != dc1394_feature_set_mode(this->camera,
FEATURE_WHITE_BALANCE,this->autoWhiteBalance ? DC1394_FEATURE_MODE_AUTO :
DC1394_FEATURE_MODE_MANUAL))
+ {
+ PLAYER_ERROR("Unable to set White Balance mode");
+ this->SafeCleanup();
+ return -1;
+ }
+ if (!this->autoWhiteBalance)
+ if (DC1394_SUCCESS !=
dc1394_feature_whitebalance_set_value(this->camera,this->blueBalance,this->redBalance))
#else
if (DC1394_SUCCESS != dc1394_set_white_balance(this->handle,
this->camera.node,this->blueBalance,this->redBalance))
#endif
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit