Notifications
Clear all

Using a esp32 cam to make a surveillance camera.

28 Posts
4 Users
2 Likes
4,385 Views
(@sj_h1)
Member
Joined: 4 years ago
Posts: 167
Topic starter  

@davee OK, I used your code, however the picture is very slow to update. I commented out the framerate selection that was in the code and used a lower framerate and now get no image at all. Help!

config.frame_size = FRAMESIZE_CIF; // modified for faster read
config.jpeg_quality = 10;
config.fb_count = 2;

 


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1663
 

Hi @sj_h1,

  Sorry to see you still have problems.

(Obviously the code is not mine, I only 'found it" and hoped it would be useful.)

I have just downloaded the code from the address I gave, installed the servo library as described in the article, copied it into an empty sketch, set SSID and password to my router, compiled and uploaded, and set it to run, and opened a new browser window with the address given in the monitor window... and so far as I can see it works as I might expect.

The picture is not 'broadcast quality', but for a $5 camera + webserver, seems pretty fair.

I tried subjectively comparing with the CameraWebServer program which prints the frame rate .. but confusingly, also seems to shrink the picture. Perhaps the frame rate for the servo version is around 20 frames per sec. But this is just a guess. It depends upon the amount of change in scene that is going on.

My camera/ESP is just dangling on the end of the cable, the WiFi link is susceptible to interruptions if I am too far from my router .. this can cause the picture to freeze, then carry on. Could the signal be weak in your case, giving poor results?

--------

I don't have any servos, but the servo version prints things like Up 10 and Right 10, so I would hope that if I had servos, they would work.

---------

I tried changing the framesize, as you suggested. I agree, for some reason "CIF" does not work. However, both SVGA and HVGA did work, and they changed the size of the picture in the browser. Why CIF doesn't work I don't know, but perhaps you can do a few trials through the list to find one that meets your needs.

-------------

I found it counterintuitive, that the example code picks VGA with the psram available, and the higher resolution SVGA, without psram, but perhaps there is a good reason. There might be an opportunity to optimise something here, if you can figure out the details. ( I have feeling the reason will be 'obvious', when someone explains it.)

----------

So, sorry if this is not a precise answer, but I hope it is enough to encourage to dig a bit deeper and find a solution that meets your needs.

 


   
ReplyQuote
(@sj_h1)
Member
Joined: 4 years ago
Posts: 167
Topic starter  

@davee At least, you confirmed what I saw. Perhaps, the image size has something to do with it. Where in the code did you see that?

 


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1663
 

Hi @sj_h1,

  Sorry I haven't tracked back into the detail code ... the only thing I found is the file sensor.h which lists possible FRAMESIZE_xxx values as an enum type. On my pc, this was deeply buried at 

arduino-1.8.13/portable/packages/esp32/1.0.6/tools/sdk/include/esp32-camera

I am still finding my way around Arduino, but it appears much of the code is precompiled, with only the linkable object code loaded for a 'standard' installation, including much of the ESP32 CAM code. I suspect the source code is available on Github, but may take some tracking down.

For example, the linkable file libesp32-camera.a , which on my machine is at

arduino_portable_IDE/arduino-1.8.13/portable.packages/esp32/hardware/esp32/1.0.6/tools/sdk/lib/

Of course, this might be delving deeper than you wish. It might also imply using a different IDE from Arduino to handle the code, etc. I haven't ventured that far yet.

-----------------

If you want to see what gets linked into your file when you hit 'Compile' in Arduino, you need to edit the preferences file "platform.txt", which on my machine was in

arduino-1.8.13/portable/packages/esp32/hardware/esp32/1.0.6/

Find the line that starts recipe.c.combine.pattern="

and may end with }.elf"          

(NB It is a very long line ... may show as 3-4 folded lines unless you have a very wide screen)

Then add to the end of that line, a space, followed by      -Xlinker   -Map=arduino.map

