Raspberry Pi camera module

Post

Posted
Rating:
#1 (In Topic #138)
Regular
sony is in the usergroup ‘Regular’
 Hello,
Is there an simple example program to use RPi camera module as video streaming like usb webcam?

Thank you for your attention.
Regards

Sony

Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
I presume you mean streaming from the pi to a computer using SSH as Matt and I did with his robot (It had a camera on it then!).
Image

(Click to enlarge)

On the Pi create a file (e.g. startvideofeed.sh) with only the following: -

  raspivid -o - -t 0 -hf -w 640 -h 360 -fps 25 | cvlc -vvv stream:///dev/stdin –sout '#rtp{sdp=rtsp://:8554}' :demux=h264

Change permissions:-
  sudo chmod +x startvideofeed.sh

Run the file ./startvideofeed.sh

On the main computer open VLC from the 'Media' menu select 'Open Networkstream'. Enter rtsp://192.168.2.111:8554/ (Where 192.168.2.111 is the IP of the Pi)
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
sony is in the usergroup ‘Regular’
 Thank for reply,
I mean streaming video with gambas. I has been tried a webcam with gambas to stram the video.
By use drawingarea I can see the current video via webcam.
Now I want to change the webcam with PiCam.

regards

Sony

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
stevedee is in the usergroup ‘Regular’
Hi sony, you asked for the code on my blog, so here it is.

As I mentioned, it is not finished (typical!). It will stream video (which I use to set the camera up and check focus) and it will capture at 90fps, but it doesn't do both at the same time.

To stream, this program simply runs the stream.sh script. You also need to install VLC.

The real-time clock stuff won't make any sense. I use it in conjunction with a simple RPi time server, so I can time stamp files.

My original blog post: Captain Bodgit: Chicks at play: RaspiCam 90fps

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
stevedee is in the usergroup ‘Regular’
 Re: MyWebCam_test on RPi, do you have: /dev/video0 and v4l2 driver?

If the software is a bit old, update:-

sudo rpi-update
sudo apt-get update
sudo apt-get upgrade

Still no /dev/video0?, run: sudo modprobe bcm2835-v4l2
Online now: No Back to the top

Post

Posted
Rating:
#6
Regular
sony is in the usergroup ‘Regular’
 Hi Steve,
The program MyWebCam_test has been tested and running. My problem is my webcam device have max frame rate at 30 fps, so I decided to change the webcam with PiCam that have frame rate at 90fps. I just need small program like MyWebCam_test by using PiCam as my reference to develop my idea. My project is shoot the image on moving object with camera device.

Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Regular
stevedee is in the usergroup ‘Regular’

sony said

…My project is shoot the image on moving object with camera device.

How are you planning to use 90fps video with your Gambas test program?
Online now: No Back to the top

Post

Posted
Rating:
#8
Regular
sony is in the usergroup ‘Regular’
 I use for higher fps to get good image, currently I use 30fps can't copied the the moving object clearly.
I use gray scale video and by using drawingarea I copy an sample area then count the pixel.
How I count? I copied the image, the corner pixel value as reference value. I get all pixel value in the sample area and compare with reference value. Let's say if pixel value > 10 then I add counter until all pixel value compared.

Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#9
Regular
sony is in the usergroup ‘Regular’
 Hello,
Now I am able to appearing the actual video with command below:

Shell "raspistill -t 0 -p 454,266,350,350 -ex auto -hf  -rot 180  -ifx none"

My problem I can not copying the video to Drawingarea as picture.
Please help me to copying the object outside of form1.form

Sony
Online now: No Back to the top

Post

Posted
Rating:
#10
Regular
sony is in the usergroup ‘Regular’
hello,
Base on source code from https://github.com/charlie-ogier/PiCam
I made a small program to copied the screen but the object from picamera can not copied.
please help me.

Sony

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#11
Avatar
Regular
stevedee is in the usergroup ‘Regular’
 I don't have any time this weekend to look at this, but I wonder whether you should be using v4l to get images from RaspiCam (via /dev/video0) rather than using Raspistill or Raspivid in a Shell.

I think there are Gambas components for both v4l and gstreamer that might be worth exploring.
Online now: No Back to the top

Post

Posted
Rating:
#12
Regular
sony is in the usergroup ‘Regular’
 Hi Steve,
Sorry I'm not use v4l for picamera but v4l for usb webcam.
Online now: No Back to the top

Post

Posted
Rating:
#13
Avatar
Guru
cogier is in the usergroup ‘Guru’
 I am trying to understand what you are trying to do, can you explain what you hope to achieve.

Are you using the Pi and a USB camera or a Pi Camera?

Are you trying to capture the video on the Pi or stream it to another computer?
Online now: No Back to the top

Post

Posted
Rating:
#14
Regular
sony is in the usergroup ‘Regular’
Sorry I'm slow in english  ;) ….
I only using RPi.
By using my latest program, I use picamera and  RPI but I can not copy the video into drawingarea as picture when a button pressed.
If I have a picture (gray scale/black white) inside drawing area I will count the pixel and compare the pixel value with my reference.
Online now: No Back to the top

Post

Posted
Rating:
#15
Avatar
Guru
cogier is in the usergroup ‘Guru’
OK let's see if I have got this right. Attached is my PiCam software with a additional Form and Class.

Run the program. Take a picture with the size at 800 x 800 then click on the 'Sony' button and you will see the picture you took in a DrawingArea.

Is this what you are looking for?

This will only work on a Raspberry Pi using the picamera
Attachment
Online now: No Back to the top

