How can I use WIA and Twain in C#? The TWIAIN/C# example found at http://www.codeproject.com/KB/dotnet/twaindotnet.aspx Throws an exception at line 59 on TwainLib.cs "an attempt was made to load a program with an incorrect format." on Vista 64.
I would use WIA but it does not have support for all of the devices I want to use.
Is there a simple way to enable TWAIN support in WIA in C#? I know it can be done but I cannot find any documentation on the subject. I am not looking for a commercial product. I can figure out how to use WIA just fine - but its the fact that I cant enable TWIAN support that is annoying.
Examples in C++/CLI or VB.net are also welcome.
Thanks.
EDIT
Thanks, cristianlibardo. You helped me out a lot and I might just continue to use TWIAN for now. But I am still wanting to use WIA; so I will not accept your answer yet. Here is some more info for people just seeing this post. All are in response to this answer:
Yup, that did it for the TWIAN support; thanks! I still want to use WIA though; but now I have something to work with. However, when I select my USB camera as the source and hit acquire, the app hangs. My camera works on other, commercial, TWIAN applications.
By commenting out the lines 100 though 104 (code that checks to see if "DScap( appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap );" returns TwRC.Success my Camera now works. I have no idea what this code does; as documentation is next-to-nothing on this subject.
OK; its a const called "CAP_XFERCOUNT" that has something to do with scanning multiple images per session. Makes seance that a camera would not support it.
Probably a long shot but have your tried building with x86 as platform target or changing thread apartment state?
Related
Since a while I am working with HoloLens2. My last OS-Versions were 10.0.18362.1005 and 10.0.19041.1109. I am developing with Unity 2019.4.7. My whole code was and still is running great on those old OS-Versions. Now I updated to OS-Version 21H1 and I have huge problems with everything including networking.
For example, my Mixed-Reality-WebRTC Pluging (from Microsoft), which only supports ARM-Architecture, does not work anymore on my new Device. The app crashes after it was successfully starting.
Another thing is, that the DevicePortal does not transmit virtual inputs. Again, on my older HoloLens2´s Virtual Input works great.
Also, even if I disable WebRTC parts of my Project, I still get an Exceptions in my Networking-System which I can´t assign to any cause. In term it is useful for you, I work with windows.Networking Library and in special with DatagramSocket.
I would be really glad if anybody could help me with this. Is OS-Version 21H1 restricted to any specific Unity- or VisualStudio Version (here currently I use 16.4.5)? Or is it Restricted to specific Networking Libraries? Thanks in advance!
Now I was able to fix the Networking Exception. The reason for that is located within my UDP-Communicator which uses DatagramSocket. Since earlier .Net.Sockets was not available at HoloLens2, now it is and I coincidentally came across this information. So I switched my implementation to .Net.Sockets which already exists in my project for editor-usage and now basic networking works fine.
Also, I was able to make WebRTC work again. With one of my Provisioning-Packages I disabled the usage of microphone for mixedReality and it seems like access to those audio-informations is mandatory for MR-WebRTC.
Unfortunately, I still have the same issues with Device Portal.This really looks like a bug.
Having searched high and low for native c# hook to webcam, I found 5 basic ways to interact with the camera.
Video for Windows (VFW)
DirectX
avicap32.dll
WIA
3rd party tools
My requirement is to take a photo. The application will be used on some legacy windows XP and Vista machines, but going forward Windows 7 and greater will be required. So what might the best approach be with the broad install base? Just reading WIA looked like the way to go but looks like some changes were made so it works a little different now (I don't know for sure). I understand that some people have done combos.
Might need to crop photo, but that is really about it.
For school visitor monitoring.
I think the best thing is to use the WIA. I know a third party toolkit that could help you doing your requirements which is leadtools. You can check this Tutorial
I would always try to pick up something already on the web and tweak it to my own needs... some open source project or an example where the mainly portion of my app is already made.
on Codeplex you can find a nice library to work with webcams and it's simply called
WebCam Library for WinForm and WPF with C# and VB.NET
Give that a try, maybe you can even help the project, by contributing your own findings, and everyone is a winner... isn't Open Source a great idea?!
I am trying to put a Flash ActiveX control into a Windows Form but I am running into a problem: a lack of documentation. The best I have found is a site called "F-IN-BOX" that has some documentation but much of the API is still a black box. For example, some property will take an integer or a string and provide no clue about what it wants. Another exanple is the FlashVersion() function that inexplicably returns 655361 on version 10.
Incidentally I'm having the same problem with Apple's Quicktime OCX. I've searched both sites and Google and I'm starting to wonder if either of these companies provide documentation for any of their products. Does anybody know where I can find documentation for either of them, even if it's the unofficial variety?
Well once i worked with flash on a windows form, I took this example to get started, and the second link its a flash game being loaded to a winform
http://www.codeproject.com/KB/audio-video/flashexternalapi.aspx
http://www.csharphelp.com/archives/files/archive81/cSharpFlash.zip
Hope this helps anyone, about documentation i didn't find any when working on that project i reached Adobe but i never got an answer from them :/
Alex
Adobe help take a look at this sample. It's very simple and nice to use.
You should stick with ExternalInterfaceProxy all time because it simplifies communication 100x times.
I have a Creative Life CAM Optia AF webcam, the software included in the package is able to control the camera in different ways, like set autofocus to auto or manual, and a bunch of gamma and brightness settings.
I'm capturing the feed with the AForge Computer vision library, and it's working great.
But i would like to be able to set the manual focus from inside my application.
Ive been searching for a tutorial, but come up empty handed.
Can i somehow either disassemble the included software, or is there some way to fetch the traffic / instructions being sent to the device?
Thanks in advance.
If the license agreement that comes with the software allows you to disassemble it, you can do so with Reflector (assuming that it's a .NET application).
How to programatically disable the auto-focus of a webcam?
I think i found a way to do this. But i have never written any C++, that is C++ right?
Thanks :)
I'm developing small app in C# 3.5 for Windows XP that will automatically download images and video from a camera to a PC, on camera plug-in via USB.
I have a Canon ixus 50 camera and I figure out how to get images from that camera to the PC, but I just can't figure out how to get/download AVI format videos. Can someone help me please?
It's true that I'm using WIA 2.0, but it seems to be working for now. :)
I have never ever managed to get WIA properly working.
Sometimes it worked almost fine for photos but there was no video.
Some other times it would never work on my customers' PCs (same camera, same PC specs).
Finally I completely gave WIA up and managed to create my custom control based on DirectX.
What I've found
Using Expression SDK to get image/video: http://www.codeproject.com/Articles/202464/How-to-use-a-WebCam-in-C-with-the-NET-Framework-4
DirectShow: http://www.codeproject.com/Articles/18511/Webcam-using-DirectShow-NET.
DirectX Capture (AVI): http://www.codeproject.com/Articles/3566/DirectX-Capture-Class-Library.
Keep in mind
It's really easy to work with. Requires some Expression (SDK) DLL and for that it will work only in x86 and you will have to set your app from AnyCPU or x64 to x86. Period.
Works really fine but this is more to static pics.
Never tested but looks really close to your needs. Can't say if it works but I'll go that way for testing, at least.
My thoughts
WIA is rather simple and easy. I've used it on Delphi and Clarion software (both are native Win32). It's somewhat fine but nowadays WIA is not the way to go.
Many webcams simply won't work with WIA and you'll have to tell your customers to change their webcam to a strangly-named chinese/korean/wtf brand just to keep your app working.
Try the last option. At least, download and run the code.
Hope it helps.