This should create a link map file called arduino.map when you compile. It appeared in my home (~) directory on Ubuntu. (I presume you could be more creative with the filename, but I haven't tested that.)

-----------

Good luck.


   
ReplyQuote
(@sj_h1)
Member
Joined: 4 years ago
Posts: 167
Topic starter  

I have verified everything you said. I examined bot applications camera settings and they appear to be the same. The result was the original example camera server code was much smoother and better update rate the the pan and tilt example. The pan and tilt is exactly what I need in terms of interface but the camera update rate is much too poor to be of use. So if there is some way to combine the two, it would be perfect.

 

 


   
ReplyQuote
(@sj_h1)
Member
Joined: 4 years ago
Posts: 167
Topic starter  

The code appears to be very simular and I expect that DaveE is correct that the only major difference is the libraries used. However, the includes appear to be the same so how do they "select" a different library?


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

@sj_h1

I was able to edit the original HTML and added buttons on the main page for up down left and right. Right now I have it just updating and printing in the loop but this should be usable. This should give you all the options without having to deal with the default stream function. I can also provide my edited HTML if you want to change it. It is set up in softAP but that can be changed. It was just easier for me to test.

 

After running custom handlers, I realized that would cut the stream so I ended up running everything through the command handler so that it will update in the background and not interfere with the stream. You will probably need to set your limits there.

 

I think this is closer to your original idea.

 


   
DaveE reacted
ReplyQuote
(@sj_h1)
Member
Joined: 4 years ago
Posts: 167
Topic starter  

@madmisha I compiled and but I can't seem to get the IP to work. I tried both and neither work.

AP IP: 192.168.4.1
Starting web server on port: '80'
Starting stream server on port: '81'
Camera Ready! Use 'http://0.0.0.0' to connect


   
ReplyQuote
(@sj_h1)
Member
Joined: 4 years ago
Posts: 167
Topic starter  

@madmisha Ok I commented out the "wifAP " stuff and used the original wifi code and I van now see the web page with the new buttons. Thx. The up and down work exactly as I expect however the right and left BOTH add to the y axis. I changed the line xaxis = xaxis + xchange; under the else if(!strcmp(variable, "xdn")) to xaxis = xaxis - xchange; It did not fix the problem. Still looking.


   
ReplyQuote
(@sj_h1)
Member
Joined: 4 years ago
Posts: 167
Topic starter  

@madmisha Ok changing the line of code above did fix the problem. Just didn't seem to work the 1st time I downloaded it. Maybe it e=was a bad load I don't know. The code appears to work now. It's update rate is MUCH better than the pan and tilt code. Now All I need to do is add in the servo move commands. Thanks alot for the help.

 


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

@sj_h1

Yeah, I was working so hard on trying to get the interface to actually work that I guess I messed up the axis. I also think the left and right may need to be switched. I guess it depends on the orientation.

I suppose you could either add fine movement buttons or a dropdown box to select the amount moved with each click. I know how annoying it can be moving a camera a long distance but only with small steps. I was thinking something like:

buttons

The double arrows would be bigger steps. Sorry, I'm no artist. Although I don't know how to make them align like that. I haven't really edited HTML since high school.

You can also reduce the delay in the loop. I brought it down by dropping a 0 but you might be able to go lower. I'm not sure at what point it will interfere with the stream though. I think they only had the delay in there to keep it alive.


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

And here is the HTML file in case you want to make changes. I was not actually sure what view angle my camera has so a pasted over both with the same. This is all based off of the HTML that I received from my camera using the default example.

 

I created classes to make the alignment work. I added a const reference to the buttons. Then set the action to the buttons to report through the updateConfig function. You can add anything you want using that method. You already saw the command handler that takes care of the other end.


   
ReplyQuote
(@sj_h1)
Member
Joined: 4 years ago
Posts: 167
Topic starter  

Thanks its working much better.


   
ReplyQuote
Page 2 / 2