Answers.Body: <p>Fswebcam on ev3dev should already be using a v4l2 API backed by a v4l2 compatible driver.</p>
  <p>The first thing I would look at is v4l-info to understand the pixel formats supported.</p>
  <p>Next, I would try ev3dev OpenCV with a known good webcam - if it fails OpenCV may just be built without webcam support.</p>
  <p>If OpenCV works with other webcams and v4l-info shows the info, you may have to patch OpenCV to understand the pixel format. Potentially you could patch the Lego camera driver to speak a format OpenCV already understands. With either approach you could do the development and testing on a desktop (might be faster than building OpenCV from source on ARM9)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-04T13:41:37.377Z
Answers.LastActivityDate: 2021-03-04T13:41:37.377Z
Answers.UserDisplayName: rsaxvc
Answers.Body: <p>Since I'm no software engineer my solution would be to retrofit the insides with known compatible hardware. Cheating? Maybe... but it isn't like the original hardware inside was actually Lego to begin with.  The mention of potentially using "compatible software" would seem to be already stepping out of bounds with "only official Lego parts", since it didn't come packaged with it. So...  </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-24T03:26:35.133Z
Answers.LastActivityDate: 2019-07-24T03:26:35.133Z
Answers.UserDisplayName: JohnnyB
Body: <p>Once upon a time, LEGO made <a href="https://www.bricklink.com/v2/catalog/catalogitem.page?P=x86px1" rel="nofollow noreferrer">a digital camera for the LEGO Studios and Mindstorms line</a>. Internally it's an old USB Logitech camera repackaged in a LEGO housing.</p>
  
  <p><a href="https://i.sstatic.net/lPIeX.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/lPIeX.png" alt="enter image description here"></a></p>
  
  <p>It could also be used with the old LEGO Mindstorms software, to do some very weak video recognition when connected to a PC.</p>
  
  <p>Fast forward some years, and Mindstorms are much more powerful, and even have a USB port, which this camera can be attached to, <a href="https://lechnology.com/2016/02/lego-moviemaker-usb-camera-with-ev3-and-ev3dev/" rel="nofollow noreferrer">as some people have done</a>.</p>
  
  <p><a href="https://i.sstatic.net/DwvaS.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/DwvaS.jpg" alt="enter image description here"></a></p>
  
  <p>When used with ev3dev, it's even possible to take some low-res pictures with it using a CLI tool like <code>fswebcam</code>.</p>
  
  <p>However, I'd like to use it as a webcam, and capture a constant video stream from it, so I can use it in competitions where only official LEGO parts are allowed. Seems easy enough, but I've so far been unsuccessful.</p>
  
  <p>It seems that OpenCV doesn't support the camera, because it uses an unusual pixel format encoding. Has anyone found a good solution for capturing a constant video stream? Something better than repeatedly calling <code>fswebcam</code> and parsing the output file (which would be unnecessarily slow).</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-23T03:28:58.510Z
Comments.Text: Can you verify which model of Logitech camera is inside?  If so you may be able to find archived drivers for it and see if they work. Also, what operating system are you running? I have had pretty good luck with Windows backwards compatibility.
Comments.UserDisplayName: JohnnyB
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-23T03:31:53.060Z
Comments.Text: @JohnnyB In order to run on the brick, it would need to be compatible with an OS the brick can run, like the ARM-based Linux of ev3dev. Any old drivers for the "046d:0850 Logitech, Inc. QuickCam Web" wouldn't help.
Comments.UserDisplayName: Alexander O'Mara
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-07-23T03:46:57.917Z
Comments.Text: So you want to run it directly from the brick? I didn't catch that part...
Comments.UserDisplayName: JohnnyB
Tags: <mindstorms><ev3dev>
Title: Capture video stream from LEGO Studio Camera (Logitech USB webcam) in ev3dev?
UserDisplayName: Alexander O'Mara
ThreadText: # Capture video stream from LEGO Studio Camera (Logitech USB webcam) in ev3dev?
  
  (Asked by: username_0 on 2018-12-22)
  
  Once upon a time, LEGO made [a digital camera for the LEGO Studios and Mindstorms line](https://www.bricklink.com/v2/catalog/catalogitem.page?P=x86px1). Internally it's an old USB Logitech camera repackaged in a LEGO housing.
  
  [![enter image description here](https://i.sstatic.net/lPIeX.png)](https://i.sstatic.net/lPIeX.png)
  
  It could also be used with the old LEGO Mindstorms software, to do some very weak video recognition when connected to a PC.
  
  Fast forward some years, and Mindstorms are much more powerful, and even have a USB port, which this camera can be attached to, [as some people have done](https://lechnology.com/2016/02/lego-moviemaker-usb-camera-with-ev3-and-ev3dev/).
  
  [![enter image description here](https://i.sstatic.net/DwvaS.jpg)](https://i.sstatic.net/DwvaS.jpg)
  
  When used with ev3dev, it's even possible to take some low-res pictures with it using a CLI tool like `fswebcam`.
  
  However, I'd like to use it as a webcam, and capture a constant video stream from it, so I can use it in competitions where only official LEGO parts are allowed. Seems easy enough, but I've so far been unsuccessful.
  
  It seems that OpenCV doesn't support the camera, because it uses an unusual pixel format encoding. Has anyone found a good solution for capturing a constant video stream? Something better than repeatedly calling `fswebcam` and parsing the output file (which would be unnecessarily slow).
  
  **Tags:** mindstorms, ev3dev
  > **Comments:**
  > **username_1**: Can you verify which model of Logitech camera is inside?  If so you may be able to find archived drivers for it and see if they work. Also, what operating system are you running? I have had pretty good luck with Windows backwards compatibility.  
  > **username_0**: @JohnnyB In order to run on the brick, it would need to be compatible with an OS the brick can run, like the ARM-based Linux of ev3dev. Any old drivers for the "046d:0850 Logitech, Inc. QuickCam Web" wouldn't help.  
  > **username_1**: So you want to run it directly from the brick? I didn't catch that part...  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2021-03-04. Score: 2
  
  Fswebcam on ev3dev should already be using a v4l2 API backed by a v4l2 compatible driver.
  
  The first thing I would look at is v4l-info to understand the pixel formats supported.
  
  Next, I would try ev3dev OpenCV with a known good webcam - if it fails OpenCV may just be built without webcam support.
  
  If OpenCV works with other webcams and v4l-info shows the info, you may have to patch OpenCV to understand the pixel format. Potentially you could patch the Lego camera driver to speak a format OpenCV already understands. With either approach you could do the development and testing on a desktop (might be faster than building OpenCV from source on ARM9)
  
  
  ---
  
  ### Answer by username_1 on 2019-07-24. Score: 2
  
  Since I'm no software engineer my solution would be to retrofit the insides with known compatible hardware. Cheating? Maybe... but it isn't like the original hardware inside was actually Lego to begin with. The mention of potentially using "compatible software" would seem to be already stepping out of bounds with "only official Lego parts", since it didn't come packaged with it. So...
  
  
  ---
  
  