Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 76e43c4

Browse files
committed
段错误
1 parent 5cda4be commit 76e43c4

File tree

4 files changed

+99
-18
lines changed

4 files changed

+99
-18
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## OpenCV Computer Vision with Python
2+
3+
-
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# -*- coding: utf-8 -*-
2+
# @Time : 2018年1月7日 11:33
3+
# @Author : play4fun
4+
# @File : freenect_test1.py
5+
# @Software: PyCharm
6+
7+
"""
8+
freenect_test1.py:
9+
不行。段错误 (核心已转储)
10+
"""
11+
12+
import pygame
13+
import numpy as np
14+
import sys
15+
from freenect import sync_get_depth as get_depth
16+
17+
18+
def make_gamma():
19+
"""
20+
Create a gamma table
21+
"""
22+
num_pix = 2048 # there's 2048 different possible depth values
23+
npf = float(num_pix)
24+
_gamma = np.empty((num_pix, 3), dtype=np.uint16)
25+
for i in range(num_pix):
26+
v = i / npf
27+
v = pow(v, 3) * 6
28+
pval = int(v * 6 * 256)
29+
lb = pval & 0xff
30+
pval >>= 8
31+
if pval == 0:
32+
a = np.array([255, 255 - lb, 255 - lb], dtype=np.uint8)
33+
elif pval == 1:
34+
a = np.array([255, lb, 0], dtype=np.uint8)
35+
elif pval == 2:
36+
a = np.array([255 - lb, lb, 0], dtype=np.uint8)
37+
elif pval == 3:
38+
a = np.array([255 - lb, 255, 0], dtype=np.uint8)
39+
elif pval == 4:
40+
a = np.array([0, 255 - lb, 255], dtype=np.uint8)
41+
elif pval == 5:
42+
a = np.array([0, 0, 255 - lb], dtype=np.uint8)
43+
else:
44+
a = np.array([0, 0, 0], dtype=np.uint8)
45+
46+
_gamma[i] = a
47+
return _gamma
48+
49+
50+
gamma = make_gamma()
51+
52+
53+
if __name__ == "__main__":
54+
fpsClock = pygame.time.Clock()
55+
FPS = 30 # kinect only outputs 30 fps
56+
disp_size = (640, 480)
57+
pygame.init()
58+
screen = pygame.display.set_mode(disp_size)
59+
font = pygame.font.Font('slkscr.ttf', 32) #TODO provide your own font
60+
while True:
61+
events = pygame.event.get()
62+
for e in events:
63+
if e.type == pygame.QUIT:
64+
sys.exit()
65+
fps_text = "FPS: {0:.2f}".format(fpsClock.get_fps())
66+
# draw the pixels
67+
68+
depth = np.rot90(get_depth()[0]) # get the depth readinngs from the camera
69+
pixels = gamma[depth] # the colour pixels are the depth readings overlayed onto the gamma table
70+
temp_surface = pygame.Surface(disp_size)
71+
pygame.surfarray.blit_array(temp_surface, pixels)
72+
pygame.transform.scale(temp_surface, disp_size, screen)
73+
screen.blit(font.render(fps_text, 1, (255, 255, 255)), (30, 30))
74+
pygame.display.flip()
75+
fpsClock.tick(FPS)

‎cv-Kinect深度相机/kinect_test.py‎

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,23 @@ def get_depth():
3535

3636

3737
if __name__ == "__main__":
38-
print 'start'
39-
while 1:
40-
# get a frame from RGB camera
41-
frame = get_video()
42-
print 'frame',type(frame)
43-
# get a frame from depth sensor
44-
depth = get_depth()
45-
print 'depth', type(depth)
46-
# display RGB image
47-
cv2.imshow('RGB image', frame)
48-
# display depth image
49-
cv2.imshow('Depth image', depth)
50-
51-
# quit program when 'esc' key is pressed
52-
k = cv2.waitKey(5) & 0xFF
53-
if k == 27:
54-
break
38+
# print 'start'
39+
try:
40+
while 1:
41+
# get a frame from RGB camera
42+
frame = get_video()
43+
# print 'frame',type(frame)
44+
# get a frame from depth sensor
45+
depth = get_depth()
46+
# print 'depth', type(depth)
47+
# display RGB image
48+
cv2.imshow('RGB image', frame)
49+
# display depth image
50+
cv2.imshow('Depth image', depth)
51+
52+
# quit program when 'esc' key is pressed
53+
k = cv2.waitKey(5) & 0xFF
54+
if k == 27:
55+
break
56+
except Exception as e:
57+
print(e)

‎参考图书Books.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
- 参考图书Books
22

33
- [OpenCV Computer Vision with Python](https://e.jd.com/30371482.html)
4-
- 包含Kinect深度相机的教程
4+
- 包含Kinect深度相机OpenNI的教程

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /