Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Applied kinect support patch.

  • Loading branch information...
commit 2f1416c09a6ec2af20ed5e8c5164dd1a2e7a2eaa 1 parent 68450d0
@avin2 authored
Showing with 1,793 additions and 146 deletions.
  1. 0  Data/{GlobalDefaults.ini → GlobalDefaultsKinect.ini}
  2. +66 −0 OpenNI/Data/SamplesConfig.xml
  3. +2 −1  Platform/Linux/Build/Utils/XnSensorServer/Makefile
  4. +2 −2 Platform/Linux/Build/XnDeviceSensorV2/Makefile
  5. +4 −2 Platform/Linux/CreateRedist/RedistMaker
  6. +17 −3 Platform/Linux/CreateRedist/install.sh
  7. +4 −0 Platform/Linux/Install/55-primesense-usb.rules
  8. +2 −0  Platform/Linux/Install/blacklist-gspca-kinect.conf
  9. +4 −4 Platform/Win32/Build/Utils/XnSensorServer/XnSensorServer.vcproj
  10. +2 −2 Platform/Win32/Build/XnDeviceSensorV2/XnDeviceSensorV2.vcproj
  11. +29 −10 Platform/Win32/CreateRedist/EE_NI/EE_NI.wxs
  12. +53 −3 Platform/Win32/CreateRedist/EE_NI/Fragments/BinariesFragment.wxs
  13. +8 −5 Platform/Win32/CreateRedist/EE_NI/Includes/EENIVariables.wxi
  14. +47 −0 Platform/Win32/CreateRedist/EE_NI/Includes/EENIVariables.wxi.bak
  15. +2 −1  Platform/Win32/CreateRedist/EE_NI/Lang/en-us/Loc_en-us.wxl
  16. +22 −0 Platform/Win32/CreateRedist/Redist.py
  17. BIN  Platform/Win32/Driver/amd64/WdfCoInstaller01009.dll
  18. BIN  Platform/Win32/Driver/amd64/psdrv3.sys
  19. BIN  Platform/Win32/Driver/dpinst-amd64.exe
  20. BIN  Platform/Win32/Driver/dpinst-x86.exe
  21. +16 −0 Platform/Win32/Driver/dpinst.xml
  22. BIN  Platform/Win32/Driver/psdrv3.cat
  23. BIN  Platform/Win32/Driver/psdrv3.ico
  24. +181 −0 Platform/Win32/Driver/psdrv3.inf
  25. BIN  Platform/Win32/Driver/x86/WdfCoInstaller01009.dll
  26. BIN  Platform/Win32/Driver/x86/psdrv3.sys
  27. +88 −0 README
  28. +1,193 −87 Source/XnDeviceSensorV2/Bayer.cpp
  29. +2 −1  Source/XnDeviceSensorV2/XnDataProcessor.h
  30. +3 −2 Source/XnDeviceSensorV2/XnDeviceSensor.h
  31. +7 −5 Source/XnDeviceSensorV2/XnDeviceSensorIO.cpp
  32. +3 −1 Source/XnDeviceSensorV2/XnDeviceSensorProtocol.h
  33. +9 −0 Source/XnDeviceSensorV2/XnFirmwareStreams.cpp
  34. +7 −0 Source/XnDeviceSensorV2/XnHostProtocol.cpp
  35. +3 −2 Source/XnDeviceSensorV2/XnHostProtocol.h
  36. +2 −1  Source/XnDeviceSensorV2/XnSensor.cpp
  37. +5 −0 Source/XnDeviceSensorV2/XnSensorDepthStream.cpp
  38. +5 −9 Source/XnDeviceSensorV2/XnSensorDepthStream.h
  39. +2 −3 Source/XnDeviceSensorV2/XnSensorFirmwareParams.cpp
  40. +3 −2 Source/XnDeviceSensorV2/XnSensorImageStream.h
