473,408 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Access Extended Camera Registers for DirectShowNet

2
Hello all,
I'm trying to implement this interface into either a C++ dll or into the DirectShowNet dll. This interface is used by the PGR type cameras to access any register on the camera. I need to access some of these registers that aren't covered by the standard ProcAMP registers. Any suggestions/guidence would be greatly appreciated.

the C++ API code from PGR for DirectShow:
Expand|Select|Wrap|Line Numbers
  1. #include <ks.h> 
  2. #include <ksproxy.h> 
  3. #include "PGRKSMedia.h" 
  4.  
  5. DECLARE_INTERFACE_(IPGRInterface, IUnknown ) 
  6. STDMETHOD (GetRegister) ( THIS_ long lRegister, long *plValue ) PURE; 
  7. STDMETHOD (SetRegister) ( THIS_ long lRegister, long lValue ) PURE; 
  8. }; 
  9.  
In the PGRKSMedia.h file contains the GUID and structures for the methods:
Expand|Select|Wrap|Line Numbers
  1. #include <ks.h> 
  2. #include <ksproxy.h> 
  3. #include <ksmedia.h> 
  4. /** 
  5. * GUID identifying the custom properties that are exported by the driver. 
  6. */ 
  7. DEFINE_GUID( PROPSETID_CUSTOM, 0xdae50fa6, 0x1dac, 0x4913, 0x98, 0x41, 0x8e, 0xd3, 0xab, 0x3f, 0xeb, 0x4 ); 
  8.  
  9. //=========================================================================== 
  10. // {DAE50FA6-1DAC-4913-9841-8ED3AB3FEB04} 
  11. #define STATIC_PROPSETID_CUSTOM\ 
  12. 0xdae50fa6, 0x1dac, 0x4913, 0x98, 0x41, 0x8e, 0xd3, 0xab, 0x3f, 0xeb, 0x4  
  13. // {DAE50FA6-1DAC-4913-9841-8ED3AB3FEB04} 
  14. DEFINE_GUIDSTRUCT("dae50fa6-1dac-4913-9841-8ed3ab3feb04", PROPSETID_CUSTOM); 
  15. #define PROPSETID_CUSTOM DEFINE_GUIDNAMED(PROPSETID_CUSTOM) 
  16.  
  17. /** 
  18. * enumeration of the custom property identifiers. 
  19. */ 
  20. typedef enum  
  21. KSPROPERTY_CUSTOM_REGISTER, // RWO 
  22. KSPROPERTY_CUSTOM_FORMAT7, 
  23. } KSPROPERTY_CUSTOM; 
  24. /** 
  25. * Structure used for getting and setting of registers on the camera. 
  26. */ 
  27. typedef struct  
  28. KSPROPERTY Property; 
  29. ULONG StreamIndex; 
  30. ULONG ulRegister; 
  31. ULONG ulRegisterValue; 
  32. } KSPROPERTY_CUSTOM_REGISTER_S, *PKSPROPERTY_CUSTOM_REGISTER_S; 
  33.  
I'm assuming to get these to work i would need to be able to define the KSPROPERTY type in C# or create a public interface in C++ i can access in C#.

Thanks for any comments.
Mar 5 '07 #1
2 2294
radcaesar
759 Expert 512MB
Refer this, Revert back if u have any issues

http://msdn.microsoft.com/msdnmag/issues/02/08/CQA/

:)
Mar 5 '07 #2
tchiex
2
I was able to convert all the code into C#. See below.

