what is the best way to save an image to the hard drive of the pc that runs the ide?
The camera is attached always via usb.
i want to save an image on an event and not continuously.
Is this possible at all?
i cant find something similar i found only to sd card examples .
It’s possible but not with mass storage, and not while the IDE is running, there’s more than one option, you can send it with USB_VCP (there’s an example), over USB debugging (there’s an example with pygame etc…) and probably the easiest is with the RPC library.
i 've tried both rpc_image_transfer_jpg_as_the_controller_device.py
and the rpc_image_transfer_jpg_streaming_as_the_controller_device.py on my pc with python 3.11
i saved the main.py to camera accordingly.
I saved the rpc.py to the same directory as the python script.
I have installed pyserial too.
After connectiong to com port by entering the name of it…
All i get is a black frame buffer althought it shouldnt.
Please make a bug tracker on github and I’ll see what I can do about it.
today i tried another camera with rgb sensor and it worked.
Then i installed a new global shutter and again it worked.
Then moved the new global shutter to the previous camera and it worked.
Then i installed the previous global shutter and it worked again!.
Dont know maybe was a hardware issue that solved by removing and install again the global shutter.
Despite that i noticed that the frame buffer not always decodes the image ok but corrapted.
A few images per minute…
I was strangling on this problem for almost 2 months.
Althought my problem solved for the examples now i have to face the adaptation on my code.
I have already a very well working script for inpection! It works great! I would be ready to install the camera for a long time ago If only i could save a desire image on an event (if condition of a tool) to the pc for user inspection!
With this example all the frames are transfered to a pygame monitor. There isnt any need for this at all.
I want to save just a simple image if some creteria occure. I dont care if this image will take too long to be saved. But its really important to keep my frame rates when image isnt about to be saved (190fps).
interface loop stack my program so another method would be the solution for me.
But really i dont know how to do this and i am really not willing to spent another 2 months for some code.
I searched the forums here, python foroums too. So if anyone can help on this will be great.
I didn’t believe that to save an image would be so difficult.
I would use the save to sd card but again camera needs reset to view the images. While resseting the camera we lost inspection seconds. So neither this is ok for me.
So iam stacked here…
Hi, I’m not following. Please note it’s hard for me to track context over a lot of threads.
You want to save an image and maintain 190 FPS at the same time? This is super challenging. To do this you need to basically change how our firmware works. You’ll need to write a driver that buffers an image and performs the write in an it interrupt to the disk. We don’t have the C code setup for this right now. Currently, the processor blocks on writing to the SD card. This is something that we can improve in our drivers but as of right now it means that disk I/O is expensive.
Our image capture and LCD output code is fully buffered currently, but not SD card writing.
No as I mention before I don’t mind if the save image function block my script . The only thing I want is to save it in my pc(I don’t care how much time it will cost) and then continue inspection at high fps.
I can do it fine on SD card but this way I cannot watch the images unless I reset the sensor. But this way I loose information for many seconds and not only the save image time which is some ms…
I wish I could save this single image on my pc as easy as I can do it on the SD card…
Okay, the easiest way to do this is to use the debug procotol on the OpenMV Cam. We put a JPEG image in the JPEG buffer and then that can be ready async. I’d recommend taking the IDE Qt code for the serial port/io_driver and using that to make a C++ app.
You can do this with our simple python code… but, the IDE has to do alot of crazy stuff to make things robust.
ok i tried the following and while connected with ide terminal i am able to see only the images i want:
the timings are fine too…
now i switch to:
cmd = usb.recv(4, timeout=5000)
if (cmd == b'snap'):
seems its working cause i see the frames drop on serial terminal when blobs_count > 0 like when i was able to see the image with print(img.compressed_for_ide()).
what left is to build a simple read controller to read and save that image.
some code will help me finish the project…
but i dont know how.
if someone have some code or can point me to a useful tutorial I would be greatful!
c# would be better for me cause i used to work with forms.
but the point is to build this controller on any language till make it work.
ok finally did this and it seems to work exactly how i want.
very simple solution and i am wondering how no one could suggest me a few lines of code instead of dealing with the useless streaming examples…
bonus timestamps on images to be saved…
if sp.isOpen() == True:
now = datetime.now()
current_time = now.strftime("%H_%M_%S")
size = struct.unpack('<L', sp.read(4))
img = sp.read(size)
with open(current_time+".jpg", "wb") as f:
We found some problems recently with the RPC/RTSP libraries and fixed them, I see you also found a solution for your problem, great! Marking this thread as solved.