ArduCAM / Arduino

This is ArduCAM library for Arduino boards
MIT License
477 stars 350 forks source link

inverted image (how do I fix), "stuck" framerate #292

Open ghost opened 6 years ago

ghost commented 6 years ago

Hi Lee, first time commenting here. I have the Arducam MT9V034_VGA & USB sheild. Please help! Somewhere in the 2 days that I have had this the image became inverted. I don't know how to reset the sensor. Also the FPS never changes: I can set register 11 to 3 or 0x20 or 0x40 and its always reading back a framerate of 37 - advertised of course at 60.

ghost commented 6 years ago

example

Addendum: I switched from the USB 3.0 I was using and restarted with USB 2.0. My FR went immediately to 62-63 FPS both capture and exposure. However there was not a significant difference in frame rate between the 3 configurations available to me:

MT9V034_VGA_8bit MT9V034_WVGA_8bit MT9V034_WVGA_10bit

Also, do the registers stay set when not using the sensor?

One big problem persists: my image is inverted. How do I fix?

ArduCAM commented 6 years ago

Please change the register 0x0D bit[5]=Column Flip, so the correct register setting is REG = 0x0D, 0x320 in order to mirror the image. These three settings are the same resolution 640x480 or 752x480 so their frame rate is the almost the same. Let me know what do you want to do with the frame rate. You can reduce the resolution to get higher fps.

ghost commented 6 years ago

Thanks! Those register settings did it. No longer mirrored.

I would like to have one more frame rate config. around 320 x 240 or slightly larger for testing.

Also is here some configuration with the lens or filters for NIR/IR operation? IR pass somehow...

ArduCAM commented 6 years ago

You have to change the width and height registers register for 320x240 resolution, I will work on that settings to then get back to you. I'm not sure what kind of camera you got and where it got from? We have lots of lens options http://www.arducam.com/lenses/ For NIR you just simple remove the IR cut filter on the bottom of the lens.

ghost commented 6 years ago

Default M12 mount 6mm LS-6020 lens 1 pcs Arducam CMOS MT9V034 1/3-Inch 0.36MP Monochrome Camera Module ArduCAM USB Camera Shield

ghost commented 6 years ago

Lee.

Hi, did you ever get the change in resolution working (above)

ghost commented 6 years ago

Have been working on other aspects of the project. I tried your registry setting above REG = 0x0D, 0x320, it works, but I have to do it every time I boot up the camera.

  1. is there a way to make it permanent?
  2. what registry read/write vals to change resolution to 320 x 240 for example.
ArduCAM commented 6 years ago

If you are using windows, you can write the regsiter settings into the MT9V034.cfg file permanently. To change to 320x240, modify the following registers: REG = 0x03, 240 REG = 0x04, 320

ghost commented 6 years ago

Its MT9V022, linux thx is the same?On May 9, 2018 9:48 AM, Lee notifications@github.com wrote:If you are using windows, you can write the regsiter settings into the MT9V034.cfg file permanently. To change to 320x240, modify the following registers: REG = 0x03, 240 REG = 0x04, 320

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

ArduCAM commented 6 years ago

For linux, you have to set the regsiter in the code like this: ArduCam_writeSensorReg( useHandle, 0x03, 0x01E0 ); ArduCam_writeSensorReg( useHandle, 0x04, 0x02F0 ); MT9V022 is almost the same as MT9V034.

ghost commented 6 years ago

Im trying the linux samples and am getting library errors...do you know what the problem might be? ... make all Building target: MT9V022 Invoking: GCC C++ Linker g++ -L/home/primeuser/Documents/Marble/MT9V022/src -o "MT9V022" ./src/MT9V022_demo.o -lArduCamLib.so -lusb-1.0.so /usr/bin/x86_64-linux-gnu-ld: cannot find -lArduCamLib.so /usr/bin/x86_64-linux-gnu-ld: cannot find -lusb-1.0.so collect2: error: ld returned 1 exit status makefile:45: recipe for target 'MT9V022' failed make: *** [MT9V022] Error 1

ArduCAM commented 6 years ago

You also need the following library files for compiling your code. https://github.com/ArduCAM/ArduCAM_USB_Camera_Shield/blob/master/Linux_x86/Cpp/ArduCAM_Linux_SDK_OpenCV_MT9V022_Demo/libArduCamLib.a https://github.com/ArduCAM/ArduCAM_USB_Camera_Shield/blob/master/Linux_x86/Cpp/ArduCAM_Linux_SDK_OpenCV_MT9V022_Demo/libusb-1.0.a

ghost commented 6 years ago

Ok. Do they go in the usr/local/lib or just the /lib

ghost commented 6 years ago