Expand|Select|Wrap|Line Numbers
  1. IKsPropertySet pKs = ibf as IKsPropertySet;
  2.             KSPropertySupport dwSupported = new KSPropertySupport();
  3.  
  4.             hr = pKs.QuerySupported(PROPSETID_CUSTOM, (int)KSPROPERTY_CUSTOM.KSPROPERTY_CUSTOM_REGISTER, out dwSupported);
  5.  
  6.             if (dwSupported == (KSPropertySupport.Get | KSPropertySupport.Set))
  7.             {
  8.                 hr = 0;
  9.             }
  10.  
  11.             KSPROPERTY_CUSTOM_REGISTER_S cRegisterStr = new KSPROPERTY_CUSTOM_REGISTER_S();
  12.             cRegisterStr.ulRegister = regNumber;
  13.  
  14.             IntPtr regData = Marshal.AllocCoTaskMem(Marshal.SizeOf(cRegisterStr));
  15.             IntPtr instData = Marshal.AllocCoTaskMem(Marshal.SizeOf(cRegisterStr));
  16.             int cbBytes = 0;
  17.  
  18.             Marshal.StructureToPtr(cRegisterStr, regData, true);
  19.             Marshal.StructureToPtr(cRegisterStr, instData, true);
  20.  
  21.             hr = pKs.Get(PROPSETID_CUSTOM,
  22.                 (int)KSPROPERTY_CUSTOM.KSPROPERTY_CUSTOM_REGISTER,
  23.                 instData,
  24.                 Marshal.SizeOf(cRegisterStr),
  25.                 regData,
  26.                 Marshal.SizeOf(cRegisterStr),
  27.                 out cbBytes);
  28.             DsError.ThrowExceptionForHR(hr);
  29.  
  30.             cRegisterStr.ulRegisterValue = regValue;
  31.             Marshal.StructureToPtr(cRegisterStr, regData, true);
  32.             Marshal.StructureToPtr(cRegisterStr, instData, true);
  33.  
  34.             hr = pKs.Set(PROPSETID_CUSTOM,
  35.                 (int)KSPROPERTY_CUSTOM.KSPROPERTY_CUSTOM_REGISTER,
  36.                 instData,
  37.                 Marshal.SizeOf(cRegisterStr),
  38.                 regData,
  39.                 Marshal.SizeOf(cRegisterStr));
  40.             DsError.ThrowExceptionForHR(hr);
  41.  
  42.             if (regData != IntPtr.Zero)
  43.             {
  44.                 Marshal.FreeCoTaskMem(regData);
  45.             }
  46.             if (instData != IntPtr.Zero)
  47.             {
  48.                 Marshal.FreeCoTaskMem(instData);
  49.             }
  50.  
Now I just have to figure out why i can't do Marshal.PtrToStructure(regData, cRegisterStr) and pull the information back into a structure to look at.
Mar 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Paul Shaw | last post by:
Can anyone explain why an insert might cause multiple logical bufferpool data reads? Here's a situation that has me scratching my head. Table A's data resides in tablespace B Table A's...
10
by: Rattanak Song | last post by:
Hi, I'm trying to build a database which can capture a still image from a digital camera or web cam and import to the database via an Object or something like that. Any help would be very...
16
by: silentlights | last post by:
Hi Guys, I am looking for an alternative means of register access in a microcontroller. Currently my get() function looks like this.. ------------------------ implementation in comm.c...
2
by: Stupid48 | last post by:
I have this Pentax Optio camera and I want to access it via vb.net. I would like to write something where I can snap the picture from the application and it automatically acquires the image from...
10
by: =?Utf-8?B?RGljaw==?= | last post by:
I'd like to read a file's "extended" properties, i.e. for some JPEG images taken with a digital camera, I'd like to read the "Date Picture Taken" property. I can see this property from the Summary...
1
by: sanoyhm | last post by:
Hello guys, how r u doing? I'm doing a final year project, Gesture recognition and am using video camera and vb.net for my project. But am now facing a problem and am in need of ur help.Is there a...
13
ak1dnar
by: ak1dnar | last post by:
Hi, I need a big favour from you guys.Need to know how to set up a IP camera to access that using Internet. Before I start need to say, I am not from the same stream as you guys. Just a web...
13
by: Berco Beute | last post by:
I've been trying to access my webcam using Python, but I failed miserably. The camera works fine under Ubuntu (using camora and skype), but I am unable to get WebCamSpy or libfg to access my...
2
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
You're going to need to start with the driver for the camera - otherwise, your application might run into problems finding where the video is. Next, search (i.e. Google) into Twain Aquire...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.