Hi @meska, any update on what I should do? I appreciate the help.
Thanks
Hi @meska
First of all, thanks for what you have done.
I'm able to run your program and I get a stream from the iSight camera.
But I'm trying to setup your program in order to use a USB webcam instead of the iSight one.
I didn't find how to select the correct webcam.
Can you help me?
Hi,
I got it
I read your code and I find the argument to use : "-c".
First I try value from 1 to 5 and that didn't work but I didn't connect the webcam
When that was done (ie connect the cam), that's working fine with the value "1".
Have a good day
Hi @meska. I think I figured out my Python problem. It appears to be loading the virtual environment now, but I'm not getting the camera feed to load in the browser. Any idea what might be wrong?
Here's the output when running the startup commands:
iMac:Downloads rkz$ cd mjpeg_stream_webcam-master
iMac:mjpeg_stream_webcam-master rkz$ virtualenv -p python3.7 .env
Running virtualenv with interpreter /usr/local/bin/python3.7
Already using interpreter /usr/local/opt/python/bin/python3.7
Using base prefix '/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/rkz/Downloads/mjpeg_stream_webcam-master/.env/bin/python3.7
Not overwriting existing python script /Users/rkz/Downloads/mjpeg_stream_webcam-master/.env/bin/python (you must use /Users/rkz/Downloads/mjpeg_stream_webcam-master/.env/bin/python3.7)
Installing setuptools, pip, wheel...
done.
iMac:mjpeg_stream_webcam-master rkz$ source .env/bin/activate
(.env) iMac:mjpeg_stream_webcam-master rkz$ pip install -r requirements.txt
Requirement already satisfied: opencvutils in ./.env/lib/python3.7/site-packages (from -r requirements.txt (line 1)) (0.9.4)
Requirement already satisfied: opencv-python in ./.env/lib/python3.7/site-packages (from -r requirements.txt (line 2)) (4.2.0.34)
Requirement already satisfied: pillow in ./.env/lib/python3.7/site-packages (from -r requirements.txt (line 3)) (7.1.1)
Requirement already satisfied: fake-rpi in ./.env/lib/python3.7/site-packages (from opencvutils->-r requirements.txt (line 1)) (0.7.0)
Requirement already satisfied: numpy in ./.env/lib/python3.7/site-packages (from opencvutils->-r requirements.txt (line 1)) (1.18.2)
Requirement already satisfied: pyyaml in ./.env/lib/python3.7/site-packages (from opencvutils->-r requirements.txt (line 1)) (5.3.1)
Requirement already satisfied: build-utils in ./.env/lib/python3.7/site-packages (from opencvutils->-r requirements.txt (line 1)) (0.3.2)
Requirement already satisfied: colorama in ./.env/lib/python3.7/site-packages (from build-utils->opencvutils->-r requirements.txt (line 1)) (0.4.3)
Requirement already satisfied: twine in ./.env/lib/python3.7/site-packages (from build-utils->opencvutils->-r requirements.txt (line 1)) (3.1.1)
Requirement already satisfied: nose in ./.env/lib/python3.7/site-packages (from build-utils->opencvutils->-r requirements.txt (line 1)) (1.3.7)
Requirement already satisfied: importlib-metadata; python_version < "3.8" in ./.env/lib/python3.7/site-packages (from twine->build-utils->opencvutils->-r requirements.txt (line 1)) (1.6.0)
Requirement already satisfied: readme-renderer>=21.0 in ./.env/lib/python3.7/site-packages (from twine->build-utils->opencvutils->-r requirements.txt (line 1)) (25.0)
Requirement already satisfied: requests>=2.20 in ./.env/lib/python3.7/site-packages (from twine->build-utils->opencvutils->-r requirements.txt (line 1)) (2.23.0)
Requirement already satisfied: requests-toolbelt!=0.9.0,>=0.8.0 in ./.env/lib/python3.7/site-packages (from twine->build-utils->opencvutils->-r requirements.txt (line 1)) (0.9.1)
Requirement already satisfied: keyring>=15.1 in ./.env/lib/python3.7/site-packages (from twine->build-utils->opencvutils->-r requirements.txt (line 1)) (21.2.0)
Requirement already satisfied: pkginfo>=1.4.2 in ./.env/lib/python3.7/site-packages (from twine->build-utils->opencvutils->-r requirements.txt (line 1)) (1.5.0.1)
Requirement already satisfied: tqdm>=4.14 in ./.env/lib/python3.7/site-packages (from twine->build-utils->opencvutils->-r requirements.txt (line 1)) (4.45.0)
Requirement already satisfied: setuptools>=0.7.0 in ./.env/lib/python3.7/site-packages (from twine->build-utils->opencvutils->-r requirements.txt (line 1)) (46.1.3)
Requirement already satisfied: zipp>=0.5 in ./.env/lib/python3.7/site-packages (from importlib-metadata; python_version < "3.8"->twine->build-utils->opencvutils->-r requirements.txt (line 1)) (3.1.0)
Requirement already satisfied: Pygments>=2.5.1 in ./.env/lib/python3.7/site-packages (from readme-renderer>=21.0->twine->build-utils->opencvutils->-r requirements.txt (line 1)) (2.6.1)
Requirement already satisfied: six in ./.env/lib/python3.7/site-packages (from readme-renderer>=21.0->twine->build-utils->opencvutils->-r requirements.txt (line 1)) (1.14.0)
Requirement already satisfied: docutils>=0.13.1 in ./.env/lib/python3.7/site-packages (from readme-renderer>=21.0->twine->build-utils->opencvutils->-r requirements.txt (line 1)) (0.16)
Requirement already satisfied: bleach>=2.1.0 in ./.env/lib/python3.7/site-packages (from readme-renderer>=21.0->twine->build-utils->opencvutils->-r requirements.txt (line 1)) (3.1.4)
Requirement already satisfied: idna<3,>=2.5 in ./.env/lib/python3.7/site-packages (from requests>=2.20->twine->build-utils->opencvutils->-r requirements.txt (line 1)) (2.9)
Requirement already satisfied: chardet<4,>=3.0.2 in ./.env/lib/python3.7/site-packages (from requests>=2.20->twine->build-utils->opencvutils->-r requirements.txt (line 1)) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in ./.env/lib/python3.7/site-packages (from requests>=2.20->twine->build-utils->opencvutils->-r requirements.txt (line 1)) (1.25.9)
Requirement already satisfied: certifi>=2017.4.17 in ./.env/lib/python3.7/site-packages (from requests>=2.20->twine->build-utils->opencvutils->-r requirements.txt (line 1)) (2020.4.5.1)
Requirement already satisfied: webencodings in ./.env/lib/python3.7/site-packages (from bleach>=2.1.0->readme-renderer>=21.0->twine->build-utils->opencvutils->-r requirements.txt (line 1)) (0.5.1)
(.env) iMac:mjpeg_stream_webcam-master rkz$
Super Super! been messing around with VLC and trying to get this to work on my Mac mini.
I have installed perfectly and it works out of the box. I can see the camera when on my Mac mini.
But... (you knew it was coming)
I cannot view the camera on any other machine on my network. Is there a config file I can edit to change the server address from localhost to the IP address of the machine (internal IP)?
Solved:
Edited mjpegsw.py
parser.add_argument('-i', '--ipaddress', help='listening ip address, default LOCALIP ADDRESS', type=str,
default='LOCALIPADDRESS')
On this point did you find a way to restart the octoprint server and enter a password (or bypass this?)
Meska,
First off, thanks for investing the time to figure out how to put all of pieces together and then writing the python script.
FYI... I am a veteran software engineer and have been using python for around 4 years now professionally.
I using a mid-2011 Mac-mini running macOS 10.13.6
for octoprint:
After that, I can get octoprint up and running just fine, connect to it from remote computers, send print jobs to it, etc. Everything is stable.
Next for mjpeg_stream_webcam
but when I tried to install the requirements from the included requirements.txt file, I got the error that there were no matching distributions found for opencvutil (line 1)
so I took a look at the mjpegsw.py script and did not see any imports (as far as I could tell) for this package. So I manually pip installed the other 2 remaining packages.
with the 3.8.5 virtualenv activated I was able to successfully execute python mjpegsw.py
with the default arguments and then view the stream by going to http://localhost:5001/cam.mjpg in safari. So I knew that was working.
I did the configuration in octoprint to set the respective values for the stream and snapshot URLs.
Then realized that I needed to install ffmpeg. So I downloaded the static FFmpeg binaries for macOS 64-bit (version release-4.3.1). installed in to my ~/bin directory verified that it worked, and updated the path setting in octoprint.
So I could see the webcam stream in octoprint and could start a time-lapse capture when doing a print.
However, during the printing, I would occasionally get segmentation fault 11 errors, so I'd restart the program again. After a few of these, I got a kernel panic. So I shut down the computer and thought I'd try again tomorrow. I did and even without printing (just viewing the webcam stream), got another kernel panic.
Any ideas as to what might be causing the segmentation fault 11 errors? or worse the kernel panics? I can upload the kernel panic log files, if it will help. I haven't used CV before, but I have a rudimentary idea of what your doing in the script... and it doesn't look terrible complex. Do you think its something in CV or one of the dependencies that were installed along with it? I wouldn't think its the http.server package or the PIL package...
Any suggestions? I'm willing to help troubleshoot.
Best Regards,
-- Greg
Hello Greg,
segfaults sometimes happens, that's why I included a startup script "start.sh" that relaunch the script on crash. You can try with different ffmpeg or opencv versions to see if changes.
I removed opencvutils from requirements, thank you.
Meska,
Thanks for the reply. I get that the start.sh script is a workaround for the script expectedly quitting (due to whatever), but this wasn't, I don't know, as eloquent as I would have liked, as I suspect that the crashes may be contributing to the Kernel panics I am experiencing when I have the script running.
In any event, let me know if you think of any specific components that I should take a look at to narrow it down a bit.
Thanks again for all the great work, keep it up!
By the way... you should have said: "Segfaults happen"... it would have made a great bumper sticker!
Best Regards,
-- Greg
Just got this setup on an iMac and working with the built in webcam. Is there anyway to configure this to use a DSLR plugged in through a generic usb capture card?
Edit: actually nevermind, I closed and restarted the stream with the DSLR plugged in and it seems to have defaulted to that over the built in webcam.
Thanks!
I have tried all of these steps, as well as using the opencv option. I'm running High Sierra, and I can view my USB camera fine using Mac apps. What can I share to help get some help to make this work? Octoprint works great otherwise. Also, when I run the URL, I get "hello world" but no video.
If you have issues, you may open a new thread with Get Help Webcams.
All necessary informations are requested when you open that thread.
Thanks, I opened it there.
CB
And got no responses.
It's not that we don't like to help you - it's just that most of us don't use Macs.
I for example have never used a Mac and maybe seen 2-3 in my life
Thanks, Ewald, that's partially my problem too, as I primarily use PCs. I'm just so close, as the only issue is the crashing webcam. I have a RPI arriving today, so I'll give it a try. I appreciate the message.
Chris
Hi Curlynerd,
"hello world" is correct, probably you missed that you need to use http://localhost:5001/cam.mjpg for stream url and http://localhost:5001/snap.jpg for snapshot url, hello world appears if you open http://localhost:5001/
Thanks Meska, I have the stream going now, but the frequency of the segmentation faults is making it hard to keep my eyes on the prints.
C
I will take a look on my Mac if I can understand where is the problem,
Meantime if you use the script provided it will restart itself.
I uploaded a new version that fixes the segfaults.
That's so cool thanks so much... I'll give it a try and let you know. You're awesome!
Chris