I'm busy with a project to make a custom printer. basically a RPi/beaglebone connected to a gantry with stepper motors and a print-head.
I'm working on getting this setup to print an image from memory (with python), but I want to be able to print essentially any format from any application.
At this point I think the easiest way would be to setup CUPS on RPi to appear as a network printer over Wi-Fi. I've seen a few tutorials showing how to do this with a regular USB printer.
So I'd like to know how to write a custom CUPS raster driver that just takes the file and saves it as a raster image in memory at a specific dpi.
Otherwise, I'd like to know if there is an easier way to do this. It seems one should be able to simply query CUPS for a raster version of any job in the queue, not so?
Related
Heading I need to get an image at the same time (almost, it is possible to take turns in a loop) from two PS3 Eye cameras, and then work with them using OpenCV.
We need drivers for the ps3 eye multicam (for example, these are not suitable https://codelaboratories.com/downloads/)
As an option for drivers there is a program zadig(https://zadig.akeo.ie/), and in particular WinUSB (libusb), but OpenCV Python (the standard function cv2.VideoCapture) sees only one camera. I found a project that can use several cameras at once in OpenCV with WinUSB drivers (libusb) - https://github.com/psmoveservice/PSMoveService/releases (Open bin/test_camera.exe). But it is written in C++ and due to its incompetence in this programming language, I could not port the code to python.
In the end, I need drivers and Python code to use the ps3 eye multicam in OpenCV.
Try checking this. Get the environment you want to build.
https://github.com/bensondaled/pseyepy
Let's you configure the camera as well.
I'm looking to write a program to change the DPI setting on my logitech G502 mouse (My goal being to use the program with AutoHotkey to help automate a task where I switch my DPI allot and to learn a bit about USB). I'm fairly fluent in C++ , C# and python. But I'm not at all knowledgeable on USB or drivers.
So far I have: used the program USBlyser to identify a Control transfer sent to my mouse when using Logitech's software, which byte of the data corresponds to my DPI setting, and the product ID and Vendor ID of my mouse.
After looking around on the net I decided PyUSB would be a good option for communicating to my mouse. After installing libUsb for use with PyUSB I realised that this then replaces my current mouse driver and makes it unusable.
Am I just going about this all wrong? In my head all I want to do is send to my mouse the data "10 FF 0E CA 01 00 00", should I instead be somehow communicating with my existing logitech driver to do this? Or can I set-up libUsb without interfering with existing drivers?
Any help will be appreciated, cheers Bradley.
libusb doesn't interfere with anything. In PyUSB you choose to communicate directly with the device. To do this any other app holding this USB port have to be stopped.
Windows driver in your mouse case.
I think it may be possible for you to push the DPI activation code while driver is still using mouse, but how, I have no idea now.
Or you may detach mouse temporarily , pass the code, and then release mouse back to Windows, hoping that DPI config wouldn't be reseted.
If that doesn't pass, you may always completely emulate mouse driver. It is very easy.
There are code samples for PyUSB on internet on how to interpret mouse data. So you do it and you pass the recognized command to OS either directly through Windows API or using PyMouse library.
In this case you do not need driver, because your program is one, and it sends to mouse whatever you want.
You have a lot of options how to do what you want.
For instance, if this is only for your local use, and there is interface already doing what you want, automate that interface using pywinauto to perform a macro to activate/disable higher DPI.
There are more possibilities.
You can replace Windows driver with your own version, which will support what you wish, thus making your own layer in mouse stack. But this is extreme.
I think you should start in order I wrote:
See whether you can use PyUSB to send bytes needed without detaching mouse from OS
If not, see whether detaching mouse, changing DPI, and returning mouse back to OS using PyUSB keeps the set DPI.
3.1 If not, make your own artificial driver using PyUSB and PyMouse
or
3.2 Use pywinauto to automate the existing interface to change DPI for you.
I have been working with some drones and robotics projects using arduino and python. There was a kickstarter project for a neat little hex copter, that hasn't been managed well.
I was lucky, i got my copter and then some time later after some frustrated email exchanges, i finally recieved the camera as well. To this day, their forum has people still complaining. Their maker forum is now down and their wiki hasn't been updated with any specifics on the camera.
http://www.flexbot.cc/wiki/index.php?title=Main_Page#Hardware
Their app to accompany the drone still doesn't support the camera module. Not that it'd matter, as their code isn't very well documented or annotated.
https://github.com/HexAirbot
There are some tips on switching the camera on the comments page of their kickstarter campaign.
https://www.kickstarter.com/projects/1387330585/hex-a-copter-that-anyone-can-fly/posts/1093716
So, sob story over, i'm stuck with this neat little wifi camera that i am unsure on how to connect to. I know how to switch it on and it does have a micro-usb port on it.
What library in Python could i use to stream an image from this camera given that it is a wifi camera. If i wanted the video stream as a numpy matrix.
I need to interface with the camera, so i can connect and disconnect.
Then, be able to read images frame by frame with ffmpeg. I have some python modules that can detect and read from a camera, but how can my code ensure that the camera is connected?
Totally stuck. Any help would be appreciated.
Considering you are building for the android platform, you will more than likely need to use some sort of java/python driver/interface, unless you just use java.
Here is an article on java/python, and using python from within java.
Using Python from within Java
Here is the objective I wish to achieve: I would like to connect multiple web cameras to a single Windows machine and take snapshots from one of them at different instances (so one camera must active at one point of time, while another must be active at another). From what I have tried, an user has to go to the control panel and set which camera should be active at a given moment to use it. Is there a way to achieve this objective via python? (If there is a way to keep all cameras active at once, how should I specify which camera should take a snapshot?
I have investigated a couple options since then. One of the tools that I could utilize is devcon, through which usb cameras could be disabled/enabled to take snapshots. Another (simpler) option is to use a function in python opencv - cv2.VideoCapture(i) will automatically allow the program to iterate through different camera devices connected to the computer via usb.
Background
I'm attempting to craft a simple video playback script for a small cinema that automates the playing of videos and control of the projector, sound and lighting systems. I have two video outputs, one goes to a monitor in the projection booth, and the other directly to the projector. I desire to play video (and only video) fullscreen to the projector while putting controls and a small (~1/4 screen) preview on the monitor. This will allow the projectionist to view the video being output and control the playback from the monitor in the booth while all the audience ever sees is the video output.
Problem
I am currently using Python to control VLC player (with libvlc Python bindings) to playback videos. I have everything working fine except that I can't figure out how to get a preview (direct copy) of the video being played fullscreen on the projector output into my GUI.
I have tried using the clone filter, but I cant get the cloned window to automagically appear full screen nor in my GUI. The clone filter seems like the logical choice but it seems to be VERY inflexible when it comes to specifying destination screens, fullscreen, etc. I must be able to open video windows full screen on the projector monitor. Professionalism is key and it would look bad if the projectionist had to drag a window over and double click on it when the movie started.
Currently Using:
Debian Linux
Python 2.7
wxPython
libvlc
I would like to continue using Python as I already have the code for controlling the projector, sound processor, lighting and curtain written and tested. I chose VLC because it really seems bulletproof when it comes to video playback but am not committed to it's continued use. I also chose wxWidgets for my GUI as a result of past experience but I am not stuck on that either.
This describes the direct solution and does not concentrate on any alternative or the overall design of your application.
As Your Application and VLC media player are separate processes, you will not be able to get what you want directly because there is no "shared memory" between those 2 applications. The best shot to "copy" the decoded frames from VLC will be to e.g. send a RAW Video .mts stream (ts is usually used for this kind of usecase) and send e.g. to udp://localhost:1234.
In your application, you will need to be able to receive the ts stream, "decode" it and display at the spot of interest.
For start, i would try if you are able to do this using 2 vlc players that you control manually. When you achieved that the first VLC streams to udp and outputs on the main display at the same time, and the other VLC player receives and plays the udp stream you can go on:
Find a player library that you can use directly in your wxpython application and check if it can receive the udp stream as well E.g.
https://wxpython.org/Phoenix/docs/html/wx.media.MediaCtrl.html
This player lib for example requires gstreamer as a base.
As a result, main display and the picture in your applicatoin might have a latency of some seconds. To come around this latency, the best way that i currently know is using WebRTC but this is a lot more complex setup than the above.
https://www.sipwise.org/news/technical/tv-over-webrt/
Sure in case you do some "encoding" for WebRTC or even for UDP, you would need to utilize some hardware encoder, e.g. Nvidia NVENC in order to be able to guarantee the needed resources are always there.