opencv image as a Panda Texture - clarification

OK. so swapping the X,Y from img.shape fixes the “jamming up on exit” problem.
but still no picture…
Any ideas ?

import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from direct.gui.DirectGui import *
from direct.gui.OnscreenText import OnscreenText
from panda3d.core import *
import sys

import cv2
import cv2.cv as cv
import numpy as np

def get_cv_img(cap):
    success, img = cap.read() # img is a numpy array
    print "success", success
    if success:
        shape = img.shape # (480,640,3)
        tex = Texture("detect")
        tex.setup2dTexture(shape[1], shape[0], Texture.TUnsignedByte, Texture.FRgb)
        p = PTAUchar.emptyArray(0)
        p.setData(img)
        tex.setRamImage(CPTAUchar(p))
        return (tex)

class World(DirectObject):
    def __init__(self):
        ###Standard initialization stuff
        #Standard title that's on screen in every tutorial
        self.title = OnscreenText(text="opencv test", style=1,
                                  fg=(1,1,1,1), pos=(0.9,-0.95),
                                  scale = .04 )
        base.setBackgroundColor(0.5,0.5,0.5)      
        # initiialise cv2 camera
        self.cap = cv2.VideoCapture(0) # first camera
        for i in range(10): self.cap.read() # ensure sensor has irised up
        sm = CardMaker('bg')
        test = render2d.attachNewNode(sm.generate(),2)
        img = get_cv_img(self.cap)
        test.setTexture(img)
        #
        self.accept('escape', sys.exit)  

    def turn(self):
        # continually call cap.read() here to update the texture
        pass


###
w = World()
run()