Python interface to ToupCam cameras.
nmgrl / toupcam Goto Github PK
View Code? Open in Web Editor NEWPython interface to ToupCam Cameras
Home Page: http://www.touptek.com/product/showproduct.php?lang=en&id=108
License: Apache License 2.0
Python interface to ToupCam Cameras
Home Page: http://www.touptek.com/product/showproduct.php?lang=en&id=108
License: Apache License 2.0
Python interface to ToupCam cameras.
I found a .so library supposedly supporting armhf here: http://www.touptek.com/download/showdownload.php?lang=en&id=32
but am currently unable to get things working completely.
Specifically, the Toupcam_StartPullModeWithCallback function is returning a non-zero value and Toupcam_PullImage is returning an array of zeroes. Other simple functions are also returning non-zero response codes (e.g. Toupcam_get_HwVersion, Toupcam_get_SerialNumber). Relevant code below.
Unsure given the lack of error if this is user error on my part or some more legitimate bug, however
# Camera Initialization
class HToupCam(ctypes.Structure):
_fields_ = [('unused', ctypes.c_int)]
...
func = lib.Toupcam_OpenByIndex
func.restype = ctypes.POINTER(HToupCam)
cam = func(index)
# Start Pull Mode
CB = ctypes.CFUNCTYPE(None, ctypes.c_uint, ctypes.c_void_p)
def dummy_fn():
return True
frame_fn = CB(dummy_fn)
result = lib.Toupcam_StartPullModeWithCallback(cam, frame_fn)
# result = -2147467259
how to use autofocus with toupcam any example please give solution to solve
Can you please advise how to interface with several cameras? When I create an instance of the class, I always connect only to one of the cameras, unless I physically disconnect it.
Jake:
I just got all of your toupcam Python code working on Linux with my camera - a MU1403 14MP USB 3 that does stills and video. Great code by the way. The image is coming out fine.
I am trying to snapshot full size images but I am stuck at 1024x768. Any suggestions? The camera will do 2048x1644 and 4096x3286. I am trying to get to 4096x3286 and then adjust white balance. Any format is okay. I can always convert with ImageMagick.
And ps - I switched to lib.Toupcam_PullImageV2() in the code.
Thanks,
Joe
Project starts with aarch lib from here http://www.touptek.com/download/showdownload.php?lang=en&id=32
But returns only empty black frames
Related to the problem in #5 the dll file in the x64 folder is still incorrect, resulting in an error when loading while running 64 bit Python.
If that file could get updated with the one available at the ToupTek website linked in #5 it could save others from troubleshooting this. Might need to swap out the .lib file too - unsure if that one could be the incorrect version too.
Link for convenience: http://www.touptek.com/download/showdownload.php?lang=en&id=33
I am getting the error below when running the sample code:
File "C:\ProgramData\Anaconda3\lib\ctypes_init_.py", line 356, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
Here is my system description:
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Hi. I am not sure where to ask this, so here I am. I bought an SCMOS digital ocular, but did not get the installation CD with it. I downloaded the ToupView from the website, however, in the drivers ini there is no SCMOS listed. OS is Windows 10 and it discovers the camera as Vimicro USB 2.0 PC Camera (Venus). Can anyone help me with this issue?
Provided .dll in 'x86' is not recognized as a Windows 32bit .dll.
I've attached here a working version of the .dll.
toupcam_x86dll.zip
Hello,
my toupcam camera is connected via ethernet and not USB. It has a static IP address and it seems to connect correctly with the ToupCam Lite software for Linux, but how would I go about using this Python Interface with it. Is there a place where I can specify the IP address in the code or do I need to edit/add something?
Hi,
I have a problem when trying to execute the do_awb() function. Python 3 gives me the following error:
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 234, in 'calling callback function'
File "/media/luca/70B60ED66D483C58/travail_luca/Pollen_Reader/code/controle/controle_python/camera.py", line 216, in temptint_cb
callback((temp, tint))
TypeError: function name must be string, bytes object or integer
Can you please help ? Thanks in advance,
ltp7
Hi, I keep getting the following error when trying to run camera.py:
Traceback (most recent call last):
File "c:\Users\akq190000\Downloads\toupcam-20210804T155303Z-001\toupcam\camera.py", line 279, in
cam.save('foo.jpg')
File "c:\Users\akq190000\Downloads\toupcam-20210804T155303Z-001\toupcam\camera.py", line 55, in save
image = self.get_pil_image()
File "c:\Users\akq190000\Downloads\toupcam-20210804T155303Z-001\toupcam\camera.py", line 82, in get_pil_image
raw = data.view(uint8).reshape(data.shape + (-1,))
AttributeError: 'NoneType' object has no attribute 'view'
I have 2 cameras connected to my computer that work fine with other code and I'm not sure where this error is coming from. I am sort of a beginner in Python so apologies if it's an obvious thing I missed. Any help is appreciated!
Hi,
I am giving video resolution (19201080) and Image Resolution (38402160) when I am calling snap callback function taking 950 milliseconds to snap. With video and Image resolution same it is taking 150 milliseconds. How to reduce that delay of snap callback in different resolution.
I have a BMS11000A and i want to retreive an image, but the example code does not work. I assume the function get_frame is supposed to be called in camera.py at line 118, but i cant trace back a single call. Im on windows 11 atm, im running it on python 3.10.1 on 64bit, and i have adjusted the code to py3 as far as i know. But ultimatly, i want to run it on a raspberry, where the .so file cannot be loaded, I assume.
On win11 i get this error:
Traceback (most recent call last):
File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Users\bubig\.vscode\extensions\ms-python.python-2023.4.0\pythonFiles\lib\python\debugpy\__main__.py", line 39, in <module>
cli.main()
File "c:\Users\bubig\.vscode\extensions\ms-python.python-2023.4.0\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 430, in main
run()
File "c:\Users\bubig\.vscode\extensions\ms-python.python-2023.4.0\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 284, in run_file
runpy.run_path(target, run_name="__main__")
File "c:\Users\bubig\.vscode\extensions\ms-python.python-2023.4.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
File "c:\Users\bubig\.vscode\extensions\ms-python.python-2023.4.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "c:\Users\bubig\.vscode\extensions\ms-python.python-2023.4.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "D:\temp\toupcam-master\toupcam-master\examples\capture_loop.py", line 49, in <module>
main()
File "D:\temp\toupcam-master\toupcam-master\examples\capture_loop.py", line 44, in main
cam.save(path)
File "D:\temp\toupcam-master\toupcam-master\camera.py", line 55, in save
image = self.get_pil_image()
File "D:\temp\toupcam-master\toupcam-master\camera.py", line 82, in get_pil_image
raw = data.view(uint8).reshape(data.shape + (-1,))
AttributeError: 'NoneType' object has no attribute 'view'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.