Post

Posted
Rating:
#16
Regular
sony is in the usergroup ‘Regular’
 Hello,
I run your program, but that is not I mean. I mean just click the "Sony" button the current running video is show in drawingarea as picture. I do not need read jpg file to visualize into drawingarea, because in the next time I will do million times to take the current running video is show in drawingarea as picture.

regards
Sony
Online now: No Back to the top

Post

Posted
Rating:
#17
Regular
sony is in the usergroup ‘Regular’
Hello,
Today I read your program carefully and now I understand about using ram drive  :)  I assume read / write into ram million times is not to make ram damage. So with raspstill command to save image *.jpg file into ram drive and read again then place into drawingarea.
Thank you very much for helping me.

Best regards

Sony
Online now: No Back to the top

Post

Posted
Rating:
#18
Avatar
Guru
cogier is in the usergroup ‘Guru’
 Hi Sony,

You cannot see the 'raspistill' output over SSH so the program takes a photo 75 times a minute that is stored in RAM which is quicker and does no damage to the SD card. The picture can then be seen over a SSH link.

Glad it helped,

Charlie
Online now: No Back to the top

Post

Posted
Rating:
#19
Regular
sony is in the usergroup ‘Regular’
Here my code,
Attachment

sorry for the messy code
Online now: No Back to the top

Post

Posted
Rating:
#20
Avatar
Guru
cogier is in the usergroup ‘Guru’
Hi Sony,

I got the LibWiringPi sorted :D

Then at line 78 I got error  'File of directory does not exist' :o

Code (gambas)

  1. nf = "~/param.par"
  2. hfile = Open nf for Input

I REMed that out then I got another error at Line 180, 'Unable to load picture' :?

Code (gambas)

  1. hMyPic = Picture.Load("/var/tmp1/sample.jpg")

What am I missing?
Online now: No Back to the top

Post

Posted
Rating:
#21
Regular
sony is in the usergroup ‘Regular’
Hi Charlie,
It's like a beginner tech to teacher :)
I think you must log in to root

1st problem, you should have 'param.par' file in the home folder.
Image

(Click to enlarge)


2nd problem, you must create the 'tmp1' ram drive
Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#22
Avatar
Guru
cogier is in the usergroup ‘Guru’
OK. I suggest you add the following code at line 79 to create 'param.par' if it does not exist

Code (gambas)

  1. If Not Exist(User.home &/ "param.par") Then File.Save(User.home &/ "param.par", "")

I changed all references to the RamDrive to /tmp (not /tmp1) and added the following 'Sub' which I took from 'PiCam'.

Code (gambas)

  1. Public Sub CreateRAMDrive()                                         'To create a RAM drive to hold the SSH Preview picture
  2. Dim sFstab As String                                                'To store the details in the fstab file
  3.  
  4. If Not Exist("/var/tmp") Then Mkdir "/var/tmp"                      'Does this folder exist, if not create it
  5.  
  6. sFstab = File.Load("/etc/fstab")                                    'Load the contents of fstab into sFstab
  7.  
  8. If Not InStr(sFstab, "tmpfs /var/tmp tmpfs nodev,nosuid,size=3M 0 0") Then 'If the string we need to create the 3Meg RAM drive is not there then..
  9.   sFstab &= "\ntmpfs /var/tmp tmpfs nodev,nosuid,size=3M 0 0\n"     'Add the string to the end of the file
  10.   File.Save(User.Home &/ "fstab", sFstab)                           'Save the file to the Home folder
  11.   Shell "sudo mv ~/fstab /etc/fstab"                                'Move the file to the 'etc' folder
  12.   Shell "sudo mount -a"                                             'Mount all drives including our new one
  13.  

Then call that the 'Sub' : -

Code (gambas)

  1. Public Sub Form_Open()
  2.  
  3. CreateRAMDrive
  4.  
  5. If (wiringPiSetup() = -1).............

I get a picture taken in the RamDrive but I am not sure what is supposed to happen next, I have changed all the values and clicked everything but nothing seems to happen. Are you still trying to display video output?
Online now: No Back to the top

Post

Posted
Rating:
#23
Regular
sony is in the usergroup ‘Regular’
It's about how to setting the parameter. For test just add a button with code like picture below:
Image

(Click to enlarge)


IF you run the program then click the button will shot the camera like below:
Image

(Click to enlarge)


Now you can fill the parameter. Size mean size area copied of image from left to right area, Pos mean position area copied of image from left to right area.

for example if you want capture the position of image with the writing SIMATIC you must set the paramater Pos with value like image below,
press copy button you will copy the necessary position to right area.
Image

(Click to enlarge)

After that if you press 'calculate' will count differential pixel color in the image copied area.

If you give different value in Pos parameter and try step like above will give different pixel count. Just if trigger active and picture shot by camera automatically and if Actual pixel count less then limit the output will be energize.
Online now: No Back to the top

Post

Posted
Rating:
#24
Avatar
Guru
cogier is in the usergroup ‘Guru’
Matt and I have done some work for you. Have a look at the attached program.

When you want to 'Copy' just use the mouse to select the area to copy and when you release the mouse button it will copy across automatically.

Hope you like it.

Attachment
Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#25
Regular
sony is in the usergroup ‘Regular’
my goal to make this project is to stop the conveyor if PiCam detected  products that are not printed with barcode images automatically. See my block diagram below.
Image

(Click to enlarge)

Online now: No Back to the top
1 guest and 0 members have just viewed this.