13

I have attached the webcam to the emulator and I always see the camera rotated by 90 degrees.

Barcode scanner demo app

What I did is simply to set "Webcam0" as the device to be used as the rear camera in the emulator.

Background: I'm trying to fix an issue with an app I'm developing that uses ZXing: it fails to scan some QR codes on certain devices, and I'm wondering if it has anything to do with what I see on the emulator.

On the devices we use to test the image is displayed correctly, on the emulator however it is rotated. Besides making me wonder whether it can cause troubles on real devices it makes it very difficult to test the QR code scanning (i.e. when you move the QR code vertically on the app it moves horizontally and vice-versa).

Do you know how to solve it?

Thanks in advance

Giordano
  • 1,401
  • 15
  • 26
  • QR codes are omnidirectional, though, right? The three squares at the corners are there so that you should be able to scan them from any angle. – Wander Nauta Feb 01 '16 at 12:40
  • camera.parameters.setOrientation(90) – Madhur Feb 01 '16 at 12:42
  • You can't just rotate the preview, because on an actual device the camera preview will be rotated incorrectly, the webcam and device camera both come in as "Rotation0", so rotating by 90 degrees only fixes one of these, not both. – Trevor Hart Nov 14 '17 at 19:48
  • Did you solved it? I'm facing the same issue on emulator but with virtual camera, not real camera – Rubén Viguera Apr 30 '19 at 14:49
  • @RubénViguera I don't remember exactly(it's over 3 years ago) but I think I was having the problem on the emulator only and on the device everything was working properly. Most likely the rotation was ininfluent. – Giordano Apr 30 '19 at 15:21
  • Still having this issue in 2021 :( – JS noob Jul 30 '21 at 01:53
  • 1
    And it's now almost 2022 and no one has found a solution other than turning the camera on it's side? Seriously? I'm also reading barcodes, and yes they are also omnidirectional so the orientation does not strictly matter, getting my brain around which direction to move the barcode to get it to line up is another matter. – LordWabbit Nov 20 '21 at 08:17

1 Answers1

1

Well reading the response from here it's rotating the image because it thinks the camera is in landscape mode (which with a webcam it actually is) so it displays it in landscape mode. In other words its functioning correctly with the hardware supplied. I have tried emulator programs like ManyCam in the hopes I can get it to rotate the image and then get Android Studio to use the rotated emulated camera but Android studio doesn't seem to pick up the emulated camera at all.

So in short I turned the camera sideways and duct taped it to the side of my monitor. Wasted enough time on something that is ONLY a problem in the emulator when trying to use a desktop web cam. It's also not stopping me from working it's just annoying (OCD kicking in I suppose).

LordWabbit
  • 147
  • 5