View
0  Data/GlobalDefaults.ini → Data/GlobalDefaultsKinect.ini
File renamed without changes
View
66 OpenNI/Data/SamplesConfig.xml
@@ -0,0 +1,66 @@
+<OpenNI>
+ <Licenses>
+ <!-- Add licenses here
+ <License vendor="vendor" key="key"/>
+ -->
+ </Licenses>
+ <Log writeToConsole="false" writeToFile="false">
+ <!-- 0 - Verbose, 1 - Info, 2 - Warning, 3 - Error (default) -->
+ <LogLevel value="3"/>
+ <Masks>
+ <Mask name="ALL" on="true"/>
+ </Masks>
+ <Dumps>
+ </Dumps>
+ </Log>
+ <ProductionNodes>
+ <!-- Normal Depth -->
+ <Node type="Depth" name="Depth1">
+ <Configuration>
+ <Mirror on="true"/>
+ </Configuration>
+ </Node>
+
+ <!-- Normal Image -->
+ <Node type="Image" name="Image1" stopOnError="false">
+ <Configuration>
+ <Mirror on="true"/>
+ </Configuration>
+ </Node>
+
+ <!-- HighRes Image -->
+ <!--
+ <Node type="Image" name="Image1" stopOnError="false">
+ <Configuration>
+ <MapOutputMode xRes="1280" yRes="1024" FPS="15"/>
+ <Mirror on="true"/>
+ </Configuration>
+ </Node>
+ -->
+
+ <!-- Normal IR -->
+ <!--
+ <Node type="IR" name="IR1">
+ <Configuration>
+ <MapOutputMode xRes="640" yRes="480" FPS="30"/>
+ <Mirror on="true"/>
+ </Configuration>
+ </Node>
+ -->
+
+ <!-- HighRes IR -->
+ <!--
+ <Node type="IR" name="IR1">
+ <Configuration>
+ <MapOutputMode xRes="1280" yRes="1024" FPS="15"/>
+ <Mirror on="true"/>
+ </Configuration>
+ </Node>
+ -->
+
+ <!--
+ <Node type="Audio" name="Audio1">
+ </Node>
+ -->
+ </ProductionNodes>
+</OpenNI>
View
3  Platform/Linux/Build/Utils/XnSensorServer/Makefile
@@ -1,7 +1,8 @@
SRC_FILES = ../../../../../Source/Utils/XnSensorServer/*.cpp
EXE_NAME = XnSensorServer
-USED_LIBS = OpenNI XnCore XnFormats XnDDK XnDeviceSensorV2
+#--avin mod--
+USED_LIBS = OpenNI XnCore XnFormats XnDDK XnDeviceSensorV2KM
include ../EngineUtilMakefile
View
4 Platform/Linux/Build/XnDeviceSensorV2/Makefile
@@ -1,7 +1,7 @@
SRC_FILES = \
../../../../Source/XnDeviceSensorV2/*.cpp
-
-LIB_NAME = XnDeviceSensorV2
+#--avin mod--
+LIB_NAME = XnDeviceSensorV2KM
USED_LIBS = XnCore XnFormats XnDDK OpenNI
DEFINES = XN_DEVICE_EXPORTS
View
6 Platform/Linux/CreateRedist/RedistMaker
@@ -80,7 +80,8 @@ mkdir -p ../$REDIST_DIR/Config
# copy files to redist
cp ../../../GPL.txt ../$REDIST_DIR
cp ../../../LGPL.txt ../$REDIST_DIR
-cp ../Bin/$PLATFORM-Release/libXnDeviceSensorV2.* ../$REDIST_DIR/Lib
+#--avin mod--
+cp ../Bin/$PLATFORM-Release/libXnDeviceSensorV2KM.* ../$REDIST_DIR/Lib
cp ../Bin/$PLATFORM-Release/libXnDeviceFile.* ../$REDIST_DIR/Lib
cp ../Bin/$PLATFORM-Release/libXnDDK.* ../$REDIST_DIR/Lib
cp ../Bin/$PLATFORM-Release/libXnFormats.* ../$REDIST_DIR/Lib
@@ -89,7 +90,8 @@ cp ../Bin/$PLATFORM-Release/XnSensorServer ../$REDIST_DIR/Bin
cp ../Install/* ../$REDIST_DIR/Install
cp install.sh ../$REDIST_DIR
-cp ../../../Data/GlobalDefaults.ini ../$REDIST_DIR/Config
+#--avin mod--
+cp ../../../Data/GlobalDefaultsKinect.ini ../$REDIST_DIR/Config
# create tar
echo "Creating tar..."
View
20 Platform/Linux/CreateRedist/install.sh
@@ -16,16 +16,19 @@ Installs PrimeSense Sensor Driver to current machine.
OS_NAME=`uname -s`
+#--avin mod--
case $OS_NAME in
Darwin)
- MODULES="libXnDeviceSensorV2.dylib libXnDeviceFile.dylib"
+ MODULES="libXnDeviceSensorV2KM.dylib libXnDeviceFile.dylib"
;;
*)
- MODULES="libXnDeviceSensorV2.so libXnDeviceFile.so"
+ MODULES="libXnDeviceSensorV2KM.so libXnDeviceFile.so"
;;
esac
RULES_FILE="55-primesense-usb.rules"
+#--avin mod--
+MODPROBE_BLACKLIST="blacklist-gspca-kinect.conf"
# create file list
SCRIPT_DIR=`pwd`/`dirname $0`
@@ -75,6 +78,8 @@ INSTALL_BIN=$rootfs/usr/bin
INSTALL_ETC=$rootfs/usr/etc/primesense
INSTALL_RULES=$rootfs/etc/udev/rules.d
SERVER_LOGS_DIR=$rootfs/var/log/primesense/XnSensorServer
+#--avin mod--
+MODPROBE_CONF_DIR=$rootfs/etc/modprobe.d
# make all calls into OpenNI run in this filesystem
export OPEN_NI_INSTALL_PATH=$rootfs
@@ -109,7 +114,8 @@ if [ "$install" = yes ]; then
# copy config file
printf "copying server config file..."
- cp Config/GlobalDefaults.ini $INSTALL_ETC
+#--avin mod--
+ cp Config/GlobalDefaultsKinect.ini $INSTALL_ETC
printf "OK\n"
# make server run as root
@@ -130,6 +136,10 @@ if [ "$install" = yes ]; then
printf "installing usb rules..."
cp Install/$RULES_FILE $INSTALL_RULES
printf "OK\n"
+ #--avin mod--
+ printf "installing modprobe blacklist..."
+ cp Install/$MODPROBE_BLACKLIST $MODPROBE_CONF_DIR
+ printf "OK\n"
fi
printf "\n*** DONE ***\n\n"
@@ -171,6 +181,10 @@ elif [ "$uninstall" = yes ]; then
printf "removing usb rules..."
rm -f $INSTALL_RULES/$RULES_FILE
printf "OK\n"
+ #--avin mod--
+ printf "removing modprobe blacklist..."
+ rm -f $MODPROBE_CONF_DIR/$MODPROBE_BLACKLIST
+ printf "OK\n"
fi
printf "\n*** DONE ***\n\n"
View
4 Platform/Linux/Install/55-primesense-usb.rules
@@ -5,4 +5,8 @@ SYSFS{idProduct}=="0400",SYSFS{idVendor}=="1d27",MODE="666",OWNER="xxx",GROUP="u
SYSFS{idProduct}=="0500",SYSFS{idVendor}=="1d27",MODE="666",OWNER="xxx",GROUP="users"
SYSFS{idProduct}=="0600",SYSFS{idVendor}=="1d27",MODE="666",OWNER="xxx",GROUP="users"
SYSFS{idProduct}=="0601",SYSFS{idVendor}=="1d27",MODE="666",OWNER="xxx",GROUP="users"
+#--avin mod--
+SYSFS{idProduct}=="02AE",SYSFS{idVendor}=="045E",MODE="666",OWNER="xxx",GROUP="users"
+SYSFS{idProduct}=="02AD",SYSFS{idVendor}=="045E",MODE="666",OWNER="xxx",GROUP="users"
+SYSFS{idProduct}=="02B0",SYSFS{idVendor}=="045E",MODE="666",OWNER="xxx",GROUP="users"
View
2  Platform/Linux/Install/blacklist-gspca-kinect.conf
@@ -0,0 +1,2 @@
+blacklist gspca_kinect
+
View
8 Platform/Win32/Build/Utils/XnSensorServer/XnSensorServer.vcproj
@@ -66,7 +66,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="openNI.lib XnDDK.lib XnDeviceSensorV2.lib XnFormats.lib "
+ AdditionalDependencies="openNI.lib XnDDK.lib XnDeviceSensorV2KM.lib XnFormats.lib "
OutputFile="../../../Bin/$(ConfigurationName)/$(ProjectName).exe"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(OPEN_NI_LIB)&quot;;../../../Lib/$(ConfigurationName)"
@@ -145,7 +145,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="openNI64.lib XnDDK64.lib XnDeviceSensorV264.lib XnFormats64.lib "
+ AdditionalDependencies="openNI64.lib XnDDK64.lib XnDeviceSensorV2KM64.lib XnFormats64.lib "
OutputFile="../../../Bin64/$(ConfigurationName)/$(ProjectName)64.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(OPEN_NI_LIB64)&quot;;../../../Lib64/$(ConfigurationName)"
@@ -232,7 +232,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="openNI.lib XnDDK.lib XnDeviceSensorV2.lib XnFormats.lib "
+ AdditionalDependencies="openNI.lib XnDDK.lib XnDeviceSensorV2KM.lib XnFormats.lib "
OutputFile="../../../Bin/$(ConfigurationName)/$(ProjectName).exe"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(OPEN_NI_LIB)&quot;;../../../Lib/$(ConfigurationName)"
@@ -320,7 +320,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="openNI64.lib XnDDK64.lib XnDeviceSensorV264.lib XnFormats64.lib "
+ AdditionalDependencies="openNI64.lib XnDDK64.lib XnDeviceSensorV2KM64.lib XnFormats64.lib "
OutputFile="../../../Bin64/$(ConfigurationName)/$(ProjectName)64.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(OPEN_NI_LIB64)&quot;;../../../Lib64/$(ConfigurationName)"
View
4 Platform/Win32/Build/XnDeviceSensorV2/XnDeviceSensorV2.vcproj
@@ -2,9 +2,9 @@
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
- Name="XnDeviceSensorV2"
+ Name="XnDeviceSensorV2KM"
ProjectGUID="{1653839A-ABA5-4c0e-9EA2-2640B0275894}"
- RootNamespace="XnDeviceSensorV2"
+ RootNamespace="XnDeviceSensorV2KM"
Keyword="Win32Proj"
TargetFrameworkVersion="0"
>
View
39 Platform/Win32/CreateRedist/EE_NI/EE_NI.wxs
@@ -30,7 +30,8 @@
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.PlatformProgramFilesFolder)">
<Directory Id="PrimeSenseFolder" Name="PrimeSense">
- <Directory Id="INSTALLLOCATION" Name="Sensor">
+<!-- avin mod -->
+ <Directory Id="INSTALLLOCATION" Name="SensorKinect">
<Directory Id="INSTALLLOCATIONSAMPLES" Name="Samples">
<Directory Id="INSTALLLOCATIONSAMPLESBIN" Name="Bin$(var.PlatformSuffix)">
<Directory Id="INSTALLLOCATIONSAMPLESBINRELEASE" Name="Release">
@@ -45,7 +46,8 @@
<Directory Id="INSTALLLOCATIONBinLog" Name="Log"/>
</Directory>
<Directory Id="INSTALLLOCATIONData" Name="Data"/>
-
+<!-- avin mod -->
+ <Directory Id="INSTALLLOCATIONDriver" Name="Driver"/>
</Directory>
</Directory>
</Directory>
@@ -203,16 +205,24 @@
<Binary Id='CheckScript' SourceFile ='checkVersion.vbs' />
<CustomAction Id="CheckOpenNIVersion" BinaryKey='CheckScript' VBScriptCall='CheckVersionNI' Execute="immediate" Return="check" />
-
+
+<!-- avin mod -->
+ <!-- Install the USB Driver -->
+ <CustomAction Id='drivex86Install' Directory="INSTALLLOCATIONDriver" Return="ignore" Impersonate="no" Execute="deferred"
+ ExeCommand="&quot;[INSTALLLOCATIONDriver]dpinst-x86.exe&quot; /sw /el" />
+ <CustomAction Id='driveamd64Install' Directory="INSTALLLOCATIONDriver" Return="ignore" Impersonate="no" Execute="deferred"
+ ExeCommand="&quot;[INSTALLLOCATIONDriver]dpinst-amd64.exe&quot; /sw /el"/>
+
<!-- Register XnDeviceFile-->
<CustomAction Id="QtExecRegXnDeviceFile" Property="SetRegXnDeviceFileProperty" Execute="immediate"
Value="&quot;[OPENNIINSTALLDIR]bin$(var.PlatformSuffix)\niReg$(var.PlatformSuffix).exe&quot; &quot;[INSTALLLOCATIONBin]XnDeviceFile$(var.PlatformSuffix).dll&quot;"/>
<CustomAction Id="SetRegXnDeviceFileProperty" BinaryKey="WixCA" DllEntry="CAQuietExec$(var.PlatformSuffix)"
Execute="deferred" Return="check" Impersonate="no"/>
-
- <!-- Register XnDeviceSensorV2-->
+
+<!-- avin mod -->
+ <!-- Register XnDeviceSensorV2KM-->
<CustomAction Id="QtExecRegXnDeviceSensorV2" Property="SetRegXnDeviceSensorV2Property" Execute="immediate"
- Value="&quot;[OPENNIINSTALLDIR]bin$(var.PlatformSuffix)\niReg$(var.PlatformSuffix).exe&quot; &quot;[INSTALLLOCATIONBin]XnDeviceSensorV2$(var.PlatformSuffix).dll&quot; &quot;[INSTALLLOCATION]Data&quot;"/>
+ Value="&quot;[OPENNIINSTALLDIR]bin$(var.PlatformSuffix)\niReg$(var.PlatformSuffix).exe&quot; &quot;[INSTALLLOCATIONBin]XnDeviceSensorV2KM$(var.PlatformSuffix).dll&quot; &quot;[INSTALLLOCATION]Data&quot;"/>
<CustomAction Id="SetRegXnDeviceSensorV2Property" BinaryKey="WixCA" DllEntry="CAQuietExec$(var.PlatformSuffix)"
Execute="deferred" Return="check" Impersonate="no"/>
@@ -222,17 +232,19 @@
<CustomAction Id="SetUnRegXnDeviceFileProperty" BinaryKey="WixCA" DllEntry="CAQuietExec$(var.PlatformSuffix)"
Execute="deferred" Return="ignore" Impersonate="no"/>-->
- <!-- UnRegister XnDeviceSensorV2
+<!-- avin mod -->
+ <!-- UnRegister XnDeviceSensorV2KM
<CustomAction Id="QtExecUnRegXnDeviceSensorV2" Property="SetUnRegXnDeviceSensorV2Property" Execute="immediate"
- Value="&quot;[OPENNIINSTALLDIR]bin$(var.PlatformSuffix)\niReg$(var.PlatformSuffix).exe&quot; -u &quot;[INSTALLLOCATIONBin]XnDeviceSensorV2$(var.PlatformSuffix).dll&quot; &quot;[INSTALLLOCATION]Data&quot;" />
+ Value="&quot;[OPENNIINSTALLDIR]bin$(var.PlatformSuffix)\niReg$(var.PlatformSuffix).exe&quot; -u &quot;[INSTALLLOCATIONBin]XnDeviceSensorV2KM$(var.PlatformSuffix).dll&quot; &quot;[INSTALLLOCATION]Data&quot;" />
<CustomAction Id="SetUnRegXnDeviceSensorV2Property" BinaryKey="WixCA" DllEntry="CAQuietExec$(var.PlatformSuffix)"
Execute="deferred" Return="ignore" Impersonate="no"/>-->
+<!-- avin mod -->
<!--
<CustomAction Id='RegXnDeviceFile' Directory="INSTALLLOCATIONBin" ExeCommand="&quot;[OPENNIINSTALLDIR]bin\niReg$(var.PlatformSuffix).exe&quot; &quot;[INSTALLLOCATIONBin]XnDeviceFile$(var.PlatformSuffix).dll&quot;" Return="check" />
- <CustomAction Id='RegXnDeviceSensorV2' Directory="INSTALLLOCATIONBin" ExeCommand="&quot;[OPENNIINSTALLDIR]bin\niReg$(var.PlatformSuffix).exe&quot; &quot;[INSTALLLOCATIONBin]XnDeviceSensorV2$(var.PlatformSuffix).dll&quot; &quot;[INSTALLLOCATION]Data&quot;" Return="check" />
+ <CustomAction Id='RegXnDeviceSensorV2' Directory="INSTALLLOCATIONBin" ExeCommand="&quot;[OPENNIINSTALLDIR]bin\niReg$(var.PlatformSuffix).exe&quot; &quot;[INSTALLLOCATIONBin]XnDeviceSensorV2KM$(var.PlatformSuffix).dll&quot; &quot;[INSTALLLOCATION]Data&quot;" Return="check" />
-->
@@ -240,8 +252,9 @@
ExeCommand="&quot;[OPENNIINSTALLDIR]bin$(var.PlatformSuffix)\niReg$(var.PlatformSuffix).exe&quot; -u &quot;[INSTALLLOCATIONBin]XnDeviceFile$(var.PlatformSuffix).dll&quot;" />
+<!-- avin mod -->
<CustomAction Id='UnRegXnDeviceSensorV2' Directory="INSTALLLOCATIONBin" Return="ignore" Impersonate="no" Execute="deferred"
- ExeCommand="&quot;[OPENNIINSTALLDIR]bin$(var.PlatformSuffix)\niReg$(var.PlatformSuffix).exe&quot; -u &quot;[INSTALLLOCATIONBin]XnDeviceSensorV2$(var.PlatformSuffix).dll&quot; &quot;[INSTALLLOCATION]Data&quot;"/>
+ ExeCommand="&quot;[OPENNIINSTALLDIR]bin$(var.PlatformSuffix)\niReg$(var.PlatformSuffix).exe&quot; -u &quot;[INSTALLLOCATIONBin]XnDeviceSensorV2KM$(var.PlatformSuffix).dll&quot; &quot;[INSTALLLOCATION]Data&quot;"/>
<!-- Register the .xns file type -->
<DirectoryRef Id="TARGETDIR">
@@ -335,6 +348,12 @@
<Custom Action='UnRegXnDeviceFile' Before="RemoveFiles"> REMOVE ~= "ALL" </Custom>
<Custom Action='UnRegXnDeviceSensorV2' Before="RemoveFiles"> REMOVE ~= "ALL" </Custom>
+<!-- avin mod -->
+ <Custom Action='driveamd64Install' After='PublishProduct'><![CDATA[NOT Installed AND VersionNT64]]></Custom>
+
+ <Custom Action='drivex86Install' After='PublishProduct'><![CDATA[NOT Installed AND NOT VersionNT64]]></Custom>
+
+
</InstallExecuteSequence>
</Product>
View
56 Platform/Win32/CreateRedist/EE_NI/Fragments/BinariesFragment.wxs
@@ -21,7 +21,8 @@
<File Id="fil1AE1A78AFB768F6BE201C2F7F7BB1B76" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Bin$(var.PlatformSuffix)\XnDeviceFile$(var.PlatformSuffix).dll" />
</Component>
<Component Id="XnDeviceSensorV2" Guid="*">
- <File Id="fil9B94B798603106A9EED4994EC16B4A27" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Bin$(var.PlatformSuffix)\XnDeviceSensorV2$(var.PlatformSuffix).dll" />
+<!-- avin mod -->
+ <File Id="fil9B94B798603106A9EED4994EC16B4A27" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Bin$(var.PlatformSuffix)\XnDeviceSensorV2KM$(var.PlatformSuffix).dll" />
</Component>
<Component Id="XnFormats" Guid="*">
<File Id="fil38183B691E2EDD1B1609E37F2664DB2D" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Bin$(var.PlatformSuffix)\XnFormats$(var.PlatformSuffix).dll" />
@@ -32,9 +33,47 @@
</Directory>
<Directory Id="dir82E287C749A0533338ECB68223E0D9A9" Name="Data">
<Component Id="GlobalDefaults" Guid="*">
- <File Id="filC7C2030C8D2CE9E28311BE630BC01055" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Data\GlobalDefaults.ini" />
+<!-- avin mod -->
+ <File Id="filC7C2030C8D2CE9E28311BE630BC01055" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Data\GlobalDefaultsKinect.ini" />
</Component>
</Directory>
+<!-- avin mod -->
+ <Directory Id="dir80E123015D0DE85FDA6E8AE3782EF58C" Name="Driver">
+ <Component Id="dpinstamd64" Guid="*">
+ <File Id="fil5E7F1D7524A6D9945C6F32A897ACAB2E" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Driver\dpinst-amd64.exe" />
+ </Component>
+ <Component Id="dpinstx86" Guid="*">
+ <File Id="fil93A2B26732B731AD14F14A35992DA281" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Driver\dpinst-x86.exe" />
+ </Component>
+ <Component Id="dpinst" Guid="*">
+ <File Id="fil7AB62A2C3A9E0C1EF8875CE84BAAAEB5" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Driver\dpinst.xml" />
+ </Component>
+ <Component Id="psdrv3cat" Guid="*">
+ <File Id="filCCDC4FCEC0114768FE35A6C4393C6D45" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Driver\psdrv3.cat" />
+ </Component>
+ <Component Id="psdrv3ico" Guid="*">
+ <File Id="fil5CB44F6FBA0EA0B70742E4BAB3E6D05C" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Driver\psdrv3.ico" />
+ </Component>
+ <Component Id="psdrv3inf" Guid="*">
+ <File Id="filE8A8D41F10867D9F61C756F08D2EF120" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Driver\psdrv3.inf" />
+ </Component>
+ <Directory Id="dirA9723C179E8A0552262F479646DEE5FD" Name="amd64">
+ <Component Id="psdrv3amd64" Guid="*">
+ <File Id="fil8640AA549985C0CA97E1122B8462C1E6" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Driver\amd64\psdrv3.sys" />
+ </Component>
+ <Component Id="WdfCoInstaller01009amd64" Guid="*">
+ <File Id="fil675979718A167BEDEBEBD10BAD7EEEFF" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Driver\amd64\WdfCoInstaller01009.dll" />
+ </Component>
+ </Directory>
+ <Directory Id="dir031BC9D00AF68A07CB4CD6F1F4152B0B" Name="x86">
+ <Component Id="psdrv3x86" Guid="*">
+ <File Id="fil0E977B72965B071387B3801543E39853" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Driver\x86\psdrv3.sys" />
+ </Component>
+ <Component Id="WdfCoInstaller01009x86" Guid="*">
+ <File Id="fil59B75A5F2F9D7F5EA55D94D0290D103B" KeyPath="yes" Source="$(var.EE_NIFilesDir)\Driver\x86\WdfCoInstaller01009.dll" />
+ </Component>
+ </Directory>
+ </Directory>
</DirectoryRef>
</Fragment>
<Fragment>
@@ -48,6 +87,17 @@
<ComponentRef Id="XnFormats" />
<ComponentRef Id="XnSensorServer" />
<ComponentRef Id="GlobalDefaults" />
- </ComponentGroup>
+<!-- avin mod -->
+ <ComponentRef Id="dpinstamd64"/>
+ <ComponentRef Id="dpinstx86"/>
+ <ComponentRef Id="dpinst"/>
+ <ComponentRef Id="psdrv3cat"/>
+ <ComponentRef Id="psdrv3ico"/>
+ <ComponentRef Id="psdrv3inf"/>
+ <ComponentRef Id="psdrv3amd64"/>
+ <ComponentRef Id="WdfCoInstaller01009amd64"/>
+ <ComponentRef Id="psdrv3x86"/>
+ <ComponentRef Id="WdfCoInstaller01009x86"/>
+ </ComponentGroup>
</Fragment>
</Wix>
View
13 Platform/Win32/CreateRedist/EE_NI/Includes/EENIVariables.wxi
@@ -13,7 +13,8 @@
<!-- Full version number to display -->
<?define VersionNumber="$(var.MajorVersion).$(var.MinorVersion).$(var.MaintenanceVersion).$(var.BuildVersion)" ?>
- <?define OpenNIVersion="1.2.0.4"?>
+<!-- avin mod -->
+ <?define OpenNIVersion="1.5.4.0"?>
<!--
Path to the resources directory. resources don't really need to be included
@@ -32,14 +33,16 @@
<?define PlatformSuffix=""?>
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
<?define ProductFullName=!(loc.ProductName) $(var.VersionNumber) !(loc.ProductNameSuffix)?>
- <?define ProductShortName=Sensor?>
- <?define UpgradeCode="E00A2C0F-15EA-447c-A976-0E76AEA89EBE" ?>
+<!-- avin mod -->
+ <?define ProductShortName=SensorKinect?>
+ <?define UpgradeCode="E00A2C0F-15EA-447c-A976-1234AEA89EBE" ?>
<?else?>
<?define PlatformSuffix="64"?>
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
<?define ProductFullName=!(loc.ProductName) $(var.VersionNumber) !(loc.ProductName64Suffix)?>
- <?define ProductShortName=Sensor !(loc.ProductName64Suffix)?>
- <?define UpgradeCode="E6674B5C-6086-480c-85D5-5559F5B546DA" ?>
+<!-- avin mod -->
+ <?define ProductShortName=SensorKinect !(loc.ProductName64Suffix)?>
+ <?define UpgradeCode="E6674B5C-6086-480c-85D5-1234F5B546DA" ?>
<?endif?>
</Include>
View
47 Platform/Win32/CreateRedist/EE_NI/Includes/EENIVariables.wxi.bak
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Include>
+ <!--
+ Versioning. These have to be changed for upgrades.
+ It's not enough to just include newer files.
+ -->
+ <?define MajorVersion=5?>
+ <?define MinorVersion=1?>
+ <?define MaintenanceVersion=2?>
+ <!-- BuildVersion is NOT used by WiX in the upgrade procedure -->
+ <?define BuildVersion=1?>
+
+ <!-- Full version number to display -->
+ <?define VersionNumber="$(var.MajorVersion).$(var.MinorVersion).$(var.MaintenanceVersion).$(var.BuildVersion)" ?>
+
+ <?define OpenNIVersion="1.5.4.0"?>
+
+ <!--
+ Path to the resources directory. resources don't really need to be included
+ in the project structure but I like to include them for for clarity
+ -->
+ <?define ResourcesDir="$(var.ProjectDir)\Resources" ?>
+
+ <?define BinaryOnlyRedist=True?>
+
+ <!--
+ Upgrade code HAS to be the same for all updates.
+ Once you've chosen it don't change it.
+ -->
+
+ <?if $(var.Platform)="x86"?>
+ <?define PlatformSuffix=""?>
+ <?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
+ <?define ProductFullName=!(loc.ProductName) $(var.VersionNumber) !(loc.ProductNameSuffix)?>
+<!-- avin mod -->
+ <?define ProductShortName=SensorKinect?>
+ <?define UpgradeCode="E00A2C0F-15EA-447c-A976-1234AEA89EBE" ?>
+ <?else?>
+ <?define PlatformSuffix="64"?>
+ <?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
+ <?define ProductFullName=!(loc.ProductName) $(var.VersionNumber) !(loc.ProductName64Suffix)?>
+<!-- avin mod -->
+ <?define ProductShortName=SensorKinect !(loc.ProductName64Suffix)?>
+ <?define UpgradeCode="E6674B5C-6086-480c-85D5-1234F5B546DA" ?>
+ <?endif?>
+
+</Include>
View
3  Platform/Win32/CreateRedist/EE_NI/Lang/en-us/Loc_en-us.wxl
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization" Codepage="1252">
<String Id="LANG">1033</String>
- <String Id="ProductName">PrimeSense Sensor</String>
+<!-- avin mod -->
+ <String Id="ProductName">PrimeSense Sensor KinectMod</String>
<String Id="ProductNameSuffix">for Windows</String>
<String Id="ProductName64Suffix">for Windows 64-bit</String>
<String Id="DefaultInstallFolder">Sensor</String>
View
22 Platform/Win32/CreateRedist/Redist.py
@@ -182,6 +182,10 @@ def get_reg_values(reg_key, value_list):
# create folder structure
os.mkdir(os.path.join(REDIST_DIR, "Bin" if vc_build_bits == "32" else "Bin64"))
os.mkdir(os.path.join(REDIST_DIR, "Data"))
+#--avin mod
+os.mkdir(os.path.join(REDIST_DIR, "Driver"))
+os.mkdir(os.path.join(REDIST_DIR, "Driver", "amd64"))
+os.mkdir(os.path.join(REDIST_DIR, "Driver", "x86"))
# copy EPL
shutil.copy(os.path.join(ROOT_DIR, "..", "..", "..", "GPL.txt"), REDIST_DIR)
@@ -203,6 +207,24 @@ def get_reg_values(reg_key, value_list):
#if vc_build_bits == '64':
# print 'Finishing without creating the installer'
# exit(0)
+
+#--avin mod
+# copy driver
+DRIVER_DIR = os.path.join(ROOT_DIR, "..", "Driver")
+for file in os.listdir(DRIVER_DIR):
+ try:
+ shutil.copy(os.path.join(DRIVER_DIR, file), os.path.join(REDIST_DIR, "Driver"))
+ except IOError:
+ pass
+
+DRIVER_DIRX86 = os.path.join(ROOT_DIR, "..", "Driver", "x86")
+for file in os.listdir(DRIVER_DIRX86):
+ shutil.copy(os.path.join(DRIVER_DIRX86, file), os.path.join(REDIST_DIR, "Driver", "x86"))
+
+DRIVER_DIRAMD64 = os.path.join(ROOT_DIR, "..", "Driver", "amd64")
+for file in os.listdir(DRIVER_DIRAMD64):
+ shutil.copy(os.path.join(DRIVER_DIRAMD64, file), os.path.join(REDIST_DIR, "Driver", "amd64"))
+
# create installer
print("Creating installer...")
os.chdir(SCRIPT_DIR + "\\EE_NI")
View
BIN  Platform/Win32/Driver/amd64/WdfCoInstaller01009.dll
Binary file not shown
View
BIN  Platform/Win32/Driver/amd64/psdrv3.sys
Binary file not shown
View
BIN  Platform/Win32/Driver/dpinst-amd64.exe
Binary file not shown
View
BIN  Platform/Win32/Driver/dpinst-x86.exe
Binary file not shown
View
16 Platform/Win32/Driver/dpinst.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<dpInst>
+ <legacyMode/>
+ <enableNotListedLanguages/>
+ <language code="0x0409">
+ <dpinstTitle>PrimeSense Sensor Device Driver Installer</dpinstTitle>
+
+ <welcomeTitle>Welcome to the PrimeSense Sensor Device Driver Installer!</welcomeTitle>
+ <welcomeIntro>This wizard will walk you through updating the drivers for your PrimeSense Sensor device.</welcomeIntro>
+
+ <installHeaderTitle>Installing the software for your PrimeSense Sensor device...</installHeaderTitle>
+
+ <finishTitle>Congratulations! You have finished installing your PrimeSense Sensor device drivers!</finishTitle>
+ </language>
+ <icon>psdrv3.ico</icon>
+</dpInst>
View
BIN  Platform/Win32/Driver/psdrv3.cat
Binary file not shown
View
BIN  Platform/Win32/Driver/psdrv3.ico
Binary file not shown
View
181 Platform/Win32/Driver/psdrv3.inf
@@ -0,0 +1,181 @@
+;/****************************************************************************
+;* *
+;* PrimeSense Sensor Device Driver v3.x INF *
+;* *
+;* Author: Ziv Hendel *
+;* *
+;* Copyright (C) 2006 PrimeSense Ltd. All Rights Reserved. *
+;* *
+;* This file has been provided pursuant to a License Agreement containing *
+;* restrictions on its use. This data contains valuable trade secrets *
+;* and proprietary information of PrimeSense Inc. and is protected by law. *
+;* *
+;****************************************************************************/
+;
+; Modded by avin to support the Kinect.
+;
+
+; ================= Version section ===================
+
+[Version]
+Signature="$WINDOWS NT$"
+Class=PrimeSense
+ClassGuid={dce97d75-aef7-1980-1909-531357633222}
+Provider=%PS%
+DriverVer=02/16/2011,3.1.2.0
+CatalogFile=psdrv3.cat
+
+; ================= Class section =====================
+
+[ClassInstall32]
+Addreg=PrimeSenseClassReg
+
+[PrimeSenseClassReg]
+HKR,,,0,%ClassName%
+HKR,,Icon,,"-20"
+
+; ================= Device section =====================
+
+[DestinationDirs]
+DefaultDestDir = 12 ; Driver Dir
+
+[Manufacturer]
+%MfgName%=PrimeSense,NTx86,NTamd64
+
+[PrimeSense.NTx86]
+%USB\VID_1D27&PID_0200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0200&MI_00
+%USB\VID_1D27&PID_0200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0200
+%USB\VID_1D27&PID_0300.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0300&MI_00
+%USB\VID_1D27&PID_0300.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0300
+%USB\VID_1D27&PID_0400.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0400&MI_00
+%USB\VID_1D27&PID_0400.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0400
+%USB\VID_1D27&PID_0500.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0500&MI_00
+%USB\VID_1D27&PID_0500.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0500
+%USB\VID_1D27&PID_0600.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0600&MI_00
+%USB\VID_1D27&PID_0600.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0600
+%USB\VID_1D27&PID_0600.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0601&MI_00
+%USB\VID_1D27&PID_1280.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_1280&MI_00
+%USB\VID_1D27&PID_1280.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_1280
+%USB\VID_1D27&PID_2100.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2100&MI_00
+%USB\VID_1D27&PID_2100.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2100
+%USB\VID_1D27&PID_2200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2200&MI_00
+%USB\VID_1D27&PID_2200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2200
+%USB\VID_1D27&PID_F9DB.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_F9DB&MI_00
+%USB\VID_1D27&PID_F9DB.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_F9DB
+%USB\VID_045E&PID_02B0.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02B0&MI_00
+%USB\VID_045E&PID_02B0.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02B0
+%USB\VID_045E&PID_02AD.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AD&MI_00
+%USB\VID_045E&PID_02AD.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AD
+%USB\VID_045E&PID_02AE.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AE&MI_00
+%USB\VID_045E&PID_02AE.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AE
+
+[PrimeSense.NTamd64]
+%USB\VID_1D27&PID_0200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0200&MI_00
+%USB\VID_1D27&PID_0200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0200
+%USB\VID_1D27&PID_0300.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0300&MI_00
+%USB\VID_1D27&PID_0300.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0300
+%USB\VID_1D27&PID_0400.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0400&MI_00
+%USB\VID_1D27&PID_0400.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0400
+%USB\VID_1D27&PID_0500.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0500&MI_00
+%USB\VID_1D27&PID_0500.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0500
+%USB\VID_1D27&PID_0600.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0600&MI_00
+%USB\VID_1D27&PID_0600.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0600
+%USB\VID_1D27&PID_0600.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_0601&MI_00
+%USB\VID_1D27&PID_1280.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_1280&MI_00
+%USB\VID_1D27&PID_1280.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_1280
+%USB\VID_1D27&PID_2100.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2100&MI_00
+%USB\VID_1D27&PID_2100.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2100
+%USB\VID_1D27&PID_2200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2200&MI_00
+%USB\VID_1D27&PID_2200.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_2200
+%USB\VID_1D27&PID_F9DB.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_F9DB&MI_00
+%USB\VID_1D27&PID_F9DB.DeviceDesc%=psdrv3.Dev, USB\VID_1D27&PID_F9DB
+%USB\VID_045E&PID_02B0.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02B0&MI_00
+%USB\VID_045E&PID_02B0.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02B0
+%USB\VID_045E&PID_02AD.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AD&MI_00
+%USB\VID_045E&PID_02AD.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AD
+%USB\VID_045E&PID_02AE.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AE&MI_00
+%USB\VID_045E&PID_02AE.DeviceDesc%=psdrv3.Dev, USB\VID_045E&PID_02AE
+
+[psdrv3.Dev.NT]
+CopyFiles=psdrv3.Files.Ext
+
+[psdrv3.Dev.NT.Services]
+Addservice = psdrv3, 0x00000002, psdrv3.AddService
+
+[psdrv3.AddService]
+DisplayName = %psdrv3.SvcDesc%
+ServiceType = 1 ; SERVICE_KERNEL_DRIVER
+StartType = 3 ; SERVICE_DEMAND_START
+ErrorControl = 1 ; SERVICE_ERROR_NORMAL
+ServiceBinary = %10%\System32\Drivers\psdrv3.sys
+AddReg = psdrv3.AddReg
+LoadOrderGroup = Base
+
+[psdrv3.AddReg]
+HKR,"Parameters","MaximumTransferSize",0x10001,65536
+HKR,"Parameters","DebugLevel",0x10001,2
+HKR,"Parameters","RemovableIcon",0x10001,0
+
+[psdrv3.Files.Ext]
+psdrv3.sys
+
+[SourceDisksNames.x86]
+1=%Disk_Description%,,,\x86
+
+[SourceDisksNames.amd64]
+2=%Disk_Description%,,,\amd64
+
+[SourceDisksFiles.x86]
+psdrv3.sys = 1
+
+[SourceDisksFiles.amd64]
+psdrv3.sys = 2
+
+; ================= WDF section =====================
+
+[DestinationDirs]
+CoInstaller_CopyFiles = 11 ; System Dir
+
+[psdrv3.Dev.NT.CoInstallers]
+AddReg=CoInstaller_AddReg
+CopyFiles=CoInstaller_CopyFiles
+
+[CoInstaller_CopyFiles]
+WdfCoInstaller01009.dll
+
+[SourceDisksFiles.x86]
+WdfCoInstaller01009.dll=1
+
+[SourceDisksFiles.amd64]
+WdfCoInstaller01009.dll=2
+
+[CoInstaller_AddReg]
+HKR,,CoInstallers32,0x00010000, "WdfCoInstaller01009.dll,WdfCoInstaller"
+
+[psdrv3.Dev.NT.Wdf]
+KmdfService = psdrv3, psdrv3_wdfsect
+
+[psdrv3_wdfsect]
+KmdfLibraryVersion = 1.9
+
+; ================= Strings section =====================
+
+[Strings]
+PS = "PrimeSense"
+MfgName = "PrimeSense Ltd."
+Disk_Description= "PrimeSense Sensor Device Driver Installation Disk v3.x"
+psdrv3.SvcDesc = "PrimeSense Sensor Device Driver Service v3.x"
+ClassName = "PrimeSense"
+USB\VID_1D27&PID_0200.DeviceDesc="PrimeSense Sensor Development Kit 2.x"
+USB\VID_1D27&PID_0300.DeviceDesc="PrimeSense Sensor Development Kit 3.x"
+USB\VID_1D27&PID_0400.DeviceDesc="PrimeSense Sensor Development Kit 4.x"
+USB\VID_1D27&PID_0500.DeviceDesc="PrimeSense Sensor Development Kit 5.x"
+USB\VID_1D27&PID_0600.DeviceDesc="PrimeSense PS1080"
+USB\VID_1D27&PID_0601.DeviceDesc="PrimeSense PS1080"
+USB\VID_1D27&PID_1280.DeviceDesc="PrimeSense RD 1.28"
+USB\VID_1D27&PID_2100.DeviceDesc="PrimeSense Sensor Development Kit NG 2100"
+USB\VID_1D27&PID_2200.DeviceDesc="PrimeSense Sensor Development Kit NG 2200"
+USB\VID_1D27&PID_F9DB.DeviceDesc="PrimeSense Sensor Development Kit NG Debug"
+USB\VID_045E&PID_02B0.DeviceDesc="Kinect Motor"
+USB\VID_045E&PID_02AD.DeviceDesc="Kinect Audio"
+USB\VID_045E&PID_02AE.DeviceDesc="Kinect Camera"
View
BIN  Platform/Win32/Driver/x86/WdfCoInstaller01009.dll
Binary file not shown
View
BIN  Platform/Win32/Driver/x86/psdrv3.sys
Binary file not shown
View
88 README
@@ -1,6 +1,94 @@
PrimeSense Sensor Module for OpenNI (Version 5.1.2.1 - May 15th 2012)
---------------------------------------------------------------------
+Kinect Mod:
+-----------
+
+***** Important notice: *****
+You must use this kinect mod version with the unstable OpenNI release which is available at:
+http://www.openni.org/Downloads/OpenNIModules.aspx
+
+Changes:
+v0.92:
+ 1) Updated codebase to the latest OpenNI / Sensor version (1.5.4.0 / 5.1.2.1)
+
+v0.91:
+ 1) Removed an unnecessary USB set interface command that caused timeout problems on Linux & Mac.
+
+v0.9:
+ 1) Updated codebase to the latest OpenNI / Sensor version (1.5.2.7 / 5.1.0.25)
+ 2) Changed the Bayer-to-RGB function to use the ROS (www.ros.org) code as requested by many community members.
+ (Thanks to Suat Gedikli from Willow Garage for writing the code and to Raphael Dumusc for the OpenNI adaptation!)
+
+v0.8:
+ 1) Updated codebase to the latest OpenNI / Sensor version (1.4.0.2 / 5.0.5.1)
+
+v0.7:
+ 1) Updated codebase to the latest OpenNI / Sensor version (1.3.2.3 / 5.0.3.34)
+ 2) Added a 64-bit binary installer for Windows.
+
+v0.6:
+ 1) Updated codebase to the latest OpenNI / Sensor version (1.3.2.1 / 5.0.3.33)
+
+v0.5:
+ 1) Updated codebase to the latest OpenNI / Sensor version (1.1.0.39 / 5.0.1.32)
+ 2) Changed to install directory from Sensor to SensorKinect to co-exist with the original PrimeSense Sensor module.
+
+v0.4:
+ 1) Merged code with the new unstable sensor driver from PrimeSense that adds MacOSX and multiple sensor support.
+ 2) Added precompiled binaries for Linux & MacOSX.
+
+v0.3:
+ 1) Added support for high-res 1280x1024 IR and Image (at ~10 FPS)
+ Checkout the file OPENNI\Data\SamplesConfig.xml for usage example.
+ (Copy it to your OpenNI\Data dir and use NiViewer to test the different resolutions)
+
+v0.2:
+ 1) VS2010 redist will now be installed automatically.
+ 2) The driver will now also be installed automatically on both x86 and x64 machines.
+ 3) Turned off the IR projector anti-cover thingy. It is off on the Xbox360 so it must be safe and it was very annoying...
+
+v0.1:
+ 1) Added the kinect USB VID/PID to the PSDrv3 driver and to the code.
+ 2) Changed the packet sequence field from 16-bit to 8-bit (don't know why it's different...)
+ 3) Changed the image format from YUV to 8-bit uncompressed bayer in the GlobalDefaults.ini file.
+ 4) Fixed the software depth-to-RGB registration. (Thanks ROS.org for that!)
+
+Install notes:
+ 1) Install unstable OpenNI (http://www.openni.org/Downloads/OpenNIModules.aspx)
+ On Linux/Mac please do: ./sudo install.sh
+ 2) Install Sensor (this version...)
+ On Linux/Mac please do: ./sudo install.sh
+ 3) Install unstable NITE (http://www.openni.org/Downloads/OpenNIModules.aspx)
+ On Linux/Mac please do: ./sudo install.sh
+ 4) Test #1: Run the NiViewer sample to make sure depth & image streams are working.
+ 5) Test #2: Run the OpenNI/NiUserTracker sample play with the skeleton.
+ 6) Test #3: Try the NITE/Sample-PointViewer sample for the hand tracking demo.
+
+ For Mac/Linux, you will need to install the latest LibUSB.
+ Linux:
+ 1) Run: sudo apt-get install libusb-1.0-0-dev
+ 2) Run: sudo apt-get install freeglut3-dev
+ MaxOSX:
+ 1) Install MacPorts for OSX 10.6 from: https://distfiles.macports.org/MacPorts/MacPorts-1.9.2-10.6-SnowLeopard.dmg
+ for OSX 10.7 from: https://distfiles.macports.org/MacPorts/MacPorts-2.0.4-10.7-Lion.dmg
+ 2) Run: sudo port install libtool
+ 3) Run: sudo port install libusb-devel +universal
+ Note: Do not forget the +universal, it's very important!!
+ If you're previously already installed libusb-devel then use "sudo port uninstall libusb-devel" and reinstall it again with the +universal flag.
+TIPs:
+ 1) If the driver is installed correctly you should see "Kinect Camera" and "Kinect Motor" under the "PrimeSensor" category in the device manager.
+ If not, try to install the driver manually by running the dp-inst files from the Driver directory.
+
+Todo:
+ 1) Add motor & led control.
+ 2) Add support for the K4W device.
+
+The source code for this version is available at:
+https://github.com/avin2/SensorKinect
+
+-------------------------- ORIGINAL README BELOW --------------------------
+
Website: http://www.primesense.com
Forum: http://groups.google.com/group/openni-dev
Wiki: http://wiki.openni.org
View
1,280 Source/XnDeviceSensorV2/Bayer.cpp
@@ -19,105 +19,1211 @@
* along with PrimeSense Sensor. If not, see <http://www.gnu.org/licenses/>.*
* *
****************************************************************************/
-//---------------------------------------------------------------------------
-// Includes
-//---------------------------------------------------------------------------
+
+/****************************************************************************
+ * Edited 12.04.2011 by Raphael Dumusc *
+ * Incorporated ROS code for improved Bayer Pattern to RGB conversion. *
+ ***************************************************************************/
+
+ /*
+ The ROS bayer pattern to RGB conversion
+ Modified to be used in Avin's mod of the Primesense driver.
+ Original code available here:
+ http://www.ros.org/doc/api/openni_camera/html/openni__image__bayer__grbg_8cpp_source.html
+*/
+
+/*
+ * Software License Agreement (BSD License)
+ *
+ * Copyright (c) 2011 2011 Willow Garage, Inc.
+ * Suat Gedikli <gedikli@willowgarage.com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of Willow Garage, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
#include "Bayer.h"
-#include <math.h>
+#include <sstream>
+#include <iostream>
-//---------------------------------------------------------------------------
-// Global Variables
-//---------------------------------------------------------------------------
-XnUInt8 Gamma[256] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
- 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
- 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
- 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
- 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
- 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
- 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
- 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
- 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
- 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255};
+#define AVG(a,b) (((int)(a) + (int)(b)) >> 1)
+#define AVG3(a,b,c) (((int)(a) + (int)(b) + (int)(c)) / 3)
+#define AVG4(a,b,c,d) (((int)(a) + (int)(b) + (int)(c) + (int)(d)) >> 2)
+#define WAVG4(a,b,c,d,x,y) ( ( ((int)(a) + (int)(b)) * (int)(x) + ((int)(c) + (int)(d)) * (int)(y) ) / ( 2 * ((int)(x) + (int(y))) ) )
+using namespace std;
-//---------------------------------------------------------------------------
-// Code
-//---------------------------------------------------------------------------
-void BayerUpdateGamma(float fGammaCorr)
+typedef enum
{
- for(XnUInt32 iG = 0; iG < 256;++iG)
- Gamma[iG] = XnUInt8(255*pow(XnDouble(iG)/255.0,(XnDouble)fGammaCorr) + 0.5);
-}
+ Bilinear = 0,
+ EdgeAware,
+ EdgeAwareWeighted
+} DebayeringMethod;
-static inline void WriteRGB(XnUInt8 *pBuffer, XnUInt8 nRed, XnUInt8 nGreen, XnUInt8 nBlue)
+void BayerUpdateGamma(float fGammaCorr)
{
- pBuffer[BAYER_RED] = Gamma[nRed];
- pBuffer[BAYER_GREEN] = Gamma[nGreen];
- pBuffer[BAYER_BLUE] = Gamma[nBlue];
}
-void Bayer2RGB888(const XnUInt8* pBayerImage, XnUInt8* pRGBImage, XnUInt32 nXRes, XnUInt32 nYRes, XnUInt32 /*nDownSampleStep*/, XnUInt32 nBadPixels)
+void fillRGB(unsigned width, unsigned height, const XnUInt8* bayer_pixel, unsigned char* rgb_buffer, DebayeringMethod debayering_method, XnUInt32 nDownSampleStep)
{
- XnUInt8 nRed;
- XnUInt8 nGreen;
- XnUInt8 nBlue;
- const XnUInt8* pBayer;
- XnUInt8* pRGB;
-
- //if (nBadPixels > 1)
- //{
- //nBadPixels = 1;
- //}
-
- XnInt32 BAYER_LINE_LENGTH = nXRes;
- XnInt32 BAYER_LINE_LENGTH2 = BAYER_LINE_LENGTH*2;
- XnInt32 BAYER_RGB_LINE_LENGTH = nXRes*BAYER_BPP;
- XnInt32 BAYER_RGB_LINE_LENGTH2 = BAYER_RGB_LINE_LENGTH*2;
-
- const XnUInt8* pCurrBayer;
- XnUInt8* pCurrRGB;
- XnUInt32 nColCount;
- XnUInt32 nTotalColsCount = (nXRes-2) / 2;
- XnUInt32 nTotalRowsCount = (nYRes-4) / 2;
-
- pBayer = pBayerImage + BAYER_LINE_LENGTH - nBadPixels;
- pRGB = pRGBImage + BAYER_RGB_LINE_LENGTH;
-
- do {
- pCurrBayer = pBayer+ 1;
- pCurrRGB = pRGB + BAYER_BPP;
-
- nColCount = nTotalColsCount;
-
- do {
+
+ unsigned rgb_line_step = width * 3;
+
+ // padding skip for destination image
+ unsigned rgb_line_skip = rgb_line_step - width * 3;
+
+ if (nDownSampleStep == 1)
+ {
+ //register const XnUInt8 *bayer_pixel = image_md_->Data ();
+ register unsigned yIdx, xIdx;
+
+ int bayer_line_step = width;
+ int bayer_line_step2 = width << 1;
+
+ if (debayering_method == Bilinear)
+ {
+ // first two pixel values for first two lines
+ // Bayer 0 1 2
+ // 0 G r g
+ // line_step b g b
+ // line_step2 g r g
+
+ rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel
+ rgb_buffer[1] = bayer_pixel[0]; // green pixel
+ rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; // blue;
+
+ // Bayer 0 1 2
+ // 0 g R g
+ // line_step b g b
+ // line_step2 g r g
+ //rgb_pixel[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ // BGBG line
+ // Bayer 0 1 2
+ // 0 g r g
+ // line_step B g b
+ // line_step2 g r g
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]);
+ //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step];
+
+ // pixel (1, 1) 0 1 2
+ // 0 g r g
+ // line_step b G b
+ // line_step2 g r g
+ //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] );
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = AVG( bayer_pixel[line_step] , bayer_pixel[line_step+2] );
+
+ rgb_buffer += 6;
+ bayer_pixel += 2;
+ // rest of the first two lines
+
+ for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
+ {
+ // GRGR line
+ // Bayer -1 0 1 2
+ // 0 r G r g
+ // line_step g b g b
+ // line_step2 r g r g
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[2] = bayer_pixel[bayer_line_step + 1];
+
+ // Bayer -1 0 1 2
+ // 0 r g R g
+ // line_step g b g b
+ // line_step2 r g r g
+ rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ // BGBG line
+ // Bayer -1 0 1 2
+ // 0 r g r g
+ // line_step g B g b
+ // line_step2 r g r g
+ rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ // Bayer -1 0 1 2
+ // 0 r g r g
+ // line_step g b G b
+ // line_step2 r g r g
+ rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = AVG( bayer_pixel[line_step] , bayer_pixel[line_step+2] );
+ }
+
+ // last two pixel values for first two lines
+ // GRGR line
+ // Bayer -1 0 1
+ // 0 r G r
+ // line_step g b g
+ // line_step2 r g r
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
+
+ // Bayer -1 0 1
+ // 0 r g R
+ // line_step g b g
+ // line_step2 r g r
+ rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
+ //rgb_pixel[5] = bayer_pixel[line_step];
+
+ // BGBG line
+ // Bayer -1 0 1
+ // 0 r g r
+ // line_step g B g
+ // line_step2 r g r
+ rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step];
+
+ // Bayer -1 0 1
+ // 0 r g r
+ // line_step g b G
+ // line_step2 r g r
+ rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step];
+
+ bayer_pixel += bayer_line_step + 2;
+ rgb_buffer += rgb_line_step + 6 + rgb_line_skip;
+
+ // main processing
+
+ for (yIdx = 2; yIdx < height - 2; yIdx += 2)
+ {
+ // first two pixel values
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 G r g
+ // line_step b g b
+ // line_step2 g r g
+
+ rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel
+ rgb_buffer[1] = bayer_pixel[0]; // green pixel
+ rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); // blue;
+
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 g R g
+ // line_step b g b
+ // line_step2 g r g
+ //rgb_pixel[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
+ rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]);
+
+ // BGBG line
+ // Bayer 0 1 2
+ // 0 g r g
+ // line_step B g b
+ // line_step2 g r g
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ // pixel (1, 1) 0 1 2
+ // 0 g r g
+ // line_step b G b
+ // line_step2 g r g
+ //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] );
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ rgb_buffer += 6;
+ bayer_pixel += 2;
+ // continue with rest of the line
+ for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
+ {
+ // GRGR line
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r G r g
+ // line_step g b g b
+ // line_step2 r g r g
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
+
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g R g
+ // line_step g b g b
+ // line_step2 r g r g
+ rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
+ rgb_buffer[5] = AVG4 (bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step], bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ // BGBG line
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g r g
+ // line_step g B g b
+ // line_step2 r g r g
+ rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g r g
+ // line_step g b G b
+ // line_step2 r g r g
+ rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+ }
+
+ // last two pixels of the line
+ // last two pixel values for first two lines
+ // GRGR line
+ // Bayer -1 0 1
+ // 0 r G r
+ // line_step g b g
+ // line_step2 r g r
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
+
+ // Bayer -1 0 1
+ // 0 r g R
+ // line_step g b g
+ // line_step2 r g r
+ rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
+ //rgb_pixel[5] = bayer_pixel[line_step];
+
+ // BGBG line
+ // Bayer -1 0 1
+ // 0 r g r
+ // line_step g B g
+ // line_step2 r g r
+ rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step];
+
+ // Bayer -1 0 1
+ // 0 r g r
+ // line_step g b G
+ // line_step2 r g r
+ rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step];
+
+ bayer_pixel += bayer_line_step + 2;
+ rgb_buffer += rgb_line_step + 6 + rgb_line_skip;
+ }
+
+ //last two lines
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 G r g
+ // line_step b g b
+
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel
+ rgb_buffer[1] = bayer_pixel[0]; // green pixel
+ rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; // blue;
+
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 g R g
+ // line_step b g b
+ //rgb_pixel[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
+ rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]);
+
+ // BGBG line
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 g r g
+ // line_step B g b
+ //rgb_pixel[rgb_line_step ] = bayer_pixel[1];
+ rgb_buffer[rgb_line_step + 1] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 g r g
+ // line_step b G b
+ //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] );
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ rgb_buffer += 6;
+ bayer_pixel += 2;
+ // rest of the last two lines
+ for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
+ {
+ // GRGR line
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r G r g
+ // line_step g b g b
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
+
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g R g
+ // line_step g b g b
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
+ rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[-bayer_line_step + 2]);
+
+ // BGBG line
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g r g
+ // line_step g B g b
+ rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[-1], bayer_pixel[1]);
+ rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g r g
+ // line_step g b G b
+ //rgb_pixel[rgb_line_step + 3] = bayer_pixel[1];
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+ }
+
+ // last two pixel values for first two lines
+ // GRGR line
+ // Bayer -1 0 1
+ // -1 g b g
+ // 0 r G r
+ // line_step g b g
+ rgb_buffer[rgb_line_step ] = rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[5] = rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
+
+ // Bayer -1 0 1
+ // -1 g b g
+ // 0 r g R
+ // line_step g b g
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[-bayer_line_step + 1]);
+ //rgb_pixel[5] = AVG( bayer_pixel[line_step], bayer_pixel[-line_step] );
+
+ // BGBG line
+ // Bayer -1 0 1
+ // -1 g b g
+ // 0 r g r
+ // line_step g B g
+ //rgb_pixel[rgb_line_step ] = AVG2( bayer_pixel[-1], bayer_pixel[1] );
+ rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ // Bayer -1 0 1
+ // -1 g b g
+ // 0 r g r
+ // line_step g b G
+ //rgb_pixel[rgb_line_step + 3] = bayer_pixel[1];
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step];
+ }
+ else if (debayering_method == EdgeAware)
+ {
+ int dh, dv;
+
+ // first two pixel values for first two lines
+ // Bayer 0 1 2
+ // 0 G r g
+ // line_step b g b
+ // line_step2 g r g
+
+ rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel
+ rgb_buffer[1] = bayer_pixel[0]; // green pixel
+ rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; // blue;
+
+ // Bayer 0 1 2
+ // 0 g R g
+ // line_step b g b
+ // line_step2 g r g
+ //rgb_pixel[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ // BGBG line
+ // Bayer 0 1 2
+ // 0 g r g
+ // line_step B g b
+ // line_step2 g r g
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]);
+ //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step];
+
+ // pixel (1, 1) 0 1 2
+ // 0 g r g
+ // line_step b G b
+ // line_step2 g r g
+ //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] );
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = AVG( bayer_pixel[line_step] , bayer_pixel[line_step+2] );
+
+ rgb_buffer += 6;
+ bayer_pixel += 2;
+ // rest of the first two lines
+ for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
+ {
+ // GRGR line
+ // Bayer -1 0 1 2
+ // 0 r G r g
+ // line_step g b g b
+ // line_step2 r g r g
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[2] = bayer_pixel[bayer_line_step + 1];
+
+ // Bayer -1 0 1 2
+ // 0 r g R g
+ // line_step g b g b
+ // line_step2 r g r g
+ rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ // BGBG line
+ // Bayer -1 0 1 2
+ // 0 r g r g
+ // line_step g B g b
+ // line_step2 r g r g
+ rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ // Bayer -1 0 1 2
+ // 0 r g r g
+ // line_step g b G b
+ // line_step2 r g r g
+ rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = AVG( bayer_pixel[line_step] , bayer_pixel[line_step+2] );
+ }
+
+ // last two pixel values for first two lines
+ // GRGR line
+ // Bayer -1 0 1
+ // 0 r G r
+ // line_step g b g
+ // line_step2 r g r
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
+
+ // Bayer -1 0 1
+ // 0 r g R
+ // line_step g b g
+ // line_step2 r g r
+ rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
+ //rgb_pixel[5] = bayer_pixel[line_step];
+
+ // BGBG line
+ // Bayer -1 0 1
+ // 0 r g r
+ // line_step g B g
+ // line_step2 r g r
+ rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step];
+
+ // Bayer -1 0 1
+ // 0 r g r
+ // line_step g b G
+ // line_step2 r g r
+ rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step];
+
+ bayer_pixel += bayer_line_step + 2;
+ rgb_buffer += rgb_line_step + 6 + rgb_line_skip;
+ // main processing
+ for (yIdx = 2; yIdx < height - 2; yIdx += 2)
+ {
+ // first two pixel values
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 G r g
+ // line_step b g b
+ // line_step2 g r g
+
+ rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel
+ rgb_buffer[1] = bayer_pixel[0]; // green pixel
+ rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); // blue;
+
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 g R g
+ // line_step b g b
+ // line_step2 g r g
+ //rgb_pixel[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
+ rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]);
+
+ // BGBG line
+ // Bayer 0 1 2
+ // 0 g r g
+ // line_step B g b
+ // line_step2 g r g
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ // pixel (1, 1) 0 1 2
+ // 0 g r g
+ // line_step b G b
+ // line_step2 g r g
+ //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] );
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ rgb_buffer += 6;
+ bayer_pixel += 2;
+ // continue with rest of the line
+ for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
+ {
+ // GRGR line
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r G r g
+ // line_step g b g b
+ // line_step2 r g r g
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
+
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g R g
+ // line_step g b g b
+ // line_step2 r g r g
+
+ dh = abs (bayer_pixel[0] - bayer_pixel[2]);
+ dv = abs (bayer_pixel[-bayer_line_step + 1] - bayer_pixel[bayer_line_step + 1]);
+
+ if (dh > dv)
+ rgb_buffer[4] = AVG (bayer_pixel[-bayer_line_step + 1], bayer_pixel[bayer_line_step + 1]);
+ else if (dv > dh)
+ rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[2]);
+ else
+ rgb_buffer[4] = AVG4 (bayer_pixel[-bayer_line_step + 1], bayer_pixel[bayer_line_step + 1], bayer_pixel[0], bayer_pixel[2]);
+
+ rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[5] = AVG4 (bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step], bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ // BGBG line
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g r g
+ // line_step g B g b
+ // line_step2 r g r g
+ rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ dv = abs (bayer_pixel[0] - bayer_pixel[bayer_line_step2]);
+ dh = abs (bayer_pixel[bayer_line_step - 1] - bayer_pixel[bayer_line_step + 1]);
+
+ if (dv > dh)
+ rgb_buffer[rgb_line_step + 1] = AVG (bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ else if (dh > dv)
+ rgb_buffer[rgb_line_step + 1] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step2]);
+ else
+ rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g r g
+ // line_step g b G b
+ // line_step2 r g r g
+ rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+ }
+
+ // last two pixels of the line
+ // last two pixel values for first two lines
+ // GRGR line
+ // Bayer -1 0 1
+ // 0 r G r
+ // line_step g b g
+ // line_step2 r g r
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
+
+ // Bayer -1 0 1
+ // 0 r g R
+ // line_step g b g
+ // line_step2 r g r
+ rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
+ //rgb_pixel[5] = bayer_pixel[line_step];
+
+ // BGBG line
+ // Bayer -1 0 1
+ // 0 r g r
+ // line_step g B g
+ // line_step2 r g r
+ rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step];
+
+ // Bayer -1 0 1
+ // 0 r g r
+ // line_step g b G
+ // line_step2 r g r
+ rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step];
+
+ bayer_pixel += bayer_line_step + 2;
+ rgb_buffer += rgb_line_step + 6 + rgb_line_skip;
+ }
+
+ //last two lines
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 G r g
+ // line_step b g b
+
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel
+ rgb_buffer[1] = bayer_pixel[0]; // green pixel
+ rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; // blue;
+
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 g R g
+ // line_step b g b
+ //rgb_pixel[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
+ rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]);
+
+ // BGBG line
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 g r g
+ // line_step B g b
+ //rgb_pixel[rgb_line_step ] = bayer_pixel[1];
+ rgb_buffer[rgb_line_step + 1] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 g r g
+ // line_step b G b
+ //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] );
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ rgb_buffer += 6;
+ bayer_pixel += 2;
+ // rest of the last two lines
+ for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
+ {
+ // GRGR line
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r G r g
+ // line_step g b g b
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
+
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g R g
+ // line_step g b g b
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
+ rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[-bayer_line_step + 2]);
+
+ // BGBG line
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g r g
+ // line_step g B g b
+ rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[-1], bayer_pixel[1]);
+ rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g r g
+ // line_step g b G b
+ //rgb_pixel[rgb_line_step + 3] = bayer_pixel[1];
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+ }
+
+ // last two pixel values for first two lines
+ // GRGR line
+ // Bayer -1 0 1
+ // -1 g b g
+ // 0 r G r
+ // line_step g b g
+ rgb_buffer[rgb_line_step ] = rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[5] = rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
+
+ // Bayer -1 0 1
+ // -1 g b g
+ // 0 r g R
+ // line_step g b g
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[-bayer_line_step + 1]);
+ //rgb_pixel[5] = AVG( bayer_pixel[line_step], bayer_pixel[-line_step] );
+
+ // BGBG line
+ // Bayer -1 0 1
+ // -1 g b g
+ // 0 r g r
+ // line_step g B g
+ //rgb_pixel[rgb_line_step ] = AVG2( bayer_pixel[-1], bayer_pixel[1] );
+ rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ // Bayer -1 0 1
+ // -1 g b g
+ // 0 r g r
+ // line_step g b G
+ //rgb_pixel[rgb_line_step + 3] = bayer_pixel[1];
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step];
+ }
+ else if (debayering_method == EdgeAwareWeighted)
+ {
+ int dh, dv;
+
+ // first two pixel values for first two lines
+ // Bayer 0 1 2
+ // 0 G r g
+ // line_step b g b
+ // line_step2 g r g
+
+ rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel
+ rgb_buffer[1] = bayer_pixel[0]; // green pixel
+ rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; // blue;
+
+ // Bayer 0 1 2
+ // 0 g R g
+ // line_step b g b
+ // line_step2 g r g
+ //rgb_pixel[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ // BGBG line
+ // Bayer 0 1 2
+ // 0 g r g
+ // line_step B g b
+ // line_step2 g r g
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]);
+ //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step];
+
+ // pixel (1, 1) 0 1 2
+ // 0 g r g
+ // line_step b G b
+ // line_step2 g r g
+ //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] );
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = AVG( bayer_pixel[line_step] , bayer_pixel[line_step+2] );
+
+ rgb_buffer += 6;
+ bayer_pixel += 2;
+ // rest of the first two lines
+ for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
+ {
+ // GRGR line
+ // Bayer -1 0 1 2
+ // 0 r G r g
+ // line_step g b g b
+ // line_step2 r g r g
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[2] = bayer_pixel[bayer_line_step + 1];
+
+ // Bayer -1 0 1 2
+ // 0 r g R g
+ // line_step g b g b
+ // line_step2 r g r g
+ rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ // BGBG line
+ // Bayer -1 0 1 2
+ // 0 r g r g
+ // line_step g B g b
+ // line_step2 r g r g
+ rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ // Bayer -1 0 1 2
+ // 0 r g r g
+ // line_step g b G b
+ // line_step2 r g r g
+ rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = AVG( bayer_pixel[line_step] , bayer_pixel[line_step+2] );
+ }
+
+ // last two pixel values for first two lines
+ // GRGR line
+ // Bayer -1 0 1
+ // 0 r G r
+ // line_step g b g
+ // line_step2 r g r
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
+
+ // Bayer -1 0 1
+ // 0 r g R
+ // line_step g b g
+ // line_step2 r g r
+ rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
+ //rgb_pixel[5] = bayer_pixel[line_step];
+
+ // BGBG line
+ // Bayer -1 0 1
+ // 0 r g r
+ // line_step g B g
+ // line_step2 r g r
+ rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step];
+
+ // Bayer -1 0 1
+ // 0 r g r
+ // line_step g b G
+ // line_step2 r g r
+ rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step];
+
+ bayer_pixel += bayer_line_step + 2;
+ rgb_buffer += rgb_line_step + 6 + rgb_line_skip;
+ // main processing
+ for (yIdx = 2; yIdx < height - 2; yIdx += 2)
+ {
+ // first two pixel values
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 G r g
+ // line_step b g b
+ // line_step2 g r g
+
+ rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel
+ rgb_buffer[1] = bayer_pixel[0]; // green pixel
+ rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]); // blue;
+
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 g R g
+ // line_step b g b
+ // line_step2 g r g
+ //rgb_pixel[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
+ rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]);
+
+ // BGBG line
+ // Bayer 0 1 2
+ // 0 g r g
+ // line_step B g b
+ // line_step2 g r g
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[bayer_line_step2]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ // pixel (1, 1) 0 1 2
+ // 0 g r g
+ // line_step b G b
+ // line_step2 g r g
+ //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] );
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ rgb_buffer += 6;
+ bayer_pixel += 2;
+ // continue with rest of the line
+ for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
+ {
+ // GRGR line
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r G r g
+ // line_step g b g b
+ // line_step2 r g r g
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
+
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g R g
+ // line_step g b g b
+ // line_step2 r g r g
+
+ dh = abs (bayer_pixel[0] - bayer_pixel[2]);
+ dv = abs (bayer_pixel[-bayer_line_step + 1] - bayer_pixel[bayer_line_step + 1]);
+
+ if (dv == 0 && dh == 0)
+ rgb_buffer[4] = AVG4 (bayer_pixel[1 - bayer_line_step], bayer_pixel[1 + bayer_line_step], bayer_pixel[0], bayer_pixel[2]);
+ else
+ rgb_buffer[4] = WAVG4 (bayer_pixel[1 - bayer_line_step], bayer_pixel[1 + bayer_line_step], bayer_pixel[0], bayer_pixel[2], dh, dv);
+ rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[5] = AVG4 (bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step], bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ // BGBG line
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g r g
+ // line_step g B g b
+ // line_step2 r g r g
+ rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ dv = abs (bayer_pixel[0] - bayer_pixel[bayer_line_step2]);
+ dh = abs (bayer_pixel[bayer_line_step - 1] - bayer_pixel[bayer_line_step + 1]);
+
+ if (dv == 0 && dh == 0)
+ rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ else
+ rgb_buffer[rgb_line_step + 1] = WAVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1], dh, dv);
+
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g r g
+ // line_step g b G b
+ // line_step2 r g r g
+ rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+ }
+
+ // last two pixels of the line
+ // last two pixel values for first two lines
+ // GRGR line
+ // Bayer -1 0 1
+ // 0 r G r
+ // line_step g b g
+ // line_step2 r g r
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = rgb_buffer[5] = rgb_buffer[2] = bayer_pixel[bayer_line_step];
+
+ // Bayer -1 0 1
+ // 0 r g R
+ // line_step g b g
+ // line_step2 r g r
+ rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
+ //rgb_pixel[5] = bayer_pixel[line_step];
+
+ // BGBG line
+ // Bayer -1 0 1
+ // 0 r g r
+ // line_step g B g
+ // line_step2 r g r
+ rgb_buffer[rgb_line_step ] = AVG4 (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1], bayer_pixel[-1], bayer_pixel[bayer_line_step2 - 1]);
+ rgb_buffer[rgb_line_step + 1] = AVG4 (bayer_pixel[0], bayer_pixel[bayer_line_step2], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ //rgb_pixel[rgb_line_step + 2] = bayer_pixel[line_step];
+
+ // Bayer -1 0 1
+ // 0 r g r
+ // line_step g b G
+ // line_step2 r g r
+ rgb_buffer[rgb_line_step + 3] = AVG (bayer_pixel[1], bayer_pixel[bayer_line_step2 + 1]);
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step];
+
+ bayer_pixel += bayer_line_step + 2;
+ rgb_buffer += rgb_line_step + 6 + rgb_line_skip;
+ }
+
+ //last two lines
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 G r g
+ // line_step b g b
+
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[rgb_line_step ] = rgb_buffer[3] = rgb_buffer[0] = bayer_pixel[1]; // red pixel
+ rgb_buffer[1] = bayer_pixel[0]; // green pixel
+ rgb_buffer[rgb_line_step + 2] = rgb_buffer[2] = bayer_pixel[bayer_line_step]; // blue;
+
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 g R g
+ // line_step b g b
+ //rgb_pixel[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
+ rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[2 - bayer_line_step]);
+
+ // BGBG line
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 g r g
+ // line_step B g b
+ //rgb_pixel[rgb_line_step ] = bayer_pixel[1];
+ rgb_buffer[rgb_line_step + 1] = AVG (bayer_pixel[0], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ // Bayer 0 1 2
+ // -1 b g b
+ // 0 g r g
+ // line_step b G b
+ //rgb_pixel[rgb_line_step + 3] = AVG( bayer_pixel[1] , bayer_pixel[line_step2+1] );
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+
+ rgb_buffer += 6;
+ bayer_pixel += 2;
+ // rest of the last two lines
+ for (xIdx = 2; xIdx < width - 2; xIdx += 2, rgb_buffer += 6, bayer_pixel += 2)
+ {
+ // GRGR line
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r G r g
+ // line_step g b g b
+ rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
+
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g R g
+ // line_step g b g b
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG4 (bayer_pixel[0], bayer_pixel[2], bayer_pixel[bayer_line_step + 1], bayer_pixel[1 - bayer_line_step]);
+ rgb_buffer[5] = AVG4 (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2], bayer_pixel[-bayer_line_step], bayer_pixel[-bayer_line_step + 2]);
+
+ // BGBG line
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g r g
+ // line_step g B g b
+ rgb_buffer[rgb_line_step ] = AVG (bayer_pixel[-1], bayer_pixel[1]);
+ rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+
+ // Bayer -1 0 1 2
+ // -1 g b g b
+ // 0 r g r g
+ // line_step g b G b
+ //rgb_pixel[rgb_line_step + 3] = bayer_pixel[1];
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ rgb_buffer[rgb_line_step + 5] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[bayer_line_step + 2]);
+ }
+
+ // last two pixel values for first two lines
+ // GRGR line
+ // Bayer -1 0 1
+ // -1 g b g
+ // 0 r G r
+ // line_step g b g
+ rgb_buffer[rgb_line_step ] = rgb_buffer[0] = AVG (bayer_pixel[1], bayer_pixel[-1]);
+ rgb_buffer[1] = bayer_pixel[0];
+ rgb_buffer[5] = rgb_buffer[2] = AVG (bayer_pixel[bayer_line_step], bayer_pixel[-bayer_line_step]);
+
+ // Bayer -1 0 1
+ // -1 g b g
+ // 0 r g R
+ // line_step g b g
+ rgb_buffer[rgb_line_step + 3] = rgb_buffer[3] = bayer_pixel[1];
+ rgb_buffer[4] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step + 1], bayer_pixel[-bayer_line_step + 1]);
+ //rgb_pixel[5] = AVG( bayer_pixel[line_step], bayer_pixel[-line_step] );
+
+ // BGBG line
+ // Bayer -1 0 1
+ // -1 g b g
+ // 0 r g r
+ // line_step g B g
+ //rgb_pixel[rgb_line_step ] = AVG2( bayer_pixel[-1], bayer_pixel[1] );
+ rgb_buffer[rgb_line_step + 1] = AVG3 (bayer_pixel[0], bayer_pixel[bayer_line_step - 1], bayer_pixel[bayer_line_step + 1]);
+ rgb_buffer[rgb_line_step + 5] = rgb_buffer[rgb_line_step + 2] = bayer_pixel[bayer_line_step];
+
+ // Bayer -1 0 1
+ // -1 g b g
+ // 0 r g r
+ // line_step g b G
+ //rgb_pixel[rgb_line_step + 3] = bayer_pixel[1];
+ rgb_buffer[rgb_line_step + 4] = bayer_pixel[bayer_line_step + 1];
+ //rgb_pixel[rgb_line_step + 5] = bayer_pixel[line_step];
+ }
+ //else
+ // THROW_OPENNI_EXCEPTION ("Unknwon debayering method: %d", (int)debayering_method);
+ }
+ //Warning: Downsampling mod is untested
+ else if (nDownSampleStep > 1)
+ {
+ // get each or each 2nd pixel group to find rgb values!
+ register unsigned bayerXStep = nDownSampleStep;
+ register unsigned bayerYSkip = (nDownSampleStep - 1) * width;
+
+ // Downsampling and debayering at once
+ register const XnUInt8* bayer_buffer = bayer_pixel;
+
+ for (register unsigned yIdx = 0; yIdx < height; ++yIdx, bayer_buffer += bayerYSkip, rgb_buffer += rgb_line_skip) // skip a line
+ {
+ for (register unsigned xIdx = 0; xIdx < width; ++xIdx, rgb_buffer += 3, bayer_buffer += bayerXStep)
+ {
+ rgb_buffer[ 2 ] = bayer_buffer[ width ];
+ rgb_buffer[ 1 ] = AVG (bayer_buffer[0], bayer_buffer[ width + 1]);
+ rgb_buffer[ 0 ] = bayer_buffer[ 1 ];
+ }
+ }
+ }
+}
- nRed = ((XnUInt32)pCurrBayer[-BAYER_LINE_LENGTH]+pCurrBayer[BAYER_LINE_LENGTH]) / 2;
- nBlue = ((XnUInt32)pCurrBayer[-1]+pCurrBayer[1]) / 2;
- WriteRGB(pCurrRGB+0, nRed, pCurrBayer[0], nBlue);
- nRed = ((XnUInt32)pCurrBayer[-BAYER_LINE_LENGTH+2]+pCurrBayer[BAYER_LINE_LENGTH+2]) / 2;
- nGreen = ((XnUInt32)pCurrBayer[0]+pCurrBayer[2]) / 2;
- WriteRGB(pCurrRGB+BAYER_BPP, nRed, nGreen, pCurrBayer[1]);
- nGreen = ((XnUInt32)pCurrBayer[BAYER_LINE_LENGTH-1]+pCurrBayer[BAYER_LINE_LENGTH+1]) / 2;
- nBlue = ((XnUInt32)pCurrBayer[BAYER_LINE_LENGTH2-1]+pCurrBayer[BAYER_LINE_LENGTH2+1]) / 2;
- WriteRGB(pCurrRGB+BAYER_RGB_LINE_LENGTH, pCurrBayer[BAYER_LINE_LENGTH], nGreen, nBlue);
+void Bayer2RGB888(const XnUInt8* pBayerImage, XnUInt8* pRGBImage, XnUInt32 nXRes, XnUInt32 nYRes, XnUInt32 nDownSampleStep, XnUInt32 nBadPixels)
+{
+ fillRGB(nXRes, nYRes, pBayerImage, pRGBImage, DebayeringMethod(1), nDownSampleStep); // DebayeringMethod(0) == bilinear, (1) == edge aware, (2) == edge aware weighted
+}
- nRed = ((XnUInt32)pCurrBayer[BAYER_LINE_LENGTH]+pCurrBayer[BAYER_LINE_LENGTH+2]) / 2;
- nBlue = ((XnUInt32)pCurrBayer[1]+pCurrBayer[BAYER_LINE_LENGTH2+1]) / 2;
- WriteRGB(pCurrRGB+BAYER_RGB_LINE_LENGTH+BAYER_BPP, nRed, pCurrBayer[BAYER_LINE_LENGTH+1], nBlue);
- pCurrBayer += 2;
- pCurrRGB += 2*BAYER_BPP;
- } while (--nColCount);
- pBayer += BAYER_LINE_LENGTH2;
- pRGB += BAYER_RGB_LINE_LENGTH2;
- } while (--nTotalRowsCount);
-}
View
3  Source/XnDeviceSensorV2/XnDataProcessor.h
@@ -90,7 +90,8 @@ class XnDataProcessor
/* The number of bytes received so far (since last time this member was reset). */
XnUInt32 m_nBytesReceived;
/* Stores last packet ID */
- XnUInt16 m_nLastPacketID;
+ // --avin mod--
+ XnUInt8 m_nLastPacketID;
/* The name of the stream. */
const XnChar* m_csName;
View
5 Source/XnDeviceSensorV2/XnDeviceSensor.h
@@ -48,8 +48,9 @@
//---------------------------------------------------------------------------
#define XN_DEVICE_MAJORVERSION 1
#define XN_DEVICE_MINORVERSION 0
-#define XN_DEVICE_NAME "SensorV2"
-#define XN_DEVICE_DESCRIPTION "Xiron I/O Prime Sensor v2/v3/v4 Device"
+// --avin mod--
+#define XN_DEVICE_NAME "SensorKinect"
+#define XN_DEVICE_DESCRIPTION "Xiron I/O Kinect Device"
#define XN_DEVICE_SENSOR_THREAD_KILL_TIMEOUT 5000
View
12 Source/XnDeviceSensorV2/XnDeviceSensorIO.cpp
@@ -29,7 +29,8 @@
//---------------------------------------------------------------------------
// Defines
//---------------------------------------------------------------------------
-#define XN_SENSOR_VENDOR_ID 0x1D27
+// --avin mod--
+#define XN_SENSOR_VENDOR_ID 0x045E
//---------------------------------------------------------------------------
// Enums
@@ -43,11 +44,10 @@ typedef enum
//---------------------------------------------------------------------------
// Globals
//---------------------------------------------------------------------------
+// --avin mod--
XnUInt16 XnSensorIO::ms_supportedProducts[] =