Skip to content

Commit

Permalink
Add more information regarding OpenCV
Browse files Browse the repository at this point in the history
KonradIT committed Apr 1, 2017
1 parent f7dacf8 commit 33f08ba
Showing 4 changed files with 77 additions and 4 deletions.
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -113,6 +113,10 @@ gpCam = GoProCamera.GoPro()

NOTE: You can initialise with ```GoProCamera.GoPro()``` and it will detect which camera is connected and what API to use, this can be unreliable as I have only tested it with HERO4 and HERO3. If you want to connect to a specific camera use ```GoProCamera.GoPro(constants.gpcontrol)``` for HERO4/5/HERO+ and ```GoProCamera.GoPro(constants.auth)``` for HERO3/HERO3+.

If you want to specify a MAC address for the camera (only for HERO4/5/HERO+):

```GoProCamera.GoPro(mac_address="...")```

---

NOTE: Some commands are HERO4/5 only and viceversa: gpControlCommand/gpControlSet/gpControlExecute are for HERO4/5 only, sendBacpac/sendCamera are HERO3/3+ only. Make sure you use the right constant for getStatus according to your camera.
@@ -506,10 +510,67 @@ A specific file:
gpCam.deleteFile("104GOPRO","GOPR0038.JPG")
```

* List camera media contents:

```python
gpCam.listMedia()
```

it will return a JSON list of the media files available on the camera:

```
{
"id": "3993129928403681535",
"media": [
{
"d": "104GOPRO",
"fs": [
{
"mod": "1490468532",
"n": "GOPR2760.JPG",
"s": "4919786"
},
{
"mod": "1490468536",
"n": "GOPR2761.JPG",
"s": "4942872"
},
{
"mod": "1490468540",
"n": "GOPR2762.JPG",
"s": "4943428"
},

```

If you want it formatted:

```python
gpCam.listMedia(format=True)
```

```
folder: 104GOPRO
GOPR2760.JPG
GOPR2761.JPG
GOPR2762.JPG
GOPR2763.JPG
GOPR2764.MP4
GOPR2765.MP4
GOPR2766.MP4
GOPR2767.MP4
GOPR2768.MP4
```

will return it in a new line each.


### Streaming:

In regards to streaming, this library provides with the following functions:

This will enable livestreaming on all cameras.

```python
gpCam.livestream("start")
gpCam.livestream("stop")
@@ -521,6 +582,8 @@ To stream the HERO4 video to another place such as localhost:
gpCam.stream("udp://localhost:5000")
```

On HERO3 you can just open /live/amba.m3u8 on VLC or another player.

See the examples/opencv folder for a python script to open the HERO4 feed in openCV and detect faces.

### Video screencap:
9 changes: 8 additions & 1 deletion examples/opencv_gopro/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## OpenCV + GoPro HERO4

This is an experiment to detect faces using a GoPro HERO4 and OpenCV on Python.
This is an experiment to detect faces using a GoPro HERO4 and OpenCV on Python. Ultimately we want to detect fishes. This has a wide range of applications, from self driving small cars to research and investigation.

Tested with a GoPro HERO4 Black and a computer running Linux. Probably does not work on Windows.

Needs FFmpeg and OpenCV-Python installed.

Open ```gopro_keepalive.py``` in one terminal and ```gopro_opencv.py``` in a separate terminal.

![](http://i.imgur.com/YXpnhMM.png)

1 change: 0 additions & 1 deletion examples/opencv_gopro/gopro_keepalive.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from goprocam import GoProCamera
from goprocam import constants
gopro = GoProCamera.GoPro()
gopro.mode(constants.Mode.PhotoMode)
gopro.stream("udp://127.0.0.1:10000")
8 changes: 6 additions & 2 deletions goprocam/GoProCamera.py
Original file line number Diff line number Diff line change
@@ -684,8 +684,12 @@ def livestream(self,option):
print(self.sendCamera("PV","00"))
def stream(self, addr):
self.livestream("start")
subprocess.Popen("ffmpeg -f mpegts -i udp://" + self.ip_addr + ":8554 -b 800k -r 30 -f mpegts " + addr, shell=True)
self.KeepAlive()
if whichCam() == "gpcontrol":
subprocess.Popen("ffmpeg -f mpegts -i udp://" + self.ip_addr + ":8554 -b 800k -r 30 -f mpegts " + addr, shell=True)
self.KeepAlive()
elif whichCam() == "auth":
subprocess.Popen("ffmpeg -f mpegts -i http://" + self.ip_addr + ":8080/live/amba.m3u8 -b 800k -r 30 -f mpegts " + addr, shell=True)

def parse_value(self, param,value):
if param == "video_left":
return str(time.strftime("%H:%M:%S", time.gmtime(value)))

0 comments on commit 33f08ba

Please sign in to comment.