I just want a working copy. ./Test: error while loading shared libraries: libopencv_core.so.2.4: cannot open shared object file: No such file or directory So recompiled with opencv linking to latest version: g++ MT9V034_demo.cpp -o Test pkg-config --cflags --libs opencv -lArduCamLib -lpthread -lusb-1.0 -L. -I. -std=gnu++11 I've added .a to my latest files. When I recompile to link to present opencv version I get error: /usr/bin/x86_64-linux-gnu-ld:/usr/local/lib/libArduCamLib.so: file format not recognized; treating as linker script /usr/bin/x86_64-linux-gnu-ld:/usr/local/lib/libArduCamLib.so:0: syntax error collect2: error: ld returned 1 exit status If I could just get this running won't have t bother you guys : )

ghost commented 6 years ago

Ok, so I updated the libraries and recompiled from within the demo code and it compiled successfully, no linker errors. Now, the window opens but shows an image very rarely; it says "cam_data_len" error or something like that. I've tried redompiling, etc., same message.

ArduCAM commented 6 years ago

can you show me some screen shot?

ghost commented 6 years ago

Sorry late ss_linux_run

ghost commented 6 years ago

Here is another error I picked up: failed to load canberra-gtk-module canberra-gtk-module shot

ghost commented 6 years ago

compiler statement: g++ MT9V022_demo.cpp -o Test pkg-config --cflags --libs opencv -lArduCamLib -lusb-1.0 -lpthread -L. -I. -std=gnu++11

from within MT9V022 demo folder Demo folder: ArduCamLib.h libArduCamLib.so.1.0 libusb-1.0.so.0 Test libArduCamLib.a libArduCamLib.so.1.0.0 libusb-1.0.so.0.1.0 Test-0 libArduCamLib.so libusb-1.0.a libusb.h Test-1 libArduCamLib.so.1 libusb-1.0.so MT9V022_demo.cpp

copy libusb-1.0.a & libArduCamLib.a --> /lib folder copy libArduCamLib.so & libusb-1.0.so -->/lib folder

Thank you!!

ArduCAM commented 6 years ago

"cam_data_len" error means that the received frame data size is less than anticipated it should be. Their might come from different situations, but the USB through put might takes the most important role for that. Please connect the camera to USB root hub only, without other USB device.

ghost commented 6 years ago

I'm not exactly sure what you mean. Can you plz clarify? FYI the 022 and 034 both work excellently in Windows USB Demo. As you have pointed out it isnt yet ready for opencv.

The Linux based will play a few frames above error until crash on the Virtual Machine. I've tried different USB configs...my keyboard and mouse are USB. We need to make this app work. Does the USB driver need an update?

ArduCAM commented 6 years ago

Please don't use Virtual machine, the performance of USB is very low in VM.

ghost commented 6 years ago

What would you suggest - a dual boot OS?

ArduCAM commented 6 years ago

Yes, you need to install dual boot OS for both Winodws and Ubuntu Linux

ghost commented 6 years ago

I've got (2) machines. Can I dedicate 1 to each OS?

ArduCAM commented 6 years ago

It will be even better, you can swap the camera if you come across any issue to do some comparison.

ghost commented 6 years ago

Hi Mr.Lee, have 2 separate systems now 1 ubuntu and 1 windows as we discussed. No major probs.The opencv installation went well in linux/ubuntu. The program re-compiles fine to link to more modern opencv version with no linker errors.

So why does it start the program without following through?

ArduCAM_Linux_SDK_Opencv_MT9V022_Demo# sudo ./Test Device found = 1

ArduCam_open successful

create capture thread successfully

create display thread successfully

That's all that happens.

No Window/image generation...

ghost commented 6 years ago

By the way this is my compiler line from command prompt: g++ MT9V022_demo.cpp -o Test pkg-config --cflags --libs opencv -lArduCamLib -lpthread -lusb-1.0 -L. -I. -std=gnu++11

DO I need to do this in addition? Download the libusb

Unzip tar -jxvf libusb-1.0.21.tar.bz2

Then configure ./configure or ./configure --disable-udev

Install the libusb library sudo make install

Install OpenCV library sudo apt-get install libopencv-dev

Install g++ compiler sudo apt-get install g++-4.8 Install the SDK

Copy the libArduCamLib.so to /lib folder

Im ready to make this work!!

ghost commented 6 years ago

Keep trying and get this:

sudo ./Test Device found = 1 ArduCam_open successful create capture thread successfully create display thread successfully Nothing else

ArduCAM commented 6 years ago

please leave your email address, I will send you a new code to try it out.

ghost commented 6 years ago

clangray@fastmail.comOn Jun 8, 2018 10:05 PM, Lee notifications@github.com wrote:please leave your email address, I will send you a new code to try it out.

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

