Notifications
Clear all

MP4 video camera?

62 Posts
6 Users
16 Likes
4,483 Views
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@dronebot-workshop

Posted by: @frogandtoad
Posted by: @frogandtoad

You can get 4K action cam with MP4 recording for well under $100.

Most of those action cameras only have digital zoom and autofocus, and I suspect that at the close-up range that Robo Pi needs they wouldn't perform well.

If a cheap camera is all you need you can get Blu and other no-name brands of phones with decent 8Mp cameras for under 50 bucks, they record in MP4 and connect to your LAN via WiFi (you don't need to actually use them as phones). Amazon also has their Fire tablets with a reasonable camera on sale often for next to nothing, and lots of sales days coming up at the end of November.

But all of the above suffer from the same problem - they don't have an adjustable optical lens. At that close range, you will want to reduce the focal length.

Hi Bill, I think some of the more expensive models may offer macro, and I'm pretty sure you can even purchase macro lenses to attach to them, but then the cost goes up significantly, so in the end I tend to agree with you 🙂

Cheers.


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: @frogandtoad

I watch a lot of YT engineering videos, and some of them do have quite good close up shot's, but I can't say exactly which model of camera they are using for sure.

A lot of those channels often post a "behind the scenes" video to answer questions about what kind of equipment they use to produce their videos.  Often times they are using cameras that approach $1000 or more.  They often have a lot of lighting figures and reflectors, etc.   In short, they often have quite a complex studio setup behind the scenes.

I can certainly appreciate such equipment.   I'm just not currently in a financial place to be able to grab all that stuff.  I just ordered a couple Arducam cameras.   I think they'll suit my needs.  I'm not looking for perfect video, and I tend to shoot in 1280 x 720 format at 30fps which also doesn't require the best camera.   There's a couple reasons I've chosen the 1280 x 720 format.  I won't go into detail on that, other than to say that one of the reasons does have to do with file size.   I not only have lame cameras, but I have lame computers for doing video editing on as well.  And the 1280 x 720 at 30 fps produce smaller videos files that are far easier for me to manage when editing.

So in the end I know my video quality is still going to be lacking and not up to snuff.   I'm just want to get to a point where I can at least see the details of the features to some degree.  The cameras I have right now simply won't even do that much.   And I'm pretty sure it's a limitation of the lens.  Because they seem to have enough detail when taking normal shots.  If I can get that same detail in a close-up shot that will be fine.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 

@robo-pi

If the Arducam cameras dont work for you, you could try a cheapie original rpi camera along the lines of this video:

A bit kludgy perhaps, but appears to work, and at a nice price point 😀 


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

@byron

I never thought of trying that.  I have a tone of reading glasses of all different powers.  So I'll give that a go and see what happens.

 

By golly, that actually works pretty good!

I could have saved myself some money.  I already ordered the Arducam boards.   Oh well, at least this suggests that the Arducam boards should do the trick.   It's not the resolution of the video sensor, it's definitely the lens.   Otherwise putting glasses in front it wouldn't help.  But it does help, a lot!

That's ok.  It will probably be nicer with the Arducam boards and the proper lens anyway.

But hey, thanks for the suggestion and video. 🥂 

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Spyder
(@spyder)
Member
Joined: 5 years ago
Posts: 846
 
Posted by: @byron

cheapie

Eye-glasses on a camera... Well, they put glasses on the Hubble, so why not ?

@robo-pi

I have one of these things that I got from Amazon for less that $30 USD...

image

Works pretty well I think. Here's an image I took with it from a raspi...

vncviewer Juision

Then I also occasionally use one of those cheapo Logitech cameras that I got from Best Buy for $25 USD that I found that if you remove the cover plate, you'll find a knob on the lens that looks like you can spin it, and you can... right after you remove the hot glue gun goop the manufacturer put on it to stop you from spinning it

That's a focus knob, quite handy actually. I use those cameras on my 3D printers to get closer views than the camera was meant to give me

Here's the same object taken with the Logitech camera...

vncviewer logitech

The double image you see is a shadow produced by viewing a transparent slide on a white piece of paper. You don't see that due to the fact that the Jiusion has a circular light built into it that washes out the shadows

Throw one of those images up on a 38" screen and you can find that one tiny blob of solder that escaped notice during one of my late night solder-fests

Although, I imagine that a $5 pair of glasses would be cheaper than either one of these options


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: @spyder

I have one of these things that I got from Amazon for less that $30 USD...

image

Thanks Spyder.  The Jiusion looks pretty darn good.   I might pick one of those up too.  So far I only have $42 invested in a pair of the cheaper ArduCams.  I think I'll have fun with those anyway. 😎 

I can pick up a couple Jiusions and still be well under my $200 budget for close up videos.  I actually like having the versatility of different options anyway.   This digital microscope does look very intriguing.

Today I just installed OpenCV on the Raspberry Pi 4.  Haven't yet had a chance to try it out with a camera.  I'm going to use Paul McWhorter's OpenCV code to see if that works on the RPI.  Not sure if it will.   Although I don't really need to use OpenCV to take videos on the RPI, but I like the AI options that OpenCV offers.

I'll definitely give one of those Jiusion microscopes a try. 👍 

I thought their might be ways to achieve this goal without having to buy an expensive camera.  Of course, the results probably won't be as good, but I just need something to get by with for now.  Later when I'm rich and famous I buy a real camera. 🤣 

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

Update on the Jiusion Microscope:

I've been watching a few YouTube videos on the Jiusion Microscope.  It certainly does appear to be a very good microscope for taking pictures or videos of extreme close-ups.   This actually might come in handy for me in some cases because on occasion I do make some extremely small parts.  So I'll probably buy one of these for those extreme cases.

However, just for general information, (and I'm not sure exactly what the limitations are), but thus far it doesn't appear that this is capable of less then extreme microscopic imaging.   From the videos I've watched it appears that it would be difficult to even get an entire American penny fully in the frame.  If so, that would be very close to the maximum possible field of view?  I can't say for sure without having one to test.  But thus far, I haven't seen anyone using these for anything even as large as an entire penny.

While this may be great for an intentional microscope, it's a bit limited for trying to capture shots of larger pieces in a lathe.    So while I might get one of these anyway just to have the microscopic ability.  It's probably a little too extreme in the Macro abilities when it comes to filming machining videos. 

I'm hoping the ArduCam will be more suitable for the range I'm looking to capture.  In fact, based on what I've seen in the ArduCam ads it appears to that ArduCam actually has a limitation just about where the Jiusion begins.   So I think the ArduCam is the best solution for my current hopes and dreams.

None the less, I thank you again Spyder, for pointing to this Jiusion Microscope.  As I say, I'll most likely grab one anyway in case I need an extreme micro-macro. 😊 In fact, I probably will find many occasions where it will come in handy, it's just a bit too powerful for filming general machining work.   Hopefully the ArduCam boards will bridge the gap between what I currently have and the microscopic power of the Jiusion.

It will be nice to have all these capabilities in the end however.   At these prices you can't go wrong. 

The Jiusion certainly has great reviews as a microscope to be sure.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

Update on the ArduCam boards I got:

To begin with, I got the cheap ones.  Only 5MP.  About $20 each, I got two of them.  They currently make far better ones at 12MP for about $75.  I didn't want to spend that much so I took a chance on the cheap ones.  So far they seem to be quite good.

5MP ArduCam on Amazon

 

I don't have a video worth posting yet. But it looks like these are going to do the trick.  They have to be focused manually, which is fine for my purposes.  They are easy to focus, and thus far they look like they will focus in on the parts I want to make on the lathe.   Hopefully I'll be able to try them out pretty soon.

On the Topic of Software to run the cameras:

I have three different methods to run these cameras right now.

 

  1. Raspivid - a command line method
  2. picamera for Python
  3. OpenCV

Thus far I've found picamera to be quite limited in what it can do.   That could be that I simply don't know enough about it yet, but it doesn't want to preview in a window, and will only preview full-screen.  This is problematic for me.  So I've given up on using picamera.  I should probably mention that this is an import for Python.

I haven't yet been able to figure out how to gain full control over the ArduCam using OpenCV.   So far I can only get it to work using the following OpenCV command:

OpenCV2.VideoCapture(0)

But that results in using a standard configuration size and frame speed.  I think to change that I need to include that in the brackets where the zero is above.  But I haven't yet discovered how to do that.

Currently Raspivid has been the most productive.  I'm actually running Raspivid from within Python and using subprocess to call the command line.  This give me total flexibility to set up the size and frame rate as well as creating a preview in a window that I can control.   It also allows me to convert the final video to MP4 format and erase the original .h264 file.

So I'm all set up to start making videos.  Although I'll still need to build some camera mounts around the lathe.  Once I get those all set up I'll try to post a video of doing some lathe work.

By the way, there's no microphones with these so audio needs to be recorded separately.  For my purposes here that's fine because it's too noisy with the lathe running anyway.  So I'll just dub the vocals over the video after the fact.

So yeah, for about $20 a piece you can't go wrong with these.  Assuming you already have a RPI and know how to program the camera. 😊 

I'll probably get this working in more depth with OpenCV eventually.   But for now, calling Raspivid from Python appears to do everything I need.  So I'll just go with that for now.

Thank you Bill @dronebot-workshop for suggesting ArudCam.  I was originally just looking for a camera and never really thought about using a Raspberry Pi cam.  I think this will work out just fine.

 

 

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

Update on my Raspberry Pi Camera project:

Due to tending unrelated projects this project has been taking some time to complete.  It's still not entirely complete, but all the programming is now done.   At least to a usable level.

Here's a screen shot taken on the 3.5" Touchscreen (Explained below)

screen 0

The entire display is only 480 x 320 resolution.   Although it looks far better than that.

What you are looking at in the picture is the entire 3.5" display just as it appears on the Raspberry Pi.  The display isn't any larger than a Raspberry Pi 4.   It attaches via a GPIO header connector.   I'm actually running this one on a Raspberry Pi Zero W.   Although I'm not using the WiFi so I could use a standard Pi Zero for this camera project.

The hardware consists of the following:

  1. Raspberry Pi Zero ($10, or just $5 without the WiFi)
  2. ArduCam (an inexpensive model for $21)
  3. A GPIO 3.5" Touchscreen (about $17 on eBay)

So this camera costs about $50.  And the ArduCam is capable of extreme close-ups which is the reason I built this.

Along the very top of the screenshot is the Raspbian desktop task bar.

The program that is running is named "Camera Settings".  It is a program I wrote in Python using TKinter as the GUI.

The window of my TK program is 430 x 320.  I made it slightly smaller than the display because I needed to be able to click on a desktop icon in the lower left of the screen shot. (more about that later).

The Widgets on the left of the TK window are as follows:

  1. Dropdown Options Menu
  2. A label (currently marked Steam) which was selected from the dropdown menu
  3. A static label "Video Name"
  4. A textbox (currently says Steam_1)
  5. Up and Dn buttons. (this allow me to change the number of the video name)
  6. A Record Video Button starts recording the video.
  7. A Snap Preview Button (allows me to check the focus and camera view)
  8. An Exit Button to exit the program when done.
  9. A Stop button that doesn't work!!!

I meant to remove the Stop button but forgot.

There was an interesting problem when I wrote this.  I'm using the terminal command (raspbivid) via Python to record the video.  The problem is that once you start the video recording you can no longer access the TK window program to stop it.  The program simply won't respond while the video is recording.   And since I wanted to be able to manually stop it I had to use a desktop icon to activate another terminal command (Pkill Raspivid).  This kills raspivid and returns control to the TK window.   And then you can either record another video, or exit the TK program.

It's a little crude, but it seems to work just fine.

I also have this program automatically convert the *.h264 video format to *.mp4.  I like to work with mp4 files so this way the videos are already in mp4 files after they have been saved to disk.

So this seems to be working pretty well so far.  I need to build a better physical stand for it before I can actually use it.  And now that I have it all figured out it will be easy to make more of these as I would like to take multiple angles when I'm shooting a video. 

By the way, the Snap Preview button only provides a still shot.  But I've found that this works just fine for setting up the camera and focus.  When the video is actually being recorded there is no preview.  This is because the display is a GPIO display.  I think if you use an actual HDMI screen you could see the raspivid preview.   But this is working for me.  It's not as bad as I thought it might be.  I don't need to monitor the video as it is recording.  I'll be too busy doing other things to be watching the video anyway.

~~~~

Couple more things worth mentioning:

Because this is a touchscreen the whole program can be operated using the stylus pen that came with the display.  Just click on the buttons and the program works just fine.  This is why I'm using a dropdown options menu so I can choose from a list of video names.  I don't want to have to hunt and peck at a touchscreen keyboard.  So I'll just use names I've programmed in on the list.  They are easy to modify in the software.

The UP and DN buttons allow me to change the number of the video filename.  The "Steam" stands for Steam Engine which is a project I'm working on.  So when working on the steam engine I can just number the videos Steam_1, Steam_2, Steam_3, etc.   No need to type in any video filenames.   I have "Robot" on the list too so I can take multiple videos of robot projects, etc.  So it turned out to be pretty nice for use with a touch screen and stylus pen.

~~~~

You might think this is a bit of a silly project to build your own camera.  But I couldn't find a cheap commercial camera capable of taking pictures this close-up.   I was also able to program this to automatically convert the h264 video format to mp4.  I like that feature too.  And of course, I like the dropdown list for filenames too.  Instead of just having some unknown numbers for my videos they will actually be named based on what videos they contain.   So it was well-worth it.

My own custom cameras!  Yippee! 👍 

If anyone is interested in the Python TKinter code let me know and I'll be happy to post it. Although I'm quite sure it could be improved upon.  In fact, I already have ideas to improve on the code.  It won't change the program functions, but it might make the code a bit more precise. 😊 

By the way, if you have a 3.5" HDMI display, this program will still work with that.   The only difference is that if you have an HDMI display you can use the live raspivid preview instead of the snap preview I'm using.  But I think you'd still need to use Pkill to stop the video.  I haven't figured out how to regain the program control once the video starts recording.   Thus the need to use the desktop Pkill icon.  That's a slight quirk, but hey, it works!

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

DroneBot Workshop Robotics Engineer
James


   
codecage reacted
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 

@robo-pi

Thats a nice workable solution and thanks for sharing the tKinter code, I've recently been getting up to speed with tKinter and look at all examples for new tips 😀 .

I wonder if instead of using the command line commands to control the camera you would have had better luck using the picamera API in getting the record not to freeze the tKinter program.  The following shows an rpi preview being modified by a tKinter window.

http://ceebeeoddsandsods.blogspot.com/2016/11/tkinter-and-picamera-in-python-on-rpi.html

But for these small projects its probably better to know when to stop and go with a workable solution or the programming never seems to stop. 😎  (and dont I just know this from my seemingly never ending central heating and control project with much tKinter windows to show and amend on-off schedules and the like).  


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1018
 

@robo-pi

Amazing @robo-pi!  I think we all could use something like this to document the progress we make on our projects, especially if we wanted to share some particular aspect.

There appears to be various models of ArduCams, so was wondering what model you are using?  And since you're recording video what size SD card are you using.  I'm assuming you have to remove the SD card from the PI to retrieve the video since you said you weren't using the wireless capabilities on the PI.

I think I'm going to try building one or more of these to record some DB1 progress.

SteveG


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: @byron

I wonder if instead of using the command line commands to control the camera you would have had better luck using the picamera API in getting the record not to freeze the tKinter program.

I tried using the picamera API and had exactly the same problems.  In fact, the problems were even worse in the case of an actual HDMI monitor.   Raspivid allows you to locate and size the preview window.  Picamera does not.  At least I didn't see a way to do that.  When I used picamera the preview would just take up the full screen with no access to even the desktop.   So I didn't see any way to use picamera short of having the recording terminate automatically after a given time.

Note: I could be wrong about the limitations of the picamera API as I'm not an expert on it by any means.   But I did try it, and I ended up going back to raspivid for features that the picamera API didn't appear to offer.

I also tried using OpenCV, and also found similar problems there.  I couldn't find a way to set the properties of the ArduCam using OpenCV.   But again, I'm not an expert on OpenCV either so it could be that I just don't know how to do it.   But I did search around for answers to my questions and came back empty-handed.

Thankfully raspivid has options available that turned out to be useful.   So I'm happy that at least something worked here.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  
Posted by: @codecage

There appears to be various models of ArduCams, so was wondering what model you are using?

I bought a cheaper model, it appears to be suitable for what I want to do.  It only cost $21 with a nice plastic holder.

The ArduCam I'm using from Amazon

You can obviously get far better ArduCams if you're willing to pay more.   They should still work with the Python code I wrote.   You'd just get better quality videos.  Someday I might spring for a better camera module.  But these should work to get me started.

Posted by: @codecage

And since you're recording video what size SD card are you using.

That's a good question.  I didn't mention it in the code, but I will actually be changing the video file paths to put the video out to a stick drive I have attached via a USB hub.   This way I can remove the videos and transfer them to my main computer without having to remove the system SD card of the Pi Zero.

I saved it to the system card for now just as a prototyping test.

Posted by: @codecage

I'm assuming you have to remove the SD card from the PI to retrieve the video since you said you weren't using the wireless capabilities on the PI.

Yes, I am using a manual transfer of the files.  But as mentioned above, I save the videos to a USB stick instead of the Pi system card.

And yes, if you want you could have the video files sent over WiFi directly to your video editing computer, or wherever you want them to go.   I chose to use the manual USB stick because my shop doesn't have WiFi access.  It's too far from my router.   So saving them to a USB stick will suit my needs.

But YES!  The possibilities are endless.   In fact, you could actually set this up to be a remote camera at some far away location (assuming you have WiFi access there), and control it from a Remote Desktop and have it send the videos back to you, or even stream them live.

So yeah, my application here is pretty crude actually.   I'll be happy to just be able to take close-up videos on my lathe and milling machines.  Bringing them back to the editing computer on a USB stick will work for me.  At least they will already be in MP4 format so I'm saving myself a step there. 😊 

I've satisfied my original four criteria:

  1. Cheap camera
  2. Close-up lens
  3. MP4 video format
  4. 1280 x 720 capability

I managed to satisfy all four of these.  So I'd say that's a WIN for me. 😎 

By the way, I think my current raspivid command is recording default 1920 x 1080 videos.   But there's an option available to set that to other sizes including 1280 x 720.  I'll probably do that in my finished code.

I want to use 1280 x 720 to match other videos that I'll be using in my video editor, so that's the reason I want that screen size.  It just makes it easier at the video editing end of things.   It also makes for smaller video file sizes too.  Easier to load and edit in the video editor.  All my computers are sluggish, so if I can keep things to a smaller file size that's always a big win.

By the way, that's something you might want to consider when using WiFi.   If you can get by with using smaller videos it just makes everything go that much faster when transferring or streaming video files.   It makes a BIG difference in video file size, and a SMALL difference in video quality.   Of course, judging video quality may be a bit subjective.   But these old eyes can't see any difference on a computer screen.  Where you might notice the difference is if you put it up on a very LARGE screen TV.  That's where 1920 x 1080 would shine.

DroneBot Workshop Robotics Engineer
James


   
codecage reacted
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
Topic starter  

DroneBot Workshop Robotics Engineer
James


   
Spyder reacted
ReplyQuote
Page 2 / 5