
it almost seems like the entry box is not at the right position... Could you send me the original video, or even just a sample and also the position you gave to the box ?
Code: Select all
#Entry location
hive = Hive(0,0,50,480)
#drawing rectangle
cv2.rectangle(frame, (0, 0), (50, 480), (255,0,0), 2)
guyver2 wrote: it almost seems like the entry box is not at the right position
Code: Select all
# new bee, check if it came from the entrance
def append(self, pt):
# if a bee pops out from the hive entrance, then count it
print "new bee at ", pt, ':',
if pt[0] > self.x and pt[0] < self.x+self.w and pt[1] > self.y and pt[1] < self.y+self.h:
self.OUT += 1
print 'coming from the hive'
else:
print 'not coming the hive'
Code: Select all
for i in xrange(len(freeKP)): # new keypoints
if freeKP[i]:
bees.append(Bee(keypoints[i].pt))
hive.append(kp.pt)
Code: Select all
for i in xrange(len(freeKP)): # new keypoints
if freeKP[i]:
bees.append(Bee(keypoints[i].pt))
hive.append(keypoints[i].pt)
Code: Select all
import io
import time
import threading
import picamera
# Create a pool of image processors
done = False
lock = threading.Lock()
pool = []
class ImageProcessor(threading.Thread):
def __init__(self):
super(ImageProcessor, self).__init__()
self.stream = io.BytesIO()
self.event = threading.Event()
self.terminated = False
self.start()
def run(self):
# This method runs in a separate thread
global done
while not self.terminated:
if self.event.wait(1):
try:
self.stream.seek(0)
# Read the image and do some processing on it
#Image.open(self.stream)
#...
#...
# Set done to True if you want the script to terminate
# at some point
#done=True
finally:
# Reset the stream and event
self.stream.seek(0)
self.stream.truncate()
self.event.clear()
# Return ourselves to the pool
with lock:
pool.append(self)
def streams():
while not done:
with lock:
processor = pool.pop()
yield processor.stream
processor.event.set()
with picamera.PiCamera() as camera:
pool = [ImageProcessor() for i in range (4)]
camera.resolution = (640, 480)
# Set the framerate appropriately; too fast and the image processors
# will stall the image pipeline and crash the script
camera.framerate = 10
camera.start_preview()
time.sleep(2)
camera.capture_sequence(streams(), use_video_port=True)
# Shut down the processors in an orderly fashion
while pool:
with lock:
processor = pool.pop()
processor.terminated = True
processor.join()
A small update on our project...gtoal wrote:I've posted the initial hardware part of our project to http://www.instructables.com/id/The-Electric-Hive/.
Code: Select all
pi@frankenputer:~/bin $ ./bmp280
Pressure: 1009.50hPa - Temperature: 26.35°C
pi@frankenputer:~/bin $ sudo ./dht22 22 22
Temp=25.7* Humidity=59.9%
Our hive is now live, and you are welcome to grab our video files to use for data:guyver2 wrote:when I said the code run real time last summer, it was for the very first version reading from a video stream and with downsampled images.
When I actually ran it on my raspberry with the camera I got a huge frame drop. Since I do not have a beehive to get proper image feed I just updated the code to use the picamera module instead of reading from a file. I did not perform extensive testing and benchmarking.
Using smaller images (not only for processing but also when reading from the sensor), reducing the background history size are two parameters that would increase framerate with a tradeoff for result's quality.
look at these parameters :
SCALE and HISTSIZE
https://github.com/guyver2/beehive/blob ... ra.py#L150