ghost commented 6 years ago

clangray@fastmail.com

ghost commented 6 years ago

root@primeuser-MS-7760:~/Desktop/ArduCAM_Linux_SDK_OpenCV_MT9V022_Demo# sudo ./Test Device found = 1 shipAddr 0x46 value is: 5 Sensor 0x03 value is: 1e0 Sensor 0x04 value is: 2f0 Sensor 0x0B value is: 200 ArduCam_open successful create capture thread successfully create display thread successfully USB_CAMERA_DATA_LEN_ERROR USB_CAMERA_DATA_LEN_ERROR USB_CAMERA_DATA_LEN_ERROR USB_CAMERA_DATA_LEN_ERROR USB_CAMERA_DATA_LEN_ERROR USB_CAMERA_DATA_LEN_ERROR USB_CAMERA_DATA_LEN_ERROR USB_CAMERA_DATA_LEN_ERROR USB_CAMERA_DATA_LEN_ERROR USB_CAMERA_DATA_LEN_ERROR USB_CAMERA_DATA_LEN_ERROR USB_CAMERA_DATA_LEN_ERROR USB_CAMERA_DATA_LEN_ERROR USB_CAMERA_DATA_LEN_ERROR ...inifinty

ArduCAM commented 6 years ago

screenshot It seems that your received data is not correct size or encounter the dropping frame issue. I run the same code without any issue. Can you show me your hardware setup?

ghost commented 6 years ago

I've attached the hardware setup report. Basically Ubuntu 18 on 250GB SSD drive, NVidia 770 card, some external USB hard drives, USB mouse and keyboard. Its all in the report, I hope its not too much information. hardinfo_report.txt

ArduCAM commented 6 years ago

You'd better not to connect both the camera and USB hard drivers in the same USB root hub, they will race the bandwidth. Can you send me a photo of your camera board? I have to determine the part number.

ghost commented 6 years ago

20180610_183514 20180610_184714

ArduCAM commented 6 years ago

Thanks for your photos. It is really strage if it is working under Windows with the same hardware setup, but stop working under linux.

ghost commented 6 years ago

NP.

Actually the Windows installation is now installed all by itself on a separate dedicated machine(#1). The second original machine (#2) is reinstalled with dedicated Ubuntu, erasing the VMWare/Windows OS. However it seems clear that the USB problem in (#2) is persisting from despite converting VMWare (NOW DELETED) to Ubuntu OS.

Tell me what you want to do. The next logical step to me would be to convert the Windows machine to dual-boot with Ubuntu and drop the current USB situation on the Ubuntu (#2) all together. It will be a pain, but I've got to get this camera going. Do you have a better idea?

Recap: Machine (#1) Windows 10 Machine (#2) Ubuntu 18+ No VMWare. All dedicated. Can we fix this??: You'd better not to connect both the camera and USB hard drivers in the same USB root hub, they will race the bandwidth. Can you send me a photo of your camera board? I have to determine the part number.

ghost commented 6 years ago

Also have you been able to get these cams to work with Linux?

ArduCAM commented 6 years ago

As you can see from my previous message, I send you the screen shot for my result. can you install the dual-boot OS on the same machine?

ghost commented 6 years ago

Hi Which machine do you want me to add dual boot? My windows machine or my ubuntu machine. I assume you are talking about dual boot by adding ubuntu to my windows.

ghost commented 6 years ago

Hi Lee, should I go ahead and add dual boot system to my windows? We were still trying to decide the configuration. The current Ubuntu sys is problematic as you have seen.

ArduCAM commented 6 years ago

We will release a new USB2.0 camera with onboard frame buffer, so the dropping frame issue will be fixed with that one.

ghost commented 6 years ago

OK, when do you expect it to be released for purchase? OpenCV ready? Also, what I really like about the the 034 and the 022 is the global shutter. It is essential. Are you all going to keep that?

ArduCAM commented 6 years ago

Actually we are ready to ship the new USB2.0 camera with onboard frame buffer. It will support more cameras including the MT9V022/034, AR0134 global shutter cameras.

ghost commented 6 years ago

Great hit me with the link Do you recommend still to do dual or try on mu Ubuntu first w/new cam

ArduCAM commented 6 years ago

The listing isn't udpate yet: http://www.uctronics.com/arducam-usb-camera-shield.html but we will ship the new ones.

ghost commented 6 years ago

Ok, need some assurances when I receive it is that it is the newest module incorporating the frame buffer changes. People I work for.

Gray Family clangray@fastmail.com

ghost commented 6 years ago

BTW< between 022, 034 and 134 which is the best? I need global shutter...fast fr