Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process closes without reason using CV2 #33

Open
simplo opened this issue Jan 2, 2024 · 1 comment
Open

Process closes without reason using CV2 #33

simplo opened this issue Jan 2, 2024 · 1 comment

Comments

@simplo
Copy link

simplo commented Jan 2, 2024

Hi, I'm trying to use NDI to process some image from another software with CV2, so, at the moment, I just trasformed the received fram in numpy array and display it.
After a few seconds I get this message: Process finished with exit code -1073741819 (0xC0000005).
I'm using Python 3.9.18 on Windows 10 in a I7 7th generation

This is the code:

import sys
import numpy as np
import NDIlib as ndi
import cv2

def main():

if not ndi.initialize():
    return 0

ndi_find = ndi.find_create_v2()

if ndi_find is None:
    return 0

sources = []
while not len(sources) > 1:
    print('Looking for sources ...')
    ndi.find_wait_for_sources(ndi_find, 1000)
    sources = ndi.find_get_current_sources(ndi_find)

for i, s in enumerate(sources):
    print('%s. %s' % (i + 1, s.ndi_name))

ndi_recv_create = ndi.RecvCreateV3()
ndi_recv_create.color_format = ndi.RECV_COLOR_FORMAT_BGRX_BGRA

ndi_recv = ndi.recv_create_v3(ndi_recv_create)

if ndi_recv is None:
    return 0

ndi.recv_connect(ndi_recv, sources[1])

ndi.find_destroy(ndi_find)

while True:
    t, v, a, _ = ndi.recv_capture_v2(ndi_recv, 5000)

    if t == ndi.FRAME_TYPE_NONE:
        print('No data received.')
        continue

    if t == ndi.FRAME_TYPE_VIDEO:

        print('Video data received (%dx%d).' % (v.xres, v.yres))
        ndi.recv_free_video_v2(ndi_recv, v)
        image = np.copy(v.data)
        cv2.imshow('NDI', image)
        continue

    if t == ndi.FRAME_TYPE_AUDIO:
        print('Audio data received (%d samples).' % a.no_samples)
        ndi.recv_free_audio_v2(ndi_recv, a)
        continue

ndi.recv_destroy(ndi_recv)

ndi.destroy()

return 0

if name == "main":
sys.exit(main())

@simplo
Copy link
Author

simplo commented Jan 2, 2024

FIXED: it was my fault, the ndi.recv_free_video_v2(ndi_recv, v) command was placed before the image process...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant