Cameras showing split-screen/double image (possible interlacing problem)

2,723 views
Skip to first unread message

Tensaiteki

unread,
Feb 17, 2017, 2:08:42 PM2/17/17
to OpenPnP
Greetings all,

I am doing a OpenPNP/Smoothie retrofit on a Madell SX 2010 pick-and-place.

The up and down facing cameras are analog machine cameras that use an analog output. I am using two generic "EasyCAP" Analog-USB video devices to capture the video signals.

The problem I am having is that the images/video from the camera are coming in with two copies of each camera view on top of each other. I suspect that the cameras are putting out an interlaced stream but the image is being displayed with half of the lines on the top half of the image and the and the interleaved lines at the bottom half of the image.

I will try to attach come captures to show the problem.

Is there some way to tell OpenPNP that the video is interlaced so the image is displayed correctly?

Extra Info: I am running Windows 10 (eventually the machine will be switched to Linux). The output from the camera looks the same in Window's "Camera" app as it does in OpenPNP.



MSX2010_BottomCamera_Problem.jpg
MSX2010_TopCamera_Problem.jpg

Jason von Nieda

unread,
Feb 17, 2017, 2:16:45 PM2/17/17
to OpenPnP
Hi Chris,

There's no way to tell OpenPnP to de-interlace. This is the first time I've seen something like that. 

It looks like you may be able to use something like http://www.amarectv.com/english/amarectv_e.htm to create a virtual capture device with a de-interlace filter in place. 

Maybe someone else with more experience with analog video sources can chime in.

Jason


--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openpnp/c915e635-cc2f-4273-9f7a-ba295046a284%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tensaiteki

unread,
Feb 17, 2017, 3:20:28 PM2/17/17
to OpenPnP
Hi Jason,

If there isn't a way to de-interlace, is there a way to change the aspect ratio or scale the height or width independently?

The cameras are supposed to be 720W x 480H interlaced. If I set the preferred width to 720 and the preferred height to 240 I can get OpenPNP to show just the top half of the image. However, the image is still "squished" such that any circles/holes/vias are ovals instead of round. I suspect this would make the CV ineffective if parts changed shape depending on orientation.

Jason von Nieda

unread,
Feb 17, 2017, 3:27:45 PM2/17/17
to OpenPnP
Hi Chris,

Unfortunately there's not. We've never previously had a need for scaling. If you are comfortable with Java and OpenCV at all this could probably be added in just a few minutes. If you aren't a programmer I'd be happy to add a scale operation for you this weekend.

Jason


Jason von Nieda

unread,
Feb 17, 2017, 3:52:41 PM2/17/17
to OpenPnP
Chris,

I had a couple minutes to spare so I added scaling. Once https://travis-ci.org/openpnp/openpnp shows that the build is finished (green) you can download the new version. I'd suggest that instead of using the preferred width / height settings you use crop + scale. Set crop to 720x240 and scale to 720x480 and it should look okay.

Jason

Tensaiteki

unread,
Feb 17, 2017, 4:14:19 PM2/17/17
to OpenPnP
Jason,

Dude, you rock.

I don't know if this interlace problem is common to all analog cameras of just the ones on this machine. If it's all/most of them, then your fix might really help those of us doing retrofits.

The hackerspace I hang out at was given this Madell machine by a guy who bought it for his company for an absurd amount of money. He said the software was so bad that he didn't want to mess with it anymore and wanted it gone.

We also have a Zevatech FM760 that also has analog cameras but is non-operational due to some random control board being broken. I could easily convert it to LinuxCNC (I've done many LCNC builds/retrofits on mills, lathes, routers, 3D printers, plasmas, and waterjets) but haven't because I never could figure out how to bridge the gap between the board design software, the vision system, and the g-code. Now that I know that OpenPNP exist, does exactly that, and talks to LinuxCNC, I am super excited about getting that machine up and running.

I've also heard that there are thousands of the FM760 machines in the wild, most with aging and dying controls. When their controls die (the mechanicals and motor drives last a very long time), they are worth less than scrap-price and can be had super cheap. This makes them a prime target for low cost OpenPNP/LinuxCNC retrofits.

Jason von Nieda

unread,
Feb 17, 2017, 4:18:35 PM2/17/17
to OpenPnP
There some info about converting a Zeva 460 here https://github.com/openpnp/openpnp/wiki/Retrofitting-a-Zeva-460---Part-1

Might help with a different conversion.

I'll be curious to hear how you get on with the Madell. Please let us know how it goes!

Jason


Message has been deleted

Jason von Nieda

unread,
Feb 17, 2017, 4:56:50 PM2/17/17
to OpenPnP
Glen, if you can show me the code to do it I'll be happy to add it. I did a quick search and didn't find much about interlacing in OpenCV. I suspect it can be done by offsetting the image data somehow into a new matrix, but I don't know offhand how to do that. 

Jason


On Fri, Feb 17, 2017 at 3:53 PM Glen English <gleneng...@gmail.com> wrote:
and... de interferlacing the sequential frames is about 2 lines of code....
just need to know how many lines...
that's also an option.....

Glen English

unread,
Feb 17, 2017, 5:16:55 PM2/17/17
to OpenPnP
and... de interlacing the sequential frames is about 2 lines of code....
Message has been deleted

Glen English

unread,
Feb 17, 2017, 5:23:56 PM2/17/17
to OpenPnP

int i=0; x=0
for x = 0 ; x < NLINES; x+=2
   de_interlaced_line[x] =  interlaced_line[i]       # put into even lines
   de_interlaced_line[x+1]   = interlaced_line[i+(NLINES/2)]   # put into odd lines
   i++;

I suspect you already know this, andI suspect I didnt understand the question

Jason von Nieda

unread,
Feb 17, 2017, 5:27:44 PM2/17/17
to OpenPnP
Ah, yea, I thought you were saying there was a quick/easy way to do it with OpenCV. I do, of course, understand the basic gist :)

