-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PiCamera troubles #2
Comments
I made sure to enable the camera I also have |
Have you installed the python picamera library? https://www.raspberrypi.org/documentation/usage/camera/python/README.md
|
Yup. Let me run through the steps again to make sure I didn't miss something. |
Does the camera work with bash commands like raspistill? On Wed, May 25, 2016 at 10:53 AM, Slack-Moehrle [email protected]
|
indeed. it does. Let me re-compile opencv and make sure I used Python 3 |
Are you using opencv inside a virtual environment? I had an issue where apt-get picamera was not in virtualenv. Pip install
|
I think I see the problem. I did |
Looks like something weird is going on. Can you follow this guide? You can likely skip to step 7.
|
I did: $ mkvirtualenv cv3 -p python3 I am following this: http://www.pyimagesearch.com/2015/10/26/how-to-install-opencv-3-on-raspbian-jessie/ |
The http://www.pyimagesearch.com/2015/10/26/how-to-install-opencv-3-on-raspbian-jessie/ is what I used when developing and testing the program and installation instructions. Were you in the virtual environment when the
|
@gregtinkers I removed the virtual environments and started over. Compiling OpenCV again now. |
just to be sure, when I run |
Yes. |
I am still struggling
|
I think that I have it working now. Except the image is upside down. When I run raspistill it is rightside up |
I'd try changing the camera.vflip bool. Should be as simple as adding
|
Glad to hear you are making progress. |
Yes @Choroid that worked. I noticed that just as your reply came in. So it works. However, I think I need to fix some math. My house sits on a hill. Edge of my house to the middle of the toad is 72 ft, but the road is a 11 degree downgrade from the house. So it is capturing speed, but it is definitely wrong. I see the camera picture, but when cars go by nothing happens on the camera. |
How much of the display is dedicated to monitoring the road? The program does not update the display while a car is being tracked, so if you monitor the entire width of the image, you will not see a car as it proceeds through the monitored area. Check the terminal to see how many readings are being taken as a car moves thought the monitored area. If you are not getting at least three or four, you may need to reduce the height of the monitored area so that opencv has time to process the images. If you play around with it, I'm sure you will be able to get a reading reasonably close. |
Yes, I have been. I adjusted the monitored area to just a portion in front of my driveway that covers both lanes of the road and it seems to be working and now I am getting cars going by and pics, etc. |
thank you so much for outlining this. It inspires me to make a C++ version as an experiment. I was reading about openCV before and trying to come up with some good experiments. Yours is great and useful. |
Great! I admire your perseverance. If you write a C++ version, please share it and post a link in the comment section of my car speed detector blog. |
Hmmm.....Thanks for pointing that last bit out, I have been struggling to get it to reliably pick up a vehicle and do anything before the vehicle is gone.... My setup is also slightly above the street level but also much closer than the development environment...
I'm thinking that perhaps the wildly inaccurate speeds returned might be due to the relatively large area that I had it set to monitor, what is the typical bounding box size that you have used? |
another planned feature I have is to initially display the selection window, then close that and as images are captured, also put them up on the screen either in a single window or possibly a rotating set such that you can see the last 2 vehicles detected. |
@RawLiquid I'm remembering about 20000 pixels (or even less) for the monitored area. Looking at your set up, I think you could reduce the height of the bounding box and still get accurate results. The target car doesn't need to be entirely contained in the monitored box as the leading edge of the vehicle is the only thing that is tracked. Are you using a Pi 2 or Pi 3? |
@gregtinkers I am using a Pi 2 and I find that the reads are inaccurate at higher speeds. 40 and below seem accurate. I have a Pi 3 coming tomorrow and will try it out and see how the reads are. By default distance to the middle of the road is 60. I am 72 but the road is an 11% grade down. Any idea how to compensate for that? |
Could you physically measure the distance from edge to edge of the frame at Knowing the distance from lens to speed is just a convenient way to
|
I didn't see an issue with slow moving objects that crossed the field of view. One of my favorite pictures is of a cat with "2 MPH" above it. However if a cat or person stays in the monitored area long enough for the lighting to change, when it leaves, the program will register the lighting change as an object and get stuck in the tracking mode. You can adjust THRESHOLD to change how much of a grey-scale change is required before identifying an object to track and MIN_AREA to exclude small objects. |
One think I am noticing is that the camera enters a continual "tracking" every night when it gets dark out. I'd assume that adjusting THRESHOLD to a much higher number would help with this? |
Another possibility is that the lighting in the image may be changing faster than the base_image can adapt. Line 304 adjusts the base_image as the lighting changes. Perhaps increasing the weight of the incoming image would reduce the continuous tracking episodes. |
I took a rather different approach towards resolving that continuous tracking issue. |
@RawLiquid could you share that fix so I can try it along with the other adjustments that I have made? |
Sure let me dig it up, it should be in my fork but I can send a pull On Wednesday, July 6, 2016, Slack-Moehrle [email protected] wrote:
I respectfully decline the invitation to join your hallucination. |
FYI I have an updated Speed2.py that crops the stream image to the motion On Sat, Jul 9, 2016 at 4:06 PM, RawLiquid [email protected] wrote:
See my YouTube Channel at http://www.youtube.com/user/pageaucp |
Just after the if statement for the tracking section, put this block right if secs >= 15: The indent should start the same as the secs line then move over by one On Wednesday, July 6, 2016, Slack-Moehrle [email protected] wrote:
I respectfully decline the invitation to join your hallucination. |
I already installed virtual environment. pip-3.2 install "picamera[array]" after that, I tried: python (still in virtualenv) and then: import picamera but at this time, I got an error saying that: "ImportError: No module named "picamera" And then I tried: pip freeze it gave me: appdirs==1.4.3 There is not picamera there!!! When I log out the virtual environment, and retry python and import picamera, it worked?! But I need to work on the virtual environment, anyone can help me please?? |
@MoreSong Perhaps someone else will assist you - also try posting this question on my blog |
I'm a bit busy with a few things to go dig up the info for you, but i believe that I posted a specific post just for that topic, along with some suggestions on how I resolved it. basically for whatever reason, the picamera module isn't linked in the virtualenv, and it's a matter of going and manually linking or copying the file into the proper directory. |
how do i install picamera on mac? |
@Zumbalamambo Picamera is designed specifically for the Raspberry Pi. If you want to run this program on a Mac, you will need to rewrite it to use images from a web cam. |
Don't mean to take away from this project but thought I would point out a similar project I wrote a few years ago. I had an interesting case where there was a robbery down the street a few days ago. Yesterday Police came to the door and asked if I had seen anything. I said no but maybe my speed or timelapse camera did. The timelapse camera could not see the house due to trees . The police had an idea from the owner about a suspected person and the car they drove. We reviewed the speed camera images and found twenty plus images of the suspect vehicle on different days and times probably casing the house. The police were amazed. |
@pageauc Thanks for writing your post. I have been working on a C++ version of @gregtinkers project. It was such great inspiration for me to built something useful to solve my own needs. You mention a robbery. This same thing happens to us. Our neighbors know about our camera system (8 security cameras, plus 3 traffic cameras from 3 different angles). When things happen in our neighborhood we have become the unofficial source for footage. Just about 2 weeks ago we had neighbors come by and ask if we had anything about a motorcycle driving up and down our street acting aggressive and scaring people. Or 4 wheelers stopping at mailboxes and taking mail from the owners or a domestic violence case where the suspect said he wasn't there but our camera showed otherwise. Hopefully soon I can share this project. I wanted to talk with @gregtinkers first to see if I should have my own repo or if we could submit a PR to this repo. |
I am currently testing a new speed camera image search. To do a search you
copy search image(s) into a designated search folder and after the search
the ,results are put in a subfolder named the same as the search image
minus the extension along with the original image. If there are more than
image to search then they will be put in separate subfolders with results
of search. After all images are searched then the main search folder will
be empty. You can adjust the depth of search by setting a variable between
0 and 1. 1 being a perfect match. I normally set this variable to 0.97.
I found that some colors like black will sometimes return dark red vehicles
especially on overcast days and of course it depends a bit on the
background.
Image search uses a technique similar to my camera tracker program that
uses opencv template matching. I can have ten's of thousands of images and
and finding similar or the same vehicle would be handy. Anyway it is
working but will take a few days to finish tweaking things. Will be posted
on github when ready.
Claude ....
…On Tue, Jul 25, 2017 at 12:42 PM, Slack-Moehrle ***@***.***> wrote:
@pageauc <https://github.com/pageauc> Thanks for writing your post. I
have been working on a C++ version of @gregtinkers
<https://github.com/gregtinkers> project. It was such great inspiration
for me to built something useful to solve my own needs.
You mention a robbery. This same thing happens to us. Our neighbors know
about our camera system (8 security cameras, plus 3 traffic cameras from 3
different angles). When things happen in our neighborhood we have become
the unofficial source for footage. Just about 2 weeks ago we had neighbors
come by and ask if we had anything about a motorcycle driving up and down
our street acting aggressive and scaring people. Or 4 wheelers stopping at
mailboxes and taking mail from the owners or a domestic violence case where
the suspect said he wasn't there but our camera showed otherwise.
Hopefully soon I can share this project. I wanted to talk with
@gregtinkers <https://github.com/gregtinkers> first to see if I should
have my own repo or if we could submit a PR to this repo.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFr1ZLJj27WQcibPv2sWVrPf74uzkFcrks5sRhr8gaJpZM4ImyZX>
.
--
See my YouTube Channel at http://www.youtube.com/user/pageaucp
|
@pageauc sounds interesting. It would be useful to know how many times the same car went up and down the street and in what sort of interval. I'm currently working on organizing all the footage from the security cameras and the pi cameras. My approach is when the pi camera takes a pic, I also capture the video snippets +/- an interval of time so that everything is all in one place. If I look at a picture I also see right along with it the video of it going by as well. I added grabbing license plate numbers. One idea I had was adding a large display outside that visually tells those driving by how fast they are going so they can see it. |
I have update my speed cam program GitHub Repo here
https://github.com/pageauc/rpi-speed-camera
I added speed-search.py that does an opencv template match to find similar
images. See Readme.md for more details. Have not updated wiki yet.
Tested with an older single core RPI (good test machine) and runs OK but
better on a quad core due to threading. After collecting quite a few speed
images you can test the speed-search.py. Just copy a speed image into the
media/search folder. You can tweek the config.py results_value if you get
too many results. default is 0.97 higher gives fewer results (more exact
match) and lower will return more results. You will get false positives
but will still help reduce the number of images to work with. White
vehicles seem to work well. Also depends on the background.. This is just
an initial release and I am still doing development work with it.
Raise a GitHub issue if you have problems or suggestions
Regards Claude ...
…On Tue, Jul 25, 2017 at 1:57 PM, Slack-Moehrle ***@***.***> wrote:
@pageauc <https://github.com/pageauc> sounds interesting. It would be
useful to know how many times the same car went up and down the street and
in what sort of interval.
I'm currently working on organizing all the footage from the security
cameras and the pi cameras. My approach is when the pi camera takes a pic,
I also capture the video snippets +/- an interval of time so that
everything is all in one place. If I look at a picture I also see right
along with it the video of it going by as well.
I added grabbing license plate numbers. One idea I had was adding a large
display outside that visually tells those driving by how fast they are
going so they can see it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFr1ZMlRxPQ3vKqcRorn-tY9OQPRKlR0ks5sRiykgaJpZM4ImyZX>
.
--
See my YouTube Channel at http://www.youtube.com/user/pageaucp
|
FYI
Did some recent repo fixes and updated/added Wiki instructions for
speed-search.py
https://github.com/pageauc/rpi-speed-camera/wiki/How-to-Run-speed-search.py
Will also publish a short YouTube video.
Claude
…On Wed, Jul 26, 2017 at 3:09 PM, Claude Pageau ***@***.***> wrote:
I have update my speed cam program GitHub Repo here https://github.com/
pageauc/rpi-speed-camera
I added speed-search.py that does an opencv template match to find similar
images. See Readme.md for more details. Have not updated wiki yet.
Tested with an older single core RPI (good test machine) and runs OK but
better on a quad core due to threading. After collecting quite a few speed
images you can test the speed-search.py. Just copy a speed image into the
media/search folder. You can tweek the config.py results_value if you get
too many results. default is 0.97 higher gives fewer results (more exact
match) and lower will return more results. You will get false positives
but will still help reduce the number of images to work with. White
vehicles seem to work well. Also depends on the background.. This is just
an initial release and I am still doing development work with it.
Raise a GitHub issue if you have problems or suggestions
Regards Claude ...
On Tue, Jul 25, 2017 at 1:57 PM, Slack-Moehrle ***@***.***>
wrote:
> @pageauc <https://github.com/pageauc> sounds interesting. It would be
> useful to know how many times the same car went up and down the street and
> in what sort of interval.
>
> I'm currently working on organizing all the footage from the security
> cameras and the pi cameras. My approach is when the pi camera takes a pic,
> I also capture the video snippets +/- an interval of time so that
> everything is all in one place. If I look at a picture I also see right
> along with it the video of it going by as well.
>
> I added grabbing license plate numbers. One idea I had was adding a large
> display outside that visually tells those driving by how fast they are
> going so they can see it.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#2 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AFr1ZMlRxPQ3vKqcRorn-tY9OQPRKlR0ks5sRiykgaJpZM4ImyZX>
> .
>
--
See my YouTube Channel at http://www.youtube.com/user/pageaucp
--
See my YouTube Channel at http://www.youtube.com/user/pageaucp
|
FYI
I have updated my speed-cam.py to make it compatible with MS Windows, Unix
platforms using a Web Cam as well as RPI using pi-camera module or USB Web
Cam. I have tested this on Windows 7 and works fine with no code changes
required. Webserver also works OK.
The latest version also includes optional Disk Free Space management that
deletes oldest files of a designated file ext. There is also feature to
allow creation of dated image subfolders by MaxFiles in subfolder or
MaxHours age of folder.
For more details See GitHub Repo here
https://github.com/pageauc/rpi-speed-camera
Claude ....
…On Thu, Jul 27, 2017 at 4:34 AM, Claude Pageau ***@***.***> wrote:
FYI
Did some recent repo fixes and updated/added Wiki instructions for
speed-search.py
https://github.com/pageauc/rpi-speed-camera/wiki/How-to-
Run-speed-search.py
Will also publish a short YouTube video.
Claude
On Wed, Jul 26, 2017 at 3:09 PM, Claude Pageau ***@***.***> wrote:
> I have update my speed cam program GitHub Repo here
> https://github.com/pageauc/rpi-speed-camera
>
> I added speed-search.py that does an opencv template match to find
> similar images. See Readme.md for more details. Have not updated wiki
> yet. Tested with an older single core RPI (good test machine) and runs
> OK but better on a quad core due to threading. After collecting quite a
> few speed images you can test the speed-search.py. Just copy a speed image
> into the media/search folder. You can tweek the config.py results_value if
> you get too many results. default is 0.97 higher gives fewer results
> (more exact match) and lower will return more results. You will get false
> positives but will still help reduce the number of images to work with.
> White vehicles seem to work well. Also depends on the background.. This is
> just an initial release and I am still doing development work with it.
>
> Raise a GitHub issue if you have problems or suggestions
> Regards Claude ...
>
> On Tue, Jul 25, 2017 at 1:57 PM, Slack-Moehrle ***@***.***>
> wrote:
>
>> @pageauc <https://github.com/pageauc> sounds interesting. It would be
>> useful to know how many times the same car went up and down the street and
>> in what sort of interval.
>>
>> I'm currently working on organizing all the footage from the security
>> cameras and the pi cameras. My approach is when the pi camera takes a pic,
>> I also capture the video snippets +/- an interval of time so that
>> everything is all in one place. If I look at a picture I also see right
>> along with it the video of it going by as well.
>>
>> I added grabbing license plate numbers. One idea I had was adding a
>> large display outside that visually tells those driving by how fast they
>> are going so they can see it.
>>
>> —
>> You are receiving this because you were mentioned.
>> Reply to this email directly, view it on GitHub
>> <#2 (comment)>,
>> or mute the thread
>> <https://github.com/notifications/unsubscribe-auth/AFr1ZMlRxPQ3vKqcRorn-tY9OQPRKlR0ks5sRiykgaJpZM4ImyZX>
>> .
>>
>
>
>
> --
> See my YouTube Channel at http://www.youtube.com/user/pageaucp
>
--
See my YouTube Channel at http://www.youtube.com/user/pageaucp
--
See my YouTube Channel at http://www.youtube.com/user/pageaucp
|
Thanks @pageauc. Please continue to post your update news here. You are taking this concept much farther than I ever planned. I'm happy to have people discover your work from these posts. |
Hi, can you please elaborate your solution at this stage? I have precisely same issue .. Thanks! |
Alok - Change the values at lines 122 or 123 to meet your needs. My setup required flipping the images, and those lines do that. |
How did you solve this problem? I'm also struggling with this problem, too. >< |
@30qwq did you change those lines? |
I did the same lines to install picamera. The most weird thing is that my camera.py which contains "import picamera" can work somehow, after I struggled for hours. However, when I input "pip freeze", it didn't show up "picamera". And when I typed "import picamera " in the terminal, I also got an error, "ImportError: No module named "picamera". |
are you in a python virtual environment? |
yes, I installed picamera and typed "pip freeze" in a python virtual environment. |
I have this camera: http://www.amazon.com/Waveshare-Raspberry-Camera-Version-Raspberry-pi/dp/B00N9YWLHE?ie=UTF8&psc=1&redirect=true&ref_=oh_aui_detailpage_o07_s00
When I run carspeed.py It cannot import PiCamera
The text was updated successfully, but these errors were encountered: