[C#/C++] Camera Access with DirectShow - Windows Mobile Development and Hacking General

Hi Guys,
Because the standard API's to use the camera aren't flexible enough I need to use directshow.
Unfortunately I'm not a very good C++ programmer (more C# ;-))
I found this solution. Wich compiles a C++ DLL and can be called from C#.
Perfect! Except the C++ code doesn't really do what I want to. (And I have no idea how to change it)
See attachement for the C++ project
Dll does: Capture one frame from the camera and store it as a file. (with 320x240 resolution, not great quality)
I'd prefer to use the best available quality, or mayby choose the quality I want.
Also I'd prefer not saving/storing the file but return a stream / bitmap / image
Because I only want to show it on screen (actualy let a mobile webserver respond an image with as much frames per sec as possible)
(Saves a step, storing and deleting everytime)
Any Help?
PS. I also tried Directshow.Net Library But it doesn't seem to work on Windows Mobile.

C# Code
Btw, this is the code I use in C# to create the functions:
[DllImport("CameraCaptureDLL.DLL")]
private static extern bool CaptureStill(string Path);
[DllImport("CameraCaptureDLL.DLL")]
private static extern bool InitializeGraph(IntPtr hWnd);

Just to keep y'all posted, I'm now looking @ this solution (CodeProject.com)
They rewrote the DLL file, and I think it's gonna do what I want, but I first need to install Windows CE 5.0 wich takes alot of time....

I met same problem with you.
I just want to show the camera sight, like the Camera app's Preview function.
I don't know if there is a HTC's Camera SDK.
Please keep contract, if I have any improvment, I will tell you.

I had fun with camera but not using directshow or the preview...I'm just launching the camera app (using sample camera in SDK).
If anyone find an easy way to have "embedded camera display" in an application I'm really interested!! (like a pictureBox having camera as image source)
If I found something I'll tell...

DarkAngelFR said:
I had fun with camera but not using directshow or the preview...I'm just launching the camera app (using sample camera in SDK).
If anyone find an easy way to have "embedded camera display" in an application I'm really interested!! (like a pictureBox having camera as image source)
If I found something I'll tell...
Click to expand...
Click to collapse
I found functions and its parameters by sniffig camera calls on my VOX
Captured data is stored as UYVY.
m32

m32 said:
I found functions and its parameters by sniffig camera calls on my VOX
Captured data is stored as UYVY.
m32
Click to expand...
Click to collapse
Could you provide the compiled version of the htccamera dll ?
Will try to build this later (@work don't have cc compiler, just VS2008)
Thanks!

An in-memory capture would almost certainly improve the live-scan mode in Barcorama also! I could really use that in-memory capable CameraCaptureDll.dll.
Many users seem to have successfully compiled the source at http://www.codeproject.com/KB/mobile/samplegrabberfilter-wm6.aspx, but I can't find the compiled dll somewhere .
I fail to compile it myself as it needs the WindowsCE Platform Builder and VS2008...
Anybody that comes across the DLL, please share!
have fun,
hypest

Hello,
working on it ^^ I will upload the dll here later today

Here you go : download (if fails : try here)
is the source code compiled (look in /bin/Release). Tested and works nice (deploy the dll then the sample app).
Hope this helps!

Thanx!!
will try it!
UPDATE:
The sample opens up but seems to do nothing on my kaiser. <-UPDATE: wrong! it works OK.
I have managed to use the DLL directly though. The capturing works fine but the capture-stop seems to fail: the Stop() function hangs. I use the Shutdown() that seems to be OK, but then I have trouble re-initializing the whole procedure. Also, there seem to be a sensitivity on manually using the garbage collector.
Thanks again anyway!!

Cannot seem to import the dll into another project
@DarkAngelFR
Thanks very much for the sample app for video streaming, was very helpful.
However I really need to use the dll or even the import the CameraCaptureDLL c++ code into our project. I have already read over the ReadMe text file but need further help on how to create this object? Have already tried the Ignore Input Library property and that does not work sadly. Any help would be great!
Thanks,
John

m32 said:
I found functions and its parameters by sniffig camera calls on my VOX
Captured data is stored as UYVY.
m32
Click to expand...
Click to collapse
I have build the camerasniffer dll (and called it htccamera.dll) with mingw32ce, but how do I use it?
I tried copying it to "/windows" and rebooted the phone (hermes) but I do not get a log file on the storage card. Any hints?
Thanks a lot!

Hi,
I got this error when I try to debug this application on my mobile (HTC HD2)
"An unhandled exception of type 'System.MissingMethodException' occurred in TestCameraCapture.exe
Additional information: Can't find PInvoke DLL 'CameraCaptureDLL.DLL'."
But it seem to works fine on the Emulator.
How can I test it on my mobile then?
EDIT
Problem solved, I just had to copy the 'CameraCaptureDLL.DLL' file to the folder where the application is running.

Related

Leading underscore in function name

Hi!
I try to integrate an external library into my vs2005 project while using the Windows Mobile 6 SDK. Of course, I added the additional directories and dependencies to the project settings, but I get some LNK2019 errors anyway.
So I created a dump of the *.lib files using "dumpbin.exe" and discovered that all function names start with a leading underscore. I found some precompiled parts of the library where there are no leading underscores in the function names and I can call them without any problems. But if I build those parts of the library on my own, there again are the LNK2019 errors and the "_functionname()" convention in the *.lib files.
Is there either a way to avoid those underscores when compiling the library or to call those function out of a windows mobile application?
Thanks in advance!
This looks a bit odd.
C++ decorates exported functions unless you add a def file to the project, but there is always way more garbage in the names.
What I don't understand is, why do you have a problem using a function that starts with an underscore?
Such names are perfectly acceptable in C / C++, in fact some C native functions like _wfopen start with an underscore.
What language are you programming in?
Also it might help find the solution, if you tell us what library you are using. Is it something available for download or your own creation?
Thanks for your quick reply.
I am working on a porting of the intel openCV computer vision library and I try to include it into a VS2005 C++ projekt created with the wizard for windows mobile 6.0 sdk for testing.
It seems that the problem appears when I switch the system to "/SUBSYSTEM:WINDOWSCE". Otherwise the library works perfectly.

Yet Another CellID Application

yes, but based on a flexible set of methods
-Using RIL (GSMTestMode)
-Using RIL_GetCellTower
-Using RIL Notifications
-Using RIL (fieldtest) -> reply structure has to be found
-Using offset method (few structures included)
-Using COM port
The project is based on:
-cellguardian.dll and cellguardian.xml : How to get CELLID on devices
-cell2latlon.dll and cellDb.xml : Calculate lat/lon using CELLID
-gsmcelluloz.exe : the main exe
-gsmcellulozCF.exe : the same, as PoC, in CF, but very simple
http://usuc.dyndns.org/tv/gsm/gsmcelluloz/
DEBUG mode creates a lot of log in \Temp
The device method configuration is in a file called "cellGuardian.xml"
Offset version works only with the "ALL" parameter (I don't know what defines the offset, which component version?)
Many things should be incomplete (like documentations )
Here is a google map (result from logging) made using a GSMTestode compatible device:
http://usuc.dyndns.org/tv/gsm/releve_poly.php
I'll write a quick documentation on how using cellguardian.dll (the brain from the cellid-getting), and cellguardian.xml.
I'm also working in antenna position interpolation but it's an harder process... (for now the cell2latlon works but uses a very simple barycentric algorithm)
Sample walk:
http://usuc.dyndns.org/tv/gsm/testParcours.php
Have fun, I hope to have some fieldtest compatible device log in order to decrypt the structure
If your device is still not working... Tell me!
The source will be released as soon as the modaco challenge will be finished (I hope to win a device with cellguardian.dll... or a sticker )
Did not work for me Tornado with Crossbow-Rom, i think you may ask maniac for the Offsets, he created CellProfileSwitcher, an very useful SmartPhoneTool with a huge list of compatible devices.
In Combination with your Tool it may be useful to create my own "CellMap", to see my Homezone or some other kind of zones, switched by CPS,yea.
But the Screenshots looks nice,...
Thank your for another nice way to waste my time with my lovely Phone,hehe...but i need the offsets...dont know how...
Have you tried "Find offset" in the 8FFB0000-8FFC0000 range?
8FDC0000-8FDD0000
8F1D0000-8F1E0000
8A3B0000-8A3C0000
8A4B0000-8A4C0000
8C0D0000-8C0E0000
Are other possible ranges.
The result will be contained in a file located on \Temp
Possible structures (if you define your configuration in cellguardian.xml)
TORNADO
TYPHOON
IPAQ
MPX220
WIZARD
Offset method will be activated once you'll have removed other options (COMPORT...) from the config file.
Remember that as long as I don't know what defines the offset, the only version that works is "ALL". This field will be used once I'll be quite sure the component version defines really the offset.
I hope to improve it, but also to let a chance to the user to configure it by himself.
Quick help page
I made a quick help page to help ppl finding the offset until I find some cleaner way to find it...
http://usuc.dyndns.org/tv/gsm/help/
After this, just modify \Program Files\cellguardian.xml
and replace
<device name="HTC Tornado">
<OEMID>Qtek 8310</OEMID>
<method type="RILHTC1"></method>
<method type="RILTOWER"></method>
<method type="COMPORT"><port>COM9:</port></method>
</device>
Click to expand...
Click to collapse
by
<device name="HTC Tornado">
<OEMID>Qtek 8310</OEMID>
<method type="OFFSET">
<offset version="ALL" structure="TORNADO">YOUROFFSET</offset>
</method>
</device>
Click to expand...
Click to collapse
Where YOUROFFSET is the offset you found (try the adresse ranges I suggested above)
Let me be your tester
Hello!
I have found your excellent project and I am going to test it and share with you results. My phone is smartphone - HTC S310 (know also as HTC Oxygene, SPV C100).
When I am launching the application I get error:
Cannot load \Program Files\GSMCelluloz\CellGuardian.dll:0x7e126
Is your app suitable for smartphones? I have downloaded the
GSMCelluloz_SP5_R.CAB.
Maybe I should use:
GSMCelluloz_WM5_R.CAB?
What offsets sould I put to test my phone and which method?
Best greetings and congratulations for your job!
RA
Solved
abramq said:
When I am launching the application I get error:
Cannot load \Program Files\GSMCelluloz\CellGuardian.dll:0x7e126
Click to expand...
Click to collapse
Hi again!
The problem was because I've installed app on card, not on device memory.
Cell searching works excellent, on my phone works GSMTestMode method (I am going to find out the differences between methods, but don't know where).
By the way - user interface for smartphone (non-touch display) looks like not fnished - 'backspace' keys doesn't work and it is difficult to leave edit mode too.
Will test it more and make some enhancement
Best greetings and please keep working
JA
P.S.
What Compact Framework needs the CellulozCF? I have the 2.0 and the app doesn't work (I get the unexpected error: Microsoft.AGI.CommonMISC.HandleAr() in System.Windows.Forms.Control._InitInstance.
I think the best cell id application from all times ever would be that which can change phone profile depending from location. I saw someone here is trying to do it, but will not be free, so no use. An app like that will eclipse all other... it will be like the next step in mobile evolution. Probably japanese already have it.
You are outDated...this idea is really old...lookat maniacs Homepage;
Maniacs SmartPhoneTools
...but for now not useable on devices without TiOmapProcessor
But PhoneAlarm by PocketMax supports different [email protected],too.. but cost money and hard to configure,no learningfunction,no neighbourcells and you have to add every Cell one by one...
but youre right,too; Actions by Locations are always missed in Apps with Notifications or ProfileChangingFunction.

Split Video with NDK for Android...

Hello,
I have to do a task, that is more specific than a pure android development. I have to create an android application with a core module written in C or C++ language, doesn't matter, to do some video processing stuff. For example, the scenario is as follows:
1. The Android application captures 10sec video clip from the camera of an Android device;
2. Pass the captured file to the core of the android application;
The core should do the following:
3. Waits for the file, gets the file and opens it;
4. Splits the file into frames - for example, if the camera captures 30fps for 10 seconds video - 300 pictures in png or jpg format;
5. Do some calculations - for example it makes a histogram of a single image and stores it somewhere (db or file, doesn't matter);
6. Returns the result to the Android Code/Java/ which will render it on the default output - e.g. Screen, Console, etc...
How can I do this? I have searched how to split the video file into frames on linux, and I found that it could be done with ffmpeg, but I never dealt with ffmpeg and video/image processing... Could you help me somehow? I don't know what to do and where to start from...
Thanks in advance!
Best Regards,
v4o4ev
Possibly OpenCV / JavaCV
i dont know the exact code but i am sure you can get histograms and stuff with it.
try looking here
http://code.google.com/p/javacv/
Pvy.
pvyParts said:
Possibly OpenCV / JavaCV
i dont know the exact code but i am sure you can get histograms and stuff with it.
try looking here
http://code.google.com/p/javacv/
Pvy.
Click to expand...
Click to collapse
Thank you! The problem now is how to split the video into frames... I am searching about ffmpeg compatibilities, but for now I'm just researching... And one thing - I don't need the code, just the help to find some information about how to do it better and so on thank you so much for the reply - I will take a look now
Thanks!
Best Regards
v4o4ev said:
Thank you! The problem now is how to split the video into frames... I am searching about ffmpeg compatibilities, but for now I'm just researching... And one thing - I don't need the code, just the help to find some information about how to do it better and so on thank you so much for the reply - I will take a look now
Thanks!
Best Regards
Click to expand...
Click to collapse
In java I use the highgui classes, createframegrabber or something like that. I grab each frame and process it for item/motion detection. Then save a movie from it. Works well enough.
Sent from my Galaxy Nexus using xda premium

[LIBRARIES][SOURCE] WP8 Native Access project

This thread is for announcements and discussion around the WP8NativeAccess project (https://wp8nativeaccess.codeplex.com/). The purpose of this project is to provide general-purpose libraries, usable from C++ or .NET, which enable access to the underlying functions of the OS. In some cases, this will mean simple wrappers around native APIs; in other cases, these will be more advanced operations which simplify using the low-level APIs.
Some of the functions that the Native Access project exposes are already available via the official APIs. Other functions, however, are not. While I have no objection to these libraries being used in Store apps (license permitting), it is unlikely that Microsoft will permit the ones which use unofficial APIs.
Note that this library does not provide any method for elevation of privileges. Consequently, the use of these APIs will be constrained by the sandbox in which all third-party WP8 apps run, as defined by the capabilities in the app manifest. In practical terms, this means that most of the system will be either inaccessible or read-only. Even so, it has already proven useful to myself. When combined with interop-unlock and Capability-unlock hacks (making it possible for apps to obtain higher privileges), these APIs become much more useful. In fact, the EnableAllCapabilities utility uses the Registry library. Similarly, if you have the ability to use restricted Capabilities in an app you are developing, you may find these libraries useful.
The libraries are as follows:
FileSystem version 0.4.0: Implements functionality to read, write, and get information about files and directories, plus supports creating symbolic links and enumerating file system volumes. This version contains a breaking change from 0.3.x: the NativeFileSystem functions are now static and the constructor is removed. This library may be built with or without the macro USE_NON_PUBLIC_APIS; by default it now includes this macro and require kernelbase.lib to build. If this macro is not defined, it builds using the public APIs without requiring any special libraries.
Registry version 0.2.9: Implements functionality to read and write registry values, and to create and delete registry keys and values. Many, though not yet all, registry value types are fully supported. This library consists entirely of non-public (for WP8) APIs and requires the KERNELBASE.LIB and ADVAPI32LEGACY.LIB export libraries for Windows Phone 8 in order to build (the DLLs are in C:\Windows\System32 on the phone; you can use Dll2Lib.exe to extract the .LIB files).
Processes version 0.1.0: Implements basic functionality to get information about your process, and to create or kill a child process. Very early version.
They are licensed under the Microsoft Permissive License.
The FileSystem and Registry libraries are currently being used by my WP8 File Access Webserver project (http://forum.xda-developers.com/showthread.php?t=2355034).
My EnableAllSideloading app uses the Registry library (http://forum.xda-developers.com/showthread.php?t=2435697).
@hjc4869 has a basic FileExplorer app which uses the FileSystem library (http://forum.xda-developers.com/showthread.php?t=2497788).
You may need to use 7-Zip or another extraction program better than the built-in Windows Zip extractor to open the archive.
Reserved for OP...
Updated. This will be the main place on XDA for releases of the NativeAccess libraries going forward. Additionally, please report problems or make feature requests here.
I think there should be some way to list all the volumes...
Perhaps windows runtime has provided an async win32 file API wrapper which has the same ability as win32 ones ,so I think undocumented file API and registry ,process and etc are more important.
The latest version of the NativeFileSystem library can give you the mount points (as strings) for all volumes (C:\, D:\, etc.)... I implemented that a few days ago; it should be in this update. Sorry for not highlighting that more clearly (typo in the OP fixed now).
Can't open "NativeAccessLibraries_040_029_010.zip"
Edit Ok with 7-zip
How odd, you're right. I didn't do anything terribly fancy while building that ZIP, so I really don't know what's up with that.
I have added the NativeFileSystem library to my PDF to Office app...
Thanks again for all your work !
@GoodDayToDie: Congratulations, good work! Unfortunately I can't import the registry library, it says it's not a valid DLL. I have Visual Studio 2013 Pro. Does it work for WP8? Please help me solving the problem. Thanks!
Sent from my Windows Phone using Tapatalk
myst02 said:
@GoodDayToDie: Congratulations, good work! Unfortunately I can't import the registry library, it says it's not a valid DLL. I have Visual Studio 2013 Pro. Does it work for WP8? Please help me solving the problem. Thanks!
Sent from my Windows Phone using Tapatalk
Click to expand...
Click to collapse
You need to reference .winmd file, not the .dll file.
Thanks! Can we also modify hex registry values with it?
Sent from my Windows Phone using Tapatalk
If you have the required permissions, yes. There's read/write functions for REG_BINARY, and also a simple wrapper around RegSetValue that will work for any type.
However, the library doesn't actually give you any privileges your app didn't already have. Without special Capabilities (which usually require hacks to enable), you won't have write access anywhere in the registry at all...
GoodDayToDie said:
If you have the required permissions, yes. There's read/write functions for REG_BINARY, and also a simple wrapper around RegSetValue that will work for any type.
However, the library doesn't actually give you any privileges your app didn't already have. Without special Capabilities (which usually require hacks to enable), you won't have write access anywhere in the registry at all...
Click to expand...
Click to collapse
OK, thanks, but another question: I referenced .winmd file, but it gives me error, the component was not found. Any idea how to fix it?
Do you have the DLL and the WINMD in the same location? Are you creating a WP8.0 app (I don't know if apps targeting 8.1 specifically will work)? Are you building for ARM?
Yeah, I have. Library now working, but it doesn't recognize the commands, I mean if I write NativeRegistry.ReadDWORD command not found :/ Can you help me?
Sent from my RM-915_lta_lta_330 using Tapatalk
You're going to need to be way more specific.
How far did you get, i.e. can you compile the app? Install the app? Launch the app? Does it crash immediately or does it actually load? Etc.
What, *exactly*, breaks? Does it break when you try to reference the NativeRegistry library, or only when you try to actually use ReadDWORD function, or some time later? If you are able to call readDWORD, what is the return value? If it fails, what is the error code?
Are you getting an exception, or does it just not work? If it's an exception, give me as much detail about it as you can (the type, the message, the code where it happened, etc. if possible).
myst02 said:
Yeah, I have. Library now working, but it doesn't recognize the commands, I mean if I write NativeRegistry.ReadDWORD command not found :/ Can you help me?
Sent from my RM-915_lta_lta_330 using Tapatalk
Click to expand...
Click to collapse
Try to rebuild the solution.
GoodDayToDie said:
You're going to need to be way more specific.
How far did you get, i.e. can you compile the app? Install the app? Launch the app? Does it crash immediately or does it actually load? Etc.
What, *exactly*, breaks? Does it break when you try to reference the NativeRegistry library, or only when you try to actually use ReadDWORD function, or some time later? If you are able to call readDWORD, what is the return value? If it fails, what is the error code?
Are you getting an exception, or does it just not work? If it's an exception, give me as much detail about it as you can (the type, the message, the code where it happened, etc. if possible).
Click to expand...
Click to collapse
Hi, I can't even build it, it doesn't recognize the command and makes a red line under it. I can reference the library, but not use any commands like ReadDWORD, WriteDWORD and so on. Screenshot is attached, this is happening if I load your EnableAllSideloading App, for example. With self-created projects I have the same problem. My system is Win 8.1 Pro x64 and I'm using Visual Studio 2013 Professional. Can you help me? Thanks!
You have added
Registry.winmd in reference library
and
Using Registry;
in your source code
Source code for EnableAllSideloading already has the requisite using directives...
When you look in the project's References, is the Registry library referenced correctly? By default it'll try to use a relative path that I use on my PC, but probably not the same path you use. You may need to manually adjust the reference, or delete it and re-create it.
Alternatively, what auto-fix options does Visual Studio give you when you click on those red lines?

Using Dual-Camera to produce a stereostopic view in realtime

Hey there,
I tried to create an app with the HTC One M8 and it´s Duallens "depthsensor".
The problem is that there is no way to activate the second rear camera in android.
In android.hardware.camera package there are some hidden methods like : enableSubCam...so I´ll tried to use java reflection to activate these SubCam, but it doesn´t work at all...
I need some depth information in realtime for my application and I thought with the new DualLens this would be possible.
Also I tried to understand the HTC DualLens SDK, but all this stuff works on an jpg format and without creating an new depthMap
So what do you think is the best method to access 1. the second rear camera or 2. directly some kind of depthMap with help from HTC SDK?
gurd123 said:
Hey there,
I tried to create an app with the HTC One M8 and it´s Duallens "depthsensor".
The problem is that there is no way to activate the second rear camera in android.
In android.hardware.camera package there are some hidden methods like : enableSubCam...so I´ll tried to use java reflection to activate these SubCam, but it doesn´t work at all...
I need some depth information in realtime for my application and I thought with the new DualLens this would be possible.
Also I tried to understand the HTC DualLens SDK, but all this stuff works on an jpg format and without creating an new depthMap
So what do you think is the best method to access 1. the second rear camera or 2. directly some kind of depthMap with help from HTC SDK?
Click to expand...
Click to collapse
i remember there was an app (german) that take 2 pictures at the same time from both rear cameras but the app was just to show that both work so it was like open app>automatic capture>save both pictures>exit.
got it : http://forum.xda-developers.com/showthread.php?t=2722352
yeah I´ve seen this app, but it´s hard coded on the linux kernel ...
and like I said I´ll try to calculate the depthMap in realtime, so a continious Depth-Matrix with opencv for example and not just a jpg
isn´t there a possibility to access the hardware components of an smartphone and activate them?
gurd123 said:
yeah I´ve seen this app, but it´s hard coded on the linux kernel ...
and like I said I´ll try to calculate the depthMap in realtime, so a continious Depth-Matrix with opencv for example and not just a jpg
isn´t there a possibility to access the hardware components of an smartphone and activate them?
Click to expand...
Click to collapse
Maybe this will help you
Code:
[URL="https://www.htcdev.com/devcenter/opensense-sdk/htc-dual-lens-api/htc-dual-lens-sdk-installation/"]https://www.htcdev.com/devcenter/opensense-sdk/htc-dual-lens-api/htc-dual-lens-sdk-installation/[/URL]
like I said in the first post, I´ve tried to understand the SDK, but in my oppinion it´s not for creating a file...
you´re just allowed to use the already created depth information of an jpg-file...
or has anyone made some other experiences with the SDK?
Have you solved the problem?
Hi,
I have the similar situation and would like to know if you have found a solution to this problem.
I agree with you that the SDK provided by the HTC website is for depth info extraction from already created image. The SDK is not viable for realtime depth processing.
Please let me know if you have the solution for this problem.
Thanks!
gurd123 said:
Hey there,
I tried to create an app with the HTC One M8 and it´s Duallens "depthsensor".
The problem is that there is no way to activate the second rear camera in android.
In android.hardware.camera package there are some hidden methods like : enableSubCam...so I´ll tried to use java reflection to activate these SubCam, but it doesn´t work at all...
I need some depth information in realtime for my application and I thought with the new DualLens this would be possible.
Also I tried to understand the HTC DualLens SDK, but all this stuff works on an jpg format and without creating an new depthMap
So what do you think is the best method to access 1. the second rear camera or 2. directly some kind of depthMap with help from HTC SDK?
Click to expand...
Click to collapse

Categories

Resources