It's a little more complicated with OpenCV since you have to deal with pixels and not lines, but not much. I can hack something together if need by.

This page makes it look like there might be a basic matrix operation in OpenCV that will do it: http://knowpapa.com/interlacing/

Just have to figure out how to convert that to OpenCV in Java.

I suspect it's something like saying "copy from this source, with this offset and with this stride" or something like that, which would cause the two copy operations to skip every other row in the destination.

Jason


On Fri, Feb 17, 2017 at 4:21 PM Glen English <gleneng...@gmail.com> wrote:
int i=0; x=0
for x = 0 ; x < NLINES; x+=2
   de_interlaced_line[x] =  interlaced_line[i]       # pull from even lines
   de_interlaced_line[x+1]   = interlaced_line[i+(NLINES/2)]   # pull from odd lines



On Saturday, February 18, 2017 at 9:16:55 AM UTC+11, Glen English wrote:

--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.

Glen English

unread,
Feb 17, 2017, 5:35:18 PM2/17/17
to OpenPnP
Not sure if its worthwhile doing....Might be a fringe condition though, I suspect the capture setup is just not setup right...

the capture boards know all about interlaced sources

This is their native. something is selected wrong

Tensaiteki, I maybe go back to settings and have another look at the input video formats
the settings are there....

select formats that end in 'i' (interlaced) rather than p - progressive.

glen

Jason von Nieda

unread,
Feb 17, 2017, 5:36:44 PM2/17/17
to ope...@googlegroups.com
That would be my suspicion as well. Seems like the capture device / software would not be very useful if you couldn't view it in the majority of software that doesn't know how to de-interlace.

Jason


--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.

Jason von Nieda

unread,
Feb 19, 2017, 10:04:37 AM2/19/17
to ope...@googlegroups.com
Hi Chris,

I went ahead and added deinterlacing. I don't know if it will end up being useful or not, but it was only like 10 lines of code, so I figured I might as well do it. It'll be in the downloads when the build finishes. Let me know if it helps!


Jason


On Fri, Feb 17, 2017 at 3:14 PM Tensaiteki <tensa...@gmail.com> wrote:

Tensaiteki

unread,
Feb 20, 2017, 6:00:09 PM2/20/17
to OpenPnP
Again, you rock.

I just got a chance to try it and it works perfectly. Even in the little preview window, having all 480 lines of resolution really helps the clarity.

I won't be able to move the machine until the Smoothie/Cohesion3D board arrives (should be here tomorrow) to really try things out.

Just some background on the capture hardware: The "EasyCAP" devices are widely available all over eBay and Amazon for around $10 each. They work on both of the machines I've tried them on (one Win10 and one Linux Mint 17) without requiring the installation of any drivers and no configuration options. On both systems the video is output as the top/bottom interlaced double image. It also seems that two of these devices can be plugged into the same (cheap) USB 2.0 hub/controller with no apparent bandwidth issues.

I did notice one thing: I can set the preferred and crop dimensions to 0 (for native and no cropping) and everything looks fine. However, if I set the scaling values to 0 (no scaling) and click apply, the image/video freezes. Setting the scale back to 720x480 (and clicking apply) will restore the normal video/image display without requiring a restart.

-C

Jason von Nieda

unread,
Feb 20, 2017, 7:47:13 PM2/20/17
to OpenPnP
That scaling bug is fixed now, thanks!

I do wonder if you installed the EasyCap's software if it might have a way to specify that the video interlaced and handle it upstream. 

Jason


Tracker J

unread,
Feb 21, 2017, 1:31:30 AM2/21/17
to OpenPnP

What do you think about the 4 Channels version?
http://www.ebay.com/itm/4-Channel-USB-2-0-DVR-Video-Audio-CCTV-Capture-Adapter-EasyCap-for-PC-Laptop-/271267137024?hash=item3f28c80600:g:JY8AAOxy3HJTH~-l

If is working will make it a nice option for upto 4 Cameras!

TJ.
Reply all
Reply to author
Forward
0 new messages